Scene stack demo — title → counter → pause overlay.
Demonstrates the opt-in scene framework: the running game is split into three Scene structs that push and pop without a hand-rolled state machine. The demo is deliberately minimal — three text screens that swap when buttons are pressed — so you can read the dispatch shape without graphics noise getting in the way.
Flow:
title scene: shows "PRESS START". Start pushes counter.
counter scene: increments a number every frame. Select pushes pause (counter is suspended; numbers stop). Start pops back to title.
pause scene: shows "PAUSED". Select pops back to counter (numbers resume from where they stopped, no init replay).
- SNES Concepts
- Scene stack: push/pop without enum + switch boilerplate
init runs once on first push; resume after pop does not re-init
- Suspended scenes get no callbacks (pause overlay = counter frozen)
- Text rendering through the auto-flush NMI hook
- What to Observe
- Start on title: enters counter, numbers increment from 0
- Select while counting: PAUSED appears, numbers freeze
- Select in pause: counter resumes, numbers continue from where they stopped (no reset —
init was not re-called)
- Start while counting: pops back to title (counter discarded; pressing Start again restarts from 0 because counter's
init re-runs on the next push)
- Modules Used
- console, sprite, dma, background, text, input, scene
- See also
- scene.h, gameloop.h