refactor RestartScan and use in sierra and f7f6 patchers

This commit is contained in:
4am 2017-12-26 11:40:08 -05:00
parent 48706b4067
commit bba448c1e7
7 changed files with 86 additions and 29 deletions

View File

@ -23,17 +23,20 @@ SkipTrack
;
.checkunformat
jsr IsUnformatted
bcs .checkf7
bcs .checkf7f6
+ lda #s_unformat
bcc .skiptrack ; always taken
;
; 3) $F7 protection track (F7F6EFEAAB nibble sequence)
; 3) $F7F6 protection track (F7F6EFEAAB nibble sequence)
;
.checkf7
jsr IsF7
.checkf7f6
jsr IsF7F6
bcs .checksync
lda #s_f7
bcc .skiptrack ; always taken
bit gMode
bpl .checksync
bvc .checksync
; if we're in 'crack' mode, restart the scan to find the protection code
jmp SetupF7F6SecondRound
;
; 4) nibble count track (mostly $FF sync bytes)
;
@ -76,7 +79,7 @@ SkipTrack
}
;-------------------------------
; IsF7
; IsF7F6
; check for a specific nibble sequence
; ("F7 F6 EF EE AB") that is used by a
; whole-track protection scheme
@ -86,7 +89,7 @@ SkipTrack
; C set if sequence was not found
;-------------------------------
!zone {
IsF7
IsF7F6
lda $C0E9
lda #$00
jsr WAIT
@ -126,6 +129,38 @@ IsF7
rts
}
;-------------------------------
; SetupF7F6SecondRound
;
; Print that we found the F7F6 protection track,
; then restart the scan so we can search every sector
; for the protection code.
; Never returns.
; Exits via RestartScan.
;-------------------------------
SetupF7F6SecondRound
; Mark in the sector map that we should ignore
; this protection track the second time around.
lda checksector+1
sta .a+1
lda checksector+2
sta .a+2
ldy gSector
lda #kSectorIgnore
.a sta $D1D1 ; modifed at runtime
dec .a+1
bne +
dec .a+2
+ dey
bpl .a
; print that we found the protection track
lda #s_f7
jsr PrintByID
; set global to activate expensive patcher
lda #TRUE
sta gIsF7F6
jmp RestartScan
;-------------------------------
; IsEEEF
; check for a specific nibble sequence

View File

@ -49,10 +49,20 @@
; compile-time flag, no way to change at runtime
FIRSTFILTER
;gIsF7F6
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in analyze/SetupF7F6SecondRound
; used to avoid an expensive search
;gIsSierra13
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in sierra13 patcher after patching
; set in sierra13 patcher
; used to avoid an expensive search
;gIsSierra
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in sierra patcher
; used to avoid an expensive search
;gIsDatasoft
!byte FALSE ; 0=true, 1=false

View File

@ -81,10 +81,12 @@ gIsMilliken1 = gIs8b3-$01 ; byte
gAdventureInternational = gIsMilliken1-$01 ; byte
gIsLaureate = gAdventureInternational-$01 ; byte
gIsDatasoft = gIsLaureate-$01 ; byte
gIsSierra13 = gIsDatasoft-$01 ; byte
gIsSierra = gIsDatasoft-$01 ; byte
gIsSierra13 = gIsSierra-$01 ; byte
gIsF7F6 = gIsSierra13-$01 ; byte
;LASTFILTER ; add new gIs* above this line
gOnAClearDayYouCanReadForever = gIsSierra13-$01 ; byte
gOnAClearDayYouCanReadForever = gIsF7F6-$01 ; byte
gUsingRAMDisk = gOnAClearDayYouCanReadForever-$01 ; byte
gRAMDiskRef = gUsingRAMDisk-$01 ; byte
gDisplayBytes = gRAMDiskRef-$0A ; 10 bytes

View File

@ -686,6 +686,24 @@ ChangeSector
sta gAddress+1
rts
;-------------------------------
; RestartScan
; Print 'Restarting scan...' then do exactly that.
; Used by several patchers that find evidence of a protection
; then activate an expensive search the second time around.
; Can be called from anywhere.
; Resets stack, never returns.
; Exits via ReadWithRWTS
;-------------------------------
RestartScan
lda #s_restart
jsr PrintByID
jsr RestartProgress
jsr IncProgress
ldx #$FF
txs
jmp ReadWithRWTS
;-------------------------------
; AnalyzeTrack routine
; Looks at buffer in memory to detect known

View File

@ -14,7 +14,7 @@
; Water in the Air Quiz (1985, EME)
;-------------------------------
!zone {
lda gIsBoot0
lda gIsF7F6
bne .exit
lda #$0F
sta .sector+1

View File

@ -28,12 +28,11 @@
; module by qkumba
;-------------------------------
!zone {
lda .foundsierra
bne +
lda gIsSierra
beq +
jmp .dosearch
+ lda gTrack
bne +
dec .foundsierra
+ ldy #3
jsr SearchTrack
.call
@ -167,8 +166,6 @@
jsr modify
!byte $2C ;BIT $xxxx
+ jmp .exit
.foundsierra
!byte $00
.trybox
ldy #17
@ -459,13 +456,8 @@
bit gMode
bpl .exit
bvc .exit
lda #s_restart
jsr PrintByID
inc .foundsierra
jsr RestartProgress
jsr IncProgress
ldx #$FF
txs
jmp ReadWithRWTS
lda #TRUE
sta gIsSierra
jmp RestartScan
.exit
}

View File

@ -138,7 +138,7 @@ StringTable
; can be set directly before calling PrintByID.
;
.header
!text "Passport by 4am 2017-12-24",$00
!text "Passport by 4am 2017-12-26",$00
.mainmenu
!text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D
!text " "
@ -185,9 +185,9 @@ StringTable
.unformat
!text "T%t is unformatted",$8D,$00
.f7
!text "T%t Found $F7F6EFEEAB protection",$8D,$00
!text "T%t Found $F7F6EFEEAB protection track",$8D,$00
.sync
!text "T%t Found nibble count protection",$8D,$00
!text "T%t Found nibble count protection track",$8D,$00
.optbad
!text "T%t,S%s is unreadable (ignoring)",$8D,$00
.passver
@ -371,7 +371,7 @@ StringTable
.eatrk6
!text "T06 Found EA protection track",$8D,$00
.eeef
!text "T%t Found $EEEFBBBA protection",$8D,$00
!text "T%t Found $EEEFBBBA protection track",$8D,$00
.poke
!text "T%t,S%0 BASIC program POKEs protection",$8D
!text "check into memory and CALLs it.",$8D,$00