Ground, a block and a wall, solid the way Mario's are
The jump lesson’s square in a small level of its own: ground, a block overhead and a wall. Play it: jump under the block, then walk into the wall and keep pushing. The program is 396 instructions in 1,078 bytes, built and checked the same way.
Play it here Change it on the desk The cartridge, to play anywhere that plays NES cartridges: solid.nes
On the screen
A jump ends where a block begins
When Mario jumps up into a block in Super Mario Bros., the jump simply stops: on the frame his head touches the block his upward speed is gone, and he falls back from right there. The block’s tiles go blank as it is bumped (the bump itself is drawn as a sprite) and come back, used, a few frames later. At a wall, his position holds while Right is still held: the game keeps taking his speed away, and it builds up again only to be taken away again a few frames later. This cartridge keeps its level as a grid of 16-pixel blocks in memory and looks it up at the square’s own edges, ahead of it as it walks, above it as it rises and below it as it falls, to do the same.
| this cartridge | Super Mario Bros. | |
|---|---|---|
| pixels a frame it was still rising when it touched the block | 3 | 3 |
| frames from the touch to standing on the ground again | 14 | 14 |
| frames from the touch until the block's tiles go blank | 1 | 0 |
| frames until they are drawn again, bumped | 13 | 16 |
| times the speed across was taken away at the wall, and frames apart | 24, every 7 | 21, every 7, 8, 9 |
| pushed back a pixel out of the wall | no | yes |
As written
The part of the program this lesson is about. The whole program is a plain text file: solid.s
rising:
LDA $15
STA $21
LDA $11
STA $20
JSR solid
BNE head
LDA $11
CLC
ADC #$0F
STA $20
JSR solid
BEQ flying
head:
PHA
LDA $21
AND #$F0
CLC
ADC #$10
STA $15
LDA #$00
STA $14
STA $16
STA $17
PLA
CMP #$02
BNE flying
JMP bump
;; The two bottom corners, one pixel under the square: the block under
;; either, in A.
feet:
LDA $15
CLC
ADC #$10
STA $21
LDA $11
STA $20
JSR solid
BNE footed
LDA $11
CLC
ADC #$0F
STA $20
JSR solid
footed:
RTS
;; A block bumped from below: bumped in the level at once, and its tiles
;; blank now and drawn bumped 12 frames later. Its tiles' place: the
;; name table, 64 for each row of blocks and 2 for each column.
bump:
LDX $22
LDA #$03
STA $0400,X
TXA
LSR A
LSR A
LSR A
LSR A
LSR A
LSR A
CLC
ADC #$20
STA $32
TXA
AND #$30
ASL A
ASL A
STA $33
TXA
AND #$0F
ASL A
ORA $33
STA $33
LDA #$01
STA $30
LDA #$0C
STA $31
RTSBefore this one: A stomp and a hit, told apart the way Mario does
Next: Walkers that turn at walls and at each other, the way Mario's Goombas do