mirror of
https://github.com/a2-4am/4cade.git
synced 2024-06-01 23:41:39 +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/
|
||||
$(CADIUS) ADDFILE build/"$(DISK)" "/${VOLUME}/" "res/PRODOS" >/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/COVER" >/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/
|
||||
# rsync -a res/dsk/*.po build/po/
|
||||
# bin/extract.py build/po/ | sh >/dev/null
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
;license:MIT
|
||||
;(c) 2017-8 by 4am
|
||||
;(c) 2018 by 4am & qkumba
|
||||
;
|
||||
; ProRWTS2 glue functions
|
||||
;
|
||||
; Public functions
|
||||
; - LoadFile
|
||||
; - LoadDHRFile
|
||||
;
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; LoadFile
|
||||
; load a file into memory all at once, using ProRWTS2
|
||||
; supports files in subdirectories, delimited by '/' like ProDOS
|
||||
; uses file's load address
|
||||
;
|
||||
; in: stack contains 2 bytes of parameters:
|
||||
|
@ -22,13 +24,114 @@ LoadFile
|
|||
+PARAMS_ON_STACK 2
|
||||
+LDPARAM 1
|
||||
+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 sizehi
|
||||
lda #0 ; 0 = read into main memory
|
||||
sta auxreq
|
||||
clc
|
||||
tya
|
||||
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)
|
||||
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
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
|
|
@ -32,13 +32,14 @@ ver_02 = 1
|
|||
;requires load_high to be set for arbitrary memory access
|
||||
;else driver must be running from same memory target
|
||||
;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
|
||||
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
|
||||
;not compatible with allow_subdir, allow_saplings
|
||||
detect_treof = 0 ;detect EOF during read of tree 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
|
||||
;but limits file size to 64k-2 bytes.
|
||||
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
|
||||
|
||||
|
||||
init jsr SETKBD
|
||||
jsr SETVID
|
||||
lda DEVNUM
|
||||
|
@ -263,6 +265,9 @@ init jsr SETKBD
|
|||
|
||||
;find current directory name in directory
|
||||
|
||||
sec
|
||||
php
|
||||
|
||||
readblock jsr MLI
|
||||
!byte $80
|
||||
!word x80_parms
|
||||
|
@ -284,7 +289,8 @@ inextent ldy #0
|
|||
;match failed, move to next directory in this block, if possible
|
||||
|
||||
- pla
|
||||
clc
|
||||
|
||||
skiphdr clc
|
||||
lda bloklo
|
||||
adc #ENTRY_SIZE
|
||||
sta bloklo
|
||||
|
@ -313,7 +319,17 @@ ifoundname dex
|
|||
lda (namlo), y
|
||||
cmp #'/'
|
||||
bne -
|
||||
tya
|
||||
pla
|
||||
and #$20 ;Volume Directory Header XOR subdirectory
|
||||
beq adjpath
|
||||
pla
|
||||
clc
|
||||
php
|
||||
lsr
|
||||
bcc skiphdr
|
||||
inx
|
||||
|
||||
adjpath tya
|
||||
eor #$ff
|
||||
adc sizelo
|
||||
sta sizelo
|
||||
|
@ -321,9 +337,8 @@ ifoundname dex
|
|||
tya
|
||||
adc namlo
|
||||
sta namlo
|
||||
pla
|
||||
and #$20 ;Volume Directory Header XOR subdirectory
|
||||
bne ++
|
||||
dex
|
||||
beq ++
|
||||
|
||||
;cache block number of current directory
|
||||
;as starting position for subsequent searches
|
||||
|
@ -343,6 +358,7 @@ ifoundname dex
|
|||
stx x80_parms + 5
|
||||
++ lda sizelo
|
||||
bne readblock
|
||||
pla
|
||||
|
||||
;unit to slot for SmartPort interface
|
||||
|
||||
|
@ -497,9 +513,6 @@ unrhddblockhi = *
|
|||
lda #0
|
||||
hddreaddir1 jsr hddreaddirsel
|
||||
|
||||
;include volume directory header in count
|
||||
|
||||
hddreaddir
|
||||
hddfirstent lda #NAME_LENGTH
|
||||
sta bloklo
|
||||
lda #>(hdddirbuf - 1)
|
||||
|
@ -625,20 +638,17 @@ unrblockhi = unrelocdsk + (* - reloc)
|
|||
lda #0
|
||||
jsr readdirsel
|
||||
|
||||
;include volume directory header in count
|
||||
|
||||
readdir
|
||||
!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
|
||||
readdir ;note that calling this location directly limits subdirectories to 14 entries!
|
||||
lda #NAME_LENGTH + ENTRY_SIZE
|
||||
firstent sta bloklo
|
||||
lda #>(dirbuf - 1)
|
||||
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
|
||||
|
||||
nextent1 inc blokhi
|
||||
|
@ -713,6 +723,7 @@ unrdrvoff2 = unrelocdsk + (* - reloc)
|
|||
ldx dirbuf + NEXT_BLOCK_LO
|
||||
lda dirbuf + NEXT_BLOCK_HI
|
||||
jsr readdirsec
|
||||
lda #NAME_LENGTH
|
||||
bne firstent
|
||||
|
||||
foundname iny
|
||||
|
@ -819,15 +830,15 @@ foundname iny
|
|||
tax
|
||||
!if (allow_subdir + allow_saplings + allow_trees) > 0 {
|
||||
sta dirbuf
|
||||
!if fast_trees = 0 {
|
||||
!if (allow_trees + (fast_trees xor 1)) > 1 {
|
||||
sta treeblklo
|
||||
} ;fast_trees
|
||||
} ;allow_trees = 1 and fast_trees = 0
|
||||
iny
|
||||
lda (bloklo), y
|
||||
sta dirbuf + 256
|
||||
!if fast_trees = 0 {
|
||||
!if (allow_trees + (fast_trees xor 1)) > 1 {
|
||||
sta treeblkhi
|
||||
} ;fast_trees
|
||||
} ;allow_trees = 1 and fast_trees = 0
|
||||
!if (allow_trees and always_trees) = 0 {
|
||||
plp
|
||||
bpl ++
|
||||
|
@ -1392,6 +1403,7 @@ readdirsel
|
|||
pha
|
||||
phx
|
||||
} ;ver_02
|
||||
;;; jsr poll
|
||||
|
||||
unrdrvon4 = unrelocdsk + (* - reloc)
|
||||
lda MOTORON
|
||||
|
@ -1899,7 +1911,7 @@ unrhddblocklo = unrelochdd + (* - reloc)
|
|||
ldx #2
|
||||
unrhddblockhi = unrelochdd + (* - reloc)
|
||||
lda #0
|
||||
hddreaddir1 jsr hddreaddirsel
|
||||
jsr hddreaddirsel
|
||||
|
||||
!if enable_floppy = 1 {
|
||||
!if (* - hddopendir) < (readdir - opendir) {
|
||||
|
@ -1908,20 +1920,17 @@ hddreaddir1 jsr hddreaddirsel
|
|||
}
|
||||
} ;enable_floppy
|
||||
|
||||
;include volume directory header in count
|
||||
|
||||
hddreaddir
|
||||
!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
|
||||
hddreaddir ;note that calling this location directly limits subdirectories to 14 entries!
|
||||
lda #NAME_LENGTH + ENTRY_SIZE
|
||||
hddfirstent sta bloklo
|
||||
lda #>(hdddirbuf - 1)
|
||||
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
|
||||
|
||||
hddnextent1 inc blokhi
|
||||
|
@ -1990,12 +1999,9 @@ hddnextent ldy #0
|
|||
|
||||
ldx hdddirbuf + NEXT_BLOCK_LO
|
||||
lda hdddirbuf + NEXT_BLOCK_HI
|
||||
!if might_exist = 1 {
|
||||
jsr hddreaddirsec
|
||||
bcc hddfirstent
|
||||
} else { ;might_exist = 0
|
||||
bcs hddreaddir1
|
||||
} ;might_exist
|
||||
lda #NAME_LENGTH
|
||||
bne hddfirstent
|
||||
|
||||
hddfoundname iny
|
||||
lda (bloklo), y
|
||||
|
@ -2101,13 +2107,15 @@ hddfoundname iny
|
|||
tax
|
||||
!if (allow_subdir + allow_saplings + allow_trees) > 0 {
|
||||
sta hdddirbuf
|
||||
!if fast_trees = 0 {
|
||||
} ;fast_trees
|
||||
!if (allow_trees + (fast_trees xor 1)) > 1 {
|
||||
sta treeblklo
|
||||
} ;allow_trees = 1 and fast_trees = 0
|
||||
iny
|
||||
lda (bloklo), y
|
||||
sta hdddirbuf + 256
|
||||
!if fast_trees = 0 {
|
||||
} ;fast_trees
|
||||
!if (allow_trees + (fast_trees xor 1)) > 1 {
|
||||
sta treeblkhi
|
||||
} ;allow_trees = 1 and fast_trees = 0
|
||||
!if (allow_trees and always_trees) = 0 {
|
||||
plp
|
||||
bpl ++
|
||||
|
|
Loading…
Reference in New Issue
Block a user