Adaptive built-in RWTS accepts any epilogue once, then enforces it

This commit is contained in:
4am 2017-12-12 15:43:41 -05:00
parent 2baf15faff
commit d7e83af2bf
5 changed files with 111 additions and 29 deletions

View File

@ -26,20 +26,3 @@ IDProDOS
!byte $4C ; JMP
rts
}
!zone {
PatchUniversalRWTSForOrigin
ldy #$0F
- lda .a, y
sta $b990, y
dey
bpl -
ldy #$14
- lda .b, y
sta $b92f, y
dey
bpl -
rts
.a !byte $C9,$AB,$D0,$0A,$EA,$BD,$8C,$C0,$C9,$AB,$F0,$95,$D0,$00,$18,$60
.b !byte $18,$60,$38,$A5,$2D,$E9,$11,$85,$2D,$18,$60,$00,$00,$00,$00,$00,$00,$00,$00,$38,$60
}

View File

@ -322,18 +322,39 @@ UseUniversal
jsr IncProgress
jsr StartWithUniv
lda gIsDinkeyDOS
bne ReadWithRWTS
; On disks with a ProDOS bootloader, we patch the universal RWTS in memory
; so it can also read protected Origin disks like Ultima V and Times of Lore.
bne +
;
; On Dinkey-DOS disks (e.g. Ultima V, Times of Lore), we start with the
; universal RWTS then apply a patch in memory.
; These disks use a hybrid RWTS that alters the sector number in the
; address field based on the address epilogue. Once we normalize the
; sector numbers, no further patches are required, since the RWTS can also
; read unprotected disks. A separate patcher finds the actual code that
; alters the sector number to print it to the log.
;
jsr PatchUniversalRWTSForOrigin
bmi ReadWithRWTS ; always branches
;
; On other disks that use the universal RWTS for the entire disk, we use
; an adaptive RWTS that accepts any epilogue on the first sector but then
; enforces all other sectors to have the same epilogue.
;
+ jsr PatchUniversalRWTSForAdaptive
;
; Some disks have different epilogues on track 0, so we stop using the
; adaptive RWTS so we don't falsely accuse those disks of being damaged.
;
lda #kSectorResetAdaptiveRWTS
sta T00S0F
;
; Some disks have an intentionally invalid checksum on T00,S00 (read by
; the drive firmware, which doesn't verify it).
;
lda #kSectorIgnoreAddressChecksum
sta T00S00
;
; note: execution falls through here
;
ReadWithRWTS
lda #$22
jsr ChangeTrackNW
@ -355,6 +376,10 @@ checksector
cmp #kSectorCustomLast
bcs +
jsr PreReadSector
tax
pla
txa
pha ; replace status (on stack) with new status returned from PreReadSector
+ cmp #kSectorIgnore ; skip this sector?
beq nextsector
+ cmp #kSectorSwitchToBuiltinRWTS ; switch to built-in RWTS before reading this sector?

View File

@ -86,8 +86,20 @@ endprotread
;-------------------------------
PreReadSector
!zone {
cmp #kSectorResetAdaptiveRWTS
beq .reset
cmp #kSectorIgnoreAddressChecksum
beq .ignore
cmp #kSectorCustomDOS32B4BB
bne +
beq .b4bb
rts
.reset
jsr CopyUniversal
lda #kSectorRequired
rts
.ignore
jmp IgnoreAddressChecksum
.b4bb
ldx jCallRWTS+2
dex
dex
@ -99,15 +111,75 @@ PreReadSector
.a stx $FF76
ldx #$ED
.b stx $FFB2
bne .exit ; always branches
+
.exit rts
}
!zone {
IgnoreAddressChecksum
lda #$00
sta $B98A
; out: A,Y preserved
; X clobbered
ldx #$00
stx $B98A
rts
}
!zone {
PatchUniversalRWTSForAdaptive
; out: N flag set
ldy #$09
- lda .addressepilogue, y
sta $B994, y
lda .dataepilogue, y
sta $B938, y
dey
bpl -
rts
.addressepilogue ; to $B994
!byte $8D,$91,$B9
!byte $A9,$AE
!byte $8D,$93,$B9
!byte $D0,$00
.dataepilogue ; to $B938
!byte $8D,$35,$B9
!byte $A9,$0A
!byte $8D,$37,$B9
!byte $18
!byte $60
}
!zone {
PatchUniversalRWTSForOrigin
; out: N flag set
ldy #$0F
- lda .addressepilogue, y
sta $B990, y
dey
bpl -
ldy #$0A
- lda .dataepilogue, y
sta $B92F, y
dey
bpl -
rts
.addressepilogue ; to $B990
!byte $C9,$AB
!byte $D0,$0A
!byte $EA
!byte $BD,$8C,$C0
!byte $C9,$AB
!byte $F0,$95
!byte $D0,$00
!byte $18,$60
.dataepilogue ; to $B92F
!byte $18
!byte $60
!byte $38
!byte $A5,$2D
!byte $E9,$11
!byte $85,$2D
!byte $18
!byte $60
}
gTrack !byte $00
gSector !byte $00

View File

@ -31,7 +31,9 @@ kSectorRequired = $FF ; sector is required (errors are fatal)
kSectorCustomFirst = $C0
kSectorCustomLast = $D0
; specific codes
kSectorCustomDOS32B4BB = $C0 ; DOS 3.2 / JMP B4BB RWTS swapper
kSectorResetAdaptiveRWTS = $C0 ; will accept any epilogue on next sector, then remember it
kSectorIgnoreAddressChecksum = $C1 ; will ignore address field checksum
kSectorCustomDOS32B4BB = $C2 ; DOS 3.2 / JMP B4BB RWTS swapper
;-------------------------------
InitSectorMap
!zone {

View File

@ -137,7 +137,7 @@ StringTable
; can be set directly before calling PrintByID.
;
.header
!text "Passport by 4am 2017-12-06",$00
!text "Passport by 4am 2017-12-11",$00
.mainmenu
!text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D
!text " "