Friday, July 27, 2012

Palette Redux

In the previous couple of posts, we have discussed how to drive the CoCo's VDG to display 8 on-screen colors even when using the VDG's 4-color graphics mode.  This has yielded a substantial improvement in the quality of "real life" images converted for display on the CoCo, but the results are still lackluster.  In particular, the lack of black is a glaring problem in the display of many images.  I think we can do better.


So, lets review our best performing options....

The "color graphics" mode with the dynamic CSS configuration gives us 8 colors on the screen at once.  The palette remains a bit limited, and any given segment of 16 pixels must share the same 4-color palette.  But, dithering and the ability to select different palette combinations for each row on the screen combine to enable generating images on the CoCo that well represent their source images.  The biggest drawback of this mode is the lack of black in the display.

The "semi-graphics" mode provides for 8 colors on the screen and includes the ability to add black into the mix as well.  But, this mode is restricted to half the horizontal resolution of the "color graphics" mode.  Further, any given pair of these lower-resolution pixels is restricted to either sharing the same color or to using one color and black between the two of them.  Obviously, these limitations produce more "blocky" results than one gets with the "color graphics" mode.

So, we have two mediocre options.  It would be nice if we could find a way to combine the advantages of each of these modes...

Flip Flop

It seems like the biggest problem with the CoCo's graphics is the lack of available colors.  One tricky technique that can be used to increase available colors is to draw different colors on alternating screens.  When those screens are alternated quickly enough (e.g. every 1/60th of a second), the eye tends to blend those colors, forming a new set of colors.  Perhaps we could alternate between the "semi-graphics" mode and the 8-color "color graphics" mode, producing a larger suite of combined colors?  The lack of black in the "color graphics" mode will still prevent us from having a true black for our converted images, but hopefully a gray or even a darker blue will at least be a more suitable replacement for black than the bright blue we have now.

We are already changing the VDG configuration mid-screen and even mid-line.  It is, of course, also possible to change the VDG configuration between screens.  In fact, this basic technique has often been used to facilitate "page flip" animations.  So, let's use this technique to produce a new combined graphics mode.

Proof Of Concept

I started with the earlier palette test application.  To that, I added initialization of a "semi-graphics" screen buffer with a series of horizontal lines in all 8 colors plus a 9th area on the bottom right of the screen that is all black.  Then, I changed the code so that after displaying the "color graphics" screen it would then reinitialize the VDG for "semi-graphics" mode.  After that screen finishes, the VDG is reinitialized for the "color graphics" mode again and the whole process is repeated.  The result is a display of all the available colors in the combined mode.

Mode-Flipping Palette of 44 colors!

If my math is correct, that should give us 44 colors to use -- I counted just to be sure!  That should lead to quite an improvement in our image conversions.  On the downside, there is some noticeable "flicker" on the screen when using this technique.  There may be ways to minimize that effect, but it is probably not completely avoidable.  Hopefully the bounty of new colors will more than compensate!

Stay tuned to hear about how I'm using this combined mode for image conversions...

No comments:

Post a Comment