michael-fadely / sadx-frame-limit

A more precise framerate limiter for SADX.
MIT License
2 stars 2 forks source link

Fix persistent stutter #1

Closed michael-fadely closed 2 months ago

michael-fadely commented 2 months ago

A long-standing issue caused by limiting the framerate to 60 FPS from the game's vanilla 61-62.5 FPS (or whatever) has been fixed. While frame delivery (present to display) was fine, every second or so, an extra game logic tick would execute to compensate for the "lag" induced by the limiter (again, going from >60 FPS to exactly 60 FPS), manifesting in a visible stutter. This means in-game time ran slightly fast as well.

This PR fixes this issue by disabling frame skip as a lag compensation mechanism. This is one of 3 modes currently configurable at compile time. There is also a mode which more closely resembles the original game's implementation, as well as a mode which uses a hybrid approach. Neither of these modes are recommended, and details are provided in the code comments.

One item that will need to be restored in the near future is the lenient wait loop. The last major version uses a CPU sleep for the majority of the frame wait time, then spins on the remainder. This implementation spins for the entire duration of the wait time. This may cause problems for some uses on low-end systems.