As I understand it, the Vic-20 reads and writes the cassette deck by the low-tech expedient of just using the CPU to bit-bang a one-bit serial line. This presumably means that for a given code sequence, the cassette baud rate depends on the CPU clock speed.

Is there any way, on a stock Vic-20, to write a cassette tape such that it will be written at the same baud rate even if the CPU speed varies, e.g. if it were overclocked?

  • Empirically, tape I/O speed is software dependent, like all software codecs.
    – Brian H
    Jan 6, 2020 at 20:44

1 Answer 1


You're in luck — I believe that tape reading and writing is already CPU speed independent.

For reading, the 1-bit tape input is provided as the CA1 input to the keyboard VIA. The OS sets it up to generate an interrupt on its rising edge. At each interrupt it interrogates the VIA's timer to determine how long the most recent wave was.

So as long as you don't change the VIA clock speed, the CPU speed shouldn't matter.

See the routine from LAB_F98E in this disassembly which, as it purports to be, is the routine called by a relevant input-level transition interrupt, and interrogates the second timer of the keyboard VIA, VIA 2 in order to discriminate the wave just seen.

I'm a little vaguer on it, but I believe the same mechanism in reverse is used to write bytes — looking at LAB_FBF5 and calls into it, the procedure seems to be to toggle the output and establish a VIA timer interrupt for when the next toggle should occur.

  • 1
    Given the significant differences between the three pulse lengths, why is it necessary for the C64 to blank the screen when reading a cassette? When writing it certainly makes sense to minimize disturbance, but when reading I would think that a badline should cause at most 43 cycles of uncertainty on pulse widths measurements that should tolerate 80us of uncertainty if compares received widths against 432us and 592us.
    – supercat
    Feb 25, 2020 at 21:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .