Facts on this page are from World of Spectrum's description of the format and
libspectrum's z80.c, and were checked by decompressing the RAM of 15 real snapshots and comparing every 16 KiB bank with libspectrum's.
Memory blocks
Version 1 has one block: 48 KiB, the RAM from $4000 to $FFFF, at offset 30. If bit 5 of header byte 12 is set it is compressed,
and then it ends with the four bytes 00 ED ED 00, which the data itself cannot contain. Otherwise it is exactly 49152 bytes.
Versions 2 and 3 have a series of blocks, one per 16 KiB page, with no end marker:
| Offset in the block | Size | Field |
|---|---|---|
0 | 2 | Length of the data that follows. $FFFF means 16384 bytes stored as they are, not compressed |
2 | 1 | Page number, below |
3 | length | The data |
Some files end with extra data after the blocks (.slt, a Super Level Loader file): a block header of length 0 and page 0 followed by the text SLT.
Page numbers
| Page | 48K mode | 128K mode | SamRam mode |
|---|---|---|---|
| 0 | 48K ROM | ROM (BASIC) | 48K ROM |
| 1 | Interface I, Disciple or Plus D ROM | same | same |
| 2 | – | ROM (reset) | SamRam ROM (BASIC) |
| 3 | – | RAM bank 0 | SamRam ROM (monitor and others) |
| 4 | $8000-$BFFF | RAM bank 1 | normal $8000-$BFFF |
| 5 | $C000-$FFFF | RAM bank 2 | normal $C000-$FFFF |
| 6 | – | RAM bank 3 | shadow $8000-$BFFF |
| 7 | – | RAM bank 4 | shadow $C000-$FFFF |
| 8 | $4000-$7FFF | RAM bank 5 | $4000-$7FFF |
| 9 | – | RAM bank 6 | – |
| 10 | – | RAM bank 7 | – |
| 11 | Multiface ROM | Multiface ROM | – |
A 48K snapshot saves pages 4, 5 and 8; a SamRam snapshot pages 4 to 8; a 128K snapshot pages 3 to 10. A Pentagon is saved like a 128K, and a Scorpion's 16 RAM pages are in pages 3 to 18 (the explorer lists them but shows only banks 0 to 7 in the disassembly). libspectrum drops the ROM pages, and keeps a page 1 only for an Interface I or Plus D ROM.
On a 128K machine the processor sees RAM bank 5 at $4000, bank 2 at $8000 and the bank chosen by bits 0-2 of port $7FFD
at $C000; the file's byte 35 holds that port's value.
Compression
The scheme stores runs of equal bytes. The data is read byte by byte:
- A run of at least five equal bytes is written
ED ED xx yy: the byteyyrepeatedxxtimes. - Shorter runs are not encoded, with one exception: a run of two or more
EDbytes is always encoded, becauseED EDis the repeat code. TwoEDbytes areED ED 02 ED. - The byte after a single
EDis never put into a run:EDfollowed by six zeros is writtenED 00 ED ED 05 00. - In version 1 the data ends with
00 ED ED 00. In versions 2 and 3 each block has its own length and no end marker.
A repeat of count zero, a repeat that goes past the 16384 bytes a block holds, a repeat code cut off by the end of the block, and a block that expands to fewer than 16384 bytes are the errors the explorer reports.
Not described
The meaning of the Scorpion's pages 11 to 18 and the +3's port $1FFD paging (special all-RAM modes) are not described, and the explorer does not model them.