2019-10-09 17:15:33 +00:00
|
|
|
;license:MIT
|
2020-03-12 19:36:28 +00:00
|
|
|
;(c) 2018-2020 by 4am & qkumba
|
2019-10-09 17:15:33 +00:00
|
|
|
;
|
|
|
|
; ProRWTS2 glue functions
|
|
|
|
;
|
|
|
|
; /!\ These live in LC RAM 2 and rely on the ProRWTS code which is also in LC RAM 2. /!\
|
|
|
|
; Code in LC RAM 1 (which is most program code) should call the functions in glue.prorwts2
|
|
|
|
; and parse.prefs which handle bank switching for you.
|
|
|
|
|
2019-10-09 17:04:39 +00:00
|
|
|
LoadFileInternal
|
2021-10-13 22:58:26 +00:00
|
|
|
ldx #0 ; 0 = read into main memory
|
2020-03-12 19:36:28 +00:00
|
|
|
LoadFileAuxInternal
|
2019-10-09 17:04:39 +00:00
|
|
|
+LDADDR gPathname
|
2021-10-15 20:00:40 +00:00
|
|
|
LoadFileDirect
|
2020-03-24 20:30:14 +00:00
|
|
|
+ST16 namlo ; set filename
|
2021-10-13 22:58:26 +00:00
|
|
|
txa
|
|
|
|
pha
|
2019-10-09 17:04:39 +00:00
|
|
|
jsr traverse ; go to subdirectory, set up filename for read
|
|
|
|
lda #cmdread ; read (instead of write)
|
|
|
|
sta reqcmd
|
2020-03-12 19:36:28 +00:00
|
|
|
lsr
|
2019-10-09 17:04:39 +00:00
|
|
|
sta auxreq
|
2021-10-13 22:58:26 +00:00
|
|
|
lda ldrhi
|
2019-10-09 17:04:39 +00:00
|
|
|
bne + ; if caller provided a load address, use it
|
|
|
|
sta sizelo ; otherwise query the load address from file metadata
|
|
|
|
sta sizehi ; 0 = query load address
|
|
|
|
jsr hddopendir ; call ProRWTS2
|
2020-03-24 20:30:14 +00:00
|
|
|
+LD16 ldrlo2
|
|
|
|
+ST16 ldrlo
|
2019-10-09 17:04:39 +00:00
|
|
|
+ lda #$FF ; read entire file (ProRWTS2 will figure out exact size)
|
2021-11-04 16:47:49 +00:00
|
|
|
LoadFileInternal_SizePatch
|
2019-10-09 17:04:39 +00:00
|
|
|
sta sizehi
|
2021-10-13 22:58:26 +00:00
|
|
|
pla
|
2020-03-12 19:36:28 +00:00
|
|
|
sta auxreq
|
|
|
|
JumpOpen
|
2019-10-09 17:04:39 +00:00
|
|
|
jmp hddopendir ; exit via ProRWTS2
|
|
|
|
|
|
|
|
LoadDHRFileInternal
|
|
|
|
+LDADDR gPathname
|
2020-03-24 20:30:14 +00:00
|
|
|
+ST16 namlo ; set filename
|
2019-10-09 17:04:39 +00:00
|
|
|
jsr traverse ; go to subdirectory, set up filename for read
|
|
|
|
lda #$20
|
|
|
|
sta sizehi
|
|
|
|
asl
|
|
|
|
sta ldrhi ; into $4000
|
|
|
|
lda #cmdread ; read (instead of write)
|
|
|
|
sta reqcmd
|
2020-03-12 19:36:28 +00:00
|
|
|
;;lda #1 ; 1 = read into aux memory
|
|
|
|
sta auxreq
|
|
|
|
lsr ; read first $2000 bytes
|
|
|
|
sta sizelo
|
|
|
|
sta ldrlo
|
2019-10-09 17:04:39 +00:00
|
|
|
jsr hddopendir ; call ProRWTS2
|
|
|
|
lda #$20 ; read next $2000 bytes
|
|
|
|
sta sizehi
|
|
|
|
dec auxreq ; 0 = read into main memory
|
|
|
|
clc ; not a subdirectory
|
|
|
|
jmp hddrdwrpart ; call ProRWTS2
|
|
|
|
|
|
|
|
SaveSmallFileInternal
|
|
|
|
+LDADDR gPathname
|
2020-03-24 20:30:14 +00:00
|
|
|
+ST16 namlo ; set filename for ProRWTS2
|
2019-10-09 17:04:39 +00:00
|
|
|
jsr traverse ; go to subdirectory, set up filename for read
|
2019-12-03 18:02:39 +00:00
|
|
|
;lda #cmdread ; read (instead of write)
|
|
|
|
;sta reqcmd
|
2019-10-09 17:04:39 +00:00
|
|
|
lda #0 ; 0 = read into main memory
|
|
|
|
sta sizelo
|
2019-12-03 18:02:39 +00:00
|
|
|
;sta sizehi ; 0 = query load address
|
|
|
|
;jsr hddopendir ; call ProRWTS2
|
|
|
|
;lda ldrlo2
|
2019-10-09 17:04:39 +00:00
|
|
|
sta ldrlo
|
2021-11-10 04:21:01 +00:00
|
|
|
lda #>kGlobalPrefsBuffer ;lda ldrhi2
|
2019-10-09 17:04:39 +00:00
|
|
|
sta ldrhi
|
|
|
|
lda #cmdwrite ; write (instead of read)
|
|
|
|
sta reqcmd
|
|
|
|
sta sizehi ; 512 bytes
|
2020-03-12 19:36:28 +00:00
|
|
|
bne JumpOpen ; exit via ProRWTS2 (must re-open the file after query)
|