diff options
author | Sven Hesse | 2008-12-14 02:09:03 +0000 |
---|---|---|
committer | Sven Hesse | 2008-12-14 02:09:03 +0000 |
commit | 126c5a1dc8ec76b74a33f9b62d553d652a382df4 (patch) | |
tree | 37179aab259ebb7c506a4e83b6b8ada874b9cd1f /engines/gob/game_v6.cpp | |
parent | 81d060675cbc6d855bc9ad89b0f0faf0d8408322 (diff) | |
download | scummvm-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/game_v6.cpp')
-rw-r--r-- | engines/gob/game_v6.cpp | 266 |
1 files changed, 266 insertions, 0 deletions
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 |