mirror of
https://github.com/a2-4am/passport.git
synced 2024-05-28 21:41:27 +00:00
446 lines
12 KiB
Plaintext
Executable File
446 lines
12 KiB
Plaintext
Executable File
;-------------------------------
|
|
; TraceDOS33
|
|
; set up 1st-level boot trace on
|
|
; a DOS 3.3-shaped bootloader
|
|
;-------------------------------
|
|
!zone {
|
|
TraceDOS33
|
|
jsr PreCheckT00 ; does not return on failure
|
|
|
|
lda $08FE
|
|
bmi + ; if we're about to trace a DOS that loads at $3600,
|
|
jsr MoveT00PakHigh ; move our packed T00 modules out of the way first
|
|
+
|
|
lda #<TraceDOS33b
|
|
ldx #>TraceDOS33b
|
|
jmp Trace
|
|
|
|
MaybeB6 !byte 0
|
|
MaybeB7 !byte 0
|
|
MaybeB8 !byte 0
|
|
MaybeB9 !byte 0
|
|
MaybeBA !byte 0
|
|
MaybeBB !byte 0
|
|
MaybeBC !byte 0
|
|
MaybeBD !byte 0
|
|
MaybeBE !byte 0
|
|
MaybeBF !byte 0
|
|
|
|
;-------------------------------
|
|
; TraceDOS33b
|
|
; set up 2nd boot trace at $084A
|
|
;-------------------------------
|
|
TraceDOS33b
|
|
lda #$4C
|
|
sta $084A
|
|
lda #<TraceDOS33c
|
|
sta $084B
|
|
lda #>TraceDOS33c
|
|
sta $084C
|
|
lda #$EA
|
|
ldy #9
|
|
.noppatch
|
|
sta $83E,Y ; disable calls to
|
|
dey ; TEXt/PR0/IN0
|
|
bne .noppatch ; including "Grafboot"
|
|
jmp $0801
|
|
|
|
TraceDOS33c ; 2nd-level trace callback is here
|
|
ldy $08FE ; Set up array of high bytes of the sectors we read
|
|
dey
|
|
ldx #0
|
|
- tya
|
|
sta MaybeB6, x
|
|
iny
|
|
inx
|
|
cpx #$0A
|
|
bcc -
|
|
|
|
lda MaybeB9
|
|
sta b4bbmodify+2
|
|
sta b4bbmodify2+2
|
|
lda MaybeBF
|
|
sta b4bbcompare+1
|
|
lda MaybeBD
|
|
sta jCallRWTS+2
|
|
;
|
|
; Check for a specific encrypted bootloader called 'Protected.DOS'
|
|
;
|
|
jsr ProtectedDOS
|
|
bcs .notprotdos
|
|
.useAD jmp ADStyle
|
|
.notprotdos
|
|
;
|
|
; Check for a specific bootloader that uses per-file sector encoding
|
|
;
|
|
jsr PanglosDOS
|
|
bcc .useAD
|
|
;
|
|
; Check if $BD00 (RWTS entry point) starts with 'STY $48;STA $49'
|
|
;
|
|
lda MaybeBD
|
|
ldx #$00
|
|
ldy #$04
|
|
jsr CompareMemory
|
|
!byte $84,$48
|
|
!byte $85,$49
|
|
bcc .okaySoFar
|
|
;
|
|
; If $BD00 check failed, check for Mastery Development variation
|
|
; (usable)
|
|
;
|
|
ldy #$03
|
|
jsr CompareMemory
|
|
!byte $20,$AF,$BE
|
|
bcs .notmastery
|
|
adc #$01
|
|
ldx #$AF
|
|
ldy #$08
|
|
jsr CompareMemory
|
|
!byte $84,$48
|
|
!byte $85,$49
|
|
!byte $A0,$04
|
|
!byte $B1,$48
|
|
bcc .okaySoFar ; passport-test-suite/Mastery Arithmetic Games.woz [C=0] here
|
|
.notmastery
|
|
;
|
|
; If $BD00 check failed, check for Kidwriter variation
|
|
; (usable)
|
|
;
|
|
cmp #$BD
|
|
bne .notkidwriter
|
|
ldy #$03
|
|
jsr CompareMemory
|
|
!byte $20,$CC,$B6
|
|
bcs .notkidwriter
|
|
lda #$B6
|
|
ldx #$CC
|
|
ldy #$08
|
|
jsr CompareMemory
|
|
!byte $84,$48
|
|
!byte $85,$49
|
|
!byte $AD,$EC,$B7
|
|
!byte $F0
|
|
bcs .notkidwriter ; passport-test-suite/Kidwriter.woz [C=0] here
|
|
lda #<gTrack ; this entry point assumes track number is in $B7EC
|
|
sta $B6D1 ; which isn't true, so change the code to look at
|
|
lda #>gTrack ; Passport's gTrack instead
|
|
sta $B6D2
|
|
bne .okaySoFar ; always branches
|
|
.notkidwriter
|
|
;
|
|
; If $BD00 check failed and all variation checks failed,
|
|
; give up and use the built-in RWTS
|
|
;
|
|
.useuniv jmp UseUniversal
|
|
;
|
|
; $BD00 check succeeded (or a supported variation),
|
|
; so now check for 'SEC;RTS' at $B942
|
|
;
|
|
.okaySoFar
|
|
lda MaybeB9
|
|
ldx #$42
|
|
ldy #$02
|
|
jsr CompareMemory
|
|
!byte $38,$60
|
|
bcs .useuniv
|
|
;
|
|
; $B942 check succeeded,
|
|
; so now check for 'LDA $C08C,X' at $B94F
|
|
;
|
|
ldx #$4F
|
|
iny ; Y=3
|
|
jsr CompareMemory
|
|
!byte $BD,$8C,$C0
|
|
bcs .useuniv
|
|
;
|
|
; $B94F check succeeded,
|
|
; so now check for 'JSR $xx00' at $BDB9
|
|
;
|
|
lda MaybeBD
|
|
ldx #$B9
|
|
dey ; Y=2
|
|
jsr CompareMemory
|
|
!byte $20,00
|
|
bcc .notVerbViper
|
|
;
|
|
; If $BDB9 check failed, check for RWTS variant that has extra code before
|
|
; JSR $B800 e.g. Verb Viper (DLM), Advanced Analogies (Hartley)
|
|
; (usable)
|
|
;
|
|
ldx #$C5 ; check for 'JSR $xx00' at $BDC5
|
|
jsr CompareMemory
|
|
!byte $20,00
|
|
bcs .useuniv ; passport-test-suite/Analogies Tutorial.woz [C=0] here
|
|
.notVerbViper
|
|
;
|
|
; Check for RWTS variant that uses non-standard address for slot
|
|
; LDX $1FE8 e.g. Pinball Construction Set (1983)
|
|
; (not usable)
|
|
;
|
|
lda MaybeBE ; check for 'LDX $1FE8' at $BE43
|
|
ldx #$43
|
|
iny ; Y=3
|
|
jsr CompareMemory
|
|
!byte $AE,$E8,$1F
|
|
bcc .useuniv ; passport-test-suite/Pinball Construction Set (Budgeco).woz [C=0] matches
|
|
;
|
|
; Check for Milliken protection routine in late-stage boot
|
|
; (affects readable/ignoreable sector map, so must ID now)
|
|
;
|
|
lda MaybeB7 ; check for 'JMP $9B03' at $B747
|
|
ldx #$47
|
|
ldy #$03
|
|
jsr CompareMemory
|
|
!byte $4C,$03,$9B
|
|
bcs .notMilliken ; passport-test-suite/Tangram Puzzler.woz [C=0] matches
|
|
jsr IDMilliken
|
|
bcs .notMilliken
|
|
lda #$0A
|
|
sta gDisplayBytes
|
|
jsr PrintByID
|
|
!byte s_milliken
|
|
lda #kSectorOptional
|
|
sta T02S05
|
|
.notMilliken
|
|
;
|
|
; Check for Didatech decryption routine
|
|
; (affects readable/ignoreable sector map, so must ID now)
|
|
;
|
|
jsr $ff58
|
|
lda MaybeBC
|
|
ldx #$E1
|
|
ldy #$0A
|
|
jsr CompareMemory
|
|
!byte $A2,$04
|
|
!byte $A0,$05
|
|
!byte $A9,$96
|
|
!byte $59,$00,$08
|
|
!byte $99
|
|
bcs .notDidatech ; passport-test-suite/Crosscountry Canada.woz [C=0] matches
|
|
jsr PrintByID
|
|
!byte s_didatech
|
|
lda #kSectorOptional
|
|
sta T02S07
|
|
lda #TRUE
|
|
sta gIsDidatech
|
|
.notDidatech
|
|
;
|
|
; Try to initialize the 'current track' variable like the bootloader would --
|
|
; required for some disks that use a strange location for this variable
|
|
; e.g. Super Taxman II
|
|
;
|
|
lda MaybeB7 ; check for 'LDA #$00 / STA $....,X / STA $....,X / JSR $..93' at $B730
|
|
sta .taxman+2
|
|
ldx #$30
|
|
ldy #$0A
|
|
jsr CompareMemory
|
|
!byte $A9,$00
|
|
!byte $9D,WILDCARD,WILDCARD
|
|
!byte $9D,WILDCARD,WILDCARD
|
|
!byte $20,$93
|
|
bcs .notTaxman ; passport-test-suite/Super Taxman II.woz [C=0] matches
|
|
ldy #$07
|
|
.taxman lda $B730,y ; SMC (high byte)
|
|
sta .trackpointer,y
|
|
dey
|
|
bpl .taxman
|
|
ldx #$06
|
|
.trackpointer
|
|
LDA #$00
|
|
STA $04F8,X
|
|
STA $0478,X
|
|
.notTaxman
|
|
;
|
|
; Check for Adventure International RWTS
|
|
; (sets flag to activate expensive search later)
|
|
;
|
|
lda MaybeB9
|
|
ldx #$36
|
|
ldy #$0A
|
|
jsr CompareMemory
|
|
!byte $EA,$EA,$EA; NOP/NOP/NOP
|
|
!byte $BD,$8C,$C0; LDA $C08C,X
|
|
!byte $10,$FB ; BPL -$FB
|
|
!byte $C9,$00 ; CMP #$00
|
|
bcs .notAdvInt ; passport-test-suite/S.A.G.A. 6.woz [C=0] matches
|
|
lda #TRUE
|
|
sta gAdventureInternational
|
|
.notAdvInt
|
|
;
|
|
; Check for Phoenix bootloader/RWTS
|
|
; (sets flag to activate expensive search later)
|
|
;
|
|
jsr IDPhoenix
|
|
bcs .notPhoenix
|
|
lda #TRUE
|
|
sta gIsPhoenix
|
|
.notPhoenix
|
|
;
|
|
; Check for MECC DOS loaded in low memory
|
|
; (sets flag to activate expensive search later)
|
|
;
|
|
lda $08FE
|
|
cmp #$36
|
|
bne .notMECCSwapper
|
|
lda $371A
|
|
cmp #$0D
|
|
bne .notMECCSwapper ; passport-test-suite/Word Wizards v1.0.woz [Z=1] here
|
|
lda #TRUE
|
|
sta gPossibleMECCSwapper
|
|
.notMECCSwapper
|
|
;
|
|
; Check for unusual init at $BFC8
|
|
; (sets flag to activate expensive search later,
|
|
; and marks a certain sector optional)
|
|
;
|
|
lda $08FE
|
|
cmp #$B7
|
|
bne .notWoodbury
|
|
lda $BFCC
|
|
cmp #$10
|
|
bne .notWoodbury ; passport-test-suite/Playwriter.woz [Z=1] here
|
|
lda #TRUE
|
|
sta gPossibleWoodbury
|
|
lda #kSectorOptional
|
|
sta T14S06
|
|
.notWoodbury
|
|
;
|
|
; Turn off drive recalibration, if possible
|
|
;
|
|
lda MaybeBD ; check for code at $BDD2
|
|
sta .recal1+2
|
|
sta .recal2+2
|
|
ldx #$D2
|
|
ldy #$06
|
|
jsr CompareMemory
|
|
!byte $A9,$60 ; LDA #$60
|
|
!byte $20,$95,$BE; JSR $BE95
|
|
!byte $CE ; DEC $xxxx
|
|
bcs .norecal
|
|
lda #$B0
|
|
.recal1 sta $BDD2 ; SMC (high byte)
|
|
lda #$30
|
|
.recal2 sta $BDD3 ; SMC (high byte)
|
|
.norecal
|
|
;
|
|
; Check for Infocom RWTS (need to massage RWTS a little)
|
|
;
|
|
lda $08FE
|
|
cmp #$23
|
|
bne .notInfocom; passport-test-suite/Planetfall r26.woz [Z=1] matches
|
|
lda #$AD ; allow $AD..$FF for third data prologue nibble
|
|
sta $24FC
|
|
lda #$90
|
|
sta $24FD
|
|
ldy #$0F ; copy sector order map from boot0 into RWTS
|
|
- lda $084D,y
|
|
sta $2BB8,y
|
|
dey
|
|
bpl -
|
|
.notInfocom
|
|
;
|
|
; Check for Micro Fun RWTS swapper
|
|
; (called from outside RWTS so we need to call it ourselves)
|
|
;
|
|
lda MaybeBC
|
|
ldx #$61
|
|
ldy #$0B
|
|
jsr CompareMemory
|
|
!byte $A9,$01
|
|
!byte $8D,$00,$B9
|
|
!byte $A9,$B5
|
|
!byte $8D,$FC,$B8
|
|
!byte $60
|
|
bcs .notFun ; passport-test-suite/Crown of Arthain.woz [C=0] matches
|
|
jsr $BC61
|
|
.notFun
|
|
;
|
|
; Check for Micro Learn RWTS
|
|
; (uses per-disk zero page values within RWTS)
|
|
;
|
|
lda MaybeB7
|
|
cmp #$B7
|
|
bne .notLearn
|
|
ldx #$38
|
|
ldy #$08
|
|
jsr CompareMemory
|
|
!byte $A9,WILDCARD
|
|
!byte $85,$31
|
|
!byte $A9,WILDCARD
|
|
!byte $85,$D6
|
|
bcs .notLearn ; passport-test-suite/U.S. Constitution Tutor.woz [C=0] matches
|
|
lda #$C9
|
|
sta $B8E6
|
|
sta $B8F0
|
|
sta $B934
|
|
sta $B954
|
|
sta $B95E
|
|
sta $B990
|
|
lda $B739
|
|
sta $B8F1
|
|
sta $B955
|
|
sta $B991
|
|
lda $B73D
|
|
sta $B8E7
|
|
sta $B935
|
|
sta $B95F
|
|
.notLearn
|
|
;
|
|
; Check for alternate RWTS entry point (e.g. Swordthrust)
|
|
;
|
|
lda MaybeB7
|
|
ldx #$75
|
|
ldy #(@end_swordthrust-@begin_swordthrust)
|
|
jsr CompareMemory
|
|
@begin_swordthrust
|
|
PHP
|
|
SEI
|
|
PHA
|
|
LDX $B7EC
|
|
LDA $BED0,X
|
|
EOR $B942
|
|
STA $B8FC
|
|
STA $B85D
|
|
PLA
|
|
JSR $BD00
|
|
@end_swordthrust
|
|
bcs .notSwordthrust ; passport-test-suite/Swordthrust 1.woz [C=0] matches
|
|
stx jCallRWTS+1; set new RWTS entry point to $B775
|
|
lda #$B7
|
|
sta jCallRWTS+2
|
|
lda #<gTrack ; this entry point assumes track number is in $B7EC
|
|
sta $B779 ; which isn't true, so change the code to look at
|
|
lda #>gTrack ; Passport's gTrack instead
|
|
sta $B77A
|
|
.notSwordthrust
|
|
;
|
|
; Check for Earthware reverse RWTS swapper
|
|
; (need to pre-swap RWTS then swap it back at T02,S04)
|
|
;
|
|
lda MaybeB6
|
|
ldx #$89
|
|
ldy #$0E
|
|
jsr CompareMemory
|
|
!byte $BD,$8C,$C0
|
|
!byte $10,$FB
|
|
!byte $C9,$AD
|
|
!byte $D0,$13
|
|
!byte WILDCARD,WILDCARD
|
|
!byte $9D,$8D,$C0
|
|
bcs .notEarthware ; passport-test-suite/Zoo Master.woz [C=0] matches
|
|
lda #$BD
|
|
sta $B8F6
|
|
lda #$8C
|
|
sta $B8F7
|
|
lda #$C0
|
|
sta $B8F8
|
|
lda #kSectorCustomEarthware
|
|
sta T02S04
|
|
.notEarthware
|
|
;
|
|
; good to go
|
|
;
|
|
; /!\ execution falls through to ADStyle
|
|
}
|