Difference between revisions of "Fix Debug Mode Crash"
From Sonic Retro
(Created page with "''(Method #1 by Esrael, Method #2 by Shadow05)'' ==Bug== In Sonic 2 there's a bug the occurs in Debug Mod...") |
(Oh right i forgot to add the reason why the fixes works.) |
||
Line 66: | Line 66: | ||
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. | ||
+ | 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. | ||
{{S2Howtos}} | {{S2Howtos}} | ||
[[Category:SCHG How-tos|{{PAGENAME}}]] | [[Category:SCHG How-tos|{{PAGENAME}}]] |
Revision as of 00:05, 25 August 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.
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.