From 4fbaa047bb530c464e727c4b7940c24c36806938 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 26 Dec 2019 22:27:58 +0100 Subject: [PATCH] optional faster DolphinDOS loop --- c64/,,config_custom.s | 3 +- c64/kernal/iec/load_iec.s | 5 +-- c64/kernal/iec_fast/load_dolphindos.s | 58 +++++++++++++++++++++++++-- 3 files changed, 58 insertions(+), 8 deletions(-) diff --git a/c64/,,config_custom.s b/c64/,,config_custom.s index c6eb3fa8..bbe3c239 100644 --- a/c64/,,config_custom.s +++ b/c64/,,config_custom.s @@ -46,7 +46,8 @@ #define CONFIG_IEC #define CONFIG_IEC_BLANK_SCREEN -#define CONFIG_IEC_DOLPHINDOS // not finished yet, but LOAD works +#define CONFIG_IEC_DOLPHINDOS // not finished yet, but LOAD works +#define CONFIG_IEC_DOLPHINDOS_FAST // needs more testing #define CONFIG_IEC_JIFFYDOS #define CONFIG_TAPE_NORMAL diff --git a/c64/kernal/iec/load_iec.s b/c64/kernal/iec/load_iec.s index 16031cc3..37f1271f 100644 --- a/c64/kernal/iec/load_iec.s +++ b/c64/kernal/iec/load_iec.s @@ -150,9 +150,8 @@ load_iec_loop: plx_trash_a !: // Check for EOI - if so, this was the last byte - lda IOSTATUS - and #K_STS_EOI - beq load_iec_loop + bit IOSTATUS + bvc load_iec_loop // FALLTROUGH diff --git a/c64/kernal/iec_fast/load_dolphindos.s b/c64/kernal/iec_fast/load_dolphindos.s index 57e63820..f9315291 100644 --- a/c64/kernal/iec_fast/load_dolphindos.s +++ b/c64/kernal/iec_fast/load_dolphindos.s @@ -15,13 +15,24 @@ load_dolphindos: // A trick to shorten EAL update time ldy #$00 +#if CONFIG_IEC_DOLPHINDOS_FAST + // Another trick: prepare values for quickly setting/releasing DATA + lda CIA2_PRA + and #$FF - BIT_CIA2_PRA_DAT_OUT - BIT_CIA2_PRA_CLK_OUT - BIT_CIA2_PRA_ATN_OUT + sta IECPROTO // release DATA + ora #BIT_CIA2_PRA_DAT_OUT + sta TBTCNT // pull DATA +#endif + // FALLTROUGH load_dolphindos_loop: +#if !CONFIG_IEC_DOLPHINDOS_FAST // Check if this was EOI bit IOSTATUS bvs load_dolphindos_end +#endif // Wait for the talker to release the CLK line !: @@ -29,25 +40,60 @@ load_dolphindos_loop: bvc !- // Release the DATA to signal we are ready +#if !CONFIG_IEC_DOLPHINDOS_FAST lda CIA2_PRA and #$FF - BIT_CIA2_PRA_DAT_OUT // release +#else + lda IECPROTO +#endif sta CIA2_PRA - // Wait till DATA line is released (someone else might be holding it) +#if !CONFIG_IEC_DOLPHINDOS_FAST + + // Check if EOI + jsr iec_rx_check_eoi // can damage .X, but this is safe + +#else + + // Check if EOI - inlined code to avoid wasting cycles on RTS + ldx #$13 !: bit CIA2_PRA - bpl !- + bvc load_dolphindos_no_eoi + dex + bne !- - // Check if EOI - routine can damage .X, but this is safe - jsr iec_rx_check_eoi + // EOI - mark it and retrieve the last byte + jsr iec_rx_check_eoi_confirm + lda CIA2_PRB + sta (EAL),y + + // Update EAL for the last time + sec + jsr iec_update_EAL_by_Y + + // Restore proper IECPROTO value + lda #$02 + sta IECPROTO + + // End of load loop + jmp load_iec_loop_end + +load_dolphindos_no_eoi: + +#endif // Retrieve and store byte lda CIA2_PRB sta (EAL),y // Pull DATA to acknowledge +#if !CONFIG_IEC_DOLPHINDOS_FAST lda CIA2_PRA ora #BIT_CIA2_PRA_DAT_OUT +#else + lda TBTCNT +#endif sta CIA2_PRA // Handle EAL @@ -56,6 +102,8 @@ load_dolphindos_loop: inc EAL+1 jmp load_dolphindos_loop +#if !CONFIG_IEC_DOLPHINDOS_FAST + load_dolphindos_end: // Update EAL @@ -65,5 +113,7 @@ load_dolphindos_end: // End of load loop jmp load_iec_loop_end +#endif + #endif // CONFIG_IEC_DOLPHINDOS and not CONFIG_MEMORY_MODEL_60K