some work towards 2nd floppy

This commit is contained in:
FeralChild64 committed 2021-05-16 17:58:22 +02:00
1 parent 6180472a9b
commit f6abf8e4cd
23 files changed
+370 -186

No files matched your search

+1 -1
View File
@@ -177,7 +177,7 @@ Enable this option if you are using a tape interface adapter lacking tape motor
## Additional storage ## Additional storage
### `UNIT_SDCARD`, `UNIT_FLOPPY`, `UNIT_RAMDISK` ### `UNIT_SDCARD`, `UNIT_FLOPPY0`, `UNIT_FLOPPY1`, `UNIT_RAMDISK`
MEGA65 specific pseudo-IEC devices, handled by internal DOS (work in progress). If set to 0, given unit is disabled. Otherwise - assigns IEC unit number to the given storage. MEGA65 specific pseudo-IEC devices, handled by internal DOS (work in progress). If set to 0, given unit is disabled. Otherwise - assigns IEC unit number to the given storage.
+1
View File
@@ -21,6 +21,7 @@ SRCDIR_BASIC = $(SRCDIR_COMMON) \
src/basic/basic_functions_06 \ src/basic/basic_functions_06 \
src/basic/board_crt \ src/basic/board_crt \
src/basic/board_m65 \ src/basic/board_m65 \
src/basic/board_u64 \
src/basic/board_x16 \ src/basic/board_x16 \
src/basic/engine_editor \ src/basic/engine_editor \
src/basic/engine_runtime \ src/basic/engine_runtime \
+2 -1
View File
@@ -91,7 +91,8 @@
; --- Built-in DOS configuration ; --- Built-in DOS configuration
;; #CONFIG# UNIT_SDCARD 27 ;; #CONFIG# UNIT_SDCARD 27
;; #CONFIG# UNIT_FLOPPY 28 ; XXX use separate number for second floppy (device 29) ;; #CONFIG# UNIT_FLOPPY0 28
;; #CONFIG# UNIT_FLOPPY1 29
;; #CONFIG# UNIT_RAMDISK 30 ;; #CONFIG# UNIT_RAMDISK 30
+12
View File
@@ -0,0 +1,12 @@
Information about Ultimate 64 bank switching: https://www.forum64.de/index.php?thread/102375-16k-bzw-24k-kernal/&postID=1674790#post1674790
lda $e460 ; only needed if switching from outside of the Kernal
lda $e460
lda $e494
lda $e464
lda $e462
lda $e495
lda $e480+bankno
There can be no $e460-$e49f access in between.
+79 -63
View File
@@ -32,13 +32,14 @@
!addr RAM_ATTIC = $8009 ; $8000000-$87FFFFF RAM status; 0 = not present, $FF = present !addr RAM_ATTIC = $8009 ; $8000000-$87FFFFF RAM status; 0 = not present, $FF = present
!addr RAM_CELLAR = $800A ; $8800000-$8FFFFFF RAM status; 0 = not present, $FF = present !addr RAM_CELLAR = $800A ; $8800000-$8FFFFFF RAM status; 0 = not present, $FF = present
; Reserved: $800B - $800C ; Reserved: $800B
; General DOS configuration ; General DOS configuration
!addr UNIT_SDCARD = $800D ; unit number for device, 0 = none !addr UNIT_SDCARD = $800C ; unit number for device, 0 = none
!addr UNIT_FLOPPY = $800E ; as above !addr UNIT_FLOPPY0 = $800D ; as above - for the internal floppy
!addr UNIT_RAMDISK = $800F ; as above !addr UNIT_FLOPPY1 = $800E ; as above - for additional floppy drive
!addr UNIT_RAMDISK = $800F ; as above - for the RAM disk
; General DOS status ; General DOS status
@@ -51,7 +52,7 @@
!addr code_LDA_nnnn_Y = $8014 ; - LDA nnnn, Y instruction !addr code_LDA_nnnn_Y = $8014 ; - LDA nnnn, Y instruction
!addr par_LDA_nnnn_Y = $8015 ; - 2 bytes; address !addr par_LDA_nnnn_Y = $8015 ; - 2 bytes; address
!addr code_RTS_04 = $8017 ; - RTS instruction !addr code_RTS_05 = $8017 ; - RTS instruction
; Parameters for utilities/helpers ; Parameters for utilities/helpers
@@ -69,65 +70,78 @@
!addr XX_DIR_PHASE = $8041 ; directory output phase, values deponds on device driver, but 0 = not reading !addr XX_DIR_PHASE = $8041 ; directory output phase, values deponds on device driver, but 0 = not reading
!addr SD_DIR_PHASE = $8041 ; - SD card !addr SD_DIR_PHASE = $8041 ; - SD card
!addr FD_DIR_PHASE = $8042 ; - floppy !addr F0_DIR_PHASE = $8042 ; - floppy 0
!addr RD_DIR_PHASE = $8043 ; - ram disk !addr F1_DIR_PHASE = $8043 ; - floppy 0
!addr RD_DIR_PHASE = $8044 ; - ram disk
; Free space: $8044-$8063 ; Free space: $8045-$8063
!addr SD_ACPTR_helper = $8052 ; subroutine in RAM to read a byte !addr SD_ACPTR_helper = $8052 ; subroutine in RAM to read a byte
!addr code_LDA_01 = $8052 ; - LDA instruction !addr code_LDA_01 = $8052 ; - LDA instruction
!addr SD_ACPTR_PTR = $8053 ; - 2 bytes; address in buffer, SD card !addr SD_ACPTR_PTR = $8053 ; - 2 bytes; address in buffer, SD card
!addr code_RTS_01 = $8055 ; - RTS instruction !addr code_RTS_01 = $8055 ; - RTS instruction
!addr FD_ACPTR_helper = $8056 ; subroutine in RAM to read a byte !addr F0_ACPTR_helper = $8056 ; subroutine in RAM to read a byte
!addr code_LDA_02 = $8056 ; - LDA instruction !addr code_LDA_02 = $8056 ; - LDA instruction
!addr FD_ACPTR_PTR = $8057 ; - 2 bytes; address in buffer, floppy !addr F0_ACPTR_PTR = $8057 ; - 2 bytes; address in buffer, floppy 0
!addr code_RTS_02 = $8059 ; - RTS instruction !addr code_RTS_02 = $8059 ; - RTS instruction
!addr RD_ACPTR_helper = $805A ; subroutine in RAM to read a byte !addr F1_ACPTR_helper = $805A ; subroutine in RAM to read a byte
!addr code_LDA_03 = $805A ; - LDA instruction !addr code_LDA_03 = $805A ; - LDA instruction
!addr RD_ACPTR_PTR = $805B ; - 2 bytes; address in buffer, ram disk !addr F1_ACPTR_PTR = $805B ; - 2 bytes; address in buffer, floppy 1
!addr code_RTS_03 = $805D ; - RTS instruction !addr code_RTS_03 = $805D ; - RTS instruction
!addr XX_ACPTR_LEN = $805E ; 2 bytes - length of data left for ACPTR !addr RD_ACPTR_helper = $805E ; subroutine in RAM to read a byte
!addr SD_ACPTR_LEN = $805E ; - SD card !addr code_LDA_04 = $805E ; - LDA instruction
!addr FD_ACPTR_LEN = $8060 ; - floppy !addr RD_ACPTR_PTR = $805F ; - 2 bytes; address in buffer, ram disk
!addr RD_ACPTR_LEN = $8062 ; - ram disk !addr code_RTS_04 = $8061 ; - RTS instruction
!addr XX_MODE = $8064 ; current mode (0 = none, 1 = receiving command/file name) !addr XX_ACPTR_LEN = $8062 ; 2 bytes - length of data left for ACPTR
!addr SD_MODE = $8064 ; - SD card !addr SD_ACPTR_LEN = $8062 ; - SD card
!addr FD_MODE = $8065 ; - floppy !addr F0_ACPTR_LEN = $8064 ; - floppy
!addr RD_MODE = $8066 ; - ram disk !addr F1_ACPTR_LEN = $8064 ; - floppy
!addr RD_ACPTR_LEN = $8066 ; - ram disk
!addr XX_CHANNEL = $8067 ; current channel !addr XX_MODE = $8068 ; current mode (0 = none, 1 = receiving command/file name)
!addr SD_CHANNEL = $8067 ; - SD card !addr SD_MODE = $8068 ; - SD card
!addr FD_CHANNEL = $8068 ; - floppy !addr F0_MODE = $8069 ; - floppy 0
!addr RD_CHANNEL = $8069 ; - ram disk !addr F1_MODE = $806A ; - floppy 1
!addr RD_MODE = $806B ; - ram disk
!addr XX_CMDFN_IDX = $806A ; index byte for storing file name/command !addr XX_CHANNEL = $806C ; current channel
!addr SD_CMDFN_IDX = $806A ; - SD card !addr SD_CHANNEL = $806C ; - SD card
!addr FD_CMDFN_IDX = $806B ; - floppy !addr F0_CHANNEL = $806D ; - floppy 0
!addr RD_CMDFN_IDX = $806C ; - ram disk !addr F1_CHANNEL = $806E ; - floppy 0
!addr RD_CHANNEL = $806F ; - ram disk
!addr XX_STATUS_IDX = $806D ; index byte for reading status !addr XX_CMDFN_IDX = $8070 ; index byte for storing file name/command
!addr SD_STATUS_IDX = $806D ; - SD card !addr SD_CMDFN_IDX = $8070 ; - SD card
!addr FD_STATUS_IDX = $806E ; - floppy !addr F0_CMDFN_IDX = $8071 ; - floppy 0
!addr RD_STATUS_IDX = $806F ; - ram disk !addr F1_CMDFN_IDX = $8072 ; - floppy 1
!addr RD_CMDFN_IDX = $8073 ; - ram disk
!addr XX_STATUS_IDX = $8074 ; index byte for reading status
!addr SD_STATUS_IDX = $8074 ; - SD card
!addr F0_STATUS_IDX = $8075 ; - floppy
!addr F1_STATUS_IDX = $8076 ; - floppy
!addr RD_STATUS_IDX = $8077 ; - ram disk
; Various, most likely to be reworked ; Various, most likely to be reworked
!addr SD_DESC = $8070 ; current file descriptor !addr SD_DESC = $8078 ; current file descriptor
!addr FD_DIRENT = $8071 ; directory entry to read, 0-15 !addr F0_DIRENT = $8079 ; directory entry to read, 0-15
!addr F1_DIRENT = $807A ; directory entry to read, 0-15
!addr FD_LOADTRACK = $8072 ; current track for file loading !addr F0_LOADTRACK = $807B ; current track for file loading
!addr FD_LOADSECTOR = $8073 ; current sector for file loading !addr F0_LOADSECTOR = $807C ; current sector for file loading
!addr RD_STARTSEG = $8074 ; RAM disk start address, 2nd most significant byte (or $FF if no RAM) !addr F1_LOADTRACK = $807D ; current track for file loading
!addr RD_MAXTRACK = $8075 ; maximum RAM disk track number !addr F1_LOADSECTOR = $807E ; current sector for file loading
!addr RD_STARTSEG = $807F ; RAM disk start address, 2nd most significant byte (or $FF if no RAM)
!addr RD_MAXTRACK = $8080 ; maximum RAM disk track number
; XXX Free space ; Reserved: $8081-$81FF
; ;
; Various buffers, caches, and other large memory chunks ; Various buffers, caches, and other large memory chunks
@@ -137,8 +151,8 @@
; General purpose buffers, 512 bytes each, each starts at page start - XXX dynamic alllocation to be written ; General purpose buffers, 512 bytes each, each starts at page start - XXX dynamic alllocation to be written
!addr SHARED_BUF_0 = $8200 ; XXX temporarily hardcoded for usage by SD card !addr SHARED_BUF_0 = $8200 ; XXX temporarily hardcoded for usage by SD card
!addr SHARED_BUF_1 = $8400 ; XXX temporarily hardcoded for usage by floppy !addr SHARED_BUF_1 = $8400 ; XXX temporarily hardcoded for usage by floppy 0
!addr SHARED_BUF_2 = $8600 !addr SHARED_BUF_2 = $8600 ; XXX temporarily hardcoded for usage by floppy 1
!addr SHARED_BUF_3 = $8800 !addr SHARED_BUF_3 = $8800
!addr SHARED_BUF_4 = $8A00 !addr SHARED_BUF_4 = $8A00
!addr SHARED_BUF_5 = $8C00 !addr SHARED_BUF_5 = $8C00
@@ -151,49 +165,51 @@
!addr SHARED_BUF_C = $9A00 !addr SHARED_BUF_C = $9A00
!addr SHARED_BUF_D = $9C00 !addr SHARED_BUF_D = $9C00
!addr SHARED_BUF_E = $9E00 !addr SHARED_BUF_E = $9E00
!addr SHARED_BUF_F = $A000
; BAM cache for floppy drives; 2 KB (4 blocks) each, to cover up to ED floppies ; BAM cache for floppy drives; 2 KB (4 blocks) each, to cover up to ED floppies
!addr FD_BAM_CACHE_0 = $A200 ; - floppy disk 0 BAM !addr F0_BAM_CACHE = $A000 ; - floppy disk 0 BAM
!addr SHARED_BUF_X0 = $A400 ; - buffer which can be used if disk is not ED !addr SHARED_BUF_X0 = $A200 ; - buffer which can be used if disk is not ED
!addr FD_BAM_CACHE_1 = $A600 ; - floppy disk 1 BAM !addr F1_BAM_CACHE = $A400 ; - floppy disk 1 BAM
!addr SHARED_BUF_X1 = $A800 ; - buffer which can be used if disk is not ED !addr SHARED_BUF_X1 = $A600 ; - buffer which can be used if disk is not ED
; Memory shadow, needed for SD card support ; Memory shadow, needed for SD card support
!addr SD_MEMSHADOW_BUF = $AA00 ; 256 byte buffer for preserving original memory content !addr SD_MEMSHADOW_BUF = $A800 ; 256 byte buffer for preserving original memory content
; Command/filename buffers, 128 bytes each - XXX extend to 256 bytes (change implementation) ; Command/filename buffers, 256 bytes each
!addr SD_CMDFN_BUF = $AB00 ; - SD card !addr SD_CMDFN_BUF = $A900 ; - SD card
!addr FD_CMDFN_BUF = $AC00 ; - floppy !addr F0_CMDFN_BUF = $AA00 ; - floppy 0
!addr F1_CMDFN_BUF = $AB00 ; - floppy 1
!addr RD_CMDFN_BUF = $AD00 ; - ram disk !addr RD_CMDFN_BUF = $AD00 ; - ram disk
; Directory entry buffers, in BASIC format, $30 bytes each ; Directory entry buffers, in BASIC format, $30 bytes each
!addr XX_DIRENT_BUF = $AE00 !addr XX_DIRENT_BUF = $AE00
!addr SD_DIRENT_BUF = $AE00 ; - SD card !addr SD_DIRENT_BUF = $AE00 ; - SD card
!addr FD_DIRENT_BUF = $AE30 ; - floppy !addr F0_DIRENT_BUF = $AE30 ; - floppy 0
!addr RD_DIRENT_BUF = $AE60 ; - ram disk !addr F1_DIRENT_BUF = $AE60 ; - floppy 1
!addr RD_DIRENT_BUF = $AE90 ; - ram disk
; Status buffers, content terminated by 0, $30 bytes each ; Status buffers, content terminated by 0, $30 bytes each
!addr XX_STATUS_BUF = $AE90 !addr XX_STATUS_BUF = $AEC0
!addr SD_STATUS_BUF = $AE90 ; - SD card !addr SD_STATUS_BUF = $AEC0 ; - SD card
!addr FD_STATUS_BUF = $AEC0 ; - floppy !addr F0_STATUS_BUF = $AEF0 ; - floppy 0
!addr RD_STATUS_BUF = $AEF0 ; - ram disk !addr F1_STATUS_BUF = $AF20 ; - floppy 1
!addr RD_STATUS_BUF = $AF50 ; - ram disk
; Shared buffer metadata tables, 18 bytes each ; Shared buffer metadata tables, 18 bytes each
!addr BUFTAB_UNIT = $AF20 ; which unit the buffer is assigned to !addr BUFTAB_UNIT = $AF50 ; which unit the buffer is assigned to
!addr BUFTAB_DEV = $AF32 ; which device within the unit !addr BUFTAB_DEV = $AF62 ; which device within the unit
!addr BUFTAB_TRACK = $AF44 ; which track (or other kind of handle) !addr BUFTAB_TRACK = $AF74 ; which track (or other kind of handle)
!addr BUFTAB_SECTOR = $AF56 ; which sector is stored in the first half of the buffer !addr BUFTAB_SECTOR = $AF86 ; which sector is stored in the first half of the buffer
; Common DMA list, 15 bytes ; Common DMA list, 15 bytes
!addr DMAJOB_LIST = $AF68 !addr DMAJOB_LIST = $AF98
!addr DMAJOB_SRC_MB = DMAJOB_LIST+2 !addr DMAJOB_SRC_MB = DMAJOB_LIST+2
!addr DMAJOB_DST_MB = DMAJOB_LIST+4 !addr DMAJOB_DST_MB = DMAJOB_LIST+4
!addr DMAJOB_SIZE = DMAJOB_LIST+7 ; keep $0200 here !addr DMAJOB_SIZE = DMAJOB_LIST+7 ; keep $0200 here
@@ -204,4 +220,4 @@
; Reserved 20 KB for floppy track buffers + some area still free ; Reserved 20 KB for floppy track buffers + some area still free
; ;
!addr XX_REMAINING = $AF87 !addr XX_REMAINING = $AFA7
+6 -2
View File
@@ -26,8 +26,10 @@ dos_INIT:
lda #CONFIG_UNIT_SDCARD lda #CONFIG_UNIT_SDCARD
sta UNIT_SDCARD sta UNIT_SDCARD
lda #CONFIG_UNIT_FLOPPY lda #CONFIG_UNIT_FLOPPY0
sta UNIT_FLOPPY sta UNIT_FLOPPY0
lda #CONFIG_UNIT_FLOPPY1
sta UNIT_FLOPPY1
lda #CONFIG_UNIT_RAMDISK lda #CONFIG_UNIT_RAMDISK
sta UNIT_RAMDISK sta UNIT_RAMDISK
@@ -68,6 +70,7 @@ dos_INIT:
sta code_LDA_01 sta code_LDA_01
sta code_LDA_02 sta code_LDA_02
sta code_LDA_03 sta code_LDA_03
sta code_LDA_04
lda #$B9 ; LDA nnnn, y opcode lda #$B9 ; LDA nnnn, y opcode
sta code_LDA_nnnn_Y sta code_LDA_nnnn_Y
@@ -77,6 +80,7 @@ dos_INIT:
sta code_RTS_02 sta code_RTS_02
sta code_RTS_03 sta code_RTS_03
sta code_RTS_04 sta code_RTS_04
sta code_RTS_05
; Initialize device handlers ; Initialize device handlers
+6
View File
@@ -28,6 +28,8 @@ dos_MEMCHK:
bne @fail bne @fail
cmp code_LDA_03 cmp code_LDA_03
bne @fail bne @fail
cmp code_LDA_04
bne @fail
lda #$60 lda #$60
cmp code_RTS_01 cmp code_RTS_01
@@ -36,6 +38,10 @@ dos_MEMCHK:
bne @fail bne @fail
cmp code_RTS_03 cmp code_RTS_03
bne @fail bne @fail
cmp code_RTS_04
bne @fail
cmp code_RTS_05
bne @fail
plx plx
pla pla
+13 -4
View File
@@ -18,8 +18,10 @@ dos_UNITCHK:
cmp UNIT_SDCARD cmp UNIT_SDCARD
beq dos_UNITCHK_sdcard beq dos_UNITCHK_sdcard
cmp UNIT_FLOPPY cmp UNIT_FLOPPY0
beq dos_UNITCHK_floppy beq dos_UNITCHK_floppy0
cmp UNIT_FLOPPY1
beq dos_UNITCHK_floppy1
cmp UNIT_RAMDISK cmp UNIT_RAMDISK
beq dos_UNITCHK_ramdisk beq dos_UNITCHK_ramdisk
@@ -36,15 +38,22 @@ dos_UNITCHK_sdcard:
; FALLTROUGH ; FALLTROUGH
dos_UNITCHK_floppy: dos_UNITCHK_floppy0:
lda #$01 lda #$01
+skip_2_bytes_trash_nvz +skip_2_bytes_trash_nvz
; FALLTROUGH ; FALLTROUGH
dos_UNITCHK_ramdisk: dos_UNITCHK_floppy1:
lda #$02 lda #$02
+skip_2_bytes_trash_nvz
; FALLTROUGH
dos_UNITCHK_ramdisk:
lda #$03
jmp dos_EXIT_CLC_A jmp dos_EXIT_CLC_A
+10 -3
View File
@@ -20,8 +20,10 @@ dos_UNITNUM:
cmp #$00 cmp #$00
beq dos_UNITNUM_sdcard beq dos_UNITNUM_sdcard
cmp #$01 cmp #$01
beq dos_UNITNUM_floppy beq dos_UNITNUM_floppy0
cmp #$02 cmp #$02
beq dos_UNITNUM_floppy1
cmp #$03
beq dos_UNITNUM_ramdisk beq dos_UNITNUM_ramdisk
; FALLTROUGH ; FALLTROUGH
@@ -37,9 +39,14 @@ dos_UNITNUM_sdcard:
lda UNIT_SDCARD lda UNIT_SDCARD
bra dos_UNITNUM_common bra dos_UNITNUM_common
dos_UNITNUM_floppy: dos_UNITNUM_floppy0:
lda UNIT_FLOPPY lda UNIT_FLOPPY0
bra dos_UNITNUM_common
dos_UNITNUM_floppy1:
lda UNIT_FLOPPY1
bra dos_UNITNUM_common bra dos_UNITNUM_common
dos_UNITNUM_ramdisk: dos_UNITNUM_ramdisk:
+14 -4
View File
@@ -21,8 +21,10 @@ dos_UNITSET:
cmp #$00 cmp #$00
beq dos_UNITSET_sdcard beq dos_UNITSET_sdcard
cmp #$01 cmp #$01
beq dos_UNITSET_floppy beq dos_UNITSET_floppy0
cmp #$02 cmp #$02
beq dos_UNITSET_floppy1
cmp #$03
beq dos_UNITSET_ramdisk beq dos_UNITSET_ramdisk
jmp dos_EXIT_SEC jmp dos_EXIT_SEC
@@ -30,15 +32,23 @@ dos_UNITSET:
dos_UNITSET_sdcard: dos_UNITSET_sdcard:
stx UNIT_SDCARD stx UNIT_SDCARD
+skip_2_bytes_trash_nvz
; FALLTROUGH ; FALLTROUGH
dos_UNITSET_floppy: dos_UNITSET_end:
stx UNIT_FLOPPY
jmp dos_EXIT_CLC jmp dos_EXIT_CLC
dos_UNITSET_floppy0:
stx UNIT_FLOPPY0
bra dos_UNITSET_end
dos_UNITSET_floppy1:
stx UNIT_FLOPPY1
bra dos_UNITSET_end
dos_UNITSET_ramdisk: dos_UNITSET_ramdisk:
stx UNIT_RAMDISK stx UNIT_RAMDISK
@@ -12,7 +12,7 @@
fs_cbm_nextdirentry: fs_cbm_nextdirentry:
lda FD_DIRENT lda F0_DIRENT
; If first entry within sector - make sure it is present within the buffer ; If first entry within sector - make sure it is present within the buffer
@@ -42,7 +42,7 @@ fs_cbm_nextdirentry:
@1: @1:
; Set next directory entry ; Set next directory entry
inc FD_DIRENT inc F0_DIRENT
; Copy data to parameter variables ; Copy data to parameter variables
@@ -69,10 +69,10 @@ fs_cbm_nextdirentry:
ldy #$03 ; get file starting track and sector ldy #$03 ; get file starting track and sector
jsr code_LDA_nnnn_Y jsr code_LDA_nnnn_Y
sta FD_LOADTRACK sta F0_LOADTRACK
iny iny
jsr code_LDA_nnnn_Y jsr code_LDA_nnnn_Y
sta FD_LOADSECTOR sta F0_LOADSECTOR
iny ; copy the file name iny ; copy the file name
@lp1: @lp1:
@@ -124,7 +124,7 @@ fs_cbm_nextdirentry:
beq @2 beq @2
lda #$08 lda #$08
@2: @2:
sta FD_DIRENT sta F0_DIRENT
jmp @cont jmp @cont
@end_of_dir: @end_of_dir:
@@ -4,6 +4,8 @@
; ;
; XXX add support for both floppies
fs_cbm_nextfileblock: fs_cbm_nextfileblock:
; Fetch the next track/sector ; Fetch the next track/sector
@@ -55,14 +57,14 @@ fs_cbm_nextfileblock_got_ts:
; Store pointer and amount of data ready to fetch ; Store pointer and amount of data ready to fetch
lda #$FE lda #$FE
sta FD_ACPTR_LEN+0 sta F0_ACPTR_LEN+0
lda #$00 lda #$00
sta FD_ACPTR_LEN+1 sta F0_ACPTR_LEN+1
lda #$02 lda #$02
sta FD_ACPTR_PTR+0 sta F0_ACPTR_PTR+0
lda #>SHARED_BUF_1 lda #>SHARED_BUF_1
sta FD_ACPTR_PTR+1 sta F0_ACPTR_PTR+1
lda PAR_SECTOR lda PAR_SECTOR
and #$01 and #$01
@@ -84,7 +86,7 @@ fs_cbm_nextfileblock_got_ts:
; Sector with data is located in the 2nd half of the buffer ; Sector with data is located in the 2nd half of the buffer
inc FD_ACPTR_PTR+1 inc F0_ACPTR_PTR+1
lda SHARED_BUF_1+$100+0 lda SHARED_BUF_1+$100+0
bne @exit bne @exit
@@ -99,7 +101,7 @@ fs_cbm_nextfileblock_got_ts:
cmp #$FF cmp #$FF
beq fs_cbm_nextfileblock_eof beq fs_cbm_nextfileblock_eof
sta FD_ACPTR_LEN+0 sta F0_ACPTR_LEN+0
; FALLTROUGH ; FALLTROUGH
+36 -36
View File
@@ -20,56 +20,56 @@ fs_cbm_read_dir_open:
ldx #$1F ; first fetch the template ldx #$1F ; first fetch the template
@lp1: @lp1:
lda dir_hdr,x lda dir_hdr,x
sta FD_DIRENT_BUF,x sta F0_DIRENT_BUF,x
dex dex
bpl @lp1 bpl @lp1
ldx #$0F ; file name ldx #$0F ; file name
@lp2: @lp2:
lda SHARED_BUF_1+$04,x lda SHARED_BUF_1+$04,x
sta FD_DIRENT_BUF+$08,x sta F0_DIRENT_BUF+$08,x
dex dex
bpl @lp2 bpl @lp2
lda SHARED_BUF_1+$16 ; disk ID XXX test this on a disk with ID lda SHARED_BUF_1+$16 ; disk ID XXX test this on a disk with ID
cmp #$A0 cmp #$A0
beq @skip1 beq @skip1
sta FD_DIRENT_BUF+$1A sta F0_DIRENT_BUF+$1A
@skip1: @skip1:
lda SHARED_BUF_1+$17 lda SHARED_BUF_1+$17
cmp #$A0 cmp #$A0
beq @skip2 beq @skip2
sta FD_DIRENT_BUF+$1B sta F0_DIRENT_BUF+$1B
@skip2: @skip2:
lda SHARED_BUF_1+$19 ; dos version lda SHARED_BUF_1+$19 ; dos version
sta FD_DIRENT_BUF+$1D sta F0_DIRENT_BUF+$1D
lda SHARED_BUF_1+$1A lda SHARED_BUF_1+$1A
sta FD_DIRENT_BUF+$1E sta F0_DIRENT_BUF+$1E
; Provide pointer to the header ; Provide pointer to the header
lda #$20 lda #$20
sta FD_ACPTR_LEN+0 sta F0_ACPTR_LEN+0
lda #$00 lda #$00
sta FD_ACPTR_LEN+1 sta F0_ACPTR_LEN+1
lda #<FD_DIRENT_BUF lda #<F0_DIRENT_BUF
sta FD_ACPTR_PTR+0 sta F0_ACPTR_PTR+0
lda #>FD_DIRENT_BUF lda #>F0_DIRENT_BUF
sta FD_ACPTR_PTR+1 sta F0_ACPTR_PTR+1
; Set directory phase to 'file name' ; Set directory phase to 'file name'
lda #$01 lda #$01
sta FD_DIR_PHASE sta F0_DIR_PHASE
; Copy 1st BAM sector to the cache ; Copy 1st BAM sector to the cache
ldx #$00 ldx #$00
@lp3: @lp3:
lda SHARED_BUF_1+$100, x lda SHARED_BUF_1+$100, x
sta FD_BAM_CACHE_0,x sta F0_BAM_CACHE,x
inx inx
bne @lp3 bne @lp3
@@ -85,14 +85,14 @@ fs_cbm_read_dir_open:
ldx #$00 ldx #$00
@lp4: @lp4:
lda SHARED_BUF_1, x lda SHARED_BUF_1, x
sta FD_BAM_CACHE_0+$100,x sta F0_BAM_CACHE+$100,x
inx inx
bne @lp4 bne @lp4
; Set variables to point to the 1st directory entry in the 2nd sector of the buffer ; Set variables to point to the 1st directory entry in the 2nd sector of the buffer
lda #$08 lda #$08
sta FD_DIRENT sta F0_DIRENT
; Make sure the 1st sector in buffer points to 2nd one ; Make sure the 1st sector in buffer points to 2nd one
@@ -117,22 +117,22 @@ fs_cbm_read_dir:
; Prepare output entry, starting from XX_DIRENT_BUF + initial offset ; Prepare output entry, starting from XX_DIRENT_BUF + initial offset
jsr util_dir_filesize_blocks jsr util_dir_filesize_blocks
ldx #(FD_DIRENT_BUF - XX_DIRENT_BUF) ldx #(F0_DIRENT_BUF - XX_DIRENT_BUF)
ldx #$30 ldx #$30
jsr util_dir_basic jsr util_dir_basic
; Provide pointers and length ; Provide pointers and length
sta FD_ACPTR_LEN+1 sta F0_ACPTR_LEN+1
txa txa
sec sec
sbc #$30 sbc #$30
sta FD_ACPTR_LEN+0 sta F0_ACPTR_LEN+0
lda #<(FD_DIRENT_BUF) lda #<(F0_DIRENT_BUF)
sta FD_ACPTR_PTR+0 sta F0_ACPTR_PTR+0
lda #>(FD_DIRENT_BUF) lda #>(F0_DIRENT_BUF)
sta FD_ACPTR_PTR+1 sta F0_ACPTR_PTR+1
clc clc
rts rts
@@ -143,7 +143,7 @@ fs_cbm_read_dir_blocksfree:
ldx #$13 ldx #$13
@lp1: @lp1:
lda dir_end, x lda dir_end, x
sta FD_DIRENT_BUF, x sta F0_DIRENT_BUF, x
dex dex
bpl @lp1 bpl @lp1
@@ -151,11 +151,11 @@ fs_cbm_read_dir_blocksfree:
ldx #$10 ldx #$10
@lp2: @lp2:
lda FD_BAM_CACHE_0+$100,x lda F0_BAM_CACHE+$100,x
jsr @sub_free_add jsr @sub_free_add
cpx #$FA cpx #$FA
beq @lp2_end beq @lp2_end
lda FD_BAM_CACHE_0+$000,x lda F0_BAM_CACHE+$000,x
jsr @sub_free_add jsr @sub_free_add
inx inx
inx inx
@@ -170,19 +170,19 @@ fs_cbm_read_dir_blocksfree:
; Set pointer and length ; Set pointer and length
lda #$13 lda #$13
sta FD_ACPTR_LEN+0 sta F0_ACPTR_LEN+0
lda #$00 lda #$00
sta FD_ACPTR_LEN+1 sta F0_ACPTR_LEN+1
lda #<FD_DIRENT_BUF lda #<F0_DIRENT_BUF
sta FD_ACPTR_PTR+0 sta F0_ACPTR_PTR+0
lda #>FD_DIRENT_BUF lda #>F0_DIRENT_BUF
sta FD_ACPTR_PTR+1 sta F0_ACPTR_PTR+1
; Mark end of directory ; Mark end of directory
lda #$00 lda #$00
sta FD_DIR_PHASE sta F0_DIR_PHASE
clc clc
rts rts
@@ -193,9 +193,9 @@ fs_cbm_read_dir_blocksfree:
; Helper routine to calculate free blocks ; Helper routine to calculate free blocks
clc clc
adc FD_DIRENT_BUF+2 adc F0_DIRENT_BUF+2
sta FD_DIRENT_BUF+2 sta F0_DIRENT_BUF+2
bcc @noinc bcc @noinc
inc FD_DIRENT_BUF+3 inc F0_DIRENT_BUF+3
@noinc: @noinc:
rts rts
@@ -18,7 +18,7 @@ fs_cbm_read_file_open:
; Set variables to point to the 1st directory entry in the 2nd sector of the buffer ; Set variables to point to the 1st directory entry in the 2nd sector of the buffer
lda #$08 lda #$08
sta FD_DIRENT sta F0_DIRENT
; Make sure the 1st sector in buffer points to 2nd one ; Make sure the 1st sector in buffer points to 2nd one
@@ -51,11 +51,11 @@ fs_cbm_read_file_open:
; Found the file, load it ; Found the file, load it
lda #$03 ; mode: read file lda #$03 ; mode: read file
sta FD_MODE sta F0_MODE
lda FD_LOADTRACK lda F0_LOADTRACK
sta PAR_TRACK sta PAR_TRACK
lda FD_LOADSECTOR lda F0_LOADSECTOR
sta PAR_SECTOR sta PAR_SECTOR
jmp fs_cbm_nextfileblock_got_ts jmp fs_cbm_nextfileblock_got_ts
+56 -16
View File
@@ -62,31 +62,61 @@ msg_ACPTR_read_SD:
@3: @3:
jmp dos_EXIT_CLC jmp dos_EXIT_CLC
msg_ACPTR_read_FD: msg_ACPTR_read_F0:
; Read and return one byte ; Read and return one byte
jsr FD_ACPTR_helper jsr F0_ACPTR_helper
sta TBTCNT sta TBTCNT
sta REG_A sta REG_A
; Increment pointer, decrement length ; Increment pointer, decrement length
inc FD_ACPTR_PTR+0 inc F0_ACPTR_PTR+0
bne @1 bne @1
inc FD_ACPTR_PTR+1 inc F0_ACPTR_PTR+1
@1: @1:
dec FD_ACPTR_LEN+0 dec F0_ACPTR_LEN+0
lda FD_ACPTR_LEN+0 lda F0_ACPTR_LEN+0
cmp #$FF cmp #$FF
bne @2 bne @2
dec FD_ACPTR_LEN+1 dec F0_ACPTR_LEN+1
@2: @2:
; If new length is 0, try to read next block of data ; If new length is 0, try to read next block of data
ora FD_ACPTR_LEN+1 ora F0_ACPTR_LEN+1
bne @3 bne @3
jsr unit_fd_cmd_READ jsr unit_f0_cmd_READ
bcc @3
jsr kernalstatus_EOI
@3:
jmp dos_EXIT_CLC
msg_ACPTR_read_F1:
; Read and return one byte
jsr F1_ACPTR_helper
sta TBTCNT
sta REG_A
; Increment pointer, decrement length
inc F1_ACPTR_PTR+0
bne @1
inc F1_ACPTR_PTR+1
@1:
dec F1_ACPTR_LEN+0
lda F1_ACPTR_LEN+0
cmp #$FF
bne @2
dec F1_ACPTR_LEN+1
@2:
; If new length is 0, try to read next block of data
ora F1_ACPTR_LEN+1
bne @3
jsr unit_f1_cmd_READ
bcc @3 bcc @3
jsr kernalstatus_EOI jsr kernalstatus_EOI
@3: @3:
@@ -117,11 +147,18 @@ msg_ACPTR_status_SD: ; get next byte of status - SD card
lda SD_STATUS_BUF,x lda SD_STATUS_BUF,x
bra msg_ACPTR_status_got bra msg_ACPTR_status_got
msg_ACPTR_status_FD: ; get next byte of status - floppy msg_ACPTR_status_F0: ; get next byte of status - floppy 0
ldx FD_STATUS_IDX ldx F0_STATUS_IDX
inc FD_STATUS_IDX inc F0_STATUS_IDX
lda FD_STATUS_BUF,x lda F0_STATUS_BUF,x
bra msg_ACPTR_status_got
msg_ACPTR_status_F1: ; get next byte of status - floppy 0
ldx F1_STATUS_IDX
inc F1_STATUS_IDX
lda F1_STATUS_BUF,x
bra msg_ACPTR_status_got bra msg_ACPTR_status_got
msg_ACPTR_status_RD: ; get next byte of status - ram disk msg_ACPTR_status_RD: ; get next byte of status - ram disk
@@ -166,17 +203,20 @@ msg_ACPTR_EOI:
msg_ACPTR_status_vectab: msg_ACPTR_status_vectab:
!word msg_ACPTR_status_SD !word msg_ACPTR_status_SD
!word msg_ACPTR_status_FD !word msg_ACPTR_status_F0
!word msg_ACPTR_status_F1
!word msg_ACPTR_status_RD !word msg_ACPTR_status_RD
msg_ACPTR_read_vectab: msg_ACPTR_read_vectab:
!word msg_ACPTR_read_SD !word msg_ACPTR_read_SD
!word msg_ACPTR_read_FD !word msg_ACPTR_read_F0
!word msg_ACPTR_read_F1
!word msg_ACPTR_read_RD !word msg_ACPTR_read_RD
msg_ACPTR_set_status_vectab: msg_ACPTR_set_status_vectab:
!word util_status_SD !word util_status_SD
!word util_status_FD !word util_status_F0
!word util_status_F1
!word util_status_RD !word util_status_RD
+23 -7
View File
@@ -38,7 +38,7 @@ msg_CIOUT_fail:
; Receiving command/file name ; Receiving command/file name XXX limit $7F is too small, buffer size is 256 bytes
msg_CIOUT_cmdfn_SD: ; get next byte of status - SD card msg_CIOUT_cmdfn_SD: ; get next byte of status - SD card
@@ -55,17 +55,32 @@ msg_CIOUT_cmdfn_SD: ; get next byte of status - SD card
+bcs unit_sd_cmd_OPEN_EOI ; if EOI - execute command +bcs unit_sd_cmd_OPEN_EOI ; if EOI - execute command
jmp dos_EXIT_CLC jmp dos_EXIT_CLC
msg_CIOUT_cmdfn_FD: ; get next byte of status - floppy msg_CIOUT_cmdfn_F0: ; get next byte of status - floppy
ldx FD_CMDFN_IDX ldx F0_CMDFN_IDX
sta FD_CMDFN_BUF,x sta F0_CMDFN_BUF,x
inx inx
bpl @1 bpl @1
ldx #$7F ldx #$7F
@1: @1:
stx FD_CMDFN_IDX stx F0_CMDFN_IDX
lda #$A0 lda #$A0
sta FD_CMDFN_BUF,x sta F0_CMDFN_BUF,x
plp
+bcs unit_fd_cmd_OPEN_EOI ; if EOI - execute command
jmp dos_EXIT_CLC
msg_CIOUT_cmdfn_F1: ; get next byte of status - floppy
ldx F1_CMDFN_IDX
sta F1_CMDFN_BUF,x
inx
bpl @1
ldx #$7F
@1:
stx F1_CMDFN_IDX
lda #$A0
sta F1_CMDFN_BUF,x
plp plp
+bcs unit_fd_cmd_OPEN_EOI ; if EOI - execute command +bcs unit_fd_cmd_OPEN_EOI ; if EOI - execute command
jmp dos_EXIT_CLC jmp dos_EXIT_CLC
@@ -88,5 +103,6 @@ msg_CIOUT_cmdfn_RD: ; get next byte of status - ram disk
msg_CIOUT_cmdfn_vectab: msg_CIOUT_cmdfn_vectab:
!word msg_CIOUT_cmdfn_SD !word msg_CIOUT_cmdfn_SD
!word msg_CIOUT_cmdfn_FD !word msg_CIOUT_cmdfn_F0
!word msg_CIOUT_cmdfn_F1
!word msg_CIOUT_cmdfn_RD !word msg_CIOUT_cmdfn_RD
+23 -7
View File
@@ -12,28 +12,44 @@ msg_LISTEN:
and #$1F and #$1F
beq msg_LISTEN_fail ; branch if device 0 (used to denote lack of device) beq msg_LISTEN_fail ; branch if device 0 (used to denote lack of device)
@try_sd:
cmp UNIT_SDCARD cmp UNIT_SDCARD
bne @1 bne @try_f0
; LISTEN on SD card ; LISTEN on SD card
lda #$00 lda #$00
bra msg_LISTEN_success bra msg_LISTEN_success
@1:
cmp UNIT_FLOPPY
bne @2
; LISTEN on floppy @try_f0:
cmp UNIT_FLOPPY0
bne @try_f1
; LISTEN on floppy 0
lda #$01 lda #$01
bra msg_LISTEN_success bra msg_LISTEN_success
@2:
@try_f1:
cmp UNIT_FLOPPY1
bne @try_rd
; LISTEN on floppy 1
lda #$02
bra msg_LISTEN_success
@try_rd:
cmp UNIT_RAMDISK cmp UNIT_RAMDISK
bne msg_LISTEN_fail bne msg_LISTEN_fail
; LISTEN on ram disk ; LISTEN on ram disk
lda #$02 lda #$03
; FALLTROUGH ; FALLTROUGH
+23 -7
View File
@@ -12,28 +12,44 @@ msg_TALK:
and #$1F and #$1F
beq msg_TALK_fail ; branch if device 0 (used to denote lack of device) beq msg_TALK_fail ; branch if device 0 (used to denote lack of device)
@try_sd:
cmp UNIT_SDCARD cmp UNIT_SDCARD
bne @1 bne @try_f0
; TALK on SD card ; TALK on SD card
lda #$00 lda #$00
bra msg_TALK_success bra msg_TALK_success
@1:
cmp UNIT_FLOPPY
bne @2
; TALK on floppy @try_f0:
cmp UNIT_FLOPPY0
bne @try_f1
; TALK on floppy 0
lda #$01 lda #$01
bra msg_TALK_success bra msg_TALK_success
@2:
@try_f1:
cmp UNIT_FLOPPY1
bne @try_rd
; TALK on floppy 1
lda #$02
bra msg_TALK_success
@try_rd:
cmp UNIT_RAMDISK cmp UNIT_RAMDISK
bne msg_TALK_fail bne msg_TALK_fail
; TALK on ram disk ; TALK on ram disk
lda #$02 lda #$03
; FALLTROUGH ; FALLTROUGH
+7 -5
View File
@@ -3,11 +3,13 @@
; Open file for reading ; Open file for reading
; ;
; XXX add support for both floppies
unit_fd_cmd_OPEN: unit_fd_cmd_OPEN:
lda #$01 ; mode: receive command or file name lda #$01 ; mode: receive command or file name
sta FD_MODE sta F0_MODE
jmp dos_EXIT_CLC jmp dos_EXIT_CLC
@@ -26,7 +28,7 @@ unit_fd_cmd_OPEN_EOI:
; XXX add support for second floppy ; XXX add support for second floppy
lda FD_CMDFN_BUF lda F0_CMDFN_BUF
cmp #'$' cmp #'$'
beq unit_fd_cmd_OPEN_dir beq unit_fd_cmd_OPEN_dir
@@ -38,7 +40,7 @@ unit_fd_cmd_OPEN_file:
ldy #$00 ldy #$00
@lp1: @lp1:
lda FD_CMDFN_BUF, y lda F0_CMDFN_BUF, y
cmp #$A0 cmp #$A0
beq @lp1_end beq @lp1_end
sta PAR_FPATTERN, y sta PAR_FPATTERN, y
@@ -54,13 +56,13 @@ unit_fd_cmd_OPEN_file:
unit_fd_cmd_OPEN_dir: unit_fd_cmd_OPEN_dir:
lda #$02 ; mode: read directory lda #$02 ; mode: read directory
sta FD_MODE sta F0_MODE
; Copy the filter from command XXX this should be moved to common part and deduplicated with file opening ; Copy the filter from command XXX this should be moved to common part and deduplicated with file opening
ldy #$00 ldy #$00
@lp1: @lp1:
lda FD_CMDFN_BUF+1, y lda F0_CMDFN_BUF+1, y
cmp #$A0 cmp #$A0
beq @lp1_end beq @lp1_end
sta PAR_FPATTERN, y sta PAR_FPATTERN, y
+10 -2
View File
@@ -4,13 +4,21 @@
; ;
unit_f0_cmd_READ:
; XXX provide implementation
unit_f1_cmd_READ:
; XXX provide implementation
unit_fd_cmd_READ: unit_fd_cmd_READ:
lda FD_MODE lda F0_MODE
cmp #$03 cmp #$03
+beq fs_cbm_nextfileblock +beq fs_cbm_nextfileblock
lda FD_DIR_PHASE lda F0_DIR_PHASE
cmp #$01 cmp #$01
+beq fs_cbm_read_dir +beq fs_cbm_read_dir
cmp #$02 cmp #$02
+19 -8
View File
@@ -9,18 +9,29 @@ unit_fd_init:
; Copy status string ; Copy status string
ldx #$00 ldx #$00
stx FD_STATUS_IDX
stx FD_CMDFN_IDX stx F0_STATUS_IDX
stx FD_MODE stx F0_CMDFN_IDX
stx FD_ACPTR_LEN+0 stx F0_MODE
stx FD_ACPTR_LEN+1 stx F0_ACPTR_LEN+0
stx FD_ACPTR_PTR+0 stx F0_ACPTR_LEN+1
stx FD_ACPTR_PTR+1 stx F0_ACPTR_PTR+0
stx F0_ACPTR_PTR+1
stx F1_STATUS_IDX
stx F1_CMDFN_IDX
stx F1_MODE
stx F1_ACPTR_LEN+0
stx F1_ACPTR_LEN+1
stx F1_ACPTR_PTR+0
stx F1_ACPTR_PTR+1
dex dex
@1: @1:
inx inx
lda dos_sts_init_floppy,x lda dos_sts_init_floppy,x
sta FD_STATUS_BUF,x sta F0_STATUS_BUF,x
sta F1_STATUS_BUF,x
bne @1 bne @1
; Initialize the controller ; Initialize the controller
+11 -4
View File
@@ -14,18 +14,25 @@ util_status_SD:
ldx #$00 ; offset to status buffer ldx #$00 ; offset to status buffer
bra util_status_common bra util_status_common
util_status_FD: util_status_F0:
ldx #$00 ldx #$00
stx FD_STATUS_IDX ; set first byte of status to read stx F0_STATUS_IDX ; set first byte of status to read
ldx #$20 ; offset to status buffer ldx #$30 ; offset to status buffer
bra util_status_common
util_status_F1:
ldx #$00
stx F1_STATUS_IDX ; set first byte of status to read
ldx #$60 ; offset to status buffer
bra util_status_common bra util_status_common
util_status_RD: util_status_RD:
ldx #$00 ldx #$00
stx RD_STATUS_IDX ; set first byte of status to read stx RD_STATUS_IDX ; set first byte of status to read
ldx #$40 ; offset to status buffer ldx #$90 ; offset to status buffer
; FALLLTROUGH ; FALLLTROUGH
+1 -1
View File
@@ -41,7 +41,7 @@ m65dos_unitchk: ; XXX expose to BASIC
; Checks is the unit number is supported by the internal DOS ; Checks is the unit number is supported by the internal DOS
; Input: .A - unit number to check ; Input: .A - unit number to check
; Output: Carry set if not supported, otherwise .A contains unit type (0 = SD card, 1 = internal floppy, 2 = RAM disk) ; Output: Carry set if not supported, otherwise .A contains unit type (0 = SD card, 1/2 = internal/external floppy, 3 = RAM disk)
jsr map_DOS_1 jsr map_DOS_1
jsr (VDOS_UNITCHK) jsr (VDOS_UNITCHK)