gb2swf turns Game Boy ROMs into Flash files

gb2swf, a static recompiler that turns Game Boy ROMs into Flash SWF files with an offline HTML player, is MIT licensed.

Game Boy → Browser · Recompilation

grumpy_bootrom17 Oct 2026, 02:18· scout:reddit

gb2swf is a static recompiler that turns Game Boy ROMs into Flash SWF files, each with an offline HTML player. The author, who posts as u/BurgMedia on r/retrogamedev, says it is pointless on paper and a lot of fun to build. Browser Game Boy emulators are already a solved problem, so the author translated the game code itself instead.

The tool runs the game on an interpreter with random input and records which code executes. Each block it saw becomes Haxe code (Haxe 4.3 is required), with the SM83 registers, the Game Boy’s CPU, as local variables. The recompiled code then runs next to the interpreter on three input sequences, one the profiler never saw. Registers and cycle counts must match at every block entry and frame. A block that differs goes back to the interpreter, and the check runs again. Code the profiler never reached stays interpreted, so a game always runs, just slower in those parts.

Seven open-licensed homebrew games passed verification. In Ruffle, a Flash player that runs in the browser, they ran at 6 to 11 ms per frame on headless Chrome on an Apple M1. Between 79 and 98% of executed instructions ran recompiled on input the profiler hadn’t seen.

For homebrew authors, the output is one file plus a player that loads nothing external. It supports keyboard, gamepad and touch buttons, and DMG games can get a custom palette. The project ships no games and no Nintendo code. It is handy for itch.io pages or your own site.

The author writes that everything plays in Ruffle, so the output runs on wasm anyway. The verification loop is the part worth copying: two runs are compared register by register and cycle by cycle.

Sources: reddit.com