diff options
-rw-r--r-- | engines/sci/engine/kevent.cpp | 5 | ||||
-rw-r--r-- | engines/sci/graphics/compare.cpp | 7 | ||||
-rw-r--r-- | engines/sci/graphics/coordadjuster.cpp | 11 | ||||
-rw-r--r-- | engines/sci/graphics/coordadjuster.h | 6 |
4 files changed, 19 insertions, 10 deletions
diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp index 93bdb5ccf3..3395811700 100644 --- a/engines/sci/engine/kevent.cpp +++ b/engines/sci/engine/kevent.cpp @@ -50,7 +50,10 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) { // Limit the mouse cursor position, if necessary g_sci->_gfxCursor->refreshPosition(); mousePos = g_sci->_gfxCursor->getPosition(); - g_sci->_gfxCoordAdjuster->getEvent(mousePos); +#ifdef ENABLE_SCI32 + if (getSciVersion() >= SCI_VERSION_2_1) + g_sci->_gfxCoordAdjuster->fromDisplayToScript(mousePos.y, mousePos.x); +#endif // If there's a simkey pending, and the game wants a keyboard event, use the // simkey instead of a normal event diff --git a/engines/sci/graphics/compare.cpp b/engines/sci/graphics/compare.cpp index c67126bfba..46ccd84e7f 100644 --- a/engines/sci/graphics/compare.cpp +++ b/engines/sci/graphics/compare.cpp @@ -139,7 +139,7 @@ void GfxCompare::kernelSetNowSeen(reg_t objectReference) { _screen->adjustToUpscaledCoordinates(y, x); break; case SCI_VERSION_2_1: - _coordAdjuster->kernelLocalToGlobal(x, y, readSelector(_segMan, objectReference, SELECTOR(plane))); + _coordAdjuster->fromScriptToDisplay(y, x); break; default: break; @@ -157,9 +157,8 @@ void GfxCompare::kernelSetNowSeen(reg_t objectReference) { } break; case SCI_VERSION_2_1: { - reg_t planeObj = readSelector(_segMan, objectReference, SELECTOR(plane)); - _coordAdjuster->kernelGlobalToLocal(celRect.left, celRect.top, planeObj); - _coordAdjuster->kernelGlobalToLocal(celRect.right, celRect.bottom, planeObj); + _coordAdjuster->fromDisplayToScript(celRect.top, celRect.left); + _coordAdjuster->fromDisplayToScript(celRect.bottom, celRect.right); break; } default: diff --git a/engines/sci/graphics/coordadjuster.cpp b/engines/sci/graphics/coordadjuster.cpp index 70b04b37bf..468c41f1c1 100644 --- a/engines/sci/graphics/coordadjuster.cpp +++ b/engines/sci/graphics/coordadjuster.cpp @@ -122,9 +122,14 @@ void GfxCoordAdjuster32::setScriptsResolution(uint16 width, uint16 height) { scriptsRunningHeight = height; } -void GfxCoordAdjuster32::getEvent(Common::Point &pos) { - pos.y = ((pos.y * scriptsRunningHeight) / g_sci->_gfxScreen->getHeight()); - pos.x = ((pos.x * scriptsRunningWidth) / g_sci->_gfxScreen->getWidth()); +void GfxCoordAdjuster32::fromDisplayToScript(int16 &y, int16 &x) { + y = ((y * scriptsRunningHeight) / g_sci->_gfxScreen->getHeight()); + x = ((x * scriptsRunningWidth) / g_sci->_gfxScreen->getWidth()); +} + +void GfxCoordAdjuster32::fromScriptToDisplay(int16 &y, int16 &x) { + y = ((y * g_sci->_gfxScreen->getHeight()) / scriptsRunningHeight); + x = ((x * g_sci->_gfxScreen->getWidth()) / scriptsRunningWidth); } void GfxCoordAdjuster32::pictureSetDisplayArea(Common::Rect displayArea) { diff --git a/engines/sci/graphics/coordadjuster.h b/engines/sci/graphics/coordadjuster.h index 8b9144981c..7e5d2351b9 100644 --- a/engines/sci/graphics/coordadjuster.h +++ b/engines/sci/graphics/coordadjuster.h @@ -51,7 +51,8 @@ public: virtual void moveCursor(Common::Point &pos) { } virtual void setScriptsResolution(uint16 width, uint16 height) { } - virtual void getEvent(Common::Point &pos) { } + virtual void fromScriptToDisplay(int16 &y, int16 &x) { } + virtual void fromDisplayToScript(int16 &y, int16 &x) { } virtual Common::Rect pictureGetDisplayArea() { return Common::Rect(0, 0); } private: @@ -89,7 +90,8 @@ public: Common::Rect onControl(Common::Rect rect); void setScriptsResolution(uint16 width, uint16 height); - void getEvent(Common::Point &pos); + void fromScriptToDisplay(int16 &y, int16 &x); + void fromDisplayToScript(int16 &y, int16 &x); void pictureSetDisplayArea(Common::Rect displayArea); Common::Rect pictureGetDisplayArea(); |