diff --git a/src/id/bootfailure.a b/src/id/bootfailure.a new file mode 100644 index 0000000..5a69a2d --- /dev/null +++ b/src/id/bootfailure.a @@ -0,0 +1,369 @@ +;------------------------------- +; 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 +; and Broderbund RW18 disks +; doubles as Infocom verification routine after ID +; triples as RW18 verification routine after ID +; written by qkumba +; +; in: nothing +; out: carry set if we can't ID it +;------------------------------- +!zone { +IDBootFailure + +VerifyInfocom18 + lda $C0E9 + lda #2 + sta modsrc + +.retry13 + ldx #$1A ; the length of a track + ldy #0 + +--- iny + bne + + dex + bne + + +.no sec + lda $C0E8 + rts + +.badsect + dec modsrc + beq .no + lda gIsInfocom18 + and gIsRW18 + beq .no ; if in Infocom/RW18 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 + ++ + jsr ReadNib +-- cmp #$D5 + bne --- + jsr ReadNib + cmp #$9D + beq .RW18 + cmp #$AA + bne -- + jsr ReadNib + cmp #$B5 ; 13-sector only + beq .build13 + cmp #$AD + bne -- + + jsr Read4x4 + lda #$12 ; all 18 sectors when in verify mode + ldx gIsInfocom18 + beq .setcount ; passport-test-suite/Trinity - Side B.woz [Z=1] here + lda #$02 ; passport-test-suite/Time Lord.woz [Z=0] here + ; only two sectors when in ID mode +.setcount + sta tmp ; sector counter + + lda #$00 +-- ldy #$56 +.x1 +- ldx $C0EC + bpl - + !if >.x1 != >* { + !serious "branch crosses a page" + } + eor $BA00,x ; from universal RWTS + dey + bne - +.x2 +- ldx $C0EC + bpl - + !if >.x2 != >* { + !serious "branch crosses a page" + } + eor $BA00,x ; from universal RWTS + iny + bne - +.x3 +- ldx $C0EC + bpl - + !if >.x3 != >* { + !serious "branch crosses a page" + } + 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 + +.RW18 + jsr .rw18pro + bne .badsect + ldx gIsRW18 + beq .verifyrw18 + sta gIsRW18 + bne .checkmode ; always taken + + ;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 + +.verifyrw18 + ldx #$06 ; six sectors, three times the usual size + stx tmp ; sector counter + bne + + +.retryrw18 + jsr ReadNib +-- cmp #$D5 + bne .retryrw18 + jsr ReadNib + cmp #$9D + bne -- + jsr .rw18pro + bne .badrw18 ++ ldy #4 +- dey + beq .badrw18 +.x4 +-- ldx $C0EC + bpl -- + !if >.x4 != >* { + !serious "branch crosses a page" + } + lda $BA00,x + eor #$A5 + bne - + sta $3A + tay +.x5 +-- ldx $C0EC + bpl -- + !if >.x5 != >* { + !serious "branch crosses a page" + } + eor $3A + eor $BA00,x + sta $2F + lda $BA00,x + asl + asl + sta $30 +.x6 +- ldx $C0EC + bpl - + !if >.x6 != >* { + !serious "branch crosses a page" + } + and #$C0 + ora $BA00,x + sta $3A + lda $30 + asl + asl +.x7 +- ldx $C0EC + bpl - + !if >.x7 != >* { + !serious "branch crosses a page" + } + sta $30 + and #$C0 + ora $BA00,x + sta $3B + lda $30 + asl +.x8 +- ldx $C0EC + bpl - + !if >.x8 != >* { + !serious "branch crosses a page" + } + asl + ora $BA00,x + eor $3B + eor $2F + iny + bne -- +.x9 +- ldx $C0EC + bpl - + !if >.x9 != >* { + !serious "branch crosses a page" + } + eor $BA00,x + eor $3A + and #$3F + bne .badrw18 + jsr ReadNib + cmp #$D4 + bne .badrw18 + dec tmp + bne .jmpretryrw18 + jmp .checkmode + +.jmpretryrw18 + jmp .retryrw18 + +.badrw18 + jmp .badsect + +.rw18pro +.x10 +-- ldx $C0EC + bpl -- + !if >.x10 != >* { + !serious "branch crosses a page" + } + lda $BA00,x ; region (half) + sta $2C +.x11 +-- ldx $C0EC + bpl -- + !if >.x11 != >* { + !serious "branch crosses a page" + } + lda $BA00,x ; region (half) + sta $2D +.x12 +-- ldx $C0EC + bpl -- + !if >.x12 != >* { + !serious "branch crosses a page" + } + lda $BA00,x ; checksum + eor $2C + eor $2D + bne + +.x13 +-- ldx $C0EC + bpl -- + !if >.x13 != >* { + !serious "branch crosses a page" + } + lda $BA00,x ; epilogue + eor #$AA ++ rts + +read13 + lda $C0E9 + lda #$1C ; retry count + sta tmp + +.readaddr + dec tmp + bmi .badread2 + clc + ldx #$02 ; 512 nibbles + ldy #0 + +.readdata + php +--- iny + bne + + dex + beq .badread1 ++ + jsr ReadNib +-- cmp #$D5 + bne --- + jsr ReadNib + cmp #$AA + bne -- + jsr ReadNib + cmp #$B5 + bne + + ldy #$03 +.x14 +-- lda $C0EC + bpl -- + !if >.x14 != >* { + !serious "branch crosses a page" + } + rol + sta $3C +.x15 +- lda $C0EC + bpl - + !if >.x15 != >* { + !serious "branch crosses a page" + } + and $3C + dey + bne -- + plp + cmp gSector + bne .readaddr + bcs .readdata ++ plp + bcc .readaddr + eor #$AD + bne .readaddr +-- ldy #$9A +.x16 +- ldx $C0EC + bpl - + !if >.x16 != >* { + !serious "branch crosses a page" + } + eor $800,x + dey + bne - +.x17 +- ldx $C0EC + bpl - + !if >.x17 != >* { + !serious "branch crosses a page" + } + eor $800,x + iny + bne - +.x18 +- ldx $C0EC + bpl - + !if >.x18 != >* { + !serious "branch crosses a page" + } + eor $800,x + cmp #$01 ; set carry if non-zero + !byte $2c +.badread1 + plp +.badread2 + sec + lda $C0E8 + rts +} diff --git a/src/id/inspect0.a b/src/id/inspect0.a index 70eaf65..26a860b 100755 --- a/src/id/inspect0.a +++ b/src/id/inspect0.a @@ -327,376 +327,6 @@ IDBootloader + jmp UseUniversal } -;------------------------------- -; 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 -; and Broderbund RW18 disks -; doubles as Infocom verification routine after ID -; triples as RW18 verification routine after ID -; written by qkumba -; -; in: nothing -; out: carry set if we can't ID it -;------------------------------- -!zone { -IDBootFailure - -VerifyInfocom18 - lda $C0E9 - lda #2 - sta modsrc - -.retry13 - ldx #$1A ; the length of a track - ldy #0 - ---- iny - bne + - dex - bne + - -.no sec - lda $C0E8 - rts - -.badsect - dec modsrc - beq .no - lda gIsInfocom18 - and gIsRW18 - beq .no ; if in Infocom/RW18 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 - -+ - jsr ReadNib --- cmp #$D5 - bne --- - jsr ReadNib - cmp #$9D - beq .RW18 - cmp #$AA - bne -- - jsr ReadNib - cmp #$B5 ; 13-sector only - beq .build13 - cmp #$AD - bne -- - - jsr Read4x4 - lda #$12 ; all 18 sectors when in verify mode - ldx gIsInfocom18 - beq .setcount ; passport-test-suite/Trinity - Side B.woz [Z=1] here - lda #$02 ; passport-test-suite/Time Lord.woz [Z=0] here - ; only two sectors when in ID mode -.setcount - sta tmp ; sector counter - - lda #$00 --- ldy #$56 -.x1 -- ldx $C0EC - bpl - - !if >.x1 != >* { - !serious "branch crosses a page" - } - eor $BA00,x ; from universal RWTS - dey - bne - -.x2 -- ldx $C0EC - bpl - - !if >.x2 != >* { - !serious "branch crosses a page" - } - eor $BA00,x ; from universal RWTS - iny - bne - -.x3 -- ldx $C0EC - bpl - - !if >.x3 != >* { - !serious "branch crosses a page" - } - 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 - -.RW18 - jsr .rw18pro - bne .badsect - ldx gIsRW18 - beq .verifyrw18 - sta gIsRW18 - bne .checkmode ; always taken - - ;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 - -.verifyrw18 - ldx #$06 ; six sectors, three times the usual size - stx tmp ; sector counter - bne + - -.retryrw18 - jsr ReadNib --- cmp #$D5 - bne .retryrw18 - jsr ReadNib - cmp #$9D - bne -- - jsr .rw18pro - bne .badrw18 -+ ldy #4 -- dey - beq .badrw18 -.x4 --- ldx $C0EC - bpl -- - !if >.x4 != >* { - !serious "branch crosses a page" - } - lda $BA00,x - eor #$A5 - bne - - sta $3A - tay -.x5 --- ldx $C0EC - bpl -- - !if >.x5 != >* { - !serious "branch crosses a page" - } - eor $3A - eor $BA00,x - sta $2F - lda $BA00,x - asl - asl - sta $30 -.x6 -- ldx $C0EC - bpl - - !if >.x6 != >* { - !serious "branch crosses a page" - } - and #$C0 - ora $BA00,x - sta $3A - lda $30 - asl - asl -.x7 -- ldx $C0EC - bpl - - !if >.x7 != >* { - !serious "branch crosses a page" - } - sta $30 - and #$C0 - ora $BA00,x - sta $3B - lda $30 - asl -.x8 -- ldx $C0EC - bpl - - !if >.x8 != >* { - !serious "branch crosses a page" - } - asl - ora $BA00,x - eor $3B - eor $2F - iny - bne -- -.x9 -- ldx $C0EC - bpl - - !if >.x9 != >* { - !serious "branch crosses a page" - } - eor $BA00,x - eor $3A - and #$3F - bne .badrw18 - jsr ReadNib - cmp #$D4 - bne .badrw18 - dec tmp - bne .jmpretryrw18 - jmp .checkmode - -.jmpretryrw18 - jmp .retryrw18 - -.badrw18 - jmp .badsect - -.rw18pro -.x10 --- ldx $C0EC - bpl -- - !if >.x10 != >* { - !serious "branch crosses a page" - } - lda $BA00,x ; region (half) - sta $2C -.x11 --- ldx $C0EC - bpl -- - !if >.x11 != >* { - !serious "branch crosses a page" - } - lda $BA00,x ; region (half) - sta $2D -.x12 --- ldx $C0EC - bpl -- - !if >.x12 != >* { - !serious "branch crosses a page" - } - lda $BA00,x ; checksum - eor $2C - eor $2D - bne + -.x13 --- ldx $C0EC - bpl -- - !if >.x13 != >* { - !serious "branch crosses a page" - } - lda $BA00,x ; epilogue - eor #$AA -+ rts - -read13 - lda $C0E9 - lda #$1C ; retry count - sta tmp - -.readaddr - dec tmp - bmi .badread2 - clc - ldx #$02 ; 512 nibbles - ldy #0 - -.readdata - php ---- iny - bne + - dex - beq .badread1 -+ - jsr ReadNib --- cmp #$D5 - bne --- - jsr ReadNib - cmp #$AA - bne -- - jsr ReadNib - cmp #$B5 - bne + - ldy #$03 -.x14 --- lda $C0EC - bpl -- - !if >.x14 != >* { - !serious "branch crosses a page" - } - rol - sta $3C -.x15 -- lda $C0EC - bpl - - !if >.x15 != >* { - !serious "branch crosses a page" - } - and $3C - dey - bne -- - plp - cmp gSector - bne .readaddr - bcs .readdata -+ plp - bcc .readaddr - eor #$AD - bne .readaddr --- ldy #$9A -.x16 -- ldx $C0EC - bpl - - !if >.x16 != >* { - !serious "branch crosses a page" - } - eor $800,x - dey - bne - -.x17 -- ldx $C0EC - bpl - - !if >.x17 != >* { - !serious "branch crosses a page" - } - eor $800,x - iny - bne - -.x18 -- ldx $C0EC - bpl - - !if >.x18 != >* { - !serious "branch crosses a page" - } - eor $800,x - cmp #$01 ; set carry if non-zero - !byte $2c -.badread1 - plp -.badread2 - sec - lda $C0E8 - rts -} - !zone { PrereadT00 lda #$0F diff --git a/src/passport.a b/src/passport.a index 20e8ae9..5bccead 100755 --- a/src/passport.a +++ b/src/passport.a @@ -436,6 +436,8 @@ _byte_hi = * + 2 _byte_skip_hi: rts + !source "id/bootfailure.a" + AnalyzeT00 ; placeholder to identify stack of packed data !bin "../build/t00only.pak" !source "apicode.a" @@ -481,4 +483,5 @@ LastMover !warn "HardDiskArray=",HardDiskArray !warn "ThisSlot=",ThisSlot !warn "CheckCache=",CheckCache + !warn "IDBootFailure=",IDBootFailure } diff --git a/src/strings/en.a b/src/strings/en.a index 0a360d5..be86db1 100755 --- a/src/strings/en.a +++ b/src/strings/en.a @@ -166,6 +166,8 @@ StringTableLow !byte <.x555 !byte <.erasingserialnumber !byte <.lockitupserial + !byte <.protection + !byte <.nodiskin StringTableHigh !byte >.header @@ -315,6 +317,8 @@ StringTableHigh !byte >.x555 !byte >.erasingserialnumber !byte >.lockitupserial + !byte >.protection + !byte >.nodiskin ; ; Text can contain substitution strings, which @@ -406,10 +410,12 @@ StringTableHigh !text "T%t,S%0 RWTS ",$00 .reasons !text "Possible reasons:",$8D,$00 +.protection + !text "protection",$00 .protectioncheck - !text "protection check",$00 + !text "@",s_protection," check",$00 .protectiontrack - !text "protection track",$00 + !text "@",s_protection," track",$00 .builtinrwts !text "built-in RWTS",$00 .thedisk @@ -420,10 +426,12 @@ StringTableHigh !text "accepts any value for the",$00 .addressepilogue !text "address epilogue ",$00 +.nodiskin + !text "- There is no disk in ",$00 .erasingserialnumber !text "T%t,S%0 Erasing serial number %1%2%3",$00 .lockitup - !text "@",s_found,"Lock-It-Up protection",$8D + !text "@",s_found,"Lock-It-Up @",s_protection,$8D !text "T00,S0A @",s_maybeunreadable,$8D,$00 .sunburst !text "@",s_found,"Sunburst disk",$8D @@ -458,14 +466,14 @@ StringTableHigh !text "@",s_reasons !text "- The source disk is not copy protected." !text "- The target disk works without patches." - !text "- @",s_thedisk,"uses an unknown protection,",$8D + !text "- @",s_thedisk,"uses an unknown @",s_protection,",",$8D !text " and @",s_passport,"can not help any further.",$8D,$00 .fail !byte $8D !text "T%t,S%s Fatal read error",$8D,$8D,$00 .fatal0000 !text "@",s_reasons - !text "- There is no disk in S6,D1.",$8D + !text "@",s_nodiskin,"S6,D1.",$8D !text "- It is not an Apple ][ disk.",$8D !text "- @",s_thedisk,"is unformatted.",$8D,$8D,$00 .fatal220f @@ -490,7 +498,7 @@ StringTableHigh ; .writeioerr !text "@",s_reasons,$8D - !text "- There is no disk in S%S,D%D.",$8D + !text "@",s_nodiskin,"S%S,D%D.",$8D !text "- @",s_thedisk,"has bad sectors.",$8D !text "- @",s_thedisk,"is unformatted.",$8D,$8D,$00 ; @@ -619,7 +627,7 @@ StringTableHigh .eatrk6 !text "@",s_tfound,"extra wide @",s_protectiontrack,$8D,$00 .poke - !text "T%t,S%0 BASIC program POKEs protection",$8D + !text "T%t,S%0 BASIC program POKEs @",s_protection,$8D !text "check into memory and CALLs it",$8D,$00 .bootcounter !text "T%t,S%0 Original disk destroys itself",$8D @@ -714,7 +722,7 @@ StringTableHigh .diskvol0x !text "T%t,S%0 Disk requires volume number 0%1",$8D,$00 .e7everywhere - !text "@",s_found,"E7 Everywhere protection",$8D,$00 + !text "@",s_found,"E7 Everywhere @",s_protection,$8D,$00 .choplifter !text "Roland was here, but he left...",$8D,$00 .pdi diff --git a/src/strings/enid.a b/src/strings/enid.a index c29a06d..7a9a0f4 100644 --- a/src/strings/enid.a +++ b/src/strings/enid.a @@ -149,3 +149,5 @@ s_rw18 = $8F s_555 = $90 s_erasingserialnumber = $91 s_lockitupserial = $92 +s_protection = $93 +s_nodiskin = $94