Spectrum history

Why Spectrum Colours Clash: Attribute Clash Explained in Pictures

Why does a Spectrum sprite change colour when it walks past a tree? We follow one character across the screen, cell by cell, and look at the games that hid it well.

Anyone who played games on a ZX Spectrum remembers it: a character walks past something colourful and suddenly turns the wrong colour, in a neat little square. This is attribute clash, sometimes called colour clash, and it came from one decision in the design of the machine. Here we follow one character across the screen, square by square, then look at how the best Spectrum games kept it out of sight.

A screen made of squares

The Spectrum's picture is 256 pixels wide and 192 tall. For colour, though, the machine sees something much coarser: a grid of 32 by 24 squares, each 8 pixels by 8. That is the same grid the Spectrum uses for letters, so every character of text sits in exactly one square.

The pixels themselves are only "on" or "off", one bit each, which takes 6,144 bytes of memory. The colour comes from a separate list of 768 bytes, one for each square, called the attributes. Together that is a screen of 6,912 bytes, small enough to leave room for a game on the 16K machine.

Two colours per square

Each attribute byte holds four settings for its square:

  • Ink: the colour of every pixel that is on.
  • Paper: the colour of every pixel that is off.
  • Bright: one switch that makes both colours brighter.
  • Flash: a switch that keeps swapping the ink and paper over.

Eight colours at two brightness levels give 15 different colours on screen, because bright black is still black. But inside any single square you get just two of them, and they share the same brightness. Our full guide to attribute clash shows how the bits are packed into the byte, and the glossary explains the terms.

Follow one character across the screen

Picture a white ghost floating from left to right across a black sky. Every square it passes through has white ink on black paper, so the ghost looks perfect. Now put a green tree in its path, drawn with green ink on the same black paper.

  • Step one. The ghost is two squares away from the tree. Its squares are white on black and the tree's are green on black. Nothing is wrong.
  • Step two. The ghost drifts a few pixels into a square that also holds part of the tree. That square has only one ink. The game has to pick: either the ghost's half turns green, or the branches turn white.
  • Step three. As the ghost moves on, the wrong colour moves with it, one whole square at a time. You see a blocky patch of white leaves or green ghost that jumps along the grid rather than following the outline.

That jumping square is the clash. The pixels move smoothly, one at a time, but the colour can only change eight pixels at a time, so the two never quite line up.

Why Sinclair built it this way

Colour for every pixel would have needed several times as much memory, and memory was one of the dearest parts of a home computer in 1982. Setting colour once per square kept the screen small, suited text perfectly and let the Spectrum show colour at a low price. Our history of the Spectrum tells the rest of that story.

Games that hid it well

Programmers soon learned to design round the grid. A few approaches stand out:

  • One colour per room. Ultimate's Knight Lore (1984) drew each room of its castle in a single colour and changed that colour from room to room. With only one ink on screen, there was nothing to clash with.
  • Sprites the size of the grid. Don Priestley's Popeye for DK'Tronics (1985) used huge cartoon characters built from whole squares, so each part of the sailor could have its own colours. He used the same style again in The Trap Door.
  • Moving in step with the grid. Light Force (1986), the first game on Gargoyle Games' Faster Than Light label, is remembered for colourful moving graphics that were carefully lined up with the squares. The Spectrum Computing entry lists its authors and release.
  • A black sky. Bright sprites over black paper look natural whatever square they are in, which is one reason shoot-'em-ups like Jetpac look so clean.

Later on, demo coders went further and changed the attributes while the TV was still drawing the picture, line by line, to squeeze more colours into a square than it should hold. The trick needs exact timing and keeps the processor very busy, so it turns up mostly in demos and special effects rather than in busy games.

Clash in our own games

We work within the same rules in the arcade. In Present Tense every piece of a falling present is exactly one square, with the wrapping paper as the paper colour and the ribbon as the ink, so there is no clash at all. A Bit of Blighty takes the opposite view: the ball turns green as it crosses the tentacle lanes, a little bit of classic clash kept to empty sea where it does no harm.

Next time you load a game in the arcade, watch the edges of the characters as they move. Once you know about the grid, you start to see how each designer chose to live with it.

More from the journal

New games and guides, straight to your inbox

Hear first when a new Spectrum game lands in the arcade. No spam, and you can unsubscribe whenever you like.