Issue swapping out palette colors

SGDK only sub forum

Moderator: Stef

Post Reply
Burbruee
Interested
Posts: 29
Joined: Sun Oct 11, 2015 12:30 am

Issue swapping out palette colors

Post 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? :)
dub
Very interested
Posts: 101
Joined: Thu Mar 19, 2015 1:26 pm

Re: Issue swapping out palette colors

Post 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.
ehaliewicz
Very interested
Posts: 50
Joined: Tue Dec 24, 2013 1:00 am

Re: Issue swapping out palette colors

Post 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.
Burbruee
Interested
Posts: 29
Joined: Sun Oct 11, 2015 12:30 am

Re: Issue swapping out palette colors

Post by Burbruee »

Thanks, that explains it. :)
I'll investigate how to change it during horizontal interrupt.
Post Reply