Case study
game-and-watch-patch: Nintendo Game & Watch custom firmware
Custom firmware for the Mario and Zelda Game & Watch consoles that patches new C code into the user's own stock firmware backups, so the original firmware runs alongside the retro-go emulator. A Python patcher hooks stock function calls, relocates and LZMA-compresses stock code and data to free flash, and can merge both models' firmware into one image. Committed symbol maps, a cross-reference mapper and an analysis-ELF builder support the reverse engineering, and a journal records the author's first firmware-patching work.
- Targets
- Firmware · Game
- Category
- Independent reconstruction cases
- Relationship
- Independent reconstruction project
- Sources reviewed
Requirements & limits
- The reviewed main commit (2026-10-19) is 111 commits past the last tag, v0.12 of 2025-02-25, and no release attaches binaries; the relocation, merged-image, analysis tooling and most tests arrived after that tag. The README lists more Mario features (whole firmware in internal flash, removable song and sleep illustrations, timeouts, clock graphics mods) than Zelda ones and says Zelda's external-flash savings are still to come.
- Requires the user's own internal and external flash backups of a Mario or Zelda unit, placed as internal_flash_backup_<device>.bin and flash_backup_<device>.bin; the patcher rejects images whose SHA-1 does not match the stock firmware. The repository commits no firmware, ROMs or keys: tools/re/README.md says the .syms files hold only the project's annotations and that ELFs derived from Nintendo's firmware must never be committed, and docs/mario.md says no ROMs or ROM-hack patches are hosted.
- Targets the consoles' STM32H7B0 microcontroller. Builds need GNU Make, the arm-none-eabi GCC toolchain and Python 3.6+ with Pillow, NumPy, pycryptodome, pyelftools, capstone and colorama; flashing uses gnwmanager, and the Mario internal-only mode also needs a patched OpenOCD for an undocumented extra 128 KB of internal flash. An Ubuntu 22.04 Dockerfile installs gnwmanager's OpenOCD and Arm toolchain for x86-64 Linux hosts.
- tests/test_golden.py rebuilds fixed option sets and compares output SHA-1 hashes with tests/golden.json, recorded for Arm GNU Toolchain 15.2.Rel1; it skips without the stock backups or under another GCC version. Other unit tests cover relocation, Thumb assembly, layout and symbols, and tools/emu runs patched images through menu tests in the GWemu emulator. CI only runs pre-commit lint checks and builds the Docker image; this review ran nothing.
- COPYING is BSD-3-Clause (2020, Konrad Beckmann, Thomas Roth, STMicroelectronics); the vendored ST CMSIS and HAL sources keep their own notices, and the stock firmware and games remain Nintendo's. The repository's CLAUDE.md is guidance for Claude Code but does not establish AI authorship; the reviewed sources establish no REA use.
About this entry
The description was reviewed against primary sources. This does not establish runtime testing, security auditing or verified compatibility.
Primary sources
- README.md GitHub · BrianPugh/game-and-watch-patch · Revision 857bb80
- COPYING GitHub · BrianPugh/game-and-watch-patch · Revision 857bb80
- Makefile GitHub · BrianPugh/game-and-watch-patch · Revision 857bb80
- requirements.txt GitHub · BrianPugh/game-and-watch-patch · Revision 857bb80
- docker/Dockerfile GitHub · BrianPugh/game-and-watch-patch · Revision 857bb80
- patches/firmware.py GitHub · BrianPugh/game-and-watch-patch · Revision 857bb80
- patches/amalgam.py GitHub · BrianPugh/game-and-watch-patch · Revision 857bb80
- tools/re/README.md GitHub · BrianPugh/game-and-watch-patch · Revision 857bb80
- tools/emu/README.md GitHub · BrianPugh/game-and-watch-patch · Revision 857bb80
- tests/test_golden.py GitHub · BrianPugh/game-and-watch-patch · Revision 857bb80
- tests/golden.json GitHub · BrianPugh/game-and-watch-patch · Revision 857bb80
- docs/journal.md GitHub · BrianPugh/game-and-watch-patch · Revision 857bb80
- docs/mario.md GitHub · BrianPugh/game-and-watch-patch · Revision 857bb80
- .pre-commit-config.yaml GitHub · BrianPugh/game-and-watch-patch · Revision 857bb80
- CLAUDE.md GitHub · BrianPugh/game-and-watch-patch · Revision 857bb80
- https://github.com/BrianPugh/game-and-watch-patch/releases/tag/v0.12
More in Games
- RenderDoc · Tool
- AssetRipper · Tool
- Cpp2IL · Tool
- Il2CppDumper · Tool
- RenderDoc MCP · Integration
- UndertaleModTool · Tool