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 > HELP ME ON PALETTE!!!

#12026 - dafagba - Mon Oct 27, 2003 11:28 am

I design a game, it used MODE_0,
BG0 show backgroud
BG1 show text.

BG0 and BG1 are both 16 color, but they do not use the same palette.

I can use LoadPalette() to load one of the palette into ram, such as:

Quote:

for (u8 i = 0; i < 255; i++)
LoadPaletteEntry(i, paletteData[i]);


then problem apeared: the two BGs use the same palette, the 2nd BG looks very ugly.

I know I can load two 16_color_palette into ram, but I do not know how to make BG_0 use 1st pal, and BG_1 use 2nd pal

So, can anyone tell me how to use different palettes.

:(

Thanks......... :)

#12030 - NoMis - Mon Oct 27, 2003 1:27 pm

You have to specify the Palette number in the tiles itself, because every tile can have another palette.

A TileEntry for a textbackground has 2 bytes splitted like this:

bits 0-9: TileNumber
bit 10: Horizontal flip
bit 11: Vertical Flip flag
bit 12-15: Palette Number (ignored if 256 colormode)

You have to put the number of the palette into the last bits (12-15) of the Tileentry and set the appropriate color bit of the background to 16-Colormode (which you should already have).

Take a look at devotos pern project day 4 for further understanding
(http://www.thepernproject.com/index2.htm)

NoMis

#12045 - dafagba - Tue Oct 28, 2003 1:02 am

THANK YOU VERY MUCH!!!!!!
I LOVE YOU, NOMIS! :)