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 .checkunformat
jsr IsUnformatted jsr IsUnformatted
bcs .checkf7 bcs .checkf7f6
+ lda #s_unformat + lda #s_unformat
bcc .skiptrack ; always taken bcc .skiptrack ; always taken
; ;
; 3) $F7 protection track (F7F6EFEAAB nibble sequence) ; 3) $F7F6 protection track (F7F6EFEAAB nibble sequence)
; ;
.checkf7 .checkf7f6
jsr IsF7 jsr IsF7F6
bcs .checksync bcs .checksync
lda #s_f7 bit gMode
bcc .skiptrack ; always taken 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) ; 4) nibble count track (mostly $FF sync bytes)
; ;
@ -76,7 +79,7 @@ SkipTrack
} }
;------------------------------- ;-------------------------------
; IsF7 ; IsF7F6
; check for a specific nibble sequence ; check for a specific nibble sequence
; ("F7 F6 EF EE AB") that is used by a ; ("F7 F6 EF EE AB") that is used by a
; whole-track protection scheme ; whole-track protection scheme
@ -86,7 +89,7 @@ SkipTrack
; C set if sequence was not found ; C set if sequence was not found
;------------------------------- ;-------------------------------
!zone { !zone {
IsF7 IsF7F6
lda $C0E9 lda $C0E9
lda #$00 lda #$00
jsr WAIT jsr WAIT
@ -126,6 +129,38 @@ IsF7
rts 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 ; IsEEEF
; check for a specific nibble sequence ; check for a specific nibble sequence

View File

@ -49,10 +49,20 @@
; compile-time flag, no way to change at runtime ; compile-time flag, no way to change at runtime
FIRSTFILTER FIRSTFILTER
;gIsF7F6
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in analyze/SetupF7F6SecondRound
; used to avoid an expensive search
;gIsSierra13 ;gIsSierra13
!byte FALSE ; 0=true, 1=false !byte FALSE ; 0=true, 1=false
; reset before each operation ; 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 ; used to avoid an expensive search
;gIsDatasoft ;gIsDatasoft
!byte FALSE ; 0=true, 1=false !byte FALSE ; 0=true, 1=false

View File

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

View File

@ -686,6 +686,24 @@ ChangeSector
sta gAddress+1 sta gAddress+1
rts 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 ; AnalyzeTrack routine
; Looks at buffer in memory to detect known ; Looks at buffer in memory to detect known

View File

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

View File

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

View File

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