mirror of
https://github.com/a2-4am/4cade.git
synced 2025-02-20 12:29:04 +00:00
new ProRWTS2, add qkumba's subdirectory support in LoadFile
This commit is contained in:
parent
ae064cdee6
commit
7e28ff5275
2
Makefile
2
Makefile
@ -27,10 +27,10 @@ dsk: md asm
|
|||||||
cp res/_FileInformation.txt build/
|
cp res/_FileInformation.txt build/
|
||||||
$(CADIUS) ADDFILE build/"$(DISK)" "/${VOLUME}/" "res/PRODOS" >/dev/null
|
$(CADIUS) ADDFILE build/"$(DISK)" "/${VOLUME}/" "res/PRODOS" >/dev/null
|
||||||
$(CADIUS) ADDFILE build/"$(DISK)" "/${VOLUME}/" "build/LAUNCHER.SYSTEM" >/dev/null
|
$(CADIUS) ADDFILE build/"$(DISK)" "/${VOLUME}/" "build/LAUNCHER.SYSTEM" >/dev/null
|
||||||
|
$(CADIUS) CREATEFOLDER build/"$(DISK)" "/${VOLUME}/X/" >/dev/null
|
||||||
$(CADIUS) ADDFILE build/"$(DISK)" "/${VOLUME}/" "res/GAMES.CONF" >/dev/null
|
$(CADIUS) ADDFILE build/"$(DISK)" "/${VOLUME}/" "res/GAMES.CONF" >/dev/null
|
||||||
$(CADIUS) ADDFILE build/"$(DISK)" "/${VOLUME}/" "res/COVER" >/dev/null
|
$(CADIUS) ADDFILE build/"$(DISK)" "/${VOLUME}/" "res/COVER" >/dev/null
|
||||||
$(CADIUS) ADDFILE build/"$(DISK)" "/${VOLUME}/" "res/COVER.A2FC" >/dev/null
|
$(CADIUS) ADDFILE build/"$(DISK)" "/${VOLUME}/" "res/COVER.A2FC" >/dev/null
|
||||||
$(CADIUS) CREATEFOLDER build/"$(DISK)" "/${VOLUME}/X/" >/dev/null
|
|
||||||
# bin/do2po.py res/dsk/ build/po/
|
# bin/do2po.py res/dsk/ build/po/
|
||||||
# rsync -a res/dsk/*.po build/po/
|
# rsync -a res/dsk/*.po build/po/
|
||||||
# bin/extract.py build/po/ | sh >/dev/null
|
# bin/extract.py build/po/ | sh >/dev/null
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
;license:MIT
|
;license:MIT
|
||||||
;(c) 2017-8 by 4am
|
;(c) 2018 by 4am & qkumba
|
||||||
;
|
;
|
||||||
; ProRWTS2 glue functions
|
; ProRWTS2 glue functions
|
||||||
;
|
;
|
||||||
; Public functions
|
; Public functions
|
||||||
; - LoadFile
|
; - LoadFile
|
||||||
|
; - LoadDHRFile
|
||||||
;
|
;
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; LoadFile
|
; LoadFile
|
||||||
; load a file into memory all at once, using ProRWTS2
|
; load a file into memory all at once, using ProRWTS2
|
||||||
|
; supports files in subdirectories, delimited by '/' like ProDOS
|
||||||
; uses file's load address
|
; uses file's load address
|
||||||
;
|
;
|
||||||
; in: stack contains 2 bytes of parameters:
|
; in: stack contains 2 bytes of parameters:
|
||||||
@ -22,13 +24,114 @@ LoadFile
|
|||||||
+PARAMS_ON_STACK 2
|
+PARAMS_ON_STACK 2
|
||||||
+LDPARAM 1
|
+LDPARAM 1
|
||||||
+STAY namlo ; set filename
|
+STAY namlo ; set filename
|
||||||
lda #$FF ; read entire file (ProRWTS2 will figure out exact size)
|
|
||||||
|
;search for '/' character in filename
|
||||||
|
|
||||||
|
ldx #0
|
||||||
|
ldy #0
|
||||||
|
lda (namlo), y
|
||||||
|
tay
|
||||||
|
- inx
|
||||||
|
dey
|
||||||
|
bmi @go ; no '/', just do the read
|
||||||
|
lda (namlo), y
|
||||||
|
cmp #'/'
|
||||||
|
bne -
|
||||||
|
sty sizelo
|
||||||
|
txa
|
||||||
|
pha
|
||||||
|
|
||||||
|
@myreadblock
|
||||||
|
@myx80_parms
|
||||||
|
ldx #2
|
||||||
|
lda #0
|
||||||
|
jsr hddreaddirsel
|
||||||
|
lda #NAME_LENGTH
|
||||||
|
sta bloklo
|
||||||
|
lda #>(hdddirbuf - 1)
|
||||||
|
sta blokhi
|
||||||
|
|
||||||
|
;there can be only one page crossed, so we can increment here
|
||||||
|
|
||||||
|
@mynextent1
|
||||||
|
inc blokhi
|
||||||
|
@mynextent
|
||||||
|
ldy #0
|
||||||
|
lda (bloklo), y
|
||||||
|
pha
|
||||||
|
and #$0f
|
||||||
|
tax
|
||||||
|
-- iny
|
||||||
|
lda (bloklo), y
|
||||||
|
cmp (namlo), y
|
||||||
|
beq @myfoundname
|
||||||
|
|
||||||
|
;match failed, move to next directory in this block, if possible
|
||||||
|
|
||||||
|
- pla
|
||||||
|
|
||||||
|
@myskiphdr
|
||||||
|
clc
|
||||||
|
lda bloklo
|
||||||
|
adc #ENTRY_SIZE
|
||||||
|
sta bloklo
|
||||||
|
bcs @mynextent1
|
||||||
|
cmp #$ff ;4 + ($27 * $0d)
|
||||||
|
bne @mynextent
|
||||||
|
|
||||||
|
;read next directory block when we reach the end of this block
|
||||||
|
|
||||||
|
lda readbuff + NEXT_BLOCK_LO
|
||||||
|
ldx readbuff + NEXT_BLOCK_HI
|
||||||
|
bcs +
|
||||||
|
|
||||||
|
@myfoundname
|
||||||
|
dex
|
||||||
|
bne --
|
||||||
|
|
||||||
|
;parse path until last directory is seen
|
||||||
|
|
||||||
|
iny
|
||||||
|
lda (namlo), y
|
||||||
|
cmp #'/'
|
||||||
|
bne -
|
||||||
|
pla
|
||||||
|
and #$20 ;Volume Directory Header XOR subdirectory
|
||||||
|
bne @myskiphdr
|
||||||
|
tya
|
||||||
|
eor #$ff
|
||||||
|
adc sizelo
|
||||||
sta sizelo
|
sta sizelo
|
||||||
sta sizehi
|
clc
|
||||||
lda #0 ; 0 = read into main memory
|
tya
|
||||||
sta auxreq
|
adc namlo
|
||||||
|
sta namlo
|
||||||
|
|
||||||
|
;cache block number of current directory
|
||||||
|
;as starting position for subsequent searches
|
||||||
|
|
||||||
|
ldy #(KEY_POINTER + 1)
|
||||||
|
lda (bloklo), y
|
||||||
|
tax
|
||||||
|
dey
|
||||||
|
lda (bloklo), y
|
||||||
|
sta (reloc + unrhddblocklo - unrelochdd) + 1
|
||||||
|
stx (reloc + unrhddblockhi - unrelochdd) + 1
|
||||||
|
+ sta @myx80_parms + 1
|
||||||
|
stx @myx80_parms + 3
|
||||||
|
++ lda sizelo
|
||||||
|
bne @myreadblock
|
||||||
|
tay
|
||||||
|
|
||||||
|
pla
|
||||||
|
sta (namlo), y
|
||||||
|
@go
|
||||||
lda #cmdread ; read (instead of write)
|
lda #cmdread ; read (instead of write)
|
||||||
sta reqcmd
|
sta reqcmd
|
||||||
|
lda #0 ; 0 = read into main memory
|
||||||
|
sta auxreq
|
||||||
|
lda #$FF ; read entire file (ProRWTS2 will figure out exact size)
|
||||||
|
sta sizehi
|
||||||
jmp hddopendir ; exit via ProRWTS2
|
jmp hddopendir ; exit via ProRWTS2
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
100
src/prorwts2.a
100
src/prorwts2.a
@ -32,13 +32,14 @@ ver_02 = 1
|
|||||||
;requires load_high to be set for arbitrary memory access
|
;requires load_high to be set for arbitrary memory access
|
||||||
;else driver must be running from same memory target
|
;else driver must be running from same memory target
|
||||||
;i.e. running from main if accessing main, running from aux if accessing aux
|
;i.e. running from main if accessing main, running from aux if accessing aux
|
||||||
allow_saplings=0 ;enable support for saplings
|
allow_saplings=1 ;enable support for saplings
|
||||||
allow_trees = 0 ;enable support for tree files, as opposed to only seedlings and saplings
|
allow_trees = 0 ;enable support for tree files, as opposed to only seedlings and saplings
|
||||||
fast_trees = 0 ;keep tree block in memory, requires an additional 512 bytes of RAM
|
fast_trees = 0 ;keep tree block in memory, requires an additional 512 bytes of RAM
|
||||||
always_trees = 0 ;set to 1 if the only file access involves tree files
|
always_trees = 0 ;set to 1 if the only file access involves tree files
|
||||||
;not compatible with allow_subdir, allow_saplings
|
;not compatible with allow_subdir, allow_saplings
|
||||||
detect_treof = 0 ;detect EOF during read of tree files
|
detect_treof = 0 ;detect EOF during read of tree files
|
||||||
allow_sparse = 1 ;enable support for reading sparse files
|
allow_sparse = 1 ;enable support for reading sparse files
|
||||||
|
;recommended if enable_write is enabled, to prevent writing to sparse blocks
|
||||||
bounds_check = 1 ;set to 1 to prevent access beyond the end of the file
|
bounds_check = 1 ;set to 1 to prevent access beyond the end of the file
|
||||||
;but limits file size to 64k-2 bytes.
|
;but limits file size to 64k-2 bytes.
|
||||||
no_interrupts= 0 ;set to 1 to disable interrupts across calls
|
no_interrupts= 0 ;set to 1 to disable interrupts across calls
|
||||||
@ -194,6 +195,7 @@ ver_02 = 1
|
|||||||
|
|
||||||
D1S1 = 1 ;disk 1 side 1 volume ID if rwts_mode enabled
|
D1S1 = 1 ;disk 1 side 1 volume ID if rwts_mode enabled
|
||||||
|
|
||||||
|
|
||||||
init jsr SETKBD
|
init jsr SETKBD
|
||||||
jsr SETVID
|
jsr SETVID
|
||||||
lda DEVNUM
|
lda DEVNUM
|
||||||
@ -263,6 +265,9 @@ init jsr SETKBD
|
|||||||
|
|
||||||
;find current directory name in directory
|
;find current directory name in directory
|
||||||
|
|
||||||
|
sec
|
||||||
|
php
|
||||||
|
|
||||||
readblock jsr MLI
|
readblock jsr MLI
|
||||||
!byte $80
|
!byte $80
|
||||||
!word x80_parms
|
!word x80_parms
|
||||||
@ -284,7 +289,8 @@ inextent ldy #0
|
|||||||
;match failed, move to next directory in this block, if possible
|
;match failed, move to next directory in this block, if possible
|
||||||
|
|
||||||
- pla
|
- pla
|
||||||
clc
|
|
||||||
|
skiphdr clc
|
||||||
lda bloklo
|
lda bloklo
|
||||||
adc #ENTRY_SIZE
|
adc #ENTRY_SIZE
|
||||||
sta bloklo
|
sta bloklo
|
||||||
@ -313,7 +319,17 @@ ifoundname dex
|
|||||||
lda (namlo), y
|
lda (namlo), y
|
||||||
cmp #'/'
|
cmp #'/'
|
||||||
bne -
|
bne -
|
||||||
tya
|
pla
|
||||||
|
and #$20 ;Volume Directory Header XOR subdirectory
|
||||||
|
beq adjpath
|
||||||
|
pla
|
||||||
|
clc
|
||||||
|
php
|
||||||
|
lsr
|
||||||
|
bcc skiphdr
|
||||||
|
inx
|
||||||
|
|
||||||
|
adjpath tya
|
||||||
eor #$ff
|
eor #$ff
|
||||||
adc sizelo
|
adc sizelo
|
||||||
sta sizelo
|
sta sizelo
|
||||||
@ -321,9 +337,8 @@ ifoundname dex
|
|||||||
tya
|
tya
|
||||||
adc namlo
|
adc namlo
|
||||||
sta namlo
|
sta namlo
|
||||||
pla
|
dex
|
||||||
and #$20 ;Volume Directory Header XOR subdirectory
|
beq ++
|
||||||
bne ++
|
|
||||||
|
|
||||||
;cache block number of current directory
|
;cache block number of current directory
|
||||||
;as starting position for subsequent searches
|
;as starting position for subsequent searches
|
||||||
@ -343,6 +358,7 @@ ifoundname dex
|
|||||||
stx x80_parms + 5
|
stx x80_parms + 5
|
||||||
++ lda sizelo
|
++ lda sizelo
|
||||||
bne readblock
|
bne readblock
|
||||||
|
pla
|
||||||
|
|
||||||
;unit to slot for SmartPort interface
|
;unit to slot for SmartPort interface
|
||||||
|
|
||||||
@ -497,9 +513,6 @@ unrhddblockhi = *
|
|||||||
lda #0
|
lda #0
|
||||||
hddreaddir1 jsr hddreaddirsel
|
hddreaddir1 jsr hddreaddirsel
|
||||||
|
|
||||||
;include volume directory header in count
|
|
||||||
|
|
||||||
hddreaddir
|
|
||||||
hddfirstent lda #NAME_LENGTH
|
hddfirstent lda #NAME_LENGTH
|
||||||
sta bloklo
|
sta bloklo
|
||||||
lda #>(hdddirbuf - 1)
|
lda #>(hdddirbuf - 1)
|
||||||
@ -580,7 +593,7 @@ filename !byte filename_e-filename_b
|
|||||||
filename_b !text "diskimage.dsk"
|
filename_b !text "diskimage.dsk"
|
||||||
filename_e
|
filename_e
|
||||||
} else { ;rwts_mode = 0
|
} else { ;rwts_mode = 0
|
||||||
rts
|
rts
|
||||||
} ;rwts_mode
|
} ;rwts_mode
|
||||||
|
|
||||||
c7_parms !byte 1
|
c7_parms !byte 1
|
||||||
@ -625,20 +638,17 @@ unrblockhi = unrelocdsk + (* - reloc)
|
|||||||
lda #0
|
lda #0
|
||||||
jsr readdirsel
|
jsr readdirsel
|
||||||
|
|
||||||
;include volume directory header in count
|
readdir ;note that calling this location directly limits subdirectories to 14 entries!
|
||||||
|
lda #NAME_LENGTH + ENTRY_SIZE
|
||||||
readdir
|
firstent sta bloklo
|
||||||
!if might_exist = 1 {
|
|
||||||
ldx dirbuf + FILE_COUNT ;assuming only 256 files per subdirectory
|
|
||||||
inx
|
|
||||||
stx entries
|
|
||||||
} ;might_exist
|
|
||||||
|
|
||||||
firstent lda #NAME_LENGTH
|
|
||||||
sta bloklo
|
|
||||||
lda #>(dirbuf - 1)
|
lda #>(dirbuf - 1)
|
||||||
sta blokhi
|
sta blokhi
|
||||||
|
|
||||||
|
!if might_exist = 1 {
|
||||||
|
lda dirbuf + FILE_COUNT ;assuming only 256 files per subdirectory
|
||||||
|
sta entries
|
||||||
|
} ;might_exist
|
||||||
|
|
||||||
;there can be only one page crossed, so we can increment here
|
;there can be only one page crossed, so we can increment here
|
||||||
|
|
||||||
nextent1 inc blokhi
|
nextent1 inc blokhi
|
||||||
@ -713,6 +723,7 @@ unrdrvoff2 = unrelocdsk + (* - reloc)
|
|||||||
ldx dirbuf + NEXT_BLOCK_LO
|
ldx dirbuf + NEXT_BLOCK_LO
|
||||||
lda dirbuf + NEXT_BLOCK_HI
|
lda dirbuf + NEXT_BLOCK_HI
|
||||||
jsr readdirsec
|
jsr readdirsec
|
||||||
|
lda #NAME_LENGTH
|
||||||
bne firstent
|
bne firstent
|
||||||
|
|
||||||
foundname iny
|
foundname iny
|
||||||
@ -819,15 +830,15 @@ foundname iny
|
|||||||
tax
|
tax
|
||||||
!if (allow_subdir + allow_saplings + allow_trees) > 0 {
|
!if (allow_subdir + allow_saplings + allow_trees) > 0 {
|
||||||
sta dirbuf
|
sta dirbuf
|
||||||
!if fast_trees = 0 {
|
!if (allow_trees + (fast_trees xor 1)) > 1 {
|
||||||
sta treeblklo
|
sta treeblklo
|
||||||
} ;fast_trees
|
} ;allow_trees = 1 and fast_trees = 0
|
||||||
iny
|
iny
|
||||||
lda (bloklo), y
|
lda (bloklo), y
|
||||||
sta dirbuf + 256
|
sta dirbuf + 256
|
||||||
!if fast_trees = 0 {
|
!if (allow_trees + (fast_trees xor 1)) > 1 {
|
||||||
sta treeblkhi
|
sta treeblkhi
|
||||||
} ;fast_trees
|
} ;allow_trees = 1 and fast_trees = 0
|
||||||
!if (allow_trees and always_trees) = 0 {
|
!if (allow_trees and always_trees) = 0 {
|
||||||
plp
|
plp
|
||||||
bpl ++
|
bpl ++
|
||||||
@ -1392,6 +1403,7 @@ readdirsel
|
|||||||
pha
|
pha
|
||||||
phx
|
phx
|
||||||
} ;ver_02
|
} ;ver_02
|
||||||
|
;;; jsr poll
|
||||||
|
|
||||||
unrdrvon4 = unrelocdsk + (* - reloc)
|
unrdrvon4 = unrelocdsk + (* - reloc)
|
||||||
lda MOTORON
|
lda MOTORON
|
||||||
@ -1899,7 +1911,7 @@ unrhddblocklo = unrelochdd + (* - reloc)
|
|||||||
ldx #2
|
ldx #2
|
||||||
unrhddblockhi = unrelochdd + (* - reloc)
|
unrhddblockhi = unrelochdd + (* - reloc)
|
||||||
lda #0
|
lda #0
|
||||||
hddreaddir1 jsr hddreaddirsel
|
jsr hddreaddirsel
|
||||||
|
|
||||||
!if enable_floppy = 1 {
|
!if enable_floppy = 1 {
|
||||||
!if (* - hddopendir) < (readdir - opendir) {
|
!if (* - hddopendir) < (readdir - opendir) {
|
||||||
@ -1908,20 +1920,17 @@ hddreaddir1 jsr hddreaddirsel
|
|||||||
}
|
}
|
||||||
} ;enable_floppy
|
} ;enable_floppy
|
||||||
|
|
||||||
;include volume directory header in count
|
hddreaddir ;note that calling this location directly limits subdirectories to 14 entries!
|
||||||
|
lda #NAME_LENGTH + ENTRY_SIZE
|
||||||
hddreaddir
|
hddfirstent sta bloklo
|
||||||
!if might_exist = 1 {
|
|
||||||
ldx hdddirbuf + FILE_COUNT ;assuming only 256 files per subdirectory
|
|
||||||
inx
|
|
||||||
stx entries
|
|
||||||
} ;might_exist
|
|
||||||
|
|
||||||
hddfirstent lda #NAME_LENGTH
|
|
||||||
sta bloklo
|
|
||||||
lda #>(hdddirbuf - 1)
|
lda #>(hdddirbuf - 1)
|
||||||
sta blokhi
|
sta blokhi
|
||||||
|
|
||||||
|
!if might_exist = 1 {
|
||||||
|
lda hdddirbuf + FILE_COUNT ;assuming only 256 files per subdirectory
|
||||||
|
sta entries
|
||||||
|
} ;might_exist
|
||||||
|
|
||||||
;there can be only one page crossed, so we can increment here
|
;there can be only one page crossed, so we can increment here
|
||||||
|
|
||||||
hddnextent1 inc blokhi
|
hddnextent1 inc blokhi
|
||||||
@ -1990,12 +1999,9 @@ hddnextent ldy #0
|
|||||||
|
|
||||||
ldx hdddirbuf + NEXT_BLOCK_LO
|
ldx hdddirbuf + NEXT_BLOCK_LO
|
||||||
lda hdddirbuf + NEXT_BLOCK_HI
|
lda hdddirbuf + NEXT_BLOCK_HI
|
||||||
!if might_exist = 1 {
|
|
||||||
jsr hddreaddirsec
|
jsr hddreaddirsec
|
||||||
bcc hddfirstent
|
lda #NAME_LENGTH
|
||||||
} else { ;might_exist = 0
|
bne hddfirstent
|
||||||
bcs hddreaddir1
|
|
||||||
} ;might_exist
|
|
||||||
|
|
||||||
hddfoundname iny
|
hddfoundname iny
|
||||||
lda (bloklo), y
|
lda (bloklo), y
|
||||||
@ -2101,13 +2107,15 @@ hddfoundname iny
|
|||||||
tax
|
tax
|
||||||
!if (allow_subdir + allow_saplings + allow_trees) > 0 {
|
!if (allow_subdir + allow_saplings + allow_trees) > 0 {
|
||||||
sta hdddirbuf
|
sta hdddirbuf
|
||||||
!if fast_trees = 0 {
|
!if (allow_trees + (fast_trees xor 1)) > 1 {
|
||||||
} ;fast_trees
|
sta treeblklo
|
||||||
|
} ;allow_trees = 1 and fast_trees = 0
|
||||||
iny
|
iny
|
||||||
lda (bloklo), y
|
lda (bloklo), y
|
||||||
sta hdddirbuf + 256
|
sta hdddirbuf + 256
|
||||||
!if fast_trees = 0 {
|
!if (allow_trees + (fast_trees xor 1)) > 1 {
|
||||||
} ;fast_trees
|
sta treeblkhi
|
||||||
|
} ;allow_trees = 1 and fast_trees = 0
|
||||||
!if (allow_trees and always_trees) = 0 {
|
!if (allow_trees and always_trees) = 0 {
|
||||||
plp
|
plp
|
||||||
bpl ++
|
bpl ++
|
||||||
|
Loading…
x
Reference in New Issue
Block a user