Actions

SCHG How-to

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.

The Fix

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:

return_3078C:
	rts

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

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 Spin Dash Code and Add Spin Dash Speeds | 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
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 | Add beta spindash to Sonic 2 | 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
Port Sonic 1 Sound Driver | Port Sonic 2 Clone Driver | Port Sonic 3 Sound Driver | Expand the Music Index to Start at $00 (Sonic 2 Clone Driver Version)
Extending the Game
Extend the Level Index Past $10 | Extend the Level Select | Extend Water Tables | Add Extra Characters | Free Up 2 Universal SSTs