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
(added .SCR extended format proposal)
Line 98: Line 98:
   
 
A 6912 byte .SCR file contains a standard Spectrum screen.
 
A 6912 byte .SCR file contains a standard Spectrum screen.
  +
A 6976 byte file contains a standard Spectrum screen followed by 64 colour registers.
+
A 6976 byte .SCR file contains a standard Spectrum screen followed by 64 colour registers.
   
 
A 12288 byte .SCR file contains a Timex hi-colour screen.
 
A 12288 byte .SCR file contains a Timex hi-colour screen.
  +
 
A 12352 byte .SCR file contains a Timex hi-colour screen followed by 64 colour registers.
 
A 12352 byte .SCR file contains a Timex hi-colour screen followed by 64 colour registers.
   
 
A 12289 byte .SCR file contains a Timex hi-res screen.
 
A 12289 byte .SCR file contains a Timex hi-res screen.
  +
A 12353 byte .SCR file contains a Timex hi-res screen followed by 64 colour registers.
+
A 12353 byte .SCR file contains a Timex hi-res screen followed by the hi-res colour information that was dumped from port 255, followed by 64 colour registers.
 
[[Category:ZX Spectrum technical information]]
 
[[Category:ZX Spectrum technical information]]

Revision as of 18:24, 16 October 2009

ZX64 palette

256 Colour Palette

This is a proposed enhanced graphics mode for the ZX Spectrum designed by Cheveron, Nikki, CSmith and KLP2. 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.

File:Fuse64.png

Manic Miner in 64 colour mode in Fuse on Ubuntu

Proposed Extension to the SZX Format

ZXSTPALETTE

The state of the ULA registers found in the 64 colour replacement ULA. This block may be present for any machine.

// Palette Block flags
#define ZXSTPALETTE_DISABLED  0
#define ZXSTPALETTE_ENABLED  1

// Palette Block. Contains the palette register values
typedef struct _tagZXSTPALETTEBLOCK
{
  ZXSTBLOCK blk;
  BYTE chFlags;
  BYTE chCurrentRegister;
  BYTE chAyRegs[16];
} ZXSTPALETTEBLOCK, *LPZXSTPALETTEBLOCK;

Members

   blk
      The block header. The block id is ZXSTBID_PALETTE ('P', 'L', 'T', 'T').
   chFlags
      A flags that indicates if the palette is enabled or if the normal display mode is in use. This can be one of:

Flag Meaning
ZXSTPALETTE_DISABLED Normal palette mode with BRIGHT and FLASH
ZXSTPALETTE_ENABLED 64 colour palette mode


    chCurrentRegister
      The currently selected palette register (0-63).
   chPaletteRegs
      The current values of the palette registers.

Proposed Extension to the SCR Format

A 6912 byte .SCR file contains a standard Spectrum screen.

A 6976 byte .SCR file contains a standard Spectrum screen followed by 64 colour registers.

A 12288 byte .SCR file contains a Timex hi-colour screen.

A 12352 byte .SCR file contains a Timex hi-colour screen followed by 64 colour registers.

A 12289 byte .SCR file contains a Timex hi-res screen.

A 12353 byte .SCR file contains a Timex hi-res screen followed by the hi-res colour information that was dumped from port 255, followed by 64 colour registers.