Actions

SCHG How-to

Difference between revisions of "Fix bug in ARZ Boss arrow's platform behavior"

From Sonic Retro

m (The bug expained)
m (The bug explained)
Line 55: Line 55:
  
 
==The bug explained==
 
==The bug explained==
The first part of the bug comes from the arrow object running its platform checks only once. The reason why the check is only run once is because the arrow's platform routine checks if the countdown timewr is set first. If it is it skips the code that checks if Sonic is standing on the arrow and initializes the timer. By skipping any further platform checks, Sonic's on-object bit never gets cleared, which causes the walking in air bug.
+
The first part of the bug comes from the arrow object running its platform checks only once. The reason why the check is only run once is because the arrow's platform routine checks if the countdown timer is set first. If it is it skips the code that checks if Sonic is standing on the arrow and initializes the timer. By skipping any further platform checks, Sonic's on-object bit never gets cleared, which causes the walking in air bug.
  
The second part, where Sonic uses his balancing animation no matter how far he is from the arrow's edge comes from the arrow object not assigning a value to its '''width_pixels'''. Now when Sonic's object checks for his distance to the object's edge it will think he's always right at the adge or beyond thus triggering his balancing animation.
+
The second part, where Sonic uses his balancing animation no matter how far he is from the arrow's edge comes from the arrow object not assigning a value to its '''width_pixels'''. Now when Sonic's object checks for his distance to the object's edge it will think he's always right at the edge or beyond thus triggering his balancing animation.

Revision as of 14:48, 22 July 2011

(Original guide by MoDule)

In Sonic 2 there is a bug in ARZ's Boss. The arrows it shoots that act as platforms can temporarily cause the walking in air glitch if the player is fast enough and walks over the edge of the arrow.

This guide will show how to fix this bug.

Fixing the bug

Locate the label loc_30CCC. It should look something like this: <asm>loc_30CCC: tst.w objoff_30(a0) ; has timer been set? bne.s + ; if yes, branch

move.w #$1B,d1 move.w #1,d2 move.w #2,d3 move.w x_pos(a0),d4 bsr.w JmpTo8_PlatformObject

btst #3,status(a0) ; is Main character standing on the arrow? beq.s return_30D02 ; if not, branch move.w #$1F,objoff_30(a0) ; set timer + subi.w #1,objoff_30(a0) ; decrement timer bne.s return_30D02 ; make arrow fall when timer runs out move.b #6,objoff_2A(a0)

return_30D02: rts </asm> Now move the following block to the top, under the first label: <asm> move.w #$1B,d1 move.w #1,d2 move.w #2,d3 move.w x_pos(a0),d4 bsr.w JmpTo8_PlatformObject </asm> Now Sonic can walk off the arrows properly.

Optional next step

Sonic will use his balancing animation when standing on an arrow. If this is undesirable, this next part will show how to change this behavior.

Locate the label loc_30BC8. It should look something like this: <asm>loc_30BC8: move.l #Obj89_MapUnc_30D68,mappings(a0) move.w #make_art_tile(ArtTile_ArtNem_ARZBoss,0,0),art_tile(a0) ori.b #4,render_flags(a0) move.b #-$70,mainspr_width(a0) [...] </asm> Although that last line seems to already set a width, it doesn't. Adding this underneath <asm> move.b #$10,width_pixels(a0) </asm> seems to work well.

The bug explained

The first part of the bug comes from the arrow object running its platform checks only once. The reason why the check is only run once is because the arrow's platform routine checks if the countdown timer is set first. If it is it skips the code that checks if Sonic is standing on the arrow and initializes the timer. By skipping any further platform checks, Sonic's on-object bit never gets cleared, which causes the walking in air bug.

The second part, where Sonic uses his balancing animation no matter how far he is from the arrow's edge comes from the arrow object not assigning a value to its width_pixels. Now when Sonic's object checks for his distance to the object's edge it will think he's always right at the edge or beyond thus triggering his balancing animation.