; 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) modify4 ldy #$04 !byte $2C ; /!\ execution falls through here modify3 ldy #$03 !byte $2C ; /!\ execution falls through here modify2 ldy #$02 !byte $2C ; /!\ execution falls through here modify1 ldy #$01 ; /!\ execution falls through here ;------------------------------- ; 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 ; A,X,Y preserved ; oVerflow bit clear ; all other flags clobbered ;------------------------------- modify sty mod_tmp_y 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 bcc + inx + sta tmp txa pha lda tmp pha sty modtmp bit gMode bpl @exitnomod ; verify mode -> no modify jsr PrintByID !byte s_modify ldy #0 - lda (moddest), y jsr PrintByte iny cpy modtmp bne - jsr PrintByID !byte s_modifyto ldy #0 - iny lda (modsrc), y jsr PrintByte cpy modtmp bne - lda #$8D jsr PrintA bvc + - sta (moddest), y + lda (modsrc), y dey bpl - @exit inc gPatchCount @exitnomod lda gDisplayBytes ldx moddest mod_tmp_y=*+1 ldy #$FD ; SMC clv 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