some work towards PRG file loading via CBDOS
This commit is contained in:
1 parent
fcb10335a9
commit
22cf6128b9
4 files changed
+108
-37
No files matched your search
@@ -15,22 +15,7 @@ dev_sd_cmd_OPEN_EOI:
|
||||
|
||||
; XXX this dispatcher is temporary
|
||||
|
||||
; XXX add support for second card
|
||||
|
||||
lda SD_CMDFN_BUF
|
||||
cmp #'$'
|
||||
beq dev_sd_cmd_OPEN_dir
|
||||
|
||||
; XXX implement for file names
|
||||
|
||||
jmp dos_EXIT_SEC
|
||||
|
||||
|
||||
dev_sd_cmd_OPEN_dir:
|
||||
|
||||
; XXX this should be moved to common part
|
||||
|
||||
; Erase filter pattern for the directory
|
||||
; Erase filter pattern XXX this should be moved to common part
|
||||
|
||||
ldy #$0F
|
||||
lda #$A0
|
||||
@@ -39,18 +24,47 @@ dev_sd_cmd_OPEN_dir:
|
||||
dey
|
||||
bpl @lp1
|
||||
|
||||
; Copy the filter from command
|
||||
; XXX add support for second card
|
||||
|
||||
lda SD_CMDFN_BUF
|
||||
cmp #'$'
|
||||
beq dev_sd_cmd_OPEN_dir
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
dev_sd_cmd_OPEN_file:
|
||||
|
||||
; Copy the filter from command XXX this should be moved to common part and deduplicated with directory opening
|
||||
|
||||
ldy #$00
|
||||
@lp2:
|
||||
lda SD_CMDFN_BUF+1, y
|
||||
@lp1:
|
||||
lda SD_CMDFN_BUF, y
|
||||
cmp #$A0
|
||||
beq @lp2_end
|
||||
beq @lp1_end
|
||||
sta PAR_FPATTERN, y
|
||||
iny
|
||||
cpy #$10
|
||||
bne @lp2
|
||||
bne @lp1
|
||||
|
||||
@lp2_end:
|
||||
@lp1_end:
|
||||
|
||||
jmp fs_hvsr_read_file_open
|
||||
|
||||
|
||||
dev_sd_cmd_OPEN_dir:
|
||||
|
||||
; Copy the filter from command XXX this should be moved to common part and deduplicated with file opening
|
||||
|
||||
ldy #$00
|
||||
@lp1:
|
||||
lda SD_CMDFN_BUF+1, y
|
||||
cmp #$A0
|
||||
beq @lp1_end
|
||||
sta PAR_FPATTERN, y
|
||||
iny
|
||||
cpy #$10
|
||||
bne @lp1
|
||||
|
||||
@lp1_end:
|
||||
|
||||
jmp fs_hvsr_read_dir_open
|
||||
@@ -1,12 +0,0 @@
|
||||
|
||||
;
|
||||
; Hypervisor virtual filesystem - opening the file
|
||||
;
|
||||
|
||||
|
||||
fs_hvsr_read_file_open:
|
||||
|
||||
; XXX provide implementation
|
||||
|
||||
sec
|
||||
rts
|
||||
@@ -4,9 +4,6 @@
|
||||
;
|
||||
|
||||
|
||||
; XXX optimize the flow; we do not need 256-byte SD_DIRENT buffer, directory entries can be constructed directly
|
||||
|
||||
|
||||
fs_hvsr_read_dir_open:
|
||||
|
||||
; Open the directory
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
|
||||
;
|
||||
; Hypervisor virtual filesystem - opening the file
|
||||
;
|
||||
|
||||
|
||||
fs_hvsr_read_file_open:
|
||||
|
||||
; Open the directory
|
||||
|
||||
lda #$12 ; dos_opendir
|
||||
sta HTRAP00
|
||||
+nop
|
||||
|
||||
; XXX handle read errors
|
||||
|
||||
sta SD_DESC ; store directory descriptor XXX invent better name
|
||||
|
||||
; Reset status to OK
|
||||
|
||||
lda #$00
|
||||
sta PAR_TRACK
|
||||
sta PAR_SECTOR
|
||||
jsr util_status_SD
|
||||
|
||||
; XXX deduplicate part above with opening directory
|
||||
|
||||
; Read dirent structures into $1000, find the first matching file
|
||||
; Starting at $1000 VIC sees chargen, so this should be a safe place
|
||||
|
||||
jsr fs_hvsr_direntmem_prepare
|
||||
|
||||
@lp_find:
|
||||
|
||||
jsr fs_hvsr_util_nextdirentry ; fetch the next file name
|
||||
+bcs fs_hvsr_file_not_found
|
||||
|
||||
; Only accept files of type 'PRG'
|
||||
|
||||
lda PAR_FTYPE
|
||||
and #%10111111
|
||||
cmp #$02
|
||||
bne @lp_find
|
||||
|
||||
; Check if file name matches the filter
|
||||
|
||||
jsr util_dir_filter
|
||||
bne @lp_find ; if does not match, try the next entry
|
||||
|
||||
; Found the file - load it
|
||||
|
||||
; XXX provide implementation
|
||||
|
||||
|
||||
|
||||
clc
|
||||
rts
|
||||
|
||||
fs_hvsr_file_not_found:
|
||||
|
||||
jsr fs_hvsr_direntmem_restore ; restore $1000 memory content
|
||||
|
||||
ldx SD_DESC
|
||||
lda #$16 ; dos_closedir
|
||||
sta HTRAP00
|
||||
+nop
|
||||
|
||||
lda #39 ; file not found error
|
||||
jsr util_status_SD
|
||||
|
||||
sec
|
||||
rts
|
||||
Reference in new issue
Block a user