From 8e04d25be6455d7cd38cd0b300fd0ddead2b4f99 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Fri, 23 Jul 2010 10:58:06 +0000 Subject: SCI: support kSetCursorSci11(-2) svn-id: r51202 --- engines/sci/engine/kgraphics.cpp | 3 ++- engines/sci/graphics/cursor.cpp | 49 +++++++++++++++++++++++----------------- engines/sci/graphics/cursor.h | 6 +++++ 3 files changed, 36 insertions(+), 22 deletions(-) (limited to 'engines') diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 55d0de8261..ed7b72f90b 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -129,9 +129,10 @@ static reg_t kSetCursorSci11(EngineState *s, int argc, reg_t *argv) { break; case -1: // TODO: Special case at least in kq6, check disassembly + // Does something with magCursor, which is set on argc = 10, which we don't support break; case -2: - // TODO: Special case at least in kq6, check disassembly + g_sci->_gfxCursor->kernelResetMoveZone(); break; default: g_sci->_gfxCursor->kernelShow(); diff --git a/engines/sci/graphics/cursor.cpp b/engines/sci/graphics/cursor.cpp index e1c05c97da..f6e2077cb3 100644 --- a/engines/sci/graphics/cursor.cpp +++ b/engines/sci/graphics/cursor.cpp @@ -47,7 +47,7 @@ GfxCursor::GfxCursor(ResourceManager *resMan, GfxPalette *palette, GfxScreen *sc // center mouse cursor setPosition(Common::Point(_screen->getWidth() / 2, _screen->getHeight() / 2)); - kernelSetMoveZone(Common::Rect(0, 0, _screen->getDisplayWidth(), _screen->getDisplayHeight())); + _moveZoneActive = false; } GfxCursor::~GfxCursor() { @@ -283,32 +283,39 @@ Common::Point GfxCursor::getPosition() { } void GfxCursor::refreshPosition() { - bool clipped = false; - Common::Point mousePoint = getPosition(); - - if (mousePoint.x < _moveZone.left) { - mousePoint.x = _moveZone.left; - clipped = true; - } else if (mousePoint.x >= _moveZone.right) { - mousePoint.x = _moveZone.right - 1; - clipped = true; - } + if (_moveZoneActive) { + bool clipped = false; + Common::Point mousePoint = getPosition(); + + if (mousePoint.x < _moveZone.left) { + mousePoint.x = _moveZone.left; + clipped = true; + } else if (mousePoint.x >= _moveZone.right) { + mousePoint.x = _moveZone.right - 1; + clipped = true; + } - if (mousePoint.y < _moveZone.top) { - mousePoint.y = _moveZone.top; - clipped = true; - } else if (mousePoint.y >= _moveZone.bottom) { - mousePoint.y = _moveZone.bottom - 1; - clipped = true; + if (mousePoint.y < _moveZone.top) { + mousePoint.y = _moveZone.top; + clipped = true; + } else if (mousePoint.y >= _moveZone.bottom) { + mousePoint.y = _moveZone.bottom - 1; + clipped = true; + } + + // FIXME: Do this only when mouse is grabbed? + if (clipped) + setPosition(mousePoint); } +} - // FIXME: Do this only when mouse is grabbed? - if (clipped) - setPosition(mousePoint); +void GfxCursor::kernelResetMoveZone() { + _moveZoneActive = false; } void GfxCursor::kernelSetMoveZone(Common::Rect zone) { - _moveZone = zone; + _moveZone = zone; + _moveZoneActive = true; } void GfxCursor::kernelSetPos(Common::Point pos) { diff --git a/engines/sci/graphics/cursor.h b/engines/sci/graphics/cursor.h index 7acd14acd9..787841f5be 100644 --- a/engines/sci/graphics/cursor.h +++ b/engines/sci/graphics/cursor.h @@ -57,6 +57,11 @@ public: Common::Point getPosition(); void refreshPosition(); + /** + * Removes limit for mouse movement + */ + void kernelResetMoveZone(); + /** * Limits the mouse movement to a given rectangle. * @@ -78,6 +83,7 @@ private: int _upscaledHires; + bool _moveZoneActive; Common::Rect _moveZone; // Rectangle in which the pointer can move CursorCache _cachedCursors; -- cgit v1.2.3