passport/src/patchers/t00_rdos13.a
2021-06-21 12:12:33 -04:00

176 lines
4.1 KiB
Plaintext

;-------------------------------
; #rdos13
; patch RDOS to be 16-sector compatible
;
; module by qkumba
;-------------------------------
!zone {
lda gIsRDOS13
beq .okay ; passport-test-suite/Epidemic.woz [Z=1] branches
.jmpexit
jmp .exit
.okay
lda #8
ldx #$C9
jsr modify3
!byte $20,$2A,$BB ;JSR $BB2A
;adjust write-timing
lda #$9
ldx #$89
jsr modify3
!byte $04 ;sync delay
!byte $48 ;PHA
!byte $68 ;PLA
lda #$56
sta (BASEPAGE * $100) + $9A3
sta (BASEPAGE * $100) + $A16
lda #$23
sta (BASEPAGE * $100) + $A2B
sta (BASEPAGE * $100) + $A3C
sta (BASEPAGE * $100) + $A4C
lda #$B8
sta (BASEPAGE * $100) + $A2C
sta (BASEPAGE * $100) + $A3D
sta (BASEPAGE * $100) + $A4D
;enable 16-sector address prologue as needed
lda #$0A
ldx #$75
jsr compare2
!byte $C9,$D5 ;CMP #$D5
bcc +
jsr modify2
!byte $C9,$D5 ;CMP #$D5
+
lda #$0A
ldx #$8B
jsr modify1
!byte $96
jsr PrintByID
!byte s_rwtswrite
lda #<((BASEPAGE * $100) + $6B9 - $16)
sta modsrc
lda #>((BASEPAGE * $100) + $6B9 - $16)
ldx #<((BASEPAGE * $100) + $B70)
ldy #>((BASEPAGE * $100) + $B70)
jsr build6and2
;replace 6-and-2 encoder routine
;and introduce DOS-order lookup
ldy #$41
- lda .writemod - 1, y
sta (BASEPAGE * $100) + $900 - 1, y
dey
bne -
;replace 6-and-2 decoder routine
ldy #$18
- lda .readmod - 1, y
sta (BASEPAGE * $100) + $AC1 - 1, y
dey
bne -
ldx #ID_RDOS13
jsr ConstructStandardDelivery
jsr PrintByID
!byte s_bootwrite
jmp .exit
;build 6-and-2 denibbilisation table for reading
build6and2
sta modsrc+1
stx moddest
sty moddest+1
ldx #$16
ldy #0
-- stx $48
txa
asl
bit $48
beq +
ora $48
eor #$ff
and #$7e
- bcs +
lsr
bne -
tya
pha
txa
tay
pla
sta (modsrc), y
tay
;and 6-and-2 nibbilisation table for writing
txa
ora #$80
sta (moddest), y
iny
+ inx
bpl --
rts
.writemod
!byte $A2,$00 ;LDX #$00
!byte $A0,$02 ;LDY #$00
!byte $88 ;DEY
!byte $B1,$3E ;LDA ($3E),Y
!byte $4A ;LSR
!byte $3E,$00,$BF ;ROL $BF00,X
!byte $4A ;LSR
!byte $3E,$00,$BF ;ROL $BF00,X
!byte $99,$00,$BE ;STA $BE00,Y
!byte $E8 ;INX
!byte $E0,$56 ;CPX #$56
!byte $90,$ED ;BCC $BC04
!byte $A2,$00 ;LDX #$00
!byte $98 ;TYA
!byte $D0,$E8 ;BNE $BC04
!byte $A2,$55 ;LDX #$55
!byte $BD,$00,$BF ;LDA $BF00,X
!byte $29,$3F ;AND #$3F
!byte $9D,$00,$BF ;STA $BF00,X
!byte $CA ;DEX
!byte $10,$F5 ;BPL $BC1E
!byte $60 ;RTS
!byte $AC,$F6,$BA ;LDY $BAF6
!byte $B9,$31,$BB ;LDA $BB31,Y
!byte $60 ;RTS
!byte $00,$0D,$0B,$09,$07,$05,$03,$01
!byte $0E,$0C,$0A,$08,$06,$04,$02,$0F
.readmod
!byte $A0,$00 ;LDY #$00
!byte $A2,$56 ;LDX #$56
!byte $CA ;DEX
!byte $30,$FB ;BMI $BCC3
!byte $B9,$00,$BE ;LDA $BE00,Y
!byte $5E,$00,$BF ;LSR $BF00,X
!byte $2A ;ROL
!byte $5E,$00,$BF ;LSR $BF00,X
!byte $2A ;ROL
!byte $91,$3E ;STA ($3E),Y
!byte $C8 ;INY
!byte $D0,$ED ;BNE $BCC5
!byte $60 ;RTS
.exit
}