}
/* This comes nearly straight from snes9x */
+/** Calculates framerate, enables frame skip if to low, sleeps if too high, etc. */
static void frameSync() {
+ Uint32 now = SDL_GetTicks();
+
if (Settings.TurboMode)
{
+ // In Turbo mode, just skip as many frames as desired, but don't sleep.
if(Settings.SkipFrames == AUTO_FRAMERATE ||
++IPPU.FrameSkip >= Settings.SkipFrames)
{
++IPPU.SkippedFrames;
IPPU.RenderThisFrame = FALSE;
}
- return;
+
+ // Take care of framerate display
+ if (Settings.DisplayFrameRate) {
+ static Uint32 last = 0;
+ // Update framecounter every second
+ if (now > last && (now - last > 1000)) {
+ IPPU.DisplayedRenderedFrameCount =
+ IPPU.RenderedFramesCount;
+ IPPU.RenderedFramesCount = 0;
+ last = now;
+ }
+ }
} else {
static Uint32 next1 = 0;
- Uint32 now = SDL_GetTicks();
// If there is no known "next" frame, initialize it now
if (next1 == 0) {
// Calculate the timestamp of the next frame.
next1 += Settings.FrameTime;
+
+ // Take care of framerate display
+ if (Settings.DisplayFrameRate) {
+ // Update every theoretical 60 frames
+ if (IPPU.FrameCount % Memory.ROMFramesPerSecond == 0) {
+ IPPU.DisplayedRenderedFrameCount =
+ IPPU.RenderedFramesCount;
+ IPPU.RenderedFramesCount = 0;
+ }
+ }
}
}