diff options
author | Sven Hesse | 2006-06-29 12:55:57 +0000 |
---|---|---|
committer | Sven Hesse | 2006-06-29 12:55:57 +0000 |
commit | 27a8b8a255478ebe76fb616e7d5dba0b8f433dce (patch) | |
tree | b89a6172d493552179273241322c75e88206c115 /engines/gob/game.cpp | |
parent | 221afd715a0806405de3e86bc30323a208096cc7 (diff) | |
download | scummvm-rg350-27a8b8a255478ebe76fb616e7d5dba0b8f433dce.tar.gz scummvm-rg350-27a8b8a255478ebe76fb616e7d5dba0b8f433dce.tar.bz2 scummvm-rg350-27a8b8a255478ebe76fb616e7d5dba0b8f433dce.zip |
- Renamed a few mult-variables to something more fitting
- Fixed a small mistake, making the entering animation work
- Correcting Game_v2::playTot() so that the loading screen is shown
- Updated most of the collisions stuff, the objects names hint stuff works now
svn-id: r23346
Diffstat (limited to 'engines/gob/game.cpp')
-rw-r--r-- | engines/gob/game.cpp | 748 |
1 files changed, 5 insertions, 743 deletions
diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp index 646b390fc1..d34004729f 100644 --- a/engines/gob/game.cpp +++ b/engines/gob/game.cpp @@ -250,65 +250,6 @@ void Game::freeCollision(int16 id) { } } -int16 Game::checkMousePoint(int16 all, int16 *resId, int16 *resIndex) { - Collision *ptr; - int16 i; - - if (resId != 0) - *resId = 0; - - *resIndex = 0; - - ptr = _collisionAreas; - for (i = 0; ptr->left != -1; ptr++, i++) { - if (all) { - if ((ptr->flags & 0xf) > 1) - continue; - - if ((ptr->flags & 0xff00) != 0) - continue; - - if (_vm->_global->_inter_mouseX < ptr->left - || _vm->_global->_inter_mouseX > ptr->right - || _vm->_global->_inter_mouseY < ptr->top - || _vm->_global->_inter_mouseY > ptr->bottom) - continue; - - if (resId != 0) - *resId = ptr->id; - - *resIndex = i; - return ptr->key; - } else { - if ((ptr->flags & 0xff00) != 0) - continue; - - if ((ptr->flags & 0xf) != 1 && (ptr->flags & 0xf) != 2) - continue; - - if ((ptr->flags & 0xf0) >> 4 != _mouseButtons - 1 - && (ptr->flags & 0xf0) >> 4 != 2) - continue; - - if (_vm->_global->_inter_mouseX < ptr->left - || _vm->_global->_inter_mouseX > ptr->right - || _vm->_global->_inter_mouseY < ptr->top - || _vm->_global->_inter_mouseY > ptr->bottom) - continue; - - if (resId != 0) - *resId = ptr->id; - *resIndex = i; - return ptr->key; - } - } - - if (_mouseButtons != 1 && all == 0) - return 0x11b; - - return 0; -} - void Game::capturePush(int16 left, int16 top, int16 width, int16 height) { int16 right; @@ -654,169 +595,6 @@ int16 Game::inputArea(int16 xPos, int16 yPos, int16 width, int16 height, int16 b } } -int16 Game::multiEdit(int16 time, int16 index, int16 *pCurPos, InputDesc * inpDesc) { - Collision *collArea; - int16 descInd; - int16 key; - int16 found = -1; - int16 i; - - descInd = 0; - for (i = 0; i < 250; i++) { - collArea = &_collisionAreas[i]; - - if (collArea->left == -1) - continue; - - if ((collArea->id & 0x8000) == 0) - continue; - - if ((collArea->flags & 0x0f) < 3) - continue; - - if ((collArea->flags & 0x0f) > 10) - continue; - - strcpy(_tempStr, _vm->_global->_inter_variables + collArea->key); - - _vm->_draw->_destSpriteX = collArea->left; - _vm->_draw->_destSpriteY = collArea->top; - _vm->_draw->_spriteRight = collArea->right - collArea->left + 1; - _vm->_draw->_spriteBottom = collArea->bottom - collArea->top + 1; - - _vm->_draw->_destSurface = 21; - - _vm->_draw->_backColor = inpDesc[descInd].backColor; - _vm->_draw->_frontColor = inpDesc[descInd].frontColor; - _vm->_draw->_textToPrint = _tempStr; - _vm->_draw->_transparency = 1; - _vm->_draw->_fontIndex = inpDesc[descInd].fontIndex; - _vm->_draw->spriteOperation(DRAW_FILLRECT); - _vm->_draw->_destSpriteY += - ((collArea->bottom - collArea->top + 1) - 8) / 2; - - _vm->_draw->spriteOperation(DRAW_PRINTTEXT); - descInd++; - } - - for (i = 0; i < 40; i++) { - WRITE_VAR_OFFSET(i * 4 + 0x44, 0); - } - - while (1) { - descInd = 0; - - for (i = 0; i < 250; i++) { - collArea = &_collisionAreas[i]; - - if (collArea->left == -1) - continue; - - if ((collArea->id & 0x8000) == 0) - continue; - - if ((collArea->flags & 0x0f) < 3) - continue; - - if ((collArea->flags & 0x0f) > 10) - continue; - - if (descInd == *pCurPos) { - found = i; - break; - } - - descInd++; - } - - assert(found != -1); - - collArea = &_collisionAreas[found]; - - key = inputArea(collArea->left, collArea->top, - collArea->right - collArea->left + 1, - collArea->bottom - collArea->top + 1, - inpDesc[*pCurPos].backColor, inpDesc[*pCurPos].frontColor, - _vm->_global->_inter_variables + collArea->key, - inpDesc[*pCurPos].fontIndex, collArea->flags, &time); - - if (_vm->_inter->_terminate) - return 0; - - switch (key) { - case 0: - if (_activeCollResId == 0) - return 0; - - if ((_collisionAreas[_activeCollIndex]. - flags & 0x0f) < 3) - return 0; - - if ((_collisionAreas[_activeCollIndex]. - flags & 0x0f) > 10) - return 0; - - *pCurPos = 0; - for (i = 0; i < 250; i++) { - collArea = &_collisionAreas[i]; - - if (collArea->left == -1) - continue; - - if ((collArea->id & 0x8000) == 0) - continue; - - if ((collArea->flags & 0x0f) < 3) - continue; - - if ((collArea->flags & 0x0f) > 10) - continue; - - if (i == _activeCollIndex) - break; - - pCurPos[0]++; - } - break; - - case 0x3b00: - case 0x3c00: - case 0x3d00: - case 0x3e00: - case 0x3f00: - case 0x4000: - case 0x4100: - case 0x4200: - case 0x4300: - case 0x4400: - return key; - - case 0x1c0d: - - if (index == 1) - return key; - - if (*pCurPos == index - 1) { - *pCurPos = 0; - break; - } - - pCurPos[0]++; - break; - - case 0x5000: - if (index - 1 > *pCurPos) - pCurPos[0]++; - break; - - case 0x4800: - if (*pCurPos > 0) - pCurPos[0]--; - break; - } - } -} - int16 Game::adjustKey(int16 key) { if (key <= 0x60 || key >= 0x7b) return key; @@ -824,522 +602,6 @@ int16 Game::adjustKey(int16 key) { return key - 0x20; } -void Game::collisionsBlock(void) { - InputDesc descArray[20]; - int16 array[250]; - char count; - int16 collResId; - char *startIP; - int16 curCmd; - int16 cmd; - int16 cmdHigh; - int16 key; - int16 flags; - int16 left; - int16 top; - int16 width; - int16 height; - int16 var_22; - int16 index; - int16 curEditIndex; - int16 deltaTime; - int16 descIndex2; - int16 stackPos2; - int16 descIndex; - int16 timeVal; - char *str; - int16 savedCollStackSize; - int16 i; - int16 counter; - int16 var_24; - int16 var_26; - int16 _collStackPos; - Collision *collPtr; - int16 timeKey; - char *savedIP; - - if (_shouldPushColls) - pushCollisions(1); - - collResId = -1; - _vm->_global->_inter_execPtr++; - count = *_vm->_global->_inter_execPtr++; - _handleMouse = _vm->_global->_inter_execPtr[0]; - deltaTime = 1000 * (byte)_vm->_global->_inter_execPtr[1]; - descIndex2 = (byte)_vm->_global->_inter_execPtr[2]; - stackPos2 = (byte)_vm->_global->_inter_execPtr[3]; - descIndex = (byte)_vm->_global->_inter_execPtr[4]; - - if (stackPos2 != 0 || descIndex != 0) - deltaTime /= 100; - - timeVal = deltaTime; - _vm->_global->_inter_execPtr += 6; - - startIP = _vm->_global->_inter_execPtr; - WRITE_VAR(16, 0); - var_22 = 0; - index = 0; - curEditIndex = 0; - - for (curCmd = 0; curCmd < count; curCmd++) { - array[curCmd] = 0; - cmd = *_vm->_global->_inter_execPtr++; - - if ((cmd & 0x40) != 0) { - cmd -= 0x40; - cmdHigh = (byte)*_vm->_global->_inter_execPtr; - _vm->_global->_inter_execPtr++; - cmdHigh <<= 8; - } else { - cmdHigh = 0; - } - - if ((cmd & 0x80) != 0) { - left = _vm->_parse->parseValExpr(); - top = _vm->_parse->parseValExpr(); - width = _vm->_parse->parseValExpr(); - height = _vm->_parse->parseValExpr(); - } else { - left = _vm->_inter->load16(); - top = _vm->_inter->load16(); - width = _vm->_inter->load16(); - height = _vm->_inter->load16(); - } - cmd &= 0x7f; - - debugC(1, DEBUG_COLLISIONS, "collisionsBlock(%d)", cmd); - - switch (cmd) { - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - - _vm->_util->waitKey(); - var_22 = 1; - key = _vm->_parse->parseVarIndex(); - descArray[index].fontIndex = _vm->_inter->load16(); - descArray[index].backColor = *_vm->_global->_inter_execPtr++; - descArray[index].frontColor = *_vm->_global->_inter_execPtr++; - - if (cmd < 5 || cmd > 8) { - descArray[index].ptr = 0; - } else { - descArray[index].ptr = _vm->_global->_inter_execPtr + 2; - _vm->_global->_inter_execPtr += _vm->_inter->load16(); - } - - if (left == -1) - break; - - if ((cmd & 1) == 0) { - addNewCollision(curCmd + 0x8000, left, - top, - left + - width * - _vm->_draw->_fonts[descArray[index].fontIndex]-> - itemWidth - 1, top + height - 1, cmd, key, - 0, - _vm->_global->_inter_execPtr - (char *)_totFileData); - - _vm->_global->_inter_execPtr += 2; - _vm->_global->_inter_execPtr += READ_LE_UINT16(_vm->_global->_inter_execPtr); - } else { - addNewCollision(curCmd + 0x8000, left, - top, - left + - width * - _vm->_draw->_fonts[descArray[index].fontIndex]-> - itemWidth - 1, top + height - 1, cmd, key, - 0, 0); - } - index++; - break; - - case 21: - key = _vm->_inter->load16(); - array[curCmd] = _vm->_inter->load16(); - flags = _vm->_inter->load16() & 3; - - addNewCollision(curCmd + 0x8000, left, top, - left + width - 1, - top + height - 1, - (flags << 4) + cmdHigh + 2, key, - _vm->_global->_inter_execPtr - (char *)_totFileData, 0); - - _vm->_global->_inter_execPtr += 2; - _vm->_global->_inter_execPtr += READ_LE_UINT16(_vm->_global->_inter_execPtr); - break; - - case 20: - collResId = curCmd; - // Fall through to case 2 - - case 2: - key = _vm->_inter->load16(); - array[curCmd] = _vm->_inter->load16(); - flags = _vm->_inter->load16() & 3; - - addNewCollision(curCmd + 0x8000, left, top, - left + width - 1, - top + height - 1, - (flags << 4) + cmdHigh + 2, key, 0, - _vm->_global->_inter_execPtr - (char *)_totFileData); - - _vm->_global->_inter_execPtr += 2; - _vm->_global->_inter_execPtr += READ_LE_UINT16(_vm->_global->_inter_execPtr); - break; - - case 0: - _vm->_global->_inter_execPtr += 6; - startIP = _vm->_global->_inter_execPtr; - _vm->_global->_inter_execPtr += 2; - _vm->_global->_inter_execPtr += READ_LE_UINT16(_vm->_global->_inter_execPtr); - key = curCmd + 0xA000; - - addNewCollision(curCmd + 0x8000, left, top, - left + width - 1, - top + height - 1, - cmd + cmdHigh, key, - startIP - (char *)_totFileData, - _vm->_global->_inter_execPtr - (char *)_totFileData); - - _vm->_global->_inter_execPtr += 2; - _vm->_global->_inter_execPtr += READ_LE_UINT16(_vm->_global->_inter_execPtr); - break; - - case 1: - key = _vm->_inter->load16(); - array[curCmd] = _vm->_inter->load16(); - flags = _vm->_inter->load16() & 3; - - startIP = _vm->_global->_inter_execPtr; - _vm->_global->_inter_execPtr += 2; - _vm->_global->_inter_execPtr += READ_LE_UINT16(_vm->_global->_inter_execPtr); - if (key == 0) - key = curCmd + 0xa000; - - addNewCollision(curCmd + 0x8000, left, top, - left + width - 1, - top + height - 1, - (flags << 4) + cmd + cmdHigh, key, - startIP - (char *)_totFileData, - _vm->_global->_inter_execPtr - (char *)_totFileData); - - _vm->_global->_inter_execPtr += 2; - _vm->_global->_inter_execPtr += READ_LE_UINT16(_vm->_global->_inter_execPtr); - break; - } - } - - _forceHandleMouse = 0; - _vm->_util->waitKey(); - - do { - if (var_22 != 0) { - key = - multiEdit(deltaTime, index, &curEditIndex, - descArray); - - if (key == 0x1c0d) { - for (i = 0; i < 250; i++) { - if (_collisionAreas[i].left == -1) - continue; - - if ((_collisionAreas[i].id & 0x8000) == 0) - continue; - - if ((_collisionAreas[i].flags & 1) != 0) - continue; - - if ((_collisionAreas[i].flags & 0x0f) <= 2) - continue; - - collResId = _collisionAreas[i].id; - _activeCollResId = collResId; - collResId &= 0x7fff; - _activeCollIndex = i; - break; - } - break; - } - } else { - key = - checkCollisions(_handleMouse, -deltaTime, - &_activeCollResId, &_activeCollIndex); - } - - if ((key & 0xff) >= ' ' && (key & 0xff) <= 0xff && - (key >> 8) > 1 && (key >> 8) < 12) { - key = '0' + (((key >> 8) - 1) % 10) + (key & 0xff00); - } - - if (_activeCollResId == 0) { - if (key != 0) { - for (i = 0; i < 250; i++) { - if (_collisionAreas[i].left == -1) - continue; - - if ((_collisionAreas[i]. - id & 0x8000) == 0) - continue; - - if (_collisionAreas[i].key == key - || _collisionAreas[i].key == - 0x7fff) { - - _activeCollResId = - _collisionAreas[i].id; - _activeCollIndex = i; - break; - } - } - - if (_activeCollResId == 0) { - for (i = 0; i < 250; i++) { - if (_collisionAreas[i].left == -1) - continue; - - if ((_collisionAreas[i].id & 0x8000) == 0) - continue; - - if ((_collisionAreas[i].key & 0xff00) != 0) - continue; - - if (_collisionAreas[i].key == 0) - continue; - - if (adjustKey(key & 0xff) == adjustKey(_collisionAreas[i].key) || _collisionAreas[i].key == 0x7fff) { - _activeCollResId = _collisionAreas[i].id; - _activeCollIndex = i; - break; - } - } - } - } else { - - if (deltaTime != 0 && VAR(16) == 0) { - if (stackPos2 != 0) { - _collStackPos = 0; - collPtr = _collisionAreas; - - for (i = 0, collPtr = _collisionAreas; collPtr->left != -1; i++, collPtr++) { - if ((collPtr->id & 0x8000) == 0) - continue; - - _collStackPos++; - if (_collStackPos != stackPos2) - continue; - - _activeCollResId = collPtr->id; - _activeCollIndex = i; - WRITE_VAR(2, _vm->_global->_inter_mouseX); - WRITE_VAR(3, _vm->_global->_inter_mouseY); - WRITE_VAR(4, _mouseButtons); - WRITE_VAR(16, array[(uint16)_activeCollResId & ~0x8000]); - - if (collPtr->funcLeave != 0) { - timeKey = _vm->_util->getTimeKey(); - savedIP = _vm->_global->_inter_execPtr; - _vm->_global->_inter_execPtr = (char *)_totFileData + collPtr->funcLeave; - _shouldPushColls = 1; - savedCollStackSize = _collStackSize; - _vm->_inter->funcBlock(0); - - if (savedCollStackSize != _collStackSize) - popCollisions(); - - _shouldPushColls = 0; - _vm->_global->_inter_execPtr = savedIP; - deltaTime = timeVal - (_vm->_util->getTimeKey() - timeKey); - - if (deltaTime < 2) - deltaTime = 2; - } - - if (VAR(16) == 0) - _activeCollResId = 0; - break; - } - } else { - if (descIndex != 0) { - counter = 0; - for (i = 0; i < 250; i++) { - if (_collisionAreas[i].left == -1) - continue; - - if ((_collisionAreas[i].id & 0x8000) == 0) - continue; - - counter++; - if (counter != descIndex) - continue; - - _activeCollResId = _collisionAreas[i].id; - _activeCollIndex = i; - break; - } - } else { - for (i = 0; i < 250; i++) { - if (_collisionAreas[i].left == -1) - continue; - - if ((_collisionAreas[i].id & 0x8000) == 0) - continue; - - _activeCollResId = _collisionAreas[i].id; - _activeCollIndex = i; - break; - } - } - } - } else { - if (descIndex2 != 0) { - counter = 0; - for (i = 0; i < 250; i++) { - if (_collisionAreas[i].left == -1) - continue; - - if ((_collisionAreas[i].id & 0x8000) == 0) - continue; - - counter++; - if (counter != descIndex2) - continue; - - _activeCollResId = _collisionAreas[i].id; - _activeCollIndex = i; - break; - } - } - } - } - } - - if (_activeCollResId == 0) - continue; - - if (_collisionAreas[_activeCollIndex].funcLeave != 0) - continue; - - WRITE_VAR(2, _vm->_global->_inter_mouseX); - WRITE_VAR(3, _vm->_global->_inter_mouseY); - WRITE_VAR(4, _mouseButtons); - WRITE_VAR(16, array[(uint16)_activeCollResId & ~0x8000]); - - if (_collisionAreas[_activeCollIndex].funcEnter != 0) { - savedIP = _vm->_global->_inter_execPtr; - _vm->_global->_inter_execPtr = (char *)_totFileData + - _collisionAreas[_activeCollIndex]. - funcEnter; - - _shouldPushColls = 1; - - _collStackPos = _collStackSize; - _vm->_inter->funcBlock(0); - if (_collStackPos != _collStackSize) - popCollisions(); - _shouldPushColls = 0; - _vm->_global->_inter_execPtr = savedIP; - } - - WRITE_VAR(16, 0); - _activeCollResId = 0; - } - while (_activeCollResId == 0 && !_vm->_inter->_terminate && !_vm->_quitRequested); - - if (((uint16)_activeCollResId & ~0x8000) == collResId) { - _collStackPos = 0; - var_24 = 0; - var_26 = 1; - for (i = 0; i < 250; i++) { - if (_collisionAreas[i].left == -1) - continue; - - if ((_collisionAreas[i].id & 0x8000) == 0) - continue; - - if ((_collisionAreas[i].flags & 0x0f) < 3) - continue; - - if ((_collisionAreas[i].flags & 0x0f) > 10) - continue; - - if ((_collisionAreas[i].flags & 0x0f) > 8) { - char *ptr; - strcpy(_tempStr, - _vm->_global->_inter_variables + _collisionAreas[i].key); - while ((ptr = strchr(_tempStr, ' ')) != 0) { - _vm->_util->cutFromStr(_tempStr, (ptr - _tempStr), 1); - ptr = strchr(_tempStr, ' '); - } - strcpy(_vm->_global->_inter_variables + _collisionAreas[i].key, _tempStr); - } - - if ((_collisionAreas[i].flags & 0x0f) >= 5 && - (_collisionAreas[i].flags & 0x0f) <= 8) { - str = descArray[var_24].ptr; - - strcpy(_tempStr, _vm->_global->_inter_variables + _collisionAreas[i].key); - - if ((_collisionAreas[i].flags & 0x0f) < 7) - _vm->_util->prepareStr(_tempStr); - - int16 pos = 0; - do { - strcpy(_collStr, str); - pos += strlen(str) + 1; - - str += strlen(str) + 1; - - if ((_collisionAreas[i].flags & 0x0f) < 7) - _vm->_util->prepareStr(_collStr); - - if (strcmp(_tempStr, _collStr) == 0) { - VAR(17)++; - WRITE_VAR(17 + var_26, 1); - break; - } - } while (READ_LE_UINT16(descArray[var_24].ptr - 2) > pos); - _collStackPos++; - } else { - VAR(17 + var_26) = 2; - } - var_24++; - var_26++; - } - - if (_collStackPos != (int16)VAR(17)) - WRITE_VAR(17, 0); - else - WRITE_VAR(17, 1); - } - - savedIP = 0; - if (!_vm->_inter->_terminate) { - savedIP = (char *)_totFileData + - _collisionAreas[_activeCollIndex].funcLeave; - - WRITE_VAR(2, _vm->_global->_inter_mouseX); - WRITE_VAR(3, _vm->_global->_inter_mouseY); - WRITE_VAR(4, _mouseButtons); - - if (VAR(16) == 0) { - WRITE_VAR(16, array[(uint16)_activeCollResId & ~0x8000]); - } - } - - for (curCmd = 0; curCmd < count; curCmd++) { - freeCollision(curCmd + 0x8000); - } - _vm->_global->_inter_execPtr = savedIP; -} - void Game::loadTotFile(char *path) { int16 handle; @@ -1408,7 +670,7 @@ void Game::loadImFile(void) { void Game::start(void) { _collisionAreas = new Collision[250]; prepareStart(); - playTot(0); + playTot(-2); delete[] _collisionAreas; @@ -1634,7 +896,7 @@ void Game::setCollisions(void) { top = _vm->_parse->parseValExpr(); width = _vm->_parse->parseValExpr(); height = _vm->_parse->parseValExpr(); - if ((_vm->_draw->_renderFlags != 8) && (left != -1)) { + if ((_vm->_draw->_renderFlags & 8) && (left != -1)) { left += _vm->_draw->_backDeltaX; top += _vm->_draw->_backDeltaY; } @@ -1680,12 +942,12 @@ void Game::collAreaSub(int16 index, int8 enter) { collId = _collisionAreas[index].id & 0xF000; - if ((collId == 0xA000) || (collId == 0x9000)) + if ((collId != 0xA000) && (collId != 0x9000)) WRITE_VAR(17, collId); else if (enter == 0) - WRITE_VAR(17, -(collId & 0x0FFF)); + WRITE_VAR(17, _collisionAreas[index].id & 0x0FFF); else - WRITE_VAR(17, collId & 0x0FFF); + WRITE_VAR(17, -(_collisionAreas[index].id & 0x0FFF)); if (enter != 0) { if (_collisionAreas[index].funcEnter != 0) |