From 8b0eff74a204a54a2917d2a2d91910acb74e7450 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 18 Dec 2019 21:45:13 +0100 Subject: [PATCH] slightly more precise pulse measurement --- c64/kernal/tape/load_tape_normal.s | 2 +- c64/kernal/tape/tape_normal_get_byte.s | 2 +- c64/kernal/tape/tape_normal_get_pulse.s | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/c64/kernal/tape/load_tape_normal.s b/c64/kernal/tape/load_tape_normal.s index 77a2e95d..9cec4f7d 100644 --- a/c64/kernal/tape/load_tape_normal.s +++ b/c64/kernal/tape/load_tape_normal.s @@ -49,7 +49,7 @@ load_tape_normal: // Let timer A run continuously ldx #%00010001 // start timer, force latch reload - stx CIA2_CRA // $DD0E + stx CIA2_CRA // $DD0E // Start playing jsr tape_ask_play diff --git a/c64/kernal/tape/tape_normal_get_byte.s b/c64/kernal/tape/tape_normal_get_byte.s index 6be83c1a..2188c4a3 100644 --- a/c64/kernal/tape/tape_normal_get_byte.s +++ b/c64/kernal/tape/tape_normal_get_byte.s @@ -20,7 +20,7 @@ tape_normal_get_byte: // First we need a byte marker - (L,M) !: jsr tape_normal_get_pulse - cmp #($100 - $95 - $05) + cmp #($100 - $95 - $04) bcs !- // too short for a long pulse jsr tape_normal_get_pulse bcs !- // too short for a medium pulse diff --git a/c64/kernal/tape/tape_normal_get_pulse.s b/c64/kernal/tape/tape_normal_get_pulse.s index 6d59b1a4..8d08b380 100644 --- a/c64/kernal/tape/tape_normal_get_pulse.s +++ b/c64/kernal/tape/tape_normal_get_pulse.s @@ -32,11 +32,12 @@ tape_normal_get_pulse: // lda - 4 cycles // ldx - 2 cycles // stx - 4 cycles - // plus approx. 3 cycles (bit + beq time divided by 2) from value change to 'bit' instruction, - // this is total 19 cycles, or $5 periods of 4 ticks (timer A) each - we need to take it into account + // plus average 3 cycles (bit + beq time divided by 2) from value change to 'bit' instruction + // minus average 2 cycles due to timer A running continouslyy (might start before the pulse) + // this is total 17 cycles, or $4 periods of 4 ticks (timer A) each - we need to take it into account // every time we check the pulse length - cmp #($100 - $6C - $05) // short vs medium is the default check + cmp #($100 - $6C - $04) // short vs medium is the default check rts