gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Graphics > Direct Palette Editing

#61166 - thegamefreak0134 - Thu Nov 17, 2005 7:47 pm

Hi again. I'm working on a menu for my game, and I wand to be able to dynamically change colors on the screen without requiring tons of images.

I am familiar with where I need to edit my palette entries (by treating the BG/OBJ palettes as an array) but I do not know how to do this. It would be nice if I could edit it in hex (#RRGGBB where R=Red, etc) or even nicer if I could specify colors via three variables, red green and blue, and let a function do the combining. This would be usefull for say fading red to orange withoug worrying about all three colors at once.) Can you help me at all with this?
_________________
What if the hokey-pokey really is what it's all about?

[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]

#61168 - kusma - Thu Nov 17, 2005 8:01 pm

Code:

BG_COLORS[i] = RGB5(r, g, b);

#61170 - thegamefreak0134 - Thu Nov 17, 2005 8:07 pm

Darn you for it being so easy. Thanks a whole bunch! I'll go try it out later! :-)
_________________
What if the hokey-pokey really is what it's all about?

[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]

#61261 - thegamefreak0134 - Fri Nov 18, 2005 4:08 pm

It says that there is an undefined reference to "RGB5". To I have to include a standard lib? if so, which one? I tried just using the RGB command, but it came out all wierd, so I assume it didn't work.

I noticed that when I did this, the palette didn't appear to be changing at all. (Palette viewer, VBA.) I figure it has more to do with the rgb thing though.

EDIT: Duh. I'm using a 256 color background and trying to assign a 16 bit color palette entree. oops. I'll try to fix it.
_________________
What if the hokey-pokey really is what it's all about?

[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]

#61265 - keldon - Fri Nov 18, 2005 4:54 pm

I use the tonc libarary - http://user.chem.tue.nl/jakvijn/tonc/tonctonc.htm

I think it is in video/gfx.h or something alike

#61267 - thegamefreak0134 - Fri Nov 18, 2005 5:04 pm

Yay! I got it to work finally! Turns out from searching that each palette entree (r,g,b) must be first a u8 and second anywhere from 0 to 31. So helpful! Now I can have dynamically color changing menus! Whoopie!

(You have no idea how helpful all of you people are.) 8-D
_________________
What if the hokey-pokey really is what it's all about?

[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]

#61268 - kusma - Fri Nov 18, 2005 5:04 pm

thegamefreak: i kinda assumed libgba....

#61274 - thegamefreak0134 - Fri Nov 18, 2005 5:46 pm

That would explain a lot then. I use my own libraries, mainly built off of a cheap tutorial, but with some stuff added myself.
_________________
What if the hokey-pokey really is what it's all about?

[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]

#61298 - kusma - Fri Nov 18, 2005 8:53 pm

here, then.

#define RGB5(r,g,b) ((r) | ((g) << 5) | ((b) << 10))

#61303 - thegamefreak0134 - Fri Nov 18, 2005 9:20 pm

Last question on the topic: If I switch from say mode 4 to mode 0-2 (like I plan to do with the project in the very near future) will I have to adjust my #define to handle a new color bit depth?
_________________
What if the hokey-pokey really is what it's all about?

[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]

#61311 - tepples - Fri Nov 18, 2005 10:12 pm

The RGB5 macro for composing values to be written to palette memory is the same in all six GBA video modes.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#61317 - thegamefreak0134 - Fri Nov 18, 2005 10:17 pm

Awesome. Thanks! I'm done here! (BTW, that kinda makes sense, considering that in 16 bit color mode the palette is simply split. Why that didn't click earlier god only knows.) You people are all so wonderfull!

You see, the reason for this is that my project I'm designing, a port though it may be, will NOT look like some cheap demo when it's done. I plan to learn and implement as many advanced techniques as possible, and this rather basic one was puzzling me. On to the next!
_________________
What if the hokey-pokey really is what it's all about?

[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]