code size optimization in CBDOS
This commit is contained in:
1 parent
c1f5ccf55b
commit
e7f3a0731f
7 files changed
+91
-57
No files matched your search
@@ -27,9 +27,7 @@ fs_vfs_nextdirentry:
|
|||||||
ldx SD_DESC ; directory descriptor XXX rename to FS_HVSR_DESC
|
ldx SD_DESC ; directory descriptor XXX rename to FS_HVSR_DESC
|
||||||
ldy #>MEM_BUF ; target page number
|
ldy #>MEM_BUF ; target page number
|
||||||
|
|
||||||
lda #$14 ; dos_readdir
|
jsr util_htrap_dos_readddir
|
||||||
sta HTRAP00
|
|
||||||
+nop
|
|
||||||
|
|
||||||
+bcc @fail
|
+bcc @fail
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,7 @@ fs_vfs_nextfileblock:
|
|||||||
; Read chunk of data to SD card buffer
|
; Read chunk of data to SD card buffer
|
||||||
|
|
||||||
ldx SD_DESC
|
ldx SD_DESC
|
||||||
lda #$1A ; dos_readfile
|
jsr util_htrap_dos_readfile
|
||||||
sta HTRAP00
|
|
||||||
+nop
|
|
||||||
|
|
||||||
; XXX check error code
|
; XXX check error code
|
||||||
|
|
||||||
@@ -26,9 +24,7 @@ fs_vfs_nextfileblock:
|
|||||||
ora SD_ACPTR_LEN+0
|
ora SD_ACPTR_LEN+0
|
||||||
bne @copy
|
bne @copy
|
||||||
|
|
||||||
lda #$20 ; dos_closefile
|
jsr util_htrap_dos_closefile
|
||||||
sta HTRAP00
|
|
||||||
+nop
|
|
||||||
|
|
||||||
lda #$00
|
lda #$00
|
||||||
sec
|
sec
|
||||||
@@ -69,9 +65,7 @@ fs_vfs_file_not_found:
|
|||||||
jsr util_shadow_restore ; restore MEM_BUF memory content
|
jsr util_shadow_restore ; restore MEM_BUF memory content
|
||||||
|
|
||||||
ldx SD_DESC
|
ldx SD_DESC
|
||||||
lda #$16 ; dos_closedir
|
jsr util_htrap_dos_closedir
|
||||||
sta HTRAP00
|
|
||||||
+nop
|
|
||||||
|
|
||||||
lda #39 ; file not found error
|
lda #39 ; file not found error
|
||||||
jsr util_status_SD
|
jsr util_status_SD
|
||||||
|
|||||||
@@ -8,9 +8,7 @@ fs_vfs_read_dir_open:
|
|||||||
|
|
||||||
; Open the directory
|
; Open the directory
|
||||||
|
|
||||||
lda #$12 ; dos_opendir
|
jsr util_htrap_dos_opendir
|
||||||
sta HTRAP00
|
|
||||||
+nop
|
|
||||||
|
|
||||||
; XXX handle read errors
|
; XXX handle read errors
|
||||||
|
|
||||||
@@ -105,9 +103,7 @@ fs_vfs_read_dir_blocksfree:
|
|||||||
; Close the directory within the hypervisor XXX maybe move it to close routine
|
; Close the directory within the hypervisor XXX maybe move it to close routine
|
||||||
|
|
||||||
ldx SD_DESC
|
ldx SD_DESC
|
||||||
lda #$16 ; dos_closedir
|
jsr util_htrap_dos_closedir
|
||||||
sta HTRAP00
|
|
||||||
+nop
|
|
||||||
|
|
||||||
clc
|
clc
|
||||||
rts
|
rts
|
||||||
@@ -50,9 +50,7 @@ fs_vfs_read_file_open:
|
|||||||
|
|
||||||
jsr util_shadow_restore ; restore MEM_BUF memory content
|
jsr util_shadow_restore ; restore MEM_BUF memory content
|
||||||
|
|
||||||
lda #$18 ; dos_openfile
|
jsr util_htrap_dos_openfile
|
||||||
sta HTRAP00
|
|
||||||
+nop
|
|
||||||
|
|
||||||
; XXX check error code
|
; XXX check error code
|
||||||
|
|
||||||
|
|||||||
@@ -31,18 +31,14 @@ unit_rd_preload:
|
|||||||
|
|
||||||
ldy #>MEM_BUF
|
ldy #>MEM_BUF
|
||||||
ldx #<MEM_BUF
|
ldx #<MEM_BUF
|
||||||
lda #$2E ; dos_setname
|
jsr util_htrap_dos_setname
|
||||||
sta HTRAP00
|
|
||||||
+nop
|
|
||||||
jsr util_shadow_restore
|
jsr util_shadow_restore
|
||||||
|
|
||||||
+bcc @error_not_found ; branch if error
|
+bcc @error_not_found ; branch if error
|
||||||
|
|
||||||
; Try to find the file
|
; Try to find the file
|
||||||
|
|
||||||
lda #$34 ; dos_findfile
|
jsr util_htrap_dos_findfile
|
||||||
sta HTRAP00
|
|
||||||
+nop
|
|
||||||
+bcc @error_not_found ; branch if file not found
|
+bcc @error_not_found ; branch if file not found
|
||||||
|
|
||||||
; Calculate maximum amount of tracks possible to load
|
; Calculate maximum amount of tracks possible to load
|
||||||
@@ -65,9 +61,7 @@ unit_rd_preload:
|
|||||||
|
|
||||||
; Load the image
|
; Load the image
|
||||||
|
|
||||||
lda #$18 ; dos_openfile
|
jsr util_htrap_dos_openfile
|
||||||
sta HTRAP00
|
|
||||||
+nop
|
|
||||||
|
|
||||||
lda #$FF
|
lda #$FF
|
||||||
sta RD_MAXTRACK
|
sta RD_MAXTRACK
|
||||||
@@ -91,9 +85,7 @@ unit_rd_preload:
|
|||||||
|
|
||||||
; Read 512 bytes
|
; Read 512 bytes
|
||||||
|
|
||||||
lda #$1A ; dos_readfile
|
jsr util_htrap_dos_readfile
|
||||||
sta HTRAP00
|
|
||||||
+nop
|
|
||||||
|
|
||||||
cpx #$00
|
cpx #$00
|
||||||
bne @error_wrong_size_plx ; file size not multiplicity of 64K
|
bne @error_wrong_size_plx ; file size not multiplicity of 64K
|
||||||
@@ -119,19 +111,13 @@ unit_rd_preload:
|
|||||||
|
|
||||||
; Make sure this is the end of the file
|
; Make sure this is the end of the file
|
||||||
|
|
||||||
lda #$1A ; dos_readfile
|
jsr util_htrap_dos_readfile
|
||||||
sta HTRAP00
|
|
||||||
+nop
|
|
||||||
|
|
||||||
cpx #$00
|
cpx #$00
|
||||||
bne @error_too_large
|
bne @error_too_large
|
||||||
cpy #$00
|
cpy #$00
|
||||||
bne @error_too_large
|
bne @error_too_large
|
||||||
|
|
||||||
lda #$20 ; dos_closefile
|
|
||||||
sta HTRAP00
|
|
||||||
+nop
|
|
||||||
|
|
||||||
@load_image_end:
|
@load_image_end:
|
||||||
|
|
||||||
plx
|
plx
|
||||||
@@ -142,9 +128,7 @@ unit_rd_preload:
|
|||||||
cmp #$02
|
cmp #$02
|
||||||
bcc @error_wrong_size ; file too small, at least 128K required
|
bcc @error_wrong_size ; file too small, at least 128K required
|
||||||
|
|
||||||
lda #$20 ; dos_closefile
|
jsr util_htrap_dos_closefile ; XXX set descriptor
|
||||||
sta HTRAP00
|
|
||||||
+nop
|
|
||||||
|
|
||||||
; End of initialization
|
; End of initialization
|
||||||
|
|
||||||
@@ -187,9 +171,7 @@ unit_rd_preload_err_common:
|
|||||||
|
|
||||||
sta RD_MSG ; set code for startup screen
|
sta RD_MSG ; set code for startup screen
|
||||||
|
|
||||||
lda #$20 ; dos_closefile
|
jsr util_htrap_dos_closefile ; XXX set descriptor
|
||||||
sta HTRAP00
|
|
||||||
+nop
|
|
||||||
|
|
||||||
; FALLTROUGH
|
; FALLTROUGH
|
||||||
|
|
||||||
|
|||||||
@@ -26,14 +26,5 @@ unit_sd_init:
|
|||||||
|
|
||||||
; Close all the files in the hypervisor, go to root directory
|
; Close all the files in the hypervisor, go to root directory
|
||||||
|
|
||||||
lda #$22 ; dos_closeall
|
jsr util_htrap_dos_closeall
|
||||||
sta HTRAP00
|
jmp util_htrap_dos_cdrootdir
|
||||||
+nop
|
|
||||||
|
|
||||||
lda #$3C ; dos_cdrootdir
|
|
||||||
sta HTRAP00
|
|
||||||
+nop
|
|
||||||
|
|
||||||
; End of initialization
|
|
||||||
|
|
||||||
rts
|
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
|
||||||
|
; Size-optimized hypervisor interaction code
|
||||||
|
|
||||||
|
|
||||||
|
util_htrap_dos_opendir:
|
||||||
|
|
||||||
|
lda #$12
|
||||||
|
+skip_2_bytes_trash_nvz
|
||||||
|
|
||||||
|
; FALLTROUGH
|
||||||
|
|
||||||
|
util_htrap_dos_readddir:
|
||||||
|
|
||||||
|
lda #$14
|
||||||
|
+skip_2_bytes_trash_nvz
|
||||||
|
|
||||||
|
; FALLTROUGH
|
||||||
|
|
||||||
|
util_htrap_dos_closedir:
|
||||||
|
|
||||||
|
lda #$16
|
||||||
|
+skip_2_bytes_trash_nvz
|
||||||
|
|
||||||
|
; FALLTROUGH
|
||||||
|
|
||||||
|
util_htrap_dos_openfile:
|
||||||
|
|
||||||
|
lda #$18
|
||||||
|
+skip_2_bytes_trash_nvz
|
||||||
|
|
||||||
|
; FALLTROUGH
|
||||||
|
|
||||||
|
util_htrap_dos_closefile:
|
||||||
|
|
||||||
|
lda #$20
|
||||||
|
+skip_2_bytes_trash_nvz
|
||||||
|
|
||||||
|
; FALLTROUGH
|
||||||
|
|
||||||
|
util_htrap_dos_closeall:
|
||||||
|
|
||||||
|
lda #$22
|
||||||
|
+skip_2_bytes_trash_nvz
|
||||||
|
|
||||||
|
; FALLTROUGH
|
||||||
|
|
||||||
|
util_htrap_dos_setname:
|
||||||
|
|
||||||
|
lda #$2E
|
||||||
|
+skip_2_bytes_trash_nvz
|
||||||
|
|
||||||
|
; FALLTROUGH
|
||||||
|
|
||||||
|
util_htrap_dos_findfile:
|
||||||
|
|
||||||
|
lda #$34
|
||||||
|
+skip_2_bytes_trash_nvz
|
||||||
|
|
||||||
|
; FALLTROUGH
|
||||||
|
|
||||||
|
util_htrap_dos_cdrootdir:
|
||||||
|
|
||||||
|
lda #$3C
|
||||||
|
+skip_2_bytes_trash_nvz
|
||||||
|
|
||||||
|
; FALLTROUGH
|
||||||
|
|
||||||
|
util_htrap_dos_readfile: ; make sure this is the fastest to execute
|
||||||
|
|
||||||
|
lda #$1A
|
||||||
|
|
||||||
|
sta HTRAP00
|
||||||
|
+nop ; NOP required by hypervisor
|
||||||
|
|
||||||
|
rts
|
||||||
Reference in new issue
Block a user