Fix ARZ boss sprite behavior
From Sonic Retro
(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.
Go to "loc_30770:" (part of the ARZ boss code) and you'll see this:
loc_30770: lea ($FFFFF740).w,a1 move.b #$31,3(a1) loc_3077A:
Under the "move.b #$31,3(a1)", insert this line:
move.b #1,objoff_36(a0) ; move 1 to checker
So you have something like this:
loc_30770: lea ($FFFFF740).w,a1 move.b #$31,3(a1) move.b #1,objoff_36(a0) ; move 1 to checker loc_3077A:
Next, go to "loc_3075C:" and you'll see this:
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
After the "bsr.w loc_3078E" command, insert these two lines:
tst.b objoff_36(a0) ; Is checker 0? bne.s loc_3077A ; If not, branch and do not check for Sonic/Tails hurt state
So you have something like this:
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
Next, go to "return_3078C:" and you'll see this:
Change it to this:
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
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!"