aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra/kyra_v2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/kyra/kyra_v2.cpp')
-rw-r--r--engines/kyra/kyra_v2.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp
index 8d2a7714fe..011e3cb48d 100644
--- a/engines/kyra/kyra_v2.cpp
+++ b/engines/kyra/kyra_v2.cpp
@@ -278,13 +278,18 @@ void KyraEngine_v2::runLoop() {
_quitFlag = false;
while (!_quitFlag) {
//XXX
+
int inputFlag = checkInput(0/*dword_324C5*/);
+ removeInputTop();
+
update();
+
if (inputFlag == 198 || inputFlag == 199) {
_unk3 = _handItemSet;
Common::Point mouse = getMousePos();
handleInput(mouse.x, mouse.y);
}
+
//XXX
}
}
@@ -353,6 +358,8 @@ void KyraEngine_v2::handleInput(int x, int y) {
}
int KyraEngine_v2::update() {
+ updateInput();
+
refreshAnimObjectsIfNeed();
updateMouse();
updateSpecialSceneScripts();
@@ -362,6 +369,7 @@ int KyraEngine_v2::update() {
//sub_1574C();
//XXX
_screen->updateScreen();
+
return 0;
}
@@ -474,10 +482,22 @@ void KyraEngine_v2::updateMouse() {
}
}
-int KyraEngine_v2::checkInput(void *p) {
+void KyraEngine_v2::updateInput() {
Common::Event event;
+
+ while (_eventMan->pollEvent(event))
+ _eventList.push_back(event);
+}
+
+int KyraEngine_v2::checkInput(void *p) {
+ updateInput();
+
int keys = 0;
- while (_eventMan->pollEvent(event)) {
+
+ while (_eventList.size()) {
+ Common::Event event = *_eventList.begin();
+ bool breakLoop = false;
+
switch (event.type) {
case Common::EVENT_KEYDOWN:
if (event.kbd.keycode == Common::KEYCODE_RETURN)
@@ -487,10 +507,12 @@ int KyraEngine_v2::checkInput(void *p) {
if (event.kbd.keycode == 'd')
_debugger->attach();
}
+ breakLoop = true;
break;
case Common::EVENT_LBUTTONUP:
keys = 198;
+ breakLoop = true;
break;
case Common::EVENT_QUIT:
@@ -503,12 +525,22 @@ int KyraEngine_v2::checkInput(void *p) {
if (_debugger->isAttached())
_debugger->onFrame();
+
+ if (breakLoop)
+ break;
+
+ _eventList.erase(_eventList.begin());
}
_system->delayMillis(10);
return keys;
}
+void KyraEngine_v2::removeInputTop() {
+ if (_eventList.begin() != _eventList.end())
+ _eventList.erase(_eventList.begin());
+}
+
void KyraEngine_v2::cleanup() {
delete [] _gamePlayBuffer;
delete [] _unkBuf500Bytes;