• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Scottie, Todd, Serena, Kris - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Other✓] Converting RGB to GBA colours

So a GBA color is stored in a 16-bit unsigned integer, with the first 15 bits being dedicated to storing color information (5 bits for red, green, and blue). This is called, obviously, 15-bit RGB.

To get an RGB color to a GBA color, just use this:
Code:
gba_color = (((red >> 3) & 31) | (((green >> 3) & 31) << 5) | (((blue >> 3) & 31) << 10))

To go from GBA to RGB, use this:
Code:
red = (gba_color & 31) << 3
green = ((gba_color >> 5) & 31) << 3
blue = ((gba_color >> 10) & 31) << 3

Hope that helps! :)
 
Last edited:
So a GBA color is stored in a 16-bit unsigned integer, with the first 15 bits being dedicated to storing color information (5 bits for red, green, and blue). This is called, obviously, 15-bit RGB.

To get an RGB color to a GBA color, just use this:
Code:
gba_color = (((red >> 3) & 31) | (((green >> 3) & 31) << 5) | (((blue >> 3) & 31) << 10))

To go from GBA to RGB, use this:
Code:
red = (gba_color & 31) << 3
green = ((gba_color >> 5) & 31) << 3
blue = ((gba_color >> 10) & 31) << 3

Hope that helps! :)

Haha I didn`t know you know that. If I knew you know that I would ask you before ^^

That is exactly what I was looking for.
 
Back
Top