#171446 - MichaelMossman - Thu Nov 19, 2009 8:14 pm
There's a lot of help about how to choose and select 16-colour palettes but I can't find any reference about how to control exactly what goes into each palette.
Are these pre-determined ? If so, how do I choose the selection I want ?
Or are they able to be defined by program ? If so, how ?
Finally, on this subject, what is the actual format of each palette (i.e How do I know which colour is in which slot ? ).
#171450 - Dwedit - Thu Nov 19, 2009 9:06 pm
There are standard palettes, and extended palettes. I'll just be talking about standard palettes here.
There are four 256 color palettes, first one for backgrounds, then one for sprites, then another background and sprite palette for the secondary screen. Each entry in the palette is 15-bit rgb (like xBBBBBGGGGGRRRRR). The most significant bit is not used in the palette. You can also think of it as Red, Green, and Blue being in the range of 0-31, and the formula for a color is Blue*1024 + Green*32 + Red.
The standard palette for background is located in memory at address 0x05000000, and the sprite palette is 512 bytes later. Add 1024 to an address to get the palette for the secondary screen.
LibNDS defines the arrays BG_PALETTE, BG_PALETTE_SUB, SPRITE_PALETTE, and SPRITE_PALETTE_SUB for your convenience, as well as macros to calculate RGB values. So you'd just use code like BG_PALETTE[4] = RGB15(15,31,4);
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."
#171460 - Dwedit - Fri Nov 20, 2009 7:48 pm
Um, what? You don't need extended palettes to select which 16 color palette a BG tile or sprite uses.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."