diff --git a/SConstruct b/SConstruct index f21bb292..aef2435f 100644 --- a/SConstruct +++ b/SConstruct @@ -15,7 +15,6 @@ opts.AddVariables( BoolVariable('FRAMESKIP', 'Enable frameskipping', 1), BoolVariable('OPENGL', 'Enable OpenGL support', 1), BoolVariable('LSB_FIRST', 'Least signficant byte first (non-PPC)', 1), - BoolVariable('SHOWFPS', 'Show the running frames per second.)', 0), # TODO: move this to runtime configuration option BoolVariable('DEBUG', 'Build with debugging symbols', 1), BoolVariable('LUA', 'Enable Lua support', 1), BoolVariable('NEWPPU', 'Enable new PPU core', 1), @@ -142,9 +141,6 @@ if env['DEBUG']: else: env.Append(CCFLAGS = ['-O2']) -if env['SHOWFPS']: - env.Append(CPPDEFINES=["SHOWFPS"]) - if env['PLATFORM'] != 'win32' and env['PLATFORM'] != 'cygwin' and env['CREATE_AVI']: env.Append(CPPDEFINES=["CREATE_AVI"]) else: diff --git a/changelog.txt b/changelog.txt index d15dd98d..fca9ce7c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,5 @@ +10-Aug-2012 - prg - sdl: add runtime option for controling drawing fps (SDL.ShowFPS) +10-Aug-2012 - prg - core: move showfps from build option to runtime option 10-Aug-2012 - prg - sdl: fix and enable SHOWFPS build option (TODO: make runtime option) 10-Aug-2012 - AnS - Debugger: "Address Bookmark Add" field follows disassembly window scrolling position 08-Aug-2012 - AnS - Taseditor: frame counter display is auto-on when Taseditor launches diff --git a/src/drivers/sdl/config.cpp b/src/drivers/sdl/config.cpp index 495d4a48..342c33ba 100644 --- a/src/drivers/sdl/config.cpp +++ b/src/drivers/sdl/config.cpp @@ -164,6 +164,7 @@ InitConfig() config->addOption("ystretch", "SDL.YStretch", 0); config->addOption("noframe", "SDL.NoFrame", 0); config->addOption("special", "SDL.SpecialFilter", 0); + config->addOption("showfps", "SDL.ShowFPS", 0); // OpenGL options config->addOption("opengl", "SDL.OpenGL", 0); diff --git a/src/drivers/sdl/sdl-video.cpp b/src/drivers/sdl/sdl-video.cpp index e9b321e2..397b16ad 100644 --- a/src/drivers/sdl/sdl-video.cpp +++ b/src/drivers/sdl/sdl-video.cpp @@ -30,6 +30,7 @@ #include "../common/vidblit.h" #include "../../fceu.h" #include "../../version.h" +#include "../../video.h" #include "../../utils/memory.h" @@ -156,7 +157,7 @@ InitVideo(FCEUGI *gi) // XXX soules - const? is this necessary? const SDL_VideoInfo *vinf; int error, flags = 0; - int doublebuf, xstretch, ystretch, xres, yres; + int doublebuf, xstretch, ystretch, xres, yres, show_fps; FCEUI_printf("Initializing video..."); @@ -173,6 +174,7 @@ InitVideo(FCEUGI *gi) g_config->getOption("SDL.YResolution", &yres); g_config->getOption("SDL.ClipSides", &s_clipSides); g_config->getOption("SDL.NoFrame", &noframe); + g_config->getOption("SDL.ShowFPS", &show_fps); // check the starting, ending, and total scan lines FCEUI_GetCurrentVidSystem(&s_srendline, &s_erendline); @@ -211,6 +213,9 @@ InitVideo(FCEUGI *gi) if(s_nativeHeight < 0) { s_nativeHeight = vinf->current_h; } + + // check to see if we are showing FPS + FCEUI_ShowFPS(show_fps); // check if we are rendering fullscreen if(s_fullscreen) { diff --git a/src/video.cpp b/src/video.cpp index 0cf0df34..a848952e 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -130,13 +130,10 @@ int FCEU_InitVirtualVideo(void) #ifdef FRAMESKIP -//#define SHOWFPS void ShowFPS(void); void FCEU_PutImageDummy(void) { -#ifdef SHOWFPS ShowFPS(); -#endif if(GameInfo->type!=GIT_NSF) { FCEU_DrawNTSCControlBars(XBuf); @@ -170,9 +167,7 @@ static void ReallySnap(void) void FCEU_PutImage(void) { -#ifdef SHOWFPS ShowFPS(); -#endif if(dosnapsave==2) //Save screenshot as, currently only flagged & run by the Win32 build. //TODO SDL: implement this? { char nameo[512]; @@ -744,16 +739,22 @@ PNGerr: fclose(pp); return(0); } -//TODO mbg - this needs to be implemented in a better way -#ifdef SHOWFPS uint64 FCEUD_GetTime(void); uint64 FCEUD_GetTimeFreq(void); +bool Show_FPS = false; +// Control whether the frames per second of the emulation is rendered. +void FCEUI_ShowFPS(bool showFPS) +{ + Show_FPS = showFPS; +} static uint64 boop[60]; static int boopcount = 0; void ShowFPS(void) { + if(Show_FPS == false) + return; uint64 da = FCEUD_GetTime() - boop[boopcount]; char fpsmsg[16]; int booplimit = PAL?50:60; @@ -764,4 +765,3 @@ void ShowFPS(void) // It's not averaging FPS over exactly 1 second, but it's close enough. boopcount = (boopcount + 1) % booplimit; } -#endif diff --git a/src/video.h b/src/video.h index daba7af9..919e34bd 100644 --- a/src/video.h +++ b/src/video.h @@ -1,3 +1,5 @@ +#ifndef _VIDEO_H_ +#define _VIDEO_H_ int FCEU_InitVirtualVideo(void); void FCEU_KillVirtualVideo(void); int SaveSnapshot(void); @@ -29,4 +31,6 @@ void FCEU_DrawNumberRow(uint8 *XBuf, int *nstatus, int cur); std::string FCEUI_GetSnapshotAsName(); void FCEUI_SetSnapshotAsName(std::string name); -void snapAVI(); \ No newline at end of file +void FCEUI_ShowFPS(bool showFPS); +void snapAVI(); +#endif