work towards directory reading in CBDOS

This commit is contained in:
FeralChild64 committed 2021-02-14 12:07:10 +01:00
1 parent 61e2c7f5e5
commit 578be0bcc8
17 files changed
+277 -10

No files matched your search

+29
View File
@@ -35,8 +35,37 @@
!addr IDX1_TALKER = $8012 ; talker idx, >=$80 = none
!addr IDX2_TALKER = $8013 ; talker idx * 2, >=$80 = none - for calling routines via vector table
; Various temporary data
!addr XX_DIR_PHASE = $8014 ; directory output phase, values deponds on device driver
!addr SD_DIR_PHASE = $8014 ; - SD card
!addr FD_DIR_PHASE = $8015 ; - floppy
!addr RD_DIR_PHASE = $8016 ; - ram disk
; Free space: $8014-$8063
!addr SD_ACPTR_helper = $8052 ; subroutine in RAM to read a byte
!addr code_LDA_01 = $8052 ; - LDA instruction
!addr SD_ACPTR_PTR = $8053 ; - 2 bytes; address in buffer, SD card
!addr code_RTS_01 = $8055 ; - RTS instruction
!addr FD_ACPTR_helper = $8056 ; subroutine in RAM to read a byte
!addr code_LDA_02 = $8056 ; - LDA instruction
!addr FD_ACPTR_PTR = $8057 ; - 2 bytes; address in buffer, floppy
!addr code_RTS_02 = $8059 ; - RTS instruction
!addr RD_ACPTR_helper = $805A ; subroutine in RAM to read a byte
!addr code_LDA_03 = $805A ; - LDA instruction
!addr RD_ACPTR_PTR = $805B ; - 2 bytes; address in buffer, ram disk
!addr code_RTS_03 = $805D ; - RTS instruction
!addr XX_ACPTR_LEN = $805E ; 2 bytes - length of data left for ACPTR
!addr SD_ACPTR_LEN = $805E ; - SD card
!addr FD_ACPTR_LEN = $8060 ; - floppy
!addr RD_ACPTR_LEN = $8062 ; - ram disk
!addr XX_MODE = $8064 ; current mode (0 = none, 1 = receiving command/file name)
!addr SD_MODE = $8064 ; - SD card
!addr FD_MODE = $8065 ; - floppy
+2 -2
View File
@@ -9,7 +9,7 @@
dos_err_init_sdcard:
!pet "73,m65 dos sdcard,00,00", 0
!pet "73,m65 dos sd card,00,00", 0
dos_err_init_floppy:
@@ -25,7 +25,7 @@ dos_err_init_ramdisk:
dos_err_00: ; not an error
!pet "ok", 0
!pet " ok", 0
dos_err_01: ; not an error
+33
View File
@@ -0,0 +1,33 @@
;
; Data used to generate directory in CBM BASIC format
;
dir_hdr: ; 32 bytes - header
!byte $01, $08 ; program location
!byte $01, $01 ; link to the next line - dummy, will be regenerated by BASIC
!byte $00, $00 ; line number 0
!byte $12, $22 ; reverse mode, quote
!pet " " ; space for disk/directory name
!byte $22, $20 ; quote, space
!pet "00 2a" ; default ID, disk format
!byte $00 ; end of the line
dir_hdr_sd: ; 32 bytes - header
!byte $01, $08 ; program location
!byte $01, $01 ; link to the next line - dummy, will be regenerated by BASIC
!byte $00, $00 ; line number 0
!byte $12, $22 ; reverse mode, quote
!pet "SD CARD " ; space for disk/directory name
!byte $22, $20 ; quote, space
!pet "fat32" ; filesystem
!byte $00 ; end of the line
dir_end: ; 19 bytes
!byte $01, $01 ; link to the next line - dummy, will be regenerated by BASIC
!byte $00, $00 ; line number 0
!pet "blocks free."
!byte $00, $00, $00 ; end of the line, end of program marker
+6
View File
@@ -9,3 +9,9 @@ dev_fd_cmd_OPEN:
; XXX provide implementation
jmp dos_EXIT_SEC
dev_fd_cmd_OPEN_EOI:
; XXX provide implementation
jmp dos_EXIT
+12
View File
@@ -0,0 +1,12 @@
;
; Read more data into the buffer
;
dev_fd_cmd_READ:
; XXX provide implementation
sec ; mark EOI
rts
+4
View File
@@ -12,6 +12,10 @@ dev_fd_init:
stx FD_STATUS_IDX
stx FD_CMDFN_IDX
stx FD_MODE
stx FD_ACPTR_LEN+0
stx FD_ACPTR_LEN+1
stx FD_ACPTR_PTR+0
stx FD_ACPTR_PTR+1
dex
@1:
inx
@@ -9,3 +9,9 @@ dev_rd_cmd_OPEN:
; XXX provide implementation
jmp dos_EXIT_SEC
dev_rd_cmd_OPEN_EOI:
; XXX provide implementation
jmp dos_EXIT
+12
View File
@@ -0,0 +1,12 @@
;
; Read more data into the buffer
;
dev_rd_cmd_READ:
; XXX provide implementation
sec ; mark EOI
rts
+4
View File
@@ -12,6 +12,10 @@ dev_rd_init:
stx RD_STATUS_IDX
stx RD_CMDFN_IDX
stx RD_MODE
stx RD_ACPTR_LEN+0
stx RD_ACPTR_LEN+1
stx RD_ACPTR_PTR+0
stx RD_ACPTR_PTR+1
dex
@1:
inx
+40
View File
@@ -10,3 +10,43 @@ dev_sd_cmd_OPEN:
sta SD_MODE
jmp dos_EXIT
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 add support for filtering
; Initialize 1st directory phase - header
lda #$01
sta SD_DIR_PHASE
; Provide pointer and length of the header
lda #$20
sta SD_ACPTR_PTR+0
lda #$00
sta SD_ACPTR_PTR+1
lda #<dir_hdr_sd
sta SD_ACPTR_PTR+0
lda #>dir_hdr_sd
sta SD_ACPTR_PTR+1
; End
jmp dos_EXIT
+12
View File
@@ -0,0 +1,12 @@
;
; Read more data into the buffer
;
dev_sd_cmd_READ:
; XXX provide implementation
sec ; mark EOI
rts
+4
View File
@@ -12,6 +12,10 @@ dev_sd_init:
stx SD_STATUS_IDX
stx SD_CMDFN_IDX
stx SD_MODE
stx SD_ACPTR_LEN+0
stx SD_ACPTR_LEN+1
stx SD_ACPTR_PTR+0
stx SD_ACPTR_PTR+1
dex
@1:
inx
+12
View File
@@ -44,6 +44,18 @@ dos_INIT:
jsr dev_fd_init
jsr dev_rd_init
; Initialize helper code in RAM
lda #$AD ; LDA opcode, absolute
sta code_LDA_01
sta code_LDA_02
sta code_LDA_03
lda #$60 ; RTS opcode
sta code_RTS_01
sta code_RTS_02
sta code_RTS_03
; Exit DOS context
jmp dos_EXIT
+18
View File
@@ -16,6 +16,24 @@ dos_MEMCHK:
dex
bpl @1
; Check if helper code is undamaged
lda #$AD
cmp code_LDA_01
bne @fail
cmp code_LDA_02
bne @fail
cmp code_LDA_03
bne @fail
lda #$60
cmp code_RTS_01
bne @fail
cmp code_RTS_02
bne @fail
cmp code_RTS_03
bne @fail
clc
rts
+67 -6
View File
@@ -11,7 +11,7 @@ msg_ACPTR:
; Check if there is a talker active
ldx IDX1_TALKER
bmi msg_ACPTR_fail
bmi msg_ACPTR_fail_no_talker
; Check if active channel is status one
@@ -19,9 +19,65 @@ msg_ACPTR:
cmp #$0F
beq msg_ACPTR_status
; XXX providde implementation for non-status channels
; XXX add support for read contexts (multiple channels)
jmp msg_ACPTR_fail
; Not a status channel - check if we have something to read out
ldx IDX2_TALKER
lda XX_ACPTR_LEN+0,x
ora XX_ACPTR_LEN+1,x
beq msg_ACPTR_fail_no_data
; Read a byte of data from the buffer
jmp (msg_ACPTR_read_vectab, X)
msg_ACPTR_read_SD:
; Read and return one byte
jsr SD_ACPTR_helper
sta TBTCNT
; Increment pointer, decrement length
inc SD_ACPTR_PTR+0
bne @1
inc SD_ACPTR_PTR+1
@1:
dec SD_ACPTR_LEN+0
lda SD_ACPTR_LEN+0
cmp #$FF
bne @2
dec SD_ACPTR_LEN+1
@2:
; If new length is 0, try to read next block of data
ora SD_ACPTR_LEN+1
bne @3
jsr dev_sd_cmd_READ
bcc @3
jsr kernalstatus_EOI
@3:
jmp dos_EXIT
msg_ACPTR_read_FD:
; XXX provide implementation
msg_ACPTR_read_RD:
; XXX provide implementation
msg_ACPTR_fail_no_data:
; XXX What should be the reaction when trying to read and no data is present?
sta TBTCNT
bra msg_ACPTR_EOI
msg_ACPTR_status:
@@ -57,7 +113,7 @@ msg_ACPTR_status_got:
jmp dos_EXIT_A
msg_ACPTR_fail:
msg_ACPTR_fail_no_talker:
; XXX set error code
@@ -70,13 +126,12 @@ msg_ACPTR_reset_status:
; FALLTROUGH
msg_ACPTR_eoi:
msg_ACPTR_EOI:
jsr kernalstatus_EOI
jmp dos_EXIT
; Vector tables for jumps
msg_ACPTR_status_vectab:
@@ -84,3 +139,9 @@ msg_ACPTR_status_vectab:
!word msg_ACPTR_status_SD
!word msg_ACPTR_status_FD
!word msg_ACPTR_status_RD
msg_ACPTR_read_vectab:
!word msg_ACPTR_read_SD
!word msg_ACPTR_read_FD
!word msg_ACPTR_read_RD
+15 -1
View File
@@ -7,10 +7,12 @@
msg_CIOUT:
jsr dos_ENTER
php
; Check operation mode
ldx IDX1_LISTENER
bmi msg_CIOUT_fail
lda XX_MODE, x
cmp #$01
@@ -18,14 +20,20 @@ msg_CIOUT:
; Receiving command or file name
ldx IDX2_TALKER
ldx IDX2_LISTENER
jmp (msg_CIOUT_cmdfn_vectab, X)
@1:
; XXX handle cases of transferring data
plp
jmp dos_EXIT_SEC
msg_CIOUT_fail:
; XXX should we set status?
lda #K_ERR_DEVICE_NOT_FOUND
jmp dos_EXIT_A_SEC
@@ -41,6 +49,8 @@ msg_CIOUT_cmdfn_SD: ; get next byte of status - SD card
@1:
lda #$00
sta SD_CMDFN_IDX,x
plp
+bcs dev_sd_cmd_OPEN_EOI ; if EOI - execute command
jmp dos_EXIT
msg_CIOUT_cmdfn_FD: ; get next byte of status - floppy
@@ -53,6 +63,8 @@ msg_CIOUT_cmdfn_FD: ; get next byte of status - floppy
@1:
lda #$00
sta FD_CMDFN_IDX,x
plp
+bcs dev_fd_cmd_OPEN_EOI ; if EOI - execute command
jmp dos_EXIT
msg_CIOUT_cmdfn_RD: ; get next byte of status - ram disk
@@ -65,6 +77,8 @@ msg_CIOUT_cmdfn_RD: ; get next byte of status - ram disk
@1:
lda #$00
sta RD_CMDFN_IDX,x
plp
+bcs dev_rd_cmd_OPEN_EOI ; if EOI - execute command
jmp dos_EXIT
msg_CIOUT_cmdfn_vectab:
+1 -1
View File
@@ -1224,7 +1224,7 @@ void DataSet::generateConfigDepStrings()
// CBDOS features
featureStrM65 += "CBDOS : SDCARD ";
featureStrM65 += "CBDOS : SD CARD ";
// Keyboard support features