• 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.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Dawn, Gloria, Juliana, or Summer - 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.

[Graphics] How do I convert RGB to GBA colors and vice versa?

  • 1
    Posts
    6
    Years
    • Seen Apr 30, 2020
    Hello, this is my first time at this forum. Sorry for the bad English, I'm not fluent. Well, I am wiriting a program in C# for edit a game of AGB, I've developed many tools: A Script Editor to edit text as a Notepad, an Item Editor to edit itens description and now I'm developing a Graphic Editor that needs a palet converter between GBA and RGB colors. I've looked a thread (Looks like I can't post links because I don't have 5 points or more)

    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! :)

    But I really did not understand that ">>", "&" and "|". Can someone explain me?
     
    Back
    Top