Apple II computers initially used audio cassette tapes for storage. How was the data stored? What was the maximum bit rate?
The Apple II recorded data as a frequency-modulated sine wave. A standard consumer cassette deck could be connected to the dedicated cassette port on the Apple ][, ][+, and //e. The //c, ///, and IIgs did not have this port.
A tape could hold one or more chunks of data, each of which had the following structure:
- Entry tone: 10.6 seconds of 770Hz (8192 cycles at 1300 usec/cycle). This let the human operator know that the start of data had been found.
- Tape-in edge: 1/2 cycle at 400 usec/cycle, followed by 1/2 cycle at 500 usec/cycle. This "short zero" indicated the transition between header and data.
- Data: one cycle per bit, using 500 usec/cycle for
0and 1000 usec/cycle for
There is no "end of data" indication, so it's up to the reader to specify the length of data. The last byte of data is followed by an XOR checksum, initialized to $FF, that can be used to check for success.
For machine-language programs, the length is specified on the monitor command line, e.g.
800.1FFFR would read $1800 (6144) bytes. For BASIC programs and data, the length is included in an initial header section:
- Integer BASIC programs have a two-byte (little-endian) length.
- Applesoft BASIC has a two-byte length, followed by a "run" flag byte.
- Applesoft shape tables (loaded with
SHLOAD) have a two-byte length.
- Applesoft arrays (loaded with
RECALL) have a three-byte header.
Note the header section is a full data area, complete with 10.6-second lead-in.
The storage density varies from 2000bps for a file full of
0 bits to 1000bps for a file full of
1 bits. Assuming an equal distribution of bits, you can expect to transfer about 187 bytes/second (ignoring the header).
An annotated 6502 assembly listing, as well as C++ code for deciphering cassette data in WAV files, can be found here. The code in the system monitor that reads and writes data is less then 200 bytes long.
Is there any difference between tapes loaded via BASIC and ones loaded from the
*monitor? I've seen that Apple 2 offer a two versions of each game WAV file based on this. (Actually they offer 4, but the other difference is "lo fi" vs "hi fi" which I guess is just an audio quality difference.) Sep 21, 2022 at 13:32
1@hippietrail: The only difference between storage of BASIC and binaries is the addition of the header, which allows the user to do the load without having to explicitly specify the length. I suspect that some machine-language programs were wrapped with BASIC just to make them simpler to load.– faddenSep 21, 2022 at 14:48
Using my own code, it seems the wavs I found are not original tapes, at least the ones intended to be loaded by the
*monitor. They seem to have been created from disk versions using a modern tool that includes Deflate compression. The ones to be loaded from the
]prompt all have a tiny 4-byte header file before the main data file of the form
5D 01 D5 76. If the first byte is higher by one or two, the fourth byte is lower by one or two. Would this be the three bytes including the "run flag" plus the XOR checksum? Sep 23, 2022 at 11:09
1@hippietrail: yes, that's the 2-byte length ($015d), the run flag ($d5), followed by a checksum ($ff^5d^01^d5=$76). You can see the Applesoft code here; it uses the monitor
READroutine to load the data. See also github.com/datajerk/c2t and brutaldeluxe.fr/projects/cassettes .– faddenSep 23, 2022 at 14:44
An excellent description of the cassette storage format, along with the monitor and ROM codes that store and retrieve data, are outlined in Apple II Monitors Peeled (start at page 81): ftp://ftp.apple.asimov.net/pub/apple_II/documentation/misc/Apple%20II%20Monitors%20Peeled.pdf
The Apple II Circuit Description (W. Gayler) has a great technical breakdown as well (page 92): http://mirrors.apple2.org.za/Apple%20II%20Documentation%20Project/Books/W.%20Gayler%20-%20The%20Apple%20II%20Circuit%20Description.pdf,
2It would be great if you could add some relevant information to this answer; at present, it's not very useful. In fact, it's been flagged as low quality.– wizzwizz4 ♦Jul 26, 2018 at 12:31