; Patches simulating the switch #define NO_CALC_DETECT. section ".data" include "OS.h" xdef xPatchNoCalcDetect xdef UninstNoCalcDetect ; Only a small part of the third type of patches applied by ; Voyage 200 Executables Patcher is used : ; ; 3) and.l/andi.l #$400000,reg ; bne.s Label ; ; (see '$$patch (_detect_calc_)' in TIGCC's tipatch.lib) ; __attribute__ ((__regparm__(2))) ; void PatchNoCalcDetect (void *prgm, unsigned long plen, char this_calc); ; PRGM must point to the beginning of the program code. ; PLEN is the size of the program code. ; THIS_CALC = 0 if the calculator emulated is a TI92+ or a V200, else ; THIS_CALC != 0. ; Use PatchNoCalcDetect() only if the user is emulating a program not ; for his calc ! ; We will try to patch only the header of the program, ie not further ; than (char*)prgm + MAX_DISTANCE MAX_DISTANCE equ 200 ; a0 = prgm ; d0.l = plen ; d1.b = this_calc xPatchNoCalcDetect: move.l a0,a1 moveq #MAX_DISTANCE/2,d2 add.l d2,d2 cmp.l d2,d0 bhi.s \SmallPrgm ; d0 > d2 move.l d0,d2 \SmallPrgm: ; d2 = min (plen, MAX_DISTANCE) adda.l d2,a1 \PatchLoop: cmp.l #$400000,(a0) beq.s \x400000Found \NextWord: addq.w #2,a0 cmp.l a0,a1 bhi.s \PatchLoop rts \x400000Found: move.w -2(a0),d0 move.w d0,d2 andi.w #%1111000111111111,d0 ; and.l #,reg ? cmp.w #%1100000010111100,d0 beq.s \IsAnd andi.w #%1111111111111000,d2 ; andi.l #,reg ? cmp.w #%0000001010000000,d2 bne.s \NextWord \IsAnd: addq.w #4,a0 ; jump the $400000.l lea ScrRectModified(pc),a1 clr.b (a1) ; FALSE tst.b d1 beq.s \PatchBra ; 92+ or V200 emulated \PatchNop: ; 89 emulated ; Give the ScrRect of a TI89 to avoid being detected as a V200. st.b (a1) ; TRUE move.l ($c8).w,a1 move.l ScrRect*4(a1),a1 move.b #159,2(a1) ; TI89 screen width move.w #$4e71,(a0) ; nop rts \PatchBra: ; 92+ or V200 emulated andi.w #%1111000011111111,(a0) ; bra.s rts ScrRectModified dc.b 0 ; 0 if FALSE, 0xFF if TRUE even UninstNoCalcDetect: lea ScrRectModified(pc),a0 tst.b (a0) beq.s \Quit move.l ($c8).w,a0 move.l ScrRect*4(a0),a0 move.b #239,2(a0) ; restore the TI92+/V200 screen width \Quit: rts