passport/src/id/dos33.a
2021-06-21 11:57:02 -04:00

137 lines
4.3 KiB
Plaintext
Executable File

;-------------------------------
; IDDOS33
; identify DOS 3.3 bootloader or some variation
; that can be safely boot traced
;
; in: $0800..$08FF contains T00,S00
; first page of track buffer also contains T00,S00
; X = 0
; out: C clear if traceable DOS 3.3-style bootloader found
; C set otherwise
; A = 0
; all other registers & flags clobbered
;-------------------------------
IDDOS33
;
; $08FE must be either $B6 (standard) or $20..$36
; ($36 is a master DOS that relocates itself later.
; Others like $22 are used by early Infocom games.)
; Must weed out some Infocom and TLC disks that would
; load over program space and crash.
;
txa
ldy $08FE
cpy #$B6
beq @ok08FE ; passport-test-suite/Binomial Multiplication.woz [Z=1] here, loads at $B600
cpy #$37
bcc + ; passport-test-suite/Beach-Head.woz [C=0] here, loads at $3F00
@fail sec
rts
+ cpy #$20
bcc @fail ; passport-test-suite/Alf.woz [C=0] here, loads at $1300
@ok08FE
;
; Code at $0800 must be standard (with one exception)
;
ldy #$3F
jsr compare ; if T00,S00,$00 ==
!byte $01
!byte $A5,$27
!byte $C9,$09
!byte $D0,$18
!byte $A5,$2B
!byte $4A
!byte $4A
!byte $4A
!byte $4A
!byte $09,$C0
!byte $85,$3F
!byte $A9,$5C
!byte $85,$3E
!byte $18
!byte $AD,$FE,$08
!byte $6D,$FF,$08
!byte WILDCARD ; will check these later
!byte WILDCARD
!byte WILDCARD
!byte $AE,$FF,$08
!byte $30,$15
!byte $BD,$4D,$08
!byte $85,$3D
!byte $CE,$FF,$08
!byte $AD,$FE,$08
!byte $85,$27
!byte $CE,$FE,$08
!byte $A6,$2B
!byte $6C,$3E,$00
!byte $EE,$FE,$08
!byte $EE,$FE,$08
bcs @fail ; passport-test-suite/Binomial Multiplication.woz [C=0] matches
;
; DOS 3.3 and most derivatives have JSR $FE89 / JSR $FE93 / JSR $FB2F at $083F
;
ldx #$3F
ldy #$0B
jsr compare ; if T00,S00,$3F ==
!byte $20,$89,$FE
!byte $20,$93,$FE
!byte $20,$2F,$FB
!byte $A6,$2B
bcc @ok083F ; passport-test-suite/Binomial Multiplication.woz [C=0] matches
;
; Sierra variants have STA $C050 / STA $C057 / STA $C055 at $083F
;
jsr compare ; if T00,S00,$3F ==
!byte $8D,$50,$C0
!byte $8D,$57,$C0
!byte $8D,$55,$C0
!byte $A6,$2B
bcs @exit ; passport-test-suite/Leisure Suit Larry.woz [C=0] matches
; other variations -> failure
@ok083F
;
; Filter out unsupported sector order map
;
ldx #$4D
ldy #$10
jsr compare ; if T00,S00,$4D ==
!byte $00,$0D,$0B,$09,$07,$05,$03,$01
!byte WILDCARD,$0C,$0A,$08,$06,$04,$02,$0F
bcs @exit ; passport-test-suite/Pitfall II.woz [C=1] here
;
; Check for MUSE sector order map (nonstandard but supported)
;
ldy $0855
cpy #$02
bne @notMUSE ; passport-test-suite/The Function Game.woz [Z=0] matches
sta gIsMUSERWTS
ldy #$0E
sty precheck_sectors+1
ldy #kSectorIgnore
sty T00S08
sty T00S0F
@notMUSE
;
; DOS 3.3 and most derivatives have STA $08FE at $081C
;
ldx #$1C
jsr compare3 ; if T00,S00,$1C ==
!byte $8D,$FE,$08
bcc @exit ; passport-test-suite/Binomial Multiplication.woz [C=0] matches
;
; Variant jumps to $08F0 and back but is still safe to trace.
; Check for this jump and also match the code at $08F0 exactly.
;
jsr compare3 ; if T00,S00,$1C ==
!byte $4C,$F0,$08; JMP $08F0
bcs @exit ; unknown code at $081C -> failure
ldx #$F0
ldy #$09
jsr compare ; if T00,S00,$F0 ==
!byte $8D,$FE,$08
!byte $EE,$F3,$03
!byte $4C,$1F,$08
; passport-test-suite/Library Magic.woz [C=0] matches acceptable code at $08F0
; unknown code at $08F0 -> failure
@exit rts