aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2019-06-23 16:15:00 -0700
committerPaul Gilbert2019-06-23 16:19:42 -0700
commit5eb0390aca85a53a6bc268e082b776119ca9b997 (patch)
tree33898f1d7487676ce2c24f1b2490e08f4549964a /engines
parente7fbd9268c9bd4a21a9f4741d4636c722368847c (diff)
downloadscummvm-rg350-5eb0390aca85a53a6bc268e082b776119ca9b997.tar.gz
scummvm-rg350-5eb0390aca85a53a6bc268e082b776119ca9b997.tar.bz2
scummvm-rg350-5eb0390aca85a53a6bc268e082b776119ca9b997.zip
GLK: ALAN2: Add loading savegames from launcher, deinitialization code
Diffstat (limited to 'engines')
-rw-r--r--engines/glk/alan2/alan2.cpp23
-rw-r--r--engines/glk/alan2/alan2.h7
-rw-r--r--engines/glk/alan2/debug.cpp2
-rw-r--r--engines/glk/alan2/exe.cpp2
-rw-r--r--engines/glk/alan2/glkio.cpp42
-rw-r--r--engines/glk/alan2/glkio.h6
-rw-r--r--engines/glk/alan2/main.cpp10
-rw-r--r--engines/glk/alan2/parse.cpp1
-rw-r--r--engines/glk/alan2/readline.cpp62
-rw-r--r--engines/glk/alan2/readline.h41
-rw-r--r--engines/glk/module.mk1
11 files changed, 80 insertions, 117 deletions
diff --git a/engines/glk/alan2/alan2.cpp b/engines/glk/alan2/alan2.cpp
index f9077c9f7a..0ad524bd47 100644
--- a/engines/glk/alan2/alan2.cpp
+++ b/engines/glk/alan2/alan2.cpp
@@ -39,17 +39,18 @@ namespace Alan2 {
Alan2 *g_vm = nullptr;
Alan2::Alan2(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gameDesc),
- vm_exited_cleanly(false), _restartFlag(false) {
+ vm_exited_cleanly(false), _restartFlag(false), _saveSlot(-1), _pendingLook(false) {
g_vm = this;
+ txtfil = nullptr;
+ logfil = nullptr;
+ memory = nullptr;
}
void Alan2::runGame() {
- Common::String gameFileName = _gameFile.getName();
+ if (initialize())
+ Glk::Alan2::run();
- if (!initialize())
- return;
-
- Glk::Alan2::run();
+ deinitialize();
}
bool Alan2::initialize() {
@@ -91,9 +92,19 @@ bool Alan2::initialize() {
return false;
}
+ // Check for a save being loaded directly from the launcher
+ _saveSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1;
+
return true;
}
+void Alan2::deinitialize() {
+ free(memory);
+
+ delete txtfil;
+ delete logfil;
+}
+
Common::Error Alan2::readSaveData(Common::SeekableReadStream *rs) {
Common::Serializer s(rs, nullptr);
synchronizeSave(s);
diff --git a/engines/glk/alan2/alan2.h b/engines/glk/alan2/alan2.h
index 413800cd90..baf02c8770 100644
--- a/engines/glk/alan2/alan2.h
+++ b/engines/glk/alan2/alan2.h
@@ -40,6 +40,8 @@ private:
public:
bool vm_exited_cleanly;
Common::String _advName;
+ int _saveSlot;
+ bool _pendingLook;
private:
/**
* Initialization
@@ -47,6 +49,11 @@ private:
bool initialize();
/**
+ * Deinitialization
+ */
+ void deinitialize();
+
+ /**
* Synchronize data to or from a save file
*/
void synchronizeSave(Common::Serializer &s);
diff --git a/engines/glk/alan2/debug.cpp b/engines/glk/alan2/debug.cpp
index bea427bdb4..af72c315f5 100644
--- a/engines/glk/alan2/debug.cpp
+++ b/engines/glk/alan2/debug.cpp
@@ -28,8 +28,6 @@
#include "glk/alan2/inter.h"
#include "glk/alan2/main.h"
#include "glk/alan2/parse.h"
-#include "glk/alan2/readline.h"
-
namespace Glk {
namespace Alan2 {
diff --git a/engines/glk/alan2/exe.cpp b/engines/glk/alan2/exe.cpp
index 5ff79c88f4..1abe60355e 100644
--- a/engines/glk/alan2/exe.cpp
+++ b/engines/glk/alan2/exe.cpp
@@ -23,10 +23,10 @@
#include "glk/alan2/alan2.h"
#include "glk/alan2/types.h"
#include "glk/alan2/exe.h"
+#include "glk/alan2/glkio.h"
#include "glk/alan2/inter.h"
#include "glk/alan2/main.h"
#include "glk/alan2/parse.h"
-#include "glk/alan2/readline.h"
#include "glk/alan2/stack.h"
#include "glk/alan2/decode.h"
diff --git a/engines/glk/alan2/glkio.cpp b/engines/glk/alan2/glkio.cpp
index fda54deec8..9f30531107 100644
--- a/engines/glk/alan2/glkio.cpp
+++ b/engines/glk/alan2/glkio.cpp
@@ -23,6 +23,7 @@
#include "glk/glk.h"
#include "glk/alan2/alan2.h"
#include "glk/alan2/glkio.h"
+#include "glk/alan2/main.h"
namespace Glk {
namespace Alan2 {
@@ -31,6 +32,10 @@ winid_t glkMainWin;
winid_t glkStatusWin;
void glkio_printf(const char *fmt, ...) {
+ // If there's a savegame being loaded from the launcher, ignore any text out
+ if (g_vm->_saveSlot != -1)
+ return;
+
va_list argp;
va_start(argp, fmt);
if (glkMainWin) {
@@ -46,6 +51,43 @@ void glkio_printf(const char *fmt, ...) {
va_end(argp);
}
+/*======================================================================
+
+ readline()
+
+ Read a line from the user, with history and editing
+
+ */
+
+ /* 4f - length of user buffer should be used */
+Boolean readline(char usrbuf[]) {
+ if (g_vm->_pendingLook) {
+ g_vm->_pendingLook = false;
+ glkio_printf("look\n");
+ strcpy(usrbuf, "look");
+ } else {
+ event_t event;
+ g_vm->glk_request_line_event(glkMainWin, usrbuf, 255, 0);
+
+ /* FIXME: buffer size should be infallible: all existing calls use 256 or
+ 80 character buffers, except parse which uses LISTLEN (currently 100)
+ */
+ do {
+ g_vm->glk_select(&event);
+ if (evtype_Arrange == event.type)
+ statusline();
+ if (g_vm->shouldQuit())
+ return false;
+
+ } while (event.type != evtype_LineInput);
+
+ usrbuf[event.val1] = 0;
+ }
+
+ return TRUE;
+}
+
+
} // End of namespace Alan2
} // End of namespace Glk
diff --git a/engines/glk/alan2/glkio.h b/engines/glk/alan2/glkio.h
index 2dff66f6ea..4bb2e026b5 100644
--- a/engines/glk/alan2/glkio.h
+++ b/engines/glk/alan2/glkio.h
@@ -27,6 +27,7 @@
*/
#include "glk/windows.h"
+#include "glk/alan2/types.h"
namespace Glk {
namespace Alan2 {
@@ -41,6 +42,11 @@ extern winid_t glkStatusWin;
void glkio_printf(const char *, ...);
+#define LINELENGTH 80
+#define HISTORYLENGTH 20
+
+extern Boolean readline(char usrbuf[]);
+
} // End of namespace Alan2
} // End of namespace Glk
diff --git a/engines/glk/alan2/main.cpp b/engines/glk/alan2/main.cpp
index 58c483a852..551fbe5b59 100644
--- a/engines/glk/alan2/main.cpp
+++ b/engines/glk/alan2/main.cpp
@@ -116,9 +116,6 @@ Boolean skipsp = FALSE;
*/
void terminate(CONTEXT, int code) {
newline();
- free(memory);
- if (logflg)
- fclose(logfil);
g_vm->glk_exit();
LONG_JUMP
@@ -1404,6 +1401,13 @@ void run() {
g_vm->setRestart(false);
init();
+ if (g_vm->_saveSlot != -1) {
+ if (g_vm->loadGameState(g_vm->_saveSlot).getCode() != Common::kNoError)
+ return;
+ g_vm->_saveSlot = -1;
+ g_vm->_pendingLook = true;
+ }
+
Context ctx;
while (!g_vm->shouldQuit() && !g_vm->shouldRestart()) {
if (!ctx._break) {
diff --git a/engines/glk/alan2/parse.cpp b/engines/glk/alan2/parse.cpp
index 5c9fd35db4..51bf0927d7 100644
--- a/engines/glk/alan2/parse.cpp
+++ b/engines/glk/alan2/parse.cpp
@@ -28,7 +28,6 @@
#include "glk/alan2/main.h"
#include "glk/alan2/params.h"
#include "glk/alan2/parse.h"
-#include "glk/alan2/readline.h"
#include "glk/alan2/term.h"
#include "glk/alan2/types.h"
diff --git a/engines/glk/alan2/readline.cpp b/engines/glk/alan2/readline.cpp
deleted file mode 100644
index cd05435c18..0000000000
--- a/engines/glk/alan2/readline.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "glk/alan2/alan2.h"
-#include "glk/alan2/types.h"
-#include "glk/alan2/glkio.h"
-#include "glk/alan2/main.h"
-#include "glk/alan2/readline.h"
-
-namespace Glk {
-namespace Alan2 {
-
-/*======================================================================
-
- readline()
-
- Read a line from the user, with history and editing
-
- */
-
-/* 4f - length of user buffer should be used */
-Boolean readline(char usrbuf[]) {
- event_t event;
- g_vm->glk_request_line_event(glkMainWin, usrbuf, 255, 0);
- /* FIXME: buffer size should be infallible: all existing calls use 256 or
- 80 character buffers, except parse which uses LISTLEN (currently 100)
- */
- do {
- g_vm->glk_select(&event);
- if (evtype_Arrange == event.type)
- statusline();
- if (g_vm->shouldQuit())
- return false;
-
- } while (event.type != evtype_LineInput);
-
- usrbuf[event.val1] = 0;
- return TRUE;
-}
-
-} // End of namespace Alan2
-} // End of namespace Glk
-
diff --git a/engines/glk/alan2/readline.h b/engines/glk/alan2/readline.h
deleted file mode 100644
index 249ccbd62c..0000000000
--- a/engines/glk/alan2/readline.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef GLK_ALAN2_READLINE
-#define GLK_ALAN2_READLINE
-
-/* Header file for user input, history andediting support */
-
-#include "glk/alan2/types.h"
-
-namespace Glk {
-namespace Alan2 {
-
-#define LINELENGTH 80
-#define HISTORYLENGTH 20
-
-extern Boolean readline(char usrbuf[]);
-
-} // End of namespace Alan2
-} // End of namespace Glk
-
-#endif
diff --git a/engines/glk/module.mk b/engines/glk/module.mk
index 6536cf071f..0a5a83d44d 100644
--- a/engines/glk/module.mk
+++ b/engines/glk/module.mk
@@ -43,7 +43,6 @@ MODULE_OBJS := \
alan2/main.o \
alan2/params.o \
alan2/parse.o \
- alan2/readline.o \
alan2/reverse.o \
alan2/rules.o \
alan2/stack.o \