Actions

SCHG How-to

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

From Sonic Retro

m (Spikes)
m (Text replace - '[[Category:SCHG How-tos|' to '{{S1Howtos}} [[Category:SCHG How-tos|')
Line 123: Line 123:
  
  
 +
{{S1Howtos}}
 
[[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 10:28, 13 September 2011

(Original guide by Cinossu and Mercury)

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 second purple rock with a yellow spring on top of it in Green Hill Zone Act 2 being a good place to see it as well as near the lava in Marble Zone), 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.

Monitors

The above fix only works concerning solid objects other than Monitors, meaning there will still be a fair number of areas in which the walk-jump bug will occur unless you also modify the following code. Find the Obj26 label, and scroll until you see this:

<asm> loc_A25C: btst #5,$22(a0) beq.s Obj26_Animate move.w #1,$1C(a1)

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

and replace it with this:

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

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

Drowning

There is also another, related bug. If Sonic drowns while adjacent to a solid object or Monitor, he will fall off the screen in his walking animation, and not his drowning animation as he should. This can be fixed by adding a check for his drowning animation in addition to his jumping/rolling animation in the routines described above.

SolidObject:

<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 cmp.b #$17,$1C(a1) ; check if in drowning animation beq.s loc_FBA0 move.w #1,$1C(a1) ; use walking animation

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

Obj26 (Monitor):

<asm> loc_A25C: btst #5,$22(a0) beq.s Obj26_Animate cmp.b #2,$1C(a1) ; check if in jumping/rolling animation beq.s loc_A26A cmp.b #$17,$1C(a1) ; check if in drowning animation beq.s loc_A26A move.w #1,$1C(a1)

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


Spikes

There is yet another related bug. If Sonic walks or runs into spike pointing sideways, he will be hurt as usual, but bounce in his walking animation, and not his hurt animation. This can be fixed by adding a check for his hurt animation.

SolidObject:

<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 cmp.b #$17,$1C(a1) ; check if in drowning animation beq.s loc_FBA0 cmp.b #$1A,$1C(a1) ; check if in hurt animation beq.s loc_FBA0 move.w #1,$1C(a1) ; use walking animation

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


SCHG How-To Guide: Sonic the Hedgehog (16-bit)
Fixing Bugs
Fix Demo Playback | Fix a Race Condition with Pattern Load Cues | Fix the SEGA Sound | Display the Press Start Button Text | Fix the Level Select Menu | Fix the Hidden Points Bug | Fix Accidental Deletion of Scattered Rings | Fix Ring Timers | Fix the Walk-Jump Bug | Correct Drowning Bugs | Fix the Death Boundary Bug | Fix the Camera Follow Bug | Fix Song Restoration Bugs | Fix the HUD Blinking | Fix the Level Select Graphics Bug | Fix a remember sprite related bug
Changing Design Choices
Change Spike Behavior | Collide with Water After Being Hurt | Fix Special Stage Jumping Physics | Improve the Fade In\Fade Out Progression Routines | Fix Scattered Rings' Underwater Physics | Remove the Speed Cap | Port the REV01 Background Effects | Port Sonic 2's Level Art Loader | Retain Rings Between Acts | Add Sonic 2 (Simon Wai Prototype) Level Select | Improve ObjectMove Subroutines | Port Sonic 2 Level Select
Adding Features
Add Spin Dash ( Part 1 / Part 2 / Part 3 / Part 4 ) | Add Eggman Monitor | Add Super Sonic | Add the Air Roll
Sound Features
Expand the Sound Index | Play Different Songs Per Act | Port Sonic 2 Final Sound Driver | Port Sonic 3's Sound Driver | Port Flamewing's Sonic 3 & Knuckles Sound Driver | Change The SEGA Sound
Extending the Game
Load Chunks From ROM | Add Extra Characters | Make an Alternative Title Screen | Use Dynamic Tilesets | Make GHZ Load Alternate Art | Make Ending Load Alternate Art | Add a New Zone | Set Up the Goggle Monitor | Add New Moves | Add a Dynamic Collision System | Dynamic Special Stage Walls System | Extend Sprite Mappings and Art Limit | Enigma Credits | Use Dynamic Palettes
Miscellaneous
Convert the Hivebrain 2005 Disassembly to ASM68K
Split Disassembly Guides
Set Up a Split Disassembly | Basic Level Editing | Basic Art Editing | Basic ASM Editing (Spin Dash)