diff options
author | Robert Göffringmann | 2004-12-09 21:32:02 +0000 |
---|---|---|
committer | Robert Göffringmann | 2004-12-09 21:32:02 +0000 |
commit | 3bd97accd48ad0d9b0180d69be450b5e14eea2dd (patch) | |
tree | 66472fe65cf41cf40c9fa2cb8ddb6d45125a83a5 | |
parent | 9f5bd8510d0919b58817aec09955be9161aeecc5 (diff) | |
download | scummvm-rg350-3bd97accd48ad0d9b0180d69be450b5e14eea2dd.tar.gz scummvm-rg350-3bd97accd48ad0d9b0180d69be450b5e14eea2dd.tar.bz2 scummvm-rg350-3bd97accd48ad0d9b0180d69be450b5e14eea2dd.zip |
make scrolling smooth.
svn-id: r16005
-rw-r--r-- | sword1/screen.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sword1/screen.cpp b/sword1/screen.cpp index f6920417a6..3b1b4579a8 100644 --- a/sword1/screen.cpp +++ b/sword1/screen.cpp @@ -89,12 +89,14 @@ void Screen::setScrolling(int16 offsetX, int16 offsetY) { _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]); } } |