Developer transpiles Lua and Swift games to run on SNES, Dreamcast and Wii
A developer's blog post describes transpiling Lua to C for a SNES homebrew game, and Swift to WASM to C for Dreamcast and Wii prototypes.
AI-drafted from 2 sources. This story was written with AI from the outside reporting listed under Sources, and checked by automated tools before it went up. The originals have the full detail.
A developer has written up two experiments in transcompilation, the practice of converting source code from one language to another rather than compiling it directly, that got a Lua game running on real SNES hardware and a Swift game engine limping onto Dreamcast and Wii. Neither project used the platform's usual toolchain to write the game logic. Both are described in the blog post, which the developer says grew out of not fancying learning a new SDK.
The SNES side started as a driving platform game written in Lua using Love2D, a framework normally aimed at desktop and mobile. The developer built it to self-imposed constraints matching the console: 8-bit integer maths via a small custom library, graphics aligned to an 8 pixel grid, and controls mapped to the SNES pad. Once the game was playable on a Mac, the Lua was transpiled to C and wired into a minimal SNES homebrew toolkit written by Phillip May, which compiles using llvm-mos, a compiler backend built for the 6502 family of chips. The SNES actually runs a 16-bit 65816 chip in a mode compatible with the older 6502, and the developer notes that llvm-mos uses “imaginary registers located in the fast zero-page area of memory” to make the CPU behave as though it has more capacity than it does, a trick assembly programmers used by hand in the 1990s that the compiler now does automatically. The result, after some fixes and decluttering, hit 60 frames per second with no hand-written assembly at all.
Why turning Lua into C works so well on the SNES
The developer's point is less about the specific game and more about how far compiler tooling has moved on. Shipping a whole SNES game written in C would have seemed impractical to developers working in the actual 1990s, according to the post, because the tools of the day were not optimised enough. Modern compilers close that gap, turning what was once an assembly-only affair into something a C compiler can handle at full speed.
The Swift to Dreamcast route the developer calls bonkers
The second experiment involved Jinks, the developer's own engine and IDE project for making games across multiple platforms, written in Swift. Swift already compiles to the web, which covered a game jam entry, but it has no path to SH4 (the Dreamcast's CPU) or PowerPC (the Wii's). The workaround found on GitHub was w2c2, a tool that transpiles WebAssembly (WASM) into plain C. Routing Swift through WASM and then through w2c2 to C produces, in the developer's words, “tens of thousands of C files”, and the process is described as “bonkers, totally OTT, like cracking a nut with a sledgehammer”. Build times were long and binaries large. Even so, the Wii build ran at full speed, while Dreamcast only managed 20 frames per second, which the post puts down mainly to the overhead of that chain. “The proof is in the pudding!” as the developer puts it.
What it means for prototyping
The Swift to WASM to C route has since been abandoned in favour of rewriting the Jinks engine directly in C, which the developer says brought “near instant build times, tiny binary sizes, and much faster execution”, with Dreamcast now running at 60fps with headroom to spare. The lasting takeaway from the post is not that either hack belongs in a shipped game, but that transcompilation is now solid enough to use for quick prototyping on hardware that a chosen language was never meant to touch. What is unconfirmed is how well either approach would hold up in a larger, more complex game rather than a small platformer or engine test, and the developer's own conclusion, moving back to native C for Jinks, suggests the tricks have their limits. The discussion thread on r/retrogamedev has further reaction from other retro developers.
Sources
- Transcompilation Express (SNES, Dreamcast, Wii dev) (blog.gingerbeardman.com)
- Discussion: Transcompilation Express (SNES, Dreamcast, Wii dev) (Reddit)
Image: Illustration: AI-generated for Gaming World