I just started a very early NES emu (no mappers atm ), and I know there are better methods but I'm just beginning and will move to them later. So I have an EmulateFrame function and on my netbook, I have a hard time regulating 60 fps. How would I go about doing that? Currently I have:
but on my netbook that sometimes results in less than ideal framerate. Is there a better way of doing it?
Also if I can't use another thread for sound, is there a way of making the sound, sound smooth? If i put my wanted fps at 60 it'll garble, if i target something higher it'll sound smooth but be out of sync (obviously )
Code:
int framesDone = 0;
int time = TimeTick(); // In Millisecs
// Main loop;
int framesWanted = (TimeTick() - time) / 1000.0f * FPS - framesDone;
for (int i = 0; i < framesWanted; ++i)
EmulateFrame();
int time = TimeTick(); // In Millisecs
// Main loop;
int framesWanted = (TimeTick() - time) / 1000.0f * FPS - framesDone;
for (int i = 0; i < framesWanted; ++i)
EmulateFrame();
but on my netbook that sometimes results in less than ideal framerate. Is there a better way of doing it?
Also if I can't use another thread for sound, is there a way of making the sound, sound smooth? If i put my wanted fps at 60 it'll garble, if i target something higher it'll sound smooth but be out of sync (obviously )