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()); }