Actions

SCHG How-to

Difference between revisions of "Fix Rexon crash"

From Sonic Retro

m (Text replacement - "<asm>" to "<syntaxhighlight lang="asm">")
Line 1: Line 1:
(Original guide by [[redhotsonic]])
+
(Original guide by [[redhotsonic]] GitHub expansion ny [[shadow05]])
  
 
On [[Hill Top Zone]], it is possible to crash the game when hitting Rexon (the plesiosaur-like badnik that sits in the lava). Conflicts in the code cause it to jump to a section of code earlier than it was meant to jump to. This results in invalid opcodes being processed and an eventual crash.
 
On [[Hill Top Zone]], it is possible to crash the game when hitting Rexon (the plesiosaur-like badnik that sits in the lava). Conflicts in the code cause it to jump to a section of code earlier than it was meant to jump to. This results in invalid opcodes being processed and an eventual crash.
 +
 +
===Xenowhirl===
  
 
Go to "loc_37454:" and you should see this:
 
Go to "loc_37454:" and you should see this:
Line 47: Line 49:
 
         bsr.w  JmpTo26_ObjectMove
 
         bsr.w  JmpTo26_ObjectMove
 
         bra.w  JmpTo39_MarkObjGone
 
         bra.w  JmpTo39_MarkObjGone
 +
</syntaxhighlight>
 +
 +
===GitHub/SNV===
 +
 +
Go to "Obj97_InitialWait:" and you should see this:
 +
 +
<syntaxhighlight lang="asm">
 +
; loc_37454:
 +
Obj97_InitialWait:
 +
    if gameRevision<2
 +
bsr.w Obj97_CheckHeadIsAlive
 +
subq.b #1,objoff_2A(a0)
 +
bmi.s Obj97_StartRaise
 +
    else
 +
; fixes an occational crash when defeated
 +
subq.b #1,objoff_2A(a0)
 +
bmi.s Obj97_StartRaise
 +
bsr.w Obj97_CheckHeadIsAlive
 +
    endif
 +
jmpto (MarkObjGone).l, JmpTo39_MarkObjGone
 +
</syntaxhighlight>
 +
 +
Change it to this.
 +
 +
<syntaxhighlight lang="asm">
 +
; loc_37454:
 +
Obj97_InitialWait:
 +
subq.b #1,objoff_2A(a0)
 +
bmi.s Obj97_StartRaise
 +
bsr.w Obj97_CheckHeadIsAlive
 +
    endif
 +
jmpto (MarkObjGone).l, JmpTo39_MarkObjGone
 +
</syntaxhighlight>
 +
 +
Then go to here
 +
 +
<syntaxhighlight lang="asm">
 +
; loc_37488:
 +
Obj97_RaiseHead:
 +
    if gameRevision<2
 +
bsr.w Obj97_CheckHeadIsAlive
 +
moveq #$10,d0
 +
add.w d0,x_vel(a0)
 +
subq.b #1,objoff_2A(a0)
 +
bmi.s Obj97_StartNormalState
 +
    else
 +
; fixes an occational crash when defeated
 +
moveq #$10,d0
 +
add.w d0,x_vel(a0)
 +
subq.b #1,objoff_2A(a0)
 +
bmi.s Obj97_StartNormalState
 +
bsr.w Obj97_CheckHeadIsAlive
 +
    endif
 +
jsrto (ObjectMove).l, JmpTo26_ObjectMove
 +
jmpto (MarkObjGone).l, JmpTo39_MarkObjGone
 +
</syntaxhighlight>
 +
 +
Change it to this
 +
 +
<syntaxhighlight lang="asm">
 +
; loc_37488:
 +
Obj97_RaiseHead:
 +
bsr.w Obj97_CheckHeadIsAlive
 +
moveq #$10,d0
 +
add.w d0,x_vel(a0)
 +
subq.b #1,objoff_2A(a0)
 +
bmi.s Obj97_StartNormalState
 +
jsrto (ObjectMove).l, JmpTo26_ObjectMove
 +
jmpto (MarkObjGone).l, JmpTo39_MarkObjGone
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Revision as of 21:32, 22 September 2017

(Original guide by redhotsonic GitHub expansion ny shadow05)

On Hill Top Zone, it is possible to crash the game when hitting Rexon (the plesiosaur-like badnik that sits in the lava). Conflicts in the code cause it to jump to a section of code earlier than it was meant to jump to. This results in invalid opcodes being processed and an eventual crash.

Xenowhirl

Go to "loc_37454:" and you should see this:

loc_37454:
        bsr.w   loc_3750C
        subq.b  #1,objoff_2A(a0)
        bmi.s   loc_37462
        bra.w   JmpTo39_MarkObjGone

That "branch to subroutine - loc_3750C" is what is causing the problem. It's happening too early. We need to move that command down a little bit. So change it to this:

loc_37454:
        subq.b  #1,objoff_2A(a0)
        bmi.s   loc_37462
        bsr.w   loc_3750C               ; Now moved here to fix Rexon crash
        bra.w   JmpTo39_MarkObjGone

One more, go to "loc_37488:" and you should see this:

loc_37488:
        bsr.w   loc_3750C
        moveq   #$10,d0
        add.w   d0,x_vel(a0)
        subq.b  #1,objoff_2A(a0)
        bmi.s   loc_374A0
        bsr.w   JmpTo26_ObjectMove
        bra.w   JmpTo39_MarkObjGone

Again, "branch to subroutine - loc_3750C" is too early. So change it to this:

loc_37488:
        moveq   #$10,d0
        add.w   d0,x_vel(a0)
        subq.b  #1,objoff_2A(a0)
        bmi.s   loc_374A0
        bsr.w   loc_3750C               ; Now moved here to fix Rexon crash
        bsr.w   JmpTo26_ObjectMove
        bra.w   JmpTo39_MarkObjGone

GitHub/SNV

Go to "Obj97_InitialWait:" and you should see this:

; loc_37454:
Obj97_InitialWait:
    if gameRevision<2
	bsr.w	Obj97_CheckHeadIsAlive
	subq.b	#1,objoff_2A(a0)
	bmi.s	Obj97_StartRaise
    else
	; fixes an occational crash when defeated
	subq.b	#1,objoff_2A(a0)
	bmi.s	Obj97_StartRaise
	bsr.w	Obj97_CheckHeadIsAlive
    endif
	jmpto	(MarkObjGone).l, JmpTo39_MarkObjGone

Change it to this.

; loc_37454:
Obj97_InitialWait:
	subq.b	#1,objoff_2A(a0)
	bmi.s	Obj97_StartRaise
	bsr.w	Obj97_CheckHeadIsAlive
    endif
	jmpto	(MarkObjGone).l, JmpTo39_MarkObjGone

Then go to here

; loc_37488:
Obj97_RaiseHead:
    if gameRevision<2
	bsr.w	Obj97_CheckHeadIsAlive
	moveq	#$10,d0
	add.w	d0,x_vel(a0)
	subq.b	#1,objoff_2A(a0)
	bmi.s	Obj97_StartNormalState
    else
	; fixes an occational crash when defeated
	moveq	#$10,d0
	add.w	d0,x_vel(a0)
	subq.b	#1,objoff_2A(a0)
	bmi.s	Obj97_StartNormalState
	bsr.w	Obj97_CheckHeadIsAlive
    endif
	jsrto	(ObjectMove).l, JmpTo26_ObjectMove
	jmpto	(MarkObjGone).l, JmpTo39_MarkObjGone

Change it to this

; loc_37488:
Obj97_RaiseHead:
	bsr.w	Obj97_CheckHeadIsAlive
	moveq	#$10,d0
	add.w	d0,x_vel(a0)
	subq.b	#1,objoff_2A(a0)
	bmi.s	Obj97_StartNormalState
	jsrto	(ObjectMove).l, JmpTo26_ObjectMove
	jmpto	(MarkObjGone).l, JmpTo39_MarkObjGone

Done! The rexon crash will no longer happen.

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