.
This commit is contained in:
4am 2017-05-14 21:29:12 -04:00
commit 8ee9b11c95

View File

@ -10,9 +10,11 @@
lda gIsOptimum lda gIsOptimum
bne .jmpexit bne .jmpexit
ldx gTrack ldx gTrack
beq .jmptrack0
dex dex
beq .dotrack1 beq .dotrack1
;for each track, search for the redirection code
ldy #15 ldy #15
jsr SearchTrack jsr SearchTrack
!byte $A2,$00 ;LDX #$00 !byte $A2,$00 ;LDX #$00
@ -23,24 +25,32 @@
!byte $BD,WILDCARD,WILDCARD ;LDA $xxxx,X !byte $BD,WILDCARD,WILDCARD ;LDA $xxxx,X
!byte $E8 ;INX !byte $E8 ;INX
!byte $85 ;STA $xx !byte $85 ;STA $xx
bcs .jmpexit bcs .checktrack
tay tay
adc #BASEPAGE-1 adc #BASEPAGE-1
sta .iob+2
pha pha
tya tya
;and disable it
ldy #$01 ldy #$01
jsr modify jsr modify
!byte $60 ;RTS !byte $60 ;RTS
pla pla
;find reference to T01 S0F ;find reference to T01 S0F
;to find page to hold protection data
ldy #6 ldy #6
jsr SearchSector jsr SearchSector
!byte $01,$60,$01,$00,$01,$0F !byte $01,$60,$01,$00,$01,$0F
bcs .jmpexit bcc .iob
adc #BASEPAGE
sta .iob+2 ;if it doesn't exist, fetch address from alternative location
inc .iob+2
ldx #7
;save for later... ;save for later...
@ -48,10 +58,9 @@
lda $D109,X lda $D109,X
sta .address+1 sta .address+1
.jmpexit .checktrack
jmp .exit lda gTrack
bne .jmpexit
.jmptrack0
jmp .dotrack0 jmp .dotrack0
.retrycount .retrycount
@ -60,6 +69,8 @@
.badread .badread
lda #s_optbad ; say read failure lda #s_optbad ; say read failure
jsr PrintByID jsr PrintByID
.jmpexit
jmp .exit jmp .exit
.dotrack1 .dotrack1
@ -104,6 +115,9 @@
;detect write-protect ;detect write-protect
;work around OE issue ;work around OE issue
;OE returns nibbles in wrong order on write-protected disks
;versus non-write-protected disks, when reset is issued
;so we detect write-protect and fix the order appropriately
ldx gRWTSParams+1 ldx gRWTSParams+1
lda $C08D,x lda $C08D,x
@ -172,6 +186,8 @@
bpl - bpl -
rts rts
;read protected data
.readcallback .readcallback
- jsr .readnib - jsr .readnib
sta $C08D,x sta $C08D,x
@ -202,10 +218,20 @@
!byte $11,$02,$00,$09 !byte $11,$02,$00,$09
;track 0, find the region with replaced page ;track 0, find the region with replaced page
;for loads to $B1 and $03, the page is stand-alone
;otherwise we have to find which page to merge
;the protection is that $87 bytes of a particular page,
;and which page depends on the title in question,
;are supplied by reading the data from the protected sector
;failing to read the data causes the title to crash
.dotrack0 .dotrack0
lda #s_construct lda #s_construct
jsr PrintByID jsr PrintByID
lda .address+1
bmi .domerge
cmp #3
beq .domerge
ldy #8 ldy #8
jsr SearchTrack jsr SearchTrack
!byte $20,$5D,$B6 ;JSR $B65D !byte $20,$5D,$B6 ;JSR $B65D
@ -246,6 +272,7 @@
;read replaced page ;read replaced page
.domerge
lda #9 ; $900-9FF lda #9 ; $900-9FF
sta gAddress+1 sta gAddress+1
ldy #<gRWTSParams ldy #<gRWTSParams
@ -262,6 +289,7 @@
bne - bne -
;read other page in block ;read other page in block
;sector $01 pairs with $0F
lda #1 lda #1
sta gTrack sta gTrack
@ -284,7 +312,6 @@
;restore original disk location ;restore original disk location
.restore
dec gTrack ; #0 dec gTrack ; #0
lda #$0F lda #$0F
sta gSector sta gSector