Difference between revisions of "Correct Drowning Bugs in Sonic 1"
From Sonic Retro
Luigi Hero (talk | contribs) |
Scarred Sun (talk | contribs) m (Text replacement - "</asm>" to "</syntaxhighlight>") |
||
Line 24: | Line 24: | ||
<asm> | <asm> | ||
move.b #$A,$24(a0) ; Force the character to drown | move.b #$A,$24(a0) ; Force the character to drown | ||
− | </ | + | </syntaxhighlight> |
And just after "move.b #1,($FFFFF744).w", insert this: | And just after "move.b #1,($FFFFF744).w", insert this: | ||
<asm> | <asm> | ||
move.b #0,($FFFFFE1E).w ; Stop the timer immediately | move.b #0,($FFFFFE1E).w ; Stop the timer immediately | ||
− | </ | + | </syntaxhighlight> |
So you have this: | So you have this: | ||
Line 57: | Line 57: | ||
movea.l (sp)+,a0 | movea.l (sp)+,a0 | ||
rts | rts | ||
− | </ | + | </syntaxhighlight> |
Next, go to "loc_13F86:" and change all this: | Next, go to "loc_13F86:" and change all this: | ||
Line 76: | Line 76: | ||
movea.l (sp)+,a0 | movea.l (sp)+,a0 | ||
bra.s loc_13FAC | bra.s loc_13FAC | ||
− | </ | + | </syntaxhighlight> |
To this: | To this: | ||
<asm> | <asm> | ||
Line 84: | Line 84: | ||
move.b #6,($FFFFD000+$24).w | move.b #6,($FFFFD000+$24).w | ||
rts | rts | ||
− | </ | + | </syntaxhighlight> |
Right, that's the drowning-routine finished. Now, we need to make Sonic apply to this. Open the main ASM file and 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 Sonic apply to this. Open the main ASM file and go to "Obj01_Index:" and add this line at the end of the table: | ||
<asm> | <asm> | ||
dc.w Sonic_Drowned-Obj01_Index | dc.w Sonic_Drowned-Obj01_Index | ||
− | </ | + | </syntaxhighlight> |
So you have: | So you have: | ||
Line 100: | Line 100: | ||
dc.w Obj01_ResetLevel-Obj01_Index | dc.w Obj01_ResetLevel-Obj01_Index | ||
dc.w Sonic_Drowned-Obj01_Index | dc.w Sonic_Drowned-Obj01_Index | ||
− | </ | + | </syntaxhighlight> |
Next, find "; End of function Sonic_Loops" and just below it, insert this: | Next, find "; End of function Sonic_Loops" and just below it, insert this: | ||
Line 119: | Line 119: | ||
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 | ||
− | </ | + | </syntaxhighlight> |
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. Also, 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. | 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. Also, 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. | ||
Line 129: | Line 129: | ||
cmpi.b #$A,($FFFFD000+$24).w ; Has Sonic drowned? | cmpi.b #$A,($FFFFD000+$24).w ; Has Sonic drowned? | ||
beq.s loc_D348 ; If so, run objects a little longer | beq.s loc_D348 ; If so, run objects a little longer | ||
− | </ | + | </syntaxhighlight> |
So you have this: | So you have this: | ||
Line 139: | Line 139: | ||
bsr.s loc_D348 | bsr.s loc_D348 | ||
moveq #$5F,d7 | moveq #$5F,d7 | ||
− | </ | + | </syntaxhighlight> |
Done. This allows objects to run for a little bit longer than normal, allowing the bubbles to run out of Sonic's mouth like normal. | Done. This allows objects to run for a little bit longer than normal, allowing the bubbles to run out of Sonic's mouth like normal. | ||
Line 149: | Line 149: | ||
<asm> | <asm> | ||
move.b #$A,obRoutine(a0) ; Force the character to drown | move.b #$A,obRoutine(a0) ; Force the character to drown | ||
− | </ | + | </syntaxhighlight> |
And just after "move.b #1,(f_nobgscroll).w", insert this: | And just after "move.b #1,(f_nobgscroll).w", insert this: | ||
<asm> | <asm> | ||
move.b #0,(f_timecount).w ; Stop the timer immediately | move.b #0,(f_timecount).w ; Stop the timer immediately | ||
− | </ | + | </syntaxhighlight> |
So you have this: | So you have this: | ||
Line 183: | Line 183: | ||
movea.l (sp)+,a0 | movea.l (sp)+,a0 | ||
rts | rts | ||
− | </ | + | </syntaxhighlight> |
Next, go to "@loc_13F86:" and change all this: | Next, go to "@loc_13F86:" and change all this: | ||
Line 200: | Line 200: | ||
addi.w #$10,obVelY(a0) | addi.w #$10,obVelY(a0) | ||
movea.l (sp)+,a0 | movea.l (sp)+,a0 | ||
− | bra.s @nochange</ | + | bra.s @nochange</syntaxhighlight> |
To this: | To this: | ||
Line 209: | Line 209: | ||
move.b #6,(v_player+obRoutine).w | move.b #6,(v_player+obRoutine).w | ||
rts | rts | ||
− | </ | + | </syntaxhighlight> |
Right, that's the drowning-routine finished. Now, we need to make Sonic apply to this. Open the main ASM file and go to "Sonic_Index:" and add this line at the end of the table: | Right, that's the drowning-routine finished. Now, we need to make Sonic apply to this. Open the main ASM file and go to "Sonic_Index:" and add this line at the end of the table: | ||
<asm> | <asm> | ||
dc.w Sonic_Drowned-Sonic_Index | dc.w Sonic_Drowned-Sonic_Index | ||
− | </ | + | </syntaxhighlight> |
So you have: | So you have: | ||
Line 224: | Line 224: | ||
dc.w Sonic_ResetLevel-Sonic_Index | dc.w Sonic_ResetLevel-Sonic_Index | ||
dc.w Sonic_Drowned-Sonic_Index | dc.w Sonic_Drowned-Sonic_Index | ||
− | </ | + | </syntaxhighlight> |
Next, find "include "_incObj\Sonic Loops.asm"" and just below it, insert this: | Next, find "include "_incObj\Sonic Loops.asm"" and just below it, insert this: | ||
<asm> | <asm> | ||
include "_incObj\Sonic Drowns.asm" | include "_incObj\Sonic Drowns.asm" | ||
− | </ | + | </syntaxhighlight> |
Then, in the "_incObj" folder, make a new ASM file called "Sonic Drowns.asm" and insert this: | Then, in the "_incObj" folder, make a new ASM file called "Sonic Drowns.asm" and insert this: | ||
Line 247: | Line 247: | ||
bsr.w Sonic_LoadGfx ; Load Sonic's DPLCs | bsr.w Sonic_LoadGfx ; Load Sonic's DPLCs | ||
bra.w DisplaySprite ; And finally, display Sonic | bra.w DisplaySprite ; And finally, display Sonic | ||
− | </ | + | </syntaxhighlight> |
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. Also, 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. | 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. Also, 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. | ||
Line 257: | Line 257: | ||
cmpi.b #$A,(v_player+obRoutine).w ; Has Sonic drowned? | cmpi.b #$A,(v_player+obRoutine).w ; Has Sonic drowned? | ||
beq.s loc_D348 ; If so, run objects a little longer | beq.s loc_D348 ; If so, run objects a little longer | ||
− | </ | + | </syntaxhighlight> |
So you have this: | So you have this: | ||
Line 267: | Line 267: | ||
bsr.s loc_D348 | bsr.s loc_D348 | ||
moveq #$5F,d7 | moveq #$5F,d7 | ||
− | </ | + | </syntaxhighlight> |
Done. This allows objects to run for a little bit longer than normal, allowing the bubbles to run out of Sonic's mouth like normal. | Done. This allows objects to run for a little bit longer than normal, allowing the bubbles to run out of Sonic's mouth like normal. |
Revision as of 21:28, 20 December 2015
(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 1, for the SVN disassembly. If you are looking for the Sonic 2 fix, its here.
Hivebrain
(Addition by Luigi Hero)
First, we need to make little edit to the drowning-routine.
Go to "Obj0A_ReduceAir:" and just after the "move.w #0,$14(a0)" command, insert this: <asm> move.b #$A,$24(a0) ; Force the character to drown </syntaxhighlight>
And just after "move.b #1,($FFFFF744).w", insert this: <asm> move.b #0,($FFFFFE1E).w ; Stop the timer immediately </syntaxhighlight>
So you have this: <asm> Obj0A_ReduceAir: subq.w #1,($FFFFFE14).w ; subtract 1 from air remaining bcc.w Obj0A_GoMakeItem ; if air is above 0, branch bsr.w ResumeMusic move.b #$81,($FFFFF7C8).w ; lock controls move.w #$B2,d0 jsr (PlaySound_Special).l ; play drowning sound move.b #$A,$34(a0) move.w #1,$36(a0) move.w #$78,$2C(a0) move.l a0,-(sp) lea ($FFFFD000).w,a0 bsr.w Sonic_ResetOnFloor move.b #$17,$1C(a0) ; use Sonic's drowning animation bset #1,$22(a0) bset #7,2(a0) move.w #0,$12(a0) move.w #0,$10(a0) move.w #0,$14(a0) move.b #$A,$24(a0) ; Force the character to drown move.b #1,($FFFFF744).w move.b #0,($FFFFFE1E).w ; Stop the timer immediately movea.l (sp)+,a0 rts </syntaxhighlight>
Next, go to "loc_13F86:" and change all this:
<asm> loc_13F86: subq.w #1,$2C(a0) bne.s loc_13F94 move.b #6,($FFFFD024).w rts
- ===========================================================================
loc_13F94: move.l a0,-(sp) lea ($FFFFD000).w,a0 jsr SpeedToPos addi.w #$10,$12(a0) movea.l (sp)+,a0 bra.s loc_13FAC </syntaxhighlight> To this: <asm> loc_13F86:
subq.w #1,$2C(a0) bne.s loc_13FAC ; Make it jump straight to this location move.b #6,($FFFFD000+$24).w rts
</syntaxhighlight>
Right, that's the drowning-routine finished. Now, we need to make Sonic apply to this. Open the main ASM file and go to "Obj01_Index:" and add this line at the end of the table: <asm>
dc.w Sonic_Drowned-Obj01_Index
</syntaxhighlight>
So you have: <asm> Obj01_Index: dc.w Obj01_Main-Obj01_Index dc.w Obj01_Control-Obj01_Index dc.w Obj01_Hurt-Obj01_Index dc.w Obj01_Death-Obj01_Index dc.w Obj01_ResetLevel-Obj01_Index dc.w Sonic_Drowned-Obj01_Index </syntaxhighlight>
Next, find "; End of function Sonic_Loops" and just below it, insert this:
<asm>
- ---------------------------------------------------------------------------
- Sonic when he's drowning
- ---------------------------------------------------------------------------
- ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
Sonic_Drowned:
bsr.w SpeedToPos ; Make Sonic able to move addi.w #$10,$12(a0) ; Apply gravity bsr.w Sonic_RecordPos ; Record position bsr.s Sonic_Animate ; Animate Sonic bsr.w LoadSonicDynPLC ; Load Sonic's DPLCs bra.w DisplaySprite ; And finally, display Sonic
</syntaxhighlight>
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. Also, 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.
BUT WAIT! There's just ONE MORE THING! You'll find that no bubbles come from Sonic's mouth when he is in his drowning animation. Bubbles come out of his mouth normally, and the countdown numbers work fine... but after he drowns, no bubbles come out. To fix this:
Go to label "loc_D362:" and between the label and it's first command, insert this: <asm>
cmpi.b #$A,($FFFFD000+$24).w ; Has Sonic drowned? beq.s loc_D348 ; If so, run objects a little longer
</syntaxhighlight>
So you have this: <asm> loc_D362:
cmpi.b #$A,($FFFFD000+$24).w ; Has Sonic drowned? beq.s loc_D348 ; If so, run objects a little longer moveq #$1F,d7 bsr.s loc_D348 moveq #$5F,d7
</syntaxhighlight>
Done. This allows objects to run for a little bit longer than normal, allowing the bubbles to run out of Sonic's mouth like normal.
SVN
First, we need to make little edit to the drowning-routine. You need to open the "0A - Drowning Countdown.asm".
Go to "@reduceair:" and just after the "move.w #0,obInertia(a0)" command, insert this: <asm>
move.b #$A,obRoutine(a0) ; Force the character to drown
</syntaxhighlight>
And just after "move.b #1,(f_nobgscroll).w", insert this: <asm>
move.b #0,(f_timecount).w ; Stop the timer immediately
</syntaxhighlight>
So you have this: <asm> @reduceair:
subq.w #1,(v_air).w ; subtract 1 from air remaining bcc.w @gotomakenum ; if air is above 0, branch
; Sonic drowns here bsr.w ResumeMusic move.b #$81,(f_lockmulti).w ; lock controls sfx sfx_Drown ; play drowning sound move.b #$A,$34(a0) move.w #1,$36(a0) move.w #$78,$2C(a0) move.l a0,-(sp) lea (v_player).w,a0 bsr.w Sonic_ResetOnFloor move.b #$17,obAnim(a0) ; use Sonic's drowning animation bset #1,obStatus(a0) bset #7,obGfx(a0) move.w #0,obVelY(a0) move.w #0,obVelX(a0) move.w #0,obInertia(a0) move.b #$A,obRoutine(a0) ; Force the character to drown move.b #1,(f_nobgscroll).w move.b #0,(f_timecount).w ; Stop the timer immediately movea.l (sp)+,a0 rts
</syntaxhighlight>
Next, go to "@loc_13F86:" and change all this: <asm> @loc_13F86:
subq.w #1,$2C(a0) bne.s @loc_13F94 move.b #6,(v_player+obRoutine).w rts
- ===========================================================================
@loc_13F94: move.l a0,-(sp) lea (v_player).w,a0 jsr SpeedToPos addi.w #$10,obVelY(a0) movea.l (sp)+,a0 bra.s @nochange</syntaxhighlight>
To this: <asm> @loc_13F86:
subq.w #1,$2C(a0) bne.s @nochange ; Make it jump straight to this location move.b #6,(v_player+obRoutine).w rts
</syntaxhighlight>
Right, that's the drowning-routine finished. Now, we need to make Sonic apply to this. Open the main ASM file and go to "Sonic_Index:" and add this line at the end of the table: <asm>
dc.w Sonic_Drowned-Sonic_Index
</syntaxhighlight>
So you have: <asm> Sonic_Index: dc.w Sonic_Main-Sonic_Index
dc.w Sonic_Control-Sonic_Index dc.w Sonic_Hurt-Sonic_Index dc.w Sonic_Death-Sonic_Index dc.w Sonic_ResetLevel-Sonic_Index dc.w Sonic_Drowned-Sonic_Index
</syntaxhighlight>
Next, find "include "_incObj\Sonic Loops.asm"" and just below it, insert this: <asm>
include "_incObj\Sonic Drowns.asm"
</syntaxhighlight>
Then, in the "_incObj" folder, make a new ASM file called "Sonic Drowns.asm" and insert this: <asm>
- ---------------------------------------------------------------------------
- Sonic when he's drowning
- ---------------------------------------------------------------------------
- ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
Sonic_Drowned:
bsr.w SpeedToPos ; Make Sonic able to move addi.w #$10,y_vel(a0) ; Apply gravity bsr.w Sonic_RecordPosition ; Record position bsr.s Sonic_Animate ; Animate Sonic bsr.w Sonic_LoadGfx ; Load Sonic's DPLCs bra.w DisplaySprite ; And finally, display Sonic
</syntaxhighlight>
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. Also, 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.
BUT WAIT! There's just ONE MORE THING! You'll find that no bubbles come from Sonic's mouth when he is in his drowning animation. Bubbles come out of his mouth normally, and the countdown numbers work fine... but after he drowns, no bubbles come out. To fix this:
Go to label "loc_D362:" and between the label and it's first command, insert this: <asm>
cmpi.b #$A,(v_player+obRoutine).w ; Has Sonic drowned? beq.s loc_D348 ; If so, run objects a little longer
</syntaxhighlight>
So you have this: <asm> loc_D362:
cmpi.b #$A,(v_player+obRoutine).w ; Has Sonic drowned? beq.s loc_D348 ; If so, run objects a little longer moveq #$1F,d7 bsr.s loc_D348 moveq #$5F,d7
</syntaxhighlight>
Done. This allows objects to run for a little bit longer than normal, allowing the bubbles to run out of Sonic's mouth like normal.