Actions

SCHG How-to

Difference between revisions of "Fix ARZ boss sprite behavior"

From Sonic Retro

(Added ANOTHER fix.)
 
m (Replaced spaces with tabs, unnamed temp label with named temp label)
Line 1: Line 1:
''(Guide by [[redhotsonic]])''
+
{{GuideBy|redhotsonic}}
  
 
With this boss, as soon as you're hurt, Eggman won't laugh instantly. Instead, he waits for you to hit the ground, then he laughs. Same goes for Tails. with all the other bosses, Eggman laughs instantly. So let's fix this.
 
With this boss, as soon as you're hurt, Eggman won't laugh instantly. Instead, he waits for you to hit the ground, then he laughs. Same goes for Tails. with all the other bosses, Eggman laughs instantly. So let's fix this.
Line 7: Line 7:
 
<asm>
 
<asm>
 
loc_30770:
 
loc_30770:
        lea     ($FFFFF740).w,a1
+
lea ($FFFFF740).w,a1
        move.b #$31,3(a1)
+
move.b #$31,3(a1)
  
 
loc_3077A:
 
loc_3077A:
Line 15: Line 15:
 
Under the "move.b #$31,3(a1)", insert this line:
 
Under the "move.b #$31,3(a1)", insert this line:
 
<asm>
 
<asm>
        move.b #1,objoff_36(a0)       ; move 1 to checker
+
move.b #1,objoff_36(a0) ; move 1 to checker
 
</asm>
 
</asm>
  
Line 21: Line 21:
 
<asm>
 
<asm>
 
loc_30770:
 
loc_30770:
        lea     ($FFFFF740).w,a1
+
lea ($FFFFF740).w,a1
        move.b #$31,3(a1)
+
move.b #$31,3(a1)
        move.b #1,objoff_36(a0)       ; move 1 to checker
+
move.b #1,objoff_36(a0) ; move 1 to checker
  
 
loc_3077A:
 
loc_3077A:
Line 31: Line 31:
 
<asm>
 
<asm>
 
loc_3075C:
 
loc_3075C:
        bsr.w   loc_3078E
+
bsr.w loc_3078E
        cmpi.b #4,(MainCharacter+routine).w
+
cmpi.b #4,(MainCharacter+routine).w
        beq.s   loc_30770
+
beq.s loc_30770
        cmpi.b #4,(Sidekick+routine).w
+
cmpi.b #4,(Sidekick+routine).w
        bne.s   loc_3077A
+
bne.s loc_3077A
 
</asm>
 
</asm>
  
 
After the "bsr.w loc_3078E" command, insert these two lines:
 
After the "bsr.w loc_3078E" command, insert these two lines:
 
<asm>
 
<asm>
        tst.b   objoff_36(a0)           ; Is checker 0?
+
tst.b objoff_36(a0) ; Is checker 0?
        bne.s   loc_3077A               ; If not, branch and do not check for Sonic/Tails hurt state
+
bne.s loc_3077A ; If not, branch and do not check for Sonic/Tails hurt state
 
</asm>
 
</asm>
  
Line 47: Line 47:
 
<asm>
 
<asm>
 
loc_3075C:
 
loc_3075C:
        bsr.w   loc_3078E
+
bsr.w loc_3078E
        tst.b   objoff_36(a0)           ; Is checker 0?
+
tst.b objoff_36(a0) ; Is checker 0?
        bne.s   loc_3077A               ; If not, branch and do not check for Sonic/Tails hurt state
+
bne.s loc_3077A ; If not, branch and do not check for Sonic/Tails hurt state
        cmpi.b #4,(MainCharacter+routine).w
+
cmpi.b #4,(MainCharacter+routine).w
        beq.s   loc_30770
+
beq.s loc_30770
        cmpi.b #4,(Sidekick+routine).w
+
cmpi.b #4,(Sidekick+routine).w
        bne.s   loc_3077A
+
bne.s loc_3077A
 
</asm>
 
</asm>
  
Line 59: Line 59:
 
<asm>
 
<asm>
 
return_3078C:
 
return_3078C:
        rts
+
rts
 
</asm>
 
</asm>
  
Line 65: Line 65:
 
<asm>
 
<asm>
 
return_3078C:
 
return_3078C:
        cmpi.b  #$17,($FFFFF743).w     ; Has Eggman stopped laughing?
+
cmpi.b  #$17,($FFFFF743).w ; Has Eggman stopped laughing?
        bne.s  +                      ; If not, branch
+
bne.s  .laughing ; If not, branch
        clr.b  objoff_36(a0)           ; If so, clear checker, so Eggman can check to see if Sonic/Tails are hurt again
+
clr.b  objoff_36(a0) ; If so, clear checker, so Eggman can check to see if Sonic/Tails are hurt again
+
+
.laughing:
        rts
+
rts
 
</asm>
 
</asm>
 
'''Done!'''
 
'''Done!'''

Revision as of 12:20, 13 September 2014

(Original guide by redhotsonic)

With this boss, as soon as you're hurt, Eggman won't laugh instantly. Instead, he waits for you to hit the ground, then he laughs. Same goes for Tails. with all the other bosses, Eggman laughs instantly. So let's fix this.

The Fix

Go to "loc_30770:" (part of the ARZ boss code) and you'll see this: <asm> loc_30770: lea ($FFFFF740).w,a1 move.b #$31,3(a1)

loc_3077A: </asm>

Under the "move.b #$31,3(a1)", insert this line: <asm> move.b #1,objoff_36(a0) ; move 1 to checker </asm>

So you have something like this: <asm> loc_30770: lea ($FFFFF740).w,a1 move.b #$31,3(a1) move.b #1,objoff_36(a0) ; move 1 to checker

loc_3077A: </asm>

Next, go to "loc_3075C:" and you'll see this: <asm> loc_3075C: bsr.w loc_3078E cmpi.b #4,(MainCharacter+routine).w beq.s loc_30770 cmpi.b #4,(Sidekick+routine).w bne.s loc_3077A </asm>

After the "bsr.w loc_3078E" command, insert these two lines: <asm> tst.b objoff_36(a0) ; Is checker 0? bne.s loc_3077A ; If not, branch and do not check for Sonic/Tails hurt state </asm>

So you have something like this: <asm> loc_3075C: bsr.w loc_3078E tst.b objoff_36(a0) ; Is checker 0? bne.s loc_3077A ; If not, branch and do not check for Sonic/Tails hurt state cmpi.b #4,(MainCharacter+routine).w beq.s loc_30770 cmpi.b #4,(Sidekick+routine).w bne.s loc_3077A </asm>

Next, go to "return_3078C:" and you'll see this: <asm> return_3078C: rts </asm>

Change it to this: <asm> return_3078C: cmpi.b #$17,($FFFFF743).w ; Has Eggman stopped laughing? bne.s .laughing ; If not, branch clr.b objoff_36(a0) ; If so, clear checker, so Eggman can check to see if Sonic/Tails are hurt again .laughing: rts </asm> Done!

Explanation

Quoted from RHS: "Most of you have probably noticed that Eggman didn't laugh instantly. BUT, did any of you notice that when hurt, Eggman's animation is actually frozen? Yup, that's right. Normally, his mustache is moving (due to wind I guess), but as soon as you're hurt, his mustache isn't moving anymore. He's frozen and until you hit the ground, he will remain that way. When you've hit the ground, he will then laugh, then carry on with his normal animations.

It's important to know, for this boss, the animations are working another way rather than they normally do. instead of "anim" being set, $FFFFF743 (or $FFFFF740+3) is being set. This RAM adress counts down every frame, to make Eggman animate. Every odd number displays one part of his anim, and every even number displays another part of his anim. His mustache for instance. Every odd number displays 1 part and every even displays another, making his mustache move.

Anyway, the reason for Eggman's animation freezing is because when Sonic/Tails gets hurt, their routine is set to 4 (hurt routine). Eggman checks this, and if hurt, move $31 to his animation. But at this moment in time, the RAM address CANNOT countdown. It tries to, but it can't. The reason why, is because as Sonic and Tails are hurt, until they land on the floor, their routine will stay at 4. Because Eggman is continuously seeing them at routine 4, it constantly writes $31 to $FFFFF743. That's why the RAM cannot countdown. And because it's constantly at $31, it's only able to display one part of his animation, and that's why Eggman's anim is frozen.

As soon as Sonic/Tails lands, their routine is set back to normal. Eggman now stops writing $31 to $FFFFF743, letting the RAM address able to countdown, now displaying his laugh animation.

So, what have we done to fix this? We've added a new check using objoff_36(a0) (not used in ARZ boss so it's free to use). As soon as Sonic/Tails gets hurt, it now moves #1 to objoff_36(a0). We've added a check before the Sonic/Tails hurt check. If objoff_36(a0) is now equals 1, to branch away from the hurt check, leaving $FFFFF743 free to countdown. Eggman now displays his laugh instantly.

After Eggman's laugh, $FFFFF743 is set back to $17 and counts down again (Eggman's normal animation). We've done one more check to see if $FFFFF743 equals $17 and if so, to clear objoff_36(a0). Now that objoff_36(a0) is now 0 again, Eggman can now check to see when Sonic/Tails gets hurt again, and laugh when so.

Everything is fine once again!"

SCHG How-To Guide: Sonic the Hedgehog 2 (16-bit)
Fixing Bugs
Fix Demo Playback | Fix a Race Condition with Pattern Load Cues | Fix Super Sonic Bugs | Use Correct Height When Roll Jumping | Fix Jump Height Bug When Exiting Water | Fix Screen Boundary Spin Dash Bug | Correct Drowning Bugs | Fix Camera Y Position for Tails | Fix Tails Subanimation Error | Fix Tails' Respawn Speeds | Fix Accidental Deletion of Scattered Rings | Fix Ring Timers | Fix Rexon Crash | Fix Monitor Collision Bug | Fix EHZ Deformation Bug | Correct CPZ Boss Attack Behavior | Fix Bug in ARZ Boss Arrow's Platform Behavior | Fix ARZ Boss Walking on Air Glitch | Fix ARZ Boss Sprite Behavior | Fix Multiple CNZ Boss Bugs | Fix HTZ Background Scrolling Mountains | Fix OOZ Launcher Speed Up Glitch | Fix DEZ Giant Mech Collision Glitch | Fix Boss Deconstruction Behavior | Fix Speed Bugs | Fix 14 Continues Cheat | Fix Debug Mode Crash | Fix 99+ Lives | Fix Sonic 2's Sega Screen
Design Choices
Remove the Air Speed Cap | Disable Floor Collision While Dying | Modify Super Sonic Transformation Methods & Behavior | Enable/Disable Tails in Certain Levels | Collide with Water After Being Hurt | Retain Rings When Returning at a Star Post | Improve the Fade In\Fade Out Progression Routines | Fix Scattered Rings' Underwater Physics | Insert LZ Water Ripple Effect | Restore Lost CPZ Boss Feature | Prevent SCZ Tornado Spin Dash Death | Improve ObjectMove Subroutines | Port S3K Rings Manager | Port S3K Object Manager | Port S3K Priority Manager | Edit Level Order with ASM‎ | Alter Ring Requirements in Special Stages | Make Special Stage Characters Use Normal DPLCs | Speed Up Ring Loss Process | Change spike behaviour in Sonic 2
Adding Features
Create Insta-kill and High Jump Monitors | Create Clone and Special Stage Monitors | Port Knuckles
Sound Features
Expand Music Index to Start at $00 | Port Sonic 1 Sound Driver | Port Sonic 2 Clone Driver | Port Sonic 3 Sound Driver | Port Flamewing's Sonic 3 & Knuckles Sound Driver | Expand the Music Index to Start at $00 (Sonic 2 Clone Driver Version) | Play Different Songs Per Act
Extending the Game
Extend the Level Index Past $10 | Extend the Level Select | Extend Water Tables | Add Extra Characters | Free Up 2 Universal SSTs