aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorSven Hesse2007-04-13 07:48:26 +0000
committerSven Hesse2007-04-13 07:48:26 +0000
commit7370c5aa1264b451766a1e5ed4d6257d3ee8b134 (patch)
treecd58774a9ab1b16f0974ac659d1ffc6bf9e1bda6 /engines
parenta35e5a42be087fe6a736eacdc5444a7f584bb3d7 (diff)
downloadscummvm-rg350-7370c5aa1264b451766a1e5ed4d6257d3ee8b134.tar.gz
scummvm-rg350-7370c5aa1264b451766a1e5ed4d6257d3ee8b134.tar.bz2
scummvm-rg350-7370c5aa1264b451766a1e5ed4d6257d3ee8b134.zip
The scrolling now works without cursor jittering...
svn-id: r26458
Diffstat (limited to 'engines')
-rw-r--r--engines/gob/game.cpp35
-rw-r--r--engines/gob/game.h2
-rw-r--r--engines/gob/game_v2.cpp45
-rw-r--r--engines/gob/util.cpp12
-rw-r--r--engines/gob/util.h2
5 files changed, 50 insertions, 46 deletions
diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp
index 0d750d525a..f146cded6d 100644
--- a/engines/gob/game.cpp
+++ b/engines/gob/game.cpp
@@ -288,10 +288,43 @@ void Game::freeSoundSlot(int16 slot) {
_vm->_snd->freeSample(sample);
}
+void Game::evaluateScroll(int16 x, int16 y) {
+ if ((_handleMouse == 0) || (_menuLevel > 0))
+ return;
+
+ if (_vm->_global->_videoMode != 0x14)
+ return;
+
+ if ((x == 0) && (_vm->_draw->_scrollOffsetX > 0)) {
+ uint16 off;
+
+ off = MIN(_vm->_draw->_cursorWidth, _vm->_draw->_scrollOffsetX);
+ off = MAX(off / 2, 1);
+ _vm->_draw->_scrollOffsetX -= off;
+ }
+
+ int16 cursorRight = x + _vm->_draw->_cursorWidth;
+ int16 screenRight = _vm->_draw->_scrollOffsetX + 320;
+
+ if ((cursorRight >= 320) && (screenRight < _vm->_video->_surfWidth)) {
+ uint16 off;
+
+ off = MIN(_vm->_draw->_cursorWidth,
+ (int16) (_vm->_video->_surfWidth - screenRight));
+ off = MAX(off / 2, 1);
+
+ _vm->_draw->_scrollOffsetX += off;
+
+ _vm->_util->setMousePos(320 - _vm->_draw->_cursorWidth, y);
+ }
+
+ _vm->_util->setScrollOffset();
+}
+
int16 Game::checkKeys(int16 *pMouseX, int16 *pMouseY,
int16 *pButtons, char handleMouse) {
- _vm->_util->processInput();
+ _vm->_util->processInput(true);
if (_vm->_mult->_multData && _vm->_global->_inter_variables &&
(VAR(58) != 0)) {
diff --git a/engines/gob/game.h b/engines/gob/game.h
index 17a7192e81..f509e0d6a0 100644
--- a/engines/gob/game.h
+++ b/engines/gob/game.h
@@ -139,6 +139,8 @@ public:
void freeSoundSlot(int16 slot);
+ void evaluateScroll(int16 x, int16 y);
+
int16 checkKeys(int16 *pMousex, int16 *pMouseY, int16 *pButtons, char handleMouse);
void start(void);
void totSub(int8 flags, const char *newTotFile);
diff --git a/engines/gob/game_v2.cpp b/engines/gob/game_v2.cpp
index 7fd681b870..3113d81349 100644
--- a/engines/gob/game_v2.cpp
+++ b/engines/gob/game_v2.cpp
@@ -407,6 +407,8 @@ int16 Game_v2::checkCollisions(byte handleMouse, int16 deltaTime, int16 *pResId,
int16 newkey;
uint32 timeKey;
+ _handleMouse = handleMouse;
+
if (deltaTime >= -1) {
_lastCollKey = 0;
_lastCollAreaIndex = 0;
@@ -448,49 +450,6 @@ int16 Game_v2::checkCollisions(byte handleMouse, int16 deltaTime, int16 *pResId,
key = checkKeys(&_vm->_global->_inter_mouseX,
&_vm->_global->_inter_mouseY, &_mouseButtons, handleMouse);
- if ((_vm->_global->_videoMode == 0x14) && (handleMouse != 0) &&
- (_menuLevel == 0)) {
-
- int16 cursorRight;
- int16 screenRight;
-
- if ((_vm->_global->_inter_mouseX == _vm->_draw->_scrollOffsetX) &&
- (_vm->_draw->_scrollOffsetX > 0)) {
- uint16 off;
- int16 min;
-
- off = MIN(_vm->_draw->_cursorWidth, _vm->_draw->_scrollOffsetX);
- off = MAX(off / 2, 1);
- min = _vm->_draw->_scrollOffsetX - off + 1;
-
- _vm->_draw->_scrollOffsetX -= off;
- _vm->_global->_inter_mouseX -= off;
- _vm->_global->_inter_mouseX = MAX(_vm->_global->_inter_mouseX, min);
- }
-
- cursorRight = _vm->_global->_inter_mouseX + _vm->_draw->_cursorWidth;
- screenRight = _vm->_draw->_scrollOffsetX + 320;
-
- if ((cursorRight >= screenRight) &&
- (screenRight < _vm->_video->_surfWidth)) {
- uint16 off;
- int16 max;
-
- off = MIN(_vm->_draw->_cursorWidth,
- (int16) (_vm->_video->_surfWidth - screenRight));
- off = MAX(off / 2, 1);
- max = _vm->_video->_surfWidth - _vm->_draw->_cursorWidth;
-
- _vm->_draw->_scrollOffsetX += off;
- _vm->_global->_inter_mouseX += off - 1;
- _vm->_global->_inter_mouseX = MIN(_vm->_global->_inter_mouseX, max);
- }
-
- _vm->_util->setScrollOffset();
- _vm->_util->setMousePos(MAX(0, _vm->_global->_inter_mouseX -
- _vm->_draw->_scrollOffsetX), _vm->_global->_inter_mouseY);
- }
-
if ((handleMouse == 0) && (_mouseButtons != 0)) {
_vm->_util->waitMouseRelease(0);
key = 3;
diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp
index 0ccb31e1c9..550d5e9a21 100644
--- a/engines/gob/util.cpp
+++ b/engines/gob/util.cpp
@@ -77,12 +77,19 @@ void Util::initInput(void) {
_keyBufferHead = _keyBufferTail = 0;
}
-void Util::processInput() {
+void Util::processInput(bool scroll) {
Common::Event event;
Common::EventManager *eventMan = g_system->getEventManager();
+ int16 x, y;
+ bool hasMove = false;
while (eventMan->pollEvent(event)) {
switch (event.type) {
+ case Common::EVENT_MOUSEMOVE:
+ hasMove = true;
+ x = event.mouse.x;
+ y = event.mouse.y;
+ break;
case Common::EVENT_LBUTTONDOWN:
_mouseButtons |= 1;
break;
@@ -107,6 +114,9 @@ void Util::processInput() {
break;
}
}
+
+ if (scroll && hasMove)
+ _vm->_game->evaluateScroll(x, y);
}
void Util::clearKeyBuf(void) {
diff --git a/engines/gob/util.h b/engines/gob/util.h
index 946da23665..d476afd69c 100644
--- a/engines/gob/util.h
+++ b/engines/gob/util.h
@@ -54,7 +54,7 @@ public:
void longDelay(uint16 msecs);
void initInput(void);
- void processInput(void);
+ void processInput(bool scroll = false);
void clearKeyBuf(void);
int16 getKey(void);
int16 checkKey(void);