News:

The forum has been updated to SMF (2.1.3)!
Please be patient as we work to polish up the place and update features as we can.

Main Menu

Palette info

Started by Salanewt, 01, December, 2009, 02:29:57 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Salanewt

Hello. Lately, I have been wondering how game handle palettes. For example, how does Golden Sun get its colours, and how many bytes are used?

I am only wondering this because Mario and Luigi uses four bytes per colour. I am still working it out for those who are interested (myself included), but a single colour is built like this (still not sure for tilesets, but I am very sure that this is the case). Sprites are also composed of 16 colours, no more.

BR BG

I can only guarantee the second two. Basically, we have Brown, Burgundy (this can be made into red with the first bit), Green, and Blue. I find this a bit confusing, so I was hoping that someone could give me some palette information if other games use similar colour systems, or hopefully even a place to enter byte combinations for colours (since finding the palette that I want is going to be hard just by trial and error). I have noticed that the very first colour might actually be shade? I doubt this, since F0 F0 is purple, not blue (although F0 0F seems to be a light green).

Have a nice day.


By the way, any palette information for hacking games should be acceptable here.
Oh yeah baby, £ me harder.

Fusion is just a cheap tactic to make weak Adepts stronger.

Yoshi's Lighthouse is a hacking website in progress. Why not check it out if you like Yoshi or the Mario & Luigi games?

Atrius (He/Him)

#1
2 bytes, all GBA games use the same palette format which is only 2 bytes for each color in a palette.

1 hex value = 4 bits
1 byte = 8 bits
1 byte =  2 hex values

The actual data is formatted as such:

bits 0-4 : Red
bits 5-9 : Green
bits 10-14 : Blue
bit 15: Unused.  (This is why white is represented as 7FFF)

For example:

001F = Red
03E0 = Green
7C00 = Blue

(GBA is little endian, so when you combine two bytes into a single 16-bit value they get reversed)

It can be rather confusing if you don't understand how each bit falls into a hex value.
[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]

Salanewt

Thanks again Atrius! I always assumed that half of a byte was a bit, but... Lol. Anyway, thanks for clearing so much up for me! Now, with the knowledge of Palettes at my side, I can slowly work on customizing any character how I want. All GBA games work like this for how their palettes are constructed? Very nice to know.

Have a nice day.

Now to find my spriting scalpel.
Oh yeah baby, £ me harder.

Fusion is just a cheap tactic to make weak Adepts stronger.

Yoshi's Lighthouse is a hacking website in progress. Why not check it out if you like Yoshi or the Mario & Luigi games?

Atrius (He/Him)

#3
Computers store data as 1's and 0's.  These are known as bits.

A single hex digit uses 4 bits, or 1's and 0's to store it's value.

bit 0 represents 1
bit 1 represents 2
bit 2 represents 4
bit 3 represents 8

By adding these values in different combinations you can get any number 0 to 15 in decimal, or 0 to F in hexadecimal

Basically, with the bits ordered from right to left as all digits are:

0 = 0000 = 0 = 0
1 = 0001 = 1 = 1
2 = 0010 = 2 = 2
3 = 0011 = 2+1 = 3
4 = 0100 = 4 = 4
5 = 0101 = 4+1 = 5
6 = 0110 = 4+2 = 6
7 = 0111 = 4+2+1 = 7
8 = 1000 = 8 = 8
9 = 1001 = 8+1 = 9
A = 1010 = 8+2 = 10
B = 1011 = 8+2+1 = 11
C = 1100 = 8+4 = 12
D = 1101 = 8+4+1 = 13
E = 1110 = 8+4+2 = 14
F = 1111 = 8+4+2+1 = 15
[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]

Salanewt

Yep, must love Binary, right? Well, thanks again! So that is the relationship between HEX and Binary... I wonder if there is a formula to convert Hexadecimal to Decimal without having to use a calculator/spend time thinking of it?

Thank you for all of your help.

Have a nice day.

Oh yes, is there any way that I can test colour values without trial and error, or not? I pretty much have the colours that I want, but I am not sure how to get them with the GBA's method of creating colours.
Oh yeah baby, £ me harder.

Fusion is just a cheap tactic to make weak Adepts stronger.

Yoshi's Lighthouse is a hacking website in progress. Why not check it out if you like Yoshi or the Mario & Luigi games?

Atrius (He/Him)

Your RGB values should all be 248 at the the highest.  Take each of them divide them by 8, and round it to the nearest number which should be between 0 and 31, if you use 32 it won't work.

Using windows calculator in scientific, or programmer mode (whichever your version actually has, and allows you to view values in hex) In decimal mode first put in the blue value, multiply by 32, add the green value, multiply by 32 again, and finally add the red value, then switch to hex mode to get your color value.
[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]

Salanewt

#6
Wow, thanks again! Wait though, wouldn't I just be able to select the same colours from Golden Sun'a palette? Hm... Hard to say. It does seem that the other colours might work (and people tend to favour the brighter colours in Superstar Saga), but they do not display correctly? Well, it is time to see if the palette that I am using for a "surprise" will work, since the original came from a DS game. One last question for now. Do you know how I can find out the values for the colours that I am using?

Have a nice day.

Edit: If it were for the html based colour system, then I would know, but for the GBA system... I would rather not do trial and error, but I will if I must.
Oh yeah baby, £ me harder.

Fusion is just a cheap tactic to make weak Adepts stronger.

Yoshi's Lighthouse is a hacking website in progress. Why not check it out if you like Yoshi or the Mario & Luigi games?

Mion Sonozaki

Bumping because relevant topic.

How does one convert RGB to a 2-byte hex?

For example, what is the formula that goes into converting 26,9,16 to 413A?

Daddy Poi's Oily Gorillas

#8
Formula?

Valid numbers for each color of RGB go from 0 to 31.
(blue * 0x400) + (green * 0x20) + (red)


In programming, it'd probably be better to do:
(blue << 10) Or (green << 5) Or (red)
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Mion Sonozaki

#9
Quote from: Fox on 10, December, 2014, 05:10:33 AM
Formula?

Valid numbers for each color of RGB go from 0 to 31.
(blue * 0x400) + (green * 0x20) + (red)


In programming, it'd probably be better to do:
(blue << 10) Or (green << 5) Or (red)

I'm not sure how to apply the double "<<" symbol. It's never something I learned in math.

Quote from: Atrius on 01, December, 2009, 10:28:43 PM

Using windows calculator in scientific, or programmer mode (whichever your version actually has, and allows you to view values in hex) In decimal mode first put in the blue value, multiply by 32, add the green value, multiply by 32 again, and finally add the red value, then switch to hex mode to get your color value.

This seems more up my alley, and now I understand it.

I'll put it into layman's terms for myself:

Atrius saying that each RGB color supported by the GBA can go up to 248.

To convert it to a value usable by the GBA, you must first convert each RGB color by dividing them each by 8. So 248/8 = 31

Then in Windows calculator, in Decimal Mode, you plug in the blue value, multiply by 32, add the green value, multiply by 32 again, then add red value. After, convert to hex. I should get the answer 7FFF.

For me, the formula would look like:
((31*32+31)*32)+31

Or otherwise

((blue*32+green)*32)+red

Okay, seems simple now.

Daddy Poi's Oily Gorillas

#10
7FFF is white.

QuoteI would multiply in hex 31x400, 31x20, and 31x1?
Close, but not quite.  I used hex numbers, you just made them dec. The dec equivalent would be: 31x1024, 31x32, 31x1.

<< just shifts the bits left by the number of given bits.

"<< 10" shifts the number over to the left 10 bits... (Think in binary.)



@Lishy's edit: Yeah, Atrius's way is obviously easiest to remember. Good thing I linked this topic!
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)