void KyraEngine_LoK::snd_voiceWaitForFinish(bool ingame) { while (_sound->voiceIsPlaying() && !skipFlag()) { if (ingame) delay(10, true); else _system->delayMillis(10); } }
void KyraEngine_LoK::delayUntil(uint32 timestamp, bool updateTimers, bool update, bool isMainLoop) { while (_system->getMillis() < timestamp && !shouldQuit() && !skipFlag()) { if (updateTimers) _timer->update(); if (timestamp - _system->getMillis() >= 10) delay(10, update, isMainLoop); } }
void KyraEngine_LoK::mainLoop() { // Initialize debugger since how it should be fully usable _debugger->initialize(); _eventList.clear(); while (!shouldQuit()) { int32 frameTime = (int32)_system->getMillis(); if (_currentCharacter->sceneId == 210) { updateKyragemFading(); if (seq_playEnd() && _deathHandler != 8) break; } if (_deathHandler != -1) { snd_playWanderScoreViaMap(0, 1); snd_playSoundEffect(49); _screen->hideMouse(); _screen->setMouseCursor(1, 1, _shapes[0]); removeHandItem(); _screen->showMouse(); _gui->buttonMenuCallback(0); _deathHandler = -1; } if ((_brandonStatusBit & 2) && _brandonStatusBit0x02Flag) _animator->animRefreshNPC(0); if ((_brandonStatusBit & 0x20) && _brandonStatusBit0x20Flag) { _animator->animRefreshNPC(0); _brandonStatusBit0x20Flag = 0; } // FIXME: Why is this here? _screen->showMouse(); int inputFlag = checkInput(_buttonList, _currentCharacter->sceneId != 210); removeInputTop(); updateMousePointer(); _timer->update(); _sound->process(); updateTextFade(); if (inputFlag == 198 || inputFlag == 199) processInput(_mouseX, _mouseY); if (skipFlag()) resetSkipFlag(); delay((frameTime + _gameSpeed) - _system->getMillis(), true, true); } }
void KyraEngine_LoK::delay(uint32 amount, bool update, bool isMainLoop) { uint32 start = _system->getMillis(); do { if (update) { _sprites->updateSceneAnims(); _animator->updateAllObjectShapes(); updateTextFade(); updateMousePointer(); } else { // We need to do Screen::updateScreen here, since client code // relies on this method to copy screen changes to the actual // screen since at least 0af418e7ea3a41f93fcc551a45ee5bae822d812a. _screen->updateScreen(); } _isSaveAllowed = isMainLoop; updateInput(); _isSaveAllowed = false; if (_currentCharacter && _currentCharacter->sceneId == 210 && update) updateKyragemFading(); if (amount > 0 && !skipFlag() && !shouldQuit()) _system->delayMillis(10); // FIXME: Major hackery to allow skipping the intro if (_seqPlayerFlag) { for (Common::List<Event>::iterator i = _eventList.begin(); i != _eventList.end(); ++i) { if (i->causedSkip) { if (i->event.type == Common::EVENT_KEYDOWN && i->event.kbd.keycode == Common::KEYCODE_ESCAPE) _abortIntroFlag = true; else i->causedSkip = false; } } } if (skipFlag()) snd_stopVoice(); } while (!skipFlag() && _system->getMillis() < start + amount && !shouldQuit()); }
void KyraEngine_v2::delay(uint32 amount, bool updateGame, bool isMainLoop) { uint32 start = _system->getMillis(); do { if (updateGame) { if (_chatText) updateWithText(); else update(); } else { updateInput(); } if (amount > 0) _system->delayMillis(amount > 10 ? 10 : amount); } while (!skipFlag() && _system->getMillis() < start + amount && !shouldQuit()); }
void KyraEngine_LoK::delayWithTicks(int ticks) { uint32 nextTime = _system->getMillis() + ticks * _tickLength; while (_system->getMillis() < nextTime) { _sprites->updateSceneAnims(); _animator->updateAllObjectShapes(); if (_currentCharacter->sceneId == 210) { updateKyragemFading(); seq_playEnd(); } if (skipFlag()) break; if (nextTime - _system->getMillis() >= 10) delay(10); } }
int KyraEngine_HoF::trySceneChange(int *moveTable, int unk1, int updateChar) { bool running = true; bool unkFlag = false; int8 updateType = -1; int changedScene = 0; const int *moveTableStart = moveTable; _unk4 = 0; while (running && !shouldQuit()) { if (*moveTable >= 0 && *moveTable <= 7) { _mainCharacter.facing = getOppositeFacingDirection(*moveTable); unkFlag = true; } else { if (*moveTable == 8) { running = false; } else { ++moveTable; unkFlag = false; } } if (checkSceneChange()) { running = false; changedScene = 1; } if (unk1) { if (skipFlag()) { resetSkipFlag(false); running = false; _unk4 = 1; } } if (!unkFlag || !running) continue; int ret = 0; if (moveTable == moveTableStart || moveTable[1] == 8) ret = updateCharPos(0); else ret = updateCharPos(moveTable); if (ret) ++moveTable; ++updateType; if (!updateType) { update(); } else if (updateType == 1) { refreshAnimObjectsIfNeed(); updateType = -1; } delay(10); } if (updateChar) _mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing]; updateCharacterAnim(0); refreshAnimObjectsIfNeed(); return changedScene; }