aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2018-12-08 16:54:31 -0800
committerPaul Gilbert2018-12-08 19:05:59 -0800
commit290196946dab0ee60498be16d8e33bb911e5a166 (patch)
treea58df19ad545b712b3d53dcb4a5b4c9debf61835
parent754819f9281d5207deaff1922a915bd9dc0437b5 (diff)
downloadscummvm-rg350-290196946dab0ee60498be16d8e33bb911e5a166.tar.gz
scummvm-rg350-290196946dab0ee60498be16d8e33bb911e5a166.tar.bz2
scummvm-rg350-290196946dab0ee60498be16d8e33bb911e5a166.zip
GLK: GLULXE: Skeleton sub-engine
-rw-r--r--engines/glk/blorb.cpp1
-rw-r--r--engines/glk/detection.cpp11
-rw-r--r--engines/glk/glk.cpp3
-rw-r--r--engines/glk/glk_types.h19
-rw-r--r--engines/glk/glulxe/detection.cpp111
-rw-r--r--engines/glk/glulxe/detection.h71
-rw-r--r--engines/glk/glulxe/detection_tables.h57
-rw-r--r--engines/glk/glulxe/glulxe.cpp48
-rw-r--r--engines/glk/glulxe/glulxe.h66
-rw-r--r--engines/glk/module.mk2
10 files changed, 378 insertions, 11 deletions
diff --git a/engines/glk/blorb.cpp b/engines/glk/blorb.cpp
index 4a4cf8c531..1438abb66b 100644
--- a/engines/glk/blorb.cpp
+++ b/engines/glk/blorb.cpp
@@ -171,6 +171,7 @@ Common::ErrorCode Blorb::load() {
if (
(_interpType == INTERPRETER_FROTZ && type == "ZCOD") ||
+ (_interpType == INTERPRETER_GLULXE && type == "GLUL") ||
(_interpType == INTERPRETER_TADS2 && type == "TAD2") ||
(_interpType == INTERPRETER_TADS3 && type == "TAD3") ||
(_interpType == INTERPRETER_HUGO && type == "HUGO")
diff --git a/engines/glk/detection.cpp b/engines/glk/detection.cpp
index 491c6c8b82..b8481788cc 100644
--- a/engines/glk/detection.cpp
+++ b/engines/glk/detection.cpp
@@ -23,6 +23,8 @@
#include "glk/glk.h"
#include "glk/frotz/detection.h"
#include "glk/frotz/frotz.h"
+#include "glk/glulxe/detection.h"
+#include "glk/glulxe/glulxe.h"
#include "glk/scott/detection.h"
#include "glk/scott/scott.h"
#include "glk/tads/detection.h"
@@ -132,9 +134,11 @@ Common::Error GlkMetaEngine::createInstance(OSystem *syst, Engine **engine) cons
gameDesc._md5 = Common::computeStreamMD5AsString(f, 5000);
f.close();
- // Correct the correct engine
+ // Create the correct engine
if (Glk::Frotz::FrotzMetaEngine::findGame(gameDesc._gameId.c_str()).description) {
*engine = new Glk::Frotz::Frotz(syst, gameDesc);
+ } else if (Glk::Glulxe::GlulxeMetaEngine::findGame(gameDesc._gameId.c_str()).description) {
+ *engine = new Glk::Glulxe::Glulxe(syst, gameDesc);
} else if (Glk::Scott::ScottMetaEngine::findGame(gameDesc._gameId.c_str()).description) {
*engine = new Glk::Scott::Scott(syst, gameDesc);
} else if ((td = Glk::TADS::TADSMetaEngine::findGame(gameDesc._gameId.c_str())).description) {
@@ -174,6 +178,7 @@ Common::String GlkMetaEngine::findFileByGameId(const Common::String &gameId) con
PlainGameList GlkMetaEngine::getSupportedGames() const {
PlainGameList list;
Glk::Frotz::FrotzMetaEngine::getSupportedGames(list);
+ Glk::Glulxe::GlulxeMetaEngine::getSupportedGames(list);
Glk::Scott::ScottMetaEngine::getSupportedGames(list);
Glk::TADS::TADSMetaEngine::getSupportedGames(list);
@@ -186,6 +191,9 @@ PlainGameDescriptor GlkMetaEngine::findGame(const char *gameId) const {
gd = Glk::Frotz::FrotzMetaEngine::findGame(gameId);
if (gd.description) return gd;
+ gd = Glk::Glulxe::GlulxeMetaEngine::findGame(gameId);
+ if (gd.description) return gd;
+
gd = Glk::Scott::ScottMetaEngine::findGame(gameId);
if (gd.description) return gd;
@@ -198,6 +206,7 @@ PlainGameDescriptor GlkMetaEngine::findGame(const char *gameId) const {
DetectedGames GlkMetaEngine::detectGames(const Common::FSList &fslist) const {
DetectedGames detectedGames;
Glk::Frotz::FrotzMetaEngine::detectGames(fslist, detectedGames);
+ Glk::Glulxe::GlulxeMetaEngine::detectGames(fslist, detectedGames);
Glk::Scott::ScottMetaEngine::detectGames(fslist, detectedGames);
Glk::TADS::TADSMetaEngine::detectGames(fslist, detectedGames);
diff --git a/engines/glk/glk.cpp b/engines/glk/glk.cpp
index 849de8d8f3..8c35cfe45e 100644
--- a/engines/glk/glk.cpp
+++ b/engines/glk/glk.cpp
@@ -114,7 +114,8 @@ Common::Error GlkEngine::run() {
initialize();
- if (filename.hasSuffixIgnoreCase(".blorb") || filename.hasSuffixIgnoreCase(".zblorb")) {
+ if (filename.hasSuffixIgnoreCase(".blorb") || filename.hasSuffixIgnoreCase(".zblorb")
+ || filename.hasSuffixIgnoreCase(".gblorb")) {
// Blorb archive
_blorb = new Blorb(filename, getInterpreterType());
SearchMan.add("blorb", _blorb, 99, false);
diff --git a/engines/glk/glk_types.h b/engines/glk/glk_types.h
index abae785ae8..3c8f60f9d6 100644
--- a/engines/glk/glk_types.h
+++ b/engines/glk/glk_types.h
@@ -43,15 +43,16 @@ enum InterpreterType {
INTERPRETER_BOCFEL = 4,
INTERPRETER_FROTZ = 5,
INTERPRETER_GEAS = 6,
- INTERPRETER_HUGO = 7,
- INTERPRETER_JACL = 8,
- INTERPRETER_LEVEL9 = 9,
- INTERPRETER_MAGNETIC = 10,
- INTERPRETER_NITFOL = 11,
- INTERPRETER_SCARE = 12,
- INTERPRETER_SCOTT = 13,
- INTERPRETER_TADS2 = 14,
- INTERPRETER_TADS3 = 15
+ INTERPRETER_GLULXE = 7,
+ INTERPRETER_HUGO = 8,
+ INTERPRETER_JACL = 9,
+ INTERPRETER_LEVEL9 = 10,
+ INTERPRETER_MAGNETIC = 11,
+ INTERPRETER_NITFOL = 12,
+ INTERPRETER_SCARE = 13,
+ INTERPRETER_SCOTT = 14,
+ INTERPRETER_TADS2 = 15,
+ INTERPRETER_TADS3 = 16
};
/**
diff --git a/engines/glk/glulxe/detection.cpp b/engines/glk/glulxe/detection.cpp
new file mode 100644
index 0000000000..0e1ec1f907
--- /dev/null
+++ b/engines/glk/glulxe/detection.cpp
@@ -0,0 +1,111 @@
+/* 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/glulxe/detection.h"
+#include "glk/glulxe/detection_tables.h"
+#include "common/debug.h"
+#include "common/file.h"
+#include "common/md5.h"
+#include "engines/game.h"
+
+namespace Glk {
+namespace Glulxe {
+
+void GlulxeMetaEngine::getSupportedGames(PlainGameList &games) {
+ for (const GlulxeDescriptor *pd = GLULXE_GAME_LIST; pd->gameId; ++pd) {
+ games.push_back(*pd);
+ }
+}
+
+GlulxeDescriptor GlulxeMetaEngine::findGame(const char *gameId) {
+ for (const GlulxeDescriptor *pd = GLULXE_GAME_LIST; pd->gameId; ++pd) {
+ if (!strcmp(gameId, pd->gameId))
+ return *pd;
+ }
+
+ return GlulxeDescriptor();
+}
+
+bool GlulxeMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) {
+ const char *const EXTENSIONS[3] = { ".ulx", ".blb", ".gblorb" };
+
+ // Loop through the files of the folder
+ for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
+ // Check for a recognised filename
+ if (file->isDirectory())
+ continue;
+ Common::String filename = file->getName();
+ bool hasExt = false;
+ for (int idx = 0; idx < 3 && !hasExt; ++idx)
+ hasExt = filename.hasSuffixIgnoreCase(EXTENSIONS[idx]);
+ if (!hasExt)
+ continue;
+
+ // Open up the file and calculate the md5
+ Common::File gameFile;
+ if (!gameFile.open(*file))
+ continue;
+ Common::String md5 = Common::computeStreamMD5AsString(gameFile, 5000);
+ size_t filesize = gameFile.size();
+ gameFile.close();
+
+ // Check for known games
+ const GlulxeGameDescription *p = GLULXE_GAMES;
+ while (p->_gameId && (md5 != p->_md5 || filesize != p->_filesize))
+ ++p;
+
+ DetectedGame gd;
+ if (!p->_gameId) {
+ if (filename.hasSuffixIgnoreCase(".blb"))
+ continue;
+
+ if (gDebugLevel > 0) {
+ // Print an entry suitable for putting into the detection_tables.h, using the
+ // name of the parent folder the game is in as the presumed game Id
+ Common::String folderName = file->getParent().getName();
+ if (folderName.hasSuffix("\\"))
+ folderName.deleteLastChar();
+ Common::String fname = filename;
+ const char *dot = strchr(fname.c_str(), '.');
+ if (dot)
+ fname = Common::String(fname.c_str(), dot);
+
+ debug("ENTRY0(\"%s\", \"%s\", %lu),",
+ fname.c_str(), md5.c_str(), filesize);
+ }
+ const PlainGameDescriptor &desc = GLULXE_GAME_LIST[0];
+ gd = DetectedGame(desc.gameId, desc.description, Common::UNK_LANG, Common::kPlatformUnknown);
+ } else {
+ PlainGameDescriptor gameDesc = findGame(p->_gameId);
+ gd = DetectedGame(p->_gameId, gameDesc.description, p->_language, Common::kPlatformUnknown, p->_extra);
+ gd.setGUIOptions(GUIO4(GUIO_NOSPEECH, GUIO_NOSFX, GUIO_NOMUSIC, GUIO_NOSUBTITLES));
+ }
+
+ gd.addExtraEntry("filename", filename);
+ gameList.push_back(gd);
+ }
+
+ return !gameList.empty();
+}
+
+} // End of namespace Glulxe
+} // End of namespace Glk
diff --git a/engines/glk/glulxe/detection.h b/engines/glk/glulxe/detection.h
new file mode 100644
index 0000000000..d6d5c6a9ad
--- /dev/null
+++ b/engines/glk/glulxe/detection.h
@@ -0,0 +1,71 @@
+/* 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_GLULXE_DETECTION
+#define GLK_GLULXE_DETECTION
+
+#include "common/fs.h"
+#include "engines/game.h"
+
+namespace Glk {
+namespace Glulxe {
+
+/**
+ * Glulxe game descriptior
+ */
+struct GlulxeDescriptor {
+ const char *gameId;
+ const char *description;
+
+ operator PlainGameDescriptor() const {
+ PlainGameDescriptor pd;
+ pd.gameId = gameId;
+ pd.description = description;
+ return pd;
+ }
+};
+
+/**
+ * Meta engine for Glulxe interpreter
+ */
+class GlulxeMetaEngine {
+public:
+ /**
+ * Get a list of supported games
+ */
+ static void getSupportedGames(PlainGameList &games);
+
+ /**
+ * Returns a game description for the given game Id, if it's supported
+ */
+ static GlulxeDescriptor findGame(const char *gameId);
+
+ /**
+ * Detect supported games
+ */
+ static bool detectGames(const Common::FSList &fslist, DetectedGames &gameList);
+};
+
+} // End of namespace Glulxe
+} // End of namespace Glk
+
+#endif
diff --git a/engines/glk/glulxe/detection_tables.h b/engines/glk/glulxe/detection_tables.h
new file mode 100644
index 0000000000..17c5ffd55b
--- /dev/null
+++ b/engines/glk/glulxe/detection_tables.h
@@ -0,0 +1,57 @@
+/* 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 "engines/game.h"
+#include "common/gui_options.h"
+#include "common/language.h"
+
+namespace Glk {
+namespace Glulxe {
+
+/**
+ * Game description
+ */
+struct GlulxeGameDescription {
+ const char *const _gameId;
+ const char *const _extra;
+ const char *const _md5;
+ size_t _filesize;
+ Common::Language _language;
+};
+
+const GlulxeDescriptor GLULXE_GAME_LIST[] = {
+ { "glulxe", "Glulxe Game" },
+ { "cragne", "Cragne Manor" },
+
+ { nullptr, nullptr }
+};
+
+#define ENTRY0(ID, MD5, FILESIZE) { ID, nullptr, MD5, FILESIZE, Common::EN_ANY }
+#define TABLE_END_MARKER { nullptr, nullptr, nullptr, 0, Common::EN_ANY }
+
+const GlulxeGameDescription GLULXE_GAMES[] = {
+ ENTRY0("cragne", "082f518c0120d2323ce340bef8a2d5a9", 8869096),
+ TABLE_END_MARKER
+};
+
+} // End of namespace Glulxe
+} // End of namespace Glk
diff --git a/engines/glk/glulxe/glulxe.cpp b/engines/glk/glulxe/glulxe.cpp
new file mode 100644
index 0000000000..25af4c2f4d
--- /dev/null
+++ b/engines/glk/glulxe/glulxe.cpp
@@ -0,0 +1,48 @@
+/* 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/glulxe/glulxe.h"
+#include "common/config-manager.h"
+#include "common/translation.h"
+
+namespace Glk {
+namespace Glulxe {
+
+Glulxe::Glulxe(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gameDesc) {
+}
+
+void Glulxe::runGame(Common::SeekableReadStream *gameFile) {
+ // TODO
+}
+
+Common::Error Glulxe::loadGameData(strid_t file) {
+ // TODO
+ return Common::kNoError;
+}
+
+Common::Error Glulxe::saveGameData(strid_t file, const Common::String &desc) {
+ // TODO
+ return Common::kNoError;
+}
+
+} // End of namespace Glulxe
+} // End of namespace Glk
diff --git a/engines/glk/glulxe/glulxe.h b/engines/glk/glulxe/glulxe.h
new file mode 100644
index 0000000000..eb4aaf3657
--- /dev/null
+++ b/engines/glk/glulxe/glulxe.h
@@ -0,0 +1,66 @@
+/* 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_GLULXE
+#define GLK_GLULXE
+
+#include "common/scummsys.h"
+#include "glk/glk_api.h"
+
+namespace Glk {
+namespace Glulxe {
+
+/**
+ * Glulxe game interpreter
+ */
+class Glulxe : public GlkAPI {
+public:
+ /**
+ * Constructor
+ */
+ Glulxe(OSystem *syst, const GlkGameDescription &gameDesc);
+
+ /**
+ * Run the game
+ */
+ void runGame(Common::SeekableReadStream *gameFile);
+
+ /**
+ * Returns the running interpreter type
+ */
+ virtual InterpreterType getInterpreterType() const override { return INTERPRETER_GLULXE; }
+
+ /**
+ * Load a savegame from the passed stream
+ */
+ virtual Common::Error loadGameData(strid_t file) override;
+
+ /**
+ * Save the game to the passed stream
+ */
+ virtual Common::Error saveGameData(strid_t file, const Common::String &desc) override;
+};
+
+} // End of namespace Glulxe
+} // End of namespace Glk
+
+#endif
diff --git a/engines/glk/module.mk b/engines/glk/module.mk
index de69645db5..71644814af 100644
--- a/engines/glk/module.mk
+++ b/engines/glk/module.mk
@@ -44,6 +44,8 @@ MODULE_OBJS := \
frotz/quetzal.o \
frotz/screen.o \
frotz/sound_folder.o \
+ glulxe/detection.o \
+ glulxe/glulxe.o \
scott/detection.o \
scott/scott.o \
tads/detection.o \