Page 1 of 1

Issue swapping out palette colors

Posted: Tue Nov 17, 2015 5:03 am
by Burbruee
Hi,

I wanted to do a small test. Print a text once per line, but with a different color on every line.

So, I tried this first:

Code: Select all

VDP_setPaletteColor(15, 0x0008);
VDP_drawText("Hello World!", 0, 0);
and it works, the color is different than the default color.

But, when I do this multiple times like so:

Code: Select all

VDP_setPaletteColor(15, 0x000E);
VDP_drawText("Hello World!", 0, 0);

VDP_setPaletteColor(15, 0x000C);
VDP_drawText("Hello World!", 0, 1);

VDP_setPaletteColor(15, 0x000A);
VDP_drawText("Hello World!", 0, 2);

VDP_setPaletteColor(15, 0x0008);
VDP_drawText("Hello World!", 0, 3);
Then the end result is the same font color on all lines! It uses the last of the setPaletteColor calls only, for all of the text. But I wanted to set a color, print it on a line, set it to another color, print on next line, change the color again etc.

What am I doing wrong here? :)

Re: Issue swapping out palette colors

Posted: Tue Nov 17, 2015 7:46 am
by dub
Hi, you can have nearly 64 colors max per frame.

So your color 15 for the frame always be the same. You can change it every frame.
But I'm sorry, I think we can have only one color/palette for system font. Wait for expert confirmation.

Re: Issue swapping out palette colors

Posted: Wed Nov 18, 2015 11:02 pm
by ehaliewicz
This is because those drawText calls do not actually draw to the screen, but are essentially telling the VDP to draw those tiles later on, after the setPaletteColor changes have been made.

There are two solutions, change the palette mid-frame (during horizontal interrupts), or use multiple palettes to draw text.

Re: Issue swapping out palette colors

Posted: Thu Nov 19, 2015 2:37 am
by Burbruee
Thanks, that explains it. :)
I'll investigate how to change it during horizontal interrupt.