diff --git a/CONFIG.md b/CONFIG.md index 73c20b49..a9236166 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -147,13 +147,19 @@ Causes screen blanking during JiffyDOS file loading to increase performance. Adds a minimal normal (standard Commodore format) tape support - just LOAD command. -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. +Needs about 1050 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 1050 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 1300 bytes are needed, as they share some code). If unsure - enable. + +### `CONFIG_TAPE_AUTODETECT` + +Tape format (normal/turbo) is always autodetected. + +Needs about 100 more bytes in KERNAL segment. ### `CONFIG_TAPE_NO_KEY_SENSE` diff --git a/STATUS.md b/STATUS.md index d4891fe6..d1cdaa6c 100644 --- a/STATUS.md +++ b/STATUS.md @@ -13,6 +13,7 @@ Here are the features of the Open ROMs not found in the original ROMs from the 8 * turbo tape load support (as device 7, or using `←L`), quite sophisticated: up to 250 blocks (can store bytes under I/O), automatically adjusts for tape speed differences * normal tape load error log is limited by free stack space only (no artificial limitation like in original ROMs) +* tape format autodetection; normal vs turbo is mostly transparent to user * improved support for tape adapters (for using regular casette players and other audio devices instead of Datasette) and emulators * extended `LOAD` command diff --git a/bin/basic_generic.rom b/bin/basic_generic.rom index e3d073ac..b8cfb3c3 100644 Binary files a/bin/basic_generic.rom and b/bin/basic_generic.rom differ diff --git a/bin/basic_testing.rom b/bin/basic_testing.rom index fb950a74..53e5df4d 100644 Binary files a/bin/basic_testing.rom and b/bin/basic_testing.rom differ diff --git a/bin/basic_ultimate64.rom b/bin/basic_ultimate64.rom index 6bbbab86..d83c3f6f 100644 Binary files a/bin/basic_ultimate64.rom and b/bin/basic_ultimate64.rom differ diff --git a/bin/kernal_generic.rom b/bin/kernal_generic.rom index 90a888be..ce28b37e 100644 Binary files a/bin/kernal_generic.rom and b/bin/kernal_generic.rom differ diff --git a/bin/kernal_testing.rom b/bin/kernal_testing.rom index 74a71589..851c2b6d 100644 Binary files a/bin/kernal_testing.rom and b/bin/kernal_testing.rom differ diff --git a/bin/kernal_ultimate64.rom b/bin/kernal_ultimate64.rom index 754f75c7..194dad40 100644 Binary files a/bin/kernal_ultimate64.rom and b/bin/kernal_ultimate64.rom differ diff --git a/bin/mega65.rom b/bin/mega65.rom index 6f99bd91..311197a3 100644 Binary files a/bin/mega65.rom and b/bin/mega65.rom differ diff --git a/c64/,,config_custom.s b/c64/,,config_custom.s index 6e5787e8..bf190455 100644 --- a/c64/,,config_custom.s +++ b/c64/,,config_custom.s @@ -56,7 +56,7 @@ #define CONFIG_TAPE_NORMAL #define CONFIG_TAPE_TURBO -#define CONFIG_TAPE_AUTODETECT // mostly works, but not fully done yet! +#define CONFIG_TAPE_AUTODETECT // #define CONFIG_TAPE_NO_KEY_SENSE // #define CONFIG_TAPE_NO_MOTOR_CONTROL // #define CONFIG_TAPE_NO_ERROR_CORRECTION diff --git a/c64/,,config_generic.s b/c64/,,config_generic.s index 0390271c..4bdb6ab0 100644 --- a/c64/,,config_generic.s +++ b/c64/,,config_generic.s @@ -50,6 +50,7 @@ #define CONFIG_TAPE_NORMAL #define CONFIG_TAPE_TURBO +#define CONFIG_TAPE_AUTODETECT // #define CONFIG_TAPE_NO_KEY_SENSE // #define CONFIG_TAPE_NO_MOTOR_CONTROL // #define CONFIG_TAPE_NO_ERROR_CORRECTION @@ -70,8 +71,8 @@ // Keyboard settings // #define CONFIG_LEGACY_SCNKEY -#define CONFIG_KEYBOARD_C128 -#define CONFIG_KEYBOARD_C128_CAPS_LOCK +// #define CONFIG_KEYBOARD_C128 +// #define CONFIG_KEYBOARD_C128_CAPS_LOCK // #define CONFIG_KEYBOARD_C65 // untested // #define CONFIG_KEYBOARD_C65_CAPS_LOCK // untested // #define CONFIG_KEY_REPEAT_DEFAULT diff --git a/c64/,,config_mega65.s b/c64/,,config_mega65.s index b498a38a..90b88161 100644 --- a/c64/,,config_mega65.s +++ b/c64/,,config_mega65.s @@ -50,9 +50,10 @@ // #define CONFIG_TAPE_NORMAL // #define CONFIG_TAPE_TURBO +// #define CONFIG_TAPE_AUTODETECT // #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_testing.s b/c64/,,config_testing.s index 537fcded..d6743178 100644 --- a/c64/,,config_testing.s +++ b/c64/,,config_testing.s @@ -50,6 +50,7 @@ // #define CONFIG_TAPE_NORMAL #define CONFIG_TAPE_TURBO +// #define CONFIG_TAPE_AUTODETECT // #define CONFIG_TAPE_NO_KEY_SENSE // #define CONFIG_TAPE_NO_MOTOR_CONTROL #define CONFIG_TAPE_NO_ERROR_CORRECTION diff --git a/c64/,,config_ultimate64.s b/c64/,,config_ultimate64.s index 0ba624d3..62e4d18b 100644 --- a/c64/,,config_ultimate64.s +++ b/c64/,,config_ultimate64.s @@ -50,6 +50,7 @@ #define CONFIG_TAPE_NORMAL #define CONFIG_TAPE_TURBO +#define CONFIG_TAPE_AUTODETECT // #define CONFIG_TAPE_NO_KEY_SENSE // #define CONFIG_TAPE_NO_MOTOR_CONTROL // #define CONFIG_TAPE_NO_ERROR_CORRECTION diff --git a/c64/kernal/tape/load_tape_normal.s b/c64/kernal/tape/load_tape_normal.s index 4fad6566..e9f9c733 100644 --- a/c64/kernal/tape/load_tape_normal.s +++ b/c64/kernal/tape/load_tape_normal.s @@ -33,10 +33,6 @@ // (L,S) = end-of-data marker -// XXX add error correction -// XXX implement proper takeover to turbo during sync/pilot - - #if CONFIG_TAPE_NORMAL @@ -50,25 +46,36 @@ load_tape_normal: jsr tape_common_prepare_cia jsr tape_ask_play + // FALLTROUGH + +load_tape_normal_header: + #else load_tape_normal_takeover: // entry point for turbo->normal takeover #endif - // FALLTROUGH - -load_tape_normal_header: - jsr load_MEMUSS_to_STAL // Try to load header into tape buffer (we will restore MEMUSS later) jsr tape_normal_get_pilot_header +#if CONFIG_TAPE_AUTODETECT + bcs load_tape_normal_switch_turbo // failed, try turbo +#endif jsr load_TAPE1_to_MEMUSS 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_AUTODETECT + bcs load_tape_normal_header // unable to read block, try again +#else + bcc !+ +load_tape_normal_switch_turbo: + jsr lvs_STAL_to_MEMUSS + jmp load_tape_turbo_takeover // unable to read block, try turbo instead +!: +#endif #if CONFIG_TAPE_NO_ERROR_CORRECTION lda RIPRTY @@ -77,11 +84,15 @@ load_tape_normal_header: 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 +#if !CONFIG_TAPE_AUTODETECT + bcs load_tape_normal_header // block load error, try again +#else + bcs load_tape_normal_switch_turbo // block load error, try turbo instead +#endif // Check header type - ldy #$00 // XXX probably can be optimized for 65C02 + ldy #$00 lda (TAPE1),y cmp #$05 @@ -90,7 +101,11 @@ load_tape_normal_header: cmp #$01 beq !+ cmp #$03 +#if !CONFIG_TAPE_AUTODETECT bne load_tape_normal_header // header types 1 and 3 are loadable, see Mapping the C64, page 77 +#else + bne load_tape_normal_takeover +#endif lda #$01 sta SA // this file is non-relocatable; override secondary address with 1 @@ -99,7 +114,11 @@ load_tape_normal_header: jsr lvs_STAL_to_MEMUSS jsr tape_handle_header +#if !CONFIG_TAPE_AUTODETECT bcs load_tape_normal_header // if name does not match, look for other header +#else + bcs load_tape_normal_takeover +#endif // FALLTROUGH diff --git a/c64/kernal/tape/load_tape_turbo.s b/c64/kernal/tape/load_tape_turbo.s index 7f8a3d9d..88feba45 100644 --- a/c64/kernal/tape/load_tape_turbo.s +++ b/c64/kernal/tape/load_tape_turbo.s @@ -37,7 +37,7 @@ load_tape_auto: #if CONFIG_TAPE_AUTODETECT -load_tape_turbo_takeover: // entry point for turbo->normal takeover +load_tape_turbo_takeover: // entry point for normal->turbo takeover jsr tape_common_autodetect bcc_16 load_tape_normal_takeover diff --git a/c64/kernal/tape/tape_common_autodetect.s b/c64/kernal/tape/tape_common_autodetect.s index 7ce2b048..88e87310 100644 --- a/c64/kernal/tape/tape_common_autodetect.s +++ b/c64/kernal/tape/tape_common_autodetect.s @@ -8,9 +8,6 @@ // Carry clear - normal, Carry set - turbo // -// XXX implement fallback to autodetection in normal - - #if CONFIG_TAPE_AUTODETECT diff --git a/c64/kernal/tape/tape_normal_get_pilot.s b/c64/kernal/tape/tape_normal_get_pilot.s index 801a2fb1..17734f33 100644 --- a/c64/kernal/tape/tape_normal_get_pilot.s +++ b/c64/kernal/tape/tape_normal_get_pilot.s @@ -16,8 +16,6 @@ #if CONFIG_TAPE_NORMAL -// XXX in tape_normal_get_pilot_header also try to detect turbo - tape_normal_get_pilot_header: // entry point, reset calibration, require 128x $40 pulses // Reading the pilot header is the first action performed, @@ -71,9 +69,14 @@ tape_normal_get_pilot_common_loop_outer: tape_normal_get_pilot_common_loop_inner: jsr tape_common_get_pulse - // XXX check for short pulses of turbo here bcc tape_normal_get_pilot_common_restart // not a pilot - try again - + +#if CONFIG_TAPE_AUTODETECT + // Try to distinguish turbo by cheecking for short signals + cmp #$B9 // see comment in tape_common_autodetect.s + bcs !+ +#endif + jsr tape_normal_calibrate_during_pilot dey @@ -82,6 +85,8 @@ tape_normal_get_pilot_common_loop_inner: dec ROPRTY bne tape_normal_get_pilot_common_loop_outer + clc +!: rts