Chris Dell's "$1 Handheld Gaming Console" Packs a Rust Game Engine Onto the WCH CH32V003
Cheap components, including a $0.09-in-bulk RISC-V microcontroller, deliver a surprisingly playable gaming experience.
Developer Chris Dell has built a compact little handheld games console with two key differences: the first is that it's programmed in Rust, and the second is that its parts cost just $1 — at least when purchased at bulk pricing.
"The [WCH] CH32V003 is an interesting little chip — not just because it's based on the up-and-coming RISC-V architecture, or because it comes in a tiny package, but mostly because you can buy it for $0.09 in bulk," Dell explains of the chip which powers his compact console. "Hard to believe this is a 32-bit microcontroller… albeit one with only 2KiB of RAM and 16KiB of flash. I'd just gotten into Embedded Rust on the [Espressif] ESP32, using libraries like Embassy and esp-hal. When I found out there was an active effort (the ch32-hal project) to bring Rust support to the CH32V003, I had to try it."
Launched in 2012 and building atop work started by Graydon Hoare in 2006, Rust is positioned as a general-purpose programming language with a focus on safety — preventing by design common type and memory safety violations that are all-too-easy to commit in earlier languages. While initially designed for full-fat computers, in recent years it has seen adoption in the embedded space too — and it's here that Dell's focus lies.
"There was something deeply appealing about using a modern, safe language like Rust on such a brutally constrained device," Dell explains. "Not to mention the sheer utility of having a chip cheaper than a 555 timer for quick, dirty, and fun hacks. I set out to build a simple side-scrolling adventure game that would look great on a 128×64 pixel display. My first move? Build a platform-agnostic 'game engine' that I could run as a desktop app using minifb. The idea: develop all the game logic on my Mac, then port over the rendering layer to the chip once everything else was solid."
That initial plan was sound, and Dell says it "almost worked" — but a lack of RAM proved a problem. The SSD1306 display driver's built-in framebuffer helped with that, but performance proved a problem: the game's physics engine was written with floating-point arithmetic in mind, while the CH32V003 lacks floating-point hardware. Swapping this out for fixed-point arithmetic saw the game jump from one frame per second to a much more playable 30, dropping to 25 frames per second when the map was added into the game.
"It's playable. On a $0.09 chip," Dell says of the project. "Rust wasn’t just possible — it was perfect. Safe, fast, expressive… and now I’ve got a working game on hardware cheaper than a chocolate bar. Sometimes, the best projects are the ones you never thought you could build."
More information is available in Dell's write-up, with source code and a simulator available on GitHub under an unspecified open source license.