
A Minimal C64 Datasette Program Loader - ingve
https://www.pagetable.com/?p=964
======
diydsp
I once put an audio cassette of The Cure into my Datasette.

Then, I made a short assembly routine to copy that datasette output while
playing to the SID. (I think I used the volume register?). it made a very
badly sampled sounding version :) was fun :)

------
myrandomcomment
The Commodore Datasette was much more reliable than any of the other systems
out there. The one on the Spectrum, Apple and Atari (all std. decks) pretty
much gave you load issue 20% of the time. You had to mess with the volume
level, etc. My Commodore one just worked.

~~~
walshemj
Most cheap cassette recorders didn't have a gain control back then. I found my
Atom (precursor to BBC B) worked well when I got a more expensive deck about
£50-60 back in 1980.

------
Luc
I wonder how the Kernal writers decided on the two-pulse-per-bit scheme. They
must have been targetting some awful hardware (or low quality tape media, I
suppose)

The fastloaders that came after all worked fine using one pulse per bit.

~~~
raphlinus
And modern alternatives (for example c2t, which is for Apple II) can achieve
even much higher data rates. I prototyped an encoding that packs 4 bits per
pulse, achieving 23kbps but not reliably. One difference, though, is that this
is designed for output from a modern digital sound interface, not designed to
withstand degradation from analog tape recorders.

[https://groups.google.com/forum/#!topic/comp.sys.apple2/qXZy...](https://groups.google.com/forum/#!topic/comp.sys.apple2/qXZyIZ9hO3s)

------
jcmeyrignac
I read the source code, and here are 2 improvements:

1) in get_block, we can replace "dec count" with "cpy count" It should save
one or 2 cycles, if I'm not mistaken

2) get_countdown can be rewritten as follows:

    
    
            ldy #$89
     c4:
            cpy #$89
            bne c1
     c0:
            jsr get_byte
     c1:
            ldy #$89
            bne c2
     cx:
            jsr get_byte
     c2:
            sty tmp_cntdwn
            cmp tmp_cntdwn
            bne c4
            dey
            cpy #$80
            bne cx
            rts

which saves probably 4 bytes

~~~
Luc
> 1) in get_block, we can replace "dec count" with "cpy count" It should save
> one or 2 cycles, if I'm not mistaken

It would, but wouldn't it also set the carry flag? Thus the routine would
always return with carry flag set.

~~~
tom_
It would, but the routine already modifies the carry flag, so no problem.

~~~
Luc
It won’t work because the carry flag signals end of file. This will cause an
infinite loop.

Check the full source on GitHub.

~~~
Luc
(oops, now that I'm looking at the code again: it would not go into an
infinite loop, but cut off after loading 1 block.)

------
melling
“The Commodore Datasette recording format is heavily optimized for data safety
and can compensate for many typical issues of cassette tape, ”

I used the tape for a few days when I got my C64. It didn’t take more than a
week before I realized that it was too slow and unreliable and talked my mom
into getting the 1540 drive.

~~~
Luc
This is really funny because that drive was so incredibly slow, and especially
the 1540 was unreliable. A tape with fastloader would approximate the speed of
the stock drive...

Still, I did the same thing!

~~~
pkaye
The interface chip they were working with had a bug on a hardware shift
register and the designer were not able to switch because management wanted it
to be compatible with the VIC 20. So they implemented a software solution
which was 5x slower that with hardware.

~~~
gnat
+1. Interested readers should check out the very good book "Commodore: A
Company on the Edge" by Brian Bagnall for this and other fascinating stories
from how the PET, VIC-20, and C64 came to be. (And parallels to Internet-age
companies are a fun exercise for the reader)

------
kidsnow
I had a Datasette. It was expensive at the time, and it was amazing that it
worked at all. You could put one of the C64 tapes into your boom box and play
them, and hear a series of unpleasant screeches and whoops.

~~~
weinzierl
>I had a Datasette. It was expensive at the time, and it was amazing that it
worked at all.

It was expensive in the beginning, but later on it was cheap, at least in
comparison to the 1541 floppy disk drive which was in the same price region as
the C64 itself.

If you look at the hardware this is not surprising. The Datasette was
basically a slightly modified cassette player. The Atari "Datasette" (410
Program Recorder) even looked like the typical portable cassette player of the
time and could be used like one. It could play audio cassettes through an
internal speaker. The 1541 and the 1541 II on the other hand were little 8-bit
computers in their own right. They contained a 6502 (almost the same CPU as
the C64) and there was software to use the floppy CPU as a co-processor.

>You could put one of the C64 tapes into your boom box and play them, and hear
a series of unpleasant screeches and whoops.

You could not only play them, you could conveniently _copy_ them with your
boom box. This was the way software was pirated back then. A dual deck boom
box with high speed dubbing - much faster than copying with the computer.

In the Netherlands there were also experiments where software was sent on FM
radio. You recorded it on a audio cassette which you could then use in your
Datasette.

While most people used regular 60 minutes audio cassettes for software there
existed special 7 minute cassettes for some time. This saved you from a lot of
winding and rewinding when you missed the program start.

Good times, good times...

~~~
tdeck
In case anyone is curious about those radio experiments, OP is talking about
Basicode:

[https://en.wikipedia.org/wiki/BASICODE?wprov=sfla1](https://en.wikipedia.org/wiki/BASICODE?wprov=sfla1)

They also invented a kind of internal DSL within BASIC to get around
inconsistencies in various BASIC dialects used by different platforms at the
time.

~~~
PhasmaFelis
That is amazing. Different manufacturers' dialects of basic were barely the
same language. I think the only things generally held in common were basic
logic and control flow, _very_ basic string manipulation, printing characters
line-by-line, and prompting the user to enter a string. It sounds like these
guys essentially created a shared function library (libraries and functions
were completely alien to BASIC!) and successful ported that library to a
couple of dozen different computers, some of them with only 16KB of RAM.

(Technically functions were supported in some dialects at least, but they had
to fit on one line and could only do mathematical operations, so they would be
useless here.)

------
myrandomcomment
So a great video on some of the HW emulation projects around this (datasette
for 80s 8-bits) from the Nostalgia Nerd.

[https://youtu.be/DoMxl_RqQlQ](https://youtu.be/DoMxl_RqQlQ)

Pretty cool stuff.

