aboutsummaryrefslogtreecommitdiff
path: root/engines/zvision/zvision.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/zvision/zvision.cpp')
-rw-r--r--engines/zvision/zvision.cpp19
1 files changed, 18 insertions, 1 deletions
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