When you start Super Mario Bros. on NES, the title screen shows 1 PLAYER GAME and 2 PLAYER GAME. If you wait for few seconds the Mario starts to play the first level of the game (this can be seen in YouTube video). Question is, how was the example play stored in the game data? Did they store some controller input and replay it as player input? Or did they store some snapshots and interpolated the steps between them?

I am asking this because NES ROMs were usually some kilobytes so storing the replay in a storage efficient way must been a priority for the developers.

  • 7
    It was replayed input. The demo responds when you hack around with the game's physics. (Storing snapshots would've been extremely wasteful for a game with deterministic physics.)
    – wizzwizz4
    Oct 19, 2022 at 20:38
  • 3
    @wizzwizz4: Note that the gameplay isn't exactly deterministic because of fractional positioning which doesn't get reset every time the demo is run.
    – supercat
    Oct 19, 2022 at 21:07
  • 5
    @supercat Now I'm really interested in the answer!
    – wizzwizz4
    Oct 19, 2022 at 21:51
  • 1
    I assume that game physics changes to counteract the frame rate without a change in the demo recording is also why the demo always does such an incredibly poor job of playing the game on PAL machines? youtube.com/watch?v=JOd-OIq9cUI is accurate to my recollection.
    – Tommy
    Oct 20, 2022 at 16:56
  • 1
    @Tommy yeah it seems that example play doesn't function identically with every system and/or run. Oct 21, 2022 at 14:19

1 Answer 1


I am asking this because NES ROMs were usually some kilobytes

The NES Cartridge for Super Mario Bros. is actually 40 KB, easily enough space for a bit of demo.

Question is, how was the example play stored in the game data?

A disassembled version is easy to google, here is the section that performs the demo:

8340: 01 80 02 81+ DemoActionData  .bulk   $01,$80,$02,$81,$41,$80,$01,$42,$c2,$02,$80,$41,$c1,$41,$c1,$01
                                    +      $c1,$01,$02,$80,$00
8355: 9b 10 18 05+ DemoTimingData  .bulk   $9b,$10,$18,$05,$2c,$20,$24,$15,$5a,$10,$20,$28,$30,$20,$10,$80
                                    +      $20,$30,$30,$01,$ff,$00

836b: ae 17 07     DemoEngine      ldx     DemoAction              ;load current demo action
836e: ad 18 07                     lda     DemoActionTimer         ;load current action timer
8371: d0 0d                        bne     DoAction                ;if timer still counting down, skip
8373: e8                           inx
8374: ee 17 07                     inc     DemoAction              ;if expired, increment action, X, and
8377: 38                           sec                             ; set carry by default for demo over
8378: bd 54 83                     lda     DemoTimingData-1,x      ;get next timer
837b: 8d 18 07                     sta     DemoActionTimer         ;store as current timer
837e: f0 0a                        beq     DemoOver                ;if timer already at zero, skip
8380: bd 3f 83     DoAction        lda     DemoActionData-1,x      ;get and perform action (current or next)
8383: 8d fc 06                     sta     SavedJoypad1Bits
8386: ce 18 07                     dec     DemoActionTimer         ;decrement action timer
8389: 18                           clc                             ;clear carry if demo still going
838a: 60           DemoOver        rts

As you can see, it's a replay, two bytes per action, one byte for the joypad bits, one byte for the delay until the next action (timing).

  • 6
    I wouldn't say "easily enough", given that there wasn't enough ROM to hold the what should have been the entire victory music, so the cartridge instead has to loop the first quarter of it.
    – supercat
    Oct 20, 2022 at 14:50
  • 40k can easily hold a demo... but not a Mario game!
    – user253751
    Oct 20, 2022 at 20:34
  • 3
    @supercat Music takes a lot more space than replying a couple of dozen actions. The demo is maybe 100 bytes (together with some other parts I haven't copied), that's really nothing if you've 40K.
    – dirkt
    Oct 20, 2022 at 20:35
  • @dirkt: Many games for 8-bit systems stored music quite compactly, and I would expect SMB would have followed that trend. The ending theme in the released game has only 14 notes in the melody, and the whole tune had an AABA format, so if the music player supports repeated sections, it could probably have been included if another 100 bytes were available.
    – supercat
    Oct 20, 2022 at 21:03
  • 1
    @supercat then rewrite the ROM to hold the entire victory music, at the expense of the demo, if you think it can be done easily...
    – dirkt
    Oct 21, 2022 at 6:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .