Note that climbing has different mechanics. This explanation only
applies to walking and jumping.
"Velocity" here refers to a variable, found in the memory address $0053,
which tells how much will be added to the hero's X position at every frame.
Negative values mean leftwards motion, and positive values mean rightwards motion.
The high 4 bits refer to fullpixel motion, low 4 bits refer to subpixel motion. 2^4 is 16, thus divide the velocity by 16 to get the motion speed in pixels per frame.
Examples:
- Velocity of +16 means moving to the right at 1.0 pix/frame
- Velocity of −24 means moving to the left at 1.5 pix/frame (24 ∕ 16 = 1.5)
When the hero enters the view from somewhere, his velocity starts from
either +16 or −16, depending on whether he moves to the right, or to
the left, respectively.
When the player holds down the Left button:
If velocity ≥ 0, velocity decreases by 2. (Meaning that the hero accelerates towards the left)
If velocity = −24, nothing happens.
If velocity < 0 and ≠ −24, velocity decreases by 1.
When the player holds down the Right button:
If velocity ≤ 0, velocity increases by 2.
If velocity = 24, nothing happens.
If velocity > 0 and ≠ 24, velocity increases by 1.
When the player holds down both Left and right:
If velocity = 15, the velocity is set to 16.
If velocity = 16, nothing happens.
If velocity ≠ 15 or 16, velocity increases by 2.
When the player does not hold either Left or Right, or is holding Down:
If the player is jumping, the velocity is preserved. Otherwise:
The velocity increases or decreases by 1 towards zero.
However, when the player is fighting:
The Left and Right keys do not affect at all, except to change the hero's facing.
If the player is jumping, the velocity is preserved. Otherwise, it is set to 0 immediately.
The velocity is a 8-bit signed integer variable, meaning
that increasing +127 by 1 yields −128, and decreasing −128 by 1 yields +127.
Hold Left+Right, until the velocity is 16. Then hold only Right for 1 frame
(to get the velocity into 17), and then hold Left+Right again, until the
velocity is 127. Do not hold Right after that, or the velocity will wrap
into −128 (Right) or −127 (Left+Right).
If you do not press any key, the velocity will start decreasing towards zero.
To prevent the velocity from decreasing, jump. During the jump, the velocity is preserved. If you cannot jump, let the velocity decrease to +126, then press Right once to restore it into +127, and keep alternating it between +126 and +127.
If you hold Left, the maximum velocity you can get is −24. To achieve further speed, you must use the wrapping trick. Increase your velocity towards the
right until it reaches +126 or +127, then let it wrap by letting it increase by 1 (Right) or 2 (Left+Right). At that point, the hero will suddenly zoom to the left.
To prevent the velocity from falling (technically, increasing) from −128 to −127, use the same technique as with when going to the right: jump, or alternate.
Note that the velocity works the same way even when the hero is facing an obstacle,
so you can achieve the zipping speed to the left even by walking towards a wall on
the right side.
If you are standing on the ground, fight, and the velocity will drop to 0 immediately. You can then jump immediately if you want to continue moving slowly.
If you are jumping, you can only slow down by changing the velocity into either direction with Left / Right / Left+right.