some more turbo tape autocalibration fixes
This commit is contained in:
1 parent
63c0404313
commit
f922f90653
1 file changed
+57
-25
@@ -16,26 +16,12 @@
|
|||||||
tape_turbo_sync_header:
|
tape_turbo_sync_header:
|
||||||
|
|
||||||
|
|
||||||
#if CONFIG_TAPE_TURBO_AUTOCALIBRATE
|
#if !CONFIG_TAPE_TURBO_AUTOCALIBRATE
|
||||||
|
|
||||||
// Initial pulse threshold
|
|
||||||
lda #$BF // auto-calibration under VICE often returns this value
|
|
||||||
sta IRQTMP+0
|
|
||||||
|
|
||||||
// Zero temporary stack area
|
|
||||||
lda #$00
|
|
||||||
ldy #$03
|
|
||||||
!:
|
|
||||||
sta STACK, y
|
|
||||||
dey
|
|
||||||
bpl !-
|
|
||||||
|
|
||||||
#endif // CONFIG_TAPE_TURBO_AUTOCALIBRATE
|
|
||||||
|
|
||||||
// Synchronize with start of sync sequence
|
// Synchronize with start of sync sequence
|
||||||
jsr tape_turbo_sync_first
|
jsr tape_turbo_sync_first
|
||||||
|
|
||||||
// Perform synchronization
|
// Perform synchronization, double loop, total $C0 * $04 iterations
|
||||||
ldx #$C0
|
ldx #$C0
|
||||||
!:
|
!:
|
||||||
phx_trash_a
|
phx_trash_a
|
||||||
@@ -51,20 +37,57 @@ tape_turbo_sync_header:
|
|||||||
dex
|
dex
|
||||||
bne !--
|
bne !--
|
||||||
|
|
||||||
// FALLTROUGH
|
#else // CONFIG_TAPE_TURBO_AUTOCALIBRATE
|
||||||
|
|
||||||
#if CONFIG_TAPE_TURBO_AUTOCALIBRATE
|
// Initial pulse threshold
|
||||||
|
lda #$BF // auto-calibration under VICE often returns this value
|
||||||
|
sta IRQTMP+0
|
||||||
|
|
||||||
tape_turbo_sync_calibrate:
|
// Zero temporary stack area
|
||||||
|
lda #$00
|
||||||
|
ldy #$03
|
||||||
|
!:
|
||||||
|
sta STACK, y
|
||||||
|
dey
|
||||||
|
bpl !-
|
||||||
|
|
||||||
ldy #$80
|
// Synchronize with start of sync sequence
|
||||||
|
jsr tape_turbo_sync_first
|
||||||
|
|
||||||
|
// Perform synchronization, get measurements from 128 bytes
|
||||||
|
ldx #$10
|
||||||
|
|
||||||
// FALLTROUGH
|
// FALLTROUGH
|
||||||
|
|
||||||
tape_turbo_sync_calibrate_loop:
|
tape_turbo_sync_outer_loop:
|
||||||
|
|
||||||
|
// Set .Y (inner loop counter) to $28-$38, average $30; $10 * $30 equals $C0 * $04
|
||||||
|
// We want a bit of irregularity with byte selection for calibration
|
||||||
|
txa
|
||||||
|
pha // store .X
|
||||||
|
clc
|
||||||
|
adc #$27
|
||||||
|
tay
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
tape_turbo_sync_inner_loop:
|
||||||
|
|
||||||
|
cpy #$09
|
||||||
|
bcc !+ // if inner couter is 8 or lower, get this byte for measurement
|
||||||
|
|
||||||
|
// Get byte without measurements
|
||||||
|
jsr tape_turbo_get_byte
|
||||||
|
cmp #$02
|
||||||
|
bne tape_turbo_sync_header // branch if failure
|
||||||
|
beq tape_turbo_sync_header_next_iter // branch always
|
||||||
|
|
||||||
|
!:
|
||||||
|
// Get byte and take measurements
|
||||||
|
|
||||||
// Skip 5 bits
|
|
||||||
phy_trash_a
|
phy_trash_a
|
||||||
|
|
||||||
|
// Skip 5 bits, they should be all 0
|
||||||
ldy #$04
|
ldy #$04
|
||||||
!:
|
!:
|
||||||
jsr tape_turbo_get_bit
|
jsr tape_turbo_get_bit
|
||||||
@@ -72,13 +95,22 @@ tape_turbo_sync_calibrate_loop:
|
|||||||
dey
|
dey
|
||||||
bpl !-
|
bpl !-
|
||||||
|
|
||||||
|
// Get measurements from 3 bits
|
||||||
jsr tape_turbo_sync_measure_0
|
jsr tape_turbo_sync_measure_0
|
||||||
jsr tape_turbo_sync_measure_1
|
jsr tape_turbo_sync_measure_1
|
||||||
jsr tape_turbo_sync_measure_0
|
jsr tape_turbo_sync_measure_0
|
||||||
|
|
||||||
ply_trash_a
|
ply_trash_a
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
tape_turbo_sync_header_next_iter:
|
||||||
|
|
||||||
dey
|
dey
|
||||||
bne tape_turbo_sync_calibrate_loop
|
bne tape_turbo_sync_inner_loop
|
||||||
|
plx_trash_a
|
||||||
|
dex
|
||||||
|
bne tape_turbo_sync_outer_loop
|
||||||
|
|
||||||
// Calculate new pulse threshold as arithmetic mean
|
// Calculate new pulse threshold as arithmetic mean
|
||||||
// We accumulated 256 zeros and 128 ones, so calculating average value is easy
|
// We accumulated 256 zeros and 128 ones, so calculating average value is easy
|
||||||
@@ -90,10 +122,10 @@ tape_turbo_sync_calibrate_loop:
|
|||||||
adc STACK+1
|
adc STACK+1
|
||||||
sta IRQTMP+0
|
sta IRQTMP+0
|
||||||
|
|
||||||
// FALLTROUGH
|
|
||||||
|
|
||||||
#endif // CONFIG_TAPE_TURBO_AUTOCALIBRATE
|
#endif // CONFIG_TAPE_TURBO_AUTOCALIBRATE
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
tape_turbo_sync_payload:
|
tape_turbo_sync_payload:
|
||||||
|
|
||||||
jsr tape_turbo_sync_first
|
jsr tape_turbo_sync_first
|
||||||
|
|||||||
Reference in new issue
Block a user