aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2019-09-30 20:33:24 -0700
committerPaul Gilbert2019-10-07 19:01:51 -0700
commit3653e83dc9f4f3d97e548ce98616ea41c291d803 (patch)
tree56271f103e2931f76902cccbfd3bd9d0c424f8b2
parentb808b572cfe119497e27ae04e4828549579dc4c4 (diff)
downloadscummvm-rg350-3653e83dc9f4f3d97e548ce98616ea41c291d803.tar.gz
scummvm-rg350-3653e83dc9f4f3d97e548ce98616ea41c291d803.tar.bz2
scummvm-rg350-3653e83dc9f4f3d97e548ce98616ea41c291d803.zip
GLK: JACL: Skeleton subengine commit
-rw-r--r--engines/glk/detection.cpp9
-rw-r--r--engines/glk/jacl/detection.cpp93
-rw-r--r--engines/glk/jacl/detection.h60
-rw-r--r--engines/glk/jacl/detection_tables.h45
-rw-r--r--engines/glk/jacl/jacl.cpp58
-rw-r--r--engines/glk/jacl/jacl.h86
-rw-r--r--engines/glk/module.mk2
7 files changed, 353 insertions, 0 deletions
diff --git a/engines/glk/detection.cpp b/engines/glk/detection.cpp
index f6531723d0..08dd7d0ce6 100644
--- a/engines/glk/detection.cpp
+++ b/engines/glk/detection.cpp
@@ -37,6 +37,8 @@
#include "glk/glulxe/glulxe.h"
#include "glk/hugo/detection.h"
#include "glk/hugo/hugo.h"
+#include "glk/jacl/detection.h"
+#include "glk/jacl/jacl.h"
#include "glk/magnetic/detection.h"
#include "glk/magnetic/magnetic.h"
#include "glk/quest/detection.h"
@@ -168,6 +170,7 @@ Common::Error GlkMetaEngine::createInstance(OSystem *syst, Engine **engine) cons
else if ((*engine = create<Glk::Quest::QuestMetaEngine, Glk::Quest::Quest>(syst, gameDesc)) != nullptr) {}
else if ((*engine = create<Glk::Scott::ScottMetaEngine, Glk::Scott::Scott>(syst, gameDesc)) != nullptr) {}
#ifndef RELEASE_BUILD
+ else if ((*engine = create<Glk::JACL::JACLMetaEngine, Glk::JACL::JACL>(syst, gameDesc)) != nullptr) {}
else if ((*engine = create<Glk::Magnetic::MagneticMetaEngine, Glk::Magnetic::Magnetic>(syst, gameDesc)) != nullptr) {}
else if ((td = Glk::TADS::TADSMetaEngine::findGame(gameDesc._gameId.c_str()))._description) {
if (td._options & Glk::TADS::OPTION_TADS3)
@@ -217,6 +220,7 @@ PlainGameList GlkMetaEngine::getSupportedGames() const {
Glk::Quest::QuestMetaEngine::getSupportedGames(list);
Glk::Scott::ScottMetaEngine::getSupportedGames(list);
#ifndef RELEASE_BUILD
+ Glk::JACL::JACLMetaEngine::getSupportedGames(list);
Glk::Magnetic::MagneticMetaEngine::getSupportedGames(list);
Glk::TADS::TADSMetaEngine::getSupportedGames(list);
#endif
@@ -253,6 +257,9 @@ PlainGameDescriptor GlkMetaEngine::findGame(const char *gameId) const {
if (gd._description) return gd;
#ifndef RELEASE_BUILD
+ gd = Glk::JACL::JACLMetaEngine::findGame(gameId);
+ if (gd._description) return gd;
+
gd = Glk::Magnetic::MagneticMetaEngine::findGame(gameId);
if (gd._description) return gd;
@@ -278,6 +285,7 @@ DetectedGames GlkMetaEngine::detectGames(const Common::FSList &fslist) const {
Glk::Scott::ScottMetaEngine::detectGames(fslist, detectedGames);
#ifndef RELEASE_BUILD
+ Glk::JACL::JACLMetaEngine::detectGames(fslist, detectedGames);
Glk::Magnetic::MagneticMetaEngine::detectGames(fslist, detectedGames);
Glk::TADS::TADSMetaEngine::detectGames(fslist, detectedGames);
#endif
@@ -298,6 +306,7 @@ void GlkMetaEngine::detectClashes() const {
Glk::Scott::ScottMetaEngine::detectClashes(map);
#ifndef RELEASE_BUILD
+ Glk::JACL::JACLMetaEngine::detectClashes(map);
Glk::Magnetic::MagneticMetaEngine::detectClashes(map);
Glk::TADS::TADSMetaEngine::detectClashes(map);
#endif
diff --git a/engines/glk/jacl/detection.cpp b/engines/glk/jacl/detection.cpp
new file mode 100644
index 0000000000..63d0485fa7
--- /dev/null
+++ b/engines/glk/jacl/detection.cpp
@@ -0,0 +1,93 @@
+/* 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/jacl/detection.h"
+#include "glk/jacl/detection_tables.h"
+#include "common/debug.h"
+#include "common/file.h"
+#include "common/md5.h"
+#include "engines/game.h"
+
+namespace Glk {
+namespace JACL {
+
+void JACLMetaEngine::getSupportedGames(PlainGameList &games) {
+ for (const PlainGameDescriptor *pd = JACL_GAME_LIST; pd->gameId; ++pd)
+ games.push_back(*pd);
+}
+
+GameDescriptor JACLMetaEngine::findGame(const char *gameId) {
+ for (const PlainGameDescriptor *pd = JACL_GAME_LIST; pd->gameId; ++pd) {
+ if (!strcmp(gameId, pd->gameId))
+ return *pd;
+ }
+
+ return GameDescriptor::empty();
+}
+
+bool JACLMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) {
+ // 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();
+ if (!filename.hasSuffixIgnoreCase(".j2"))
+ continue;
+
+ Common::File gameFile;
+ if (!gameFile.open(*file))
+ continue;
+
+ gameFile.seek(0);
+ Common::String md5 = Common::computeStreamMD5AsString(gameFile, 5000);
+ uint32 filesize = gameFile.size();
+
+ // Scan through the JACL game list for a match
+ const GlkDetectionEntry *p = JACL_GAMES;
+ while (p->_md5 && p->_filesize != filesize && md5 != p->_md5)
+ ++p;
+
+ if (!p->_gameId) {
+ const PlainGameDescriptor &desc = JACL_GAME_LIST[0];
+ gameList.push_back(GlkDetectedGame(desc.gameId, desc.description, filename, md5, filesize));
+ } else {
+ // Found a match
+ PlainGameDescriptor gameDesc = findGame(p->_gameId);
+ gameList.push_back(GlkDetectedGame(p->_gameId, gameDesc.description, filename));
+ }
+ }
+
+ return !gameList.empty();
+}
+
+void JACLMetaEngine::detectClashes(Common::StringMap &map) {
+ for (const PlainGameDescriptor *pd = JACL_GAME_LIST; pd->gameId; ++pd) {
+ if (map.contains(pd->gameId))
+ error("Duplicate game Id found - %s", pd->gameId);
+ map[pd->gameId] = "";
+ }
+}
+
+} // End of namespace JACL
+} // End of namespace Glk
diff --git a/engines/glk/jacl/detection.h b/engines/glk/jacl/detection.h
new file mode 100644
index 0000000000..f576b66906
--- /dev/null
+++ b/engines/glk/jacl/detection.h
@@ -0,0 +1,60 @@
+/* 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 JACL_DETECTION
+#define JACL_DETECTION
+
+#include "common/fs.h"
+#include "common/hash-str.h"
+#include "engines/game.h"
+#include "glk/detection.h"
+
+namespace Glk {
+namespace JACL {
+
+class JACLMetaEngine {
+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 GameDescriptor findGame(const char *gameId);
+
+ /**
+ * Detect supported games
+ */
+ static bool detectGames(const Common::FSList &fslist, DetectedGames &gameList);
+
+ /**
+ * Check for game Id clashes with other sub-engines
+ */
+ static void detectClashes(Common::StringMap &map);
+};
+
+} // End of namespace JACL
+} // End of namespace Glk
+
+#endif
diff --git a/engines/glk/jacl/detection_tables.h b/engines/glk/jacl/detection_tables.h
new file mode 100644
index 0000000000..a5d7b03b6f
--- /dev/null
+++ b/engines/glk/jacl/detection_tables.h
@@ -0,0 +1,45 @@
+/* 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 JACL {
+
+const PlainGameDescriptor JACL_GAME_LIST[] = {
+ { "prisonbreak", "Prisoner Break" },
+ { "unholygrail", "The Unholy Grail" },
+
+ { nullptr, nullptr }
+};
+
+const GlkDetectionEntry JACL_GAMES[] = {
+ DT_ENTRY0("prisonbreak", "e2e85c5e60a63575bf0cd0481f0f3958", 199403),
+ DT_ENTRY0("unholygrail", "7d40e485c8cf8c9d5c4958a79337d6c7", 447833),
+
+ DT_END_MARKER
+};
+
+} // End of namespace JACL
+} // End of namespace Glk
diff --git a/engines/glk/jacl/jacl.cpp b/engines/glk/jacl/jacl.cpp
new file mode 100644
index 0000000000..998a3fc5e8
--- /dev/null
+++ b/engines/glk/jacl/jacl.cpp
@@ -0,0 +1,58 @@
+/* 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/jacl/jacl.h"
+#include "common/config-manager.h"
+
+namespace Glk {
+namespace JACL {
+
+JACL *g_vm;
+
+JACL::JACL(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gameDesc),
+ _saveSlot(-1) {
+ g_vm = this;
+}
+
+void JACL::runGame() {
+ // Check for savegame
+ _saveSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1;
+
+}
+
+bool JACL::initialize() {
+ return true;
+}
+
+void JACL::deinitialize() {
+}
+
+Common::Error JACL::readSaveData(Common::SeekableReadStream *rs) {
+ return Common::kNoError;
+}
+
+Common::Error JACL::writeGameData(Common::WriteStream *ws) {
+ return Common::kNoError;
+}
+
+} // End of namespace JACL
+} // End of namespace Glk
diff --git a/engines/glk/jacl/jacl.h b/engines/glk/jacl/jacl.h
new file mode 100644
index 0000000000..49def8fd11
--- /dev/null
+++ b/engines/glk/jacl/jacl.h
@@ -0,0 +1,86 @@
+/* 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 JACL_JACL
+#define JACL_JACL
+
+#include "glk/glk_api.h"
+
+namespace Glk {
+namespace JACL {
+
+/**
+ * JACL game interpreter
+ */
+class JACL : public GlkAPI {
+private:
+ int _saveSlot;
+private:
+ /**
+ * Engine initialization
+ */
+ bool initialize();
+
+ /**
+ * Engine cleanup
+ */
+ void deinitialize();
+public:
+ /**
+ * Constructor
+ */
+ JACL(OSystem *syst, const GlkGameDescription &gameDesc);
+
+ /**
+ * Run the game
+ */
+ virtual void runGame() override;
+
+ /**
+ * Returns the running interpreter type
+ */
+ virtual InterpreterType getInterpreterType() const override {
+ return INTERPRETER_JACL;
+ }
+
+ /**
+ * Savegames aren't supported for JACL games
+ */
+ virtual Common::Error readSaveData(Common::SeekableReadStream *rs) override;
+
+ /**
+ * Savegames aren't supported for JACL games
+ */
+ virtual Common::Error writeGameData(Common::WriteStream *ws) override;
+
+ /**
+ * Returns true if a savegame is being loaded directly from the ScummVM launcher
+ */
+ bool loadingSavegame() const { return _saveSlot != -1; }
+};
+
+extern JACL *g_vm;
+
+} // End of namespace JACL
+} // End of namespace Glk
+
+#endif
diff --git a/engines/glk/module.mk b/engines/glk/module.mk
index 8dfb249bc0..0082631539 100644
--- a/engines/glk/module.mk
+++ b/engines/glk/module.mk
@@ -177,6 +177,8 @@ MODULE_OBJS := \
hugo/htokens.o \
hugo/hugo.o \
hugo/stringfn.o \
+ jacl/detection.o \
+ jacl/jacl.o \
magnetic/detection.o \
magnetic/emu.o \
magnetic/graphics.o \