Egghead.page Logo

How ZX Spectrum Attribute Bytes Controlled Color

The Sinclair ZX Spectrum utilized a unique memory structure to manage graphics, relying on an attribute byte to define color within fixed 8x8 pixel character blocks. This article explains the specific bit allocation within that byte, detailing how ink, paper, brightness, and flash effects were stored. Readers will understand the technical limitations that led to the famous color clash phenomenon inherent to the machine’s affordable design.

Screen Memory Structure

The Spectrum’s display memory was divided into two distinct areas: the bitmap and the attribute file. While the bitmap determined which pixels were on or off within an 8x8 grid, the attribute file dictated how those pixels appeared visually. Each 8x8 character block on the 256x192 resolution screen corresponded to a single byte in the attribute memory, totaling 768 bytes for the entire display.

The Attribute Byte Breakdown

Each attribute byte consisted of eight bits, split into specific sections to control visual properties. Bits 0 through 2 defined the ink color, allowing for eight possible foreground colors ranging from black to white. Bits 3 through 5 controlled the paper color, offering the same eight options for the background. This structure meant that every character block was restricted to only two colors at any given time.

Brightness and Flash Effects

The remaining two bits in the byte handled special effects. Bit 6 acted as the brightness flag, where a value of 0 produced normal intensity and 1 produced bright intensity for both ink and paper. Bit 7 controlled the flash attribute, causing the ink and paper colors to swap periodically if set to 1. This bitwise efficiency allowed the Z80 processor to manage color data without consuming excessive memory.

The Color Clash Limitation

Because only two colors could exist within a single 8x8 block, graphics often suffered from attribute clash. When multicolored sprites moved across the screen, they were forced to adopt the background color of the character block they entered. This technical constraint became a defining visual characteristic of the platform, requiring developers to carefully design graphics around the grid to minimize visual distortion.