Nintendo Famicom console with controllers

Test-driven NES development (1): red

🎮 Why test an NES game? During Hack Week 26 I wrote Hack to the Future, an endless runner for the Nintendo Entertainment System, in C. A 1983 console has no debugger you can attach to, no printf, and no unit test framework. What it has is an emulator: Mesen2 embeds a Lua scripting engine and a headless --testRunner mode, so a script can run the ROM, press buttons, read RAM, VRAM and sprite memory, and exit with a status code. That is everything a test needs. The game ended up with about ten Lua test files, and they saved me many times (a drone that never hit a standing player, a HUD that scrolled with the playfield…). In this series I will rebuild the idea from scratch, in the smallest possible program, following the classic red-green-refactor loop: 🔴 write a test, watch it fail 🟢 write the least code that makes it pass 🔵 clean up, with the tests as safety net Goal of the series: a sprite you can move with the d-pad. Tiny, but it touches video, memory and input. Today: the toolbox, the blank project, and the first failing test. ...

November 30, 2026 · Andrea Manzini
Buy Me a Coffee at ko-fi.com Buy Me A Coffee

This site does not use cookies or collect any personal data. © 2026 Andrea Manzini.