Skip to Content

Colours and Palettes: From an 8-Bit Index to a 9-Bit Colour

The Next can show 512 colours, yet not one of its layers can name a single one of them. Every layer speaks in 8-bit indices, and a palette turns each index into a colour only at the very last moment. Change one palette entry, and every dot that uses it changes colour at once, without a byte of the picture being touched. And one value, $E3, means “nothing here” almost everywhere, so you can fill a whole screen with it and see straight through. How can a colour mean “no colour”?

Why should you care? Because on an 8-bit CPU, the palette is the cheapest paintbrush you have. Rewriting a picture costs thousands of bytes; rewriting a palette entry costs one register write. Water that flows, a sky that darkens into night, a sprite that comes in eight team colours from one pattern, a picture that fades to black: all of them are palette tricks. And the same mechanism decides what is transparent, so sooner or later every Next program meets it, usually at the moment a hole in its graphics stops being a hole. If you ask me, no part of the Next’s screen gives you more for less.

Read the first screen chapter first: it explains the layers and the pipeline the palettes sit in, including why the eight palettes live in two memories. The previous chapter explains the frame and how the picture leaves the machine; we pick up its thread at the very end.

The road ahead

We start with a single colour: nine bits of it, and the 8-bit shortcut most programs write instead, with a small trick that keeps full blue within reach. Then come the eight palettes, which layer owns which, and the three registers that write them. Next we ask where each layer’s index comes from: the ULA reads it from its attributes in three different ways, and the other layers build it from their dots and a palette offset. The key idea follows, and it is the one to read if you read nothing else: the Next has two quite different rules for transparency, and $E3, the colour of nothing, sits at the meeting point of both. After that, the colours the palettes hold at power-on, the effects palettes make cheap, shown on the machine, and, at the end, how a 9-bit colour becomes a signal on the cable.

The pictures here show the scene of the first screen chapter, taken from checked tests. Every fact was checked against the Next’s hardware design.

Nine bits of colour

Every colour the Next shows is RGB333: three bits each of red, green and blue, levels 0 to 7, 512 colours in all. The first screen chapter shows every one of them. Three bits a channel is what the video output carries, and nine bits is what a palette entry stores. I think of a palette as the wardrobe: the layers never pick a colour themselves, they only say which costume number to wear, and the wardrobe hands over the actual colour.

Nine bits is awkward for an 8-bit machine: one byte is one bit short. So most of the time your program writes colours in an 8-bit form, RRRGGGBB: three bits of red, three of green, and only two of blue, the upper two. The missing lowest bit of blue is made by the hardware: it is B1 OR B0 of the 8-bit value.

B1 OR B08-bit colourR27R16R05G24G13G02B11B009-bit colourR28R17R06G25G14G03B22B11B008-bit blue000110119-bit blue000011101111level
An 8-bit colour becomes a 9-bit one. Red and green are copied; the lowest blue bit is the OR of the two blue bits written.

Why OR, and not simply 0? Because of the four blue levels it gives. With a 0, two blue bits would reach the levels 0, 2, 4 and 6, and never full blue. With the OR they reach 0, 3, 5 and 7: no blue and full blue both, and two steps between them, nearly even. Neat, isn’t it? One gate, and an 8-bit colour can be as bright as a 9-bit one, which is what matters most. I would not have thought of it, and I am glad someone did.

Want all nine bits? Then write them in two goes, through the 9-bit Palette Value register, NextReg $44. The first write is the upper eight bits, the same RRRGGGBB, and the second write carries the lowest blue bit in bit 0. Bit 7 of the second write has another job, for Layer 2 only: the priority bit that lifts a Layer 2 dot above every other layer, whatever their order. My advice: use the 8-bit form until you need that last bit of blue or the priority bit, and only then pay for the second write.

1st writeheld until thesecond writeR27R16R05G24G13G02B21B102nd writestores the entry;the index moves onP7–6–5–4–3–2–1B00priority(Layer 2)reserved, 0
The two writes of NextReg $44. Nothing is stored until the second write arrives.

Eight palettes

There are eight palettes of 256 entries: a first and a second one for each of the ULA (which LoRes shares), Layer 2, the sprites and the tilemap. Each layer shows one of its two at a time, and your program can edit any of the eight, shown or not, with two independent choices in the registers:

firstsecondULA256 entriesedit: NextReg $43bits 6–4 = 000256 entriesedit: NextReg $43bits 6–4 = 100shown:NextReg $43 bit 1Layer 2256 entriesedit: NextReg $43bits 6–4 = 001256 entriesedit: NextReg $43bits 6–4 = 101shown:NextReg $43 bit 2sprites256 entriesedit: NextReg $43bits 6–4 = 010256 entriesedit: NextReg $43bits 6–4 = 110shown:NextReg $43 bit 3tilemap256 entriesedit: NextReg $43bits 6–4 = 011256 entriesedit: NextReg $43bits 6–4 = 111shown:NextReg $6B bit 4memory 1: ULA and tilemapmemory 2: Layer 2 and sprites
The eight palettes. The code you write to NextReg $43 bits 6–4 picks the palette you edit; another bit picks the palette each layer shows.

Two of every layer is not luxury. Your program can prepare the second palette while the first is on screen, and then switch the whole layer to its new colours with one register write, between two frames or in the middle of one. I think of it as a stage with two sets of lights: the audience sees one while the crew quietly rigs the other. Every layer has two racks in the wardrobe, in other words, and only one of them is on stage at a time.

Writing and reading a palette

Writing a palette takes three steps. Bits 6–4 of the Palette Control register, NextReg $43, pick the palette. The Palette Index register, NextReg $40, sets the index of the first entry to write. Then each write to the 8-bit Palette Value register, NextReg $41, stores one 8-bit colour into the entry at the index and moves the index on by one, so a run of colours goes into a run of entries without setting the index again:

NextReg $43which paletteNextReg $40index = 16NextReg $41entry 16, → 17NextReg $41entry 17, → 18NextReg $41entry 18, → 19each write to NextReg $41 stores one colour and moves the index on(unless NextReg $43 bit 7 stops it)with NextReg $44, two writes per entry;a write to NextReg $40, $41 or $43 restarts the pair
Writing a palette: one index, then a colour per write. NextReg $43 bit 7 stops the index moving on, for a program that wants to rewrite the same entry again and again.

Let’s set four shades of red into Layer 2’s first palette:

; Layer 2's first palette, entries 16-19: four reds nextreg $43,%00010000 ; Layer 2 palette 1, index moves nextreg $40,16 ; start at entry 16 nextreg $41,%01000000 ; red 2 nextreg $41,%10000000 ; red 4 nextreg $41,%11000000 ; red 6 nextreg $41,%11100000 ; red 7

With the 9-bit Palette Value register, NextReg $44, it works the same way, with two writes per entry; the index moves on after the second. A write to NextReg $40, $41 or $43 in between restarts the pair, so your program can never leave half a colour behind. I find that a thoughtful touch: the hardware will not let a slip in your code leave the wardrobe in a mess.

You can read the entries back, too. Reading NextReg $41 gives the upper eight bits of the entry at the index, and reading NextReg $44 gives its second byte, the lowest blue bit and the priority bit. Reads never move the index on.

The ULA: three maps of one palette

The palettes are only half of the story; the other half is the index each layer looks up. Every layer makes its 8-bit index in its own way, and the ULA’s way is the oddest, so let’s start there. The veteran, after all, was dressing its dots long before the Next had a wardrobe.

The ULA’s dots are not bytes but attributes: a bitmap bit says “ink” or “paper”, and the cell’s attribute says which colours those are. The Next can read the same attribute byte three ways, and each uses different entries of the ULA palette:

  • Standard, as on the Spectrum: INK uses entries 0–7, BRIGHT INK 8–15, PAPER 16–23 and BRIGHT PAPER 24–31. The border uses the PAPER entries. FLASH swaps ink and paper, as it always did. Change these 32 entries, and you change the Spectrum’s colours: old software keeps working, in new clothes.
  • ULANext (bit 0 of the Palette Control register, NextReg $43): the attribute byte is split by a mask in the ULANext Attribute Byte Format register, NextReg $42. The bits the mask covers are the INK, an index from 0 upward; the rest are the PAPER, an index from 128 upward, and the border uses the PAPER entries too. A mask of $07 gives 8 inks and 32 papers, $FF gives 256 inks and takes paper and border from the fallback colour. FLASH and BRIGHT are gone: their bits are colour now.
  • ULA+ (bit 3 of the ULA Control register, NextReg $68, or ULA+‘s own ports): a standard from other Spectrum clones, with 64 colours in entries 192–255. FLASH and BRIGHT choose one of four groups of 16, each with 8 inks and 8 papers. ULA+ software writes its colours to port $FF3B in its own bit order, green first; the Next reorders them into RRRGGGBB and stores them in the ULA palette like any other colour.

Which one would I pick? For new code, ULANext: it frees the most colours from one attribute byte. ULA+ is for software already written for it, and the standard map is for everything that should look exactly like a Spectrum.

03264128192255standardINK · BRIGHT INK · PAPER and border · BRIGHT PAPERINKULANextINK: attribute AND maskPAPER and border: 128 + the restULA+4 groups of 8 INK + 8 PAPER
The entries of the ULA palette each mode uses. In ULANext the split moves with the mask; with the mask $07 shown here, PAPER takes entries 128–159.

The other layers: a dot and an offset

The other layers do not have attributes; they have real pixels, here called dots. Each dot is a number stored in memory, and the layer turns it into a palette index, a number from 0 to 255. How it does that depends on how big a dot is.

Think of an index as two hex digits. This is the picture I find most useful in the whole section. An index is one byte, 0 to 255, or $00 to $FF in hex. Each hex digit is four bits, and you can draw the palette’s 256 entries as 16 rows of 16: the first digit is the row, the second the column. Entry $59 is in row 5, column 9.

second digit: the columnfirst digit: the row0123456789ABCDEF$0x$1x$2x$3x$4x$5x$6x$7x$8x$9x$Ax$Bx$Cx$Dx$Ex$Fxrow $5x: 4-bit dots, offset 5row $6x: the same dots, offset 6the dot (0–F) picks the column$A8 → $B8:an 8-bit dot, offset 1one row down, the same column$E3 → $F3: the same for “empty”from row $F, a row down is row $0
The palette as 16 rows of 16 entries. An index’s first hex digit is its row, its second the column. The highlights are the examples of the text below.

Dots come in two sizes.

  • An 8-bit dot is a whole byte, $00 to $FF: two hex digits, a complete index. Layer 2’s dots in its 256 × 192 and 320 × 256 modes are 8-bit, one byte per dot, and so are the dots of 8-bit sprite patterns.
  • A 4-bit dot is half a byte, 0 to F: one hex digit, so one byte holds two dots, the left dot in the first digit and the right dot in the second. 4-bit sprite patterns, tiles, Layer 2’s 640 × 256 mode and LoRes in Radastan mode store their dots this way. They save half the memory, but a single digit can name only 16 entries.

The palette offset fills the gap. The offset is one more hex digit, 4 bits, 0 to F, that each of these layers keeps beside its dots. What the layer does with it depends on the dot:

  • A 4-bit dot has no first digit, so the offset becomes the first digit. Offset 5 and dot 9 make index $59. So the offset picks the row and the dot picks the column: a 4-bit sprite with offset 5 uses the 16 entries of row 5, $50 to $5F, and the same sprite with offset 6 uses row 6 and appears in a different set of 16 colours. The pattern does not change; only its row of the palette does.
  • An 8-bit dot already has both digits, so the offset is added to its first digit, and the second digit is left alone. Layer 2 byte $A8 with offset 1 shows entry $B8: one row down, the same column. If the first digit passes F it wraps round to 0: $F3 with offset 1 shows $03. With offset 0, nothing changes, which is why Layer 2 normally shows its bytes as they are.
a 4-bit dot: one hex digit4-bit sprites and tiles,Layer 2 at 640 wide, Radastan59the offsetthe dot0101100159index $59the offset becomes the first digit,the dot the second: 5 × 16 + 9 = 89an 8-bit dot: two hex digitsLayer 2 at 256 and 320 wide,8-bit spritesA81+the dotthe offsetB8index $B8A + 1 = B8 stays 8one row down$E3 + offset 1 = $F3$F3 + offset 1 = $03 (F + 1 wraps to 0)the offset is added to the first digit only
The two rules side by side. A 4-bit dot gets the offset in front of it; an 8-bit dot gets the offset added to its first digit.

The two rules serve two different purposes. For 4-bit dots the offset is what makes them useful at all: 16 colours per sprite or tile, but up to 16 different sets of them in one palette. For 8-bit dots it is a way to shift a whole picture’s colours to another part of the palette without rewriting a byte of it, for an effect or to share one palette between pictures. I like to think of the 4-bit rule as choosing a rack in the wardrobe, and the 8-bit rule as moving the whole wardrobe along by a few racks.

Every layer with dots keeps its offset somewhere else. Two of them are in a register of their own, Layer 2’s in the Layer 2 Control register, NextReg $70, and LoRes’s in the LoRes Control register, NextReg $6A:

LayerIts dotsIts offsetThe index
Layer 2, 256 × 192 and 320 × 2568-bitNextReg $70 bits 3–0, one for the whole layerthe byte, offset added to the first digit
Layer 2, 640 × 2564-bit, two per byteNextReg $70 bits 3–0offset, then the dot
Sprites, 8-bit patterns8-bitin each sprite’s attributes, one per spritethe dot, offset added to the first digit
Sprites, 4-bit patterns4-bit, two per bytein each sprite’s attributesoffset, then the dot
Tilemap4-bit, two per bytein each tile’s attribute byte, one per tileoffset, then the dot
LoRes8-bitNextReg $6A bits 3–0, one for the whole screenthe byte, offset added to the first digit
LoRes, Radastan mode4-bit, two per byteNextReg $6A bits 3–0offset, then the dot

The tilemap’s text mode is the extreme case. Its dots are a single bit, on or off, so nearly the whole index comes from the tile’s attribute: a 7-bit offset, with the dot’s one bit as the last bit of the index. Every tile of text can have its own pair of colours.

Keep one consequence in mind for what follows, because I think it is the most important sentence here: an offset moves every dot, and for an 8-bit layer that includes the byte your program uses for “nothing here”. The next sections, on transparency and on what palettes make cheap, show what that does.

Two rules for transparency

The first screen chapter says that every layer answers “am I transparent here?” for every dot. Here is how the answer is made, and why there are two different rules for it. If you read only one section, I would make it this one:

the layer’s dotits valuethe paletteoffset, then lookupa 9-bit colouron to stage 2the index test, before the palettea sprite dot is transparent if its value equalsthe value held in NextReg $4Ba tile dot is transparent if its value equalsthe value held in NextReg $4Cthe colour test, after the palettea dot is transparent if the upper 8 bits of its colourequal the value held in NextReg $14for the ULA, LoRes, Layer 2 and text-mode tilestested before the offset:a hole in a pattern stays a hole
The two transparency tests. A sprite or tile dot is compared, before the palette, with the value your program has put in NextReg $4B or $4C; a colour is compared, after the palette, with the value in NextReg $14.

The first rule, the index rule, makes a hole in a shape. A sprite dot is transparent when its pattern value equals the value in the Sprite Transparency Index register, NextReg $4B, and a tile dot when its 4-bit value equals the value in the Tilemap Transparency Index register, NextReg $4C (for 4-bit sprites, the lower four bits of NextReg $4B). The test is made on the dot itself, before the palette offset is applied. That is what makes a pattern reusable: the hole is part of the shape, and it stays a hole whichever offset a sprite or tile is drawn with, and whatever the palette holds. This is the rule I trust: a hole in a shape is a property of the shape, and nothing in the wardrobe can fill it.

The second rule, the colour rule, makes a colour that means nothing. The ULA, LoRes, Layer 2, and tiles in text mode use it: a dot is transparent when its colour, after the palette, equals the global transparency colour, held in the Global Transparency Colour register, NextReg $14. NextReg $14 is an 8-bit colour, and it is compared with the upper eight bits of the 9-bit colour, so the lowest blue bit does not matter: two colours that differ only in it are both transparent.

These layers draw whole screens of colours, and for a picture “this colour means see-through” is the natural rule. But because the test is made on the colour, it has consequences, and let me warn you: every one of them will surprise you at least once.

  • Any index can be transparent. Whatever entry holds the colour in NextReg $14 makes its dots transparent, and two entries with that colour make two transparent indices.
  • A palette change can make dots appear or vanish. Give an entry the colour in NextReg $14 and every dot using it disappears; give the transparent entry another colour and the “empty” parts of the layer suddenly show. The section on what palettes make cheap shows both on the machine.
  • The offset moves transparency too. The offset is added before the lookup, so with an offset the “empty” byte $E3 points at another entry, with another colour.
  • Changing NextReg $14 changes the meaning of every layer that uses it. Set it to some other colour and that colour vanishes from the ULA, LoRes and Layer 2 alike, while every dot that was $E3 becomes visible.

$E3: the colour of nothing

The Global Transparency Colour register, NextReg $14, starts at $E3, and so do the sprites’ Sprite Transparency Index register, NextReg $4B, and the fallback colour, while the tilemap’s Tilemap Transparency Index register, NextReg $4C, starts at $F. $E3 is 111 000 11, a bright magenta, a colour a picture rarely wants. And in the default Layer 2 and sprite palettes, entry $E3 holds the colour $E3 (see the colours at power-on, below). So out of the box, a Layer 2 byte $E3 and a sprite pattern value $E3 are both invisible, by two different rules that happen to agree. Two locks, one key. The first screen chapter calls $E3 the Next’s way of saying “nobody home”, and I cannot improve on that.

The same choice explains a detail of the ULA’s default palette. Pure bright magenta, red 7, green 0, blue 7, would be the colour $E3 itself, and every bright magenta dot of the Spectrum screen would be a hole. So the default ULA palette gives bright magenta one step of green. Spectrum fans, rest easy: your magenta is still there, just a touch greener.

The fallback colour

When every layer answers “transparent” for a dot, the picture still needs a colour. It is the fallback colour, held in the Fallback Colour register, NextReg $4A: an 8-bit colour made into nine bits the same way as a write to the 8-bit Palette Value register, NextReg $41. The ULA uses it in two more places: in ULANext with the mask $FF, as the paper and the border, and for any mask that is not one of the eight it accepts. I think of the fallback colour as the bare stage: what the audience sees when every actor has left.

The colours at power-on

The palette memories have no reset: a reset of the Next leaves their colours as they were. It is the Next’s firmware that fills them when the machine is switched on. My advice follows from that: a program that relies on a particular palette should write it, rather than trust whoever ran before.

  • The ULA palettes get the Spectrum’s colours: the eight colours at level 5 in entries 0–7, and BRIGHT at level 7 in entries 8–15, bright magenta with its step of green. The same 16 colours repeat in every block of 16 entries, so PAPER (16–31) has the same colours as INK, and any offset or mode that reaches another block still finds Spectrum colours there.
  • The Layer 2, sprite and tilemap palettes get the identity: entry n holds the 8-bit colour n. So until your program writes a palette, a Layer 2 byte or a sprite pattern value is an RRRGGGBB colour, and $E3 is the transparency colour.

Here are the ULA’s sixteen:

normal0: black0001: blue0052: red5003: magenta5054: green0505: cyan0556: yellow5507: white555BRIGHT8: black0009: blue00710: red70011: magenta71712: green07013: cyan07714: yellow77015: white777digits: red, green, blue levels (0–7)the red ring: bright magenta, one step of green
The default ULA palette, entries 0–15, with their red, green and blue levels. The normal colours use level 5, the BRIGHT ones level 7.

What palettes make cheap

A palette sits between the picture’s memory and the screen, so changing it changes the screen without touching the memory. On an 8-bit CPU, that is the difference between one register write and thousands of bytes, and I find these the most satisfying effects on the machine:

  • Palette cycling. Rotate the colours of a run of entries, and water flows, lights chase, a waterfall falls, while the bitmap stands perfectly still.
  • Fades. Darken every entry a step at a time, and the whole picture fades to black in a few frames, at the cost of 256 writes per palette.
  • Switching. Prepare the second palette and switch to it with one bit: day becomes night.
  • Recolouring. One sprite pattern in eight colourings needs eight offsets, not eight patterns.
  • Changing it mid-frame. A palette entry rewritten at every line gives one entry a different colour on each line: the sky gradients and colour bars of Next games.

For that last kind, and for most palette effects that follow the beam, the Copper is the best and the cheapest tool, and I would reach for it first. It is a small co-processor of its own, beside the CPU, that runs a list of up to 1,024 instructions in step with the beam: WAIT until the beam reaches a line and a position, and MOVE a value into a NextReg. The palette registers are NextRegs, so a Copper list can rewrite a palette entry at any line, or at several places along one: WAIT for the line, MOVE the index into the Palette Index register, NextReg $40, MOVE the colour into the 8-bit Palette Value register, NextReg $41. With bit 7 of the Palette Control register, NextReg $43, set, the index does not move on after a NextReg $41 write, so a gradient that recolours one entry needs a single MOVE per line.

Everything about it is cheaper than doing the same with the CPU. Once the list is written, it costs the CPU nothing: no interrupt, no instruction, not a T-state, every frame, by itself. And it is on time: the CPU answers a line interrupt only when its current instruction ends, a few T-states earlier or later from frame to frame, while the Copper makes its MOVE at the position it waited for, every frame alike. The chapter on changing the picture mid-frame explains the Copper in detail, and the Copper guide shows how to watch a Copper list at work in the IDE.

What do these tricks look like on the machine? Here is the scene of the first screen chapter, four times. Layer 2’s bitmap is the same in all four; only NextRegs changed:

as drawnentry $A8 rewrittenNextReg $43 = $10, NextReg $40 = $A8,NextReg $41 = $12palette offset 1NextReg $70 = $01entry $A8 given the colour $E3NextReg $40 = $A8, NextReg $41 = $E3
One bitmap, four pictures. Top right: one palette entry rewritten. Bottom left: an offset moves every byte, and the “empty” $E3 moves to an opaque pink that covers the layers below. Bottom right: the hills’ entry given the transparency colour; only their edge, another entry, remains.

Look at the bottom-left picture: it is the colour rule’s trap in action. The offset turned the hills from $A8 into $B8, as wanted, but it also turned every transparent $E3 byte into $F3, an opaque pink, and Layer 2, in front of the tilemap and the ULA, now covers them. Pink sky, nobody asked for it. A program that gives Layer 2 an offset has to give the entry its “empty” byte now lands on the transparency colour too, or use another byte for “empty”. I would do the first: it is one more palette write, and it keeps “empty” meaning the same byte everywhere in your code.

From palette to screen

The colour that leaves the pipeline is nine bits, and the outputs of the previous chapter carry it on. The VGA and RGB outputs have three bits a channel, so the colour goes out as it is, through a small digital-to-analogue converter for each channel. HDMI carries eight bits a channel, and the Next makes eight from three by repeating the bits: 101 becomes 10110110.

0000000000003600100100100730100100100110901101101101146100100100101821011011011021911011011011255111111111113 bits8 bitsthe three bits repeated: even steps, and level 7 is full brightness
A 3-bit level as eight bits on HDMI. Repeating the bits spreads the eight levels evenly from 0 to 255.

Repeating is a cheap and good way to stretch a value: it needs no arithmetic, only wires, and it gives the same result as scaling by 255/7 and rounding. Level 0 stays black, level 7 becomes full 255, and the steps between are within a unit of even. I find this one of the prettiest tricks in the whole machine: free, exact, and made of nothing but wires.

What to take home

Time to close the wardrobe. Every colour the Next shows is RGB333, 512 colours. Programs usually write the 8-bit form RRRGGGBB, whose missing blue bit is B1 OR B0, so blue still reaches levels 0, 3, 5 and 7; NextReg $44 writes all nine bits, and the Layer 2 priority bit, in two writes.

There are eight palettes, two each for the ULA, Layer 2, the sprites and the tilemap. NextReg $43 bits 6–4 pick the one you edit, and separate bits pick the one each layer shows. NextReg $40 sets the index, and each NextReg $41 write stores a colour and moves the index on.

The ULA makes its indices from attributes in three maps, standard, ULANext and ULA+. The other layers use their dots with a 4-bit palette offset: it becomes the first hex digit of a 4-bit dot, and is added to the first digit of an 8-bit one.

Transparency has two rules. The sprites and the tilemap test their index, against NextRegs $4B and $4C, before the offset; the ULA, LoRes and Layer 2 test their colour, against NextReg $14, after the palette, so for those three a palette change or an offset can make dots appear or vanish. $E3 is the colour of nothing by default, which is also why the default bright magenta has one step of green, and when every layer is transparent, the fallback colour in NextReg $4A shows.

At power-on the firmware fills the ULA palettes with the Spectrum’s colours and the others with the identity; a reset keeps whatever they hold. Palettes make colour changes cheap: cycling, fades, switching, recolouring and per-line changes, which the Copper makes at exact beam positions without costing the CPU a thing. And at the very end, the 9-bit colour goes out as three bits a channel on VGA and RGB, and with its bits repeated to eight on HDMI. Five hundred and twelve colours, and you now know the way to every one of them.

Last updated on