#176908 - blessingta@hotmail.co.uk - Tue Oct 18, 2011 6:16 pm
hi
how do I modify the colour palettes? So far I've learnt where the characters are stored (a-z), and can modify them through bit shifting.
But going back to colours palettes I'm suspecting that they are in BG_COLORS, but I'm not sure how I can create my own colour palettes.
#176911 - Dwedit - Tue Oct 18, 2011 8:12 pm
Palette memory is at 05000000-050003FF, and it's 16-bit memory, so writes must be done as 16-bit writes or 32-bit writes. Libgba calls the palette BG_PALETTE or BG_COLORS, they are the same exact thing. The sprite palette begins 0x200 bytes after the background palette, and is called SPRITE_PALETTE or OBJ_COLORS.
BG_PALETTE is already declared as a u16 array, so you won't be doing any 8-bit writes to there. You also can memcpy to that area.
Colors are 15-bit, blue is the most significant 5 bits, red is the least significant 5 bits.
There's also a RGB5 macro that does the multiplication for you if you want to use that.
When you write to the tilemap, you can pick which palette a tile uses. When you write to OAM, you can pick which palette a sprite uses.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."
#176917 - blessingta@hotmail.co.uk - Thu Oct 20, 2011 4:17 pm
if its ordered like BLUE GREEN RED, then where is the extra 1bit left? Is it the most[furthest left] or least[furthest right] significant bit?
#176918 - sverx - Thu Oct 20, 2011 4:23 pm
the msb. it's xBBBBBGGGGGRRRRR
_________________
libXM7|NDS programming tutorial (Italiano)|Waimanu DS / GBA|A DS Homebrewer's Diary
Last edited by sverx on Thu Oct 20, 2011 4:25 pm; edited 1 time in total
#176919 - Dwedit - Thu Oct 20, 2011 4:24 pm
The extra bit does absolutely nothing on the GBA.
On the Nintendo DS, in some extended frame-buffer modes, the bit must be set to 1, otherwise the pixel is considered fully transparent, but that varies depending on what video mode you are using. Some modes ignore the bit, others require it to be 1. This is just for framebuffer modes where you are setting every pixel to a 16-bit value. On palettes, the most significant bit does nothing.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."
#176920 - blessingta@hotmail.co.uk - Fri Oct 21, 2011 9:13 am
is the first colour of a pallete always transparent ? which would mean that there are actually 15 colours to choose from instead.
#176923 - sverx - Fri Oct 21, 2011 1:48 pm
color 0 is transparent. its RGB value will be the backdrop color.
_________________
libXM7|NDS programming tutorial (Italiano)|Waimanu DS / GBA|A DS Homebrewer's Diary