Pinball Fantastic: ESP32 Runs DOS Emulator, Hits Jackpot
This site often goes through the ESP32 build in preference to the Raspberry Pi. (Opens in a new tab) Or RP2040 (Opens in a new tab)It’s a slice of the base genius, but I couldn’t let go of it. Inspired by Jeroen Domburg spritesmods.com (Opens in a new tab) Attracted our attention by Hackaday (Opens in a new tab)It turns out that a small microcontroller in this 3D printed pinball machine can do more than throw some metal balls.
This is because it runs an X86 emulator that is powerful enough to run Digital Illusions’ 1992 DOS classic pinball fantasy. The programming part of the build sounds pretty tricky because Domburg faced code with comments in three languages, some jokes, and some gaps.
“Pinball Fantasies was written in a completely handwritten x86 assembly,” Domburg wrote. Very detailed article (Opens in a new tab) Of the project. “As I intended [to] I used the ESP32S3 as the brain of a small pinball table, but I couldn’t use it directly. The Xtensa core of that chip doesn’t know what to do with x86 instructions. So my first idea was to slowly convert the code to C. After assembling the x86 assembly files and linking them to the C file framework, slowly converting the routine from assembly to C, everything is converted and all that remains is clean C. code. “
Of course, that didn’t work. So Domburg modified the tack, interpreting the code as if it were written for a particular VM, and emulating that machine. He used the 8086 emulator written in C to add the graphics, IO, and DOS calls used by the game. Along the way, Domburg discovered that the entire pinball deck was kept in memory while displaying only the slices of the table with the balls. That is, you can adjust it to display the entire table as needed.
The hardware included an ESP32-S3 with a dual-core 240MHz Xtensa LX7 processor, 0.5 megabytes of RAM, and a convenient integrated parallel LCD interface. Its display is a 320×640 LCD plus a small amplifier and speakers for audio, and some buttons to provide input. Optional extras include a second LCD and plunger that provide a genuine pinball launch action. The cases are 3D printed and you can find more information if you want to create one. Domburg’s Github (Opens in a new tab)..