anti-m/src/idboot.a
2019-04-10 16:43:19 -07:00

302 lines
5.8 KiB
Plaintext

; Bootsector tracer
; written by qkumba
;
IDBoot
; try to determine sector type based on found boot sector
lda #$60
sta $867B
@patch
jsr $8600 ;SMC
ldy #$5C
sty @patch+1
bcc +
lda #$90
sta $867B
; found D5 AA 96 T00S00 D5 AA AD, proceed as 16-sector
bne @patch ;always
@retries
!byte 14 ;sectors per track+1 to cover the corner-case
; found D5 AA not-96
; check for out-of-order D5 AA AD, and retry in that case
+ cmp #$AD
beq @patch
; otherwise, loop in case we will see D5 AA B5
cmp #$B5
bne @patch
; and loop anyway in case it's a hybrid disk and we missed the D5 AA 96
dec @retries
bne @patch
; found nothing but D5 AA B5, proceed as 13-sector
lda #$90
sta $867B
; build 5-and-3 decoder table
ldx #$00
ldy #$AB
- tya
sta $3C
lsr
ora $3C
cmp #$FF
bne +
cpy #$D5
beq +
txa
asl
asl
asl
sta $300,y
inx
+ iny
bne -
; patch boot PROM to recognise 13-sector instead
lda #$B5
sta $8677
lda #$9A
sta $86A7
sty $86B0
inc $86B1
sty $86C2
inc $86C3
sty $86D1
inc $86D2
- lda @decode53,y
sta $86D5,y
lda @decode53+$100,y
sta $86D5+$100,y
iny
bne -
lda #$02
sta $27
sty $42
lda #$08
ldx #<@callback53
ldy #>@callback53
- sta $43
stx $44
sty $45
clc
jmp @run53
@callback53
lda $8FF
lsr
lsr
lsr
tay
iny
sty @patch53+1
ldy $8FE
tya
pha
lda #$FF
pha
iny
tya
ldx #<@callback53_2
ldy #>@callback53_2
bne -
@decode53 !pseudopc $86D5 {
@decode53x
ldx #$32
ldy #$00
- lda $300,x
lsr
lsr
lsr
sta $3C
lsr
sta $2A
lsr
ora $200,x
sta ($42),y
iny
lda $333,x
lsr
lsr
lsr
lsr
rol $3C
lsr
rol $2A
ora $233,x
sta ($42),y
iny
lda $366,x
lsr
lsr
lsr
lsr
rol $3C
lsr
rol $2A
ora $266,x
sta ($42),y
iny
lda $2A
and #7
ora $299,x
sta ($42),y
iny
lda $3C
and #7
ora $2CC,x
sta ($42),y
iny
dex
bpl -
lda $399
lsr
lsr
lsr
ora $2FF
sta ($42),y
inc $3D
inc $43
lda $3D
@patch53
cmp #$01
@run53
ldx #$60
bcs +
jmp $865D
+ jmp ($44)
@CompareMemoryRel
sta cmp1+1
stx cmp1
pla
sta cmp2
pla
sta cmp2+1
tax
tya
clc
adc cmp2
bcc +
inx
+ sta tmp
txa
pha
lda tmp
pha
.cmp
lda (cmp2),y
dey
bmi .success
cmp (cmp1),y
beq .cmp
cmp #WILDCARD
beq .cmp
sec
!byte $24 ; hide CLC
.success clc
lda cmp1+1
ldx cmp1
rts
@callback53_2
lda $85FF
beq @skip2
lda #$29
ldx #$6E
ldy #8
jsr @CompareMemoryRel
!byte $BD,$8A,$C0 ;LDA $C08A,X
!byte $B0,$03 ;BCS *+5
!byte $BD,$8B,$C0 ;LDA $C08B,X
bcs @notinfocom
inc $296F
@skip2
rts
@notinfocom
lda #$3D
ldx #$5F
ldy #8
jsr @CompareMemoryRel
!byte $BD,$8A,$C0 ;LDA $C08A,X
!byte $B0,$03 ;BCS *+5
!byte $BD,$8B,$C0 ;LDA $C08B,X
bcs @notdos32a
inc $3D60
ldx #$60
rts
@notdos32a
lda #$BD
ldx #$6E
ldy #8
jsr @CompareMemoryRel
!byte $BD,$8A,$C0 ;LDA $C08A,X
!byte $B0,$03 ;BCS *+5
!byte $BD,$8B,$C0 ;LDA $C08B,X
bcs @notdos32b
inc $BD6F
ldx #$60
rts
@notdos32b
lda #$3D
ldx #$6E
ldy #8
jsr @CompareMemoryRel
!byte $BD,$8A,$C0 ;LDA $C08A,X
!byte $B0,$03 ;BCS *+5
!byte $BD,$8B,$C0 ;LDA $C08B,X
bcs @notdos32c
inc $3D6F
ldx #$60
rts
@notdos32c
lda #$BD
ldx #$5F
ldy #8
jsr @CompareMemoryRel
!byte $BD,$8A,$C0 ;LDA $C08A,X
!byte $B0,$03 ;BCS *+5
!byte $BD,$8B,$C0 ;LDA $C08B,X
bcs @notdos32d
inc $BD60
ldx #$60
rts
@notdos32d
lda #$24
ldx #$6E
ldy #8
jsr @CompareMemoryRel
!byte $BD,$8A,$C0 ;LDA $C08A,X
!byte $B0,$03 ;BCS *+5
!byte $BD,$8B,$C0 ;LDA $C08B,X
bcs @notdos32e
inc $246F
ldx #$60
rts
@notdos32e
lda #$7D
ldx #$5F
ldy #8
jsr @CompareMemoryRel
!byte $BD,$8A,$C0 ;LDA $C08A,X
!byte $B0,$03 ;BCS *+5
!byte $BD,$8B,$C0 ;LDA $C08B,X
bcs @notdos32f
inc $7D60
ldx #$60
rts
@notdos32f
rts
}