Actions

SCHG How-to

Fix camera y position for Tails

From Sonic Retro

(Original guide by MoDule)

Due to an oversight in the camera system in Sonic 2, when Tails goes into a roll on the ground the camera will seem to jerk upward by a few pixels. The camera will also generally be slightly lower when playing as Tails.

This guide will show how to fix this.

Fixing the bug

Step 1

First, locate the ScrollVerti routine and comment out a few lines as follows:

;sub_D77A:
ScrollVerti:
	moveq	#0,d1
	move.w	y_pos(a0),d0

	; <-- add something here

	sub.w	(a1),d0		; subtract camera Y pos
	cmpi.w	#-$100,(Camera_Min_Y_pos).w ; does the level wrap vertically?
	bne.s	+		; if not, branch
	andi.w	#$7FF,d0
+
;	btst	#2,status(a0)	; is the player rolling?
;	beq.s	+		; if not, branch
;	subq.w	#5,d0		; subtract difference between standing and rolling heights
;+

Step 2

Now add the following at the line indicated above:

	moveq	#$13,d2		; set default character height
	sub.b	y_radius(a0),d2
	sub.w	d2,d0	; get difference to character's actual height

Step 3

Our new code relies on the character's y_radius being set, which it normally isn't, at this point, so let's fix that. Find InitPlayers. Here, we'll initialise the characters' y_radius before they do so themselves. Find this line:

	move.b	#ObjID_SpindashDust,(Sonic_Dust+id).w ; load Obj08 Sonic's spindash dust/splash object at $FFFFD100

Insert this instruction under it:

	move.b	#$13,(MainCharacter+y_radius).w		; Set Sonic's y-radius

Do this again with the same instruction under InitPlayers_Alone.

Step 4

New to initialise Tails' y-radius. Under InitPlayers_TailsAlone, find this instruction:

	move.b	#ObjID_SpindashDust,(Tails_Dust+id).w ; load Obj08 Tails' spindash dust/splash object at $FFFFD100

Under it, insert this instruction:

	move.b	#$F,(MainCharacter+y_radius).w		; Set Tails' y-radius

Step 5

One last thing: ScrollVerti runs before InitPlayers. We don't want that. Under Level_TtlCard, find this instruction:

	bsr.w	InitPlayers

Move it just above this instruction:

	jsrto	(DeformBgLayer).l, JmpTo_DeformBgLayer

Now InitPlayers will execute before ScrollVerti, making everything work as it should.

With this the camera will always have the right position for everyone.

The bug explained

Whenever a character's height changes, so does their y position. Jumping reduces the height and the character gets moved down a few pixels to the ground. The original code only took Sonic's height change into account, so when it compensates for the height change from jumping or rolling it does so incorrectly for Tails.

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 Spin Dash Code and Add Spin Dash Speeds | 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
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
Adding Features
Create Insta-kill and High Jump Monitors | Create Clone and Special Stage Monitors | Port Knuckles
Sound Features
Port Sonic 1 Sound Driver | Port Sonic 2 Clone Driver | Port Sonic 3 Sound Driver | Expand the Music Index to Start at $00 (Sonic 2 Clone Driver Version)
Extending the Game
Extend the Level Index Past $10 | Extend the Level Select | Extend Water Tables | Add Extra Characters | Free Up 2 Universal SSTs