Introduction
A ZX Spectrum TAP file holds the blocks of a Spectrum cassette tape as plain bytes. It is the simplest Spectrum tape format and the easiest to make by hand, which is why cross-compilers and assemblers for the Spectrum often write it.
TAP keeps only what the Spectrum’s standard loader reads, not the sound of the tape, so
it cannot hold turbo loaders or copy protection; TZX
does that. Emulators play each block as the ROM would write it, followed by a pause of about a
second. The extension .tap is also used for two unrelated tape formats,
the Commodore 64 tape image and the
Oric tape image; they are separate formats and the
explorer tells the three apart by their content (all the formats that use .tap).
A .tap file dropped on any page of this site opens in the explorer, which
shows every block with its flag, length and checksum checked, decodes the headers, lists
BASIC programs, and opens each code block as Z80 machine code at the
address in its header, with the names of the Spectrum ROM's routines and system variables
(labels). A code block of 6912 bytes loaded at $4000 is also drawn as a screen. The
numbers written after USR, CODE and CLEAR in the BASIC loader are listed
as they are. A data block with no header has no address in the file, so the options bar says where to place it.
Structure
The file is a series of blocks with no file
header. Each block is a 2-byte
little-endian length, then that many bytes exactly as the Spectrum saves them: a flag
byte, the data and a checksum byte, which is all the previous bytes of the block XORed
together. The flag is 00 for a header block and FF for a data
block.
A program or file saved from BASIC is a pair of blocks. The header block is 19 bytes long: the flag, a type byte (0 for a program, 1 and 2 for arrays, 3 for bytes of code), a 10-character file name, the data length, two parameters such as the start line or load address, and the checksum. The data block follows.
0Block length little-endian2 bytes2Header block flag00, type, name, length, parameters, checksum19 bytes21Block length little-endian2 bytes23Data block flagFF, data, checksumvaries
Links
Software
- Fuse – ZX Spectrum emulator that loads TAP files (Windows, macOS, Linux)
- ZEsarUX – emulator of the Spectrum and other machines (Windows, macOS, Linux)
- Spectaculator – ZX Spectrum emulator that loads TAP files (Windows)
Reference
- TAP format – the Sinclair Wiki’s description of the format
Not described
The container is described: the blocks page covers lengths, flags, checksums, the four header types, BASIC programs and code. What remains:
Known, not yet covered
- Viewer: every byte of a code block is decoded as Z80 code (there is no separation of code from data, and nothing follows jumps). The loader's numbers are only those written as plain digits; the entry the loader really uses is not worked out. Number and character arrays are shown as bytes, not as values. A screen is drawn only when the header says 6912 (or 6144) bytes at $4000, and flashing cells are drawn in their first phase.
Unknown
- Reference: how the contents of a number or character array block are laid out. The Spectrum ROM defines it, but no tape with an array block was available to check a description against, so none is given on the blocks page.
Also used for
- Commodore 64 tape image – The length of every pulse on a C64, VIC-20, C16 or PET tape, after the text C64-TAPE-RAW.
- Oric tape image – Oric-1 and Atmos tapes: a $16 leader, sync byte $24, a 9-byte header, name and data.