Re: Emulating NES CPU and PPU on PIC32, too slow?
Posted: Wed Feb 26, 2025 2:38 am
AndrewP wrote:
Looking really good! It must be so satisfying to have that up and running 
I was doing some speed tests with Super Mario, and I found while running at 20 FPS, my emulator was about 10% too slow. If I disabled audio, it was about 7% too slow.
I tried to 'interlace' the scanlines, essentially using DMA only half the time. That totally failed my expectations! It seems the internal cache of the processor does a LOT even while DMA is running at full speed. Or perhaps that's why DMA takes 4 cycles, so the CPU can still do it's thing? Either way, interlacing does not help, as of now.
The only other option is to go faster. Currently the PIC32 is running at 200 MHz, which is the theoretical maximum for older versions of that chip, but the newer ones are rated to 252 MHz. So found a VGA output with a pixel clock of 108 MHz, double that to make 216 MHz on the CPU side, each pixel is doubled in size horizontally. That made it only 3% slower, and with audio disabled it was perfect speed.
This evening I had an idea to remove the 'overscan' lines at the top and bottom. Essentially all CRT TV's in the 80's and 90's couldn't properly display the top 8 scanlines or the bottom 8 scanlines. So I removed them from my drawing functions, and sure enough, I'm at perfect speed now, even with audio enabled!
Still, that's only 20 FPS. Some games don't do well with that, but overall it's very playable
Instead of going to MMC1 mapper games next, I'm going to make a pit-stop at the CNROM, UNROM, and AOROM games. They seem very easy to 'map' and will include some cool games like Castlevania and Contra. Lastly, the audio isn't *perfect*, with that buzzing sound still there, but that will have to be another day
There's the update. I really didn't think this could be done, at all. Now it's very much possible! Thank you everyone!
Chad