How to fix Tails' respawn speeds in Sonic 2 and S3K

Discussion in 'Tutorials Archive' started by redhotsonic, May 26, 2012.

Thread Status:
Not open for further replies.
  1. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    How to fix Tails' respawn speeds


    The problem


    [​IMG]


    Bye, Tails! I'm leaving you behind.


    [​IMG]


    Oh, Tails! You're back!


    [​IMG]


    Keep up, Tails! Oh wait, you can't, you still think you're underwater!


    The problem here is when you and Tails enter the water, your speed, acceleration and deceleration are decreased, to give you the underwater physics. The problem is, if you lose Tails when underwater, when he next respawns (in Sonic 2, he only respawns when you've come out of water), he will still have his underwater speeds. Hence why Tails suddenly cannot keep up. This bug only occurs when you lose Tails underwater, and his underwater speed will remain this way until he enters/exits water again (no matter how many times you lose him and he respawns).


    The bug is NOT fixed in S3K either, but to fix it, you have to do an extra check, so follow the S3K fix.


    The fix


    Sonic 2


    This can be done in Xenowhirl's 2007 disassembly or the SVN disassembly.


    Go to "loc_1BC68:" and you'll see this:



    loc_1BC68:
    lea (Sonic_Stat_Record_Buf).w,a2


    move.b 2(a2,d3.w),d2


    andi.b #$D2,d2


    bne.s return_1BCDE


    or.w d0,d1


    bne.s return_1BCDE


    ; etc...



    Right after the 2nd "bne.s return_1BCDE" command, insert this:



    move.w #$600,(Tails_top_speed).w ; set Tails' top speed
    move.w #$C,(Tails_acceleration).w ; set Tails' acceleration


    move.w #$80,(Tails_deceleration).w ; set Tails' deceleration



    So, you have something like this:



    loc_1BC68: ; Fix for Tails' underwater respawn
    lea (Sonic_Stat_Record_Buf).w,a2


    move.b 2(a2,d3.w),d2


    andi.b #$D2,d2


    bne.s return_1BCDE


    or.w d0,d1


    bne.s return_1BCDE


    move.w #$600,(Tails_top_speed).w ; set Tails' top speed


    move.w #$C,(Tails_acceleration).w ; set Tails' acceleration


    move.w #$80,(Tails_deceleration).w ; set Tails' deceleration


    ; etc...



    Done


    Sonic 3 and Knuckles


    This can be done in SVN disassembly.


    Go to "loc_13CD2:" and you'll see this:



    loc_13CD2:
    lea (Stat_table).w,a2


    move.b 2(a2,d3.w),d2


    andi.b #$80,d2


    bne.s loc_13D42


    or.w d0,d1


    bne.s loc_13D42


    ; etc...



    Right after the 2nd "bne.s loc_13D42" command, insert this:



    btst #6,$2A(a0) ; test underwater flag
    bne.s +


    move.w #$600,($FFFFFEC0).w ; set Tails' top speed


    move.w #$C,($FFFFFEC2).w ; set Tails' acceleration


    move.w #$80,($FFFFFEC4).w ; set Tails' deceleration


    +



    So, you have something like this:



    loc_13CD2: ; Fix for Tails' underwater respawn
    lea (Stat_table).w,a2


    move.b 2(a2,d3.w),d2


    andi.b #$80,d2


    bne.s loc_13D42


    or.w d0,d1


    bne.s loc_13D42


    btst #6,$2A(a0) ; test underwater flag


    bne.s +


    move.w #$600,($FFFFFEC0).w ; set Tails' top speed


    move.w #$C,($FFFFFEC2).w ; set Tails' acceleration


    move.w #$80,($FFFFFEC4).w ; set Tails' deceleration


    +


    ; etc...



    Done


    The bug explained


    Now, when you lose Tails, he goes through lots of commands to move him about and to respawn him on certain conditions. BUT, none of these commands reset Tails' speeds. Because of this, when Tails respawns, he has the exact same speeds as when you lost him. So, if you lose him underwater, when he respawns, he will still have underwater speeds. So, all we've done here is added the command to reset his speeds. So...


    In Sonic 2, all we've done is set Tails to use his normal speeds no matter what when he respawns. This is fine because he only respawns when you're not in water, so he will always be out of water when he arrives. So we want his normal speed.


    In Sonic 3 and Knuckles, we have to do a check first to see if Tails is respawning in water or not. If not, do not bother resetting the speeds because he's going to spawn in water. On the other hand, if not in water, it will reset to his normal speeds because he's going to respawn out of water.


    That's it.


    Enjoy


    redhotsonic
     
    Last edited by a moderator: May 31, 2012
  2. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    415
    Nice to see another good guide from you, redhotsonic!


    I've never noticed this bug in S2/S3K before, because Tails always seemed to behave silly to me. =P


    Anyways, good to see one more bug found and fixed.


    Also, there is a small mistake in your guide (in S3K section):



    btst #6,$2A(a0) ; unset underwater flag



    Comment says 'unset', while command says 'test'.
     
  3. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    Small typo, lol. At least it doesn't affect the code itself, but I will change it anyway =P
     
  4. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    Bumped for your attention, in case anyone has applied this to their hack.


    Both S2 and S3K guides have been slightly edited. The commands to reset Tails' speeds have been moved a bit lower. That way, his speeds only get written once, rather than over and over and over until he stops flying. That way, this won't take as much processing time.
     
Thread Status:
Not open for further replies.