018. A Brief History of Graphics Cards — Part Two

According to the plan, this section was supposed to cover VESA, but I felt MDA/CGA still had a lot of interesting ground to cover, so I decided to walk through some of the fun tricks people pulled off under MDA/CGA modes with everyone.

The previous section talked about three stages in the evolution of graphics cards: text mode, color mode, and 3D mode. That division is my own rough attempt at slicing things up, and it may not be very accurate.
What I call text mode essentially corresponds to MDA cards, while color mode refers to cards that can control the color of a single pixel — this includes the CGA card and later cards such as VESA.

Fun Tricks in Text Mode

CGA Card’s Standard Text Modes

When I talk about the CGA card here, I’m referring to IBM’s standard CGA card.

It supports four BIOS text modes:

  1. BIOS Mode 0/1:
    40 columns × 25 rows of text, 16 colors. Each character occupies 8×8 pixels. Screen resolution is 320×200. Each text cell can display one of 256 characters; the specific mapping is determined by the code page, and 8 code pages are supported. BIOS Mode 0 does not support color and only displays grayscale, while BIOS Mode 1 supports color.

  2. BIOS Mode 2/3:
    80 columns × 25 rows of text, 16 colors. Each character occupies 8×8 pixels. Screen resolution is 640×200. 4 code pages are supported. BIOS Mode 2 does not support color.

When you hear “text mode,” you might picture nothing more than a black screen showing line after line of characters — pretty boring to look at. But no matter how harsh the constraints, the human imagination refuses to be boxed in. On MDA, or when using text mode on CGA, people still managed to pull off some genuinely interesting displays. For example:

It does look a bit crude, but it’s already far more pleasant to look at, and much friendlier to someone just getting started with computers.

In reality, text mode can do far more than this. Lots of tricks can be played in text mode too.

ASCII art

If you’ve spent time around Linux, you’ve probably come across some fun stuff — like ASCII art, for instance, or playing video at the command line. ASCII art simulates large pixels by displaying characters of different pixel densities.

Using Text to Simulate Pixels

The image below shows a game — you can probably guess that it’s rendered in text mode, but this game uses only a single character, treating that character as a single pixel to draw the entire game.

In text mode, this card only supports 80 columns × 25 rows of text. To draw graphics, the game’s author needed finer control over rows and columns, so he changed the cell height register value from 8 to 2, lowering the text height from 8 pixels to 2 pixels. This turned a screen that originally showed 25 rows vertically into one showing 100 rows, with each text column now showing only the top two pixels. In text mode, every character can independently set its foreground and background colors. One particular character is fully drawn in the left half of its cell and blank in the right half — meaning the left half of the cell shows the foreground color and the right half shows the background color. By carefully choosing the foreground and background colors, the author could make the character show the same or different colors on each half, effectively letting a single character emulate two large pixels. Through this, the author turned an 80×25 text display area into a 160×100 graphics display area.

The image below is a diagram of a large pixel that contains two pixels vertically and 4 pixels horizontally.

Some Black Magic in Color Mode

Early color displays were nowhere near as easy to use as today’s — neither were the monitors themselves — so people came up with a lot of methods to work around those limitations.

Standard Graphics Modes

The CGA card provides 3 standard BIOS graphics modes, also known as all-points-addressable modes.

  1. BIOS Mode 4/5:
    320 × 200 pixels, with only 4 colors visible at any one time out of a total palette of 16. BIOS Mode 4 and 5 are both this mode; the difference is that BIOS Mode 4 enables color display, while BIOS Mode 5 disables color and only shows grayscale.

  2. BIOS Mode 6:
    640 × 200 pixels, but only monochrome — the background color is fixed as black, and the foreground color can be chosen from the remaining colors, but only one foreground color at a time.

Tricks for Breaking Past the Graphics Mode Limits

  1. Changing the palette at runtime

On a 4.77 MHz 8088 CPU, with careful timing control, you can apply a different palette on each scanline. This breaks through the limit of being able to use only 4 colors simultaneously.

  1. Using dithering to display colors not in the palette

That is, mixing different colors so that an intermediate color appears — for example, mixing red and blue to produce purple.

  1. Mimicking TV monitor flaws to display 1024 colors

The analog TV monitor only has a single signal channel, and it’s analog, so timing issues easily arise and cause adjacent colors to interfere with one another.

But experienced programmers figured out how to leverage this shortcoming to make CGA display 16 colors simultaneously, and even combine it with other tricks to push past the palette limit and produce 1024 colors.

For details, see:

https://en.wikipedia.org/wiki/Composite_artifact_colors

Last modified: 2026年7月13日

Author

Comments

Write a Reply or Comment

Your email address will not be published.