[Scummvm-cvs-logs] CVS: scummvm/sword1 screen.cpp,1.48,1.49

Robert Göffringmann lavosspawn at users.sourceforge.net
Thu Dec 9 13:33:05 CET 2004


Update of /cvsroot/scummvm/scummvm/sword1
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10840/sword1

Modified Files:
	screen.cpp 
Log Message:
make scrolling smooth.

Index: screen.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/screen.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- screen.cpp	5 Dec 2004 07:35:27 -0000	1.48
+++ screen.cpp	9 Dec 2004 21:32:02 -0000	1.49
@@ -89,12 +89,14 @@
 			_fullRefresh = true;
 		_oldScrollX = Logic::_scriptVars[SCROLL_OFFSET_X];
 		_oldScrollY = Logic::_scriptVars[SCROLL_OFFSET_Y];
-		int32 distX = inRange(-MAX_SCROLL_DISTANCE, _oldScrollX - offsetX, MAX_SCROLL_DISTANCE);
-		int32 distY = inRange(-MAX_SCROLL_DISTANCE, _oldScrollY - offsetY, MAX_SCROLL_DISTANCE);
-		if ((distX != 0) || (distY != 0))
+		int dx = offsetX - Logic::_scriptVars[SCROLL_OFFSET_X];
+		int dy = offsetY - Logic::_scriptVars[SCROLL_OFFSET_Y];
+		int scrlDistX = inRange(-MAX_SCROLL_DISTANCE, ((1 + ABS(dx)) / SCROLL_FRACTION) * ((dx > 0) ? 1 : -1), MAX_SCROLL_DISTANCE);
+		int scrlDistY = inRange(-MAX_SCROLL_DISTANCE, ((1 + ABS(dy)) / SCROLL_FRACTION) * ((dy > 0) ? 1 : -1), MAX_SCROLL_DISTANCE);
+		if ((scrlDistX != 0) || (scrlDistY != 0))
 			_fullRefresh = true;
-		Logic::_scriptVars[SCROLL_OFFSET_X] -= distX;
-		Logic::_scriptVars[SCROLL_OFFSET_Y] -= distY;
+		Logic::_scriptVars[SCROLL_OFFSET_X] = inRange(0, Logic::_scriptVars[SCROLL_OFFSET_X] + scrlDistX, Logic::_scriptVars[MAX_SCROLL_OFFSET_X]);
+		Logic::_scriptVars[SCROLL_OFFSET_Y] = inRange(0, Logic::_scriptVars[SCROLL_OFFSET_Y] + scrlDistY, Logic::_scriptVars[MAX_SCROLL_OFFSET_Y]);
 	}
 }
 





More information about the Scummvm-git-logs mailing list