Actions

SCHG How-to

Fix Boss Deconstruction Behavior

From Sonic Retro

Revision as of 11:11, 25 August 2018 by Black Squirrel (talk | contribs) (Text replacement - "\[\[Category:SCHG How-tos.*" to "")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

(Original guide by Esrael, Optimization by redhotsonic) Images can be found in the OP, until I can figure out how to put them on the wiki page. [1]

In Sonic 2, when a boss is defeated, it falls apart. Basically, it is supposed to send parts of the machine flying away as it explodes. If the machine faces one way, the parts fly one way. If the machine faces the opposite way, well, they fly out the opposite way! Obviously!

Well, apparently its not so obvious after all! There are 3 bosses in the game that behave somewhat wonky: The ARZ boss, the CNZ boss, and the MCZ boss. If they are facing left, they fall apart properly. However, if they face the other way, the pieces still fall as if the machine was facing left! This behavior is obviously wrong. The following code checks which way Dr. Robotnik is facing, and properly calls for the right routine so that his machine falls apart properly!

NOTE: This guide uses the 2007 Xenowhirl disassembly.

The Aquatic Ruin Zone boss

Let's start with the ARZ boss first. It has one piece that falls apart: its hammer. Facing left, the hammer flies to the left. Facing right, however, the hammer still falls to the left. Let's fix that.

Change:

loc_30850:
	cmpi.w	#$78,($FFFFF75C).w
	bgt.s	return_3088A
	subi.w	#1,y_radius(a0)
	move.l	objoff_3A(a0),d0
	move.w	objoff_2E(a0),d1

To this:

loc_30850:
	cmpi.w	#$78,($FFFFF75C).w
	bgt.s	return_3088A
	subi.w	#1,y_radius(a0)		; Make hammer fall to the left
	btst	#0,render_flags(a0)	; Is Eggman facing left?
	beq.s	+			; Yes?  Branch and continue
	addi.w	#2,y_radius(a0)		; So he's facing right?  Make hammer fall to the right instead
+
	move.l	objoff_3A(a0),d0
	move.w	objoff_2E(a0),d1

DONE!

The Casino Night Zone boss

Now, onto the CNZ boss. This one has two pieces that fall apart: its claws. Facing left, the claws fly outward. Facing right, however, the claws still fly in the same direction, causing them to fly inward. While it might not be as much of a nuance as the first bug we fixed, we can go ahead and fix the inconsistency anyways...

Change all of this:

loc_31EAE:
	cmpi.w	#$78,($FFFFF75C).w
	bgt.s	return_31F22
	subi.w	#1,status(a0)
	move.l	objoff_3A(a0),d0
	move.w	objoff_2E(a0),d1
	addi.w	#$38,objoff_2E(a0)
	ext.l	d1
	asl.l	#8,d1
	add.l	d1,d0
	move.l	d0,objoff_3A(a0)
	move.w	objoff_3A(a0),routine(a0)
	cmpi.w	#$6F0,routine(a0)
	blt.s	loc_31EE8
	move.w	#0,objoff_2E(a0)

loc_31EE8:
	cmpi.w	#$3C,($FFFFF75C).w
	bgt.s	return_31F22
	addi.w	#1,x_vel(a0)
	move.l	objoff_34(a0),d0
	move.w	objoff_30(a0),d1
	addi.w	#$38,objoff_30(a0)
	ext.l	d1
	asl.l	#8,d1
	add.l	d1,d0
	move.l	d0,objoff_34(a0)
	move.w	objoff_34(a0),y_vel(a0)
	cmpi.w	#$6F0,y_vel(a0)
	blt.s	return_31F22
	move.w	#0,objoff_30(a0)

return_31F22:
	rts

To this:

loc_31EAE:
	cmpi.w	#$78,($FFFFF75C).w
	bgt.w	return_31F22
	subi.w	#1,status(a0)		; Make catcher face to the left
	btst	#0,render_flags(a0)	; Is Eggman facing left?
	beq.s	+			; Yes?  Branch and continue
	addi.w	#2,status(a0)		; So he's facing right?  Make catcher face to the right instead
+
	move.l	objoff_3A(a0),d0
	move.w	objoff_2E(a0),d1
	addi.w	#$38,objoff_2E(a0)
	ext.l	d1
	asl.l	#8,d1
	add.l	d1,d0
	move.l	d0,objoff_3A(a0)
	move.w	objoff_3A(a0),routine(a0)
	cmpi.w	#$6F0,routine(a0)
	blt.s	loc_31EE8
	move.w	#0,objoff_2E(a0)

loc_31EE8:
	cmpi.w	#$3C,($FFFFF75C).w
	bgt.s	return_31F22
	addi.w	#1,x_vel(a0)		; Make catcher fall to the left
	btst	#0,render_flags(a0)	; Is Eggman facing left?
	beq.s	+			; Yes?  Branch and continue
	subi.w	#2,x_vel(a0)		; So he's facing right?  Make catcher fall to the right instead
+
	move.l	objoff_34(a0),d0
	move.w	objoff_30(a0),d1
	addi.w	#$38,objoff_30(a0)
	ext.l	d1
	asl.l	#8,d1
	add.l	d1,d0
	move.l	d0,objoff_34(a0)
	move.w	objoff_34(a0),y_vel(a0)
	cmpi.w	#$6F0,y_vel(a0)
	blt.s	return_31F22
	move.w	#0,objoff_30(a0)

return_31F22:
	rts

DONE!

The Mystic Cave Zone boss

Getting tired? Well, hold on. There is ONE MORE to go! This one is the Mystic Cave Zone boss, with the 2 drills that fly out when you defeat it. The behavior for these two pieces is exactly the same as the behavior for the claws on the previously mentioned boss, so lets go ahead and tackle this one as well.

Change all this:

loc_31358:
	cmpi.w	#$78,($FFFFF75C).w
	bgt.s	return_313C4
	subi.w	#1,status(a0)
	move.l	objoff_3A(a0),d0
	move.w	objoff_2E(a0),d1
	addi.w	#$38,objoff_2E(a0)
	ext.l	d1
	asl.l	#8,d1
	add.l	d1,d0
	move.l	d0,objoff_3A(a0)
	move.w	objoff_3A(a0),routine(a0)
	cmpi.w	#$6F0,routine(a0)
	blt.s	loc_31392
	move.w	#0,objoff_2E(a0)

loc_31392:
	addi.w	#1,x_vel(a0)
	move.l	objoff_34(a0),d0
	move.w	objoff_30(a0),d1
	addi.w	#$38,objoff_30(a0)
	ext.l	d1
	asl.l	#8,d1
	add.l	d1,d0
	move.l	d0,objoff_34(a0)
	move.w	objoff_34(a0),y_vel(a0)
	cmpi.w	#$6F0,y_vel(a0)
	blt.s	return_313C4
	move.w	#0,objoff_30(a0)

return_313C4:
	rts

To this:

loc_31358:
	cmpi.w	#$78,($FFFFF75C).w
	bgt.w	return_313C4
	subi.w	#1,status(a0)		; Make drill face to the left
	btst	#0,render_flags(a0)	; Is Eggman facing left?
	beq.s	+			; Yes?  Branch and continue
	addi.w	#2,status(a0)		; So he's facing right?  Make drill face to the right instead
+
	move.l	objoff_3A(a0),d0
	move.w	objoff_2E(a0),d1
	addi.w	#$38,objoff_2E(a0)
	ext.l	d1
	asl.l	#8,d1
	add.l	d1,d0
	move.l	d0,objoff_3A(a0)
	move.w	objoff_3A(a0),routine(a0)
	cmpi.w	#$6F0,routine(a0)
	blt.s	loc_31392
	move.w	#0,objoff_2E(a0)

loc_31392:
	addi.w	#1,x_vel(a0)		; Make drill fall to the left
	btst	#0,render_flags(a0)	; Is Eggman facing left?
	beq.s	+			; Yes?  Branch and continue
	subi.w	#2,x_vel(a0)		; So he's facing right?  Make drill fall to the right instead
+
	move.l	objoff_34(a0),d0
	move.w	objoff_30(a0),d1
	addi.w	#$38,objoff_30(a0)
	ext.l	d1
	asl.l	#8,d1
	add.l	d1,d0
	move.l	d0,objoff_34(a0)
	move.w	objoff_34(a0),y_vel(a0)
	cmpi.w	#$6F0,y_vel(a0)
	blt.s	return_313C4
	move.w	#0,objoff_30(a0)

return_313C4:
	rts

Done, and DONE!

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

|Fix Boss Deconstruction Behavior]]