diff options
author | Paul Gilbert | 2019-06-22 22:02:51 -0700 |
---|---|---|
committer | Paul Gilbert | 2019-06-22 22:03:06 -0700 |
commit | c0d5981ff9b125e0c56ce68707ade7e07e304206 (patch) | |
tree | 12359d73ea3afb11401fc0dd6fd9fde9c16796e5 /engines | |
parent | 3683e74d65273126afd3d7a101c656b7b52b8580 (diff) | |
download | scummvm-rg350-c0d5981ff9b125e0c56ce68707ade7e07e304206.tar.gz scummvm-rg350-c0d5981ff9b125e0c56ce68707ade7e07e304206.tar.bz2 scummvm-rg350-c0d5981ff9b125e0c56ce68707ade7e07e304206.zip |
GLK: ALAN2: Fix quitting in-game
Diffstat (limited to 'engines')
-rw-r--r-- | engines/glk/alan2/debug.cpp | 7 | ||||
-rw-r--r-- | engines/glk/alan2/exe.cpp | 22 | ||||
-rw-r--r-- | engines/glk/alan2/exe.h | 3 | ||||
-rw-r--r-- | engines/glk/alan2/inter.cpp | 7 | ||||
-rw-r--r-- | engines/glk/alan2/inter.h | 3 | ||||
-rw-r--r-- | engines/glk/alan2/main.cpp | 9 | ||||
-rw-r--r-- | engines/glk/alan2/main.h | 2 | ||||
-rw-r--r-- | engines/glk/alan2/parse.cpp | 6 |
8 files changed, 37 insertions, 22 deletions
diff --git a/engines/glk/alan2/debug.cpp b/engines/glk/alan2/debug.cpp index b455db6930..bea427bdb4 100644 --- a/engines/glk/alan2/debug.cpp +++ b/engines/glk/alan2/debug.cpp @@ -315,8 +315,11 @@ void debug() { $iX -- exit debug mode\ $iQ -- quit game"); break; - case 'Q': - terminate(0); + case 'Q': { + Context ctx; + terminate(ctx, 0); + break; + } case 'X': dbgflg = FALSE; /* Fall through to 'G' */ case 'G': diff --git a/engines/glk/alan2/exe.cpp b/engines/glk/alan2/exe.cpp index fd3b065b46..2acd9d2885 100644 --- a/engines/glk/alan2/exe.cpp +++ b/engines/glk/alan2/exe.cpp @@ -166,7 +166,7 @@ Boolean confirm(MsgKind msgno) { return (buf[0] == '\0'); } -void quit() { +void quit(CONTEXT) { char buf[80]; para(); @@ -174,18 +174,20 @@ void quit() { col = 1; statusline(); prmsg(M_QUITACTION); - if (!readline(buf)) terminate(0); + if (!readline(buf)) { + CALL1(terminate, 0) + } - if (strcmp(buf, "restart") == 0) - //longjmp(restart_label, TRUE); - ::error("TODO: restart"); - else if (strcmp(buf, "restore") == 0) { + if (strcmp(buf, "restart") == 0) { + g_vm->setRestart(true); + LONG_JUMP + } else if (strcmp(buf, "restore") == 0) { restore(); - return; - } else if (strcmp(buf, "quit") == 0) - terminate(0); + LONG_JUMP + } else if (strcmp(buf, "quit") == 0) { + CALL1(terminate, 0) + } } - syserr("Fallthrough in QUIT"); } void restart() { diff --git a/engines/glk/alan2/exe.h b/engines/glk/alan2/exe.h index cc99719ded..89a34b5379 100644 --- a/engines/glk/alan2/exe.h +++ b/engines/glk/alan2/exe.h @@ -27,6 +27,7 @@ */ #include "glk/alan2/types.h" +#include "glk/alan2/jumps.h" namespace Glk { namespace Alan2 { @@ -61,7 +62,7 @@ extern void score(Aword sc); extern void visits(Aword v); extern void schedule(Aword evt, Aword whr, Aword aft); extern void cancl(Aword evt); -extern void quit(void); +extern void quit(CONTEXT); extern void restart(void); extern void save(void); extern void restore(void); diff --git a/engines/glk/alan2/inter.cpp b/engines/glk/alan2/inter.cpp index 51c1e795fb..4e6639a3f6 100644 --- a/engines/glk/alan2/inter.cpp +++ b/engines/glk/alan2/inter.cpp @@ -146,6 +146,11 @@ static void depcase() { } void interpret(Aaddr adr) { + Context ctx; + interpret(ctx, adr); +} + +void interpret(CONTEXT, Aaddr adr) { Aaddr oldpc; Aword i; @@ -233,7 +238,7 @@ void interpret(Aaddr adr) { case I_QUIT: { if (stpflg) printf("QUIT"); - quit(); + CALL0(quit) break; } case I_LOOK: { diff --git a/engines/glk/alan2/inter.h b/engines/glk/alan2/inter.h index b4ae725726..bb26ce1f3e 100644 --- a/engines/glk/alan2/inter.h +++ b/engines/glk/alan2/inter.h @@ -23,10 +23,13 @@ #ifndef GLK_ALAN2_INTER #define GLK_ALAN2_INTER +#include "glk/alan2/jumps.h" + namespace Glk { namespace Alan2 { extern void interpret(Aaddr adr); +extern void interpret(CONTEXT, Aaddr adr); } // End of namespace Alan2 } // End of namespace Glk diff --git a/engines/glk/alan2/main.cpp b/engines/glk/alan2/main.cpp index 6e6133db87..e6d2226d24 100644 --- a/engines/glk/alan2/main.cpp +++ b/engines/glk/alan2/main.cpp @@ -114,13 +114,14 @@ Boolean skipsp = FALSE; return buffers... */ -void terminate(int code) { +void terminate(CONTEXT, int code) { newline(); free(memory); if (logflg) fclose(logfil); g_vm->glk_exit(); + LONG_JUMP } /*====================================================================== @@ -885,7 +886,7 @@ static void do_it(CONTEXT) { else printf("\n<VERB %d, %s (ONLY), Body:>\n", cur.vrb, trace); } - interpret(alt[i]->action); + CALL1(interpret, alt[i]->action) if (fail) return; if (alt[i]->qual == (Aword)Q_ONLY) return; } @@ -908,7 +909,7 @@ static void do_it(CONTEXT) { sprintf(trace, "in PARAMETER %d", i - 1); printf("\n<VERB %d, %s, Body:>\n", cur.vrb, trace); } - interpret(alt[i]->action); + CALL1(interpret, alt[i]->action) if (fail) return; } done[i] = TRUE; @@ -929,7 +930,7 @@ static void do_it(CONTEXT) { sprintf(trace, "in PARAMETER %d", i - 1); printf("\n<VERB %d, %s (AFTER), Body:>\n", cur.vrb, trace); } - interpret(alt[i]->action); + CALL1(interpret, alt[i]->action) if (fail) return; } i--; diff --git a/engines/glk/alan2/main.h b/engines/glk/alan2/main.h index 9672899c81..a77a0c5813 100644 --- a/engines/glk/alan2/main.h +++ b/engines/glk/alan2/main.h @@ -99,7 +99,7 @@ extern Boolean needsp; #define endOfTable(x) eot((Aword *) x) extern void *allocate(unsigned long len); -extern void terminate(int code); +extern void terminate(CONTEXT, int code); extern void usage(void); extern void error(CONTEXT, MsgKind msg); extern void syserr(const char *msg); diff --git a/engines/glk/alan2/parse.cpp b/engines/glk/alan2/parse.cpp index bc12d3ea8e..5c9fd35db4 100644 --- a/engines/glk/alan2/parse.cpp +++ b/engines/glk/alan2/parse.cpp @@ -150,7 +150,7 @@ static char *gettoken(char *tokBuf) { return tokBuf; } -static void agetline() { +static void agetline(CONTEXT) { para(); do { statusline(); @@ -164,7 +164,7 @@ static void agetline() { return; newline(); - quit(); + CALL0(quit) } getPageSize(); @@ -189,7 +189,7 @@ static void scan(CONTEXT) { int w; char *str; - agetline(); + CALL0(agetline) if (g_vm->shouldQuit()) return; |