fhoedemakers / pico-infonesPlus

NES Emulator with SD card and menu support for the Raspberry PI Pico, Pico 2 and other RP2040/RP2350 based microcontrollers. Play your games from SD card on a HDMI display.
GNU General Public License v3.0
280 stars 30 forks source link
adafruit adafruit-feather-dvi emulator hdmi nes nintendo-nes pico pimoroni pimoroni-pico-dv raspberry raspberry-pi-pico raspberry-pi-pico-2 rp2040 rp2350 sdcard waveshare waveshare-rp2040-pizero

pico-infonesPlus.

Introduction

A NES (Nintendo Entertainment System) emulator with SD card and menu support for the Raspberry Pi Pico, Raspberry Pi Pico 2 and other RP2040/RP2350 based microcontrollers. Uses HDMI for display.

Supports two controllers for two player games. See "about two player games" below for specifics and limitations

The emulator used is Infones by Jay Kumogata which was ported to the Raspberry Pi Pico by Shuichi Takano with changes done by me to accomodate the SD card menu.

Create a FAT32 formatted SD card and copy your NES roms on to it. It is possible to organize your roms into different folders. Then insert the SD Card into the card slot. Needless to say you must own all the roms you put on the card.

A menu is added to the emulator, which reads the roms from the SD card and shows them on screen for the user to select, flash and play.

See below for possible configurations, supported game controllers and how to setup. There is even a custom PCB (printed circuit board) available and a 3D-printable case design which fits the PCB.

See also the Adafruit guide.

There is also an emulator port for the Sega Master System/Sega Game Gear and DMG Game Boy. You can find them here:


Video

Click on image below to see a demo video.

Video


Possible configurations

You can use it with these RP2040/RP2350 boards and configurations:

See below to see how to setup your specific configuration.

[!NOTE] It seems that sellers on AliExpress have copied the PCB design and are selling pre-populated PCB's. I do not condone this in any way. For questions about those boards, please contact the seller on AliExpress.


Gamecontroller support

Depending on the hardware configuration, the emulator supports these gamecontrollers:

USB Controllers

See also troubleshooting USB controllers below

[!NOTE] There is some input lag when using USB controllers.

Legacy controllers

Parts list for legacy controllers


About two player games

The emulator supports two player games using two NES controllers or an USB gamecontroller and a NES controller.

[!NOTE] You cannot use two USB controllers for two player games. At the moment only one USB controller is recognized by the driver. In this case the USB controller is always player 1. Player 2 must be a NES controller.

Player 1 Player 2
USB controller connected USB NES port 1 or NES port 2
No usb controller connected NES port 1 NES port 2

Warning

Repeatedly flashing your Pico will eventually wear out the flash memory.

The emulator overclocks the Pico in order to get the emulator working fast enough. Overclocking can reduce the Pico's lifespan.

Use this software at your own risk! I will not be responsible in any way for any damage to your Pico and/or connected peripherals caused by using this software.

I also do not take responsability in any way when damage is caused to the Pico or display due to incorrect wiring or voltages.


Setup

Click on the link below for your specific board configuration:


Raspberry Pi Pico or Pico 2, setup for Pimoroni Pico DV Demo Base.

materials needed

flashing the Pico

Pinout

NES controller port(s) (if you want to use legacy NES controllers).

Port 1 Port 2 (optional) Note
GND GND (- on board)
VCC (Power) Connect to 3V3
NES Clock GPIO14 GPIO1
NES LATCH GPIO16 GPIO20
NES Data GPIO15 GPIO21

[!NOTE] Soldering is required. There is only one 3v3 pin header on the board, the other 3V3 must be soldered directly onto pin 36 (3V3 OUT) of the Pico. For GND there are two pin headers available on the board. Clock Data and Latch for NES controller port 1 must be soldered directly onto the Pico. The Clock, Data and Latch for NES controller port 2 can be soldered on the available pin headers on the board, no need to solder them directly onto the Pico.

PinHeadersPimoroniDV

Image

setting up the hardware

Image: Usb controller only

Image

Image: one or two player setup with usb controller and NES controller port 2

In this image the NES controller port is wired to port 2.

For single player games: use USB controller.

For two player games: Connect a USB controller for player 1 and a NES controller for player 2.

Image

Image: Two player setup using two NES controllers or a USB controller and a NES controller

Controller port 1 pins must be soldered directly onto the Pico.

Controller port 2 pins can be soldered to the available headers of the Pimoroni DV.

For two player games:

NOIMAGE - TODO


Raspberry Pi Pico or Pico 2, setup with Adafruit hardware and breadboard

materials needed

flashing the Pico

Pinout

See https://www.raspberrypi.com/documentation/microcontrollers/images/pico-pinout.svg for the pinout schema of the Raspberry Pi Pico.

Use the breadboard to connect all together:

Adafruit Micro-SD breakout board+

Breakout GPIO Note
CS GPIO5
CLK (SCK) GPIO2
DI (MOSI) GPIO3
DO (MISO) GPIO4
3V Pin 36 (3v3 OUT)
GND Ground on breadboard (-)

Adafruit DVI Breakout For HDMI Source Devices

Breakout GPIO Note
D0+ GPIO12
D0- GPIO13
CK+ GPIO14
CK- GPIO15
D2+ GPIO16
D2- GPIO17
D1+ GPIO18
D1- GPIO19
5 (*) VBUS Pin 40 (5volt)
GND (3x) Ground on breadboard (-)

(*) This is the via on the side of the board marked 5. (next to via D and C).

Image

NES controller port(s). (if you want to use legacy NES controllers).

Port1 Port 2 (optional) Note
GND Ground on breadboard (-)
VCC (Power) (3v3 OUT)
NES Clock GPIO6 GPIO9
NES LATCH GPIO8 GPIO11
NES Data GPIO7 GPIO10

Image

setting up the hardware

See image below.

[!NOTE] The Shotky Diode (VSYS - Pin 39 to breadboard + column) and the wire on breadboard left (+) to right (+) are not necessary, but recommended when powering the Pico from a Raspberry Pi. See Chapter 4.6 - Powering the Board of the Raspberry Pi Pico Getting Started guide

Image: one or two player setup with usb controller and NES controller port

In this image the NES controller port is wired to port 1.

For single player games, connect either an USB controller or a NES controller. Not both!

For two player games: Connect a USB controller for player 1 and a NES controller for player 2.

Image

Image: Two player setup using two NES controllers or a USB controller and a NES controller

Choose either of the following:

[!NOTE] The device on the left is a Pico Debug probe used for debugging. This is optional

Image


Adafruit Feather RP2040 with DVI (HDMI) Output Port setup

materials needed

When using a USB gamecontroller this is needed:

When using legacy controllers, this is needed:

Pinout

See: https://learn.adafruit.com/assets/119662 for the Feather pin scheme.

Use the breadboard to connect all together:

Adafruit Micro-SD breakout board+

Breakout GPIO
CS GPIO10
CLK (SCK) GPIO14
DI (MOSI) GPIO15
DO (MISO) GPIO8
5V USB pin labelled USB on feather
3V See Note below
GND - column on breadboard connected to feather ground pin

[!NOTE] The Adafruit Micro-SD breakout board+ has also a 3V input pin which can be connected to + column on breadboard connected to feather 3.3V pin. However, this gave me frequently errors trying to mount the SD card. So use 5V in stead.

WII nunchuck breakout adapter.

Connect the nunchuck breakout adapter to the Feather DVI using the STEMMA QT cable.

NES controller port(s). (if you want to use legacy NES controllers).

Port 1 Port 2 (optional) Note
GND - column on breadboard connected to feather ground pin
VCC (Power) + column on breadboard connected to feather 3.3V pin
NES Clock GPIO5 GPIO26
NES LATCH GPIO9 GPIO27
NES Data GPIO6 GPIO28

Image

flashing the Feather RP2040

[!NOTE] When the emulator won't start after flashing or powering on, and the screen shows 'No signal,' press the reset button once again. The emulator should now boot.

setting up the hardware

Image: one or two player setup with usb controller and NES/WII_classic controller port

In this image the NES controller port is wired to port 1.

For single player games, connect either an USB controller or a NES/WII-classic controller. Not both!

For two player games: Connect a USB controller for player 1 and a NES or WII-Classic controller for player 2.

Image

Image: Two player setup using two NES controllers or a USB controller and a NES/WII-classic controller

Choose either of the following:

Image


Waveshare RP2040-PiZero Development Board

materials needed

[!NOTE] The PIO-USB cannot be used to connect the USB controller because DVI and PIO-USB cannot be used simultaneously. See productpage Therefore, connect the controller and the power adapter to the Y-cable, and then connect the Y-cable to the port on the board labeled "USB." While the PIO-USB can be used to power the board, I don't recommend this due to occasional strange behavior it has caused.

NES controller port.

When using a original NES controller you need:

For two player games with two NES controllers you need an extra NES controller port, controller and wire

Port 1 Port 2 (Optional) Note
GND Any ground pin
VCC (Power) 5Volt pin
NES Clock GPIO5 GPIO10
NES LATCH GPIO9 GPIO11
NES Data GPIO6 GPIO12

Image

[!NOTE] Contrary to other configurations where VCC is connected to 3Volt, VCC should be connected to a 5Volt pin. Otherwise the NES controller could possibly not work.

WII-Classic controller.

When using a WII-Classic controller you need:

Connections are as follows:

Nunchuck Breakout Adapter RP2040-PiZero
3.3V 3V3
GND GND
SDA GPIO2
SCL GPIO3

flashing the Waveshare RP2040-PiZero Development Board

[!NOTE] When the emulator won't start after flashing or powering on, and the screen shows 'No signal,' press the run button once again. The emulator should now boot.

Image: one or two player setup with usb controller and NES controller port

In this image the NES controller port is wired to port 1.

For single player games, connect either an USB controller or a NES controller. Not both!

For two player games: Connect a USB controller for player 1 and a NES controller for player 2.

Image

Image

Image: Two player setup using two NES controllers or a USB controller and a NES controller

Choose either of the following:

Image

Image: Using a wii-classic controller

WS-Wiiclassic

WS-Wiiclassic2

3D printed case for RP2040-PiZero

Gavin Knight (DynaMight1124) designed a NES-like case you can 3d-print as an enclosure for this board. This enclosure is designed for 2 NES controller ports so you can play 1 or 2-player games. Click here for the design. Please contact the creator on his Thingiverse page if you have any questions about this case.

WS3D1

WS3D2


PCB with Raspberry Pi Pico or Pico 2

Create your own Pico-based NES console. It features two NES controller ports for 1 or 2-player games.

Designed by @johnedgarpark

IMG_6011

Several Companies can make these PCBs for you.

I personally recommend PCBWay. The boards i ordered from them are of excellent quality. They have also a very short lead time. Boards i ordered on Monday arrived from China to my home in the Netherlands on Friday of the same week.

Image

When ordering, simply upload the zip file containing the gerber design. This file (pico_nesPCB_v2.1.zip) is available in the releases page and can also be found in the PCB folder.

[!NOTE] Soldering skills are required. Make sure you solder all the connections from the Pico onto the PCB. Also the connections on the short right-side of the Pico. (For ground)

[!NOTE] If you are looking for the previous design (v0.2). You can find it here

[!NOTE] It seems that sellers on AliExpress have copied the PCB design and are selling pre-populated PCB's. I do not condone this in any way. For questions about those boards, please contact the seller on AliExpress.

Other materials needed:

When using a Pico, Flash piconesPlusAdaFruitDVISD.uf2 from the releases page. When using a Pico 2 flash pico2_piconesPlusAdaFruitDVISD.uf2 instead.

Image: Two player setup using two NES controllers or a USB controller and a NES controller

Choose either of the following:

image0

3D printed case for PCB

Gavin Knight (DynaMight1124) designed a NES-like case you can 3d-print as an enclosure for this pcb. You can find it here: https://www.thingiverse.com/thing:6689537. Here you can find two designs: the latest design for PCB v2.0 and the previous design for PCB v0.2. In the latest v2.0 design, you can choose between two top covers, one with a button connecting to the bootsel button for easy firmware upgrades, the other without the button. In this case you have to remove the top cover to access the bootsel button. See images below. Make sure to print the correct files for the PCB version you own. You can find more information on Gavin's Thingiverse page.

Top Cover v2.0 without button (Top_v2.0.stl)

Top cover without button

Top Cover v2.0 with bootsel button (Top_v2.0_with_Bootsel_Button.stl)

Top Cover with button to access bootsel

Base v2.0 (Base_v2.0.stl)

3d2playerBottom

on/off button (Power_Switch.stl)

powerswitch


Gamepad and keyboard usage

Menu Usage

Gamepad buttons:

The colors in the menu can be changed and saved:

When using an USB-Keyboard:

Emulator (in game)

Gamepad buttons:

When using a Genesis Mini controller, press C for SELECT.

When using an USB-Keyboard

[!NOTE] The standard NES style layout is used for all controller types. So when using XInput controllers, B and A are swapped.


Save games

For games which support it, saves will be stored in the /SAVES folder of the SD card. Caution: the save ram will only be saved back to the SD card when quitting the game via (START + SELECT)


Raspberry Pico W support

The emulator works with the Pico W, but without the onboard blinking led. In order for the led to work on the Pico W, the cyw43 driver needs to be initialised. This causes the emulator to stop with an out of memory panic.


USB game Controllers latency

Using a USB gamecontroller introduces some latency. The legacy controllers ((S)NES, WII-classic) have less latency.


Troubleshooting usb controllers

AliExpress Controllers (Mantapad)

When starting a game, and the controller is unresponsive, you have to unplug and replug the controller to get it working. Not all controllers behave this way. I have a SNES controller that has no problems. The NES controller however must alwas be replugged to make it work. It is kind of a hit and miss.

XInput style controllers.

Might not work with all controllers.

Tested devices:

Troubleshooting:

After flashing some bigger games, the controller might become unresponsive:


Troubleshooting no image on TV or monitor

Image


Known Issues and limitations


Building from source

Best is to use the included build script buildAll.sh. You can then copy the correct .uf2 to your Pico via the bootsel option. The script builds all the .uf2 files and puts them in the releases folder.

git clone https://github.com/fhoedemakers/pico-infonesPlus.git
cd pico-infonesPlus
git submodule update --init
chmod +x build*.sh
./buildAll.sh

Alternatively, you can use the bld.sh shell script:

Build script for the pico-InfoNESPlus project

Usage: ./bld.sh [-d] [-2 | -r] [-t path to toolchain] [-c <hwconfig>]
Options:
  -d: build in DEBUG configuration
  -2: build for Pico 2 board (RP2350)
  -r: build for Pico 2 board (RP2350) with riscv core
  -t <path to toolchain>: only needed for riscv, specify the path to the riscv toolchain bin folder
  -c <hwconfig>: specify the hardware configuration
     1: Pimoroni Pico DV Demo Base (Default)
     2: Breadboard with Adafruit AdaFruit DVI Breakout Board and AdaFruit MicroSD card breakout board
        Custom pcb
     3: Adafruit Feather RP2040 DVI
     4: Waveshare RP2040-PiZero
     hwconfig 3 and 4 are RP2040-based boards, so they cannot be built for Pico 2
  -h: display this help

To install the RISC-V toolchain:
 - Raspberry Pi: https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-5/riscv-toolchain-14-aarch64-lin.tar.gz
 - X86/64 Linux: https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-5/riscv-toolchain-14-x86_64-lin.tar.gz
and extract it to $PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2

Example riscv toolchain install for Raspberry Pi OS:

        cd
        sudo apt-get install wget
        wget https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-5/riscv-toolchain-14-aarch64-lin.tar.gz
        mkdir -p $PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2
        tar -xzvf riscv-toolchain-14-aarch64-lin.tar.gz -C $PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2

To build for riscv:

        ./bld.sh -c <hwconfig> -r -t $PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2/bin

When using Visual Studio code, choose the Release or the RelWithDebuginfo build variant.


Credits

InfoNes is programmed by Jay Kumogata and ported to the Raspberry Pi Pico by Shuichi Takano.

I contributed by programming functionality for SD card, menu, 2-player games and support for various USB gamepads and keyboard.

PCB design by John Edgar Park.

3D-printable case for PCB and WaveShare RP2040 by Gavin Knight

NES gamepad support contributed by PaintYourDragon & Adafruit.

WII-Classic controller support by PaintYourDragon & Adafruit.

Adafruit Feather DVI - RP2040 support by PaintYourDragon & Adafruit.

XInput driver: https://github.com/Ryzee119/tusb_XInput by Ryzee119


Other versions

There is also a version available for the Pimoroni PicoSystem handheld.

Image