Classic Computer Magazine Archive ATARI CLASSICS Volume 2, Issue 3 / June 1993 / PAGE 25

COLRVIEW: 4096 SiMUlATEd COlORS ON ThE ClASSiC ATARi

JEff POTTER, GRAPhiCS & ENTERTAiNMENT EdiTOR

    Those of you who recognize my name have probably seen my APAC (All Points All Colors) mode GIF (Graphic Interchange File) picture file decoders. I imagine a fair number of you gave up on APAC mode when your monitor produced only pale shades of red and blue, instead of the wide range of colors I claimed APAC would give you. Well, that has something to do with the type of monitor you have, and it's something nobody has been able to clear up for me. Some monitors produce excellent colors with APAC mode, while others (which are otherwise fine) just can't show APAC pictures.

The Beginning...
    So, I decided to see if I could improve upon APAC. I had studied the Atari ST Spectrum 512 graphics format for awhile, with thoughts of writing an 8-bit progam to decode and display these picture files. It was quite a trick: rewriting each of the 16 color registers up to three times each, allowing up to 48 different colors within a raster line. So I thought to myself: surely the 8-bit computer could do something that approached this many colors. I wrote a program to display GRAPHICS 9 images, and a display list interrupt to try to change the color as many times in a line as possible.
    Well, that didn't get too far. At best I seemed to be able to change one color register about two or three times within a raster line (and not very reliably at that). The old 6502 just isn't as fast as the 68000 series, especially when it has to deal with the extensive Antic DMA required by GRAPHICS 9. It seemed hopeless at that point, but then I noticed something. Somehow, every once in a while in the picture, the color would be almost perfect. I studied it carefully and realized that one line contained the correct red color component, the next line contained the correct green color, and the next had the blue. If you didn't look too closely, your eyes would merge the three lines into the correct color. If you break out a magnifying glass and examine a color monitor or television you'll notice this on a smaller scale. A three dot pattern (either in a triangle, or horizontally adjacent dots) exists on the surface of your picture tube. Because it's too small to be seen as individual dots, your eye perceives it as one color, not three.
    I then tried displaying three images in rapid succession (by page flipping), where the image is entirely red, green, or blue (GRAPHICS 9). This flickered horribly and didn't produce the color effect I sought. But it got me to thinking... .

COLRVIEW Is Born
    Then I hit upon the idea of page flipping three screens of display memory, and also using a display list interrupt to cycle between the three colors on a per-line basis. On the first screen, the top line (and every 3rd thereafter) is red, followed each time by lines of green and blue. On the second screen, the top line (and every 3rd thereafter) is green, followed by blue and red. Similarly, on the third screen, the top line is blue, then red and green. Every line of all three screens would be 80 unique pixels of GRAPHICS 9 (16 intensities, one color), as decoded from, say, a GIF image file. Each screen would be 192 lines, containing 7680 bytes. This is best shown by the diagram below, where RRR...RRR represents individual red pixels (80 per line), etc.

First Screen       Second Screen     Third Screen   
line   0  RRRRRRRRRRRRRRRR  GGGGGGGGGGGGGGGG  BBBBBBBBBBBBBBBB
line   1  GGGGGGGGGGGGGGGG  BBBBBBBBBBBBBBBB  RRRRRRRRRRRRRRRR
line   2  BBBBBBBBBBBBBBBB  RRRRRRRRRRRRRRRR  GGGGGGGGGGGGGGGG
line   3  RRRRRRRRRRRRRRRR  GGGGGGGGGGGGGGGG  BBBBBBBBBBBBBBBB
line   4  GGGGGGGGGGGGGGGG  BBBBBBBBBBBBBBBB  RRRRRRRRRRRRRRRR
line   5  BBBBBBBBBBBBBBBB  RRRRRRRRRRRRRRRR  GGGGGGGGGGGGGGGG
       :                  :                 :

       :                  :                 :
line 189  RRRRRRRRRRRRRRRR  GGGGGGGGGGGGGGGG  BBBBBBBBBBBBBBBB
line 190  GGGGGGGGGGGGGGGG  BBBBBBBBBBBBBBBB  RRRRRRRRRRRRRRRR
line 191  BBBBBBBBBBBBBBBB  RRRRRRRRRRRRRRRR  GGGGGGGGGGGGGGGG

    This produced wonderful colors! Within the image there will appear to be a "swimming" effect, as if something were constantly moving downwards. This can be minimized with judicious contrast and brightness settings. Best of all, this technique appears to work on all color monitors and televisions I've tried! Atari users could now display 80Hx192V pixel images, with 16 shades each of red, green and blue. If you allow for the color combining that your eyes can perform, along with the persistence of vision effect, you can show 16x16x16 or 4096 colors!
    I later generalized this technique by applying it to GRAPHICS 15 (160Hx192V with four colors) to produce higher resoluton images with 64 colors (4x4x4). The 4096 color mode is best for digitized photographs, or images with areas of pastel colors, or where the color changes gradually and subtly. The 64-color mode is best for line drawings, cartoons, or photographs with fine detail and high contrast.
    As you might guess, this new technique relies heavily on display lists and vertical blank interrupts. It relies so heavily on them that little time is left for your computer to do other things like read and write to the disk drive, or to service interrupts caused by the R: device.

Support Shareware: Get COLRVIEW
    If you'd like to experiment with this new technique, download the program COLRVIEW from your local BBS (if it's there). GEnie subscribers can obtain it from the Atari8 RT Library, file #6134, COLRVW26.ARC; CompuServe users will find it as CLRV26.ARC in the CIS 8-bit library. [Editor's Note: due to an administrative snafu we inadvertently omitted COLRVIEW from the June Software Disk; we plan to offer COLRVIEW on the October Disk. -BP] I'd also like to point out that COLRVIEW is shareware, so if you use it I'd appreciate your sending the modest $8.50 shareware fee I've requested. It is primarily through shareware that our software market now survives. Shareware fees are usually well within the means of most users, and the payment of these modest sums is all that fuels research into novel programming techniques such as this article describes.
    Many people have uploaded picture files to local BBSes and to the commercial network systems that can be viewed with COLRVIEW. Some of these were created with another shareware program of mine called APACVIEW, which can convert GIF picture files to COLRVIEW format. You might also wish to check your online sources for DEGASRD, another of my shareware offerings which decodes and views Atari ST Degas pictures directly into COLRVIEW mode.

How To Use COLRVIEW
    COLRVIEW's s file format is simplicity itself. You create three images in GRAPHICS 9 or 15 (if in 15, set your four colors to black, dark gray, light gray, and white). Save them as three separate files, named PICTURE.R, PICTURE.G, and PICTURE.B (replace PICTURE with your filename). The R file contains the red informaton, G contains the green, and B contains the blue.
    One way to create pictures is with a ComputerEyes camera and sets of color filters. Although I haven't tried this personally, a professional photographer gave me the following advice: Use a daylight-balanced (BCA-No.1) photo light if possible. Obtain some Kodak Wratten Gelatin Filters (these are available in 3"x3" squares and can be cut to any size) of the following types: #25 red, #58 green, and #47 blue. (These filters are usually available at any photo shop.) Make one exposure (saving it as a R, G, or.B file) through each filter. Try photographing still lifes, as your subject must not move between exposures. If you want to digitize livelier subjects, take a color photo of it and digitize the photograph with your camera.
    I know an artist/programmer who has created his own images in GRAPHICS 9 or 15 (with great difficulty) using a program like RAMbrandt. He would mentally decide on the color to be used for each area of the picture, and modify all three picture files in the right way. He has since gone on to create a program to automate some of this activity. Look for RGBPAINT, available in the CompuServe 8-bit library. I can't comment on its performance, as it requires an expanded memory machine (130XE or 256K 800XL).
    I've also seen the output of a program to convert Amiga ILBM/IFF pictures to ColorView mode, and another program that plots fractal curves in ColorView mode. Neither of these have been released yet (but let's encourage these guys!).
    In a future sequel to this article, I'll tell you where to look for COLRVIEW images. I'll also provide some code segments to allow you to set up the appropriate display lists and display list interrupts in your own programs. With just a bit of clever programming, you can train your Classic Atari to render graphics displays that will compare favorably with the performance of the overblown hardware being sold in today's mainstream market.