Background:
I'm having a problem getting the jump curve correct for a retro platformer remake project of mine. The original game is for the NES, and the player's velocity is stored in two separate parts: one byte for the whole number and another for the fractional part.
Gravity is added to the player's Y speed at a rate of 0.25/frame.
When the player jumps, his Y speed is set to -4.64453125. The rest of the jump curve is left to gravity.
As the player ascends his vertical velocity converges to 0 at a rate of 0.25/frame. When the player's velocity reaches a value less than zero, however, the velocity changes following a different pattern. Instead of decreasing steadily by 0.25 every frame, it follows this pattern:
[1.75, -0.25, -0.25, -0.25, 1.75, -0.25, -0.25, -0.25, 1.75, ...]
It appears to have something to do with integer overflow.
Data:
Here is a dump of the data from the original. It's a table of the velocity.
Jump Curve
Y-Hi Y-Lo Decimal Change/Frame
4 165 4.64453125 ?
4 101 4.39453125 -0.25
4 37 4.14453125 -0.25
3 229 3.89453125 -0.25
3 165 3.64453125 -0.25
3 101 3.39453125 -0.25
3 37 3.14453125 -0.25
2 229 2.89453125 -0.25
2 165 2.64453125 -0.25
2 101 2.39453125 -0.25
2 37 2.14453125 -0.25
1 229 1.89453125 -0.25
1 165 1.64453125 -0.25
1 101 1.39453125 -0.25
1 37 1.14453125 -0.25
0 229 0.89453125 -0.25
0 165 0.64453125 -0.25
0 101 0.39453125 -0.25
0 37 0.14453125 -0.25
-1 229 -1.89453125 1.75
-1 165 -1.64453125 -0.25
-1 101 -1.39453125 -0.25
-1 37 -1.14453125 -0.25
-2 229 -2.89453125 1.75
-2 165 -2.64453125 -0.25
-2 101 -2.39453125 -0.25
-2 37 -2.14453125 -0.25
-3 229 -3.89453125 1.75
-3 165 -3.64453125 -0.25
-3 101 -3.39453125 -0.25
-3 37 -3.14453125 -0.25
-4 229 -4.89453125 1.75
-4 165 -4.64453125 -0.25
-4 101 -4.39453125 -0.25
-4 37 -4.14453125 -0.25
-5 229 -5.89453125 1.75
-5 165 -5.64453125 -0.25
-5 101 -5.39453125 -0.25
-5 37 -5.14453125 -0.25
-6 229 -6.89453125 1.75
Problem:
In my game I haven't been able to achieve this effect. When the velocity is less than zero it continues to decrease regularly by 0.25 rather than the pattern described above. Rather than storing the whole and fractional parts separately, I am storing them together in a single float.
How can this effect be achieved?