From f9595b11fc2bef08d84a00b81f9b2884f77897b0 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 23:18:54 +0200 Subject: ZVISION: Add an FPS timer (accessible with F10, or the "FRAME" cheat) --- engines/zvision/zvision.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'engines/zvision/zvision.cpp') diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index b3fc02ee15..615574bbcd 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -101,7 +101,9 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) _frameRenderDelay(2), _keyboardVelocity(0), _mouseVelocity(0), - _videoIsPlaying(false) { + _videoIsPlaying(false), + _renderedFrameCount(0), + _fps(0) { debug(1, "ZVision::ZVision"); @@ -130,6 +132,8 @@ ZVision::~ZVision() { delete _rnd; delete _midiManager; + getTimerManager()->removeTimerProc(&fpsTimerCallback); + // Remove all of our debug levels DebugMan.clearAllDebugChannels(); } @@ -214,6 +218,9 @@ void ZVision::initialize() { // Create debugger console. It requires GFX to be initialized _console = new Console(this); _doubleFPS = ConfMan.getBool("doublefps"); + + // Initialize FPS timer callback + getTimerManager()->installTimerProc(&fpsTimerCallback, 1000000, this, "zvisionFPS"); } Common::Error ZVision::run() { @@ -246,6 +253,7 @@ Common::Error ZVision::run() { // Update the screen if (canRender()) { _system->updateScreen(); + _renderedFrameCount++; } else { _frameRenderDelay--; } @@ -291,4 +299,13 @@ bool ZVision::canRender() { return _frameRenderDelay <= 0; } +void ZVision::fpsTimerCallback(void *refCon) { + ((ZVision *)refCon)->fpsTimer(); +} + +void ZVision::fpsTimer() { + _fps = _renderedFrameCount; + _renderedFrameCount = 0; +} + } // End of namespace ZVision -- cgit v1.2.3