• Please review our updated Terms and Rules here

More fun with CGA composite color

resman

Veteran Member
Joined
Dec 31, 2013
Messages
661
Location
Lake Tahoe
I've been playing with composite artifact colors on the Apple IIGS and IIe computers for years. I've just recently made some breakthroughs with RGB image conversions to the Apple's Double Hi Res Graphics mode that I decided to port to the CGA's 640x200 hi res mode, as they implement artifact colors almost identically. This is a very simple algorithm to implement, but took quite a while to figure out.

TLDR:​

cgargb_000.png
cgargb_001.png
cgargb_002.png
cgargb_003.png
cgargb_004.png

The included ZIP file has the code and DOS executable along with these sample images. To run yourself, DOSBox with the video mode set to CGA. I've tried DOSBox-X with cga_composite but I can't get it to stick - it reverts to regular CGA after fully booting.

To use your own images:​

  • Install 'The GIMP' (https://www.gimp.org/) and load your image into it.
  • Crop if needed to fit a 4:3 aspect ratio.
  • Scale the image to 640x200 (very important!). You will need to unlink the chain icon forcing the original aspect ratio.
  • Check the image color precision to ensure it is 8 bits and not 16 bits.
  • Finally, export the image as a .pnm image. This is a brain dead simple 24BPP format.

To display the image:​

cgargb <pnmfile>

If you omit the pnmfile, you will get a list of options. The most useful options are:
-g# - with # being 2, 1, 0, -1, -2. This will use different gamma correction from dark (2) to light(-2)
-t# - with # from -180 to 180. This is the tint adjustment in degrees. Try big values for cool effects.

Now the screen captures above were taken with DOSBox. To truly get the best experience requires a real composite color CRT. This algorithm was designed based on how TV's and monitors decode the NTSC signal and not all emulators are as faithful in this regard.

To compile the code:​

I compiled with MSC5.1 but TurboC/BorlandC should compile, too. I tried to keep the code very simple.
cl -DDOS cgargb.c

Implementation details:​

This algorithm started many years ago with my experiments with artifact colors on the IIGS using the Super Hires Graphics Mode:
This evolved recently when I started creating a toolkit for the Apple II's Double Hi Res mode in PLASMA: https://github.com/dschmenk/PLASMA/wiki/DHGR-RGB-Image-Converter - a much more challenging environment.

By thinking NTSC in reverse, I started formulating an algorithm to convert RGB pixels into a best-case string of bits that would display an acceptable image given the constraint that the NTSC chroma cycle is divided up into only 4 pieces, and there is only one bit per piece. This actually simplified the decisions to be made a great deal. You only have to decide to set a bit or not, with only four colors to choose from (the four sections of the chroma cycle). By breaking with tradition and treating the scanline as a sliding window into the chroma cycle, more resolution can be retained.

Enjoy!
 

Attachments

Last edited:
Back
Top