diff options
-rw-r--r-- | engines/mortevielle/mortevielle.cpp | 35 | ||||
-rw-r--r-- | engines/mortevielle/mouse.cpp | 14 |
2 files changed, 40 insertions, 9 deletions
diff --git a/engines/mortevielle/mortevielle.cpp b/engines/mortevielle/mortevielle.cpp index 0e6db5447f..f3ad46894d 100644 --- a/engines/mortevielle/mortevielle.cpp +++ b/engines/mortevielle/mortevielle.cpp @@ -155,6 +155,11 @@ int MortevielleEngine::getChar() { return shouldQuit() ? 0 : _keypresses.pop(); } +/** + * Handle pending events + * @remarks Since the ScummVM screen surface is double height to handle 640x200 using 640x400, + * the mouse Y position is divided by 2 to keep the game thinking the Y goes from 0 - 199 + */ bool MortevielleEngine::handleEvents() { Common::Event event; if (!g_system->getEventManager()->pollEvent(event)) @@ -166,9 +171,9 @@ bool MortevielleEngine::handleEvents() { case Common::EVENT_RBUTTONDOWN: case Common::EVENT_RBUTTONUP: case Common::EVENT_MOUSEMOVE: - _mousePos = event.mouse; + _mousePos = Common::Point(event.mouse.x, event.mouse.y / 2); x_s = event.mouse.x; - y_s = event.mouse.y; + y_s = event.mouse.y / 2; if (event.type == Common::EVENT_LBUTTONDOWN) _mouseButtons |= 1; @@ -212,29 +217,40 @@ void MortevielleEngine::addKeypress(Common::Event &evt) { case Common::KEYCODE_KP4: case Common::KEYCODE_LEFT: ch = '4'; + break; case Common::KEYCODE_KP2: case Common::KEYCODE_DOWN: ch = '2'; + break; case Common::KEYCODE_KP6: case Common::KEYCODE_RIGHT: ch = '6'; + break; case Common::KEYCODE_KP8: case Common::KEYCODE_UP: ch = '8'; + break; case Common::KEYCODE_KP7: ch = '7'; + break; case Common::KEYCODE_KP1: ch = '1'; + break; case Common::KEYCODE_KP9: ch = '9'; + break; case Common::KEYCODE_KP3: ch = '3'; + break; case Common::KEYCODE_KP5: ch = '5'; + break; case Common::KEYCODE_RETURN: ch = '\13'; + break; case Common::KEYCODE_ESCAPE: ch = '\33'; + break; default: break; } @@ -271,8 +287,21 @@ void MortevielleEngine::initMouse() { CursorMan.showMouse(true); } +/** + * Sets the mouse position + * @remarks Since the ScummVM screen surface is double height to handle 640x200 using 640x400, + * the mouse Y position is doubled to convert from 0-199 to 0-399 + */ void MortevielleEngine::setMousePos(const Common::Point &pt) { - _mousePos = pt; + // Adjust the passed position from simulated 640x200 to 640x400 co-ordinates + Common::Point newPoint(pt.x, (pt.y == 199) ? 399 : pt.y * 2); + + if (newPoint != _mousePos) + // Warp the mouse to the new position + g_system->warpMouse(newPoint.x, newPoint.y); + + // Save the new position + _mousePos = newPoint; } /*-------------------------------------------------------------------------*/ diff --git a/engines/mortevielle/mouse.cpp b/engines/mortevielle/mouse.cpp index e79086ed2c..2e945287ba 100644 --- a/engines/mortevielle/mouse.cpp +++ b/engines/mortevielle/mouse.cpp @@ -286,20 +286,22 @@ void mov_mouse(bool &funct, char &key) { char in1, in2; int cx, cy, cd; + // Set defaults and check pending events + funct = false; + key = '\377'; + p_key = keypressed(); + // If mouse button clicked, return it if (g_vm->getMouseButtons() != 0) { clic = true; return; } - funct = false; - key = '\377'; - p_key = keypressed(); - + // Handle any pending keypresses while (p_key) { CHECK_QUIT; - in1 = get_ch(); // input >> kbd >> in1; + in1 = get_ch(); read_pos_mouse(cx, cy, cd); switch (toupper(in1)) { case '4' : @@ -349,7 +351,7 @@ void mov_mouse(bool &funct, char &key) { p_key = keypressed(); if (p_key) { - in2 = get_ch(); // input >> kbd >> in2; + in2 = get_ch(); if ((in2 >= ';') && (in2 <= 'D')) { funct = true; |