improved tape system autodetection
This commit is contained in:
1 parent
854f03ef84
commit
82347a8b17
11 files changed
+112
-30
No files matched your search
@@ -5,13 +5,13 @@
|
||||
//
|
||||
// Tries to detect
|
||||
//
|
||||
// Carry clear - NORMAL, Carry set - TURBO
|
||||
// Carry clear - normal, Carry set - turbo
|
||||
//
|
||||
|
||||
// XXX implement fallback to autodetection, correct screen color for NORMAL
|
||||
// XXX implement fallback to autodetection in normal
|
||||
|
||||
|
||||
#if CONFIG_TAPE_NORMAL && CONFIG_TAPE_TURBO && CONFIG_TAPE_AUTODETECT
|
||||
#if CONFIG_TAPE_AUTODETECT
|
||||
|
||||
|
||||
tape_common_autodetect:
|
||||
@@ -26,18 +26,18 @@ tape_common_autodetect:
|
||||
|
||||
tape_common_autodetect_retry:
|
||||
|
||||
// It is not trivial to distinguish between NORMAL and TURBO,
|
||||
// as short pulses of NORMAL (and sync uses only shorts)
|
||||
// have similar lengths as long pulses of TURBO
|
||||
// It is not trivial to distinguish between normal and turbo,
|
||||
// as short pulses of normal (and sync uses only shorts)
|
||||
// have similar lengths as long pulses of turbo
|
||||
|
||||
// Thus, the routine here reads certain amount of pulses
|
||||
// looking for evidence for either NORMAL or TURBO system;
|
||||
// in case of no evidence found, assume NORMAL
|
||||
// looking for evidence for either normal or turbo system;
|
||||
// in case of no evidence found, assume normal
|
||||
|
||||
lda #$00 // plus = probably NORMAL, minus = TURBO
|
||||
lda #$00 // plus = probably normal, minus = turbo
|
||||
sta XSAV
|
||||
|
||||
ldy #$60 // $60 pulses cover 12 bytes of TURBO recording
|
||||
ldy #$60 // $60 pulses cover 12 bytes of turbo recording
|
||||
jsr tape_normal_get_pulse // first pulse might be a garbage, ignore it
|
||||
|
||||
// FALLTROUGH
|
||||
@@ -52,24 +52,24 @@ tape_common_autodetect_loop:
|
||||
cmp #$E8
|
||||
bcs tape_common_autodetect_retry // this is a VERY short pulse
|
||||
|
||||
// First try to distinguish TURBO short signal (reference: $CD)
|
||||
// from NORMAL signals (reference: $A5 or lower), these values
|
||||
// First try to distinguish turbo short signal (reference: $CD)
|
||||
// from normal signals (reference: $A5 or lower), these values
|
||||
// give us threshold of ($CD + $A5) / 2 = $B9
|
||||
|
||||
cmp #$B9
|
||||
bcc !+
|
||||
dec XSAV // above $B9 (so signal is shorter), looks like TURBO
|
||||
dec XSAV // above $B9 (so signal is shorter), looks like turbo
|
||||
!:
|
||||
// Now try to distinguish TURBO signals (reference: $B1 or higher)
|
||||
// from NORMAL medium/long signals (reference: $7D or below), these values
|
||||
// Now try to distinguish turbo signals (reference: $B1 or higher)
|
||||
// from normal medium/long signals (reference: $7D or below), these values
|
||||
// give us threshold of ($B1 + $7D) / 2 = $97
|
||||
|
||||
cmp #$97
|
||||
bcs !+
|
||||
inc XSAV
|
||||
!:
|
||||
// The sync for TURBO is not too long - if we have enough evidence,
|
||||
// assume TURBO recording already
|
||||
// The sync for turbo is not too long - if we have enough evidence,
|
||||
// assume turbo recording already
|
||||
|
||||
lda XSAV
|
||||
cmp #$FD
|
||||
@@ -79,7 +79,7 @@ tape_common_autodetect_loop:
|
||||
dey
|
||||
bpl tape_common_autodetect_loop
|
||||
|
||||
// Last chance for TURBO
|
||||
// Last chance for turbo
|
||||
|
||||
lda XSAV
|
||||
bmi tape_common_autodetect_turbo
|
||||
|
||||
Reference in new issue
Block a user