How to ensure that the output video of ppu is around 60 frames?

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
GZYangKui
Posts: 46
Joined: Wed Dec 21, 2022 6:54 am

How to ensure that the output video of ppu is around 60 frames?

Post by GZYangKui »

At present, my program uses the most original scheme to ensure that the fps is 60 frames, that is, when the ppu outputs through "Thread. sleep (mill)". But using this method does not guarantee that the fps is maintained at 60 frames. Is there any good processing scheme to maintain the fps at about 60 frames?
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: How to ensure that the output video of ppu is around 60 frames?

Post by Dwedit »

This is a complicated topic, and there are several approaches to this. It depends on your platform, or which graphics API you are targeting.

NES has a framerate of 60.098FPS, and that does not match a common monitor refresh rate of ~60Hz. Also even 60Hz has some variance here, you can often see +/- 0.02 Hz.

Because of the mismatch, you either need to do one of the following:
* Make the user set up a custom refresh rate to better match 60.098FPS (Yes this is actually possible)
* Draw at 60.098FPS with screen tearing
* Draw at 60.098FPS with vsync, with occasional frames being discarded to fit the monitor refresh rate
* Draw at 60FPS (matching the monitor's refresh rate) and slow down the audio slightly

On a Variable Frame Rate display, you can simply pick "Draw at 60.098FPS" and there should not be any screen tearing. May require going fullscreen first.

The problem with adjusting the framerate from 60.098 to 60FPS is that after you play for an hour, you're 5.8 seconds behind. This is okay for most cases, but not okay for speedrun races of long games or RPGs.

---

(will post more soon)
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Post Reply