Sonic 1 water guide!

Discussion in 'Approved' started by Tornado, Sep 17, 2009.

  1. Tornado

    Tornado Active Member Member

    Joined:
    Dec 1, 2008
    Messages:
    30
    Location:
    Hydrocity - Angel Island
    Surely some of you have tried to add water to another zone in sonic 1 without creating problems in Labirynth Zone .. here I will explain one easy way to do this .. the address $FFFFFFBC will be used.


    add the address at the beginning of the rom:



    Water_Flag equ $FFFFFFBC ; if the level has water
    StartOfRom: .....



    Sonic 1 runs with water only in Labirynth Zone, and Sonic 2 has a flag to work with water ..


    search for loc_B9A:, and change to this:



    loc_B9A:
    ;cmpi.b #1,($FFFFFE10).w


    ;bne.w loc_B5E


    tst.b (Water_flag).w


    beq.w loc_B5E ; if not, branch


    ....



    search for loc_1DFA:, and change to this:



    loc_1DFA:
    bsr.s Pal_AddColor


    dbf d0,loc_1DFA


    ;cmpi.b #1,($FFFFFE10).w


    ;bne.s locret_1E24


    tst.b (Water_flag).w


    beq.s locret_1E24


    ...



    search for loc_1F20:, and change to this:



    loc_1F20:
    bsr.s Pal_DecColor2


    dbf d0,loc_1F20


    ;cmpi.b #1,($FFFFFE10).w


    ;bne.s locret_1F4A


    tst.b (Water_flag).w


    beq.s locret_1F4A


    ...



    search for Level_ClrVars3: and after bsr.w ClearScreen, add the following lines:



    cmpi.b #$1,($FFFFFE10).w ; LZ
    bne.s Level_ClearWater


    Level_InitWater:


    move.b #1,(Water_flag).w


    bra.w Level_ClrVars3_Continue


    Level_ClearWater:


    move.b #0,(Water_flag).w


    Level_ClrVars3_Continue:


    ...



    a little lower, look for the lines:



    cmpi.b #1,($FFFFFE10).w
    bne.s Level_LoadPal



    change to:



    ;cmpi.b #1,($FFFFFE10).w
    ;bne.s Level_LoadPal


    tst.b (Water_flag).w ; does level have water?


    beq.s Level_LoadPal ; if not, branch


    ...



    Go to Level_ChkWater, and change to:



    Level_ChkWater:
    move.w #0,($FFFFF602).w


    move.w #0,($FFFFF604).w


    ;cmpi.b #1,($FFFFFE10).w


    ;bne.s Level_LoadObj


    tst.b (Water_flag).w ; does level have water?


    beq.s Level_LoadObj ; if not, branch


    ...



    Go to Level_LoadPal, and change to:



    Level_LoadPal:
    move.w #$1E,($FFFFFE14).w


    move #$2300,sr


    moveq #3,d0


    bsr.w PalLoad2 ; load Sonic's pallet line


    ;cmpi.b #1,($FFFFFE10).w ; is level LZ?


    ;bne.s Level_GetBgm ; if not, branch


    tst.b (Water_flag).w ; does level have water?


    beq.s Level_GetBgm


    ...



    Go to LZWaterEffects, and change to:



    LZWaterEffects: ; XREF: Level
    ;cmpi.b #1,($FFFFFE10).w


    ;bne.s locret_3C28


    tst.b (Water_flag).w


    beq.s locret_3C28


    tst.b ($FFFFF744).w


    bne.s LZMoveWater


    cmpi.b #6,($FFFFD024).w


    bcc.s LZMoveWater


    cmpi.b #0,($FFFFFE10).w


    beq.s LZMoveWater


    bne.s LZWaterEffects_Cont


    rts


    LZWaterEffects_Cont:


    bsr.w LZWindTunnels


    bsr.w LZWaterSlides


    bsr.w LZDynamicWater


    LZMoveWater:



    note the line # 0,($ FFFFFE10). w. .. could be any other zone in this case, i used the GHZ (this is to disable the DynamicWater).


    Go to Sonic_Water, and change to:



    Sonic_Water: ; XREF: loc_12C7E
    ;cmpi.b #1,($FFFFFE10).w


    ;beq.s Obj01_InWater


    tst.b (Water_flag).w ; does level have water?


    bne.s Obj01_InWater ; if yes, branch


    locret_12D80:


    rts



    Go to Obj79_LoadInfo, and change to:



    Obj79_LoadInfo: ; XREF: LevelSizeLoad
    move.b ($FFFFFE31).w,($FFFFFE30).w


    move.w ($FFFFFE32).w,($FFFFD008).w


    move.w ($FFFFFE34).w,($FFFFD00C).w


    move.w ($FFFFFE36).w,($FFFFFE20).w


    move.b ($FFFFFE54).w,($FFFFFE1B).w


    clr.w ($FFFFFE20).w


    clr.b ($FFFFFE1B).w


    move.l ($FFFFFE38).w,($FFFFFE22).w


    move.b #59,($FFFFFE25).w


    subq.b #1,($FFFFFE24).w


    move.b ($FFFFFE3C).w,($FFFFF742).w


    move.b ($FFFFFE52).w,($FFFFF64D).w


    move.w ($FFFFFE3E).w,($FFFFF72E).w


    move.w ($FFFFFE3E).w,($FFFFF726).w


    move.w ($FFFFFE40).w,($FFFFF700).w


    move.w ($FFFFFE42).w,($FFFFF704).w


    move.w ($FFFFFE44).w,($FFFFF708).w


    move.w ($FFFFFE46).w,($FFFFF70C).w


    move.w ($FFFFFE48).w,($FFFFF710).w


    move.w ($FFFFFE4A).w,($FFFFF714).w


    move.w ($FFFFFE4C).w,($FFFFF718).w


    move.w ($FFFFFE4E).w,($FFFFF71C).w


    ;cmpi.b #1,($FFFFFE10).w


    ;bne.s loc_170E4


    tst.b (Water_flag).w ; does the level have water?


    beq.s loc_170E4


    move.w ($FFFFFE50).w,($FFFFF648).w


    move.b ($FFFFFE52).w,($FFFFF64D).w


    move.b ($FFFFFE53).w,($FFFFF64E).w



    Ready .. Now the Sonic 1 works with water, just as the Sonic 2.


    I now teach to add water in another zone, and set palette.


    (I'm using as an example GHZ)


    palette:


    Go to Level_ChkWaterPal, and change to:



    Level_ChkWaterPal:
    cmpi.b #0,($FFFFFE10).w


    beq.s Ghz_ChkWaterPal


    bne.s Level_ChkWaterPal_Cont


    rts


    ; ===========================================================================


    Ghz_ChkWaterPal:


    moveq #$1E,d0 ; pallet $1E (GHZ underwater)


    bsr.w PalLoad4_Water


    move.w #3,d1


    jmp Level_DelayLoop


    ; ===========================================================================


    Level_ChkWaterPal_Cont:


    ...



    change $1E to your palette id.


    to add water in another zone:


    Go to Level_ClrVars3, and change to:



    Level_ClrVars3:
    move.l d0,(a1)+


    dbf d1,Level_ClrVars3 ; clear object variables


    move #$2700,sr


    bsr.w ClearScreen


    cmpi.b #$0,($FFFFFE10).w ; GHZ -> new zone with water


    beq.s Level_InitWater ; -> init water


    cmpi.b #$1,($FFFFFE10).w ; LZ


    bne.s Level_ClearWater ; -> clear water


    Level_InitWater:


    move.b #1,(Water_flag).w


    bra.w Level_ClrVars3_Continue


    Level_ClearWater:


    move.b #0,(Water_flag).w


    Level_ClrVars3_Continue:


    ...



    PS: After a time away, I returned to make a small fix, so no one gets boosting water heights:


    Immediately below Level_InitWater you find these lines:



    move.w #$8014,(a6)
    moveq #0,d0


    move.b ($FFFFFE11).w,d0


    add.w d0,d0


    lea (WaterHeight).l,a1 ; load water height array


    move.w (a1,d0.w),d0



    Replace with:



    move.w #$8014,(a6)
    moveq #0,d0


    move.w ($FFFFFE10).w,d0


    ror.b #2,d0


    lsr.w #6,d0


    add.w d0,d0


    lea (WaterHeight).l,a1 ; load water height array


    move.w (a1,d0.w),d0



    Now look WaterHeight: and replace with this:


    (remembering that this change from the game uses one line for each zone and each corresponds to one act)



    ; ---------------------------------------------------------------------------
    ; water heights


    ; ---------------------------------------------------------------------------


    WaterHeight:


    ;BINCLUDE "Level/Misc/Water Heights.bin"


    ;even


    dc.w $430, $430, $430, $430; 0 - GHZ


    dc.w $FB8, $328, $900, $228; 3 - LZ


    dc.w $600, $328, $900, $228; 2 - MZ


    dc.w $0B8, $328, $900, $228; 3 - SLZ


    dc.w $4A0, $328, $900, $228; 4 - SYZ


    dc.w $600, $328, $228, $228; 5 - SBZ


    dc.w $600, $328, $900, $228; 6 - END



    In my hack is so that you can change ..


    the lower the value, the greater the level of water


    Ready. Comment on any bugs ..
     
    Last edited by a moderator: Jul 10, 2011
    HackGame likes this.
  2. Selbi

    Selbi Plug in, baby. Retired Staff

    Joined:
    Jul 20, 2008
    Messages:
    2,394
    Location:
    Northern Germany
    I am NOT going to read a single word before you change those codeboxes to ASM boxes.
     
  3. redhotsonic

    redhotsonic Also known as RHS Retired Staff

    Joined:
    Aug 10, 2007
    Messages:
    2,967
    Location:
    England
    Eh? What are you on about? It is ASM =P
     
  4. Selbi

    Selbi Plug in, baby. Retired Staff

    Joined:
    Jul 20, 2008
    Messages:
    2,394
    Location:
    Northern Germany
    Ugly code box:



    Code:
    loc_B9A:
    		;cmpi.b #1,($FFFFFE10).w
    		;bne.w loc_B5E
    		tst.b (Water_flag).w
    		beq.w loc_B5E ; if not, branch
    		....
    Nice ASM box:



    loc_B9A:
    ;cmpi.b #1,($FFFFFE10).w


    ;bne.w loc_B5E


    tst.b (Water_flag).w


    beq.w loc_B5E ; if not, branch


    ....
     
  5. OrdosAlpha

    OrdosAlpha RIGHT! Naebody move! Administrator

    Joined:
    Aug 5, 2007
    Messages:
    1,780
    Location:
    Glasgow, Scotland
    Replace the codebox tags with asm tags please.
     
  6. NewSonic

    NewSonic Newcomer Member

    Joined:
    Sep 16, 2008
    Messages:
    19
    This is fantastic!!! It will be very useful for me.


    Nice work. :p
     
  7. bareirito

    bareirito Well-Known Member Member

    Joined:
    Nov 17, 2008
    Messages:
    87
    Location:
    Argentina
    This is what I was searching for so much time ago. Nice work, mate. I always wanted an Green Hill Zone with water. Once again nice work.
     
    Last edited by a moderator: Sep 18, 2009
  8. Dark Lips

    Dark Lips Well-Known Member Member

    Joined:
    Nov 14, 2008
    Messages:
    282
    Location:
    Wolverhampton UK
    is there some way to stop those code boxes changing when I am trying to read them? great guide apart from that !!!
     
  9. EMK-20218

    EMK-20218 They call me as 'Eduardo Knuckles' Member

    Joined:
    Aug 8, 2008
    Messages:
    957
    Location:
    SEGA Land
    Water surface object causes lag if the level uses lots of sprites at the same place...


    ...But yeah, I have to admit the fact that this is a great work. Certainly I will use it on my hacks.
     
  10. DeoxysKyogre

    DeoxysKyogre No idea what to put here .-. Member

    Joined:
    Jan 31, 2009
    Messages:
    298
    Truly awesome. It's real useful for me. I used it in the ice level in my hack :)
     
  11. DeoxysKyogre

    DeoxysKyogre No idea what to put here .-. Member

    Joined:
    Jan 31, 2009
    Messages:
    298
    Sorry for double posting, but will you teach how to edit the heights in hex and fixing the surface? That would be awesome.
     
  12. shadowbeasts

    shadowbeasts I'm Legend Member

    Joined:
    Jan 5, 2009
    Messages:
    286
    Location:
    Good 'ol USA.
    It's definitely a useful guide especially if you want to flood Labyrinth Zone and keep the bubbles in the same place they were originally without adding more, or you can get rid of all the bubbles and make sonic 1 impossible if you flood every level. I'll do that I'm evil what can I say.
     
  13. Dark Lips

    Dark Lips Well-Known Member Member

    Joined:
    Nov 14, 2008
    Messages:
    282
    Location:
    Wolverhampton UK
    Ok I have followed the guide and its great however - there are a couple of bits i need help understanding - firstly how do i change the pallet used in water? and secondly is there anyway to change the water height?
     
    Last edited by a moderator: Sep 28, 2009
  14. Tornado

    Tornado Active Member Member

    Joined:
    Dec 1, 2008
    Messages:
    30
    Location:
    Hydrocity - Angel Island
    firstly how do i change the pallet used in water?


    I explained in the tutorial, how to change the palette used:


    Go to Level_ChkWaterPal, and change to:



    Level_ChkWaterPal:
    cmpi.b #0,($FFFFFE10).w


    beq.s Ghz_ChkWaterPal


    bne.s Level_ChkWaterPal_Cont


    rts


    ; ===========================================================================


    Ghz_ChkWaterPal:


    moveq #$1E,d0 ; pallet $1E (GHZ underwater)


    bsr.w PalLoad4_Water


    move.w #3,d1


    jmp Level_DelayLoop


    ; ===========================================================================


    Level_ChkWaterPal_Cont:


    ...



    will be including brief tutorial in the guide to change the water line
     
    Last edited by a moderator: Sep 29, 2009
  15. Dark Lips

    Dark Lips Well-Known Member Member

    Joined:
    Nov 14, 2008
    Messages:
    282
    Location:
    Wolverhampton UK
    I really dont want to sound stupid but I dont understand what you are saying? I changed the 1E to something else and stull the underwater pallets dont look right... can you explain in a little more detail please?
     
  16. Tornado

    Tornado Active Member Member

    Joined:
    Dec 1, 2008
    Messages:
    30
    Location:
    Hydrocity - Angel Island
    Open _inc\pallet pointers.asm and you will see:



    ; ---------------------------------------------------------------------------
    ; Pallet pointers


    ; ---------------------------------------------------------------------------


    PalPointers:


    dc.l Pal_SegaBG ;0 ; pallet address


    dc.w $FB00 ; RAM address


    dc.w $1F ; (pallet length / 2) - 1


    dc.l Pal_Title ;1


    dc.w $FB00


    dc.w $1F


    dc.l Pal_LevelSel;2


    dc.w $FB20


    dc.w $17


    dc.l Pal_Sonic ;3


    dc.w $FB00


    dc.w 7


    dc.l Pal_GHZ ;4


    dc.w $FB20


    dc.w $17


    dc.l Pal_LZ ;5


    dc.w $FB20


    dc.w $17


    dc.l Pal_MZ ;6


    dc.w $FB20


    dc.w $17


    dc.l Pal_SLZ ;7


    dc.w $FB20


    dc.w $17


    dc.l Pal_SYZ ;8


    dc.w $FB20


    dc.w $17


    dc.l Pal_SBZ1 ;9


    dc.w $FB20


    dc.w $17


    dc.l Pal_Special ;$A


    dc.w $FB00


    dc.w $1F


    dc.l Pal_LZWater ;$B


    dc.w $FB00


    dc.w $1F


    dc.l Pal_SBZ3 ;$C


    dc.w $FB20


    dc.w $17


    dc.l Pal_SBZ3Water ;$D


    dc.w $FB00


    dc.w $1F


    dc.l Pal_SBZ2 ; $E


    dc.w $FB20


    dc.w $17


    dc.l Pal_LZSonWater ;$F


    dc.w $FB00


    dc.w 7


    dc.l Pal_SBZ3SonWat ;$10


    dc.w $FB00


    dc.w 7


    dc.l Pal_SpeResult ;$11


    dc.w $FB00


    dc.w $1F


    dc.l Pal_SpeContinue ;$12


    dc.w $FB00


    dc.w $F


    dc.l Pal_Ending ;$13


    dc.w $FB00


    dc.w $1F



    Ending Sequence palette is $13, add below:



    dc.l Pal_New_Level_Water ; $14
    dc.w $FB20


    dc.w $17



    change $1E to $14 .. and do not forget to include the palette in the rom
     
  17. theocas

    theocas #! Member

    Joined:
    Apr 10, 2010
    Messages:
    375
    Sorry to bump such an old topic, but where is the little guide on how to change the water height? I have tried HEX-Editing the ghz_heigh.bin file to all possible values, but the water level never changes?!
     
  18. Selbi

    Selbi Plug in, baby. Retired Staff

    Joined:
    Jul 20, 2008
    Messages:
    2,394
    Location:
    Northern Germany
    I didn't even know there is a file called ghz_heigh.bin (because there isn't, there is no water in GHZ unless you add it). The file you are looking for is probably lz_heigh.bin (in the misc folder).
     
  19. theocas

    theocas #! Member

    Joined:
    Apr 10, 2010
    Messages:
    375
     
  20. Selbi

    Selbi Plug in, baby. Retired Staff

    Joined:
    Jul 20, 2008
    Messages:
    2,394
    Location:
    Northern Germany
    Oddest reply I ever saw... why did you just quoted my post without a comment?