aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2019-06-18 21:34:44 -0700
committerPaul Gilbert2019-06-22 14:40:49 -0700
commit2fba84bf0a220a3515efdaddb6aae4109d777935 (patch)
treea05807fedda5d6a1112d0f7ea0422cf163c5de7c /engines
parent0bbd9e26385efc19557d3d96ed275f051d7fbd04 (diff)
downloadscummvm-rg350-2fba84bf0a220a3515efdaddb6aae4109d777935.tar.gz
scummvm-rg350-2fba84bf0a220a3515efdaddb6aae4109d777935.tar.bz2
scummvm-rg350-2fba84bf0a220a3515efdaddb6aae4109d777935.zip
GLK: ALAN2: Add Glk window initialization
Diffstat (limited to 'engines')
-rw-r--r--engines/glk/alan2/alan2.cpp27
-rw-r--r--engines/glk/alan2/alan2.h6
-rw-r--r--engines/glk/alan2/glkstart.cpp65
-rw-r--r--engines/glk/alan2/glkstart.h70
-rw-r--r--engines/glk/alan2/main.cpp6
-rw-r--r--engines/glk/module.mk1
6 files changed, 31 insertions, 144 deletions
diff --git a/engines/glk/alan2/alan2.cpp b/engines/glk/alan2/alan2.cpp
index 5a00464f0a..05a024d4d4 100644
--- a/engines/glk/alan2/alan2.cpp
+++ b/engines/glk/alan2/alan2.cpp
@@ -22,6 +22,7 @@
#include "glk/alan2/alan2.h"
#include "glk/alan2/main.h"
+#include "glk/alan2/glkio.h"
#include "common/config-manager.h"
#include "common/translation.h"
#include "common/error.h"
@@ -46,16 +47,30 @@ void Alan2::runGame() {
if (!is_gamefile_valid())
return;
- Common::String filename = getFilename();
- while (filename.contains('.'))
- filename.deleteLastChar();
- advnam = filename.c_str();
+ initialize();
+
+ Glk::Alan2::run();
+}
+
+void Alan2::initialize() {
+ // first, open a window for error output
+ glkMainWin = g_vm->glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
+ if (glkMainWin == nullptr)
+ ::error("FATAL ERROR: Cannot open initial window");
+
+ g_vm->glk_stylehint_set(wintype_TextGrid, style_User1, stylehint_ReverseColor, 1);
+ glkStatusWin = g_vm->glk_window_open(glkMainWin, winmethod_Above |
+ winmethod_Fixed, 1, wintype_TextGrid, 0);
+ g_vm->glk_set_window(glkMainWin);
+
+ _advName = getFilename();
+ while (_advName.contains('.'))
+ _advName.deleteLastChar();
+ advnam = _advName.c_str();
codfil = &_gameFile;
strncpy(codfnm, getFilename().c_str(), 255);
codfnm[255] = '\0';
-
- Glk::Alan2::run();
}
Common::Error Alan2::readSaveData(Common::SeekableReadStream *rs) {
diff --git a/engines/glk/alan2/alan2.h b/engines/glk/alan2/alan2.h
index 3b5c778d95..78c5107406 100644
--- a/engines/glk/alan2/alan2.h
+++ b/engines/glk/alan2/alan2.h
@@ -36,11 +36,17 @@ namespace Alan2 {
class Alan2 : public GlkAPI {
public:
bool vm_exited_cleanly;
+ Common::String _advName;
private:
/**
* Validates the game file, and if it's invalid, displays an error dialog
*/
bool is_gamefile_valid();
+
+ /**
+ * Initialization
+ */
+ void initialize();
public:
/**
* Constructor
diff --git a/engines/glk/alan2/glkstart.cpp b/engines/glk/alan2/glkstart.cpp
deleted file mode 100644
index 1119e18bf0..0000000000
--- a/engines/glk/alan2/glkstart.cpp
+++ /dev/null
@@ -1,65 +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/glkstart.h"
-#include "glk/alan2/glkio.h"
-#include "glk/alan2/args.h"
-
-#include "glk/alan2/alan_version.h"
-
-namespace Glk {
-namespace Alan2 {
-
-glkunix_argumentlist_t glkunix_arguments[] = {
- { "-v", glkunix_arg_NoValue, "-v: verbose mode" },
- { "-l", glkunix_arg_NoValue, "-l: log player command and game output" },
- { "-i", glkunix_arg_NoValue, "-i: ignore version and checksum errors" },
- { "-d", glkunix_arg_NoValue, "-d: enter debug mode" },
- { "-t", glkunix_arg_NoValue, "-t: trace game execution" },
- { "-s", glkunix_arg_NoValue, "-s: single instruction trace" },
- { "", glkunix_arg_ValueFollows, "filename: The game file to load." },
- { NULL, glkunix_arg_End, NULL }
-};
-
-bool glkunix_startup_code(glkunix_startup_t *data) {
- // first, open a window for error output
- glkMainWin = g_vm->glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
- if (glkMainWin == nullptr)
- error("FATAL ERROR: Cannot open initial window");
-
- g_vm->glk_stylehint_set(wintype_TextGrid, style_User1, stylehint_ReverseColor, 1);
- glkStatusWin = g_vm->glk_window_open(glkMainWin, winmethod_Above |
- winmethod_Fixed, 1, wintype_TextGrid, 0);
- g_vm->glk_set_window(glkMainWin);
-
- /* now process the command line arguments */
- args(data->argc, data->argv);
-
- g_vm->garglk_set_program_name(alan.shortHeader);
- g_vm->garglk_set_program_info("Alan Interpreter 2.8.6 by Thomas Nilsson\n");
-
- return true;
-}
-
-} // End of namespace Alan2
-} // End of namespace Glk
diff --git a/engines/glk/alan2/glkstart.h b/engines/glk/alan2/glkstart.h
deleted file mode 100644
index 7e3a24b4dc..0000000000
--- a/engines/glk/alan2/glkstart.h
+++ /dev/null
@@ -1,70 +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_GLK_START
-#define GLK_ALAN2_GLK_START
-
-/* This header defines an interface that must be used by program linked
- with the various Unix Glk libraries -- at least, the three I wrote.
- (I encourage anyone writing a Unix Glk library to use this interface,
- but it's not part of the Glk spec.)
-
- Because Glk is *almost* perfectly portable, this interface *almost*
- doesn't have to exist. In practice, it's small.
-*/
-
-namespace Glk {
-namespace Alan2 {
-
-#define glkunix_arg_End (0)
-#define glkunix_arg_ValueFollows (1)
-#define glkunix_arg_NoValue (2)
-#define glkunix_arg_ValueCanFollow (3)
-#define glkunix_arg_NumberValue (4)
-
-typedef struct glkunix_argumentlist_struct {
- char *name;
- int argtype;
- char *desc;
-} glkunix_argumentlist_t;
-
-typedef struct glkunix_startup_struct {
- int argc;
- char **argv;
-} glkunix_startup_t;
-
-/* The list of command-line arguments; this should be defined in your code. */
-extern glkunix_argumentlist_t glkunix_arguments[];
-
-/* The external function; this should be defined in your code. */
-extern bool glkunix_startup_code(glkunix_startup_t *data);
-
-/* Some helpful utility functions which the library makes available
- to your code. Obviously, this is nonportable; so you should
- only call it from glkunix_startup_code().
-*/
-extern strid_t glkunix_stream_open_pathname(char *pathname, uint textmode, uint rock);
-
-} // End of namespace Alan2
-} // End of namespace Glk
-
-#endif
diff --git a/engines/glk/alan2/main.cpp b/engines/glk/alan2/main.cpp
index 196ff908ff..2a1b884b3d 100644
--- a/engines/glk/alan2/main.cpp
+++ b/engines/glk/alan2/main.cpp
@@ -1903,10 +1903,12 @@ static void openFiles()
Run the adventure
*/
-void run(void)
-{
+void run() {
openFiles();
+ // Set default line and column
+ col = lin = 1;
+
//setjmp(restart_label); /* Return here if he wanted to restart */
init(); /* Load, initialise and start the adventure */
diff --git a/engines/glk/module.mk b/engines/glk/module.mk
index 49f44ade60..3537fcd553 100644
--- a/engines/glk/module.mk
+++ b/engines/glk/module.mk
@@ -39,7 +39,6 @@ MODULE_OBJS := \
alan2/decode.o \
alan2/exe.o \
alan2/glkio.o \
- alan2/glkstart.o \
alan2/inter.o \
alan2/main.o \
alan2/params.o \