Actions

SCHG How-to

Difference between revisions of "Fix the Walk-Jump Bug in Sonic 1"

From Sonic Retro

(Changed the guide to a much better method of fixing this bug)
(well screw my crap. His is WAY better. DO IT NOW)
Line 30: Line 30:
  
 
And that's it! A much simpler method of getting rid of this bug, and one that doesn't alter the original player object as well.
 
And that's it! A much simpler method of getting rid of this bug, and one that doesn't alter the original player object as well.
 
==Original Guide==
 
{{GuideBy|Aquaslash}}
 
 
In the original ''[[Sonic the Hedgehog (16-bit)|Sonic the Hedgehog]]'' there exists an odd bug where Sonic does not use his Spin Attack while jumping next to certain objects.  He'll walk in place instead of rolling into a ball.  In addition to looking way weird, this can also hamper the game play a great deal.  It's most noticeable in [[Final Zone]], where it can cost players a few hits.  Today, we're going to fix that annoying glitch (because if I have to play ONE more hack with it, I'm losing it).
 
 
The first thing we want to look for is the modes for controlling Sonic, which is where this fix will be called from.  We'll want to call this in the air at all times so look for "Obj01_MdJump".  Once there, find the line "bsr.w Sonic_JumpHeight".  This is an optimal place for our fix since it'll be called after Sonic's jump height is looked at.  You'll want to paste this line after it:
 
 
<asm>bsr.w FixMZBug</asm>
 
 
Thus, the completed section should look like this (give or take your own modifications):
 
 
<asm>
 
bsr.w Sonic_JumpHeight
 
bsr.w FixMZBug
 
bsr.w Sonic_ChgJumpDir
 
bsr.w Sonic_LevelBound
 
jsr ObjectFall
 
btst #6,$22(a0)
 
beq.s loc_12E5C
 
subi.w #$28,$12(a0)</asm>
 
 
We'll also want to do this at the second check of the jump modes: "Obj01_MdJump2"  Once there, paste the same fix line in the same spot.  It should look similar to this:
 
 
<asm>Obj01_MdJump2: ; XREF: Obj01_Modes
 
bsr.w Sonic_JumpHeight
 
bsr.w FixMZBug
 
bsr.w Sonic_ChgJumpDir
 
bsr.w Sonic_LevelBound
 
jsr ObjectFall
 
btst #6,$22(a0)
 
beq.s loc_12EA6
 
subi.w #$28,$12(a0)</asm>
 
 
Now for the fix.  Find "Sonic_SlopeResist".  We're going to place our fix BEFORE it.  Make some space after the routine above it and add the following:
 
 
<asm>
 
; ---------------------------------------------------------------------------
 
; Subroutine to fix that godawful jumping bug
 
; ---------------------------------------------------------------------------
 
 
; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
 
 
FixMZBug:
 
      tst.b  $3C(a0) ; Are we jumping?
 
      beq  @rts ; If not, rts
 
      tst.w $12(a0) ; Just to make sure, is speed negative, aka are we going up?
 
    blt @jumping ; If yes, branch
 
     
 
@rts:
 
      rts
 
     
 
@jumping:
 
      cmp.b  #$01,$1C(a0) ; Are we using the walking animation?
 
      blt    @fix_bug ; If yes, fix that.
 
      rts
 
     
 
@fix_bug:
 
      move.b  #$2,$1C(a0) ; Set animation to rolling.
 
      rts
 
; End of function FixMZBug
 
; ===========================================================================
 
</asm>
 
 
As explained by the comments, this checks if Sonic's moving upwards while using the walking animation.  If he is, the proper rolling animation is put in it's place, problems are solved, and the Final Zone boss dies in record time!
 
 
That's it! It's one of those simple, but necessary fixes.  Put it in your ''Sonic 1'' hack.  NOW.  Else I'll hunt you down and force you to do it >:(.
 
 
(Special thanks go to [[Puto]] for helping out with this)
 
  
 
[[Category:SCHG How-tos|Fix the Walk-Jump Bug in Sonic 1]]
 
[[Category:SCHG How-tos|Fix the Walk-Jump Bug in Sonic 1]]

Revision as of 23:02, 13 January 2010

(Original guide by Cinossu)

In Sonic the Hedgehog there's a lovely bug where Sonic jumps into the air in his walking animation. It occurs in several places (to the right of the first purple rock in Green Hill Zone Act 2 being a good place to see it), but they all have one thing in common; they are near an object that calls the SolidObject routine.

Instead of changing how jumps are shown within Sonic's object code, you can fix this within the SolidObject routine itself (and if you look in Sonic 2, a variant of this is used as well).

The first thing you'll want to find is loc_FB92. It starts off looking like this:

<asm>loc_FB92: btst #5,$22(a0) beq.s loc_FBAC move.w #1,$1C(a1) ; use walking animation

loc_FBA0: bclr #5,$22(a0) ...</asm>

If you look at the comment left, it sets the walking animation for use right here. Your first assumption may be to remove this call altogether, but you don't want to do that as some little animation bugs can still occur this way. The way to fix it is to add a conditional branch over it, checking to see if Sonic's animation should be set to rolling. You should change the code to look something like this:

<asm>loc_FB92: btst #5,$22(a0) beq.s loc_FBAC cmp.b #2,$1C(a1) ; check if in jumping/rolling animation beq.s loc_FBA0 move.w #1,$1C(a1) ; use walking animation

loc_FBA0: bclr #5,$22(a0) ...</asm>

And that's it! A much simpler method of getting rid of this bug, and one that doesn't alter the original player object as well.