include "92plus.h" ; This include file contains the ROM functions include "util.h" ; This include file includes keyboard input and clear screen functions. include "hexlib.h" xdef _main ;tell the assembler that execution starts at _main xdef _comment ; tell the assembler that a program comment exists. _main: ; Execution will start here, at the _main label move.b #0,lookup move.b #0,place jsr util::clr_scr ; clear the screen move.w #4,-(a7) ; move the first param to the stack pea _comment(pc) ; move adress of string to the stack move.w #6,-(sp) push position y move.w #53,-(a7) ; push position x jsr tios::DrawStrXY ; call the DrawStrXY ROM function lea 10(a7),a7 ; restore the stack pointer move.w #1,-(sp) jsr tios::FontSetSys addq.l #2,sp move.w #4,-(sp) pea line2(pc) move.w #27,-(sp) move.w #7,-(sp) jsr tios::DrawStrXY lea 10(sp),sp \ag1: jsr util::idle_loop ;get required info :bytes or string cmp.b #264,d0 beq \exit cmp.b #'b',d0 beq \ex1 cmp.b #'s',d0 bne \ag1 \ex1: move.b d0,lookup move.w #4,-(sp) pea line2(pc) move.w #27,-(sp) move.w #7,-(sp) jsr tios::DrawStrXY lea 10(sp),sp move.w #4,-(sp) pea line3(pc) ;prepare for Input of Searchob move.w #45,-(sp) move.w #7,-(sp) jsr tios::DrawStrXY lea 10(sp),sp bsr InputStr cmp.w #0,d0 beq \exit \goon: move.w #4,-(sp) pea line5(pc) move.w #63,-(sp) ;get part of mem to search in move.w #7,-(sp) jsr tios::DrawStrXY lea 10(sp),sp \ag2: jsr util::idle_loop move.b d0,place cmp.b #264,d0 beq \exit moveq #0,d1 cmp.b #'r',d0 beq \ex4 cmp.b #'o',d0 beq \ex3 cmp.b #'a',d0 bne \ag2 moveq #16,d1 bra \ex4 \ex3: moveq #8,d1 \ex4: lea startr(pc),a0 ;set addresses move.l 0(a0,d1.l),a6 move.l 4(a0,d1.l),a3 move.w #4,-(sp) pea line5(pc) move.w #63,-(sp) ;get part of mem to search in move.w #7,-(sp) jsr tios::DrawStrXY lea 10(sp),sp ;do not forget the stack bsr start ; do the work \exit: move.w #2,-(sp) jsr tios::FontSetSys addq.l #2,sp rts InputStr: lea inpbuf(pc),a6 ;clear buffers lea searchfor(pc),a5 movem.l a5-a6,-(sp) move.w #4,d1 moveq #0,d0 \ilp1: move.l d0,(a5)+ move.l d0,(a6)+ dbf d1,\ilp1 movem.l (sp)+,a5-a6 move.b #'?',(a6) move.w #4,-(sp) pea inpbuf(pc) move.w #45,-(sp) move.w #100,-(sp) jsr tios::DrawStrXY lea 10(sp),sp moveq #0,d7 inplp1: jsr util::idle_loop ;here all characters via keyboard cmp.w #264,d0 beq InputStr cmp.w #13,d0 beq \gotit andi.b #$ff,d0 cmpi.b #32,d0 bcs inplp1 cmp.b #'s',lookup beq \is09 cmp.b #'0',d0 bcs inplp1 cmp.b #'g',d0 bcc inplp1 cmp.b #'9',d0 bls \is09 cmp.b #'a',d0 bcs inplp1 \is09 move.b d0,(a6)+ addq.l #1,d7 move.w #4,-(sp) pea inpbuf(pc) move.w #45,-(sp) move.w #100,-(sp) jsr tios::DrawStrXY lea 10(sp),sp cmp.w #16,d7 bls inplp1 \gotit: move.w d7,d0 cmp.b #0,d7 bne \noexitinp rts \noexitinp: lea inpbuf(pc),a6 cmp.b #'b',lookup beq makebytes move.w d0,slngth subq.w #1,d7 \lp11: move.b (a6)+,(a5)+ dbeq d7,\lp11 rts makebytes: and.b #$1,d0 cmp.b #0,d0 beq \iseven subq.l #1,a6 addq.l #1,d7 \iseven: move.b d7,d0 lsr.b #1,d0 move.w d0,slngth \mkloop: moveq #0,d0 move.b (a6)+,d0 swap d0 move.b (a6)+,d0 subq #2,d7 subi.b #'0',d0 cmpi.b #10,d0 bcs \is091 subi.b #'a'-'0'-10,d0 \is091: swap d0 subi.b #'0',d0 cmpi.b #10,d0 bcs \is092 subi.b #'a'-'0'-10,d0 \is092: move.b d0,d1 rol.w #4,d1 swap d0 or.b d1,d0 move.b d0,(a5)+ cmpi.b #0,d7 bne \mkloop move.w #1,d0 rts start: tst.w $757c+$1e beq \nokey move.w $757c+$1e,d0 clr.w $757c+$1e cmp.w #264,d0 bne \nokey \exstrt: moveq #0,d0 rts \nokey: move.w slngth(pc),d7 lea searchfor(pc),a5 movea.l #$40ffff,a4 cmpa.l a6,a4 bne \go_on movea.l #$420000,a6 \go_on: movea.l a6,a4 moveq.l #0,d1 \sloop: addq.l #1,d1 cmpm.b (a5)+,(a4)+ bne \not cmp.b d7,d1 bne \sloop beq \found \not: subq.l #1,d1 add.l d1,a6 bra \notesc \found: lea inpbuf(pc),a5 cmpa.l a5,a6 beq \not lea searchfor(pc),a5 cmpa.l a5,a6 beq \not move.l a6,d0 move.l #10,d1 move.l #12,d2 move.l #7,d4 jsr hexlib::put_hex move.w #4,-(sp) pea line6(pc) move.w #81,-(sp) move.w #10,-(sp) jsr tios::DrawStrXY addq.l #8,sp pea cont(pc) move.w #100,-(sp) move.w #158,-(sp) jsr tios::DrawStrXY lea 10(sp),sp jsr util::idle_loop cmp.w #'n',d0 beq \exstrt \notesc: addq.l #1,a6 cmpa.l a3,a6 ;a3:endaddress bls start rts line2: dc.b "Look for (b)ytes or (s)tring ? " lookup: dc.b 0,0 line3: dc.b "Search object:",0 line5: dc.b "Where ? (r)am,r(o)m,(a)rchive ? " place: dc.b 0,0 line6: dc.b "Found at:",0 cont: dc.b "Continue y/n?",0 even inpbuf: ds.b 20 even slngth: dc.w 0 dc.b "AK42" searchfor: ds.b 16 startr: dc.l 0,$3ffff,$200000,$4fffff,$500000,$5fffff _comment: dc.b "LookUp, by A.K. '98,99",0 end