megaload: patch on fly to use current disk slot

This commit is contained in:
Vince Weaver 2018-10-30 12:28:25 -04:00
parent 56598f4196
commit cab24e9717

View File

@ -3,6 +3,7 @@
; TODO: ; TODO:
; non-slot6? self modfiy code? ; non-slot6? self modfiy code?
; Slot<<4 is in $2b by boot firmware? can we rely on that?
adrlo = $26 ; constant from boot prom adrlo = $26 ; constant from boot prom
adrhi = $27 ; constant from boot prom adrhi = $27 ; constant from boot prom
@ -154,6 +155,30 @@ md000x2_filename: ;.byte "MUSIC.D000X2 "
;unhook DOS and build nibble table ;unhook DOS and build nibble table
init: init:
; patch to use current drive
lda $2b ; has boot slot << 4 ?
ora #$80 ; add in $80
; c0e0
sta mlsmc06+1
; c0e8
clc
adc #8
sta mlsmc02+1
; c0e9
clc
adc #1
sta mlsmc01+1
; c0ec
clc
adc #3
sta mlsmc03+1
sta mlsmc04+1
sta mlsmc05+1
jsr $fe93 ; clear COUT jsr $fe93 ; clear COUT
jsr $fe89 ; clear KEYIN jsr $fe89 ; clear KEYIN
@ -192,7 +217,7 @@ L3: inx ; increment x x=4, a=0f
; turn on drive and read volume table of contents ; turn on drive and read volume table of contents
opendir: opendir:
lda $c0e9 ; turn slot#6 drive on mlsmc01:lda $c0e9 ; turn slot#6 drive on
ldx #0 ldx #0
stx adrlo ; zero out adrlo stx adrlo ; zero out adrlo
stx secsize ; zero out secsize stx secsize ; zero out secsize
@ -364,7 +389,7 @@ readdone:
sta adrhi sta adrhi
bcc readfirst bcc readfirst
lda $c0e8 mlsmc02:lda $c0e8
; restore from stack bytes that were overwritten by extra read ; restore from stack bytes that were overwritten by extra read
@ -424,14 +449,14 @@ readdata:
bne re_read_addr bne re_read_addr
L12: L12:
ldx $c0ec ; read until valid data (high bit set) mlsmc03:ldx $c0ec ; read until valid data (high bit set)
bpl L12 bpl L12
eor nibtbl-$80, x eor nibtbl-$80, x
sta bit2tbl-$aa, y sta bit2tbl-$aa, y
iny iny
bne L12 bne L12
L13: L13:
ldx $c0ec ; read until valid data (high bit set) mlsmc04:ldx $c0ec ; read until valid data (high bit set)
bpl L13 bpl L13
eor nibtbl-$80, x eor nibtbl-$80, x
sta (adrlo), y ; the real address sta (adrlo), y ; the real address
@ -496,7 +521,7 @@ L17:
tay ; we need Y=#$AA later tay ; we need Y=#$AA later
readnib: readnib:
lda $c0ec ; read until valid (high bit set) mlsmc05:lda $c0ec ; read until valid (high bit set)
bpl readnib bpl readnib
seekret: seekret:
@ -553,7 +578,7 @@ L24:
rol rol
tax tax
lsr lsr
lda $c0e0, x mlsmc06:lda $c0e0, x
L25: L25:
ldx #$12 ldx #$12
L26: L26:
@ -589,30 +614,32 @@ repeat_until_right_sector:
; ;
readdata: readdata:
mlsmc07:
ldy $c0ec ; read data until valid ldy $c0ec ; read data until valid
bpl readdata bpl readdata
find_D5: find_D5:
cpy #$d5 ; if not D5, repeat cpy #$d5 ; if not D5, repeat
bne readdata bne readdata
find_AA: find_AA:
mlsmc08:
ldy $c0ec ; read data until valid, should be AA ldy $c0ec ; read data until valid, should be AA
bpl find_AA bpl find_AA
cpy #$aa ; we need Y=#$AA later cpy #$aa ; we need Y=#$AA later
bne find_D5 bne find_D5
find_AD: find_AD:
lda $c0ec ; read data until high bit set (valid) mlsmc09:lda $c0ec ; read data until high bit set (valid)
bpl find_AD bpl find_AD
eor #$ad ; should match $ad eor #$ad ; should match $ad
bne * ; lock if didn't find $ad (failure) bne * ; lock if didn't find $ad (failure)
L12: L12:
ldx $c0ec ; read data until high bit set (valid) mlsmc0A:ldx $c0ec ; read data until high bit set (valid)
bpl L12 bpl L12
eor nibtbl-$80, x eor nibtbl-$80, x
sta bit2tbl-$aa, y sta bit2tbl-$aa, y
iny iny
bne L12 bne L12
L13: L13:
ldx $c0ec ; read data until high bit set (valid) mlsmc0B:ldx $c0ec ; read data until high bit set (valid)
bpl L13 bpl L13
eor nibtbl-$80, x eor nibtbl-$80, x
sta (adrlo), y ; the real address sta (adrlo), y ; the real address
@ -643,20 +670,20 @@ L15:
;================= ;=================
; Find address field, put track in cutrk, sector in tmpsec ; Find address field, put track in cutrk, sector in tmpsec
readadr: readadr:
lda $c0ec ; read data until we find a $D5 mlsmc0C:lda $c0ec ; read data until we find a $D5
bpl readadr bpl readadr
adr_d5: adr_d5:
cmp #$d5 cmp #$d5
bne readadr bne readadr
adr_aa: adr_aa:
lda $c0ec ; read data until we find a $AA mlsmc0D:lda $c0ec ; read data until we find a $AA
bpl adr_aa bpl adr_aa
cmp #$aa cmp #$aa
bne adr_d5 bne adr_d5
adr_96: adr_96:
lda $c0ec ; read data until we find a $96 mlsmc0E:lda $c0ec ; read data until we find a $96
bpl adr_96 bpl adr_96
cmp #$96 cmp #$96
bne adr_d5 bne adr_d5
@ -669,12 +696,12 @@ adr_read_two_bytes:
sta curtrk ; store out current track sta curtrk ; store out current track
tax tax
L20: L20:
lda $c0ec ; read until full value mlsmc0F:lda $c0ec ; read until full value
bpl L20 bpl L20
rol rol
sta tmpsec sta tmpsec
L21: L21:
lda $c0ec ; read until full value mlsmc10:lda $c0ec ; read until full value
bpl L21 ; sector value is (v1<<1)&v2???? bpl L21 ; sector value is (v1<<1)&v2????
and tmpsec and tmpsec
dey ; loop 3 times dey ; loop 3 times
@ -730,7 +757,7 @@ L118:
and #3 and #3
rol rol
tax tax
sta $c0e0, x mlsmc11:sta $c0e0, x
L119: L119:
ldx #$13 ldx #$13
L120: L120: