Wednesday, September 17, 2014

CGA 16 Color RGB Graphics Modes

CGA RGB 16-Color Graphics Modes Introduction

The IBM Color/Graphics Display Adapter could output 16 colors via a digital color monitor connector. Because the monitor connection was digital and not encoded into an NTSC video connection like composite video, separate chroma and luma (essentially S-video) or through an RF modulator, the colors would be displayed without any demodulation.  The result was the best video quality a 13" CRT monitor could produce.

The CGA supports 40 and 80 column text, 320x200 resolution and 640x200 resolution graphics.  Even though the adapter had 16KB, the maximum number of RGB colors it could display in a graphics mode was 4 colors from the available 16 color palette.  In addition, those colors were not freely selectable because IBM used off-the-shelf TTL logic chips in its board design, which limited the board's capabilities.

That being said, CGA could show all 16 colors with the text modes.  Each text cell has a character byte and an attribute byte.  The character byte determine the pattern to show on the screen, like an A or a &.  The attribute byte determines the foreground and background color of each character.  Each text cell can show any of the two colors available (you need to turn off the blink attribute to show 16 background colors).  The new banner for this blog demonstrates the available text colors other than black (using VGA text characters).

The CGA has a ROM chip that contains the pattern data for 256 characters, originally called IBM Extended ASCII and later known as DOS Codepage 437. (Actually, it has two sets of patterns, a thin font and the default, thick font, which can be selected via jumper.)  These are the patterns contained in ROM :

These patterns get fetched and displayed by the Motorola 6845 CRTC. The BIOS programs the CRTC to display either 40 columns by 25 lines or 80 columns by 25 lines.  Each cell is 8x8 pixels, giving effective 320x200 and 640x200 resolutions.  However,  the 6845 can be programmed to show any number of columns and rows and cell size.  Even at 80x25, with 8x8 text cells, the graphics potential is very limited.

However, if you were to reduce the cell size to 8x2 pixels, you can obtain a lot more detail.  At this point, you have a 40 or 80 column screen by 100 rows.  Fortunately the CGA card and monitors of the day can handle this without breaking.  Using the ASCII characters 221 or 222, which have a pattern that is half on, half off, you can designate each cell to have to two independent colors by use of its attribute byte.  Thus ASCII character 221 or 222:

Becomes colored :

And reduced to this :

Each cell becomes the equivalent of two pixels, and with the 40 column mode, you obtain an effective 80x100 screen resolution.  However, such a mode lacks detail, so more often the 80 column mode would be used to give an effective 160x100 resolution.

One of the advantages of these modes is the ability to use multiple graphics pages.  Each 40 column screen requires 2K of video memory and each 80 column screen requires 4K of video memory. As the CGA has 16K of video memory, 8 pages are available in 40 column mode and 4 pages are available in 80 column mode.  This can eliminate screen tearing when the screen scrolls.  Unfortunately, few games actually used a scrolling screen.

The disadvantage with the 80-column mode on a true IBM CGA card and many clones is the visibility of CGA snow.  CGA snow is the random flickering lines shown on the screen.  It happens when the CPU and the CGA try to access the video RAM at the same time.  In the 40 column and graphics modes, the CGA properly interleaves CRTC and CPU accesses, but in the 80 column mode it lacks the bandwidth to seamlessly separate the two types of accesses.  The result is the IBM CGA does not read the byte correctly and some garbage is shown.

Although it doesn't require the whole amount of RAM like a graphics mode, 80-column mode requires the most bandwidth of all the modes because it is similar to a 640x200x16 color mode.  CGA snow can be avoided by only writing to RAM during the vertical retrace period (the time where the raster beam goes from the bottom to the top of the screen), but that is painfully slow with a 4.77MHz 8088 CPU.  No other video adapter generally suffers from snow.

IBM made a vague mention of a 160x100x16 mode in its PC Technical References, but did not introduce it as a BIOS mode and did not document how to use it.

All Known Games using the 16-Color CGA RGB Graphics Modes with Screenshots

Windmill Software

Windmill Software was one of the first game developers that focused on the IBM PC platform, and while their games are clones of popular arcade games, they were always done well and pushed the CGA card to its limits.  It released three games that used the 160x100 resolution mode, The Exterminator, Moon Bugs and Styx.  The Exterminator is Centipede, Styx is Klax and Moon Bugs is Phoenix with a little Defender mixed in.  While not made by Windmill, Bricks and Round 42 evoke the same spirit.  Bricks (a.k.a. Wrecking Ball) is a Breakout clone, and Round 42 is highly reminiscent of Gorf, but it is not quite as varied.

All these games were intended to be run on an IBM PC or PC/XT running at 4.77MHz with an IBM CGA card and PC Speaker sound.  They also expect the IBM PC 83-key Keyboard.  The use of F1 to fire makes much more sense when the key is at the side of the keyboard instead of at the top.  Bricks uses Caps Lock and Ins to move the paddle, and while those keys are far apart on modern keyboards, on the 83-key PC/XT and the 84-key AT keyboards they are next to each other.  While they will run on a Tandy 1000, do not expect any of them to run on an EGA or VGA card.

Most of the title screens for these games use a standard 320x200x4 CGA graphics mode or a text mode, but the real in-game gameplay uses the 160x100x16 graphics mode.


The Exterminator

Moon Bugs



Macrocom released two action-adventure games, ICON : Quest for the Ring and The Seven Spirits of RA They use a 40-column based mode, and the effective resolution is 320x200x16.  For these Legend of Zelda-like games, ASCII other than 221 was used, allowing for greater detail in the graphics.  Unfortunately, they rely on the patterns on the ROM of the IBM CGA card, clone cards often tweak the patterns slightly, and Tandys also use slightly different patterns, making the graphics look wrong when the games are played on these systems.  The games are still playable despite the errors.

The extra detail comes with a price, the programmers were limited to the top two lines of each ASCII character, and had to pick the best choice from the limited patterns available.  The Seven Spirits of RA uses the regular 320x200x4 CGA graphics mode for certain screens because it provides finer resolution.  These games should run on a PCjr., a Tandy 1000 or even with an EGA card, but will fail on a VGA card.

ICON: Quest for the Ring

The Seven Spirits of RA

Macrocom also released a demo, one of the earliest known demos for the PC, demonstrating its graphics modes.  The pictures in these modes use both the 40 and 80 column 16 color modes.  The demo is a slideshow of static pictures, and here are all the pictures.  Pictures 7-10 use the 80 column mode, and is one of the only two known programs known to use an ASCII pattern other than 221.  The other pictures use a 40-column mode with multiple ASCII character patterns.


An extremely basic game called Bandit was released, and it was a slot machine game and nothing more.

Miscellaneous Games


An Edutainment game called Kids on Keys was released by Spinnaker Software for several systems, and when Tandy released the Tandy 1000, it licensed the game from Spinnaker and released it for the Tandy 1000.  The games included is supposed to help children learn the keys on the keyboard.  The program also contains a feature where you can edit the graphics characters used.  Instead of using a Tandy graphics mode, it used the 160x100x16 CGA mode, most likely because Tandy also released the CGA-based Tandy 1200 computer around the same time.  However, on a Tandy 1000, the game supports 3-voice music.  On a PC, it supports PC speaker sound.  Although the graphics are very blocky, they do not use an 80x100 mode.

Kids on Keys

Level 9 Computing

Two text-based adventure games developed by Level 9 Computing, Lancelot and Scapeghost, use the 160x100 mode for graphics.  They also support other graphics adapters and show graphics in a window with the text with them, but for the 160x100x16 CGA mode, the graphics are full screen.  Essentially these games alternate between text and full color CGA graphics.  Level 9 was a U.K. company and its CGA modes were intended for the Amstrad PC-1512, a very popular PC compatible in the U.K. with a more-or-less CGA compatible video adapter.  They seem to work fine on the real CGA.



The Final Games

The last game, from 1991, known to support 160x100x16 graphics back in the day was a shareware game called Tunneler.  In this Tank-inspired game, you had to search for your opponent with a limited view of the surrounding area.  If you look at the screenshots in detail, you will see that ASCI 176 is being used for the border around the E and S gauges.  Due to this, it is not totally a 160x100x16 game.


Twenty years after Tunnler, which is the last known game to use 160x100x16 CGA mode, Paladin Systems North released a Pac-Man clone for the PC called Paku Paku that uses the mode.  Originally intended as a retro computing challenge for the IBM PC, the software is free and the code is open source.  Since its release in 2011, it has gone through six revisions, adding support for the PCjr. and Tandy Graphics Adapters, EGA, MCGA and VGA.  In addition, it supports sound devices beyond the PC speaker, including PCjr/Tandy 3-voice sound, Game Blaster, Adlib and MT-32.  While it is quite a bit easier and more lenient with extra lives than the arcade original, it is still a very nice implementation that works on the IBM PC.  You can download it here :

Paku Paku

Programming on the early PC platform and with the CGA card is a challenging endeavor.  A promising demo has been made recently of a game called MagicDuck.  I have found the graphics to be very impressive and the gameplay to be fairly fluid, despite the limited view and early nature of the software.

Aspect Ratio

The above screenshots use a 1.6:1 aspect ratio, although the monitors that CGA was designed to use are 1.33:1.  Fortunately, the low 160x100 resolution can scale to 800x600 and maintain a 4:3 aspect ratio without introducing unsightly artifacts.  Here is an example of these graphics as a CGA monitor or TV would show them :

Click on the image to get the full resolution.


  1. i played thexder so there were tandy 1 320 x 200 x 16

    are there any games that use tandy 640 x 200 x 16 colors?

  2. My friend Cloudschatze ably covered the Tandy 640x200x16 graphics mode here :

  3. Fantastic! I had an original IBM 5150 with CGA and was always envious of my friends with c64s due to the IBM's limited 4-color palate. Had no ideal most of this software existed.

    I guess the low resolution was why this mode wasn't used more at the time.

  4. In 2009 I wrote a program in QBasic that took a 16 color 320x200 or 640x200 image and converted it into something a CGA card could display.

    There's an example on my website: It's the Wolfenstein 3-D title screen
    Other examples can be found on

  5. is the tandy cm-11 the very best monitor to showcase tandy graphics from this era?

  6. dear nerdy

    i still remember being in the radio shack in lincoln mall in matteson il way back as early as 85 as a very young child.

    one computer i saw featured was the coco3.

    any thoughts on the coco3 and how does it compare with c64?

    i know there are more games with c64. how about productivity aps?

    one reason i ended up with the tandy 1000sx was that a lot of my peers had ibm xt and leading edge model d if you remember that.

    ive read on wikipedia though that the coco3 has capabilities on par with a pc, and that with coco max and coco paint comparable to a mac. but priced like a c64.

    and then there's the apple iigs

    ofc the atari st and amiga were superior but who owned that?

    back in the day software was very expensive so i ended up trading it and the pc was the best for that purpose.

  7. Silly Knight is a new 160x100x16 game that uses the same graphics routines as Paku Paku:

  8. Plenty of us in Europe had Amigas and STs... we couldn't work out why you funny Americans put up with the PC platform. I suppose the Tandys helped, but you were still stuck with an RGBI palette, and we could always spot a lazy port of a PC original because of the ugly colours (and occasionally, with things like LSL and King's Quest, the 160x200 Tandy/PCjr/CGA-composite resolution).

    Anyway, this is a pretty impressive showcase, especially the Micom stuff. Still doesn't quite match up to the other 16-bits, but if you put those next to some ST adventure games with less well made graphics (Ultima, for example, though that has something of an excuse as it's a lazy Apple II port) you could almost believe that the PC had better hardware.

    Couple points of order for the early parts of the article though:
    1) Styx isn't Klax - it's clearly Qix, aka Painter. Klax is a completely different game.
    2) The bandwidth for CGA 80-column text mode is more like a 640x200 4-colour (2bpp) graphics mode. Each 1-character/8-pixel strip along a single line involves reading one byte from the character ROM as if it were a full bitmap plane (with its output addressing based partly on the character cell based content of the actual VRAM, partly on a pair of repeating 0-7 counters, one for horizontal and the other for vertical position), and another byte (encoding two 4-bit colours, one for BG, one for FG) from the separate, same-sized attribute map. So, 16 bits per 8 pixels, meaning 2bpp, and the equivalent of 4 colours. The graphics modes are obviously half that bandwidth, as is the 40-column text mode (which still reads 16 bits per 8 pixels, but clocks the pixels at half the speed).

    Really, if the adaptor PCB had enough space for another 16kb of memory and a few extra bits of logic, it could easily have supported 32kb (thus 320x200x4bpp, 640x200x2bpp) modes more like the first Tandys and base model PCjr (or the ST, but with a fixed 16-colour palette), if you didn't mind either snow or hefty waitstates in return for a more colourful picture. And even with only 16kb, the lack of 160x200 16c/4bpp (or actual palette registers for 320x200) is probably only down to there not being any more than a few square millimetres of free board space, and that's down to the compressed development period that meant IBM essentially put the discrete-logic prototypes directly onto the market without going through an LSI condensation stage to put all the non-memory parts into an ASIC...

  9. On a what's-old-is-new-again note, I'd like to mention that the media player mpv (Linux) has a way of playing movies on text-mode terminals that works very similarly to the hacked CGA 160×200 mode. With

    mpv --vo=tct

    the player runs the movie on the terminal (xterm, GNOME/MATE Terminal, rxvt, kitty et cetera) using the Unicode character U+2584 LOWER HALF BLOCK ▄ with the appropriate background and foreground colors to double the resolution (unless you choose the option --vo-tct-algo=plain, then it uses a full block, U+2588, reducing the resolution).

    Differences be noted, the window size and font size can be changed to alter the quality of the movie display, and there is a choice of either 2^24 or 2^8 colors, but I think it's fascinating how the half-block with background and foreground hack is employed to display graphics in a text mode, in mpv just as it was on the old CGA. Also CGA used left half while mpv uses lower half, but that doesn't change the principle.

  10. Near the top, you write: "*Even though* the adapter had 16KB, the maximum number of RGB colors it could display in a graphics mode was 4 colors from the available 16 color palette."
    The "even though" seems to suggest a 16K graphics card should be able to do more. However, for the standard BIOS-supported 320x200 resolution, 4 colours was about the most you could expect from 16K VRAM, because 320x200x2/8=16000, just a little less than 16384. I know you're part of a team that's blown past those limitations on composite displays, but still, the "even though" here seems misplaced.

    1. What I meant by that is that you could have theoretically displayed 16 colors in a 160x200 resolution with an RGBI monitor and that amount of RAM, but the CGA does not have the hardware capable of doing that.

  11. You write: "Styx is Klax", but you mean Qix. Klax is an altogether different game.
    (There also are two successive however's in the fifth and sixth paragraphs. You may wish to reword that.)

    1. I really should spend more time proof-reading :)

  12. OUT 3D4h->8h
    OUT 3D5h->3h
    This change video port R8 register.
    This make 40x100 "text" mode CGA only.
    For example on PicoXT emulator.
    For mode 80x100 is litle more difficult. It,s need to change R0-:-R11. Turning back is by using 40x25 text mode.
    It work on CGA/EGA only.
    On VGA/VGA+ this make 2 error rows on the top - 2 rows 80x25.
    One R# register have to be changes.
    I thik was R8 again - 1 instead the original 2.
    This method is described in PC World, April 1985 by Larry McMillin.

  13. On CGA/EGA this modifying of R registers give 80x100 "text" resolution, but on VGA/VGA+ this method give automatically 80x200 "text" resolution.

  14. I'm having some fun with the CGA 160x100 16 color mode and the recreated Commander Keen 4 source code: