BIGpedia.com - Color Graphics Adapter - Encyclopedia and Dictionary Online
encyclopedia search

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.

The 320×200 4 color mode with its default colors — title screen from .
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 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.

Standard text modes

CGA offered two text modes:

  • 40×25 characters in up to 16 colors. Each character was a pattern of 8×8 dots. The effective screen resolution in this mode was 320×200 pixels (a pixel aspect ratio of 1:1.2), though individual pixels could not be addressed independently. The choice of patterns for any location was thus limited to one of the 256 available characters. (The upper 128 characters could be redefined to a user-definable font, but would only be recognized by the BIOS when printing text in graphics modes only. Thus, the display font in text mode was fixed and could not be changed.) This mode allowed each character a foreground and a background color, both of which could be freely chosen from the entire CGA palette (see table) — e.g. red on yellow text for one character, white on black for the next and cyan on gray for yet another. The card had sufficient video RAM for 8 different text pages.
  • 80×25 characters in up to 16 colors. Each character was again an 8×8 dot pattern, in a pixel aspect ratio of 1:2.4. The effective screen resolution of this mode was 640×200 pixels. Again, the pixels could not be individually addressed. The card had enough video RAM for 4 different text pages.

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:

  • 320×200 pixels, as with the 40×25 text mode. In the graphics mode, however, each pixel could be addressed independently. The tradeoff was that only 4 colors could be displayed at a time. These four colors, however, could not be freely chosen from the 16 CGA colors — there were only two official palettes for this mode:
    1. Magenta, cyan, white and background color (black by default).
    2. Red, green, brown and background color (black by default).
The 1:1.2 pixel aspect ratio needed to be taken into account when drawing large geometrical shapes on the screen.
  • 640×200 pixels, as with the 80×25 text mode. All pixels could be addressed independently. This mode was monochrome, offering only black and white as colors (though this could be changed), with a pixel aspect ratio of 1:2.4.

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 (not the same color table as the CGA color set, but similar). This composite color mode was rarely utilized in software. No BIOS support led to poor programmer adoption. Only a handful of software titles used the 160×200 graphics mode, most of them games. Contrary to some beliefs, this mode was available on at least some RGB-equipped as well as composite monitor CGA systems. On cards which do not support it (including the ATI Graphics Solution) it appears identical to the 640x200 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.

  • In 320×200 graphics mode, the background color, which defaulted to black on mode initialization, could be changed to any of the other 15 colors of the CGA palette. This allowed for some variation, as well as flashing effects, as the background color could be changed without having to redraw the screen.
  • In 640×200 graphics mode, both colors could be changed; for example, one could have blue and orange-brown as the displayed colors instead of black and white.
  • The border color (displayed outside the regular display area) could be changed from its usual black to any of the other 15 colors.
  • A third 320×200 4-color palette was achieved by enabling the monochrome bit while in color graphics mode. This switched the current graphics palette to red, cyan, white and the background color.
  • Through precision timing, it was possible to switch to another palette while the screen content was still being drawn, allowing two or more 4-color palettes to be combined.
  • Additional colors were often approximated using dithering, although the low resolution made it very apparent.

Some of these above tweaks could even be combined. Examples could be found in several games [1] [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.

    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.

 
 

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:

  • For business and word processing use, IBM launched its Monochrome Display Adapter (MDA) at the same time as CGA. The MDA produced significantly higher resolution text display in 80×25 mode, rendering each character in a box of 9×14 pixels, of which 7×11 were the character itself. This was clearly superior than the CGA's 8×8 dots text character matrix. Because of this and CGA's higher price at the time, MDA was often preferred for business use.
  • In 1982, the non-IBM Hercules Graphics Card (HGC) was introduced. It offered an MDA-compatible high resolution text mode and a monochrome graphics mode. The black and white graphics mode had a resolution of 720×348 pixels, which was better than even the highest resolution CGA could offer. Thus, even without a color capability of any kind, the Hercules adapter's offer of better monochrome graphics and its ability to work with less expensive monochrome monitors made it a desirable choice for many. In 1987, emulator drivers became available, allowing the Hercules to display the standard CGA modes as well (albeit reduced to black and white, with dithered grays for different colors). The HGC outsold both CGA and MDA adapters, and, despite no support or standardization by IBM, quickly became a de-facto standard, supported by software vendors and later competing graphics cards.

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.

The MC6845 as used in the Amstrad CPC

The Amstrad CPC series of 8-bit computers also used the MC6845 and so had a similar set of graphics modes to CGA but with more palette flexibility: 27 colors, of which any combination could be used in every graphic mode avaiable limited only by the available bit depth.

The 160x200 16-color mode was very commonly used on the Amstrad CPC, even being accessible from the built-in Basic interpreter, and special overscan, "full color" or both could be achieved by directly manipulating the hardware via assembly, resulting in a maximum resolution of nearly 768*384 pixels with all 27 palette colors visible, although this was probably HAM mode. The Amstrad CPC's CRT monitors were fully analog and could probably handle bigger color depths and non-standard resolutions much better than most IBM-compatible CGA monitors.

However, the text modes normally used under MS-DOS were either not supported or not widely used on the Amstrad CPC, being inadequate for the standard CPC monitors, which had a significantly lower resolution than a CGA or Hercules monitor of the times.

References

See also



The contents of this article are licensed from Wikipedia.org under the GNU Free Documentation License.
How to see transparent copy

01-04-2007 01:21:04