# Display pixel data format

The CPC, CPC+ and KC Compact have 3 official bitmapped graphics modes:

- Mode 0, low resolution, 2 pixels per byte, 16 colours
- Mode 1, medium resolution, 4 pixels per byte, 4 colours
- Mode 2, high resolution, 8 pixels per byte, 2 colours

The CPC and CPC+ have one unofficial bitmapped graphics mode:

- Mode 3, low resolution, 2 pixels per byte, 4 colours

The display mode is defined using the Gate-Array. If the mode is changed, the result will only be seen at the next HSYNC.

The standard resolutions are:

- 160x200pixels; 20x25 characters (low resolution)
- 320x200pixels; 40x25 characters (medium resolution)
- 640x200pixels; 80x25 characters (high resolution)

But, the width and height of the display area can be redefined using the 6845 CRTC, so it is possible to define other resolutions.

Pixel properties:

- a pixel will always be 1 scanline tall, regardless of mode setting
- the width of a pixel is different depending on the mode setting.
- the pixel defines a look-up into a re-defineable palette. The size of the palette depends on the mode setting.

## Mode 0

Properties of this mode:

- 2 pixels per display byte. Each pixel is defined from a re-defineable palette of 16 colours (pens 0-15).
- lowest resolution. (a pixel in this mode is 2 times the width of a mode 1 pixel, or 4 times the width of a mode 2 pixel).
- pixels are rectangular
- Each pixel is defined by 4 bits.

Order of pixel display:

pixel 0 | pixel 1

Bit mappings for Pixel 0:

| Bit in display byte
--- | ---
bit 3 | 1
bit 2 | 5
bit 1 | 3
bit 0 | 7

Bit mappings for Pixel 1:

| Bit in display byte
--- | ---
bit 3 | 0
bit 2 | 4
bit 1 | 2
bit 0 | 6

e.g. if pixel 0 is 13 and pixel 1 is 6, this is encoded as:

pixel 0: 1101 becomes 0-1-0-0-

pixel 1: 0110 becomes -0-1-1-0

and together becomes: 00110100

## Mode 1

Properties of this mode:

- 4 pixels per display byte. Each pixel is defined from a re-defineable palette of 4 colours (pens 0-3).
- medium resolution. (a pixel in this mode is half the width of a mode 0 pixel, or 2 times the width of a mode 2 pixel).
- pixels are square
- Each pixel is defined by 2 bits

Order of pixel display:

pixel 0 | pixel 1 | pixel 2 | pixel 3

Bit mappings for Pixel 0:

| Bit in display byte
--- | ---
bit 1 | 3
bit 0 | 7

Bit mappings for Pixel 1:

| Bit in display byte
--- | ---
bit 1 | 2
bit 0 | 6

Bit mappings for Pixel 2:

| Bit in display byte
--- | ---
bit 1 | 1
bit 0 | 5

Bit mappings for Pixel 3:

| Bit in display byte
--- | ---
bit 1 | 0
bit 0 | 4

## Mode 2

Properties of this mode:

- 8 pixels per display byte. Each pixel is defined from a re-defineable palette of 2 colours (pen 0 and 1).
- high resolution. (a pixel in this mode is quarter the width of a mode 0 pixel AND half the width of a mode 1 pixel).
- pixels are rectangular
- Each pixel is defined by 1 bit

Order of pixel display:

pixel 0 | pixel 1 | pixel 2 | pixel 3 | pixel 4 | pixel 5 | pixel 6 | pixel 7

Bit mappings for Pixel 0:

| Bit in display byte
--- | ---
bit 0 | 7

Bit mappings for Pixel 1:

| Bit in display byte
--- | ---
bit 0 | 6

Bit mappings for Pixel 2:

| Bit in display byte
--- | ---
bit 0 | 5

Bit mappings for Pixel 3:

| Bit in display byte
--- | ---
bit 0 | 4

Bit mappings for Pixel 4:

| Bit in display byte
--- | ---
bit 0 | 3

Bit mappings for Pixel 5:

| Bit in display byte
--- | ---
bit 0 | 2

Bit mappings for Pixel 6:

| Bit in display byte
--- | ---
bit 0 | 1

Bit mappings for Pixel 7:

| Bit in display byte
--- | ---
bit 0 | 0

## Mode 3

This mode is not official and exists on the CPC and CPC+ only and does not exist on the KC Compact.

Properties of this mode:

- 4 pixels per display byte. Each pixel is defined from a re-defineable palette of 4 colours (pens 0-3).
- lowest resolution. (a pixel in this mode is 2 times the width of a mode 1 pixel, or 4 times the width of a mode 2 pixel).
- pixels are rectangular

Order of pixel display:

pixel 0 | pixel 1

Bit mappings for Pixel 0:

| Bit in display byte
--- | ---
bit 1 | 3
bit 0 | 7

Bit mappings for Pixel 1:

| Bit in display byte
--- | ---
bit 1 | 2
bit 0 | 6