Sonic and Sega Retro Message Board: How the Drop Dash works in Mania - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
Page 1 of 1
    Locked
    Locked Forum

How the Drop Dash works in Mania So you can properly implement it in your hacks/fangames.

#1 User is online MainMemory 

Posted 25 November 2017 - 02:07 AM

  • Every day's the same old thing... Same place, different day...
  • Posts: 4204
  • Joined: 14-August 09
  • Gender:Not Telling
  • Project:SonLVL
  • Wiki edits:1,339

Now, while I haven't actually played any hacks or fangames that have the Drop Dash in them, I have a feeling that few if any of them are implementing it in exactly the same way that Sonic Mania does, simply because of how complex the calculations actually are. This post is meant to explain the mechanics and physics behind the Drop Dash, I will not give you ASM code to paste into your hack with no effort. At the bottom of the post, I have a Sonic 2 ROM with Drop Dash implemented according to this information as an example.

This first part of code runs when Sonic is jumping. If the jump button is pressed, the jump ability flag is 1 (meaning you can use an ability), Sonic does not have an elemental shield power, and the moveset is set to Mania, the jump ability flag is set to 2 to signify the initiation of a Drop Dash. Then, if the jump ability flag is greater than 1 and the jump button is held, the flag's value is incremented each frame until the result is greater than 21 (meaning a 20-frame waiting period), at which point the Drop Dash is properly started, playing the sound effect, changing Sonic's animation, and changing his movement routine (you may use a flag instead).
Now, if the jump button is released before Sonic hits the ground, the Drop Dash is cancelled, restoring the normal rolling sprites and putting him in a falling state and setting the jump ability flag to 0 so he cannot use abilities.
When Sonic hits the ground with a Drop Dash charged, first the game performs the regular landing speed calculations so his ground speed is set according to X and Y speed in the air and the slope of the ground. The game checks if you are holding Left or Right, and sets Sonic's current direction to the direction you are holding.
Then, it sets two variables depending on whether you are currently Super Sonic, which I will call dashspeed and maxspeed. Sonic Mania uses 32-bit speed values, but for convenience I will use 16-bit values with decimal versions in parentheses. If you are not Super, dashspeed is set to $800 (8.0) and maxspeed is set to $C00 (12.0); if you are Super, dashspeed is set to $C00 (12.0) and maxspeed is set to $D00 (13.0).
The dashspeed and maxspeed values and the comparisons in the next lines are all negated if your direction is left, but otherwise the math is the same as when your direction is right. If your X speed (in the air) is greater than or equal to 0, your ground speed (inertia) is divided by four (>> 2) and added to the dashspeed, then it is capped to maxspeed. Otherwise, if your angle is not 0 (on a slope), your ground speed (which is moving backwards because the first check failed) is cut in half and added to the dashspeed, resulting in a slower than normal dash. If you're moving backwards on flat ground, your ground speed is simply set to dashspeed.

Here's some code directly from the game for when you hit the ground while charging a Drop Dash:
    v0->JumpAbilityFlag = 0;
    if ( v0->RightHeld == 1 )
      v0->Direction = 0;
    if ( v0->LeftHeld == 1 )
      v0->Direction = 1;
    if ( v0->SuperMode == 2 )
    {
      dashspeed = 0xC0000;
      maxspeed = 0xD0000;
    }
    else
    {
      dashspeed = 0x80000;
      maxspeed = 0xC0000;
    }
    if ( v0->Direction )
    {
      if ( v0->XSpeed <= 0 )
      {
        v6 = -maxspeed;
        v7 = (v0->GSpeed >> 2) - dashspeed;
        v0->GSpeed = v7;
        if ( v7 < v6 )
          v0->GSpeed = v6;
        goto LABEL_25;
      }
      if ( v0->GroundAngle )
      {
        v0->GSpeed = (v0->GSpeed >> 1) - dashspeed;
        goto LABEL_25;
      }
      dashspeed = -dashspeed;
    }
    else
    {
      if ( v0->XSpeed >= 0 )
      {
        v5 = dashspeed + (v0->GSpeed >> 2);
        v0->GSpeed = v5;
        if ( v5 > maxspeed )
          v0->GSpeed = maxspeed;
        goto LABEL_25;
      }
      if ( v0->GroundAngle )
      {
        v0->GSpeed = dashspeed + (v0->GSpeed >> 1);
        goto LABEL_25;
      }
    }
    v0->GSpeed = dashspeed;
LABEL_25:



And here's the Sonic 2 with Drop Dash ROM: http://mm.reimuhakur.../S2DropDash.zip
I've also removed the air speed cap and disabled the rolljump behavior.
This post has been edited by MainMemory: 26 November 2017 - 12:46 PM

#2 User is offline Zphase 

Posted 25 November 2017 - 11:51 PM

  • Posts: 8
  • Joined: 19-June 17
I played to Metropolis Zone and the drop dash in Sonic 2 is a lot of fun, thanks!
I guess you mentioned this is an example.. but any plans to give Super Sonic a drop dash sprite?
This post has been edited by Zphase: 25 November 2017 - 11:51 PM

#3 User is online MainMemory 

Posted 26 November 2017 - 01:04 AM

  • Every day's the same old thing... Same place, different day...
  • Posts: 4204
  • Joined: 14-August 09
  • Gender:Not Telling
  • Project:SonLVL
  • Wiki edits:1,339
Whoops, two of Sonic's animations are missing from the end of Super Sonic's list. I've fixed it now.

#4 User is offline Crappy Blue Luigi 

Posted 26 November 2017 - 01:42 PM

  • just a blue bud
  • Posts: 690
  • Joined: 14-March 09
  • Gender:Female
  • Location:Vera City
  • Wiki edits:2

View PostMainMemory, on 25 November 2017 - 02:07 AM, said:

I've also ... disabled the rolljump behavior.

I think this is the biggest issue with prior attempts at coding the drop dash in rom hacks. While there are a lot of factors of its functions in Mania that go into why it's fun (and habit-forming) to use, the ability to control your air movement from a drop dash jump and even turn yourself around to drop dash in the other direction makes a huge difference in its utility. To my knowledge, every hack submitted to the hacking contest or expo this year that added the drop dash missed this bit, and it just makes it... less fun.

#5 User is offline KingofHarts 

Posted 07 December 2017 - 03:27 AM

  • Posts: 1610
  • Joined: 07-August 10
  • Gender:Male
  • Project:Project Sonic 8x16
  • Wiki edits:1

View PostCrappy Blue Luigi, on 26 November 2017 - 01:42 PM, said:

View PostMainMemory, on 25 November 2017 - 02:07 AM, said:

I've also ... disabled the rolljump behavior.
I think this is the biggest issue with prior attempts at coding the drop dash in rom hacks. While there are a lot of factors of its functions in Mania that go into why it's fun (and habit-forming) to use, the ability to control your air movement from a drop dash jump and even turn yourself around to drop dash in the other direction makes a huge difference in its utility. To my knowledge, every hack submitted to the hacking contest or expo this year that added the drop dash missed this bit, and it just makes it... less fun.


I completely agree with this. Personally I didn't care for seeing that control lock removed back when they did it in CD... but I get why double jumps in Sonic 3 essentially negated it. It made sense. Makes just as much sense with the drop dash.
This post has been edited by KingofHarts: 07 December 2017 - 03:27 AM

#6 User is offline Okamikurainya 

Posted 15 December 2017 - 05:49 AM

  • Posts: 209
  • Joined: 12-April 13
  • Gender:Male
  • Location:Somewhere in Africa
  • Project:Sonic: Time Attacked - MAX
Also, can't forget that while Super the DropDash causes the screen to shake as well as playing the Peelout release sound rather than the normal one. That may not be related to the physical effects but it's still a little thing that adds to making it feel authentic.

Thanks! This guide was a massive help for me, until I read this I assumed that the frame timer was actually a detection for a downwards yspeed. :v:

#7 User is online MainMemory 

Posted 26 December 2017 - 03:30 PM

  • Every day's the same old thing... Same place, different day...
  • Posts: 4204
  • Joined: 14-August 09
  • Gender:Not Telling
  • Project:SonLVL
  • Wiki edits:1,339
Since it's related to the topic, I'll just put this here: Drop Dash in S3K.


#8 User is offline EnderWaffle 

Posted 01 January 2018 - 11:07 PM

  • Ghostly Friend
  • Posts: 12
  • Joined: 13-August 15
  • Gender:Male
  • Location:New Donk City, Metro Kingdom
  • Project:Sonic Legends
Even better! Now the next step up is Drop Dash in SA1 *runs*
I got all the way to Launch Base, and I gotta say, this is a much better recreation of the original style than the handful other hacks I've seen with the Drop Dash, which just give you a chargeable Spin Dash in each jump. Bravo!

#9 User is offline AeroGP 

Posted 24 January 2018 - 12:21 PM

  • Posts: 120
  • Joined: 02-November 06
  • Gender:Male
  • Location:Los Angeles, CA
  • Project:Sonic for GameMaker: Studio
  • Wiki edits:8
Hey, late response but I wanted something clarified:

View PostMainMemory, on 25 November 2017 - 02:07 AM, said:

[...] If your X speed (in the air) is greater than or equal to 0, your ground speed (inertia) is divided by four (>> 2) and added to the dashspeed, then it is capped to maxspeed. Otherwise, if your angle is not 0 (on a slope), your ground speed (which is moving backwards because the first check failed) is cut in half and added to the dashspeed, resulting in a slower than normal dash.


That sounds like it would be faster than normal, since adding half of something to something else is greater than adding only a fourth of it, or adding nothing at all. I also notice that this speed addition is not capped by max_speed the way the first check is. If slowing the dash down was the intent, I believe this needs to be re-evaluated ...

EDIT: Nevermind. I realized that the speed would negative in the second case, so it would subtract from the dash speed, not add to it. Silly me.
This post has been edited by AeroGP: 24 January 2018 - 12:22 PM

#10 User is offline Caverns 4 

Posted 08 February 2018 - 12:08 AM

  • Posts: 338
  • Joined: 07-December 12
  • Gender:Male
  • Project:Sanik Quest: Journey To The Right
This is impressive and helpful, nice code hunting!

Now just to get it working in my hack. Which is a chore in itself.

#11 User is offline Zeoinx 

Posted 02 September 2018 - 06:25 PM

  • Posts: 36
  • Joined: 24-March 08
  • Gender:Male
I always assumed the drop dash acting in a simlar manner to that of a normal spin dash, execpt you only spin up once, and auto go when you hit the ground.

Page 1 of 1
    Locked
    Locked Forum

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users