An Arduino Uno has 2 KB of RAM, 32 KB of flash and a 16 MHz 8-bit ATmega328P. That is less memory than the 1982 ZX Spectrum had, and nowhere near enough to hold a frame of video. Even so, Smashcat has built a game engine that runs full arcade-style games on it at a locked 50 frames per second, straight to a TV over composite video made with just two resistors. It now runs four games: Manic Miner, Scramble, Space Invaders and, as of this month, a version of Pac-Man Championship Edition.
Racing the beam
The engine has no framebuffer at all. Instead of drawing a picture in memory and sending it out, the Uno works out every line of the image at the exact moment the TV needs it, a technique known as racing the beam. That gives an effective resolution of 256x256 with a scrolling tile map, up to nine 16x16 sprites on screen (up to seven on the same line), pixel-perfect collision for one sprite, and two channels of PWM audio. Smashcat says there are still spare cycles left for game logic, enough to update every tile on screen in a single frame.
The timing is so tight that the board matters. The engine only works on an original Uno-style board with a real 16 MHz crystal. Many cheap compatible boards use a ceramic resonator instead, and Smashcat found that these are not accurate enough: the picture jitters badly. It also will not run on other Arduino models.
The games
- Manic Miner: all 20 original levels from the ZX Spectrum game, including the special boss mechanics, with the original music and a saved high score
- Space Invaders: pixel-perfect graphics and gameplay logic matching the arcade original
- Scramble: level data from the original arcade ROMs with smooth pixel scrolling
- Pac-Man Championship Edition: fast smooth-scrolling gameplay with graphics redrawn for the 1-bit display and sound effects close to the original Pac-Man
The shield
Smashcat also designed a PCB shield for the Uno with buttons, the composite video output, a speaker driver and space for a real NES controller port. All the production files are ready for an assembled order from JLCPCB, and he says 20 fully assembled boards worked out at about 4 pounds each including delivery to the UK. If you don't have the hardware, there is a WebAssembly demo of Pac-Man that runs in a browser.
Our take
This is a great reminder of how much an ATmega328P can do when every clock cycle is planned. If you have only ever used the Uno to blink LEDs and read sensors, the source code is worth a look just to see how video timing, sprites and sound are juggled on one 8-bit core. Use a genuine board or one with a proper crystal, or you will be chasing a jittery picture.
Image credit: Smashcat, Pac-Man CE video thumbnail, cropped and resized.
About the author: Aswinth Raj is an electronics engineer and the editor of CircuitDigest, where he has published more than 150 hands-on projects and tutorials across Arduino, PIC, ESP32, Raspberry Pi and EV battery systems. He selects the stories on this page for what engineers and makers can actually learn or build from. Connect on LinkedIn
Add a comment
No account needed. Your comment appears once a moderator has reviewed it.