Fix camera y position for Tails
From Sonic Retro
Revision as of 10:11, 25 August 2018 by Black Squirrel (Text replacement - "\[\[Category:SCHG How-tos.*" to "")
(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
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 ;+
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
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.
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
One last thing: ScrollVerti runs before InitPlayers. We don't want that. Under Level_TtlCard, find this instruction:
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.
|Fix camera y position for Tails]]