From d314e7be03b5b20c547ac3f86ab93352d025b700 Mon Sep 17 00:00:00 2001 From: 4am Date: Wed, 15 Jul 2020 11:53:18 -0400 Subject: [PATCH] add support for RPS protection [fixes several Britannica and Thunder Mountain disks] --- src/analyze.a | 37 +++++++++++++++++++ src/mods/t00only.a | 2 +- src/passport.a | 21 +++++++---- src/patchers/rps.a | 84 ++++++++++++++++++++++++++++++++++++++++++ src/patchers/thunder.a | 63 ------------------------------- src/sectormap.a | 6 ++- src/strings/en.a | 12 +++--- src/strings/enid.a | 4 +- 8 files changed, 147 insertions(+), 82 deletions(-) create mode 100755 src/patchers/rps.a delete mode 100755 src/patchers/thunder.a diff --git a/src/analyze.a b/src/analyze.a index feecc63..eba6633 100755 --- a/src/analyze.a +++ b/src/analyze.a @@ -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 +} diff --git a/src/mods/t00only.a b/src/mods/t00only.a index 62e8a31..e994132 100644 --- a/src/mods/t00only.a +++ b/src/mods/t00only.a @@ -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" diff --git a/src/passport.a b/src/passport.a index 86f466c..c24c479 100755 --- a/src/passport.a +++ b/src/passport.a @@ -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 diff --git a/src/patchers/rps.a b/src/patchers/rps.a new file mode 100755 index 0000000..c55c7fb --- /dev/null +++ b/src/patchers/rps.a @@ -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 +} diff --git a/src/patchers/thunder.a b/src/patchers/thunder.a deleted file mode 100755 index dfa8ca2..0000000 --- a/src/patchers/thunder.a +++ /dev/null @@ -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 -} diff --git a/src/sectormap.a b/src/sectormap.a index 1153303..0d51438 100755 --- a/src/sectormap.a +++ b/src/sectormap.a @@ -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 diff --git a/src/strings/en.a b/src/strings/en.a index 4a829dc..f29f181 100755 --- a/src/strings/en.a +++ b/src/strings/en.a @@ -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 diff --git a/src/strings/enid.a b/src/strings/enid.a index df1d011..df1e8af 100644 --- a/src/strings/enid.a +++ b/src/strings/enid.a @@ -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