2026-11-11

Two CH32V003 game projects solve 2 KB of SRAM in different ways

CH32V003RISC-VRustSSD1306Open SourceEmbedded
Two CH32V003 game projects solve 2 KB of SRAM in different ways

A microcontroller with 2 KB of SRAM and a 128 by 64 monochrome display presents a simple arithmetic problem: one full framebuffer is 1024 bytes, half the memory, before the game state is stored at all. Two independent open projects built around the CH32V003J4M6 answer that problem in different ways. One ships a complete C console with a board, a case and a set of ported games. The other is a Rust engine that reorganises the physics and the renderer so that no full framebuffer is ever allocated. Both repositories are readable enough to check the claims directly.

The part and its published limits

Item Value in the project README
Core QingKe RISC-V2A with the RV32EC instruction set
Clock 48 MHz system frequency
Memory 16 KB flash and 2 KB SRAM
Supply 2.7 to 5.5 V
Debug Single-wire serial debug interface
Peripherals DMA, 10-bit ADC, op-amp comparators, timers, USART, I2C and SPI
Display SSD1306 128 by 64, 0.96 inch, four-pin I2C module
Power CR2032 or LIR2032 coin cell holder
Unit cost About ten US cents at the time the README was written

The SOP8 package leaves few usable pins, so the console design puts five buttons on one ADC input through a resistor ladder: each key produces a different divider voltage and is identified by the conversion result. The README warns that four-pin and seven-pin SSD1306 modules have different pin orders and that the correct pinout must be confirmed before wiring. That is a small detail, but on a board with this few pins it decides whether the display lights at all.

The C console: six games and two board revisions

The wagiminator repository was created in June 2023, carries a CC-BY-SA 3.0 licence file, and was last pushed in November 2026. Its README currently documents six games, not five: Tiny Invaders, Tiny Lander, Tiny Tris, Tiny Arkanoid, Tiny Pacman and Tiny Doom. The first five are adaptations of games originally written for the ATtiny85, with credits to Daniel Champagne and tscha70. Tiny Lander keeps its original easter eggs: holding up while pressing fire on the start screen skips to a later level, and holding down grants 255 lives.

Board revision Buzzer circuit Behaviour on a weak cell
Version 1.0 Driven through a transistor, louder A weak CR2032 can droop far enough to brown out the controller and restart the game
Version 1.1 Driven directly through a low resistor, quieter No brownout; the rechargeable LIR2032 at 3.6 V also avoids it

The README reports an average current of about 10 mA at 3.6 V, measured with a Nordic Power Profiler Kit II. It also supplies Gerbers, a bill of materials, EasyEDA design files, STL files for a printed case and assembly notes, including a recommended layer height and screw size. That makes it a fabrication package rather than just a code dump, and it is the reason this repository is the easier of the two to reproduce physically.

The Rust engine: fixed point and row rendering

The cjdell repository was published in April 2026, while its commit history reaches back to July 2025 with entries such as Working prototype, Remove floats completely, Good performance for 10+ entities and Use fixed precision number library. That split is worth noting: the code was developed well before the public repository appeared, so a repository creation date is not the date the engineering started.

Technique Where it appears in the source
Fixed-point physics core.rs uses I22F10 from the fixed crate, 22 integer bits and 10 fractional bits
Desktop simulation local-test depends on minifb and shares the common crate
Row buffer renderer.rs takes a 128-byte buffer and a row index, and the main loop calls it eight times
Display as memory SSD1306 column addressing keeps written pixels, so no full framebuffer is needed
Object culling Bounding boxes skip entities that do not intersect the current row
Tile map scene.rs declares MAP as a 218-element array of u64, four bits per tile

The 128-byte figure is not arbitrary. The SSD1306 organises its display memory in columns, one byte covering eight vertical pixels, so 128 columns need exactly 128 bytes for one horizontal band of eight rows. The renderer computes one band, sends it, then moves to the next; objects outside the band are skipped by a bounding-box test and tile graphics are read from ROM. Collision queries against the packed map reduce to shifts and masks rather than table lookups. Together these choices keep the working set inside 2 KB while still leaving room for game state.

Frame-rate figures that are not in the repository

The WeChat write-up that pointed at these projects gives a dramatic performance story: one frame per second at first, over thirty frames after switching to fixed point, and a final playable twenty-five. None of those numbers has a first-party source in either repository. The only frame-rate text in the Rust source is a comment next to an initial time-step value describing an assumed rate of about forty frames per second, which is an initial parameter, not a measurement. There is no benchmark file, no timing log and no README claim about achieved frame rate in either project.

That gap is worth stating plainly rather than filling with a plausible number. What can be verified is the sequence of code changes and their shape: floating-point physics was removed, fixed-point arithmetic was introduced, and the renderer was restructured around a single row buffer. Those are durable, checkable facts. A frame rate quoted without a measurement setup, a build profile and a target board is not.

Choosing between the two projects

C console Rust engine
Scope Complete handheld with board, case and six games A side-scrolling game plus a reusable engine
Files Gerbers, BOM, EasyEDA sources, STL, firmware Cargo workspace, shared crate, device and simulator binaries
Licence CC-BY-SA 3.0 licence file No licence file in the repository
Toolchain C firmware Rust nightly features and a hardware abstraction crate
Reproduction path Order a PCB and assemble Build the simulator first, then flash a chip
Documentation Long README with assembly and build steps Short README with GPIO mapping and two build commands

The Rust README publishes the device pin map: PA2 for jump, PC4 for left, PD4 for right, PC1 for I2C SDA, PC2 for I2C SCL and PD6 for UART transmit. It also documents the simulator command and the on-device build command. A builder who wants a finished object should start with the C console; someone studying how to fit a game into 2 KB should start with the Rust renderer.

Both projects make the same architectural point, even though they were written years apart and in different languages: the memory limit is a design input, not an obstacle discovered at the end. Deciding first that there will be no framebuffer changes the renderer, the map format, the object loop and the physics representation all at once. On a part this small, that decision is the whole design.

← All news