Actions

SCHG How-to

Fix Debug Mode Crash

From Sonic Retro

Revision as of 11:11, 25 August 2018 by Black Squirrel (talk | contribs) (Text replacement - "\[\[Category:SCHG How-tos.*" to "")

(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.

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

|Fix Debug Mode Crash]]