diff options
-rw-r--r-- | engines/agi/agi.cpp | 34 | ||||
-rw-r--r-- | engines/agi/agi.h | 8 | ||||
-rw-r--r-- | engines/agi/cycle.cpp | 7 | ||||
-rw-r--r-- | engines/agi/keyboard.cpp | 11 | ||||
-rw-r--r-- | engines/agi/op_test.cpp | 2 |
5 files changed, 20 insertions, 42 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp index 6046d5ee79..401c42a76a 100644 --- a/engines/agi/agi.cpp +++ b/engines/agi/agi.cpp @@ -58,30 +58,23 @@ void AgiEngine::allowSynthetic(bool allow) { _allowSynthetic = allow; } -void AgiEngine::pollTimer() { - _lastTick += 50; - - while (_system->getMillis() < _lastTick) { - processScummVMEvents(); - _console->onFrame(); - _system->delayMillis(10); - _system->updateScreen(); - } - - _lastTick = _system->getMillis(); -} - -void AgiEngine::pause(uint32 msec) { +void AgiEngine::wait(uint32 msec, bool busy) { uint32 endTime = _system->getMillis() + msec; - _gfx->setMouseCursor(true); // Busy mouse cursor + if (busy) { + _gfx->setMouseCursor(true); // Busy mouse cursor + } - while (_system->getMillis() < endTime) { + do { processScummVMEvents(); + _console->onFrame(); _system->updateScreen(); _system->delayMillis(10); + } while (_system->getMillis() < endTime); + + if (busy) { + _gfx->setMouseCursor(); // regular mouse cursor } - _gfx->setMouseCursor(); // regular mouse cursor } int AgiEngine::agiInit() { @@ -395,7 +388,6 @@ AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBas _game._curLogic = NULL; _lastSaveTime = 0; - _lastTick = 0; memset(_keyQueue, 0, sizeof(_keyQueue)); @@ -472,8 +464,6 @@ void AgiEngine::initialize() { _lastSaveTime = 0; - _lastTick = _system->getMillis(); - debugC(2, kDebugLevelMain, "Detect game"); if (agiDetectGame() == errOK) { @@ -614,7 +604,7 @@ void AgiEngine::loadingTrigger_NewRoom(int16 newRoomNr) { if (newRoomNr != curRoomNr) { if (!_game.automaticRestoreGame) { // wait a bit, we detected non-blocking text - pause(2000); // 2 seconds + wait(2000, true); // 2 seconds, set busy } } } @@ -626,7 +616,7 @@ void AgiEngine::loadingTrigger_DrawPicture() { if (!_game.automaticRestoreGame) { // wait a bit, we detected non-blocking text - pause(2000); // 2 seconds + wait(2000, true); // 2 seconds, set busy } } } diff --git a/engines/agi/agi.h b/engines/agi/agi.h index 4e65c57890..5d14850509 100644 --- a/engines/agi/agi.h +++ b/engines/agi/agi.h @@ -655,7 +655,6 @@ public: return false; } - virtual void pollTimer() = 0; virtual int getKeypress() = 0; virtual bool isKeypress() = 0; virtual void clearKeyQueue() = 0; @@ -735,8 +734,6 @@ public: void adjustPosToGameScreen(int16 &x, int16 &y); private: - uint32 _lastTick; - int _keyQueue[KEY_QUEUE_SIZE]; int _keyQueueStart; int _keyQueueEnd; @@ -788,7 +785,7 @@ public: int16 p4, int16 p5, int16 p6, int16 p7); void releaseImageStack(); - void pause(uint32 msec); + void wait(uint32 msec, bool busy = false); Console *_console; GUI::Debugger *getDebugger() { return _console; } @@ -800,7 +797,6 @@ public: int agiUnloadResource(int16 resourceType, int16 resourceNr); void agiUnloadResources(); - virtual void pollTimer(); virtual int getKeypress(); virtual bool isKeypress(); virtual void clearKeyQueue(); @@ -818,7 +814,7 @@ public: public: void decrypt(uint8 *mem, int len); void releaseSprites(); - uint16 processAGIEvents(bool doDelay = true); + uint16 processAGIEvents(); int viewPictures(); int runGame(); int getAppDir(char *appDir, unsigned int size); diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp index 4d870d9ccf..630a91a93a 100644 --- a/engines/agi/cycle.cpp +++ b/engines/agi/cycle.cpp @@ -174,14 +174,11 @@ void AgiEngine::interpretCycle() { } // We return the current key, or 0 if no key was pressed -uint16 AgiEngine::processAGIEvents(bool doDelay) { +uint16 AgiEngine::processAGIEvents() { uint16 key; ScreenObjEntry *screenObjEgo = &_game.screenObjTable[SCREENOBJECTS_EGO_ENTRY]; - if (doDelay) { - pollTimer(); - } - + wait(10); key = doPollKeyboard(); // In AGI Mouse emulation mode we must update the mouse-related diff --git a/engines/agi/keyboard.cpp b/engines/agi/keyboard.cpp index 1809d579e7..169c294e4d 100644 --- a/engines/agi/keyboard.cpp +++ b/engines/agi/keyboard.cpp @@ -540,14 +540,10 @@ int AgiEngine::waitKey() { debugC(3, kDebugLevelInput, "waiting..."); while (!(shouldQuit() || _restartGame || getFlag(VM_FLAG_RESTORE_JUST_RAN))) { - pollTimer(); + wait(10); key = doPollKeyboard(); if (key == AGI_KEY_ENTER || key == AGI_KEY_ESCAPE || key == AGI_MOUSE_BUTTON_LEFT) break; - - pollTimer(); - - g_system->updateScreen(); } return key; } @@ -559,11 +555,10 @@ int AgiEngine::waitAnyKey() { debugC(3, kDebugLevelInput, "waiting... (any key)"); while (!(shouldQuit() || _restartGame)) { - pollTimer(); + wait(10); key = doPollKeyboard(); if (key) break; - g_system->updateScreen(); } return key; } @@ -577,7 +572,7 @@ int AgiEngine::getKeypress() { int k; while (_keyQueueStart == _keyQueueEnd) // block - pollTimer(); + wait(10); keyDequeue(k); diff --git a/engines/agi/op_test.cpp b/engines/agi/op_test.cpp index c99d2f92ac..4b215edc63 100644 --- a/engines/agi/op_test.cpp +++ b/engines/agi/op_test.cpp @@ -127,7 +127,7 @@ void condHaveKey(AgiGame *state, AgiEngine *vm, uint8 *p) { } // we are not really an inner loop, but we stop processAGIEvents() from doing regular cycle work by setting it up vm->cycleInnerLoopActive(CYCLE_INNERLOOP_HAVEKEY); - uint16 key = vm->processAGIEvents(false); // also no delay + uint16 key = vm->processAGIEvents(); vm->cycleInnerLoopInactive(); if (key) { debugC(5, kDebugLevelScripts | kDebugLevelInput, "keypress = %02x", key); |