code size optimization in CBDOS

This commit is contained in:
FeralChild64 committed 2021-05-23 13:00:13 +02:00
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
ldy #>MEM_BUF ; target page number
lda #$14 ; dos_readdir
sta HTRAP00
+nop
jsr util_htrap_dos_readddir
+bcc @fail
@@ -9,9 +9,7 @@ fs_vfs_nextfileblock:
; Read chunk of data to SD card buffer
ldx SD_DESC
lda #$1A ; dos_readfile
sta HTRAP00
+nop
jsr util_htrap_dos_readfile
; XXX check error code
@@ -26,9 +24,7 @@ fs_vfs_nextfileblock:
ora SD_ACPTR_LEN+0
bne @copy
lda #$20 ; dos_closefile
sta HTRAP00
+nop
jsr util_htrap_dos_closefile
lda #$00
sec
@@ -69,9 +65,7 @@ fs_vfs_file_not_found:
jsr util_shadow_restore ; restore MEM_BUF memory content
ldx SD_DESC
lda #$16 ; dos_closedir
sta HTRAP00
+nop
jsr util_htrap_dos_closedir
lda #39 ; file not found error
jsr util_status_SD
+2 -6
View File
@@ -8,9 +8,7 @@ fs_vfs_read_dir_open:
; Open the directory
lda #$12 ; dos_opendir
sta HTRAP00
+nop
jsr util_htrap_dos_opendir
; 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
ldx SD_DESC
lda #$16 ; dos_closedir
sta HTRAP00
+nop
jsr util_htrap_dos_closedir
clc
rts
@@ -50,9 +50,7 @@ fs_vfs_read_file_open:
jsr util_shadow_restore ; restore MEM_BUF memory content
lda #$18 ; dos_openfile
sta HTRAP00
+nop
jsr util_htrap_dos_openfile
; XXX check error code
+7 -25
View File
@@ -31,18 +31,14 @@ unit_rd_preload:
ldy #>MEM_BUF
ldx #<MEM_BUF
lda #$2E ; dos_setname
sta HTRAP00
+nop
jsr util_htrap_dos_setname
jsr util_shadow_restore
+bcc @error_not_found ; branch if error
; Try to find the file
lda #$34 ; dos_findfile
sta HTRAP00
+nop
jsr util_htrap_dos_findfile
+bcc @error_not_found ; branch if file not found
; Calculate maximum amount of tracks possible to load
@@ -65,9 +61,7 @@ unit_rd_preload:
; Load the image
lda #$18 ; dos_openfile
sta HTRAP00
+nop
jsr util_htrap_dos_openfile
lda #$FF
sta RD_MAXTRACK
@@ -91,9 +85,7 @@ unit_rd_preload:
; Read 512 bytes
lda #$1A ; dos_readfile
sta HTRAP00
+nop
jsr util_htrap_dos_readfile
cpx #$00
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
lda #$1A ; dos_readfile
sta HTRAP00
+nop
jsr util_htrap_dos_readfile
cpx #$00
bne @error_too_large
cpy #$00
bne @error_too_large
lda #$20 ; dos_closefile
sta HTRAP00
+nop
@load_image_end:
plx
@@ -142,9 +128,7 @@ unit_rd_preload:
cmp #$02
bcc @error_wrong_size ; file too small, at least 128K required
lda #$20 ; dos_closefile
sta HTRAP00
+nop
jsr util_htrap_dos_closefile ; XXX set descriptor
; End of initialization
@@ -187,9 +171,7 @@ unit_rd_preload_err_common:
sta RD_MSG ; set code for startup screen
lda #$20 ; dos_closefile
sta HTRAP00
+nop
jsr util_htrap_dos_closefile ; XXX set descriptor
; FALLTROUGH
+2 -11
View File
@@ -26,14 +26,5 @@ unit_sd_init:
; Close all the files in the hypervisor, go to root directory
lda #$22 ; dos_closeall
sta HTRAP00
+nop
lda #$3C ; dos_cdrootdir
sta HTRAP00
+nop
; End of initialization
rts
jsr util_htrap_dos_closeall
jmp util_htrap_dos_cdrootdir
+75
View File
@@ -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