aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/agos/agos.cpp12
-rw-r--r--engines/agos/agos.h1
-rw-r--r--engines/agos/event.cpp6
-rw-r--r--engines/agos/gfx.cpp2
-rw-r--r--engines/agos/input.cpp4
-rw-r--r--engines/agos/script.cpp9
-rw-r--r--engines/agos/script_e1.cpp4
-rw-r--r--engines/agos/script_s1.cpp4
-rw-r--r--engines/agos/subroutine.cpp4
9 files changed, 30 insertions, 16 deletions
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp
index b1586bfecc..ec7244c068 100644
--- a/engines/agos/agos.cpp
+++ b/engines/agos/agos.cpp
@@ -98,6 +98,8 @@ AGOSEngine::AGOSEngine(OSystem *syst)
_vc_get_out_of_code = 0;
_gameOffsetsPtr = 0;
+ _quit = false;
+
_debugger = 0;
_gameFile = 0;
@@ -933,7 +935,7 @@ void AGOSEngine::pause() {
_mixer->pauseAll(true);
_sound->ambientPause(true);
- while (_pause) {
+ while (_pause && !_quit) {
delay(1);
if (_keyPressed.keycode == Common::KEYCODE_p)
_pause = false;
@@ -974,7 +976,7 @@ int AGOSEngine::go() {
(getFeatures() & GF_DEMO)) {
int i;
- while (1) {
+ while (!_quit) {
for (i = 0; i < 4; i++) {
setWindowImage(3, 9902 + i);
debug(0, "Displaying image %d", 9902 + i);
@@ -1003,7 +1005,7 @@ int AGOSEngine::go() {
runSubroutine101();
permitInput();
- while (1) {
+ while (!_quit) {
waitForInput();
handleVerbClicked(_verbHitArea);
delay(100);
@@ -1012,6 +1014,9 @@ int AGOSEngine::go() {
return 0;
}
+
+/* I do not think that this will be used
+ *
void AGOSEngine::shutdown() {
// Sync with AGOSEngine::~AGOSEngine()
// In Simon 2, this gets deleted along with _sound further down
@@ -1059,6 +1064,7 @@ void AGOSEngine::shutdown() {
_system->quit();
}
+*/
uint32 AGOSEngine::getTime() const {
// FIXME: calling time() is not portable, use OSystem::getMillis instead
diff --git a/engines/agos/agos.h b/engines/agos/agos.h
index 50dbf7d6db..bd8ff9d63c 100644
--- a/engines/agos/agos.h
+++ b/engines/agos/agos.h
@@ -269,6 +269,7 @@ protected:
uint16 _marks;
+ bool _quit;
bool _scriptVar2;
bool _runScriptReturn1;
bool _runScriptCondition[40];
diff --git a/engines/agos/event.cpp b/engines/agos/event.cpp
index 250ff2fcfd..010b331cf8 100644
--- a/engines/agos/event.cpp
+++ b/engines/agos/event.cpp
@@ -142,7 +142,7 @@ bool AGOSEngine::kickoffTimeEvents() {
cur_time = getTime() - _gameStoppedClock;
- while ((te = _firstTimeStruct) != NULL && te->time <= cur_time) {
+ while ((te = _firstTimeStruct) != NULL && te->time <= cur_time && !_quit) {
result = true;
_pendingDeleteTimeEvent = te;
invokeTimeEvent(te);
@@ -521,7 +521,7 @@ void AGOSEngine::delay(uint amount) {
_rightButtonDown++;
break;
case Common::EVENT_QUIT:
- shutdown();
+ _quit = true;
return;
default:
break;
@@ -544,7 +544,7 @@ void AGOSEngine::delay(uint amount) {
_system->delayMillis(this_delay);
cur = _system->getMillis();
- } while (cur < start + amount);
+ } while (cur < start + amount && !_quit);
}
void AGOSEngine::timer_callback() {
diff --git a/engines/agos/gfx.cpp b/engines/agos/gfx.cpp
index 193b7347d6..c014413bdc 100644
--- a/engines/agos/gfx.cpp
+++ b/engines/agos/gfx.cpp
@@ -1263,7 +1263,7 @@ void AGOSEngine::setWindowImageEx(uint16 mode, uint16 vga_res) {
if (getGameType() == GType_WW && (mode == 6 || mode == 8 || mode == 9)) {
setWindowImage(mode, vga_res);
} else {
- while (_copyScnFlag)
+ while (_copyScnFlag && !_quit)
delay(1);
setWindowImage(mode, vga_res);
diff --git a/engines/agos/input.cpp b/engines/agos/input.cpp
index add7eb96f0..d36549f187 100644
--- a/engines/agos/input.cpp
+++ b/engines/agos/input.cpp
@@ -189,12 +189,12 @@ void AGOSEngine::waitForInput() {
resetVerbs();
}
- for (;;) {
+ while (!_quit) {
_lastHitArea = NULL;
_lastHitArea3 = NULL;
_dragAccept = 1;
- for (;;) {
+ while (!_quit) {
if ((getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) &&
_keyPressed.keycode == Common::KEYCODE_F10)
displayBoxStars();
diff --git a/engines/agos/script.cpp b/engines/agos/script.cpp
index 44fbb4e9e0..6758aec511 100644
--- a/engines/agos/script.cpp
+++ b/engines/agos/script.cpp
@@ -410,7 +410,7 @@ void AGOSEngine::o_msg() {
void AGOSEngine::o_end() {
// 68: exit interpreter
- shutdown();
+ _quit = true;
}
void AGOSEngine::o_done() {
@@ -965,6 +965,9 @@ void AGOSEngine::writeVariable(uint16 variable, uint16 contents) {
int AGOSEngine::runScript() {
bool flag;
+ if (_quit)
+ return 1;
+
do {
if (_continousMainScript)
dumpOpcode(_codePtr);
@@ -1007,7 +1010,7 @@ int AGOSEngine::runScript() {
error("Invalid opcode '%d' encountered", _opcode);
executeOpcode(_opcode);
- } while (getScriptCondition() != flag && !getScriptReturn());
+ } while (getScriptCondition() != flag && !getScriptReturn() && !_quit);
return getScriptReturn();
}
@@ -1063,7 +1066,7 @@ void AGOSEngine::waitForSync(uint a) {
_exitCutscene = false;
_rightButtonDown = false;
- while (_vgaWaitFor != 0) {
+ while (_vgaWaitFor != 0 && !_quit) {
if (_rightButtonDown) {
if (_vgaWaitFor == 200 && (getGameType() == GType_FF || !getBitFlag(14))) {
skipSpeech();
diff --git a/engines/agos/script_e1.cpp b/engines/agos/script_e1.cpp
index 94df21979c..c7e1d6736e 100644
--- a/engines/agos/script_e1.cpp
+++ b/engines/agos/script_e1.cpp
@@ -565,7 +565,7 @@ void AGOSEngine_Elvira1::oe1_look() {
lobjFunc(l, "You can see "); /* Show objects */
}
if (r && (r->flags & 4) && levelOf(i) < 10000) {
- shutdown();
+ _quit = true;
}
}
@@ -944,7 +944,7 @@ restart:
windowPutChar(window, *message2);
if (confirmYesOrNo(120, 62) == 0x7FFF) {
- shutdown();
+ _quit = true;
} else {
goto restart;
}
diff --git a/engines/agos/script_s1.cpp b/engines/agos/script_s1.cpp
index a1308b951d..51918b9515 100644
--- a/engines/agos/script_s1.cpp
+++ b/engines/agos/script_s1.cpp
@@ -345,14 +345,14 @@ void AGOSEngine_Simon1::os1_pauseGame() {
if (isSmartphone()) {
if (_keyPressed.keycode) {
if (_keyPressed.keycode == Common::KEYCODE_RETURN)
- shutdown();
+ _quit = true;
else
break;
}
}
#endif
if (_keyPressed.keycode == keyYes)
- shutdown();
+ _quit = true;
else if (_keyPressed.keycode == keyNo)
break;
}
diff --git a/engines/agos/subroutine.cpp b/engines/agos/subroutine.cpp
index 44ada82585..cb71ed7efa 100644
--- a/engines/agos/subroutine.cpp
+++ b/engines/agos/subroutine.cpp
@@ -554,6 +554,10 @@ int AGOSEngine::startSubroutine(Subroutine *sub) {
_currentTable = sub;
restart:
+
+ if (_quit)
+ return result;
+
while ((byte *)sl != (byte *)sub) {
_currentLine = sl;
if (checkIfToRunSubroutineLine(sl, sub)) {