Merge pull request #70 from peterferrie/master

verify Infocom 18-sector format
This commit is contained in:
4am 2018-12-29 12:29:46 -05:00 committed by GitHub
commit f1160b90e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 276 additions and 10 deletions

View File

@ -48,6 +48,16 @@
; instead of falling back to built-in RWTS ; instead of falling back to built-in RWTS
; compile-time flag, no way to change at runtime ; compile-time flag, no way to change at runtime
;gIs13Sector
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootFailure() after reading T00
;gIsInfocom18
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootFailure() after reading T00
;gMECCFastloadType ;gMECCFastloadType
!byte 00 ; int !byte 00 ; int
; reset before each operation ; reset before each operation

View File

@ -99,8 +99,12 @@ gIsPanglosDOS = gIsAdvent-$01 ; byte
gIsDavidson = gIsPanglosDOS-$01 ; byte gIsDavidson = gIsPanglosDOS-$01 ; byte
gIsRDOS13 = gIsDavidson-$01 ; byte gIsRDOS13 = gIsDavidson-$01 ; byte
;LASTFILTER ; add new gIs* above this line ;LASTFILTER ; add new gIs* above this line
;gIsInfocom18 is a special case whose ID is not in the regular inspection path
gIsInfocom18 = gIsRDOS13-$01 ; byte
;gIs13Sector is a special case whose ID is not in the regular inspection path
gIs13Sector = gIsInfocom18-$01 ; byte
;gMECCFastloadType is a special case integer whose default value cannot be #FALSE ;gMECCFastloadType is a special case integer whose default value cannot be #FALSE
gMECCFastloadType = gIsRDOS13-$01 ; byte gMECCFastloadType = gIs13Sector-$01 ; byte
gOnAClearDayYouCanReadForever = gMECCFastloadType-$01 ; byte gOnAClearDayYouCanReadForever = gMECCFastloadType-$01 ; byte
gUsingRAMDisk = gOnAClearDayYouCanReadForever-$01 ; byte gUsingRAMDisk = gOnAClearDayYouCanReadForever-$01 ; byte
@ -168,6 +172,8 @@ ConstructStandardDelivery = jConstructStandardDelivery
!warn "gIsPanglosDOS=",gIsPanglosDOS !warn "gIsPanglosDOS=",gIsPanglosDOS
!warn "gIsDavidson=",gIsDavidson !warn "gIsDavidson=",gIsDavidson
!warn "gIsRDOS13=",gIsRDOS13 !warn "gIsRDOS13=",gIsRDOS13
!warn "gIsInfocom18=",gIsInfocom18
!warn "gIs13Sector=",gIs13Sector
!warn "gOnAClearDayYouCanReadForever=",gOnAClearDayYouCanReadForever !warn "gOnAClearDayYouCanReadForever=",gOnAClearDayYouCanReadForever
!warn "gUsingRAMDisk=",gUsingRAMDisk !warn "gUsingRAMDisk=",gUsingRAMDisk
!warn "gRAMDiskRef=",gRAMDiskRef !warn "gRAMDiskRef=",gRAMDiskRef

View File

@ -18,6 +18,21 @@ IDBootloader
bne - bne -
stx gMECCFastloadType stx gMECCFastloadType
stx gLastTrack stx gLastTrack
lda gIsInfocom18
bne .check13
lda #s_infocom18
jsr PrintByID
jmp UseUniversal
.check13
lda gIs13Sector
bne .sanity
lda #s_13sector
jsr PrintByID
jmp UseUniversal
.sanity
; ;
; Quick sanity check -- only recognized values for $0800 ; Quick sanity check -- only recognized values for $0800
; are 1 or 2 for regular disks, and 5 for possible Electronic Arts. ; are 1 or 2 for regular disks, and 5 for possible Electronic Arts.
@ -288,3 +303,195 @@ PrereadT00Partial
.exit .exit
rts rts
} }
;-------------------------------
; IDBootFailure
; main entry point to identify the bootloader
; when the initial read failed
; identifies Infocom 18-sector side B disks
; and pure 13-sector disks
; doubles as Infocom verification routine after ID
; written by qkumba
;
; in: nothing
; out: carry set if we can't ID it
;-------------------------------
!zone {
IDBootFailure
VerifyInfocom18
lda $C0E9
.retry13
ldx #$1A ; the length of a track
ldy #0
--- iny
bne +
dex
bne +
.no sec
lda $C0E8
rts
.badsect
lda gIsInfocom18
beq .no ; if in Infocom mode already then we have a true failure
bne .retry13 ; otherwise, try to identify 13-sector instead
; the issue being that both have a D5 AA AD sequence
+
- lda $C0EC
bpl -
-- cmp #$D5
bne ---
- lda $C0EC
bpl -
cmp #$AA
bne --
- lda $C0EC
bpl -
cmp #$B5 ; 13-sector only
beq .build13
cmp #$AD
bne --
- lda $C0EC
bpl -
nop
nop ; ignore half of 4x4 track number
- lda $C0EC
bpl - ; ignore half of 4x4 track number
lda #$12 ; all 18 sectors when in verify mode
ldx gIsInfocom18
beq .setcount
lda #$01 ; only one sector when in ID mode
.setcount
sta tmp ; sector counter
lda #$00
-- ldy #$56
- ldx $C0EC
bpl -
eor $BA00,x ; from universal RWTS
dey
bne -
- ldx $C0EC
bpl -
eor $BA00,x ; from universal RWTS
iny
bne -
- ldx $C0EC
bpl -
eor $BA00,x ; from universal RWTS
bne .badsect
dec tmp
bne --
sta gIsInfocom18
.checkmode
bit gMode ; verify-mode already?
bpl + ; yes, continue
lda #%00000000 ;
sta gMode ; no, switch to verify-mode
lda #s_toverify
jsr PrintByID ; and say so
+ clc ; all clear
lda $C0E8
rts
;build 5-and-3 decoding table
;for 13-sector support
.build13
ldx #$00
ldy #$AB
- tya
sta tmp
lsr
ora tmp
cmp #$FF
bne +
cpy #$D5
beq +
txa
sta $800,y
inx
+ iny
bne -
sty gIs13Sector
beq .checkmode ; always taken
read13
lda $C0E9
lda #$1C ; retry count
sta tmp
.readaddr
dec tmp
bmi .badread
clc
ldx #$02 ; 512 nibbles
ldy #0
.readdata
php
--- iny
bne +
dex
beq .badread
+
- lda $C0EC
bpl -
-- cmp #$D5
bne ---
- lda $C0EC
bpl -
cmp #$AA
bne --
- lda $C0EC
bpl -
cmp #$B5
bne +
ldy #$03
-- lda $C0EC
bpl --
rol
sta $3C
- lda $C0EC
bpl -
and $3C
dey
bne --
plp
cmp gSector
bne .readaddr
bcs .readdata
+ plp
bcc .readaddr
eor #$AD
bne read13
-- ldy #$9A
- ldx $C0EC
bpl -
eor $800,x
dey
bne -
- ldx $C0EC
bpl -
eor $800,x
iny
bne -
- ldx $C0EC
bpl -
eor $800,x
cmp #$01 ; set carry if non-zero
!byte $24
.badread
sec
lda $C0E8
rts
}

View File

@ -254,6 +254,8 @@ Reaction
sta gTriedUniv sta gTriedUniv
sta gSaidWriting sta gSaidWriting
sta gIsProtDOS sta gIsProtDOS
sta gIsInfocom18
sta gIs13Sector
lda #$00 lda #$00
sta gTrack sta gTrack
sta gSector sta gSector
@ -274,6 +276,8 @@ Reaction
jsr IgnoreAddressChecksum jsr IgnoreAddressChecksum
jsr ReadSector jsr ReadSector
bcc + bcc +
jsr IDBootFailure ; /src/id/inspect0
bcc +
lda #s_fail lda #s_fail
jsr PrintByID jsr PrintByID
lda #s_fatal0000 lda #s_fatal0000
@ -339,6 +343,17 @@ UseUniversal
jsr PatchUniversalRWTSForOrigin jsr PatchUniversalRWTSForOrigin
bmi ReadWithRWTS ; always branches bmi ReadWithRWTS ; always branches
; ;
; On pure 13-sector disks, we just hijack the read routine to perform a
; verification instead.
;
+ lda gIs13Sector
bne +
lda #<read13
sta jCallRWTS+1
lda #>read13
sta jCallRWTS+2
bne ReadWithRWTS ; always branches
;
; On other disks that use the universal RWTS for the entire disk, we use ; On other disks that use the universal RWTS for the entire disk, we use
; an adaptive RWTS that accepts any epilogue on the first sector but then ; an adaptive RWTS that accepts any epilogue on the first sector but then
; enforces all other sectors to have the same epilogue. ; enforces all other sectors to have the same epilogue.
@ -368,18 +383,30 @@ ReadWithRWTS
lda #$22 lda #$22
jsr ChangeTrackNW jsr ChangeTrackNW
lda #$0F lda #$0F
jsr ChangeSector ldx gIs13Sector
bne +
lda #$0C
+ jsr ChangeSector
lda #<T22S0F lda #<T22S0F
sta checksector+1 sta checksector+1
lda #>T22S0F lda #>T22S0F
sta checksector+2 sta checksector+2
.read .read
lda KEY lda KEY
bpl checksector bpl .checkinfocom
bit STROBE bit STROBE
cmp #$e0 ;ignore backtick (MAME debug break) cmp #$e0 ;ignore backtick (MAME debug break)
beq checksector beq .checkinfocom
jmp Cancel jmp Cancel
.checkinfocom
lda gIsInfocom18
bne checksector
jsr VerifyInfocom18
bcc .passtrack
jmp FatalError
.passtrack
jmp .prevtrack
checksector checksector
lda $FFFF ; status of current sector in sector map (modified above) lda $FFFF ; status of current sector in sector map (modified above)
pha pha
@ -387,10 +414,8 @@ checksector
bcc + bcc +
cmp #kSectorCustomLast cmp #kSectorCustomLast
bcs + bcs +
jsr PreReadSector
tax
pla pla
txa jsr PreReadSector
pha ; replace status (on stack) with new status returned from PreReadSector pha ; replace status (on stack) with new status returned from PreReadSector
+ cmp #kSectorIgnore ; skip this sector? + cmp #kSectorIgnore ; skip this sector?
beq nextsector beq nextsector
@ -406,8 +431,11 @@ checksector
; If we just got to this track, check for whole-track protections. ; If we just got to this track, check for whole-track protections.
; ;
ldx #$0F ;16-sector ldx #$0F ;16-sector
lda gIs13Sector
beq .expect13
lda gIsDOS32 lda gIsDOS32
bne + bne +
.expect13
ldx #$0C ;13-sector ldx #$0C ;13-sector
+ cpx gSector + cpx gSector
bne .checkoptional bne .checkoptional
@ -484,7 +512,10 @@ nextsector
jmp .read jmp .read
.prevtrack .prevtrack
lda #$0F lda #$0F
jsr ChangeSector ldx gIs13Sector
bne +
lda #$0C
+ jsr ChangeSector
lda gTrack lda gTrack
sec sec
sbc #$01 sbc #$01

View File

@ -123,6 +123,9 @@ StringTable
!word .rdos13 !word .rdos13
!word .ssi !word .ssi
!word .aacount !word .aacount
!word .infocom18
!word .toverify
!word .sector13
; ;
; Text can contain substitution strings, which ; Text can contain substitution strings, which
; are replaced by current values at runtime. Each ; are replaced by current values at runtime. Each
@ -148,7 +151,7 @@ StringTable
; can be set directly before calling PrintByID. ; can be set directly before calling PrintByID.
; ;
.header .header
!text "Passport by 4am 2018-10-14",$00 !text "Passport by 4am 2018-12-29",$00
.mainmenu .mainmenu
!text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D !text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D
!text " " !text " "
@ -456,4 +459,10 @@ StringTable
!text "T%t,S%0 Found SSI protection check",$8D,$00 !text "T%t,S%0 Found SSI protection check",$8D,$00
.aacount .aacount
!text "T%t,S%0 Found AA nibble count",$8D,$00 !text "T%t,S%0 Found AA nibble count",$8D,$00
.infocom18
!text "T00,S00 Found Infocom 18-sector format",$8D,$00
.toverify
!text "Switching to verify-only mode",$8D,$00
.sector13
!text "T00,S00 Found 13-sector format",$8D,$00
} }

View File

@ -109,4 +109,7 @@ s_davidson = $67
s_rdos13 = $68 s_rdos13 = $68
s_ssi = $69 s_ssi = $69
s_aacount = $6A s_aacount = $6A
STRINGCOUNT = $6B s_infocom18 = $6B
s_toverify = $6C
s_13sector = $6D
STRINGCOUNT = $6E