preparation for more general error handling in CBDOS

This commit is contained in:
FeralChild64 committed 2021-02-17 17:46:06 +01:00
1 parent e98520d805
commit 45ad2ebe6d
12 files changed
+347 -173

No files matched your search

+17 -9
View File
@@ -35,19 +35,28 @@
!addr IDX1_TALKER = $8012 ; talker idx, >=$80 = none
!addr IDX2_TALKER = $8013 ; talker idx * 2, >=$80 = none - for calling routines via vector table
; Helper subroutines to fetch data
!addr code_LDA_nnnn_Y = $8014 ; - LDA nnnn, Y instruction
!addr par_LDA_nnnn_Y = $8015 ; - 2 bytes; address in buffer, ram disk
!addr code_RTS_04 = $8017 ; - RTS instruction
; Parameters for utilities
!addr PAR_FSIZE_BLOCKS = $8014 ; 2 bytes - file size in blocks
!addr PAR_FSIZE_BYTES = $8016 ; 4 bytes - file size in bytes
!addr PAR_TRACK = $8018 ; track number for status/error
!addr PAR_SECTOR = $8019 ; sector number for status/error
!addr PAR_FSIZE_BYTES = $801A ; 4 bytes - file size in bytes
!addr PAR_FSIZE_BLOCKS = $801E ; 2 bytes - file size in blocks
; Various temporary data
!addr XX_DIR_PHASE = $801A ; directory output phase, values deponds on device driver
!addr SD_DIR_PHASE = $801A ; - SD card
!addr FD_DIR_PHASE = $801B ; - floppy
!addr RD_DIR_PHASE = $801C ; - ram disk
!addr XX_DIR_PHASE = $8020 ; directory output phase, values deponds on device driver, but 0 = not reading
!addr SD_DIR_PHASE = $8020 ; - SD card
!addr FD_DIR_PHASE = $8021 ; - floppy
!addr RD_DIR_PHASE = $8022 ; - ram disk
; Free space: $801D-$8063
; Free space: $8023-$8063
!addr SD_ACPTR_helper = $8052 ; subroutine in RAM to read a byte
!addr code_LDA_01 = $8052 ; - LDA instruction
@@ -99,5 +108,4 @@
!addr RD_CMDFN_BUF = $8200 ; buffer for command and/or file name, 128 bytes, ram disk
!addr SD_DIRENT = $8280 ; 256 byte buffer for 'dirent' structure
!addr SD_DIR_DESC = $8380 ; file descriptor for reading directory
!addr SD_DESC = $8380 ; current file descriptor
-156
View File
@@ -1,156 +0,0 @@
;
; DOS error codes and strings
;
; XXX get rid of unnecessary error messages
dos_err_init_sdcard:
!pet "73,m65 dos sd card,00,00", 0
dos_err_init_floppy:
!pet "73,m65 dos floppy,00,00", 0
dos_err_init_ramdisk:
!pet "73,m65 dos ram disk,00,00", 0
; List compiled from various manuals (CBM 1571, CBM 1581, CMD FD4000, MSD Super Disk, IDE64)
dos_err_00: ; not an error
!pet " ok", 0
dos_err_01: ; not an error
!pet "files scratched", 0
dos_err_02: ; not an error
!pet "partition selected", 0
dos_err_20: ; header not found
dos_err_21: ; no data addres mark
dos_err_22: ; block not found
dos_err_23: ; data error
dos_err_27: ; header error
!pet "read error", 0
dos_err_25:
!pet "write error", 0
dos_err_26:
!pet "write protect on", 0
dos_err_29:
!pet "disk changed", 0
dos_err_30: ; invalid characters in command
dos_err_31: ; unrecognized command
dos_err_32: ; command too long
dos_err_33: ; illegal file name
dos_err_34: ; missing file name
!pet "syntax error", 0
dos_err_39:
!pet "file not found", 0
dos_err_49: ; disk formatted, but format not supported
!pet "invalid format", 0
dos_err_50:
!pet "record not present", 0
dos_err_51:
!pet "overflow in record", 0
dos_err_52:
!pet "file too large", 0
dos_err_60:
!pet "write file open", 0
dos_err_61:
!pet "file not open", 0
dos_err_62:
!pet "file not found", 0
dos_err_63:
!pet "file exists", 0
dos_err_64:
!pet "file type mismatch", 0
dos_err_65:
!pet "no block", 0
dos_err_66:
!pet "illegal track and sector", 0
dos_err_67:
!pet "illegal system t or s", 0
dos_err_70:
!pet "no channel", 0
dos_err_71:
!pet "directory error", 0
dos_err_72:
!pet "partition full", 0
dos_err_73:
!pet "dos mismatch", 0
dos_err_74:
!pet "drive not ready", 0
dos_err_75:
!pet "format error", 0
dos_err_76:
!pet "controller error", 0
dos_err_77:
!pet "selected partition illegal", 0
dos_err_78:
!pet "system error", 0
dos_err_79: ; SD2IEC compatible
!pet "image invalid", 0
+1 -1
View File
@@ -28,7 +28,7 @@ dir_hdr_sd: ; 32 bytes - header
dir_end: ; 19 bytes
!byte $01, $01 ; link to the next line - dummy, will be regenerated by BASIC
!byte $FF, $FF ; line number 65535 (for SD2IEC compatibility)
!byte $00, $00 ; line number 0 (blocks available)
!pet "blocks free."
!byte $00, $00, $00 ; end of the line, end of program marker
+184
View File
@@ -0,0 +1,184 @@
;
; DOS error codes and strings
;
; XXX get rid of unnecessary error messages
dos_sts_init_sdcard:
!pet "73,m65 dos sd card,00,00", 0
dos_sts_init_floppy:
!pet "73,m65 dos floppy,00,00", 0
dos_sts_init_ramdisk:
!pet "73,m65 dos ram disk,00,00", 0
; List compiled from various manuals (CBM 1571, CBM 1581, CMD FD4000, MSD Super Disk, IDE64)
dos_sts_00: ; not an error
!pet " ok", 0
dos_sts_01: ; not an error
!pet "files scratched", 0
dos_sts_02: ; not an error
!pet "partition selected", 0
dos_sts_20: ; header not found
dos_sts_21: ; no data addres mark
dos_sts_22: ; block not found
dos_sts_23: ; data error
dos_sts_27: ; header error
!pet "read error", 0
dos_sts_25:
!pet "write error", 0
dos_sts_26:
!pet "write protect on", 0
dos_sts_29:
!pet "disk changed", 0
dos_sts_30: ; invalid characters in command
dos_sts_31: ; unrecognized command
dos_sts_32: ; command too long
dos_sts_33: ; illegal file name
dos_sts_34: ; missing file name
!pet "syntax error", 0
dos_sts_39:
!pet "file not found", 0
dos_sts_49: ; disk formatted, but format not supported
!pet "invalid format", 0
dos_sts_50:
!pet "record not present", 0
dos_sts_51:
!pet "overflow in record", 0
dos_sts_52:
!pet "file too large", 0
dos_sts_60:
!pet "write file open", 0
dos_sts_61:
!pet "file not open", 0
dos_sts_62:
!pet "file not found", 0
dos_sts_63:
!pet "file exists", 0
dos_sts_64:
!pet "file type mismatch", 0
dos_sts_65:
!pet "no block", 0
dos_sts_66:
!pet "illegal track and sector", 0
dos_sts_67:
!pet "illegal system t or s", 0
dos_sts_70:
!pet "no channel", 0
dos_sts_71:
!pet "directory error", 0
dos_sts_72:
!pet "partition full", 0
dos_sts_73:
!pet "dos mismatch", 0
dos_sts_74:
!pet "drive not ready", 0
dos_sts_75:
!pet "format error", 0
dos_sts_76:
!pet "controller error", 0
dos_sts_77:
!pet "selected partition illegal", 0
dos_sts_78:
!pet "system error", 0
dos_sts_79: ; SD2IEC compatible
!pet "image invalid", 0
dos_sts_XX: ; Open ROMs specific - unspecified error
!pet "internal error", 0
dos_sts_tab_lo:
!byte <dos_sts_00, <dos_sts_01, <dos_sts_02, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX
!byte <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX
!byte <dos_sts_20, <dos_sts_21, <dos_sts_22, <dos_sts_23, <dos_sts_XX, <dos_sts_25, <dos_sts_26, <dos_sts_27, <dos_sts_XX, <dos_sts_29
!byte <dos_sts_30, <dos_sts_31, <dos_sts_32, <dos_sts_33, <dos_sts_34, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_39
!byte <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_49
!byte <dos_sts_50, <dos_sts_51, <dos_sts_52, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX, <dos_sts_XX
!byte <dos_sts_60, <dos_sts_61, <dos_sts_62, <dos_sts_63, <dos_sts_64, <dos_sts_65, <dos_sts_66, <dos_sts_67, <dos_sts_XX, <dos_sts_XX
!byte <dos_sts_70, <dos_sts_71, <dos_sts_72, <dos_sts_73, <dos_sts_74, <dos_sts_75, <dos_sts_76, <dos_sts_77, <dos_sts_78, <dos_sts_79
!byte <dos_sts_XX
dos_sts_tab_hi:
!byte >dos_sts_00, >dos_sts_01, >dos_sts_02, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX
!byte >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX
!byte >dos_sts_20, >dos_sts_21, >dos_sts_22, >dos_sts_23, >dos_sts_XX, >dos_sts_25, >dos_sts_26, >dos_sts_27, >dos_sts_XX, >dos_sts_29
!byte >dos_sts_30, >dos_sts_31, >dos_sts_32, >dos_sts_33, >dos_sts_34, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_39
!byte >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_49
!byte >dos_sts_50, >dos_sts_51, >dos_sts_52, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX, >dos_sts_XX
!byte >dos_sts_60, >dos_sts_61, >dos_sts_62, >dos_sts_63, >dos_sts_64, >dos_sts_65, >dos_sts_66, >dos_sts_67, >dos_sts_XX, >dos_sts_XX
!byte >dos_sts_70, >dos_sts_71, >dos_sts_72, >dos_sts_73, >dos_sts_74, >dos_sts_75, >dos_sts_76, >dos_sts_77, >dos_sts_78, >dos_sts_79
!byte >dos_sts_XX
+1 -1
View File
@@ -19,7 +19,7 @@ dev_fd_init:
dex
@1:
inx
lda dos_err_init_floppy,x
lda dos_sts_init_floppy,x
sta FD_STATUS_STR,x
bne @1
+1 -1
View File
@@ -19,7 +19,7 @@ dev_rd_init:
dex
@1:
inx
lda dos_err_init_ramdisk,x
lda dos_sts_init_ramdisk,x
sta RD_STATUS_STR,x
bne @1
+1 -1
View File
@@ -20,7 +20,7 @@ dev_sd_init:
dex
@1:
inx
lda dos_err_init_sdcard,x
lda dos_sts_init_sdcard,x
sta SD_STATUS_STR,x
bne @1
@@ -0,0 +1,12 @@
;
; Hypervisor virtual filesystem - opening the file
;
fs_hvsr_read_file_open:
; XXX provide implementation
sec
rts
+3 -3
View File
@@ -17,7 +17,7 @@ fs_hvsr_read_dir_open:
; XXX handle read errors
sta SD_DIR_DESC ; store directory descriptor XXX invent better name
sta SD_DESC ; store directory descriptor XXX invent better name
; Reset status to OK
@@ -53,7 +53,7 @@ fs_hvsr_read_dir:
jsr fs_hvsr_dirent_prepare
ldx SD_DIR_DESC ; directory descriptor
ldx SD_DESC ; directory descriptor
ldy #$10 ; target page number
lda #$14 ; dos_readdir
@@ -333,7 +333,7 @@ fs_hvsr_read_dir_blocksfree:
; Close the directory within the hypervisor XXX maybe move it to close routine
ldx SD_DIR_DESC
ldx SD_DESC
lda #$16 ; dos_closedir
sta HTRAP00
+nop
+1 -1
View File
@@ -41,7 +41,7 @@ dos_status_00: ; OK
@1:
inx
iny
lda dos_err_00, y
lda dos_sts_00, y
beq @2
sta XX_STATUS_STR, x
bra @1
+4
View File
@@ -51,10 +51,14 @@ dos_INIT:
sta code_LDA_02
sta code_LDA_03
lda #$B9 ; LDA nnnn, y opcode
sta code_LDA_nnnn_Y
lda #$60 ; RTS opcode
sta code_RTS_01
sta code_RTS_02
sta code_RTS_03
sta code_RTS_04
; Exit DOS context
+122
View File
@@ -0,0 +1,122 @@
; Set current status or error
; XXX add code for handling the LEDs
; .A = status to set
util_status_SD:
ldx #$00
stx SD_STATUS_IDX ; set first byte of status to read
ldx $00 ; offset to status buffer
bra util_status_common
util_status_FD:
ldx #$00
stx FD_STATUS_IDX ; set first byte of status to read
ldx $20 ; offset to status buffer
bra util_status_common
util_status_RD:
ldx #$00
stx RD_STATUS_IDX ; set first byte of status to read
ldx $40 ; offset to status buffer
; FALLLTROUGH
util_status_common:
; Store the error number
taz
jsr util_status_store_number
jsr util_status_store_comma
; Store the status / error string
tza ; prepare helper routine
tay
lda dos_sts_tab_lo, y
sta par_LDA_nnnn_Y+0
lda dos_sts_tab_hi, y
sta par_LDA_nnnn_Y+1
ldy #$00 ; copy the string
@lp:
jsr code_LDA_nnnn_Y
bne @lp_end
sta XX_STATUS_STR, x
iny
inx
bra @lp
@lp_end:
; Store track and sector
lda PAR_TRACK
jsr util_status_store_number
jsr util_status_store_comma
lda PAR_SECTOR
jsr util_status_store_number
; Mark end of status and quit
lda #$00
sta XX_STATUS_STR, x
rts
util_status_store_comma:
ldy #','
sty XX_STATUS_STR, x
inx
rts
util_status_store_number:
; Check if number to store is 200 or above
cmp #200
bcc @store_00_199
ldy #'2'
sty XX_STATUS_STR, x
inx
sec
sbc #200
bra @store_00_99
@store_00_199: ; number to store is within 00-199 range
cmp #100
bcc @store_00_99
ldy #'1'
sty XX_STATUS_STR, x
inx
sec
sbc #100
@store_00_99: ; number to store is within 00-99 range - separate digits
ldy #'0'
@lp:
cmp #10
bcc @store_finalize
iny
sec
sbc #10
bra @lp
@store_finalize: ; first digit to store in .Y, second in .A
sty XX_STATUS_STR, x
inx
sta XX_STATUS_STR, x
inx
rts