passport/src/id/inspect0.a

316 lines
7.9 KiB
Plaintext
Executable File

;-------------------------------
; IDBootloader
; main entry point to identify the bootloader
; and exit via the appropriate tracer/copier
;
; in: T00,S00 in memory at $0800
;-------------------------------
!zone {
IDBootloader
;
; Reset all per-disk globals.
; These are used as filters later so irrelevant patchers can be skipped.
;
lda #FALSE
sta gIsDOS32
sta gIsBoot0
sta gIsBoot1
sta gIsMaster
sta gIsRWTS
sta gIsProDOS
sta gIsPascal
sta gIsProtDOS
sta gIsDavidDOS
sta gIsEA
sta gIsMECCFastloader
sta gPossibleGamco
sta gPossibleD5D5F7
sta gAdventureInternational
lda #$00
sta gLastTrack
;
; Quick sanity check -- only recognized values for $0800
; are 1 or 2 for regular disks, and 5 for possible Electronic Arts.
;
lda $0800
beq +
cmp #$03
bcc .sane
cmp #$05
beq .sane
+ jmp UseUniversal
.sane
;
; Copy the boot sector from $0800 to the track/sector buffer
; so we can reuse our standard compare functions.
;
lda #$08
ldx #BASEPAGE
ldy #$01
jsr CopyMemory
;
; Try to identify DOS 3.3-shaped bootloader.
; Exit via custom trace function if found.
;
jsr IDDOS33
bcs .notdos33
lda #TRUE
sta gIsBoot0
jsr IDD5D5F7
bcs +
lda #TRUE
sta gPossibleD5D5F7
+ jsr IDDiversi
bcc .diversi
jsr IDPronto
bcc .pronto
lda #s_dosb0
!byte $2c
.diversi
lda #s_diversidos
!byte $2c
.pronto
lda #s_prontodos
jsr PrintByID
jmp TraceDOS33
;
; Try to identify a variant bootloader that calls to $08B3
; early to munge the nibble tables used by the drive firmware.
; Exit via custom trace function if found.
;
.notdos33
jsr ID8b3
bcs +
lda #s_jsr8b3
jsr PrintByID
jmp Trace8B3
;
; Try to identify all the different MECC fastloader variants.
; Exit via custom trace function if found.
;
+ jsr IDMECC
bcs .notmecc
lda #TRUE
sta gIsMECCFastloader
lda #s_mecc
jsr PrintByID
jsr PrereadT00
bcs .notmecc
jsr IDMECC1
bcs +
jmp foundmecc1
+ jsr IDMECC2
bcs +
jmp foundmecc2
+ jsr IDMECC3
bcs +
jmp foundmecc3
+ jsr IDMECC4
bcs .notmecc
jmp foundmecc4
.notmecc
;
; Try to identify DOS 3.3P (Special Delivery) bootloader.
; Exit via custom trace function if found.
;
jsr IDSpecDel
bcs +
lda #s_specdel
jsr PrintByID
jmp TraceSpecDel
;
; Try to identify Laureate Learning Systems bootloader.
; Exit via custom trace function if found.
;
+ jsr IDLaureate
bcs +
lda #s_laureate
jsr PrintByID
lda #$0B
jsr PrereadT00Partial
bcs +
jmp TraceLaureate
;
; Try to identify Electronic Arts bootloader.
; Exit via custom trace function if found.
;
+ jsr IDEA
bcs +
jmp foundea
;
; Try to identify hybrid 16-/13-sector bootloader on
; DOS 3.2 disks.
; Exit via custom trace function if found.
;
+ jsr IDDOS32
bcs +
lda #s_dos32b0
jsr PrintByID
jmp TraceDOS32
;
; Try to detect whether there is code in the boot sector
; that loads 4-and-4-encoded data. This is an early escape
; hatch for disks that are guaranteed to fail later anyway.
;
+ jsr IDEncoded44
bcs +
lda #s_encoded44
jsr PrintByID
jmp TheEnd
;
; Try to detect whether there is code in the boot sector
; that loads 5-and-3-encoded data (like DOS 3.2 disks with
; a hybrid boot sector that loads on 16-sector drives).
; Passport has no support for converting DOS 3.2 disks, so
; this serves as an early escape hatch for disks that are
; guaranteed to fail later anyway.
;
+ jsr IDEncoded53
bcs +
lda #s_encoded53
jsr PrintByID
jmp TheEnd
;
; ProDOS (all versions)
;
+ jsr IDProDOS
bcs +
lda #s_prodosb0
jsr PrintByID
lda #TRUE
sta gIsProDOS
beq .useuniv ; always branches
;
;Apple Pascal (all versions)
;
+ jsr IDPascal
bcs +
lda #s_pascalb0
jsr PrintByID
lda #TRUE
sta gIsPascal
beq .useuniv ; always branches
;
; David-DOS II
;
+ jsr IDDavid
bcs +
lda #s_daviddos
jsr PrintByID
lda #TRUE
sta gIsDavidDOS
beq .useuniv ; always branches
;
; Encrypted Datasoft bootloader
;
+ jsr IDDatasoft
bcs +
lda #s_datasoftb0
jsr PrintByID
bcc .useuniv ; always branches
;
; Micrograms bootloader
;
+ jsr IDMicrograms
bcs +
lda #s_micrograms
jsr PrintByID
;
; Quick-DOS
;
+ jsr IDQuickDOS
bcs +
lda #s_quickdos
jsr PrintByID
+
.useuniv
jmp UseUniversal
}
;-------------------------------
; AnalyzeT00
; set additional flags based on contents of track $00
;
; in: Track $00 in data buffer
; out: gIsBoot1, gIsMaster, gIsRWTS set to #TRUE or #FALSE
; all flags clobbered
; all registers clobbered
;-------------------------------
!zone {
AnalyzeT00
lda #$01
ldx #$00
ldy #$38
jsr compare ; if T00,S01,$00 ==
!byte $8E,$E9,$B7,$8E,$F7,$B7,$A9,$01
!byte $8D,$F8,$B7,$8D,$EA,$B7,$AD,$E0
!byte $B7,$8D,$E1,$B7,$A9,$02,$8D,$EC
!byte $B7,$A9,$04,$8D,$ED,$B7,$AC,$E7
!byte $B7,$88,$8C,$F1,$B7,$A9,$01,$8D
!byte $F4,$B7,$8A,$4A,$4A,$4A,$4A,$AA
!byte $A9,$00,$9D,$F8,$04,$9D,$78,$04
ldx #TRUE
bcc .boot1
ldx #FALSE
.boot1
stx gIsBoot1
lda #$01
ldx #$00
ldy #$38
jsr compare ; if T00,S01,$00 ==
!byte $8E,$E9,$37,$8E,$F7,$37,$A9,$01
!byte $8D,$F8,$37,$8D,$EA,$37,$AD,$E0
!byte $37,$8D,$E1,$37,$A9,$02,$8D,$EC
!byte $37,$A9,$04,$8D,$ED,$37,$AC,$E7
!byte $37,$88,$8C,$F1,$37,$A9,$01,$8D
!byte $F4,$37,$8A,$4A,$4A,$4A,$4A,$AA
!byte $A9,$00,$9D,$F8,$04,$9D,$78,$04
ldx #TRUE
bcc .master
ldx #FALSE
.master
stx gIsMaster
lda #$07
ldx #$00
ldy #$40
jsr compare ; if T00,S07,$00 ==
!byte $84,$48,$85,$49,$A0,$02,$8C,$F8
!byte $06,$A0,$04,$8C,$F8,$04,$A0,$01
!byte $B1,$48,$AA,$A0,$0F,$D1,$48,$F0
!byte $1B,$8A,$48,$B1,$48,$AA,$68,$48
!byte $91,$48,$BD,$8E,$C0,$A0,$08,$BD
!byte $8C,$C0,$DD,$8C,$C0,$D0,$F6,$88
!byte $D0,$F8,$68,$AA,$BD,$8E,$C0,$BD
!byte $8C,$C0,$A0,$08,$BD,$8C,$C0,$48
ldx #TRUE
bcc .rwts
ldx #FALSE
.rwts
stx gIsRWTS
rts
}
!zone {
PrereadT00
lda #$0F
PrereadT00Partial
sta gSector
clc
adc #BASEPAGE
sta gAddress+1
lda #$00
sta gTrack
sta gAddress
- jsr ReadSector
bcs .exit
dec gAddress+1
dec gSector
bne -
.exit
rts
}