some work towards I/O stack modularization
This commit is contained in:
1 parent
966658eae0
commit
6fa2c5b570
56 files changed
+357
-69
No files matched your search
@@ -38,6 +38,13 @@
|
|||||||
// #define CONFIG_MEMORY_MODEL_60K
|
// #define CONFIG_MEMORY_MODEL_60K
|
||||||
|
|
||||||
|
|
||||||
|
// I/O devices
|
||||||
|
|
||||||
|
#define CONFIG_IEC // please keep enabled for now
|
||||||
|
// #define CONFIG_TAPE // please keep disabled for now
|
||||||
|
// #define CONFIG_RS_232 // please keep disabled for now
|
||||||
|
|
||||||
|
|
||||||
// Multiple SID support
|
// Multiple SID support
|
||||||
|
|
||||||
// #define CONFIG_SID_2ND
|
// #define CONFIG_SID_2ND
|
||||||
|
|||||||
@@ -40,6 +40,13 @@
|
|||||||
// #define CONFIG_MEMORY_MODEL_60K
|
// #define CONFIG_MEMORY_MODEL_60K
|
||||||
|
|
||||||
|
|
||||||
|
// I/O devices
|
||||||
|
|
||||||
|
#define CONFIG_IEC // please keep enabled for now
|
||||||
|
// #define CONFIG_TAPE // please keep disabled for now
|
||||||
|
// #define CONFIG_RS_232 // please keep disabled for now
|
||||||
|
|
||||||
|
|
||||||
// Multiple SID support
|
// Multiple SID support
|
||||||
|
|
||||||
#define CONFIG_SID_2ND
|
#define CONFIG_SID_2ND
|
||||||
|
|||||||
@@ -39,6 +39,13 @@
|
|||||||
#define CONFIG_MEMORY_MODEL_60K
|
#define CONFIG_MEMORY_MODEL_60K
|
||||||
|
|
||||||
|
|
||||||
|
// I/O devices
|
||||||
|
|
||||||
|
#define CONFIG_IEC // please keep enabled for now
|
||||||
|
// #define CONFIG_TAPE // please keep disabled for now
|
||||||
|
// #define CONFIG_RS_232 // please keep disabled for now
|
||||||
|
|
||||||
|
|
||||||
// Multiple SID support
|
// Multiple SID support
|
||||||
|
|
||||||
#define CONFIG_SID_2ND
|
#define CONFIG_SID_2ND
|
||||||
|
|||||||
@@ -38,6 +38,13 @@
|
|||||||
// #define CONFIG_MEMORY_MODEL_60K
|
// #define CONFIG_MEMORY_MODEL_60K
|
||||||
|
|
||||||
|
|
||||||
|
// I/O devices
|
||||||
|
|
||||||
|
#define CONFIG_IEC // please keep enabled for now
|
||||||
|
// #define CONFIG_TAPE // please keep disabled for now
|
||||||
|
// #define CONFIG_RS_232 // please keep disabled for now
|
||||||
|
|
||||||
|
|
||||||
// Multiple SID support
|
// Multiple SID support
|
||||||
|
|
||||||
// #define CONFIG_SID_2ND
|
// #define CONFIG_SID_2ND
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ chkin_real:
|
|||||||
cmp #$01
|
cmp #$01
|
||||||
beq chkinout_file_not_input
|
beq chkinout_file_not_input
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
// For IEC devices, send TALK + TKSA first
|
// For IEC devices, send TALK + TKSA first
|
||||||
lda FAT,Y
|
lda FAT,Y
|
||||||
jsr iec_check_devnum_oc
|
jsr iec_check_devnum_oc
|
||||||
@@ -51,6 +53,8 @@ chkin_real:
|
|||||||
jsr TKSA
|
jsr TKSA
|
||||||
bcs chkinout_device_not_present
|
bcs chkinout_device_not_present
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
|
|
||||||
chkin_set_device:
|
chkin_set_device:
|
||||||
lda FAT,Y
|
lda FAT,Y
|
||||||
sta DFLTN
|
sta DFLTN
|
||||||
@@ -121,6 +125,8 @@ ckout_real:
|
|||||||
lda LAT, Y
|
lda LAT, Y
|
||||||
beq chkinout_file_not_output
|
beq chkinout_file_not_output
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
// For IEC devices, send LISTEN + SECOND first
|
// For IEC devices, send LISTEN + SECOND first
|
||||||
lda FAT,Y
|
lda FAT,Y
|
||||||
jsr iec_check_devnum_oc
|
jsr iec_check_devnum_oc
|
||||||
@@ -133,6 +139,8 @@ ckout_real:
|
|||||||
jsr SECOND
|
jsr SECOND
|
||||||
bcs chkinout_device_not_present
|
bcs chkinout_device_not_present
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
|
|
||||||
chkout_set_device:
|
chkout_set_device:
|
||||||
lda FAT,Y
|
lda FAT,Y
|
||||||
sta DFLTO
|
sta DFLTO
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ chrin_real:
|
|||||||
beq chrin_keyboard // #$00 - keyboard
|
beq chrin_keyboard // #$00 - keyboard
|
||||||
// XXX add screen support
|
// XXX add screen support
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
jsr iec_check_devnum_oc
|
jsr iec_check_devnum_oc
|
||||||
bcc chrin_iec
|
bcc chrin_iec
|
||||||
jmp lvs_device_not_found_error // not a supported device
|
jmp lvs_device_not_found_error // not a supported device
|
||||||
@@ -33,6 +35,8 @@ chrin_iec:
|
|||||||
bcs chrin_done_fail
|
bcs chrin_done_fail
|
||||||
// FALLTROUGH
|
// FALLTROUGH
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
|
|
||||||
chrin_done:
|
chrin_done:
|
||||||
clc // indicate success
|
clc // indicate success
|
||||||
rts
|
rts
|
||||||
|
|||||||
@@ -10,5 +10,11 @@
|
|||||||
|
|
||||||
|
|
||||||
ACPTR:
|
ACPTR:
|
||||||
|
|
||||||
jsr kernalstatus_reset
|
jsr kernalstatus_reset
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
jmp iec_rx_byte
|
jmp iec_rx_byte
|
||||||
|
#else
|
||||||
|
jmp kernalerror_ILLEGAL_DEVICE_NUMBER
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
|
||||||
|
//
|
||||||
|
// IEC part of the CLOSE routine
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
|
// .Y contains LAT/FAT/SAT table index, it should stay this way
|
||||||
|
|
||||||
|
close_iec:
|
||||||
|
|
||||||
|
jsr iec_tx_flush // make sure no byte is awaiting
|
||||||
|
lda SAT, y // get secondary address
|
||||||
|
cmp #$60
|
||||||
|
bne !+
|
||||||
|
|
||||||
|
// workaround for using CLOSE on reading executable - XXX is this a proper way?
|
||||||
|
jsr iec_close_load
|
||||||
|
jmp close_remove_from_table
|
||||||
|
|
||||||
|
!:
|
||||||
|
ora $E0 // CLOSE command
|
||||||
|
sta TBTCNT
|
||||||
|
jsr iec_tx_command
|
||||||
|
bcs close_iec_end
|
||||||
|
jsr iec_tx_command_finalize
|
||||||
|
|
||||||
|
close_iec_end:
|
||||||
|
|
||||||
|
jmp close_remove_from_table
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -6,26 +6,28 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
iec_check_devnum_lvs: // for load/verify/save
|
iec_check_devnum_lvs: // for load/verify/save
|
||||||
|
|
||||||
cmp #$08 // below 8 are illegal for load/save
|
cmp #$08 // below 8 are illegal for load/save
|
||||||
bcs !+
|
bcc iec_check_devnum_failed
|
||||||
|
|
||||||
// FALLTROUGH
|
// FALLTROUGH
|
||||||
|
|
||||||
iec_check_devnum_oc: // for open/close
|
iec_check_devnum_oc: // for open/close
|
||||||
|
|
||||||
cmp #$04 // below 4 are illegal, reserved for non-IEC devices on Commodore
|
cmp #$04 // below 4 are illegal, reserved for non-IEC devices on Commodore
|
||||||
bcs !+
|
bcc iec_check_devnum_failed
|
||||||
|
|
||||||
// FALLTROUGH
|
|
||||||
|
|
||||||
iec_check_devnum_failed:
|
|
||||||
sec // indicate non-IEC device
|
|
||||||
rts
|
|
||||||
|
|
||||||
!:
|
|
||||||
// 31 and above are illegal too, due to IEC command encoding scheme,
|
// 31 and above are illegal too, due to IEC command encoding scheme,
|
||||||
// see https://www.pagetable.com/?p=1031
|
// see https://www.pagetable.com/?p=1031
|
||||||
cmp #$1F // sets carry for 31 or above
|
cmp #$1F // sets carry for 31 or above
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
iec_check_devnum_failed:
|
||||||
|
|
||||||
|
sec // indicate non-IEC device
|
||||||
|
rts
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
|
|
||||||
|
//
|
||||||
|
// Common part of CLOSE and LOAD routines for IEC
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
// Common ppart of CLOSE and LOAD routines
|
#if CONFIG_IEC
|
||||||
|
|
||||||
close_load:
|
iec_close_load:
|
||||||
|
|
||||||
tax
|
tax
|
||||||
|
|
||||||
@@ -21,3 +25,5 @@ close_load:
|
|||||||
jsr UNLSN
|
jsr UNLSN
|
||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -5,6 +5,10 @@
|
|||||||
// - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc
|
// - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_cmd_close:
|
iec_cmd_close:
|
||||||
|
|
||||||
jsr iec_check_channel_openclose
|
jsr iec_check_channel_openclose
|
||||||
@@ -14,3 +18,6 @@ iec_cmd_close:
|
|||||||
ora #$E0
|
ora #$E0
|
||||||
|
|
||||||
jmp common_open_close_unlsn_second
|
jmp common_open_close_unlsn_second
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -6,6 +6,9 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_cmd_open: // similar to TKSA, but without turnaround
|
iec_cmd_open: // similar to TKSA, but without turnaround
|
||||||
|
|
||||||
jsr iec_check_channel_openclose
|
jsr iec_check_channel_openclose
|
||||||
@@ -40,3 +43,6 @@ iec_check_channel_openclose:
|
|||||||
!:
|
!:
|
||||||
clc // mark suitable channel number
|
clc // mark suitable channel number
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_pull_atn_clk_release_data:
|
iec_pull_atn_clk_release_data:
|
||||||
|
|
||||||
// Pulled CLK = DATA considered invalid; for extra robustness on non-emulated
|
// Pulled CLK = DATA considered invalid; for extra robustness on non-emulated
|
||||||
@@ -13,3 +17,6 @@ iec_pull_atn_clk_release_data:
|
|||||||
and #$FF - BIT_CIA2_PRA_DAT_OUT // release
|
and #$FF - BIT_CIA2_PRA_DAT_OUT // release
|
||||||
sta CIA2_PRA
|
sta CIA2_PRA
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_pull_clk_release_data:
|
iec_pull_clk_release_data:
|
||||||
|
|
||||||
// Pulled CLK = DATA considered invalid; for extra robustness on non-emulated
|
// Pulled CLK = DATA considered invalid; for extra robustness on non-emulated
|
||||||
@@ -11,3 +15,5 @@ iec_pull_clk_release_data:
|
|||||||
and #$FF - BIT_CIA2_PRA_DAT_OUT // release
|
and #$FF - BIT_CIA2_PRA_DAT_OUT // release
|
||||||
sta CIA2_PRA
|
sta CIA2_PRA
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_pull_clk_release_data_oneshot:
|
iec_pull_clk_release_data_oneshot:
|
||||||
|
|
||||||
lda CIA2_PRA
|
lda CIA2_PRA
|
||||||
@@ -6,3 +10,6 @@ iec_pull_clk_release_data_oneshot:
|
|||||||
and #$FF - BIT_CIA2_PRA_DAT_OUT // release
|
and #$FF - BIT_CIA2_PRA_DAT_OUT // release
|
||||||
sta CIA2_PRA
|
sta CIA2_PRA
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_pull_data_release_atn_clk:
|
iec_pull_data_release_atn_clk:
|
||||||
|
|
||||||
// Released CLK = DATA considered valid; for extra robustness on non-emulated
|
// Released CLK = DATA considered valid; for extra robustness on non-emulated
|
||||||
@@ -13,3 +17,6 @@ iec_pull_data_release_atn_clk:
|
|||||||
and #$FF - BIT_CIA2_PRA_ATN_OUT // release
|
and #$FF - BIT_CIA2_PRA_ATN_OUT // release
|
||||||
sta CIA2_PRA
|
sta CIA2_PRA
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_release_atn:
|
iec_release_atn:
|
||||||
|
|
||||||
lda CIA2_PRA
|
lda CIA2_PRA
|
||||||
@@ -6,3 +10,5 @@ iec_release_atn:
|
|||||||
sta CIA2_PRA
|
sta CIA2_PRA
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_release_atn_clk_data:
|
iec_release_atn_clk_data:
|
||||||
|
|
||||||
// Released CLK = DATA considered valid; for extra robustness on non-emulated
|
// Released CLK = DATA considered valid; for extra robustness on non-emulated
|
||||||
@@ -14,3 +18,5 @@ iec_release_atn_clk_data:
|
|||||||
sta CIA2_PRA
|
sta CIA2_PRA
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_release_clk_data:
|
iec_release_clk_data:
|
||||||
|
|
||||||
// Released CLK = DATA considered valid; for extra robustness on non-emulated
|
// Released CLK = DATA considered valid; for extra robustness on non-emulated
|
||||||
@@ -11,3 +15,6 @@ iec_release_clk_data:
|
|||||||
and #$FF - BIT_CIA2_PRA_CLK_OUT // release
|
and #$FF - BIT_CIA2_PRA_CLK_OUT // release
|
||||||
sta CIA2_PRA
|
sta CIA2_PRA
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_release_clk_pull_data:
|
iec_release_clk_pull_data:
|
||||||
|
|
||||||
// Released CLK = DATA considered valid; for extra robustness on non-emulated
|
// Released CLK = DATA considered valid; for extra robustness on non-emulated
|
||||||
@@ -11,3 +15,6 @@ iec_release_clk_pull_data:
|
|||||||
and #$FF - BIT_CIA2_PRA_CLK_OUT // release
|
and #$FF - BIT_CIA2_PRA_CLK_OUT // release
|
||||||
sta CIA2_PRA
|
sta CIA2_PRA
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -8,6 +8,10 @@
|
|||||||
// take care about .A and IOSTATUS
|
// take care about .A and IOSTATUS
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_return_success:
|
iec_return_success:
|
||||||
|
|
||||||
// BSOUR is certainly not valid anymore
|
// BSOUR is certainly not valid anymore
|
||||||
@@ -32,3 +36,6 @@ iec_return_DEVICE_NOT_FOUND:
|
|||||||
plx_trash_a
|
plx_trash_a
|
||||||
// Report error
|
// Report error
|
||||||
jmp kernalerror_DEVICE_NOT_FOUND
|
jmp kernalerror_DEVICE_NOT_FOUND
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -4,6 +4,10 @@
|
|||||||
//
|
//
|
||||||
// Preserves .X and .Y registers
|
// Preserves .X and .Y registers
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_rx_byte:
|
iec_rx_byte:
|
||||||
|
|
||||||
// Store .X and .Y on the stack - preserve them
|
// Store .X and .Y on the stack - preserve them
|
||||||
@@ -143,3 +147,5 @@ iec_rx_clk_wait2:
|
|||||||
cli
|
cli
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -1,7 +1,14 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_set_idle:
|
iec_set_idle:
|
||||||
lda CIA2_PRA
|
lda CIA2_PRA
|
||||||
ora #BIT_CIA2_PRA_CLK_OUT // pull
|
ora #BIT_CIA2_PRA_CLK_OUT // pull
|
||||||
and #$FF - BIT_CIA2_PRA_DAT_OUT - BIT_CIA2_PRA_ATN_OUT // release
|
and #$FF - BIT_CIA2_PRA_DAT_OUT - BIT_CIA2_PRA_ATN_OUT // release
|
||||||
sta CIA2_PRA
|
sta CIA2_PRA
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -2,6 +2,10 @@
|
|||||||
// pages 7--8.
|
// pages 7--8.
|
||||||
// See also https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc
|
// See also https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_turnaround_to_listen:
|
iec_turnaround_to_listen:
|
||||||
|
|
||||||
// Store .X and .Y on the stack - preserve them
|
// Store .X and .Y on the stack - preserve them
|
||||||
@@ -34,3 +38,4 @@ iec_turnaround_to_listen:
|
|||||||
jmp iec_return_success
|
jmp iec_return_success
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -2,6 +2,10 @@
|
|||||||
// pages 7--8.
|
// pages 7--8.
|
||||||
// See also https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc
|
// See also https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_turnaround_to_talk:
|
iec_turnaround_to_talk:
|
||||||
|
|
||||||
// Store .X and .Y on the stack - preserve them
|
// Store .X and .Y on the stack - preserve them
|
||||||
@@ -25,3 +29,5 @@ iec_turnaround_to_talk:
|
|||||||
plp
|
plp
|
||||||
jmp iec_return_success
|
jmp iec_return_success
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -7,6 +7,8 @@
|
|||||||
// Preserves .X and .Y registers
|
// Preserves .X and .Y registers
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
iec_tx_byte:
|
iec_tx_byte:
|
||||||
|
|
||||||
// Store .X and .Y on the stack - preserve them
|
// Store .X and .Y on the stack - preserve them
|
||||||
@@ -94,3 +96,6 @@ iec_tx_common_bit_is_sent:
|
|||||||
jmp iec_return_DEVICE_NOT_FOUND
|
jmp iec_return_DEVICE_NOT_FOUND
|
||||||
!:
|
!:
|
||||||
jmp iec_return_success
|
jmp iec_return_success
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -7,6 +7,9 @@
|
|||||||
// Preserves .X and .Y registers
|
// Preserves .X and .Y registers
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_tx_command:
|
iec_tx_command:
|
||||||
|
|
||||||
// Store .X and .Y on the stack - preserve them
|
// Store .X and .Y on the stack - preserve them
|
||||||
@@ -36,3 +39,5 @@ iec_tx_command:
|
|||||||
clc // Carry flag set is used for EOI mark
|
clc // Carry flag set is used for EOI mark
|
||||||
jmp iec_tx_common
|
jmp iec_tx_common
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -3,6 +3,9 @@
|
|||||||
// Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc
|
// Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_tx_command_finalize:
|
iec_tx_command_finalize:
|
||||||
|
|
||||||
// Store .X and .Y on the stack - preserve them
|
// Store .X and .Y on the stack - preserve them
|
||||||
@@ -16,3 +19,6 @@ iec_tx_command_finalize:
|
|||||||
jsr iec_wait20us
|
jsr iec_wait20us
|
||||||
|
|
||||||
jmp iec_return_success
|
jmp iec_return_success
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -3,6 +3,10 @@
|
|||||||
//
|
//
|
||||||
// Preserves .X, .Y and .A registers
|
// Preserves .X, .Y and .A registers
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_tx_flush:
|
iec_tx_flush:
|
||||||
|
|
||||||
pha
|
pha
|
||||||
@@ -13,3 +17,6 @@ iec_tx_flush:
|
|||||||
!:
|
!:
|
||||||
pla
|
pla
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -8,6 +8,9 @@
|
|||||||
// 63 cycles, we need at least 17 full rasters to be 100% sure we wait enough
|
// 63 cycles, we need at least 17 full rasters to be 100% sure we wait enough
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_wait1ms:
|
iec_wait1ms:
|
||||||
ldx #18 // we probably won't start with the beginning of raster
|
ldx #18 // we probably won't start with the beginning of raster
|
||||||
lda VIC_RASTER
|
lda VIC_RASTER
|
||||||
@@ -19,3 +22,6 @@ iec_wait1ms:
|
|||||||
bne !-
|
bne !-
|
||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_wait20us:
|
iec_wait20us:
|
||||||
|
|
||||||
// Wait 20usec
|
// Wait 20usec
|
||||||
@@ -20,3 +24,5 @@ iec_wait20us:
|
|||||||
// 1 cycle to fetch next instruction
|
// 1 cycle to fetch next instruction
|
||||||
// ---
|
// ---
|
||||||
// 21 cycles
|
// 21 cycles
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_wait60us:
|
iec_wait60us:
|
||||||
|
|
||||||
// Wait 60usec
|
// Wait 60usec
|
||||||
@@ -21,3 +25,5 @@ iec_wait60us:
|
|||||||
// ---
|
// ---
|
||||||
// 64 cycles
|
// 64 cycles
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -1,7 +1,14 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_wait_for_clk_release:
|
iec_wait_for_clk_release:
|
||||||
|
|
||||||
lda CIA2_PRA
|
lda CIA2_PRA
|
||||||
and #BIT_CIA2_PRA_CLK_IN
|
and #BIT_CIA2_PRA_CLK_IN
|
||||||
beq iec_wait_for_clk_release
|
beq iec_wait_for_clk_release
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_wait_for_data_pull:
|
iec_wait_for_data_pull:
|
||||||
|
|
||||||
lda CIA2_PRA
|
lda CIA2_PRA
|
||||||
@@ -6,3 +10,6 @@ iec_wait_for_data_pull:
|
|||||||
// (highest bit set = negative value)
|
// (highest bit set = negative value)
|
||||||
bmi iec_wait_for_data_pull
|
bmi iec_wait_for_data_pull
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
iec_wait_for_data_release:
|
iec_wait_for_data_release:
|
||||||
|
|
||||||
lda CIA2_PRA
|
lda CIA2_PRA
|
||||||
@@ -6,3 +10,5 @@ iec_wait_for_data_release:
|
|||||||
// (highest bit set = negative value)
|
// (highest bit set = negative value)
|
||||||
bpl iec_wait_for_data_release
|
bpl iec_wait_for_data_release
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
LISTEN:
|
LISTEN:
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
// According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
// According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||||
jsr iec_tx_flush
|
jsr iec_tx_flush
|
||||||
|
|
||||||
@@ -25,3 +27,9 @@ LISTEN:
|
|||||||
ora #$20
|
ora #$20
|
||||||
|
|
||||||
jmp common_talk_listen
|
jmp common_talk_listen
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
jmp kernalerror_ILLEGAL_DEVICE_NUMBER
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -4,6 +4,9 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
load_iec_dev_not_found:
|
load_iec_dev_not_found:
|
||||||
jmp lvs_device_not_found_error
|
jmp lvs_device_not_found_error
|
||||||
|
|
||||||
@@ -94,7 +97,10 @@ iec_load_loop:
|
|||||||
// Close file on drive
|
// Close file on drive
|
||||||
|
|
||||||
lda FA
|
lda FA
|
||||||
jsr close_load
|
jsr iec_close_load
|
||||||
|
|
||||||
// Return last address
|
// Return last address
|
||||||
jmp lvs_return_last_address
|
jmp lvs_return_last_address
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
|
||||||
|
//
|
||||||
|
// IEC part of the OPEN routine
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
|
||||||
|
open_iec:
|
||||||
|
|
||||||
|
// We have a command to send to IEC device
|
||||||
|
jsr LISTEN
|
||||||
|
bcc !+
|
||||||
|
jmp kernalerror_DEVICE_NOT_FOUND
|
||||||
|
!:
|
||||||
|
lda SA
|
||||||
|
jsr iec_cmd_open
|
||||||
|
bcc !+
|
||||||
|
jmp kernalerror_DEVICE_NOT_FOUND
|
||||||
|
!:
|
||||||
|
|
||||||
|
#if CONFIG_MEMORY_MODEL_60K
|
||||||
|
// We need our helpers to get to filenames under ROMs or IO area
|
||||||
|
jsr install_ram_routines
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Send command ('file name')
|
||||||
|
jsr lvs_send_file_name
|
||||||
|
|
||||||
|
jmp open_done_success
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_IEC
|
||||||
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
SECOND:
|
SECOND:
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
// Due to OPEN/CLOSE/TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031),
|
// Due to OPEN/CLOSE/TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031),
|
||||||
// allowed channels are 0-15; report error if out of range
|
// allowed channels are 0-15; report error if out of range
|
||||||
cmp #$10
|
cmp #$10
|
||||||
@@ -22,4 +24,8 @@ SECOND:
|
|||||||
|
|
||||||
jmp common_open_close_unlsn_second
|
jmp common_open_close_unlsn_second
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
jmp kernalerror_ILLEGAL_DEVICE_NUMBER
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
TALK:
|
TALK:
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
// According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
// According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||||
jsr iec_tx_flush
|
jsr iec_tx_flush
|
||||||
|
|
||||||
@@ -28,3 +30,9 @@ common_talk_listen: // common part of TALK and LISTEN
|
|||||||
|
|
||||||
sta TBTCNT
|
sta TBTCNT
|
||||||
jmp iec_tx_command
|
jmp iec_tx_command
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
jmp kernalerror_ILLEGAL_DEVICE_NUMBER
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
TKSA:
|
TKSA:
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
// Due to OPEN/CLOSE/TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031),
|
// Due to OPEN/CLOSE/TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031),
|
||||||
// allowed channels are 0-15; report error if out of range
|
// allowed channels are 0-15; report error if out of range
|
||||||
cmp #$10
|
cmp #$10
|
||||||
@@ -22,5 +24,8 @@ TKSA:
|
|||||||
|
|
||||||
jmp common_untlk_tksa
|
jmp common_untlk_tksa
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
jmp kernalerror_ILLEGAL_DEVICE_NUMBER
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
UNLSN:
|
UNLSN:
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
// According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
// According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||||
jsr iec_tx_flush
|
jsr iec_tx_flush
|
||||||
|
|
||||||
@@ -21,5 +23,8 @@ UNLSN:
|
|||||||
|
|
||||||
jmp common_open_close_unlsn_second
|
jmp common_open_close_unlsn_second
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
jmp kernalerror_ILLEGAL_DEVICE_NUMBER
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
UNTLK:
|
UNTLK:
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
// According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
// According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||||
jsr iec_tx_flush
|
jsr iec_tx_flush
|
||||||
|
|
||||||
@@ -31,3 +33,9 @@ common_untlk_tksa: // common part of UNTLK and TKSA
|
|||||||
jmp iec_turnaround_to_listen
|
jmp iec_turnaround_to_listen
|
||||||
!:
|
!:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
jmp kernalerror_ILLEGAL_DEVICE_NUMBER
|
||||||
|
|
||||||
|
#endif
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -16,30 +16,21 @@ CLOSE:
|
|||||||
// Find the LAT / SAT / FAT entry which LAT corresponds to A
|
// Find the LAT / SAT / FAT entry which LAT corresponds to A
|
||||||
|
|
||||||
jsr find_fls
|
jsr find_fls
|
||||||
bcs close_error_not_found // XXX can we report error in IOSTATUS here?
|
bcs close_end // XXX can we report error in IOSTATUS here?
|
||||||
|
|
||||||
// We have the entry index in Y - check whether this is IEC device
|
#if CONFIG_IEC
|
||||||
|
|
||||||
|
// We have the entry index in .Y - check whether this is IEC device
|
||||||
lda FAT, y
|
lda FAT, y
|
||||||
jsr iec_check_devnum_oc
|
jsr iec_check_devnum_oc
|
||||||
bcs close_remove_from_table
|
bcc_far close_iec
|
||||||
|
|
||||||
// IEC device
|
#endif // CONFIG_IEC
|
||||||
|
|
||||||
jsr iec_tx_flush // make sure no byte is awaiting
|
// FALLTROUGH
|
||||||
lda SAT, y // get secondary address
|
|
||||||
cmp #$60
|
|
||||||
bne !+
|
|
||||||
// workaround for using CLOSE on reading executable - XXX is this a proper way?
|
|
||||||
jsr close_load
|
|
||||||
jmp close_remove_from_table
|
|
||||||
!:
|
|
||||||
ora $E0 // CLOSE command
|
|
||||||
sta TBTCNT
|
|
||||||
jsr iec_tx_command
|
|
||||||
bcs close_remove_from_table
|
|
||||||
jsr iec_tx_command_finalize
|
|
||||||
|
|
||||||
close_remove_from_table:
|
close_remove_from_table:
|
||||||
|
|
||||||
// Remove channel from the table
|
// Remove channel from the table
|
||||||
iny
|
iny
|
||||||
cpy #$0A
|
cpy #$0A
|
||||||
@@ -56,9 +47,6 @@ close_remove_from_table:
|
|||||||
dec LDTND
|
dec LDTND
|
||||||
|
|
||||||
clc // report success - not sure if original CLOSE does this, but it's nevertheless a good practice
|
clc // report success - not sure if original CLOSE does this, but it's nevertheless a good practice
|
||||||
rts
|
|
||||||
|
|
||||||
close_error_not_found:
|
close_end:
|
||||||
|
|
||||||
sec // report success - not sure if original CLOSE does this, but it's nevertheless a good practice
|
|
||||||
rts
|
rts
|
||||||
File renamed without changes.
File renamed without changes.
@@ -23,6 +23,7 @@ OPEN:
|
|||||||
cmp LA
|
cmp LA
|
||||||
bne open_not_yet_open
|
bne open_not_yet_open
|
||||||
jmp kernalerror_FILE_ALREADY_OPEN
|
jmp kernalerror_FILE_ALREADY_OPEN
|
||||||
|
|
||||||
open_not_yet_open:
|
open_not_yet_open:
|
||||||
cpy #$00
|
cpy #$00
|
||||||
jmp !-
|
jmp !-
|
||||||
@@ -60,33 +61,11 @@ open_has_space:
|
|||||||
// Check for IEC device
|
// Check for IEC device
|
||||||
lda FA
|
lda FA
|
||||||
jsr iec_check_devnum_oc
|
jsr iec_check_devnum_oc
|
||||||
bcc open_iec
|
bcc_far open_iec
|
||||||
|
|
||||||
// FALLTROUGH
|
// FALLTROUGH
|
||||||
|
|
||||||
open_done_success:
|
open_done_success:
|
||||||
|
|
||||||
clc
|
clc
|
||||||
rts
|
rts
|
||||||
|
|
||||||
open_iec:
|
|
||||||
|
|
||||||
// We have a command to send to IEC device
|
|
||||||
jsr LISTEN
|
|
||||||
bcc !+
|
|
||||||
jmp kernalerror_DEVICE_NOT_FOUND
|
|
||||||
!:
|
|
||||||
lda SA
|
|
||||||
jsr iec_cmd_open
|
|
||||||
bcc !+
|
|
||||||
jmp kernalerror_DEVICE_NOT_FOUND
|
|
||||||
!:
|
|
||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_60K
|
|
||||||
// We need our helpers to get to filenames under ROMs or IO area
|
|
||||||
jsr install_ram_routines
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Send command ('file name')
|
|
||||||
jsr lvs_send_file_name
|
|
||||||
|
|
||||||
jmp open_done_success
|
|
||||||
@@ -40,15 +40,9 @@ LOAD:
|
|||||||
// Check whether we support the requested device
|
// Check whether we support the requested device
|
||||||
lda FA
|
lda FA
|
||||||
|
|
||||||
// Try IEC - legal device numbers for LOAD are 8-30
|
#if CONFIG_IEC
|
||||||
// Device numbers above 30 can not be used as IEC (see https://www.pagetable.com/?p=1031),
|
jsr iec_check_devnum_lvs
|
||||||
// as the protocol combines device number with command code in one byte, above 30 it is
|
bcc_far load_iec
|
||||||
// no longer possible. Original ROMs show ILLEGAL DEVICE NUMBER error only for devices
|
#endif // CONFIG_IEC
|
||||||
// 0-3; our implementation is more strict here
|
|
||||||
|
|
||||||
cmp #$1F
|
|
||||||
bcs !+ // >= 31
|
|
||||||
cmp #$08
|
|
||||||
bcs_far load_iec // >= 8
|
|
||||||
!:
|
|
||||||
jmp lvs_illegal_device_number
|
jmp lvs_illegal_device_number
|
||||||
File renamed without changes.
@@ -12,8 +12,8 @@ vector_real:
|
|||||||
// warning and does not mention any preparations needed.
|
// warning and does not mention any preparations needed.
|
||||||
|
|
||||||
// Initial idea was to do php, cli, ..., plp to make the routine safer,
|
// Initial idea was to do php, cli, ..., plp to make the routine safer,
|
||||||
// but it seems it might cause problem with initialization sequence,
|
// but it seems it might cause problem with initialization on XEMU emulator
|
||||||
// as the stack might be uninitialized when this routine is called
|
// XXX find out, why
|
||||||
|
|
||||||
// Prepare the user data pointer - strange order to reduce risk
|
// Prepare the user data pointer - strange order to reduce risk
|
||||||
// of potential similarity to the original routine
|
// of potential similarity to the original routine
|
||||||
|
|||||||
Reference in new issue
Block a user