While the EGA can only display up to 16 colours at a time, those 16 can be chosen from a selection of 64 possible colours. Effectively this allows each of the red, green and blue channels to be independently set at four different levels (off, low, medium and high.)
| Default EGA 16-Color Palette|
|6||yellow / brown||#AA5500||010100||20|
|7||white / light gray||#AAAAAA||000111||7|
|8||dark gray / bright black||(#555555||111000||56|
The default EGA palette found in most DOS games is shown on the right. This is set up to be backwards-compatible with the 16 colours available in text mode on the original CGA. Notice that colour entry #6 (brown) doesn't fit in sequence with the other entries. This is because the CGA had additional circuitry to make this colour appear "more visually pleasing." The introduction of the EGA palette meant this adjustment no longer required additional hardware. Setting palette entry #6 to the in-sequence value of 6 (#AAAA00) instead of 20 reveals the "dark yellow" colour found in cheaper clone CGA monitors lacking the additional circuitry.
The default format
As there are 16 colours to change, it is easiest to write these values out as 16 bytes. In this case, the palette file is only 16 bytes long.
To convert from an EGA palette to RGB values, each 2-bit EGA red, green or blue value should be multiplied by 85, to produce the values 0, 85, 170 and 255.
To obtain the 2-bit value, the bits must be extracted as shown in the following table (where -H is the high bit and -L is the low bit, for each colour.)
Or as a formula:
red = 85 * (((ega >> 1) & 2) | (ega >> 5) & 1) green = 85 * (( ega & 2) | (ega >> 4) & 1) blue = 85 * (((ega << 1) & 2) | (ega >> 3) & 1)
There are not many EGA palettes in existence on account of so few games bothering to change the palette, and any palette is so short detection is difficult. Typically the first entry will be black (0x00) and the 16th white (0x3F) however even this is not guaranteed. Any value larger than 0x3F is invalid and can be used to identify files that are definitely not palettes.