diff options
Diffstat (limited to 'engines/kyra')
-rw-r--r-- | engines/kyra/items.cpp | 47 | ||||
-rw-r--r-- | engines/kyra/kyra.cpp | 9 | ||||
-rw-r--r-- | engines/kyra/kyra.h | 3 | ||||
-rw-r--r-- | engines/kyra/scene.cpp | 8 | ||||
-rw-r--r-- | engines/kyra/sequences_v1.cpp | 10 |
5 files changed, 30 insertions, 47 deletions
diff --git a/engines/kyra/items.cpp b/engines/kyra/items.cpp index b9aef48b79..c09bd88374 100644 --- a/engines/kyra/items.cpp +++ b/engines/kyra/items.cpp @@ -218,7 +218,7 @@ void KyraEngine::wipeDownMouseItem(int xpos, int ypos) { _screen->updateScreen(); y += 2; height -= 2; - while (_system->getMillis() < nextTime) {} + delayUntil(nextTime); } _screen->restoreRect1(xpos, ypos); _screen->resetShapeHeight(_shapes[220+_itemInHand]); @@ -560,10 +560,7 @@ void KyraEngine::itemDropDown(int x, int y, int destX, int destY, byte freeItem, uint32 nextTime = _system->getMillis() + 1 * _tickLength; _screen->drawShape(0, _shapes[220+item], drawX, drawY, 0, 0); _screen->updateScreen(); - while (_system->getMillis() < nextTime) { - if ((nextTime - _system->getMillis()) >= 10) - delay(10); - } + delayUntil(nextTime); } bool skip = false; @@ -603,10 +600,7 @@ void KyraEngine::itemDropDown(int x, int y, int destX, int destY, byte freeItem, uint32 nextTime = _system->getMillis() + 1 * _tickLength; _screen->drawShape(0, _shapes[220+item], drawX, drawY, 0, 0); _screen->updateScreen(); - while (_system->getMillis() < nextTime) { - if ((nextTime - _system->getMillis()) >= 10) - delay(10); - } + delayUntil(nextTime); } _screen->restoreRect0(drawX, drawY); } else { @@ -659,10 +653,7 @@ void KyraEngine::itemSpecialFX1(int x, int y, int item) { uint32 nextTime = _system->getMillis() + 1 * _tickLength; _screen->drawShape(0, shape, x, startY, 0, 0); _screen->updateScreen(); - while (_system->getMillis() < nextTime) { - if ((nextTime - _system->getMillis()) >= 10) - delay(10); - } + delayUntil(nextTime); } _screen->restoreRect0(x, y); _screen->showMouse(); @@ -683,10 +674,7 @@ void KyraEngine::itemSpecialFX2(int x, int y, int item) { uint32 nextTime = _system->getMillis() + 3 * _tickLength; _screen->drawShape(0, _shapes[4+i], x, y + yAdd, 0, 0); _screen->updateScreen(); - while (_system->getMillis() < nextTime) { - if ((nextTime - _system->getMillis()) >= 10) - delay(10); - } + delayUntil(nextTime); } for (int i = 204; i >= 201; --i) { @@ -695,10 +683,7 @@ void KyraEngine::itemSpecialFX2(int x, int y, int item) { _screen->drawShape(0, _shapes[220+item], x, y, 0, 0); _screen->drawShape(0, _shapes[4+i], x, y + yAdd, 0, 0); _screen->updateScreen(); - while (_system->getMillis() < nextTime) { - if ((nextTime - _system->getMillis()) >= 10) - delay(10); - } + delayUntil(nextTime); } _screen->restoreRect0(x, y); } @@ -755,10 +740,7 @@ void KyraEngine::magicOutMouseItem(int animIndex, int itemPos) { specialMouseItemFX(shape, x, y, animIndex, tableIndex, loopStart, maxLoops); } _screen->updateScreen(); - while (_system->getMillis() < nextTime) { - if (nextTime - _system->getMillis() >= 10) - delay(10); - } + delayUntil(nextTime); } if (itemPos != -1) { @@ -777,10 +759,7 @@ void KyraEngine::magicOutMouseItem(int animIndex, int itemPos) { specialMouseItemFX(shape, x, y, animIndex, tableIndex, loopStart, maxLoops); } _screen->updateScreen(); - while (_system->getMillis() < nextTime) { - if (nextTime - _system->getMillis() >= 10) - delay(10); - } + delayUntil(nextTime); } _screen->restoreRect1(x, y); if (itemPos == -1) { @@ -843,10 +822,7 @@ void KyraEngine::magicInMouseItem(int animIndex, int item, int itemPos) { specialMouseItemFX(shape, x, y, animIndex, tableIndex, loopStart, maxLoops); } _screen->updateScreen(); - while (_system->getMillis() < nextTime) { - if (nextTime - _system->getMillis() >= 10) - delay(10); - } + delayUntil(nextTime); } for (int shape = _magicMouseItemStartFrame2[animIndex]; shape <= _magicMouseItemEndFrame2[animIndex]; ++shape) { @@ -858,10 +834,7 @@ void KyraEngine::magicInMouseItem(int animIndex, int item, int itemPos) { specialMouseItemFX(shape, x, y, animIndex, tableIndex, loopStart, maxLoops); } _screen->updateScreen(); - while (_system->getMillis() < nextTime) { - if (nextTime - _system->getMillis() >= 10) - delay(10); - } + delayUntil(nextTime); } _screen->restoreRect1(x, y); if (itemPos == -1) { diff --git a/engines/kyra/kyra.cpp b/engines/kyra/kyra.cpp index 904f8475cd..a6bf71459d 100644 --- a/engines/kyra/kyra.cpp +++ b/engines/kyra/kyra.cpp @@ -561,6 +561,15 @@ void KyraEngine::quitGame() { _system->quit(); } +void KyraEngine::delayUntil(uint32 timestamp, bool updateTimers, bool update, bool isMainLoop) { + while (_system->getMillis() < timestamp) { + if (updateTimers) + updateGameTimers(); + if (timestamp - _system->getMillis() >= 10) + delay(10, update, isMainLoop); + } +} + void KyraEngine::delay(uint32 amount, bool update, bool isMainLoop) { OSystem::Event event; char saveLoadSlot[20]; diff --git a/engines/kyra/kyra.h b/engines/kyra/kyra.h index 2d8fc7fbba..3f273257ac 100644 --- a/engines/kyra/kyra.h +++ b/engines/kyra/kyra.h @@ -286,7 +286,8 @@ public: const uint8 * const*palTable2() { return &_specialPalettes[29]; } bool seq_skipSequence() const; - void delay(uint32 millis, bool update = false, bool mainLoop = false); + void delayUntil(uint32 timestamp, bool updateGameTimers = false, bool update = false, bool isMainLoop = false); + void delay(uint32 millis, bool update = false, bool isMainLoop = false); void quitGame(); void loadBitmap(const char *filename, int tempPage, int dstPage, uint8 *palData); diff --git a/engines/kyra/scene.cpp b/engines/kyra/scene.cpp index 9933a7267a..0d12a64c5a 100644 --- a/engines/kyra/scene.cpp +++ b/engines/kyra/scene.cpp @@ -252,7 +252,7 @@ void KyraEngine::moveCharacterToPos(int character, int facing, int xpos, int ypo while (ypos < ch->y1) { nextFrame = getTimerDelay(5 + character) * _tickLength + _system->getMillis(); setCharacterPositionWithUpdate(character); - while (_system->getMillis() < nextFrame) { updateGameTimers(); } + delayUntil(nextFrame, true); } break; @@ -260,7 +260,7 @@ void KyraEngine::moveCharacterToPos(int character, int facing, int xpos, int ypo while (ch->x1 < xpos) { nextFrame = getTimerDelay(5 + character) * _tickLength + _system->getMillis(); setCharacterPositionWithUpdate(character); - while (_system->getMillis() < nextFrame) { updateGameTimers(); } + delayUntil(nextFrame, true); } break; @@ -268,7 +268,7 @@ void KyraEngine::moveCharacterToPos(int character, int facing, int xpos, int ypo while (ypos > ch->y1) { nextFrame = getTimerDelay(5 + character) * _tickLength + _system->getMillis(); setCharacterPositionWithUpdate(character); - while (_system->getMillis() < nextFrame) { updateGameTimers(); } + delayUntil(nextFrame, true); } break; @@ -276,7 +276,7 @@ void KyraEngine::moveCharacterToPos(int character, int facing, int xpos, int ypo while (ch->x1 > xpos) { nextFrame = getTimerDelay(5 + character) * _tickLength + _system->getMillis(); setCharacterPositionWithUpdate(character); - while (_system->getMillis() < nextFrame) { updateGameTimers(); } + delayUntil(nextFrame, true); } break; diff --git a/engines/kyra/sequences_v1.cpp b/engines/kyra/sequences_v1.cpp index 594198582e..71378513db 100644 --- a/engines/kyra/sequences_v1.cpp +++ b/engines/kyra/sequences_v1.cpp @@ -948,10 +948,10 @@ int KyraEngine::seq_playEnd() { _finalA->open("finald.wsa", 1, 0); _finalA->_x = _finalA->_y = 8; _finalA->_drawPage = 0; - while (_system->getMillis() < nextTime) {} + delayUntil(nextTime); snd_playSoundEffect(0x40); for (int i = 0; i < 22; ++i) { - while (_system->getMillis() < nextTime) {} + delayUntil(nextTime); if (i == 4) { snd_playSoundEffect(0x3E); } else if (i == 20) { @@ -1292,7 +1292,7 @@ int KyraEngine::handleMalcolmFlag() { timer2 = _system->getMillis() + 4 * _tickLength; _finalC->displayFrame(i); _screen->updateScreen(); - while (_system->getMillis() < timer2) {} + delayUntil(timer2); } snd_playWanderScoreViaMap(51, 1); delay(60 * _tickLength); @@ -1496,14 +1496,14 @@ int KyraEngine::handleBeadState() { nextRun = _system->getMillis() + _tickLength; _finalB->displayFrame(i); _screen->updateScreen(); - while (_system->getMillis() < nextRun) {} + delayUntil(nextRun); } snd_playSoundEffect(0x0D); for (int i = 7; i >= 0; --i) { nextRun = _system->getMillis() + _tickLength; _finalB->displayFrame(i); _screen->updateScreen(); - while (_system->getMillis() < nextRun) {} + delayUntil(nextRun); } initBeadState(beadState1.x, beadState1.y, 63, 60, 6, &beadState2); } else { |