anti-m/src/idboot.a

299 lines
5.8 KiB
Plaintext
Raw Normal View History

2019-03-12 20:35:43 +00:00
; 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
2019-03-12 20:35:43 +00:00
bcc +
lda #$90
sta $867B
2019-03-12 20:35:43 +00:00
; 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
2019-03-12 20:35:43 +00:00
; found D5 AA not-96
; check for out-of-order D5 AA AD, and retry in that case
2019-03-12 20:35:43 +00:00
+ cmp #$AD
beq @patch
2019-03-12 20:35:43 +00:00
; 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
2019-03-12 20:35:43 +00:00
lda #$90
sta $867B
2019-03-12 20:35:43 +00:00
; 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
2019-03-12 20:35:43 +00:00
lda #$9A
sta $86A7
sty $86B0
inc $86B1
sty $86C2
inc $86C3
sty $86D1
inc $86D2
2019-03-12 20:35:43 +00:00
- lda @decode53,y
sta $86D5,y
2019-04-10 21:17:31 +00:00
lda @decode53+$100,y
sta $86D5+$100,y
2019-03-12 20:35:43 +00:00
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
2019-04-10 21:17:31 +00:00
tya
pha
lda #$FF
pha
2019-03-12 20:35:43 +00:00
iny
tya
2019-04-10 21:17:31 +00:00
ldx #<@callback53_2
ldy #>@callback53_2
2019-03-12 20:35:43 +00:00
bne -
2019-03-13 22:53:53 +00:00
@decode53 !pseudopc $86D5 {
2019-03-12 20:35:43 +00:00
@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
2019-03-12 20:35:43 +00:00
+ jmp ($44)
2019-04-10 21:17:31 +00:00
@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 #$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
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
2019-04-10 21:41:29 +00:00
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
2019-04-10 23:15:40 +00:00
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
2019-04-10 21:17:31 +00:00
rts
2019-03-12 20:35:43 +00:00
}