Spectrum Video Modes
The video modes of a computer are the ways in which it can produce a display. A vanilla ZX Spectrum has only one video mode, a 256x192 resolution with 15 colours in attribute cells. Some versions such as the Timex machines added other modes, as do some hardware modifications such as the ULAplus.
ZX Spectrum Video Mode
The display is actually quite strangely made:
- First there's the pixel data; this just has a single bit for each pixel. Also it's laid out quite oddly; see below.
- Then there's the attribute data - each 8x8 cell has two colours, the Ink and the Paper colour (each from a palette of 8), and two flag bits, one for Bright and one for Flash.
- For any given pixel, it's either the Ink colour or the Paper colour for its cell, depending on the value of its bit in the pixel data.
- If the Bright bit is set, both Ink and Paper colours in that cell are brighter (note that Bright black is still black).
- If the Flash bit is set, half the time the Ink and Paper colours will be swapped for the cell (Flash is synchronous across the whole screen, and alternates every 32 frames (thus a complete cycle takes 1.28s).
Display file layout
The pixel data appear starting at address 4000h (16384); the screen is divided vertically into thirds, then lines modulo 8, then rows (blocks of 8 lines). This might become clearer if you look at how the address lines are 'jumbled': if we write L4-L0 for the bits of the Line number (0-23), P2-P0 for the bits of the Pixel row within the line (0-7), and C4-C0 for the bits of the Column number (0-31), we get the following... pixelByteAddr = (msb)| 0 | 1 | 0 |L4|L3|P2|P1|P0| || |L2|L1|L0|C4|C3|C2|C1|C0|(lsb) Alternatively, in C, dataByteHigh=0x40|(line&0x18)|(pixelrow%8), dataByteLow=((line&0x7)<<5)|column. Then, the byte at this address contains 8 bits, which are the pixel data for the relevant row of 8 pixels. The attribute bytes are arranged slightly more sanely, as they don't have the pixel row in there... attrByteAddr = (msb)| 0 | 1 | 0 | 1 | 1 | 0 |L4|L3| || |L2|L1|L0|C4|C3|C2|C1|C0|(lsb) In C again, attrByteHigh=0x58|(line>>3), attrByteLow=dataByteLow.
Each attribute byte sets the colours for a whole 8x8 cell (this is the origin of the Spectrum's infamous 'colour clash', since it only allows two colours within each cell). The attribute is laid out as follows: (msb)|Flash|Bright|Paper-G|Paper-R|Paper-B|Ink-G|Ink-R|Ink-B|(lsb)
Something about the Timex 8x1 hi-res mode and hi-colour mode should go here.
See ZX Spectrum 64 Colour Mode for details of ULAplus's paletted 64 colour mode.