[Scummvm-cvs-logs] scummvm master -> 40bd4c485f9ab24e667e66a047214eb7dcef73e8

RichieSams adastley at gmail.com
Tue Dec 23 07:40:35 CET 2014


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
11cb47e897 ZVISION: Remove unnecessary math
6548300a41 ZVISION: Use Common::Rational to simplify fixed point math
40bd4c485f ZVISION: Clamp the rotation velocity to never be zero


Commit: 11cb47e89772ea59fc55d2801685d1a3505235a0
    https://github.com/scummvm/scummvm/commit/11cb47e89772ea59fc55d2801685d1a3505235a0
Author: Adrian Astley (adastley at gmail.com)
Date: 2014-12-23T00:39:15-06:00

Commit Message:
ZVISION: Remove unnecessary math

Changed paths:
    engines/zvision/core/events.cpp



diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp
index 6e8cf1f..72e7f33 100644
--- a/engines/zvision/core/events.cpp
+++ b/engines/zvision/core/events.cpp
@@ -296,18 +296,20 @@ 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;
-				if (mspeed <= 0)
-					mspeed = 400 >> 4;
 				_mouseVelocity  = (((clippedPos.x - (ROTATION_SCREEN_EDGE_OFFSET + _workingWindow.left)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7;
+				if (mspeed <= 0) {
+					mspeed = 25;
+				}
 
 				_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;
-				if (mspeed <= 0)
-					mspeed = 400 >> 4;
 				_mouseVelocity  = (((clippedPos.x - (_workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7;
+				if (mspeed <= 0) {
+					mspeed = 25;
+				}
 
 				_cursorManager->changeCursor(CursorIndex_Right);
 				cursorWasChanged = true;
@@ -318,18 +320,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;
-				if (mspeed <= 0)
-					mspeed = 400 >> 4;
 				_mouseVelocity  = (((clippedPos.y - (_workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7;
+				if (mspeed <= 0) {
+					mspeed = 25;
+				}
 
 				_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;
-				if (mspeed <= 0)
-					mspeed = 400 >> 4;
 				_mouseVelocity  = (((clippedPos.y - (_workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7;
+				if (mspeed <= 0) {
+					mspeed = 25;
+				}
 
 				_cursorManager->changeCursor(CursorIndex_DownArr);
 				cursorWasChanged = true;


Commit: 6548300a4182e1dc805b390678df800b05d07554
    https://github.com/scummvm/scummvm/commit/6548300a4182e1dc805b390678df800b05d07554
Author: Adrian Astley (adastley at gmail.com)
Date: 2014-12-23T00:39:20-06:00

Commit Message:
ZVISION: Use Common::Rational to simplify fixed point math

Changed paths:
    engines/zvision/core/events.cpp



diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp
index 72e7f33..ccd7772 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;


Commit: 40bd4c485f9ab24e667e66a047214eb7dcef73e8
    https://github.com/scummvm/scummvm/commit/40bd4c485f9ab24e667e66a047214eb7dcef73e8
Author: Adrian Astley (adastley at gmail.com)
Date: 2014-12-23T00:39:25-06:00

Commit Message:
ZVISION: Clamp the rotation velocity to never be zero

Before, if we set the in-game preferences to have very low rotation speed,
the velocity ends up always being 0 - 0.99
Hence, when we convert back to an int, everything gets truncated to zero.
Therefore, we clamp, in order to ensure the user can always move, no matter
which setting they use.

Changed paths:
    engines/zvision/core/events.cpp



diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp
index ccd7772..1920ffd 100644
--- a/engines/zvision/core/events.cpp
+++ b/engines/zvision/core/events.cpp
@@ -299,7 +299,7 @@ void ZVision::onMouseMove(const Common::Point &pos) {
 				if (mspeed <= 0) {
 					mspeed = 25;
 				}
-				_mouseVelocity  = ((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.left)) - mspeed).toInt();
+				_mouseVelocity  = MIN(((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.left)) - mspeed).toInt(), -1);
 				
 
 				_cursorManager->changeCursor(CursorIndex_Left);
@@ -310,7 +310,7 @@ void ZVision::onMouseMove(const Common::Point &pos) {
 				if (mspeed <= 0) {
 					mspeed = 25;
 				}
-				_mouseVelocity  = (Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.right + ROTATION_SCREEN_EDGE_OFFSET)).toInt();
+				_mouseVelocity  = MAX((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.right + ROTATION_SCREEN_EDGE_OFFSET)).toInt(), 1);
 
 				_cursorManager->changeCursor(CursorIndex_Right);
 				cursorWasChanged = true;
@@ -324,7 +324,7 @@ void ZVision::onMouseMove(const Common::Point &pos) {
 				if (mspeed <= 0) {
 					mspeed = 25;
 				}
-				_mouseVelocity  = ((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.top)) - mspeed).toInt();
+				_mouseVelocity  = MIN(((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.top)) - mspeed).toInt(), -1);
 
 				_cursorManager->changeCursor(CursorIndex_UpArr);
 				cursorWasChanged = true;
@@ -334,7 +334,7 @@ void ZVision::onMouseMove(const Common::Point &pos) {
 				if (mspeed <= 0) {
 					mspeed = 25;
 				}
-				_mouseVelocity = (Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.bottom + ROTATION_SCREEN_EDGE_OFFSET)).toInt();
+				_mouseVelocity = MAX((Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.bottom + ROTATION_SCREEN_EDGE_OFFSET)).toInt(), 1);
 
 				_cursorManager->changeCursor(CursorIndex_DownArr);
 				cursorWasChanged = true;






More information about the Scummvm-git-logs mailing list