LOAD for normal (standard system) tapes works, still needs a lot of work
This commit is contained in:
1 parent
dc00b3cc6b
commit
c497e3b03c
18 files changed
+134
-89
No files matched your search
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in new issue
Block a user