mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-07-13 22:29:14 +00:00
megaload: it will never work
This commit is contained in:
parent
ec6b4b9f54
commit
343a990896
225
megademo/disk/megaload.s
Normal file
225
megademo/disk/megaload.s
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
;fast bootable seek/read, slot 6 version
|
||||||
|
;copyright (c) Peter Ferrie 2011-2012
|
||||||
|
|
||||||
|
; Translated to ca64 by Vince Weaver
|
||||||
|
|
||||||
|
chksum = 0 ;otherwise safer but 12 bytes larger
|
||||||
|
secldr2 = $0e ;14th sector is fastest when loaded from bootsector but can be any of them
|
||||||
|
seekback = 0 ;set to 1 to enable seek backwards
|
||||||
|
|
||||||
|
adrlo = $26 ;constant from boot prom
|
||||||
|
adrhi = $27 ;constant from boot prom
|
||||||
|
slot = $2b ;constant from boot prom
|
||||||
|
tmpsec = $3c ;constant from boot prom
|
||||||
|
tmpadr = $41
|
||||||
|
partial2 = $f9 ;copy of partial1
|
||||||
|
partial1 = $fa ;sectors to read from one track
|
||||||
|
total = $fb ;total sectors to read
|
||||||
|
step = $fc ;state for stepper motor
|
||||||
|
tmptrk = $fd ;temporary copy of current track
|
||||||
|
curtrk = $fe ;current track (must initialise before calling seek)
|
||||||
|
phase = $ff ;current phase for seek
|
||||||
|
addrtbl = $50 ;requires 16 bytes
|
||||||
|
nibtbl = $2d6 ;constant from boot prom
|
||||||
|
bit2tbl = $200 ;hard-coded (uses $2aa-$2ff)
|
||||||
|
|
||||||
|
maxsec = $10 ;sectors per track, usually 10 but 0b for Olympic Decathlon, 0c for Karateka
|
||||||
|
|
||||||
|
;this section is specific to bootsectors
|
||||||
|
;load second stage sector to $900, enabling track seek
|
||||||
|
; tax ;1 sector
|
||||||
|
; lda #secldr2
|
||||||
|
; ldy #9
|
||||||
|
; jsr seekread
|
||||||
|
jmp ldr2
|
||||||
|
;
|
||||||
|
|
||||||
|
seekread: stx total
|
||||||
|
sta addrtbl
|
||||||
|
sty tmpadr
|
||||||
|
calcpart: sec
|
||||||
|
lda #maxsec
|
||||||
|
sbc addrtbl
|
||||||
|
cmp total
|
||||||
|
bcs L1
|
||||||
|
tax
|
||||||
|
L1: stx partial1
|
||||||
|
stx partial2
|
||||||
|
callseek: jsr seek - 1 ;(seekret) disabled during boot, increment to enable
|
||||||
|
ldy addrtbl
|
||||||
|
ldx #$0f
|
||||||
|
lda #0
|
||||||
|
L2: sta addrtbl, x
|
||||||
|
dex
|
||||||
|
bpl L2
|
||||||
|
L3: lda tmpadr
|
||||||
|
ldx sectbl, y
|
||||||
|
sta addrtbl, x
|
||||||
|
inc tmpadr
|
||||||
|
iny
|
||||||
|
dec partial1
|
||||||
|
bne L3
|
||||||
|
|
||||||
|
read: ldx #0
|
||||||
|
read1:
|
||||||
|
L4: jsr readnib
|
||||||
|
L5: cmp #$d5
|
||||||
|
bne L4
|
||||||
|
jsr readnib
|
||||||
|
cmp #$aa
|
||||||
|
bne L5
|
||||||
|
tay ;we need Y=#$AA later
|
||||||
|
jsr readnib
|
||||||
|
eor #$ad ;zero A if match
|
||||||
|
beq check_mode
|
||||||
|
|
||||||
|
;if not #$AD, then #$96 is assumed
|
||||||
|
|
||||||
|
ldy #2 ;high 8 bits of bit2tbl
|
||||||
|
sty adrhi ;store 2-bits array at $2xx
|
||||||
|
L6: jsr readnib
|
||||||
|
rol ;set carry
|
||||||
|
sta tmpsec
|
||||||
|
jsr readnib
|
||||||
|
and tmpsec
|
||||||
|
dey
|
||||||
|
bpl L6
|
||||||
|
.if chksum
|
||||||
|
sta tmpsec
|
||||||
|
tay
|
||||||
|
ldx addrtbl, y
|
||||||
|
stx step
|
||||||
|
.else
|
||||||
|
tay
|
||||||
|
lda addrtbl, y
|
||||||
|
sta step
|
||||||
|
stx addrtbl, y
|
||||||
|
tax
|
||||||
|
.endif
|
||||||
|
bcs read1
|
||||||
|
check_mode: cpx #0 ;set carry if non-zero
|
||||||
|
beq read1
|
||||||
|
.byte $90
|
||||||
|
L7: clc
|
||||||
|
L8: ldx $c0ec
|
||||||
|
bpl L8
|
||||||
|
eor nibtbl, x
|
||||||
|
sta (adrlo), y ;$2xx initially, and then the real address
|
||||||
|
iny
|
||||||
|
bne L8
|
||||||
|
ldx step
|
||||||
|
stx adrhi ;set real address
|
||||||
|
bcs L7 ;carry is set on first pass, clear on second, loops one time
|
||||||
|
.if chksum
|
||||||
|
L9: ldx $c0ec
|
||||||
|
bpl L9
|
||||||
|
eor nibtbl, x
|
||||||
|
bne read
|
||||||
|
ldx tmpsec
|
||||||
|
sta addrtbl, x
|
||||||
|
.endif
|
||||||
|
L10: ldx #$a9
|
||||||
|
L11: inx
|
||||||
|
beq L10
|
||||||
|
lda (adrlo), y
|
||||||
|
lsr bit2tbl, x
|
||||||
|
rol
|
||||||
|
lsr bit2tbl, x
|
||||||
|
rol
|
||||||
|
sta (adrlo), y
|
||||||
|
iny
|
||||||
|
bne L11
|
||||||
|
dec total
|
||||||
|
dec partial2
|
||||||
|
bne read ;read all requested sectors in one track
|
||||||
|
ldx total
|
||||||
|
beq seekret
|
||||||
|
inc phase
|
||||||
|
inc phase ;update current track
|
||||||
|
jmp calcpart
|
||||||
|
|
||||||
|
sectbl: .byte 0, $0d, $0b, 9, 7, 5, 3, 1, $0e, $0c, $0a, 8, 6, 4, 2, $0f
|
||||||
|
|
||||||
|
readnib:
|
||||||
|
L12: lda $c0ec
|
||||||
|
bpl L12
|
||||||
|
seekret: rts ;hard-coded relative to seek
|
||||||
|
|
||||||
|
seek: lda #0
|
||||||
|
sta step
|
||||||
|
copy_cur: lda curtrk
|
||||||
|
sta tmptrk
|
||||||
|
sec
|
||||||
|
sbc phase
|
||||||
|
beq seekret
|
||||||
|
.if seekback
|
||||||
|
bcs L13
|
||||||
|
.endif
|
||||||
|
eor #$ff
|
||||||
|
inc curtrk
|
||||||
|
.if seekback
|
||||||
|
bcc L14
|
||||||
|
L13: adc #$fe
|
||||||
|
dec curtrk
|
||||||
|
L14:
|
||||||
|
.endif
|
||||||
|
cmp step
|
||||||
|
bcc L15
|
||||||
|
lda step
|
||||||
|
L15: cmp #8
|
||||||
|
bcs L16
|
||||||
|
tay
|
||||||
|
sec
|
||||||
|
L16: lda curtrk
|
||||||
|
ldx step1, y
|
||||||
|
bne L18
|
||||||
|
L17: clc
|
||||||
|
lda tmptrk
|
||||||
|
ldx step2, y
|
||||||
|
L18: stx tmpsec
|
||||||
|
and #3
|
||||||
|
rol
|
||||||
|
tax
|
||||||
|
sta $c0e0, x
|
||||||
|
L19: ldx #$13
|
||||||
|
L20: dex
|
||||||
|
bne L20
|
||||||
|
dec tmpsec
|
||||||
|
bne L19
|
||||||
|
lsr
|
||||||
|
bcs L17
|
||||||
|
inc step
|
||||||
|
bne copy_cur
|
||||||
|
|
||||||
|
step1: .byte 1, $30, $28, $24, $20, $1e, $1d, $1c
|
||||||
|
step2: .byte $70, $2c, $26, $22, $1f, $1e, $1d, $1c
|
||||||
|
|
||||||
|
newtrk = $36 ;track*2 for main stage
|
||||||
|
newnum = $80 ;number of sectors in main stage
|
||||||
|
newsec = 0 ;first sector in main stage
|
||||||
|
newadr = $40 ;load address for main stage
|
||||||
|
newstart = $4000 ;start address for main stage
|
||||||
|
|
||||||
|
ldr2: ;jmp ldr2
|
||||||
|
;replace with something like the following:
|
||||||
|
|
||||||
|
inc callseek + 1
|
||||||
|
|
||||||
|
lda #$50
|
||||||
|
sta curtrk
|
||||||
|
lda #0
|
||||||
|
sta phase
|
||||||
|
jsr seek
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
|
||||||
|
sty curtrk
|
||||||
|
lda #newtrk
|
||||||
|
sta phase
|
||||||
|
ldx #newnum
|
||||||
|
lda #newsec
|
||||||
|
ldy #newadr
|
||||||
|
jsr seekread
|
||||||
|
; jmp newstart
|
||||||
|
|
||||||
|
ldr3: jmp ldr3
|
@ -20,7 +20,8 @@
|
|||||||
sizelo = $44
|
sizelo = $44
|
||||||
sizehi = $45
|
sizehi = $45
|
||||||
secsize = $46
|
secsize = $46
|
||||||
tempy = $fa
|
TEMPX = $f9
|
||||||
|
TEMPY = $fa
|
||||||
namlo = $fb
|
namlo = $fb
|
||||||
namhi = $fc
|
namhi = $fc
|
||||||
step = $fd ;state for stepper motor
|
step = $fd ;state for stepper motor
|
||||||
@ -212,7 +213,7 @@ L6:
|
|||||||
inc adrhi
|
inc adrhi
|
||||||
iny
|
iny
|
||||||
iny
|
iny
|
||||||
bne eadnext
|
bne readnext
|
||||||
|
|
||||||
; save current address for after t/s read
|
; save current address for after t/s read
|
||||||
|
|
||||||
@ -365,18 +366,19 @@ L21:
|
|||||||
; Stepper motor delay
|
; Stepper motor delay
|
||||||
;=====================
|
;=====================
|
||||||
stepdelay:
|
stepdelay:
|
||||||
phx
|
stx TEMPX ; was **phx**
|
||||||
and #3
|
and #3
|
||||||
rol
|
rol
|
||||||
tax
|
tax
|
||||||
lda $c0e0, x
|
lda $c0e0, x
|
||||||
pla
|
lda TEMPX ; was **pla**
|
||||||
L22:
|
L22:
|
||||||
ldx #$13
|
ldx #$13
|
||||||
L23:
|
L23:
|
||||||
dex
|
dex
|
||||||
bne L23
|
bne L23
|
||||||
dec
|
sec
|
||||||
|
sbc #1 ; was **dec**
|
||||||
bne L22
|
bne L22
|
||||||
seekret:
|
seekret:
|
||||||
rts
|
rts
|
||||||
@ -399,7 +401,7 @@ copy_cur:
|
|||||||
eor #$ff
|
eor #$ff
|
||||||
inc curtrk
|
inc curtrk
|
||||||
bcc L25
|
bcc L25
|
||||||
l24:
|
L24:
|
||||||
sec
|
sec
|
||||||
sbc #1 ; *** WAS *** dec
|
sbc #1 ; *** WAS *** dec
|
||||||
dec curtrk
|
dec curtrk
|
||||||
|
@ -1,215 +1,464 @@
|
|||||||
;fast bootable seek/read, slot 6 version
|
;read any file slot 6 version
|
||||||
;copyright (c) Peter Ferrie 2011-2012
|
;copyright (c) Peter Ferrie 2013
|
||||||
|
;!cpu 65c02
|
||||||
; Translated to ca64 by Vince Weaver
|
;!to "trk",plain
|
||||||
|
;*=$800
|
||||||
chksum = 0 ;otherwise safer but 12 bytes larger
|
|
||||||
secldr2 = $0e ;14th sector is fastest when loaded from bootsector but can be any of them
|
|
||||||
seekback = 0 ;set to 1 to enable seek backwards
|
|
||||||
|
|
||||||
adrlo = $26 ;constant from boot prom
|
adrlo = $26 ;constant from boot prom
|
||||||
adrhi = $27 ;constant from boot prom
|
adrhi = $27 ;constant from boot prom
|
||||||
slot = $2b ;constant from boot prom
|
|
||||||
tmpsec = $3c ;constant from boot prom
|
tmpsec = $3c ;constant from boot prom
|
||||||
tmpadr = $41
|
reqsec = $3d ;constant from boot prom
|
||||||
partial2 = $f9 ;copy of partial1
|
A1L = $3c ;constant from ROM
|
||||||
partial1 = $fa ;sectors to read from one track
|
A1H = $3d ;constant from ROM
|
||||||
total = $fb ;total sectors to read
|
A2L = $3e ;constant from ROM
|
||||||
step = $fc ;state for stepper motor
|
A2H = $3f ;constant from ROM
|
||||||
tmptrk = $fd ;temporary copy of current track
|
curtrk = $40
|
||||||
curtrk = $fe ;current track (must initialise before calling seek)
|
niblo = $41
|
||||||
|
nibhi = $42
|
||||||
|
A4L = $42 ;constant from ROM
|
||||||
|
A4H = $43 ;constant from ROM
|
||||||
|
sizelo = $44
|
||||||
|
sizehi = $45
|
||||||
|
secsize = $46
|
||||||
|
TEMPX = $f9
|
||||||
|
TEMPY = $fa
|
||||||
|
namlo = $fb
|
||||||
|
namhi = $fc
|
||||||
|
step = $fd ;state for stepper motor
|
||||||
|
tmptrk = $fe ;temporary copy of current track
|
||||||
phase = $ff ;current phase for seek
|
phase = $ff ;current phase for seek
|
||||||
addrtbl = $50 ;requires 16 bytes
|
reloc = $bc00
|
||||||
nibtbl = $2d6 ;constant from boot prom
|
dirbuf = $bf00
|
||||||
bit2tbl = $200 ;hard-coded (uses $2aa-$2ff)
|
MOVE = $fe2c
|
||||||
|
|
||||||
maxsec = $10 ;sectors per track, usually 10 but 0b for Olympic Decathlon, 0c for Karateka
|
start:
|
||||||
|
jsr init ;one-time call to unhook DOS
|
||||||
|
;open and read a file
|
||||||
|
lda #<file_to_read
|
||||||
|
sta namlo
|
||||||
|
lda #>file_to_read
|
||||||
|
sta namhi
|
||||||
|
jsr opendir ;open and read entire file into memory at its load address
|
||||||
|
|
||||||
;this section is specific to bootsectors
|
blah: jmp blah
|
||||||
;load second stage sector to $900, enabling track seek
|
|
||||||
tax ;1 sector
|
|
||||||
lda #secldr2
|
|
||||||
ldy #9
|
|
||||||
jsr seekread
|
|
||||||
jmp ldr2
|
|
||||||
;
|
|
||||||
|
|
||||||
seekread: stx total
|
; format of request name is 30-character Apple text:
|
||||||
sta addrtbl
|
;e.g. !scrxor $80, "MYFILE "
|
||||||
sty tmpadr
|
file_to_read: ;.byte "MYFILE "
|
||||||
calcpart: sec
|
.byte 'M'|$80,'E'|$80,'G'|$80,'A'|$80,'D'|$80,'E'|$80,'M'|$80,'O'|$80
|
||||||
lda #maxsec
|
.byte $A0,$A0,$A0,$A0,$A0,$A0,$A0,$A0
|
||||||
sbc addrtbl
|
.byte $A0,$A0,$A0,$A0,$A0,$A0,$A0,$A0
|
||||||
cmp total
|
.byte $A0,$A0,$A0,$A0,$A0,$A0
|
||||||
bcs L1
|
|
||||||
tax
|
|
||||||
L1: stx partial1
|
;unhook DOS and build nibble table
|
||||||
stx partial2
|
|
||||||
callseek: jsr seek - 1 ;(seekret) disabled during boot, increment to enable
|
init:
|
||||||
ldy addrtbl
|
jsr $fe93 ; clear COUT
|
||||||
ldx #$0f
|
jsr $fe89 ; clear KEYIN
|
||||||
lda #0
|
; lda #<unreloc
|
||||||
L2: sta addrtbl, x
|
; sta A1L
|
||||||
dex
|
; lda #>unreloc
|
||||||
bpl L2
|
; sta A1H
|
||||||
L3: lda tmpadr
|
; lda #<(unreloc+(codeend-opendir)-1)
|
||||||
ldx sectbl, y
|
; sta A2L
|
||||||
sta addrtbl, x
|
; lda #>(unreloc+(codeend-opendir)-1)
|
||||||
inc tmpadr
|
; sta A2H
|
||||||
|
; ldy #0
|
||||||
|
; sty A4L
|
||||||
|
; lda #>reloc
|
||||||
|
; sta A4H
|
||||||
|
; jsr MOVE ; move mem from A1-A2 to location A4
|
||||||
|
|
||||||
|
ldx #3
|
||||||
|
L1: stx $3c
|
||||||
|
txa
|
||||||
|
asl
|
||||||
|
bit $3c
|
||||||
|
beq L3
|
||||||
|
ora $3c
|
||||||
|
eor #$ff
|
||||||
|
and #$7e
|
||||||
|
L2: bcs L3
|
||||||
|
lsr
|
||||||
|
bne L2
|
||||||
|
tya
|
||||||
|
sta nibtbl, x
|
||||||
iny
|
iny
|
||||||
dec partial1
|
L3: inx
|
||||||
bne L3
|
bpl L1
|
||||||
|
|
||||||
read: ldx #0
|
rts
|
||||||
read1:
|
|
||||||
L4: jsr readnib
|
|
||||||
L5: cmp #$d5
|
|
||||||
bne L4
|
|
||||||
jsr readnib
|
|
||||||
cmp #$aa
|
|
||||||
bne L5
|
|
||||||
tay ;we need Y=#$AA later
|
|
||||||
jsr readnib
|
|
||||||
eor #$ad ;zero A if match
|
|
||||||
beq check_mode
|
|
||||||
|
|
||||||
;if not #$AD, then #$96 is assumed
|
unreloc:
|
||||||
|
;!pseudopc reloc {
|
||||||
|
|
||||||
ldy #2 ;high 8 bits of bit2tbl
|
;turn on drive and read volume table of contents
|
||||||
sty adrhi ;store 2-bits array at $2xx
|
|
||||||
L6: jsr readnib
|
opendir:
|
||||||
rol ;set carry
|
lda $c0e9
|
||||||
sta tmpsec
|
ldx #0
|
||||||
jsr readnib
|
stx adrlo
|
||||||
and tmpsec
|
stx secsize
|
||||||
|
lda #$11
|
||||||
|
jsr readdirsec
|
||||||
|
firstent:
|
||||||
|
lda dirbuf+1
|
||||||
|
|
||||||
|
;lock if entry not found
|
||||||
|
|
||||||
|
beq *
|
||||||
|
|
||||||
|
;read directory sector
|
||||||
|
|
||||||
|
ldx dirbuf+2
|
||||||
|
jsr seekread1
|
||||||
|
ldy #7 ;number of directory entries in a sector
|
||||||
|
ldx #$2b ;offset of filename in directory entry
|
||||||
|
nextent:
|
||||||
|
tya
|
||||||
|
pha ; was **phy**
|
||||||
|
txa
|
||||||
|
pha ; was **phx**
|
||||||
|
ldy #$1d
|
||||||
|
|
||||||
|
; match name backwards (slower but smaller)
|
||||||
|
|
||||||
|
L4:
|
||||||
|
lda (namlo), y
|
||||||
|
cmp dirbuf, x
|
||||||
|
beq foundname
|
||||||
|
pla
|
||||||
|
|
||||||
|
; move to next directory in this block, if possible
|
||||||
|
|
||||||
|
clc
|
||||||
|
adc #$23
|
||||||
|
tax
|
||||||
|
pla
|
||||||
|
tay ; was **ply**
|
||||||
dey
|
dey
|
||||||
bpl L6
|
bne nextent
|
||||||
.if chksum
|
beq firstent ; was **bra**
|
||||||
sta tmpsec
|
|
||||||
tay
|
foundname:
|
||||||
ldx addrtbl, y
|
dex
|
||||||
stx step
|
dey
|
||||||
.else
|
bpl L4
|
||||||
tay
|
pla
|
||||||
lda addrtbl, y
|
tay ; was **ply**
|
||||||
sta step
|
pla
|
||||||
stx addrtbl, y
|
|
||||||
tax
|
; read track/sector list
|
||||||
.endif
|
|
||||||
bcs read1
|
lda dirbuf-32, y
|
||||||
check_mode: cpx #0 ;set carry if non-zero
|
ldx dirbuf-31, y
|
||||||
beq read1
|
jsr seekread1
|
||||||
.byte $90
|
|
||||||
L7: clc
|
; read load offset and length info only, initially
|
||||||
L8: ldx $c0ec
|
|
||||||
bpl L8
|
lda #<filbuf
|
||||||
eor nibtbl, x
|
sta adrlo
|
||||||
sta (adrlo), y ;$2xx initially, and then the real address
|
lda #4
|
||||||
iny
|
sta secsize
|
||||||
bne L8
|
lda dirbuf+12
|
||||||
ldx step
|
ldx dirbuf+13
|
||||||
stx adrhi ;set real address
|
ldy #>filbuf
|
||||||
bcs L7 ;carry is set on first pass, clear on second, loops one time
|
jsr seekread
|
||||||
.if chksum
|
|
||||||
L9: ldx $c0ec
|
; reduce load offset by 4, to account for offset and length
|
||||||
bpl L9
|
|
||||||
eor nibtbl, x
|
sec
|
||||||
bne read
|
lda filbuf
|
||||||
ldx tmpsec
|
sbc #4
|
||||||
sta addrtbl, x
|
sta adrlo
|
||||||
.endif
|
lda filbuf+1
|
||||||
L10: ldx #$a9
|
sbc #0
|
||||||
L11: inx
|
sta adrhi
|
||||||
beq L10
|
|
||||||
|
; save on stack bytes that will be overwritten by extra read
|
||||||
|
|
||||||
|
ldy #3
|
||||||
|
L5:
|
||||||
lda (adrlo), y
|
lda (adrlo), y
|
||||||
lsr bit2tbl, x
|
pha
|
||||||
|
dey
|
||||||
|
bpl L5
|
||||||
|
|
||||||
|
lda adrhi
|
||||||
|
pha
|
||||||
|
lda adrlo
|
||||||
|
pha
|
||||||
|
|
||||||
|
; increase load size by 4, to account for offst and length
|
||||||
|
|
||||||
|
lda filbuf+2
|
||||||
|
adc #3
|
||||||
|
sta sizelo
|
||||||
|
sta secsize
|
||||||
|
lda filbuf+3
|
||||||
|
adc #0
|
||||||
|
sta sizehi
|
||||||
|
beq readfirst
|
||||||
|
ldy #0 ; was **stz secsize**
|
||||||
|
sty secsize
|
||||||
|
|
||||||
|
readfirst:
|
||||||
|
ldy #$0c
|
||||||
|
|
||||||
|
; read a file sector
|
||||||
|
|
||||||
|
readnext:
|
||||||
|
lda dirbuf, y
|
||||||
|
ldx dirbuf+1, y
|
||||||
|
sty TEMPY ; ** was phy **
|
||||||
|
jsr seekread1
|
||||||
|
ldy TEMPY ; ** was ply **
|
||||||
|
|
||||||
|
; if low count is non-zero then we are done
|
||||||
|
; (can happen only for partial last block)
|
||||||
|
|
||||||
|
lda secsize
|
||||||
|
bne readdone
|
||||||
|
|
||||||
|
; continue if more than $100 bytes left
|
||||||
|
|
||||||
|
dec sizehi
|
||||||
|
bne L6
|
||||||
|
|
||||||
|
;set read size to min(length, $100)
|
||||||
|
|
||||||
|
lda sizelo
|
||||||
|
beq readdone
|
||||||
|
sta secsize
|
||||||
|
L6:
|
||||||
|
inc adrhi
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
bne readnext
|
||||||
|
|
||||||
|
; save current address for after t/s read
|
||||||
|
|
||||||
|
lda adrhi
|
||||||
|
pha
|
||||||
|
lda adrlo
|
||||||
|
pha
|
||||||
|
lda #0
|
||||||
|
sta adrlo ; was **stz adrlo**
|
||||||
|
|
||||||
|
; read next track/sector sector
|
||||||
|
|
||||||
|
lda dirbuf+1
|
||||||
|
ldx dirbuf+2
|
||||||
|
jsr readdirsec
|
||||||
|
clc
|
||||||
|
|
||||||
|
; restore current address
|
||||||
|
readdone:
|
||||||
|
pla
|
||||||
|
sta adrhi
|
||||||
|
pla
|
||||||
|
sta adrlo
|
||||||
|
bcc readfirst
|
||||||
|
|
||||||
|
lda $c0e8
|
||||||
|
|
||||||
|
; restore from stack bytes that were overwritten by extra read
|
||||||
|
|
||||||
|
ldx #3
|
||||||
|
ldy #0
|
||||||
|
L7:
|
||||||
|
pla
|
||||||
|
sta (adrlo), y
|
||||||
|
iny
|
||||||
|
dex
|
||||||
|
bpl L7
|
||||||
|
rts
|
||||||
|
|
||||||
|
readdirsec:
|
||||||
|
ldy #>dirbuf
|
||||||
|
seekread:
|
||||||
|
sty adrhi
|
||||||
|
seekread1:
|
||||||
|
sta phase
|
||||||
|
lda sectbl, x
|
||||||
|
sta reqsec
|
||||||
|
jsr readadr
|
||||||
|
|
||||||
|
; if track does not match, then seek
|
||||||
|
|
||||||
|
lda curtrk
|
||||||
|
cmp phase
|
||||||
|
beq checksec
|
||||||
|
jsr seek
|
||||||
|
|
||||||
|
; [re-]read sector
|
||||||
|
|
||||||
|
L8:
|
||||||
|
jsr readadr
|
||||||
|
checksec:
|
||||||
|
cmp reqsec
|
||||||
|
bne L8
|
||||||
|
|
||||||
|
; read sector data
|
||||||
|
|
||||||
|
readdata:
|
||||||
|
ldy $c0ec
|
||||||
|
bpl readdata
|
||||||
|
L9:
|
||||||
|
cpy #$d5
|
||||||
|
bne readdata
|
||||||
|
L10:
|
||||||
|
ldy $c0ec
|
||||||
|
bpl L10
|
||||||
|
cpy #$aa ;we need Y=#$AA later
|
||||||
|
bne L9
|
||||||
|
L11:
|
||||||
|
lda $c0ec
|
||||||
|
bpl L11
|
||||||
|
eor #$ad ;zero A if match
|
||||||
|
bne * ;lock if read failure
|
||||||
|
L12:
|
||||||
|
ldx $c0ec
|
||||||
|
bpl L12
|
||||||
|
eor nibtbl-$80, x
|
||||||
|
sta bit2tbl-$aa, y
|
||||||
|
iny
|
||||||
|
bne L12
|
||||||
|
L13:
|
||||||
|
ldx $c0ec
|
||||||
|
bpl L13
|
||||||
|
eor nibtbl-$80, x
|
||||||
|
sta (adrlo), y ;the real address
|
||||||
|
iny
|
||||||
|
cpy secsize
|
||||||
|
bne L13
|
||||||
|
ldy #0
|
||||||
|
L14:
|
||||||
|
ldx #$a9
|
||||||
|
L15:
|
||||||
|
inx
|
||||||
|
beq L14
|
||||||
|
lda (adrlo), y
|
||||||
|
lsr bit2tbl-$aa, x
|
||||||
rol
|
rol
|
||||||
lsr bit2tbl, x
|
lsr bit2tbl-$aa, x
|
||||||
rol
|
rol
|
||||||
sta (adrlo), y
|
sta (adrlo), y
|
||||||
iny
|
iny
|
||||||
bne L11
|
cpy secsize
|
||||||
dec total
|
bne L15
|
||||||
dec partial2
|
rts
|
||||||
bne read ;read all requested sectors in one track
|
|
||||||
ldx total
|
|
||||||
beq seekret
|
|
||||||
inc phase
|
|
||||||
inc phase ;update current track
|
|
||||||
jmp calcpart
|
|
||||||
|
|
||||||
sectbl: .byte 0, $0d, $0b, 9, 7, 5, 3, 1, $0e, $0c, $0a, 8, 6, 4, 2, $0f
|
;no tricks here, just the regular stuff
|
||||||
|
|
||||||
readnib:
|
readadr:
|
||||||
L12: lda $c0ec
|
lda $c0ec
|
||||||
bpl L12
|
bpl readadr
|
||||||
seekret: rts ;hard-coded relative to seek
|
L16:
|
||||||
|
cmp #$d5
|
||||||
|
bne readadr
|
||||||
|
L17:
|
||||||
|
lda $c0ec
|
||||||
|
bpl L17
|
||||||
|
cmp #$aa
|
||||||
|
bne L16
|
||||||
|
L18:
|
||||||
|
lda $c0ec
|
||||||
|
bpl L18
|
||||||
|
cmp #$96
|
||||||
|
bne L16
|
||||||
|
ldy #3
|
||||||
|
L19:
|
||||||
|
sta curtrk
|
||||||
|
L20:
|
||||||
|
lda $c0ec
|
||||||
|
bpl L20
|
||||||
|
rol
|
||||||
|
sta tmpsec
|
||||||
|
L21:
|
||||||
|
lda $c0ec
|
||||||
|
bpl L21
|
||||||
|
and tmpsec
|
||||||
|
dey
|
||||||
|
bne L19
|
||||||
|
rts
|
||||||
|
|
||||||
seek: lda #0
|
;=====================
|
||||||
sta step
|
; Stepper motor delay
|
||||||
copy_cur: lda curtrk
|
;=====================
|
||||||
|
stepdelay:
|
||||||
|
stx TEMPX ; was **phx**
|
||||||
|
and #3
|
||||||
|
rol
|
||||||
|
tax
|
||||||
|
lda $c0e0, x
|
||||||
|
lda TEMPX ; was **pla**
|
||||||
|
L22:
|
||||||
|
ldx #$13
|
||||||
|
L23:
|
||||||
|
dex
|
||||||
|
bne L23
|
||||||
|
sec
|
||||||
|
sbc #1 ; was **dec**
|
||||||
|
bne L22
|
||||||
|
seekret:
|
||||||
|
rts
|
||||||
|
|
||||||
|
;================
|
||||||
|
; SEEK
|
||||||
|
;================
|
||||||
|
seek:
|
||||||
|
asl curtrk
|
||||||
|
lda #0
|
||||||
|
sta step ; *** WAS *** stz step
|
||||||
|
asl phase
|
||||||
|
copy_cur:
|
||||||
|
lda curtrk
|
||||||
sta tmptrk
|
sta tmptrk
|
||||||
sec
|
sec
|
||||||
sbc phase
|
sbc phase
|
||||||
beq seekret
|
beq seekret
|
||||||
.if seekback
|
bcs L24
|
||||||
bcs L13
|
|
||||||
.endif
|
|
||||||
eor #$ff
|
eor #$ff
|
||||||
inc curtrk
|
inc curtrk
|
||||||
.if seekback
|
bcc L25
|
||||||
bcc L14
|
L24:
|
||||||
L13: adc #$fe
|
sec
|
||||||
|
sbc #1 ; *** WAS *** dec
|
||||||
dec curtrk
|
dec curtrk
|
||||||
L14:
|
L25:
|
||||||
.endif
|
|
||||||
cmp step
|
cmp step
|
||||||
bcc L15
|
bcc L26
|
||||||
lda step
|
lda step
|
||||||
L15: cmp #8
|
L26:
|
||||||
bcs L16
|
cmp #8
|
||||||
|
bcs L27
|
||||||
tay
|
tay
|
||||||
sec
|
sec
|
||||||
L16: lda curtrk
|
L27:
|
||||||
|
lda curtrk
|
||||||
ldx step1, y
|
ldx step1, y
|
||||||
bne L18
|
jsr stepdelay
|
||||||
L17: clc
|
|
||||||
lda tmptrk
|
lda tmptrk
|
||||||
ldx step2, y
|
ldx step2, y
|
||||||
L18: stx tmpsec
|
jsr stepdelay
|
||||||
and #3
|
|
||||||
rol
|
|
||||||
tax
|
|
||||||
sta $c0e0, x
|
|
||||||
L19: ldx #$13
|
|
||||||
L20: dex
|
|
||||||
bne L20
|
|
||||||
dec tmpsec
|
|
||||||
bne L19
|
|
||||||
lsr
|
|
||||||
bcs L17
|
|
||||||
inc step
|
inc step
|
||||||
bne copy_cur
|
bne copy_cur
|
||||||
|
|
||||||
step1: .byte 1, $30, $28, $24, $20, $1e, $1d, $1c
|
step1: .byte $01, $30, $28, $24, $20, $1e, $1d, $1c
|
||||||
step2: .byte $70, $2c, $26, $22, $1f, $1e, $1d, $1c
|
step2: .byte $70, $2c, $26, $22, $1f, $1e, $1d, $1c
|
||||||
|
|
||||||
newtrk = $36 ;track*2 for main stage
|
sectbl: .byte 0, $0d, $0b, 9, 7, 5, 3, 1, $0e, $0c, $0a, 8, 6, 4, 2, $0f
|
||||||
newnum = $80 ;number of sectors in main stage
|
|
||||||
newsec = 0 ;first sector in main stage
|
|
||||||
newadr = $40 ;load address for main stage
|
|
||||||
newstart = $4000 ;start address for main stage
|
|
||||||
|
|
||||||
ldr2: ;jmp ldr2
|
codeend = *
|
||||||
;replace with something like the following:
|
|
||||||
inc callseek + 1
|
|
||||||
sty curtrk
|
|
||||||
lda #newtrk
|
|
||||||
sta phase
|
|
||||||
ldx #newnum
|
|
||||||
lda #newsec
|
|
||||||
ldy #newadr
|
|
||||||
jsr seekread
|
|
||||||
; jmp newstart
|
|
||||||
|
|
||||||
ldr3: jmp ldr3
|
nibtbl = *
|
||||||
|
bit2tbl = nibtbl+128
|
||||||
|
filbuf = bit2tbl+86
|
||||||
|
dataend = filbuf+4
|
||||||
|
;hack to error out when code is too large for current address
|
||||||
|
;!if ((dirbuf-(dataend-opendir))&$ff00)<reloc {
|
||||||
|
;1=1
|
||||||
|
;}
|
||||||
|
;}
|
||||||
|
Loading…
Reference in New Issue
Block a user