Copypaste from SSRG since there's no point posting it there without doing the same on here.
Since a few people have begged for a guide on making a character have its own palette in Sonic 2, I'll just throw my shitty code around. Since my original method didn't want to play nice with underwater palettes, I've essentially cloned PalPointers and gave the character a new set. This means that you could effectively have different level palettes for the character too if you wanted to.
I'm using Knuckles because I have that character in a hack. I'm also using the Sonic 2 2007 disassembly, but the SVN code will most likely be similar. Go to PalLoad1:
Add these two lines after PalLoad1 before loading PalPointers:
PalLoad1 will now look like this:
Now for PalLoad1_Knux. Simply copypaste the original, untouched PalLoad1 (without the Knuckles check of course) and set it to load a different set of PalPointers named PalPointers_Knux:
Now, we're going to do the same to PalLoad2, PalLoad3_Water and PalLoad4_Water. Really simple stuff here.
Finally, copypaste the PalPointers list, rename it PalPointers_Knux and change the pointers required for your character. Or, you could be a lazy arse and copypaste this into the disassembly, making the necessary changes:
Now, build and this is what you should see:
- Sonic and Tails still load the same palette as they should
- Your new character will have its own palette
- Your new character will have correct underwater palettes
Just like this:



Try it yourself, making a character load its own palettes in Sonic 2.
Since a few people have begged for a guide on making a character have its own palette in Sonic 2, I'll just throw my shitty code around. Since my original method didn't want to play nice with underwater palettes, I've essentially cloned PalPointers and gave the character a new set. This means that you could effectively have different level palettes for the character too if you wanted to.
I'm using Knuckles because I have that character in a hack. I'm also using the Sonic 2 2007 disassembly, but the SVN code will most likely be similar. Go to PalLoad1:
Syntax Highlighted Code: ASM
PalLoad1:
lea (PalPointers).l,a1
lsl.w #3,d0
adda.w d0,a1
movea.l (a1)+,a2
movea.w (a1)+,a3
adda.w #$80,a3
move.w (a1)+,d7
- move.l (a2)+,(a3)+
dbf d7,-
rts
; End of function PalLoad1
Add these two lines after PalLoad1 before loading PalPointers:
Syntax Highlighted Code: ASM
cmpi.w #3,(Player_Mode).l ; is Player Knuckles?
beq.w PalLoad1_Knux ; If yes, load different stuff
PalLoad1 will now look like this:
Syntax Highlighted Code: ASM
PalLoad1:
cmpi.w #3,(Player_Mode).l ; is Player Knuckles?
beq.w PalLoad1_Knux ; If yes, load different stuff
lea (PalPointers).l,a1
lsl.w #3,d0
adda.w d0,a1
movea.l (a1)+,a2
movea.w (a1)+,a3
adda.w #$80,a3
move.w (a1)+,d7
- move.l (a2)+,(a3)+
dbf d7,-
rts
; End of function PalLoad1
Now for PalLoad1_Knux. Simply copypaste the original, untouched PalLoad1 (without the Knuckles check of course) and set it to load a different set of PalPointers named PalPointers_Knux:
Syntax Highlighted Code: ASM
PalLoad1_Knux:
lea (PalPointers_Knux).l,a1
lsl.w #3,d0
adda.w d0,a1
movea.l (a1)+,a2
movea.w (a1)+,a3
adda.w #$80,a3
move.w (a1)+,d7
- move.l (a2)+,(a3)+
dbf d7,-
rts
; End of function PalLoad1
Now, we're going to do the same to PalLoad2, PalLoad3_Water and PalLoad4_Water. Really simple stuff here.
Finally, copypaste the PalPointers list, rename it PalPointers_Knux and change the pointers required for your character. Or, you could be a lazy arse and copypaste this into the disassembly, making the necessary changes:
Syntax Highlighted Code: ASM
PalPointers_Knux:
palptr Pal_SEGA, Normal_palette, $1F
palptr Pal_Title, Normal_palette_line2, 7
palptr Pal_UNK1, Normal_palette, $1F
palptr Pal_Knuckles, Normal_palette, $F ; S2K Palette
palptr Pal_EHZ, Normal_palette_line2, $17
palptr Pal_EHZ, Normal_palette_line2, $17
palptr Pal_WZ, Normal_palette_line2, $17
palptr Pal_EHZ, Normal_palette_line2, $17
palptr Pal_MTZ, Normal_palette_line2, $17
palptr Pal_MTZ, Normal_palette_line2, $17
palptr Pal_WFZ, Normal_palette_line2, $17
palptr Pal_HTZ, Normal_palette_line2, $17
palptr Pal_HPZ, Normal_palette_line2, $17
palptr Pal_EHZ, Normal_palette_line2, $17
palptr Pal_OOZ, Normal_palette_line2, $17
palptr Pal_MCZ, Normal_palette_line2, $17
palptr Pal_CNZ, Normal_palette_line2, $17
palptr Pal_CPZ, Normal_palette_line2, $17
palptr Pal_DEZ, Normal_palette_line2, $17
palptr Pal_ARZ, Normal_palette_line2, $17
palptr Pal_SCZ, Normal_palette_line2, $17
palptr Pal_HPZ_U_K, Normal_palette, $1F ; S2K Palette
palptr Pal_CPZ_U_K, Normal_palette, $1F ; S2K Palette
palptr Pal_ARZ_U_K, Normal_palette, $1F ; S2K Palette
palptr Pal_SS, Normal_palette, $17
palptr Pal_UNK2, Normal_palette_line2, 7
palptr Pal_UNK3, Normal_palette_line2, 7
palptr Pal_SS1, Normal_palette_line4, 7
palptr Pal_SS2, Normal_palette_line4, 7
palptr Pal_SS3, Normal_palette_line4, 7
palptr Pal_SS4, Normal_palette_line4, 7
palptr Pal_SS5, Normal_palette_line4, 7
palptr Pal_SS6, Normal_palette_line4, 7
palptr Pal_SS7, Normal_palette_line4, 7
palptr Pal_UNK4, Normal_palette_line4, 7
palptr Pal_UNK5, Normal_palette_line4, 7
palptr Pal_UNK6, Normal_palette_line4, 7
palptr Pal_OOZ_B, Normal_palette_line2, 7
palptr Pal_Menu, Normal_palette, $1F
palptr Pal_UNK7, Normal_palette, $1F
Now, build and this is what you should see:
- Sonic and Tails still load the same palette as they should
- Your new character will have its own palette
- Your new character will have correct underwater palettes
Just like this:



Try it yourself, making a character load its own palettes in Sonic 2.
This post has been edited by SOTI: 24 July 2010 - 07:50 AM


05
