There’s only one thing left to mention about colour – and that’s the border.
You can set it to any of the 8 main colours – bright and flash have no effect – using the ‘out’ command.
‘out’, and it’s mirror ‘in’, are somewhat special, as what they do is entirely down to the hardware you run it on. Out writes something to the hardware, where In reads from it. Both use a ‘port address’ – just a term for a certain part of the hardware.
To see the border to red, using the following:
ld a, 1 out (254), a
And that’s it! The colour, 0 to 7, is in A, and we send that out of port 254 – which the machine interprets as wanting to set the border colour. That port does other things to, both writing to, and reading from, but those are for another day…
There’s is literally nothing more to learn about displaying colours on the Spectrum – you can now put any colour you like on both the screen and the border 🙂