Fix Rexon crash
From Sonic Retro
(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.