Actions

SCHG How-to

Difference between revisions of "Correct Drowning Bugs in Sonic 2"

From Sonic Retro

m (Link typo)
m (Replaced spaces with tabs, changed added 'move.b #0' to 'clr.b')
Line 21: Line 21:
 
First, we need to make little edit to the drowning-routine. Go to "Obj0A_ReduceAir:" and just after the "move.w #0,inertia(a0)" command, insert this:
 
First, we need to make little edit to the drowning-routine. Go to "Obj0A_ReduceAir:" and just after the "move.w #0,inertia(a0)" command, insert this:
 
<asm>
 
<asm>
        move.b #$C,routine(a0) ; Force the character to drown
+
move.b #$C,routine(a0) ; Force the character to drown
 
</asm>
 
</asm>
  
 
And just after "move.b #1,($FFFFEEDC).w", insert this:
 
And just after "move.b #1,($FFFFEEDC).w", insert this:
 
<asm>
 
<asm>
        move.b #0,(Update_HUD_timer).w ; Stop the timer immediately
+
clr.b (Update_HUD_timer).w ; Stop the timer immediately
 
</asm>
 
</asm>
  
Line 32: Line 32:
 
<asm>
 
<asm>
 
Obj0A_ReduceAir:
 
Obj0A_ReduceAir:
        subq.b #1,air_left(a2)         ; subtract 1 from air remaining
+
subq.b #1,air_left(a2) ; subtract 1 from air remaining
        bcc.w   BranchTo_Obj0A_MakeItem ; if air is above 0, branch
+
bcc.w BranchTo_Obj0A_MakeItem ; if air is above 0, branch
        move.b #$81,obj_control(a2)   ; lock controls
+
move.b #$81,obj_control(a2) ; lock controls
        move.w #$32+$80,d0
+
move.w #$32+$80,d0
        jsr     (PlaySound).l           ; play drowning sound
+
jsr (PlaySound).l ; play drowning sound
        move.b #$A,objoff_34(a0)
+
move.b #$A,objoff_34(a0)
        move.w #1,objoff_36(a0)
+
move.w #1,objoff_36(a0)
        move.w #$78,objoff_2C(a0)
+
move.w #$78,objoff_2C(a0)
        movea.l a2,a1
+
movea.l a2,a1
        bsr.w   ResumeMusic
+
bsr.w ResumeMusic
        move.l a0,-(sp)
+
move.l a0,-(sp)
        movea.l a2,a0
+
movea.l a2,a0
        bsr.w   Sonic_ResetOnFloor_Part2
+
bsr.w Sonic_ResetOnFloor_Part2
        move.b #$17,anim(a0)   ; use Sonic's drowning animation
+
move.b #$17,anim(a0) ; use Sonic's drowning animation
        bset   #1,status(a0)
+
bset #1,status(a0)
        bset   #7,art_tile(a0)
+
bset #7,art_tile(a0)
        move.w #0,y_vel(a0)
+
move.w #0,y_vel(a0)
        move.w #0,x_vel(a0)
+
move.w #0,x_vel(a0)
        move.w #0,inertia(a0)
+
move.w #0,inertia(a0)
        move.b #$C,routine(a0) ; Force the character to drown
+
move.b #$C,routine(a0) ; Force the character to drown
        movea.l (sp)+,a0 ; load 0bj address ; restore a0 = obj0A
+
movea.l (sp)+,a0 ; load 0bj address ; restore a0 = obj0A
        cmpa.w #MainCharacter,a2
+
cmpa.w #MainCharacter,a2
        bne.s   +       ; if it isn't player 1, branch
+
bne.s + ; if it isn't player 1, branch
        move.b #1,($FFFFEEDC).w
+
move.b #1,($FFFFEEDC).w
        move.b #0,(Update_HUD_timer).w ; Stop the timer immediately
+
clr.b (Update_HUD_timer).w ; Stop the timer immediately
 
+
 
+
        rts
+
rts
 
</asm>
 
</asm>
  
Line 64: Line 64:
 
<asm>
 
<asm>
 
loc_1D708:
 
loc_1D708:
        subq.w #1,objoff_2C(a0)
+
subq.w #1,objoff_2C(a0)
        bne.s   +
+
bne.s +
        move.b #6,routine(a2)
+
move.b #6,routine(a2)
        rts
+
rts
 
; ---------------------------------------------------------------------------
 
; ---------------------------------------------------------------------------
+       move.l a0,-(sp)
+
+ move.l a0,-(sp)
        movea.l a2,a0
+
movea.l a2,a0
        jsr     ObjectMove
+
jsr ObjectMove
        addi.w #$10,y_vel(a0)
+
addi.w #$10,y_vel(a0)
        movea.l (sp)+,a0 ; load 0bj address
+
movea.l (sp)+,a0 ; load 0bj address
        bra.s   loc_1D72C
+
bra.s loc_1D72C
 
</asm>
 
</asm>
  
Line 80: Line 80:
 
<asm>
 
<asm>
 
loc_1D708:
 
loc_1D708:
        subq.w #1,objoff_2C(a0)
+
subq.w #1,objoff_2C(a0)
        bne.s   loc_1D72C               ; Make it jump straight to this location
+
bne.s loc_1D72C ; Make it jump straight to this location
        move.b #6,routine(a2)
+
move.b #6,routine(a2)
        rts
+
rts
 
</asm>
 
</asm>
  
 
Right, that's the drowning-routine finished. Now, we need to make the characters apply to this. First, Sonic. Go to "Obj01_States:" and add this line at the end of the table:
 
Right, that's the drowning-routine finished. Now, we need to make the characters apply to this. First, Sonic. Go to "Obj01_States:" and add this line at the end of the table:
 
<asm>
 
<asm>
        dc.w   Obj01_Drowned - Obj01_States   ;$C
+
dc.w Obj01_Drowned - Obj01_States ;$C
 
</asm>
 
</asm>
  
Line 94: Line 94:
 
<asm>
 
<asm>
 
Obj01_States:
 
Obj01_States:
        dc.w   Obj01_Init - Obj01_States       ; 0
+
dc.w Obj01_Init - Obj01_States ; 0
        dc.w   Obj01_Control - Obj01_States   ; 2
+
dc.w Obj01_Control - Obj01_States ; 2
        dc.w   Obj01_Hurt - Obj01_States       ; 4
+
dc.w Obj01_Hurt - Obj01_States ; 4
        dc.w   Obj01_Dead - Obj01_States       ; 6
+
dc.w Obj01_Dead - Obj01_States ; 6
        dc.w   Obj01_Gone - Obj01_States       ; 8
+
dc.w Obj01_Gone - Obj01_States ; 8
        dc.w   Obj01_Respawning - Obj01_States ;$A
+
dc.w Obj01_Respawning - Obj01_States ;$A
        dc.w   Obj01_Drowned - Obj01_States   ;$C
+
dc.w Obj01_Drowned - Obj01_States ;$C
 
</asm>
 
</asm>
  
Line 109: Line 109:
 
; ---------------------------------------------------------------------------
 
; ---------------------------------------------------------------------------
 
Obj01_Drowned:
 
Obj01_Drowned:
        bsr.w   ObjectMove     ; Make Sonic able to move
+
bsr.w ObjectMove ; Make Sonic able to move
        addi.w #$10,y_vel(a0) ; Apply gravity
+
addi.w #$10,y_vel(a0) ; Apply gravity
        bsr.w   Sonic_RecordPos ; Record position
+
bsr.w Sonic_RecordPos ; Record position
        bsr.w   Sonic_Animate   ; Animate Sonic
+
bsr.w Sonic_Animate ; Animate Sonic
        bsr.w   LoadSonicDynPLC ; Load Sonic's DPLCs
+
bsr.w LoadSonicDynPLC ; Load Sonic's DPLCs
        bra.w   DisplaySprite   ; And finally, display Sonic
+
bra.w DisplaySprite ; And finally, display Sonic
 
</asm>
 
</asm>
  
 
That's Sonic done. Tails is next. Go to "Obj02_States:" and again, insert this line at the end of the table:
 
That's Sonic done. Tails is next. Go to "Obj02_States:" and again, insert this line at the end of the table:
 
<asm>
 
<asm>
        dc.w Obj02_Drowned - Obj02_States       ;$C
+
dc.w Obj02_Drowned - Obj02_States ;$C
 
</asm>
 
</asm>
  
Line 125: Line 125:
 
<asm>
 
<asm>
 
Obj02_States:
 
Obj02_States:
        dc.w Obj02_Init - Obj02_States         ; 0
+
dc.w Obj02_Init - Obj02_States ; 0
        dc.w Obj02_Control - Obj02_States       ; 2
+
dc.w Obj02_Control - Obj02_States ; 2
        dc.w Obj02_Hurt - Obj02_States         ; 4
+
dc.w Obj02_Hurt - Obj02_States ; 4
        dc.w Obj02_Dead - Obj02_States         ; 6
+
dc.w Obj02_Dead - Obj02_States ; 6
        dc.w Obj02_Gone - Obj02_States         ; 8
+
dc.w Obj02_Gone - Obj02_States ; 8
        dc.w Obj02_Respawning - Obj02_States   ;$A
+
dc.w Obj02_Respawning - Obj02_States ;$A
        dc.w Obj02_Drowned - Obj02_States       ;$C
+
dc.w Obj02_Drowned - Obj02_States ;$C
 
</asm>
 
</asm>
  
Line 140: Line 140:
 
; ---------------------------------------------------------------------------
 
; ---------------------------------------------------------------------------
 
Obj02_Drowned:
 
Obj02_Drowned:
        bsr.w   ObjectMove     ; Make Tails able to move
+
bsr.w ObjectMove ; Make Tails able to move
        addi.w #$10,y_vel(a0) ; Apply gravity
+
addi.w #$10,y_vel(a0) ; Apply gravity
        bsr.w   Tails_RecordPos ; Record position
+
bsr.w Tails_RecordPos ; Record position
        bsr.s   Tails_Animate   ; Animate Tails
+
bsr.s Tails_Animate ; Animate Tails
        bsr.w   LoadTailsDynPLC ; Load Tails's DPLCs
+
bsr.w LoadTailsDynPLC ; Load Tails's DPLCs
        bra.w   DisplaySprite   ; And finally, display Tails
+
bra.w DisplaySprite ; And finally, display Tails
 
</asm>
 
</asm>
  
Line 153: Line 153:
 
First, we need to make little edit to the drowning-routine. Go to "Obj0A_ReduceAir:" and just after the "move.w #0,inertia(a0)" command, insert this:
 
First, we need to make little edit to the drowning-routine. Go to "Obj0A_ReduceAir:" and just after the "move.w #0,inertia(a0)" command, insert this:
 
<asm>
 
<asm>
        move.b #$C,routine(a0) ; Force the character to drown
+
move.b #$C,routine(a0) ; Force the character to drown
 
</asm>
 
</asm>
  
 
And just after "move.b #1,(Deform_lock).w", insert this:
 
And just after "move.b #1,(Deform_lock).w", insert this:
 
<asm>
 
<asm>
        move.b  #0,(Update_HUD_timer).w ; Stop the timer immediately
+
clr.b  (Update_HUD_timer).w ; Stop the timer immediately
 
</asm>
 
</asm>
  
Line 164: Line 164:
 
<asm>
 
<asm>
 
Obj0A_ReduceAir:
 
Obj0A_ReduceAir:
        subq.b #1,air_left(a2)         ; subtract 1 from air remaining
+
subq.b #1,air_left(a2) ; subtract 1 from air remaining
        bcc.w   BranchTo_Obj0A_MakeItem ; if air is above 0, branch
+
bcc.w BranchTo_Obj0A_MakeItem ; if air is above 0, branch
        move.b #$81,obj_control(a2)   ; lock controls
+
move.b #$81,obj_control(a2) ; lock controls
        move.w #SndID_Drown,d0
+
move.w #SndID_Drown,d0
        jsr     (PlaySound).l           ; play drowning sound
+
jsr (PlaySound).l ; play drowning sound
        move.b #$A,objoff_34(a0)
+
move.b #$A,objoff_34(a0)
        move.w #1,objoff_36(a0)
+
move.w #1,objoff_36(a0)
        move.w #$78,objoff_2C(a0)
+
move.w #$78,objoff_2C(a0)
        movea.l a2,a1
+
movea.l a2,a1
        bsr.w   ResumeMusic
+
bsr.w ResumeMusic
        move.l a0,-(sp)
+
move.l a0,-(sp)
        movea.l a2,a0
+
movea.l a2,a0
        bsr.w   Sonic_ResetOnFloor_Part2
+
bsr.w Sonic_ResetOnFloor_Part2
        move.b #$17,anim(a0)   ; use Sonic's drowning animation
+
move.b #$17,anim(a0) ; use Sonic's drowning animation
        bset   #1,status(a0)
+
bset #1,status(a0)
        bset   #high_priority_bit,art_tile(a0)
+
bset #high_priority_bit,art_tile(a0)
        move.w #0,y_vel(a0)
+
move.w #0,y_vel(a0)
        move.w #0,x_vel(a0)
+
move.w #0,x_vel(a0)
        move.w #0,inertia(a0)
+
move.w #0,inertia(a0)
        move.b #$C,routine(a0) ; Force the character to drown
+
move.b #$C,routine(a0) ; Force the character to drown
        movea.l (sp)+,a0 ; load 0bj address ; restore a0 = obj0A
+
movea.l (sp)+,a0 ; load 0bj address ; restore a0 = obj0A
        cmpa.w #MainCharacter,a2
+
cmpa.w #MainCharacter,a2
        bne.s   +       ; if it isn't player 1, branch
+
bne.s + ; if it isn't player 1, branch
        move.b #1,(Deform_lock).w
+
move.b #1,(Deform_lock).w
        move.b #0,(Update_HUD_timer).w ; Stop the timer immediately
+
clr.b (Update_HUD_timer).w ; Stop the timer immediately
 
+
 
+
        rts
+
rts
 
</asm>
 
</asm>
  
Line 196: Line 196:
 
<asm>
 
<asm>
 
loc_1D708:
 
loc_1D708:
        subq.w #1,objoff_2C(a0)
+
subq.w #1,objoff_2C(a0)
        bne.s   +
+
bne.s +
        move.b #6,routine(a2)
+
move.b #6,routine(a2)
        rts
+
rts
 
; ---------------------------------------------------------------------------
 
; ---------------------------------------------------------------------------
+       move.l a0,-(sp)
+
+ move.l a0,-(sp)
        movea.l a2,a0
+
movea.l a2,a0
        jsr     (ObjectMove).l
+
jsr (ObjectMove).l
        addi.w #$10,y_vel(a0)
+
addi.w #$10,y_vel(a0)
        movea.l (sp)+,a0 ; load 0bj address
+
movea.l (sp)+,a0 ; load 0bj address
        bra.s   loc_1D72C
+
bra.s loc_1D72C
 
</asm>
 
</asm>
  
Line 212: Line 212:
 
<asm>
 
<asm>
 
loc_1D708:
 
loc_1D708:
        subq.w #1,objoff_2C(a0)
+
subq.w #1,objoff_2C(a0)
        bne.s   loc_1D72C               ; Make it jump straight to this location
+
bne.s loc_1D72C ; Make it jump straight to this location
        move.b #6,routine(a2)
+
move.b #6,routine(a2)
        rts
+
rts
 
</asm>
 
</asm>
  
 
Right, that's the drowning-routine finished. Now, we need to make the characters apply to this. First,Sonic. Go to "Obj01_Index:" and add this line at the end of the table:
 
Right, that's the drowning-routine finished. Now, we need to make the characters apply to this. First,Sonic. Go to "Obj01_Index:" and add this line at the end of the table:
 
<asm>
 
<asm>
                offsetTableEntry.w Obj01_Drowned       ; $C
+
offsetTableEntry.w Obj01_Drowned ; $C
 
</asm>
 
</asm>
  
 
So you have:
 
So you have:
 
<asm>
 
<asm>
Obj01_Index:   offsetTable
+
Obj01_Index: offsetTable
                offsetTableEntry.w Obj01_Init           ;  0
+
offsetTableEntry.w Obj01_Init ;  0
                offsetTableEntry.w Obj01_Control       ;  2
+
offsetTableEntry.w Obj01_Control ;  2
                offsetTableEntry.w Obj01_Hurt           ;  4
+
offsetTableEntry.w Obj01_Hurt ;  4
                offsetTableEntry.w Obj01_Dead           ;  6
+
offsetTableEntry.w Obj01_Dead ;  6
                offsetTableEntry.w Obj01_Gone           ;  8
+
offsetTableEntry.w Obj01_Gone ;  8
                offsetTableEntry.w Obj01_Respawning     ; $A
+
offsetTableEntry.w Obj01_Respawning ; $A
                offsetTableEntry.w Obj01_Drowned       ; $C
+
offsetTableEntry.w Obj01_Drowned ; $C
 
</asm>
 
</asm>
  
Line 241: Line 241:
 
; ---------------------------------------------------------------------------
 
; ---------------------------------------------------------------------------
 
Obj01_Drowned:
 
Obj01_Drowned:
        bsr.w   ObjectMove     ; Make Sonic able to move
+
bsr.w ObjectMove ; Make Sonic able to move
        addi.w #$10,y_vel(a0) ; Apply gravity
+
addi.w #$10,y_vel(a0) ; Apply gravity
        bsr.w   Sonic_RecordPos ; Record position
+
bsr.w Sonic_RecordPos ; Record position
        bsr.w   Sonic_Animate   ; Animate Sonic
+
bsr.w Sonic_Animate ; Animate Sonic
        bsr.w   LoadSonicDynPLC ; Load Sonic's DPLCs
+
bsr.w LoadSonicDynPLC ; Load Sonic's DPLCs
        bra.w   DisplaySprite   ; And finally, display Sonic
+
bra.w DisplaySprite ; And finally, display Sonic
 
</asm>
 
</asm>
  
 
That's Sonic done. Tails is next. Go to "Obj02_Index:" and again, insert this line at the end of the table:
 
That's Sonic done. Tails is next. Go to "Obj02_Index:" and again, insert this line at the end of the table:
 
<asm>
 
<asm>
                offsetTableEntry.w Obj02_Drowned       ; $C
+
offsetTableEntry.w Obj02_Drowned ; $C
 
</asm>
 
</asm>
  
 
So you have:
 
So you have:
 
<asm>
 
<asm>
Obj02_Index:   offsetTable
+
Obj02_Index: offsetTable
                offsetTableEntry.w Obj02_Init           ;  0
+
offsetTableEntry.w Obj02_Init ;  0
                offsetTableEntry.w Obj02_Control       ;  2
+
offsetTableEntry.w Obj02_Control ;  2
                offsetTableEntry.w Obj02_Hurt           ;  4
+
offsetTableEntry.w Obj02_Hurt ;  4
                offsetTableEntry.w Obj02_Dead           ;  6
+
offsetTableEntry.w Obj02_Dead ;  6
                offsetTableEntry.w Obj02_Gone           ;  8
+
offsetTableEntry.w Obj02_Gone ;  8
                offsetTableEntry.w Obj02_Respawning     ; $A
+
offsetTableEntry.w Obj02_Respawning ; $A
                offsetTableEntry.w Obj02_Drowned       ; $C
+
offsetTableEntry.w Obj02_Drowned ; $C
 
</asm>
 
</asm>
  
Line 272: Line 272:
 
; ---------------------------------------------------------------------------
 
; ---------------------------------------------------------------------------
 
Obj02_Drowned:
 
Obj02_Drowned:
        bsr.w   ObjectMove     ; Make Tails able to move
+
bsr.w ObjectMove ; Make Tails able to move
        addi.w #$10,y_vel(a0) ; Apply gravity
+
addi.w #$10,y_vel(a0) ; Apply gravity
        bsr.w   Tails_RecordPos ; Record position
+
bsr.w Tails_RecordPos ; Record position
        bsr.s   Tails_Animate   ; Animate Tails
+
bsr.s Tails_Animate ; Animate Tails
        bsr.w   LoadTailsDynPLC ; Load Tails's DPLCs
+
bsr.w LoadTailsDynPLC ; Load Tails's DPLCs
        bra.w   DisplaySprite   ; And finally, display Tails
+
bra.w DisplaySprite ; And finally, display Tails
 
</asm>
 
</asm>
  
Line 287: Line 287:
 
Go to label "RunObjectsWhenPlayerIsDead:" and between the label and it's first command, insert this:
 
Go to label "RunObjectsWhenPlayerIsDead:" and between the label and it's first command, insert this:
 
<asm>
 
<asm>
         cmpi.b #$C,(MainCharacter+routine).w   ; Has Sonic drowned?
+
         cmpi.b #$C,(MainCharacter+routine).w ; Has Sonic drowned?
        beq.s   RunObject                       ; If so, run objects a little longer
+
beq.s RunObject ; If so, run objects a little longer
 
</asm>
 
</asm>
  

Revision as of 15:40, 3 December 2014

(Guide by redhotsonic)

These bugs are present in both Sonic's 1 & 2, but have been fixed in Sonic 3 (& Knuckles).

So, you're underwater, timer starts, can't find air, AND... you drown. But what happens if you get hurt as soon as you're about to drown? Watch this video and find out: [1]

Basically, what happens, is if you're hurt and you haven't landed yet, when you drown, Sonic will still be using the gravity from his falling back from hurt state. He will also be able to detect the floors and walls. Hence why in this video, I was able to move about after drowning. However, there is a timer present, and it will force you to the bottom of the screen and restart within seconds.

Also, in both 1 & 2, there is another bug, although, hard to pull off. If you drown around the 9:58 mark, then the timer hits 9:59 and you're still drowning, Sonic will all of a sudden zoom to the top of the screen then back down again, really fast, in his death animation. The Time over appears.

In Sonic 2, there is an extra bug. When you and Tails (sidekick) drowns (normally), when Sonic reaches to the bottom of the screen, if Tails hasn't yet, he will suddenly start flying and move closer to where you drowned, but will continue to fall downwards.

In Sonic 3 and Knuckles, all of these have been fixed. It doesn't matter if you're in the hurt state, Sonic will still fall normally and will ignore the floor. And unless Tails entered the water at the exact same time as you (like he does at the beginning of HCZ1), Tails will automatically start swimming to where you drowned but will not fall. If he did enter the water at the same time, he will drown with you, but won't have time to do that bug where he would start flying suddenly. Time over will still make an appearance if you drown near the 9:58 mark, but Sonic won't misbehave.

Now, I'm going to show you how to fix these bugs in Sonic 1 and Sonic 2, the way Sonic 3 and Knuckles did it. It's not that hard, I've done all the research for you.

This guide will show you the fix for Sonic 2, for both Xenowhirl's 2007 and SVN disassembly. If you are looking for the Sonic 1 fix, you can find it here.

Xenowhirl Fix

First, we need to make little edit to the drowning-routine. Go to "Obj0A_ReduceAir:" and just after the "move.w #0,inertia(a0)" command, insert this: <asm> move.b #$C,routine(a0) ; Force the character to drown </asm>

And just after "move.b #1,($FFFFEEDC).w", insert this: <asm> clr.b (Update_HUD_timer).w ; Stop the timer immediately </asm>

So you have this: <asm> Obj0A_ReduceAir: subq.b #1,air_left(a2) ; subtract 1 from air remaining bcc.w BranchTo_Obj0A_MakeItem ; if air is above 0, branch move.b #$81,obj_control(a2) ; lock controls move.w #$32+$80,d0 jsr (PlaySound).l ; play drowning sound move.b #$A,objoff_34(a0) move.w #1,objoff_36(a0) move.w #$78,objoff_2C(a0) movea.l a2,a1 bsr.w ResumeMusic move.l a0,-(sp) movea.l a2,a0 bsr.w Sonic_ResetOnFloor_Part2 move.b #$17,anim(a0) ; use Sonic's drowning animation bset #1,status(a0) bset #7,art_tile(a0) move.w #0,y_vel(a0) move.w #0,x_vel(a0) move.w #0,inertia(a0) move.b #$C,routine(a0) ; Force the character to drown movea.l (sp)+,a0 ; load 0bj address ; restore a0 = obj0A cmpa.w #MainCharacter,a2 bne.s + ; if it isn't player 1, branch move.b #1,($FFFFEEDC).w clr.b (Update_HUD_timer).w ; Stop the timer immediately + rts </asm>

Next, go to "loc_1D708:" and change all this: <asm> loc_1D708: subq.w #1,objoff_2C(a0) bne.s + move.b #6,routine(a2) rts

---------------------------------------------------------------------------

+ move.l a0,-(sp) movea.l a2,a0 jsr ObjectMove addi.w #$10,y_vel(a0) movea.l (sp)+,a0 ; load 0bj address bra.s loc_1D72C </asm>

To this: <asm> loc_1D708: subq.w #1,objoff_2C(a0) bne.s loc_1D72C ; Make it jump straight to this location move.b #6,routine(a2) rts </asm>

Right, that's the drowning-routine finished. Now, we need to make the characters apply to this. First, Sonic. Go to "Obj01_States:" and add this line at the end of the table: <asm> dc.w Obj01_Drowned - Obj01_States ;$C </asm>

So you have: <asm> Obj01_States: dc.w Obj01_Init - Obj01_States ; 0 dc.w Obj01_Control - Obj01_States ; 2 dc.w Obj01_Hurt - Obj01_States ; 4 dc.w Obj01_Dead - Obj01_States ; 6 dc.w Obj01_Gone - Obj01_States ; 8 dc.w Obj01_Respawning - Obj01_States ;$A dc.w Obj01_Drowned - Obj01_States ;$C </asm>

Next, go to "Sonic_Animate:" and just above it, insert this: <asm>

---------------------------------------------------------------------------
Sonic when he's drowning
---------------------------------------------------------------------------

Obj01_Drowned: bsr.w ObjectMove ; Make Sonic able to move addi.w #$10,y_vel(a0) ; Apply gravity bsr.w Sonic_RecordPos ; Record position bsr.w Sonic_Animate ; Animate Sonic bsr.w LoadSonicDynPLC ; Load Sonic's DPLCs bra.w DisplaySprite ; And finally, display Sonic </asm>

That's Sonic done. Tails is next. Go to "Obj02_States:" and again, insert this line at the end of the table: <asm> dc.w Obj02_Drowned - Obj02_States ;$C </asm>

So you have: <asm> Obj02_States: dc.w Obj02_Init - Obj02_States ; 0 dc.w Obj02_Control - Obj02_States ; 2 dc.w Obj02_Hurt - Obj02_States ; 4 dc.w Obj02_Dead - Obj02_States ; 6 dc.w Obj02_Gone - Obj02_States ; 8 dc.w Obj02_Respawning - Obj02_States ;$A dc.w Obj02_Drowned - Obj02_States ;$C </asm>

Next, go to "Tails_Animate:" and just above it, insert this: <asm>

---------------------------------------------------------------------------
Tails when he's drowning
---------------------------------------------------------------------------

Obj02_Drowned: bsr.w ObjectMove ; Make Tails able to move addi.w #$10,y_vel(a0) ; Apply gravity bsr.w Tails_RecordPos ; Record position bsr.s Tails_Animate ; Animate Tails bsr.w LoadTailsDynPLC ; Load Tails's DPLCs bra.w DisplaySprite ; And finally, display Tails </asm>

There, all done. When you drown, everything will be normal. If you got hurt then drown, everything will still be normal and you won't be able to hit the floor, nor will you fall fast. If Tails is with you, he will fly out of the water as soon as you drown. Unless he entered the water at the exact same time as you; then he will drown with you, but won't have time to suddenly fly again. Now, as soon as Sonic drowns, the timer will stop immediately, rather than continuing to countdown. Because of this, there is no way you can get Time Over when drowning.

SVN Fix

First, we need to make little edit to the drowning-routine. Go to "Obj0A_ReduceAir:" and just after the "move.w #0,inertia(a0)" command, insert this: <asm> move.b #$C,routine(a0) ; Force the character to drown </asm>

And just after "move.b #1,(Deform_lock).w", insert this: <asm> clr.b (Update_HUD_timer).w ; Stop the timer immediately </asm>

So you have this: <asm> Obj0A_ReduceAir: subq.b #1,air_left(a2) ; subtract 1 from air remaining bcc.w BranchTo_Obj0A_MakeItem ; if air is above 0, branch move.b #$81,obj_control(a2) ; lock controls move.w #SndID_Drown,d0 jsr (PlaySound).l ; play drowning sound move.b #$A,objoff_34(a0) move.w #1,objoff_36(a0) move.w #$78,objoff_2C(a0) movea.l a2,a1 bsr.w ResumeMusic move.l a0,-(sp) movea.l a2,a0 bsr.w Sonic_ResetOnFloor_Part2 move.b #$17,anim(a0) ; use Sonic's drowning animation bset #1,status(a0) bset #high_priority_bit,art_tile(a0) move.w #0,y_vel(a0) move.w #0,x_vel(a0) move.w #0,inertia(a0) move.b #$C,routine(a0) ; Force the character to drown movea.l (sp)+,a0 ; load 0bj address ; restore a0 = obj0A cmpa.w #MainCharacter,a2 bne.s + ; if it isn't player 1, branch move.b #1,(Deform_lock).w clr.b (Update_HUD_timer).w ; Stop the timer immediately + rts </asm>

Next, go to "loc_1D708:" and change all this: <asm> loc_1D708: subq.w #1,objoff_2C(a0) bne.s + move.b #6,routine(a2) rts

---------------------------------------------------------------------------

+ move.l a0,-(sp) movea.l a2,a0 jsr (ObjectMove).l addi.w #$10,y_vel(a0) movea.l (sp)+,a0 ; load 0bj address bra.s loc_1D72C </asm>

To this: <asm> loc_1D708: subq.w #1,objoff_2C(a0) bne.s loc_1D72C ; Make it jump straight to this location move.b #6,routine(a2) rts </asm>

Right, that's the drowning-routine finished. Now, we need to make the characters apply to this. First,Sonic. Go to "Obj01_Index:" and add this line at the end of the table: <asm> offsetTableEntry.w Obj01_Drowned ; $C </asm>

So you have: <asm> Obj01_Index: offsetTable offsetTableEntry.w Obj01_Init ; 0 offsetTableEntry.w Obj01_Control ; 2 offsetTableEntry.w Obj01_Hurt ; 4 offsetTableEntry.w Obj01_Dead ; 6 offsetTableEntry.w Obj01_Gone ; 8 offsetTableEntry.w Obj01_Respawning ; $A offsetTableEntry.w Obj01_Drowned ; $C </asm>

Next, go to "Sonic_Animate:" and just above it, insert this: <asm>

---------------------------------------------------------------------------
Sonic when he's drowning
---------------------------------------------------------------------------

Obj01_Drowned: bsr.w ObjectMove ; Make Sonic able to move addi.w #$10,y_vel(a0) ; Apply gravity bsr.w Sonic_RecordPos ; Record position bsr.w Sonic_Animate ; Animate Sonic bsr.w LoadSonicDynPLC ; Load Sonic's DPLCs bra.w DisplaySprite ; And finally, display Sonic </asm>

That's Sonic done. Tails is next. Go to "Obj02_Index:" and again, insert this line at the end of the table: <asm> offsetTableEntry.w Obj02_Drowned ; $C </asm>

So you have: <asm> Obj02_Index: offsetTable offsetTableEntry.w Obj02_Init ; 0 offsetTableEntry.w Obj02_Control ; 2 offsetTableEntry.w Obj02_Hurt ; 4 offsetTableEntry.w Obj02_Dead ; 6 offsetTableEntry.w Obj02_Gone ; 8 offsetTableEntry.w Obj02_Respawning ; $A offsetTableEntry.w Obj02_Drowned ; $C </asm>

Next, go to "Tails_Animate:" and just above it, insert this: <asm>

---------------------------------------------------------------------------
Tails when he's drowning
---------------------------------------------------------------------------

Obj02_Drowned: bsr.w ObjectMove ; Make Tails able to move addi.w #$10,y_vel(a0) ; Apply gravity bsr.w Tails_RecordPos ; Record position bsr.s Tails_Animate ; Animate Tails bsr.w LoadTailsDynPLC ; Load Tails's DPLCs bra.w DisplaySprite ; And finally, display Tails </asm>

There, all done. When you drown, everything will be normal. If you got hurt then drown, everything will still be normal and you won't be able to hit the floor, nor will you fall fast. If Tails is with you, he will fly out of the water as soon as you drown. Unless he entered the water at the exact same time as you; then he will drown with you, but won't have time to suddenly fly again. Now, as soon as Sonic drowns, the timer will stop immediately, rather than continuing to countdown. Because of this, there is no way you can get Time Over when drowning.

ONE MORE STEP

BUT WAIT! There's just ONE MORE THING! You'll find that no bubbles come from Sonic/Tails's mouth when they are in their drowning animation. Bubbles come out of their mouth normally, and the countdown numbers work fine... but after drowning, no bubbles come out. To fix this:

Go to label "RunObjectsWhenPlayerIsDead:" and between the label and it's first command, insert this: <asm>

       cmpi.b	#$C,(MainCharacter+routine).w	; Has Sonic drowned?

beq.s RunObject ; If so, run objects a little longer </asm>

Ok, now you are done.

SCHG How-To Guide: Sonic the Hedgehog 2 (16-bit)
Fixing Bugs
Fix Demo Playback | Fix a Race Condition with Pattern Load Cues | Fix Super Sonic Bugs | Use Correct Height When Roll Jumping | Fix Jump Height Bug When Exiting Water | Fix Screen Boundary Spin Dash Bug | Correct Drowning Bugs | Fix Camera Y Position for Tails | Fix Tails Subanimation Error | Fix Tails' Respawn Speeds | Fix Accidental Deletion of Scattered Rings | Fix Ring Timers | Fix Rexon Crash | Fix Monitor Collision Bug | Fix EHZ Deformation Bug | Correct CPZ Boss Attack Behavior | Fix Bug in ARZ Boss Arrow's Platform Behavior | Fix ARZ Boss Walking on Air Glitch | Fix ARZ Boss Sprite Behavior | Fix Multiple CNZ Boss Bugs | Fix HTZ Background Scrolling Mountains | Fix OOZ Launcher Speed Up Glitch | Fix DEZ Giant Mech Collision Glitch | Fix Boss Deconstruction Behavior | Fix Speed Bugs | Fix 14 Continues Cheat | Fix Debug Mode Crash | Fix 99+ Lives | Fix Sonic 2's Sega Screen
Design Choices
Remove the Air Speed Cap | Disable Floor Collision While Dying | Modify Super Sonic Transformation Methods & Behavior | Enable/Disable Tails in Certain Levels | Collide with Water After Being Hurt | Retain Rings When Returning at a Star Post | Improve the Fade In\Fade Out Progression Routines | Fix Scattered Rings' Underwater Physics | Insert LZ Water Ripple Effect | Restore Lost CPZ Boss Feature | Prevent SCZ Tornado Spin Dash Death | Improve ObjectMove Subroutines | Port S3K Rings Manager | Port S3K Object Manager | Port S3K Priority Manager | Edit Level Order with ASM‎ | Alter Ring Requirements in Special Stages | Make Special Stage Characters Use Normal DPLCs | Speed Up Ring Loss Process | Change spike behaviour in Sonic 2
Adding Features
Create Insta-kill and High Jump Monitors | Create Clone and Special Stage Monitors | Port Knuckles
Sound Features
Expand Music Index to Start at $00 | Port Sonic 1 Sound Driver | Port Sonic 2 Clone Driver | Port Sonic 3 Sound Driver | Port Flamewing's Sonic 3 & Knuckles Sound Driver | Expand the Music Index to Start at $00 (Sonic 2 Clone Driver Version) | Play Different Songs Per Act
Extending the Game
Extend the Level Index Past $10 | Extend the Level Select | Extend Water Tables | Add Extra Characters | Free Up 2 Universal SSTs