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.
Some software achieved greater color depth by utilizing artifact color when connected to a composite monitor.
Text modes:
  • with pixel font
  • with pixel font
IBM intended that CGA be compatible with a home television set. The text and graphics modes are usable with a television, and the text and graphics modes are intended for a monitor.

Color palette

CGA uses a List of monochrome and [RGB color formats#IBM PC graphics|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.
ColorIRGBColorIRGB
Black0000Gray 21000
Blue0001Light Blue1001
Green0010Light Green1010
Cyan0011Light Cyan1011
Red0100Light Red1100
Magenta0101Light Magenta1101
Brown0110Light Yellow1110
Gray 10111White1111

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:
0black
  1. 000000
8dark gray
  • 555555
  • 1blue
  • 0000AA
  • 9light blue
  • 5555FF
  • 2green
  • 00AA00
  • 10light green
  • 55FF55
  • 3cyan
  • 00AAAA
  • 11light cyan
  • 55FFFF
  • 4red
  • AA0000
  • 12light red
  • FF5555
  • 5magenta
  • AA00AA
  • 13light magenta
  • FF55FF
  • 6brown
  • AA5500
  • 14yellow
  • FFFF55
  • 7light gray
  • AAAAAA
  • 15white
  • FFFFFF
  • ''Note: Color hex values shown are 8-bit RGB equivalents, internally CGA is 4-bit RGBI''

    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.

    Standard graphics modes

    CGA offers graphics modes at three resolutions:, and. In all modes every pixel on the screen can be set directly, but the color depth for the higher modes does not permit selecting freely from the full 16-color palette.

    320 × 200

    In the medium-resolution modes, each pixel is two bits, which select colors from a four-color palette. In mode 4, there are two palettes, and in mode 5 there is a single palette.
    Several choices can be made by programming hardware registers. First, the selected palette. Second, the intensity – which is defined for the entire screen, not on a per-pixel basis. Third, color 0 can be set to any of the 16 colors.
    The specific BIOS graphics mode influences which palettes are available. BIOS Mode 4 offers two palettes: green/red/brown and cyan/magenta/white.
    As with the text modes 0 and 2, Mode 5 disables the color burst to allow colors to appear in grayscale on composite monitor. However, unlike the text modes, this also affects the colors displayed on an RGBI monitor, altering them to the cyan/red/white palette seen above. This palette is not documented by IBM, but was used in some software.

    640 × 200

    In the high-resolution mode, each pixel is one bit, providing two colors which can be chosen from the 16-color palette by programming hardware registers.
    In this mode, the video picture is stored as a simple bitmap, with one bit per pixel setting the color to "foreground" or "background". By default the colors are black and bright white, but the foreground color can be changed to any entry in the 16-color CGA palette. The background color cannot be changed from black on an original IBM CGA card.
    This mode disables the composite color burst signal by default. The BIOS does not provide an option to turn the color burst on in 640 × 200 mode, and the user must write directly to the mode control register to enable it.

    Further graphics modes and tweaks

    A number of official and unofficial features exist that can be exploited to achieve special effects.
    • In graphics mode, the background color, which defaults to black on mode initialization, can be changed to any of the other 15 colors of the CGA palette. This allows for some variation, as well as flashing effects, as the background color can be changed without having to redraw the screen.
    • In text mode, the border color can be changed from the default black to any of the other 15 colors.
    • Through precision timing, it is possible to switch to another palette while the video is being output, allowing the use of any one of the six palettes per scanline. An example of this is California Games, when run on a stock 4.77 MHz 8088. Running on a faster computer does not produce the effect, as the method the programmers used to switch palettes at predetermined locations is extremely sensitive to machine speed. The same can be done with the background color, as is used to create the river and road in Frogger. Another documented example of the technique is in Atarisoft's port of Jungle Hunt to the PC.
    • Additional colors can be approximated using dithering.
    • Using palette 0 at low intensity and dark blue as the background color provides the three primary RGB colors, as well as brown.
    Some of these above tweaks can be combined. Examples can be found in several games.

    160 × 100 16 color mode

    Technically, this mode is not a graphics mode, but a tweak of the text mode. The character cell height register is changed to display only two lines per character cell instead of the normal eight lines. This quadruples the number of text rows displayed from 25 to 100. These "tightly squeezed" text characters are not full characters. The system only displays their top two lines of pixels 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 of the CGA character set consists of a box occupying the entire left half of the character matrix.
    Because each character can be assigned different foreground and background colors, it can be colored blue on the left and bright red on the right. This can be reversed by swapping the foreground and background colors.
    Using either character 221 or 222, each half of each truncated character cell can thus be treated as an individual pixel—making 160 horizontal pixels available per line. Thus, pixels at 16 colors, with a pixel aspect ratio of 1:1.2, are possible.
    Although a roundabout way of achieving a 16-color graphics display, this works quite well and the mode is even mentioned in IBM's official hardware documentation. This mode was used as early as 1983 on the game Moon Bugs.
    More detail can be achieved in this mode by using other characters, combining ASCII art with the aforesaid technique. This was explored by Macrocom, Inc on two games: Icon: Quest for the Ring and The Seven Spirits of Ra.
    The same text cell height reduction technique can also be used with the text mode, yielding a resolution of and a pixel aspect ratio of ~1.67:1.

    Composite output

    Using the composite output instead of an RGBI monitor produced lower-quality video, due to NTSC's inferior separation between luminance and chrominance. This is especially a problem with 80-column text:
    For this reason, each of the text and graphics modes has a duplicate mode which disables the composite colorburst, resulting in a black-and-white picture, but also eliminating color bleeding to produce a sharper picture. On RGBI monitors, the two versions of each mode are usually identical, with the exception of the graphics mode, where the "monochrome" version produces a third palette.

    Extended artifact colors

    Programmers discovered that this flaw could be turned into an asset, as distinct patterns of high-resolution dots would turn into consistent areas of solid colors, thus allowing the display of completely new artifact colors. Both the standard four-color and the color-on-black graphics modes could be used with this technique.

    Internal operation

    Direct colors are the normal 16 colors as described above under "The CGA color palette".
    Artifact colors are seen because the composite monitor's NTSC chroma decoder misinterprets some of the luminance information as color. By carefully placing pixels in appropriate patterns, a programmer can produce specific cross-color artifacts yielding a desired new color; either from purely black-and-white pixels in mode, or resulting from a combination of direct and artifact colors in mode, as seen on the following pictures:
    Thus, with the choice between 320 × 200 vs. 640 × 200 mode, the choice between the two palettes, and one freely-selectable color, it is possible to use many different sets of artifact colors, making for a total gamut of over 100 colors.
    Later demonstrations by enthusiasts have increased the maximum number of colors the CGA can display at the same time to 1024. This technique involves a text mode tweak which quadruples the number of text rows. Certain ASCII characters such as U and ‼ are then used to produce the necessary patterns, which result in non-dithered images with an effective resolution of on a composite monitor.
    160 cycles of the NTSC color clock occur during each line's output, so in 40-column mode each pixel occupies half a cycle and in 80-column mode each pixel uses a quarter of a cycle. Limiting the character display to the upper one or two scanlines, and taking advantage of the pixel arrangement in certain characters of the codepage 437, it is possible to display up to 1024 colors. This technique was used in the demo 8088 MPH.

    Availability and caveats

    The variant of this technique is how the standard BIOS-supported graphics mode looks on a composite color monitor. The variant, however, requires modifying a bit directly in the CGA's hardware registers. As a result, it is usually referred to as a separate "mode".
    Being completely dependent on the NTSC encoding/decoding process, composite color artifacting is not available on an RGBI monitor, nor is it emulated by EGA, VGA or contemporary graphics adapters.
    The modern, games-centric PC emulator DOSBox supports a CGA mode, which can emulate a composite monitor's color artifacting. Both composite mode and the more complex variant are supported.

    Resolution and usage

    Composite artifacting, whether used intentionally or as an unwanted artifact, reduces the effective horizontal resolution to a maximum of 160 pixels, more for black-on-white or white-on-black text, without changing the vertical resolution. The resulting composite video display with "artifacted" colors is sometimes described as a / 16-color "mode", though technically it was a technique using a standard mode.
    The low resolution of this composite color artifacting method led to it being used almost exclusively in games. Many high-profile titles offered graphics optimized for composite color monitors. Ultima II, the first game in the game series to be ported to IBM PC, used CGA composite graphics. King's Quest I also offered 16-color graphics on the PC, PCjr and Tandy 1000, but provided a 'RGB mode' at the title screen which would utilize only the ordinary CGA graphics mode, limited to 4 colors.

    Limitations, bugs and errata

    Video timing on the CGA is provided by the Motorola 6845 video controller. This integrated circuit was originally designed only for character-based alphanumeric displays and can address a maximum of 128 character rows.
    To realize graphics modes with 200 scanlines on the CGA, the MC6845 is programmed with 100 character rows per picture and two scanlines per character row. Because the video memory address output by the MC6845 is identical for each scanline within a character row, the CGA must use the MC6845's "row address" output as an additional address bit to fetch raster data from video memory.
    This implies that unless the size of a single scanline's raster data is a power of two, raster data cannot be laid out continuously in video memory. Instead, graphics modes on the CGA store the even-numbered scanlines contiguously in memory, followed by a second block of odd-numbered scanlines starting at video memory position 8,192. This arrangement results in additional overhead in graphics modes for software that manipulates video memory.
    Even though the MC6845 video controller can provide the timing for interlaced video, the CGA's circuitry aligns the synchronization signals in such a way that scanning is always progressive. Consequently, it is impossible to double the vertical resolution to 400 scanlines using a standard 15 kHz monitor.
    The higher bandwidth used by 80-column text mode results in random short horizontal lines appearing onscreen if a program writes directly to video memory during screen drawing. The BIOS avoids the problem by only accessing the memory during horizontal retrace, or by temporarily turning off the output during scrolling. While this causes the display to flicker, IBM decided that doing so was better than snow. The "snow" problem does not occur on any other video adapter, or on most CGA clones.
    In the 80-column text mode, the pixel clock frequency is doubled, and all synchronization signals are output for twice the number of clock cycles in order to last for their proper duration. The composite output's color burst signal circuit is an exception: because it still outputs the same number of cycles, now at the doubled clock rate, the color burst signal produced is too short for most monitors, yielding no or unstable color. Hence, IBM documentation lists the 80-column text mode as a "feature" only for RGBI and black-and-white composite monitors. Stable color can still be achieved by setting the border color to brown, which happens to produce a phase identical to the correct color burst signal and serves as a substitute for it.

    Dual-head support

    The CGA was released alongside the IBM MDA, and can be installed alongside the MDA in the same computer. A command included with PC DOS permits switching the display output between the CGA and MDA cards. Some programs like Lotus 1-2-3 and AutoCAD support using both displays concurrently.

    Software support

    CGA was widely supported in PC software up until the early 1990s. Some of the software that supported the board was:

    Competing adapters

    BYTE in January 1982 described the output from CGA as "very good—slightly better than color graphics on existing microcomputers". PC Magazine disagreed, reporting in June 1983 that "the IBM monochrome display is absolutely beautiful for text and wonderfully easy on the eyes, but is limited to simple character graphics. Text quality on displays connected to the color/graphics adapter... is at best of medium quality and is conducive to eyestrain over the long haul".
    In a retrospective commentary, Next Generation also took a negative view on the CGA, stating: "Even for the time, these graphics were terrible, paling in comparison to other color machines available on the market."
    CGA had several competitors:
    • For business and word processing use, IBM provided the Monochrome Display Adapter at the same time as CGA. MDA was much more popular than CGA at first. Since a great many PCs were sold to businesses, the sharp, high-resolution monochrome text was more desirable for running applications.
    • In 1982, the non-IBM Hercules Graphics Card was introduced, the first third-party video card for the PC. In addition to an MDA-compatible text mode, it offered a monochrome graphics mode with a resolution of pixels, higher than the CGA.
    • Also in 1982 the Plantronics Colorplus board was introduced, with twice the memory of a standard CGA board. The additional memory can be used in graphics modes to double the color depth, giving two additional graphics modes—16 colors at resolution, or 4 colors at resolution.
    • The IBM PCjr and compatible Tandy 1000 featured onboard "extended CGA" video hardware that extended video RAM beyond 16 kB, allowing 16 colors at resolution and four colors at resolution. Because the Tandy 1000 long outlived the PCjr, the video modes became known as "Tandy Graphics Adapter" or "TGA", and were very popular for games during the 1980s. Similar but less widely used was the Plantronics Colorplus.
    • In 1984, IBM also introduced the Professional Graphics Controller, a high-end graphics solution intended for e.g. CAD applications. It was mostly backwards compatible with CGA. The PGC did not see widespread adoption due to its $4,000 price tag, and was discontinued in 1987.
    Other alternatives:
    • Paradise Systems introduced in 1984 the first successful CGA-compatible card for MDA monitors. It displayed CGA's 16 colors in shades of monochrome. Because it was hardware-compatible with CGA, the Paradise card did not need special software support or additional drivers.
    • Another extension in some CGA-compatible chipsets is a doubled vertical resolution. This gives a higher quality text display and an additional graphics mode.
    The CGA card was succeeded in the consumer space by IBM's Enhanced Graphics Adapter card, which supports most of CGA's modes and adds an additional resolution as well as a software-selectable palette of 16 colors out of 64 in both text and graphics modes.

    Specifications

    DE-9 connector for RGBI monitor

    The Color Graphics Adapter uses a standard DE-9 connector for direct-drive video. The connector on the card is female and the one on the monitor cable is male.
    PinFunction
    1Ground
    2Ground
    3Red
    4Green
    5Blue
    6Intensity
    7Reserved
    8Horizontal Sync
    9Vertical Sync

    RCA connector for composite monitor or television

    The Color Graphics Adapter uses a standard RCA connector for connection to an NTSC-compatible television or composite video monitor. The connector on the card is female and the one on the monitor cable is male.
    TypeAnalog composite NTSC compatible
    Resolution640 × 200, 320 × 200
    H-freq15699.8 Hz
    V-freq59.923 Hz
    Colors16, hundreds of artifact colors