Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FreeJ2ME + Anbu + Libretro: Implement a better frame limit logic
Previously, frame limiting in FreeJ2ME relied on a fixed interval for Thread.sleep(), which is already a bit innacurate by itself, but with a fixed sleep interval meant that the time the game logic took to render also influenced the reslulting framerate. For example: If a game took 3ms to render and the fps limit was set to 60 fps, the resulting framerate would be around 50 to 51fps, as the limit would actually be ~19,666ms (3ms + 16,666ms fixed). This new logic works by calculating the time it took to render the last frame and subtracting it from the time we should wait for the next one, which will then be our Thread.sleep() interval. While it still relies on Thread.sleep() and its inaccuracies, this approach is miles better than what was already in place, case in point, jbenchmark 2.0 now locks around 59.5 to 60.3 fps in all tests on my machine, whereas it ran at about 48.6fps on the first test, 55.3 on the second, 56.4 on the third and 52.5 on the fourth.
- Loading branch information