diff --git a/c64/kernal/iec/ciout.s b/c64/kernal/iec/ciout.s index 5e4c3e8b..3b92cc14 100644 --- a/c64/kernal/iec/ciout.s +++ b/c64/kernal/iec/ciout.s @@ -32,13 +32,13 @@ ciout_store_in_buffer: ciout_send_byte: - clc // don't send with EOI -#if CONFIG_IEC_JIFFYDOS || CONFIG_IEC_DOLPHINDOS + clc // send without EOI +#if CONFIG_IEC_JIFFYDOS jsr iec_tx_dispatch -#else // no turbo supported +#else jsr iec_tx_byte #endif - inc C3PO // iec_tx_byte sets it to 0, but we still have something to send + inc C3PO // tx byte routine sets to 0, but we still have something to send jmp ciout_store_in_buffer #else diff --git a/c64/kernal/iec/iec_rx_byte.s b/c64/kernal/iec/iec_rx_byte.s index c186f33c..d0cdeee0 100644 --- a/c64/kernal/iec/iec_rx_byte.s +++ b/c64/kernal/iec/iec_rx_byte.s @@ -8,6 +8,19 @@ #if CONFIG_IEC +#if CONFIG_IEC_JIFFYDOS + +iec_rx_dispatch: + + lda IECPROTO + cmp #$01 + beq_far jiffydos_rx_byte + + // FALLTROUGH + +#endif // CONFIG_IEC_JIFFYDOS + + iec_rx_byte: // Store .X and .Y on the stack - preserve them diff --git a/c64/kernal/iec/iec_send_file_name.s b/c64/kernal/iec/iec_send_file_name.s index a372b8cd..72f107bf 100644 --- a/c64/kernal/iec/iec_send_file_name.s +++ b/c64/kernal/iec/iec_send_file_name.s @@ -30,9 +30,9 @@ iec_send_file_name_loop: !: // Transmit one character sta TBTCNT -#if CONFIG_IEC_JIFFYDOS || CONFIG_IEC_DOLPHINDOS +#if CONFIG_IEC_JIFFYDOS jsr iec_tx_dispatch -#else // no turbo supported +#else jsr iec_tx_byte #endif jmp iec_send_file_name_loop diff --git a/c64/kernal/iec/iec_tx_byte.s b/c64/kernal/iec/iec_tx_byte.s index 5dcca324..9b4cf8db 100644 --- a/c64/kernal/iec/iec_tx_byte.s +++ b/c64/kernal/iec/iec_tx_byte.s @@ -9,6 +9,26 @@ #if CONFIG_IEC + +#if CONFIG_IEC_JIFFYDOS + +iec_tx_dispatch: + + php // preserve C flag for EOI indication + lda IECPROTO + cmp #$01 + bne !+ + + plp + jmp jiffydos_tx_byte +!: + plp + + // FALLTROUGH + +#endif // CONFIG_IEC_JIFFYDOS + + iec_tx_byte: // Store .X and .Y on the stack - preserve them diff --git a/c64/kernal/iec/load_iec.s b/c64/kernal/iec/load_iec.s index 37f1271f..d901e6a7 100644 --- a/c64/kernal/iec/load_iec.s +++ b/c64/kernal/iec/load_iec.s @@ -103,12 +103,12 @@ load_iec: #if CONFIG_IEC_JIFFYDOS cmp #$01 - beq_far load_jiffydos // branch if JiffyDOS + beq_far jiffydos_load // branch if JiffyDOS #endif #if CONFIG_IEC_DOLPHINDOS cmp #$02 - beq_far load_dolphindos // branch if DolphinDOS + beq_far dolphindos_load // branch if DolphinDOS #endif #endif diff --git a/c64/kernal/iec_fast/load_dolphindos.s b/c64/kernal/iec_fast/dolphindos_load.s similarity index 90% rename from c64/kernal/iec_fast/load_dolphindos.s rename to c64/kernal/iec_fast/dolphindos_load.s index f9315291..849f3948 100644 --- a/c64/kernal/iec_fast/load_dolphindos.s +++ b/c64/kernal/iec_fast/dolphindos_load.s @@ -7,7 +7,7 @@ #if CONFIG_IEC_DOLPHINDOS && !CONFIG_MEMORY_MODEL_60K -load_dolphindos: +dolphindos_load: // Timing is critical for some parts, do not allow interrupts sei @@ -26,12 +26,12 @@ load_dolphindos: // FALLTROUGH -load_dolphindos_loop: +dolphindos_load_loop: #if !CONFIG_IEC_DOLPHINDOS_FAST // Check if this was EOI bit IOSTATUS - bvs load_dolphindos_end + bvs dolphindos_load_end #endif // Wait for the talker to release the CLK line @@ -59,7 +59,7 @@ load_dolphindos_loop: ldx #$13 !: bit CIA2_PRA - bvc load_dolphindos_no_eoi + bvc dolphindos_load_no_eoi dex bne !- @@ -79,7 +79,7 @@ load_dolphindos_loop: // End of load loop jmp load_iec_loop_end -load_dolphindos_no_eoi: +dolphindos_load_no_eoi: #endif @@ -98,13 +98,13 @@ load_dolphindos_no_eoi: // Handle EAL iny - bne load_dolphindos_loop + bne dolphindos_load_loop inc EAL+1 - jmp load_dolphindos_loop + jmp dolphindos_load_loop #if !CONFIG_IEC_DOLPHINDOS_FAST -load_dolphindos_end: +dolphindos_load_end: // Update EAL clc diff --git a/c64/kernal/iec_fast/iec_rx_byte_dolphindos.s b/c64/kernal/iec_fast/iec_rx_byte_dolphindos.s deleted file mode 100644 index 54828900..00000000 --- a/c64/kernal/iec_fast/iec_rx_byte_dolphindos.s +++ /dev/null @@ -1,61 +0,0 @@ - -// -// DolphinDOS protocol support for IEC - byte reception -// - - -#if CONFIG_IEC_DOLPHINDOS - - -// XXX experimental, partially copied from standard protocol, not fully tested yet! -// XXX maybe this can be integrated into iec_rx_byte??? - - -iec_rx_byte_dolphindos: - - // Store .X and .Y on the stack - preserve them - phx_trash_a - phy_trash_a - - // First, we wait for the talker to release the CLK line - jsr iec_wait_for_clk_release - - // We then release the DATA to signal we are ready - // We can use this routine, since we were not pulling CLK anyway - jsr iec_release_clk_data - - // Wait for talker to pull CLK. - // If over 200 usec (205 cycles on NTSC machine) , then it is EOI. - // Loop iteraction takes 13 cycles, 17 full iterations are enough - - ldx #$11 // 2 cycles -iec_rx_dd_clk_wait1: - lda CIA2_PRA // 4 cycles - rol // 2 cycles, to put CLK in as the last bit - bpl iec_rx_dd_not_eoi // 2 cycles if not jumped - dex // 2 cycles - bne iec_rx_dd_clk_wait1 // 3 cycles if jumped - - // Timeout - either this is the last byte of stream, or the stream is empty at all. - // Mark end of stream in IOSTATUS - jsr kernalstatus_EOI - -iec_rx_dd_not_empty: - - // Pull data for 60 usec to confirm it - jsr iec_release_clk_pull_data - jsr iec_wait60us - jsr iec_release_clk_data - -iec_rx_dd_not_eoi: - - // Retrieve byte via parallel, store it - lda CIA2_PRB - sta TBTCNT // $A4 is a byte buffer according to http://sta.c64.org/cbm64mem.html - - // Inform the drive about byte reception - jsr iec_release_clk_pull_data - - jmp iec_rx_end - -#endif diff --git a/c64/kernal/iec_fast/iec_rx_dispatch.s b/c64/kernal/iec_fast/iec_rx_dispatch.s deleted file mode 100644 index 5ec3ba49..00000000 --- a/c64/kernal/iec_fast/iec_rx_dispatch.s +++ /dev/null @@ -1,22 +0,0 @@ - -// -// Arbitration code for normal/JiffyDOS transfer -// - - -#if CONFIG_IEC_JIFFYDOS - - -iec_rx_dispatch: - - lda IECPROTO - -#if CONFIG_IEC_JIFFYDOS - cmp #$01 - beq_far iec_rx_byte_jiffydos -#endif // CONFIG_IEC_JIFFYDOS - - jmp iec_rx_byte - - -#endif diff --git a/c64/kernal/iec_fast/iec_tx_byte_dolphindos.s b/c64/kernal/iec_fast/iec_tx_byte_dolphindos.s deleted file mode 100644 index 1f2cbbe9..00000000 --- a/c64/kernal/iec_fast/iec_tx_byte_dolphindos.s +++ /dev/null @@ -1,15 +0,0 @@ - -// -// DolphinDOS protocol support for IEC - byte transfer -// - - -#if CONFIG_IEC_DOLPHINDOS - - -iec_tx_byte_dolphindos: - - panic #$00 // XXX implement this - - -#endif diff --git a/c64/kernal/iec_fast/iec_tx_dispatch.s b/c64/kernal/iec_fast/iec_tx_dispatch.s deleted file mode 100644 index e7310024..00000000 --- a/c64/kernal/iec_fast/iec_tx_dispatch.s +++ /dev/null @@ -1,45 +0,0 @@ - -// -// Arbitration code for normal/turbo transfer -// - - -#if CONFIG_IEC_JIFFYDOS || CONFIG_IEC_DOLPHINDOS - - -iec_tx_dispatch: - - php // preserve C flag for EOI indication - lda IECPROTO - -#if CONFIG_IEC_JIFFYDOS - cmp #$01 - beq iec_tx_dispatch_jiffydos -#endif // CONFIG_IEC_JIFFYDOS - -#if CONFIG_IEC_DOLPHINDOS - cmp #$02 - beq iec_tx_dispatch_dolphindos -#endif // CONFIG_IEC_DOLPHINDOS - - // FALLTROUGH - -iec_tx_dispatch_normal: - - plp - jmp iec_tx_byte - -#if CONFIG_IEC_JIFFYDOS -iec_tx_dispatch_jiffydos: - plp - jmp iec_tx_byte_jiffydos -#endif // CONFIG_IEC_JIFFYDOS - -#if CONFIG_IEC_DOLPHINDOS -iec_tx_dispatch_dolphindos: - plp - jmp iec_tx_byte_dolphindos -#endif // CONFIG_IEC_DOLPHINDOS - - -#endif // any turbo supported diff --git a/c64/kernal/iec_fast/load_jiffydos.s b/c64/kernal/iec_fast/jiffydos_load.s similarity index 96% rename from c64/kernal/iec_fast/load_jiffydos.s rename to c64/kernal/iec_fast/jiffydos_load.s index db19537c..5b6ca0c4 100644 --- a/c64/kernal/iec_fast/load_jiffydos.s +++ b/c64/kernal/iec_fast/jiffydos_load.s @@ -15,7 +15,7 @@ // will want to terminate the loading. -load_jiffydos: +jiffydos_load: // Timing is critical, do not allow interrupts sei @@ -48,7 +48,7 @@ load_jiffydos: // FALLTROUGH -load_jiffydos_loop: +jiffydos_load_loop: // Wait until device is ready to send (releases CLK) jsr iec_wait_for_clk_release @@ -118,15 +118,15 @@ load_jiffydos_loop: stx CIA2_PRA // If CLK line not active - this was the last byte - bvs load_jiffydos_end + bvs jiffydos_load_end // Handle EAL cpy #$FF - bne load_jiffydos_loop + bne jiffydos_load_loop inc EAL+1 - jmp load_jiffydos_loop + jmp jiffydos_load_loop -load_jiffydos_end: +jiffydos_load_end: // Save last byte tax diff --git a/c64/kernal/iec_fast/iec_rx_byte_jiffydos.s b/c64/kernal/iec_fast/jiffydos_rx_byte.s similarity index 96% rename from c64/kernal/iec_fast/iec_rx_byte_jiffydos.s rename to c64/kernal/iec_fast/jiffydos_rx_byte.s index d796a88f..cb55f3ec 100644 --- a/c64/kernal/iec_fast/iec_rx_byte_jiffydos.s +++ b/c64/kernal/iec_fast/jiffydos_rx_byte.s @@ -7,7 +7,7 @@ #if CONFIG_IEC_JIFFYDOS -iec_rx_byte_jiffydos: +jiffydos_rx_byte: // Timing is critical, do not allow interrupts sei @@ -81,14 +81,15 @@ iec_rx_byte_jiffydos: stx CIA2_PRA // If CLK line active - success - bvc iec_rx_byte_jiffydos_end + bvc jiffydos_rx_byte_end + // XXX the DATA line can probably be used to distinguish between file not found error and normal stream EOI jsr kernalstatus_EOI // FALLTROUGH -iec_rx_byte_jiffydos_end: +jiffydos_rx_byte_end: // Indicate that no byte waits in output buffer lda #$00 diff --git a/c64/kernal/iec_fast/iec_tx_byte_jiffydos.s b/c64/kernal/iec_fast/jiffydos_tx_byte.s similarity index 93% rename from c64/kernal/iec_fast/iec_tx_byte_jiffydos.s rename to c64/kernal/iec_fast/jiffydos_tx_byte.s index dd33e378..26be0860 100644 --- a/c64/kernal/iec_fast/iec_tx_byte_jiffydos.s +++ b/c64/kernal/iec_fast/jiffydos_tx_byte.s @@ -7,7 +7,7 @@ #if CONFIG_IEC_JIFFYDOS -iec_tx_byte_jiffydos: +jiffydos_tx_byte: // Timing is critical, do not allow interrupts sei @@ -70,11 +70,11 @@ iec_tx_byte_jiffydos: // Signal EOI if needed; cycles till no EOI: 3 + 3 + 2 + 2 + 4 = 14 lda C3PO ldx IECPROTO - beq iec_tx_byte_jiffydos_wait_eoi + beq jiffydos_tx_byte_wait_eoi // FALLTROUGH -iec_tx_byte_jiffydos_finalize: +jiffydos_tx_byte_finalize: ora #BIT_CIA2_PRA_CLK_OUT // pull CLK sta CIA2_PRA @@ -92,12 +92,12 @@ iec_tx_byte_jiffydos_finalize: jmp iec_return_success -iec_tx_byte_jiffydos_wait_eoi: +jiffydos_tx_byte_wait_eoi: sta CIA2_PRA jsr iec_wait20us lda C3PO - jmp iec_tx_byte_jiffydos_finalize + jmp jiffydos_tx_byte_finalize #endif // CONFIG_IEC_JIFFYDOS