mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-02-07 05:30:55 +00:00
megaload: optimize it down some
This commit is contained in:
parent
0d22a6547a
commit
8f4393b4bb
@ -1,54 +1,38 @@
|
|||||||
;read any file slot 6 version
|
; read any file slot 6 version
|
||||||
;copyright (c) Peter Ferrie 2013
|
; based on FASTLD6 and RTS copyright (c) Peter Ferrie 2011-2013
|
||||||
;!cpu 65c02
|
|
||||||
;!to "trk",plain
|
|
||||||
;*=$800
|
|
||||||
|
|
||||||
adrlo = $26 ;constant from boot prom
|
|
||||||
adrhi = $27 ;constant from boot prom
|
adrlo = $26 ; constant from boot prom
|
||||||
tmpsec = $3c ;constant from boot prom
|
adrhi = $27 ; constant from boot prom
|
||||||
reqsec = $3d ;constant from boot prom
|
tmpsec = $3c ; constant from boot prom
|
||||||
A1L = $3c ;constant from ROM
|
reqsec = $3d ; constant from boot prom
|
||||||
A1H = $3d ;constant from ROM
|
curtrk = $40
|
||||||
A2L = $3e ;constant from ROM
|
sizelo = $44
|
||||||
A2H = $3f ;constant from ROM
|
sizehi = $45
|
||||||
curtrk = $40
|
secsize = $46
|
||||||
niblo = $41
|
TEMPY = $fa
|
||||||
nibhi = $42
|
namlo = $fb
|
||||||
A4L = $42 ;constant from ROM
|
namhi = $fc
|
||||||
A4H = $43 ;constant from ROM
|
step = $fd ; state for stepper motor
|
||||||
sizelo = $44
|
tmptrk = $fe ; temporary copy of current track
|
||||||
sizehi = $45
|
phase = $ff ; current phase for /seek
|
||||||
secsize = $46
|
dirbuf = $bf00
|
||||||
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
|
|
||||||
reloc = $bc00
|
|
||||||
dirbuf = $bf00
|
|
||||||
MOVE = $fe2c
|
|
||||||
|
|
||||||
start:
|
start:
|
||||||
; jmp start
|
jsr init ; unhook DOS, init nibble table
|
||||||
jsr init ;one-time call to unhook DOS
|
|
||||||
;open and read a file
|
; open and read a file
|
||||||
lda #<file_to_read
|
lda #<file_to_read
|
||||||
sta namlo
|
sta namlo
|
||||||
lda #>file_to_read
|
lda #>file_to_read
|
||||||
sta namhi
|
sta namhi
|
||||||
jsr opendir ;open and read entire file into memory at its load address
|
jsr opendir ; open and read entire file into memory
|
||||||
|
|
||||||
|
jmp $4000 ; jump to entry point
|
||||||
|
|
||||||
|
|
||||||
jmp $4000
|
; filename to open is 30-character Apple text:
|
||||||
|
file_to_read: ;.byte "MEGADEMO "
|
||||||
;blah: jmp blah
|
|
||||||
|
|
||||||
; format of request name is 30-character Apple text:
|
|
||||||
;e.g. !scrxor $80, "MYFILE "
|
|
||||||
file_to_read: ;.byte "MYFILE "
|
|
||||||
.byte 'M'|$80,'E'|$80,'G'|$80,'A'|$80,'D'|$80,'E'|$80,'M'|$80,'O'|$80
|
.byte 'M'|$80,'E'|$80,'G'|$80,'A'|$80,'D'|$80,'E'|$80,'M'|$80,'O'|$80
|
||||||
.byte $A0,$A0,$A0,$A0,$A0,$A0,$A0,$A0
|
.byte $A0,$A0,$A0,$A0,$A0,$A0,$A0,$A0
|
||||||
.byte $A0,$A0,$A0,$A0,$A0,$A0,$A0,$A0
|
.byte $A0,$A0,$A0,$A0,$A0,$A0,$A0,$A0
|
||||||
@ -60,23 +44,15 @@ file_to_read: ;.byte "MYFILE "
|
|||||||
init:
|
init:
|
||||||
jsr $fe93 ; clear COUT
|
jsr $fe93 ; clear COUT
|
||||||
jsr $fe89 ; clear KEYIN
|
jsr $fe89 ; clear KEYIN
|
||||||
; lda #<unreloc
|
|
||||||
; sta A1L
|
|
||||||
; lda #>unreloc
|
|
||||||
; sta A1H
|
|
||||||
; lda #<(unreloc+(codeend-opendir)-1)
|
|
||||||
; sta A2L
|
|
||||||
; lda #>(unreloc+(codeend-opendir)-1)
|
|
||||||
; sta A2H
|
|
||||||
ldy #0
|
|
||||||
; sty A4L
|
|
||||||
; lda #>reloc
|
|
||||||
; sta A4H
|
|
||||||
; jsr MOVE ; move mem from A1-A2 to location A4
|
|
||||||
|
|
||||||
; Create nibble table?
|
;========================
|
||||||
|
; Create nibble table
|
||||||
|
; Note: the table starts 16 bytes in, and is sparse
|
||||||
|
; so it doesn't entirely look like the DOS33 table at
|
||||||
|
|
||||||
|
ldy #0
|
||||||
ldx #3
|
ldx #3
|
||||||
L1: stx $3c ; store tempx (3?)
|
L1: stx $3c ; store tempx (3?)
|
||||||
txa ; a=x (a=3)
|
txa ; a=x (a=3)
|
||||||
asl ; a*=2 (a=6)
|
asl ; a*=2 (a=6)
|
||||||
bit $3c ; a&tempx, set N/V (a=6)
|
bit $3c ; a&tempx, set N/V (a=6)
|
||||||
@ -98,29 +74,27 @@ L3: inx ; increment x x=4, a=0f
|
|||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.align $100
|
;===========================
|
||||||
unreloc:
|
; opendir
|
||||||
;!pseudopc reloc {
|
;===========================
|
||||||
|
|
||||||
;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
|
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
|
||||||
lda #$11 ; a=$11 (VTOC?)
|
lda #$11 ; a=$11 (VTOC)
|
||||||
jsr readdirsec
|
jsr readdirsec
|
||||||
firstent:
|
firstent:
|
||||||
; jmp firstent
|
|
||||||
|
|
||||||
lda dirbuf+1
|
lda dirbuf+1
|
||||||
|
|
||||||
;lock if entry not found
|
; lock if entry not found
|
||||||
entry_not_found:
|
entry_not_found:
|
||||||
beq entry_not_found
|
beq entry_not_found
|
||||||
|
|
||||||
;read directory sector
|
; read directory sector
|
||||||
|
|
||||||
ldx dirbuf+2
|
ldx dirbuf+2
|
||||||
jsr seekread1
|
jsr seekread1
|
||||||
@ -215,33 +189,33 @@ L5:
|
|||||||
sty secsize
|
sty secsize
|
||||||
|
|
||||||
readfirst:
|
readfirst:
|
||||||
ldy #$0c
|
ldy #$0c
|
||||||
|
|
||||||
; read a file sector
|
; read a file sector
|
||||||
|
|
||||||
readnext:
|
readnext:
|
||||||
lda dirbuf, y
|
lda dirbuf, y
|
||||||
ldx dirbuf+1, y
|
ldx dirbuf+1, y
|
||||||
sty TEMPY ; ** was phy **
|
sty TEMPY ; ** was phy **
|
||||||
jsr seekread1
|
jsr seekread1
|
||||||
ldy TEMPY ; ** was ply **
|
ldy TEMPY ; ** was ply **
|
||||||
|
|
||||||
; if low count is non-zero then we are done
|
; if low count is non-zero then we are done
|
||||||
; (can happen only for partial last block)
|
; (can happen only for partial last block)
|
||||||
|
|
||||||
lda secsize
|
lda secsize
|
||||||
bne readdone
|
bne readdone
|
||||||
|
|
||||||
; continue if more than $100 bytes left
|
; continue if more than $100 bytes left
|
||||||
|
|
||||||
dec sizehi
|
dec sizehi
|
||||||
bne L6
|
bne L6
|
||||||
|
|
||||||
;set read size to min(length, $100)
|
; set read size to min(length, $100)
|
||||||
|
|
||||||
lda sizelo
|
lda sizelo
|
||||||
beq readdone
|
beq readdone
|
||||||
sta secsize
|
sta secsize
|
||||||
L6:
|
L6:
|
||||||
inc adrhi
|
inc adrhi
|
||||||
iny
|
iny
|
||||||
@ -318,10 +292,6 @@ repeat_until_right_sector:
|
|||||||
cmp reqsec
|
cmp reqsec
|
||||||
bne re_read_addr
|
bne re_read_addr
|
||||||
|
|
||||||
;blah2: jmp blah2
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;==========================
|
;==========================
|
||||||
; read sector data
|
; read sector data
|
||||||
;==========================
|
;==========================
|
||||||
@ -364,16 +334,16 @@ L14:
|
|||||||
L15:
|
L15:
|
||||||
inx
|
inx
|
||||||
beq L14
|
beq L14
|
||||||
lda (adrlo), y
|
lda (adrlo), y
|
||||||
lsr bit2tbl-$aa, x
|
lsr bit2tbl-$aa, x
|
||||||
rol
|
rol
|
||||||
lsr bit2tbl-$aa, x
|
lsr bit2tbl-$aa, x
|
||||||
rol
|
rol
|
||||||
sta (adrlo), y
|
sta (adrlo), y
|
||||||
iny
|
iny
|
||||||
cpy secsize
|
cpy secsize
|
||||||
bne L15
|
bne L15
|
||||||
rts
|
rts
|
||||||
|
|
||||||
; no tricks here, just the regular stuff
|
; no tricks here, just the regular stuff
|
||||||
|
|
||||||
@ -418,28 +388,8 @@ L21:
|
|||||||
dey ; loop 3 times
|
dey ; loop 3 times
|
||||||
bne adr_read_two_bytes
|
bne adr_read_two_bytes
|
||||||
|
|
||||||
rts ; return
|
|
||||||
|
|
||||||
;=====================
|
|
||||||
; Stepper motor delay
|
|
||||||
;=====================
|
|
||||||
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:
|
seekret:
|
||||||
rts
|
rts ; return
|
||||||
|
|
||||||
;================
|
;================
|
||||||
; SEEK
|
; SEEK
|
||||||
@ -538,9 +488,7 @@ step2: .byte $70, $2c, $26, $22, $1f, $1e, $1d, $1c
|
|||||||
|
|
||||||
sectbl: .byte $00,$0d,$0b,$09,$07,$05,$03,$01,$0e,$0c,$0a,$08,$06,$04,$02,$0f
|
sectbl: .byte $00,$0d,$0b,$09,$07,$05,$03,$01,$0e,$0c,$0a,$08,$06,$04,$02,$0f
|
||||||
|
|
||||||
.align $100
|
;.align $100
|
||||||
|
|
||||||
codeend = *
|
|
||||||
|
|
||||||
; From $BA96 of DOS33
|
; From $BA96 of DOS33
|
||||||
nibtbl = *
|
nibtbl = *
|
||||||
@ -565,8 +513,4 @@ nibtbl = *
|
|||||||
bit2tbl = nibtbl+128
|
bit2tbl = nibtbl+128
|
||||||
filbuf = bit2tbl+86
|
filbuf = bit2tbl+86
|
||||||
dataend = filbuf+4
|
dataend = filbuf+4
|
||||||
;hack to error out when code is too large for current address
|
|
||||||
;!if ((dirbuf-(dataend-opendir))&$ff00)<reloc {
|
|
||||||
;1=1
|
|
||||||
;}
|
|
||||||
;}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user