Color Graphics Adapter
The Color Graphics Adapter, originally also called the Color/Graphics Adapter or IBM Color/Graphics Monitor Adapter, introduced in 1981, was IBM's first color graphics card for the IBM PC and established a de facto computer display standard.
Hardware design
The original IBM CGA graphics card was built around the Motorola 6845 display controller, came with 16 kilobytes of video memory built in, and featured several graphics and text modes. The highest display resolution of any mode was, and the highest color depth supported was 4-bit.The CGA card could be connected either to a direct-drive CRT monitor using a 4-bit digital RGBI interface, such as the IBM 5153 color display, or to an NTSC-compatible television or composite video monitor via an RCA connector. The RCA connector provided only baseband video, so to connect the CGA card to a television set without a composite video input required a separate RF modulator.
IBM produced the 5153 Personal Computer Color Display for use with the CGA, but this was not available at release and would not be released until March 1983.
Although IBM's own color display was not available, customers could either use the composite output, or the direct-drive output with available third-party monitors that supported the RGBI format and scan rate. Some third-party displays lacked the intensity input, reducing the number of available colors to eight, and many also lacked IBM's unique circuitry which rendered the dark-yellow color as brown, so any software that used brown would be displayed incorrectly.
Output capabilities
CGA offered several video modes.Graphics modes:
- in 16 colors, chosen from a 16-color palette, utilizing a specific configuration of the text mode.
- * This used 4 bits per pixel, with a total memory use of / 8 = 8 kilobytes.
- in 4 colors, chosen from 3 fixed palettes, with high- and low-intensity variants, with color 1 chosen from a 16-color palette.
- * This used 2 bits per pixel, with a total memory use of / 8 = 16 kilobytes.
- in 2 colors, one black, one chosen from a 16-color palette.
- * This used 1 bit per pixel, with a total memory use of / 8 = 16 kilobytes.
Text modes:
- with pixel font
- with pixel font
Color palette
CGA uses a 4-bit RGBI 16-color gamut, but not all colors are available at all times, depending on which graphics mode is being used. In the medium- and high-resolution modes, colors are stored at a lower bit depth and selected by fixed palette indexes, not direct selection from the full 16-color palette.When four bits are used they are arranged according to the RGBI color model:
- The lower three bits represent red, green, and blue color components
- The fourth "intensifier" bit, when set, increases the brightness of all three color components.
| Color | I | R | G | B | Color | I | R | G | B |
| Black | 0 | 0 | 0 | 0 | Gray 2 | 1 | 0 | 0 | 0 |
| Blue | 0 | 0 | 0 | 1 | Light Blue | 1 | 0 | 0 | 1 |
| Green | 0 | 0 | 1 | 0 | Light Green | 1 | 0 | 1 | 0 |
| Cyan | 0 | 0 | 1 | 1 | Light Cyan | 1 | 0 | 1 | 1 |
| Red | 0 | 1 | 0 | 0 | Light Red | 1 | 1 | 0 | 0 |
| Magenta | 0 | 1 | 0 | 1 | Light Magenta | 1 | 1 | 0 | 1 |
| Brown | 0 | 1 | 1 | 0 | Light Yellow | 1 | 1 | 1 | 0 |
| Gray 1 | 0 | 1 | 1 | 1 | White | 1 | 1 | 1 | 1 |
These four colour bits are then interpreted internally by the monitor, or converted to NTSC colours.
With an RGBI monitor
When using a direct-drive monitor, the four color bits are output directly to the DE-9 connector at the back of the card.Within the monitor, the four signals are interpreted to drive the red, green and blue color guns. With respect to the RGBI color model described above, the monitor would translate the digital four-bit color number to some seven distinctive analog voltages in the range from 0.0 to 1.0 for each gun.
Color 6 is treated specially; normally, color 6 would become dark yellow, as seen to the right, but in order to achieve a more pleasing brown tone, special circuitry in most RGBI monitors, starting with the IBM 5153 color display, makes an exception for color 6 and changes its hue from dark yellow to brown by reducing the analogue green signal's amplitude. The exact amount of reduction differed between monitor models: the original IBM 5153 Personal Computer Color Display reduces the green signal's amplitude by about one third, while the IBM 5154 Enhanced Color Display internally converts all 4-bit RGBI color numbers to 6-bit ECD color numbers, which amounts to halving the green signal's amplitude. The Tandy CM-2, CM-4 and CM-11 monitors provide a potentiometer labelled "BROWN ADJ." to adjust the amount of green signal reduction.
This "RGBI with tweaked brown" palette was retained as the default palette of later PC graphics standards such as EGA and VGA, which can select colors from much larger gamuts, but default to these until reprogrammed.
Later video cards/monitors in CGA emulation modes would approximate the colors with the following formula:
red := 2/3×/4 + 1/3×/8
green := 2/3×/2 + 1/3×/8
blue := 2/3×/1 + 1/3×/8
if
green := green * 2/3
which yields the canonical CGA palette:
| 0 | black
| 8 | dark gray |
| 1 | blue | 9 | light blue |
| 2 | green | 10 | light green |
| 3 | cyan | 11 | light cyan |
| 4 | red | 12 | light red |
| 5 | magenta | 13 | light magenta |
| 6 | brown | 14 | yellow |
| 7 | light gray | 15 | white |
With a composite color monitor/television set
For the composite output, these four-bit color numbers are encoded by the CGA's onboard hardware into an NTSC-compatible signal fed to the card's RCA output jack. For cost reasons, this is not done using an RGB-to-YIQ converter as called for by the NTSC standard, but by a series of flip-flops and delay lines.Consequently, the hues seen are lacking in purity; notably, both cyan and yellow have a greenish tint, and color 6 again looks dark yellow instead of brown.
The relative luminances of the colors produced by the composite color-generating circuit differ between CGA revisions: they are identical for colors 1-6 and 9-14 with early CGAs produced until 1983, and are different for later CGAs due to the addition of additional resistors.
Standard text modes
CGA offers four BIOS text modes. In these modes, individual pixels on the screen cannot be addressed directly. Instead, the screen is divided into a grid of character cells, each displaying a character defined in one of two bitmap fonts, "normal" and "thin", included in the card's ROM. The fonts are fixed and cannot be modified or selected from software, only by a jumper on the board itself.Fonts are stored as bitmaps at a color depth of 1-bit, with a "1" representing the character and a "0" representing the background. These colors can be chosen independently, for each character on the screen, from the full 16-color CGA palette. The character set is defined by hardware code page 437.
The font bitmap data is only available to the card itself, it cannot be read by the CPU. In graphics modes, text output by the BIOS operates by copying text from the font ROM bit-by-bit to video memory.
40 × 25 mode
BIOS Modes 0 and 1 are both 40 columns by 25 rows text modes, with each character a pattern of dots. The effective screen resolution in this mode is pixels The card has sufficient video RAM for eight different text pages in this mode.The difference between these two modes can only be seen on a composite monitor, where mode 0 disables the color burst, making all text appear in grayscale. Mode 1 enables the color burst, allowing for color. Mode 0 and Mode 1 are functionally identical on RGB monitors and on later adapters that emulate CGA without supporting composite color output.
80 × 25 mode
BIOS Modes 2 and 3 select 80 columns by 25 rows text modes, with each character still an dot pattern, but displayed at a higher scan rate. The effective screen resolution of this mode is pixels. In this mode, the card has enough video RAM for four different text pages.As with the 40-column text modes, Mode 2 disables the color burst in the composite signal and Mode 3 enables it.
Textmode color
Each character cell stored four bits for foreground and background color. However, in the card's default configuration, the fourth bit of the background color does not set intensity, but sets the blink attribute for the cell. All characters on the screen with this bit set will periodically blink, meaning their foreground color will be changed to their background color so the character becomes invisible. All characters blink in unison.By setting a hardware register, the blink feature can be disabled, restoring access to high-intensity background colors.
All blinking characters on the screen blink in sync. The blinking attribute effect is enabled by default and the high-intensity background effect is disabled; disabling blinking is the only way to freely choose the latter eight-color indexes for the background color.
Notably, the GW-BASIC and Microsoft QBASIC programming languages included with MS-DOS supported all the text modes of the CGA with full color control, but did not provide a normal means through the BASIC language to switch the CGA from blink mode to 16-background-color mode. This was still possible however by directly programming the hardware registers using the OUT statement of the BASIC language.