aboutsummaryrefslogtreecommitdiff
path: root/engines/agi/op_test.cpp
diff options
context:
space:
mode:
authorMartin Kiewitz2016-02-02 22:26:39 +0100
committerMartin Kiewitz2016-02-02 22:26:39 +0100
commit8269a94bcd55200f7ae8aba00c7b6fd0d37b9a37 (patch)
tree234371f2909bcdf224111f273393ba1f3ca35816 /engines/agi/op_test.cpp
parent8a29f98c9c2139da6c1f6bb2237765cad2534b34 (diff)
downloadscummvm-rg350-8269a94bcd55200f7ae8aba00c7b6fd0d37b9a37.tar.gz
scummvm-rg350-8269a94bcd55200f7ae8aba00c7b6fd0d37b9a37.tar.bz2
scummvm-rg350-8269a94bcd55200f7ae8aba00c7b6fd0d37b9a37.zip
AGI: Use inner loop functionality for have.key
Also do it like the original interpreter did it
Diffstat (limited to 'engines/agi/op_test.cpp')
-rw-r--r--engines/agi/op_test.cpp49
1 files changed, 24 insertions, 25 deletions
diff --git a/engines/agi/op_test.cpp b/engines/agi/op_test.cpp
index aad1d94cee..2fbdaab2c7 100644
--- a/engines/agi/op_test.cpp
+++ b/engines/agi/op_test.cpp
@@ -32,7 +32,7 @@ namespace Agi {
#define ip (state->_curLogic->cIP)
#define code (state->_curLogic->data)
-#define getVar(a) state->_vm->getVar(a)
+#define getVar(a) vm->getVar(a)
#define testEqual(v1, v2) (getVar(v1) == (v2))
#define testLess(v1, v2) (getVar(v1) < (v2))
@@ -98,7 +98,29 @@ void condController(AgiGame *state, AgiEngine *vm, uint8 *p) {
}
void condHaveKey(AgiGame *state, AgiEngine *vm, uint8 *p) {
- state->testResult = vm->testKeypressed();
+ if (!getVar(VM_VAR_KEY)) {
+ // Only wait for key when there is not already one set by scripts
+ vm->cycleInnerLoopActive(CYCLE_INNERLOOP_HAVEKEY);
+ do {
+ // Only check for events here, without updating the game cycle,
+ // otherwise the animations in some games are drawn too quickly
+ // like, for example, Manannan's lightnings in the intro of KQ3
+ // and the bullets opened in the logo of PQ1, during its intro.
+ // Fixes bug #3600733
+ vm->mainCycle(true);
+ } while (vm->cycleInnerLoopIsActive() && !(vm->shouldQuit() || vm->_restartGame));
+ }
+
+ state->testResult = 1;
+}
+
+void AgiEngine::testHaveKeyCharPress(uint16 newChar) {
+ // pass key to scripts
+ setVar(VM_VAR_KEY, newChar);
+
+ // Exit on any key press
+ cycleInnerLoopInactive();
+ debugC(5, kDebugLevelScripts | kDebugLevelInput, "keypress = %02x", newChar);
}
void condSaid(AgiGame *state, AgiEngine *vm, uint8 *p) {
@@ -239,29 +261,6 @@ uint8 AgiEngine::testCompareStrings(uint8 s1, uint8 s2) {
return !strcmp(ms1, ms2);
}
-uint8 AgiEngine::testKeypressed() {
- int x = _game.keypress;
-
- _game.keypress = 0;
- if (!x) {
- InputMode mode = _game.inputMode;
-
- _game.inputMode = INPUTMODE_NONE;
- // Only check for events here, without updating the game cycle,
- // otherwise the animations in some games are drawn too quickly
- // like, for example, Manannan's lightnings in the intro of KQ3
- // and the bullets opened in the logo of PQ1, during its intro.
- // Fixes bug #3600733
- mainCycle(true);
- _game.inputMode = mode;
- }
-
- if (x)
- debugC(5, kDebugLevelScripts | kDebugLevelInput, "keypress = %02x", x);
-
- return x;
-}
-
uint8 AgiEngine::testController(uint8 cont) {
return (_game.controllerOccured[cont] ? true : false);
}