clean up TraceDOS33

This commit is contained in:
4am 2021-07-10 01:32:29 -04:00
parent 9ca2297c1d
commit fe21da1a00

View File

@ -15,6 +15,17 @@ TraceDOS33
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
@ -34,53 +45,54 @@ TraceDOS33b
bne .noppatch ; including "Grafboot"
jmp $0801
TraceDOS33c
lda $08FE ; 2nd-level trace callback is here
sta .x6+1
sta .x6b+1
sta .x6c+2
clc
adc #$02
_Inspect1a
sta .x1+1
sta .x2+1
sta .x7+1
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
clc
adc #$06
lda MaybeBF
sta b4bbcompare+1
tax
dex
stx .x5+1
dex
stx .x3+1
stx .x4+1
stx .x8+2
stx .x9+2
stx jCallRWTS+2
jsr ProtectedDOS ; check for a specific (encrypted)
; bootloader called "Protected DOS"
lda MaybeBD
sta jCallRWTS+2
;
; Check for a specific encrypted bootloader called 'Protected.DOS'
;
jsr ProtectedDOS
bcs .notprotdos
jmp ADStyle
.useAD jmp ADStyle
.notprotdos
jsr PanglosDOS ; check for a specific bootloader
; that uses per-file sector encoding
bcs .notpanglosdos
jmp ADStyle
.notpanglosdos
lda jCallRWTS+2
ldx #$00 ; check for "STY $48;STA $49"
ldy #$04 ; at RWTS entry point
jsr CompareMemory ; (e.g. $BD00 or $3D00)
;
; 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 .x1
bcc .okaySoFar
;
; If $BD00 check failed, check for Mastery Development variation
; (usable)
;
ldy #$03
jsr CompareMemory
!byte $20,$AF,$BE
bcs .notmastery ; passport-test-suite/Mastery Arithmetic Games.woz [C=0] here
bcs .notmastery
adc #$01
ldx #$AF
ldy #$08
@ -89,14 +101,18 @@ _Inspect1a
!byte $85,$49
!byte $A0,$04
!byte $B1,$48
bcc .x1 ; passport-test-suite/Mastery Arithmetic Games.woz [C=0] here
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 ; passport-test-suite/Kidwriter.woz [C=0] here
bcs .notkidwriter
lda #$B6
ldx #$CC
ldy #$08
@ -110,76 +126,90 @@ _Inspect1a
sta $B6D1 ; which isn't true, so change the code to look at
lda #>gTrack ; Passport's gTrack instead
sta $B6D2
bne .x1 ; always branches
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
.x1 lda #$B9 ; [SMC] check for "SEC;RTS" at $B942
;
; $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
bcc .x2
jmp UseUniversal
.x2 lda #$B9 ; [SMC} check for "LDA $C08C,X" at $B94F
bcs .useuniv
;
; $B942 check succeeded,
; so now check for 'LDA $C08C,X' at $B94F
;
ldx #$4F
ldy #$03
iny ; Y=3
jsr CompareMemory
!byte $BD,$8C,$C0
bcc .x3
jmp UseUniversal
.x3 lda #$BD ; [SMC] check for "JSR $xx00" at $BDB9
bcs .useuniv
;
; $B94F check succeeded,
; so now check for 'JSR $xx00' at $BDB9
;
lda MaybeBD
ldx #$B9
ldy #$02
dey ; Y=2
jsr CompareMemory
!byte $20,00
bcc .x5
bcc .notVerbViper
;
; Check for RWTS variant that has extra code before
; If $BDB9 check failed, check for RWTS variant that has extra code before
; JSR $B800 e.g. Verb Viper (DLM), Advanced Analogies (Hartley)
; (usable)
;
.x4 lda #$BD ; [SMC] check for "JSR $xx00" at $BDC5
ldx #$C5
ldy #$02
ldx #$C5 ; check for 'JSR $xx00' at $BDC5
jsr CompareMemory
!byte $20,00
bcc .x5 ; passport-test-suite/Analogies Tutorial.woz [C=0] matches
jmp UseUniversal ; give up tracing; this RWTS is unsupported
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)
; we don't like that one
; (not usable)
;
.x5 lda #$BE ; [SMC] check for "LDX $1FE8" at $BE43
lda MaybeBE ; check for 'LDX $1FE8' at $BE43
ldx #$43
ldy #$03
iny ; Y=3
jsr CompareMemory
!byte $AE,$E8,$1F
bcs .x6 ; passport-test-suite/Pinball Construction Set (Budgeco).woz [C=0] matches
jmp UseUniversal ; give up tracing; this RWTS is unsupported
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)
;
.x6 lda #$B7 ; [SMC] check for "JMP $9B03" at $B747
lda MaybeB7 ; check for 'JMP $9B03' at $B747
ldx #$47
ldy #$03
jsr CompareMemory
!byte $4C,$03,$9B
bcs .x6b ; passport-test-suite/Tangram Puzzler.woz [C=0] matches
bcs .notMilliken ; passport-test-suite/Tangram Puzzler.woz [C=0] matches
jsr IDMilliken
bcs .x6b
bcs .notMilliken
lda #$0A
sta gDisplayBytes
jsr PrintByID
!byte s_milliken
lda #kSectorOptional
sta T02S05
.notMilliken
;
; Try to initialize the "current track" variable like the bootloader would --
; 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
;
.x6b lda #$B7 ; [SMC] check for "LDA #$00 / STA $....,X / STA $....,X / JSR $..93" at $B730
lda MaybeB7 ; check for 'LDA #$00 / STA $....,X / STA $....,X / JSR $..93' at $B730
sta .taxman+2
ldx #$30
ldy #$0A
jsr CompareMemory
@ -187,21 +217,23 @@ _Inspect1a
!byte $9D,WILDCARD,WILDCARD
!byte $9D,WILDCARD,WILDCARD
!byte $20,$93
bcs .x7 ; passport-test-suite/Super Taxman II.woz [C=0] matches
bcs .notTaxman ; passport-test-suite/Super Taxman II.woz [C=0] matches
ldy #$07
.x6c lda $B730,y ; SMC
.taxman lda $B730,y ; SMC (high byte)
sta .trackpointer,y
dey
bpl .x6c
bpl .taxman
ldx #$06
.trackpointer
LDA #$00
STA $04F8,X
STA $0478,X
.notTaxman
;
; Check for Adventure International RWTS (sets flag for patcher)
; Check for Adventure International RWTS
; (sets flag to activate expensive search later)
;
.x7 lda #$B9 ; [SMC] check for code at $B936
lda MaybeB9
ldx #$36
ldy #$0A
jsr CompareMemory
@ -209,65 +241,72 @@ _Inspect1a
!byte $BD,$8C,$C0; LDA $C08C,X
!byte $10,$FB ; BPL -$FB
!byte $C9,$00 ; CMP #$00
bcs + ; passport-test-suite/S.A.G.A. 6.woz [C=0] matches
bcs .notAdvInt ; passport-test-suite/S.A.G.A. 6.woz [C=0] matches
lda #TRUE
sta gAdventureInternational
.notAdvInt
;
; Check for Phoenix bootloader/RWTS
; (implies possible secondary protection elsewhere)
; (sets flag to activate expensive search later)
;
+ jsr IDPhoenix
bcs +
jsr IDPhoenix
bcs .notPhoenix
lda #TRUE
sta gIsPhoenix
.notPhoenix
;
; Check for MECC DOS loaded in lower memory
; (sets flag for a specific patcher)
; Check for MECC DOS loaded in low memory
; (sets flag to activate expensive search later)
;
+ lda $08FE
lda $08FE
cmp #$36
bne +
bne .notMECCSwapper
lda $371A
cmp #$0D
bne +
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 for a specific patcher
; (sets flag to activate expensive search later,
; and marks a certain sector optional)
;
+ lda $08FE
lda $08FE
cmp #$B7
bne +
bne .notWoodbury
lda $BFCC
cmp #$10
bne +
bne .notWoodbury ; passport-test-suite/Playwriter.woz [Z=1] here
lda #TRUE
sta gPossibleWoodbury
lda #kSectorOptional
sta T14S06
.notWoodbury
;
; Turn off drive recalibration
; Turn off drive recalibration, if possible
;
+ lda jCallRWTS+2; check for code at $BDD2
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 +
bcs .norecal
lda #$B0
.x8 sta $BDD2 ; SMC
.recal1 sta $BDD2 ; SMC (high byte)
lda #$30
.x9 sta $BDD3 ; SMC
.recal2 sta $BDD3 ; SMC (high byte)
.norecal
;
; Check for Infocom disk (need to massage RWTS a little)
; Check for Infocom RWTS (need to massage RWTS a little)
;
+ lda $08FE
lda $08FE
cmp #$23
bne + ; passport-test-suite/Planetfall r26.woz [Z=1] matches
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
@ -277,12 +316,12 @@ _Inspect1a
sta $2BB8,y
dey
bpl -
.notInfocom
;
; Check for Micro Fun RWTS swapper (called from outside RWTS so
; we need to call it ourselves)
+ ldx jCallRWTS+2
dex
txa
; 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
@ -291,14 +330,13 @@ _Inspect1a
!byte $A9,$B5
!byte $8D,$FC,$B8
!byte $60
bcs + ; passport-test-suite/Crown of Arthain.woz [C=0] matches
bcs .notFun ; passport-test-suite/Crown of Arthain.woz [C=0] matches
jsr $BC61
.notFun
;
; Check for alternate RWTS entry point (e.g. Swordthrust)
;
+ lda jCallRWTS+2
sec
sbc #$06
lda MaybeB7
ldx #$75
ldy #(@end_swordthrust-@begin_swordthrust)
jsr CompareMemory
@ -314,7 +352,7 @@ _Inspect1a
PLA
JSR $BD00
@end_swordthrust
bcs + ; passport-test-suite/Swordthrust 1.woz [C=0] matches
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
@ -322,13 +360,12 @@ _Inspect1a
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 jCallRWTS+2
sec
sbc #$07
lda MaybeB6
ldx #$89
ldy #$0E
jsr CompareMemory
@ -338,7 +375,7 @@ _Inspect1a
!byte $D0,$13
!byte WILDCARD,WILDCARD
!byte $9D,$8D,$C0
bcs +
bcs .notEarthware ; passport-test-suite/Zoo Master.woz [C=0] matches
lda #$BD
sta $B8F6
lda #$8C
@ -347,8 +384,9 @@ _Inspect1a
sta $B8F8
lda #kSectorCustomEarthware
sta T02S04
.notEarthware
;
; good to go
;
+ jmp ADStyle ; use this RWTS to read the disk
jmp ADStyle ; use this RWTS to read the disk
}