From 69b1485a22dc2b8a2cfe0bd10edcbaad0da0cf6e Mon Sep 17 00:00:00 2001 From: strangerke Date: Thu, 12 May 2011 01:13:57 +0200 Subject: GIT: Clean up: Suppress SVN tags, now useless --- engines/mohawk/graphics.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'engines/mohawk/graphics.cpp') diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp index a1bcb55f7b..9e02e70a22 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" -- cgit v1.2.3 From 7cc82487d368fb94fc4e9e9ad16a80eb4536beda Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sat, 14 May 2011 14:10:05 +0200 Subject: MOHAWK: When running scripts in Myst, add delays when necessary between draws to mimic older hardware. --- engines/mohawk/graphics.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'engines/mohawk/graphics.cpp') diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp index 9e02e70a22..b3653b1fdf 100644 --- a/engines/mohawk/graphics.cpp +++ b/engines/mohawk/graphics.cpp @@ -293,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() { @@ -444,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); } @@ -499,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"); @@ -604,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) { @@ -629,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 -- cgit v1.2.3