From 22e1e201afeb4b52f0fcfa00dc7ead26f50f1c3d Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 22 Jun 2019 14:35:28 +0200 Subject: [PATCH] robustness improvements in IEC support --- c64/kernal/iec_pull_atn_clk_release_data.s | 12 ++++++++++-- c64/kernal/iec_pull_clk_release_data.s | 6 ++++++ c64/kernal/iec_pull_data_release_atn_clock.s | 14 +++++++++++--- c64/kernal/iec_release_atn_clk_data.s | 11 ++++++++++- c64/kernal/iec_release_clk_data.s | 9 ++++++++- c64/kernal/iec_release_clk_pull_data.s | 8 +++++++- c64/kernal/iec_turnaround_to_listen.s | 2 +- c64/kernal/listen.s | 4 +++- c64/kernal/second.s | 4 +++- c64/kernal/talk.s | 4 +++- c64/kernal/tksa.s | 1 + 11 files changed, 63 insertions(+), 12 deletions(-) diff --git a/c64/kernal/iec_pull_atn_clk_release_data.s b/c64/kernal/iec_pull_atn_clk_release_data.s index 07c98292..7e11d311 100644 --- a/c64/kernal/iec_pull_atn_clk_release_data.s +++ b/c64/kernal/iec_pull_atn_clk_release_data.s @@ -1,7 +1,15 @@ iec_pull_atn_clk_release_data: + + ;; Pulled CLK = DATA considered invalid; for extra robustness on non-emulated + ;; hardware give some lines few more cycles to stabilize; see page 10 of + ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf + lda CI2PRA - ora #BIT_CI2PRA_ATN_OUT + BIT_CI2PRA_CLK_OUT ; pull - and #$FF - BIT_CI2PRA_DAT_OUT ; release + ora #BIT_CI2PRA_ATN_OUT ; pull + sta CI2PRA + ora #BIT_CI2PRA_CLK_OUT ; pull + sta CI2PRA + and #$FF - BIT_CI2PRA_DAT_OUT ; release sta CI2PRA rts diff --git a/c64/kernal/iec_pull_clk_release_data.s b/c64/kernal/iec_pull_clk_release_data.s index e37f6736..613aa4ef 100644 --- a/c64/kernal/iec_pull_clk_release_data.s +++ b/c64/kernal/iec_pull_clk_release_data.s @@ -1,7 +1,13 @@ iec_pull_clk_release_data: + + ;; Pulled CLK = DATA considered invalid; for extra robustness on non-emulated + ;; hardware give some lines few more cycles to stabilize; see page 10 of + ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf + lda CI2PRA ora #BIT_CI2PRA_CLK_OUT ; pull + sta CI2PRA and #$FF - BIT_CI2PRA_DAT_OUT ; release sta CI2PRA rts diff --git a/c64/kernal/iec_pull_data_release_atn_clock.s b/c64/kernal/iec_pull_data_release_atn_clock.s index 0e8822da..7b2a18d0 100644 --- a/c64/kernal/iec_pull_data_release_atn_clock.s +++ b/c64/kernal/iec_pull_data_release_atn_clock.s @@ -1,7 +1,15 @@ -iec_pull_data_release_atn_clock: +iec_pull_data_release_atn_clk: + + ;; Released CLK = DATA considered valid; for extra robustness on non-emulated + ;; hardware give some lines few more cycles to stabilize; see page 10 of + ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf + lda CI2PRA - ora #BIT_CI2PRA_DAT_OUT ; pull - and #$FF - BIT_CI2PRA_ATN_OUT - BIT_CI2PRA_CLK_OUT ; release + ora #BIT_CI2PRA_DAT_OUT ; pull + sta CI2PRA + and #$FF - BIT_CI2PRA_CLK_OUT ; release + sta CI2PRA + and #$FF - BIT_CI2PRA_ATN_OUT ; release sta CI2PRA rts diff --git a/c64/kernal/iec_release_atn_clk_data.s b/c64/kernal/iec_release_atn_clk_data.s index c35af0da..3fccfbcb 100644 --- a/c64/kernal/iec_release_atn_clk_data.s +++ b/c64/kernal/iec_release_atn_clk_data.s @@ -1,7 +1,16 @@ iec_release_atn_clk_data: + + ;; Released CLK = DATA considered valid; for extra robustness on non-emulated + ;; hardware give some lines few more cycles to stabilize; see page 10 of + ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf + lda CI2PRA - and #$FF - BIT_CI2PRA_ATN_OUT - BIT_CI2PRA_CLK_OUT - BIT_CI2PRA_DAT_OUT ; release + and #$FF - BIT_CI2PRA_ATN_OUT ; release + sta CI2PRA + and #$FF - BIT_CI2PRA_DAT_OUT ; release + sta CI2PRA + and #$FF - BIT_CI2PRA_CLK_OUT ; release sta CI2PRA rts diff --git a/c64/kernal/iec_release_clk_data.s b/c64/kernal/iec_release_clk_data.s index 65bbb7a7..e74ff7e4 100644 --- a/c64/kernal/iec_release_clk_data.s +++ b/c64/kernal/iec_release_clk_data.s @@ -1,6 +1,13 @@ iec_release_clk_data: + + ;; Released CLK = DATA considered valid; for extra robustness on non-emulated + ;; hardware give some lines few more cycles to stabilize; see page 10 of + ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf + lda CI2PRA - and #$FF - BIT_CI2PRA_CLK_OUT - BIT_CI2PRA_DAT_OUT ; release + and #$FF - BIT_CI2PRA_DAT_OUT ; release + sta CI2PRA + and #$FF - BIT_CI2PRA_CLK_OUT ; release sta CI2PRA rts diff --git a/c64/kernal/iec_release_clk_pull_data.s b/c64/kernal/iec_release_clk_pull_data.s index ea4dd673..1c167a04 100644 --- a/c64/kernal/iec_release_clk_pull_data.s +++ b/c64/kernal/iec_release_clk_pull_data.s @@ -1,7 +1,13 @@ iec_release_clk_pull_data: + + ;; Released CLK = DATA considered valid; for extra robustness on non-emulated + ;; hardware give some lines few more cycles to stabilize; see page 10 of + ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf + lda CI2PRA - and #$FF - BIT_CI2PRA_CLK_OUT ; release ora #BIT_CI2PRA_DAT_OUT ; pull sta CI2PRA + and #$FF - BIT_CI2PRA_CLK_OUT ; release + sta CI2PRA rts diff --git a/c64/kernal/iec_turnaround_to_listen.s b/c64/kernal/iec_turnaround_to_listen.s index dcb4f635..f8c6f237 100644 --- a/c64/kernal/iec_turnaround_to_listen.s +++ b/c64/kernal/iec_turnaround_to_listen.s @@ -5,7 +5,7 @@ iec_turnaround_to_listen: ;; Pull DATA, release CLK and ATN (we are not sending commands) - jsr iec_pull_data_release_atn_clock + jsr iec_pull_data_release_atn_clk ;; Wait for clock line to be pulled by the drive ldx #$FF ; XXX should we really use that high number? diff --git a/c64/kernal/listen.s b/c64/kernal/listen.s index 06cc7121..10d57fe0 100644 --- a/c64/kernal/listen.s +++ b/c64/kernal/listen.s @@ -2,6 +2,8 @@ listen: - ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 223 + ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 223 and + ;; https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc + and #$1F ; make sure bits encoding the command are cleared out ora #$20 jmp iec_tx_command diff --git a/c64/kernal/second.s b/c64/kernal/second.s index 1dc7de8a..7adadbda 100644 --- a/c64/kernal/second.s +++ b/c64/kernal/second.s @@ -1,6 +1,8 @@ ; Function defined on pp272-273 of C64 Programmers Reference Guide second: - ;; This trivial routine is documented in 'C64 Programmer's Reference Guide', page 296 + ;; This trivial routine is documented in 'C64 Programmer's Reference Guide', page 296 and + ;; https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc + and #$1F ; make sure bits encoding the command are cleared out ora #$60 jmp iec_tx_command diff --git a/c64/kernal/talk.s b/c64/kernal/talk.s index 7a421974..0f7fb1e4 100644 --- a/c64/kernal/talk.s +++ b/c64/kernal/talk.s @@ -2,7 +2,9 @@ talk: - ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 223 + ;; This routine is documented in 'Compute's Mapping the Commodore 64', page 223 and + ;; https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc + and #$1F ; make sure bits encoding the command are cleared out ora #$40 jmp iec_tx_command diff --git a/c64/kernal/tksa.s b/c64/kernal/tksa.s index 49bca787..04fff397 100644 --- a/c64/kernal/tksa.s +++ b/c64/kernal/tksa.s @@ -3,6 +3,7 @@ tksa: ;; This routine is documented in 'C64 Programmer's Reference Guide', page 302 and ;; https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc + and #$1F ; make sure bits encoding the command are cleared out ora #$F0 jmp iec_tx_command