From 0cafc8defb2a30bff5f0eb6f6f8a12e1a25e2cd6 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 26 Dec 2019 16:24:13 +0100 Subject: [PATCH] IEC code size optimizations --- c64/kernal/iec/iec_wait60us.s | 8 ++++++-- c64/kernal/iec/load_iec.s | 2 +- c64/kernal/iec_fast/iec_fast_common.s | 22 ++++++++++++++++++++++ c64/kernal/iec_fast/load_dolphindos.s | 14 +++----------- c64/kernal/iec_fast/load_jiffydos.s | 9 ++------- 5 files changed, 34 insertions(+), 21 deletions(-) create mode 100644 c64/kernal/iec_fast/iec_fast_common.s diff --git a/c64/kernal/iec/iec_wait60us.s b/c64/kernal/iec/iec_wait60us.s index f748ea28..5673d528 100644 --- a/c64/kernal/iec/iec_wait60us.s +++ b/c64/kernal/iec/iec_wait60us.s @@ -1,4 +1,8 @@ +// +// Note: damages .X +// + #if CONFIG_IEC @@ -14,8 +18,8 @@ iec_wait60us: // Waste cycles in a loop - ldy #$0A // 2 cycles -!: dey // 2 cycles * 10 + ldx #$0A // 2 cycles +!: dex // 2 cycles * 10 bpl !- // 3 cycles * 9 + 2 cycles rts // 6 cycles diff --git a/c64/kernal/iec/load_iec.s b/c64/kernal/iec/load_iec.s index cf5e5995..ccbff761 100644 --- a/c64/kernal/iec/load_iec.s +++ b/c64/kernal/iec/load_iec.s @@ -93,7 +93,7 @@ load_iec: // Display start address jsr lvs_display_loading_verifying -#if CONFIG_IEC_JIFFYDOS && !CONFIG_MEMORY_MODEL_60K +#if (CONFIG_IEC_JIFFYDOS || CONFIG_IEC_DOLPHINDOS) && !CONFIG_MEMORY_MODEL_60K // If feasible, use JiffyDOS optimized LOAD loop diff --git a/c64/kernal/iec_fast/iec_fast_common.s b/c64/kernal/iec_fast/iec_fast_common.s new file mode 100644 index 00000000..9b8cf89d --- /dev/null +++ b/c64/kernal/iec_fast/iec_fast_common.s @@ -0,0 +1,22 @@ + +// +// Common routines for multiple IEC fact protocols +// + + +#if (CONFIG_IEC_JIFFYDOS || CONFIG_IEC_DOLPHINDOS) && !CONFIG_MEMORY_MODEL_60K + + +iec_update_EAL_by_Y: + + tya + sec + adc EAL+0 + sta EAL+0 + bcc !+ + inc EAL+1 +!: + rts + + +#endif diff --git a/c64/kernal/iec_fast/load_dolphindos.s b/c64/kernal/iec_fast/load_dolphindos.s index 27258a14..eb7a18af 100644 --- a/c64/kernal/iec_fast/load_dolphindos.s +++ b/c64/kernal/iec_fast/load_dolphindos.s @@ -39,10 +39,8 @@ load_dolphindos_loop: lda CIA2_PRA bpl !- - // Check if EOI - routine can damage .Y, so store it in safe place - sty TBTCNT + // Check if EOI - routine can damage .X, but this is safe jsr iec_rx_check_eoi - ldy TBTCNT // Retrieve and store byte lda CIA2_PRB @@ -62,14 +60,8 @@ load_dolphindos_loop: load_dolphindos_end: - // Update EAL - XXX deduplicate with JiffyDOS counterpart - tya - sec - adc EAL+0 - sta EAL+0 - bcc !+ - inc EAL+1 -!: + // Update EAL + jsr iec_update_EAL_by_Y // End of load loop jmp load_iec_loop_end diff --git a/c64/kernal/iec_fast/load_jiffydos.s b/c64/kernal/iec_fast/load_jiffydos.s index acb0c7e5..923e7dbc 100644 --- a/c64/kernal/iec_fast/load_jiffydos.s +++ b/c64/kernal/iec_fast/load_jiffydos.s @@ -132,13 +132,8 @@ load_jiffydos_end: tax // Update EAL - tya - sec - adc EAL+0 - sta EAL+0 - bcc !+ - inc EAL+1 -!: + jsr iec_update_EAL_by_Y + // Indicate that no byte waits in output buffer lda #$00 sta C3PO