badvision / esp32_nesemu

Based on espressif's nesemu port with MittisBootloop's "Pretty Effect" menu. Supports PSX Controller and either SD Card or SPIFFS [Platform.IO]
41 stars 10 forks source link

Game and music played too quickly #2

Open jd5000 opened 3 years ago

jd5000 commented 3 years ago

I compiled it on latest Platformio v2.3.3 under Ubuntu 20.04, and flashed on DOIT ESP32 DEVKIT V1 (with ESP-WROOM-32 chip), it worked but the game and music played too quickly, for example the 400 seconds timer in Super Mario will finish in about 1 minute. Maybe the original timing is not fully compatible with latest compiler.

badvision commented 3 years ago

The NES timing of the emulator is controller here:

https://github.com/badvision/esp32_nesemu/blob/c2b65885d9924eb36794396f321372cc1031f004/lib/nofrendo/src/nes/nes.c#L46

It looks like the emulator is hardwired to run games at 60hz. If you try a PAL version of a game made for 50hz systems then it might run 20% faster than it should. Can you confirm if your are using an NTSC or a PAL game file?

-Brendan

jd5000 commented 3 years ago

I tried a few games, they all running very quickly. I believe they should be NTSC version, because when I run them on MittisBootloop's pre-compiled firmware, speed is normal.

SpazCode153 commented 2 years ago

Hi @jd5000 I managed to overcome this issue by defining PAL in nes.h above the ifdef but this I had to do as the ROM was PAL If the ROM is a European ROM its most likely be the PAL version however American ones are NTSC. Try the define in the nes.h file and see if it works.

/ NTSC = 60Hz, PAL = 50Hz /

define PAL

ifdef PAL

define NES_REFRESH_RATE 50

else / !PAL /

define NES_REFRESH_RATE 60

endif / !PAL /

for reference this is one of the games I tried and it works at normal speed if you add the define