[Scummvm-cvs-logs] scummvm master -> 778c1ddb69bb45b6992fdc9b8fff6b2c8d3e22ac

m-kiewitz m_kiewitz at users.sourceforge.net
Wed Feb 3 02:21:28 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:
778c1ddb69 AGI: Cycle event processing changed


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

Commit Message:
AGI: Cycle event processing changed

processEvents() renamed to processScummVMEvents()
mainCycle() renamed to processAGIEvents()
have.key now sets up an inner loop and calls processAGIEvents()
to avoid any further cycle work processing

Changed paths:
    engines/agi/agi.cpp
    engines/agi/agi.h
    engines/agi/cycle.cpp
    engines/agi/inv.cpp
    engines/agi/keyboard.cpp
    engines/agi/menu.cpp
    engines/agi/op_test.cpp
    engines/agi/systemui.cpp
    engines/agi/text.cpp



diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index ba8a2ba..6046d5e 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -62,7 +62,7 @@ void AgiEngine::pollTimer() {
 	_lastTick += 50;
 
 	while (_system->getMillis() < _lastTick) {
-		processEvents();
+		processScummVMEvents();
 		_console->onFrame();
 		_system->delayMillis(10);
 		_system->updateScreen();
@@ -77,7 +77,7 @@ void AgiEngine::pause(uint32 msec) {
 	_gfx->setMouseCursor(true); // Busy mouse cursor
 
 	while (_system->getMillis() < endTime) {
-		processEvents();
+		processScummVMEvents();
 		_system->updateScreen();
 		_system->delayMillis(10);
 	}
@@ -552,7 +552,7 @@ Common::Error AgiEngine::go() {
 
 	if (_game.state < STATE_LOADED) {
 		do {
-			mainCycle();
+			processAGIEvents();
 		} while (_game.state < STATE_RUNNING);
 	}
 
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 4b98a70..4e65c57 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -390,7 +390,8 @@ enum CycleInnerLoopType {
 	CYCLE_INNERLOOP_MENU_VIA_KEYBOARD            = 3,
 	CYCLE_INNERLOOP_MENU_VIA_MOUSE               = 4,
 	CYCLE_INNERLOOP_SYSTEMUI_SELECTSAVEDGAMESLOT = 5,
-	CYCLE_INNERLOOP_MESSAGEBOX                   = 6
+	CYCLE_INNERLOOP_MESSAGEBOX                   = 6,
+	CYCLE_INNERLOOP_HAVEKEY                      = 7
 };
 
 enum State {
@@ -817,7 +818,7 @@ public:
 public:
 	void decrypt(uint8 *mem, int len);
 	void releaseSprites();
-	int mainCycle(bool onlyCheckForEvents = false);
+	uint16 processAGIEvents(bool doDelay = true);
 	int viewPictures();
 	int runGame();
 	int getAppDir(char *appDir, unsigned int size);
@@ -831,7 +832,7 @@ public:
 	int playGame();
 
 	void allowSynthetic(bool);
-	void processEvents();
+	void processScummVMEvents();
 	void checkQuickLoad();
 
 	// Objects
diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp
index 3887999..4d870d9 100644
--- a/engines/agi/cycle.cpp
+++ b/engines/agi/cycle.cpp
@@ -173,12 +173,12 @@ void AgiEngine::interpretCycle() {
 	//_gfx->doUpdate();
 }
 
-// If main_cycle returns false, don't process more events!
-int AgiEngine::mainCycle(bool onlyCheckForEvents) {
+// We return the current key, or 0 if no key was pressed
+uint16 AgiEngine::processAGIEvents(bool doDelay) {
 	uint16 key;
 	ScreenObjEntry *screenObjEgo = &_game.screenObjTable[SCREENOBJECTS_EGO_ENTRY];
 
-	if (!onlyCheckForEvents) {
+	if (doDelay) {
 		pollTimer();
 	}
 
@@ -188,10 +188,8 @@ int AgiEngine::mainCycle(bool onlyCheckForEvents) {
 	// vars in every interpreter cycle.
 	//
 	// We run AGIMOUSE always as a side effect
-	//if (getFeatures() & GF_AGIMOUSE) {
-		setVar(VM_VAR_MOUSE_X, _mouse.pos.x / 2);
-		setVar(VM_VAR_MOUSE_Y, _mouse.pos.y);
-	//}
+	setVar(VM_VAR_MOUSE_X, _mouse.pos.x / 2);
+	setVar(VM_VAR_MOUSE_Y, _mouse.pos.y);
 
 	if (!cycleInnerLoopIsActive()) {
 		// Click-to-walk mouse interface
@@ -234,6 +232,10 @@ int AgiEngine::mainCycle(bool onlyCheckForEvents) {
 			}
 		}
 
+		if (_menu->delayedExecuteActive()) {
+			_menu->execute();
+		}
+
 	} else {
 		// inner loop active
 		// call specific workers
@@ -255,11 +257,11 @@ int AgiEngine::mainCycle(bool onlyCheckForEvents) {
 			if (key) {
 				_menu->keyPress(key);
 			}
-			return false;
+			break;
 
 		case CYCLE_INNERLOOP_MENU_VIA_MOUSE:
 			_menu->mouseEvent(key);
-			return false;
+			break;
 
 		case CYCLE_INNERLOOP_SYSTEMUI_SELECTSAVEDGAMESLOT:
 			if (key) {
@@ -278,15 +280,9 @@ int AgiEngine::mainCycle(bool onlyCheckForEvents) {
 		}
 	}
 
-	if (!onlyCheckForEvents) {
-		if (_menu->delayedExecuteActive()) {
-			_menu->execute();
-		}
-	}
-
 	_gfx->updateScreen();
 
-	return true;
+	return key;
 }
 
 int AgiEngine::playGame() {
@@ -341,9 +337,7 @@ int AgiEngine::playGame() {
 	nonBlockingText_Forget();
 
 	do {
-
-		if (!mainCycle())
-			continue;
+		processAGIEvents();
 
 		inGameTimerUpdate();
 
diff --git a/engines/agi/inv.cpp b/engines/agi/inv.cpp
index 08dba9b..1df5282 100644
--- a/engines/agi/inv.cpp
+++ b/engines/agi/inv.cpp
@@ -148,7 +148,7 @@ void InventoryMgr::show() {
 		_vm->cycleInnerLoopActive(CYCLE_INNERLOOP_INVENTORY);
 
 		do {
-			_vm->mainCycle();
+			_vm->processAGIEvents();
 		} while (_vm->cycleInnerLoopIsActive() && !(_vm->shouldQuit() || _vm->_restartGame));
 
 		if (_activeItemNr >= 0) {
diff --git a/engines/agi/keyboard.cpp b/engines/agi/keyboard.cpp
index dd850d9..1809d57 100644
--- a/engines/agi/keyboard.cpp
+++ b/engines/agi/keyboard.cpp
@@ -62,7 +62,7 @@ const uint8 scancodeTable[26] = {
 	44          // Z
 };
 
-void AgiEngine::processEvents() {
+void AgiEngine::processScummVMEvents() {
 	Common::Event event;
 	int key = 0;
 
@@ -569,7 +569,7 @@ int AgiEngine::waitAnyKey() {
 }
 
 bool AgiEngine::isKeypress() {
-	processEvents();
+	processScummVMEvents();
 	return _keyQueueStart != _keyQueueEnd;
 }
 
diff --git a/engines/agi/menu.cpp b/engines/agi/menu.cpp
index f7c7162..f154472 100644
--- a/engines/agi/menu.cpp
+++ b/engines/agi/menu.cpp
@@ -331,7 +331,7 @@ void GfxMenu::execute() {
 	}
 
 	do {
-		_vm->mainCycle();
+		_vm->processAGIEvents();
 	} while (_vm->cycleInnerLoopIsActive() && !(_vm->shouldQuit() || _vm->_restartGame));
 
 	if (_drawnMenuNr >= 0) {
diff --git a/engines/agi/op_test.cpp b/engines/agi/op_test.cpp
index 0ffd1f5..c99d2f9 100644
--- a/engines/agi/op_test.cpp
+++ b/engines/agi/op_test.cpp
@@ -120,19 +120,21 @@ void condController(AgiGame *state, AgiEngine *vm, uint8 *p) {
 }
 
 void condHaveKey(AgiGame *state, AgiEngine *vm, uint8 *p) {
+	// Only check for key when there is not already one set by scripts
 	if (vm->getVar(VM_VAR_KEY)) {
 		state->testResult = 1;
 		return;
 	}
-	// Only check for key when there is not already one set by scripts
-	uint16 key = vm->doPollKeyboard();
+	// 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
+	vm->cycleInnerLoopInactive();
 	if (key) {
 		debugC(5, kDebugLevelScripts | kDebugLevelInput, "keypress = %02x", key);
 		vm->setVar(VM_VAR_KEY, key);
 		state->testResult = 1;
 		return;
 	}
-	vm->_gfx->updateScreen(); // TODO: Solve this in a better way
 	state->testResult = 0;
 }
 
diff --git a/engines/agi/systemui.cpp b/engines/agi/systemui.cpp
index aa1b2e4..2d82730 100644
--- a/engines/agi/systemui.cpp
+++ b/engines/agi/systemui.cpp
@@ -287,7 +287,7 @@ int16 SystemUI::askForSavedGameSlot(const char *slotListText) {
 
 	_vm->cycleInnerLoopActive(CYCLE_INNERLOOP_SYSTEMUI_SELECTSAVEDGAMESLOT);
 	do {
-		_vm->mainCycle();
+		_vm->processAGIEvents();
 	} while (_vm->cycleInnerLoopIsActive() && !(_vm->shouldQuit() || _vm->_restartGame));
 
 	_text->closeWindow();
diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp
index ceca678..317ecbe 100644
--- a/engines/agi/text.cpp
+++ b/engines/agi/text.cpp
@@ -360,7 +360,7 @@ bool TextMgr::messageBox(const char *textPtr) {
 	_vm->inGameTimerResetPassedCycles();
 	_vm->cycleInnerLoopActive(CYCLE_INNERLOOP_MESSAGEBOX);
 	do {
-		_vm->mainCycle();
+		_vm->processAGIEvents();
 		_vm->inGameTimerUpdate();
 
 		if (windowTimer > 0) {
@@ -786,7 +786,7 @@ void TextMgr::stringEdit(int16 stringMaxLen) {
 	inputEditOff();
 
 	do {
-		_vm->mainCycle();
+		_vm->processAGIEvents();
 	} while (_vm->cycleInnerLoopIsActive() && !(_vm->shouldQuit() || _vm->_restartGame));
 
 	inputEditOn();






More information about the Scummvm-git-logs mailing list