diff --git a/CONFIG.md b/CONFIG.md index 13effa95..31c8437a 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -119,6 +119,12 @@ Adds support for JiffyDOS fast protocol to the IEC bus. Needs about 430 bytes in KERNAL segment. If unsure - enable. +### `CONFIG_TAPE_LOAD` + +Adds a minimal normal (standard Commodore format) tape support - just LOAD command. + +Needs some space in KERNAL segment. If unsure - enable. + ### `CONFIG_TAPE_TURBO` Adds a minimal turbo tape support - just LOAD command (device 7, like on _Action Replay_ and _Final_ cartridges) diff --git a/STATUS.md b/STATUS.md index 110815b5..31ed9acc 100644 --- a/STATUS.md +++ b/STATUS.md @@ -52,7 +52,7 @@ The following ROM features are currently missing: | Driver | Status | Remarks | | :-----------: | :------: | :------------------------------------------------: | -| normal | NOT DONE | | +| normal | PARITAL | works, but needs improvements, no error correction | | turbo | PARTIAL | works, to do: use sync to calibrate read speed | ## IEC bus (disk drives, etc.) diff --git a/bin/basic_generic.rom b/bin/basic_generic.rom index e5b98544..b616aec8 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 0f7c76c6..1b0d3c9b 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 55d8b492..d9a7f638 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 06c23b71..3ce521dd 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 b34d40ec..286dfc4b 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 c1d6bd4f..7d3f9735 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 aad0e85b..1db906dc 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 b3e0bc11..226ad47a 100644 --- a/c64/,,config_custom.s +++ b/c64/,,config_custom.s @@ -11,6 +11,7 @@ // - file contains options to enable unfinished functionalities + // Hardware platform and brand #define CONFIG_PLATFORM_COMMODORE_64 @@ -48,7 +49,7 @@ // #define CONFIG_IEC_DOLPHINDOS // please keep disabled for now #define CONFIG_IEC_JIFFYDOS -#define CONFIG_TAPE_NORMAL // not finished yet! +#define CONFIG_TAPE_NORMAL #define CONFIG_TAPE_TURBO // #define CONFIG_RS232_UP2400 // please keep disabled for now diff --git a/c64/,,config_generic.s b/c64/,,config_generic.s index de3116f0..8049f2c2 100644 --- a/c64/,,config_generic.s +++ b/c64/,,config_generic.s @@ -11,6 +11,7 @@ // - do not enable features which are a significant compatibility risk + // Hardware platform and brand #define CONFIG_PLATFORM_COMMODORE_64 @@ -44,6 +45,7 @@ #define CONFIG_IEC_BLANK_SCREEN #define CONFIG_IEC_JIFFYDOS +#define CONFIG_TAPE_NORMAL #define CONFIG_TAPE_TURBO diff --git a/c64/,,config_mega65.s b/c64/,,config_mega65.s index 9d1e9de7..87586d45 100644 --- a/c64/,,config_mega65.s +++ b/c64/,,config_mega65.s @@ -11,6 +11,7 @@ // - do not enable features which are a significant compatibility risk + // Hardware platform and brand #define CONFIG_PLATFORM_COMMODORE_64 @@ -44,6 +45,7 @@ #define CONFIG_IEC_BLANK_SCREEN #define CONFIG_IEC_JIFFYDOS +// #define CONFIG_TAPE_NORMAL // #define CONFIG_TAPE_TURBO diff --git a/c64/,,config_testing.s b/c64/,,config_testing.s index 911c9d38..2134a928 100644 --- a/c64/,,config_testing.s +++ b/c64/,,config_testing.s @@ -43,15 +43,11 @@ #define CONFIG_IEC // #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 #define CONFIG_TAPE_TURBO -// #define CONFIG_RS232_UP2400 // please keep disabled for now -// #define CONFIG_RS232_UP9600 // please keep disabled for now - // Multiple SID support diff --git a/c64/,,config_ultimate64.s b/c64/,,config_ultimate64.s index 08741cab..4295ccdd 100644 --- a/c64/,,config_ultimate64.s +++ b/c64/,,config_ultimate64.s @@ -11,6 +11,7 @@ // - do not enable features which are a significant compatibility risk + // Hardware platform and brand #define CONFIG_PLATFORM_COMMODORE_64 @@ -44,10 +45,10 @@ #define CONFIG_IEC_BLANK_SCREEN #define CONFIG_IEC_JIFFYDOS +#define CONFIG_TAPE_NORMAL #define CONFIG_TAPE_TURBO - // Multiple SID support // #define CONFIG_SID_2ND diff --git a/c64/aliases/,aliases_config.s b/c64/aliases/,aliases_config.s index b3ff8bfe..e07297f0 100644 --- a/c64/aliases/,aliases_config.s +++ b/c64/aliases/,aliases_config.s @@ -297,13 +297,13 @@ .var features_str = "" #if CONFIG_TAPE_NORMAL && !CONFIG_TAPE_TURBO - .eval features_str = ADD_FEATURE(features_str, "TAPE LOAD NORMAL-DEV") + .eval features_str = ADD_FEATURE(features_str, "TAPE LOAD NORMAL") #endif #if !CONFIG_TAPE_NORMAL && CONFIG_TAPE_TURBO .eval features_str = ADD_FEATURE(features_str, "TAPE LOAD TURBO") #endif #if CONFIG_TAPE_NORMAL && CONFIG_TAPE_TURBO - .eval features_str = ADD_FEATURE(features_str, "TAPE LOAD NORMAL-DEV TURBO") + .eval features_str = ADD_FEATURE(features_str, "TAPE LOAD NORMAL 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 a28bea37..cd2b0254 100644 --- a/c64/kernal/tape/load_tape_normal.s +++ b/c64/kernal/tape/load_tape_normal.s @@ -63,6 +63,31 @@ load_tape_normal: load_tape_normal_header: +/* XXX try to reuse block retrieeval rooutine, like this: + + // Try to load header into tape buffer + + lda TAPE1+1 + sta MEMUSS+1 + lda TAPE1+0 + sta MEMUSS+0 + + // Initialize checksum (RIPRTY, see http://sta.c64.org/cbm64mem.html) + + lda #$00 + sta RIPRTY + + // Retrieve the header XXX limit it to 192 bytes + + jsr tape_normal_get_block + bcs load_tape_normal_header // unable to read block, try again + + // Handle the header + + jsr tape_handle_header + bcs load_tape_normal_header // if name does not match, look for other header +*/ + // Read pilot and sync of the first header jsr tape_normal_pilot @@ -117,9 +142,15 @@ load_tape_normal_header_loop: load_tape_normal_payload: - // Retrieve block + // Initialize checksum (RIPRTY, see http://sta.c64.org/cbm64mem.html) + + lda #$00 + sta RIPRTY - jsr tape_normal_get_block // XXX handle errors + // Retrieve data + + jsr tape_normal_get_data + bcs_far tape_load_error // Advance MEMUSS (see Mapping the C64, page 36), check if end @@ -130,9 +161,9 @@ load_tape_normal_payload: bcc !+ inc MEMUSS+1 !: - - jsr lvs_check_EAL - bne load_tape_normal_payload + // XXX check below does not work - why? + // jsr lvs_check_EAL + // bne_far tape_load_error // amount of data read does not match header info jmp tape_load_success diff --git a/c64/kernal/tape/tape_normal_get_block.s b/c64/kernal/tape/tape_normal_get_block.s deleted file mode 100644 index f4e3798d..00000000 --- a/c64/kernal/tape/tape_normal_get_block.s +++ /dev/null @@ -1,74 +0,0 @@ - -// -// Tape (normal) helper routine - block reading -// -// Stores data starting from MEMUSS, Carry set means error, on 0 bit .A is 0 too -// - - -// XXX does not detect block end - find out why -// XXX improve error handling - do not ignore second copy, handle damaged checksum byte, handle damaged sync part - - -tape_normal_get_block: - - // Read the pilot and sync of the block - - jsr tape_normal_pilot - ldy #$89 - jsr tape_normal_sync // XXX handle result - - // Initialize byte counter and block checksum (RIPRTY, see http://sta.c64.org/cbm64mem.html) - ldy #$00 - sty RIPRTY - -tape_normal_get_block_loop: - - jsr tape_normal_get_marker - bcs tape_normal_get_block_checksum // end of data for the block - jsr tape_normal_get_byte - - bcs tape_normal_get_block_done // error reading byte - fatal for now - - // Store byte, calculate checksum - sta (MEMUSS), y - eor RIPRTY - sta RIPRTY - - iny - bne tape_normal_get_block_loop - - // FALLTROUGH - if we are here, it means the block is too long - -tape_normal_get_block_done_fail: - - sec - rts - -tape_normal_get_block_checksum: -.break - jsr tape_normal_get_byte - bcs tape_normal_get_block_done // cannot get block checksum - fatal for now - - eor RIPRTY - cmp #$01 - bcs tape_normal_get_block_done // checksum error - fatal for now - - // Read trailing pulses - - jsr tape_normal_sync // XXX handle result - - // Read the pilot and sync of the backup block - - jsr tape_normal_pilot - ldy #$09 - jsr tape_normal_sync // XXX handle result - - // For now we ignore the backup block - clc - - // FALLTROUGH - -tape_normal_get_block_done: - - rts diff --git a/c64/kernal/tape/tape_normal_get_data.s b/c64/kernal/tape/tape_normal_get_data.s new file mode 100644 index 00000000..71efb6f7 --- /dev/null +++ b/c64/kernal/tape/tape_normal_get_data.s @@ -0,0 +1,80 @@ + +// +// Tape (normal) helper routine - data block reading +// +// Stores data starting from MEMUSS, Carry set means error, on 0 bit .A is 0 too +// + + +// XXX improve error handling - do not ignore second copy, handle damaged sync part + + +#if CONFIG_TAPE_NORMAL + + +tape_normal_get_data: + + // Read the pilot and sync of the block + + jsr tape_normal_pilot + ldy #$89 + jsr tape_normal_sync + bcs tape_normal_get_block_done // XXX make it more erroor resistant + + // Initialize byte counter + ldy #$00 + +tape_normal_get_data_loop: + + jsr tape_normal_get_marker + bcs tape_normal_get_data_2nd_copy // end of data for the block + jsr tape_normal_get_byte + + bcs tape_normal_get_block_done // error reading byte - fatal for now + + // Store byte, calculate checksum + sta (MEMUSS), y + eor RIPRTY + sta RIPRTY + + iny + bne tape_normal_get_data_loop + + // 256 bytes read + + inc MEMUSS+1 + jmp tape_normal_get_data_loop + +tape_normal_get_data_2nd_copy: + + // Read the pilot and sync of the block + + jsr tape_normal_pilot + ldy #$09 + jsr tape_normal_sync + bcs tape_normal_get_block_done // XXX make it more error resistant + + // For now skip the error correction data +!: + jsr tape_normal_get_marker + bcs tape_normal_get_checksum + jsr tape_normal_get_byte + tay + jmp !- + +tape_normal_get_checksum: + + tya + eor RIPRTY + cmp #$01 // sets Carry if checksum verification failed + + clc // XXX checksum calculation fails - why? + + // FALLTROUGH + +tape_normal_get_block_done: + + rts + + +#endif