All the colours of the Spectrum (well, 15 of them!)

So we drew a green box, woohoo! But why was it green?  The Spectrum has 8 core colours: Black, Blue, Red, Magenta, Green, Cyan, Yellow, and White, and those can be used individually for the background (referred to in BASIC as ‘PAPER’), and foreground (INK), of a square on the screen – which are arranged as 24 rows of 32 columns.

I did promise you 15 colours in the title though, and that is done by making the colour ‘Bright’.  You might think that would make 16 colours, but even a bright black looks, erm, pretty black.

And finally, you can elect to have the square swap the foreground and background colours around every few seconds – by making it ‘Flash’.  A great example of this can be seen on the loading screen to Manic Miner.

All the combinations of this – 2 lots of 8 colours, with bright and/or flashing – can be stored in a single byte using the following calculation:

Combined value = INK + (PAPER * 8) + (BRIGHT? * 64) + (FLASH? * 128)

With each colour being assigned a number:

1 = BLUE
2 = RED
5 = CYAN

So our value of 32 is made up of black INK, green PAPER, no BRIGHT, and no FLASH, as that is 0 + (4*8) + (0*64) + (0*128) = 32

You might have tried changing that value, for example to 33, and found that nothing happened – and that was because there wasn’t actually anything under the square, so the foreground colour wasn’t seen.  We’ll fix all that shortly, and fill the screen with colour…


4 thoughts on “All the colours of the Spectrum (well, 15 of them!)

  1. I was tinkering with this last night, and got all the colours. I was using % notation to write the binary, like this:

    ld a, %00111000
    ld (22535),a

    So I was able to set the different bits, and get the different colours!

    Liked by 1 person

  2. Just in case anyone wondering about Bob’s equation for colour and how it makes up the byte, its made up in binary of:

    First 3 bits are the ink colour (again in binary meaning 000 to 111 which gives 0-7, thus providing all 8 colours)

    Next 3 bits are the paper colour (again 0-7 giving all 8 colours)

    Bit 7 is brightness

    Bit 8 is flash

    Thus every value in the byte from 0-255 is used and has some effect on colour, flash and bright. That’s why Bob’s next post can loop through every value when showing all colours.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s