Removed "Experimental timing" as an option from the Makefile. Option is

now always compiled into the SDL and X11 versions.

Default is to use the CPU-intensive (normal) timing code.  The less CPU-
intensive timing can be selected with the commandline argument '-nohog', or
by setting 'nohog = 1' in the rc file.

Note that the nohog setting works much better in SDL vs. X11, since SDL_Delay()
seems to have a finer granularity than usleep().


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@105 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2002-08-04 00:28:18 +00:00
parent 457b1edfab
commit a6d330fa2c
6 changed files with 191 additions and 164 deletions

View File

@ -13,7 +13,7 @@
## See the file "license" for information on usage and redistribution of ## See the file "license" for information on usage and redistribution of
## this file, and for a DISCLAIMER OF ALL WARRANTIES. ## this file, and for a DISCLAIMER OF ALL WARRANTIES.
## ##
## $Id: makefile,v 1.18 2002-08-03 22:52:39 stephena Exp $ ## $Id: makefile,v 1.19 2002-08-04 00:28:18 stephena Exp $
##============================================================================ ##============================================================================
##============================================================================ ##============================================================================
@ -35,8 +35,8 @@ OPTIMIZATIONS =
# -malign-functions=2 -malign-jumps=2 -malign-loops=2 # -malign-functions=2 -malign-jumps=2 -malign-loops=2
### to get full optimization under gcc/x Athlon based OS's.. ### to get full optimization under gcc/x Athlon based OS's..
# OPTIMIZATIONS = -O3 -mcpu=athlon -march=athlon -Wall -Wno-unused \ # OPTIMIZATIONS = -O3 -mcpu=athlon -march=athlon -Wall -Wno-unused \
-funroll-loops -fstrength-reduce -fomit-frame-pointer -ffast-math \ # -funroll-loops -fstrength-reduce -fomit-frame-pointer -ffast-math \
-falign-functions=2 -falign-jumps=2 -falign-loops=2 # -falign-functions=2 -falign-jumps=2 -falign-loops=2
### if your C++ compiler doesn't support the bool type ### if your C++ compiler doesn't support the bool type
# BSPF_BOOL = 1 # BSPF_BOOL = 1
@ -55,10 +55,10 @@ OPTIMIZATIONS =
### Only X11 and SDL ports supported for now ### Only X11 and SDL ports supported for now
# SNAPSHOT_SUPPORT = 1 # SNAPSHOT_SUPPORT = 1
### to enable EXPERIMENTAL TIMING code ### comment this out if your system doesn't
### Enables emulator to not use 100% CPU ### have the gettimeofday function
### Only X11 and SDL ports supported for now ### Currently, the X11 version won't compile without it
# EXPERIMENTAL_TIMING = 1 HAVE_GETTIMEOFDAY = 1
##============================================================================ ##============================================================================
## All done, type make to get a list of frontends ## All done, type make to get a list of frontends
@ -124,9 +124,9 @@ OPTS.SDL += -DHAVE_PNG=1
LIBS.SDL += -lpng LIBS.SDL += -lpng
endif endif
ifdef EXPERIMENTAL_TIMING ifdef HAVE_GETTIMEOFDAY
OPTS.X11 += -DEXPERIMENTAL_TIMING=1 OPTS.X11 += -DHAVE_GETTIMEOFDAY=1
OPTS.SDL += -DEXPERIMENTAL_TIMING=1 OPTS.SDL += -DHAVE_GETTIMEOFDAY=1
endif endif
default: default:

View File

@ -27,3 +27,4 @@
;ssdir = <pathname> ;ssdir = <pathname>
;ssname = <romname|md5sum> ;ssname = <romname|md5sum>
;sssingle = <0|1> ;sssingle = <0|1>
;nohog = <0|1>

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Settings.cxx,v 1.1 2002-03-21 22:47:00 stephena Exp $ // $Id: Settings.cxx,v 1.2 2002-08-04 00:28:18 stephena Exp $
//============================================================================ //============================================================================
#include "Settings.hxx" #include "Settings.hxx"
@ -28,6 +28,7 @@ Settings::Settings()
theHideCursorFlag = false; theHideCursorFlag = false;
theUsePrivateColormapFlag = false; theUsePrivateColormapFlag = false;
theMultipleSnapShotFlag = true; theMultipleSnapShotFlag = true;
theHogCPUFlag = true;
theDesiredVolume = 75; theDesiredVolume = 75;
theDesiredFrameRate = 60; theDesiredFrameRate = 60;
thePaddleMode = 0; thePaddleMode = 0;
@ -106,6 +107,10 @@ bool Settings::handleCommandLineArgs(int argc, char* argv[])
{ {
theShowInfoFlag = true; theShowInfoFlag = true;
} }
else if(string(argv[i]) == "-nohog")
{
theHogCPUFlag = false;
}
else if(string(argv[i]) == "-zoom") else if(string(argv[i]) == "-zoom")
{ {
uInt32 size = atoi(argv[++i]); uInt32 size = atoi(argv[++i]);
@ -251,6 +256,14 @@ void Settings::handleRCFile(istream& in)
else if(option == 0) else if(option == 0)
theShowInfoFlag = false; theShowInfoFlag = false;
} }
else if(key == "nohog")
{
uInt32 option = atoi(value.c_str());
if(option == 1)
theHogCPUFlag = false;
else if(option == 0)
theShowInfoFlag = true;
}
else if(key == "zoom") else if(key == "zoom")
{ {
// They're setting the initial window size // They're setting the initial window size

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Settings.hxx,v 1.1 2002-03-21 22:47:00 stephena Exp $ // $Id: Settings.hxx,v 1.2 2002-08-04 00:28:18 stephena Exp $
//============================================================================ //============================================================================
#ifndef SETTINGS_HXX #ifndef SETTINGS_HXX
@ -53,6 +53,10 @@ class Settings
// overwriting the same file. Set to true by default. // overwriting the same file. Set to true by default.
bool theMultipleSnapShotFlag; bool theMultipleSnapShotFlag;
// Indicates whether to use more/less accurate emulation,
// resulting in more/less CPU usage.
bool theHogCPUFlag;
// Indicates what the desired volume is // Indicates what the desired volume is
uInt32 theDesiredVolume; uInt32 theDesiredVolume;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: mainSDL.cxx,v 1.24 2002-05-14 18:29:44 stephena Exp $ // $Id: mainSDL.cxx,v 1.25 2002-08-04 00:28:18 stephena Exp $
//============================================================================ //============================================================================
#include <fstream> #include <fstream>
@ -52,7 +52,6 @@
#define SDL_DISABLE 0 #define SDL_DISABLE 0
#endif #endif
#define HAVE_GETTIMEOFDAY 1
#define MESSAGE_INTERVAL 2 #define MESSAGE_INTERVAL 2
// function prototypes // function prototypes
@ -1329,6 +1328,7 @@ void usage()
" -sssingle Generate single snapshot instead of many", " -sssingle Generate single snapshot instead of many",
#endif #endif
" -pro <props file> Use the given properties file instead of stella.pro", " -pro <props file> Use the given properties file instead of stella.pro",
" -nohog Don't take all the CPU (gives less accurate emulation)",
"", "",
0 0
}; };
@ -1576,89 +1576,94 @@ int main(int argc, char* argv[])
return 0; return 0;
} }
#ifdef EXPERIMENTAL_TIMING // These variables are common to both timing options
// Set up timing stuff // and are needed to calculate the overall frames per second.
uInt32 startTime, frameTime, virtualTime, currentTime; uInt32 frameTime = 0, numberOfFrames = 0;
uInt32 numberOfFrames = 0;
uInt32 timePerFrame = (uInt32) (1000000.0 / (double) settings->theDesiredFrameRate);
// Set the base for the timers if(settings->theHogCPUFlag) // normal, CPU-intensive timing
virtualTime = getTicks();
frameTime = 0;
// Main game loop
for(;;)
{ {
// Exit if the user wants to quit // Set up accurate timing stuff
if(theQuitIndicator) uInt32 startTime, delta;
{ uInt32 timePerFrame = (uInt32) (1000000.0 / (double) settings->theDesiredFrameRate);
break;
}
startTime = getTicks(); // Set the base for the timers
if(!thePauseIndicator) frameTime = 0;
{
theConsole->mediaSource().update();
}
updateDisplay(theConsole->mediaSource());
handleEvents();
currentTime = getTicks(); // Main game loop
virtualTime += timePerFrame;
if(currentTime < virtualTime)
{
SDL_Delay((virtualTime - currentTime)/1000);
}
currentTime = getTicks() - startTime;
frameTime += currentTime;
++numberOfFrames;
}
#else
// Set up timing stuff
uInt32 startTime, frameTime, delta;
uInt32 numberOfFrames = 0;
uInt32 timePerFrame = (uInt32) (1000000.0 / (double) settings->theDesiredFrameRate);
// Set the base for the timers
frameTime = 0;
// Main game loop
for(;;)
{
// Exit if the user wants to quit
if(theQuitIndicator)
{
break;
}
// Call handleEvents here to see if user pressed pause
handleEvents();
if(thePauseIndicator)
{
updateDisplay(theConsole->mediaSource());
SDL_Delay(10);
continue;
}
startTime = getTicks();
theConsole->mediaSource().update();
updateDisplay(theConsole->mediaSource());
handleEvents();
// Now, waste time if we need to so that we are at the desired frame rate
for(;;) for(;;)
{ {
delta = getTicks() - startTime; // Exit if the user wants to quit
if(theQuitIndicator)
if(delta >= timePerFrame) {
break; break;
} }
frameTime += getTicks() - startTime; // Call handleEvents here to see if user pressed pause
++numberOfFrames; handleEvents();
if(thePauseIndicator)
{
updateDisplay(theConsole->mediaSource());
SDL_Delay(10);
continue;
}
startTime = getTicks();
theConsole->mediaSource().update();
updateDisplay(theConsole->mediaSource());
handleEvents();
// Now, waste time if we need to so that we are at the desired frame rate
for(;;)
{
delta = getTicks() - startTime;
if(delta >= timePerFrame)
break;
}
frameTime += getTicks() - startTime;
++numberOfFrames;
}
}
else // less accurate, less CPU-intensive timing
{
// Set up less accurate timing stuff
uInt32 startTime, virtualTime, currentTime;
uInt32 timePerFrame = (uInt32) (1000000.0 / (double) settings->theDesiredFrameRate);
// Set the base for the timers
virtualTime = getTicks();
frameTime = 0;
// Main game loop
for(;;)
{
// Exit if the user wants to quit
if(theQuitIndicator)
{
break;
}
startTime = getTicks();
if(!thePauseIndicator)
{
theConsole->mediaSource().update();
}
updateDisplay(theConsole->mediaSource());
handleEvents();
currentTime = getTicks();
virtualTime += timePerFrame;
if(currentTime < virtualTime)
{
SDL_Delay((virtualTime - currentTime)/1000);
}
currentTime = getTicks() - startTime;
frameTime += currentTime;
++numberOfFrames;
}
} }
#endif
if(settings->theShowInfoFlag) if(settings->theShowInfoFlag)
{ {

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: mainX11.cxx,v 1.24 2002-05-14 18:29:45 stephena Exp $ // $Id: mainX11.cxx,v 1.25 2002-08-04 00:28:18 stephena Exp $
//============================================================================ //============================================================================
#include <fstream> #include <fstream>
@ -53,7 +53,6 @@
#include <linux/joystick.h> #include <linux/joystick.h>
#endif #endif
#define HAVE_GETTIMEOFDAY 1
#define MESSAGE_INTERVAL 2 #define MESSAGE_INTERVAL 2
// A graphic context for each of the 2600's colors // A graphic context for each of the 2600's colors
@ -1468,89 +1467,94 @@ int main(int argc, char* argv[])
return 0; return 0;
} }
#ifdef EXPERIMENTAL_TIMING // These variables are common to both timing options
// Set up timing stuff // and are needed to calculate the overall frames per second.
uInt32 startTime, frameTime, virtualTime, currentTime; uInt32 frameTime = 0, numberOfFrames = 0;
uInt32 numberOfFrames = 0;
uInt32 timePerFrame = (uInt32) (1000000.0 / (double) settings->theDesiredFrameRate);
// Set the base for the timers if(settings->theHogCPUFlag) // normal, CPU-intensive timing
virtualTime = getTicks();
frameTime = 0;
// Main game loop
for(;;)
{ {
// Exit if the user wants to quit // Set up timing stuff
if(theQuitIndicator) uInt32 startTime, delta;
{ uInt32 timePerFrame = (uInt32) (1000000.0 / (double) settings->theDesiredFrameRate);
break;
}
startTime = getTicks(); // Set the base for the timers
if(!thePauseIndicator) frameTime = 0;
{
theConsole->mediaSource().update();
}
updateDisplay(theConsole->mediaSource());
handleEvents();
currentTime = getTicks(); // Main game loop
virtualTime += timePerFrame;
if(currentTime < virtualTime)
{
usleep(virtualTime - currentTime);
}
currentTime = getTicks() - startTime;
frameTime += currentTime;
++numberOfFrames;
}
#else
// Set up timing stuff
uInt32 startTime, frameTime, delta;
uInt32 numberOfFrames = 0;
uInt32 timePerFrame = (uInt32) (1000000.0 / (double) settings->theDesiredFrameRate);
// Set the base for the timers
frameTime = 0;
// Main game loop
for(;;)
{
// Exit if the user wants to quit
if(theQuitIndicator)
{
break;
}
// Call handleEvents here to see if user pressed pause
handleEvents();
if(thePauseIndicator)
{
updateDisplay(theConsole->mediaSource());
usleep(10000);
continue;
}
startTime = getTicks();
theConsole->mediaSource().update();
updateDisplay(theConsole->mediaSource());
handleEvents();
// Now, waste time if we need to so that we are at the desired frame rate
for(;;) for(;;)
{ {
delta = getTicks() - startTime; // Exit if the user wants to quit
if(theQuitIndicator)
if(delta >= timePerFrame) {
break; break;
} }
frameTime += getTicks() - startTime; // Call handleEvents here to see if user pressed pause
++numberOfFrames; handleEvents();
if(thePauseIndicator)
{
updateDisplay(theConsole->mediaSource());
usleep(10000);
continue;
}
startTime = getTicks();
theConsole->mediaSource().update();
updateDisplay(theConsole->mediaSource());
handleEvents();
// Now, waste time if we need to so that we are at the desired frame rate
for(;;)
{
delta = getTicks() - startTime;
if(delta >= timePerFrame)
break;
}
frameTime += getTicks() - startTime;
++numberOfFrames;
}
}
else // less accurate, less CPU-intensive timing
{
// Set up timing stuff
uInt32 startTime, virtualTime, currentTime;
uInt32 timePerFrame = (uInt32) (1000000.0 / (double) settings->theDesiredFrameRate);
// Set the base for the timers
virtualTime = getTicks();
frameTime = 0;
// Main game loop
for(;;)
{
// Exit if the user wants to quit
if(theQuitIndicator)
{
break;
}
startTime = getTicks();
if(!thePauseIndicator)
{
theConsole->mediaSource().update();
}
updateDisplay(theConsole->mediaSource());
handleEvents();
currentTime = getTicks();
virtualTime += timePerFrame;
if(currentTime < virtualTime)
{
usleep(virtualTime - currentTime);
}
currentTime = getTicks() - startTime;
frameTime += currentTime;
++numberOfFrames;
}
} }
#endif
if(settings->theShowInfoFlag) if(settings->theShowInfoFlag)
{ {