From 13c675990440f170977f024fdab7635f68d3339c Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 13 Feb 2021 14:50:10 +0100 Subject: [PATCH] rework in CBDOS --- src/dos_m65/,aliases_dos.s | 30 +++-- src/dos_m65/4020.dos_vectable.s | 16 +-- src/dos_m65/dev_floppy/dev_fd_cmd_close.s | 3 +- src/dos_m65/dev_floppy/dev_fd_cmd_open.s | 3 +- src/dos_m65/dev_floppy/dev_fd_init.s | 1 + src/dos_m65/dev_ramdisk/dev_rd_cmd_close.s | 3 +- src/dos_m65/dev_ramdisk/dev_rd_cmd_open.s | 3 +- src/dos_m65/dev_ramdisk/dev_rd_init.s | 1 + src/dos_m65/dev_sdcard/dev_sd_cmd_close.s | 3 +- src/dos_m65/dev_sdcard/dev_sd_cmd_open.s | 6 +- src/dos_m65/dev_sdcard/dev_sd_init.s | 1 + src/dos_m65/dos_acptr.s | 80 ------------- src/dos_m65/dos_ciout.s | 71 ----------- src/dos_m65/dos_enter_exit.s | 54 +++++++++ src/dos_m65/dos_error.s | 9 -- src/dos_m65/dos_init.s | 9 +- src/dos_m65/dos_listen_talk.s | 110 ------------------ src/dos_m65/dos_memchk.s | 7 -- src/dos_m65/dos_second_tksa.s | 71 ----------- src/dos_m65/dos_unitchk.s | 19 +-- src/dos_m65/dos_unitnum.s | 19 +-- src/dos_m65/dos_unitset.s | 12 +- .../{dos_vectable_dev.s => dos_vectab_dev.s} | 4 +- src/dos_m65/msg_acptr.s | 86 ++++++++++++++ src/dos_m65/msg_ciout.s | 74 ++++++++++++ src/dos_m65/msg_listen.s | 54 +++++++++ src/dos_m65/msg_second.s | 49 ++++++++ src/dos_m65/msg_talk.s | 52 +++++++++ src/dos_m65/msg_tksa.s | 22 ++++ src/dos_m65/msg_unlsn_untlk.s | 25 ++++ 30 files changed, 485 insertions(+), 412 deletions(-) delete mode 100644 src/dos_m65/dos_acptr.s delete mode 100644 src/dos_m65/dos_ciout.s create mode 100644 src/dos_m65/dos_enter_exit.s delete mode 100644 src/dos_m65/dos_listen_talk.s delete mode 100644 src/dos_m65/dos_second_tksa.s rename src/dos_m65/{dos_vectable_dev.s => dos_vectab_dev.s} (80%) create mode 100644 src/dos_m65/msg_acptr.s create mode 100644 src/dos_m65/msg_ciout.s create mode 100644 src/dos_m65/msg_listen.s create mode 100644 src/dos_m65/msg_second.s create mode 100644 src/dos_m65/msg_talk.s create mode 100644 src/dos_m65/msg_tksa.s create mode 100644 src/dos_m65/msg_unlsn_untlk.s diff --git a/src/dos_m65/,aliases_dos.s b/src/dos_m65/,aliases_dos.s index 68c1d1a0..5c40c77a 100644 --- a/src/dos_m65/,aliases_dos.s +++ b/src/dos_m65/,aliases_dos.s @@ -13,20 +13,34 @@ !addr MAGICSTR = $8000 ; magic string; if not matching, DOS considered non-functional + ; Register storage + + !addr REG_A = $8005 + !addr REG_X = $8006 + !addr REG_Y = $8007 + !addr REG_Z = $8008 + + ; Reserved: $8009 - $800C + ; General DOS configuration - !addr UNIT_SDCARD = $8005 ; unit number for device, 0 = none - !addr UNIT_FLOPPY = $8006 ; as above - !addr UNIT_RAMDISK = $8007 ; as above + !addr UNIT_SDCARD = $800D ; unit number for device, 0 = none + !addr UNIT_FLOPPY = $800E ; as above + !addr UNIT_RAMDISK = $800F ; as above ; General DOS status - !addr IDX1_LISTENER = $8008 ; listener idx, >=$80 = none - !addr IDX2_LISTENER = $8009 ; listener idx * 2, >=$80 = none - for calling routines via vector table - !addr IDX1_TALKER = $800A ; talker idx, >=$80 = none - !addr IDX2_TALKER = $800B ; talker idx * 2, >=$80 = none - for calling routines via vector table + !addr IDX1_LISTENER = $8010 ; listener idx, >=$80 = none + !addr IDX2_LISTENER = $8011 ; listener idx * 2, >=$80 = none - for calling routines via vector table + !addr IDX1_TALKER = $8012 ; talker idx, >=$80 = none + !addr IDX2_TALKER = $8013 ; talker idx * 2, >=$80 = none - for calling routines via vector table - ; Free space: $800C-$8069 + ; Free space: $8014-$8063 + + !addr XX_MODE = $8064 ; current mode (0 = none, 1 = receiving command/file name) + !addr SD_MODE = $8064 ; - SD card + !addr FD_MODE = $8065 ; - floppy + !addr RD_MODE = $8066 ; - ram disk !addr XX_CHANNEL = $8067 ; current channel !addr SD_CHANNEL = $8067 ; - SD card diff --git a/src/dos_m65/4020.dos_vectable.s b/src/dos_m65/4020.dos_vectable.s index 8df00ad4..fb940b73 100644 --- a/src/dos_m65/4020.dos_vectable.s +++ b/src/dos_m65/4020.dos_vectable.s @@ -5,11 +5,11 @@ !word dos_UNITCHK !word dos_UNITSET !word dos_UNITNUM -!word dos_ACPTR -!word dos_CIOUT -!word dos_LISTEN -!word dos_SECOND -!word dos_TALK -!word dos_TKSA -!word dos_UNTLK -!word dos_UNLSN +!word msg_ACPTR +!word msg_CIOUT +!word msg_LISTEN +!word msg_SECOND +!word msg_TALK +!word msg_TKSA +!word msg_UNTLK +!word msg_UNLSN diff --git a/src/dos_m65/dev_floppy/dev_fd_cmd_close.s b/src/dos_m65/dev_floppy/dev_fd_cmd_close.s index 09a06999..cf2b6b6f 100644 --- a/src/dos_m65/dev_floppy/dev_fd_cmd_close.s +++ b/src/dos_m65/dev_floppy/dev_fd_cmd_close.s @@ -8,5 +8,4 @@ dev_fd_cmd_CLOSE: ; XXX provide implementation - sec - jmp dos_SECOND_done + jmp dos_EXIT_SEC diff --git a/src/dos_m65/dev_floppy/dev_fd_cmd_open.s b/src/dos_m65/dev_floppy/dev_fd_cmd_open.s index 462309b1..eeca8192 100644 --- a/src/dos_m65/dev_floppy/dev_fd_cmd_open.s +++ b/src/dos_m65/dev_floppy/dev_fd_cmd_open.s @@ -8,5 +8,4 @@ dev_fd_cmd_OPEN: ; XXX provide implementation - sec - jmp dos_SECOND_done + jmp dos_EXIT_SEC diff --git a/src/dos_m65/dev_floppy/dev_fd_init.s b/src/dos_m65/dev_floppy/dev_fd_init.s index 5c3a8141..fbaddd33 100644 --- a/src/dos_m65/dev_floppy/dev_fd_init.s +++ b/src/dos_m65/dev_floppy/dev_fd_init.s @@ -11,6 +11,7 @@ dev_fd_init: ldx #$00 stx FD_STATUS_IDX stx FD_CMDFN_IDX + stx FD_MODE dex @1: inx diff --git a/src/dos_m65/dev_ramdisk/dev_rd_cmd_close.s b/src/dos_m65/dev_ramdisk/dev_rd_cmd_close.s index 58be858d..87575b81 100644 --- a/src/dos_m65/dev_ramdisk/dev_rd_cmd_close.s +++ b/src/dos_m65/dev_ramdisk/dev_rd_cmd_close.s @@ -8,5 +8,4 @@ dev_rd_cmd_CLOSE: ; XXX provide implementation - sec - jmp dos_SECOND_done + jmp dos_EXIT_SEC diff --git a/src/dos_m65/dev_ramdisk/dev_rd_cmd_open.s b/src/dos_m65/dev_ramdisk/dev_rd_cmd_open.s index 64f55a31..46eceb62 100644 --- a/src/dos_m65/dev_ramdisk/dev_rd_cmd_open.s +++ b/src/dos_m65/dev_ramdisk/dev_rd_cmd_open.s @@ -8,5 +8,4 @@ dev_rd_cmd_OPEN: ; XXX provide implementation - sec - jmp dos_SECOND_done + jmp dos_EXIT_SEC diff --git a/src/dos_m65/dev_ramdisk/dev_rd_init.s b/src/dos_m65/dev_ramdisk/dev_rd_init.s index b5aad740..352cf003 100644 --- a/src/dos_m65/dev_ramdisk/dev_rd_init.s +++ b/src/dos_m65/dev_ramdisk/dev_rd_init.s @@ -11,6 +11,7 @@ dev_rd_init: ldx #$00 stx RD_STATUS_IDX stx RD_CMDFN_IDX + stx RD_MODE dex @1: inx diff --git a/src/dos_m65/dev_sdcard/dev_sd_cmd_close.s b/src/dos_m65/dev_sdcard/dev_sd_cmd_close.s index b6e75e00..af8ca747 100644 --- a/src/dos_m65/dev_sdcard/dev_sd_cmd_close.s +++ b/src/dos_m65/dev_sdcard/dev_sd_cmd_close.s @@ -8,5 +8,4 @@ dev_sd_cmd_CLOSE: ; XXX provide implementation - sec - jmp dos_SECOND_done + jmp dos_EXIT diff --git a/src/dos_m65/dev_sdcard/dev_sd_cmd_open.s b/src/dos_m65/dev_sdcard/dev_sd_cmd_open.s index 61a504c6..b104f0ba 100644 --- a/src/dos_m65/dev_sdcard/dev_sd_cmd_open.s +++ b/src/dos_m65/dev_sdcard/dev_sd_cmd_open.s @@ -6,7 +6,7 @@ dev_sd_cmd_OPEN: - ; XXX provide implementation + lda #$01 ; mode: receive command or file name + sta SD_MODE - sec - jmp dos_SECOND_done + jmp dos_EXIT diff --git a/src/dos_m65/dev_sdcard/dev_sd_init.s b/src/dos_m65/dev_sdcard/dev_sd_init.s index b12689e2..cf47aa11 100644 --- a/src/dos_m65/dev_sdcard/dev_sd_init.s +++ b/src/dos_m65/dev_sdcard/dev_sd_init.s @@ -11,6 +11,7 @@ dev_sd_init: ldx #$00 stx SD_STATUS_IDX stx SD_CMDFN_IDX + stx SD_MODE dex @1: inx diff --git a/src/dos_m65/dos_acptr.s b/src/dos_m65/dos_acptr.s deleted file mode 100644 index 35d2658c..00000000 --- a/src/dos_m65/dos_acptr.s +++ /dev/null @@ -1,80 +0,0 @@ - -; -; Implementation of ACPTR command. For detailed description see 'm65dos_bridge.s' file. -; - - -dos_ACPTR: ; does not have to preserve .X - - ldx IDX1_TALKER - bmi dos_ACPTR_fail - - lda XX_CHANNEL, X - cmp #$0F - beq dos_ACPTR_status - - ; XXX providde implementation for non-status streams - - jmp dos_ACPTR_fail - -dos_ACPTR_status: - - ldx IDX2_TALKER - jsr (dos_ACPTR_getsts_table, X) - sta TBTCNT ; byte return - beq dos_ACPTR_reset_status - - clc - rts - -dos_ACPTR_fail: - - ; XXX set error code - - sec - rts - -dos_ACPTR_reset_status: - - lda IDX1_TALKER - jsr dos_status_00 - - ; FALLTROUGH - -dos_ACPTR_eoi: - - jsr kernalstatus_EOI - - clc - rts - - - -; Sending bytes from the status string - -dos_ACPTR_getsts_SD: ; get next byte of status - SD card - - ldx SD_STATUS_IDX - inc SD_STATUS_IDX - lda SD_STATUS_STR,x - rts - -dos_ACPTR_getsts_FD: ; get next byte of status - floppy - - ldx FD_STATUS_IDX - inc FD_STATUS_IDX - lda FD_STATUS_STR,x - rts - -dos_ACPTR_getsts_RD: ; get next byte of status - ram disk - - ldx RD_STATUS_IDX - inc RD_STATUS_IDX - lda RD_STATUS_STR,x - rts - -dos_ACPTR_getsts_table: - - !word dos_ACPTR_getsts_SD - !word dos_ACPTR_getsts_FD - !word dos_ACPTR_getsts_RD diff --git a/src/dos_m65/dos_ciout.s b/src/dos_m65/dos_ciout.s deleted file mode 100644 index 7549b070..00000000 --- a/src/dos_m65/dos_ciout.s +++ /dev/null @@ -1,71 +0,0 @@ - -; -; Implementation of ACPTR command. For detailed description see 'm65dos_bridge.s' file. -; - - -dos_CIOUT: - - pha - phx - - ; XXX handle cases of transferring data - - ; Receive command/file name byte - - ldx IDX2_TALKER - jsr (dos_CIOUT_putcmdfn_table, X) - - plx - pla - - clc - rts - - - - - -; Receiving command/file name - -dos_CIOUT_putcmdfn_SD: ; get next byte of status - SD card - - ldx SD_CMDFN_IDX - sta SD_CMDFN_IDX,x - inx - bpl @1 - ldx #$7F -@1: - lda #$00 - sta SD_CMDFN_IDX,x - rts - -dos_CIOUT_putcmdfn_FD: ; get next byte of status - floppy - - ldx FD_CMDFN_IDX - sta FD_CMDFN_IDX,x - inx - bpl @1 - ldx #$7F -@1: - lda #$00 - sta FD_CMDFN_IDX,x - rts - -dos_CIOUT_putcmdfn_RD: ; get next byte of status - ram disk - - ldx RD_CMDFN_IDX - sta RD_CMDFN_IDX,x - inx - bpl @1 - ldx #$7F -@1: - lda #$00 - sta RD_CMDFN_IDX,x - rts - -dos_CIOUT_putcmdfn_table: - - !word dos_CIOUT_putcmdfn_SD - !word dos_CIOUT_putcmdfn_FD - !word dos_CIOUT_putcmdfn_RD diff --git a/src/dos_m65/dos_enter_exit.s b/src/dos_m65/dos_enter_exit.s new file mode 100644 index 00000000..12b524fe --- /dev/null +++ b/src/dos_m65/dos_enter_exit.s @@ -0,0 +1,54 @@ + +; Helper routines for entering/exiting the context + + + +dos_ENTER: ; enter DOS context + + sta REG_A + stx REG_X + sty REG_Y + stz REG_Z + + rts + + +dos_EXIT_SEC: ; exit DOS context with Carry set + + sec + bra dos_EXIT_common + +dos_EXIT: ; exit DOS context with Carry clear + + clc + + ; FALLTROUGH + +dos_EXIT_common: + + ldz REG_Z + ldy REG_Y + ldx REG_X + lda REG_A + + rts + + +dos_EXIT_A_SEC: ; exit DOS context with Carry set, return .A + + sec + bra dos_EXIT_A_common + +dos_EXIT_A: ; exit DOS context with Carry clear, return .A + + clc + + ; FALLTROUGH + +dos_EXIT_A_common: + + ldz REG_Z + ldy REG_Y + ldx REG_X + + rts diff --git a/src/dos_m65/dos_error.s b/src/dos_m65/dos_error.s index 490270c5..d8859e04 100644 --- a/src/dos_m65/dos_error.s +++ b/src/dos_m65/dos_error.s @@ -12,10 +12,6 @@ dos_status_00: ; OK - pha - phx - phy - ; Set status byte pointer to the beginning tax @@ -76,11 +72,6 @@ dos_status_00: ; OK ; End - ply - plx - pla - - clc ; mark status as OK rts diff --git a/src/dos_m65/dos_init.s b/src/dos_m65/dos_init.s index 5cad08ed..53784393 100644 --- a/src/dos_m65/dos_init.s +++ b/src/dos_m65/dos_init.s @@ -10,9 +10,10 @@ dos_INIT: + jsr dos_ENTER + ; Set the magic string 'CBDOS' - phx ldx #$04 @1: lda dos_magicstr, x @@ -20,8 +21,6 @@ dos_INIT: dex bpl @1 - plx - ; Set default device numbers lda #CONFIG_UNIT_SDCARD @@ -45,4 +44,6 @@ dos_INIT: jsr dev_fd_init jsr dev_rd_init - rts + ; Exit DOS context + + jmp dos_EXIT diff --git a/src/dos_m65/dos_listen_talk.s b/src/dos_m65/dos_listen_talk.s deleted file mode 100644 index 72dbd45d..00000000 --- a/src/dos_m65/dos_listen_talk.s +++ /dev/null @@ -1,110 +0,0 @@ - -; -; Implementation of LISTEN/UNLSN/TALK/UNTLK commands. -; For detailed description see 'm65dos_bridge.s' file. -; - - -; LISTEN - -dos_LISTEN: - - pha - and #$1F - beq dos_fail_TALK_LISTEN ; branch if device 0 (used to denote lack of device) - - cmp UNIT_SDCARD - bne @1 - - lda #$00 - bra dos_LISTEN_success -@1: - cmp UNIT_FLOPPY - bne @2 - - lda #$01 - bra dos_LISTEN_success -@2: - cmp UNIT_RAMDISK - bne dos_fail_TALK_LISTEN - - lda #$02 - - ; FALLTROUGH - -dos_LISTEN_success: - - sta IDX1_LISTENER - asl - sta IDX2_LISTENER - - ; XXX should we reset XX_CMDFN_IDX ? - - bra dos_common_LSN_TALK_UN - -; TALK - -dos_TALK: - - pha - and #$1F - beq dos_fail_TALK_LISTEN ; branch if device 0 (used to denote lack of device) - - cmp UNIT_SDCARD - bne @1 - - lda #$00 - bra dos_TALK_success -@1: - cmp UNIT_FLOPPY - bne @2 - - lda #$01 - bra dos_TALK_success -@2: - cmp UNIT_RAMDISK - bne dos_fail_TALK_LISTEN - - lda #$02 - - ; FALLTROUGH - -dos_TALK_success: - - sta IDX1_TALKER - asl - sta IDX2_TALKER - - bra dos_common_LSN_TALK_UN - -dos_fail_TALK_LISTEN: - - pla - lda #K_ERR_DEVICE_NOT_FOUND - sec - rts - -; UNLSN / UNTLK - -dos_UNLSN: - - pha - lda #$FF - sta IDX1_LISTENER - sta IDX2_LISTENER - bra dos_common_LSN_TALK_UN - -dos_UNTLK: - - pha - lda #$FF - sta IDX1_TALKER - sta IDX2_TALKER - - ; FALLTROUGH - -dos_common_LSN_TALK_UN: - - pla - clc - rts diff --git a/src/dos_m65/dos_memchk.s b/src/dos_m65/dos_memchk.s index 62eea52d..683a33a5 100644 --- a/src/dos_m65/dos_memchk.s +++ b/src/dos_m65/dos_memchk.s @@ -8,9 +8,6 @@ dos_MEMCHK: ; Check for magic string - pha - phx - ldx #$04 @1: lda MAGICSTR, x @@ -19,14 +16,10 @@ dos_MEMCHK: dex bpl @1 - plx - pla clc rts @fail: - plx - pla sec rts diff --git a/src/dos_m65/dos_second_tksa.s b/src/dos_m65/dos_second_tksa.s deleted file mode 100644 index 8b8ee56c..00000000 --- a/src/dos_m65/dos_second_tksa.s +++ /dev/null @@ -1,71 +0,0 @@ - -; -; Implementation of SECOND/TKSA commands. -; For detailed description see 'm65dos_bridge.s' file. -; - - -dos_SECOND: - - pha - phx - phy - - ; First store the channel - - tay - and #$0F ; support channels 0-15, like 1541 drive - - ldx IDX1_LISTENER - bmi dos_SECOND_done ; do nothing if no listener - sta XX_CHANNEL, x ; store channel - - ; Determine command type - - tya - and #$F0 - - cmp #$F0 - beq dos_SECOND_OPEN - cmp #$E0 - beq dos_SECOND_CLOSE - - ; XXX provide implementation - - bra dos_SECOND_done - -dos_SECOND_OPEN: - - ldx IDX2_LISTENER - jmp (dos_cmd_OPEN_vectable, x) - -dos_SECOND_CLOSE: - - ldx IDX2_LISTENER - jmp (dos_cmd_CLOSE_vectable, x) - -dos_SECOND_done: - - ply - bra dos_TKSA_done ; reuse part of TKSA code - - -dos_TKSA: - - pha - phx - - and #$0F ; support channels 0-15, like 1541 drive - - ldx IDX1_TALKER - bmi dos_TKSA_done ; do nothing if no taalker - sta XX_CHANNEL, x ; store channel - - ; FALLTROUGH - -dos_TKSA_done: - - plx - pla - clc - rts diff --git a/src/dos_m65/dos_unitchk.s b/src/dos_m65/dos_unitchk.s index ee94d898..ad5dc9a4 100644 --- a/src/dos_m65/dos_unitchk.s +++ b/src/dos_m65/dos_unitchk.s @@ -6,10 +6,12 @@ dos_UNITCHK: + jsr dos_ENTER + ; Check if memory content is not damaged jsr dos_MEMCHK - bcs dos_UNITCHK_none + bcs dos_UNITCHK_fail ; Check for unit @@ -22,10 +24,9 @@ dos_UNITCHK: ; FALLTROUGH -dos_UNITCHK_none: +dos_UNITCHK_fail: - sec - rts + jmp dos_EXIT_SEC dos_UNITCHK_sdcard: @@ -44,13 +45,5 @@ dos_UNITCHK_floppy: dos_UNITCHK_ramdisk: lda #$02 - - clc - rts -dos_UNITCHK_mem_fail: - - plx - pla - sec - rts + jmp dos_EXIT_A diff --git a/src/dos_m65/dos_unitnum.s b/src/dos_m65/dos_unitnum.s index c0bc9509..dbdc3c99 100644 --- a/src/dos_m65/dos_unitnum.s +++ b/src/dos_m65/dos_unitnum.s @@ -6,10 +6,13 @@ dos_UNITNUM: + jsr dos_ENTER + ; Check if memory content is not damaged jsr dos_MEMCHK - bcs dos_UNITNUM_none + bcs dos_UNITNUM_fail + lda REG_A ; Check what kind of device was requested @@ -22,12 +25,11 @@ dos_UNITNUM: ; FALLTROUGH -dos_UNITNUM_none: +dos_UNITNUM_fail: lda #$00 - sec - rts + jmp dos_EXIT_A_SEC dos_UNITNUM_sdcard: @@ -42,13 +44,12 @@ dos_UNITNUM_floppy: dos_UNITNUM_ramdisk: lda UNIT_RAMDISK - bra dos_UNITNUM_common + + ; FALLTROUGH dos_UNITNUM_common: cmp #$00 - beq dos_UNITNUM_none - - clc - rts + beq dos_UNITNUM_fail + jmp dos_EXIT_A diff --git a/src/dos_m65/dos_unitset.s b/src/dos_m65/dos_unitset.s index 9ef2326b..2de4eebe 100644 --- a/src/dos_m65/dos_unitset.s +++ b/src/dos_m65/dos_unitset.s @@ -6,6 +6,8 @@ dos_UNITSET: + jsr dos_ENTER + ; Check if memory content is not damaged jsr dos_MEMCHK @@ -18,14 +20,13 @@ dos_UNITSET: cmp #$00 beq dos_UNITSET_sdcard - ; XXX devioces below are not implemented yet + ; XXX devices below are not implemented yet ; cmp #$01 ; beq dos_UNITSET_floppy ; cmp #$02 ; beq dos_UNITSET_ramdisk - sec - rts + jmp dos_EXIT_SEC dos_UNITSET_sdcard: @@ -45,7 +46,4 @@ dos_UNITSET_ramdisk: stx UNIT_RAMDISK - ; FALLTROUGH - - clc - rts + jmp dos_EXIT diff --git a/src/dos_m65/dos_vectable_dev.s b/src/dos_m65/dos_vectab_dev.s similarity index 80% rename from src/dos_m65/dos_vectable_dev.s rename to src/dos_m65/dos_vectab_dev.s index 7881735f..d11f837c 100644 --- a/src/dos_m65/dos_vectable_dev.s +++ b/src/dos_m65/dos_vectab_dev.s @@ -4,14 +4,14 @@ ; -dos_cmd_OPEN_vectable: +dos_cmd_OPEN_vectab: !word dev_sd_cmd_OPEN !word dev_fd_cmd_OPEN !word dev_rd_cmd_OPEN -dos_cmd_CLOSE_vectable: +dos_cmd_CLOSE_vectab: !word dev_sd_cmd_CLOSE !word dev_fd_cmd_CLOSE diff --git a/src/dos_m65/msg_acptr.s b/src/dos_m65/msg_acptr.s new file mode 100644 index 00000000..431cea6f --- /dev/null +++ b/src/dos_m65/msg_acptr.s @@ -0,0 +1,86 @@ + +; +; Implementation of ACPTR command. For detailed description see 'm65dos_bridge.s' file. +; + + +msg_ACPTR: + + jsr dos_ENTER + + ; Check if there is a talker active + + ldx IDX1_TALKER + bmi msg_ACPTR_fail + + ; Check if active channel is status one + + lda XX_CHANNEL, X + cmp #$0F + beq msg_ACPTR_status + + ; XXX providde implementation for non-status channels + + jmp msg_ACPTR_fail + +msg_ACPTR_status: + + ldx IDX2_TALKER + jmp (msg_ACPTR_status_vectab, X) + +msg_ACPTR_status_SD: ; get next byte of status - SD card + + ldx SD_STATUS_IDX + inc SD_STATUS_IDX + lda SD_STATUS_STR,x + bra msg_ACPTR_status_got + +msg_ACPTR_status_FD: ; get next byte of status - floppy + + ldx FD_STATUS_IDX + inc FD_STATUS_IDX + lda FD_STATUS_STR,x + bra msg_ACPTR_status_got + +msg_ACPTR_status_RD: ; get next byte of status - ram disk + + ldx RD_STATUS_IDX + inc RD_STATUS_IDX + lda RD_STATUS_STR,x + + ; FALLTROUGH + +msg_ACPTR_status_got: + + sta TBTCNT ; byte return + beq msg_ACPTR_reset_status + + jmp dos_EXIT + +msg_ACPTR_fail: + + ; XXX set error code + + jmp dos_EXIT_SEC + +msg_ACPTR_reset_status: + + lda IDX1_TALKER + jsr dos_status_00 + + ; FALLTROUGH + +msg_ACPTR_eoi: + + jsr kernalstatus_EOI + jmp dos_EXIT_SEC + + + +; Vector tables for jumps + +msg_ACPTR_status_vectab: + + !word msg_ACPTR_status_SD + !word msg_ACPTR_status_FD + !word msg_ACPTR_status_RD diff --git a/src/dos_m65/msg_ciout.s b/src/dos_m65/msg_ciout.s new file mode 100644 index 00000000..e62e376d --- /dev/null +++ b/src/dos_m65/msg_ciout.s @@ -0,0 +1,74 @@ + +; +; Implementation of ACPTR command. For detailed description see 'm65dos_bridge.s' file. +; + + +msg_CIOUT: + + jsr dos_ENTER + + ; Check operation mode + + ldx IDX1_LISTENER + lda XX_MODE, x + + cmp #$01 + bne @1 + + ; Receiving command or file name + + ldx IDX2_TALKER + jmp (msg_CIOUT_cmdfn_vectab, X) +@1: + ; XXX handle cases of transferring data + + jmp dos_EXIT_SEC + + + + + +; Receiving command/file name + +msg_CIOUT_cmdfn_SD: ; get next byte of status - SD card + + ldx SD_CMDFN_IDX + sta SD_CMDFN_IDX,x + inx + bpl @1 + ldx #$7F +@1: + lda #$00 + sta SD_CMDFN_IDX,x + jmp dos_EXIT + +msg_CIOUT_cmdfn_FD: ; get next byte of status - floppy + + ldx FD_CMDFN_IDX + sta FD_CMDFN_IDX,x + inx + bpl @1 + ldx #$7F +@1: + lda #$00 + sta FD_CMDFN_IDX,x + jmp dos_EXIT + +msg_CIOUT_cmdfn_RD: ; get next byte of status - ram disk + + ldx RD_CMDFN_IDX + sta RD_CMDFN_IDX,x + inx + bpl @1 + ldx #$7F +@1: + lda #$00 + sta RD_CMDFN_IDX,x + jmp dos_EXIT + +msg_CIOUT_cmdfn_vectab: + + !word msg_CIOUT_cmdfn_SD + !word msg_CIOUT_cmdfn_FD + !word msg_CIOUT_cmdfn_RD diff --git a/src/dos_m65/msg_listen.s b/src/dos_m65/msg_listen.s new file mode 100644 index 00000000..ee0e2d79 --- /dev/null +++ b/src/dos_m65/msg_listen.s @@ -0,0 +1,54 @@ + +; +; Implementation of LISTEN commands. +; For detailed description see 'm65dos_bridge.s' file. +; + + +msg_LISTEN: + + jsr dos_ENTER + + and #$1F + beq msg_LISTEN_fail ; branch if device 0 (used to denote lack of device) + + cmp UNIT_SDCARD + bne @1 + + ; LISTEN on SD card + + lda #$00 + bra msg_LISTEN_success +@1: + cmp UNIT_FLOPPY + bne @2 + + ; LISTEN on floppy + + lda #$01 + bra msg_LISTEN_success +@2: + cmp UNIT_RAMDISK + bne msg_LISTEN_fail + + ; LISTEN on ram disk + + lda #$02 + + ; FALLTROUGH + +msg_LISTEN_success: + + sta IDX1_LISTENER + asl + sta IDX2_LISTENER + + ; XXX should we reset XX_CMDFN_IDX ? + + jmp dos_EXIT + +msg_LISTEN_fail: + + lda #K_ERR_DEVICE_NOT_FOUND + + jmp dos_EXIT_A_SEC diff --git a/src/dos_m65/msg_second.s b/src/dos_m65/msg_second.s new file mode 100644 index 00000000..febd686e --- /dev/null +++ b/src/dos_m65/msg_second.s @@ -0,0 +1,49 @@ + +; +; Implementation of SECOND command. +; For detailed description see 'm65dos_bridge.s' file. +; + + +msg_SECOND: + + jsr dos_ENTER + + ; First store the channel + + tay + and #$0F ; support channels 0-15, like 1541 drive + + ldx IDX1_LISTENER + bmi msg_SECOND_done ; do nothing if no listener + sta XX_CHANNEL, x ; store channel + + ; Determine command type + + tya + and #$F0 + + cmp #$F0 + beq msg_SECOND_OPEN + cmp #$E0 + beq msg_SECOND_CLOSE + + ; XXX provide implementation + + ; FALLTROUGH + +msg_SECOND_done: + + jmp dos_EXIT + +msg_SECOND_OPEN: + + lda #$00 + sta XX_CMDFN_IDX, x ; reset the index to the command/filename + ldx IDX2_LISTENER + jmp (dos_cmd_OPEN_vectab, x) + +msg_SECOND_CLOSE: + + ldx IDX2_LISTENER + jmp (dos_cmd_CLOSE_vectab, x) diff --git a/src/dos_m65/msg_talk.s b/src/dos_m65/msg_talk.s new file mode 100644 index 00000000..24381ecb --- /dev/null +++ b/src/dos_m65/msg_talk.s @@ -0,0 +1,52 @@ + +; +; Implementation of TALK commands. +; For detailed description see 'm65dos_bridge.s' file. +; + + +msg_TALK: + + jsr dos_ENTER + + and #$1F + beq msg_TALK_fail ; branch if device 0 (used to denote lack of device) + + cmp UNIT_SDCARD + bne @1 + + ; TALK on SD card + + lda #$00 + bra msg_TALK_success +@1: + cmp UNIT_FLOPPY + bne @2 + + ; TALK on floppy + + lda #$01 + bra msg_TALK_success +@2: + cmp UNIT_RAMDISK + bne msg_TALK_fail + + ; TALK on ram disk + + lda #$02 + + ; FALLTROUGH + +msg_TALK_success: + + sta IDX1_TALKER + asl + sta IDX2_TALKER + + jmp dos_EXIT + +msg_TALK_fail: + + lda #K_ERR_DEVICE_NOT_FOUND + + jmp dos_EXIT_A_SEC diff --git a/src/dos_m65/msg_tksa.s b/src/dos_m65/msg_tksa.s new file mode 100644 index 00000000..9df0a4ca --- /dev/null +++ b/src/dos_m65/msg_tksa.s @@ -0,0 +1,22 @@ + +; +; Implementation of TKSA commands. +; For detailed description see 'm65dos_bridge.s' file. +; + + +msg_TKSA: + + jsr dos_ENTER + + and #$0F ; support channels 0-15, like 1541 drive + + ldx IDX1_TALKER + bmi msg_TKSA_done ; do nothing if no taalker + sta XX_CHANNEL, x ; store channel + + ; FALLTROUGH + +msg_TKSA_done: + + jmp dos_EXIT diff --git a/src/dos_m65/msg_unlsn_untlk.s b/src/dos_m65/msg_unlsn_untlk.s new file mode 100644 index 00000000..a61a7993 --- /dev/null +++ b/src/dos_m65/msg_unlsn_untlk.s @@ -0,0 +1,25 @@ + +; +; Implementation of UNLSN/UNTLK messages. +; For detailed description see 'm65dos_bridge.s' file. +; + + +msg_UNLSN: + + jsr dos_ENTER + + lda #$FF + sta IDX1_LISTENER + sta IDX2_LISTENER + + jmp dos_EXIT + +msg_UNTLK: + + jsr dos_ENTER + + sta IDX1_TALKER + sta IDX2_TALKER + + jmp dos_EXIT