Difference between revisions of "Fix Debug Mode Crash"
From Sonic Retro
m (Text replacement - "\[\[Category:SCHG How-tos.*" to "") |
(→Explanation) |
||
Line 56: | Line 56: | ||
==Explanation== | ==Explanation== | ||
− | This crash occurs because in the [[Sonic the Hedgehog 2 (Simon Wai prototype)|Simon Wai Prototype]] it was a simple branch to command but later builds added this line. | + | This crash occurs because in the [[Sonic the Hedgehog 2 (Simon Wai prototype)|Simon Wai Prototype]] it was a simple branch to command, but later builds added this line. |
<syntaxhighlight lang="asm"> | <syntaxhighlight lang="asm"> | ||
Line 62: | Line 62: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | This is why the game crashes as the word operation is at an odd address. | + | This is why the game crashes as the word operation is at an odd address and the Mega Drive can't handle it. |
REV01 tried to fix this by branching to check for the next object but it removes a useful check. | REV01 tried to fix this by branching to check for the next object but it removes a useful check. |
Revision as of 22:29, 9 October 2018
(Method #1 by Esrael, Method #2 by Shadow05)
Bug
In Sonic 2 there's a bug the occurs in Debug Mode.
When Placing an object in Debug Mode after dying it crashes the game.
The culprit can be found at the BuildSprites_ObjLoop: or Debug_SpawnObject:
Esrael's Method
At Debug_SpawnObject: you'll see this
btst #button_C,(Ctrl_1_Press).w
beq.s Debug_ExitDebugMode
; Spawn object
jsr (SingleObjLoad).l
In between beq.s Debug_ExitDebugMode and ; Spawn object add this,
cmpi.b #$06,(MainCharacter+status).w ; is Sonic dead?
bne.s + ; if not, branch
rts ; return to prevent Sonic from placing objects.
+
Shadow05's Method
At BuildSprites_ObjLoop: you'll see this.
if gameRevision=0
; the additional check prevents a crash triggered by placing an object in debug mode while dead
; unfortunately, the code it branches *to* causes a crash of its own
tst.b id(a0) ; is this object slot occupied?
beq.w BuildSprites_Unknown ; if not, branch
tst.l mappings(a0) ; does this object have any mappings?
beq.w BuildSprites_Unknown ; if not, branch
else
; REV01 uses a better branch, but removed the useful check
tst.b id(a0) ; is this object slot occupied?
beq.w BuildSprites_NextObj ; if not, check next one
endif
Replace it with this.
tst.b id(a0) ; is this object slot occupied?
beq.w BuildSprites_NextObj ; if not, check next one
tst.l mappings(a0) ; does this object have any mappings?
beq.w BuildSprites_NextObj ; if not, check next one
Explanation
This crash occurs because in the Simon Wai Prototype it was a simple branch to command, but later builds added this line.
move.w (1).w,d0
This is why the game crashes as the word operation is at an odd address and the Mega Drive can't handle it.
REV01 tried to fix this by branching to check for the next object but it removes a useful check.
Esrael's method works as it checks if Sonic is dead before placing an object.
My method works as it checks if the object has any mappings.
|Fix Debug Mode Crash]]