Skip to content

Run the games through a game host with its screens, high scores and the Arcade's live host - #84

Merged
AnakinRaW merged 31 commits into
mainfrom
claude/game-host-plan
Dec 5, 2026
Merged

AnakinRaW merged 31 commits into
mainfrom
claude/game-host-plan

Conversation

@AnakinRaW

@AnakinRaW AnakinRaW commented Dec 4, 2026 •

Copy link
Copy Markdown
Owner

Summary

The firmware gets its game host. A GameHost runs the games through their phases, hands them the driver events and the time, and keeps the list of failed devices. HostScreens leads the player around the games on the touch display: game choice, curtain and launch card, the menu at the right edge, Settings, Service, the warning lights, and after a game Game over, the players' names and the high scores. FREE PLAY stands in as the built-in game until the loader of game.yml brings real games.

What changes

Game abstraction and host

  • src/game/: Game, Machine and the list GAMES in games.cpp, which main.cpp and the Arcade's module both take.
  • src/host/game-host.*: phases, dispatch, fault list, arming hook, launch once the screen has settled, the boot film, and the card guard for the running game's directory. A game can be held in Post-game while the screens ask for names.
  • HostAccess classes open the components' host-only functions, so a game cannot call them through its Machine.
  • main.cpp runs the host in the main loop and starts the servo, the break beam and the toggle switch. The toggle switch reads pin 5, as the bench is wired today.

Host screens

  • Game choice with the built-in game first and card games that need a newer firmware, a mute speaker beside the gear, and each game's best score on its card.
  • Curtain, launch card, the menu at the right edge, End game.
  • Settings with Sound, Lights and Options, saved in the config. The game choice plays the machine's theme, and the effects' level plays the bumper sound.
  • Service with the lights adapter and a touch calibration by four taps.
  • The restart notice after a crash, a coil left on or a hang, the start report, and the warning lights. A full green bulb means the device confirms it works, and a green ring means it reports no fault without confirming. Neon red means failed.
  • After a game: Game over, a name for every player from the known names or the keyboard, and the high scores with a countdown to Play again. Lists stand in /games/<id>/highscores.yml and names in /names.yml. Both are read right after the config at the start, since libyaml finds no room on the heap later. A file that could not be read is never written.
  • End game in the menu ends without a score, as real machines do.

Components and tools

  • Sounds play the machine's sounds from /audio/.
  • Touch gives its raw reading and takes new edges while running. Config tells whether its file was read, missing or rejected.
  • Watchdog tells whether a crash or a watchdog reset came before the start. DeviceMonitor tells which devices a source watches.
  • YamlTree quotes a text that starts with a question mark, which libyaml would read as a key inside braces.
  • firmware/tools/upload-check.py fails an upload that reached no Teensy. PlatformIO's teensy-gui upload reported success with no board attached.
  • The driver tick holds twelve slots. The drivers on main and in the driver branches take eight.
  • firmware/tools/libyaml-buffers.py sets libyaml's input buffer to 1 KB before every build, so a parse takes about 4 KB of heap and finds it at any time.

Arcade

  • The module runs the firmware's GameHost and HostScreens with the firmware's games. npm run wasm lists them in src/wasm/firmware-games.json, the Games page shows them under Firmware, and a firmware game picked in the Studio's Screens runs in the real host. The view gallery stays.
  • The resource page knows the sources of theme.wav and bumper.wav.

Testing

  • All 35 computer test programs pass, among them the new high-scores and the game-host rows for every screen flow.
  • Teensy tests run: watchdog.crash, watchdog.start-up, touch.*, config.*, and the game-host bench tests switch, menu and menu-switch.
  • Release firmware and test image build, and RAM1 keeps its floor. clang-tidy, the test coverage check and figcheck report nothing.
  • The Arcade's 316 tests and its build pass.
  • On the bench: the flows after a game, the high scores across a restart, the mute across games, and the card service refusing a PUT into the running game's directory while accepting it after End game.

Not in this PR

  • H10: the contacts with the hit targets, the solenoids' arming hook and the magnetic rotary sensor join the host once their branches are merged. The toggle switch moves to E-3 of the port expander with the contacts branch, before the backlight takes pin 5.

🤖 Generated with Claude Code

AnakinRaW and others added 30 commits December 3, 2026 16:31
Game holds the lifecycle the host runs a game through, from start() to
stop(), with its players and their scores. Machine gives a game the screen,
the sounds, the lamps, the video player and the file system. GAMES lists the
games the firmware carries, with the built-in game first. The game
abstraction's interfaces link both headers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The screen, the sounds, the video player and the file system keep the
functions only the game host calls private and open them to ScreenAccess,
SoundsAccess, VideoPlayerAccess and FileSystemAccess in src/host. The test
programs, the Arcade's stand-in host and the cost bench call them there, in
place of the classes named GameHost and VideoPlayer each of them declared
for itself, which would have met the real GameHost in the test image. The
stand-in host in main.cpp moves into an anonymous namespace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The cost bench builds every file of src/, core/watchdog.cpp among them,
which includes WDT_T4. The stream bench takes all of io/, where i2c-bus.cpp
includes Wire. Both take the library at the version the root project pins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…parse

The test task's stack lies in RAM1, as the firmware's main task's does, in
place of 32 KB of RAM2's heap. The lighting program's counts and ramp share
one driver with the longest chain on chain F, so the heap holds one frame
of 48.7 KB for both. The event-queue program's queues lie in the PSRAM.
With that, video-player.frames, lighting.ramp and both config tests find
their memory in a run of every test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The card service refuses PUT, MOVE and DELETE in a directory that guard()
names, of the directory itself and of a directory that holds it. Every other
path, CHECK and reading go on while a game runs, since the streams of sound
and video outrank the service's requests and their rings and read-ahead carry
them through the card's longest stall.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GameHost hands every driver event to its components in order and their
pinball events to the running game, and copies TOGGLE_SWITCHED from the
toggle switch to the game. It keeps the failed devices out of the game,
restarts the display once the touch controller answers again, plays the
boot film before the first game and moves each game through Intro, Play
and Post-game. A launched game starts once the screen has settled. Links
arm the solenoids in Play and guard the running game's directory on the
card. FreePlay is the built-in game until one with rules replaces it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… beam

main.cpp hands every driver event to the host and updates it in every pass,
in place of its stand-in for the host. The host gets the screen, the sounds
and the video player, plays the boot film after host.boot_film and starts
FREE PLAY, and the card service guards the running game's directory. The
break beam and the servo start with the other drivers, the servo with its
angles and speed from the config, and the device monitor watches both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The touch driver reads a controller that did not answer at begin() as it
reads one that did. Past 100 ms it counts as failed, and its first answer
recovers it, so the host sets the display up again. Before, the driver never
asked again, and a module powered after the Teensy stayed white.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The last fold of a curtain drew past its right edge, inside the area its
shadow draws in, so the open left curtain left a red stripe at the screen's
left edge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
teensy41-tests.ld is teensy41.ld with lines added, and it lacked the lines
that keep the code and the tables of libyaml, the YAML tree and the config
in the flash. The test image now has their room in RAM1 again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HostScreens shows the game choice after the boot film, with the firmware's
games first and the card's other games as ones that cannot start yet, or the
notice when no card is in. Play closes the curtain, starts the game behind
it and opens on the launch card. During a game the menu follows the swipe
from the right edge, End game asks first and returns to the game choice, and
the status bulb and the toasts show failed devices. The game host gets stop()
and ready(), and begin() can leave the first start to the screens. LVGL's
heap grows to 96 KB, since the menu and the curtain left too little for a
drawn layer. The test image's game-host program carries the bench tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A finger that drags the open drawer to the right moves it with itself.
Let go past half the drawer's width it closes, before that it snaps open
again, and a drag chooses no row. During a game a tap beside the open menu
closes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LVGL keeps a control pressed while the finger slides off and clicks it on
the lift wherever the finger is. The screen now ends such a press without
a click when the finger leaves the screen beside the control it came down on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The valance stood over the screen's top while the curtain was open, so it
covered the host's pages and the menu's header with its mute and close.
The curtain now hides once it has opened and shows again when it closes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The host plays the game choice's music and the sample of the effects'
level while any game's directory is in use, so Sounds opens them by
their full path through two calls that only the host reaches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Settings leads from the game choice to Sound, Lights and Options, and the
menu's Sound and Lights rows open their pages over the running game. The
levels and the options stand in the config and outlast a game switch, and
the menu's mute silences every channel. The game choice plays the theme
below the music's level, the effects' level plays the intro's bumper once
it rests, and free play lights the left perimeter in a rainbow. The test
image keeps the host's fonts in the flash and its program objects in the
PSRAM.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Touch::reading() gives the controller's readings before the mapping, and
configure() takes new edges while the driver runs, which the next read
maps with. Config::source() tells a read file from a missing and a
rejected one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Service names the firmware and where the config came from, and saves the
lights adapter for the next start after its warning. The touch
calibration takes a tap on each of four marks near the corners, works out
the readings at the picture's edges and hands them to the touch driver and
the config at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…devices a source watches

Watchdog::lastByWatchdog() and lastCrashed() keep what begin() read from the reset status and from CrashReport, so the host can name a restart without a noted cause. DeviceMonitor::watches() tells whether a source reports on a device.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'s screens

A restart by a crash, a coil left on, a hang or the watchdog shows a notice before the game choice, and a device failed at the start shows the start report. The warning lights show a tile per device: full green where the driver confirms it works, a green ring where it cannot, neon red with the fault dialog where it failed. The warnings open from their count in the header.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
libyaml reads a question mark at the start of a value inside braces or brackets as the mark of a name, so "???" written there unquoted did not read back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Teensy Loader takes the file and PlatformIO reported success whether a Teensy took it or not. upload-check.py now requires a Teensy on USB before the upload and its serial port to go and come back during it, for the firmware, the test image and every bench program.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…high scores

After a game the host shows Game over, asks every player for a name from the known names or on the keyboard, and shows the game's high scores with a countdown to Play again. The lists stand in /games/<id>/highscores.yml and the names in /names.yml. The host reads both right after the config at the start, while the heap has room for libyaml, and never writes a file it could not read. The game choice gets a speaker that mutes the sound and shows each game's best score. FREE PLAY scores taps and moves of the toggle switch, which main.cpp now starts, and ends on a resting finger.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The display sends its pixels one ahead of the panel's kept pixel. The test image keeps this branch's memory layout: the test task's stack lies in RAM1, which leaves RAM2's heap room for the card service's chunk, and the event-queue program's queues lie in the PSRAM. Main's move of both into RAM1 left RAM1 30.6 KB short of nothing beside the stack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
firmware/card-resources.json lists /audio/theme.wav and /audio/bumper.wav, and the Arcade's resource page found no source for them, so it could not copy them onto a card.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Arcade's module runs the firmware's GameHost and HostScreens with the games of src/game/games.cpp, which main.cpp takes as well. npm run wasm lists those games, the Games page shows them under Firmware, and a firmware game picked in the Studio's Screens runs in the real host. The stand-in for the host's menu stays for the gallery's scenes of a running game, and a waiting card request is served at once in the browser.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The drivers on main and in the driver branches take all eight slots between them, so the next driver that runs on the tick would find none. Twelve leave four free, and the firmware model holds the code's SLOTS to its n_tick_slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
libyaml took 64 KB of heap for every parse, which RAM2 holds in one piece only right after the start, so a parse after the boot film failed. libyaml-buffers.py sets INPUT_RAW_BUFFER_SIZE to 1024 in the pinned sources before every build, the Arcade's module included, and a parse then takes about 4 KB. A file and a text larger than the buffer read whole.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
testing.md's row named 16 KB, which no figure of the model holds since the buffer is 1 KB, so figcheck failed. The row and the test give the file and the long text as multiples of the buffer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
game-host.boot-film plays the boot film through a host of its own and starts it once more with the film's files set aside. game-host.setting sets the music's level twice at once and reads a config of its own anew, so it runs on the Teensy alone. game-host.card-pulled runs a game with music and a small film while the card is pulled and put back. The program begins the audio driver for the film's sound and the music.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
storage.card-back's checks move into game-host.card-pulled: a request to
the pulled card fails at once, the card reads again once it is back, and
a quarter of the storage task's stack stays untouched. logger.card-missing
moves into storage.no-card: without a card the log does not begin, and a
line is lost and counted at once. no-card ends by asking that the card is
back, since a card put in after a start without one waits for the next start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AnakinRaW
AnakinRaW merged commit 8b915ba into main Dec 5, 2026
14 checks passed
@AnakinRaW
AnakinRaW deleted the claude/game-host-plan branch December 5, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant