Running, and why a running jump goes higher
The jump lesson’s square with B to run. Running is faster, and a jump taken while running starts faster and pulls harder, so it goes higher and still comes down in good time. The program is 276 instructions in 616 bytes, built and checked the same way.
Play it here The cartridge, to play anywhere that plays NES cartridges: run.nes
On the screen
Two jumps, chosen by the speed
Holding B in Super Mario Bros. raises the top speed and the speed-up toward it. Jumping at different speeds showed that there are two jumps, not one that grows with speed: up to walking speed, one; any faster, the other, which starts faster and pulls harder on the way up and down. So a running jump is not a walking jump pushed further; it is a different set of numbers, picked at the moment of the jump. This cartridge picks the same way.
| this cartridge | Super Mario Bros. | |
|---|---|---|
| top walking speed, pixels a frame | 1.5 | 1.5 |
| top running speed, and frames of B to reach it | 2.5, 45 | 2.5, 45 |
| walking jump: first speed up, pull with A held, pull after | 4, 30/256, 96/256 | 4, 30/256, 96/256 |
| running jump: the same | 5, 40/256, 144/256 | 5, 40/256, 144/256 |
| rise with A held 20 frames: walking, running | 63, 75 | 63, 75 |
| speed before the jump (sixteenths): the fastest light jump, the slowest strong one | 24.5, 25.38 | 24, 25 |
As written
The part of the program this lesson is about. The whole program is a plain text file: run.s
;; Up and down: a new press of A on the ground starts a jump.
jump:
LDA $03
BNE air
LDA $02
EOR #$FF
AND $01
AND #$80
BEQ done
;; How fast it was going chooses the jump: $18 is 0 for the light one,
;; 1 for the strong one (speed 25/16 or more).
LDA #$00
STA $18
STA $16
LDA $13
CMP #$01
BCC light
BNE strong
LDA $12
CMP #$90
BCC light
strong:
INC $18
LDA #$FB
STA $17
JMP leapt
light:
LDA #$FC
STA $17
leapt:
LDA #$01
STA $03