diff options
Diffstat (limited to 'engines/tucker/tucker.cpp')
-rw-r--r-- | engines/tucker/tucker.cpp | 904 |
1 files changed, 470 insertions, 434 deletions
diff --git a/engines/tucker/tucker.cpp b/engines/tucker/tucker.cpp index 04e83efbe5..de555cd7b6 100644 --- a/engines/tucker/tucker.cpp +++ b/engines/tucker/tucker.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -43,6 +43,34 @@ namespace Tucker { TuckerEngine::TuckerEngine(OSystem *system, Common::Language language, uint32 flags) : Engine(system), _gameLang(language), _gameFlags(flags), _rnd("tucker") { _console = new TuckerConsole(this); + + resetVariables(); + + _execData3Counter = 0; + _currentSaveLoadGameState = 1; + _fileLoadSize = 0; + _csDataSize = 0; + _startSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1; + + _player = nullptr; + _loadTempBuf = nullptr; + _cursorGfxBuf = nullptr; + _charsetGfxBuf = nullptr; + _panelGfxBuf = nullptr; + _itemsGfxBuf = nullptr; + _spritesGfxBuf = nullptr; + _locationBackgroundGfxBuf = nullptr; + _data5Buf = nullptr; + _data3GfxBuf = nullptr; + _quadBackgroundGfxBuf = nullptr; + _objTxtBuf = nullptr; + _panelObjectsGfxBuf = nullptr; + _ptTextBuf = nullptr; + _infoBarBuf = nullptr; + _bgTextBuf = nullptr; + _charNameBuf = nullptr; + _locationBackgroundMaskBuf = nullptr; + _csDataBuf = nullptr; } TuckerEngine::~TuckerEngine() { @@ -64,7 +92,8 @@ Common::Error TuckerEngine::run() { initGraphics(kScreenWidth, kScreenHeight, false); syncSoundSettings(); _compressedSound.openFile(); - handleIntroSequence(); + if (_startSlot == -1) + handleIntroSequence(); if ((_gameFlags & kGameFlagIntroOnly) == 0 && !shouldQuit()) { mainLoop(); } @@ -84,17 +113,17 @@ void TuckerEngine::allocateBuffers() { _charsetGfxBuf = (uint8 *)calloc(1, 22400); _cursorGfxBuf = (uint8 *)calloc(1, 256 * 7); _infoBarBuf = (uint8 *)calloc(1, 1000); - _charNameBuf = 0; - _bgTextBuf = 0; - _objTxtBuf = 0; + _charNameBuf = nullptr; + _bgTextBuf = nullptr; + _objTxtBuf = nullptr; _panelObjectsGfxBuf = (uint8 *)calloc(1, 20000); - _data5Buf = 0; + _data5Buf = nullptr; _data3GfxBuf = (uint8 *)calloc(1, 250000); _quadBackgroundGfxBuf = (uint8 *)calloc(1, 320 * 140 * 4); _locationBackgroundMaskBuf = (uint8 *)calloc(1, 640 * 140); - _csDataBuf = 0; + _csDataBuf = nullptr; _spritesGfxBuf = (uint8 *)calloc(1, 160000); - _ptTextBuf = 0; + _ptTextBuf = nullptr; memset(_charWidthTable, 0, sizeof(_charWidthTable)); } @@ -119,7 +148,7 @@ void TuckerEngine::freeBuffers() { free(_ptTextBuf); } -void TuckerEngine::restart() { +void TuckerEngine::resetVariables() { _quitGame = false; _fastMode = false; _syncCounter = 0; @@ -131,15 +160,16 @@ void TuckerEngine::restart() { _nextLocationNum = (_gameFlags & kGameFlagDemo) == 0 ? kStartupLocationGame : kStartupLocationDemo; _gamePaused = false; _gameDebug = false; - _displayGameHints = false; _displaySpeechText = (_gameFlags & kGameFlagNoSubtitles) == 0 ? ConfMan.getBool("subtitles") : false; memset(_flagsTable, 0, sizeof(_flagsTable)); _gameHintsIndex = 0; _gameHintsCounter = 0; - _gameHintsDisplayText = 0; _gameHintsStringNum = 0; + _displayGameHints = false; + _displayHintsText = false; + if ((_gameFlags & kGameFlagDemo) == 0) { _locationWidthTable = _locationWidthTableGame; _locationHeightTable = _locationHeightTableGame; @@ -189,7 +219,7 @@ void TuckerEngine::restart() { _switchPanelCounter = 0; _conversationOptionsCount = 0; _fadedPanel = false; - _panelLockedFlag = 0; + _panelLockedFlag = false; _conversationOptionLinesCount = 0; memset(_inventoryItemsState, 0, sizeof(_inventoryItemsState)); memset(_inventoryObjectsList, 0, sizeof(_inventoryObjectsList)); @@ -223,11 +253,11 @@ void TuckerEngine::restart() { _selectedCharacterNum = 0; _actionObj1Type = _actionObj2Type = 0; _actionObj1Num = _actionObj2Num = 0; - _actionRequiresTwoObjects = 0; - _actionVerbLocked = 0; + _actionRequiresTwoObjects = false; + _actionVerbLocked = false; _actionPosX = 0; _actionPosY = 0; - _selectedObjectLocationMask = 0; + _selectedObjectLocationMask = false; memset(&_selectedObject, 0, sizeof(_selectedObject)); _selectedCharacterDirection = 0; _selectedCharacter2Num = 0; @@ -247,10 +277,10 @@ void TuckerEngine::restart() { _nextTableToLoadIndex = 0; memset(_nextTableToLoadTable, 0, sizeof(_nextTableToLoadTable)); _soundInstructionIndex = 0; - _tableInstructionsPtr = 0; + _tableInstructionsPtr = nullptr; memset(_tableInstructionObj1Table, 0, sizeof(_tableInstructionObj1Table)); memset(_tableInstructionObj2Table, 0, sizeof(_tableInstructionObj2Table)); - _tableInstructionFlag = 0; + _tableInstructionFlag = false; _tableInstructionItemNum1 = _tableInstructionItemNum2 = 0; memset(_instructionsActionsTable, 0, sizeof(_instructionsActionsTable)); _validInstructionId = false; @@ -266,7 +296,7 @@ void TuckerEngine::restart() { _skipCurrentCharacterDraw = false; _yPosCurrent = 131; _xPosCurrent = 160; - _characterSpeechDataPtr = 0; + _characterSpeechDataPtr = nullptr; _ptTextOffset = 0; memset(_characterAnimationsTable, 0, sizeof(_characterAnimationsTable)); memset(_characterStateTable, 0, sizeof(_characterStateTable)); @@ -279,26 +309,26 @@ void TuckerEngine::restart() { _currentSpriteAnimationFrame2 = 0; _characterAnimationIndex = -1; _characterFacingDirection = _characterPrevFacingDirection = 0; - _characterBackFrontFacing = _characterPrevBackFrontFacing = 0; + _characterBackFrontFacing = _characterPrevBackFrontFacing = false; _characterAnimationNum = 0; _noCharacterAnimationChange = 0; - _changeBackgroundSprite = 0; _characterSpriteAnimationFrameCounter = 0; - _locationMaskIgnore = 0; + _locationMaskIgnore = false; _locationMaskType = 0; _locationMaskCounter = 0; - _updateSpriteFlag1 = 0; - _updateSpriteFlag2 = 0; _handleMapCounter = 0; _noPositionChangeAfterMap = false; + _changeBackgroundSprite = false; + _updateSpriteFlag1 = false; + _updateSpriteFlag2 = false; - _mirroredDrawing = 0; - _loadLocBufPtr = 0; - _backgroundSpriteDataPtr = 0; + _mirroredDrawing = false; + _loadLocBufPtr = nullptr; + _backgroundSpriteDataPtr = nullptr; _locationHeight = 0; _scrollOffset = 0; _currentGfxBackgroundCounter = 0; - _currentGfxBackground = 0; + _currentGfxBackground = nullptr; _fadePaletteCounter = 0; memset(_currentPalette, 0, sizeof(_currentPalette)); _fullRedraw = false; @@ -319,14 +349,14 @@ void TuckerEngine::restart() { memset(_updateLocation14ObjNum, 0, sizeof(_updateLocation14ObjNum)); memset(_updateLocation14Delay, 0, sizeof(_updateLocation14Delay)); _updateLocationCounter2 = 0; - _updateLocationFlag = 0; + _updateLocationFlag = false; _updateLocation70StringLen = 0; memset(_updateLocation70String, 0, sizeof(_updateLocation70String)); } void TuckerEngine::mainLoop() { allocateBuffers(); - restart(); + resetVariables(); loadCharSizeDta(); if ((_gameFlags & kGameFlagDemo) != 0) { @@ -352,7 +382,7 @@ void TuckerEngine::mainLoop() { _flagsTable[219] = 1; _flagsTable[105] = 1; - _spriteAnimationFrameIndex = _spriteAnimationsTable[14].firstFrameIndex; + _spriteAnimationFrameIndex = _spriteAnimationsTable[14]._firstFrameIndex; if (ConfMan.hasKey("save_slot")) { const int slot = ConfMan.getInt("save_slot"); @@ -412,7 +442,7 @@ void TuckerEngine::mainLoop() { } if (_flagsTable[158] == 1) { _flagsTable[158] = 0; - _skipCurrentCharacterDraw = 1; + _skipCurrentCharacterDraw = true; } _mainLoopCounter1 = 0; } @@ -440,7 +470,7 @@ void TuckerEngine::mainLoop() { updateGameHints(); } if (_panelState == 0) { - if (_panelLockedFlag == 1 || _pendingActionDelay > 0) { + if (_panelLockedFlag || _pendingActionDelay > 0) { if (!_fadedPanel) { updateItemsGfxColors(0x60, 0x80); _fadedPanel = true; @@ -450,7 +480,7 @@ void TuckerEngine::mainLoop() { clearItemsGfx(); if (_gamePaused) { drawPausedInfoBar(); - } else if (_gameHintsDisplayText == 1 && _mouseIdleCounter > 1000) { + } else if (_displayHintsText && _mouseIdleCounter > 1000) { drawGameHintString(); } else { drawInfoString(); @@ -466,10 +496,10 @@ void TuckerEngine::mainLoop() { } _currentGfxBackground = _quadBackgroundGfxBuf + (_currentGfxBackgroundCounter / 10) * 44800; if (_fadePaletteCounter < 34 && _locationNum == 22) { - _spritesTable[0].gfxBackgroundOffset = (_currentGfxBackgroundCounter / 10) * 640; + _spritesTable[0]._gfxBackgroundOffset = (_currentGfxBackgroundCounter / 10) * 640; _mainSpritesBaseOffset = _currentGfxBackgroundCounter / 10; if (_locationNum == 22 && _currentGfxBackgroundCounter <= 29) { - _spritesTable[0].gfxBackgroundOffset = 640; + _spritesTable[0]._gfxBackgroundOffset = 640; _mainSpritesBaseOffset = 1; } } @@ -489,11 +519,11 @@ void TuckerEngine::mainLoop() { drawData3(); execData3PreUpdate(); for (int i = 0; i < _spritesCount; ++i) { - if (!_spritesTable[i].disabled) { + if (!_spritesTable[i]._disabled) { drawSprite(i); } } - if (_skipCurrentCharacterDraw != 1) { + if (!_skipCurrentCharacterDraw) { if (_backgroundSpriteCurrentAnimation > -1 && _backgroundSpriteCurrentFrame > 0) { drawBackgroundSprites(); } else { @@ -522,7 +552,7 @@ void TuckerEngine::mainLoop() { --_miscSoundFxDelayCounter[num]; if (_miscSoundFxDelayCounter[num] == 0) { const int index = _miscSoundFxNum[num]; - startSound(_locationSoundsTable[index].offset, index, _locationSoundsTable[index].volume); + startSound(_locationSoundsTable[index]._offset, index, _locationSoundsTable[index]._volume); } } } @@ -565,7 +595,7 @@ void TuckerEngine::mainLoop() { } if (_inputKeys[kInputKeyHelp]) { _inputKeys[kInputKeyHelp] = false; - if (_displayGameHints && _gameHintsDisplayText == 1) { + if (_displayGameHints && _displayHintsText) { _gameHintsStringNum = _gameHintsIndex + 1; _mouseIdleCounter = 1100; } @@ -576,6 +606,7 @@ void TuckerEngine::mainLoop() { _flagsTable[236] = 74; } } + if (_flagsTable[236] > 70) { handleCreditsSequence(); _quitGame = true; @@ -689,14 +720,14 @@ void TuckerEngine::setupNewLocation() { _mainLoopCounter2 = 0; _mainLoopCounter1 = 0; _characterFacingDirection = 0; - _actionVerbLocked = 0; - _locationMaskIgnore = 0; + _actionVerbLocked = false; + _locationMaskIgnore = false; _backgroundSprOffset = 0; if (_backgroundSpriteCurrentAnimation > 0 && _backgroundSpriteCurrentFrame > 0) { _backgroundSpriteCurrentAnimation = -1; _backgroundSpriteCurrentFrame = 0; } - if (_panelLockedFlag == 0 || (_backgroundSpriteCurrentAnimation > 0 && _locationNum != 25)) { + if (!_panelLockedFlag || (_backgroundSpriteCurrentAnimation > 0 && _locationNum != 25)) { _locationMaskType = 0; } else { _locationMaskType = 3; @@ -829,8 +860,8 @@ void TuckerEngine::updateCharPosition() { updateCharPositionHelper(); return; case 1: - if (_locationAnimationsTable[_selectedCharacter2Num].getFlag == 1) { - _speechSoundNum = _speechSoundBaseNum + _locationAnimationsTable[_selectedCharacter2Num].inventoryNum; + if (_locationAnimationsTable[_selectedCharacter2Num]._getFlag == 1) { + _speechSoundNum = _speechSoundBaseNum + _locationAnimationsTable[_selectedCharacter2Num]._inventoryNum; _characterSpeechDataPtr = _ptTextBuf; updateCharPositionHelper(); return; @@ -842,8 +873,8 @@ void TuckerEngine::updateCharPosition() { break; case 2: _characterSpeechDataPtr = _ptTextBuf; - _speechSoundNum = 2175 + _charPosTable[_selectedCharacterNum].description; - if (_charPosTable[_selectedCharacterNum].description != 0) { + _speechSoundNum = 2175 + _charPosTable[_selectedCharacterNum]._description; + if (_charPosTable[_selectedCharacterNum]._description != 0) { updateCharPositionHelper(); return; } @@ -852,59 +883,61 @@ void TuckerEngine::updateCharPosition() { } int actionKey = _currentActionObj2Num * 1000000 + _currentInfoString2SourceType * 100000 + _currentActionVerb * 10000 + _currentInfoString1SourceType * 1000 + _currentActionObj1Num; debug(3, "updateCharPosition() actionKey %d", actionKey); - int skip = 0; - Action *action = 0; - for (int i = 0; i < _actionsCount && skip == 0; ++i) { + bool skip = false; + Action *action = nullptr; + for (int i = 0; i < _actionsCount && !skip; ++i) { action = &_actionsTable[i]; - if (action->key == actionKey) { - skip = 1; - if (action->testFlag1Num != 0) { - if (action->testFlag1Num < 500) { - if (_flagsTable[action->testFlag1Num] != action->testFlag1Value) { - skip = 0; - } - } else if (_inventoryItemsState[action->testFlag1Num - 500] != action->testFlag1Value) { - skip = 0; + if (action->_key == actionKey) { + skip = true; + if (action->_testFlag1Num != 0) { + if (action->_testFlag1Num < 500) { + if (action->_testFlag1Num >= 300) + error("updateCharPosition() - Unexpected value for _testFlag1Num : %d", action->_testFlag1Num); + if (_flagsTable[action->_testFlag1Num] != action->_testFlag1Value) + skip = false; + } else if (_inventoryItemsState[action->_testFlag1Num - 500] != action->_testFlag1Value) { + skip = false; } - debug(3, "updateCharPosition() flag1 %d value %d", action->testFlag1Num, action->testFlag1Value); - } - if (action->testFlag2Num != 0) { - if (action->testFlag2Num < 500) { - if (_flagsTable[action->testFlag2Num] != action->testFlag2Value) { - skip = 0; - } - } else if (_inventoryItemsState[action->testFlag2Num - 500] != action->testFlag2Value) { - skip = 0; + debug(3, "updateCharPosition() flag1 %d value %d", action->_testFlag1Num, action->_testFlag1Value); + } + if (action->_testFlag2Num != 0) { + if (action->_testFlag2Num < 500) { + if (action->_testFlag2Num >= 300) + error("updateCharPosition() - Unexpected value for _testFlag1Num : %d", action->_testFlag1Num); + if (_flagsTable[action->_testFlag2Num] != action->_testFlag2Value) + skip = false; + } else if (_inventoryItemsState[action->_testFlag2Num - 500] != action->_testFlag2Value) { + skip = false; } - debug(3, "updateCharPosition() flag2 %d value %d", action->testFlag2Num, action->testFlag2Value); + debug(3, "updateCharPosition() flag2 %d value %d", action->_testFlag2Num, action->_testFlag2Value); } } } - if (skip == 0) { + if (!skip) { playSpeechForAction(_currentActionVerb); _currentActionVerb = 0; return; } assert(action); - if (action->speech != 6) { - if (action->speech < 100) { - _spriteAnimationFrameIndex = _spriteAnimationsTable[action->speech].firstFrameIndex; - _currentSpriteAnimationLength = _spriteAnimationsTable[action->speech].numParts; - _mirroredDrawing = action->flipX; + if (action->_speech != 6) { + if (action->_speech < 100) { + _spriteAnimationFrameIndex = _spriteAnimationsTable[action->_speech]._firstFrameIndex; + _currentSpriteAnimationLength = _spriteAnimationsTable[action->_speech]._numParts; + _mirroredDrawing = (action->_flipX != 0); _characterFacingDirection = 5; _mainLoopCounter2 = 0; } else { - _backgroundSpriteCurrentAnimation = action->speech - 100; + _backgroundSpriteCurrentAnimation = action->_speech - 100; _backgroundSpriteCurrentFrame = 0; - _mirroredDrawing = 0; + _mirroredDrawing = false; } } - _pendingActionDelay = action->delay; - _charPositionFlagNum = action->setFlagNum; - _charPositionFlagValue = action->setFlagValue; - _pendingActionIndex = action->index; - _characterSoundFxDelayCounter = action->fxDelay; - _characterSoundFxNum = action->fxNum; + _pendingActionDelay = action->_delay; + _charPositionFlagNum = action->_setFlagNum; + _charPositionFlagValue = action->_setFlagValue; + _pendingActionIndex = action->_index; + _characterSoundFxDelayCounter = action->_fxDelay; + _characterSoundFxNum = action->_fxNum; _previousActionVerb = _currentActionVerb; _currentActionVerb = 0; } @@ -980,10 +1013,10 @@ void TuckerEngine::setBlackPalette() { void TuckerEngine::updateCursor() { setCursorNum(0); - if (_backgroundSpriteCurrentAnimation == -1 && _panelLockedFlag == 0 && _selectedObject.locationObject_locationNum > 0) { - _selectedObject.locationObject_locationNum = 0; + if (_backgroundSpriteCurrentAnimation == -1 && !_panelLockedFlag && _selectedObject._locationObjectLocationNum > 0) { + _selectedObject._locationObjectLocationNum = 0; } - if (_locationMaskType > 0 || _selectedObject.locationObject_locationNum > 0 || _pendingActionDelay > 0) { + if (_locationMaskType > 0 || _selectedObject._locationObjectLocationNum > 0 || _pendingActionDelay > 0) { return; } if (_rightMouseButtonPressed) { @@ -993,13 +1026,13 @@ void TuckerEngine::updateCursor() { _actionVerb = 0; } _updateCursorFlag = true; - _actionVerbLocked = 1; + _actionVerbLocked = true; _actionRequiresTwoObjects = false; } } else { _updateCursorFlag = false; } - if (_actionVerbLocked == 0) { + if (!_actionVerbLocked) { setActionVerbUnderCursor(); if (_actionVerb == 0 && _locationNum == 63) { _actionVerb = 8; @@ -1016,7 +1049,7 @@ void TuckerEngine::updateCursor() { } else { num = getObjectUnderCursor(); if (num > -1) { - _selectedObjectNum = _locationObjectsTable[num].textNum; + _selectedObjectNum = _locationObjectsTable[num]._textNum; } } handleMouseClickOnInventoryObject(); @@ -1027,7 +1060,7 @@ void TuckerEngine::updateCursor() { _selectedObjectNum = 0; _selectedObjectType = 0; } - if (_actionVerbLocked == 0 && _selectedObjectType == 2 && _selectedObjectNum != 21) { + if (!_actionVerbLocked && _selectedObjectType == 2 && _selectedObjectNum != 21) { _actionVerb = 2; } if (!_actionRequiresTwoObjects) { @@ -1055,7 +1088,7 @@ void TuckerEngine::updateCursor() { if (_mousePosY >= 150 && _mousePosX < 212) { if (_mousePosX < 200) { setActionVerbUnderCursor(); - _actionVerbLocked = 1; + _actionVerbLocked = true; _actionRequiresTwoObjects = false; } else if (_mousePosY < 175) { moveDownInventoryObjects(); @@ -1066,13 +1099,13 @@ void TuckerEngine::updateCursor() { if (_selectedObjectType == 3) { setActionForInventoryObject(); } else if (_actionVerb != 0) { - _actionVerbLocked = 0; + _actionVerbLocked = false; setActionState(); } else if (_actionObj1Num == 261 || (_actionObj1Num == 205 && _flagsTable[143] == 0)) { - _actionVerbLocked = 0; + _actionVerbLocked = false; setActionState(); } else { - _actionVerbLocked = 0; + _actionVerbLocked = false; _actionRequiresTwoObjects = false; _currentActionVerb = 0; setSelectedObjectKey(); @@ -1092,26 +1125,26 @@ void TuckerEngine::stopSounds() { void TuckerEngine::playSounds() { for (int i = 0; i < _locationSoundsCount; ++i) { - if (_locationSoundsTable[i].type == 1 || _locationSoundsTable[i].type == 2 || _locationSoundsTable[i].type == 5 || - (_locationSoundsTable[i].type == 7 && _flagsTable[_locationSoundsTable[i].flagNum] == _locationSoundsTable[i].flagValueStartFx)) { - startSound(_locationSoundsTable[i].offset, i, _locationSoundsTable[i].volume); + if (_locationSoundsTable[i]._type == 1 || _locationSoundsTable[i]._type == 2 || _locationSoundsTable[i]._type == 5 || + (_locationSoundsTable[i]._type == 7 && _flagsTable[_locationSoundsTable[i]._flagNum] == _locationSoundsTable[i]._flagValueStartFx)) { + startSound(_locationSoundsTable[i]._offset, i, _locationSoundsTable[i]._volume); } } for (int i = 0; i < _locationMusicsCount; ++i) { - if (_locationMusicsTable[i].flag > 0) { - startMusic(_locationMusicsTable[i].offset, i, _locationMusicsTable[i].volume); + if (_locationMusicsTable[i]._flag > 0) { + startMusic(_locationMusicsTable[i]._offset, i, _locationMusicsTable[i]._volume); } } } void TuckerEngine::updateCharactersPath() { - if (_panelLockedFlag == 0) { + if (!_panelLockedFlag) { return; } if (_backgroundSpriteCurrentAnimation != -1 && _locationNum != 25) { - if (_xPosCurrent == _selectedObject.xPos && _yPosCurrent == _selectedObject.yPos) { + if (_xPosCurrent == _selectedObject._xPos && _yPosCurrent == _selectedObject._yPos) { _locationMaskCounter = 1; - _panelLockedFlag = 0; + _panelLockedFlag = false; } return; } @@ -1120,68 +1153,68 @@ void TuckerEngine::updateCharactersPath() { if (_characterFacingDirection == 5) { _characterPrevFacingDirection = 5; } - int flag = 0; - if (_yPosCurrent > _selectedObject.yPos) { - if (testLocationMask(_xPosCurrent, _yPosCurrent - 1) == 1) { + bool flag = false; + if (_yPosCurrent > _selectedObject._yPos) { + if (testLocationMask(_xPosCurrent, _yPosCurrent - 1)) { --_yPosCurrent; _characterFacingDirection = 4; - flag = 1; + flag = true; } - } else if (_yPosCurrent < _selectedObject.yPos) { - if (testLocationMask(_xPosCurrent, _yPosCurrent + 1) == 1) { + } else if (_yPosCurrent < _selectedObject._yPos) { + if (testLocationMask(_xPosCurrent, _yPosCurrent + 1)) { ++_yPosCurrent; _characterFacingDirection = 2; - flag = 1; + flag = true; } } - if (_xPosCurrent > _selectedObject.xPos) { - if (testLocationMask(_xPosCurrent - 1, _yPosCurrent) == 1) { + if (_xPosCurrent > _selectedObject._xPos) { + if (testLocationMask(_xPosCurrent - 1, _yPosCurrent)) { --_xPosCurrent; _characterFacingDirection = 3; - _characterBackFrontFacing = 0; - flag = 1; + _characterBackFrontFacing = false; + flag = true; } - } else if (_xPosCurrent < _selectedObject.xPos) { - if (testLocationMask(_xPosCurrent + 1, _yPosCurrent) == 1) { + } else if (_xPosCurrent < _selectedObject._xPos) { + if (testLocationMask(_xPosCurrent + 1, _yPosCurrent)) { ++_xPosCurrent; _characterFacingDirection = 1; - _characterBackFrontFacing = 1; - flag = 1; + _characterBackFrontFacing = true; + flag = true; } } - if (flag == 0) { - if (_selectedObjectLocationMask == 1) { - _selectedObjectLocationMask = 0; - _selectedObject.xPos = _selectedObject.xDefaultPos; - _selectedObject.yPos = _selectedObject.yDefaultPos; + if (!flag) { + if (_selectedObjectLocationMask) { + _selectedObjectLocationMask = false; + _selectedObject._xPos = _selectedObject._xDefaultPos; + _selectedObject._yPos = _selectedObject._yDefaultPos; } else { - _panelLockedFlag = 0; + _panelLockedFlag = false; _characterFacingDirection = 0; - if (_xPosCurrent == _selectedObject.xPos && _yPosCurrent == _selectedObject.yPos) { + if (_xPosCurrent == _selectedObject._xPos && _yPosCurrent == _selectedObject._yPos) { _locationMaskCounter = 1; } } } if (_locationNum == 25) { - if ((_backgroundSpriteCurrentAnimation != 3 || _characterBackFrontFacing != 0) && (_backgroundSpriteCurrentAnimation != 6 || _characterBackFrontFacing != 1)) { + if ((_backgroundSpriteCurrentAnimation != 3 || _characterBackFrontFacing) && (_backgroundSpriteCurrentAnimation != 6 || !_characterBackFrontFacing)) { _xPosCurrent = xPos; _yPosCurrent = yPos; return; } } - if (_xPosCurrent != _selectedObject.xPos || _yPosCurrent != _selectedObject.yPos) { + if (_xPosCurrent != _selectedObject._xPos || _yPosCurrent != _selectedObject._yPos) { return; } - if (_selectedObjectLocationMask != 0) { + if (_selectedObjectLocationMask) { return; } _locationMaskCounter = 1; - _panelLockedFlag = 0; - _locationMaskIgnore = 0; + _panelLockedFlag = false; + _locationMaskIgnore = false; if (_characterPrevFacingDirection <= 0 || _characterPrevFacingDirection >= 5) { return; } - if (_selectedObject.locationObject_locationNum == 0) { + if (_selectedObject._locationObjectLocationNum == 0) { _characterFacingDirection = 5; while (_spriteAnimationFramesTable[_spriteAnimationFrameIndex] != 999) { ++_spriteAnimationFrameIndex; @@ -1200,12 +1233,12 @@ void TuckerEngine::setSoundVolumeDistance() { void TuckerEngine::updateData3DrawFlag() { for (int i = 0; i < _locationAnimationsCount; ++i) { LocationAnimation *a = &_locationAnimationsTable[i]; - if (a->flagNum > 0 && a->flagValue != _flagsTable[a->flagNum]) { - a->drawFlag = 0; - } else if (a->getFlag == 0) { - a->drawFlag = 1; + if (a->_flagNum > 0 && a->_flagValue != _flagsTable[a->_flagNum]) { + a->_drawFlag = false; + } else if (a->_getFlag == 0) { + a->_drawFlag = true; } else { - a->drawFlag = (_inventoryItemsState[a->inventoryNum] == 0) ? 1 : 0; + a->_drawFlag = (_inventoryItemsState[a->_inventoryNum] == 0); } } } @@ -1214,26 +1247,26 @@ void TuckerEngine::updateData3() { updateData3DrawFlag(); for (int i = 0; i < _locationAnimationsCount; ++i) { LocationAnimation *a = &_locationAnimationsTable[i]; - if (a->animLastCounter != 0 && a->drawFlag != 0) { - if (a->animLastCounter == a->animCurrentCounter) { - a->animCurrentCounter = a->animInitCounter; + if (a->_animLastCounter != 0 && a->_drawFlag) { + if (a->_animLastCounter == a->_animCurrentCounter) { + a->_animCurrentCounter = a->_animInitCounter; } else { - ++a->animCurrentCounter; + ++a->_animCurrentCounter; } - const int index = a->animCurrentCounter; + const int index = a->_animCurrentCounter; if (_staticData3Table[index] == 998) { _flagsTable[_staticData3Table[index + 1]] = _staticData3Table[index + 2]; - a->animCurrentCounter = a->animInitCounter; - a->drawFlag = 0; + a->_animCurrentCounter = a->_animInitCounter; + a->_drawFlag = false; } if (_locationNum == 24 && i == 0) { // workaround bug #2872385: update fish animation sequence for correct // position in aquarium. - if (a->animInitCounter == 505 && a->animCurrentCounter == 513) { - a->animCurrentCounter = 525; + if (a->_animInitCounter == 505 && a->_animCurrentCounter == 513) { + a->_animCurrentCounter = 525; } } - a->graphicNum = _staticData3Table[a->animCurrentCounter]; + a->_graphicNum = _staticData3Table[a->_animCurrentCounter]; } } updateData3DrawFlag(); @@ -1242,16 +1275,16 @@ void TuckerEngine::updateData3() { void TuckerEngine::updateSfxData3_1() { for (int i = 0; i < _locationSoundsCount; ++i) { LocationSound *s = &_locationSoundsTable[i]; - if ((s->type == 6 || s->type == 7) && s->updateType == 1) { + if ((s->_type == 6 || s->_type == 7) && s->_updateType == 1) { for (int j = 0; j < _spritesCount; ++j) { - if (_spritesTable[j].animationFrame == s->startFxSpriteNum && _spritesTable[j].state == s->startFxSpriteState) { - if (s->type == 7) { - _flagsTable[s->flagNum] = s->flagValueStartFx; + if (_spritesTable[j]._animationFrame == s->_startFxSpriteNum && _spritesTable[j]._state == s->_startFxSpriteState) { + if (s->_type == 7) { + _flagsTable[s->_flagNum] = s->_flagValueStartFx; } - startSound(s->offset, i, s->volume); - } else if (s->type == 7) { - if (_spritesTable[j].animationFrame == s->stopFxSpriteNum && _spritesTable[j].state == s->stopFxSpriteState) { - _flagsTable[s->flagNum] = s->flagValueStopFx; + startSound(s->_offset, i, s->_volume); + } else if (s->_type == 7) { + if (_spritesTable[j]._animationFrame == s->_stopFxSpriteNum && _spritesTable[j]._state == s->_stopFxSpriteState) { + _flagsTable[s->_flagNum] = s->_flagValueStopFx; stopSound(i); } } @@ -1263,15 +1296,15 @@ void TuckerEngine::updateSfxData3_1() { void TuckerEngine::updateSfxData3_2() { for (int i = 0; i < _locationSoundsCount; ++i) { LocationSound *s = &_locationSoundsTable[i]; - if ((s->type == 6 || s->type == 7) && s->updateType == 0) { - if (s->startFxSpriteNum == _backgroundSpriteCurrentFrame && s->startFxSpriteState == _backgroundSpriteCurrentAnimation) { - if (s->type == 7) { - _flagsTable[s->flagNum] = s->flagValueStartFx; + if ((s->_type == 6 || s->_type == 7) && s->_updateType == 0) { + if (s->_startFxSpriteNum == _backgroundSpriteCurrentFrame && s->_startFxSpriteState == _backgroundSpriteCurrentAnimation) { + if (s->_type == 7) { + _flagsTable[s->_flagNum] = s->_flagValueStartFx; } - startSound(s->offset, i, s->volume); - } else if (s->type == 7) { - if (s->stopFxSpriteNum == _backgroundSpriteCurrentFrame && s->stopFxSpriteState == _backgroundSpriteCurrentAnimation) { - _flagsTable[s->flagNum] = s->flagValueStopFx; + startSound(s->_offset, i, s->_volume); + } else if (s->_type == 7) { + if (s->_stopFxSpriteNum == _backgroundSpriteCurrentFrame && s->_stopFxSpriteState == _backgroundSpriteCurrentAnimation) { + _flagsTable[s->_flagNum] = s->_flagValueStopFx; stopSound(i); } } @@ -1422,7 +1455,7 @@ void TuckerEngine::redrawPanelOverBackground() { void TuckerEngine::drawConversationTexts() { int y = 141; - int flag = 0; + bool flag = false; for (int i = 0; i < _conversationOptionsCount; ++i) { int color = 108; if ((_mousePosY > y && _mousePosY < y + 11) || _nextTableToLoadIndex == i) { @@ -1431,11 +1464,11 @@ void TuckerEngine::drawConversationTexts() { drawSpeechText(0, y, _characterSpeechDataPtr, _instructionsActionsTable[i], color); if (_mousePosY > y && _mousePosY < _conversationOptionLinesCount * 10 + y + 1) { _nextTableToLoadIndex = i; - flag = 1; + flag = true; } y += _conversationOptionLinesCount * 10; } - if (flag == 0) { + if (!flag) { _nextTableToLoadIndex = -1; } } @@ -1471,31 +1504,31 @@ void TuckerEngine::updateGameHints() { if (_gameHintsIndex == 0 && _flagsTable[3] > 0) { _gameHintsIndex = 1; _gameHintsCounter = 0; - _gameHintsDisplayText = 0; + _displayHintsText = false; } else if (_gameHintsIndex == 1 && _flagsTable[12] > 0) { _gameHintsIndex = 2; _gameHintsCounter = 0; - _gameHintsDisplayText = 0; + _displayHintsText = false; } else if (_gameHintsIndex == 2 && _flagsTable[20] > 0) { _gameHintsIndex = 3; _gameHintsCounter = 0; - _gameHintsDisplayText = 0; + _displayHintsText = false; } else if (_gameHintsIndex == 3 && _flagsTable[9] > 0) { _gameHintsIndex = 4; _gameHintsCounter = 0; - _gameHintsDisplayText = 0; + _displayHintsText = false; } else if (_gameHintsIndex == 4 && _flagsTable[23] > 0) { _gameHintsIndex = 5; _gameHintsCounter = 0; - _gameHintsDisplayText = 0; + _displayHintsText = false; } else if (_flagsTable[19] > 0) { _gameHintsIndex = 6; _gameHintsCounter = 0; - _gameHintsDisplayText = 0; + _displayHintsText = false; } ++_gameHintsCounter; if (_gameHintsCounter > 1500) { - _gameHintsDisplayText = 1; + _displayHintsText = true; } } @@ -1503,7 +1536,7 @@ void TuckerEngine::startCharacterSounds() { if (_characterSoundFxDelayCounter != 0) { --_characterSoundFxDelayCounter; if (_characterSoundFxDelayCounter <= 0) { - startSound(_locationSoundsTable[_characterSoundFxNum].offset, _characterSoundFxNum, _locationSoundsTable[_characterSoundFxNum].volume); + startSound(_locationSoundsTable[_characterSoundFxNum]._offset, _characterSoundFxNum, _locationSoundsTable[_characterSoundFxNum]._volume); } } } @@ -1513,16 +1546,16 @@ void TuckerEngine::updateSoundsTypes3_4() { return; } for (int i = 0; i < _locationSoundsCount; ++i) { - switch (_locationSoundsTable[i].type) { + switch (_locationSoundsTable[i]._type) { case 3: if (getRandomNumber() >= 32300) { - startSound(_locationSoundsTable[i].offset, 0, _locationSoundsTable[i].volume); + startSound(_locationSoundsTable[i]._offset, 0, _locationSoundsTable[i]._volume); return; } break; case 4: if (getRandomNumber() >= 32763) { - startSound(_locationSoundsTable[i].offset, 0, _locationSoundsTable[i].volume); + startSound(_locationSoundsTable[i]._offset, 0, _locationSoundsTable[i]._volume); return; } break; @@ -1532,11 +1565,11 @@ void TuckerEngine::updateSoundsTypes3_4() { void TuckerEngine::drawData3() { for (int i = 0; i < _locationAnimationsCount; ++i) { - if (_locationAnimationsTable[i].drawFlag != 0) { - int num = _locationAnimationsTable[i].graphicNum; + if (_locationAnimationsTable[i]._drawFlag) { + int num = _locationAnimationsTable[i]._graphicNum; const Data *d = &_dataTable[num]; - Graphics::decodeRLE(_locationBackgroundGfxBuf + d->yDest * 640 + d->xDest, _data3GfxBuf + d->sourceOffset, d->xSize, d->ySize); - addDirtyRect(d->xDest, d->yDest, d->xSize, d->ySize); + Graphics::decodeRLE(_locationBackgroundGfxBuf + d->_yDest * 640 + d->_xDest, _data3GfxBuf + d->_sourceOffset, d->_xSize, d->_ySize); + addDirtyRect(d->_xDest, d->_yDest, d->_xSize, d->_ySize); } } } @@ -1750,28 +1783,28 @@ void TuckerEngine::drawCurrentSprite() { // Workaround original game glitch: location 14 contains some colors from [0xE0-0xF8] in a walkable area (tracker item #3106542) const bool color248Only = (_locationNum == 14); SpriteFrame *chr = &_spriteFramesTable[_currentSpriteAnimationFrame]; - int yPos = _yPosCurrent + _mainSpritesBaseOffset - 54 + chr->yOffset; + int yPos = _yPosCurrent + _mainSpritesBaseOffset - 54 + chr->_yOffset; int xPos = _xPosCurrent; - if (_mirroredDrawing == 0) { - xPos += chr->xOffset - 14; + if (!_mirroredDrawing) { + xPos += chr->_xOffset - 14; } else { - xPos -= chr->xSize + chr->xOffset - 14; + xPos -= chr->_xSize + chr->_xOffset - 14; } - Graphics::decodeRLE_248(_locationBackgroundGfxBuf + yPos * 640 + xPos, _spritesGfxBuf + chr->sourceOffset, chr->xSize, chr->ySize, - chr->yOffset, _locationHeightTable[_locationNum], _mirroredDrawing != 0, color248Only); - addDirtyRect(xPos, yPos, chr->xSize, chr->ySize); + Graphics::decodeRLE_248(_locationBackgroundGfxBuf + yPos * 640 + xPos, _spritesGfxBuf + chr->_sourceOffset, chr->_xSize, chr->_ySize, + chr->_yOffset, _locationHeightTable[_locationNum], _mirroredDrawing, color248Only); + addDirtyRect(xPos, yPos, chr->_xSize, chr->_ySize); if (_currentSpriteAnimationLength > 1) { SpriteFrame *chr2 = &_spriteFramesTable[_currentSpriteAnimationFrame2]; - yPos = _yPosCurrent + _mainSpritesBaseOffset - 54 + chr2->yOffset; + yPos = _yPosCurrent + _mainSpritesBaseOffset - 54 + chr2->_yOffset; xPos = _xPosCurrent; - if (_mirroredDrawing == 0) { - xPos += chr2->xOffset - 14; + if (!_mirroredDrawing) { + xPos += chr2->_xOffset - 14; } else { - xPos -= chr2->xSize + chr2->xOffset - 14; + xPos -= chr2->_xSize + chr2->_xOffset - 14; } - Graphics::decodeRLE_248(_locationBackgroundGfxBuf + yPos * 640 + xPos, _spritesGfxBuf + chr2->sourceOffset, chr2->xSize, chr2->ySize, - chr2->yOffset, _locationHeightTable[_locationNum], _mirroredDrawing != 0, color248Only); - addDirtyRect(xPos, yPos, chr2->xSize, chr2->ySize); + Graphics::decodeRLE_248(_locationBackgroundGfxBuf + yPos * 640 + xPos, _spritesGfxBuf + chr2->_sourceOffset, chr2->_xSize, chr2->_ySize, + chr2->_yOffset, _locationHeightTable[_locationNum], _mirroredDrawing, color248Only); + addDirtyRect(xPos, yPos, chr2->_xSize, chr2->_ySize); } } @@ -1790,8 +1823,8 @@ void TuckerEngine::setVolumeMusic(int index, int volume) { } void TuckerEngine::startSound(int offset, int index, int volume) { - bool loop = (_locationSoundsTable[index].type == 2 || _locationSoundsTable[index].type == 5 || _locationSoundsTable[index].type == 7); - loadSound(Audio::Mixer::kSFXSoundType, _locationSoundsTable[index].num, volume, loop, &_sfxHandles[index]); + bool loop = (_locationSoundsTable[index]._type == 2 || _locationSoundsTable[index]._type == 5 || _locationSoundsTable[index]._type == 7); + loadSound(Audio::Mixer::kSFXSoundType, _locationSoundsTable[index]._num, volume, loop, &_sfxHandles[index]); } void TuckerEngine::stopSound(int index) { @@ -1803,8 +1836,8 @@ bool TuckerEngine::isSoundPlaying(int index) { } void TuckerEngine::startMusic(int offset, int index, int volume) { - bool loop = (_locationMusicsTable[index].flag == 2); - loadSound(Audio::Mixer::kMusicSoundType, _locationMusicsTable[index].num, volume, loop, &_musicHandles[index]); + bool loop = (_locationMusicsTable[index]._flag == 2); + loadSound(Audio::Mixer::kMusicSoundType, _locationMusicsTable[index]._num, volume, loop, &_musicHandles[index]); } void TuckerEngine::stopMusic(int index) { @@ -1831,14 +1864,16 @@ void TuckerEngine::rememberSpeechSound() { } void TuckerEngine::redrawPanelItems() { - const uint8 *src = 0; - uint8 *dst = 0; - int sz = 0; if (_forceRedrawPanelItems || (_redrawPanelItemsCounter != 0 && _panelState == 0)) { _forceRedrawPanelItems = false; if (_redrawPanelItemsCounter > 0) { --_redrawPanelItemsCounter; } + + const uint8 *src = nullptr; + uint8 *dst = nullptr; + int sz = 0; + switch (_panelState) { case 0: src = _panelGfxBuf; @@ -1892,25 +1927,25 @@ void TuckerEngine::redrawPanelItemsHelper() { void TuckerEngine::drawSprite(int num) { Sprite *s = &_spritesTable[num]; - if (s->animationFrame <= s->firstFrame && s->animationFrame > 0 && s->state != -1) { - const uint8 *p = s->animationData; + if (s->_animationFrame <= s->_firstFrame && s->_animationFrame > 0 && s->_state != -1) { + const uint8 *p = s->_animationData; if (!p) { return; } - int frameOffset = READ_LE_UINT24(p + s->animationFrame * 4); + int frameOffset = READ_LE_UINT24(p + s->_animationFrame * 4); int srcW = READ_LE_UINT16(p + frameOffset); int srcH = READ_LE_UINT16(p + frameOffset + 2); int srcX = READ_LE_UINT16(p + frameOffset + 8); int srcY = READ_LE_UINT16(p + frameOffset + 10); - int xPos = s->gfxBackgroundOffset + srcX; + int xPos = s->_gfxBackgroundOffset + srcX; if (xPos < 600 && (_scrollOffset + 320 < xPos || _scrollOffset - srcW > xPos)) { return; } - s->xSource = srcX; - s->gfxBackgroundOffset += s->backgroundOffset; + s->_xSource = srcX; + s->_gfxBackgroundOffset += s->_backgroundOffset; uint8 *dstPtr = _locationBackgroundGfxBuf + srcY * 640 + xPos; const uint8 *srcPtr = p + frameOffset + 12; - switch (s->colorType) { + switch (s->_colorType) { case 0: Graphics::decodeRLE(dstPtr, srcPtr, srcW, srcH); break; @@ -1918,11 +1953,11 @@ void TuckerEngine::drawSprite(int num) { Graphics::decodeRLE_224(dstPtr, srcPtr, srcW, srcH); break; default: - Graphics::decodeRLE_248(dstPtr, srcPtr, srcW, srcH, 0, s->yMaxBackground, s->flipX != 0); + Graphics::decodeRLE_248(dstPtr, srcPtr, srcW, srcH, 0, s->_yMaxBackground, s->_flipX); break; } - const int xR = srcX + (s->gfxBackgroundOffset % 640); - const int yR = srcY + (s->gfxBackgroundOffset / 640); + const int xR = srcX + (s->_gfxBackgroundOffset % 640); + const int yR = srcY + (s->_gfxBackgroundOffset / 640); addDirtyRect(xR, yR, srcW, srcH); } } @@ -1938,7 +1973,7 @@ void TuckerEngine::drawPausedInfoBar() { } const uint8 *TuckerEngine::getStringBuf(int type) const { - const uint8 *p = 0; + const uint8 *p = nullptr; switch (type) { case 0: p = _data5Buf; @@ -2031,7 +2066,7 @@ void TuckerEngine::updateCharacterAnimation() { ++_spriteAnimationFrameIndex; } _characterFacingDirection = 0; - if (_changeBackgroundSprite == 1) { + if (_changeBackgroundSprite) { if (_backgroundSpriteCurrentFrame == 0) { _backgroundSpriteDataPtr = _sprA02Table[_backgroundSpriteCurrentAnimation]; _backgroundSpriteCurrentFrame = _backgroundSpriteLastFrame = READ_LE_UINT16(_backgroundSpriteDataPtr); @@ -2040,7 +2075,7 @@ void TuckerEngine::updateCharacterAnimation() { if (_backgroundSpriteCurrentFrame < 1) { _backgroundSpriteCurrentAnimation = -1; _backgroundSpriteCurrentFrame = 0; - _changeBackgroundSprite = 0; + _changeBackgroundSprite = false; if (_nextAction == 0) { setCursorType(0); } @@ -2052,7 +2087,7 @@ void TuckerEngine::updateCharacterAnimation() { assert(_backgroundSpriteCurrentAnimation >= 0 && _backgroundSpriteCurrentAnimation < kSprA02TableSize); _backgroundSpriteDataPtr = _sprA02Table[_backgroundSpriteCurrentAnimation]; _backgroundSpriteLastFrame = READ_LE_UINT16(_backgroundSpriteDataPtr); - } else if (_locationNum == 25 && _panelLockedFlag != 1 && (_backgroundSpriteCurrentAnimation == 3 || _backgroundSpriteCurrentAnimation == 6)) { + } else if (_locationNum == 25 && !_panelLockedFlag && (_backgroundSpriteCurrentAnimation == 3 || _backgroundSpriteCurrentAnimation == 6)) { _backgroundSpriteCurrentFrame = 0; _backgroundSpriteCurrentAnimation = -1; } else { @@ -2068,9 +2103,9 @@ void TuckerEngine::updateCharacterAnimation() { } } if (_locationNum == 24 && _flagsTable[103] == 0) { - if (_panelLockedFlag == 1) { - _panelLockedFlag = 0; - _selectedObject.locationObject_locationNum = 0; + if (_panelLockedFlag) { + _panelLockedFlag = false; + _selectedObject._locationObjectLocationNum = 0; if (_actionVerb != 2) { _speechSoundNum = 2236; startSpeechSound(_speechSoundNum, _speechVolume); @@ -2105,10 +2140,10 @@ void TuckerEngine::updateCharacterAnimation() { } } else if (_locationNum == 25) { if (_backgroundSpriteCurrentFrame == 0) { - if (_characterBackFrontFacing == 0) { + if (!_characterBackFrontFacing) { if (_characterBackFrontFacing != _characterPrevBackFrontFacing) { _backgroundSpriteCurrentAnimation = 10; - } else if (_panelLockedFlag == 1) { + } else if (_panelLockedFlag) { _backgroundSpriteCurrentAnimation = 3; } else if (_charSpeechSoundCounter > 0 && _actionCharacterNum == 99) { _backgroundSpriteCurrentAnimation = 8; @@ -2118,7 +2153,7 @@ void TuckerEngine::updateCharacterAnimation() { } else { if (_characterBackFrontFacing != _characterPrevBackFrontFacing) { _backgroundSpriteCurrentAnimation = 2; - } else if (_panelLockedFlag == 1) { + } else if (_panelLockedFlag) { _backgroundSpriteCurrentAnimation = 6; } else if (_charSpeechSoundCounter > 0 && _actionCharacterNum == 99) { _backgroundSpriteCurrentAnimation = 9; @@ -2143,7 +2178,7 @@ void TuckerEngine::updateCharacterAnimation() { _backgroundSpriteLastFrame = READ_LE_UINT16(_backgroundSpriteDataPtr); } int frame = _spriteAnimationFramesTable[_spriteAnimationFrameIndex]; - if (_panelLockedFlag == 0 && _characterFacingDirection < 5 && _selectedObject.locationObject_locationNum == 0) { + if (!_panelLockedFlag && _characterFacingDirection < 5 && _selectedObject._locationObjectLocationNum == 0) { _characterFacingDirection = 0; } if (_charSpeechSoundCounter > 0 && _characterFacingDirection != 6 && _actionCharacterNum == 99) { @@ -2155,7 +2190,7 @@ void TuckerEngine::updateCharacterAnimation() { } int num = 0; if (frame == 999 || (_characterFacingDirection != _characterPrevFacingDirection && _characterFacingDirection < 5)) { - _mirroredDrawing = 0; + _mirroredDrawing = false; if (_characterFacingDirection == 6) { if (_csDataHandled) { switch (_selectedCharacterDirection) { @@ -2170,7 +2205,7 @@ void TuckerEngine::updateCharacterAnimation() { break; default: num = 16; - _mirroredDrawing = 1; + _mirroredDrawing = true; break; } } else { @@ -2182,7 +2217,7 @@ void TuckerEngine::updateCharacterAnimation() { } if (_characterFacingDirection == 0) { if (_csDataHandled) { - _mirroredDrawing = 0; + _mirroredDrawing = false; switch (_selectedCharacterDirection) { case 1: num = 3; @@ -2192,7 +2227,7 @@ void TuckerEngine::updateCharacterAnimation() { break; case 3: num = 1; - _mirroredDrawing = 1; + _mirroredDrawing = true; break; default: num = 5; @@ -2218,21 +2253,21 @@ void TuckerEngine::updateCharacterAnimation() { break; case 3: num = 0; - _mirroredDrawing = 1; + _mirroredDrawing = true; break; case 4: num = 2; break; } } - _currentSpriteAnimationLength = _spriteAnimationsTable[num].numParts; - _spriteAnimationFrameIndex = _spriteAnimationsTable[num].firstFrameIndex; + _currentSpriteAnimationLength = _spriteAnimationsTable[num]._numParts; + _spriteAnimationFrameIndex = _spriteAnimationsTable[num]._firstFrameIndex; frame = _spriteAnimationFramesTable[_spriteAnimationFrameIndex]; } if (_characterAnimationNum > 0) { num = _characterAnimationNum; - _currentSpriteAnimationLength = _spriteAnimationsTable[num].numParts; - _spriteAnimationFrameIndex = _spriteAnimationsTable[num].firstFrameIndex; + _currentSpriteAnimationLength = _spriteAnimationsTable[num]._numParts; + _spriteAnimationFrameIndex = _spriteAnimationsTable[num]._firstFrameIndex; frame = _spriteAnimationFramesTable[_spriteAnimationFrameIndex]; _characterAnimationNum = 0; } @@ -2287,10 +2322,10 @@ void TuckerEngine::handleMap() { if (_handleMapCounter > 19) { _handleMapCounter = 0; _locationMaskCounter = 1; - _panelLockedFlag = 0; + _panelLockedFlag = false; } } - if (_panelLockedFlag == 0 && (_backgroundSpriteCurrentAnimation == -1 || _locationNum == 25) && _locationMaskType == 3) { + if (!_panelLockedFlag && (_backgroundSpriteCurrentAnimation == -1 || _locationNum == 25) && _locationMaskType == 3) { setCursorType(0); if (_locationMaskCounter == 1) { _characterFacingDirection = 0; @@ -2298,22 +2333,22 @@ void TuckerEngine::handleMap() { } return; } - if (_selectedObject.locationObject_locationNum != 0 && _locationMaskCounter != 0 && (_backgroundSpriteCurrentAnimation <= -1 || _locationNum == 25)) { + if (_selectedObject._locationObjectLocationNum != 0 && _locationMaskCounter != 0 && (_backgroundSpriteCurrentAnimation <= -1 || _locationNum == 25)) { if (_locationNum == 25 || _backgroundSpriteCurrentAnimation != 4) { if (_locationMaskType == 0) { _locationMaskType = 1; setCursorType(2); - if (_selectedObject.locationObject_toWalkX2 > 800) { - _backgroundSpriteCurrentAnimation = _selectedObject.locationObject_toWalkX2 - 900; - if (_selectedObject.locationObject_toWalkY2 > 499) { - _changeBackgroundSprite = 1; - _backgroundSprOffset = _selectedObject.locationObject_toWalkY2 - 500; + if (_selectedObject._locationObjectToWalkX2 > 800) { + _backgroundSpriteCurrentAnimation = _selectedObject._locationObjectToWalkX2 - 900; + if (_selectedObject._locationObjectToWalkY2 > 499) { + _changeBackgroundSprite = true; + _backgroundSprOffset = _selectedObject._locationObjectToWalkY2 - 500; } else { - _backgroundSprOffset = _selectedObject.locationObject_toWalkY2; - _changeBackgroundSprite = 0; + _backgroundSprOffset = _selectedObject._locationObjectToWalkY2; + _changeBackgroundSprite = false; } _backgroundSpriteCurrentFrame = 0; - _mirroredDrawing = 0; + _mirroredDrawing = false; if (_locationNum == 25) { _backgroundSpriteDataPtr = _sprA02Table[_backgroundSpriteCurrentAnimation]; _backgroundSpriteLastFrame = READ_LE_UINT16(_backgroundSpriteDataPtr); @@ -2321,17 +2356,17 @@ void TuckerEngine::handleMap() { } } else { _locationMaskCounter = 0; - _selectedObject.xPos = _selectedObject.locationObject_toWalkX2; - _selectedObject.yPos = _selectedObject.locationObject_toWalkY2; + _selectedObject._xPos = _selectedObject._locationObjectToWalkX2; + _selectedObject._yPos = _selectedObject._locationObjectToWalkY2; _handleMapCounter = 1; - _panelLockedFlag = 1; + _panelLockedFlag = true; } return; } _locationMaskType = 2; _panelState = 0; setCursorType(0); - if (_selectedObject.locationObject_locationNum == 99) { + if (_selectedObject._locationObjectLocationNum == 99) { _noPositionChangeAfterMap = true; handleMapSequence(); return; @@ -2341,28 +2376,28 @@ void TuckerEngine::handleMap() { redrawScreen(_scrollOffset); _fadePaletteCounter = 34; } - _nextLocationNum = _selectedObject.locationObject_locationNum; - _xPosCurrent = _selectedObject.locationObject_toX; - _yPosCurrent = _selectedObject.locationObject_toY; - if (_selectedObject.locationObject_toX2 > 800) { - _backgroundSpriteCurrentAnimation = _selectedObject.locationObject_toX2 - 900; - if (_selectedObject.locationObject_toY2 > 499) { - _changeBackgroundSprite = 1; - _backgroundSprOffset = _selectedObject.locationObject_toY2 - 500; + _nextLocationNum = _selectedObject._locationObjectLocationNum; + _xPosCurrent = _selectedObject._locationObjectToX; + _yPosCurrent = _selectedObject._locationObjectToY; + if (_selectedObject._locationObjectToX2 > 800) { + _backgroundSpriteCurrentAnimation = _selectedObject._locationObjectToX2 - 900; + if (_selectedObject._locationObjectToY2 > 499) { + _changeBackgroundSprite = true; + _backgroundSprOffset = _selectedObject._locationObjectToY2 - 500; } else { - _changeBackgroundSprite = 0; - _backgroundSprOffset = _selectedObject.locationObject_toY2; + _changeBackgroundSprite = false; + _backgroundSprOffset = _selectedObject._locationObjectToY2; } _backgroundSpriteCurrentFrame = 0; } else { - _selectedObject.xPos = _selectedObject.locationObject_toX2; - _selectedObject.yPos = _selectedObject.locationObject_toY2; - _panelLockedFlag = 1; + _selectedObject._xPos = _selectedObject._locationObjectToX2; + _selectedObject._yPos = _selectedObject._locationObjectToY2; + _panelLockedFlag = true; } _scrollOffset = 0; _handleMapCounter = 0; _locationMaskCounter = 0; - _selectedObject.locationObject_locationNum = 0; + _selectedObject._locationObjectLocationNum = 0; } } } @@ -2370,79 +2405,79 @@ void TuckerEngine::handleMap() { void TuckerEngine::clearSprites() { memset(_spritesTable, 0, sizeof(_spritesTable)); for (int i = 0; i < kMaxCharacters; ++i) { - _spritesTable[i].state = -1; - _spritesTable[i].stateIndex = -1; + _spritesTable[i]._state = -1; + _spritesTable[i]._stateIndex = -1; } } void TuckerEngine::updateSprites() { const int count = (_locationNum == 9) ? 3 : _spritesCount; for (int i = 0; i < count; ++i) { - if (_spritesTable[i].stateIndex > -1) { - ++_spritesTable[i].stateIndex; - if (_characterStateTable[_spritesTable[i].stateIndex] == 99) { - _spritesTable[i].stateIndex = -1; - _spritesTable[i].state = -1; + if (_spritesTable[i]._stateIndex > -1) { + ++_spritesTable[i]._stateIndex; + if (_characterStateTable[_spritesTable[i]._stateIndex] == 99) { + _spritesTable[i]._stateIndex = -1; + _spritesTable[i]._state = -1; updateSprite(i); } else { - _spritesTable[i].animationFrame = _characterStateTable[_spritesTable[i].stateIndex]; + _spritesTable[i]._animationFrame = _characterStateTable[_spritesTable[i]._stateIndex]; } continue; } - if (_spritesTable[i].state == -1) { + if (_spritesTable[i]._state == -1) { updateSprite(i); continue; } - if (_charSpeechSoundCounter > 0 && i == _actionCharacterNum && _spritesTable[i].needUpdate == 0) { + if (_charSpeechSoundCounter > 0 && i == _actionCharacterNum && !_spritesTable[i]._needUpdate) { updateSprite(i); continue; } - if (_charSpeechSoundCounter == 0 && _spritesTable[i].needUpdate > 0) { + if (_charSpeechSoundCounter == 0 && _spritesTable[i]._needUpdate) { updateSprite(i); continue; } - if (_spritesTable[i].updateDelay > 0) { - --_spritesTable[i].updateDelay; - if (_spritesTable[i].updateDelay == 0) { + if (_spritesTable[i]._updateDelay > 0) { + --_spritesTable[i]._updateDelay; + if (_spritesTable[i]._updateDelay == 0) { updateSprite(i); } continue; } - if (_spritesTable[i].defaultUpdateDelay > 0) { - _spritesTable[i].updateDelay = _spritesTable[i].defaultUpdateDelay - 1; - ++_spritesTable[i].animationFrame; - if (_spritesTable[i].animationFrame == _spritesTable[i].firstFrame) { + if (_spritesTable[i]._defaultUpdateDelay > 0) { + _spritesTable[i]._updateDelay = _spritesTable[i]._defaultUpdateDelay - 1; + ++_spritesTable[i]._animationFrame; + if (_spritesTable[i]._animationFrame == _spritesTable[i]._firstFrame) { updateSprite(i); } continue; } - if (_spritesTable[i].nextAnimationFrame == 0) { - ++_spritesTable[i].animationFrame; - if (_spritesTable[i].firstFrame - 1 < _spritesTable[i].animationFrame) { - if (_spritesTable[i].prevAnimationFrame == 1) { - --_spritesTable[i].animationFrame; - _spritesTable[i].nextAnimationFrame = 1; + if (!_spritesTable[i]._nextAnimationFrame) { + ++_spritesTable[i]._animationFrame; + if (_spritesTable[i]._firstFrame - 1 < _spritesTable[i]._animationFrame) { + if (_spritesTable[i]._prevAnimationFrame) { + --_spritesTable[i]._animationFrame; + _spritesTable[i]._nextAnimationFrame = true; } else { updateSprite(i); } } continue; } - --_spritesTable[i].animationFrame; - if (_spritesTable[i].animationFrame == 0) { + --_spritesTable[i]._animationFrame; + if (_spritesTable[i]._animationFrame == 0) { updateSprite(i); } } } void TuckerEngine::updateSprite(int i) { - _spritesTable[i].prevState = _spritesTable[i].state; - _spritesTable[i].prevAnimationFrame = 0; - _spritesTable[i].nextAnimationFrame = 0; - _updateSpriteFlag1 = 0; - _updateSpriteFlag2 = 0; - _spritesTable[i].defaultUpdateDelay = 0; - _spritesTable[i].updateDelay = 0; + _spritesTable[i]._prevState = _spritesTable[i]._state; + _spritesTable[i]._prevAnimationFrame = false; + _spritesTable[i]._nextAnimationFrame = false; + _updateSpriteFlag1 = false; + _updateSpriteFlag2 = false; + _spritesTable[i]._defaultUpdateDelay = 0; + _spritesTable[i]._updateDelay = 0; switch (_locationNum) { case 2: updateSprite_locationNum2(); @@ -2632,7 +2667,7 @@ void TuckerEngine::updateSprite(int i) { if (i == 0) { updateSprite_locationNum32_0(0); } else { - _spritesTable[i].state = -1; + _spritesTable[i]._state = -1; } break; case 33: @@ -2643,7 +2678,7 @@ void TuckerEngine::updateSprite(int i) { } else if (i == 2) { updateSprite_locationNum33_2(2); } else { - _spritesTable[i].state = 12; + _spritesTable[i]._state = 12; } break; case 34: @@ -2654,7 +2689,7 @@ void TuckerEngine::updateSprite(int i) { break; case 37: if (i == 0) { - _spritesTable[0].state = -1; + _spritesTable[0]._state = -1; } else { updateSprite_locationNum37(i); } @@ -2670,9 +2705,9 @@ void TuckerEngine::updateSprite(int i) { updateSprite_locationNum43_2(i); } else if (i < 2) { if (_flagsTable[236] < 4) { - _spritesTable[i].state = i + 1; + _spritesTable[i]._state = i + 1; } else { - _spritesTable[i].state = -1; + _spritesTable[i]._state = -1; } } else if (i == 3) { updateSprite_locationNum43_3(3); @@ -2685,10 +2720,10 @@ void TuckerEngine::updateSprite(int i) { } break; case 45: - _spritesTable[0].state = 1; + _spritesTable[0]._state = 1; break; case 47: - _spritesTable[i].state = i + 1; + _spritesTable[i]._state = i + 1; break; case 48: updateSprite_locationNum48(0); @@ -2700,7 +2735,7 @@ void TuckerEngine::updateSprite(int i) { if (i < 6) { updateSprite_locationNum50(i); } else { - _spritesTable[i].state = i + 1; + _spritesTable[i]._state = i + 1; } break; case 51: @@ -2782,7 +2817,7 @@ void TuckerEngine::updateSprite(int i) { break; case 69: if (i == 0) { - _spritesTable[0].state = 1; + _spritesTable[0]._state = 1; } else if (i == 1) { updateSprite_locationNum69_1(1); } else if (i == 2) { @@ -2814,23 +2849,23 @@ void TuckerEngine::updateSprite(int i) { updateSprite_locationNum82(0); break; case 98: - _spritesTable[0].state = 1; + _spritesTable[0]._state = 1; break; } - if (_spritesTable[i].stateIndex <= -1) { - if (_updateSpriteFlag1 == 0) { - _spritesTable[i].animationFrame = 1; + if (_spritesTable[i]._stateIndex <= -1) { + if (!_updateSpriteFlag1) { + _spritesTable[i]._animationFrame = 1; } - if (_spritesTable[i].state < 0 || !_sprC02Table[_spritesTable[i].state]) { + 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) { - _spritesTable[i].state = _spritesTable[i].firstFrame; - _spritesTable[i].nextAnimationFrame = 1; - _spritesTable[i].prevAnimationFrame = 1; + _spritesTable[i]._animationData = _sprC02Table[_spritesTable[i]._state]; + _spritesTable[i]._firstFrame = READ_LE_UINT16(_spritesTable[i]._animationData); + if (_updateSpriteFlag2) { + _spritesTable[i]._state = _spritesTable[i]._firstFrame; + _spritesTable[i]._nextAnimationFrame = true; + _spritesTable[i]._prevAnimationFrame = true; } } } @@ -2844,7 +2879,7 @@ void TuckerEngine::drawStringInteger(int num, int x, int y, int digits) { Graphics::drawStringChar(_locationBackgroundGfxBuf, _scrollOffset + x, y, 640, numStr[i], 102, _charsetGfxBuf); x += 8; } - addDirtyRect(_scrollOffset + x, y, Graphics::_charset.charW * 3, Graphics::_charset.charH); + addDirtyRect(_scrollOffset + x, y, Graphics::_charset._charW * 3, Graphics::_charset._charH); } void TuckerEngine::drawStringAlt(int x, int y, int color, const uint8 *str, int strLen) { @@ -2856,7 +2891,7 @@ void TuckerEngine::drawStringAlt(int x, int y, int color, const uint8 *str, int x += _charWidthTable[chr]; ++pos; } - addDirtyRect(xStart, y, x - xStart, Graphics::_charset.charH); + addDirtyRect(xStart, y, x - xStart, Graphics::_charset._charH); } void TuckerEngine::drawItemString(int x, int num, const uint8 *str) { @@ -2911,15 +2946,15 @@ void TuckerEngine::updateItemsGfxColors(int color1, int color128) { } } -int TuckerEngine::testLocationMask(int x, int y) { - if (_locationMaskType > 0 || _locationMaskIgnore > 0) { - return 1; +bool TuckerEngine::testLocationMask(int x, int y) { + if (_locationMaskType > 0 || _locationMaskIgnore) { + return true; } if (_locationNum == 26 || _locationNum == 32) { y -= 3; } const int offset = y * 640 + x; - return _locationBackgroundMaskBuf[offset] > 0 ? 1 : 0; + return (_locationBackgroundMaskBuf[offset] > 0); } int TuckerEngine::getStringWidth(int num, const uint8 *ptr) { @@ -3096,7 +3131,7 @@ int TuckerEngine::readTableInstructionParam(int len) { ++_tableInstructionsPtr; --len; } - char *end = 0; + char *end = nullptr; const int param = strtol((const char *)_tableInstructionsPtr, &end, 10); if (end != (const char *)_tableInstructionsPtr + len) { warning("Unexpected instruction parameter length %d (%d)", (int)(end - (const char *)_tableInstructionsPtr), len); @@ -3123,7 +3158,7 @@ int TuckerEngine::executeTableInstruction() { return 0; case kCode_bub: i = readTableInstructionParam(3); - _spriteAnimationFrameIndex = _spriteAnimationsTable[i].firstFrameIndex; + _spriteAnimationFrameIndex = _spriteAnimationsTable[i]._firstFrameIndex; _characterFacingDirection = 5; _mainLoopCounter2 = 0; return 0; @@ -3137,13 +3172,13 @@ int TuckerEngine::executeTableInstruction() { _selectedCharacterDirection = readTableInstructionParam(2); return 0; case kCode_bof: - _skipCurrentCharacterDraw = 1; + _skipCurrentCharacterDraw = true; return 0; case kCode_buh: _noCharacterAnimationChange = readTableInstructionParam(2); return 0; case kCode_bon: - _skipCurrentCharacterDraw = 0; + _skipCurrentCharacterDraw = false; return 0; case kCode_bso: _backgroundSprOffset = readTableInstructionParam(3); @@ -3159,24 +3194,24 @@ int TuckerEngine::executeTableInstruction() { _charSpeechSoundCounter = kDefaultCharSpeechSoundCounter; return 0; case kCode_buw: - _selectedObject.xPos = readTableInstructionParam(3); - _selectedObject.yPos = readTableInstructionParam(3); - _locationMaskIgnore = 1; - _panelLockedFlag = 1; + _selectedObject._xPos = readTableInstructionParam(3); + _selectedObject._yPos = readTableInstructionParam(3); + _locationMaskIgnore = true; + _panelLockedFlag = true; return 0; case kCode_bux: _xPosCurrent = readTableInstructionParam(3); _yPosCurrent = readTableInstructionParam(3); return 0; case kCode_c0a: - _spritesTable[index].state = readTableInstructionParam(3); - if (_spritesTable[index].state == 999) { - _spritesTable[index].state = -1; + _spritesTable[index]._state = readTableInstructionParam(3); + if (_spritesTable[index]._state == 999) { + _spritesTable[index]._state = -1; } _mainLoopCounter1 = 0; - _spritesTable[index].updateDelay = 0; - _spritesTable[index].nextAnimationFrame = 0; - _spritesTable[index].prevAnimationFrame = 0; + _spritesTable[index]._updateDelay = 0; + _spritesTable[index]._nextAnimationFrame = false; + _spritesTable[index]._prevAnimationFrame = false; return 0; case kCode_c0c: setCharacterAnimation(readTableInstructionParam(3), index); @@ -3187,7 +3222,7 @@ int TuckerEngine::executeTableInstruction() { startSpeechSound(_partNum * 3000 + _ptTextOffset + _speechSoundNum - 3000, kMaxSoundVolume); _charSpeechSoundCounter = kDefaultCharSpeechSoundCounter; _actionTextColor = 181 + index; - if (_tableInstructionFlag == 0) { + if (!_tableInstructionFlag) { _actionPosX = _tableInstructionItemNum1; _actionPosY = _tableInstructionItemNum2; } else { @@ -3210,8 +3245,8 @@ int TuckerEngine::executeTableInstruction() { return 0; case kCode_flx: i = readTableInstructionParam(2); - _locationSoundsTable[i].type = 2; - startSound(_locationSoundsTable[i].offset, i, _locationSoundsTable[i].volume); + _locationSoundsTable[i]._type = 2; + startSound(_locationSoundsTable[i]._offset, i, _locationSoundsTable[i]._volume); return 0; case kCode_fxx: i = readTableInstructionParam(2); @@ -3221,7 +3256,7 @@ int TuckerEngine::executeTableInstruction() { return 0; case kCode_fx: i = readTableInstructionParam(2); - startSound(_locationSoundsTable[i].offset, i, _locationSoundsTable[i].volume); + startSound(_locationSoundsTable[i]._offset, i, _locationSoundsTable[i]._volume); _soundInstructionIndex = i; return 0; case kCode_gfg: @@ -3284,12 +3319,12 @@ int TuckerEngine::executeTableInstruction() { _csDataLoaded = false; return 3; case kCode_ssp: - _tableInstructionFlag = 0; + _tableInstructionFlag = false; _tableInstructionItemNum1 = readTableInstructionParam(3); _tableInstructionItemNum2 = readTableInstructionParam(3); return 0; case kCode_s0p: - _tableInstructionFlag = 1; + _tableInstructionFlag = true; _tableInstructionObj1Table[index] = readTableInstructionParam(3); _tableInstructionObj2Table[index] = readTableInstructionParam(3); return 0; @@ -3380,21 +3415,21 @@ int TuckerEngine::getObjectUnderCursor() { return -1; } for (int i = 0; i < _locationObjectsCount; ++i) { - if (_mousePosX + _scrollOffset + 1 <= _locationObjectsTable[i].xPos) { + if (_mousePosX + _scrollOffset + 1 <= _locationObjectsTable[i]._xPos) { continue; } - if (_mousePosX + _scrollOffset >= _locationObjectsTable[i].xPos + _locationObjectsTable[i].xSize) { + if (_mousePosX + _scrollOffset >= _locationObjectsTable[i]._xPos + _locationObjectsTable[i]._xSize) { continue; } - if (_mousePosY <= _locationObjectsTable[i].yPos) { + if (_mousePosY <= _locationObjectsTable[i]._yPos) { continue; } - if (_mousePosY >= _locationObjectsTable[i].yPos + _locationObjectsTable[i].ySize) { + if (_mousePosY >= _locationObjectsTable[i]._yPos + _locationObjectsTable[i]._ySize) { continue; } _selectedObjectType = 0; _selectedCharacterNum = i; - setCursorNum(_locationObjectsTable[i].cursorNum); + setCursorNum(_locationObjectsTable[i]._cursorNum); return i; } return -1; @@ -3405,127 +3440,127 @@ void TuckerEngine::setSelectedObjectKey() { if (_mousePosY > 139 && _nextAction == 0) { return; } - _panelLockedFlag = 1; + _panelLockedFlag = true; _locationMaskCounter = 0; _actionRequiresTwoObjects = false; - _selectedObject.yPos = 0; - _selectedObject.locationObject_locationNum = 0; + _selectedObject._yPos = 0; + _selectedObject._locationObjectLocationNum = 0; _pendingActionIndex = 0; if (_selectedObjectType == 0) { if (_selectedObjectNum == 0) { - _selectedObject.xPos = x; - _selectedObject.yPos = _mousePosY; + _selectedObject._xPos = x; + _selectedObject._yPos = _mousePosY; } else { - _selectedObject.xPos = _locationObjectsTable[_selectedCharacterNum].standX; - _selectedObject.yPos = _locationObjectsTable[_selectedCharacterNum].standY; + _selectedObject._xPos = _locationObjectsTable[_selectedCharacterNum]._standX; + _selectedObject._yPos = _locationObjectsTable[_selectedCharacterNum]._standY; if (_actionVerb == 0 || _actionVerb == 8) { - _selectedObject.locationObject_locationNum = _locationObjectsTable[_selectedCharacterNum].locationNum; - _selectedObject.locationObject_toX = _locationObjectsTable[_selectedCharacterNum].toX; - _selectedObject.locationObject_toY = _locationObjectsTable[_selectedCharacterNum].toY; - _selectedObject.locationObject_toX2 = _locationObjectsTable[_selectedCharacterNum].toX2; - _selectedObject.locationObject_toY2 = _locationObjectsTable[_selectedCharacterNum].toY2; - _selectedObject.locationObject_toWalkX2 = _locationObjectsTable[_selectedCharacterNum].toWalkX2; - _selectedObject.locationObject_toWalkY2 = _locationObjectsTable[_selectedCharacterNum].toWalkY2; + _selectedObject._locationObjectLocationNum = _locationObjectsTable[_selectedCharacterNum]._locationNum; + _selectedObject._locationObjectToX = _locationObjectsTable[_selectedCharacterNum]._toX; + _selectedObject._locationObjectToY = _locationObjectsTable[_selectedCharacterNum]._toY; + _selectedObject._locationObjectToX2 = _locationObjectsTable[_selectedCharacterNum]._toX2; + _selectedObject._locationObjectToY2 = _locationObjectsTable[_selectedCharacterNum]._toY2; + _selectedObject._locationObjectToWalkX2 = _locationObjectsTable[_selectedCharacterNum]._toWalkX2; + _selectedObject._locationObjectToWalkY2 = _locationObjectsTable[_selectedCharacterNum]._toWalkY2; } } } else { switch (_selectedObjectType) { case 1: - _selectedObject.xPos = _locationAnimationsTable[_selectedCharacterNum].standX; - _selectedObject.yPos = _locationAnimationsTable[_selectedCharacterNum].standY; + _selectedObject._xPos = _locationAnimationsTable[_selectedCharacterNum]._standX; + _selectedObject._yPos = _locationAnimationsTable[_selectedCharacterNum]._standY; break; case 2: - _selectedObject.xPos = _charPosTable[_selectedCharacterNum].xWalkTo; - _selectedObject.yPos = _charPosTable[_selectedCharacterNum].yWalkTo; + _selectedObject._xPos = _charPosTable[_selectedCharacterNum]._xWalkTo; + _selectedObject._yPos = _charPosTable[_selectedCharacterNum]._yWalkTo; break; case 3: - _selectedObject.xPos = _xPosCurrent; - _selectedObject.yPos = _yPosCurrent; + _selectedObject._xPos = _xPosCurrent; + _selectedObject._yPos = _yPosCurrent; break; } } - if (_selectedObject.yPos == 0) { - _selectedObject.xPos = x; - _selectedObject.yPos = _mousePosY; + if (_selectedObject._yPos == 0) { + _selectedObject._xPos = x; + _selectedObject._yPos = _mousePosY; } - _selectedObjectLocationMask = testLocationMask(_selectedObject.xPos, _selectedObject.yPos); - if (_selectedObjectLocationMask == 0 && _objectKeysLocationTable[_locationNum] == 1) { - if (_selectedObject.yPos < _objectKeysPosYTable[_locationNum]) { - while (_selectedObjectLocationMask == 0 && _selectedObject.yPos < _objectKeysPosYTable[_locationNum]) { - ++_selectedObject.yPos; - _selectedObjectLocationMask = testLocationMask(_selectedObject.xPos, _selectedObject.yPos); + _selectedObjectLocationMask = testLocationMask(_selectedObject._xPos, _selectedObject._yPos); + if (!_selectedObjectLocationMask && _objectKeysLocationTable[_locationNum] == 1) { + if (_selectedObject._yPos < _objectKeysPosYTable[_locationNum]) { + while (!_selectedObjectLocationMask && _selectedObject._yPos < _objectKeysPosYTable[_locationNum]) { + ++_selectedObject._yPos; + _selectedObjectLocationMask = testLocationMask(_selectedObject._xPos, _selectedObject._yPos); } } else { - while (_selectedObjectLocationMask == 0 && _selectedObject.yPos < _objectKeysPosYTable[_locationNum]) { - --_selectedObject.yPos; - _selectedObjectLocationMask = testLocationMask(_selectedObject.xPos, _selectedObject.yPos); + while (!_selectedObjectLocationMask && _selectedObject._yPos < _objectKeysPosYTable[_locationNum]) { + --_selectedObject._yPos; + _selectedObjectLocationMask = testLocationMask(_selectedObject._xPos, _selectedObject._yPos); } } } - if (_selectedObjectLocationMask == 1) { - _selectedObjectLocationMask = testLocationMaskArea(_xPosCurrent, _yPosCurrent, _selectedObject.xPos, _selectedObject.yPos); - if (_selectedObjectLocationMask == 1 && _objectKeysPosXTable[_locationNum] > 0) { - _selectedObject.xDefaultPos = _selectedObject.xPos; - _selectedObject.yDefaultPos = _selectedObject.yPos; - _selectedObject.xPos = _objectKeysPosXTable[_locationNum]; - _selectedObject.yPos = _objectKeysPosYTable[_locationNum]; + if (_selectedObjectLocationMask) { + _selectedObjectLocationMask = testLocationMaskArea(_xPosCurrent, _yPosCurrent, _selectedObject._xPos, _selectedObject._yPos); + if (_selectedObjectLocationMask && _objectKeysPosXTable[_locationNum] > 0) { + _selectedObject._xDefaultPos = _selectedObject._xPos; + _selectedObject._yDefaultPos = _selectedObject._yPos; + _selectedObject._xPos = _objectKeysPosXTable[_locationNum]; + _selectedObject._yPos = _objectKeysPosYTable[_locationNum]; if (_objectKeysLocationTable[_locationNum] == 1) { - _selectedObject.xPos = _selectedObject.xDefaultPos; + _selectedObject._xPos = _selectedObject._xDefaultPos; } } } } void TuckerEngine::setCharacterAnimation(int count, int spr) { - _spritesTable[spr].animationFrame = 0; - _spritesTable[spr].stateIndex = 0; + _spritesTable[spr]._animationFrame = 0; + _spritesTable[spr]._stateIndex = 0; for (int i = 0; i < count; ++i) { - while (_characterStateTable[_spritesTable[spr].stateIndex] != 99) { - ++_spritesTable[spr].stateIndex; + while (_characterStateTable[_spritesTable[spr]._stateIndex] != 99) { + ++_spritesTable[spr]._stateIndex; } - ++_spritesTable[spr].stateIndex; + ++_spritesTable[spr]._stateIndex; } - _spritesTable[spr].state = _characterStateTable[_spritesTable[spr].stateIndex]; - ++_spritesTable[spr].stateIndex; - _spritesTable[spr].animationFrame = _characterStateTable[_spritesTable[spr].stateIndex]; - ++_spritesTable[spr].stateIndex; - _spritesTable[spr].animationData = _sprC02Table[_spritesTable[spr].state]; - _spritesTable[spr].firstFrame = READ_LE_UINT16(_spritesTable[spr].animationData); + _spritesTable[spr]._state = _characterStateTable[_spritesTable[spr]._stateIndex]; + ++_spritesTable[spr]._stateIndex; + _spritesTable[spr]._animationFrame = _characterStateTable[_spritesTable[spr]._stateIndex]; + ++_spritesTable[spr]._stateIndex; + _spritesTable[spr]._animationData = _sprC02Table[_spritesTable[spr]._state]; + _spritesTable[spr]._firstFrame = READ_LE_UINT16(_spritesTable[spr]._animationData); } -int TuckerEngine::testLocationMaskArea(int xBase, int yBase, int xPos, int yPos) { +bool TuckerEngine::testLocationMaskArea(int xBase, int yBase, int xPos, int yPos) { while (true) { bool loop = false; if (yBase > yPos) { - if (testLocationMask(xBase, yBase - 1) == 1) { + if (testLocationMask(xBase, yBase - 1)) { --yBase; loop = true; } } else if (yBase < yPos) { - if (testLocationMask(xBase, yBase + 1) == 1) { + if (testLocationMask(xBase, yBase + 1)) { ++yBase; loop = true; } } if (xBase > xPos) { - if (testLocationMask(xBase - 1, yBase) == 1) { + if (testLocationMask(xBase - 1, yBase)) { --xBase; loop = true; } } else if (xBase < xPos) { - if (testLocationMask(xBase + 1, yBase) == 1) { + if (testLocationMask(xBase + 1, yBase)) { ++xBase; loop = true; } } if (xBase == xPos && yBase == yPos) { - return 0; + return false; } if (!loop) { break; } } - return 1; + return true; } void TuckerEngine::handleMouseClickOnInventoryObject() { @@ -3548,7 +3583,7 @@ void TuckerEngine::handleMouseClickOnInventoryObject() { _selectedObjectType = 0; _selectedObjectNum = 0; _actionVerb = 0; - _actionVerbLocked = 0; + _actionVerbLocked = false; _forceRedrawPanelItems = true; _panelState = 2; setCursorType(1); @@ -3573,7 +3608,7 @@ void TuckerEngine::handleMouseClickOnInventoryObject() { _actionVerb = 0; _selectedObjectType = 0; _selectedObjectNum = 0; - _actionVerbLocked = 0; + _actionVerbLocked = false; } } break; @@ -3585,23 +3620,23 @@ int TuckerEngine::setCharacterUnderCursor() { return -1; } for (int i = 0; i < _charPosCount; ++i) { - if (_mousePosX + _scrollOffset <= _charPosTable[i].xPos) { + if (_mousePosX + _scrollOffset <= _charPosTable[i]._xPos) { continue; } - if (_mousePosX + _scrollOffset >= _charPosTable[i].xPos + _charPosTable[i].xSize) { + if (_mousePosX + _scrollOffset >= _charPosTable[i]._xPos + _charPosTable[i]._xSize) { continue; } - if (_mousePosY <= _charPosTable[i].yPos) { + if (_mousePosY <= _charPosTable[i]._yPos) { continue; } - if (_mousePosY >= _charPosTable[i].yPos + _charPosTable[i].ySize) { + if (_mousePosY >= _charPosTable[i]._yPos + _charPosTable[i]._ySize) { continue; } - if (_charPosTable[i].flagNum == 0 || _flagsTable[_charPosTable[i].flagNum] == _charPosTable[i].flagValue) { + if (_charPosTable[i]._flagNum == 0 || _flagsTable[_charPosTable[i]._flagNum] == _charPosTable[i]._flagValue) { _selectedObjectType = 2; - _selectedCharacterDirection = _charPosTable[i].direction; + _selectedCharacterDirection = _charPosTable[i]._direction; _selectedCharacterNum = i; - return _charPosTable[i].name; + return _charPosTable[i]._name; } } return -1; @@ -3612,29 +3647,29 @@ int TuckerEngine::setLocationAnimationUnderCursor() { return -1; } for (int i = _locationAnimationsCount - 1; i >= 0; --i) { - if (_locationAnimationsTable[i].drawFlag == 0) { + if (!_locationAnimationsTable[i]._drawFlag) continue; - } - int num = _locationAnimationsTable[i].graphicNum; - if (_mousePosX + _scrollOffset + 1 <= _dataTable[num].xDest) { + + int num = _locationAnimationsTable[i]._graphicNum; + if (_mousePosX + _scrollOffset + 1 <= _dataTable[num]._xDest) { continue; } - if (_mousePosX + _scrollOffset >= _dataTable[num].xDest + _dataTable[num].xSize) { + if (_mousePosX + _scrollOffset >= _dataTable[num]._xDest + _dataTable[num]._xSize) { continue; } - if (_mousePosY <= _dataTable[num].yDest) { + if (_mousePosY <= _dataTable[num]._yDest) { continue; } - if (_mousePosY >= _dataTable[num].yDest + _dataTable[num].ySize) { + if (_mousePosY >= _dataTable[num]._yDest + _dataTable[num]._ySize) { continue; } - if (_locationAnimationsTable[i].selectable == 0) { + if (_locationAnimationsTable[i]._selectable == 0) { return -1; } _selectedObjectType = 1; _selectedCharacterNum = i; _selectedCharacter2Num = i; - return _locationAnimationsTable[i].selectable; + return _locationAnimationsTable[i]._selectable; } return -1; } @@ -3642,14 +3677,14 @@ int TuckerEngine::setLocationAnimationUnderCursor() { void TuckerEngine::setActionForInventoryObject() { if (_actionVerb == 0 || _actionVerb == 2 || _actionVerb == 6 || _actionVerb == 7) { playSpeechForAction(_actionVerb); - _actionVerbLocked = 0; + _actionVerbLocked = false; _actionRequiresTwoObjects = false; return; } if (_actionVerb == 3 || _actionVerb == 4) { if (!(_partNum == 2 && _selectedObjectNum == 19) && !(_partNum == 3 && _selectedObjectNum == 42)) { playSpeechForAction(_actionVerb); - _actionVerbLocked = 0; + _actionVerbLocked = false; _actionRequiresTwoObjects = false; return; } @@ -3659,13 +3694,13 @@ void TuckerEngine::setActionForInventoryObject() { _currentActionObj2Num = _actionObj2Num; _currentInfoString2SourceType = _actionObj2Type; if (_actionVerb == 1 && _selectedObjectType == 3) { - if (_panelLockedFlag == 1) { + if (_panelLockedFlag) { if (_locationMaskType != 0) { return; } - _panelLockedFlag = 0; + _panelLockedFlag = false; } - if (handleSpecialObjectSelectionSequence() == 1) { + if (handleSpecialObjectSelectionSequence()) { return; } _speechSoundNum = _actionObj1Num + _speechSoundBaseNum; @@ -3678,14 +3713,15 @@ void TuckerEngine::setActionForInventoryObject() { _actionCharacterNum = 99; setCursorType(2); _charSpeechSoundCounter = kDefaultCharSpeechSoundCounter; - _actionVerbLocked = 0; + _actionVerbLocked = false; _actionRequiresTwoObjects = false; return; } - if ((_partNum == 3 && (_actionObj1Num == 6 || _actionObj1Num == 3 || _actionObj1Num == 17)) || + // Items with unary usage i.e. "Use X", rather than "Use X on Y" + if ((_partNum == 3 && (_actionObj1Num == 6 || _actionObj1Num == 3 || _actionObj1Num == 17 || _actionObj1Num == 33)) || (_partNum == 2 && _actionObj1Num == 19) || (_partNum == 3 && (_actionObj1Num == 42 && _selectedObjectNum == 18)) ) { - _actionVerbLocked = 0; + _actionVerbLocked = false; _actionRequiresTwoObjects = false; _locationMaskCounter = 1; setActionState(); @@ -3694,7 +3730,7 @@ void TuckerEngine::setActionForInventoryObject() { if (!_actionRequiresTwoObjects) { _actionRequiresTwoObjects = true; } else { - _actionVerbLocked = 0; + _actionVerbLocked = false; _actionRequiresTwoObjects = false; _locationMaskCounter = 1; setActionState(); @@ -3754,12 +3790,12 @@ void TuckerEngine::drawSpeechText(int xStart, int y, const uint8 *dataPtr, int n } } int count = 0; - int flag = 0; + bool flag = false; struct { int w, count, offset; } lines[5]; lines[0].offset = getPositionForLine(num, dataPtr); - while (flag == 0 && count < 4) { + while (!flag && count < 4) { int lineCharsCount, lineWidth; flag = splitSpeechTextLines(dataPtr, lines[count].offset, x, lineCharsCount, lineWidth); lines[count].w = lineWidth; @@ -3788,7 +3824,7 @@ void TuckerEngine::drawSpeechText(int xStart, int y, const uint8 *dataPtr, int n } } -int TuckerEngine::splitSpeechTextLines(const uint8 *dataPtr, int pos, int x, int &lineCharsCount, int &lineWidth) { +bool TuckerEngine::splitSpeechTextLines(const uint8 *dataPtr, int pos, int x, int &lineCharsCount, int &lineWidth) { int count = 0; int w = 0; lineCharsCount = 0; @@ -3802,11 +3838,11 @@ int TuckerEngine::splitSpeechTextLines(const uint8 *dataPtr, int pos, int x, int ++count; ++pos; } - int ret = 0; + bool ret = false; if (x + 1 > w) { lineCharsCount = count; lineWidth = w; - ret = 1; + ret = true; } return ret; } @@ -3818,7 +3854,7 @@ void TuckerEngine::drawSpeechTextLine(const uint8 *dataPtr, int pos, int count, x += _charWidthTable[dataPtr[pos]]; ++pos; } - addDirtyRect(xStart, y, x - xStart, Graphics::_charset.charH); + addDirtyRect(xStart, y, x - xStart, Graphics::_charset._charH); } void TuckerEngine::redrawScreen(int offset) { |