SCI: speed throttler changed, now gets triggered by kAnimate, removed initial no-delay, i'm still getting animation now in iceman and sq3, slow palette animation in longbow fixed

svn-id: r47343
This commit is contained in:
Martin Kiewitz 2010-01-17 18:41:28 +00:00
parent cb1419ece9
commit 3e44180e47
5 changed files with 26 additions and 16 deletions

View File

@ -58,20 +58,23 @@ reg_t kGameIsRestarting(EngineState *s, int argc, reg_t *argv) {
// Some games seem to get the duration of main loop initially and then switch of animations for the whole game
// based on that (qfg2, iceman). We are now running full speed initially to avoid that.
if (s->_lastAnimateCounter < 50) {
s->_lastAnimateCounter++;
return s->r_acc;
}
if (s->_throttleTrigger) {
//if (s->_throttleCounter < 50) {
// s->_throttleCounter++;
// return s->r_acc;
//}
uint32 curTime = g_system->getMillis();
uint32 duration = curTime - s->_lastAnimateTime;
uint32 neededSleep = 30;
uint32 curTime = g_system->getMillis();
uint32 duration = curTime - s->_throttleLastTime;
uint32 neededSleep = 30;
if (duration < neededSleep) {
kernel_sleep(s->_event, neededSleep - duration);
s->_lastAnimateTime = g_system->getMillis();
} else {
s->_lastAnimateTime = curTime;
if (duration < neededSleep) {
kernel_sleep(s->_event, neededSleep - duration);
s->_throttleLastTime = g_system->getMillis();
} else {
s->_throttleLastTime = curTime;
}
s->_throttleTrigger = false;
}
return s->r_acc;

View File

@ -71,8 +71,9 @@ EngineState::EngineState(ResourceManager *res, Kernel *kernel, Vocabulary *voc,
successor = 0;
_lastAnimateCounter = 0;
_lastAnimateTime = 0;
_throttleCounter = 0;
_throttleLastTime = 0;
_throttleTrigger = false;
_setCursorType = SCI_VERSION_NONE;
_doSoundType = SCI_VERSION_NONE;

View File

@ -158,8 +158,9 @@ public:
uint32 game_start_time; /**< The time at which the interpreter was started */
uint32 last_wait_time; /**< The last time the game invoked Wait() */
uint32 _lastAnimateCounter; /**< total times kAnimate was invoked */
uint32 _lastAnimateTime; /**< last time kAnimate was invoked */
uint32 _throttleCounter; /**< total times kAnimate was invoked */
uint32 _throttleLastTime; /**< last time kAnimate was invoked */
bool _throttleTrigger;
/* Kernel File IO stuff */

View File

@ -80,6 +80,8 @@ public:
void addToPicDrawCels();
void addToPicDrawView(GuiResourceId viewId, int16 loopNo, int16 celNo, int16 leftPos, int16 topPos, int16 priority, int16 control);
uint16 getLastCastCount() { return _lastCastCount; };
private:
void init();

View File

@ -675,6 +675,9 @@ void SciGui::animate(reg_t listReference, bool cycle, int argc, reg_t *argv) {
_animate->updateScreen(old_picNotValid);
_animate->restoreAndDelete(argc, argv);
if (_animate->getLastCastCount() > 1)
_s->_throttleTrigger = true;
_gfx->SetPort(oldPort);
}