passport/src/id/inspect0.a

429 lines
10 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
;-------------------------------
IDBootloader
;
; Reset all per-disk globals.
; Some of these are used as filters later so irrelevant patchers can be skipped.
;
ldx #(LASTFILTER-FIRSTFILTER)
lda #FALSE
- sta FIRSTFILTER-1, x
dex
bne -
; X = 0
stx gMECCFastloadType
stx gLastTrack
txa
; A = 0
ldx #9
- sta gDisplayBytes, x
dex
bpl -
ldx #$0F
ldy #$F8
- tya
sta precheck_sectors, x
iny
dex
bpl -
lda #s_infocom18
ldx gIsInfocom18
beq .printinfo
lda #s_rw18
ldx gIsRW18
beq .printinfo
.check13
lda gIs13Sector
bne .sanity
lda #s_13sector
.printinfo
sta +
jsr PrintByID
+ !byte $FD ; SMC
jmp UseUniversal
.sanity
;
; Quick sanity check -- only recognized values for $0800 are
; $00 = some Enlightenment disks
; $01 = most disks
; $02 = Special Delivery (DOS 3.3P)
; $05 = some EA disks
;
lda $0800
beq +
cmp #$03
bcc .sane
cmp #$05
beq .sane
- jmp UseUniversal
+
;
; Try to identify Enlightenment bootloader.
; (in none; out none)
;
+IDEnlightenment
bcs -
lda #TRUE
sta gIsEnlightenment
jsr PrintByID
!byte s_enlightenmentb0
bvc - ; always branches
.sane
;
; Copy the boot sector from $0800 to the track/sector buffer
; so we can reuse our standard compare functions.
;
lda #$08
ldx #BASEPAGE
jsr CopyMemory1 ; exits with X=0
;
; Try to identify DOS 3.3-shaped bootloader.
; Exit via custom trace function if found.
; (in X=0; out A=0)
;
jsr IDDOS33
bcs .notdos33
sta gIsBoot0 ; A = 0 (TRUE)
;
; Try to identify Diversi-DOS
; (in A=0; out A=0)
;
+IDDiversi
ldx #s_diversidos
bcc .printdos
;
; Try to identify Pronto-DOS
; (in A=0; out A=0)
;
+IDPronto
ldx #s_prontodos
bcc .printdos
ldx #s_dosb0
.printdos
stx +
jsr PrintByID
+ !byte $FD ; SMC
jmp TraceDOS33
.notdos33
;
; Try to identify Laureate Learning Systems bootloader.
; Exit via custom trace function if found.
; (in A=0; out A=0)
;
+IDLaureate
bcs .notLaureate
jsr PrintByID
!byte s_laureate
sta gIsLaureate ; A = 0 (TRUE)
lda #$0B
jsr PrereadT00Partial
bcs .notLaureate
jmp TraceLaureate
.notLaureate
;
; 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.
; (in A=0; out A=0,X=0)
;
+ID8b3
bcs .not8b3
jsr PrintByID
!byte s_jsr8b3
sta gIs8b3 ; A = 0 (TRUE)
jmp Trace8B3
.not8b3
;
; Try to identify a bootloader that loads several sectors
; into the text page before loading a non-standard RWTS in
; higher memory.
; Exit via custom trace function if found.
;
+IDJMP600
bcs .notjmp600
jsr PrintByID
!byte s_jmp600
sta gIsJMP600 ; A = 0 (TRUE)
jmp FoundJMP600
.notjmp600
;
; Try to identify all the different MECC fastloader variants.
; Exit via custom trace function if found.
; (in A=0,X=0; out A=0,X=0)
;
+IDMECC
bcs .notmecc
lda #ID_MECC_UNK
sta gMECCFastloadType
jsr PrintByID
!byte s_mecc
jsr PrereadT00
bcs .notmecc
jsr IDMECC1
bcs +
lda #ID_MECC1
sta gMECCFastloadType
jmp foundmecc1
+ jsr IDMECC2
bcs +
lda #ID_MECC2
sta gMECCFastloadType
jmp foundmecc2
+ jsr IDMECC3
bcs +
lda #ID_MECC3
sta gMECCFastloadType
jmp foundmecc3
+ jsr IDMECC4
bcs .notmecc
lda #ID_MECC4
sta gMECCFastloadType
jmp foundmecc4
.notmecc
;
; Try to identify encrypted Datasoft bootloader
; (in A=0,X=0; out A=0,X=0)
;
+IDDatasoft
bcs .notDatasoft
jsr PrintByID
!byte s_datasoftb0
sta gIsDatasoft ; A = 0 (TRUE)
; /!\ execution falls through here
.notDatasoft
;
; Try to identify RDOS 16-sector bootloader
; (in A=0,X=0; out A=0,X=0)
;
+IDRDOS16
bcs .notRDOS16
jsr PrintByID
!byte s_rdos
; /!\ execution falls through here
.notRDOS16
;
; David-DOS II
; (in A=0,X=0; out A=0,X=0)
;
+IDDavid
bcs .notDavid
jsr PrintByID
!byte s_daviddos
sta gIsDavidDOS ; A = 0 (TRUE)
; /!\ execution falls through here
.notDavid
;
; TSR bootloader
; (in A=0,X=0; out A=0,X=0)
;
+IDTSR
bcs .notTSR
jsr PrintByID
!byte s_tsr
sta gIsTSR ; A = 0 (TRUE)
; /!\ execution falls through here
.notTSR
;
; Micrograms bootloader
; (in A=0,X=0; out A=0,X=0)
;
+IDMicrograms
bcs .notMicrograms
jsr PrintByID
!byte s_micrograms
; /!\ execution falls through here
.notMicrograms
;
; Quick-DOS
; (in A=0,X=0; out A=0,X=0)
;
+IDQuickDOS
bcs .notQuickDOS
jsr PrintByID
!byte s_quickdos
; /!\ execution falls through here
.notQuickDOS
;
; Dav Holle encrypted bootloader
; (in A=0,X=0; out A=0,X=0)
;
+IDHolle
bcs .notHolle
jsr PrintByID
!byte s_holle
sta gIsHolle ; A = 0 (TRUE)
; /!\ execution falls through here
.notHolle
;
; Try to identify Electronic Arts bootloader.
; Exit via custom trace function if found.
; (in A=0,X=0; out A=0,X=0)
;
+IDEA
bcs .notEA
jmp foundea
.notEA
;
; Try to identify hybrid 16-/13-sector bootloader.
; Exit via custom trace function if found.
; (in A=0,X=0; out A=0,X=0)
;
+IDDOS32
bcs .notDOS32
jsr PrintByID
!byte s_dos32b0
jmp TraceDOS32
.notDOS32
;
; Try to identify DOS 3.3P (Special Delivery) bootloader.
; Exit via custom trace function if found.
; (in A=0,X=0; out A=0,X=0)
;
+IDSpecDel
bcs .notSpecialDelivery
jsr PrintByID
!byte s_specdel
jmp TraceSpecDel
.notSpecialDelivery
;
; Try to identify hybrid 16-/13-sector bootloader (variant
; that loads into $3600 then relocates).
; Exit via custom trace function if found.
; (in A=0,X=0; out A=0,X=0)
+IDDOS32LO
bcs .notDOS32LO
jsr PrintByID
!byte s_dos32b0
jmp TraceDOS32LO
.notDOS32LO
;
; ProDOS (all versions)
; (in A=0,X=0; out none [after jsr IDVolumeName])
;
+IDProDOS
bcs .notProDOS
jsr PrintByID
!byte s_prodosb0
sta gIsProDOS ; A = 0 (TRUE)
jsr IDVolumeName
; /!\ execution falls through here because Dinkey-DOS disks are also ProDOS
;
; Dinkey-DOS (ProDOS file structure with DOS 3.3-ish RWTS in language card)
; detectable now because IDVolumeName just read the first sector of the
; volume directory into memory so we can look for a unique filename
; (in none; out none)
;
+IDDinkeyDOS
bcs .notDinkey
sta gDisplayBytes ; A = #$0B
jsr PrintByID
!byte s_dinkeydos
lda #TRUE
sta gIsDinkeyDOS
; /!\ execution falls through here to save bytes (no other IDs will match)
.notProDOS
.notDinkey
;
; Apple Pascal (all versions)
; (in none; out none [after jsr IDVolumeName])
;
+IDPascal
bcs .notPascal
jsr PrintByID
!byte s_pascalb0
sta gIsPascal ; A = 0 (TRUE)
jsr IDVolumeName
; /!\ execution falls through here
.notPascal
;
; Try to identify Interplay bootloader.
; Exit via custom trace function if found.
; (in none; out none)
;
+IDAdvent
bcs .notInterplay
jmp foundadvent
.notInterplay
;
; Try to identify Baudville bootloader.
; (in none; out none)
;
+IDBaudville
bcs .notBaudville
jsr PrintByID
!byte s_baudville
lda #TRUE
sta gIsBaudville
.notBaudville
;
; 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 will fail later anyway.
; (in none; out none)
;
+IDEncoded44
bcs .not44
jsr PrintByID
!byte s_encoded44
jmp TheEnd
.not44
;
; Try to detect whether there is code in the boot sector
; that loads 5-and-3-encoded data. If the earlier DOS 3.2
; identification failed, we will have no way to read the disk
; (the universal RWTS only works on 6-and-2 encoded data), so
; this serves as an early escape hatch for disks that will
; fail later anyway.
; (in none; out none)
;
+IDEncoded53
bcs .not53
jsr PrintByID
!byte s_encoded53
jmp TheEnd
.not53
;
; 5-5-5 spiral bootloader
; (in none; out none)
;
+ID555
bcs .not555
lda #0
sta gDisplayBytes
jsr PrintByID
!byte s_555
jmp Do555
.not555
jmp UseUniversal
PrereadT00
lda #$0F
PrereadT00Partial
sta gSector
clc
adc #BASEPAGE
sta gAddress+1
lda #$00
sta gTrack
sta gAddress
- jsr ReadSector
bcs +
dec gAddress+1
dec gSector
bne -
+ rts