2018-08-31 04:31:54 +00:00
|
|
|
;license:MIT
|
2018-09-01 01:04:00 +00:00
|
|
|
;(c) 2018 by 4am & qkumba
|
2018-08-31 04:31:54 +00:00
|
|
|
;
|
|
|
|
; ProRWTS2 glue functions
|
|
|
|
;
|
|
|
|
; Public functions
|
|
|
|
; - LoadFile
|
2018-09-01 01:04:00 +00:00
|
|
|
; - LoadDHRFile
|
2018-08-31 04:31:54 +00:00
|
|
|
;
|
|
|
|
|
2018-10-28 15:44:26 +00:00
|
|
|
gRootDirectory
|
|
|
|
!word $FDFD
|
|
|
|
|
2018-08-31 04:31:54 +00:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; LoadFile
|
|
|
|
; load a file into memory all at once, using ProRWTS2
|
2018-09-01 01:04:00 +00:00
|
|
|
; supports files in subdirectories, delimited by '/' like ProDOS
|
2018-08-31 04:31:54 +00:00
|
|
|
; uses file's load address
|
|
|
|
;
|
|
|
|
; in: stack contains 2 bytes of parameters:
|
|
|
|
; +1 address of filename
|
|
|
|
; out: all flags clobbered
|
|
|
|
; all registers clobbered
|
|
|
|
; stack set to next instruction after parameters
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
LoadFile
|
|
|
|
+PARAMS_ON_STACK 2
|
|
|
|
+LDPARAM 1
|
|
|
|
+STAY namlo ; set filename
|
2018-09-01 01:04:00 +00:00
|
|
|
|
2018-10-28 18:04:52 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; LoadDHRFile
|
|
|
|
; load .A2FC file (uncompressed double hi-res graphics) into memory
|
|
|
|
; all at once, using ProRWTS2
|
|
|
|
; first $2000 bytes of file are loaded into auxiliary memory $2000..$3FFF
|
|
|
|
; second $2000 bytes of file are loaded into main memory $2000..$3FFF
|
|
|
|
;
|
|
|
|
; in: stack contains 2 bytes of parameters:
|
|
|
|
; +1 address of filename
|
|
|
|
; out: all flags clobbered
|
|
|
|
; all registers clobbered
|
|
|
|
; stack set to next instruction after parameters
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
LoadDHRFile
|
|
|
|
+PARAMS_ON_STACK 2
|
|
|
|
+LDPARAM 1
|
|
|
|
+STAY namlo ; set filename
|
|
|
|
|
|
|
|
jsr traverse ; go to subdirectory, set up filename for read
|
|
|
|
|
|
|
|
lda #$00 ; read first $2000 bytes
|
|
|
|
sta sizelo
|
|
|
|
lda #$20
|
|
|
|
sta sizehi
|
|
|
|
lda #1 ; 1 = read into aux memory
|
|
|
|
sta auxreq
|
|
|
|
lda #cmdread ; read (instead of write)
|
|
|
|
sta reqcmd
|
|
|
|
jsr hddopendir ; call ProRWTS2
|
|
|
|
lda #$20 ; read next $2000 bytes
|
|
|
|
sta sizehi
|
|
|
|
dec auxreq ; 0 = read into main memory
|
|
|
|
jmp hddrdwrpart ; call ProRWTS2
|
|
|
|
|
|
|
|
traverse
|
2018-10-28 15:44:26 +00:00
|
|
|
+LDAY gRootDirectory
|
|
|
|
sta @myreadblock+1
|
|
|
|
sty @myreadblock+3 ; reset 'root' directory (saved at program start)
|
|
|
|
|
2018-09-01 01:04:00 +00:00
|
|
|
;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
|
2018-08-31 04:31:54 +00:00
|
|
|
sta sizelo
|
2018-09-01 01:04:00 +00:00
|
|
|
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
|
2018-10-28 18:04:52 +00:00
|
|
|
rts
|