aboutsummaryrefslogtreecommitdiff
path: root/engines/gob
diff options
context:
space:
mode:
authorSven Hesse2008-12-14 02:09:03 +0000
committerSven Hesse2008-12-14 02:09:03 +0000
commit126c5a1dc8ec76b74a33f9b62d553d652a382df4 (patch)
tree37179aab259ebb7c506a4e83b6b8ada874b9cd1f /engines/gob
parent81d060675cbc6d855bc9ad89b0f0faf0d8408322 (diff)
downloadscummvm-rg350-126c5a1dc8ec76b74a33f9b62d553d652a382df4.tar.gz
scummvm-rg350-126c5a1dc8ec76b74a33f9b62d553d652a382df4.tar.bz2
scummvm-rg350-126c5a1dc8ec76b74a33f9b62d553d652a382df4.zip
More modified collision stuff for Urban Runner. The hotspots are correctly recognized now
svn-id: r35350
Diffstat (limited to 'engines/gob')
-rw-r--r--engines/gob/game.cpp2
-rw-r--r--engines/gob/game.h16
-rw-r--r--engines/gob/game_v1.cpp2
-rw-r--r--engines/gob/game_v2.cpp1
-rw-r--r--engines/gob/game_v6.cpp266
-rw-r--r--engines/gob/util.cpp7
6 files changed, 288 insertions, 6 deletions
diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp
index 3bc721e08d..47da5cf8f4 100644
--- a/engines/gob/game.cpp
+++ b/engines/gob/game.cpp
@@ -765,7 +765,7 @@ byte *Game::loadLocTexts(int32 *dataSize) {
return 0;
}
-void Game::setCollisions(void) {
+void Game::setCollisions(byte arg_0) {
byte *savedIP;
uint16 left;
uint16 top;
diff --git a/engines/gob/game.h b/engines/gob/game.h
index b66fbc8edf..b536c8bf86 100644
--- a/engines/gob/game.h
+++ b/engines/gob/game.h
@@ -223,11 +223,12 @@ protected:
void loadExtTable(void);
void loadImFile(void);
- void setCollisions(void);
- void collSub(uint16 offset);
void collAreaSub(int16 index, int8 enter);
int16 openLocTextFile(char *locTextFile, int language);
+ virtual void setCollisions(byte arg_0 = 1);
+ virtual void collSub(uint16 offset);
+
virtual int16 checkMousePoint(int16 all, int16 *resId, int16 *resIndex) = 0;
};
@@ -305,8 +306,19 @@ public:
virtual void pushCollisions(char all);
+ virtual int16 checkCollisions(byte handleMouse, int16 deltaTime,
+ int16 *pResId, int16 *pResIndex);
+
Game_v6(GobEngine *vm);
virtual ~Game_v6() {}
+
+protected:
+ uint32 _dword_63E44;
+
+ virtual void setCollisions(byte arg_0 = 1);
+ virtual void collSub(uint16 offset);
+
+ void sub_1BA78();
};
} // End of namespace Gob
diff --git a/engines/gob/game_v1.cpp b/engines/gob/game_v1.cpp
index aecdde4309..35fb3d8b23 100644
--- a/engines/gob/game_v1.cpp
+++ b/engines/gob/game_v1.cpp
@@ -276,6 +276,8 @@ int16 Game_v1::addNewCollision(int16 id, uint16 left, uint16 top,
ptr->key = key;
ptr->funcEnter = funcEnter;
ptr->funcLeave = funcLeave;
+ ptr->totFileData = 0;
+
return i;
}
error("Game_v1::addNewCollision(): Collision array full!\n");
diff --git a/engines/gob/game_v2.cpp b/engines/gob/game_v2.cpp
index 28de420467..4220688940 100644
--- a/engines/gob/game_v2.cpp
+++ b/engines/gob/game_v2.cpp
@@ -335,6 +335,7 @@ int16 Game_v2::addNewCollision(int16 id, uint16 left, uint16 top,
ptr->funcEnter = funcEnter;
ptr->funcLeave = funcLeave;
ptr->funcSub = 0;
+ ptr->totFileData = 0;
return i;
}
diff --git a/engines/gob/game_v6.cpp b/engines/gob/game_v6.cpp
index a75e6c9f5e..2a9a1c254f 100644
--- a/engines/gob/game_v6.cpp
+++ b/engines/gob/game_v6.cpp
@@ -28,11 +28,15 @@
#include "gob/gob.h"
#include "gob/game.h"
+#include "gob/global.h"
#include "gob/inter.h"
+#include "gob/draw.h"
+#include "gob/parse.h"
namespace Gob {
Game_v6::Game_v6(GobEngine *vm) : Game_v2(vm) {
+ _dword_63E44 = 0;
}
int16 Game_v6::addNewCollision(int16 id, uint16 left, uint16 top,
@@ -123,4 +127,266 @@ void Game_v6::pushCollisions(char all) {
}
}
+int16 Game_v6::checkCollisions(byte handleMouse, int16 deltaTime, int16 *pResId,
+ int16 *pResIndex) {
+ int16 resIndex;
+ int16 key;
+ uint32 timeKey;
+
+ _scrollHandleMouse = handleMouse != 0;
+
+ if (deltaTime >= -1) {
+ _lastCollKey = 0;
+ _lastCollAreaIndex = 0;
+ _lastCollId = 0;
+ }
+
+ if (pResId != 0)
+ *pResId = 0;
+
+ resIndex = 0;
+
+ if ((_lastCollKey != 0) &&
+ ( (_collisionAreas[_lastCollAreaIndex].id != _lastCollId) ||
+ (_collisionAreas[_lastCollAreaIndex].key != _lastCollKey))) {
+
+ _lastCollKey = 0;
+ _lastCollAreaIndex = 0;
+ _lastCollId = 0;
+ }
+
+ if ((_vm->_draw->_cursorIndex == -1) &&
+ (handleMouse != 0) && (_lastCollKey == 0)) {
+ _lastCollKey = checkMousePoint(1, &_lastCollId, &_lastCollAreaIndex);
+
+ if ((_lastCollKey != 0) && (_lastCollId & 0x8000))
+ collAreaSub(_lastCollAreaIndex, 1);
+ }
+
+ if (handleMouse != 0)
+ _vm->_draw->animateCursor(-1);
+
+ timeKey = _vm->_util->getTimeKey();
+ _vm->_draw->blitInvalidated();
+ while (1) {
+ if (_vm->_inter->_terminate || _vm->shouldQuit()) {
+ if (handleMouse)
+ _vm->_draw->blitCursor();
+ return 0;
+ }
+
+ sub_1BA78();
+ if (!_vm->_draw->_noInvalidated) {
+ if (handleMouse != 0)
+ _vm->_draw->animateCursor(-1);
+ else
+ _vm->_draw->blitInvalidated();
+ _vm->_video->waitRetrace();
+ }
+
+ key = checkKeys(&_vm->_global->_inter_mouseX,
+ &_vm->_global->_inter_mouseY, &_mouseButtons, handleMouse);
+
+ if ((handleMouse == 0) && (_mouseButtons != 0)) {
+ _vm->_util->waitMouseRelease(0);
+ key = 3;
+ }
+
+ if (key != 0) {
+
+ if (handleMouse & 1)
+ _vm->_draw->blitCursor();
+
+ if (pResId != 0)
+ *pResId = 0;
+
+ if (pResIndex != 0)
+ *pResIndex = 0;
+
+ if ((_lastCollKey != 0) && (_lastCollId & 0x8000))
+ collAreaSub(_lastCollAreaIndex, 0);
+
+ _lastCollKey = 0;
+ if (key != 0)
+ return key;
+
+ if (handleMouse)
+ _vm->_draw->animateCursor(-1);
+ }
+
+ if (handleMouse != 0) {
+ if (_mouseButtons != 0) {
+
+ if (deltaTime > 0) {
+ _vm->_draw->animateCursor(2);
+ _vm->_util->delay(deltaTime);
+ } else if (handleMouse & 1)
+ _vm->_util->waitMouseRelease(1);
+
+ _vm->_draw->animateCursor(-1);
+
+ if (pResId != 0)
+ *pResId = 0;
+
+ key = checkMousePoint(0, pResId, &resIndex);
+ if (pResIndex != 0)
+ *pResIndex = resIndex;
+
+ if ((key != 0) || ((pResId != 0) && (*pResId != 0))) {
+ if ((handleMouse & 1) &&
+ ((deltaTime <= 0) || (_mouseButtons == 0)))
+ _vm->_draw->blitCursor();
+
+ if (key != _lastCollKey)
+ collAreaSub(_lastCollAreaIndex, 0);
+
+ _lastCollKey = 0;
+ return key;
+ }
+
+ if (handleMouse & 4)
+ return 0;
+
+ if (_lastCollKey != 0)
+ collAreaSub(_lastCollAreaIndex, 0);
+
+ _lastCollKey = checkMousePoint(1, &_lastCollId, &_lastCollAreaIndex);
+ if ((_lastCollKey != 0) && (_lastCollId & 0x8000))
+ collAreaSub(_lastCollAreaIndex, 1);
+ } else
+ sub_1BA78();
+ }
+
+ if ((deltaTime == -2) && (key == 0) && (_mouseButtons == 0)) {
+ if (pResId != 0)
+ *pResId = 0;
+
+ if (pResIndex != 0)
+ *pResIndex = 0;
+
+ return 0;
+
+ } else if (handleMouse != 0)
+ _vm->_draw->animateCursor(-1);
+
+ if ((deltaTime < 0) && (key == 0) && (_mouseButtons == 0)) {
+ uint32 curtime = _vm->_util->getTimeKey();
+ if ((curtime + deltaTime) > timeKey) {
+ if (pResId != 0)
+ *pResId = 0;
+
+ if (pResIndex != 0)
+ *pResIndex = 0;
+
+ return 0;
+ }
+ }
+
+ _vm->_util->delay(10);
+ }
+}
+
+void Game_v6::setCollisions(byte arg_0) {
+ for (Collision *collArea = _collisionAreas; collArea->left != 0xFFFF; collArea++) {
+ if (((collArea->id & 0xC000) != 0x8000) || (collArea->funcSub == 0))
+ continue;
+
+ if (arg_0 == 0)
+ if (collArea->flags & 0x80)
+ continue;
+
+ byte *totFileData = collArea->totFileData;
+
+ if (!totFileData)
+ totFileData = _totFileData;
+
+ byte *savedIP = _vm->_global->_inter_execPtr;
+
+ _vm->_global->_inter_execPtr = totFileData + collArea->funcSub;
+
+ int16 left = _vm->_parse->parseValExpr();
+ int16 top = _vm->_parse->parseValExpr();
+ int16 width = _vm->_parse->parseValExpr();
+ int16 height = _vm->_parse->parseValExpr();
+ uint16 flags;
+
+ if ((collArea->id & 0xF000) == 0xA000)
+ flags = _vm->_parse->parseValExpr();
+
+ if ((_vm->_draw->_renderFlags & RENDERFLAG_CAPTUREPOP) &&
+ (left != -1)) {
+ left += _vm->_draw->_backDeltaX;
+ top += _vm->_draw->_backDeltaY;
+ }
+ if (_vm->_draw->_needAdjust != 2) {
+ _vm->_draw->adjustCoords(0, &left, &top);
+ if ((collArea->flags & 0x0F) < 3)
+ _vm->_draw->adjustCoords(2, &width, &height);
+ else {
+ height &= 0xFFFE;
+ _vm->_draw->adjustCoords(2, 0, &height);
+ }
+ }
+
+ if (left < 0) {
+ width += left;
+ left = 0;
+ }
+
+ if (top < 0) {
+ height += top;
+ top = 0;
+ }
+
+ collArea->left = left;
+ collArea->top = top;
+ collArea->right = left + width - 1;
+ collArea->bottom = top + height - 1;
+
+ if ((collArea->id & 0xF000) == 0xA000)
+ collArea->flags = flags;
+
+ _vm->_global->_inter_execPtr = savedIP;
+ }
+}
+
+void Game_v6::collSub(uint16 offset) {
+ byte *savedIP;
+ int16 collStackSize;
+
+ savedIP = _vm->_global->_inter_execPtr;
+ _vm->_global->_inter_execPtr = _totFileData + offset;
+
+ _shouldPushColls = 1;
+ collStackSize = _collStackSize;
+
+ _vm->_inter->funcBlock(0);
+
+ if (collStackSize != _collStackSize)
+ popCollisions();
+
+ _shouldPushColls = 0;
+ _vm->_global->_inter_execPtr = savedIP;
+
+ if ((_vm->_util->getTimeKey() - _dword_63E44) > 500)
+ setCollisions(0);
+}
+
+void Game_v6::sub_1BA78() {
+ int16 lastCollAreaIndex = _lastCollAreaIndex;
+ int16 lastCollId = _lastCollId;
+ int16 collKey = checkMousePoint(1, &_lastCollId, &_lastCollAreaIndex);
+
+ if (collKey == _lastCollKey)
+ return;
+
+ if ((_lastCollKey != 0) && (lastCollId & 0x8000))
+ collAreaSub(lastCollAreaIndex, 0);
+
+ _lastCollKey = collKey;
+
+ if ((_lastCollKey != 0) && (_lastCollId & 0x8000))
+ collAreaSub(_lastCollAreaIndex, 1);
+}
+
} // End of namespace Gob
diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp
index 543e363c31..52831637c1 100644
--- a/engines/gob/util.cpp
+++ b/engines/gob/util.cpp
@@ -267,12 +267,13 @@ void Util::waitMouseRelease(char drawMouse) {
int16 mouseX;
int16 mouseY;
- do {
- _vm->_game->checkKeys(&mouseX, &mouseY, &buttons, drawMouse);
+ _vm->_game->checkKeys(&mouseX, &mouseY, &buttons, drawMouse);
+ while (buttons != 0) {
if (drawMouse != 0)
_vm->_draw->animateCursor(2);
delay(10);
- } while (buttons != 0);
+ _vm->_game->checkKeys(&mouseX, &mouseY, &buttons, drawMouse);
+ }
}
void Util::forceMouseUp(bool onlyWhenSynced) {