4cade/src/glue.prorwts2.lc2.a

92 lines
3.3 KiB
Plaintext
Raw Normal View History

;license:MIT
2020-03-12 19:36:28 +00:00
;(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.
2019-10-09 17:04:39 +00:00
LoadFileInternal
2020-03-12 19:36:28 +00:00
lda #0 ; 0 = read into main memory
LoadFileAuxInternal
sta @auxreq+1 ; call with A=1 to load directly into aux memory
2019-10-09 17:04:39 +00:00
+LDADDR gPathname
2020-05-23 17:10:07 +00:00
!if RELBASE != $2000 {
!ifdef PASS2 {
} else { ;PASS2
2020-05-23 22:47:16 +00:00
!if * != LoadFileDirect {
!error "LoadFileDirect=",*, ", fix constants.a"
2020-05-23 17:10:07 +00:00
}
}
}
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 #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
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
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)
sta sizehi
!if RELBASE != $2000 {
!ifdef PASS2 {
} else { ;PASS2
!if *+1 != iAuxReq {
!error "iAuxReq=",*+1, ", fix constants.a"
}
}
}
2020-03-12 19:36:28 +00:00
@auxreq
lda #0
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
2019-12-03 18:02:39 +00:00
lda #$80 ;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)