|Architecture||Motorola 6845, ATI CW16800|
|Entry-level||IBM Color Graphics Adapter, ATi Graphics Solution Rev 3, ATi Color Emulation Card, Tseng Labs ColorPAK,|
|Mid-range||ATi Graphics Solution plus, ATi Graphics Solution Plus SP, ATi Graphics Solution SR, Number Nine Graphics System|
|High-end||ATi Small Wonder Graphics Solution, Tseng Labs EVA/480|
|Enthusiast||ATi Small Wonder Graphics Solution with game port|
Professional Graphics Controller
The Color Graphics Adapter (CGA), originally also called the Color/Graphics Adapter or IBM Color/Graphics Monitor Adapter, introduced in 1981, was IBM's first graphics card and first color display card for the IBM PC. For this reason, it also became that computer's first color computer display standard.
The standard IBM CGA graphics card was equipped with 16 kilobytes of video memory and could be connected either to a dedicated direct-drive CRT monitor using a 4-bit digital (TTL) 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 standard television set required a separate RF modulator unless the TV had an RCA jack, although doing so with the former combined with an amplifier was sometimes more practical, since one could then hook up an antenna to the amplifier and get wireless video.
Built around the Motorola 6845 display controller, the CGA card featured several graphics and text modes. The highest display resolution of any mode was 640×200, and the highest color depth supported was 4-bit (16 colors).
|black||[palette-based color #1]||[palette-based color #2]||[palette-based color #3]|
(The pixel aspect ratio stems from rendering said distribution of pixels on a screen with 4:3 proportions, typical of monitors at the time.)
Extended graphics modes:
IBM intended that CGA be compatible with a home television set. The 40×25 text and 320×200 graphics modes are usable with a television, and the 80×25 text and 640×200 graphics modes are intended for a monitor.
Cga p0.png CGA 320×200 in 4 colors palette 0 (red, yellow, green, black background)
Cga p1.png CGA 320×200 in 4 colors palette 1 (cyan, magenta, white, black background)
Cga p3.png CGA 320×200 in 4 colors 3rd palette (tweaked), (cyan, red, white, black background)
Cga 640x200.png CGA 640×200 in 2 colors(1-bit)
Cga 150x100.png CGA 160×100 16 color mode(4-bit)
Despite varying bit depths among the CGA graphics modes (see below), CGA processes colors in its palette in four bits, yielding 24 = 16 different colors. The four color bits are arranged according to the RGBI color model: the lower three bits represent red, green, and blue color components; a fourth "intensifier" bit, when set, increases the brightness of all three color components (red, green, and blue). In graphics modes, colors are set per-pixel; in text modes, colors are set per-character, with an independent foreground and background color for each character.
|Full CGA 16-color palette|
These four bits are passed on unmodified to the DE-9 connector at the back of the card, leaving all color processing to the RGBI monitor connected to it. With respect to the RGBI color model described above, the monitor would use approximately the following formula to process the digital four-bit color number to analog voltages ranging from 0.0 to 1.0:
red := 2/3×(colorNumber & 4)/4 + 1/3×(colorNumber & 8)/8 green := 2/3×(colorNumber & 2)/2 + 1/3×(colorNumber & 8)/8 blue := 2/3×(colorNumber & 1)/1 + 1/3×(colorNumber & 8)/8
Color 6 is treated differently; when using the formula above, color 6 would become dark yellow, as seen to the left, but in order to achieve a more pleasing brown tone, special circuitry in most RGBI monitors, including the IBM 5153 color display, makes an exception for color 6 and changes its hue from dark yellow to brown by halving the analogue green signal's amplitude:
if colorNumber = 6 then green := green / 2
It is this "RGBI with tweaked brown" palette, shown in the complete palette to the right, that all later PC graphics standards such as EGA and VGA have retained for compatibility as a power-on default setting of their internal palette registers and/or DAC registers.
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.
As noted however, this method only works on NTSC television sets, PAL TVs do not display the colors as expected when connected to the composite output, as PAL's superior color separation prevents artifacting from occurring.
When the CGA was introduced in 1981, IBM did not offer an RGBI monitor. Instead, customers were supposed to use the RCA output with an RF modulator (that they obtained separately, from a third party) to connect the CGA to their television set. The IBM 5153 Personal Computer Color Display would not be introduced until March 1983. Resulting from the lack of available RGBI monitors in 1981 and 1982, many users would use simpler RGB monitors (without provisions for the "intensifier" bit), reducing the number of available colors to eight, and displaying both colors 6 and 14 as yellow. This is relevant insofar as if an application or game programmer used either one of these configurations, they will have expected color 6 to look dark yellow instead of brown.
CGA offers four BIOS text modes (called alphanumeric modes in IBM's documentation):
In every text mode, each character has a background and a foreground color—e.g. red on yellow text for one character, white on black for the next, etc. While the same 4-bit nybble value used for the foreground color would normally allow all 16 colors to be used for the background color, the most significant bit of the background nybble is alternatively used to denote whether or not the character should blink (a hardware effect offered by CGA independent of the CPU). When a character is blinking, its foreground dots alternate between the foreground and background color, so that the during the blink off period, the character cell is filled with the background color (exactly like a space character). 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 (8-15) for the background color.
Notably, the GW-BASIC and, later, Microsoft QBASIC (a lesser derivative of Microsoft QuickBASIC) programming language interpreters included with MS-DOS (which was the de facto PC OS while the CGA was popular) 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, though it would be possible by directly programming the hardware registers using the OUT statement of the BASIC language. In BASIC, foreground text color numbers 16-31 are the blinking versions of colors 0-15, respectively, but background colors 8-15 are identical to colors 0-7 respectively.
CGA offers graphics modes in two resolutions:
BIOS Mode 4 offers two palettes (differing in the presence or absence of the blue color component): green/red/brown and cyan/magenta/white. By setting the high-intensity bit, brighter versions of these modes can be accessed. The background can be set to any of the 16 CGA colors, but is black by default.
As with Modes 0 and 2, Mode 5 disables the color burst bit to allow colors to appear in grayscale on Composite monitor. Unlike the text modes, disabling the composite color burst bit affects the colors displayed on an RGB monitor with the IBM CGA card and true compatibles. Some programmers use Mode 5 as an unofficial third palette on RGB monitors: cyan/red/white and the background color. The intense versions of these colors can also be used and the background color may be changed, but the palette cannot be switched to palettes 0 or 1 without enabling the composite color signal again. Notably, it is not mentioned in the IBM Technical Reference manual, and some CGA clones may not support it.
|#||Mode 4||Mode 5|
|Palette 0||Palette 1||low intensity||high intensity|
|low intensity||high intensity||low intensity||high intensity|
|1||2 -- green||10 -- light green||3 -- cyan||11 -- light cyan||3 -- cyan||11 -- light cyan|
|2||4 -- red||12 -- light red||5 -- magenta||13 -- light magenta||4 -- red||12 -- light red|
|3||6 -- brown||14 -- yellow||7 -- light gray||15 -- white||7 -- light gray||15 -- white|
In text mode, font bitmap data comes from the character ROM on the card, which is only available to the card itself. In graphics modes, text output by the BIOS uses two separate tables. The first half of the character set (characters numbered 0 through 127, corresponding to 7-bit ASCII with some added graphical symbols) is supplied by a table in the BIOS ROM chip on the computer's mainboard at the fixed address F000:FA6E (the table is still present at this location even in modern PC BIOSes; unlike the font ROM on the CGA card itself that is used for the text modes, this table provides only the "thick" font shapes, not the "thin" ones). The second half of the set (characters numbered 128 through 255, corresponding to the international, block-graphics and mathematics characters) is supplied by the location pointed to by interrupt vector 1F (the vector itself is found at memory address 0000:007C; this is not in fact a real interrupt vector, since the vector does not point to executable machine code, as real interrupt vectors on the PC's Intel 8086 CPU do). The second half of the character set is ordinarily absent (the vector 1F does not point to actual font data), and trying to display it will result in garbage or blank characters. The character data may be placed into memory manually by the user, or by a utility such as GRAFTABL.
A number of official and unofficial features exist that can be exploited to achieve special effects.
Some of these above tweaks can even be combined. Examples can be found in several games. Most software titles did not use these possibilities, but there were a few impressive exceptions.
Technically, this mode is not a graphics mode, but a tweak of the 80×25 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 (eight each) before moving on to the next row.
|221 with blue text and red background color.|
|221 with red text and blue background color.|
Character 221 of the CGA character set consists of a box occupying the entire left half of the character matrix. (Character 222 consists of a box occupying the entire right half.)
Because each character can be assigned different foreground and background colors, it can be colored (for example) blue on the left (foreground color) and bright red on the right (background color). 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, 160×100 pixels at 16 colors, with an aspect ratio of 1:1.2, are possible.
More detail can be achieved in this mode by using other characters, combining ASCII art with the aforesaid technique.
Because the CGA has 16 KiB (16,384 bytes) of graphics memory, not 16,000, it is just as easy to set the number of lines in this mode to 102 instead of 100 for a resolution of 160×102 (16320 pixels). This uses extra video memory that is normally unused. However, most games did not do this, perhaps out of fear it would only work on some monitors but not others- a fear that is not unfounded as it was later found that certain compatibles have cards that either glitch or ignore any attempt to put the device into this mode.
The same text cell height reduction technique can 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.
Using the NTSC TV-out instead of an RGBI monitor not only made for less attractive colors, as described above, but as is common with NTSC composite video, the separation between luminance and chrominance is far from perfect, yielding cross-color artifacts, or color "smearing". This is especially a problem with 80-column text:
It is for this reason that each of the text and graphics modes described above exists twice: once as the normal "color" version and once as a "monochrome" version; the "monochrome" version of each mode would turn off the NTSC color decoding in the viewing monitor completely, resulting in a black-and-white picture, but also no color bleeding, hence, a sharper picture. On RGBI monitors, the two versions of each mode are identical, with the exception of the 320×200 graphics mode, where the "monochrome" version produces the third palette, as described above.
However, programmers soon found out that this flaw could be turned into an asset, as distinct patterns of high-resolution dots would "smear" into consistent areas of solid colors, thus allowing the display of completely new artifact colors. Both the standard 320×200 four-color and the 640×200 color-on-black graphics modes could be used with this technique.
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, as stated before. By carefully placing pixels in appropriate patterns, the skilled programmer produces particular cross-color artifacts yielding the desired color; either from purely black-and-white pixels in 640×200 mode, or resulting from a combination of direct and artifact colors in 320×200 mode, as seen in these pictures.
Thus, with the choice of 320×200 vs. 640×200 mode, the choice of palette (1 or 2) and the freely-selectable color 0 in 320×200 modes (see above), plus the ability to set the foreground color in 640×200 mode freely, each one of these parameters results in a different set of artifact colors, making for a total gamut of over 100 colors, of which 16 can be displayed at the same time.
Later demonstrations by enthusiasts have increased the maximum number of colors the CGA is known to produce in a single image to approximately a thousand. Aside of artifacting, this technique involves the text mode tweak which quadruples its rows, thus offering the benefit of 16 foreground and 16 background colors. 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 80×100 on a composite monitor.
The 320×200 variant of this technique (see above) is how the standard BIOS-supported graphics mode looks on a composite color monitor. The 640×200 variant, however, requires modifying a bit (color burst disable) directly in the CGA's hardware registers, as a result, it is usually referred to as a separate "mode", often just as "the" composite color mode, since its more distinctive set of artifact colors led it to being more commonly used than the 320×200 variant.
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 includes a CGA mode, which can emulate a composite monitor (in graphics modes). As of December 2012, the latest official version will emulate the more common 640×200 composite mode and its set of 16 artifact colors; support for the more complex 320×200 variant has been added to the DOSBox codebase for the next official build.
Composite artifacting, whether used intentionally or as an unwanted artifact, reduces the effective horizontal resolution to a minimum 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 was thus sometimes described as a 160×200/16-color "mode", though technically it was a method, not a mode.
The low resolution of this composite color artifacting method led to it being used almost exclusively in games. Many of the more high-profile titles optionally, sometimes exclusively, offering 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 was innovative in its use of 16-color graphics on the PC, PCjr and Tandy 1000; even CGA owners could enjoy the 16-color graphics by using a composite color monitor or television, thanks to programmers exploiting the inaccuracies of composite NTSC chroma decoding. Selecting 'RGB mode' at the title screen would instead result in the usual CGA graphics mode limited to 4 colors. In this mode, dithering was employed to simulate extra colors.
By taking advantage of the color smearing, the NTSC color clock and a method similar to that used in the 16 color mode, it's possible to display over 16 colors in composite monitors.
160 cycles of the NTSC color clock occur during the each line's pixel period 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 or upper 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.
Video timing on the CGA is provided by the Motorola 6845 video controller. This integrated circuit was originally designed only for character-based alphanumeric (text) displays and can only 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 (i.e. the scanline within the character row) 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 first put only the even-numbered scanlines continuously in a first block of video memory, then 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. Therefore, 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 (known as "snow") if a program writes directly to video memory. The BIOS avoids the problem by only accessing the memory during horizontal retrace, or by temporarily turning off the output during scrolling; while causing the display to blink, 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 is doubled, and all the 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 twice the 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.
CGA was widely supported in PC software up until the 1990s. Some of the software that supported the board was:
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 (early 1980s), these graphics were terrible, paling in comparison to other color machines available on the market."
CGA had two main competitors:
The CGA card was succeeded in the consumer space by IBM's Enhanced Graphics Adapter (EGA) card, which supports most of CGA's modes and adds an additional resolution (640×350) as well as a software-selectable palette of 16 colors out of 64 in both text and graphics modes. Along with this move, the price of the older CGA card was lowered considerably; it became an attractive low-cost option and was soon adopted by the new PC cloning companies as well. Entry-level non-AT PCs with CGA graphics sold very well during the next few years, and consequently there were many games released for such systems, despite CGA's limitations. CGA's popularity started to wane after VGA became IBM's high-level standard and EGA the entry-level standard in 1987. However, most software made up to 1990 supported it.
The Color Graphics Adapter uses a standard DE-9 connector for direct-drive video (to an RGBI monitor). The connector on the card is female and the one on the monitor cable is male.
|Resolution||640h × 200v, 320h × 200v|