add support for RPS protection [fixes several Britannica and Thunder Mountain disks]

This commit is contained in:
4am 2020-07-15 11:53:18 -04:00
parent 73270715a8
commit d314e7be03
8 changed files with 147 additions and 82 deletions

View File

@ -546,3 +546,40 @@ xHarvey
sta T02S0F
.exit rts
}
;-------------------------------
; xRPS
; check if disk has RPS protection
; (boot1 jumps to $B3C1 to change RWTS,
; epilogue checker jumps to $B6B3 to
; check timing bits, late DOS routes
; through nibble check at $B74B)
;
; in: $B600..$BFFF contains boot1
; out: C clear if protection found
; C set if protection was not found
;-------------------------------
!zone {
xRPS
lda #$B7
ldx #$47
ldy #$07
jsr CompareMemory
!byte $4C,$C1,$B3
!byte $60
!byte $48
!byte $A9,$02
bcs .exit
lda #kSectorOptional
sta T02S05
sta T02S0A
lda #kSectorSwitchToBuiltinRWTS
sta T02S04 ; some variants might auto-switch earlier, some need to be told
ldy #$FF
sty $BA29
iny
sty $BAFF
ldy #$3F
sty $BA96
.exit rts
}

View File

@ -84,7 +84,7 @@ AnalyzeT00
!source "../patchers/rwtslog.a"
!source "../patchers/mecc.a"
!source "../patchers/rol1e.a"
; !source "../patchers/thunder.a"
!source "../patchers/rps.a"
!source "../patchers/bb03.a"
!source "../patchers/rwtsswap.a"
!source "../patchers/rwtsswap2.a"

View File

@ -278,31 +278,36 @@ ADStyle
; before we start.
;
jsr xHeredityDog
bcs .noDog
bcs +
lda #s_bb00
jsr PrintByID
.noDog
+
jsr xSunburst
bcs .noSun
bcs +
lda #s_sunburst
jsr PrintByID
.noSun
+
jsr xOptimumRes
bcs .noOptimum
bcs +
lda #TRUE
sta gIsOptimum
lda #s_optimum
jsr PrintByID
.noOptimum
+
jsr xSVE
bcs .noSVE
bcs +
lda #s_sve
jsr PrintByID
lda #$CA
sta $BE5B
lda #$B6
sta $BE5C
.noSVE
+
jsr xRPS
bcs +
lda #s_rps
jsr PrintByID
+
jsr xB660
jsr xB4BB
jsr xHarvey

84
src/patchers/rps.a Executable file
View File

@ -0,0 +1,84 @@
;-------------------------------
; #RPS
; boot1 jumps to $B3C1 to change RWTS,
; epilogue checker jumps to $B6B3 to
; check timing bits, late DOS routes
; through nibble check at $B74B
;
; so named because the disk volume string is
; C1984 RPS A#
;
; variant 1
; - Dig Dug (Thunder Mountain)
; - Pac-Man (Thunder Mountain)
; - Galaxian (Thunder Mountain)
;
; variant 2
; - Problem Solving in Algebra (Encyclopaedia Britannica)
; - Math Skills: Elementary Level (Encyclopaedia Britannica)
; - Math Skills: Junior High Level (Encyclopaedia Britannica)
;-------------------------------
!zone {
bit gMode ; nothing to do here in verify-only mode
bpl .exit
lda gIsBoot0 ; if DOS 3.3 boot0 loader
bne .exit
lda gIsBoot1 ; and DOS 3.3 boot1 loader
bne .exit
lda #$01
ldx #$48
ldy #$02
jsr compare ; if T00,S01,$48 ==
!byte $C1,$B3
bcs .exit ; primary pattern not found, bail
ldy #$02
jsr modify ; then set T00,S01,$48 =
!byte $1F,$B4
lda #$03
ldx #$3E
ldy #$04
jsr compare ; if T00,S03,$3E ==
!byte $4C,$B3,$B6
!byte $EA
bcs .variant1
lda #$03
ldx #$3E
ldy #$04
jsr modify ; then set T00,S03,$3E =
!byte $C9,$AA
!byte $F0,$5C
.variant1
lda #$01
ldx #$87
ldy #$03
jsr compare ; if T00,S01,$87 ==
!byte $6C,$58,$9D
bcs .variant2 ; passport-test-suite/Pac-Man (Thunder Mountain).woz [C=0] here
ldx #$8E
ldy #$01
jsr modify ; then set T00,S01,$8E =
!byte $F8 ; change branch to unconditionally jump to success path
ldx #$92
ldy #$01
jsr modify ; and set T00,S01,$92 =
!byte $F1 ; change branch to unconditionally jump to success path
bvc .exit ; always branches
.variant2
inx
ldy #$03
jsr compare ; if T00,S01,$88 ==
!byte $6C,$58,$9D
bcs .exit ; passport/test-suite/Problem Solving in Algebra.woz [C=0] here
ldx #$8E
ldy #$01
jsr modify ; then set T00,S01,$8E =
!byte $F9 ; change branch to unconditionally jump to success path
ldx #$92
ldy #$01
jsr modify ; and set T00,S01,$92 =
!byte $F2 ; change branch to unconditionally jump to success path
.exit
}

View File

@ -1,63 +0,0 @@
; /!\ CURRENTLY UNUSED, REQUIRES ADDITIONAL TRACE SUPPORT, KEEP IN REPO FOR FUTURE RELEASE /!\
;-------------------------------
; #THUNDER
; boot1 jumps to $B3C1 to change RWTS,
; epilogue checker jumps to $B6B3 to
; check timing bits, late DOS routes
; through nibble check at $B74B
; e.g. Thunder Mountain versions of
; Dig Dug, Pac-Man, Galaxian
;-------------------------------
!zone {
bit gMode ; nothing to do here in verify-only mode
bpl .no
lda gIsBoot0 ; if DOS 3.3 boot0 loader
bne .no
lda gIsBoot1 ; and DOS 3.3 boot1 loader
bne .no
lda #$03
ldx #$3E
ldy #$04
jsr compare ; and T00,S03,$3E ==
!byte $4C,$B3,$B6
!byte $EA
bcc +
.no
jmp .exit
+
lda #$01
ldx #$47
ldy #$4C
jsr compare ; and T00,S01,$47 ==
!byte $4C
!byte $C1,$B3,$60,$48,$A9,$02,$8D,$EC
!byte $B7,$A9,$00,$8D,$EB,$B7,$8D,$F2
!byte $B7,$A9,$05,$8D,$ED,$B7,$A9,$36
!byte $8D,$F0,$B7,$A9,$B4,$8D,$F1,$B7
!byte $A9,$01,$8D,$E1,$B7,$8D,$F4,$B7
!byte $20,$93,$B7,$90,$09,$4C,$62,$FA
!byte $EA,$EA,$EA,$EA,$EA,$EA,$20,$36
!byte $B4,$68,$F0,$03,$6C,$72,$AA,$6C
!byte $58,$9D,$00,$A9,$00,$F0,$BC,$A9
!byte $01,$D0,$B8
bcs .exit
lda #s_thunder
jsr PrintByID
lda #$01
ldx #$48
ldy #$02
jsr modify ; then set T00,S01,$48 =
!byte $1F,$B4
lda #$01
ldx #$7E
ldy #$01
jsr modify ; and set T00,S01,$7E =
!byte $2C
lda #$03
ldx #$3E
ldy #$04
jsr modify ; and set T00,S03,$3E =
!byte $C9,$AA,$F0,$5C
.exit
}

View File

@ -71,9 +71,11 @@ T00S0E !byte $FF
T00S0F !byte $FF
T01 !byte $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
T01S0F !byte $FF
T02 !byte $FF,$FF,$FF,$FF,$FF
T02 !byte $FF,$FF,$FF,$FF
T02S04 !byte $FF
T02S05 !byte $FF
!byte $FF,$FF,$FF,$FF,$FF,$FF
!byte $FF,$FF,$FF,$FF
T02S0A !byte $FF,$FF
T02S0C !byte $FF
!byte $FF,$FF
T02S0F !byte $FF

View File

@ -63,7 +63,7 @@ StringTableLow
!byte <.e7
!byte <.jmpbeca
!byte <.bb03
!byte <.thunder
!byte <.rps
!byte <.jmpae8e
!byte <.diskvol
!byte <.d5d5f7
@ -183,7 +183,7 @@ StringTableHigh
!byte >.e7
!byte >.jmpbeca
!byte >.bb03
!byte >.thunder
!byte >.rps
!byte >.jmpae8e
!byte >.diskvol
!byte >.d5d5f7
@ -280,7 +280,7 @@ StringTableHigh
; can be set directly before calling PrintByID.
;
.header
!text "Passport by 4am 2020-07-14",$00
!text "Passport by 4am 2020-07-15",$00
.mainmenu
!text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D,$8D
!text " "
@ -442,9 +442,9 @@ StringTableHigh
.bb03
!text "T%t,S%0 Found a self-decrypting",$8D
!text "protection check at $BB03.",$8D,$00
.thunder
!text "T00,S03 RWTS counts timing bits and",$8D
!text "checks them later.",$8D,$00
.rps
!text "T00,S01 Found RPS protection check",$8D
!text "Some sectors on T02 might be unreadable",$8D,$00
.jmpae8e
!text "T00,S0D Disk calls a protection check at"
!text "$AE8E after initializing DOS.",$8D,$00

View File

@ -49,7 +49,7 @@ s_runhello = $2B
s_e7 = $2C
s_jmpbeca = $2D
s_bb03 = $2E
s_thunder = $2F
s_rps = $2F
s_jmpae8e = $30
s_diskvol = $31
s_d5d5f7 = $32
@ -74,7 +74,7 @@ s_eab0 = $44
s_eatrk6 = $45
s_eeef = $46
s_poke = $47
s_bootcounter = $48
s_bootcounter =$48
s_milliken = $49
s_jsr8b3 = $4A
s_daviddos = $4B