various tape loading fixes

This commit is contained in:
FeralChild64 committed 2019-12-24 21:07:55 +01:00
1 parent c497e3b03c
commit 8c8e18bb80
15 files changed
+127 -131

No files matched your search

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -136,7 +136,7 @@
.label FA = $BA // current device number
.label FNADDR = $BB // $BB-$BC current file name pointer
.label ROPRTY = $BD // -- NOT IMPLEMENTED -- tape / RS-232 temporary storage
.label FSBLK = $BE // -- NOT IMPLEMENTED --
.label FSBLK = $BE // -- NOT IMPLEMENTED -- tape / RS-232 temporary storage
.label MYCH = $BF // -- NOT IMPLEMENTED --
.label CAS1 = $C0 // tape motor interlock
.label STAL = $C1 // $C1-$C2 LOAD/SAVE start address
+6 -1
View File
@@ -85,7 +85,12 @@ iec_save_loop:
#endif
// Next iteration
jsr lvs_advance_MEMUSS_check_EAL
#if !HAS_OPCODES_65CE02
jsr lvs_advance_MEMUSS
#else
inw MEMUSS+0
#endif
jsr lvs_check_EAL
bne iec_save_loop
iec_save_loop_end:
+6 -10
View File
@@ -87,25 +87,22 @@ lvs_setup_MEMUSS:
#endif
#if CONFIG_TAPE_TURBO || CONFIG_IEC
#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO || CONFIG_IEC
lvs_advance_MEMUSS_check_EAL:
#if !HAS_OPCODES_65CE02
lvs_advance_MEMUSS:
// Advance pointer
#if !HAS_OPCODES_65CE02
inc MEMUSS+0
bne !+
inc MEMUSS+1
!:
#else
inw MEMUSS+0
rts
#endif
// FALLTROUGH
#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO || CONFIG_IEC
lvs_check_EAL:
lda MEMUSS+1
@@ -116,7 +113,6 @@ lvs_check_EAL:
!:
rts
#endif
lvs_display_searching_for:
+34 -72
View File
@@ -56,15 +56,21 @@ load_tape_normal:
ldx #%00010001 // start timer, force latch reload
stx CIA2_CRA // $DD0E
// Temporarily store MEMUSS in EAL
lda MEMUSS+1
sta EAL+1
lda MEMUSS+0
sta EAL+0
// Start playing
jsr tape_ask_play
// FALLTROUGH
load_tape_normal_header:
/* XXX try to reuse block retrieeval rooutine, like this:
// Try to load header into tape buffer
lda TAPE1+1
@@ -72,66 +78,36 @@ load_tape_normal_header:
lda TAPE1+0
sta MEMUSS+0
// Initialize checksum (RIPRTY, see http://sta.c64.org/cbm64mem.html)
lda #$00
sta RIPRTY
// Retrieve the header
// Retrieve the header XXX limit it to 192 bytes
jsr tape_normal_get_block
jsr tape_normal_pilot_header
jsr tape_normal_get_data // XXX limit it to 192 bytes
bcs load_tape_normal_header // unable to read block, try again
// Handle the header
// Check header type
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
ldy #$89
jsr tape_normal_sync
bcs load_tape_normal_header
ldy #$00
// FALLTROUGH
load_tape_normal_header_loop:
// Read the header
jsr tape_normal_get_marker // XXX handle result
jsr tape_normal_get_byte // XXX handle errors
sta (TAPE1), y
iny
cpy #$15
bne load_tape_normal_header_loop
// Read pilot and sync of the second header
jsr tape_normal_pilot
ldy #$09
jsr tape_normal_sync
bcs load_tape_normal_header
// XXX do not skip second header, use it to correct data
ldy #$15
!:
jsr tape_normal_get_marker
jsr tape_normal_get_byte
dey
bne !-
// For now only one type of header is supported
ldy #$00
ldy #$00 // XXX probably can be optimized for 65C02
lda (TAPE1),y
cmp #$05
beq_far tape_load_error // end of tape mark, nothing to load
cmp #$01
bne load_tape_normal_header // XXX also handle other header types, see Mapping the C64 page 77
beq !+
cmp #$03
bne load_tape_normal_header // header types 1 and 3 are loadable, see Mapping the C64, page 77
// XXX handle non-relocatable program, header type 3
!:
// Handle the header
// Restore MEMUSS
lda EAL+1
sta MEMUSS+1
lda EAL+0
sta MEMUSS+0
// Handle the header
@@ -142,28 +118,14 @@ load_tape_normal_header_loop:
load_tape_normal_payload:
// Initialize checksum (RIPRTY, see http://sta.c64.org/cbm64mem.html)
lda #$00
sta RIPRTY
// Retrieve data
jsr tape_normal_pilot_data
jsr tape_normal_get_data
bcs_far tape_load_error
// Advance MEMUSS (see Mapping the C64, page 36), check if end
tya
clc
adc MEMUSS+0
sta MEMUSS+0
bcc !+
inc MEMUSS+1
!:
// 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
jsr lvs_check_EAL
bne_far tape_load_error // amount of data read does not match header info
jmp tape_load_success
+7 -2
View File
@@ -64,7 +64,7 @@ load_tape_turbo_header_loop:
// Handle the header
jsr tape_clean_sid
jsr tape_handle_header
jsr tape_handle_header // XXX handle non-relocatable programs - any non-0 even header type
bcs load_tape_turbo_header // if name does not match, look for other header
// FALLTROUGH
@@ -91,7 +91,12 @@ load_tape_turbo_loop:
sta PRTY
// Advance MEMUSS (see Mapping the C64, page 36)
jsr lvs_advance_MEMUSS_check_EAL
#if !HAS_OPCODES_65CE02
jsr lvs_advance_MEMUSS
#else
inw MEMUSS+0
#endif
jsr lvs_check_EAL
bne load_tape_turbo_loop
// Get the checksum
+1 -1
View File
@@ -2,7 +2,7 @@
//
// Tape (normal) helper routine - byte reading
//
// Returns byte in .A, Carry flag set = error
// Returns byte in .A (also sotred in INBIT), Carry flag set = error
//
+19 -34
View File
@@ -14,61 +14,46 @@
tape_normal_get_data:
// Initialize checksum (RIPRTY, see http://sta.c64.org/cbm64mem.html)
lda #$00
sta RIPRTY
// 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
jsr tape_normal_get_marker
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
jsr tape_normal_get_marker
bcs tape_normal_get_checksum // end of data for the block
// Store byte, calculate checksum
lda INBIT
ldy #$00 // XXX probably can be optimized for 65C02
sta (MEMUSS), y
eor RIPRTY
sta RIPRTY
iny
bne tape_normal_get_data_loop
// Advance pointer
#if !HAS_OPCODES_65CE02
jsr lvs_advance_MEMUSS
#else
inw MEMUSS+0
#endif
// 256 bytes read
inc MEMUSS+1
jmp tape_normal_get_data_loop
tape_normal_get_data_2nd_copy:
tape_normal_get_checksum: // XXX handle second copy, with pilot starting from $09
// 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
lda INBIT
eor RIPRTY
cmp #$01 // sets Carry if checksum verification failed
clc // XXX checksum calculation fails - why?
cmp #$01 // sets Carry if checksum verification fails
// FALLTROUGH
+53 -10
View File
@@ -3,27 +3,70 @@
// Tape (turbo) helper routine - handling the pilot
//
// Injest the pilot - series of short pulses. According to http://sidpreservation.6581.org/tape-format/
// it consist of the following number of pulses:
// - $6A00 for header
// - $1A00 for data and seq block header
// - $4F for repeated header/data
#if CONFIG_TAPE_NORMAL
tape_normal_pilot:
// Injest the pilot - series of short pulses. According to http://sidpreservation.6581.org/tape-format/
// it consist of the foollowing number of pulses:
// - $6A00 for header
// - $1A00 for data and seq block header
// - $4F for repeated header/data
tape_normal_pilot_short: // require 1x $40 pulses
lda #$01
// FALLTROUGH
tape_normal_pilot_common:
sta FSBLK
// FALLTROUGH
tape_normal_pilot_common_restart:
lda FSBLK
sta ROPRTY
// FALLTROUGH
tape_normal_pilot_common_loop_outer:
ldy #$40
// FALLTROUGH
tape_normal_pilot_common_loop_inner:
ldy #$05 // this should be enough
!:
jsr tape_normal_get_pulse
bcc tape_normal_pilot // not a pilot - try again
bcc tape_normal_pilot_common_restart // not a pilot - try again
dey
bne !-
bne tape_normal_pilot_common_loop_inner
dec ROPRTY
bne tape_normal_pilot_common_loop_outer
rts
tape_normal_pilot_data: // require 4x $40 pulses
lda #$04
skip_2_bytes_trash_nvz
// FALLTROUGH
tape_normal_pilot_header: // require 128x $40 pulses
lda #$80
jmp tape_normal_pilot_common // XXX calibrate tape speeed afterwards
#endif