From c81b04d92388f805a6a3b29e30f2374eec88648c Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 18 Dec 2019 20:52:04 +0100 Subject: [PATCH] bit decoding for tape normal system --- Makefile | 2 +- c64/,,config_generic.s | 4 +- c64/,,config_mega65.s | 2 + c64/,,config_testing.s | 2 + c64/,,config_ultimate64.s | 4 +- c64/aliases/,aliases_config.s | 12 +++--- c64/kernal/tape/load_tape_normal.s | 19 ++------- c64/kernal/tape/load_tape_turbo.s | 3 ++ c64/kernal/tape/tape_normal_get_bit.s | 57 +++++++++++++++++++++++++ c64/kernal/tape/tape_normal_get_byte.s | 49 +++++++++++++++++++++ c64/kernal/tape/tape_normal_get_pulse.s | 3 +- c64/kernal/tape/tape_turbo_get_bit.s | 4 -- c64/kernal/tape/tape_turbo_get_byte.s | 2 + 13 files changed, 135 insertions(+), 28 deletions(-) create mode 100644 c64/kernal/tape/tape_normal_get_bit.s create mode 100644 c64/kernal/tape/tape_normal_get_byte.s diff --git a/Makefile b/Makefile index 4f22c87b..17a662f8 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # Test files TESTDISK = testsuite/testdisk.d64 -TESTTAPE = testsuite/testtape-turbo.tap +TESTTAPE = testsuite/testtape-normal.tap # Source files diff --git a/c64/,,config_generic.s b/c64/,,config_generic.s index 48da55c3..14803a88 100644 --- a/c64/,,config_generic.s +++ b/c64/,,config_generic.s @@ -44,8 +44,10 @@ #define CONFIG_IEC_BLANK_SCREEN // #define CONFIG_IEC_DOLPHINDOS // please keep disabled for now #define CONFIG_IEC_JIFFYDOS -// #define CONFIG_TAPE_NORMAL // please keep disabled for now + +#define CONFIG_TAPE_NORMAL // not finished yet! #define CONFIG_TAPE_TURBO + // #define CONFIG_RS232_UP2400 // please keep disabled for now // #define CONFIG_RS232_UP9600 // please keep disabled for now diff --git a/c64/,,config_mega65.s b/c64/,,config_mega65.s index 62589655..0c04da31 100644 --- a/c64/,,config_mega65.s +++ b/c64/,,config_mega65.s @@ -46,8 +46,10 @@ #define CONFIG_IEC_BLANK_SCREEN // #define CONFIG_IEC_DOLPHINDOS // please keep disabled for now #define CONFIG_IEC_JIFFYDOS + // #define CONFIG_TAPE_NORMAL // please keep disabled for now // #define CONFIG_TAPE_TURBO + // #define CONFIG_RS232_UP2400 // please keep disabled for now // #define CONFIG_RS232_UP9600 // please keep disabled for now diff --git a/c64/,,config_testing.s b/c64/,,config_testing.s index a70ff39e..911c9d38 100644 --- a/c64/,,config_testing.s +++ b/c64/,,config_testing.s @@ -45,8 +45,10 @@ // #define CONFIG_IEC_BLANK_SCREEN // #define CONFIG_IEC_DOLPHINDOS // please keep disabled for now #define CONFIG_IEC_JIFFYDOS + // #define CONFIG_TAPE_NORMAL // please keep disabled for now #define CONFIG_TAPE_TURBO + // #define CONFIG_RS232_UP2400 // please keep disabled for now // #define CONFIG_RS232_UP9600 // please keep disabled for now diff --git a/c64/,,config_ultimate64.s b/c64/,,config_ultimate64.s index 22089550..1ba117be 100644 --- a/c64/,,config_ultimate64.s +++ b/c64/,,config_ultimate64.s @@ -44,8 +44,10 @@ #define CONFIG_IEC_BLANK_SCREEN // #define CONFIG_IEC_DOLPHINDOS // please keep disabled for now #define CONFIG_IEC_JIFFYDOS + // #define CONFIG_TAPE_NORMAL // please keep disabled for now #define CONFIG_TAPE_TURBO + // #define CONFIG_RS232_UP2400 // please keep disabled for now // #define CONFIG_RS232_UP9600 // please keep disabled for now @@ -114,7 +116,7 @@ // Eye candy -// #define CONFIG_COLORS_BRAND +#define CONFIG_COLORS_BRAND // #define CONFIG_BANNER_SIMPLE #define CONFIG_BANNER_FANCY // #define CONFIG_BANNER_BRAND diff --git a/c64/aliases/,aliases_config.s b/c64/aliases/,aliases_config.s index 99b2d2c9..4af7ff64 100644 --- a/c64/aliases/,aliases_config.s +++ b/c64/aliases/,aliases_config.s @@ -303,12 +303,14 @@ { .var features_str = "" -#if CONFIG_TAPE_NORMAL - .eval features_str = ADD_FEATURE(features_str, "TAPE LOAD NORMAL") -#elif CONFIG_TAPE_TURBO +#if CONFIG_TAPE_NORMAL && !CONFIG_TAPE_TURBO + .eval features_str = ADD_FEATURE(features_str, "TAPE LOAD NORMAL-DEV") +#endif +#if !CONFIG_TAPE_NORMAL && CONFIG_TAPE_TURBO .eval features_str = ADD_FEATURE(features_str, "TAPE LOAD TURBO") -#elif CONFIG_TAPE_NORMAL && CONFIG_TAPE_TURBO - .eval features_str = ADD_FEATURE(features_str, "TAPE LOAD NORMAL TURBO") +#endif +#if CONFIG_TAPE_NORMAL && CONFIG_TAPE_TURBO + .eval features_str = ADD_FEATURE(features_str, "TAPE LOAD NORMAL-DEV TURBO") #endif .eval feature_new_line = true diff --git a/c64/kernal/tape/load_tape_normal.s b/c64/kernal/tape/load_tape_normal.s index 056ebaa6..84b8d7c5 100644 --- a/c64/kernal/tape/load_tape_normal.s +++ b/c64/kernal/tape/load_tape_normal.s @@ -51,9 +51,10 @@ load_tape_normal: ldx #%00010001 // start timer, force latch reload stx CIA2_CRA // $DD0E + // Prepare for sound effects + jsr tape_clean_sid // XXX implement some effects + // Start playing - - jsr tape_clean_sid jsr tape_ask_play // FALLTROUGH @@ -62,19 +63,7 @@ load_tape_normal_header: // XXX replace this placeholder by a real routine - - jsr tape_load_get_pulse - ldx #$00 - cmp #($100 - $6C - $05) - - bcs !+ -#if CONFIG_COLORS_BRAND && CONFIG_BRAND_ULTIMATE_64 - ldx #$0B -#else - ldx #$06 -#endif -!: - stx VIC_EXTCOL + jsr tape_normal_get_byte jmp load_tape_normal_header diff --git a/c64/kernal/tape/load_tape_turbo.s b/c64/kernal/tape/load_tape_turbo.s index 59eb619a..2b2bbba7 100644 --- a/c64/kernal/tape/load_tape_turbo.s +++ b/c64/kernal/tape/load_tape_turbo.s @@ -22,7 +22,10 @@ load_tape_turbo: lda #$FE // timer threshold for TurboTape sta CIA2_TIMALO // $DD04 + // Prepare for sound effects jsr tape_clean_sid + + // Start playing jsr tape_ask_play // FALLTROUGH diff --git a/c64/kernal/tape/tape_normal_get_bit.s b/c64/kernal/tape/tape_normal_get_bit.s new file mode 100644 index 00000000..3314f228 --- /dev/null +++ b/c64/kernal/tape/tape_normal_get_bit.s @@ -0,0 +1,57 @@ + +// +// Tape (turbo) helper routine - bit reading +// +// Returns bit in Zero flag, Carry set means error +// + + +#if CONFIG_TAPE_NORMAL + + +tape_normal_get_bit: + + // Fetch the first pulse + + jsr tape_normal_get_pulse + bcc tape_normal_get_bit_0 + + // First impulse was short, second should be long + + jsr tape_normal_get_pulse + bcs tape_normal_get_bit_error + + // We have a bit '1' + + clc + lda #$06 + + // FALLTROUGH + +tape_normal_get_bit_done: + + sta VIC_EXTCOL + rts + + +tape_normal_get_bit_0: + + // First impulse was long, second should be short + + jsr tape_normal_get_pulse + bcc tape_normal_get_bit_error + + // We have a bit '0' + + // Carry flag already clear + lda #$00 + beq tape_normal_get_bit_done // branch always + + +tape_normal_get_bit_error: + + sec + rts + + +#endif // CONFIG_TAPE_NORMAL diff --git a/c64/kernal/tape/tape_normal_get_byte.s b/c64/kernal/tape/tape_normal_get_byte.s new file mode 100644 index 00000000..94e3dda8 --- /dev/null +++ b/c64/kernal/tape/tape_normal_get_byte.s @@ -0,0 +1,49 @@ + +// +// Tape (turbo) helper routine - byte reading +// +// Returns byte in .A +// + + +#if CONFIG_TAPE_NORMAL + + +tape_normal_get_byte: + + lda #$0B + sta VIC_EXTCOL + + // First we need a byte marker - (L,M) + +!: + jsr tape_normal_get_pulse + cmp #($100 - $95 - $05) + bcs !- // too short for a long pulse + jsr tape_normal_get_pulse + bcs !- // too short for a medium pulse + + // Now fetch individual bits + + // XXX finish this + + jsr tape_normal_get_bit + jsr tape_normal_get_bit + jsr tape_normal_get_bit + jsr tape_normal_get_bit + jsr tape_normal_get_bit + jsr tape_normal_get_bit + jsr tape_normal_get_bit + jsr tape_normal_get_bit + + + + + + + + + rts + + +#endif diff --git a/c64/kernal/tape/tape_normal_get_pulse.s b/c64/kernal/tape/tape_normal_get_pulse.s index bd69e013..6d59b1a4 100644 --- a/c64/kernal/tape/tape_normal_get_pulse.s +++ b/c64/kernal/tape/tape_normal_get_pulse.s @@ -9,7 +9,7 @@ #if CONFIG_TAPE_NORMAL -tape_load_get_pulse: +tape_normal_get_pulse: // Contrary to original ROM implementation we do not use interrupts // (see http://unusedino.de/ec64/technical/formats/tap.html) - busy wait @@ -36,6 +36,7 @@ tape_load_get_pulse: // this is total 19 cycles, or $5 periods of 4 ticks (timer A) each - we need to take it into account // every time we check the pulse length + cmp #($100 - $6C - $05) // short vs medium is the default check rts diff --git a/c64/kernal/tape/tape_turbo_get_bit.s b/c64/kernal/tape/tape_turbo_get_bit.s index b900528d..a6cf343a 100644 --- a/c64/kernal/tape/tape_turbo_get_bit.s +++ b/c64/kernal/tape/tape_turbo_get_bit.s @@ -26,11 +26,7 @@ tape_turbo_get_bit: asl sta SID_SIGVOL beq !+ -#if CONFIG_COLORS_BRAND && CONFIG_BRAND_ULTIMATE_64 - lda #$0B -#else lda #$06 -#endif !: sta VIC_EXTCOL pla diff --git a/c64/kernal/tape/tape_turbo_get_byte.s b/c64/kernal/tape/tape_turbo_get_byte.s index 22a54110..68c0192a 100644 --- a/c64/kernal/tape/tape_turbo_get_byte.s +++ b/c64/kernal/tape/tape_turbo_get_byte.s @@ -2,6 +2,8 @@ // // Tape (turbo) helper routine - byte reading // +// Returns byte in .A +// // Based on routine by enthusi/Onslaught, found here: // - https://codebase64.pokefinder.org/doku.php?id=base:turbotape_loader_source