Well, I'm gonna explain how this works exactly on game's code, and then I'll try to explain a bit more about it. (Credits to Tyler for finding out basically all the formulas I'm gonna show right now).
To understand this, we have to understand that Longjumping consists on 2 different states:
1. Releasing a Longjump
2. Being in air after a Longjump.
Being in air after a Longjump
I think the clearest way to show this is with some pseudocode.
Language: c
float hSpeed; //horizontal Speed from previous state (we assume this was already initialized).
float vSpeed; //vertical Speed from previous state.
if (hSpeed > 0)
{
if (hSpeed > 0.35) hSpeed -= 0.35;
else hSpeed = 0;
}
else
{
if (-0.35 > hSpeed) hSpeed += 0.35;
else hSpeed = 0;
}
int S0 = facingAngle - moveAngle; // angle goes from -32768 to 32767.
float F2 = joystickTilt / 32; //joystickTilt is just a value that goes from 0 to 32
hSpeed += F2 * cos(S0) * 1.5;
F0 = SM64Operation.sin(S0) * F2 * 10; //this is not used to calculate horizontal speed so ignore.
if (hSpeed > 48) hSpeed -= 1;
if (hSpeed < -16) hSpeed += 2;
calculateXSpeedAndYSpeed(); // Calculating x speed and y speed based on the horizontal speed you just got.
Now let's see what this means in the different scenarios:
- If you're forward longjumping, if your speed goes from 0.0001 to 48, your speed will increase at most 1.15.
- If your speed is higher than 48, your speed will increase at most 0.15.
- If you're backwards longjumping, if your speed goes from -16 to -0.0001, your speed will decrease at most -1.15.
- If your speed is lower than -16, your absolute speed will always decrease by at least 0.85 (your speed will increase by at least 0.85).
- When your speed is 47, if you do a perfect input, your speed will go to 47.15. Instead, you can force your joystick tilt to be worse to get a 47.9999 speed.
Releasing a longjump
This one is very simple, just multiply speed by 1.5, and if speed is higher than 48, cap speed to 48. As you can see there's no cap here for negative values, which makes BLJ possible.
Another important thing to say is, on the frame where you release a longjump, you get both releasing state and air state. You can notice this when you are forward longjumping at high speed, when you release a longjump you don't see a 48 but a 48.15 (speed was capped to 48, then you got a 0.15 increment from the air state).