diff options
author | Adrian Astley | 2014-12-23 00:27:53 -0600 |
---|---|---|
committer | Adrian Astley | 2014-12-23 00:39:20 -0600 |
commit | 6548300a4182e1dc805b390678df800b05d07554 (patch) | |
tree | 9f28cfef9e167655a5965577c82af2bb2c20af25 /engines/zvision | |
parent | 11cb47e89772ea59fc55d2801685d1a3505235a0 (diff) | |
download | scummvm-rg350-6548300a4182e1dc805b390678df800b05d07554.tar.gz scummvm-rg350-6548300a4182e1dc805b390678df800b05d07554.tar.bz2 scummvm-rg350-6548300a4182e1dc805b390678df800b05d07554.zip |
ZVISION: Use Common::Rational to simplify fixed point math
Diffstat (limited to 'engines/zvision')
-rw-r--r-- | engines/zvision/core/events.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 72e7f33266..ccd7772975 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -296,20 +296,21 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (clippedPos.x >= _workingWindow.left && clippedPos.x < _workingWindow.left + ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; - _mouseVelocity = (((clippedPos.x - (ROTATION_SCREEN_EDGE_OFFSET + _workingWindow.left)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; if (mspeed <= 0) { mspeed = 25; } + _mouseVelocity = ((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.left)) - mspeed).toInt(); + _cursorManager->changeCursor(CursorIndex_Left); cursorWasChanged = true; } else if (clippedPos.x <= _workingWindow.right && clippedPos.x > _workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; - _mouseVelocity = (((clippedPos.x - (_workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; if (mspeed <= 0) { mspeed = 25; } + _mouseVelocity = (Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.right + ROTATION_SCREEN_EDGE_OFFSET)).toInt(); _cursorManager->changeCursor(CursorIndex_Right); cursorWasChanged = true; @@ -320,20 +321,20 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (clippedPos.y >= _workingWindow.top && clippedPos.y < _workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; - _mouseVelocity = (((clippedPos.y - (_workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; if (mspeed <= 0) { mspeed = 25; } + _mouseVelocity = ((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.top)) - mspeed).toInt(); _cursorManager->changeCursor(CursorIndex_UpArr); cursorWasChanged = true; } else if (clippedPos.y <= _workingWindow.bottom && clippedPos.y > _workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; - _mouseVelocity = (((clippedPos.y - (_workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; if (mspeed <= 0) { mspeed = 25; } + _mouseVelocity = (Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.bottom + ROTATION_SCREEN_EDGE_OFFSET)).toInt(); _cursorManager->changeCursor(CursorIndex_DownArr); cursorWasChanged = true; |