From 36d803505e8ab2cd39cfa9e4fcf134e503cab6c5 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 28 Nov 2019 22:01:22 +0100 Subject: [PATCH] more work on JiffyDOS byte reception --- c64/kernal/iec/iec_jiffydos.s | 44 +++++++++++++++++++++++++---------- c64/kernal/iec/iec_rx_byte.s | 11 +++++---- c64/kernal/iec/talk.s | 2 ++ 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/c64/kernal/iec/iec_jiffydos.s b/c64/kernal/iec/iec_jiffydos.s index 33331fad..e19795f8 100644 --- a/c64/kernal/iec/iec_jiffydos.s +++ b/c64/kernal/iec/iec_jiffydos.s @@ -3,7 +3,8 @@ // JiffyDOS protocol support for IEC // -// XXX finish this +// XXX make it work +// XXX split into multiple files @@ -85,7 +86,18 @@ iec_tx_byte_jiffydos_finalize: ora #BIT_CIA2_PRA_CLK_OUT // pull CLK sta CIA2_PRA - bne jiffydos_return_success // branch always + // Restore proper IECPROTO value + lda #$01 + sta IECPROTO + + // Re-enable sprites and interrupts + pla + sta VIC_SPENA + cli + + // Return success + jmp iec_return_success + iec_tx_byte_jiffydos_wait_eoi: @@ -154,26 +166,33 @@ iec_rx_byte_jiffydos: eor C3PO eor CIA2_PRA // bits 6 and 7 on CLK/DATA + // Preserve read byte + sta TBTCNT // $A4 is a byte buffer according to http://sta.c64.org/cbm64mem.html + + // Retrieve status bits + lda CIA2_PRA tax - // XXX CLK and DATA active = EOI - lda CIA2_PRA - - // FALLTROUGH - -jiffydos_return_success: + // Pull DATA at the end + ora #BIT_CIA2_PRA_DAT_OUT + sta CIA2_PRA + // Check for EOI + txa + bmi !+ + jsr kernalstatus_EOI +!: // Restore proper IECPROTO value lda #$01 sta IECPROTO - // Re-enable sprites and interrupts + // Re-enable sprites pla sta VIC_SPENA - cli - // Return success - jmp iec_return_success + // End byte reception + jmp iec_rx_end + jiffydos_wait_line: @@ -198,6 +217,7 @@ jiffydos_wait_line_done: rts + jiffydos_prepare_for_transfer: // We need to preserve 3 lowest bits of CIA2_PRA, they contain important diff --git a/c64/kernal/iec/iec_rx_byte.s b/c64/kernal/iec/iec_rx_byte.s index cd86f951..36f00f78 100644 --- a/c64/kernal/iec/iec_rx_byte.s +++ b/c64/kernal/iec/iec_rx_byte.s @@ -137,10 +137,13 @@ iec_rx_clk_wait2: // Restore registers sta TBTCNT // $A4 is a byte buffer according to http://sta.c64.org/cbm64mem.html - pla - tay - pla - tax + + // FALLTROUGH + +iec_rx_end: + + ply_trash_a + plx_trash_a lda TBTCNT clc diff --git a/c64/kernal/iec/talk.s b/c64/kernal/iec/talk.s index 52b689c3..76b83ff0 100644 --- a/c64/kernal/iec/talk.s +++ b/c64/kernal/iec/talk.s @@ -26,6 +26,8 @@ TALK: // Encode and execute the command ora #$40 + // FALLTROUGH + common_talk_listen: // common part of TALK and LISTEN sta TBTCNT