Browser Game Boy emulators are a solved problem, so I tried something nobody asked for: translating the game code itself into a SWF.
How it works
gb2swf game.gb runs four steps:
Profile: runs the game on an interpreter with random input and records which code actually executes.
Recompile: every basic block it saw becomes Haxe code, with the SM83 registers as local variables. Blocks are grouped into functions, so one block jumps straight into the next without going back to a dispatch loop.
Verify: the game runs again, on the interpreter and on the recompiled code side by side, with three input sequences (one the profiler never saw). Registers and cycle counts have to match at every block entry and every frame. If a block differs, it goes back to the interpreter and the check runs again.
Build: Haxe compiles it all into a SWF, plus an offline HTML player around it.
Code the profiler never reached stays on the interpreter, so a game always runs, just slower in those parts. You can record your own play in the player and feed it back with --record to get those paths recompiled too. The interpreter and the recompiler are generated from one instruction set description, so they can't drift apart, and memory accesses happen on the right cycle.
Numbers
I tested seven open-licensed homebrew games in Ruffle (headless Chrome, Apple M1). All passed verification and ran at full speed at 6 to 11 ms per frame. Between 79 and 98% of executed instructions ran as recompiled code, measured on input the profiler hadn't seen. Libbet and the Magic Floor: 742 blocks, 96.6%, 21 second build. µCity: 97.5%.
Why this might be useful for homebrew
You get your game as one file and an HTML player that works offline and loads nothing external. It supports keyboard, gamepad and touch buttons, and DMG games can get a custom palette. That's handy for itch.io or your own site.
It's free and MIT. It ships no games and no Nintendo code, and the SWFs you make aren't GPL. You need the Haxe compiler 4.3 installed. Everything plays in Ruffle, so in the end it runs on wasm anyway. Completely pointless on paper, a lot of fun to build.
GitHub: https://github.com/Burg-Media/gb2swf
Happy to answer questions about the recompiler or the verification setup.