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. Their fields (pulse
lengths, checksum and endianness settings) are given in the specification.