User Tools

Site Tools


oric:hardware:tape_encoding

Means of Detection

A 1-bit digitised version of the tape's audio stream is fed as an input to the CB1 pin of the Oric's VIA. The ROM configures the 6522 to raise an interrupt upon a low-to-high transition of CB1. It then measures the amount of time between those interrupts using the 6522's second timer.

Bit Encoding

The period between one low-to-high transition and the next forms a complete wave. The ROM officially uses three lengths of wave for data encoding — short, medium and long. Fast encoding uses short and medium waves, slow encoding uses short and long waves.

The archetypal lengths for the three waves are 416µs, 624µs and 833µs.

Fast Encoding

A zero is encoded as a medium wave. A one is encoded as a short wave.

Slow Encoding

A zero is encoded as four consecutive long waves. A one is encoded as eight consecutive short waves.

Byte Encoding

Each byte is encoded as 10 meaningful bits plus a suffix of three-or-more that gives the CPU time to prepare for the next byte.

Each byte begins with a 0 as a start bit.

The start bit is followed by the eight bits that form the byte, in least significant to most significant order.

The eight data bits are followed by an even parity bit.

The 10 meaningful bits are then followed by at least three 1s as stop bits.

Data Rates

Fast Encoding

As a zero takes 416µs and a one 624µs, a bit stream composed of an equal number of 1s and 0s will be encoded at an average of 512µs per bit, for a baud rate of just over 1953. At 13 bits per byte that's a little above 150 bytes/second — it would take slightly less than five and a half minutes to load a complete 48 kb of information with fast encoding.

Slow Encoding

As a zero takes 4 * 833 = 3332µs and a one 8 * 416 = 3328µs, a bit stream composed of an equal number of 1s and 0s will be encoded at an average of 3330µs per bit, for a baud rate close to 300. At 13 bits per byte that's around 23 bytes/second — it would take around 35 and a half minutes to load a complete 48 kb of information with slow encoding.

Minimal Wave Lengths for Fast Encoding

When loading fast data, the ROM compares a wave's length to a threshold of 512µs to mark it as either short or medium; allowing for other work involved, a wave needs to be at least 115µs to be recognised at all, and at least 529µs to be recognised as a medium wave. So if a playback device with guaranteed ideal pitch is used, the average bit length can be reduced to 322µs, a baud rate of around 3105, implying almost 239 bps and around three and a half minutes for a complete 48kb (source).

File Encoding

Files are encoded as:

  • at least four instances of $16, acting as synchronisation bytes;
  • an instance of $24, acting to signal the end of the synchronisation bytes;
  • two reserved bytes;
  • a single byte specifying the data type of the upcoming file, one of:
    • $00: the file is BASIC;
    • $80: the file is machine code;
  • a single byte specifying how to execute the upcoming file:
    • $80: RUN as BASIC;
    • $C7: execute as machine code;
    • any other value: don't automatically launch;
  • the ending address of the data stored, two bytes in big-endian form;
  • the starting address of the data stored, two bytes in big-endian form;
  • a reserved byte;
  • the file's name — ASCII format, 16 characters at most, NULL terminated;
  • the body of the file.

The starting and ending addresses are inclusive so there will be (ending address) - (starting address) + 1 bytes in the file's body.

oric/hardware/tape_encoding.txt · Last modified: 2016/12/31 21:10 by thomh