From c9e9ad5eda9388415a190106f4f1ff49dfd62727 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 5 Dec 2019 22:16:58 +0100 Subject: [PATCH] improved JiffyDOS optimized LOAD loop --- CONFIG.md | 6 ++-- c64/kernal/iec/load_iec.s | 2 +- c64/kernal/iec_fast/load_jiffydos.s | 43 ++++++++++++++++++----------- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/CONFIG.md b/CONFIG.md index 0572f73d..7b75bcd1 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -91,9 +91,9 @@ Planned for the future - not available yet. ### `CONFIG_MEMORY_MODEL_60K` -Uses RAM under BASIC, I/O and KERNAL, takes over `$C000`-`$CFFF` area requires special helper routines installed in `$2A7`-`$2FF` area (normally unused and free for the user). Gives the most free memory for BASIC programs, but it's the slowest and the least compatible model. +Uses RAM under BASIC, I/O and KERNAL, takes over `$C000`-`$CFFF` area requires special helper routines installed in `$2A7`-`$2FF` area (normally unused and free for the user). Gives the most free memory for BASIC programs, but it's the slowest (for example, forces disabling optimized LOAD loop for JiffyDOS) and the least compatible model. -Comparing to standard memoryy model, it needs about 180 bytes in BASIC segment and 80 bytes in KERNAL segment - at the moment of doing the test, these values are expected to change often. +Comparing to standard memory model, it needs about 180 bytes in BASIC segment and 80 bytes in KERNAL segment - at the moment of doing the test, these values are expected to change often. ## I/O devices @@ -107,7 +107,7 @@ Needs over 1000 bytes in KERNAL segment. If unsure - enable. Adds support for JiffyDOS fast protocol to the IEC bus. -Needs about 420 bytes in KERNAL segment. If unsure - enable. +Needs about 430 bytes in KERNAL segment. If unsure - enable. ### `CONFIG_TAPE_TURBO` diff --git a/c64/kernal/iec/load_iec.s b/c64/kernal/iec/load_iec.s index 6379aefd..0ab544ff 100644 --- a/c64/kernal/iec/load_iec.s +++ b/c64/kernal/iec/load_iec.s @@ -87,7 +87,7 @@ load_iec: // Display start address jsr lvs_display_loading_verifying -#if CONFIG_IEC_JIFFYDOS +#if CONFIG_IEC_JIFFYDOS && !CONFIG_MEMORY_MODEL_60K // If feasible, use JiffyDOS optimized LOAD loop diff --git a/c64/kernal/iec_fast/load_jiffydos.s b/c64/kernal/iec_fast/load_jiffydos.s index e9b858cd..f24bdd42 100644 --- a/c64/kernal/iec_fast/load_jiffydos.s +++ b/c64/kernal/iec_fast/load_jiffydos.s @@ -4,10 +4,14 @@ // -#if CONFIG_IEC_JIFFYDOS +#if CONFIG_IEC_JIFFYDOS && !CONFIG_MEMORY_MODEL_60K - // XXX add RUN/STOP support +// Note: original JiffyDOS LOAD loop checks for RUN/STOP key every time a sector is read. +// For simplicity and some space savings, our routine does not check the RUN/STOP key at all; +// the protocol is fast enough (especiallyy with modern flash mediums) that probably nobody +// will want to terminate the loading. + load_jiffydos: @@ -18,10 +22,8 @@ load_jiffydos: jsr jiffydos_prepare sta TBTCNT - // XXX For the first iteration load the whole sector minus 2 bytes - // XXX (as they are used to store the start address) - // XXX ldy #$FB - ldy #$00 + // A trick to shorten EAL update time + ldy #$FF // FALLTROUGH @@ -55,8 +57,8 @@ load_jiffydos_loop: lsr lsr - // Wait for the drive, cycles: 2 - nop + // Wait for the drive - we have time to increment offset, cycles: 2 + iny // Get bits, cycles: 4 + 2 + 2 = 8 ora CIA2_PRA // bits 2 and 3 on CLK/DATA @@ -74,7 +76,7 @@ load_jiffydos_loop: eor CIA2_PRA // bits 6 and 7 on CLK/DATA // Store retrieved byte, cycles: 6 - sta (EAL),y + sta (EAL),y // not compatible with CONFIG_MEMORY_MODEL_60K // Retrieve status bits, cycles: 4 bit CIA2_PRA @@ -85,16 +87,25 @@ load_jiffydos_loop: // If CLK line not active - this was the last byte bvs load_jiffydos_end - // Advance pointer to data XXX use INY instead, advance once per sector only - jsr lvs_advance_EAL - - jmp load_jiffydos_loop + // Handle EAL + cpy #$FF + bne load_jiffydos_loop + inc EAL+1 + jmp load_jiffydos_loop load_jiffydos_end: - // Save last byyte + // Save last byte tax + // Update EAL + tya + sec + adc EAL+0 + sta EAL+0 + bcc !+ + inc EAL+1 +!: // Indicate that no byte waits in output buffer lda #$00 sta C3PO @@ -107,11 +118,11 @@ load_jiffydos_end: lda TBTCNT sta VIC_SPENA - // Store last byte as unoptimized LOAD would + // Store last byte as unoptimized LOAD routine would stx TBTCNT // End of load loop jmp load_iec_loop_end -#endif // CONFIG_IEC_JIFFYDOS +#endif // CONFIG_IEC_JIFFYDOS and not CONFIG_MEMORY_MODEL_60K