home *** CD-ROM | disk | FTP | other *** search
- ;Machinelanguage script, search line in history
- ;a2 = pointer to PVCallTable
-
- Search:
- ;pvcall 12, pvcall 20, pvcall 36
- move.l 12*4(a2),a0
- jsr (a0) ;Get pointer to stringgadget buffer
- move.l d0,a3
- move.l 20*4(a2),a0
- jsr (a0) ;Get pointer to StringInfo of stringgadget
- move.l d0,a4
- move.l 36*4(a2),a0
- jsr (a0) ;Get pointer to MainBase
- move.l d0,a5
-
- move.w 8(a4),d0 ;Position in stringgadget buffer
- move.b 0(a3,d0.w),d7 ;Remember byte
- move.b #0,0(a3,d0.w) ;Clear byte
-
- lea 166(a5),a5 ;Remember pointer to history
- move.l (a5),a6 ;Remember this line
- move.l (a6),a6 ;Go to next
-
- 1$ lea 10(a6),a0 ;Pointer to history string
- move.l a3,a1 ;Pointer to stringgadget
- bsr.s Compare
- beq.s 2$
- ;Not equal, go to next history line
- move.l (a6),a6
- cmp.l (a5),a6 ;If a5==a6 we have turned arround
- ;(The history list is a circular list)
- beq.s 3$
- bra.s 1$
-
- ;We have found a matching line !
- 2$ move.l a6,(a5) ;New current history
-
- ;pvcall 4
- move.l 4*4(a2),a0
- jsr (a0) ;Copy current history line to stringgadget
- ;pvcall 5
- move.l 5*4(a2),a0
- jsr (a0) ;Refresh stringgadget
-
- moveq #1,d0 ;Return code success
- rts
-
- ;No match found, restore current line
- 3$ move.w 8(a4),d0 ;Position in stringgadget buffer
- move.b d7,0(a3,d0.w) ;Restore byte
- moveq #0,d0 ;Return code failure
- rts
-
- ;***
- ;Compare two strings
- ;a0 = string 1
- ;a1 = string 2
- ;-> Z flag true if equal
- ;***
- Compare:
- cmp.b (a0)+,(a1)+
- beq.s Compare
- tst.b -1(a1)
- rts
-
- END
-