Actions

SCHG How-to

Fix the OOZ launcher speed up glitch

From Sonic Retro

Revision as of 13:56, 22 July 2011 by MoDule (talk | contribs) (Guide completed)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

(Original guide by MoDule)

The launchers in Sonic 2's OOZ have a bug that when triggered causes Sonic to move around at twice his normal speed. It is described in more detail here. As amusing as this bug can be, it doesn't belong and this guide will show how to fix it.

Fixing the bug

Part 1

This fixes the round launcher object.

Locate the label loc_252F0. It should look like this: <asm>loc_252F0: tst.w (Debug_placement_mode).w bne.w return_253C4 move.w x_pos(a1),d0 sub.w x_pos(a0),d0 addi.w #$10,d0 cmpi.w #$20,d0 bhs.w return_253C4 move.w y_pos(a1),d1 sub.w y_pos(a0),d1 addi.w #$10,d1 cmpi.w #$20,d1 bhs.w return_253C4 cmpa.w #Sidekick,a1 bne.s + cmpi.w #4,(Tails_CPU_routine).w ; TailsCPU_Flying beq.w return_253C4 + cmpi.b #6,routine(a1) ; is Sonic dead? </asm> Change the last line to this: <asm> cmpi.b #4,routine(a1) ; is Sonic hurt or dead? </asm> This fixes the commonly known method of triggering the bug during normal gameplay.

Optional change

There is a redundant Debug Mode check in the code at loc_252F0 below the fix in Part 1. <asm> tst.w (Debug_placement_mode).w ;<-- bne.w return_253C4 ;<-- btst #3,status(a1) beq.s +

[...] </asm> This can be removed. Additionally, the check for Sonic's hurt state and Tails's flying state can be move to above the collision check, like so: <asm>loc_252F0: tst.w (Debug_placement_mode).w bne.w return_253C4

cmpa.w #Sidekick,a1 bne.s + cmpi.w #4,(Tails_CPU_routine).w ; TailsCPU_Flying beq.w return_253C4 +

cmpi.b #4,routine(a1) ; is Sonic hurt or dead? bhs.w return_253C4 ; if yes, branch

move.w x_pos(a1),d0 sub.w x_pos(a0),d0 addi.w #$10,d0 cmpi.w #$20,d0 bhs.w return_253C4 move.w y_pos(a1),d1 sub.w y_pos(a0),d1 addi.w #$10,d1 cmpi.w #$20,d1 bhs.w return_253C4

[...] </asm>


Part 2

This fixes the breakable block that propels Sonic into the other launcher objects.

Locate the label loc_24F84. Farther down, there should be this: <asm> cmpa.w #Sidekick,a1 bne.s loc_24FC2 cmpi.w #4,(Tails_CPU_routine).w ; TailsCPU_Flying beq.w return_25034 </asm> Extend the code as follows: <asm> tst.w (Debug_placement_mode).w bne.w return_25034

cmpa.w #Sidekick,a1 bne.s + cmpi.w #4,(Tails_CPU_routine).w ; TailsCPU_Flying beq.w return_25034 + cmpi.b #4,routine(a1) ; is Sonic hurt or dead? bhs.w return_25034 ; if yes, branch </asm> This adds previously missing checks for debug mode and Sonic's hurt state.

Optional change

Just as in Part 1, the modified code can be moved to just below the loc_24F84 label, above the collision check.

The bug explained

This and a few other objects in OOZ are special in that they are not immediately deleted when they go offscreen. That's because these objects need to be able to control Sonic's movement themselves.

When the player interacts with one of these objects a routine counter gets set in the object to prevent it form being deleted when it goes off screen. While the object is in a specific state it calls a routine that adds Sonic's x- and y-velocities to his position, something that Sonic normally does himself, but since Sonic is supposed to fly in a striaght line, the object needs to disable his movement. If Sonic triggers this interaction with more than one of these objects or disabling his movement for some reason doesn't happen, his horizontal and vertical speed are effectively doubled, or more.

The bug occurs when Sonic touches a launcher object while he is in his hurt state. This state is special, because it does not react to changes to Sonic's obj_control, which is used by various objects to control Sonic's movement, in this case to take away Sonic's own ability to move in the air. Because this state is not ignored after the collision check the object's routine counter gets set and Sonic's obj_control get set so to ignore movement. Now when Sonic lands on the ground during his hurt state his obj_control gets reset and his movement is restored, giving him twice his normal speed.