don't click here

Dynamic Player Palette Loading in Sonic 1

Discussion in 'Engineering & Reverse Engineering' started by Afti, Oct 25, 2009.

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

    Afti

    ORIGINAL MACHINE Member
    3,521
    0
    0
    Let's face it- some levels are darker than others. Sometimes, the light is tinted. Sometimes, Sonic is supposed to be green for no readily apparent reason.

    However, until the dawn of lighting systems, such effects were quite rare. This is, frankly, a shame, because they're very easy to implement.

    Code (ASM):
    1.  
    2.         ...
    3. Level_LoadPal:
    4.         move.w  #$1E,($FFFFFE14).w
    5.         move    #$2300,sr
    6.                 tst.b       ($FFFFFFFE) ; playing as Ray?
    7.                 beq.s       LContV ; if not, load a Sonic pallet
    8.         cmpi.b  #5,($FFFFFE10).w ; is level SBZ?
    9.         beq.s       LContV2     ; load Ray's HEATED pallet
    10.         moveq   #20,d0      ; load Ray's pallet
    11.         bsr.w       PalLoad2    ; load pallet line
    12.                 bra.s       CV2
    13. LContV:
    14.  
    15.         cmpi.b  #5,($FFFFFE10).w ; is level SBZ?
    16.         beq.s       LContV3     ;load Sonic's HEATED pallet
    17.         moveq   #3,d0
    18.         bsr.w       PalLoad2    ; load Sonic's pallet line
    19.         bra.s       CV2
    20. LContV2:
    21.         moveq   #22,d0      ; load Ray's pallet
    22.         bsr.w       PalLoad2    ; load pallet line
    23.                 bra.s   CV2
    24.  
    25. LContV3:
    26.         moveq   #21,d0      ; load Sonic's pallet
    27.         bsr.w       PalLoad2    ; load pallet line
    28.        
    29. CV2:
    30.         cmpi.b  #1,($FFFFFE10).w ; is level LZ?
    31.         ...
    32.  
    This is what I'm using to handle player palette loading in Sonic 1 With Fries. However, unlike vanilla Sonic 1, this code checks two values, and loads a different palette into the reserved area of RAM depending on them. First, it checks the character; if it's Sonic, it skips over the Ray code (which checks the zone, and, if it's zone 5 (SBZ/foundry) loads the heated Ray palette, loading the normal Ray palette otherwise) and goes to LContV. LContV checks the level, and loads one of two Sonic palettes, depending on it- just like Ray's code. It's all very simple, and fairly efficient.

    Now, I'm not going to give you any help you don't need. I'm not going to provide some stupid template; if you need another level check, or you need another character, or you don't need the character or level check and don't want to waste cycles, none of these are in the least bit difficult. Any potential for confusion in the greatest of novices should have been eliminated by the explanation; if you still can't comprehend a very basic piece of code, that's your prerogative. Even if I wanted to, I couldn't provide a neat module like the Spin Dash because it's dependent on your gameplay design when you need an alternate player palette. If you can't figure out "how do I changed level" when it's SBZ, then GHZ or whatever the example would use wouldn't have any better effect anyway.
     
Thread Status:
Not open for further replies.