add support for Adventure International RWTS and encrypted protection check (fixes SAGA titles)

This commit is contained in:
4am 2017-08-03 10:08:36 -04:00
parent a74cc9b78a
commit 0b6afb0fad
5 changed files with 141 additions and 82 deletions

View File

@ -24,6 +24,7 @@ IDBootloader
sta gIsMECCFastloader
sta gPossibleGamco
sta gPossibleD5D5F7
sta gAdventureInternational
lda #$00
sta gLastTrack
;

View File

@ -60,6 +60,7 @@ TraceDOS33c
_Inspect1a
sta .x1+1
sta .x2+1
sta .x7+1
sta b4bbmodify+2
sta b4bbmodify2+2
clc
@ -136,13 +137,27 @@ _Inspect1a
ldy #$03
jsr CompareMemory
!byte $4C,$03,$9B
bcs +
bcs .x7
jsr IDMilliken
bcs +
bcs .x7
lda #s_milliken
jsr PrintByID
lda #$80
sta T02S05
;
; Check for Adventure International RWTS (sets flag for patcher)
;
.x7 lda #$FF ; check for code at $B936
ldx #$36
ldy #$0A
jsr CompareMemory
!byte $EA,$EA,$EA; NOP/NOP/NOP
!byte $BD,$8C,$C0; LDA $C08C,X
!byte $10,$FB ; BPL -$FB
!byte $C9,$00 ; CMP #$00
bcs +
lda #TRUE
sta gAdventureInternational
+ jmp ADStyle ; use this RWTS to read the disk
;-------------------------------

View File

@ -717,6 +717,7 @@ _applyToAll
!source "patchers/bootcounter.a" ; T01 only
!source "patchers/jmpb412.a" ; T02 only
!source "patchers/jmpb400.a" ; T02 && gIsBoot0 only
!source "patchers/advint.a" ; gAdventureInternational only
lda gPatchCount
beq .nopatches
@ -813,6 +814,10 @@ gPossibleD5D5F7
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
gAdventureInternational
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in TraceDOS33c() after tracing DOS 3.3-shaped RWTS
gOnAClearDayYouCanReadForever
!byte FALSE ; 0=true, 1=false
; retry reads with a captured RWTS forever,

33
src/patchers/advint.a Normal file
View File

@ -0,0 +1,33 @@
;-------------------------------
; #ADVINT
; encrypted protection check on
; Adventure International disks
;
; tested on
; SAGA1 - Adventureland v2.1-416
; SAGA2 - Pirate Adventure v2.1-408
; SAGA5 - The Count v2.1-115
; SAGA6 - Strange Odyssey v2.1-119
;-------------------------------
!zone {
lda gAdventureInternational
bne .exit
ldy #$0A
jsr SearchTrack
; bytes are XORd with #$C9 on disk -- comments show decrypted code
!byte $85,WILDCARD,WILDCARD ;JMP $****
!byte $74,$45,$09 ;LDA $C08C,X
!byte $D9,$32 ;BPL -$FB
!byte $0C,$30 ;CMP $F9
bcs .exit
sta gDisplayBytes
pha
lda #s_advint
jsr PrintByID
pla
ldy #$03
jsr modify
!byte $D1 ;CLC
!byte $59,$A7 ;BCC +$6E
.exit
}

View File

@ -103,7 +103,8 @@ s_micrograms = $54
s_cmpbne0 = $55
s_writeram = $56
s_d5timing = $57
STRINGCOUNT = $58
s_advint = $58
STRINGCOUNT = $59
!zone {
StringTable
@ -195,6 +196,7 @@ StringTable
!word .cmpbne0
!word .writeram
!word .d5timing
!word .advint
;
; Text can contain substitution strings, which
; are replaced by current values at runtime. Each
@ -220,7 +222,7 @@ StringTable
; can be set directly before calling PrintByID.
;
.header
!text "Passport by 4am 2017-08-01",00
!text "Passport by 4am 2017-08-03",$00
.mainmenu
!text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D
!text " "
@ -237,47 +239,47 @@ StringTable
!text "uit",$8D,$8D,$8D,$8D,$8D,$8D,$8D
!text "source: S6,D1 target: "
!scrxor $40, "S"
!text "%S,D%D",00
!text "%S,D%D",$00
.progbar
!byte $8D
!text " ______________________________________",$8D
!text " "
!scrxor $00, " "
!text "____________________________________"
!scrxor $00, " ",$8D,$8D,$8D,00
!scrxor $00, " ",$8D,$8D,$8D,$00
.reading
!text "Reading from S6,D1",$8D,00
!text "Reading from S6,D1",$8D,$00
.diskrwts
!text "Using disk's own RWTS",$8D,00
!text "Using disk's own RWTS",$8D,$00
.bb00
!text "T00,S05 Found $BB00 protection check",$8D
!text "T00,S0A might be unreadable",$8D,00
!text "T00,S0A might be unreadable",$8D,$00
.sunburst
!text "T00,S04 Found Sunburst disk",$8D
!text "T11,S0F might be unreadable",$8D,00
!text "T11,S0F might be unreadable",$8D,$00
.optimum
!text "T00,S00 Found Optimum Resource disk",$8D
!text "T01,S0F might be unreadable",$8D,00
!text "T01,S0F might be unreadable",$8D,$00
.builtin
!text "Using built-in RWTS",$8D,00
!text "Using built-in RWTS",$8D,$00
.switch
!text "Switching to built-in RWTS",$8D,00
!text "Switching to built-in RWTS",$8D,$00
.writing
!text "Writing to S%S,D%D",$8D,00
!text "Writing to S%S,D%D",$8D,$00
.unformat
!text "T%t is unformatted",$8D,00
!text "T%t is unformatted",$8D,$00
.f7
!text "T%t Found $F7F6EFEEAB protection",$8D,00
!text "T%t Found $F7F6EFEEAB protection",$8D,$00
.sync
!text "T%t Found nibble count protection",$8D,00
!text "T%t Found nibble count protection",$8D,$00
.optbad
!text "T%t,S%s is unreadable (ignoring)",$8D,00
!text "T%t,S%s is unreadable (ignoring)",$8D,$00
.passver
!text "Verification complete. The disk is good.",00
!text "Verification complete. The disk is good.",$00
.passdemuf
!text "Demuffin complete.",$8D,00
!text "Demuffin complete.",$8D,$00
.passcrack
!text "Crack complete.",$8D,00
!text "Crack complete.",$8D,$00
.passcrack0
!byte $8D
!text "The disk was copied successfully, but",$8D
@ -286,35 +288,35 @@ StringTable
!text "- The source disk is not copy protected."
!text "- The target disk works without patches."
!text "- The disk uses an unknown protection,",$8D
!text " and Passport can not help any further.",00
!text " and Passport can not help any further.",$00
.fail
!byte $8D
!text "T%t,S%s Fatal read error",$8D,00
!text "T%t,S%s Fatal read error",$8D,$00
.fatal0000
!byte $8D
!text "Possible reasons:",$8D
!text "- There is no disk in S6,D1.",$8D
!text "- It is not an Apple ][ disk.",$8D
!text "- The disk is DOS 3.2-only.",$8D
!text "- The disk is unformatted.",$8D,00
!text "- The disk is unformatted.",$8D,$00
.fatal220f
!byte $8D
!text "Passport does not work on this disk.",$8D,$8D
!text "Possible reasons:",$8D
!text "- This is not a 16-sector disk.",$8D
!text "- The disk modifies its RWTS in ways",$8D
!text " that Passport is not able to detect.",$8D,00
!text " that Passport is not able to detect.",$8D,$00
.done
!byte $8D
!text "Press any key to continue "
!scrxor $40, " ",00
!scrxor $40, " ",$00
.noslot6
!text "Passport requires a Disk II drive in S6.",$8D
!text "Press any key to quit "
!scrxor $40, " ",00
!scrxor $40, " ",$00
.writeerr
!byte $8D
!text "T%t Fatal write error",$8D,$8D,00
!text "T%t Fatal write error",$8D,$8D,$00
;
; MLI error $27
;
@ -322,121 +324,121 @@ StringTable
!text "Possible reasons:",$8D
!text "- There is no disk in S%S,D%D.",$8D
!text "- The disk has bad sectors.",$8D
!text "- The disk is unformatted.",$8D,$8D,00
!text "- The disk is unformatted.",$8D,$8D,$00
;
; MLI error $28
;
.writenodev
!text "S%S,D%D does not exist.",$8D,00
!text "S%S,D%D does not exist.",$8D,$00
;
; MLI error $2B
;
.writeprot
!text "The disk in S%S,D%D is write-protected.",$8D,00
!text "The disk in S%S,D%D is write-protected.",$8D,$00
;
; other MLI error
;
.othermli
!text "MLI error $%0.",$8D
!text "Please contact the developer.",$8D,00
!text "Please contact the developer.",$8D,$00
.canttrace
!text "Unrecognized drive, tracing is disabled",$8D,00
!text "Unrecognized drive, tracing is disabled",$8D,$00
.canceled
!text "Canceled at your request.",$8D,00
!text "Canceled at your request.",$8D,$00
.bademu
!byte 00
.reset
!byte $8D
!text "Press <Ctrl-Reset> to continue.",$8D,00
!text "Press <Ctrl-Reset> to continue.",$8D,$00
.modify
!text "T%t,S%0,$%1: ",00
!text "T%t,S%0,$%1: ",$00
.modifyto
!text " -> ",00
!text " -> ",$00
.dosboot0
!text "T00,S00 Found DOS 3.3 bootloader",$8D,00
!text "T00,S00 Found DOS 3.3 bootloader",$8D,$00
.prodosboot0
!text "T00,S00 Found ProDOS bootloader",$8D,00
!text "T00,S00 Found ProDOS bootloader",$8D,$00
.pascalboot0
!text "T00,S00 Found Pascal bootloader",$8D,00
!text "T00,S00 Found Pascal bootloader",$8D,$00
.mecc
!text "T00,S00 Found MECC bootloader",$8D,00
!text "T00,S00 Found MECC bootloader",$8D,$00
.sierra
!text "T%t,S%0 Found Sierra protection check",$8D,00
!text "T%t,S%0 Found Sierra protection check",$8D,$00
.a6bc95
!text "T%t,S%0 Found A6BC95 protection check",$8D,00
!text "T%t,S%0 Found A6BC95 protection check",$8D,$00
.jmpbcf0
!text "T00,S03 RWTS requires a timing bit after"
!text "the first data epilogue by jumping to",$8D
!text "$BCF0.",$8D,00
!text "$BCF0.",$8D,$00
.rol1e
!text "T00,S03 RWTS accumulates timing bits in",$8D
!text "$1E and checks its value later.",$8D,00
!text "$1E and checks its value later.",$8D,$00
.runhello
!text "T%t,S%0 Startup program executes a",$8D
!text "protection check before running the real"
!text "startup program.",$8D,00
!text "startup program.",$8D,$00
.e7
!text "T%t,S%0 Found E7 bitstream",$8D,00
!text "T%t,S%0 Found E7 bitstream",$8D,$00
.jmpb4bb
!text "T00,S0C Disk calls a protection check at"
!text "$B4BB before initializing DOS.",$8D,00
!text "$B4BB before initializing DOS.",$8D,$00
.jmpb400
!text "T%t,S%0 Disk calls a protection check at"
!text "$B400 before initializing DOS.",$8D,00
!text "$B400 before initializing DOS.",$8D,$00
.jmpbeca
!text "T00,S02 RWTS requires extra nibbles and",$8D
!text "timing bits after the data prologue by",$8D
!text "jumping to $BECA.",$8D,00
!text "jumping to $BECA.",$8D,$00
.jsrbb03
!text "T00,S05 Found a self-decrypting",$8D
!text "protection check at $BB03.",$8D,00
!text "protection check at $BB03.",$8D,$00
.thunder
!text "T00,S03 RWTS counts timing bits and",$8D
!text "checks them later.",$8D,00
!text "checks them later.",$8D,$00
.jmpae8e
!text "T00,S0D Disk calls a protection check at"
!text "$AE8E after initializing DOS.",$8D,00
!text "$AE8E after initializing DOS.",$8D,$00
.diskvol
!text "T00,S08 RWTS requires a non-standard",$8D
!text "disk volume number.",$8D,00
!text "disk volume number.",$8D,$00
.d5d5f7
!text "T%t,S%0 Found D5D5F7 protection check",$8D,00
!text "T%t,S%0 Found D5D5F7 protection check",$8D,$00
.construct
!text "T01,S0F Reconstructing missing data",$8D,$00
.datasoftb0
!text "T00,S00 Found Datasoft bootloader",$8D,00
!text "T00,S00 Found Datasoft bootloader",$8D,$00
.datasoft
!text "T%t,S%0 Found Datasoft protection check",$8D,00
!text "T%t,S%0 Found Datasoft protection check",$8D,$00
.lsr6a
!text "T%t,S%0 RWTS accepts $D4 or $D5 for the",$8D
!text "first address prologue nibble.",$8D,00
!text "first address prologue nibble.",$8D,$00
.bcs08
!text "T%t,S%0 RWTS accepts $DE or a timing bit"
!text "for the first address epilogue nibble.",$8D,00
!text "for the first address epilogue nibble.",$8D,$00
.jmpb660
!text "T00,S02 RWTS requires timing bits after",$8D
!text "the data prologue by jumping to $B660.",$8D,00
!text "the data prologue by jumping to $B660.",$8D,$00
.protdos
!text "T00,S01 Found encrypted RWTS, key=$%0",$8D,00
!text "T00,S01 Found encrypted RWTS, key=$%0",$8D,$00
.protdosw
!text "T00 Decrypting RWTS before writing",$8D,00
!text "T00 Decrypting RWTS before writing",$8D,$00
.protserial
!text "T%t,S%3 Erasing serial number %0%1%2",$8D,00
!text "T%t,S%3 Erasing serial number %0%1%2",$8D,$00
.fbff
!text "T%t,S%0 Found FBFF protection check",$8D,00
!text "T%t,S%0 Found FBFF protection check",$8D,$00
.encoded44
!byte $8D
!text "T00,S00 Fatal error",$8D,$8D
!text "Passport does not work on this disk,",$8D
!text "because it uses a 4-and-4 encoding.",$8D,00
!text "because it uses a 4-and-4 encoding.",$8D,$00
.encoded53
!byte $8D
!text "T00,S00 Fatal error",$8D,$8D
!text "Passport does not work on this disk,",$8D
!text "because it uses a 5-and-3 encoding.",$8D,00
!text "because it uses a 5-and-3 encoding.",$8D,$00
.specdel
!text "T00,S00 Found DOS 3.3P bootloader",$8D,00
!text "T00,S00 Found DOS 3.3P bootloader",$8D,$00
.bytrack
!text "T%t,S%0 RWTS changes based on track",$8D,$00
.a5count
@ -447,11 +449,11 @@ StringTable
!text "T13,S0E Protection check intentionally",$8D
!text "destroys unauthorized copies",$8D,$00
.eaboot0
!text "T00 Found Electronic Arts bootloader",$8D,00
!text "T00 Found Electronic Arts bootloader",$8D,$00
.eatrk6
!text "T06 Found EA protection track",$8D,00
!text "T06 Found EA protection track",$8D,$00
.eeef
!text "T%t Found $EEEFBBBA protection",$8D,00
!text "T%t Found $EEEFBBBA protection",$8D,$00
.poke
!text "T%t,S%0 BASIC program POKEs protection",$8D
!text "check into memory and CALLs it.",$8D,$00
@ -460,32 +462,35 @@ StringTable
!text "after a limited number of boots.",$8D,$00
.milliken
!text "T00,S0A Found Milliken protection check",$8D
!text "T02,S05 might be unreadable",$8D,00
!text "T02,S05 might be unreadable",$8D,$00
.jsr8b3
!text "T00,S00 Found JSR $08B3 bootloader",$8D,00
!text "T00,S00 Found JSR $08B3 bootloader",$8D,$00
.daviddos
!text "T00,S00 Found David-DOS bootloader",$8D,00
!text "T00,S00 Found David-DOS bootloader",$8D,$00
.quickdos
!text "T00,S00 Found Quick-DOS bootloader",$8D,00
!text "T00,S00 Found Quick-DOS bootloader",$8D,$00
.diversidos
!text "T00,S00 Found Diversi-DOS bootloader",$8D,00
!text "T00,S00 Found Diversi-DOS bootloader",$8D,$00
.prontodos
!text "T00,S00 Found Pronto-DOS bootloader",$8D,00
!text "T00,S00 Found Pronto-DOS bootloader",$8D,$00
.jmpb412
!text "T02,S00 Disk calls a protection check",$8D
!text "at $B412 before initializing DOS.",$8D,00
!text "at $B412 before initializing DOS.",$8D,$00
.laureate
!text "T00,S00 Found Laureate bootloader",$8D,00
!text "T00,S00 Found Laureate bootloader",$8D,$00
.bbf9
!text "T%t,S%0 Found BBF9 protection check",$8D,00
!text "T%t,S%0 Found BBF9 protection check",$8D,$00
.micrograms
!text "T00,S00 Found Micrograms bootloader",$8D,00
!text "T00,S00 Found Micrograms bootloader",$8D,$00
.cmpbne0
!text "T%t,S%0 RWTS accepts any value for the",$8D
!text "first address epilogue nibble.",$8D,00
!text "first address epilogue nibble.",$8D,$00
.writeram
!text "Writing to RAM disk",$8D,00
!text "Writing to RAM disk",$8D,$00
.d5timing
!text "T%t,S%0 RWTS accepts $D5 plus a timing",$8D
!text "bit as the entire address prologue.",$8D,$00
.advint
!text "T%t,S%0 Found Adventure International",$8D
!text "protection check",$8D,$00
}