core: move ShowFPS from built-time macro to runtime option

sdl: add SDL.ShowFPS runtime option
This commit is contained in:
punkrockguy318 2012-08-10 15:50:57 +00:00
parent 16083638be
commit 28c348d9f9
6 changed files with 22 additions and 14 deletions

View File

@ -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:

View File

@ -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

View File

@ -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);

View File

@ -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) {

View File

@ -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

View File

@ -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();
void FCEUI_ShowFPS(bool showFPS);
void snapAVI();
#endif