Re: [cc65] Re: TGI colors revisited

From: Oliver Schmidt <>
Date: 2011-05-03 14:57:06
Hi Karri,

>> I didn't receive any feedback at all on my posting below.

> It is spring in Finland. No time to sit by the computer when the sun shines.

That's exactly the type of reason for not getting feedback I had hoped for :-))

>>> 2. We aggreed that we live with the somewhat inconsistent usage of the
>>> TGI_COLOR_... macros in the TGI API. [...]

> True. But if the programmer starts changing the default palette I believe he
> is using sprites.

By far not every TGI-enabled cc65 target supports sprites...

> He is probably also allocating one color for text and one
> color for text background.

If I understand you right than this is (at least sort of) what I made
the TGI demo program do. It by now defines a COLOR_FORE and COLOR_BACK
and uses only those macros in calls to tgi_setcolor().

> He is not interested in color macros found in
> cc65 at this point.

Hm, for tgi_setcolor() I agree with you (see above) but for
setting/creating/changing the palette he needs the macros to get
anywhere near a target-independent program.

>>> - 'lynx' has only a 16-color mode driver. So the (black/white = 0/1)
>>> rules do _NOT_ above apply. In fact white has the value $0F so this
>>> target benefits from the target-specific TGI_COLOR_... macros. I
>>> defined the 16 macros to be identical to the TGI_COLOR_... macros.
>>> Please speak up if this is wrong and needs to be changed!

If the Lynx doesn't have conio support than the stuff I put into
lynx.h doesn't make sense. Instead of

#define COLOR_BLACK 0x00

it should rather just be

#define TGI_COLOR_BLACK 0x00

>>> However the
>>> default palette has totally different values than the TGI_COLOR_...
>>> macros - they even seem to be 16-bit values so there is some work in
>>> the drivers necessary - which I can't do.

> The actual 16-bit value for a color is  RGB with 4 bits for each component.
> (The order is $0GBR to confuse the programmers.)

I understand and I believe that this is the very thing that needs to
be "abstracted away" in the driver.

> I can easily change all the color values to comply with the TGI_COLOR
> defines. Black can be 0 and white can be 1.

As I tried to point out there's no reason to map
TGI_COLOR_BLACK/TGI_COLOR_WHITE to 0/1 if this isn't the "natural"
choice for the the Lynx.

> Please tell me what the default
> TGI-palette should look like.

Just to make sure there's no misunderstanding which might result in
potentially unnecessary work on your side:

- The default palette needs to contain the values 0, 1, ..., 14, 15 in
that order.

- The TGI functions tgi_setpalette/tgi_getpalette/tgi_getdefpalette
need to operate on palettes being 16 bytes large. So there needs to be
some mapping between the "TGI palette" and the "12-bit palette".

- If you feel that this doesn't give a finegrained enough control over
the colors used you might consider to provide some tgi_ioctl function
to manipulate the 12-bit palette directly.

> I just need the RGB values and names for the
> colors.

Again just to be sure...

Regarding the TGI_COLOR_... macro names I'd probably go for the names
used by the C64. Simply because many cc65 TGI programs start as
C64-only programs. So using the maco names used there gives maximal
source code compatibility.

The TGI_COLOR_... macros values need to be 0-15.

Regarding the RGB values I've no good idea. On the one hand one might
again look at the C64 (-emulator VICE). On the other hand the C64
colors are really ugly...

There is by the way no reason to restrict yourself to 16 TGI_COLOR_...
macros. In just the same way the C64 with only a 2-color driver has
more than 2 TGI_COLOR_... macros your 16-color driver doesn't restrict
you to 16 TGI_COLOR_... macros. It's just that the ones with the
values 0-15 need to be there and correspond to the default palette
entries. The values 16-255 are free for whatever.

A fancy idea might be to allow for arbitrary 6-bit values (RGB with 2
bits for each component). The upper two bits left would always be set
to not interfere with the obligatory "fixed" colors 0-15 mentioned so
far. Then a macro TGI_COLOR_RGB(r, g, b) could be defined...

To unsubscribe from the list send mail to with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue May 3 14:57:14 2011

This archive was generated by hypermail 2.1.8 : 2011-05-03 14:57:16 CEST