SCHG How-to

Fix the death boundary bug

From Sonic Retro

(Original guide by MarkeyJester)

In Sonic 1, if Sonic is at the top of a level, and he dies causing him to fly up and above the top of the screen, rather than dropping back down to the bottom of the screen before resetting the level, or bringing in the Game Over/Time Over text, he will simply disappear. This bug is mostly noticeable in Labyrinth Zone, Act 1 at the beginning. This quick fix will ensure that Sonic drops back down before ending the level.

Explaining the issue

At the routine named "GameOver:", you will see the following code:

		move.w	($FFFFF72E).w,d0
		addi.w	#$100,d0
		cmp.w	$C(a0),d0
		bcc.w	locret_13900

What happens here is that it checks to see if Sonic has dropped 100 (hex) pixels below the Y boundary, however, the comparison here is "unsigned", meaning that if Sonic were to fall above the screen, and his Y position were to wrap around to FFFF and below to 8000, the engine believes that FFFF below to 8000 is a higher number than the level's Y boundary.

Fixing the issue

Traditionally, here, what you will want to do is treat FFFF - 8000 as a negative representative, to do that, you'll need to simply change the branch condition flag:

		bcc.w	locret_13900

"bcc", this is Branch on Carry Clear, it is equivalent to bhs (Branch on Higher than or the Same), this however is an unsigned condition, we need a signed condition, the following branches are signed equivalences of "bcc" and "bhs":

  • bge - Branch on Greater than or Equal
  • bpl - Branch on PLus

Using either bge or bpl instead of bcc, will ensure that if Sonic is to move out of the screen above, it will not count as wrapping to a higher Y position, but rather dropping to a lower negative Y position.

Another optional fix

As explained, the comparison is made with the level's Y boundary position, the problem with using the lower Y boundary is that if Sonic is to die at the top of the level, it will take a short while longer for the level to fade out and reset, than if he had died at the bottom of the level. Whether this is intentional or not, doesn't reflect the fact that it is rather odd considering you do not see the character falling all the way to the bottom.

To set it so that the level resets at the same rate regardless of the position, simply changing the RAM address FFFFF72E to RAM address FFFFF704 will check the screen's position, rather than the lower boundary of the level, as shown below:

		move.w	($FFFFF704).w,d0
		addi.w	#$100,d0
		cmp.w	$C(a0),d0
		bge.w	locret_13900

Again, this is an optional fix, as it isn't known whether dropping to the bottom of the entire level, is in fact intentional or not.

SCHG How-To Guide: Sonic the Hedgehog (16-bit)
Fixing Bugs
Fix Demo Playback | Fix a Race Condition with Pattern Load Cues | Fix the SEGA Sound | Display the Press Start Button Text | Fix the Level Select Menu | Fix the Hidden Points Bug | Fix Accidental Deletion of Scattered Rings | Fix Ring Timers | Fix the Walk-Jump Bug | Correct Drowning Bugs | Fix the Death Boundary Bug | Fix the Camera Follow Bug | Fix Song Restoration Bugs | Fix the HUD Blinking | Fix the Level Select Graphics Bug | Fix a remember sprite related bug
Changing Design Choices
Change Spike Behavior | Collide with Water After Being Hurt | Fix Special Stage Jumping Physics | Improve the Fade In\Fade Out Progression Routines | Fix Scattered Rings' Underwater Physics | Remove the Speed Cap | Port the REV01 Background Effects | Port Sonic 2's Level Art Loader | Retain Rings Between Acts | Add Sonic 2 (Simon Wai Prototype) Level Select | Improve ObjectMove Subroutines | Port Sonic 2 Level Select
Adding Features
Add Spin Dash ( Part 1 / Part 2 / Part 3 / Part 4 ) | Add Eggman Monitor | Add Super Sonic | Add the Air Roll
Sound Features
Expand the Sound Index | Play Different Songs Per Act | Port Sonic 2 Final Sound Driver | Port Sonic 3's Sound Driver | Port Flamewing's Sonic 3 & Knuckles Sound Driver | Change The SEGA Sound
Extending the Game
Load Chunks From ROM | Add Extra Characters | Make an Alternative Title Screen | Use Dynamic Tilesets | Make GHZ Load Alternate Art | Make Ending Load Alternate Art | Add a New Zone | Set Up the Goggle Monitor | Add New Moves | Add a Dynamic Collision System | Dynamic Special Stage Walls System | Extend Sprite Mappings and Art Limit | Enigma Credits | Use Dynamic Palettes
Convert the Hivebrain 2005 Disassembly to ASM68K
Split Disassembly Guides
Set Up a Split Disassembly | Basic Level Editing | Basic Art Editing | Basic ASM Editing (Spin Dash)

|Fix the death boundary bug]]