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.

Styx








The Exterminator










Moon Bugs














Bricks

















Macrocom

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.

ICON Demo















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

Miscellaneous Games

Bandit







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.

Lancelot









Scapeghost







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.

Tunneler












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 : http://www.deathshadow.com/pakuPaku

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.

6 comments:

notagain001 said...

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?

Great Hierophant said...

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

http://www.vintage-computer.com/vcforum/showthread.php?30424-Tandy-(1000)-Video-II-Mode-E-640x200x16&highlight=640x200

Anonymous said...

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.

Dook Nookim said...

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: http://sfprod.shikadi.net/old/games/wolf3d.htm#demo It's the Wolfenstein 3-D title screen
Other examples can be found on https://drive.google.com/file/d/0BxgC9wZH-xHqODdtSDFoNENDSlE/edit?usp=sharing

notagain001 said...

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

notagain001 said...

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.