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.

Beginners > Background Palette

#170140 - Azenris - Wed Sep 02, 2009 3:19 pm

I have some tiles each using a single 256 palette. However the colours themselves are shown as rgb 0..255. but that needs 8 bits each and from I saw the nds only has 16 bit palette. (B, G, R, x) BGR=5 bit each. 0..31

Am I looking at this wrong or to get the colour do I have to convert it, like 255 becomes 31 as its max value, 127 = 15. etc.

TY for any help, ask if you need me to explain better.
_________________
My Homebrew Games

#170141 - Dwedit - Wed Sep 02, 2009 3:47 pm

You are correct. Just divide by 8 and truncate or round to get your reduced-bit R G or B value. (Obviously, you don't round to values higher than 31). Then pack the values into a 16-bit number, Red + Green * 32 + Blue * 1024.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#170143 - Azenris - Thu Sep 03, 2009 5:08 pm

Thankyou Dwedit for the help
_________________
My Homebrew Games