I’ve hit my limit!

So anyways, normally I end up having nothing to write here, so I usually don’t. But once in a while I get a good question from someone which gives me a good idea for a post. This time I was asked about frame-limiting/frame-skipping in the context of an emulator.

For people new to the concept, I guarantee their first attempt(for at least frame-limiting) probably looks like this:

DrawFrame();
framecount++;
if (framecount > 60)
{
WaitUntilSecondIsUp();
framecount = 0;
}

For those of us that have already implemented a good frame-limiting scheme, you’ll know already what’s wrong with it :) You see, what you want is to have a steady frame rate regardless of how fast your emulator’s progressing. The problem is, say your system is capable of emulating at a speed like 100 FPS(a bit of stretch, but hey, some older emulated systems can run that fast and then some), if you render only the first 60 FPS and wait till the end of the second before you resume rendering, you’ll have around 4/10’s of a second where you’re doing nothing. Visibly, you’ll see gameplay going at a really jittery, disconnected pace.

A better solution is to calculate the time of each rendered frame and compare after each frame rendered to see how much you need to delay emulation by. There’s obviously a little more overhead, but the results are much, much better.

Leave a Reply

You must be logged in to post a comment.