The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Fan Games > Binary ROM Hacking
Reload this Page Other Converting RGB to GBA colours

Notices
For all updates, view the main page.

Binary ROM Hacking Need a helping hand or just want to talk about binary ROM hacks? Get comments and answers to any ROM Hacking-related problems, questions or thoughts you have here.

Ad Content
Reply
 
Thread Tools
  #1   Link to this post, but load the entire thread.  
Old August 15th, 2015 (12:48 PM).
xGal xGal is offline
Mhm
 
Join Date: Nov 2011
Location: A tree
Gender: Other
Nature: Relaxed
Posts: 241
Does anyone know how to convert RGB to a GBA palette?
__________________
Reply With Quote
  #2   Link to this post, but load the entire thread.  
Old August 15th, 2015 (2:22 PM).
PokéMew's Avatar
PokéMew PokéMew is offline
Pokémon Fuchsia
 
Join Date: Sep 2013
Location: Refresh
Gender: Male
Nature: Modest
Posts: 484
Quote:
Originally Posted by xGal View Post
Does anyone know how to convert RGB to a GBA palette?
http://romhacking.merlindenker.de/RGB2GBAConverter.rar
-By the long lost Neti.
Reply With Quote
  #3   Link to this post, but load the entire thread.  
Old August 15th, 2015 (4:26 PM).
xGal xGal is offline
Mhm
 
Join Date: Nov 2011
Location: A tree
Gender: Other
Nature: Relaxed
Posts: 241
Quote:
Originally Posted by PokéMew View Post
Thanks very much for linking to it. I was hoping to get the formula, not a program that does the convertion proccess but I see that the source code is in the rar package so I will definetly check it out when I am on my computer!
__________________
Reply With Quote
  #4   Link to this post, but load the entire thread.  
Old August 15th, 2015 (8:30 PM). Edited August 15th, 2015 by esperance.
esperance's Avatar
esperance esperance is offline
 
Join Date: Mar 2010
Location: OH
Age: 26
Gender: Male
Nature: Relaxed
Posts: 3,830
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! :)
__________________
What are you so afraid of?
Reply With Quote
  #5   Link to this post, but load the entire thread.  
Old August 16th, 2015 (6:31 AM).
xGal xGal is offline
Mhm
 
Join Date: Nov 2011
Location: A tree
Gender: Other
Nature: Relaxed
Posts: 241
Quote:
Originally Posted by Lost Heart View Post
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.
__________________
Reply With Quote
Reply

Quick Reply

Join the conversation!

Create an account to post a reply in this thread, participate in other discussions, and more!

Create a PokéCommunity Account
Ad Content

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 9:09 AM.