Run Your Favorite 8-bit Games On An ESP32

Here at Hackaday HQ we’re no strangers to vintage game emulation. New versions of old consoles and arcade cabinets frequently make excellent fodder for clever hacks to cram as much functionality as possible into tiny modern microcontrollers. We’ve covered [rossumur]’s hacks before, but the ESP_8-bit is a milestone in comprehensive capability. This time, he’s topped himself.

There isn’t much the ESP 8-bit won’t do. It can emulate three popular consoles, complete with ROM selection menus (with menu bloops). Don’t worry about building a controller, just connect any old (HID compliant) Bluetooth Classic keyboard or WiiMote you have at hand. Or if that doesn’t do it, a selection of IR devices ranging from joysticks from the Atari Flashback 4 to Apple TV remotes are compatible. Connect analog audio and composite video and the device is ready to go.

The system provides this impressive capability with an absolute minimum of components. Often a schematic is too complex to fit into a short post, but we’ll reproduce this one here to give you a sense for what we’re talking about. Come back when you’ve refreshed your Art of Electronics and have a complete understanding of the hardware at work. We never cease to be amazed at the amount of capability available in modern “hobbyist” components. With such a short BOM this thing can be put together by anyone with an ESP-32-anything.

There’s one more hack worth noting; the clever way [rossumur] gets full color NTSC composite video from a very busy microcontroller. They note that NTSC can be finicky and requires an extremely stable high speed reference clock as a foundation. [rossumur] discovered that the ESP-32 includes a PLL designed for audio work (the “APLL”) which conveniently supports fractional components, allowing it to be trimmed to within an inch of the desired frequency. The full description is included in the GitHub page for the project and includes detailed background of various efforts to get color NTSC video (including the names of a couple hackers you might recognize from these pages).

20 thoughts on “Run Your Favorite 8-bit Games On An ESP32

  1. Some mandatory “metoo” comment, sorry :) : Since I attempted to propose my own comparable DIY “old console on ESP” project once, I can totally share the “all-inclusive” approach of [rossumur] and appreciate his explanations with comprehensive aknowledgment of related works. This is a mix of well known lightweight emulators “retrofitted” to ESP32 (some of them already chosen for the same reason by retro-emulation handleds PocketSprite and Go-Play using the same chip) and composite video generation made easier by onboard PLL and high speed DACs. On top of that, it looks like Peter took special care of good palette approximation for each console in both composite PAL and NTSC, while providing a very nice turnkey “all in one” system, easily buildable by any tinkerer for cheap (though wireless gamepad among those pictured could be the most costly element, if don’t have one already).

    Probably like others, I had *exactly* the same project in mind back when the ESP32 was coming, but as a first-day retail purchaser in September 2016, it was a big disapointement to discover that the initial chip version had its PLL clock generator crippled (sdm0 & sdm1 registers inoperative in revision 0) thus preventing it to be tuned precisely enough to obtain those desired colorcarrier frequency for PAL and NTSC… so for this, beware of old esp32 chips and dev boards from your drawer (even including first PICO-D4 of… 2018 :( ). Then documentation and some hardware-specific libraries like Bluetooth were rather incomplete, and Arduino SDK not as mature… looks like everything comes to those who wait.

    Anyway it was a bit too early to the game for me as an unexperienced amateur, and to console :D myself I turned back to see what I can do with the not so old and still great ESP8266, and eventually achieved a full-featured Master System emulator, still “bitbanging” analog TV video signal with roughly correct aspect ratio abeilt in RGB which is obviously much easier to get colors (and requires a TV with SCART input) but is generaly nicer.
    It consisted of an overclocked NodeMCU board + 74HC595 shift register to feed a 6-bit resistor DAC comparable to the one of the real console, and also had clean ample PDM audio and support for cheap I2S classic-nes gamepads (and for some extra peripherals, which were the “surprise highlight” and my main motivation, rather tricky to add efficiently along the rest, but once I succeeded and got intended results, the fun vanished while extensively testing and polishing emulation, the guis and web interface… in preparation for public release, left alone the extensive work required for a good presentation and documentation).

    I could relate the interesting technical bits later, but despite the ESP8266 inherent limitations, with a fraction of the ram and rather crude peripherals compared with its successor, finding ways to deal with those (like the various optimizations needed, or fiddling with obscure registers settings) turned out to be very time consuming but possibly a lot more instructive and intellectually rewarding. And in many regards, it felt more close to the original hardware in “spirit”, yet without requiring “the power of the ESP31” :)

    1. I’d like to read about the whole video implementation, sounds good for CGA-EGA evolving to VGA implementation for PC emulation or using the 8266 as a video processor for other CPU.

  2. Thanks for your nice encouragement Terry. And Jock you’re right, my mystake! Like other DIY projects, mine targeted these most affordable clones using the I2C Wiimote protocol (in their particular manners…). So not to be confused with I2S (using DMA) which is of course the cornerstone of such high speed signals generation on esp8266, as brillantly demonstrated by a Mister Lohr ;) whose work was indeed inpirational.

    RW: nothing fancy with my video generation (very straightforward with parallel RGBS signals) but esp8266 wouldn’t make it a good candidate for a dedicated solution with standard timings choice, since you can only “pick” an integer division of the CPU clock (and pratically only a 2^n divisor) to get the desired pixel rate…
    That’s where the ESP32 can make things far easier and better with its precise PLL and parallel I2S bus (so no more need for an external shift register), officialy provided (see documentation, nothing was “discovered” about it, unlike what is said in the above article) to feed the onboard DACs, or LCDs driven similarly to VGA. So tailoring the settings of the later feature to get the right timings for low resolutions is no big deal, and was previously reported on Youtube and HaD.

  3. This is awesome. I really wish I got beyond my prototype portable nes project but this one gives me hope that I might eventually get it assembled. Shameless plug:

    Stl and openscad files are there as well as my heavily improved fork of espressif’s sample port. I was able to coax a full frame rate on Metroid and get sram support working for Zelda. Also fixed sound bugs and added turbo button support, full psx controller support, sd card support, etc.

    Hope to see more projects like this one, especially ntsc hacks! Awesome stuff.


    1. I’m a complete beginner, but I’d love to see those changes with composite output! It would be wonderful to expand what the ESP32 can play through composite.

      I’m trying to learn enough board design to make this into a nice little keychain. I was thinking one of the WROOM32 modules with more flash and/or RAM paired with a ~1.5 hour battery? Using a headphone jack so a 3.5 to RCA cable can carry the signal would make it easily pocketable.

      I know I’m too much of a newb to even understand where to start with code, but if I can make a board that works I’ll share the files for it.

      Basically I’m trying to entice you because I’m still figuring out pinouts on my ESP32 and improved emulator performance is much more than I am able to approach for a first real project.

  4. This is really amazing. It was my weekend project and ran from the pretty first second including sound. Impressive. But…

    Does anyone have trouble with bluetooth devices, too? Bluetooth is VERY unstable with my devices. It either freezes (using a wiimote clone) or just resets (apple magic keyboard) which rendered the whole system interesting but useless. I have added code to support wired controls (got an arcade joystick lying around…) which makes a very nice and smooth system now. I am still documenting and will soon make a pull request to support that option. Other ideas include supporting those arduino analog stick modules flying arround everywhere and also binding those over the (other) SPI port. Making a nice enclosure is also on the list…

    1. I haven’t run into bluetooth stability issues so far and ran a few NES games for a long while this weekend. I only tried using a white first party wii remote. One thing I noticed though, is that if I don’t hold the reset button down on my esp32 board for a few seconds the setup can be unstable and freeze on me.

      1. I‘ll try an original Wiimote – have found an old one. I can cancel out power failure because this happens too it I use a 5A 5V power supply.
        During my tried to integrate a direkt pin input method I realized strange things happen if there are too many input signals (concurrent key actions). Whenever my function did not filter out repetitive key actions it also resetted immediately. I think there might be wrong input signals getting in and filtering them took too long. I will investigate further…

  5. I have built 3 of the Atari 8 bit esp32 boards. I love them. Only wish there was a way to save basic programs to an sd card or some other storage device. Keep up the great work!!!

  6. Hello, I have built this arcade game and loved so much, but I would like to know if it’s possible or if there is code ready for mounting many emulation games on SD card instead of using SPIFFS. Again, excellent job!!!

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.