A pause that holds the world still, the way Mario's does
The sound lesson’s square and tune, with a pause on Start. Play it, walk right, and press Start; try pressing it again straight away. The program is 313 instructions in 717 bytes, built and checked the same way.
Play it here The cartridge, to play anywhere that plays NES cartridges: pause.nes
On the screen
A pause draws nothing
Pausing Super Mario Bros. puts nothing on the screen: no word, no box. The game simply stops running its world, and the console keeps showing the last picture it was given. The music is cut on the same frame and a short sound plays instead. For a while after a press, Start is ignored, so a button that bounces or a second press that comes too soon cannot undo it. Unpausing plays the sound again, Mario moves at once, and the music comes back only when that wait is over. This cartridge pauses the same way, with a wait, a chime and a tune of its own. Only that shape is taken from the game; what either sound plays is not compared.
| this cartridge | Super Mario Bros. | |
|---|---|---|
| frames from Start to everything holding still | 0 | 1 |
| nothing moved while paused, with Right held and A pressed | yes | yes |
| frames Start is ignored after a press | 32 | 43 |
| frames in when a second Start was tried, and did nothing | 15 | 20 |
| writes to the picture while paused | 0 | 0 |
| two pictures taken while paused are identical | yes | yes |
| every sound cut on the press | yes | yes |
| notes in the pause sound, and frames between them | 3, 8 apart | 4, 6 apart |
| frames from Start to moving again | 0 | 1 |
| frames from unpausing until the music plays again | 32 | 43 |
As written
The part of the program this lesson is about. The whole program is a plain text file: pause.s
;; Start: a new press flips the pause, unless one came in the last 32
;; frames. Either way the sound is cut, the chime starts, and the tune's
;; next note is due as soon as it may play.
pause:
LDA $54
BEQ ready
DEC $54
RTS
ready:
LDA $02
EOR #$FF
AND $01
AND #$10
BEQ none
LDA $53
EOR #$01
STA $53
LDA #$20
STA $54
LDA #$00
STA $4015
STA $51
STA $52
STA $56
LDA #$03
STA $4015
STA $55
none:
RTS
;; The chime: three short notes on the second square channel, 8 frames
;; apart, rising.
chime:
LDA $55
BEQ quiet
DEC $56
BPL quiet
LDA #$07
STA $56
DEC $55
LDX $55
LDA #$9C
STA $4004
LDA #$00
STA $4005
LDA chimenote,X
STA $4006
LDA #$00
STA $4007
quiet:
RTS