aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/agos/agos.h4
-rw-r--r--engines/agos/pn.cpp42
-rw-r--r--engines/agos/saveload.cpp18
-rw-r--r--engines/agos/script_pn.cpp6
4 files changed, 38 insertions, 32 deletions
diff --git a/engines/agos/agos.h b/engines/agos/agos.h
index 536c1ca3ab..b8af9df95f 100644
--- a/engines/agos/agos.h
+++ b/engines/agos/agos.h
@@ -1470,8 +1470,8 @@ protected:
virtual void windowPutChar(WindowBlock *window, byte c, byte b = 0);
bool badload(int8 errorNum);
- int loadfl(char *name);
- int savfl(char *name);
+ int loadFile(char *name);
+ int saveFile(char *name);
void getFilename();
void sysftodb();
void dbtosysf();
diff --git a/engines/agos/pn.cpp b/engines/agos/pn.cpp
index 6ba5e8c891..e8135f56cd 100644
--- a/engines/agos/pn.cpp
+++ b/engines/agos/pn.cpp
@@ -251,29 +251,33 @@ void AGOSEngine_PN::setupBoxes() {
}
void AGOSEngine_PN::processor() {
- int q;
-
setqptrs();
- q = setjmp(_loadfail);
-
- _variableArray[6] = 0;
- if (getPlatform() == Common::kPlatformAtariST) {
- _variableArray[21] = 2;
- } else if (getPlatform() == Common::kPlatformAmiga) {
- _variableArray[21] = 0;
- } else {
- _variableArray[21] = 1;
- }
+ _tagOfActiveDoline = 0;
+ int q = 0;
+ do {
+ assert(_tagOfActiveDoline == 0);
+ _dolineReturnVal = 0;
+
+ _variableArray[6] = 0;
+
+ if (getPlatform() == Common::kPlatformAtariST) {
+ _variableArray[21] = 2;
+ } else if (getPlatform() == Common::kPlatformAmiga) {
+ _variableArray[21] = 0;
+ } else {
+ _variableArray[21] = 1;
+ }
- _variableArray[16] = _quickshort[6];
- _variableArray[17] = _quickshort[7];
- _variableArray[19] = getptr(55L);
+ _variableArray[16] = _quickshort[6];
+ _variableArray[17] = _quickshort[7];
+ _variableArray[19] = getptr(55L);
- // q indicates the process to run and is 0 the first time,
- // but 1 later on (i.e., when we are "called" from badload()).
- setposition(q, 0);
- doline(0);
+ // q indicates the process to run and is 0 the first time,
+ // but 1 later on (i.e., when we are "called" from badload()).
+ setposition(0, 0);
+ q = doline(0);
+ } while (q);
}
void AGOSEngine_PN::setqptrs() {
diff --git a/engines/agos/saveload.cpp b/engines/agos/saveload.cpp
index 16bde0097b..92632775f9 100644
--- a/engines/agos/saveload.cpp
+++ b/engines/agos/saveload.cpp
@@ -23,8 +23,6 @@
*
*/
-
-
#include "common/savefile.h"
#include "common/system.h"
@@ -1553,15 +1551,19 @@ bool AGOSEngine_Elvira2::saveGame(uint slot, const char *caption) {
#ifdef ENABLE_PN
// Personal Nightmare specific
bool AGOSEngine_PN::badload(int8 errorNum) {
+printf("badload(%d)\n", errorNum);
if (errorNum == -2)
return 0;
- /* Load error recovery routine */
+ // Load error recovery routine
+
+ // Clear any stack
while (_stackbase != NULL) {
- /* Clear any stack */
dumpstack();
}
- /* Restart from process 1 */
- longjmp(_loadfail, 1);
+
+ // Restart from process 1
+ _tagOfActiveDoline = 1;
+ _dolineReturnVal = 2;
return 1;
}
@@ -1582,7 +1584,7 @@ void AGOSEngine_PN::getFilename() {
}
}
-int AGOSEngine_PN::loadfl(char *name) {
+int AGOSEngine_PN::loadFile(char *name) {
Common::InSaveFile *f;
haltAnimation();
@@ -1615,7 +1617,7 @@ int AGOSEngine_PN::loadfl(char *name) {
return 0;
}
-int AGOSEngine_PN::savfl(char *name) {
+int AGOSEngine_PN::saveFile(char *name) {
Common::OutSaveFile *f;
sysftodb();
haltAnimation();
diff --git a/engines/agos/script_pn.cpp b/engines/agos/script_pn.cpp
index 116f1e1975..f033a65669 100644
--- a/engines/agos/script_pn.cpp
+++ b/engines/agos/script_pn.cpp
@@ -397,7 +397,7 @@ void AGOSEngine_PN::opn_opcode31() {
if (slot == -1) {
setScriptReturn(false);
} else {
- a = loadfl(bf);
+ a = loadFile(bf);
if (a)
setScriptReturn(badload(a));
else
@@ -434,7 +434,7 @@ void AGOSEngine_PN::opn_opcode32() {
break;
}
- a = savfl(bf);
+ a = saveFile(bf);
setScriptReturn(a);
}
@@ -918,7 +918,7 @@ int AGOSEngine_PN::doline(int needsave) {
if (x > 0) {
dumpstack();
// Restore the active jmpbuf to its previous value,
- // then return the longjmp value (will be 2-1=1 or 1-1=0).
+ // then return _dolineReturnVal-1 (will be 2-1=1 or 1-1=0).
_tagOfActiveDoline = myTag - 1;
return (x - 1);
}