Re: C2N ideas/thoughts?

Re: C2N ideas/thoughts?

From: Marko Mäkelä <>
Date: Tue, 7 Apr 2009 21:17:35 +0300
Message-ID: <20090407181735.GB32118@x60s>
On Tue, Apr 07, 2009 at 09:47:06AM -0400, Ethan Dicks wrote:
> On Mon, Apr 6, 2009 at 4:30 PM, Marko Mäkelä <> wrote:
> > Please have a look at the c2n source code.  That program will decode and
> > encode Commodore tape images...
> >
> > ...Commodore format, because each block is set twice
> > and because there are three different pulse widths in use, as opposed to
> > two.  It's easy to detect byte boundaries.  To decode these broken tapes
> > (mostly BASIC programs), I wrote a Perl script to decode the pulse stream
> > and edited the binary in GNU Emacs.
> This sounds interesting to me - I have a number of tapes that I've
> already read in and archived the contents of on modern machines
> (mostly stuff I wrote, but a few commercial tapes I bought in the late
> 1970s), but I probably have a small stack of tapes that had read
> errors, at least one of which is commercial (and occasionally had read
> problems back in the day).

Can you archive the problematic tapes in the *.tap format?  That should be
enough for decoding.  If the *.tap files are too corrupted, then you could
try playing with the azimuth settings or sample it in PCM format (*.wav)
and use an appropriate digital filter.  A few years ago, I made some
experiments with TAPir <>, but I can't remember
if it was of any use to me.  I didn't try to mess around with the stereo
head of the analog tape deck that I used.

> > If you want to see a slow format, try KIM-1. :-)  It's also supported by
> > the "c2n" program.
> I don't have any KIM tapes (though I do have a MicroKIM), but I do
> have a number of "PET Rabbit"-format tapes.  I have the Rabbit program
> on ROM and on C= tape but have not yet attempted to reverse-engineer
> it.  What sort of information would I have to know about the format to
> consider adding it to the c2n program?  I doubt there's m uch
> documentation about it already, so I'm guessing I'll have to get the
> code to tell me.

There are four decoder functions implemented so far: decode and decode264
in decode.c, decode_kim in kim_d.c and decode_oric in oric_d.c.  You could
start by studying the decoders in decode.c.

Hmm, I seem to remember that I once encountered VIC Rabbit.  Sure enough,
I even documented the format:

I probably wrote some throw-away Perl one-liners to decode the samples
that I produced with the cartridge image.  I must have run the "save"
command on the VIC-20 and sampled the pulses with the C2N232 directly
from the tape port, without going through analog tape.  If the PET Rabbit
is anything like Vic Rabbit, I wish you luck.

Basically, the decoding can be divided to four steps:

(1) sample the tape
(2) detect edges or pulses from the samples
(3) quantize the pulse widths to symbols B, C, D (using the c2n232 notation)
(4) decode the string of symbols to binary

The decoder functions in the "c2n" program implement step (4).

I hope that this helps.


       Message was sent through the cbm-hackers mailing list
Received on 2009-04-07 21:27:55

Archive generated by hypermail 2.2.0.