/sprig-nes

A Sprig customization of fhoedemaker's pico-infonesPlus project

Primary LanguageCGNU General Public License v3.0GPL-3.0

pico-infonesPlus

A more comprehensive guide from Adafruit can be found here

A NES (Nintendo Entertainment System) emulator for the Raspberry PI Pico and Adafruit feather RP2040 DVI with SD card and menu support. Uses HDMI for display.

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.

In stead of flashing a NES rom to the Pico using picotool, you 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.

You can use it with these RP2040 boards and configurations:

  • Raspberry Pi Pico. Requires one of these addons:

  • Adafruit Feather RP2040 with DVI (HDMI) Output Port. For use with a USB gamecontroller or a legacy NES controller, or even a WII classic controller. Requires these addons:

See below to see how to setup your specific configuration.

Gamecontroller support

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

  • Raspberry Pi Pico
    • USB controllers
      • Sony Dual Shock 4
      • Sony Dual Sense
      • BUFFALO BGC-FC801 connected to USB - not tested
    • Legacy Controllers
      • An original NES controller. Requires soldering when using Pico DV Demo Base.
      • An original SNES controller. PCB Only
      • WII-classic controller. Breadboard only. Not tested - should work
  • Adafruit Feather RP2040 with DVI (HDMI)
    • USB controllers
      • Sony Dual Shock 4
      • Sony Dual Sense
      • BUFFALO BGC-FC801 connected to USB - not tested
    • Legacy Controllers
      • An original NES controller.
      • WII-classic controller.

When using Legacy Controllers, you need these additional items:

Video

Click on image below to see a demo video.

Video

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.

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

materials needed

  • Raspberry Pi Pico with soldered male headers.
  • Pimoroni Pico DV Demo Base.
  • Micro usb to usb OTG Cable
  • Controllers (Depending on what you have)
  • HDMI Cable.
  • Micro usb power adapter.
  • Micro usb to usb cable when using the Duak Shock 4 controller
  • USB C to USB data cable when using the Sony Dual Sense controller.
  • FAT 32 formatted Micro SD card with roms you legally own. Roms must have the .nes extension. You can organise your roms into different folders.

flashing the Pico

  • Download piconesPlusPimoroniDV.uf2 from the releases page.
  • Push and hold the BOOTSEL button on the Pico, then connect to your computer using a micro usb cable. Release BOOTSEL once the drive RPI-RP2 appears on your computer.
  • Drag and drop the UF2 file on to the RPI-RP2 drive. The Raspberry Pi Pico will reboot and will now run the emulator.

Pinout

NES controller port (if you want to use a NES controller).

Note: This requires soldering!

Port GPIO Pin number
NES Clock GP14 19
NES Data GP15 20
NES LATCH GP16 21
VCC (Power) 3V3 on base
GND GND on base

setting up the hardware

  • Disconnect the Pico from your computer.
  • Attach the Pico to the DV Demo Base.
  • Connect the HDMI cable to the Demo base and your monitor.
  • Connect the usb OTG cable to the Pico's usb port.
  • Depending which controller you want to use:
    • Connect the controller to the other end of the usb OTG.
    • Connect legacy NES controller to NES controller port.
  • Insert the SD card into the SD card slot.
  • Connect the usb power adapter to the usb port of the Demo base.
  • Power on the monitor and the Pico

Image

Raspberry Pi Pico, setup with Adafruit hardware and breadboard

materials needed

flashing the Pico

  • Download piconesPlusAdaFruitDVISD.uf2 from the releases page.
  • Push and hold the BOOTSEL button on the Pico, then connect to your computer using a micro usb cable. Release BOOTSEL once the drive RPI-RP2 appears on your computer.
  • Drag and drop the UF2 file on to the RPI-RP2 drive. The Raspberry Pi Pico will reboot and will now run the emulator.

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:

  • Wire Pico Pin 38 to the breadboard ground column (-)
  • Wire the breadboard left ground column (-) with the breadboard right ground column (-)

Adafruit Micro-SD breakout board+

Breakout GPIO Pin number
CS GP5 7
CLK (SCK) GP2 4
DI (MOSI) GP3 5
DO (MISO) GP4 6
3V 36 (3v3 OUT)
GND Ground on breadboard (-)

Adafruit DVI Breakout For HDMI Source Devices

Breakout GPIO Pin number
D0+ GP12 16
D0- GP13 17
CK+ GP14 19
CK- GP15 20
D2+ GP16 21
D2- GP17 22
D1+ GP18 24
D1- GP19 25
5 (*) VBUS 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. (If you want to use a NES controller)

Port GPIO Pin number
NES Clock GP6 9
NES Data GP7 10
NES LATCH GP8 11
VCC (Power) 36 (3v3 OUT)
GND Ground on breadboard (-)

Image

setting up the hardware

  • Disconnect the Pico from your computer.
  • Attach the Pico to the breadboard.
  • Insert the SD card into the SD card slot.
  • Connect the HDMI cable to the Adafruit HDMI Breakout board and to your monitor.
  • Connect the usb OTG Y-cable to the Pico's usb port.
  • Connect the controller to the full size female usb port of the OTG Y-Cable.
  • Controllers (Depending on what you have)
    • Connect the Micro usb power adapter to the female Micro usb connecter of the OTG Y-Cable.
    • Connect your NES controller to the NES controller port.
  • Power on the monitor and the Pico

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

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:

flashing the Feather RP2040

  • Download piconesPlusFeatherDVI.uf2 from the releases page.
  • Connect the feather to a USB port on your computer using the USB-C data cable.
  • On the feather, push and hold the BOOTSEL button, then press RESET. Release the buttons, the drive RPI-RP2 should appear on your computer.
  • Drag and drop the UF2 file on to the RPI-RP2 drive. The Raspberry Pi Pico will reboot and will now run the emulator.

Pinout

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

Use the breadboard to connect all together:

  • Wire the 3.3V Pin to the breadboard + column.
  • Wire the GND Pin to the breadboard - column
  • Wire the breadboard left ground column (-) with the breadboard right ground column (-)
  • Optional: Attach a push button to the breadboard and connect a wire from this button to the Feather RST pin and breadboard ground column(-). This adds an extra easy to access Reset button.

Adafruit Micro-SD breakout board+

Breakout GPIO
CS GP10
CLK (SCK) GP14
DI (MOSI) GP15
DO (MISO) GP8
3V + column on breadboard connected to feather 3.3V pin
GND - column on breadboard connected to feather ground pin

WII nunchuck breakout adapter.

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

NES controller port.

Port GPIO
NES Clock 5
NES Data 6
NES LATCH 9
VCC (Power) + column on breadboard connected to feather 3.3V pin
GND - column on breadboard connected to feather ground pin

Image

setting up the hardware

  • Disconnect the Pico from your computer.
  • Attach the Adafruit Feather RP2040 DVI to the breadboard.
  • Insert the SD card into the SD card slot.
  • Connect the HDMI cable to the HDMI port of the Adafruit Feather and to your monitor.
  • Connect controllers depending on your setup:
    • Legacy controllers.
      • NES Controller to the NES controller port.
      • WII-Classic controller to the Nunchuck Breakout Adapter.
      • Connect USB-C power supply to USB-C connector.
    • USB game Controllers
      • Connect the USB C connector of the "male USB C to female micro usb cable" to the USB C port of the feather.
      • Connect the female micro USB port of the "male USB C to female micro usb cable" to the male micro USB port of the USB OTG Y cable.
      • Connect the Dual Sense or Dual Shock controller with the appropriate cable to the full size female usb port of the OTG Y-Cable.
      • Connect the Micro usb power adapter to the female Micro usb connecter of the OTG Y-Cable.
  • Power on the monitor and the Pico

Image

PCB with Raspberry Pi Pico

Note: Soldering skills are required.

Create your own little Pico Based NES console and play with an orginal (S)NES controller. The PCB design files can be found in the assets/pcb folder. Several Companies can make these PCBs for you.

I personally recommend PCBWay. The boards i ordered from them are of excellent quality.

Image

Simply upload the design files packed as a zip archive when ordering. A zip file containing the design files can be found on the releases page.

Other materials needed:

Flash the Pico with piconesPlusAdaFruitDVISD.uf2 from the releases page.

Image

Menu Usage

Gamepad buttons:

  • UP/DOWN: Next/previous item in the menu.
  • LEFT/RIGHT: next/previous page.
  • A (Circle): Open folder/flash and start game.
  • B (X): Back to parent folder.
  • START: Starts game currently loaded in flash.

Emulator (in game)

Gamepad buttons:

  • SELECT + START: Resets back to the SD Card menu. Game saves are saved to the SD card.
  • SELECT + UP/SELECT + DOWN: switches screen modes.
  • SELECT + A/B: toggle rapid-fire.
  • START + A : Toggle framerate display

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 no image on TV or monitor

  • Make sure the board is directly connected to your display. Do not connect through a HDMI splitter.
  • Some displays need 5V in order to work:
    • When using the breadboard with HDMI and SD breakout, make sure VBUS (Pin 40) is connected to the 5 volt via on the board. (Marked 5 on the side)

Image

Known Issues and limitations

  • Pimoroni Pico DV: Audio through the audio out jack is not supported, audio only works over hdmi.
  • Due to the Pico's memory limitations, not all games will work. Games not working will show a "Mapper n is unsupported." (n is a number). For example starting Castlevania III will show the "Mapper 5 is unsupported." message.
  • tar file support is removed.
  • Pico W: The onboard led does not blink every 60 frames.

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 three .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
./buildAll.sh

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

Credits

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

I contributed by adding SD card and menu support. For this reasons I made code changes to the emulator for accommodating the menu and SD card.

PCB design by @johnedgarpark.

NES gamepad support contributed by PaintYourDragon & Adafruit. If using Pimoroni Pico DV Demo Base: NES controller clock, data and latch go to GPIO pins 14, 15 and 16, respectively. If Adafruit DVI Breakout build, it's GPIO pins 6, 7, 8 instead. FeatherDVI Gamepad should be powered from 3.3V when connected to Pico GPIO, not 5V as usual...seems to work OK regardless.

WII-Classic controller support by PaintYourDragon & Adafruit.

Adafruit Feather DVI - RP2040 support by PaintYourDragon & Adafruit.

Other versions

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

Image