jsnes-web
jsnes-web copied to clipboard
Emulator speed
@bfirsh Hi. Could you help me with one question. I tried to run my custom game by example from source directory https://github.com/bfirsh/jsnes and compare it with the same game in web https://jsnes.org/. I tested it on same computer. And in case of example I see that game is faster than in web. I think the difference is about 15-20%. Could you help me with it? How can I set the speed of emulated game?
I've encountered two speed related issues while porting this to my own project. The first one is to ensure you are running NTSC roms, as this repo is currently locked to US frame rates (60Hz)... This one could be resolved via a feature which detects the ROM region, or provides a UI with a PAL/NTSC toggle.
The second is from using displays over 60Hz because of the use of requestAnimationFrame()
, which is typically locked to a monitors refresh rate. To put a frame limiter for 60FPS I used a time based check, which uses a frame skip. An example of this can be seen here. My debugging case for this was subtle, because I had a dual monitor setup – one with 60Hz and the other with 75Hz (ultrawide). Once I dragged between the 60Hz monitor to the 75Hz monitor the speed would increase/stabilise.
As for the solution, this would only require a tweak inside FrameTimer.js
on the callback method. However I do still believe the code for this could be further optimised with use of performance.now()
for time checking.
@bfirsh This could be a solution for people running refresh rates over 60Hz
My computer screen has a refresh rate of 165Hz, and when I use it to run 90 tanks it is much, much faster than normal. But I find that when I minimize the window, the soundtrack sounds like it's back to normal speed. However, once I open the window again, the speed comes back up.