mirror of https://github.com/a2-4am/anti-m.git
219 lines
4.4 KiB
Plaintext
219 lines
4.4 KiB
Plaintext
; ProDOS tracer
|
|
; written by qkumba
|
|
;
|
|
IDProDOS
|
|
lda #8
|
|
ldx #1
|
|
ldy #10
|
|
jsr CompareMemory
|
|
!byte $38 ;SEC
|
|
!byte $B0,$03 ;BCS *+5
|
|
!byte $4C,$32,$A1 ;JMP $A132
|
|
!byte $86,$43 ;STA $43
|
|
!byte $C9,$03 ;CMP #$03
|
|
bcs @exit
|
|
ldx #$60
|
|
stx $801
|
|
inc $3D
|
|
jsr $C65C
|
|
dec $27
|
|
dec $3D
|
|
dec $3D
|
|
lda #$38
|
|
sta $801
|
|
lda #9
|
|
ldx #$48
|
|
ldy #7
|
|
jsr CompareMemory
|
|
!byte $C9,$E7 ;CMP #$E7
|
|
!byte $D0,$F4 ;BCS *-$0B
|
|
!byte $BD,$8C,$C0 ;LDA $C08C,X
|
|
bcc @exit
|
|
|
|
ldy #@ProDOSCallback_e-@ProDOSCallback
|
|
- lda @ProDOSCallback-1,y
|
|
sta @ProDOSCallbackx-1,y
|
|
dey
|
|
bne -
|
|
|
|
lda #$4C
|
|
sta $8FC
|
|
lda #<@ProDOSCallbackx
|
|
sta $8FD
|
|
lda #>@ProDOSCallbackx
|
|
sta $8FE
|
|
clc
|
|
@exit
|
|
rts
|
|
|
|
@ProDOSCallback
|
|
!pseudopc $B000 {
|
|
@ProDOSCallbackx
|
|
lda #$20
|
|
ldx #$30
|
|
ldy #4
|
|
jsr @SearchMemory
|
|
!byte $A9,$02 ;LDA #$02
|
|
!byte $91,$14 ;STA ($14),Y
|
|
bcs @ProDOS_exit
|
|
sta @ProDOS_patch+2
|
|
lda #$EA
|
|
ldy #6
|
|
@ProDOS_patch
|
|
sta $D100,X
|
|
inx
|
|
dey
|
|
bne @ProDOS_patch
|
|
@ProDOS_exit
|
|
lda $85FF
|
|
beq @OneDrive
|
|
lda #$E0
|
|
sta $43
|
|
@OneDrive
|
|
jmp $2000
|
|
|
|
;-------------------------------
|
|
; SearchMemory subroutine
|
|
; written by qkumba
|
|
; search for a string occurring anywhere
|
|
; in the main memory
|
|
; #WILDCARD in search string matches any 1 byte
|
|
; (like "." character in regular expressions)
|
|
; in: A = starting page to search
|
|
; X = ending page+1 to search
|
|
; Y = string length
|
|
; stack = string to find
|
|
; out: C clear if string found
|
|
; or set if not found
|
|
; If C is clear, then
|
|
; A = page where string was found
|
|
; X = starting offset where string was found
|
|
; all other registers and flags clobbered
|
|
;-------------------------------
|
|
@SearchMemory
|
|
|
|
stx @endvalue+1
|
|
sta @search+2
|
|
pla
|
|
sta @match_buffer1+1
|
|
sta @match_all+1
|
|
pla
|
|
sta @match_buffer1+2
|
|
sta @match_all+2
|
|
tax
|
|
sty @match_size1+1
|
|
sty @match_size2+1
|
|
|
|
; fetch last byte to improve search speed
|
|
|
|
@match_buffer1
|
|
lda $d1d1,y ; modified at runtime
|
|
sta @check_byte1+1
|
|
sta @check_byte2+1
|
|
|
|
; set low part of initial search position
|
|
|
|
tya
|
|
dey
|
|
sty @cont_search+1
|
|
|
|
; set return address
|
|
|
|
clc
|
|
adc @match_buffer1+1
|
|
tay
|
|
bcc @plus01
|
|
inx
|
|
@plus01
|
|
txa
|
|
pha
|
|
tya
|
|
pha
|
|
|
|
; set match position
|
|
|
|
inc @match_all+1
|
|
bne @plus02
|
|
inc @match_all+2
|
|
@plus02
|
|
|
|
lda #<@cont_search-@branch_cont-2
|
|
sta @branch_cont+1
|
|
|
|
; search...
|
|
|
|
@cont_search
|
|
ldy #$d1 ; modified at runtime
|
|
|
|
@search
|
|
lda $d100,y ; modified at runtime
|
|
iny
|
|
beq @check_end
|
|
|
|
@check_byte1
|
|
cmp #$d1 ; modified at runtime
|
|
bne @search
|
|
|
|
; point to first byte
|
|
|
|
sty @cont_search+1
|
|
|
|
@check_match
|
|
tya
|
|
|
|
@match_size1
|
|
sbc #$d1 ; modified at runtime
|
|
sta @match_buffer2+1
|
|
ldx @search+2
|
|
bcs @plus03
|
|
dex
|
|
@plus03
|
|
stx @match_buffer2+2
|
|
ldy #$00
|
|
|
|
@match_all
|
|
lda $d1d1,y ; modified at runtime
|
|
cmp #WILDCARD
|
|
beq @found_wild
|
|
|
|
@match_buffer2
|
|
cmp $d1d1,y ; modified at runtime
|
|
|
|
@branch_cont
|
|
bne @cont_search
|
|
|
|
@found_wild
|
|
iny
|
|
|
|
@match_size2
|
|
cpy #$d1 ; modified at runtime
|
|
bne @match_all
|
|
|
|
; point to start of match
|
|
|
|
ldx @match_buffer2+1
|
|
lda @match_buffer2+2
|
|
clc
|
|
rts
|
|
|
|
; cold path
|
|
|
|
@check_end
|
|
inc @search+2
|
|
ldx @search+2
|
|
@endvalue
|
|
cpx #$D1
|
|
bne @check_byte1
|
|
ldx #<@all_done_set-@branch_cont-2
|
|
stx @branch_cont+1
|
|
|
|
@check_byte2
|
|
cmp #$d1 ; modified at runtime
|
|
beq @check_match
|
|
|
|
@all_done_set
|
|
sec
|
|
rts
|
|
}
|
|
@ProDOSCallback_e
|