Log in


faerie_gift in td_project

About the commodore TAP format...

The TAP format was created for the Commodore 64 Emulator CCS64 (link) by Per Hakan Sundell, as a means of representing the audio pulses on a commodore tape. These pulses represent square waves, with a one to one mark spacing, which essentially means, that the pulse spends as much time "up", as it does "down".

A TAP file contains a simple header, followed by a series of bytes representing these pulse widths. These values represent the pulse widths in microseconds (millionths of a second), and are calculated by the following formula: -

TAP data byte = P(uS) * (1/1000000) * (F(Hz)/8)

Where P = length of pulse in microseconds, and F = PAL Frequency of the C64 (985248Hz).

Sometimes the measured pulses are longer than 255*8 machine cycles, and in that case, we instead encode a zero byte, followed by another byte (which represents the overflow). In the most recent version of the TAP format, we still use zero to flag overflow, by follow it with a 24 bit number (3 bytes) which gives the actual length of the long pulse in machine cycles.

The beauty of this format is that it preserves everything within it. Load a TAP file into an emulator, and you will see the original loading screens, music, and yes, if you run your emulator at 100% speed, it will take 5-6 minutes to load!

I guess just to finish here, I should document the actual TAP header format, as there are scarce few places where it is documented online: -

Offset        Size         Description
0             12 bytes     File ID. 'C64-TAPE-RAW'
12            1 byte       Version (0 or 1 so far)
13            3 bytes      Reserved for future use (usually zeros)
16            4 bytes      Data length (Longword - Intel endianess)



March 2008

Powered by LiveJournal.com