LoadFileAt

This commit is contained in:
Peter Ferrie 2019-06-17 20:05:19 -07:00
parent 529167b655
commit 8a6a8c6864
3 changed files with 67 additions and 3 deletions

View File

@ -64,6 +64,45 @@ LoadFile
sta reqcmd
lda #0 ; 0 = read into main memory
sta auxreq
sta sizelo
sta sizehi ; 0 = query load address
jsr hddopendir ; call ProRWTS2
lda ldrlo2
sta ldrlo
lda ldrhi2
sta ldrhi
dec sizehi ; read entire file (ProRWTS2 will figure out exact size)
jmp hddopendir ; exit via ProRWTS2 (must re-open the file after query)
;------------------------------------------------------------------------------
; LoadFileAt
; Load a file into memory all at once, using ProRWTS2, at the load address
; specified by the passed parameter.
;
; supports paths, see note
;
; in: stack contains 4 bytes of parameters:
; +1 address of filename
; +3 address to load file
; out: all flags clobbered
; all registers clobbered
; filename clobbered (hey, this is important, you can't call this with
; the same filename buffer twice unless you REALLY know what you're
; doing, so you should probably use one of the LOAD_* macros which
; copies the filename to a temporary buffer)
; stack set to next instruction after parameters
;------------------------------------------------------------------------------
LoadFileAt
+PARAMS_ON_STACK 4
+LDPARAM 1
+STAY namlo ; set filename
+LDPARAM 3
+STAY ldrlo ; set load address
jsr traverse ; go to subdirectory, set up filename for read
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
@ -90,8 +129,11 @@ LoadDHRFile
jsr traverse ; go to subdirectory, set up filename for read
lda #$00 ; read first $2000 bytes
sta sizelo
sta ldrlo
lda #$20
sta sizehi
asl
sta ldrhi
lda #1 ; 1 = read into aux memory
sta auxreq
lda #cmdread ; read (instead of write)
@ -99,6 +141,8 @@ LoadDHRFile
jsr hddopendir ; call ProRWTS2
lda #$20 ; read next $2000 bytes
sta sizehi
asl
sta ldrhi
dec auxreq ; 0 = read into main memory
clc ; not a subdirectory
jmp hddrdwrpart ; call ProRWTS2
@ -125,9 +169,21 @@ SaveSmallFile
+LDPARAM 3
+STAY ldrlo ; set data buffer address for ProRWTS2
jsr traverse ; go to subdirectory, set up filename for read
;;if the write address is always a fixed value then we can discard the query
lda #cmdread ; read (instead of write)
sta reqcmd
lda #0 ; 0 = read into main memory
sta sizelo
sta sizehi ; 0 = query load address
jsr hddopendir ; call ProRWTS2
lda ldrlo2
sta ldrlo
lda ldrhi2
sta ldrhi
lda #cmdwrite ; write (instead of read)
sta reqcmd
jmp hddopendir ; exit via ProRWTS2
sta sizelo ; non-zero
jmp hddopendir ; exit via ProRWTS2 (must re-open the file after query)
;------------------------------------------------------------------------------
; traverse [private]

View File

@ -17,7 +17,7 @@ ver_02 = 1
enable_floppy = 0 ;set to 1 to enable floppy drive support
poll_drive = 0 ;set to 1 to check if disk is in drive, recommended if allow_multi is enabled
allow_extend = 0 ;enable support for more than four partitions (note: it has overhead)
override_adr = 0 ;set to 1 to require an explicit load address
override_adr = 1 ;set to 1 to require an explicit load address
aligned_read = 0 ;set to 1 if all reads can be a multiple of block size
enable_readseq=0 ;set to 1 to enable reading multiple sequential times from the same file without seek
;(exposes a fixed address that can be called for either floppy or hard disk support)
@ -2222,6 +2222,14 @@ hddfoundname iny
} ;allow_subdir or allow_saplings or allow_trees or not aligned_read
} ;override_adr
;;allow query even in override mode
ldy #AUX_TYPE
lda (bloklo), y
sta ldrlo2
iny
lda (bloklo), y
sta ldrhi2
;cache KEY_POINTER
ldy #KEY_POINTER

View File

@ -99,7 +99,7 @@ cscript /nologo bin\padto.js 512 build\PREFS.CONF
%CADIUS% ADDFILE "build\%DISK%" "/%VOLUME%/" "res\FX.CONF" >>build\log
%CADIUS% ADDFILE "build\%DISK%" "/%VOLUME%/" "res\DFX.CONF" >>build\log
cscript /nologo bin\rsync.js res\title.hgr\* build\TITLE.HGR >>build\log
cscript /nologo cscript /nologo bin\buildfileinfo.js build\TITLE.HGR "06" "4000" >>build\log
cscript /nologo bin\buildfileinfo.js build\TITLE.HGR "06" "4000" >>build\log
%CADIUS% ADDFOLDER "build\%DISK%" "/%VOLUME%/TITLE.HGR" "build\TITLE.HGR" >>build\log
cscript /nologo bin\rsync.js res\title.dhgr\* build\TITLE.DHGR >>build\log
cscript /nologo bin\buildfileinfo.js build\TITLE.DHGR "06" "4000" >>build\log