The open source NES game console based on esp32 is programmed with Arduino software, which is convenient for transplantation and DIY. The game files support large files (using psram technology). The game files are stored in the memory card. The number of games can be 999+, so you can fully enjoy the fun of the game.
At present, there are two esp32 game consoles in the Lichuang open source community. One can only be placed in the esp32 rom space and has a limited number of games. The other is espplay. espplay is very powerful, but the audio circuit is very complicated and the cost soars. In addition, this Both game consoles are written in IDF. Generally, you can only flash the bin file. It is difficult to transplant. After all, IDF installation and compilation are quite complicated, let alone modifying the source code. So I searched online and found this project, which is based on Arduino programming. The original project can only run the first game and cannot be selected. I modified it slightly to support selecting game files.
Original project address:
https://www.instructables.com/Arduino-NES/
https://github.com/moononournation/arduino-nofrendo
In fact, appcardv3 has been completed, but the buttons are a bit small and the feel is not very good. There is this new version, which includes a base board and panel.
1. Hardware part
1. PCB and welding
When pcb is printed, there is no thickness requirement for the substrate. It is best to use an aluminum substrate for the panel. In addition, it should be as thin as possible, 0.8-1mm is most suitable.
When welding, the buzzer pins with many pins need to be cut off, and there are no requirements for others.
2. Assembly
Use M3 screws, M3 two-way copper posts, M3 spacers,
M3 screws, and a length of 8mm or more.
M3 two-way copper posts are based on the thickness of your battery.
M3 gaskets, with a thickness of 0.5mm, are used to pad the front panel, base plate, back panel, and copper posts.
In the video, the gasket is not shown because it has not arrived yet.
2. Software part
You can directly program the firmware or compile it yourself.
1. Directly program firmware
(1) After opening flash_download_tool , select esp32 for the development board .
(2) Then click 3 ... to select the correct bin file location (do not enter it manually), then check, fill in the burning address 0x00000 after @ , select 40MHz for SPI SPEED (SPI speed ) , select QIO for SPI MODE ( SPI mode) , FLASH SIZE (memory size) select 32Mbit ( to convert to M , you need to divide by 8 , which is 4M . If the esp32 wrover you bought has other capacities, modify it yourself ) , DoNotChgbin (do not change the bin file) is checked, and the port COM is selected correctly Port ( windows device manager - port, the one with ch340 ), select 921600 for BAUD (burning rate) , and then click " START " to start burning.
(3) After programming is completed, " FINISH " will be displayed. You need to unplug the cable or manually turn off the switch and restart.
(4) The above is a tutorial for using the esp32 wrapper chip for the first time. If you have used other programs before, you may have called the eeprom area. To prevent data anomalies, you need to click " ERASE " to clear it first, and then proceed to steps (1)-( 3) operation.
2. Program use
(1) Copy the nes game firmware to the root directory of the memory card. The nes game name usually has the .nes suffix.
(2) If it prompts that the memory card failed to mount after turning on the computer (displays "Filesystem mount failed! try to restart."), you can try to restart. If it still cannot be used after two or three restarts, please check the memory card or PCB circuit.
(3) After powering on, the memory card is mounted normally and a picture is displayed, showing the "waiting" interface.
(4) In this interface, you can use the left and right buttons to adjust the brightness, which takes effect immediately. Left minus 10, right plus 10. The minimum brightness is 10 and the maximum is 255. It supports remembering the previous setting value after restarting. (For key definitions, please refer to the previous "4.appcardv3 Software Instructions for Use.pdf", the same below)
(5) In this interface, press the A key once to browse the root directory file. If it is not a game file, "Not a game file, please select again." will be displayed. You need to continue to press the A key to continue selecting until it appears. nes game files.
(6) After the .nes game file name appears, press the mode button to start the game.
(7) Follow up by following the key prompts in the game.
3. Compile the program yourself
(1) Place the two library files in the libraries folder into the libraries directory of Arduino, otherwise the compilation will fail.
(2), Arduino needs to install the esp32 development board, search for tutorials by yourself
(3) When compiling Arduino, select esp32 wrapr module as the board type and select the COM port correctly.
Okay, this is the content of esp32gamepad. For the high-definition demonstration video, see: Bilibili display page
Welcome to like and collect
It’s not over yet. What if you only have esp32 wroom or other screens? Here is a brief introduction to the transplantation method. Novices can skip this part.
The first step is to explain what the source code file contains.
esp32gamepad.ino, main file
controller.cpp, controller, mainly button type and joystick class definition
display.cpp, display driver file
hw_config.h, file system definition, audio pin and button pin
osd.c, operation Some functions sound.c processed by the system
, some functions of the audio system
Generally, you only need to modify the three files esp32gamepad.ino, display.cpp, and hw_config.h
The second step, the difference between esp32 wroom and wrapr
I won’t go into the specific differences here. I will only talk about two here. One is that the package size is different. If you use Wroom, you have to redraw the schematic diagram and PCB diagram.
Another thing is that wroom does not have psram (off-chip memory area, this memory is running memory, not the memory where files are stored), while wrapr does.
What does psram do? For game console processing, nes files are loaded into the running memory. Generally, small game files of one to two hundred kb are no problem.
But if the game file is 1M, the default running memory of esp32 cannot be loaded, which requires off-chip ram. The psram size is 8M but
Only 4M is actually available, which is enough to run a 1M game file.
Once you know this, you can easily modify it. The corresponding file is the 28th line of osd.c.
/* memory allocation */
extern void *mem_alloc(int size, bool prefer_fast_memory)
{
if (prefer_fast_memory)
{
return heap_caps_malloc(size, MALLOC_CAP_8BIT);
}
else
{
return heap_caps_malloc_prefer(size, MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT);
}
}
If you use wroom, change the return in else to the same as in if, and note that the game file cannot exceed the running content.
The modification method has not been verified, so unless you have a lot of esp32 wroom, it is recommended to buy a wrapper directly.
The third step, screen transplantation
If you use other screens (minimum resolution is 240*240) and want to transplant
Modify the display.cpp file, the content after line 47 else
#else
//Display brightness
#define TFT_BRIGHTNESS 128 /* 0 - 255 */
//Display control backlight pin (backlight negative pole)
#define TFT_BL 22
//Display driver, define spi pin, miso can be left unconnected to -1
Arduino_DataBus *bus = new Arduino_ESP32SPI(27 /* DC */, 5 /* CS */, 18 /* SCK */, 23 /* MOSI */, -1 /* MISO */);
//Define the bus type, where rotation is the rotation angle, whether IPS is a high-definition screen
Arduino_ST7789 *gamegfx = new Arduino_ST7789(bus, 26 /* RST */, 3 /* rotation */, false /* IPS */);
My screen is 7789. If you need other types of screens, you can find them in the folder of the library Arduino_GFXsrcdisplay. Those listed are supported.
Step 4: Modify keys and file system
Starts after line 105 else of hw_config.h
#else
//Storage method, 21 is the CS pin of SD, which needs to be different from the display screen
#define FILESYSTEM_BEGIN SD.begin(21, SPI, 40000000, FSROOT); FS filesystem = SD;
//Buzzer audio
/* buzzer audio */
#define HW_AUDIO_BUZZER
//Buzzer pin
#define HW_AUDIO_BUZZER_PIN 13
#define HW_AUDIO_SAMPLERATE 22050
// nofrendo minimum sample rate
//Minimum sampling rate, adjusted according to actual situation, default 22050
//Button pins, X and Y are not used by me, so they are assigned to unused IO.
/* controller is GPIO */
#define HW_CONTROLLER_GPIO
//#define HW_CONTROLLER_GPIO_ANALOG_JOYSTICK
#define HW_CONTROLLER_GPIO_UP 39
#define HW_CONTROLLER_GPIO_DOWN 36 #define HW_CONTROLLER_GPIO_LEFT
35 #define HW_CONTROLLER_GPIO_RIGHT
34 #define
HW_CONTROLLER_GPIO_SELECT 32
#define HW_CONTROLLER_GPIO_START 25 #define HW_CONTROLLER_GPIO_A 14
#define
HW_CONTROLLER_GPIO_B 33
#define HW_CONTROLLER_GPIO_X 0
#define HW_CONTROLLER_GPIO_Y 2
There are two audio modes, one is the buzzer, and the other is the DAC. For the DAC, you can refer to the commented case, and be careful that the pins cannot conflict with other pins.
All reference designs on this site are sourced from major semiconductor manufacturers or collected online for learning and research. The copyright belongs to the semiconductor manufacturer or the original author. If you believe that the reference design of this site infringes upon your relevant rights and interests, please send us a rights notice. As a neutral platform service provider, we will take measures to delete the relevant content in accordance with relevant laws after receiving the relevant notice from the rights holder. Please send relevant notifications to email: bbs_service@eeworld.com.cn.
It is your responsibility to test the circuit yourself and determine its suitability for you. EEWorld will not be liable for direct, indirect, special, incidental, consequential or punitive damages arising from any cause or anything connected to any reference design used.
Supported by EEWorld Datasheet