Scratchpad

If you are new to Scratchpad, and want full access as a Scratchpad editor, create an account!
If you already have an account, log in and have fun!!

READ MORE

Scratchpad
Advertisement
ZX64 palette

256 Colour Palette

This is a proposed enhanced graphics mode for the ZX Spectrum designed by Cheveron, Nikki, and CSmith. It could be implemented as a plug-in replacement for the ULA in the 48K machines, in emulators, or in clones. It is designed to make it easy to re-colour existing software with the minimum of effort.

I/O Ports

The mode is controlled by two ports.

0xBF3B is the register port (write only)

The byte output will be interpreted as follows:

Bits 0-5: Select the register sub-group
Bits 6-7: Select the register group. Two groups are currently available:

     00 - palette group

          When this group is selected, the sub-group determines the
          entry in the palette table (0-63).

     01 - mode group

          This group ignores the sub-group.

0xFF3B is the data (read/write)

When the palette group is selected, the byte output will be interpreted as follows:

Bits 0-1: Blue intensity.
Bits 2-4: Red intensity.
Bits 5-7: Green intensity.

This mode uses a sub-set of 9-bit RGB. The low bit is duplicated (Bb becomes Bbb). This gives access to a fixed half the potential 512 colour palette. The jump in intensity happens in the lower range where it is less noticeable.

When the mode group is selected, the byte output will be interpreted as follows:

Bit 0: Palette mode select; on when set.

Note: Because of incomplete decoding, both by Sinclair and third-party add-on manufacturers, there are no free I/O ports on the Spectrum. Port xx3B was chosen because it clashes with only one item of hardware - the ZX Printer.

Software

PaletteEditor

The palette editor

The palette editor enables you to create a palette for use with existing software without needing to rewrite the software. You can save the palette and load it before loading the original software as normal. In this way all existing software can be re-coloured without any programming knowledge required.

Emulation

The 64 colour mode lookup table is organized as 4 palettes of 16 colours.

Bits 7 and 6 of each Spectrum attribute byte (normally used for FLASH and BRIGHT) will be used as an index value (0-3) to select one of the four colour palettes.

Each colour palette has 16 entries (8 for INK, 8 for PAPER). Bits 0 to 2 (INK) and 3 to 5 (PAPER) of the attribute byte will be used as indexes to retrieve colour data from the selected palette.

The complete index can be calculated as

ink_colour = (FLASH * 2 + BRIGHT) * 16 + INK
paper_colour = (FLASH * 2 + BRIGHT) * 16 + PAPER + 8

When scaling 3-bits of colour data to 8-bits for emulators that operate in high colour mode the following conversion should be used:

76543210

hmlhmlml

where h is the high bit, m is the middle bit, and l is the low bit of the original 3-bit value.

Advertisement