2017-08-15 15:31:36 +00:00
|
|
|
; DOS 3.2 boot tracer
|
|
|
|
; for DOS 3.2 disks with a 3.2/3.3 hybrid bootloader
|
|
|
|
; that boots automatically on 16-sector drives
|
2017-08-16 15:31:49 +00:00
|
|
|
; e.g. many early disks from Edu-Ware, Hartley, DLM, Milliken
|
2017-08-15 15:31:36 +00:00
|
|
|
|
|
|
|
;-------------------------------
|
|
|
|
; IDDOS32
|
|
|
|
; returns C clear if 3.2/3.3 bootloader detected in T00,S00
|
|
|
|
;-------------------------------
|
|
|
|
!zone {
|
|
|
|
IDDOS32
|
|
|
|
lda #$00
|
|
|
|
ldx #$00
|
|
|
|
ldy #$0F
|
|
|
|
jsr compare
|
|
|
|
!byte $01
|
|
|
|
!byte $A0,$0F ; LDY #$0F
|
|
|
|
!byte $B9,$00,$08; LDA $0800,Y
|
|
|
|
!byte $99,$00,$02; STA $0200,Y
|
|
|
|
!byte $C8 ; INY
|
|
|
|
!byte $D0,$F7 ; BNE -
|
|
|
|
!byte $4C,$0F,$02; JMP $020F
|
|
|
|
bcs .exit
|
|
|
|
ldx #$33
|
|
|
|
ldy #$08
|
|
|
|
jsr compare
|
|
|
|
!byte $A6,$2B ; LDX $2B
|
|
|
|
!byte $20,$5D,$02; JSR $025D
|
|
|
|
!byte $4C,$D1,$02; JMP $02D1
|
|
|
|
bcs .exit
|
|
|
|
ldx #$F4
|
|
|
|
ldy #$08
|
|
|
|
jsr compare
|
|
|
|
!byte $CC,$00,$03; CPY $0300
|
|
|
|
!byte $D0,$03 ; BNE +
|
|
|
|
!byte $4C,$3B,$02; JMP $023B
|
|
|
|
bcs .exit
|
|
|
|
ldx #$45
|
|
|
|
ldy #$03
|
|
|
|
jsr compare
|
|
|
|
!byte $4C,$01,$03; JMP $0301
|
|
|
|
.exit rts
|
|
|
|
}
|
|
|
|
|
|
|
|
;-------------------------------
|
2017-08-16 15:31:49 +00:00
|
|
|
; IDDOS32LO
|
|
|
|
; detect earlier variant of hybrid bootloader that loads into
|
|
|
|
; low memory ($3600) then relocates to the top of main memory
|
|
|
|
; after loading DOS
|
|
|
|
; returns C clear if 3.2lo/3.3 bootloader detected in T00,S00
|
|
|
|
;-------------------------------
|
|
|
|
!zone {
|
|
|
|
IDDOS32LO
|
|
|
|
lda #$00
|
|
|
|
ldx #$00
|
|
|
|
ldy #$0F
|
|
|
|
jsr compare
|
|
|
|
!byte $01
|
|
|
|
!byte $A2,$00 ; LDX #$00
|
|
|
|
!byte $BD,$00,$08; LDA $0800,X
|
|
|
|
!byte $9D,$00,$02; STA $0200,X
|
|
|
|
!byte $E8 ; INX
|
|
|
|
!byte $D0,$F7 ; BNE -
|
|
|
|
!byte $4C,$0F,$02; JMP $020F
|
|
|
|
bcs .exit
|
|
|
|
ldx #$2F
|
|
|
|
ldy #$08
|
|
|
|
jsr compare
|
|
|
|
!byte $A6,$2B ; LDX $2B
|
|
|
|
!byte $20,$5D,$02; JSR $025D
|
|
|
|
!byte $20,$D1,$02; JSR $02D1
|
|
|
|
bcs .exit
|
|
|
|
ldx #$41
|
|
|
|
ldy #$03
|
|
|
|
jsr compare
|
|
|
|
!byte $4C,$01,$03; JMP $0301
|
|
|
|
.exit rts
|
|
|
|
}
|
|
|
|
|
|
|
|
;-------------------------------
|
|
|
|
; TraceDOS32/TraceDOS32LO
|
2017-08-15 15:31:36 +00:00
|
|
|
; set up boot trace to capture 13-sector RWTS
|
|
|
|
;-------------------------------
|
|
|
|
!zone {
|
|
|
|
TraceDOS32
|
2017-08-16 15:31:49 +00:00
|
|
|
lda #<.TraceDOS32b
|
|
|
|
ldx #>.TraceDOS32b
|
|
|
|
jmp Trace
|
|
|
|
TraceDOS32LO
|
|
|
|
lda #<.TraceDOS32LOb
|
|
|
|
ldx #>.TraceDOS32LOb
|
2017-08-15 15:31:36 +00:00
|
|
|
jmp Trace
|
|
|
|
|
2017-08-16 15:31:49 +00:00
|
|
|
.TraceDOS32b
|
|
|
|
lda #<.TraceDOS32c
|
2017-08-15 15:31:36 +00:00
|
|
|
sta $0846
|
2017-08-16 15:31:49 +00:00
|
|
|
lda #>.TraceDOS32c
|
2017-08-15 15:31:36 +00:00
|
|
|
sta $0847
|
|
|
|
jmp $0801
|
|
|
|
|
2017-08-16 15:31:49 +00:00
|
|
|
.TraceDOS32LOb
|
|
|
|
lda #<.TraceDOS32c
|
|
|
|
sta $0842
|
|
|
|
lda #>.TraceDOS32c
|
|
|
|
sta $0843
|
|
|
|
jmp $0801
|
|
|
|
|
|
|
|
.TraceDOS32c
|
2017-08-15 15:31:36 +00:00
|
|
|
lda #$03
|
|
|
|
ldx #$0D
|
|
|
|
ldy #$39
|
|
|
|
jsr CompareMemory
|
|
|
|
!byte $A6,$2B
|
|
|
|
!byte $A9,$09
|
|
|
|
!byte $85,$27
|
|
|
|
!byte $AD,$CC,$03
|
|
|
|
!byte $85,$41
|
|
|
|
!byte $84,$40
|
|
|
|
!byte $8A
|
|
|
|
!byte $4A
|
|
|
|
!byte $4A
|
|
|
|
!byte $4A
|
|
|
|
!byte $4A
|
|
|
|
!byte $A9,$02
|
|
|
|
!byte $85,$3F
|
|
|
|
!byte $A9,$5D
|
|
|
|
!byte $85,$3E
|
|
|
|
!byte $20,$43,$03
|
|
|
|
!byte $20,$46,$03
|
|
|
|
!byte $A5,$3D
|
|
|
|
!byte $4D,$FF,$03
|
|
|
|
!byte $F0,$06
|
|
|
|
!byte $E6,$41
|
|
|
|
!byte $E6,$3D
|
|
|
|
!byte $D0,$ED
|
|
|
|
!byte $85,$3E
|
|
|
|
!byte $AD,$CC,$03
|
|
|
|
!byte $85,$3F
|
|
|
|
!byte $E6,$3F
|
|
|
|
!byte $6C,$3E,$00
|
|
|
|
bcs .fail
|
|
|
|
lda $03CC
|
|
|
|
cmp #$B6
|
|
|
|
beq +
|
|
|
|
cmp #$36
|
|
|
|
bne .fail
|
|
|
|
+
|
2017-09-30 17:55:20 +00:00
|
|
|
;
|
|
|
|
; set up RWTS entry point and other self-modified vectors
|
|
|
|
; that depend on where the RWTS is in memory
|
|
|
|
;
|
2017-08-15 15:31:36 +00:00
|
|
|
clc
|
2017-09-30 17:55:20 +00:00
|
|
|
adc #$03 ; $B9 or $39
|
|
|
|
sta b4bbmodify+2
|
|
|
|
sta b4bbmodify2+2
|
|
|
|
adc #$04 ; $BD or $3D
|
2017-08-15 15:31:36 +00:00
|
|
|
sta callrwts+2
|
2017-09-30 17:55:20 +00:00
|
|
|
adc #$02 ; $BF or $3F
|
|
|
|
sta b4bbcompare+1
|
2017-08-15 15:31:36 +00:00
|
|
|
lda #$00
|
|
|
|
sta callrwts+1
|
|
|
|
|
|
|
|
; set up final trace
|
|
|
|
|
|
|
|
lda #$4C
|
|
|
|
sta $033A
|
|
|
|
lda #<TraceDOS32d
|
|
|
|
sta $033B
|
|
|
|
lda #>TraceDOS32d
|
|
|
|
sta $033C
|
|
|
|
ldy $0300
|
|
|
|
jmp $0301
|
|
|
|
|
2017-08-16 15:31:49 +00:00
|
|
|
; something did not match, not comfortable tracing,
|
|
|
|
; but we know enough to know that the universal RWTS won't work,
|
|
|
|
; so we're done
|
|
|
|
|
|
|
|
.fail jmp FatalError
|
|
|
|
|
2017-08-15 15:31:36 +00:00
|
|
|
TraceDOS32d
|
|
|
|
lda callrwts+2
|
|
|
|
ldx #$00 ; check for "STY $48;STA $49"
|
|
|
|
ldy #$04 ; at RWTS entry point
|
|
|
|
jsr CompareMemory ; (e.g. $BD00 or $3D00)
|
|
|
|
!byte $84,$48,$85,$49
|
|
|
|
bcs .fail
|
|
|
|
|
2017-08-17 13:29:35 +00:00
|
|
|
lda #$FA
|
|
|
|
sta modsrc
|
|
|
|
lda callrwts+2
|
|
|
|
sec
|
|
|
|
sbc #$05
|
|
|
|
sta modsrc+1
|
|
|
|
ldy #$00
|
|
|
|
lda #$4C ; set up JMP at $B8FA to our routine that will
|
|
|
|
sta (modsrc),y ; check whether the data field is missing
|
|
|
|
iny
|
|
|
|
lda #<FFer
|
|
|
|
sta (modsrc),y
|
|
|
|
iny
|
|
|
|
lda #>FFer
|
|
|
|
sta (modsrc),y
|
|
|
|
ldy #$07
|
|
|
|
lda #$F8 ; change BEQ at $B900 to branch to that JMP at $B8FA
|
|
|
|
; if data prologue is not found
|
|
|
|
sta (modsrc),y
|
|
|
|
|
2017-08-15 15:31:36 +00:00
|
|
|
; skip sectors $0D, $0E, and $0F on all tracks
|
|
|
|
; since this is a 13-sector disk
|
|
|
|
|
|
|
|
lda #<sectormap
|
|
|
|
sta .C+1
|
|
|
|
lda #>sectormap
|
|
|
|
sta .C+2
|
|
|
|
lda #$00
|
|
|
|
ldx #$22
|
|
|
|
.A ldy #$0F
|
|
|
|
.B cpy #$03
|
|
|
|
bcs .D
|
|
|
|
.C sta $FFFF
|
|
|
|
.D inc .C+1
|
|
|
|
bne +
|
|
|
|
inc .C+2
|
|
|
|
+ dey
|
|
|
|
bpl .B
|
|
|
|
dex
|
|
|
|
bpl .A
|
|
|
|
|
2017-08-15 21:17:14 +00:00
|
|
|
; skip T00,S00-S0A
|
2017-08-15 15:31:36 +00:00
|
|
|
; since we're going to construct our own bootloader later
|
|
|
|
|
|
|
|
ldy #$0A
|
|
|
|
- sta T00,y
|
|
|
|
dey
|
2017-08-15 21:17:14 +00:00
|
|
|
bpl -
|
|
|
|
|
|
|
|
; set flag for patcher
|
|
|
|
|
|
|
|
lda #TRUE
|
|
|
|
sta gIsDOS32
|
2017-08-15 15:31:36 +00:00
|
|
|
|
|
|
|
; read the rest of the disk with the original RWTS
|
|
|
|
|
|
|
|
jmp ADStyle
|
2017-08-17 13:29:35 +00:00
|
|
|
|
|
|
|
; callback to check if the data field is missing
|
2017-08-18 13:46:39 +00:00
|
|
|
; and if so, fill the RWTS data buffer with zeros
|
|
|
|
; and tell the caller that nibblizing was successful
|
2017-08-17 13:29:35 +00:00
|
|
|
|
|
|
|
FFer
|
|
|
|
ldy #$00
|
|
|
|
- lda $C08C,x
|
|
|
|
bpl -
|
|
|
|
cmp #$FF
|
|
|
|
bne +
|
|
|
|
iny
|
|
|
|
bne -
|
2017-08-18 13:46:39 +00:00
|
|
|
ldy callrwts+2
|
|
|
|
dey
|
|
|
|
sty .G+2
|
|
|
|
dey
|
|
|
|
sty .F+2
|
|
|
|
ldy #$00
|
|
|
|
tya
|
|
|
|
.F sta $FF00,y
|
|
|
|
iny
|
|
|
|
bne .F
|
|
|
|
.G sta $FF00,y
|
|
|
|
iny
|
|
|
|
cpy #$9A
|
|
|
|
bne .G
|
2017-08-17 13:29:35 +00:00
|
|
|
clc
|
2017-08-18 13:46:39 +00:00
|
|
|
rts
|
2017-08-17 13:29:35 +00:00
|
|
|
+ sec
|
|
|
|
rts
|
2017-08-15 15:31:36 +00:00
|
|
|
}
|