passport/src/modify.a

135 lines
3.3 KiB
Plaintext
Raw Permalink Normal View History

2021-06-21 15:57:02 +00:00
; utility functions for common cases
; (from the caller's perspective, these have the side effect of setting Y,
; since the modify routine will 'save' and 'restore' the value we're setting here)
2021-06-30 16:11:14 +00:00
modify4
ldy #$04
!byte $2C
; /!\ execution falls through here
2021-06-21 15:57:02 +00:00
modify3
ldy #$03
!byte $2C
; /!\ execution falls through here
modify2
ldy #$02
!byte $2C
; /!\ execution falls through here
2021-06-21 14:33:16 +00:00
modify1
ldy #$01
; /!\ execution falls through here
2017-01-08 03:35:35 +00:00
;-------------------------------
; modify subroutine
; in: A = starting address (high byte)
; X = starting address (low byte)
; Y = string length
; stack = string to set
; out $BASEPAGE buffer changed
; $gPatchCount++
; $modsrc zero page clobbered
; $moddest zero page clobbered
; stack set to return to
; code after string
2021-06-12 04:50:09 +00:00
; A,X,Y preserved
; oVerflow bit clear
; all other flags clobbered
2017-01-08 03:35:35 +00:00
;-------------------------------
modify
2021-06-12 04:50:09 +00:00
sty mod_tmp_y
2017-01-08 03:35:35 +00:00
sta gDisplayBytes
clc
adc #BASEPAGE
sta moddest+1
stx moddest
stx gDisplayBytes+1
pla
sta modsrc
pla
sta modsrc+1
tax
tya
clc
adc modsrc
2021-04-20 04:27:11 +00:00
bcc +
2017-01-08 03:35:35 +00:00
inx
2021-04-20 04:27:11 +00:00
+ sta tmp
2017-01-08 03:35:35 +00:00
txa
pha
lda tmp
pha
sty modtmp
bit gMode
bpl @exitnomod ; verify mode -> no modify
2017-01-08 03:35:35 +00:00
jsr PrintByID
!byte s_modify
2017-01-08 03:35:35 +00:00
ldy #0
2021-04-20 04:27:11 +00:00
- lda (moddest), y
2017-01-08 03:35:35 +00:00
jsr PrintByte
iny
cpy modtmp
2021-04-20 04:27:11 +00:00
bne -
2017-01-08 03:35:35 +00:00
jsr PrintByID
!byte s_modifyto
2017-01-08 03:35:35 +00:00
ldy #0
2021-04-20 04:27:11 +00:00
- iny
lda (modsrc), y
2017-01-08 03:35:35 +00:00
jsr PrintByte
cpy modtmp
2021-04-20 04:27:11 +00:00
bne -
2017-01-08 03:35:35 +00:00
lda #$8D
jsr PrintA
bvc +
2021-04-20 04:27:11 +00:00
- sta (moddest), y
+ lda (modsrc), y
dey
2021-04-20 04:27:11 +00:00
bpl -
@exit
2017-01-08 03:35:35 +00:00
inc gPatchCount
2021-04-20 04:27:11 +00:00
@exitnomod
2018-01-12 15:47:25 +00:00
lda gDisplayBytes
ldx moddest
2021-06-12 04:50:09 +00:00
mod_tmp_y=*+1
ldy #$FD ; SMC
clv
2017-01-08 03:35:35 +00:00
rts
multimodify
; in: (A/Y) -> sector+offsets+values block
; X = number of values (must also be equal number of sectors and offsets)
; out: all registers/flags clobbered
sta @getsector+1
sty @getsector+2
stx @loop+1
clc
adc @loop+1
bcc +
iny
+ sta @getoffset+1
sty @getoffset+2
clc
adc @loop+1
bcc +
iny
+ sta @getvalue+1
sty @getvalue+2
jmp @next
@loop
ldy #$FD ; SMC
@getvalue
lda $FDFD, y ; SMC
sta @cmpvalue
sta @modvalue
@getsector
lda $FDFD, y ; SMC
@getoffset
ldx $FDFD, y ; SMC
jsr compare1
@cmpvalue
!byte $FD ; SMC
bcc @next
jsr modify1
@modvalue
!byte $FD ; SMC
@next
dec @loop+1
bpl @loop
rts