diff options
author | Florian Kagerer | 2009-03-08 02:17:14 +0000 |
---|---|---|
committer | Florian Kagerer | 2009-03-08 02:17:14 +0000 |
commit | e23fd08dfbdac9d6eedb78813d3504eeccba31a5 (patch) | |
tree | ba0a0c81477f8327a2b8275e27cf17fecc12b3da /engines/kyra | |
parent | cc89a46a0ef8b9bd62e69ab0d6a8c1e28bc46781 (diff) | |
download | scummvm-rg350-e23fd08dfbdac9d6eedb78813d3504eeccba31a5.tar.gz scummvm-rg350-e23fd08dfbdac9d6eedb78813d3504eeccba31a5.tar.bz2 scummvm-rg350-e23fd08dfbdac9d6eedb78813d3504eeccba31a5.zip |
LOL: fixed bug reported by MD5 (crashes and freezes caused by calls to non-existent sub scripts)
svn-id: r39209
Diffstat (limited to 'engines/kyra')
-rw-r--r-- | engines/kyra/gui_lol.cpp | 14 | ||||
-rw-r--r-- | engines/kyra/items_lol.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/lol.cpp | 36 | ||||
-rw-r--r-- | engines/kyra/lol.h | 9 | ||||
-rw-r--r-- | engines/kyra/scene_lol.cpp | 20 | ||||
-rw-r--r-- | engines/kyra/screen_lol.cpp | 23 | ||||
-rw-r--r-- | engines/kyra/screen_lol.h | 3 | ||||
-rw-r--r-- | engines/kyra/script_lol.cpp | 27 | ||||
-rw-r--r-- | engines/kyra/sprites_lol.cpp | 16 | ||||
-rw-r--r-- | engines/kyra/timer.cpp | 13 | ||||
-rw-r--r-- | engines/kyra/timer_lol.cpp | 2 |
11 files changed, 91 insertions, 74 deletions
diff --git a/engines/kyra/gui_lol.cpp b/engines/kyra/gui_lol.cpp index 68cd379d5c..a70935e43d 100644 --- a/engines/kyra/gui_lol.cpp +++ b/engines/kyra/gui_lol.cpp @@ -34,26 +34,26 @@ namespace Kyra { void LoLEngine::gui_drawPlayField() { _screen->loadBitmap("PLAYFLD.CPS", 3, 3, 0); - if (_screen->_drawGuiFlag & 0x4000) { + if (_gameFlags[15] & 0x4000) { // copy compass shape static const int cx[] = { 112, 152, 224 }; _screen->copyRegion(cx[_lang], 32, 288, 0, 32, 32, 2, 2, Screen::CR_NO_P_CHECK); _compassDirection = -1; } - if (_screen->_drawGuiFlag & 0x1000) + if (_gameFlags[15] & 0x1000) // draw automap book _screen->drawShape(2, _gameShapes[78], 289, 32, 0, 0); int cp = _screen->setCurPage(2); - if (_screen->_drawGuiFlag & 0x2000) { + if (_gameFlags[15] & 0x2000) { gui_drawScroll(); } else { _selectedSpell = 0; } - if (_screen->_drawGuiFlag & 0x800) + if (_gameFlags[15] & 0x800) resetLampStatus(); gui_drawScene(2); @@ -537,7 +537,7 @@ void LoLEngine::gui_drawMoneyBox(int pageNum) { } void LoLEngine::gui_drawCompass() { - if (!(_screen->_drawGuiFlag & 0x4000)) + if (!(_gameFlags[15] & 0x4000)) return; if (_compassDirection == -1) { @@ -595,7 +595,7 @@ void LoLEngine::gui_toggleButtonDisplayMode(int shapeIndex, int mode) { static const int16 buttonX[] = { 0x0056, 0x0128, 0x000C, 0x0021, 0x0122, 0x000C, 0x0021, 0x0036, 0x000C, 0x0021, 0x0036 }; static const int16 buttonY[] = { 0x00B4, 0x00B4, 0x00B4, 0x00B4, 0x0020, 0x0084, 0x0084, 0x0084, 0x0096, 0x0096, 0x0096 }; - if (shapeIndex == 78 && !(_screen->_drawGuiFlag & 0x1000)) + if (shapeIndex == 78 && !(_gameFlags[15] & 0x1000)) return; if (_hideControls && _hideInventory) @@ -808,7 +808,7 @@ void LoLEngine::gui_enableDefaultPlayfieldButtons() { gui_initCharacterControlButtons(29, 0); gui_initCharacterControlButtons(25, 33); - if (_screen->_drawGuiFlag & 0x2000) + if (_gameFlags[15] & 0x2000) gui_initMagicScrollButtons(); } diff --git a/engines/kyra/items_lol.cpp b/engines/kyra/items_lol.cpp index 7faee163e1..5eb0214ac6 100644 --- a/engines/kyra/items_lol.cpp +++ b/engines/kyra/items_lol.cpp @@ -220,7 +220,7 @@ void LoLEngine::setHandItem(uint16 itemIndex) { int mouseOffs = 0; - if (itemIndex && !(_screen->_drawGuiFlag & 0x200)) { + if (itemIndex && !(_gameFlags[15] & 0x200)) { mouseOffs = 10; if (!_hideControls || textEnabled()) _txt->printMessage(0, getLangString(0x403E), getLangString(_itemProperties[_itemsInPlay[itemIndex].itemPropertyIndex].nameStringId)); diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp index f71e141ce6..e1df23e6ce 100644 --- a/engines/kyra/lol.cpp +++ b/engines/kyra/lol.cpp @@ -150,7 +150,7 @@ LoLEngine::LoLEngine(OSystem *system, const GameFlags &flags) : KyraEngine_v1(sy _monsters = 0; _unkGameFlag = 0; _lastMouseRegion = 0; - _monsterUnkDir = _monsterCountUnk = _monsterShiftAlt = 0; + _monsterLastWalkDirection = _monsterCountUnk = _monsterShiftAlt = 0; _monsterCurBlock = 0; //_preSeq_X1 = _preSeq_Y1 = _preSeq_X2 = _preSeq_Y2 = 0; @@ -413,7 +413,7 @@ Common::Error LoLEngine::init() { _tmpData136 = new uint8[136]; memset(_tmpData136, 0, 136); - memset(_gameFlags, 0, 15 * sizeof(uint16)); + memset(_gameFlags, 0, 16 * sizeof(uint16)); memset(_unkEMC46, 0, 16 * sizeof(uint16)); _levelFileData = 0; @@ -568,7 +568,7 @@ void LoLEngine::loadItemIconShapes() { } void LoLEngine::setMouseCursorToIcon(int icon) { - _screen->_drawGuiFlag |= 0x200; + _gameFlags[15] |= 0x200; int i = _itemProperties[_itemsInPlay[_itemInHand].itemPropertyIndex].shpIndex; if (i == icon) return; @@ -576,7 +576,7 @@ void LoLEngine::setMouseCursorToIcon(int icon) { } void LoLEngine::setMouseCursorToItemInHand() { - _screen->_drawGuiFlag &= 0xFDFF; + _gameFlags[15] &= 0xFDFF; int o = (_itemInHand == 0) ? 0 : 10; _screen->setMouseCursor(o, o, getItemIconShapePtr(_itemInHand)); } @@ -794,10 +794,10 @@ void LoLEngine::update() { if (_updateCharNum != -1 && _system->getMillis() > _updatePortraitNext) updatePortraitSpeechAnim(); - if (_screen->_drawGuiFlag & 0x800 || !(_updateFlags & 4)) + if (_gameFlags[15] & 0x800 || !(_updateFlags & 4)) updateLampStatus(); - if (_screen->_drawGuiFlag & 0x4000 && !(_updateFlags & 4) && (_compassDirection == -1 || (_currentDirection << 6) != _compassDirection || _compassUnk)) + if (_gameFlags[15] & 0x4000 && !(_updateFlags & 4) && (_compassDirection == -1 || (_currentDirection << 6) != _compassDirection || _compassUnk)) updateCompass(); snd_characterSpeaking(); @@ -1156,7 +1156,7 @@ void LoLEngine::restoreSceneAfterDialogueSequence(int redraw) { if (_screen->_fadeFlag != 2) _screen->fadeClearSceneWindow(10); gui_drawPlayField(); - _screen->setPaletteBrightness(_screen->_currentPalette, _brightness, _lampOilStatus); + setPaletteBrightness(_screen->_currentPalette, _brightness, _lampOilStatus); _screen->_fadeFlag = 0; } @@ -1189,6 +1189,28 @@ void LoLEngine::fadeText() { _fadeText = false; } +void LoLEngine::setPaletteBrightness(uint8 *palette, int brightness, int modifier) { + generateBrightnessPalette(palette, _screen->getPalette(1), brightness, modifier); + _screen->fadePalette(_screen->getPalette(1), 5, 0); + _screen->_fadeFlag = 0; +} + +void LoLEngine::generateBrightnessPalette(uint8 *src, uint8 *dst, int brightness, int modifier) { + memcpy(dst, src, 0x300); + _screen->loadSpecialColours(dst); + brightness = (8 - brightness) << 5; + if (modifier >= 0 && modifier < 8 && _gameFlags[15] & 0x800) { + brightness = 256 - ((((modifier & 0xfffe) << 5) * (256 - brightness)) >> 8); + if (brightness < 0) + brightness = 0; + } + + for (int i = 0; i < 384; i++) { + uint16 c = (dst[i] * brightness) >> 8; + dst[i] = c & 0xff; + } +} + void LoLEngine::updateWsaAnimations() { if (_updateFlags & 8) return; diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h index 4a6ac70bb1..3ffdf736f6 100644 --- a/engines/kyra/lol.h +++ b/engines/kyra/lol.h @@ -493,11 +493,12 @@ private: uint16 _currentBlock; bool _sceneUpdateRequired; int16 _currentBlockPropertyIndex[18]; - uint16 _gameFlags[15]; + uint16 _gameFlags[16]; uint16 _unkEMC46[16]; // emc opcode int olol_drawScene(EMCState *script); + int olol_delay(EMCState *script); int olol_setGameFlag(EMCState *script); int olol_testGameFlag(EMCState *script); int olol_loadLevelGraphics(EMCState *script); @@ -522,6 +523,7 @@ private: int olol_setUnkArrayVal(EMCState *script); int olol_getGlobalVar(EMCState *script); int olol_setGlobalVar(EMCState *script); + int olol_triggerDoorSwitch(EMCState *script); int olol_mapShapeToBlock(EMCState *script); int olol_resetBlockShapeAssignment(EMCState *script); int olol_initMonster(EMCState *script); @@ -538,6 +540,7 @@ private: int olol_loadLangFile(EMCState *script); int olol_playSoundEffect(EMCState *script); int olol_stopTimScript(EMCState *script); + int olol_getWallFlags(EMCState *script); int olol_playCharacterScriptChat(EMCState *script); int olol_loadSoundFile(EMCState *script); int olol_stopCharacterSpeech(EMCState *script); @@ -598,6 +601,8 @@ private: void resetPortraitsArea(); void toggleSelectedCharacterFrame(bool mode); void fadeText(); + void setPaletteBrightness(uint8 *palette, int brightness, int modifier); + void generateBrightnessPalette(uint8 *src, uint8 *dst, int brightness, int modifier); void updateWsaAnimations(); uint8 **_itemIconShapes; @@ -971,7 +976,7 @@ private: uint8 **_monsterShapesEx; uint8 _monsterUnk[3]; uint16 _monsterCurBlock; - int _monsterUnkDir; + int _monsterLastWalkDirection; int _monsterCountUnk; int _monsterShiftAlt; diff --git a/engines/kyra/scene_lol.cpp b/engines/kyra/scene_lol.cpp index c7591a3e1c..3525a5a0df 100644 --- a/engines/kyra/scene_lol.cpp +++ b/engines/kyra/scene_lol.cpp @@ -94,7 +94,7 @@ void LoLEngine::loadLevel(int index) { gui_drawPlayField(); - _screen->setPaletteBrightness(_screen->_currentPalette, _brightness, _lampOilStatus); + setPaletteBrightness(_screen->_currentPalette, _brightness, _lampOilStatus); setMouseCursorToItemInHand(); snd_playTrack(_curMusicTheme); @@ -440,7 +440,7 @@ void LoLEngine::loadLevelGraphics(const char *file, int specialColor, int weight _screen->getLevelOverlay(7)[i] = i & 0xff; _loadSuppFilesFlag = 0; - _screen->generateBrightnessPalette(_screen->_currentPalette, _screen->getPalette(1), _brightness, _lampOilStatus); + generateBrightnessPalette(_screen->_currentPalette, _screen->getPalette(1), _brightness, _lampOilStatus); char tname[13]; snprintf(tname, sizeof(tname), "LEVEL%.02d.TLC", _currentLevel); @@ -522,14 +522,14 @@ bool LoLEngine::testWallInvisibility(int block, int direction) { } void LoLEngine::resetLampStatus() { - _screen->_drawGuiFlag |= 0x400; + _gameFlags[15] |= 0x400; _lampOilStatus = 255; updateLampStatus(); } void LoLEngine::setLampMode(bool lampOn) { - _screen->_drawGuiFlag &= 0xFBFF; - if (!(_screen->_drawGuiFlag & 0x800) || !lampOn) + _gameFlags[15] &= 0xFBFF; + if (!(_gameFlags[15] & 0x800) || !lampOn) return; _screen->drawShape(0, _gameShapes[43], 291, 56, 0, 0); @@ -540,20 +540,20 @@ void LoLEngine::updateLampStatus() { uint8 newLampOilStatus = 0; uint8 tmp2 = 0; - if ((_updateFlags & 4) || !(_screen->_drawGuiFlag & 0x800)) + if ((_updateFlags & 4) || !(_gameFlags[15] & 0x800)) return; if (!_brightness || !_lampStatusUnk) { newLampOilStatus = 8; if (newLampOilStatus != _lampOilStatus && _screen->_fadeFlag == 0) - _screen->setPaletteBrightness(_screen->_currentPalette, _lampOilStatus, newLampOilStatus); + setPaletteBrightness(_screen->_currentPalette, _lampOilStatus, newLampOilStatus); } else { tmp2 = (_lampStatusUnk < 100) ? _lampStatusUnk : 100; newLampOilStatus = (3 - (tmp2 - 1) / 25) << 1; if (_lampOilStatus == 255) { if (_screen->_fadeFlag == 0) - _screen->setPaletteBrightness(_screen->_currentPalette, _brightness, newLampOilStatus); + setPaletteBrightness(_screen->_currentPalette, _brightness, newLampOilStatus); _lampStatusTimer = _system->getMillis() + (10 + _rnd.getRandomNumberRng(1, 30)) * _tickLength; } else { if ((_lampOilStatus & 0xfe) == (newLampOilStatus & 0xfe)) { @@ -565,7 +565,7 @@ void LoLEngine::updateLampStatus() { } } else { if (_screen->_fadeFlag == 0) - _screen->setPaletteBrightness(_screen->_currentPalette, _lampOilStatus, newLampOilStatus); + setPaletteBrightness(_screen->_currentPalette, _lampOilStatus, newLampOilStatus); } } } @@ -1104,7 +1104,7 @@ int LoLEngine::smoothScrollDrawSpecialShape(int pageNum) { } void LoLEngine::setLF2(int block) { - if (!(_screen->_drawGuiFlag & 0x1000)) + if (!(_gameFlags[15] & 0x1000)) return; _levelBlockProperties[block].flags |= 7; // TODO diff --git a/engines/kyra/screen_lol.cpp b/engines/kyra/screen_lol.cpp index 19f2d16d8b..615dd0c4b3 100644 --- a/engines/kyra/screen_lol.cpp +++ b/engines/kyra/screen_lol.cpp @@ -45,7 +45,6 @@ Screen_LoL::Screen_LoL(LoLEngine *vm, OSystem *system) : Screen_v2(vm, system), _levelOverlays[i] = new uint8[256]; _fadeFlag = 2; - _drawGuiFlag = 0; _curDimIndex = 0; _dimLineCount = 0; } @@ -535,28 +534,6 @@ void Screen_LoL::fadeToBlack(int delay, const UpdateFunctor *upFunc) { _fadeFlag = 2; } -void Screen_LoL::setPaletteBrightness(uint8 *palette, int brightness, int modifier) { - generateBrightnessPalette(palette, getPalette(1), brightness, modifier); - fadePalette(getPalette(1), 5, 0); - _fadeFlag = 0; -} - -void Screen_LoL::generateBrightnessPalette(uint8 *src, uint8 *dst, int brightness, int modifier) { - memcpy(dst, src, 0x300); - loadSpecialColours(dst); - brightness = (8 - brightness) << 5; - if (modifier >= 0 && modifier < 8 && _drawGuiFlag & 0x800) { - brightness = 256 - ((((modifier & 0xfffe) << 5) * (256 - brightness)) >> 8); - if (brightness < 0) - brightness = 0; - } - - for (int i = 0; i < 384; i++) { - uint16 c = (dst[i] * brightness) >> 8; - dst[i] = c & 0xff; - } -} - void Screen_LoL::loadSpecialColours(uint8 *destPalette) { memcpy(destPalette + 0x240, _screenPalette + 0x240, 12); } diff --git a/engines/kyra/screen_lol.h b/engines/kyra/screen_lol.h index 58267312e5..1b1842bffc 100644 --- a/engines/kyra/screen_lol.h +++ b/engines/kyra/screen_lol.h @@ -64,8 +64,6 @@ public: // palette stuff void fadeToBlack(int delay=0x54, const UpdateFunctor *upFunc = 0); - void setPaletteBrightness(uint8 *palDst, int brightness, int modifier); - void generateBrightnessPalette(uint8 *palSrc, uint8 *palDst, int brightness, int modifier); void loadSpecialColours(uint8 *destPalette); void copyColour(int dstColourIndex, int srcColourIndex); bool fadeColour(int dstColourIndex, int srcColourIndex, uint32 elapsedTime, uint32 targetTime); @@ -80,7 +78,6 @@ public: uint8 *_paletteOverlay2; uint8 *_grayOverlay; int _fadeFlag; - int _drawGuiFlag; int _dimLineCount; private: diff --git a/engines/kyra/script_lol.cpp b/engines/kyra/script_lol.cpp index dcda6feb0b..670c652f01 100644 --- a/engines/kyra/script_lol.cpp +++ b/engines/kyra/script_lol.cpp @@ -118,6 +118,12 @@ int LoLEngine::olol_drawScene(EMCState *script) { return 1; } +int LoLEngine::olol_delay(EMCState *script) { + debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_delay(%p) (%d)", (const void *)script, stackPos(0)); + delay(stackPos(0) * _tickLength); + return 1; +} + int LoLEngine::olol_setGameFlag(EMCState *script) { debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_setGameFlag(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); if (stackPos(1)) @@ -566,6 +572,12 @@ int LoLEngine::olol_setGlobalVar(EMCState *script) { return 1; } +int LoLEngine::olol_triggerDoorSwitch(EMCState *script) { + debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_triggerDoorSwitch(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + processDoorSwitch(stackPos(0)/*, (_wllWallFlags[_levelBlockProperties[stackPos(0)].walls[0]] & 8) ? 0 : 1*/, stackPos(1)); + return 1; +} + int LoLEngine::olol_mapShapeToBlock(EMCState *script) { debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_mapShapeToBlock(%p) (%d)", (const void *)script, stackPos(0)); return assignLevelShapes(stackPos(0)); @@ -787,6 +799,11 @@ int LoLEngine::olol_stopTimScript(EMCState *script) { return 1; } +int LoLEngine::olol_getWallFlags(EMCState *script) { + debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_getWallFlags(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + return _wllWallFlags[_levelBlockProperties[stackPos(0)].walls[stackPos(1) & 3]]; +} + int LoLEngine::olol_playCharacterScriptChat(EMCState *script) { debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_playCharacterScriptChat(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); snd_stopSpeech(1); @@ -812,7 +829,7 @@ int LoLEngine::olol_setPaletteBrightness(EMCState *script) { uint16 old = _brightness; _brightness = stackPos(0); if (stackPos(1) == 1) - _screen->setPaletteBrightness(_screen->_currentPalette, stackPos(0), _lampOilStatus); + setPaletteBrightness(_screen->_currentPalette, stackPos(0), _lampOilStatus); return old; } @@ -1014,7 +1031,7 @@ int LoLEngine::tlol_fadeClearWindow(const TIM *tim, const uint16 *param) { if (_screen->_fadeFlag != 2) _screen->fadeClearSceneWindow(10); gui_drawPlayField(); - _screen->setPaletteBrightness(_screen->_currentPalette, _brightness, _lampOilStatus); + setPaletteBrightness(_screen->_currentPalette, _brightness, _lampOilStatus); _screen->_fadeFlag = 0; break; @@ -1088,7 +1105,7 @@ void LoLEngine::setupOpcodeTable() { // 0x04 OpcodeUnImpl(); OpcodeUnImpl(); - OpcodeUnImpl(); + Opcode(olol_delay); Opcode(olol_setGameFlag); // 0x08 @@ -1153,7 +1170,7 @@ void LoLEngine::setupOpcodeTable() { // 0x30 Opcode(olol_setGlobalVar); - OpcodeUnImpl(); + Opcode(olol_triggerDoorSwitch); OpcodeUnImpl(); OpcodeUnImpl(); @@ -1214,7 +1231,7 @@ void LoLEngine::setupOpcodeTable() { // 0x58 OpcodeUnImpl(); Opcode(olol_stopTimScript); - OpcodeUnImpl(); + Opcode(olol_getWallFlags); OpcodeUnImpl(); // 0x5C diff --git a/engines/kyra/sprites_lol.cpp b/engines/kyra/sprites_lol.cpp index 7180671ec5..d05a585bac 100644 --- a/engines/kyra/sprites_lol.cpp +++ b/engines/kyra/sprites_lol.cpp @@ -306,7 +306,7 @@ void LoLEngine::assignItemOrMonsterToBlock(uint16 *blockItemIndex, int id) { } int LoLEngine::checkBlockBeforeMonsterPlacement(int x, int y, int monsterWidth, int testFlag, int wallFlag) { - _monsterUnkDir = 0; + _monsterLastWalkDirection = 0; int x2 = 0; int y2 = 0; int xOffs = 0; @@ -324,7 +324,7 @@ int LoLEngine::checkBlockBeforeMonsterPlacement(int x, int y, int monsterWidth, if (x & 0x80) { if (((x & 0xff) + monsterWidth) & 0xff00) { xOffs = 1; - _monsterUnkDir = 2; + _monsterLastWalkDirection = 2; x2 = x + monsterWidth; r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x2, y), x, y, monsterWidth, testFlag, wallFlag); @@ -340,7 +340,7 @@ int LoLEngine::checkBlockBeforeMonsterPlacement(int x, int y, int monsterWidth, } else { if (((x & 0xff) - monsterWidth) & 0xff00) { xOffs = -1; - _monsterUnkDir = 6; + _monsterLastWalkDirection = 6; x2 = x - monsterWidth; r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x2, y), x, y, monsterWidth, testFlag, wallFlag); @@ -358,7 +358,7 @@ int LoLEngine::checkBlockBeforeMonsterPlacement(int x, int y, int monsterWidth, if (y & 0x80) { if (((y & 0xff) + monsterWidth) & 0xff00) { yOffs = 1; - _monsterUnkDir = 4; + _monsterLastWalkDirection = 4; y2 = y + monsterWidth; r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x, y2), x, y, monsterWidth, testFlag, wallFlag); @@ -374,7 +374,7 @@ int LoLEngine::checkBlockBeforeMonsterPlacement(int x, int y, int monsterWidth, } else { if (((y & 0xff) - monsterWidth) & 0xff00) { yOffs = -1; - _monsterUnkDir = 0; + _monsterLastWalkDirection = 0; y2 = y - monsterWidth; r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x, y2), x, y, monsterWidth, testFlag, wallFlag); @@ -944,8 +944,8 @@ void LoLEngine::walkMonster(MonsterInPlay *monster) { if (walkMonsterCheckDest(monster->x, monster->y, monster, 4) != 1) return; - _monsterUnkDir ^= 4; - setMonsterDirection(monster, _monsterUnkDir); + _monsterLastWalkDirection ^= 4; + setMonsterDirection(monster, _monsterLastWalkDirection); } else { setMonsterDirection(monster, s); if (monster->field_25) { @@ -961,7 +961,7 @@ void LoLEngine::walkMonster(MonsterInPlay *monster) { int fx = 0; int fy = 0; - walkMonsterGetNextStepCoords(monster->x, monster->y, fx, fy, (s == -1) ? _monsterUnkDir : s); + walkMonsterGetNextStepCoords(monster->x, monster->y, fx, fy, (s == -1) ? _monsterLastWalkDirection : s); placeMonster(monster, fx, fy); } diff --git a/engines/kyra/timer.cpp b/engines/kyra/timer.cpp index 88b86393c8..c3ebad852a 100644 --- a/engines/kyra/timer.cpp +++ b/engines/kyra/timer.cpp @@ -122,9 +122,9 @@ void TimerManager::update() { _nextRun += 99999; for (Iterator pos = _timers.begin(); pos != _timers.end(); ++pos) { - if (pos->enabled) + if (pos->enabled == 1) - if (pos->enabled && pos->countdown >= 0) { + if (pos->enabled == 1 && pos->countdown >= 0) { if (pos->nextRun <= _system->getMillis()) { if (pos->func && pos->func->isValid()) { (*pos->func)(pos->id); @@ -138,7 +138,6 @@ void TimerManager::update() { _nextRun = MIN(_nextRun, pos->nextRun); } } - } void TimerManager::resync() { @@ -229,10 +228,10 @@ void TimerManager::pauseSingleTimer(uint8 id, bool p) { if (p) { timer->pauseStartTime = _system->getMillis(); - timer->enabled = 0; + timer->enabled ^= 2; } else if (timer->pauseStartTime) { int32 elapsedTime = _system->getMillis() - timer->pauseStartTime; - timer->enabled = 1; + timer->enabled ^= 2; timer->lastUpdate += elapsedTime; timer->nextRun += elapsedTime; resync(); @@ -256,7 +255,7 @@ void TimerManager::enable(uint8 id) { Iterator timer = Common::find_if(_timers.begin(), _timers.end(), TimerEqual(id)); if (timer != _timers.end()) - timer->enabled = 1; + timer->enabled |= 1; else warning("TimerManager::enable: No timer %d", id); } @@ -266,7 +265,7 @@ void TimerManager::disable(uint8 id) { Iterator timer = Common::find_if(_timers.begin(), _timers.end(), TimerEqual(id)); if (timer != _timers.end()) - timer->enabled = 0; + timer->enabled &= 2; else warning("TimerManager::disable: No timer %d", id); } diff --git a/engines/kyra/timer_lol.cpp b/engines/kyra/timer_lol.cpp index d646b13f0e..98a4f2845b 100644 --- a/engines/kyra/timer_lol.cpp +++ b/engines/kyra/timer_lol.cpp @@ -150,7 +150,7 @@ void LoLEngine::timerUpdatePortraitAnimations(int skipUpdate) { } void LoLEngine::timerUpdateLampState(int timerNum) { - if ((_screen->_drawGuiFlag & 0x800) && (_screen->_drawGuiFlag & 0x400) && _lampStatusUnk) + if ((_gameFlags[15] & 0x800) && (_gameFlags[15] & 0x400) && _lampStatusUnk) _lampStatusUnk--; } |