Contents

Linear CGA data

For CGA tiles, one byte stores the color information for four pixels. Since the tile has 64 pixels (8×8), each tile takes up 16 bytes.

There are four possible combinations of 2 bits (2^2). The actual colors for each pixel depend on the active CGA palette, of which there are three basic ones. See wp:Color Graphics Adapter for details. Every game can use the four color palette differently. Catacomb uses color palette 1 with high intensity.

With color palette 1i, each pair of bits represents a different color:

Bits

Color

00

black

01

light cyan

10

light magenta

11

white

Resulting Image (actual size):

Resulting Image (8× the size):

Interlaced CGA Data

Offsets into file data

Line (Y)

Plane

Column (X)

0-3

4-7

8-11

12-15

0

0

00

01

02

03

1

1

10

11

12

13

2

0

04

05

06

07

3

1

14

15

16

17

4

0

08

09

0A

0B

5

1

18

19

1A

1B

6

0

0C

0D

0E

0F

7

1

1C

1D

1E

1F

This arrangement stores the image data in two halves - even lines and odd lines.

It is essentially two black-and-white (1bpp) images one after the other, each half the height of the total picture. The first image is drawn on lines 0, 2, 4, etc. and the second image is drawn on lines 1, 3, 5, etc. to produce the final picture. Each row of data is in the same arrangement as #Linear CGA data above.

A 16×8 image in this arrangement is described in the table on the right. The byte at index 00 contains the first eight-pixels in the image, and the byte at offset 15 contains the second four pixels on the fourth line.

Full-Screen Images

Many full screen CGA images store their data in interlaced format, so that they can be loaded directly into video memory without any additional processing. In some of these cases however, the data is loaded in one operation for the entire image rather than two operations (one per plane.)

This is significant because in 320×200 mode, each plane occupies 8000 bytes of memory, leading to 16000 bytes for the entire image. However because the planes are aligned in CGA memory, the second plane actually starts at offset 8192 into memory, not at offset 8000.

This means that file formats which load an image in a single operation will have 192 bytes of padding between the planes (and possibly 192 bytes after the last plane), which should be ignored when processing the image.

A quick way to tell is to look at the image size. If it is 16000 bytes, it contains two planes with no padding, and if it is 16192 or 16384 bytes then it contains padding between planes.

CGA palettes

RGB values of CGA palettes

Colour index

Palette

0

0i

1

1i

2

2i

0

Application-specific (default #000000)

1

#00AA00

#55FF55

#00AAAA

#55FFFF

#00AAAA

#55FFFF

2

#AA0000

#FF5555

#AA00AA

#FF55FF

#AA0000

#FF5555

3

#AA5500

#FFFF55

#AAAAAA

#FFFFFF

#AAAAAA

#FFFFFF

The actual RGB values that correspond to each colour value depend on the palette in use by the game. This table lists the RGB values for all the CGA palettes.