diff --git a/stella/src/gp2x/OSystemGP2X.cxx b/stella/src/gp2x/OSystemGP2X.cxx index 379ab18c1..7e24494ba 100644 --- a/stella/src/gp2x/OSystemGP2X.cxx +++ b/stella/src/gp2x/OSystemGP2X.cxx @@ -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; } }