more work towards tape error correction

This commit is contained in:
FeralChild64 committed 2020-01-23 21:35:05 +01:00
1 parent 136cb528f7
commit 28a96a7ffc
4 files changed
+91 -61

No files matched your search

+23 -10
View File
@@ -62,16 +62,15 @@ load_tape_normal_header:
// Try to load header into tape buffer (we will restore MEMUSS later) // Try to load header into tape buffer (we will restore MEMUSS later)
lda TAPE1+1
sta MEMUSS+1
lda TAPE1+0
sta MEMUSS+0
// Retrieve the header
jsr tape_normal_get_pilot_header jsr tape_normal_get_pilot_header
jsr tape_normal_get_data
bcs load_tape_normal_header // unable to read block, try again XXX restore MEMUSS and jump to turbo detection jsr load_tape_normal_buf_MEMUSS
jsr tape_normal_get_data_1
bcs load_tape_normal_header // unable to read block, try again XXX jump to turbo detection
jsr load_tape_normal_buf_MEMUSS
jsr tape_normal_get_data_2
bcs load_tape_normal_header // block load error, try again XXX jump to turbo detection
// Check header type // Check header type
@@ -103,13 +102,27 @@ load_tape_normal_payload:
jsr tape_normal_get_pilot_data jsr tape_normal_get_pilot_data
ldy #$00 // no data size limit ldy #$00 // no data size limit
jsr tape_normal_get_data jsr tape_normal_get_data_1
bcs_16 tape_load_error bcs_16 tape_load_error
jsr lvs_check_EAL jsr lvs_check_EAL
bne_16 tape_load_error // amount of data read does not match header info bne_16 tape_load_error // amount of data read does not match header info
// XXX setup MEMUSS once again
jsr tape_normal_get_data_2
bcs_16 tape_load_error
jmp tape_load_success jmp tape_load_success
load_tape_normal_buf_MEMUSS: // set MEMUSS (start address) as tape buffer
lda TAPE1+1
sta MEMUSS+1
lda TAPE1+0
sta MEMUSS+0
rts
#endif #endif
+1 -1
View File
@@ -160,7 +160,7 @@ tape_handle_header:
sbc STAL+1 sbc STAL+1
sta EAL+1 sta EAL+1
// STAL = MEMUSS // STAL = MEMUSS XXX is it needed?
lda MEMUSS+0 lda MEMUSS+0
sta STAL+0 sta STAL+0
@@ -3,7 +3,7 @@
// #LAYOUT# * * #IGNORE // #LAYOUT# * * #IGNORE
// //
// Tape (normal) helper routine - data block reading // Tape (normal) helper routine - data block (primary) reading
// //
// Stores data starting from MEMUSS, Carry set means error, on 0 bit .A is 0 too // Stores data starting from MEMUSS, Carry set means error, on 0 bit .A is 0 too
// .Y not equal to 0 - returns error if data block is longer (length includes checksum) // .Y not equal to 0 - returns error if data block is longer (length includes checksum)
@@ -15,7 +15,7 @@
#if CONFIG_TAPE_NORMAL #if CONFIG_TAPE_NORMAL
tape_normal_get_data: tape_normal_get_data_1:
// Initialize checksum (RIPRTY, see http://sta.c64.org/cbm64mem.html) // Initialize checksum (RIPRTY, see http://sta.c64.org/cbm64mem.html)
// and pointers for error log and correction mechanism // and pointers for error log and correction mechanism
@@ -26,7 +26,7 @@ tape_normal_get_data:
// FALLTROUGH // FALLTROUGH
tape_normal_get_data_block_1: tape_normal_get_data_1_block:
// //
// Read the 1st copy of the block // Read the 1st copy of the block
@@ -35,19 +35,19 @@ tape_normal_get_data_block_1:
// Read sync of the block // Read sync of the block
ldy #$89 ldy #$89
jsr tape_normal_sync jsr tape_normal_sync
bcs tape_normal_get_data_fail bcs tape_normal_get_data_1_fail
jsr tape_normal_get_marker jsr tape_normal_get_marker
tape_normal_get_data_loop_1: tape_normal_get_data_1_loop:
jsr tape_normal_get_byte jsr tape_normal_get_byte
bcc tape_normal_get_data_loop_1_byte_OK bcc tape_normal_get_data_1_loop_byte_OK
// Problem reading a byte, try to add it to the error log // Problem reading a byte, try to add it to the error log
tsx tsx
cpx #$20 // just to be on a safe side cpx #$20 // just to be on a safe side
bcc tape_normal_get_data_fail // branch if no more space in error log bcc tape_normal_get_data_1_fail // branch if no more space in error log
ldx PTR1 ldx PTR1
lda MEMUSS+0 lda MEMUSS+0
@@ -60,18 +60,17 @@ tape_normal_get_data_loop_1:
// Addres added to error log, check if this was a checksum // Addres added to error log, check if this was a checksum
jsr tape_normal_get_marker jsr tape_normal_get_marker
bcc tape_normal_get_data_loop_1_advance bcc tape_normal_get_data_1_loop_advance
bcs tape_normal_get_data_block_2 bcs tape_normal_get_data_1_success
tape_normal_get_data_1_loop_byte_OK:
tape_normal_get_data_loop_1_byte_OK:
jsr tape_normal_get_marker jsr tape_normal_get_marker
bcc !+ bcc !+
// End of the block // End of the block
jsr tape_normal_update_checksum jsr tape_normal_update_checksum
jmp tape_normal_get_data_block_2 jmp tape_normal_get_data_1_success
!: !:
// Store byte, calculate checksum // Store byte, calculate checksum
@@ -82,7 +81,7 @@ tape_normal_get_data_loop_1_byte_OK:
// FALLTROUGH // FALLTROUGH
tape_normal_get_data_loop_1_advance: tape_normal_get_data_1_loop_advance:
// Advance pointer // Advance pointer
#if !HAS_OPCODES_65CE02 #if !HAS_OPCODES_65CE02
@@ -91,48 +90,15 @@ tape_normal_get_data_loop_1_advance:
inw MEMUSS+0 inw MEMUSS+0
#endif #endif
jmp tape_normal_get_data_loop_1 jmp tape_normal_get_data_1_loop
tape_normal_get_data_block_2: tape_normal_get_data_1_success:
//
// Read the 2nd copy of the block
//
// First check if there is a need to read anything
// XXX
// Read sync of the block
ldy #$09
jsr tape_normal_sync
bcs tape_normal_get_data_fail
jsr tape_normal_get_marker
// XXX implement the second pass
lda PTR1
beq tape_normal_get_data_checksum
jmp tape_normal_get_data_fail
tape_normal_get_data_checksum:
lda RIPRTY
cmp #$01 // sets Carry if checksum verification fails
// FALLTROUGH
tape_normal_get_data_done:
clc
rts rts
tape_normal_get_data_fail: tape_normal_get_data_1_fail:
sec sec
rts rts
+51
View File
@@ -0,0 +1,51 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Tape (normal) helper routine - data block (backup) reading
//
#if CONFIG_TAPE_NORMAL
tape_normal_get_data_2:
// First check if there is a need to read anything
lda PTR1
beq tape_normal_get_data_2_checksum
// Read sync of the block
ldy #$09
jsr tape_normal_sync
bcs tape_normal_get_data_2_done // Carry already set, will indicate error
jsr tape_normal_get_marker
// FALLTROUGH
tape_normal_get_data_2_loop:
// XXX read missing bytes
sec
rts
tape_normal_get_data_2_checksum:
// Validate checksum
lda RIPRTY
cmp #$01 // sets Carry if checksum verification fails
// FALLTROUGH
tape_normal_get_data_2_done:
rts
#endif