aboutsummaryrefslogtreecommitdiff
path: root/engines/zvision/zvision.cpp
diff options
context:
space:
mode:
authorFilippos Karapetis2014-12-26 23:18:54 +0200
committerFilippos Karapetis2014-12-26 23:18:54 +0200
commitf9595b11fc2bef08d84a00b81f9b2884f77897b0 (patch)
tree8626ab1737e0f02ad51aef52fb0baf520043ee98 /engines/zvision/zvision.cpp
parent19ce38d40e9f273335b06a62bcb0d3643602080c (diff)
downloadscummvm-rg350-f9595b11fc2bef08d84a00b81f9b2884f77897b0.tar.gz
scummvm-rg350-f9595b11fc2bef08d84a00b81f9b2884f77897b0.tar.bz2
scummvm-rg350-f9595b11fc2bef08d84a00b81f9b2884f77897b0.zip
ZVISION: Add an FPS timer (accessible with F10, or the "FRAME" cheat)
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