mirror of
https://github.com/a2-4am/passport.git
synced 2024-12-22 19:30:50 +00:00
Adaptive built-in RWTS accepts any epilogue once, then enforces it
This commit is contained in:
parent
2baf15faff
commit
d7e83af2bf
@ -26,20 +26,3 @@ IDProDOS
|
|||||||
!byte $4C ; JMP
|
!byte $4C ; JMP
|
||||||
rts
|
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
|
|
||||||
}
|
|
||||||
|
@ -322,18 +322,39 @@ UseUniversal
|
|||||||
jsr IncProgress
|
jsr IncProgress
|
||||||
jsr StartWithUniv
|
jsr StartWithUniv
|
||||||
lda gIsDinkeyDOS
|
lda gIsDinkeyDOS
|
||||||
bne ReadWithRWTS
|
bne +
|
||||||
; 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.
|
; 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
|
; These disks use a hybrid RWTS that alters the sector number in the
|
||||||
; address field based on the address epilogue. Once we normalize the
|
; address field based on the address epilogue. Once we normalize the
|
||||||
; sector numbers, no further patches are required, since the RWTS can also
|
; sector numbers, no further patches are required, since the RWTS can also
|
||||||
; read unprotected disks. A separate patcher finds the actual code that
|
; read unprotected disks. A separate patcher finds the actual code that
|
||||||
; alters the sector number to print it to the log.
|
; alters the sector number to print it to the log.
|
||||||
|
;
|
||||||
jsr PatchUniversalRWTSForOrigin
|
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
|
; note: execution falls through here
|
||||||
|
;
|
||||||
ReadWithRWTS
|
ReadWithRWTS
|
||||||
lda #$22
|
lda #$22
|
||||||
jsr ChangeTrackNW
|
jsr ChangeTrackNW
|
||||||
@ -355,6 +376,10 @@ checksector
|
|||||||
cmp #kSectorCustomLast
|
cmp #kSectorCustomLast
|
||||||
bcs +
|
bcs +
|
||||||
jsr PreReadSector
|
jsr PreReadSector
|
||||||
|
tax
|
||||||
|
pla
|
||||||
|
txa
|
||||||
|
pha ; replace status (on stack) with new status returned from PreReadSector
|
||||||
+ cmp #kSectorIgnore ; skip this sector?
|
+ cmp #kSectorIgnore ; skip this sector?
|
||||||
beq nextsector
|
beq nextsector
|
||||||
+ cmp #kSectorSwitchToBuiltinRWTS ; switch to built-in RWTS before reading this sector?
|
+ cmp #kSectorSwitchToBuiltinRWTS ; switch to built-in RWTS before reading this sector?
|
||||||
|
82
src/rwts.a
82
src/rwts.a
@ -86,8 +86,20 @@ endprotread
|
|||||||
;-------------------------------
|
;-------------------------------
|
||||||
PreReadSector
|
PreReadSector
|
||||||
!zone {
|
!zone {
|
||||||
|
cmp #kSectorResetAdaptiveRWTS
|
||||||
|
beq .reset
|
||||||
|
cmp #kSectorIgnoreAddressChecksum
|
||||||
|
beq .ignore
|
||||||
cmp #kSectorCustomDOS32B4BB
|
cmp #kSectorCustomDOS32B4BB
|
||||||
bne +
|
beq .b4bb
|
||||||
|
rts
|
||||||
|
.reset
|
||||||
|
jsr CopyUniversal
|
||||||
|
lda #kSectorRequired
|
||||||
|
rts
|
||||||
|
.ignore
|
||||||
|
jmp IgnoreAddressChecksum
|
||||||
|
.b4bb
|
||||||
ldx jCallRWTS+2
|
ldx jCallRWTS+2
|
||||||
dex
|
dex
|
||||||
dex
|
dex
|
||||||
@ -99,15 +111,75 @@ PreReadSector
|
|||||||
.a stx $FF76
|
.a stx $FF76
|
||||||
ldx #$ED
|
ldx #$ED
|
||||||
.b stx $FFB2
|
.b stx $FFB2
|
||||||
bne .exit ; always branches
|
|
||||||
+
|
|
||||||
.exit rts
|
.exit rts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
!zone {
|
||||||
IgnoreAddressChecksum
|
IgnoreAddressChecksum
|
||||||
lda #$00
|
; out: A,Y preserved
|
||||||
sta $B98A
|
; X clobbered
|
||||||
|
ldx #$00
|
||||||
|
stx $B98A
|
||||||
rts
|
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
|
gTrack !byte $00
|
||||||
gSector !byte $00
|
gSector !byte $00
|
||||||
|
@ -31,7 +31,9 @@ kSectorRequired = $FF ; sector is required (errors are fatal)
|
|||||||
kSectorCustomFirst = $C0
|
kSectorCustomFirst = $C0
|
||||||
kSectorCustomLast = $D0
|
kSectorCustomLast = $D0
|
||||||
; specific codes
|
; 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
|
InitSectorMap
|
||||||
!zone {
|
!zone {
|
||||||
|
@ -137,7 +137,7 @@ StringTable
|
|||||||
; can be set directly before calling PrintByID.
|
; can be set directly before calling PrintByID.
|
||||||
;
|
;
|
||||||
.header
|
.header
|
||||||
!text "Passport by 4am 2017-12-06",$00
|
!text "Passport by 4am 2017-12-11",$00
|
||||||
.mainmenu
|
.mainmenu
|
||||||
!text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D
|
!text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D
|
||||||
!text " "
|
!text " "
|
||||||
|
Loading…
Reference in New Issue
Block a user