support some Sierra 13-sector protections

This commit is contained in:
Peter Ferrie 2017-12-02 13:07:38 -08:00
parent d07c4e3ebb
commit a243c97f68
5 changed files with 139 additions and 32 deletions

View File

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

View File

@ -79,9 +79,10 @@ gIsMilliken1 = gIs8b3-$01 ; byte
gAdventureInternational = gIsMilliken1-$01 ; byte
gIsLaureate = gAdventureInternational-$01 ; byte
gIsDatasoft = gIsLaureate-$01 ; byte
gIsSierra13 = gIsDatasoft-$01 ; byte
;LASTFILTER ; add new gIs* above this line
gOnAClearDayYouCanReadForever = gIsDatasoft-$01 ; byte
gOnAClearDayYouCanReadForever = gIsSierra13-$01 ; byte
gUsingRAMDisk = gOnAClearDayYouCanReadForever-$01 ; byte
gRAMDiskRef = gUsingRAMDisk-$01 ; byte
gDisplayBytes = gRAMDiskRef-$0A ; 10 bytes
@ -139,6 +140,7 @@ ConstructStandardDelivery = jConstructStandardDelivery
!warn "gAdventureInternational=",gAdventureInternational
!warn "gIsLaureate=",gIsLaureate
!warn "gIsDatasoft=",gIsDatasoft
!warn "gIsSierra13=",gIsSierra13
!warn "gOnAClearDayYouCanReadForever=",gOnAClearDayYouCanReadForever
!warn "gUsingRAMDisk=",gUsingRAMDisk
!warn "gRAMDiskRef=",gRAMDiskRef

View File

@ -352,53 +352,51 @@ checksector
jsr SwitchToUniv
+ jsr ReadSector
bcc nextsector
pla
pha
;
; Uh oh, we got a read error. But do we care?
; Maybe we marked this sector as optional based
; on markers in the bootloader.
;
cmp #kSectorOptional
beq .optional
;
; (13-sector only)
; If we just got to this track, check for whole-track protections.
;
ldx #$0F ;16-sector
lda gIsDOS32
bne +
lda gSector
cmp #$0C
beq .tryskip
;
; If we're in the middle of a track, try switching to the
; universal RWTS and see if that helps. (Many disks contain
; an RWTS that can't read the early tracks or sectors that
; contain the RWTS code, since those are loaded by the
; disk controller firmware.)
;
+ lda gSector
cmp #$0F
bne .tryuniversal
;
; We just got to this track, so check for a variety
; of whole-track conditions that might indicate we should
; just skip the entire track
.tryskip
sta .sub+1
ldx #$0C ;13-sector
+ cpx gSector
bne .checkoptional
stx .sub+1
jsr SkipTrack
bcs .tryuniversal
bcs .checkoptional
; Skip this track (we already printed the reason)
lda #$00
jsr ChangeSector
lda checksector+1
sec
.sub sbc #$0F
.sub sbc #$0F ;self-modified according to sectors per track
sta checksector+1
bcs +
dec checksector+2
+ jmp nextsector
; do this only *after* checking for track-skip
; to avoid fatal errors on unformatted tracks
.checkoptional
pla
pha
;
; Maybe we marked this sector as optional based
; on markers in the bootloader.
;
cmp #kSectorOptional
beq .optional
;
; Otherwise we're in the middle of a track, so try switching to
; the universal RWTS and see if that helps. (Many disks contain
; an RWTS that can't read the early tracks or sectors that
; contain the RWTS code, since those are loaded by the
; disk controller firmware.)
;
.tryuniversal
lda gIsDOS32 ; is this a DOS 3.2 disk?
beq .fatal ; yes, so read error is fatal
@ -699,6 +697,7 @@ _applyToAll
!source "patchers/jmpb4bb.a" ; T02 only
!source "patchers/dos32muse.a" ; T01 && gIsDOS32 only
!source "patchers/sra.a" ; gIsDOS32 or gIsRWTS only
!source "patchers/sierra13.a" ; gIsDOS32 only
lda gPatchCount
beq .nopatches

101
src/patchers/sierra13.a Normal file
View File

@ -0,0 +1,101 @@
;-------------------------------
; #SIERRA13
; search and disable a self-decrypting
; protection check used on some Sierra
; disks
;
; Cranston Manor
; Jawbreaker ][
; Missile Defense
; Pegasus ][
; Threshold
;
; module by qkumba
;-------------------------------
!zone {
lda gIsDOS32
bne .jmpexit
;Cranston Manor/Wizard and the Princess
;secondary protection
ldy #10
jsr SearchTrack
!byte $A9,$24 ;LDA #$24
!byte $8D,$1E,$B9 ;STA $B91E
!byte $A9,$00 ;LDA #$00
!byte $8D,$7F,$89 ;STA $897F
bcs +
inx
inx ;patch the STA
ldy #$01
jsr modify
!byte $AD ;LDA
jmp .exit
;Missile Defense
+ ldy #17
jsr SearchTrack
!byte $20,$00,$8F ;JSR $8F00
!byte $20,$00,$90 ;JSR $9000
!byte $20,$00,$8F ;JSR $8F00
!byte $A9,$00 ;LDA #$00
!byte $85,$03 ;STA $03
!byte $A9,$20 ;LDA #$20
!byte $85,$02 ;STA $02
bcs +
pha
lda #s_sierra
jsr PrintByID
pla
inx
inx
inx ;patch the second JSR
ldy #$01
jsr modify
!byte $2C ;LDA
jmp .exit
;Cranston Manor, etc.
+ ldy #14
jsr SearchTrack
!byte $A0,$00 ;LDY #$00
!byte $A9,$55 ;LDA #$55
!byte $59,WILDCARD,WILDCARD ;EOR $xxxx,Y
!byte $99,WILDCARD,WILDCARD ;STA $xxxx,Y
!byte $88 ;DEY
!byte $D0,$F5 ;BNE *-9
!byte $EA ;NOP
bcs .exit
cpx #$50
bcc +
tay
dey ;Pegasus code spans pages
tya
clc
+ sta .adjust+1
adc #BASEPAGE
pha
lda #s_sierra
jsr PrintByID
pla
ldy #8
jsr SearchSector
!byte $85,WILDCARD ;encoded BNE *+xx
!byte $DD ;encoded DEY
!byte WILDCARD,$A0 ;encoded Bxx *-9
!byte $E8,$DD,$95 ;encoded LDA $C088,X
bcs .exit
inx
.adjust lda #$d1
ldy #$01
jsr modify
!byte $55 ;encoded zero
lda #TRUE
sta gIsSierra13
.exit
}

View File

@ -134,7 +134,7 @@ StringTable
; can be set directly before calling PrintByID.
;
.header
!text "Passport by 4am 2017-11-25",$00
!text "Passport by 4am 2017-12-02",$00
.mainmenu
!text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D
!text " "