Pinball Fantastic: ESP32 Runs DOS Emulator, Hits Jackpot

Jeroen Domburg's pinball machine
(Image credit: Jeroen Domburg)

We often pass by ESP32 builds on this site in favor of Raspberry Pi or RP2040-based slices of genius, but we couldn’t let this one go. The brainchild of Jeroen Domburg of spritesmods.com and brought to our attention by Hackaday, the tiny microcontroller inside this 3D-printed pinball machine turns out to be capable of more than just flinging a few metal balls. 

That’s because it’s running an X86 emulator powerful enough to set Digital Illusions’ 1992 DOS classic Pinball Fantasies in motion. The programming part of the build sounds pretty tricky, as Domburg was faced with code that contained comments in three languages, some in-jokes, and some gaps. 

“Pinball Fantasies was entirely written in hand-coded x86 assembly,” Domburg writes in his exceptionally detailed write-up of the project. “As I intended [to] use an ESP32S3 as the mind of the tiny pinball table, I couldn't use that directly; the Xtensa core in that chip doesn't know what to make of x86 instructions. So my initial idea was to slowly convert the code to C: assemble the x86 assembly files, link them to a framework of C files, then slowly convert routines from assembly to C until the entire thing was converted and all I had left was clean C code.”

Of course, that didn’t work out, so Domburg changed tack, interpreting the code as if it were written for a particular VM, then emulating that machine. Using an 8086 emulator written in C, he added the graphics, IO and DOS calls the game uses and no more. Domburg discovered along the way that while it only displays a slice of the table where the ball is, the entire pinball deck is kept in memory, meaning it can be tweaked to display the whole table if you want.

The hardware included an ESP32-S3, which sports a dual-core 240MHz Xtensa LX7 processor, half a meg of RAM, and comes with a useful integrated parallel LCD interface. That display is a 320x640 LCD, plus a little amp and speaker for audio and some buttons to provide input. Optional extras include a second LCD and a plunger to give the authentic pinball startup motion. The case is 3D printed, and if you want to have a go at building one, you’ll find even more information on Domburg’s Github.

Ian Evenden
Freelance News Writer

Ian Evenden is a UK-based news writer for Tom’s Hardware US. He’ll write about anything, but stories about Raspberry Pi and DIY robots seem to find their way to him.

  • digitalgriffin
    Exceptionally well done.
    Reply
  • w_barath
    Always heartwarming to see a labour of love like this come to fruition, and then the code shared, to enable others to learn and pursue their own passions.
    🌠
    Reply