Difference between revisions of "Fix Debug Mode Crash"
From Sonic Retro
(→Explanation) |
(Heavily Updated) |
||
Line 1: | Line 1: | ||
''(Method #1 by [[User:Esrael|Esrael]], Method #2 by [[User:Shadow05|Shadow05]])'' | ''(Method #1 by [[User:Esrael|Esrael]], Method #2 by [[User:Shadow05|Shadow05]])'' | ||
− | |||
==Bug== | ==Bug== | ||
− | In [[Sonic the Hedgehog 2 (16-bit)|Sonic 2]] there's a | + | In [[Sonic the Hedgehog 2 (16-bit)|Sonic 2]], there's a very annoying revolving around Debug Mode. Simply, if you place an object after dying the game will crash. This guide will show you how to fix this. |
− | |||
− | |||
− | |||
− | |||
==Esrael's Method== | ==Esrael's Method== | ||
Line 22: | Line 17: | ||
<syntaxhighlight lang="asm"> | <syntaxhighlight lang="asm"> | ||
− | cmpi.b # | + | cmpi.b #6,(MainCharacter+status).w ; is Sonic dead? |
bne.s + ; if not, branch | bne.s + ; if not, branch | ||
rts ; return to prevent Sonic from placing objects. | rts ; return to prevent Sonic from placing objects. | ||
Line 28: | Line 23: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | == | + | ==My Method== |
At ''BuildSprites_ObjLoop:'' you'll see this. | At ''BuildSprites_ObjLoop:'' you'll see this. | ||
Line 56: | Line 51: | ||
==Explanation== | ==Explanation== | ||
− | + | The crash occurs because of this line. | |
− | |||
<syntaxhighlight lang="asm"> | <syntaxhighlight lang="asm"> | ||
move.w (1).w,d0 | move.w (1).w,d0 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | This was a simple "JmpTo" command in the [[Sonic the Hedgehog 2 (Simon Wai prototype)|Simon Wai Prototype]], but for some reason, this mystery line was added. This causes the Genesis to try to read off an odd-address, as the Genesis can't the game crashes immediately. REV01 tried to fix this by changing the branch to something better, however it removes a useful check still causing the game to crash. Esrael's fix makes Debug Mode check if the player has died while mine checks if the object has any mappings. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
{{S2Howtos}} | {{S2Howtos}} | ||
|{{PAGENAME}}]] | |{{PAGENAME}}]] |
Revision as of 06:19, 20 March 2019
(Method #1 by Esrael, Method #2 by Shadow05)
Contents
Bug
In Sonic 2, there's a very annoying revolving around Debug Mode. Simply, if you place an object after dying the game will crash. This guide will show you how to fix this.
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 #6,(MainCharacter+status).w ; is Sonic dead?
bne.s + ; if not, branch
rts ; return to prevent Sonic from placing objects.
+
My 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
The crash occurs because of this line.
move.w (1).w,d0
This was a simple "JmpTo" command in the Simon Wai Prototype, but for some reason, this mystery line was added. This causes the Genesis to try to read off an odd-address, as the Genesis can't the game crashes immediately. REV01 tried to fix this by changing the branch to something better, however it removes a useful check still causing the game to crash. Esrael's fix makes Debug Mode check if the player has died while mine checks if the object has any mappings.
|Fix Debug Mode Crash]]