Re: [cc65] Colormania (was: TGI summary)

From: Daniel Serpell <daniel.serpell1gmail.com>
Date: 2009-10-27 20:19:57
Hi!

On Tue, Oct 27, 2009 at 3:02 PM, Ullrich von Bassewitz <uz@musoftware.de> wrote:
>
[...]
>
> There is a case that cannot be covered by reassigning palette indices. Assume
> a four color driver and an eight color driver, where the four color palette is
> not a subset of the eight color palette. In this case, the colors are not
> platform, but driver depdendent, so there cannot be platform speficic
> TGI_COLOR_XXX #defines for a platform.
>

This is what happens in the Atari:
*  Mode 8 (hi-res) have palette with index "0" for background, index "1" for
    foreground, so you should set TGI_COLOR_WHITE to "1" and set the
    palette accordingly.
* Mode 9 (grayscale) hasn't palette, index '0' is BLACK and index '15' is
   white. Here, the driver should convert index "1" to "15" on setcolor.
* Mode 11 (color) also hasn't palette, index '0' is BLACK and index '1' to
  '15' are different colors, there is NO white. Here, the driver should
  convert index "1" to, for example, index "14" (yellow).

The problem with the above is that a program that is designed to
run on the Atari mode 9 normally expects index 0 to be black and
index 15 to be white, with all the 14 grays in between, and this
mapping will break the expectations.

Perhaps a new api could be designed modeled on, for example,
how X11 works:

* There is a call "tgi_alloc_color", that takes R, G and B values and
  returns the index with the closest color available. If the mode has a
  palette, one index of the palette is reserved, the palette is set to the
  best approximation of the R,G,B values and the new index is returned.
* There is a corresponding call "tgi_free_color" that takes the index
  (as returned from "tgi_alloc_color") and frees it, so new calls to
  alloc_color can use it again.
* The argument to pass to setcolor is the index returned from alloc_color.

With this calls, you can do:

unsigned char black = tgi_alloc_color(0,0,0);
unsigned char white = tgi_alloc_color(255,255,255);

tgi_setcolor(white);
// Now, draw with white color...
tgi_setcolor(black);
// Now, draw with black color...

For compatibility, at startup all two color drivers should set the
palette to white on black.

    Daniel.
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Oct 27 20:20:06 2009

This archive was generated by hypermail 2.1.8 : 2009-10-27 20:20:08 CET