| |||||||||
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.
| Full CGA 16-color palette (hex values as per 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 RGB 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 could display the same 16 colors; however it was programmed differently from IBMs CGA and had fewer limitations, so that the rest of this article does not apply to it.
CGA offered two text modes:
| Fixed CGA 4-color palette #1 | ||
| default | 5 - magenta | |
| 3 - cyan | 7 - white (light gray) | |
| Fixed CGA 4-color palette #2 | ||
| default | 4 - red | |
| 2 - green | 6 - brown (orange) | |
CGA offered two commonly-used graphics modes:
Little-known to many was an additional 160×200 graphics mode (pixel aspect ratio 1.67:1), which could utilize 16 different colors (not the same color table as the CGA color set, but similar). This mode, however, only worked with the RCA jack composite video output. This port, present on all IBM CGA cards and optional on clone cards, allowed the user to connect a TV set or composite color monitor to the computer.
This composite color mode was rarely utilized in software. No BIOS support led to poor programmer adoption. Also, most users preferred a monitor, as the only modes that could be displayed via composite video in color were composite color mode, 40-column text mode and 320×200 graphics mode. The IBM PC was primarily viewed as a business computer, so the number of television sets connected to an IBM PC was very low. As such, only a handful of software titles used the 160×200 graphics mode, most of them games.
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 . Most software titles did not use these possibilities, but there were a few impressive exceptions.
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.
| Character 221. | |
| 221 with blue text and red background color. | |
| 221 with red text and blue background color. | |
| 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 character 221, 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.
|
Although a roundabout way of achieving 16 color graphics display, this worked quite well 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 .
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 rows between 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.
CGA had two main competitors:
The CGA card was succeeded by IBM's Enhanced Graphics Adapter (EGA) card, which supported most of the CGA modes, and added modes with up to 640×350 pixels with a software-selectable palette of 16 colors out of 64.