turbo tape can now adjust itself for tape motor speed

This commit is contained in:
FeralChild64 committed 2020-01-14 16:22:30 +01:00
1 parent 723a7772fa
commit 9061a8d0fc
18 files changed
+206 -62

No files matched your search

+62 -2
View File
@@ -22,18 +22,78 @@ tape_turbo_sync_common:
tape_turbo_sync_header:
ldx #$FF
!:
#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
// Perform synchronization
ldx #$C0
!:
phx_trash_a
ldy #$04
!:
jsr tape_turbo_sync_common
dey
bne !-
plx_trash_a
dex
bne !--
// FALLTROUGH
#if CONFIG_TAPE_TURBO_AUTOCALIBRATE
tape_turbo_sync_calibrate:
ldy #$80
// FALLTROUGH
tape_turbo_sync_calibrate_loop:
// Skip 5 bits
phy_trash_a
ldy #$04
!:
jsr tape_turbo_get_bit
bcs tape_turbo_sync_header
dey
bpl !-
jsr tape_turbo_sync_measure_0
jsr tape_turbo_sync_measure_1
jsr tape_turbo_sync_measure_0
ply_trash_a
dey
bne tape_turbo_sync_calibrate_loop
// Calculate new pulse threshold as arithmetic mean
// We accumulated 256 zeros and 128 ones, so calculating average value is easy
lda STACK+0
clc
ror
clc
adc STACK+1
sta IRQTMP+0
// FALLTROUGH
#endif // CONFIG_TAPE_TURBO_AUTOCALIBRATE
tape_turbo_sync_payload:
jsr tape_turbo_sync_common