[Scummvm-cvs-logs] scummvm master -> 34117170f2955e854a93925a652af37575361b44

m-kiewitz m_kiewitz at users.sourceforge.net
Wed Feb 3 02:40:24 CET 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
34117170f2 AGI: Change cycle delay handling, seems to fix GR


Commit: 34117170f2955e854a93925a652af37575361b44
    https://github.com/scummvm/scummvm/commit/34117170f2955e854a93925a652af37575361b44
Author: Martin Kiewitz (m_kiewitz at users.sourceforge.net)
Date: 2016-02-03T02:40:01+01:00

Commit Message:
AGI: Change cycle delay handling, seems to fix GR

Removed pollTimer()
Renamed pause() to wait()
Doing 10 msec delays instead of at least 50 msec per EventProcess
Seems to fix weird Gold Rush ingame timer issue?! bug #4147

Changed paths:
    engines/agi/agi.cpp
    engines/agi/agi.h
    engines/agi/cycle.cpp
    engines/agi/keyboard.cpp
    engines/agi/op_test.cpp



diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 6046d5e..401c42a 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 4e65c57..5d14850 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 4d870d9..630a91a 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 1809d57..169c294 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 c99d2f9..4b215ed 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);






More information about the Scummvm-git-logs mailing list