diff --git a/src/dos_m65/,aliases_dos.s b/src/dos_m65/,aliases_dos.s index cdcad8a2..61f61fa3 100644 --- a/src/dos_m65/,aliases_dos.s +++ b/src/dos_m65/,aliases_dos.s @@ -177,7 +177,7 @@ ; Memory shadow, needed for SD card support - !addr SD_MEMSHADOW_BUF = $A800 ; 256 byte buffer for preserving original memory content + !addr MEMSHADOW_BUF = $A800 ; 256 byte buffer for preserving original memory content ; Command/filename buffers, 256 bytes each diff --git a/src/dos_m65/filesystem_vfs/fs_vfs_nextfileblock.s b/src/dos_m65/filesystem_vfs/fs_vfs_nextfileblock.s index e787af5f..d804f8e3 100644 --- a/src/dos_m65/filesystem_vfs/fs_vfs_nextfileblock.s +++ b/src/dos_m65/filesystem_vfs/fs_vfs_nextfileblock.s @@ -66,7 +66,7 @@ fs_vfs_nextfileblock: fs_vfs_file_not_found: - jsr fs_vfs_direntmem_restore ; restore $1000 memory content + jsr util_shadow_restore ; restore $1000 memory content ldx SD_DESC lda #$16 ; dos_closedir diff --git a/src/dos_m65/filesystem_vfs/fs_vfs_read_dir.s b/src/dos_m65/filesystem_vfs/fs_vfs_read_dir.s index f1ca167b..ad99c314 100644 --- a/src/dos_m65/filesystem_vfs/fs_vfs_read_dir.s +++ b/src/dos_m65/filesystem_vfs/fs_vfs_read_dir.s @@ -49,9 +49,9 @@ fs_vfs_read_dir: ; Read dirent structure into $1000, process it, restore the memory content. ; Starting at $1000 VIC sees chargen, so this should be a safe place - jsr fs_vfs_direntmem_prepare + jsr util_shadow jsr fs_vfs_nextdirentry - jsr fs_vfs_direntmem_restore ; processor status is preserved + jsr util_shadow_restore ; processor status is preserved ; If nothing to read, output 'blocks free' @@ -112,34 +112,3 @@ fs_vfs_read_dir_blocksfree: clc rts - -; -; Helper routines -; - -fs_vfs_direntmem_prepare: - - ldx #$00 -@1: - ldy $1000, x - sty SD_MEMSHADOW_BUF, x - inx - bne @1 - - rts - -fs_vfs_direntmem_restore: - - php - - ldx #$00 -@1: - ldy SD_MEMSHADOW_BUF, x - sty $1000, x - inx - bne @1 - - bne @1 - - plp - rts diff --git a/src/dos_m65/filesystem_vfs/fs_vfs_read_file.s b/src/dos_m65/filesystem_vfs/fs_vfs_read_file.s index bf7ee626..8e7a07c8 100644 --- a/src/dos_m65/filesystem_vfs/fs_vfs_read_file.s +++ b/src/dos_m65/filesystem_vfs/fs_vfs_read_file.s @@ -28,7 +28,7 @@ fs_vfs_read_file_open: ; 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_vfs_direntmem_prepare + jsr util_shadow @lp_find: @@ -49,7 +49,7 @@ fs_vfs_read_file_open: ; Found the file - load it - jsr fs_vfs_direntmem_restore ; restore $1000 memory content + jsr util_shadow_restore ; restore $1000 memory content lda #$18 ; dos_openfile sta HTRAP00 diff --git a/src/dos_m65/unit_ramdisk/unit_rd_preload.s b/src/dos_m65/unit_ramdisk/unit_rd_preload.s index 53bbf47f..b62a57e3 100644 --- a/src/dos_m65/unit_ramdisk/unit_rd_preload.s +++ b/src/dos_m65/unit_ramdisk/unit_rd_preload.s @@ -21,11 +21,21 @@ unit_rd_preload: ; Set file name - ldy #>ramdisk_filename - ldx #$1000 + ldx #<$1000 lda #$2E ; dos_setname sta HTRAP00 +nop + jsr util_shadow_restore + +bcc @error_not_found ; branch if error ; Try to find the file diff --git a/src/dos_m65/utils/util_shadow.s b/src/dos_m65/utils/util_shadow.s new file mode 100644 index 00000000..bdfed2bf --- /dev/null +++ b/src/dos_m65/utils/util_shadow.s @@ -0,0 +1,31 @@ + +; Handling shadow memory, preserves .P + + + +util_shadow: + + ldx #$00 +@1: + ldy $1000, x + sty MEMSHADOW_BUF, x + inx + bne @1 + + rts + +util_shadow_restore: + + php + + ldx #$00 +@1: + ldy MEMSHADOW_BUF, x + sty $1000, x + inx + bne @1 + + bne @1 + + plp + rts