TZX stores a tape as the pulses it plays, so that turbo loaders and copy protection survive. This page follows the TZX format specification, revision 1.20, kept by World of Spectrum. Numbers are little-endian; times are in T-states of the Spectrum’s 3.5 MHz Z80 (one T-state is 1/3,500,000 of a second); pauses are in milliseconds. Offsets below count from the byte after the block’s ID.
File header
| Offset | Size | Name | Description |
|---|---|---|---|
0 | 7 | Signature | ZXTape! |
7 | 1 | End of text | 1A. |
8 | 1 | Major version | 1. |
9 | 1 | Minor version | 20 for revision 1.20. A reader must accept any minor version of a major version it knows, skipping blocks it does not understand. |
Blocks follow, each an ID byte and its fields. The signal starts low, and each pulse flips it. Blocks added after revision 1.10 start with a 4-byte length so that older readers can skip them.
Default ROM timings
| Pulse | T-states |
|---|---|
| Pilot pulse | 2,168 |
| Pilot tone length | 8,063 pulses for a header block (flag < 128), 3,223 for a data block |
| First sync pulse | 667 |
| Second sync pulse | 735 |
| Bit 0 pulse (two per bit) | 855 |
| Bit 1 pulse (two per bit) | 1,710 |
| Pause after a block | 1,000 ms |
10 – Standard speed data
A block as the ROM saves it, played with the default timings.
| Offset | Size | Field |
|---|---|---|
0x00 | 2 | Pause after this block (ms) |
0x02 | 2 | Length of data |
0x04 | length | Data, as in a TAP block: flag, contents, checksum |
11 – Turbo speed data
| Offset | Size | Field |
|---|---|---|
0x00 | 2 | Pilot pulse length |
0x02 | 2 | First sync pulse length |
0x04 | 2 | Second sync pulse length |
0x06 | 2 | Zero bit pulse length |
0x08 | 2 | One bit pulse length |
0x0A | 2 | Pilot tone length, in pulses |
0x0C | 1 | Bits used in the last byte (default 8; the rest are ignored, most significant bit first) |
0x0D | 2 | Pause after this block (ms) |
0x0F | 3 | Length of data |
0x12 | length | Data |
12 – Pure tone · 13 – Pulse sequence
| Block | Offset | Size | Field |
|---|---|---|---|
| 12 | 0x00 | 2 | Length of one pulse |
| 12 | 0x02 | 2 | Number of pulses |
| 13 | 0x00 | 1 | Number of pulses, N (up to 255) |
| 13 | 0x01 | 2 × N | The length of each pulse |
14 – Pure data
Data bits only, with no pilot or sync, usually after blocks 12 and 13.
| Offset | Size | Field |
|---|---|---|
0x00 | 2 | Zero bit pulse length |
0x02 | 2 | One bit pulse length |
0x04 | 1 | Bits used in the last byte |
0x05 | 2 | Pause after this block (ms) |
0x07 | 3 | Length of data |
0x0A | length | Data |
15 – Direct recording
The signal sampled at a fixed rate, one bit per sample (1 high, 0 low), most significant bit first.
| Offset | Size | Field |
|---|---|---|
0x00 | 2 | T-states per sample (79 for 44.1 kHz, 158 for 22.05 kHz) |
0x02 | 2 | Pause after this block (ms) |
0x04 | 1 | Samples used in the last byte, 1 to 8 |
0x05 | 3 | Length of samples data |
0x08 | length | Samples |
18 – CSW recording
Pulses stored as in a compressed square wave (CSW) file, version 2.
| Offset | Size | Field |
|---|---|---|
0x00 | 4 | Block length, not counting these 4 bytes |
0x04 | 2 | Pause after this block (ms) |
0x06 | 3 | Sample rate in Hz |
0x09 | 1 | Compression: 1 run-length encoding, 2 Z-RLE (zlib-compressed) |
0x0A | 4 | Number of pulses stored after decompression |
0x0E | rest | CSW data |
19 – Generalised data
Describes any encoding: pilot and sync as runs of symbols, then data as a stream of symbols, each symbol being a short sequence of pulses from an alphabet.
| Offset | Size | Field |
|---|---|---|
0x00 | 4 | Block length, not counting these 4 bytes |
0x04 | 2 | Pause after this block (ms) |
0x06 | 4 | TOTP: total pilot and sync symbols in the run-length stream |
0x0A | 1 | NPP: most pulses in a pilot or sync symbol |
0x0B | 1 | ASP: pilot and sync alphabet size (0 means 256) |
0x0C | 4 | TOTD: total data symbols |
0x10 | 1 | NPD: most pulses in a data symbol |
0x11 | 1 | ASD: data alphabet size (0 means 256) |
0x12 | varies | If TOTP > 0: ASP symbol definitions of (2 × NPP + 1) bytes each, then TOTP run-length entries of 3 bytes |
| … | varies | If TOTD > 0: ASD symbol definitions of (2 × NPD + 1) bytes each, then the data stream |
- Symbol definition: a flag byte, then up to NPP (or NPD) pulse lengths of 2 bytes; a shorter symbol ends with a zero length. Flag bits 0–1 give the level at the start: 00 flip (an edge), 01 no flip, 10 force low, 11 force high.
- Run-length entry: a symbol number (1 byte) and how many times to repeat it (2 bytes).
- Data stream: each symbol takes NB = ⌈log₂ ASD⌉ bits, most significant first; the stream is ⌈NB × TOTD ÷ 8⌉ bytes.
Deprecated data blocks
Files of revision 1.20 should not contain these, but readers may meet them in older
files: 16 Commodore 64 ROM data and 17 Commodore 64 turbo
data, each starting with a 4-byte length so they can be skipped. The specification
(World of Spectrum, TZX format, deprecated block list) says they were in the
format up to revision 1.13, have proved of little use and almost no TZX file holds
one. Values in brackets are the ones the specification gives for the C64 ROM loader.
Block 16: C64 ROM type data
Made for the Commodore 64 standard ROM tape format and anything else that writes two or four pulses per bit, equal in pairs. A wave is two pulses; each field gives the length of one pulse. A wave always starts at the LOW level, because the C64 can only detect HIGH to LOW transitions. A pulse length of 0 means the whole wave is absent, data included.
| Offset | Size | Meaning |
|---|---|---|
0x00 | 4 | Length of the whole block including the data (the extension rule) |
0x04 | 2 | Pilot tone pulse length [616] |
0x06 | 2 | Number of waves in the pilot tone |
0x08 | 2 | Sync first wave pulse length [1176] |
0x0A | 2 | Sync second wave pulse length [896] |
0x0C | 2 | Zero bit first wave pulse length [616] |
0x0E | 2 | Zero bit second wave pulse length [896] |
0x10 | 2 | One bit first wave pulse length [896] |
0x12 | 2 | One bit second wave pulse length [616] |
0x14 | 1 | XOR checksum bit for each data byte [1]: 00 start the XOR with 0, 01 start it with 1, FF no checksum bit |
0x15 | 2 | Finish byte first wave pulse length [1176] |
0x17 | 2 | Finish byte second wave pulse length [896] |
0x19 | 2 | Finish data first wave pulse length [1176] |
0x1B | 2 | Finish data second wave pulse length [616] |
0x1D | 2 | Trailing tone pulse length [616] |
0x1F | 2 | Number of waves in the trailing tone |
0x21 | 1 | Used bits in the last byte, the others being 0 (6 means xxxxxx00) |
0x22 | 1 | General purpose flags [1]: bit 0, data endianness, 0 least significant bit first, 1 most significant first |
0x23 | 2 | Pause after this block, in milliseconds |
0x25 | 3 | Length of the data that follows (N) |
0x28 | N | Data, as in .TAP files |
The XOR checksum bit, when its field is 0 or 1, is the XOR of all the bits of the byte with that start value. “Finish byte” waves play after every byte except the last; “finish data” waves play only after the last byte. Playback order: pilot tone, sync waves, data bytes (each with its XOR bit and finish-byte waves), the finish-data waves, the trailing tone (an optional extra, standard in the C64 ROM loader’s repeated blocks).
Block 17: C64 turbo tape data
For the other C64 encoding, common in commercial software: the pilot tone is a data byte repeated many times, a different byte signals the start of the data, each data bit is one wave, and there is no XOR checksum. The trailing byte plays after the data ends.
| Offset | Size | Meaning |
|---|---|---|
0x00 | 4 | Length of the whole block including the data |
0x04 | 2 | Zero bit pulse length |
0x06 | 2 | One bit pulse length |
0x08 | 1 | Additional bits in bytes: bits 0–1 number of bits (0–3); bit 2 play them before (0) or after (1) the byte; bit 3 their value |
0x09 | 2 | Number of lead-in bytes |
0x0B | 1 | Lead-in byte |
0x0C | 1 | Used bits in the last byte [8] |
0x0D | 1 | General purpose flags [0]: bit 0, little (0) or big (1) endian |
0x0E | 2 | Number of trailing bytes |
0x10 | 1 | Trailing byte |
0x11 | 2 | Pause after this block, in milliseconds |
0x13 | 3 | Length of the data that follows (N) |
0x16 | N | Data, as in .TAP files |
The block has a field for the lead-in byte but none for the “different” sync byte the description mentions; the specification does not say where it comes from.