Thread: [Tutorial] 1st Gen Hacking: Useful Links
View Single Post
  #35    
Old March 2nd, 2016 (9:57 PM).
esperance's Avatar
esperance esperance is offline
 
Join Date: Mar 2010
Location: Ohio
Age: 21
Gender: Male
Nature: Relaxed
Posts: 3,820
Quote:
Originally Posted by RaidenRaider View Post
Okay thank you so much. That was a very detailed and helpful tutorial. I have now got a Red version, Green version and Blue version on the titlescreen, with each in their respective colours. It looks amazing. Thank you very much. It's greatly appreciated. I do have one more favour/request if you're willing to help me out further? I'll even list you as one of my Special Thanks credits when this ROM Hack goes live, alongside Mateo, to show my appreciation for your help.

On the titlescreen, you get a selection of Pokemon that scrolls across the screen, in the respective Red and Blue versions, with each of the Pokemon having respective Red and Blue colour palettes, but I was wondering how I create a green palette for each of the Pokemon on the titlescreen in my Green version. I know the answer is in data/super_palettes.asm somewhere.
I'm glad I was able to help! Now for your next question, I took a peek in data/super_palettes.asm and found this code at line 55:
Code:
IF DEF(_RED)
	RGB 31,29,31 ; PAL_LOGO1
	RGB 30,30,17
	RGB 17,23,10
	RGB 21,0,4
ENDC
IF DEF(_BLUE)
	RGB 31,29,31 ; PAL_LOGO1
	RGB 30,30,17
	RGB 21,0,4
	RGB 14,19,29
ENDC
I have a hunch that these are the palettes we want to edit for the title screen (the comment of "PAL_LOGO1" makes it stand out to me). On the GameBoy, colors are stored in a 16 bit word, using 5 bits for each color with 1 extra left over in this order: [extra (1)][blue (5)][green (5)][red (5)]. This is simply called 15-bit RGB and Nintendo loves this format, as it is also used on the GBC, GBA and NDS. Since each color is only allowed 5 bits per color, this means that each color component will have a value between 0 and 31. To turn this into a normal color value, which ranges from 0 to 255, the value is multiplied by 8.

Here, the "RGB #,#,#" format refers to a macro, which is a piece of code defined in macros.asm that makes it easier for a programmer to write specialized code while the assembler will translate it into a more specific format (in this case the word holding color data).

This is what the values of the RED palette would thus be:
Code:
IF DEF(_RED)
	RGB 31,29,31 ; 248, 232, 248 (this color)
	RGB 30,30,17 ; 240, 240, 136 (this color)
	RGB 17,23,10 ; 136, 184, 80 (this color)
	RGB 21,0,4 ; 168, 0, 32 (this color)
ENDC
Looks strange, right? I was a bit worried I had gone the wrong way. So just to make sure, I dug a bit deeper. First, I found the code that handles sending palette data when the titlescreen is loaded. It is found on line 113 of engine/palettes.asm (labeled "SenPalPacket_Titlescreen"). From there, I found the palette "packet" sent to the titlescreen in data/sgb_packets.asm, specificially at line 208, which shows:
Code:
PalPacket_Titlescreen:    PAL_SET PAL_LOGO2, PAL_LOGO1, PAL_MEWMON, PAL_PURPLEMON
What this tells us is that in the data/super_palettes.asm file, the palettes labeled as PAL_LOGO2, PAL_LOGO1, PAL_MEWMON, and PAL_PURPLEMON are all sent to the titlescreen when it loads its palettes. So we are on the right track!

For this, look for the comments denoting those palettes and mess around with the values. It'll take some trial and error but it should work out. You can even try adding some of your own IF DEF sections for custom palettes depending on game version.
__________________
What are you so afraid of?
Reply With Quote