From 94a0338ee75210f0eb5c3e9ce3783d6284eda96b Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Mon, 27 Jan 2020 20:12:30 +0100 Subject: [PATCH] cleanup in tape support code --- CONFIG.md | 6 ++--- c64/,,config_generic.s | 2 +- c64/,,config_ultimate64.s | 2 +- c64/kernal/tape/load_tape_normal.s | 10 ++++++++ c64/kernal/tape/tape_normal_get_data_2.s | 32 +++++------------------- 5 files changed, 21 insertions(+), 31 deletions(-) diff --git a/CONFIG.md b/CONFIG.md index 13afd09b..73c20b49 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -147,13 +147,13 @@ Causes screen blanking during JiffyDOS file loading to increase performance. Adds a minimal normal (standard Commodore format) tape support - just LOAD command. -Needs about 700 bytes in KERNAL segment (if both normal and turbo are enabled, about 900 bytes are needed, as they share some code). If unsure - enable. +Needs about 850 bytes in KERNAL segment (if both normal and turbo are enabled, about 900 bytes are needed, as they share some code). If unsure - enable. ### `CONFIG_TAPE_TURBO` Adds a minimal turbo tape support - just LOAD command (device 7, like on _Action Replay_ and _Final_ cartridges), up to 250 blocks -Needs about 700 bytes in KERNAL segment (if both normal and turbo are enabled, about 950 bytes are needed, as they share some code). If unsure - enable. +Needs about 700 bytes in KERNAL segment (if both normal and turbo are enabled, about 1050 bytes are needed, as they share some code). If unsure - enable. ### `CONFIG_TAPE_NO_KEY_SENSE` @@ -167,7 +167,7 @@ Enable this option if you are using a tape interface adapter lacking tape motor Normal tape format contains two copies of each data block - in case some bytes from the first one are damaged, they can be corrected by reading them from the second copy. Enabling this option omits the core to read the second block. -If using real magnetic tape - disable. Enable if only using Tapuino or other tape emulators. +If used with `CONFIG_TAPE_NORMAL`, saves about 125 bytes in KERNAL segment. Not recommended when using real magnetic tapes. ## Multiple SID support diff --git a/c64/,,config_generic.s b/c64/,,config_generic.s index 86516d96..0390271c 100644 --- a/c64/,,config_generic.s +++ b/c64/,,config_generic.s @@ -52,7 +52,7 @@ #define CONFIG_TAPE_TURBO // #define CONFIG_TAPE_NO_KEY_SENSE // #define CONFIG_TAPE_NO_MOTOR_CONTROL -#define CONFIG_TAPE_NO_ERROR_CORRECTION +// #define CONFIG_TAPE_NO_ERROR_CORRECTION // Multiple SID support diff --git a/c64/,,config_ultimate64.s b/c64/,,config_ultimate64.s index 6293096d..0ba624d3 100644 --- a/c64/,,config_ultimate64.s +++ b/c64/,,config_ultimate64.s @@ -52,7 +52,7 @@ #define CONFIG_TAPE_TURBO // #define CONFIG_TAPE_NO_KEY_SENSE // #define CONFIG_TAPE_NO_MOTOR_CONTROL -#define CONFIG_TAPE_NO_ERROR_CORRECTION +// #define CONFIG_TAPE_NO_ERROR_CORRECTION // Multiple SID support diff --git a/c64/kernal/tape/load_tape_normal.s b/c64/kernal/tape/load_tape_normal.s index d4ad448f..4fad6566 100644 --- a/c64/kernal/tape/load_tape_normal.s +++ b/c64/kernal/tape/load_tape_normal.s @@ -70,8 +70,13 @@ load_tape_normal_header: jsr tape_normal_get_data_1 bcs load_tape_normal_header // unable to read block, try again XXX jump to turbo detection +#if CONFIG_TAPE_NO_ERROR_CORRECTION + lda RIPRTY + cmp #$01 // sets Carry if checksum verification fails +#else jsr load_TAPE1_to_MEMUSS jsr tape_normal_get_data_2 +#endif bcs load_tape_normal_header // block load error, try again XXX jump to turbo detection // Check header type @@ -110,8 +115,13 @@ load_tape_normal_payload: jsr lvs_check_EAL bne_16 tape_load_error // amount of data read does not match header info +#if CONFIG_TAPE_NO_ERROR_CORRECTION + lda RIPRTY + cmp #$01 // sets Carry if checksum verification fails +#else jsr lvs_STAL_to_MEMUSS jsr tape_normal_get_data_2 +#endif bcs_16 tape_load_error jmp tape_load_success diff --git a/c64/kernal/tape/tape_normal_get_data_2.s b/c64/kernal/tape/tape_normal_get_data_2.s index 2c378473..d5ec0c14 100644 --- a/c64/kernal/tape/tape_normal_get_data_2.s +++ b/c64/kernal/tape/tape_normal_get_data_2.s @@ -7,21 +7,7 @@ // -#if CONFIG_TAPE_NORMAL - -#if CONFIG_TAPE_NO_ERROR_CORRECTION - - -tape_normal_get_data_2: // XXX implement under separate name - - // Just validate the checksum - - lda RIPRTY - cmp #$01 - rts - - -#else +#if CONFIG_TAPE_NORMAL && !CONFIG_TAPE_NO_ERROR_CORRECTION tape_normal_get_data_2: @@ -42,6 +28,11 @@ tape_normal_get_data_2: tape_normal_get_data_2_loop: + // Check if there are missing bytes to read + lda PTR1 + cmp PTR2 + beq tape_normal_get_data_2_log_checksum // branch if no more errors to correct + // Read missing bytes jsr tape_normal_get_byte @@ -106,16 +97,8 @@ tape_normal_get_data_2_done: rts - load_cmp_log_MEMUSS: - lda PTR1 // XXX this comparison can be probably moved somewhere else - cmp PTR2 - bne !+ - - lda #$01 // to clear Zero flag - rts -!: ldx PTR2 lda STACK+0, x cmp MEMUSS+0 @@ -135,6 +118,3 @@ load_cmp_log_MEMUSS: #endif - - -#endif