diff options
Diffstat (limited to 'engines/tucker')
-rw-r--r-- | engines/tucker/locations.cpp | 9 | ||||
-rw-r--r-- | engines/tucker/resource.cpp | 37 | ||||
-rw-r--r-- | engines/tucker/sequences.cpp | 39 | ||||
-rw-r--r-- | engines/tucker/tucker.cpp | 215 | ||||
-rw-r--r-- | engines/tucker/tucker.h | 27 |
5 files changed, 182 insertions, 145 deletions
diff --git a/engines/tucker/locations.cpp b/engines/tucker/locations.cpp index 514b2c3610..913bc7b3ae 100644 --- a/engines/tucker/locations.cpp +++ b/engines/tucker/locations.cpp @@ -358,17 +358,18 @@ void TuckerEngine::execData3PreUpdate_locationNum3() { } void TuckerEngine::updateSprite_locationNum4(int i) { - int flag = -1; + int state = -1; + printf("_flagsTable[9] %d\n", _flagsTable[9]); if (_flagsTable[9] == 2) { if (_charSpeechSoundCounter > 0 && _actionCharacterNum == i) { - flag = 1; + state = 1; _spritesTable[i].needUpdate = 1; } else { - flag = 2; + state = 2; _spritesTable[i].needUpdate = 0; } } - _spritesTable[i].state = -1; + _spritesTable[i].state = state; } void TuckerEngine::execData3PreUpdate_locationNum4() { diff --git a/engines/tucker/resource.cpp b/engines/tucker/resource.cpp index 495637134e..cd1761c424 100644 --- a/engines/tucker/resource.cpp +++ b/engines/tucker/resource.cpp @@ -215,15 +215,8 @@ void TuckerEngine::loadImage(uint8 *dst, int type) { return; } f.seek(128, SEEK_SET); - int size = 0, count = 0; + int size = 0; while (size < 64000) { - if (type == 2) { - ++count; - if (count > 500) { - count = 0; - isSpeechSoundPlaying(); - } - } int code = f.readByte(); if (code >= 0xC0) { const int sz = code - 0xC0; @@ -587,10 +580,10 @@ void TuckerEngine::loadData4() { loadFile(_loadTempBuf); DataTokenizer t(_loadTempBuf, _fileLoadSize); t.findNextToken(kDataTokenDw); - _data4FlagDebug = t.getNextInteger(); - _displayGameHints = t.getNextInteger(); + _gameDebug = t.getNextInteger() != 0; + _displayGameHints = t.getNextInteger() != 0; // forces game hints feature -// _displayGameHints = 1; +// _displayGameHints = true; _locationObjectsCount = 0; if (t.findIndex(_locationNum)) { while (t.findNextToken(kDataTokenDw)) { @@ -728,10 +721,7 @@ void TuckerEngine::loadCharPos() { } void TuckerEngine::loadSprA02_01() { - for (int i = 1; i < kSprA02TableSize; ++i) { - free(_sprA02Table[i]); - _sprA02Table[i] = 0; - } + unloadSprA02_01(); const int count = _sprA02LookupTable[_locationNum]; for (int i = 1; i < count + 1; ++i) { sprintf(_fileToLoad, "sprites/a%02d_%02d.spr", _locationNum, i); @@ -740,6 +730,13 @@ void TuckerEngine::loadSprA02_01() { _sprA02Table[0] = _sprA02Table[1]; } +void TuckerEngine::unloadSprA02_01() { + for (int i = 1; i < kSprA02TableSize; ++i) { + free(_sprA02Table[i]); + _sprA02Table[i] = 0; + } +} + void TuckerEngine::loadSprC02_01() { for (int i = 1; i < kSprC02TableSize; ++i) { free(_sprC02Table[i]); @@ -759,6 +756,13 @@ void TuckerEngine::loadSprC02_01() { } } +void TuckerEngine::unloadSprC02_01() { + for (int i = 1; i < kSprC02TableSize; ++i) { + free(_sprC02Table[i]); + _sprC02Table[i] = 0; + } +} + void TuckerEngine::loadFx() { strcpy(_fileToLoad, "fx.c"); loadFile(_loadTempBuf); @@ -888,6 +892,7 @@ void TuckerEngine::loadSound(Audio::Mixer::SoundType type, int num, int volume, } } if (stream) { + _mixer->stopHandle(*handle); _mixer->playInputStream(type, handle, stream, -1, volume * Audio::Mixer::kMaxChannelVolume / kMaxSoundVolume); } } @@ -951,7 +956,7 @@ void TuckerEngine::loadActionsTable() { } } if (_conversationOptionsCount != 0) { - if (_mouseButtons != 0 && _nextTableToLoadIndex != -1) { + if (_leftMouseButtonPressed && _nextTableToLoadIndex != -1) { _nextAction = _nextTableToLoadTable[_nextTableToLoadIndex]; _csDataLoaded = false; _conversationOptionsCount = 0; diff --git a/engines/tucker/sequences.cpp b/engines/tucker/sequences.cpp index 7540312cd2..50c697aa23 100644 --- a/engines/tucker/sequences.cpp +++ b/engines/tucker/sequences.cpp @@ -76,7 +76,8 @@ void TuckerEngine::handleCreditsSequence() { if (num < 6) { Graphics::copyTo640(_locationBackgroundGfxBuf, _quadBackgroundGfxBuf, 320, 320, 200); } else { - if (getLastKeyCode() > 0) { + if (_inputKeys[kInputKeyEscape]) { + _inputKeys[kInputKeyEscape] = false; return; } Graphics::copyTo640(_locationBackgroundGfxBuf, imgBuf + imgNum * 64000, 320, 320, 200); @@ -107,11 +108,9 @@ void TuckerEngine::handleCreditsSequence() { } for (int i = 0; i < _spritesCount; ++i) { drawSprite(i); - isSpeechSoundPlaying(); } copyToVGA(_locationBackgroundGfxBuf); waitForTimer(3); - isSpeechSoundPlaying(); _timerCounter1 = 0; counter4 = _timerCounter2 / 3; if (counter4 == _creditsSequenceData1[num]) { @@ -228,14 +227,8 @@ void TuckerEngine::handleNewPartSequence() { _spritesTable[0].stateIndex = -1; int currentLocation = _locationNum; _locationNum = 98; - for (int i = 1; i < kSprA02TableSize; ++i) { - free(_sprA02Table[i]); - _sprA02Table[i] = 0; - } - for (int i = 1; i < kSprC02TableSize; ++i) { - free(_sprC02Table[i]); - _sprC02Table[i] = 0; - } + unloadSprA02_01(); + unloadSprC02_01(); _sprC02Table[1] = loadFile(); startSpeechSound(9000, 60); _fadePaletteCounter = 0; @@ -249,10 +242,12 @@ void TuckerEngine::handleNewPartSequence() { drawSprite(0); copyToVGA(_locationBackgroundGfxBuf); waitForTimer(3); - if (getLastKeyCode() > 0) { - stopSounds(); + if (_inputKeys[kInputKeyEscape]) { + _inputKeys[kInputKeyEscape] = false; + break; } } while (isSpeechSoundPlaying()); + stopSpeechSound(); do { if (_fadePaletteCounter > 0) { fadeInPalette(); @@ -268,7 +263,8 @@ void TuckerEngine::handleNewPartSequence() { } void TuckerEngine::handleMeanwhileSequence() { - backupPalette(); + uint8 backupPalette[256 * 3]; + memcpy(backupPalette, _currentPalette, 256 * 3); switch (_partNum) { case 1: strcpy(_fileToLoad, "meanw01.pcx"); @@ -304,7 +300,7 @@ void TuckerEngine::handleMeanwhileSequence() { copyToVGA(_locationBackgroundGfxBuf); waitForTimer(3); } while (_fadePaletteCounter > 0); - restorePalette(); + memcpy(_currentPalette, backupPalette, 256 * 3); } void TuckerEngine::handleMapSequence() { @@ -365,16 +361,16 @@ void TuckerEngine::handleMapSequence() { if (!_noPositionChangeAfterMap) { xPos = _xPosCurrent; yPos = _yPosCurrent; - } else if (_locationNum == 3 ||_locationNum == 65) { + } else if (_locationNum == 3 || _locationNum == 65) { xPos = 620; yPos = 130; - } else if (_locationNum == 9 ||_locationNum == 66) { + } else if (_locationNum == 9 || _locationNum == 66) { xPos = 344; yPos = 120; - } else if (_locationNum == 16 ||_locationNum == 61) { + } else if (_locationNum == 16 || _locationNum == 61) { xPos = 590; yPos = 130; - } else if (_locationNum == 20 ||_locationNum == 68) { + } else if (_locationNum == 20 || _locationNum == 68) { xPos = 20; yPos = 130; } else { @@ -570,8 +566,9 @@ void AnimationSequencePlayer::syncTime() { break; } } - } while (_system->getMillis() <= end); - _lastFrameTime = _system->getMillis(); + _system->delayMillis(10); + _lastFrameTime = _system->getMillis(); + } while (_lastFrameTime <= end); } Audio::AudioStream *AnimationSequencePlayer::loadSoundFileAsStream(const char *name, AnimationSoundType type) { diff --git a/engines/tucker/tucker.cpp b/engines/tucker/tucker.cpp index f2b134ba3c..34384e6bea 100644 --- a/engines/tucker/tucker.cpp +++ b/engines/tucker/tucker.cpp @@ -130,6 +130,9 @@ void TuckerEngine::restart() { _nextLocationNum = kStartupLocation; } _gamePaused = _gamePaused2 = false; + _gameDebug = false; + _displayGameHints = false; + _displaySpeechText = false; memset(_flagsTable, 0, sizeof(_flagsTable)); _gameHintsIndex = 0; @@ -163,7 +166,8 @@ void TuckerEngine::restart() { _mouseClickOnPanelSliders = 0; _mouseIdleCounter = 0; _leftMouseButtonPressed = _rightMouseButtonPressed = false; - _keyLastKeyCodePressed = _lastKeyPressed = 0; + _lastKeyPressed = 0; + memset(_inputKeys, 0, sizeof(_inputKeys)); _cursorNum = 0; _cursorType = 0; _updateCursorFlag = 0; @@ -293,7 +297,6 @@ void TuckerEngine::restart() { _currentGfxBackground = 0; _fadePaletteCounter = 0; memset(&_currentPalette, 0, sizeof(_currentPalette)); - memset(&_backupPalette, 0, sizeof(_backupPalette)); _updateLocationFadePaletteCounter = 0; _updateLocationCounter = 10; @@ -335,6 +338,7 @@ void TuckerEngine::mainLoop() { strcpy(_fileToLoad, "csdata.c"); _csDataBuf = loadFile(); _csDataSize = _fileLoadSize; + _currentSaveGameSlot = _firstSaveGameSlot = 1; _maxSaveGameSlot = _lastSaveGameSlot = 99; loadBudSpr(0); @@ -420,7 +424,7 @@ void TuckerEngine::mainLoop() { if (_locationHeight == 140) { switchPanelType(); redrawPanelItems(); - if (_displayGameHints != 0 && _gameHintsIndex < 6) { + if (_displayGameHints && _gameHintsIndex < 6) { updateGameHints(); } if (_panelState == 0) { @@ -493,7 +497,7 @@ void TuckerEngine::mainLoop() { if (_currentFxSet != 0) { setSoundVolumeDistance(); } - if (_data4FlagDebug != 0) { + if (_gameDebug) { drawStringInteger(_scrollOffset + _mousePosX, 0, 10, 3); drawStringInteger(_scrollOffset + _mousePosY, 0, 20, 3); drawStringInteger(_backgroundSpriteCurrentFrame, 0, 40, 3); @@ -512,37 +516,61 @@ void TuckerEngine::mainLoop() { } } } - _lastKeyPressed = getLastKeyCode(); if (_gamePaused && _charSpeechSoundCounter == 0) { stopSounds(); _gamePaused2 = true; while (1) { - if (_lastKeyPressed == Common::KEYCODE_p && _charSpeechSoundCounter <= 0) { // Paused - playSounds(); - _gamePaused = _gamePaused2 = false; - break; + waitForTimer(1); + if (_inputKeys[kInputKeyPause]) { + _inputKeys[kInputKeyPause] = false; + if (_charSpeechSoundCounter <= 0) { + break; + } } - _lastKeyPressed = getLastKeyCode(); if (_charSpeechSoundCounter == 0) { if (_lastKeyPressed >= Common::KEYCODE_1 && _lastKeyPressed <= Common::KEYCODE_5) { if (_speechHistoryTable[_lastKeyPressed - Common::KEYCODE_1] > 0) { startSpeechSound(_speechHistoryTable[_lastKeyPressed - Common::KEYCODE_1], 100); _charSpeechSoundCounter = kDefaultCharSpeechSoundCounter; } + _lastKeyPressed = 0; } } updateCharSpeechSound(); } + playSounds(); + _gamePaused = _gamePaused2 = false; } - if (_lastKeyPressed == Common::KEYCODE_p && _locationNum == 70) { - _gamePaused = true; + if (_inputKeys[kInputKeyPause]) { + _inputKeys[kInputKeyPause] = false; + if (_locationNum != 70) { + _gamePaused = true; + } + } + if (_inputKeys[kInputKeyToggleTextSpeech]) { + _inputKeys[kInputKeyToggleTextSpeech] = false; + if (_lang != Common::FR_FRA) { + if (_displaySpeechText) { + _displaySpeechText = false; +// kDefaultCharSpeechSoundCounter = 1; + } else { + _displaySpeechText = true; +// kDefaultCharSpeechSoundCounter = 70; + } + } } - if (_lastKeyPressed == Common::KEYCODE_F3 && _displayGameHints != 0 && _gameHintsDisplayText == 1) { - _mouseButton2 = _gameHintsIndex + 1; - _mouseIdleCounter = 1100; + if (_inputKeys[kInputKeyHelp]) { + _inputKeys[kInputKeyHelp] = false; + if (_displayGameHints && _gameHintsDisplayText == 1) { + _mouseButton2 = _gameHintsIndex + 1; + _mouseIdleCounter = 1100; + } } - if (_lastKeyPressed == 1 && _data4FlagDebug != 0) { - _flagsTable[236] = 74; + if (_inputKeys[kInputKeyEscape]) { + _inputKeys[kInputKeyEscape] = false; + if (_gameDebug) { + _flagsTable[236] = 74; + } } if (_flagsTable[236] > 70) { handleCreditsSequence(); @@ -552,7 +580,10 @@ void TuckerEngine::mainLoop() { if (_flagsTable[100] == 1) { handleCongratulationsSequence(); } + closeCompressedSoundFile(); + unloadSprA02_01(); + unloadSprC02_01(); freeBuffers(); } @@ -577,12 +608,31 @@ void TuckerEngine::parseEvents() { while (_eventMan->pollEvent(ev)) { switch (ev.type) { case Common::EVENT_KEYDOWN: - if (ev.kbd.flags == Common::KBD_CTRL) { - if (ev.kbd.keycode == Common::KEYCODE_f) { + switch (ev.kbd.keycode) { + case Common::KEYCODE_f: + if (ev.kbd.flags == Common::KBD_CTRL) { _fastMode = !_fastMode; } - } - _keyLastKeyCodePressed = ev.kbd.keycode; + break; + case Common::KEYCODE_p: + _inputKeys[kInputKeyPause] = true; + break; + case Common::KEYCODE_F1: + _inputKeys[kInputKeyToggleInventory] = true; + break; + case Common::KEYCODE_F2: + _inputKeys[kInputKeyToggleTextSpeech] = true; + break; + case Common::KEYCODE_F3: + _inputKeys[kInputKeyHelp] = true; + break; + case Common::KEYCODE_ESCAPE: + _inputKeys[kInputKeyEscape] = true; + break; + default: + break; + } + _lastKeyPressed = ev.kbd.keycode; break; case Common::EVENT_MOUSEMOVE: updateCursorPos(ev.mouse.x, ev.mouse.y); @@ -710,12 +760,6 @@ void TuckerEngine::updateMouseState() { _mouseButton2 = 0; } } - if (_mousePosX > 307) { - _mousePosX = 307; - } - if (_mousePosY > 195) { - _mousePosY = 195; - } if (_cursorType == 1) { if (_panelState == 1) { setCursorNum(1); @@ -886,14 +930,6 @@ void TuckerEngine::updateFlagsForCharPosition() { } } -void TuckerEngine::backupPalette() { - memcpy(_backupPalette, _currentPalette, 256 * 3); -} - -void TuckerEngine::restorePalette() { - memcpy(_currentPalette, _backupPalette, 256 * 3); -} - void TuckerEngine::fadeOutPalette(int colorsCount) { uint8 pal[256 * 4]; _system->grabPalette(pal, 0, colorsCount); @@ -929,6 +965,7 @@ 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); } @@ -1050,12 +1087,6 @@ void TuckerEngine::updateCursor() { } } -int TuckerEngine::getLastKeyCode() { - int keyCode = _keyLastKeyCodePressed; - _keyLastKeyCodePressed = 0; - return keyCode; -} - void TuckerEngine::stopSounds() { for (int i = 0; i < _locationSoundsCount; ++i) { stopSound(i); @@ -1348,10 +1379,13 @@ void TuckerEngine::handleMouseOnPanel() { } void TuckerEngine::switchPanelType() { - if (_panelState == 0 && _switchPanelFlag == 0 && _lastKeyPressed == Common::KEYCODE_F1) { - _switchPanelFlag = 1; - _switchPanelCounter = 1; - return; + if (_inputKeys[kInputKeyToggleInventory]) { + _inputKeys[kInputKeyToggleInventory] = false; + if (_panelState == 0 && _switchPanelFlag == 0) { + _switchPanelFlag = 1; + _switchPanelCounter = 1; + return; + } } if (_switchPanelFlag == 0) { return; @@ -1687,29 +1721,25 @@ void TuckerEngine::drawBackgroundSprites(int flipX) { } void TuckerEngine::drawCurrentSprite() { - int offset; SpriteFrame *chr = &_spriteFramesTable[_currentSpriteAnimationFrame]; + int offset = (_yPosCurrent + _mainSpritesBaseOffset - 54 + chr->yOffset) * 640 + _xPosCurrent; if (_mirroredDrawing == 0) { - offset = (_yPosCurrent + _mainSpritesBaseOffset - 54 + chr->yOffset) * 640 + _xPosCurrent; offset += chr->xOffset - 14; } else { - offset = (_yPosCurrent + _mainSpritesBaseOffset - 54 + chr->yOffset) * 640 + _xPosCurrent; offset -= chr->xSize + chr->xOffset - 14; } Graphics::decodeRLE_248(_locationBackgroundGfxBuf + offset, _spritesGfxBuf + chr->sourceOffset, chr->xSize, chr->ySize, chr->yOffset, _locationHeightTable[_locationNum], _mirroredDrawing != 0); if (_currentSpriteAnimationLength > 1) { SpriteFrame *chr2 = &_spriteFramesTable[_currentSpriteAnimationFrame2]; + offset = (_yPosCurrent + _mainSpritesBaseOffset - 54 + chr2->yOffset) * 640 + _xPosCurrent; if (_mirroredDrawing == 0) { - offset = (_yPosCurrent + _mainSpritesBaseOffset - 54 + chr2->yOffset) * 640 + _xPosCurrent; offset += chr2->xOffset - 14; } else { - offset = (_yPosCurrent + _mainSpritesBaseOffset - 54 + chr2->yOffset) * 640 + _xPosCurrent; offset -= chr2->xSize + chr2->xOffset - 14; } Graphics::decodeRLE_248(_locationBackgroundGfxBuf + offset, _spritesGfxBuf + chr2->sourceOffset, chr2->xSize, chr2->ySize, - _spriteFramesTable[_currentSpriteAnimationFrame].yOffset, // _currentCharacter instead ? - _locationHeightTable[_locationNum], _mirroredDrawing != 0); + chr2->yOffset, _locationHeightTable[_locationNum], _mirroredDrawing != 0); } } @@ -1753,6 +1783,10 @@ void TuckerEngine::startSpeechSound(int num, int volume) { loadSound(Audio::Mixer::kSpeechSoundType, num, volume, false, &_speechHandle); } +void TuckerEngine::stopSpeechSound() { + _mixer->stopHandle(_speechHandle); +} + bool TuckerEngine::isSpeechSoundPlaying() { return _mixer->isSoundHandleActive(_speechHandle); } @@ -2068,21 +2102,21 @@ void TuckerEngine::updateCharacterAnimation() { _backgroundSpriteDataPtr = _sprA02Table[_backgroundSpriteCurrentAnimation]; _backgroundSpriteLastFrame = READ_LE_UINT16(_backgroundSpriteDataPtr); } - int var8 = _spriteAnimationFramesTable[_spriteAnimationFrameIndex]; + int frame = _spriteAnimationFramesTable[_spriteAnimationFrameIndex]; if (_panelLockedFlag == 0 && _characterFacingDirection < 5 && _selectedObject.locationObject_locationNum == 0) { _characterFacingDirection = 0; } if (_charSpeechSoundCounter > 0 && _characterFacingDirection == 6 && _actionCharacterNum == 99) { _characterFacingDirection = 6; - var8 = 999; + frame = 999; } else { if (_characterFacingDirection == 6 && _charSpeechSoundCounter != 0 && _actionCharacterNum != 99) { _characterFacingDirection = 0; - var8 = 999; + frame = 999; } } int num = 0; - if (var8 == 999 || (_characterFacingDirection != _characterPrevFacingDirection && _characterFacingDirection < 5)) { + if (frame == 999 || (_characterFacingDirection != _characterPrevFacingDirection && _characterFacingDirection < 5)) { _mirroredDrawing = 0; if (_characterFacingDirection == 6) { if (_csDataHandled != 0) { @@ -2140,16 +2174,16 @@ void TuckerEngine::updateCharacterAnimation() { } _currentSpriteAnimationLength = _spriteAnimationsTable[num].numParts; _spriteAnimationFrameIndex = _spriteAnimationsTable[num].firstFrameIndex; - var8 = _spriteAnimationFramesTable[_spriteAnimationFrameIndex]; + frame = _spriteAnimationFramesTable[_spriteAnimationFrameIndex]; } if (_characterAnimationNum > 0) { num = _characterAnimationNum; _currentSpriteAnimationLength = _spriteAnimationsTable[num].numParts; _spriteAnimationFrameIndex = _spriteAnimationsTable[num].firstFrameIndex; - var8 = _spriteAnimationFramesTable[_spriteAnimationFrameIndex]; + frame = _spriteAnimationFramesTable[_spriteAnimationFrameIndex]; _characterAnimationNum = 0; } - _currentSpriteAnimationFrame = var8; + _currentSpriteAnimationFrame = frame; ++_spriteAnimationFrameIndex; if (_currentSpriteAnimationLength > 1) { _currentSpriteAnimationFrame2 = _spriteAnimationFramesTable[_spriteAnimationFrameIndex]; @@ -2226,17 +2260,17 @@ void TuckerEngine::addObjectToInventory(int num) { } void TuckerEngine::removeObjectFromInventory(int num) { - int i = 0; - while (_inventoryObjectsList[i] != num && i < _inventoryObjectsCount) { - ++i; - } - --_inventoryObjectsCount; - int j = i; - while (j < _inventoryObjectsCount) { - _inventoryObjectsList[j] = _inventoryObjectsList[j + 1]; - ++j; + for (int i = 0; i < _inventoryObjectsCount; ++i) { + if (_inventoryObjectsList[i] == num) { + --_inventoryObjectsCount; + _inventoryItemsState[num] = 2; + const int count = _inventoryObjectsCount - i; + if (count != 0) { + memmove(_inventoryObjectsList + i, _inventoryObjectsList + i + 1, count * sizeof(int)); + } + break; + } } - _inventoryItemsState[num] = 2; } void TuckerEngine::handleMap() { @@ -2777,6 +2811,10 @@ void TuckerEngine::updateSprite(int i) { if (_updateSpriteFlag1 == 0) { _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); + return; + } _spritesTable[i].animationData = _sprC02Table[_spritesTable[i].state]; _spritesTable[i].firstFrame = READ_LE_UINT16(_spritesTable[i].animationData); if (_updateSpriteFlag2 == 1) { @@ -2846,8 +2884,7 @@ void TuckerEngine::updateCharSpeechSound() { setCursorType(0); return; } - static const int constEq0 = 0; // display text for speech - if (constEq0 == 1 && !_gamePaused2) { + if (_displaySpeechText && !_gamePaused2) { drawSpeechText(_actionPosX, _actionPosY, _characterSpeechDataPtr, _speechSoundNum, _actionTextColor); } } @@ -2931,7 +2968,7 @@ static int parseInt(const uint8 *buf, int offset, int len) { int TuckerEngine::parseTableInstruction() { int spr; - printf("parseTableInstruction instruction %c %c %c\n", _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 @@ -3277,7 +3314,7 @@ int TuckerEngine::parseTableInstruction() { } break; } - printf("Instruction not recognised %c %c %c\n", _tableInstructionsPtr[0], _tableInstructionsPtr[1], _tableInstructionsPtr[2]); + warning("Instruction not recognised %c%c%c", _tableInstructionsPtr[0], _tableInstructionsPtr[1], _tableInstructionsPtr[2]); return 2; } @@ -3450,48 +3487,38 @@ void TuckerEngine::setCharacterAnimation(int count, int spr) { } int TuckerEngine::testLocationMaskArea(int xBase, int yBase, int xPos, int yPos) { - int i = 0; - bool quitLoop = false; - while (!quitLoop) { - bool flag = false; + while (true) { + bool loop = false; if (yBase > yPos) { if (testLocationMask(xBase, yBase - 1) == 1) { --yBase; - flag = true; - } else { - ++i; + loop = true; } } else if (yBase < yPos) { if (testLocationMask(xBase, yBase + 1) == 1) { ++yBase; - flag = true; - } else { - ++i; + loop = true; } } if (xBase > xPos) { if (testLocationMask(xBase - 1, yBase) == 1) { --xBase; - flag = true; - } else { - ++i; + loop = true; } - } else if (xBase <= xPos) { + } else if (xBase < xPos) { if (testLocationMask(xBase + 1, yBase) == 1) { ++xBase; - flag = true; - } else { - ++i; + loop = true; } } if (xBase == xPos && yBase == yPos) { - break; + return 0; } - if (!flag) { - return 1; + if (!loop) { + break; } } - return 0; + return 1; } void TuckerEngine::handleMouseClickOnInventoryObject() { diff --git a/engines/tucker/tucker.h b/engines/tucker/tucker.h index 17726ea570..5a5020d32e 100644 --- a/engines/tucker/tucker.h +++ b/engines/tucker/tucker.h @@ -191,6 +191,15 @@ enum Verb { kVerbUse = 8 }; +enum InputKey { + kInputKeyPause = 0, + kInputKeyEscape, + kInputKeyToggleInventory, + kInputKeyToggleTextSpeech, + kInputKeyHelp, + kInputKeyCount +}; + class TuckerEngine: public Engine { public: @@ -236,15 +245,12 @@ protected: void updateCharPositionHelper(); void updateCharPosition(); void updateFlagsForCharPosition(); - void backupPalette(); - void restorePalette(); void fadeOutPalette(int colorsCount = 256); 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(); - int getLastKeyCode(); void stopSounds(); void playSounds(); void updateCharactersPath(); @@ -274,8 +280,8 @@ protected: void startMusic(int offset, int index, int volume); void stopMusic(int index); void startSpeechSound(int num, int volume); + void stopSpeechSound(); bool isSpeechSoundPlaying(); - void isSoundFinished(); void redrawPanelItems(); void redrawPanelItemsHelper(); void drawSprite(int i); @@ -537,7 +543,9 @@ protected: void loadActionFile(); void loadCharPos(); void loadSprA02_01(); + void unloadSprA02_01(); void loadSprC02_01(); + void unloadSprC02_01(); void loadFx(); void loadSound(Audio::Mixer::SoundType type, int num, int volume, bool loop, Audio::SoundHandle *handle); void loadActionsTable(); @@ -562,9 +570,10 @@ protected: int _nextLocationNum; bool _gamePaused; bool _gamePaused2; - int _data4FlagDebug; - int _displayGameHints; + bool _gameDebug; + bool _displayGameHints; int _execData3Counter; + bool _displaySpeechText; uint8 _maxSaveGameSlot, _currentSaveGameSlot; uint8 _firstSaveGameSlot, _lastSaveGameSlot; @@ -602,7 +611,6 @@ protected: int _mousePosX, _mousePosY; int _prevMousePosX, _prevMousePosY; int _mouseButtonsMask; - int _mouseButtons; int _mouseButton2; int _mouseClick; int _mouseClickOnPanelSliders; @@ -610,7 +618,7 @@ protected: bool _leftMouseButtonPressed; bool _rightMouseButtonPressed; int _lastKeyPressed; - int _keyLastKeyCodePressed; + bool _inputKeys[kInputKeyCount]; int _cursorNum; int _cursorType; int _updateCursorFlag; @@ -774,7 +782,6 @@ protected: uint8 *_currentGfxBackground; int _fadePaletteCounter; uint8 _currentPalette[768]; - uint8 _backupPalette[768]; int _updateLocationFadePaletteCounter; int _updateLocationCounter; @@ -876,7 +883,7 @@ private: int _updateScreenOffset; int _frameCounter; int _frameTime; - int _lastFrameTime; + uint32 _lastFrameTime; uint8 *_picBufPtr, *_pic2BufPtr; Audio::SoundHandle _soundsHandle[15]; Audio::SoundHandle _sfxHandle; |