diff options
author | Matthew Hoops | 2011-05-18 18:23:37 -0400 |
---|---|---|
committer | Matthew Hoops | 2011-05-18 18:23:37 -0400 |
commit | d4c92983920cfe3b25a22d91e12c750e591b917e (patch) | |
tree | c0b63318b9ba0e67528337cfaa21515def1c3962 /engines/mohawk/graphics.cpp | |
parent | 7e2edf16b3e2bf1d2b31999979a60802514df6cb (diff) | |
parent | cf107e24be28c7e6db65b5c7ffed120af4a7994b (diff) | |
download | scummvm-rg350-d4c92983920cfe3b25a22d91e12c750e591b917e.tar.gz scummvm-rg350-d4c92983920cfe3b25a22d91e12c750e591b917e.tar.bz2 scummvm-rg350-d4c92983920cfe3b25a22d91e12c750e591b917e.zip |
Merge remote branch 'upstream/master' into pegasus
Diffstat (limited to 'engines/mohawk/graphics.cpp')
-rw-r--r-- | engines/mohawk/graphics.cpp | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp index a1bcb55f7b..b3653b1fdf 100644 --- a/engines/mohawk/graphics.cpp +++ b/engines/mohawk/graphics.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "mohawk/resource.h" @@ -296,6 +293,9 @@ MystGraphics::MystGraphics(MohawkEngine_Myst* vm) : GraphicsManager(), _vm(vm) { // Initialize our buffer _backBuffer = new Graphics::Surface(); _backBuffer->create(_vm->_system->getWidth(), _vm->_system->getHeight(), _pixelFormat); + + _nextAllowedDrawTime = _vm->_system->getMillis(); + _enableDrawingTimeSimulation = 0; } MystGraphics::~MystGraphics() { @@ -447,6 +447,8 @@ void MystGraphics::copyImageSectionToScreen(uint16 image, Common::Rect src, Comm debug(3, "\twidth: %d", width); debug(3, "\theight: %d", height); + simulatePreviousDrawDelay(dest); + _vm->_system->copyRectToScreen((byte *)surface->getBasePtr(src.left, top), surface->pitch, dest.left, dest.top, width, height); } @@ -502,10 +504,18 @@ void MystGraphics::copyImageToBackBuffer(uint16 image, Common::Rect dest) { void MystGraphics::copyBackBufferToScreen(Common::Rect r) { r.clip(_viewport); + + simulatePreviousDrawDelay(r); + _vm->_system->copyRectToScreen((byte *)_backBuffer->getBasePtr(r.left, r.top), _backBuffer->pitch, r.left, r.top, r.width(), r.height()); } void MystGraphics::runTransition(uint16 type, Common::Rect rect, uint16 steps, uint16 delay) { + + // Do not artificially delay during transitions + int oldEnableDrawingTimeSimulation = _enableDrawingTimeSimulation; + _enableDrawingTimeSimulation = 0; + switch (type) { case 0: { debugC(kDebugScript, "Left to Right"); @@ -607,6 +617,8 @@ void MystGraphics::runTransition(uint16 type, Common::Rect rect, uint16 steps, u _vm->_system->updateScreen(); break; } + + _enableDrawingTimeSimulation = oldEnableDrawingTimeSimulation; } void MystGraphics::drawRect(Common::Rect rect, RectState state) { @@ -632,6 +644,34 @@ void MystGraphics::drawLine(const Common::Point &p1, const Common::Point &p2, ui _backBuffer->drawLine(p1.x, p1.y, p2.x, p2.y, color); } +void MystGraphics::enableDrawingTimeSimulation(bool enable) { + if (enable) + _enableDrawingTimeSimulation++; + else + _enableDrawingTimeSimulation--; + + if (_enableDrawingTimeSimulation < 0) + _enableDrawingTimeSimulation = 0; +} + +void MystGraphics::simulatePreviousDrawDelay(const Common::Rect &dest) { + uint32 time = 0; + + if (_enableDrawingTimeSimulation) { + time = _vm->_system->getMillis(); + + // Do not draw anything new too quickly after the previous draw call + // so that images stay at least a little while on screen + // This is enabled only for scripted draw calls + if (time < _nextAllowedDrawTime) + _vm->_system->delayMillis(_nextAllowedDrawTime - time); + } + + // Next draw call allowed at DELAY + AERA * COEFF milliseconds from now + time = _vm->_system->getMillis(); + _nextAllowedDrawTime = time + _constantDrawDelay + dest.height() * dest.width() / _proportionalDrawDelay; +} + #endif // ENABLE_MYST #ifdef ENABLE_RIVEN |