Color Graphics Adapter

The Color Graphics Adapter (CGA), introduced in 1981, was IBM's first color graphics card, and the first color computer display standard for the IBM PC.

The standard IBM CGA graphics card was equipped with 16 kilobytes of video memory. The CGA card featured several graphics and text modes with a resolution of up to 640×200 and up to 16 colors (albeit not at that resolution). CGA was commonly considered to be able to display a maximum of 4 colors at a resolution of 320×200; however, there were several ways (some official, some not) to display more colors, even for graphics display purposes.

Missing image
Alleycat.png
The 320×200 4 color mode with its default colors — title screen from Alley Cat.
Contents

The CGA color palette

Full CGA 16-color palette
(hex values adapted from MC6845 specification)
0 — black
#000000
8 — (dark) gray
#545454
1 — blue
#0000A8
9 — bright blue
#5454FE
2 — green
#00A800
10 — bright green
#54FE54
3 — cyan
#00A8A8
11 — bright cyan
#54FEFE
4 — red
#A80000
12 — bright red
#FE5454
5 — magenta
#A800A8
13 — bright magenta
#FE54FE
6 — brown (orange)
#A85400
14 — yellow
#FEFE54
7 — white (light gray)
#A8A8A8
15 — bright white
#FEFEFE

The CGA card worked with CRT RGBI color monitors. It was based around the Motorola MC6845 display controller and had a palette of 16 colors. Red, green and blue corresponded to the three cathode rays and black meant all rays were almost off. Cyan was a mix between the blue and green rays, magenta was a mix between blue and red and orange-brown was a mix between green and red. White (or light gray) was a mix between all three rays.

The remaining 8 colors were achieved by turning on an "intensifier" bit, giving a brighter version of each color, although the dark gray color was indistinguishable from black with many monitors. CGA's "RGB plus intensity bit" design was also called RGBI.

The Commodore 128 used the same method of transmitting colors on its RGBI output and thus could use the same monitors and display the same 16 colors.

Standard text modes

CGA offered two text modes:

Standard graphics modes

Fixed CGA 4-color palette #1
default5 — magenta
3 — cyan7 — white (light gray)
Fixed CGA 4-color palette #2
default4 — red
2 — green6 — brown (orange)

CGA offered two commonly-used graphics modes:

The 1:1.2 pixel aspect ratio needed to be taken into account when drawing large geometrical shapes on the screen.

The composite video modes

Little-known to many was an additional 160×200 graphics mode (pixel aspect ratio 1.67:1), which could utilize 16 different colors. The colors in Composite color mode did not use the same color table as the CGA color set, but was more like that of the Apple II's "double-hi-res" mode, as both used a similar technique (composite signal color artifacting). Composite color mode was rarely utilized in software: No BIOS support led to poor programmer adoption, and the cost of an IBM system was high enough that most people who could afford it could also afford the more expensive RGB monitor IBM offered. Only a handful of software titles used the 160×200 graphics mode, most of them games.

A common misconception is that Composite color mode was supported on some RGB-equipped machines, but this is a direct contradiction to how composite color mode technically functioned. A more likely explanation for the misconception is that people confuse the 160×200 modes of the PCjr/Tandy 1000 and Amstrad CPCs as being the same thing (they are identical in resolution, but not color and memory organization). Attempting to set Composite color mode on any card with an RGB monitor attached would appear identical to the 640×200 graphics mode.

Further graphics modes and tweaks

A number of official and unofficial features existed that could be exploited to achieve better graphics on a monitor.

Some of these above tweaks could even be combined. Examples could be found in several games [2]. Most software titles did not use these possibilities, but there were a few impressive exceptions.

The 160×100 16 color mode

Technically, this mode was not a graphics mode, but a tweak of the 80×25 text mode. The character cell height register was changed to display only 2 lines per character cell instead of the normal 8 lines. This quadrupled the number of text rows displayed from 25 to 100. These "tightly squeezed" text characters were not full characters. The system only displayed their top two lines of pixels (8 each) before moving on to the next row.

 Missing image
ASCII.221.character.gif
Image:ASCII.221.character.gif

 
 Character 221. 
 Missing image
Half-block.character.blue.red.gif
Image:Half-block.character.blue.red.gif

 
 221 with blue text and red background color. 
 Missing image
Half-block.character.red.blue.gif
Image:Half-block.character.red.blue.gif

 
 221 with red text and blue background color. 
 Missing image
ASCII.222.character.gif
Image:ASCII.222.character.gif

 
 Character 222. 

Character 221 in the extended ASCII character set consisted of a box occupying the entire left half of the character matrix. (Character 222 consisted of a box occupying the entire right half.)

Because each character could be assigned different foreground and background colors, it could be colored (for example) blue on the left (foreground color) and bright red on the right (background color). This could be reversed by swapping the foreground and background colors.

Using either character 221 or 222, each half of each truncated character cell could thus be treated as an individual pixel— making 160 horizontal pixels available per line. Thus, 160×100 pixels at 16 colors, with an aspect ratio of 1:1.2, were possible.

 
Missing image
Single.pixel.in.CGA.160x100.mode.gif


 

A single big "pixel" in 160×100 mode.
This is the two top rows of half of character 221.
Note the 8 constituent pixels and the
overall 1:1.2 aspect ratio.

Although a roundabout way of achieving 16 color graphics display, this worked quite well [3] and the mode was even mentioned (although not explained) in IBM's official hardware documentation.

More detail could be achieved in this mode by using other characters, combining ASCII art with the aforesaid technique.

The same text cell height reduction technique could also be used with the 40×25 text mode. This only made sense when using ASCII art, because without it the resulting resolution would only have been 80×100 [4] [5] [6].

Bugs and errata

CGA's most noticeable hardware bug was snow in 80×25 text mode. The display RAM on the original IBM CGA card was not dual-ported — read and write access was not possible simultaneously. As such, random pixels were displayed whenever display memory was written to by the CPU at the same time as being read by the display hardware. This bug was fixed in most third-party clones, but still existed in some iterations (such as the AT&T PC 6300 display adapter).

For programmers, another annoyance was that CGA display memory in graphics modes was interlaced. Normally, video memory is strictly linear: the next row of display data corresponds to the next row of pixels. But with CGA, the next row of display data corresponded to the row of pixels two rows down. This continued until the end of the screen and only with the second half of display data were the in-between rows addressed. So the first half of display memory was for rows 0, 2, 4, 6, 8, 10, etc., till the end of the screen and the second half of CGA RAM was for rows 1, 3, 5, 7, 9, etc. This added extra calculation steps to most CGA graphics operations if the programmer wanted to avoid visual artifacts when updating the screen.

Competing adapters

CGA had two main competitors:

The CGA card was succeeded in the consumer space by IBM's Enhanced Graphics Adapter (EGA) card, which supported most of CGA's modes, and added an additional resolution (640×350) as well as a software-selectable palette of 16 colors out of 64 in both text and graphics modes.

References

See also

See also: Color Graphics Adapter, 1981, 1982, ASCII art, Alley Cat, Amstrad CPC, Apple II, California Games, Cathode ray tube, Commodore 128