Show HN: I Built a Handheld ESP32 NES from Scratch as My First Embedded Project

20 hours ago 1

Anemoia-ESP32 is a rewrite and port of the Anemoia Nintendo Entertainment System (NES) emulator running directly on the ESP32. It is written in C++ and is designed to bring classic NES games to the ESP32. This project focuses on performance, being able to run the emulator at native speeds and with full audio emulation implemented. However, games with complex mappers may induce a small speed loss.
Anemoia-ESP32 is available on GitHub under the GNU General Public License v3.0 (GPLv3).

Anemoia-ESP32.mp4


Anemoia-ESP32 is heavily optimized to achieve native NES speeds on the ESP32, running at ~60.098 FPS (NTSC) with full audio emulation enabled.

Here are the performance benchmarks for several popular NES games.

Note

The following benchmarks show average framerates recorded over 8192 frames (~2 minutes) of emulation time. Some games, such as Kirby's Adventure, which frequently switch banks may experience significant FPS drops in certain sections.

Game Mapper Average FPS
Super Mario Bros. NROM (0) 60.10 FPS
Contra UxROM (2) 60.10 FPS
The Legend of Zelda MMC1 (1) 60.10 FPS
Mega Man 2 MMC1 (1) 60.10 FPS
Castlevania UxROM (2) 60.10 FPS
Metroid MMC1 (1) 60.10 FPS
Kirby’s Adventure MMC3 (4) 59.57 FPS
Donkey Kong NROM (0) 60.10 FPS

As of now, Anemoia-ESP32 has implemented five major memory mappers, totalling to around 79% of the entire NES game catalogue. Feel free to open an issue if a game has glitches or fails to boot.


  • ESP32 38-pin development board
  • MicroSD card module
  • 320x240 TFT ST7789 LCD
  • PAM8403 with a potentiometer
  • 8 Ohms 0.5W speaker
  • 8 Tactile push buttons
Component Signal ESP32 Pin
MicroSD Module MOSI 13
MISO 34
SCLK 26
CS GND
TFT Display MOSI 23
MISO -1 (N/A)
SCLK 18
CS 4
DC 2
RST EN
PAM8403 L 25
Buttons A 22
B 21
Left 0
Right 12
Up 15
Down 5
Start 32
Select 27

  1. Upload the Anemoia-ESP32.ino program into the ESP32
  2. Put .nes game roms inside the root of a microSD card
  3. Insert the microSD card into the microSD card module
  4. Power on the ESP32 and select a game from the file select menu

Either use git clone https://github.com/Shim06/Anemoia-ESP32.git on the command line to clone the repository or use Code → Download zip button and extract to get the files.

  1. Download and install the Arduino IDE.
  2. In File → Preferences → Additional boards manager URLs , add:
https://espressif.github.io/arduino-esp32/package_esp32_index.json
  1. Download the ESP32 board support v3.2.1 through Tools → Board → Boards Manager .

Important

Make sure to download version 3.2.1, as different board versions may have worse performance.

  1. Download the SdFat and TFT_eSPI libraries from Tools → Manage Libraries .

Step 3 - Configure TFT_eSPI

The emulator uses a custom display configuration for the ST7789 display.

  1. Navigate to your Arduino Libraries folder: (Default location): Documents/Arduino/libraries/TFT_eSPI
  2. Open User_Setup_Select.h in a text editor.
  3. Comment out #include <User_Setup.h> and any other setup includes and add <User_Setups/Anemoia-ST7789.h>:
// #include <User_Setup.h> #include <User_Setups/Anemoia-ST7789.h>
  1. Copy the provided Anemoia-ST7789.h file from this repository into TFT_eSPI/User_Setups/. Optionally, edit the #define pins as desired.

Note

If using a screen with the ILI9341 driver, open Anemoia-ST7789.h in a text editor and comment out #define ST7789_DRIVER and uncomment #define ILI9341_DRIVER.

// #define ST7789_DRIVER #define ILI9341_DRIVER

Step 4 - Apply custom build flags

  1. Locate your ESP32 Arduino platform directory. This is typically at:
\Users\{username}\AppData\Local\Arduino15\packages\esp32\hardware\esp32\{version}\
  1. Copy the platform.txt file from this repository and paste into that folder. This file defines additional compiler flags and optimizations used by Anemoia-ESP32.

Warning

Backup your platform.txt file if you have your own custom settings already.

  1. Connect your ESP32 via USB.
  2. In the Arduino IDE, go to Tools → Board and select your ESP32 board (e.g., ESP32 Dev Module).
  3. Click Upload or press Ctrl+U to build and flash the emulator. Optionally, edit the #define pins as desired.

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

This project is licensed under the GNU General Public License v3.0 (GPLv3) - see the LICENSE file for more details.

Read Entire Article