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...
Alternatively, in C,
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...
In C again,
One way to make this clearer (or not...) is to run a program which sequentially fills in the screen RAM, like the following:
10 FOR a=16384 TO 23295 20 POKE a,255 30 NEXT a
Watching the order in which the screen is filled should make it clear how the screen RAM works.
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:
Something about the Timex 8x1 hi-res mode and hi-colour mode should go here.
- Main article: ZX Spectrum 64 Colour Mode
The ULAplus, a plug-in replacement for the Spectrum ULA, provides a paletted 64 colour mode in addition to the usual 16 colour mode. The display file layout is the same except that attribute bytes are interpreted differently.