used for Layer2)9. It may seem to be a bit inefficient as it stands, because it appears to be wasting memory but that's only if we store our palette in memory before we load it, otherwise palettes do not use memory at all and they only need to be set once and the memory used by the BANK method can be immediately released to the system.
You have already seen an example of this method in the Extended Colour Attribute Display System section where a palette is set up first as colours and then assigned into the chosen layer palette. Could you change it to accept double-byte colour values?
The tables that follow, show the proper format for single and double-byte palette entries. The integer values are included for a better understanding of the conversion process. In actuality, you can use either the BIN keyword or the %@ qualifier to enter binary numbers directly.
| First Byte | Second Byte | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| R₁ | R₂ | R₃ | G₁ | G₂ | G₃ | B₁ | B₂ | P2 | 0 | 0 | 0 | 0 | 0 | 0 | B₃ |
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
| 4 | 2 | 1 | 4 | 2 | 1 | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Table 8– Double byte colour entry
| First Byte | |||||||
|---|---|---|---|---|---|---|---|
| R₁ | R₂ | R₃ | G₁ | G₂ | G₃ | B₁ | B₂ |
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| 4 | 2 | 1 | 4 | 2 | 1 | 2 | 1 |
| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Table 9 – Single byte colour entry
Writing the entire palette into memory is not the only option available to the user in order to program a palette. It is also possible to specify individual colours within the palette using the following compound command (as with the rest of the examples in this section layer here implies a memory space organisational unit):
LAYER PALETTE number, index, value
where number is the current layer palette we wish to update (0 or 1), index is the index of the palette entry to be updated (0 to 255), and value is the colour components value expressed in binary using either the BIN keyword or the %@ qualifier in RGB3 format. That means that the colour in that case is ALWAYS 9-bit For example:
LAYER PALETTE 0,0,BIN 110010011
that sets colour index 0 in palette 0 to a nice pink is exactly the same as:
LAYER PALETTE 0,0,%@110010011
Try:
PRINT "B"; CHR$ 8; OVER 1; "/"
Where the / has cut through the B, it has left a white dot. This is the way overprinting works on the ZX Spectrum: two papers or two inks give a paper, one of each gives an ink. This has the interesting property that if you overprint with the same thing twice you get back what you started off with. If you now type:
9 In the future 15-bit (with priority) or even 16-bit (without priority) may be possible on an HDMI display as the hardware is very capable of displaying it albeit slowly
ZX Spectrum Next User Manual, 3rd Edition (ISBN 978-1-5272-5496-1), written and illustrated by Phoebus R. Dokos. Copyright © 2020-2024 Phoebus Dokos / SpecNext Ltd. Licensed under CC BY-NC-SA 4.0. This is a transcription and can contain errors; check any doubt against the printed page.