[Coco] It's a small win, but a win nonetheless

RETRO Innovations go4retro at go4retro.com
Sun Mar 12 23:32:31 EDT 2017


A bit of an update

After spending *ALL AFTERNOON* on it, I finally have a nice piece of 
optimized C that reliably handle the Coco cassette stream and uses 
interrupts to keep it out of the way of the main code.  I must have 
written 9 different sets of codebases to get one that works, that I know 
exactly how it works, and it works reliably (no more 0xaa)

Some notes:

  * One has to count the entire period of the bit transmissions, in case
    the comparator is set outside the middle of the voltage swing. 
    Otherwise, the code risks seeing a lopsided duty cycle (1/4 on, 3/4
    off), which will make 1's look like 0's, or vice versa.  I did not
    have this issue, but counting the entire period creates another problem
  * After the first batch of data, the waveform goes low, and that looks
    like a really long half cycle to the code.  Since the code has to
    use the transition from the last bit to the next one, it misses the
    last bit.  I picked it up by letting the counter time out, and
    checking if I was at bit 7.  if so, finish up the byte and store
    it.  There's a small bug here in that it makes it impossible to know
    the last bit, but since TANDY ends each segment with an 0x55, it's
    not horrible at present, just use 0. I'll probably clean this up as
    I learn more.  I wonder how the Coco handles the transition from the
    last part of the last cycle of data and the beginning of the
    filename to program gap.  I suspect it just ignores the 0x55 at the end.
  * I also wired in the motor control.  If the motor control turns off
    and we have yet to finish our byte and we're on bit 7, do the same
    as above.  The timer would catch this, but it seemed useful to
    support the motor control, so I added that IRQ.
  * In my code, anything higher than 2400Hz or lower than 600 Hz is an
    error.
  * Doing 'CSAVE' without a filename saved debugging time.  For the
    record, a CSAVE without a filename uses all spaces for the
    filename.  Probably everyone knew that, but I did not.
  * The smallest BASIC program one can save is 8 bytes in length on
    tape:   55 3C 01 02 00 00 03 55 (2 data bytes, plug framing)
  * Interfacing with the cassette port is hard.  Dave, my hat is off to you.

Jim



More information about the Coco mailing list