Making a character load its own palettes in Sonic 2

Discussion in 'Approved' started by Spanner, Jul 24, 2010.

Thread Status:
Not open for further replies.
  1. Spanner

    Spanner The Tool Member

    Joined:
    Aug 9, 2007
    Messages:
    2,570
    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:



    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:



    cmpi.w #3,(Player_Mode).l ; is Player Knuckles?
    beq.w PalLoad1_Knux ; If yes, load different stuff



    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:



    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:



    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:


    [​IMG]


    [​IMG]


    [​IMG]


    Try it yourself, making a character load its own palettes in Sonic 2.
     
  2. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    Thanks for taking the time to create this guide SOTI, much appreciated.
     
  3. shadowbeasts

    shadowbeasts I'm Legend Member

    Joined:
    Jan 5, 2009
    Messages:
    286
    Location:
    Good 'ol USA.
    Thanks you for the guide it's very helpful. It's very appreciated.
     
  4. Goonie

    Goonie Active Member Member

    Joined:
    Jun 14, 2010
    Messages:
    47
    Location:
    Australia
    You the man SOTI!!!!!!Thanks mate!
     
  5. shadowbeasts

    shadowbeasts I'm Legend Member

    Joined:
    Jan 5, 2009
    Messages:
    286
    Location:
    Good 'ol USA.
    Ok, I give up now Sonic, Tails, Knuckles, and the zone load black the water loads the normal blue in Emerald Hill but every thing else is black. I'm about to quit, I've tried everything. :( This happens after I add



    Pal_Knuckles: BINCLUDE "art/palettes/Knuckles.bin" ; Knuckles Palette
    Pal_HPZ_U_K: BINCLUDE "art/palettes/Knuckles.bin" ; Knuckles Palette


    Pal_CPZ_U_K: BINCLUDE "art/palettes/Knuckles.bin" ; Knuckles Palette


    Pal_ARZ_U_K:BINCLUDE "art/palettes/Knuckles.bin" ; Knuckles Palette



    to prevent an error.
     
    Last edited by a moderator: Jul 25, 2010
Thread Status:
Not open for further replies.