From 57a53420c366d327581cee72181bd6bed8d8e7c7 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Sat, 2 Jul 2016 19:11:59 -0500 Subject: SCI32: Expose graphics throttling code Controls that manage their own event loops and call frameOut directly generally need to sleep in order to avoid 100% CPU, just like the main VM event loop. --- engines/sci/graphics/controls32.cpp | 3 +-- engines/sci/graphics/frameout.cpp | 4 ++++ engines/sci/graphics/frameout.h | 8 +++++++- 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/sci/graphics/controls32.cpp b/engines/sci/graphics/controls32.cpp index 6aad636e7e..4cbb4541df 100644 --- a/engines/sci/graphics/controls32.cpp +++ b/engines/sci/graphics/controls32.cpp @@ -310,8 +310,7 @@ reg_t GfxControls32::kernelEditText(const reg_t controlObject) { g_sci->_gfxFrameout->frameOut(true); g_sci->getSciDebugger()->onFrame(); - g_sci->getEngineState()->speedThrottler(16); - g_sci->getEngineState()->_throttleTrigger = true; + g_sci->_gfxFrameout->throttle(); } g_sci->_gfxFrameout->deletePlane(*plane); diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp index 50f26474f1..c0feea8999 100644 --- a/engines/sci/graphics/frameout.cpp +++ b/engines/sci/graphics/frameout.cpp @@ -1567,6 +1567,10 @@ void GfxFrameout::kernelFrameOut(const bool shouldShowBits) { frameOut(shouldShowBits); } + throttle(); +} + +void GfxFrameout::throttle() { if (_throttleFrameOut) { uint8 throttleTime; if (_throttleState == 2) { diff --git a/engines/sci/graphics/frameout.h b/engines/sci/graphics/frameout.h index 05c48c3485..cc62c61d22 100644 --- a/engines/sci/graphics/frameout.h +++ b/engines/sci/graphics/frameout.h @@ -185,7 +185,7 @@ private: /** * Whether or not calls to kFrameOut should be framerate - * limited to ~60fps. + * limited to 60fps. */ bool _throttleFrameOut; @@ -437,6 +437,12 @@ public: void kernelFrameOut(const bool showBits); + /** + * Throttles the engine as necessary to maintain + * 60fps output. + */ + void throttle(); + /** * Updates the internal screen buffer for the next * frame. If `shouldShowBits` is true, also sends the -- cgit v1.2.3