Hard Light Productions Forums
Off-Topic Discussion => Gaming Discussion => Topic started by: FlamingCobra on January 02, 2012, 02:57:49 pm
-
I've been doing some investigations into how Samus' color palette works in Metroid Fusion.
Codebreaker codes for GBA are written in Hexadecimal. I think. Just like the game itself. I think. Anyway, here's what I've come up with:
83004D28 4E73 - ?????
83004D2A 0000 - ?????
83004D2C XXXX - Shoulder, Kneecap, Elbow, part of feet
83004D2E XXXX - Front of Legs (shin), part of back and arm, part of feet
83004D30 XXXX - Back of legs, arms, and backside
83004D32 XXXX - Shadows -- OVERWRITES MAGENTA IN SCREW ATTACK
83004D34 XXXX - Two pixels, one on shoulder, one on leg
83004D36 XXXX - Part of armor layer 2 (yellow areas)
83004D38 XXXX - Part of helmet
83004D3A XXXX - Part of helmet
83004D3C XXXX - Most of helmet (maroon)
83004D3E XXXX - Visor
83004D40 XXXX - Dark Yellow areas on inside of leg
83004D42 XXXX - Backpack (gray), oxygen pipe on helmet, top of arm cannon while running
83004D44 XXXX - One pixel on back, middle of gun while running
83004D46 XXXX - Outline
The first number set points to a part of Samus' suit. The second, four digit set assigns a color value.
At first I thought it was RGB. That didn't work out. Then I began to believe it a hex color code, but on Wikipedia and all other websites, hex color codes have six digits. I eventually decided to work it out on my own.
The general pattern I came up with is this:
XXXX -- the first digit refers to blue
XXXX -- the second digit refers to green
XXXX -- the fourth digit refers to red
This led me to believe the third digit referred to yellow. In fact, it turns out to be doo-doo yellow-brown.
Anyway, these digits are hex digits; values can range from 0 to F. You can mix these colors kind of like paints. Well, more like mixing light, because when you put them all together you get white. The higher the number, the more you put in it.
F000 does not give you bright blue, as you would initially expect; you get navy. 0F00 gives you dark green, and 000F gives you maroon.
Mixing them like paint (or light) is a pretty good rule of thumb, but it only works up to a certain point. For example, after trying several combinations of values in an attempt to get a brighter shade of red, I accidentally mixed in a high value of green with the red. And I got bright red. This is one of the most basic examples of the many perversions of the pattern that I came up with.
Which leads me to believe that the pattern I came up with is not the way it works at all and is merely a coincidence. Could anybody here offer some insight?
-
I like Metroid Fusion.
-
That's a rather intresting find you've made FlamingCobra. I myself know bugger all about coding of any kind, apart from there being 10 kinds of people who can read binary.
Your mission now, if you choose to accept it, is to take this knowlege and apply it in the manner of Rule 34.
That is all.
-
I myself know bugger all about coding of any kind, apart from there being 10 kinds of people who can read binary.
Fail.
-
Erm... 10 in base 2= 2. (1*2^1)+(0*2^0)=2.
It's a compsci joke. Unless, of course, you're being facetious.
-
It's a compsci joke.
No way. Really?
-
Erm... 10 in base 2= 2. (1*2^1)+(0*2^0)=2.
It's a compsci joke. Unless, of course, you're being facetious.
Yeah....lets go with that..... :nervous:
-
Yeah....lets go with that..... :nervous:
oh u
-
Erm... 10 in base 2= 2. (1*2^1)+(0*2^0)=2.
It's a compsci joke. Unless, of course, you're being facetious.
there aren't 10 kinds of people that can read binary. there are 10 kinds of people. those who can read binary and those who can't. that's what he mean by fail.
-
In my defence I hadn't heard ther joke in almost two years.
-
I've never heard the joke and I understood the issue with it
-
There are also only 10 people who understand trinary
those that do, those that dont and those who get if confused with binary
-
On a note that may be of more practical value, the GBA uses 5 bits per channel, not 8. The highest value would be 1F, not FF. If it is overflowing and ignoring the larger bits, F0 would be binary 11110000. That would truncate to 10000 for 5 bits, or about half maximum brightness - seems about right for what you're seeing.
-
There are also only 10 people who understand trinary
those that do, those that dont and those who get if confused with binary
First FireSpawn and now you too?
Seriously, the joke starts with "There are 10 types/kinds/whatever of people period", not with "There are 10 people who can understand base N". This is especially cringe-worthy when you then contradict yourself and say one of those people doesn't understand base N afterall.
-
There are two kinds of people that understand how to do this joke properly
Those that make the joke properly, and those that piss on the people who don't know how to do it
-
the set of all people that understand set theory contains two kinds of people: all of the people that understand set theory and nobody.
-
you left out those who confuse it with binary :D
-
On a note that may be of more practical value, the GBA uses 5 bits per channel, not 8. The highest value would be 1F, not FF. If it is overflowing and ignoring the larger bits, F0 would be binary 11110000. That would truncate to 10000 for 5 bits, or about half maximum brightness - seems about right for what you're seeing.
wut?
-
The GBA's display doesn't store channel values as 0-255. It uses them as values from 0-31.
Assume 100% is going to be 31, or 1F in hex.
-
its probibly 16 bit color, like 5'6'5. 4 hex digits = 2 bytes.
you need to right shift the value 11 places to get the first channel
then rightshift 5 places and mask it (logical and) with 3f to get the secontd channel
third channel just requires masking with 1f (again logical and)
the reasont he second digit looks brown is because its sharing some bits with both the 3rd channel (red) and the second (green). not sure about the endianness here , but the last difit contails the 4 least significant bits for red, while the second to last has a red most significant bit, and the 3 lsbs of green (the other 3 being in the second digit wit one of the blue bits). all signs point to 16 bit.
that assuming 5'6'5, some archaic implementations use a bit for alpha. it could be 1'5'5'5 or 5'5'5'1. this was common on sprite engines. the bit could also be completely ignored. these are the things you lear when you build a video card from scratch using 74xx series logic chips and some microcontrollers and srams.
-
I was under the impression GBA was 32bit, not 16
-
thats probibly architecture, not graphics engine. even in modern games and hardware still use 16 bit textures. did you honestly think that dxt* textures were 24/32 bit? its 32 bit cause its running a 32-bit arm processor. reguardless of the cpu with a machine with limited resources, 16 mhz arm7, 128k vram and 256k wram. not a whole lot to work with, so youre not going to waste it on 24 bit gfx. on top of that i very much doubt the screen is 24 bit either, 12 or 16 bit is more probable. at 16 bit and a screen resolution of 240*160, you are using up 115200 bytes of ram which fits nicely into the vram, but doesnt allow space for a dual buffer. this is still workable however.
that said:
The technical specifications of the original Game Boy Advance are, as provided by Nintendo:[5]
Length: approximately 14.45 cm (5.69 in)
Width: approximately 2.45 cm (0.96 in)
Height: approximately 8.2 cm (3.2 in)
Mass: approximately 140 g (4.9 oz)
Screen: 2.9 inches reflective thin-film transistor (TFT) color LCD
Power: 2 AA batteries
Battery life: approximately 15 hours on average while playing Game Boy Advance games (also dependent on the Game Pak being played and the volume setting)[6]
CPU: 16.8 MHz 32-bit ARM7TDMI with embedded memory
Memory: 32 kilobyte + 96 kilobyte VRAM (internal to the CPU), 256 kilobyte WRAM (outside the CPU).
Resolution: 240 × 160 pixels (3:2 aspect ratio)
Color support: 15-bit RGB (16-bit color space using 5 bits depth per channel), capable of displaying 512 simultaneous colors in "character mode" and 32,768 (215) simultaneous colors in "bitmap mode"
Sound: Dual 8-bit DAC for stereo sound (called Direct Sound), plus all legacy channels from Gameboy. The new DACs can be used to play back streams of wave data, or can be used to output multiple wave samples processed/mixed in software by the CPU.
this would indicate 15 bit color, where one bit is probibly reserved for sprite alpha. "character mode" is actually a way to compress backgrounds (very similar to how dxt* works), using tiny cells called characters where each one has a small pallet (usually 4 or 8 colors), which in turn are just references to entries in what seems like a 9 bit color table. so that the individual pixels only take up a couple of bits. this was the norm of how things worked in the 8 and 16 bit eras. bitmap mode is sprites, and so you need a transparency bit, so that bitmaps can be blitted correctly. when you deal with these tight architectures it comes down to the bits.
so even if the game system says 32 bits on it, it probibly just has a 32 bit cpu or gpu. do we forget the lessons learned durring the bit wars so easily? bits dont matter. case in point you can take an arduino and a gameduino (http://excamera.com/sphinx/gameduino/) and have amazing graphics while still staying in the 8 bit realm (seriously watch the graphics demos there, they are pretty awesome for 8 bit). its not the number of bits, its what you do with them that matters (and also the speed of your cpu clock and number of processors/cores/gpus you have).
-
I'll go ahead and point out, not for the first time, that FlamingCobra would be far better served posting on a forum that actually covers GBA ROM-hacking. :p
-
@Nuke: I was referring to colour...
But no, that does clarify that. I am now aware
-
its probably 16 bit color, like 5'6'5. 4 hex digits = 2 bytes.
you need to right shift the value 11 places to get the first channel
then rightshift 5 places and mask it (logical and) with 3f to get the second channel
third channel just requires masking with 1f (again logical and)
the reason the second digit looks brown is because its sharing some bits with both the 3rd channel (red) and the second (green). not sure about the endianness here , but the last digit contains the 4 least significant bits for red, while the second to last has a red most significant bit, and the 3 lsbs of green (the other 3 being in the second digit wit one of the blue bits). all signs point to 16 bit.
that assuming 5'6'5, some archaic implementations use a bit for alpha. it could be 1'5'5'5 or 5'5'5'1. this was common on sprite engines. the bit could also be completely ignored. these are the things you lear when you build a video card from scratch using 74xx series logic chips and some microcontrollers and srams.
Hang on, I'm trying to process this.
You're saying that the same results would be achieved if I used a hex editor to change the color palette? The game does color values the same way codebreaker does and codebreaker works by temporarily changing in-game data? This is what I believed at first but then I began to doubt it because Super Metroid does colors as hex triplets. I realize they are two different games on two different consoles that have different architectures.
you lost me when you started talking about shifting values, places, channels, and "logical and." Oh, and "masking it" oh and the apostrophe thingies
EDIT: Alright. Channel = RED GREEN BLUE
You're also saying that Digit 3 is not a "channel" in itself but it just overlaps with red and green.
I'm kind of a visual learner. Could you give examples?
Here's a yahoo article on it. http://answers.yahoo.com/question/index?qid=20090320085915AAVjZKk
but that doesn't really tell me anything.
-
I love it when you guys talk coding......Do some more.
-
Hexadecimal is confusing you. Stop using it for now, and look at the raw binary.
0000000000000000 to 1111111111111111
Now, of those 15 binary digits, there are 5 for each red, green and blue, plus 1 that says transparent. Lets group them. It's either
00000-00000-00000-0
Blue - Green - Red - Transparent
So, if I want bright blue that's not transparent, I want the number to be 11111-00000-00000-0.
If we remove the dashes, that becomes 1111100000000000. We can convert that to hex easily, it becomes F800.
Now, there is one gotcha you need to know about - These numbers are clearly Little Endian based on what you've told us. That means the rightmost digit is the largest one, not the smallest one. You'll need to reverse the digits of the binary 5 sets before you put in your values.
-
if youre on windows 7 play with calculator in programmer mode, very useful tool for this kinda work. makes it easy to do hex<->bin<->dec conversions, and gives you bitwise operations (such as logical and and shift operations). endianness is a huge point of confusion. so if you have bits that arent doing what you want them to do, flip your bytes.
-
There are also only 10 people who understand trinary
those that do, those that dont and those who get if confused with binary
I'd like to know what each value would mean in a if statement? Yes/No/Maybe ?
-
0, 1 or 2. Any meaning beyond that is solely a creation of a troubled mind.
-
:D this is great! you did a good job! i'll be using this to make some new suprise suits for my videos... :)