aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authordhewg2011-03-05 10:32:56 +0100
committerdhewg2011-03-05 11:00:37 +0100
commit69a026192e30c544379cf938efa6b545a62e3a08 (patch)
tree9a8904977d188cc45c3b2c819945e7a94f54302d /engines
parent83b00526d0da2265eef8d59767cafd16190ec092 (diff)
downloadscummvm-rg350-69a026192e30c544379cf938efa6b545a62e3a08.tar.gz
scummvm-rg350-69a026192e30c544379cf938efa6b545a62e3a08.tar.bz2
scummvm-rg350-69a026192e30c544379cf938efa6b545a62e3a08.zip
AGI: Kill the timer based counter
Using the timer mechanism for just a simple counter is not just overkill, its also inaccurate. When using a call frequency of x, and waiting for y callbacks, the passed time will not be x*y. The problem amplifies on slower platforms and/or fair thread schedulers. Use absolute times instead. Most notably, the walking speed of the avatar is now smooth on android, but probably on all other handhelds we support too.
Diffstat (limited to 'engines')
-rw-r--r--engines/agi/agi.cpp23
-rw-r--r--engines/agi/agi.h5
-rw-r--r--engines/agi/preagi.cpp3
3 files changed, 6 insertions, 25 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index fdc05f0ba9..c5a1f81af6 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -273,23 +273,16 @@ void AgiEngine::processEvents() {
}
void AgiEngine::pollTimer() {
- uint32 dm;
+ _lastTick += 50;
- if (_tickTimer < _lastTickTimer)
- _lastTickTimer = 0;
-
- while ((dm = _tickTimer - _lastTickTimer) < 5) {
+ while (_system->getMillis() < _lastTick) {
processEvents();
_console->onFrame();
_system->delayMillis(10);
_system->updateScreen();
}
- _lastTickTimer = _tickTimer;
-}
-void AgiEngine::agiTimerFunctionLow(void *refCon) {
- AgiEngine *self = (AgiEngine *)refCon;
- self->_tickTimer++;
+ _lastTick = _system->getMillis();
}
void AgiEngine::pause(uint32 msec) {
@@ -532,9 +525,6 @@ AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBas
_allowSynthetic = false;
- _tickTimer = 0;
- _lastTickTimer = 0;
-
_intobj = NULL;
_menu = NULL;
@@ -646,11 +636,10 @@ void AgiEngine::initialize() {
_lastSaveTime = 0;
- _timer->installTimerProc(agiTimerFunctionLow, 10 * 1000, this);
+ _lastTick = _system->getMillis();
debugC(2, kDebugLevelMain, "Detect game");
-
if (agiDetectGame() == errOK) {
_game.state = STATE_LOADED;
debugC(2, kDebugLevelMain, "game loaded");
@@ -662,8 +651,6 @@ void AgiEngine::initialize() {
}
AgiEngine::~AgiEngine() {
- _timer->removeTimerProc(agiTimerFunctionLow);
-
// If the engine hasn't been initialized yet via AgiEngine::initialize(), don't attempt to free any resources,
// as they haven't been allocated. Fixes bug #1742432 - AGI: Engine crashes if no game is detected
if (_game.state == STATE_INIT) {
@@ -719,7 +706,7 @@ void AgiEngine::parseFeatures() {
/* FIXME: Seems this method doesn't really do anything. It might
be a leftover that could be removed, except that some of its
intended purpose may still need to be reimplemented.
-
+
[0:29] <Fingolfin> can you tell me what the point behind AgiEngine::parseFeatures() is?
[0:30] <_sev> when games are created with WAGI studio
[0:31] <_sev> it creates .wag site with game-specific features such as full game title, whether to use AGIMOUSE etc
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 89b116daec..df19f55b52 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -810,9 +810,7 @@ public:
Common::Error saveGameState(int slot, const char *desc);
private:
-
- uint32 _tickTimer;
- uint32 _lastTickTimer;
+ uint32 _lastTick;
int _keyQueue[KEY_QUEUE_SIZE];
int _keyQueueStart;
@@ -883,7 +881,6 @@ public:
virtual bool isKeypress();
virtual void clearKeyQueue();
- static void agiTimerFunctionLow(void *refCon);
void initPriTable();
void newInputMode(InputMode mode);
diff --git a/engines/agi/preagi.cpp b/engines/agi/preagi.cpp
index fe864d7659..1aa6ef5cc4 100644
--- a/engines/agi/preagi.cpp
+++ b/engines/agi/preagi.cpp
@@ -122,9 +122,6 @@ void PreAgiEngine::initialize() {
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_speakerHandle,
_speakerStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
-
- //_timer->installTimerProc(agiTimerFunctionLow, 10 * 1000, NULL);
-
debugC(2, kDebugLevelMain, "Detect game");
// clear all resources and events