4cade/src/glue.prorwts2.lc2.a
2020-05-23 15:47:16 -07:00

84 lines
3.1 KiB
Plaintext

;license:MIT
;(c) 2018-2020 by 4am & qkumba
;
; 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.
LoadFileInternal
lda #0 ; 0 = read into main memory
LoadFileAuxInternal
sta @auxreq+1 ; call with A=1 to load directly into aux memory
+LDADDR gPathname
!if RELBASE != $2000 {
!ifdef PASS2 {
} else { ;PASS2
!if * != LoadFileDirect {
!error "LoadFileDirect=",*, ", fix constants.a"
}
}
}
+ST16 namlo ; set filename
jsr traverse ; go to subdirectory, set up filename for read
lda #cmdread ; read (instead of write)
sta reqcmd
lsr
sta auxreq
lda ldrlo+1
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
+LD16 ldrlo2
+ST16 ldrlo
+ lda #$FF ; read entire file (ProRWTS2 will figure out exact size)
sta sizehi
@auxreq
lda #0
sta auxreq
JumpOpen
jmp hddopendir ; exit via ProRWTS2
LoadDHRFileInternal
+LDADDR gPathname
+ST16 namlo ; set filename
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
;;lda #1 ; 1 = read into aux memory
sta auxreq
lsr ; read first $2000 bytes
sta sizelo
sta ldrlo
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
+ST16 namlo ; set filename for ProRWTS2
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 sizelo
;sta sizehi ; 0 = query load address
;jsr hddopendir ; call ProRWTS2
;lda ldrlo2
sta ldrlo
lda #$80 ;lda ldrhi2
sta ldrhi
lda #cmdwrite ; write (instead of read)
sta reqcmd
sta sizehi ; 512 bytes
bne JumpOpen ; exit via ProRWTS2 (must re-open the file after query)