From the zx-state specification’s pages for the blocks, read through a summarising fetch tool: “our words”. Offsets below are relative to the start of the block’s data (after the 8-byte block header); the byte widths are the usual ones and every size agrees with the real files of libspectrum’s test folder. Everything is little-endian.
Block structure
| Offset | Size | Field | Meaning |
|---|---|---|---|
0 | 4 | Id | Four characters packed in a 32-bit value, for example C R T R |
4 | 4 | Size | The number of data bytes that follow, not counting this 8-byte header |
8 | size | Data | The block’s fields |
A reader that does not know an id skips the size and goes on. The page describes no compression of the block as a whole: the pages and the ROM are compressed inside their own blocks. Blocks may come in any order (the RAM pages explicitly so).
Block ids
“Where from”: spec — the id and layout are from the specification page fetched for this site; file — the id was seen in a real test file and named from the specification’s index; memory — written from memory, not checked. A zero byte in an id is shown as ·.
| Id | Block | Where from |
|---|---|---|
CRTR | Creator | spec |
Z80R | Z80 registers | spec |
SPCR | Spectrum registers: border, paging ports | spec |
RAMP | A RAM page | spec |
ROM· | A custom ROM | spec |
AY·· | The AY-3-8912 sound chip | spec |
KEYB | Keyboard | spec |
JOY· | Joystick | spec |
SCLD | Timex SCLD registers | spec |
COVX | Covox | spec |
DRUM | SpecDrum | spec |
AMXM | Mouse | spec |
ZXAT, ATRP | ATASP hard disk interface and its RAM page | file |
ZXCF, CFRP | ZXCF interface and its RAM page | file |
SIDE | Simple 8-bit IDE | file |
ZXPR | ZX Printer | file |
ZMMC | ZXMMC interface (not on the specification index we read) | file |
B128, BDSK | Beta 128 interface and disk | memory |
DOCK | Timex dock cartridge | memory |
DSK· | Disk file | memory |
GS··, GSRP | General Sound and its RAM page | memory |
IF1·, IF2R | Interface 1; Interface 2 ROM | memory |
LEC·, LCRP | LEC memory expansion and its RAM page | memory |
MDRV | Microdrive cartridge | memory |
MFCE | Multiface | memory |
OPUS, ODSK | Opus Discovery and its disk | memory |
+3·· | +3 disk drives | memory |
PLSD, PDSK | +D and its disk | memory |
TAPE | Tape (the cassette recorder) | memory |
SNET | Spectranet | memory |
USPE | uSpeech | memory |
The specification index lists 38 blocks by their C names; the ids of the “memory” rows were written from memory and are not checked, so a block with one of them may carry a different id.
CRTR: creator
| Offset | Size | Meaning |
|---|---|---|
0 | 32 | Name of the emulator or utility that wrote the file |
32 | 2 | Major version of that program |
34 | 2 | Minor version |
36 | rest | Creator-specific data of any length |
Z80R: Z80 registers
| Offset | Size | Meaning |
|---|---|---|
0–23 | 12 × 2 | AF, BC, DE, HL, AF′, BC′, DE′, HL′, IX, IY, SP, PC |
24 | 1 | I |
25 | 1 | R |
26 | 1 | IFF1, 0 or 1 |
27 | 1 | IFF2, 0 or 1 |
28 | 1 | Interrupt mode, 0, 1 or 2 |
29 | 4 | T-states at the snapshot, counting up from zero to the frame length of the model |
33 | 1 | T-states left on restart during which an interrupt can still occur (the ULA holds INT low for up to 48; the AMX mouse can raise it too) |
34 | 1 | Flags: bit 0 interrupts suppressed (after EI or an invalid DD/FD prefix), bit 1 halted (excludes bit 0), bit 2 the last instruction changed F |
35 | 2 | MEMPTR, 0 if unsupported (it supplies bits 5 and 3 of F after BIT x,(HL); added in 1.4 over two older fields, the size did not change) |
The block is 37 bytes; the page does not state the size, we derive it from the fields and the real file agrees.
SPCR: Spectrum registers
| Offset | Size | Meaning |
|---|---|---|
0 | 1 | Border colour, 0 (black) to 7 (white) |
1 | 1 | Port $7FFD: the paging of the 128K models; 0 on a 16K or 48K |
2 | 1 | Port $1FFD on the +2A, +3 and Scorpion, or port $EFF7 on the Pentagon 1024; 0 elsewhere |
3 | 1 | The last value written to port $FE; only bit 3 (MIC) and bit 4 (EAR) are guaranteed (since 1.1) |
4 | 4 | Reserved, 0 |
RAMP: a RAM page
| Offset | Size | Meaning |
|---|---|---|
0 | 2 | Flags: bit 0 set means the data is compressed with zlib |
2 | 1 | Page number |
3 | rest | The page: zlib data (size − 3 bytes) or raw, 16384 bytes after decoding |
Pages by model (the specification’s list): 16K: page 5 ($4000–$7FFF); 48K and Timex: pages 5, 2 ($8000–$BFFF) and 0 ($C000–$FFFF); 128K and Pentagon 128: pages 0 to 7; Pentagon 512: 0 to 31; Pentagon 1024: 0 to 63; Scorpion ZS-256: 0 to 15.
The blocks may come in any order. The page has no size field: it is 16 KiB. The ATASP and ZXCF RAM-page blocks (ATRP, CFRP) have the same 3-byte start in the real test files (flags, page, zlib data); that they follow this layout is our reading of those files, not a specification statement.
ROM·: a custom ROM
| Offset | Size | Meaning |
|---|---|---|
0 | 2 | Flags: bit 0 zlib-compressed |
2 | 4 | Size of the ROM after decoding: 16384 (16K/48K, TS/TC2048), 24576 (TS2068), 32768 (128, +2, Pentagon 128, SE) or 65536 (+2A, +3, Scorpion) |
6 | rest | The image, several ROMs concatenated in ascending order. With no custom ROM the standard ROMs are used (the +2A/+3: v4.0) |
AY··: sound chip
| Offset | Size | Meaning |
|---|---|---|
0 | 1 | Flags: 0 for a machine with a built-in AY, 1 Fuller Box, 2 Melodik Soundbox (the 128K ports); only one flag set |
1 | 1 | The selected register, 0 to 15 |
2 | 16 | Registers 0 to 15; unused bits 0 |
KEYB: keyboard
A 32-bit flags word (bit 0: Issue 2 keyboard, 16K/48K only) and, since 1.1, one byte for the joystick the PC keyboard emulates: 0 Kempston, 1 Fuller, 2 Cursor (AGF/Protek), 3 Sinclair Interface II port 1 (or +2A/+3 joystick 1), 4 Sinclair port 2 (or joystick 2), 5 the cursor keys of the Spectrum+/128/+2/+2A/+3, 6 and 7 Timex built-in port 1 and 2, 8 none.
JOY·: joystick
A 32-bit flags word (bit 0, deprecated: always return 0 for port 31 when Kempston is off), then one byte each for player 1 and player 2: 0 Kempston, 1 Fuller, 2 Cursor, 3 Sinclair 1, 4 Sinclair 2, 5 Comcon, 6 and 7 Timex built-in port 1 and 2, 8 disabled.
SCLD: Timex registers
Two bytes (since 1.2): the value of port $F4 (memory paging) and of port $FF (screen mode, interrupt state, hi-res colours and the rest of the paging).
COVX: Covox
One byte, the current amplitude of the Covox DAC, then three reserved bytes that should be 0.
DRUM: SpecDrum
One signed byte, the current amplitude of the SpecDrum DAC (+127 to −128). A file with no DRUM block means SpecDrum emulation is off.
AMXM: mouse
One byte for the type (0 none, 1 AMX, 2 Kempston), then three bytes each for the Z80 PIO CTRLA and CTRLB registers of the AMX mouse (7 bytes in all).
Not described
Known, not yet covered
- The layouts of every block not in the list above (about 26 of the specification’s 38); a block that is not described here is skipped and shown as bytes.
Unknown
- The ids of the blocks marked “memory”; the layouts of
ZXAT,ZXCF,SIDE,ZXPRandZMMC(only their sizes in the real test files are known).