Using a Rasp Pico board to emulate NES

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
ropgar
Posts: 3
Joined: Sat Apr 03, 2021 6:25 am

Using a Rasp Pico board to emulate NES

Post by ropgar » Sat Apr 03, 2021 6:39 am

Hello All,

I'd like to share with you an alternative for emulating NES in a single board computer.
It runs games as the real device on a Rasp Pico RP2040 processor. This is a new product and it has enough power to emulate NES.

It can do 60 frames per second on VGA and emulates APU and PPP perfectly well.
It uses a PS/2 Keyboard as controller (I have no NES controller here with me) - but it's possible to make it work with a original NES controller.
Sound is very impressive and there no glitches on video and backgound game music.

This a video of demonstration with a short game play of Castlevania:
https://www.youtube.com/watch?v=_iFT6jDa9Ug

Is it of interest to this community?

User avatar
Dwedit
Posts: 4417
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Using a Rasp Pico board to emulate NES

Post by Dwedit » Sat Apr 03, 2021 4:48 pm

From Datasheet
RP2040 is a low-cost, high-performance microcontroller device with flexible digital interfaces. Key features:
•Dual Cortex M0+ processor cores, up to 133 MHz
•264 kB of embedded SRAM in 6 banks
•30 multifunction GPIO
•6 dedicated IO for SPI Flash (supporting XIP)
•Dedicated hardware for commonly used peripherals
•Programmable IO for extended peripheral support
•4 channel ADC with internal temperature sensor, 0.5 MSa/s, 12-bit conversion
•USB 1.1 Host/Device
From Youtube description:
RP2040 MCU is runing at 250MHz using both ARM Cotex M0+ Cores.
One core runs the emulator and the order runs the VGA and sound driver.
...
Sound is done with a single PWM GPIO port running as PDM at a very high frequency.
Interesting how the YouTube video runs it at 250MHz while the datasheet claims "up to 133MHz".
RAM is really tiny here. There probably isn't enough RAM to store a 256K-sized NES ROM in the RAM, seems like it would be forced into Flash ROM instead.

RP2040 has no built-in flash, it must be external. Despite being SPI (serial interface), it supports "execute in place" by reading code into cache memory.


So in some ways, this is far stronger hardware than a GBA (much higher clock speed), yet in other ways, much weaker than a GBA (Less RAM, no built-in graphics and sound, they need to be bit-banged in software)
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

lidnariq
Posts: 10423
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Using a Rasp Pico board to emulate NES

Post by lidnariq » Sat Apr 03, 2021 5:13 pm

The kinda nifty thing about the Pico is that it has a couple special processors ("PIO") that operate like one cog out of a Propeller, or the Beaglebone PRU. Someone (on the RP2040 dev team) has abused them to bitbang DVI, which isn't something I thought I was going to see.

Apparently although the Pico is only officially rated to 133MHz, apparently all units actually seen so far can operate at 250MHz, or 320-odd MHz with a little overvolting and extra heat sinking.

But other than the special features that the Pico can bring to the table, I'm not certain what makes a baremetal NES emulator on it any different from such an emulator on a ESP32 or similar SoCs.

ropgar
Posts: 3
Joined: Sat Apr 03, 2021 6:25 am

Re: Using a Rasp Pico board to emulate NES

Post by ropgar » Sat Apr 03, 2021 5:23 pm

Interesting how the YouTube video runs it at 250MHz while the datasheet claims "up to 133MHz".
RAM is really tiny here. There probably isn't enough RAM to store a 256K-sized NES ROM in the RAM, seems like it would be forced into Flash ROM instead.

RP2040 has no built-in flash, it must be external. Despite being SPI (serial interface), it supports "execute in place" by reading code into cache memory.
Yes, the official datasheet says 133MHz, but the C/C++ SDK has a function that allows the developer to set any CPU speed.
It can be seen in Raspberry Forum: Overclocking Pico with up to 436MHz works: https://www.raspberrypi.org/forums/view ... p?t=301902

ROM is placed in Flash - 2MB.
So in some ways, this is far stronger hardware than a GBA (much higher clock speed), yet in other ways, much weaker than a GBA (Less RAM, no built-in graphics and sound, they need to be bit-banged in software)
Yes, you are right. To compensate for the lack of RAM and no dedicated graphics/sound chipset, Pico has other goodies, such as dual-core, high speed CPU, dedicated PIO with 8 State Machunes for controlling GPIO with no use of CPU etc.

ropgar
Posts: 3
Joined: Sat Apr 03, 2021 6:25 am

Re: Using a Rasp Pico board to emulate NES

Post by ropgar » Sat Apr 03, 2021 5:32 pm

lidnariq wrote:
Sat Apr 03, 2021 5:13 pm
But other than the special features that the Pico can bring to the table, I'm not certain what makes a baremetal NES emulator on it any different from such an emulator on a ESP32 or similar SoCs.
Pico can run at 250MHz with no heat sinking or overvolting.

You are right. It's very similar to emulating with ESP32 or similar SoCs. But in this case it uses PIO for VGA and it can use an Interpolation dedicated hardware that can process Affine Transformations in a single cycle per pixel. This feature allows to run SNES Mode 7, for instance, in hardware, likewise SNES / Nintendo DS does.

You can combine the Interpolation Hardware with DMA and PIO... power!
I think RaspPi Pico is very well suited for emulation / graphic / sound applications. Better than other SoCs.

Post Reply