aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMartin Kiewitz2016-02-03 02:21:07 +0100
committerMartin Kiewitz2016-02-03 02:21:07 +0100
commit778c1ddb69bb45b6992fdc9b8fff6b2c8d3e22ac (patch)
tree51c8437a6c8eab0bd70ef313d71a562f20fca22e /engines
parentc2038e00d001c93a37028864ad661b89377686c9 (diff)
downloadscummvm-rg350-778c1ddb69bb45b6992fdc9b8fff6b2c8d3e22ac.tar.gz
scummvm-rg350-778c1ddb69bb45b6992fdc9b8fff6b2c8d3e22ac.tar.bz2
scummvm-rg350-778c1ddb69bb45b6992fdc9b8fff6b2c8d3e22ac.zip
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
Diffstat (limited to 'engines')
-rw-r--r--engines/agi/agi.cpp6
-rw-r--r--engines/agi/agi.h7
-rw-r--r--engines/agi/cycle.cpp32
-rw-r--r--engines/agi/inv.cpp2
-rw-r--r--engines/agi/keyboard.cpp4
-rw-r--r--engines/agi/menu.cpp2
-rw-r--r--engines/agi/op_test.cpp8
-rw-r--r--engines/agi/systemui.cpp2
-rw-r--r--engines/agi/text.cpp4
9 files changed, 32 insertions, 35 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index ba8a2bab13..6046d5ee79 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 4b98a70ec7..4e65c57890 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 3887999580..4d870d9ccf 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 08dba9b0ab..1df5282622 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 dd850d92f8..1809d579e7 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 f7c7162580..f154472aa8 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 0ffd1f56e6..c99d2f92ac 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 aa1b2e4127..2d82730f78 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 ceca6780a3..317ecbea14 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();