From db0c951a0d180a36e7d1ffd5612890159ea49afc Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Sun, 23 Nov 2008 03:42:01 +0000 Subject: various fixes, Bud Tucker should now be completable (tested with french version) svn-id: r35155 --- engines/tucker/locations.cpp | 96 ++++++++++----------- engines/tucker/resource.cpp | 95 ++++++++++++--------- engines/tucker/sequences.cpp | 27 +++--- engines/tucker/tucker.cpp | 194 ++++++++++++++++++------------------------- engines/tucker/tucker.h | 12 +-- 5 files changed, 202 insertions(+), 222 deletions(-) (limited to 'engines') diff --git a/engines/tucker/locations.cpp b/engines/tucker/locations.cpp index 913bc7b3ae..988f0da9a3 100644 --- a/engines/tucker/locations.cpp +++ b/engines/tucker/locations.cpp @@ -359,7 +359,6 @@ void TuckerEngine::execData3PreUpdate_locationNum3() { void TuckerEngine::updateSprite_locationNum4(int i) { int state = -1; - printf("_flagsTable[9] %d\n", _flagsTable[9]); if (_flagsTable[9] == 2) { if (_charSpeechSoundCounter > 0 && _actionCharacterNum == i) { state = 1; @@ -415,7 +414,7 @@ void TuckerEngine::updateSprite_locationNum6_0(int i) { state = 3; _spritesTable[0].counter = 0; } else if (_xPosCurrent < 370 && _flagsTable[26] == 4) { - state = 2; + state = 2; } else if (_spritesTable[0].counter == 0) { setCharacterAnimation(0, 0); _updateSpriteFlag1 = 1; @@ -456,7 +455,7 @@ void TuckerEngine::updateSprite_locationNum6_1(int i) { state = 7; _soundsMapTable[0] = 3; _miscSoundFxDelayCounter[0] = 70; -// _miscSoundFxDelayCounter[-1] = 4; + _soundsMapTable[1] = 4; _miscSoundFxDelayCounter[1] = 25; } } @@ -525,31 +524,26 @@ void TuckerEngine::execData3PreUpdate_locationNum6Helper1() { } } int x1, x2; - switch (_flagsTable[27]) { - case 0: + if (_flagsTable[27] == 0) { x1 = 8; x2 = 0; - break; - case 15: + } else if (_flagsTable[27] == 15) { x1 = 1; x2 = 0; - break; - case 8: - x1 = _flagsTable[27]; + } else if (_flagsTable[27] < 8) { + x1 = 8 - _flagsTable[27]; x2 = _flagsTable[27]; - break; - default: + } else { x1 = 1; x2 = 15 - _flagsTable[27]; - break; } for (int i = 0; i < x1; ++i) { execData3PreUpdate_locationNum6Helper2(_locationBackgroundGfxBuf + 13125 + i * 8, _data3GfxBuf + _dataTable[238].sourceOffset); execData3PreUpdate_locationNum6Helper2(_locationBackgroundGfxBuf + 13245 - i * 8, _data3GfxBuf + _dataTable[238].sourceOffset); } for (int i = 0; i < x2; ++i) { - execData3PreUpdate_locationNum6Helper2(_locationBackgroundGfxBuf + 13125 + x1 * 8 + i * 2, _data3GfxBuf + _dataTable[238].sourceOffset); - execData3PreUpdate_locationNum6Helper2(_locationBackgroundGfxBuf + 13249 - x1 * 8 - i * 2, _data3GfxBuf + _dataTable[238].sourceOffset); + execData3PreUpdate_locationNum6Helper3(_locationBackgroundGfxBuf + 13125 + x1 * 8 + i * 4, _data3GfxBuf + _dataTable[238].sourceOffset); + execData3PreUpdate_locationNum6Helper3(_locationBackgroundGfxBuf + 13249 - x1 * 8 - i * 4, _data3GfxBuf + _dataTable[238].sourceOffset); } } @@ -1337,18 +1331,6 @@ void TuckerEngine::updateSprite_locationNum21() { _spritesTable[0].gfxBackgroundOffset = 320; } -void TuckerEngine::updateSprite_locationNum22() { - if (_flagsTable[207] == 1) { - _spritesTable[0].state = -1; - } else if (_charSpeechSoundCounter > 0 && _actionCharacterNum == 0) { - _spritesTable[0].needUpdate = 1; - _spritesTable[0].state = 2; - } else { - _spritesTable[0].needUpdate = 0; - _spritesTable[0].state = 1; - } -} - void TuckerEngine::execData3PreUpdate_locationNum21() { if (_xPosCurrent > 460 && _flagsTable[58] == 0 && _nextAction == 0) { _updateCharPositionNewType = 0; @@ -1393,10 +1375,9 @@ void TuckerEngine::execData3PostUpdate_locationNum21() { void TuckerEngine::execData3PreUpdate_locationNum22() { if (_flagsTable[53] > 1 && _flagsTable[53] != 4) { - if (_inventoryItemsState[5] > 0 && _inventoryItemsState[20] <= 0 && _inventoryItemsState[16] > 0 && _inventoryItemsState[27] > 0) { + if (_inventoryItemsState[5] > 0 && _inventoryItemsState[20] > 0 && _inventoryItemsState[16] > 0 && _inventoryItemsState[27] > 0) { _flagsTable[53] = 3; - } - if (_inventoryItemsState[5] > 0 || _inventoryItemsState[20] > 0 || _inventoryItemsState[16] > 0 || _inventoryItemsState[27] > 0) { + } else if (_inventoryItemsState[5] > 0 || _inventoryItemsState[20] > 0 || _inventoryItemsState[16] > 0 || _inventoryItemsState[27] > 0) { _flagsTable[53] = 5; } } @@ -1407,6 +1388,18 @@ void TuckerEngine::execData3PreUpdate_locationNum22() { } } +void TuckerEngine::updateSprite_locationNum22() { + if (_flagsTable[207] == 1) { + _spritesTable[0].state = -1; + } else if (_charSpeechSoundCounter > 0 && _actionCharacterNum == 0) { + _spritesTable[0].needUpdate = 1; + _spritesTable[0].state = 2; + } else { + _spritesTable[0].needUpdate = 0; + _spritesTable[0].state = 1; + } +} + void TuckerEngine::updateSprite_locationNum23_0(int i) { int state; if (_flagsTable[210] == 3) { @@ -1781,10 +1774,14 @@ void TuckerEngine::execData3PreUpdate_locationNum29() { if (_updateLocationFadePaletteCounter > 10) { _updateLocationFadePaletteCounter = 0; } - int d = _updateLocationFadePaletteCounter / 2; + const int d = _updateLocationFadePaletteCounter / 2; + uint8 scrollPal[5 * 4]; for (int i = 0; i < 5; ++i) { - setPaletteColor(118 + i, r[i] + d, g[i] + d, b[i] + d); + scrollPal[i * 4] = r[i + d]; + scrollPal[i * 4 + 1] = g[i + d]; + scrollPal[i * 4 + 2] = b[i + d]; } + _system->setPalette(scrollPal, 118, 5); if (_flagsTable[143] == 1) { _locationObjectsTable[2].xPos = 999; _locationObjectsTable[3].xPos = 187; @@ -2187,7 +2184,7 @@ void TuckerEngine::updateSprite_locationNum48(int i) { void TuckerEngine::updateSprite_locationNum49(int i) { if (_flagsTable[136] == 1 && _flagsTable[207] == 0) { - _flagsTable[207] = 2; + _flagsTable[136] = 2; } if (_flagsTable[185] == 0 && _yPosCurrent < 125) { _flagsTable[185] = 1; @@ -2683,12 +2680,12 @@ void TuckerEngine::updateSprite_locationNum63_0(int i) { void TuckerEngine::updateSprite_locationNum63_1(int i) { int state = -1; - if (_flagsTable[132] == 2 && _flagsTable[133] == 1 && _flagsTable[136] > 0) { - state = -1; - } else if (getRandomNumber() > 30000) { - state = 5; - } else if (getRandomNumber() > 30000) { - state = 8; + if (_flagsTable[132] == 2 && _flagsTable[133] == 1 && _flagsTable[136] <= 0) { + if (getRandomNumber() > 30000) { + state = 5; + } else if (getRandomNumber() > 30000) { + state = 8; + } } _spritesTable[i].state = state; } @@ -2696,7 +2693,7 @@ void TuckerEngine::updateSprite_locationNum63_1(int i) { void TuckerEngine::updateSprite_locationNum63_2(int i) { ++_spritesTable[i].counter; int state = -1; - if (_flagsTable[132] == 2 && _flagsTable[133] == 1 && _flagsTable[136] > 0) { + if (_flagsTable[132] == 2 && _flagsTable[133] == 1 && _flagsTable[136] <= 0) { if (_flagsTable[226] == 0) { state = 9; _spritesTable[i].updateDelay = 5; @@ -2716,7 +2713,7 @@ void TuckerEngine::updateSprite_locationNum63_2(int i) { void TuckerEngine::updateSprite_locationNum63_3(int i) { ++_spritesTable[i].counter; int state = -1; - if (_flagsTable[133] == 1 && _flagsTable[132] == 2 && _flagsTable[136] > 0) { + if (_flagsTable[132] == 2 && _flagsTable[133] == 1 && _flagsTable[136] <= 0) { if (_spritesTable[i].counter > 80) { state = 7; _spritesTable[i].counter = 0; @@ -2742,6 +2739,7 @@ void TuckerEngine::updateSprite_locationNum63_4(int i) { void TuckerEngine::execData3PreUpdate_locationNum63() { _currentGfxBackgroundCounter = 20 - _flagsTable[132] * 10; if (_flagsTable[132] != _execData3Counter) { + _mainLoopCounter1 = 0; _execData3Counter = _flagsTable[132]; } if (_flagsTable[133] == 0) { @@ -2757,7 +2755,7 @@ void TuckerEngine::execData3PreUpdate_locationNum63() { } } } else { - if (_flagsTable[132] == 0 || _flagsTable[132] == 2 || _flagsTable[136] > 0) { + if (_flagsTable[132] == 0 || (_flagsTable[132] == 2 && _flagsTable[136] > 0)) { if (!isSoundPlaying(1)) { _locationSoundsTable[1].type = 2; startSound(_locationSoundsTable[1].offset, 1, _locationSoundsTable[1].volume); @@ -2773,8 +2771,8 @@ void TuckerEngine::execData3PreUpdate_locationNum63() { startSound(_locationSoundsTable[0].offset, 0, _locationSoundsTable[0].volume); } } else { - if (isSoundPlaying(1)) { - stopSound(1); + if (isSoundPlaying(0)) { + stopSound(0); } } if (_flagsTable[132] == 2 && _flagsTable[136] == 0) { @@ -2825,7 +2823,7 @@ void TuckerEngine::updateSprite_locationNum65(int i) { } void TuckerEngine::execData3PreUpdate_locationNum65() { - _flagsTable[137]= 0; + _flagsTable[137] = 0; } void TuckerEngine::updateSprite_locationNum66_0(int i) { @@ -2887,7 +2885,8 @@ void TuckerEngine::updateSprite_locationNum66_4(int i) { } void TuckerEngine::execData3PreUpdate_locationNum66() { - _flagsTable[137]= 0; + // FIXME: shouldn't be executed after using the map + _flagsTable[137] = 0; if (_xPosCurrent > 583 && _flagsTable[191] == 0 && _nextAction == 0 && _locationMaskType == 0) { _panelLockedFlag = 0; _csDataLoaded = 0; @@ -3081,7 +3080,7 @@ void TuckerEngine::execData3PreUpdate_locationNum70Helper() { chr = 96; break; default: - if (_lastKeyPressed >= Common::KEYCODE_a && _lastKeyPressed >= Common::KEYCODE_z) { + if (_lastKeyPressed >= Common::KEYCODE_a && _lastKeyPressed <= Common::KEYCODE_z) { chr = 'A' + (_lastKeyPressed - Common::KEYCODE_a); } break; @@ -3092,6 +3091,7 @@ void TuckerEngine::execData3PreUpdate_locationNum70Helper() { ++_updateLocation70StringLen; } } + _lastKeyPressed = 0; } } @@ -3115,7 +3115,7 @@ void TuckerEngine::updateSprite_locationNum71(int i) { void TuckerEngine::updateSprite_locationNum72(int i) { int state; - if (_flagsTable[155] != 7 || _flagsTable[207] == 1) { + if (_flagsTable[155] == 7 || _flagsTable[207] == 1) { state = -1; } else if (_charSpeechSoundCounter > 0 && _actionCharacterNum == i) { _spritesTable[i].needUpdate = 1; diff --git a/engines/tucker/resource.cpp b/engines/tucker/resource.cpp index cd1761c424..6968b8e256 100644 --- a/engines/tucker/resource.cpp +++ b/engines/tucker/resource.cpp @@ -211,8 +211,24 @@ void TuckerEngine::closeCompressedSoundFile() { void TuckerEngine::loadImage(uint8 *dst, int type) { Common::File f; if (!f.open(_fileToLoad)) { - warning("Unable to open '%s'", _fileToLoad); - return; + // workaround for "paper-3.pcx" / "paper_3.pcx" + bool tryOpen = false; + for (char *p = _fileToLoad; *p; ++p) { + switch (*p) { + case '-': + *p = '_'; + tryOpen = true; + break; + case '_': + *p = '-'; + tryOpen = true; + break; + } + } + if (!tryOpen || !f.open(_fileToLoad)) { + warning("Unable to open '%s'", _fileToLoad); + return; + } } f.seek(128, SEEK_SET); int size = 0; @@ -432,7 +448,7 @@ void TuckerEngine::loadObj() { if (_locationNum < 24) { _partNum = 1; _speechSoundBaseNum = 2639; - } else if (_locationNum < 41 || (_locationNum >= 69 && _locationNum < 73) || (_locationNum > 79 && _locationNum < 83)) { + } else if (_locationNum < 41 || (_locationNum > 69 && _locationNum < 73) || (_locationNum > 78 && _locationNum < 83)) { _partNum = 2; _speechSoundBaseNum = 2679; } else { @@ -442,16 +458,15 @@ void TuckerEngine::loadObj() { if (_partNum == _currentPartNum) { return; } + debug(2, "loadObj() partNum %d locationNum %d", _partNum, _locationNum); handleNewPartSequence(); _currentPartNum = _partNum; - sprintf(_fileToLoad, "objtxt%d.c", _partNum); free(_objTxtBuf); _objTxtBuf = loadFile(); sprintf(_fileToLoad, "pt%dtext.c", _partNum); free(_ptTextBuf); _ptTextBuf = loadFile(); - loadData(); loadPanObj(); } @@ -682,40 +697,40 @@ void TuckerEngine::loadCharPos() { charPos->name = t.getNextInteger(); charPos->description = t.getNextInteger(); } - } - int quitLoop = 0; - size_t count = 0; - while (quitLoop == 0) { - t.findNextToken(kDataTokenDw); - int num = 0; - while (num != 99) { - num = t.getNextInteger(); - assert(count < ARRAYSIZE(_characterAnimationsTable)); - _characterAnimationsTable[count] = num; - if (num < 0) { - quitLoop = 1; - break; + int quitLoop = 0; + size_t count = 0; + while (quitLoop == 0) { + t.findNextToken(kDataTokenDw); + int num = 0; + while (num != 99) { + num = t.getNextInteger(); + assert(count < ARRAYSIZE(_characterAnimationsTable)); + _characterAnimationsTable[count] = num; + if (num < 0) { + quitLoop = 1; + break; + } + ++count; } - ++count; } - } - quitLoop = 0; - count = 0; - while (quitLoop == 0) { - t.findNextToken(kDataTokenDw); - int num = 0; - while (num < 98) { - num = t.getNextInteger(); - assert(count < ARRAYSIZE(_characterStateTable)); - _characterStateTable[count] = num; - if (num == 98) { - --count; - } - if (num < 0) { - quitLoop = 1; - break; + quitLoop = 0; + count = 0; + while (quitLoop == 0) { + t.findNextToken(kDataTokenDw); + int num = 0; + while (num < 98) { + num = t.getNextInteger(); + assert(count < ARRAYSIZE(_characterStateTable)); + _characterStateTable[count] = num; + if (num == 98) { + --count; + } + if (num < 0) { + quitLoop = 1; + break; + } + ++count; } - ++count; } } } @@ -735,13 +750,11 @@ void TuckerEngine::unloadSprA02_01() { free(_sprA02Table[i]); _sprA02Table[i] = 0; } + _sprA02Table[0] = 0; } void TuckerEngine::loadSprC02_01() { - for (int i = 1; i < kSprC02TableSize; ++i) { - free(_sprC02Table[i]); - _sprC02Table[i] = 0; - } + unloadSprC02_01(); const int count = _sprC02LookupTable[_locationNum]; for (int i = 1; i < count + 1; ++i) { sprintf(_fileToLoad, "sprites/c%02d_%02d.spr", _locationNum, i); @@ -761,6 +774,7 @@ void TuckerEngine::unloadSprC02_01() { free(_sprC02Table[i]); _sprC02Table[i] = 0; } + _sprC02Table[0] = 0; } void TuckerEngine::loadFx() { @@ -914,6 +928,7 @@ void TuckerEngine::loadActionsTable() { _tableInstructionsPtr = _csDataBuf + t._pos + 1; _csDataLoaded = true; _csDataHandled = 1; + debug(2, "loadActionsTable() _nextAction %d", _nextAction); } if (_csDataTableFlag2 == 1 && _charSpeechSoundCounter > 0) { break; diff --git a/engines/tucker/sequences.cpp b/engines/tucker/sequences.cpp index 50c697aa23..f0c15b48d5 100644 --- a/engines/tucker/sequences.cpp +++ b/engines/tucker/sequences.cpp @@ -46,6 +46,7 @@ void TuckerEngine::handleCreditsSequence() { loadCharset2(); stopSounds(); _locationNum = 74; + _flagsTable[236] = 74; uint8 *imgBuf = (uint8 *)malloc(16 * 64000); loadSprC02_01(); _spritesCount = _creditsSequenceData2[num]; @@ -76,10 +77,6 @@ void TuckerEngine::handleCreditsSequence() { if (num < 6) { Graphics::copyTo640(_locationBackgroundGfxBuf, _quadBackgroundGfxBuf, 320, 320, 200); } else { - if (_inputKeys[kInputKeyEscape]) { - _inputKeys[kInputKeyEscape] = false; - return; - } Graphics::copyTo640(_locationBackgroundGfxBuf, imgBuf + imgNum * 64000, 320, 320, 200); drawString2(5, 48, counter2 * 6); drawString2(5, 60, counter2 * 6 + 1); @@ -150,7 +147,7 @@ void TuckerEngine::handleCreditsSequence() { _spritesCount = _creditsSequenceData2[num]; ++_flagsTable[236]; } - } while (isSpeechSoundPlaying()); + } while (!_quitGame && isSpeechSoundPlaying()); free(imgBuf); _locationNum = prevLocationNum; do { @@ -171,13 +168,12 @@ void TuckerEngine::handleCongratulationsSequence() { loadImage(_loadTempBuf, 1); Graphics::copyTo640(_locationBackgroundGfxBuf, _loadTempBuf, 320, 320, 200); copyToVGA(_locationBackgroundGfxBuf); - while (_timerCounter2 < 450) { + while (!_quitGame && _timerCounter2 < 450) { while (_fadePaletteCounter < 14) { ++_fadePaletteCounter; fadeOutPalette(); } waitForTimer(3); - updateTimer(); } } @@ -326,7 +322,7 @@ void TuckerEngine::handleMapSequence() { } _fadePaletteCounter = 0; int xPos = 0, yPos = 0, textNum = 0; - do { + while (!_quitGame) { waitForTimer(2); updateMouseState(); Graphics::copyTo640(_locationBackgroundGfxBuf + _scrollOffset, _quadBackgroundGfxBuf + 89600, 320, 320, 200); @@ -386,7 +382,10 @@ void TuckerEngine::handleMapSequence() { fadeOutPalette(); ++_fadePaletteCounter; } - } while (!_leftMouseButtonPressed || textNum == 0); + if (_leftMouseButtonPressed && textNum != 0) { + break; + } + } while (_fadePaletteCounter > 0) { fadeInPalette(); copyToVGA(_locationBackgroundGfxBuf + _scrollOffset); @@ -408,8 +407,8 @@ void TuckerEngine::handleMapSequence() { } void TuckerEngine::copyMapRect(int x, int y, int w, int h) { - const uint8 *src = _quadBackgroundGfxBuf + 89600 + y * 320 + x; - uint8 *dst = _loadTempBuf + y * 320 + x; + const uint8 *src = _loadTempBuf + y * 320 + x; + uint8 *dst = _quadBackgroundGfxBuf + 89600 + y * 320 + x; for (int i = 0; i < h; ++i) { memcpy(dst, src, w); src += 320; @@ -420,7 +419,7 @@ void TuckerEngine::copyMapRect(int x, int y, int w, int h) { int TuckerEngine::handleSpecialObjectSelectionSequence() { if (_partNum == 1 && _selectedObjectNum == 6) { strcpy(_fileToLoad, "news1.pcx"); - _flagsTable[7] = 1; + _flagsTable[7] = 4; } else if (_partNum == 3 && _selectedObjectNum == 45) { strcpy(_fileToLoad, "profnote.pcx"); } else if (_partNum == 1 && _selectedObjectNum == 26) { @@ -443,7 +442,7 @@ int TuckerEngine::handleSpecialObjectSelectionSequence() { _mouseClick = 1; loadImage(_quadBackgroundGfxBuf, 1); _fadePaletteCounter = 0; - while (1) { + while (!_quitGame) { waitForTimer(2); updateMouseState(); Graphics::copyTo640(_locationBackgroundGfxBuf + _scrollOffset, _quadBackgroundGfxBuf, 320, 320, 200); @@ -456,7 +455,7 @@ int TuckerEngine::handleSpecialObjectSelectionSequence() { } if (_partNum == 3 && _selectedObjectNum == 45) { for (int i = 0; i < 13; ++i) { - const int offset = _dataTable[204 + i].yDest * 640 + _dataTable[i].xDest; + const int offset = _dataTable[204 + i].yDest * 640 + _dataTable[204 + i].xDest; static const int itemsTable[] = { 15, 44, 25, 19, 21, 24, 12, 27, 20, 29, 35, 23, 3 }; if (_inventoryItemsState[itemsTable[i]] > 1) { Graphics::decodeRLE(_locationBackgroundGfxBuf + _scrollOffset + offset, _data3GfxBuf + _dataTable[204 + i].sourceOffset, _dataTable[204 + i].xSize, _dataTable[204 + i].ySize); diff --git a/engines/tucker/tucker.cpp b/engines/tucker/tucker.cpp index 34384e6bea..93f16a68d4 100644 --- a/engines/tucker/tucker.cpp +++ b/engines/tucker/tucker.cpp @@ -138,6 +138,7 @@ void TuckerEngine::restart() { _gameHintsIndex = 0; _gameHintsCounter = 0; _gameHintsDisplayText = 0; + _gameHintsStringNum = 0; memset(_sprA02Table, 0, sizeof(_sprA02Table)); memset(_sprC02Table, 0, sizeof(_sprC02Table)); @@ -161,9 +162,8 @@ void TuckerEngine::restart() { _mousePosX = _mousePosY = 0; _prevMousePosX = _prevMousePosY = 0; _mouseButtonsMask = 0; - _mouseButton2 = 0; _mouseClick = 0; - _mouseClickOnPanelSliders = 0; + _saveOrLoadGamePanel = 0; _mouseIdleCounter = 0; _leftMouseButtonPressed = _rightMouseButtonPressed = false; _lastKeyPressed = 0; @@ -339,8 +339,8 @@ void TuckerEngine::mainLoop() { _csDataBuf = loadFile(); _csDataSize = _fileLoadSize; - _currentSaveGameSlot = _firstSaveGameSlot = 1; - _maxSaveGameSlot = _lastSaveGameSlot = 99; + _currentSaveLoadGameState = 1; + loadBudSpr(0); loadCursor(); setCursorNum(_cursorNum); @@ -478,7 +478,7 @@ void TuckerEngine::mainLoop() { } if (_skipCurrentCharacterDraw != 1) { if (_backgroundSpriteCurrentAnimation > -1 && _backgroundSpriteCurrentFrame > 0) { - drawBackgroundSprites(0); + drawBackgroundSprites(); } else { drawCurrentSprite(); } @@ -497,13 +497,6 @@ void TuckerEngine::mainLoop() { if (_currentFxSet != 0) { setSoundVolumeDistance(); } - if (_gameDebug) { - drawStringInteger(_scrollOffset + _mousePosX, 0, 10, 3); - drawStringInteger(_scrollOffset + _mousePosY, 0, 20, 3); - drawStringInteger(_backgroundSpriteCurrentFrame, 0, 40, 3); - drawStringInteger(_backgroundSpriteCurrentAnimation, 0, 50, 3); - drawStringInteger(_mouseButton2, 0, 60, 3); - } updateCharSpeechSound(); copyToVGA(_locationBackgroundGfxBuf + _scrollOffset); startCharacterSounds(); @@ -549,7 +542,7 @@ void TuckerEngine::mainLoop() { } if (_inputKeys[kInputKeyToggleTextSpeech]) { _inputKeys[kInputKeyToggleTextSpeech] = false; - if (_lang != Common::FR_FRA) { + if (_lang != Common::FR_FRA) { // only a few subtitles are translated to french if (_displaySpeechText) { _displaySpeechText = false; // kDefaultCharSpeechSoundCounter = 1; @@ -562,7 +555,7 @@ void TuckerEngine::mainLoop() { if (_inputKeys[kInputKeyHelp]) { _inputKeys[kInputKeyHelp] = false; if (_displayGameHints && _gameHintsDisplayText == 1) { - _mouseButton2 = _gameHintsIndex + 1; + _gameHintsStringNum = _gameHintsIndex + 1; _mouseIdleCounter = 1100; } } @@ -580,26 +573,21 @@ void TuckerEngine::mainLoop() { if (_flagsTable[100] == 1) { handleCongratulationsSequence(); } - closeCompressedSoundFile(); unloadSprA02_01(); unloadSprC02_01(); freeBuffers(); } -void TuckerEngine::updateTimer() { - ++_timerCounter1; - ++_timerCounter2; -} - void TuckerEngine::waitForTimer(int ticksCount) { uint32 end = _lastFrameTime + ticksCount * 1000 / 46; do { - updateTimer(); + ++_timerCounter1; parseEvents(); _system->delayMillis(10); _lastFrameTime = _system->getMillis(); } while (!_fastMode && _lastFrameTime < end); + _timerCounter2 += ticksCount; _timerCounter1 = 0; } @@ -678,6 +666,7 @@ void TuckerEngine::setCursorType(int type) { } void TuckerEngine::setupNewLocation() { + debug(2, "setupNewLocation() current %d next %d", _locationNum, _nextLocationNum); _locationNum = _nextLocationNum; loadObj(); _switchPanelFlag = 0; @@ -749,7 +738,7 @@ void TuckerEngine::updateMouseState() { _leftMouseButtonPressed = (_mouseButtonsMask & 1) != 0; if (_leftMouseButtonPressed) { _mouseIdleCounter = 0; - _mouseButton2 = 0; + _gameHintsStringNum = 0; } _rightMouseButtonPressed = (_mouseButtonsMask & 2) != 0; _mouseButtonsMask = 0; @@ -757,7 +746,7 @@ void TuckerEngine::updateMouseState() { ++_mouseIdleCounter; } else { _mouseIdleCounter = 0; - _mouseButton2 = 0; + _gameHintsStringNum = 0; } } if (_cursorType == 1) { @@ -965,7 +954,6 @@ void TuckerEngine::fadePaletteColor(int color, int step) { const int c = _currentPalette[color * 3 + i] + step * 4; rgb[i] = MIN(c, 255); } - rgb[3] = 255; _system->setPalette(rgb, color, 1); } @@ -975,15 +963,6 @@ void TuckerEngine::setBlackPalette() { _system->setPalette(pal, 0, 256); } -void TuckerEngine::setPaletteColor(int color, int r, int g, int b) { - uint8 rgb[4]; - rgb[0] = r & 255; - rgb[1] = g & 255; - rgb[2] = b & 255; - rgb[3] = 255; - _system->setPalette(rgb, color, 1); -} - void TuckerEngine::updateCursor() { setCursorNum(0); if (_backgroundSpriteCurrentAnimation == -1 && _panelLockedFlag == 0 && _selectedObject.locationObject_locationNum > 0) { @@ -1113,8 +1092,6 @@ void TuckerEngine::playSounds() { } void TuckerEngine::updateCharactersPath() { - int i = 0; - int flag = 0; if (_panelLockedFlag == 0) { return; } @@ -1130,21 +1107,18 @@ void TuckerEngine::updateCharactersPath() { if (_characterFacingDirection == 5) { _characterPrevFacingDirection = 5; } + int flag = 0; if (_yPosCurrent > _selectedObject.yPos) { if (testLocationMask(_xPosCurrent, _yPosCurrent - 1) == 1) { --_yPosCurrent; _characterFacingDirection = 4; flag = 1; - } else { - ++i; } } else if (_yPosCurrent < _selectedObject.yPos) { if (testLocationMask(_xPosCurrent, _yPosCurrent + 1) == 1) { ++_yPosCurrent; _characterFacingDirection = 2; flag = 1; - } else { - ++i; } } if (_xPosCurrent > _selectedObject.xPos) { @@ -1153,8 +1127,6 @@ void TuckerEngine::updateCharactersPath() { _characterFacingDirection = 3; _characterBackFrontFacing = 0; flag = 1; - } else { - ++i; } } else if (_xPosCurrent < _selectedObject.xPos) { if (testLocationMask(_xPosCurrent + 1, _yPosCurrent) == 1) { @@ -1162,8 +1134,6 @@ void TuckerEngine::updateCharactersPath() { _characterFacingDirection = 1; _characterBackFrontFacing = 1; flag = 1; - } else { - ++i; } } if (flag == 0) { @@ -1180,7 +1150,7 @@ void TuckerEngine::updateCharactersPath() { } } if (_locationNum == 25) { - if ((_backgroundSpriteCurrentAnimation == 3 || _characterBackFrontFacing != 0) && (_backgroundSpriteCurrentAnimation != 6 || _characterBackFrontFacing != 1)) { + if ((_backgroundSpriteCurrentAnimation != 3 || _characterBackFrontFacing != 0) && (_backgroundSpriteCurrentAnimation != 6 || _characterBackFrontFacing != 1)) { _xPosCurrent = xPos; _yPosCurrent = yPos; return; @@ -1293,25 +1263,25 @@ void TuckerEngine::saveOrLoad() { if (!_leftMouseButtonPressed) { _mouseClick = 0; } - if (_firstSaveGameSlot > 0) { - drawSpeechText(_scrollOffset + 120, 170, _infoBarBuf, _mouseClickOnPanelSliders + 19, 102); - int len = getStringWidth(_mouseClickOnPanelSliders + 19, _infoBarBuf); - drawStringInteger(_firstSaveGameSlot, len / 2 + 128, 160, 2); + if (_currentSaveLoadGameState > 0) { + drawSpeechText(_scrollOffset + 120, 170, _infoBarBuf, _saveOrLoadGamePanel + 19, 102); + int len = getStringWidth(_saveOrLoadGamePanel + 19, _infoBarBuf); + drawStringInteger(_currentSaveLoadGameState, len / 2 + 128, 160, 2); } else { drawSpeechText(_scrollOffset + 120, 170, _infoBarBuf, 21, 102); } if (_leftMouseButtonPressed && _mouseClick == 0) { _mouseClick = 1; if (_mousePosX > 228 && _mousePosX < 240 && _mousePosY > 154 && _mousePosY < 170) { - if (_firstSaveGameSlot < _lastSaveGameSlot) { - ++_firstSaveGameSlot; + if (_currentSaveLoadGameState < 99) { + ++_currentSaveLoadGameState; _forceRedrawPanelItems = 1; } return; } if (_mousePosX > 228 && _mousePosX < 240 && _mousePosY > 170 && _mousePosY < 188) { - if (_firstSaveGameSlot > 1) { - --_firstSaveGameSlot; + if (_currentSaveLoadGameState > 1) { + --_currentSaveLoadGameState; _forceRedrawPanelItems = 1; } return; @@ -1322,10 +1292,10 @@ void TuckerEngine::saveOrLoad() { return; } if (_mousePosX > 260 && _mousePosX < 290 && _mousePosY > 152 && _mousePosY < 168) { - if (_mouseClickOnPanelSliders == 1) { - saveGame(_firstSaveGameSlot); - } else if (_firstSaveGameSlot > 0) { - loadGame(_firstSaveGameSlot); + if (_saveOrLoadGamePanel == 1) { + saveGame(_currentSaveLoadGameState); + } else if (_currentSaveLoadGameState > 0) { + loadGame(_currentSaveLoadGameState); } _forceRedrawPanelItems = 1; _panelState = 0; @@ -1348,26 +1318,13 @@ void TuckerEngine::handleMouseOnPanel() { return; } if (_mousePosX < 96) { - _mouseClickOnPanelSliders = 0; + _saveOrLoadGamePanel = 0; _forceRedrawPanelItems = 1; _panelState = 3; - _firstSaveGameSlot = _currentSaveGameSlot; - _lastSaveGameSlot = _maxSaveGameSlot; } else if (_mousePosX < 158) { - _mouseClickOnPanelSliders = 1; + _saveOrLoadGamePanel = 1; _forceRedrawPanelItems = 1; _panelState = 3; - if (_maxSaveGameSlot < 99) { - _firstSaveGameSlot = _maxSaveGameSlot + 1; - _lastSaveGameSlot = _firstSaveGameSlot; - } else { - _lastSaveGameSlot = 99; - if (_currentSaveGameSlot < 99) { - _firstSaveGameSlot = _currentSaveGameSlot + 1; - } else { - _firstSaveGameSlot = 1; - } - } } else if (_mousePosX < 218) { _forceRedrawPanelItems = 1; _panelState = 0; @@ -1698,7 +1655,7 @@ void TuckerEngine::execData3PreUpdate() { } } -void TuckerEngine::drawBackgroundSprites(int flipX) { +void TuckerEngine::drawBackgroundSprites() { if (_backgroundSpriteDataPtr && _backgroundSpriteCurrentFrame != 0 && _backgroundSpriteCurrentFrame <= _backgroundSpriteLastFrame) { int frameOffset = READ_LE_UINT24(_backgroundSpriteDataPtr + _backgroundSpriteCurrentFrame * 4); int srcW = READ_LE_UINT16(_backgroundSpriteDataPtr + frameOffset); @@ -1716,7 +1673,7 @@ void TuckerEngine::drawBackgroundSprites(int flipX) { srcX += 320; } int offset = _backgroundSprOffset + srcY * 640 + srcX; - Graphics::decodeRLE_248(_locationBackgroundGfxBuf + offset, _backgroundSpriteDataPtr + frameOffset + 12, srcW, srcH, 0, _locationHeightTable[_locationNum], flipX); + Graphics::decodeRLE_248(_locationBackgroundGfxBuf + offset, _backgroundSpriteDataPtr + frameOffset + 12, srcW, srcH, 0, _locationHeightTable[_locationNum], false); } } @@ -1917,7 +1874,7 @@ const uint8 *TuckerEngine::getStringBuf(int type) const { void TuckerEngine::drawInfoString() { const uint8 *infoStrBuf = _infoBarBuf; const uint8 *obj1StrBuf = getStringBuf(_actionObj1Type); - const uint8 *obj2StrBuf = 0; + const uint8 *obj2StrBuf = getStringBuf(_actionObj2Type); int infoStringWidth = 0; int object1NameWidth = 0; int verbWidth = getStringWidth(_actionVerb + 1, infoStrBuf); @@ -1932,36 +1889,37 @@ void TuckerEngine::drawInfoString() { if (_actionRequiresTwoObjects) { verbPreposition = (_actionVerb == 5) ? 12 : 11; verbPrepositionWidth = getStringWidth(verbPreposition, infoStrBuf) + 4; - if ((_actionObj2Num > 0 || _actionObj2Type > 0) && verbPreposition > 0) { - infoStringWidth = 0; - verbWidth = 0; - object1NameWidth = 0; + if (_lang == Common::FR_FRA) { + if ((_actionObj2Num > 0 || _actionObj2Type > 0) && verbPreposition > 0) { + infoStringWidth = 0; + verbWidth = 0; + object1NameWidth = 0; + } } infoStringWidth += verbPrepositionWidth; - obj2StrBuf = getStringBuf(_actionObj2Type); - if (_actionObj2Num > 0 && _actionObj2Type > 0) { + if (_actionObj2Num > 0) { infoStringWidth += getStringWidth(_actionObj2Num + 1, obj2StrBuf); } } const int xPos = 159 - infoStringWidth / 2; if (verbPreposition == 0 || (_actionObj2Num == 0 && _actionObj2Type == 0)) { drawString(_itemsGfxBuf + xPos, _actionVerb + 1, infoStrBuf); - if (_actionObj1Num != 0 || _actionObj1Type != 0) { - drawString(_itemsGfxBuf + 4 + xPos + verbWidth, _actionObj1Num + 1, obj1StrBuf); + if (_actionObj1Num > 0 || _actionObj1Type > 0) { + drawString(_itemsGfxBuf + xPos + 4 + verbWidth, _actionObj1Num + 1, obj1StrBuf); } } if (verbPreposition > 0) { drawString(_itemsGfxBuf + xPos + 4 + verbWidth + object1NameWidth, verbPreposition, infoStrBuf); - if (_actionObj2Num != 0 || _actionObj2Type != 0) { + if (_actionObj2Num > 0 || _actionObj2Type > 0) { drawString(_itemsGfxBuf + xPos + 4 + verbWidth + object1NameWidth + verbPrepositionWidth, _actionObj2Num + 1, obj2StrBuf); } } } void TuckerEngine::drawGameHintString() { - int len = getStringWidth(_mouseButton2 + 29, _infoBarBuf); - int x = 159 - len / 2; - drawString(_itemsGfxBuf + 326 + x, _mouseButton2 + 29, _infoBarBuf); + const int len = getStringWidth(_gameHintsStringNum + 29, _infoBarBuf); + const int x = 159 - len / 2; + drawString(_itemsGfxBuf + 326 + x, _gameHintsStringNum + 29, _infoBarBuf); } void TuckerEngine::updateCharacterAnimation() { @@ -1996,7 +1954,7 @@ void TuckerEngine::updateCharacterAnimation() { _backgroundSpriteCurrentFrame = _backgroundSpriteLastFrame = READ_LE_UINT16(_backgroundSpriteDataPtr); } else { --_backgroundSpriteCurrentFrame; - if (_backgroundSpriteCurrentFrame > 1) { + if (_backgroundSpriteCurrentFrame < 1) { _backgroundSpriteCurrentAnimation = -1; _backgroundSpriteCurrentFrame = 0; _changeBackgroundSprite = 0; @@ -2041,7 +1999,6 @@ void TuckerEngine::updateCharacterAnimation() { _actionCharacterNum = 99; setCursorType(2); _charSpeechSoundCounter = kDefaultCharSpeechSoundCounter; - } } if (_charSpeechSoundCounter == 0 || _actionCharacterNum != 99) { @@ -2106,29 +2063,32 @@ void TuckerEngine::updateCharacterAnimation() { if (_panelLockedFlag == 0 && _characterFacingDirection < 5 && _selectedObject.locationObject_locationNum == 0) { _characterFacingDirection = 0; } - if (_charSpeechSoundCounter > 0 && _characterFacingDirection == 6 && _actionCharacterNum == 99) { + if (_charSpeechSoundCounter > 0 && _characterFacingDirection != 6 && _actionCharacterNum == 99) { _characterFacingDirection = 6; frame = 999; - } else { - if (_characterFacingDirection == 6 && _charSpeechSoundCounter != 0 && _actionCharacterNum != 99) { - _characterFacingDirection = 0; - frame = 999; - } + } else if (_characterFacingDirection == 6 && (_charSpeechSoundCounter == 0 || _actionCharacterNum != 99)) { + _characterFacingDirection = 0; + frame = 999; } int num = 0; if (frame == 999 || (_characterFacingDirection != _characterPrevFacingDirection && _characterFacingDirection < 5)) { _mirroredDrawing = 0; if (_characterFacingDirection == 6) { if (_csDataHandled != 0) { - if (_selectedCharacterDirection == 1) { + switch (_selectedCharacterDirection) { + case 1: num = 17; - } else if (_selectedCharacterDirection == 2) { + break; + case 2: num = 16; - } else if (_selectedCharacterDirection == 4) { + break; + case 4: num = 15; - } else { + break; + default: num = 16; _mirroredDrawing = 1; + break; } } else { num = 15; @@ -2140,15 +2100,20 @@ void TuckerEngine::updateCharacterAnimation() { if (_characterFacingDirection == 0) { if (_csDataHandled != 0) { _mirroredDrawing = 0; - if (_selectedCharacterDirection == 1) { + switch (_selectedCharacterDirection) { + case 1: num = 3; - } else if (_selectedCharacterDirection == 2) { - num = 1; // 2 ? - } else if (_selectedCharacterDirection == 3) { + break; + case 2: + num = 1; + break; + case 3: num = 1; _mirroredDrawing = 1; - } else { + break; + default: num = 5; + break; } } else if (getRandomNumber() < 2000) { num = 13; @@ -2161,15 +2126,20 @@ void TuckerEngine::updateCharacterAnimation() { num = (getRandomNumber() < 20000) ? 18 : 6; } } else { - if (_characterFacingDirection == 1) { + switch (_characterFacingDirection) { + case 1: num = 0; - } else if (_characterFacingDirection == 2) { + break; + case 2: num = 4; - } else if (_characterFacingDirection == 3) { + break; + case 3: num = 0; _mirroredDrawing = 1; - } else if (_characterFacingDirection == 4) { + break; + case 4: num = 2; + break; } } _currentSpriteAnimationLength = _spriteAnimationsTable[num].numParts; @@ -2812,7 +2782,7 @@ void TuckerEngine::updateSprite(int i) { _spritesTable[i].animationFrame = 1; } if (_spritesTable[i].state < 0 || !_sprC02Table[_spritesTable[i].state]) { - warning("Invalid state %d for sprite %d location %d", _spritesTable[i].state, i, _locationNum); +// warning("Invalid state %d for sprite %d location %d", _spritesTable[i].state, i, _locationNum); return; } _spritesTable[i].animationData = _sprC02Table[_spritesTable[i].state]; @@ -2873,9 +2843,8 @@ void TuckerEngine::updateCharSpeechSound() { return; } --_charSpeechSoundCounter; - int i = isSpeechSoundPlaying(); if (_charSpeechSoundCounter == 0) { - _charSpeechSoundCounter = i; + _charSpeechSoundCounter = isSpeechSoundPlaying() ? 1 : 0; if (_charSpeechSoundCounter == 0) { _characterSpriteAnimationFrameCounter = 0; } @@ -2968,7 +2937,7 @@ static int parseInt(const uint8 *buf, int offset, int len) { int TuckerEngine::parseTableInstruction() { int spr; - debug(2, "parseTableInstruction instruction %c%c%c", _tableInstructionsPtr[0], _tableInstructionsPtr[1], _tableInstructionsPtr[2]); + debug(2, "parseTableInstruction() instruction %c%c%c", _tableInstructionsPtr[0], _tableInstructionsPtr[1], _tableInstructionsPtr[2]); switch (_tableInstructionsPtr[0]) { case 'p': // 12 if (_tableInstructionsPtr[1] == 'a') { // 0 @@ -3080,7 +3049,7 @@ int TuckerEngine::parseTableInstruction() { _tableInstructionsPtr += 8; return 0; } - if (_tableInstructionsPtr[2] == 'e') { // 4 + if (_tableInstructionsPtr[2] == 'c') { // 2 int i = parseInt(_tableInstructionsPtr, 4, 3); setCharacterAnimation(i, spr); _tableInstructionsPtr += 8; @@ -3203,6 +3172,7 @@ int TuckerEngine::parseTableInstruction() { int flag = parseInt(_tableInstructionsPtr, 0, 3); int value = parseInt(_tableInstructionsPtr, 4, 2); if (value == _flagsTable[flag]) { + assert(_conversationOptionsCount < 6); _instructionsActionsTable[_conversationOptionsCount] = parseInt(_tableInstructionsPtr, 7, 3) - 1; _nextTableToLoadTable[_conversationOptionsCount] = parseInt(_tableInstructionsPtr, 11, 3); ++_conversationOptionsCount; diff --git a/engines/tucker/tucker.h b/engines/tucker/tucker.h index 5a5020d32e..ae175d6207 100644 --- a/engines/tucker/tucker.h +++ b/engines/tucker/tucker.h @@ -233,7 +233,6 @@ protected: void freeBuffers(); void restart(); void mainLoop(); - void updateTimer(); void waitForTimer(int ticksCount); void parseEvents(); void updateCursorPos(int x, int y); @@ -249,7 +248,6 @@ protected: void fadeInPalette(int colorsCount = 256); void fadePaletteColor(int color, int step); void setBlackPalette(); - void setPaletteColor(int color, int r, int g, int b); void updateCursor(); void stopSounds(); void playSounds(); @@ -270,7 +268,7 @@ protected: void updateSoundsTypes3_4(); void drawData3(); void execData3PreUpdate(); - void drawBackgroundSprites(int flipX); + void drawBackgroundSprites(); void drawCurrentSprite(); void setVolumeSound(int index, int volume); void setVolumeMusic(int index, int volume); @@ -574,13 +572,12 @@ protected: bool _displayGameHints; int _execData3Counter; bool _displaySpeechText; - - uint8 _maxSaveGameSlot, _currentSaveGameSlot; - uint8 _firstSaveGameSlot, _lastSaveGameSlot; + int _currentSaveLoadGameState; int _gameHintsIndex; int _gameHintsCounter; int _gameHintsDisplayText; + int _gameHintsStringNum; char _fileToLoad[40]; int _fileLoadSize; @@ -611,9 +608,8 @@ protected: int _mousePosX, _mousePosY; int _prevMousePosX, _prevMousePosY; int _mouseButtonsMask; - int _mouseButton2; int _mouseClick; - int _mouseClickOnPanelSliders; + int _saveOrLoadGamePanel; int _mouseIdleCounter; bool _leftMouseButtonPressed; bool _rightMouseButtonPressed; -- cgit v1.2.3