Peeled back last change. I vaguely recall a conversation a year ago about not needing accurate timing.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1241 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
azaballa 2006-12-26 04:35:36 +00:00
parent 5eba721e55
commit 09c3a38a0d
1 changed files with 23 additions and 71 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: OSystemGP2X.cxx,v 1.21 2006-12-26 02:20:23 azaballa Exp $
// $Id: OSystemGP2X.cxx,v 1.22 2006-12-26 04:35:36 azaballa Exp $
// Modified on 2006/01/06 by Alex Zaballa for use on GP2X
//============================================================================
@ -83,80 +83,32 @@ void OSystemGP2X::mainLoop()
// and are needed to calculate the overall frames per second.
uInt32 frameTime = 0, numberOfFrames = 0;
if(mySettings->getBool("accurate")) // normal, CPU-intensive timing
// Set up less accurate timing stuff
uInt32 startTime, virtualTime, currentTime;
// Set the base for the timers
virtualTime = getTicks();
frameTime = 0;
// Main game loop
for(;;)
{
// Set up accurate timing stuff
uInt32 startTime, delta;
// Exit if the user wants to quit
if(myEventHandler->doQuit())
break;
// Set the base for the timers
frameTime = 0;
startTime = getTicks();
myEventHandler->poll(startTime);
myFrameBuffer->update();
// Main game loop
for(;;)
{
// Exit if the user wants to quit
if(myEventHandler->doQuit())
break;
currentTime = getTicks();
virtualTime += myTimePerFrame;
if(currentTime < virtualTime)
SDL_Delay((virtualTime - currentTime)/1000);
startTime = getTicks();
myEventHandler->poll(startTime);
myFrameBuffer->update();
// Now, waste time if we need to so that we are at the desired frame rate
for(;;)
{
delta = getTicks() - startTime;
if(delta >= myTimePerFrame)
break;
}
frameTime += getTicks() - startTime;
++numberOfFrames;
}
}
else // less accurate, less CPU-intensive timing
{
// Set up less accurate timing stuff
uInt32 startTime, virtualTime, currentTime;
// Set the base for the timers
virtualTime = getTicks();
frameTime = 0;
// Main game loop
for(;;)
{
// Exit if the user wants to quit
if(myEventHandler->doQuit())
break;
startTime = getTicks();
myEventHandler->poll(startTime);
myFrameBuffer->update();
currentTime = getTicks();
virtualTime += myTimePerFrame;
if(currentTime < virtualTime)
{
SDL_Delay((virtualTime - currentTime)/1000);
}
currentTime = getTicks() - startTime;
frameTime += currentTime;
++numberOfFrames;
}
}
// Only print console information if a console was actually created
if(mySettings->getBool("showinfo"))
{
double executionTime = (double) frameTime / 1000000.0;
double framesPerSecond = (double) numberOfFrames / executionTime;
cout << endl;
cout << numberOfFrames << " total frames drawn\n";
cout << framesPerSecond << " frames/second\n";
currentTime = getTicks() - startTime;
frameTime += currentTime;
++numberOfFrames;
}
}