passport/src/patchers/t00_rwts.a
2021-07-11 01:10:32 -04:00

233 lines
4.5 KiB
Plaintext
Executable File

;-------------------------------
; RWTS fixups for DOS 3.3-shaped RWTSen
;-------------------------------
!zone {
ldy #0
beq .initmatch1 ; always branches
; address prologue (read)
; A,X
.table1
!byte $03,$4F
!byte $03,$59
!byte $03,$64
!byte $03,$8B
!byte $03,$95
!byte $02,$E1
!byte $02,$EB
!byte $02,$F6
!byte $03,$2F
!byte $03,$39
.table1_e
; Y, compare bytes (nop-pad to four bytes)
.table2
!byte $03,$D0,$F0,$EA,$EA
!byte $04,$D0,$F2,$A0,$03
!byte $02,$D0,$E7,$EA,$EA
!byte $02,$D0,$AE,$EA,$EA
!byte $03,$D0,$A4,$18,$EA
!byte $03,$D0,$F4,$EA,$EA
!byte $04,$D0,$F2,$A0,$56
!byte $02,$D0,$E7,$EA,$EA
!byte $03,$D0,$0A,$EA,$EA
!byte $03,$F0,$5C,$38,$EA
.table2_e
; compare/modify byte
.table3
!byte $D5
!byte $AA
!byte $96
!byte $DE
!byte $AA
!byte $D5
!byte $AA
!byte $AD
!byte $DE
!byte $AA
.table3_e
.initmatch1
sty .findmatch1+1
.findmatch1
ldy #$D1 ; SMC
lda #$C9
ldx .table1+1,y
cpx #$E1
bne .compare1
lda #$49
.compare1
sta .cmpbyte1
lda .table1,y
ldy #6
jsr compare
!byte $BD,$8C,$C0
!byte $10,$FB
.cmpbyte1
!byte $D1 ; SMC
bcs +
pha
txa
adc #7
pha
lda .findmatch1+1
lsr
adc .findmatch1+1
adc .findmatch1+1
adc #4
tay
ldx #$04
- lda .table2+1-1,y
sta .cmpbytes2-1,x
dey
dex
bne -
pla
tax
lda .table2,y
tay
pla
jsr compare
.cmpbytes2 ; SMC
!byte $EA,$EA,$EA,$EA
bcs +
pha
lda .findmatch1+1
lsr
tay
lda .table3,y
sta .cmpbyte3
sta .modify3
pla
dex
jsr compare1
.cmpbyte3 ; SMC
!byte $D1
bcc +
jsr modify1
.modify3 ; SMC
!byte $D1
+ ldy .findmatch1+1
iny
iny
cpy #.table1_e-.table1
bne .initmatch1
ldy #$00
.initmatch2
sty .findmatch4+1
.findmatch4
ldy #$D1 ; SMC
lda .table4,y
ldx .table4+1,y
jsr compare1
!byte $A9
bcs +
pha
lda .findmatch4+1
lsr
tay
lda .table5,y
sta .cmpbyte5+1
pla
inx
inx
jsr compare2
.cmpbyte5
!byte $20,$D1 ; SMC
bcs +
pha
lda .findmatch4+1
lsr
tay
lda .table6,y
sta .cmpbyte6
sta .modify6
pla
dex
jsr compare1
.cmpbyte6
!byte $D1 ; SMC
bcc +
jsr modify1
.modify6
!byte $D1 ; SMC
+ ldy .findmatch4+1
iny
iny
cpy #.table4_e-.table4
bne .initmatch2
beq .exit
; address prologue (write)
; A,X
.table4
!byte $06,$79
!byte $06,$7E
!byte $06,$83
!byte $06,$AD
!byte $06,$B2
!byte $06,$B7
!byte $02,$52
!byte $02,$57
!byte $02,$5C
!byte $02,$9D
!byte $02,$A2
!byte $02,$A7
!byte $02,$AC
.table4_e
; compare byte
.table5
!byte $D5
!byte $D5
!byte $D5
!byte $D5
!byte $D5
!byte $D5
!byte $B8
!byte $B8
!byte $B8
!byte $B8
!byte $B8
!byte $B8
!byte $B8
.table5_e
; modify byte
.table6
!byte $D5
!byte $AA
!byte $96
!byte $DE
!byte $AA
!byte $EB
!byte $D5
!byte $AA
!byte $AD
!byte $DE
!byte $AA
!byte $EB
!byte $FF
.table6_e
.exit
}