Difference between revisions of "Fix Boss Deconstruction Behavior"
From Sonic Retro
m (Text replacement - "redhotsonic" to "redhotsonic") |
|||
Line 1: | Line 1: | ||
− | (Original guide by [[Esrael]], Optimization by [[User:Redhotsonic|redhotsonic]]) | + | (Original guide by [[User:Esrael|Esrael]], Optimization by [[User:Redhotsonic|redhotsonic]]) |
Images can be found in the OP, until I can figure out how to put them on the wiki page. [http://forums.sonicretro.org/index.php?showtopic=29029&view=findpost&p=691513] | Images can be found in the OP, until I can figure out how to put them on the wiki page. [http://forums.sonicretro.org/index.php?showtopic=29029&view=findpost&p=691513] | ||
Revision as of 14:01, 15 April 2018
(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!