aboutsummaryrefslogtreecommitdiff
path: root/engines/glk
diff options
context:
space:
mode:
Diffstat (limited to 'engines/glk')
-rw-r--r--engines/glk/alan3/detection.cpp106
-rw-r--r--engines/glk/alan3/detection.h63
-rw-r--r--engines/glk/alan3/detection_tables.h69
-rw-r--r--engines/glk/alan3/glkio.cpp3
-rw-r--r--engines/glk/alan3/save.cpp10
-rw-r--r--engines/glk/detection.cpp8
-rw-r--r--engines/glk/module.mk1
7 files changed, 259 insertions, 1 deletions
diff --git a/engines/glk/alan3/detection.cpp b/engines/glk/alan3/detection.cpp
new file mode 100644
index 0000000000..cafc426151
--- /dev/null
+++ b/engines/glk/alan3/detection.cpp
@@ -0,0 +1,106 @@
+/* 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/alan3/detection.h"
+#include "glk/alan3/detection_tables.h"
+#include "common/debug.h"
+#include "common/file.h"
+#include "common/md5.h"
+#include "engines/game.h"
+
+namespace Glk {
+namespace Alan3 {
+
+void Alan3MetaEngine::getSupportedGames(PlainGameList &games) {
+ for (const PlainGameDescriptor *pd = ALAN3_GAME_LIST; pd->gameId; ++pd) {
+ games.push_back(*pd);
+ }
+}
+
+GameDescriptor Alan3MetaEngine::findGame(const char *gameId) {
+ for (const PlainGameDescriptor *pd = ALAN3_GAME_LIST; pd->gameId; ++pd) {
+ if (!strcmp(gameId, pd->gameId))
+ return *pd;
+ }
+
+ return GameDescriptor::empty();
+}
+
+bool Alan3MetaEngine::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();
+ bool hasExt = filename.hasSuffix(".a3c");
+ if (!hasExt)
+ continue;
+
+ // Open up the file and calculate the md5
+ Common::File gameFile;
+ if (!gameFile.open(*file) || gameFile.readUint32BE() != MKTAG('A', 'L', 'A', 'N'))
+ continue;
+
+ gameFile.seek(0);
+ Common::String md5 = Common::computeStreamMD5AsString(gameFile, 5000);
+ size_t filesize = gameFile.size();
+ gameFile.close();
+
+ // Check for known games
+ const Alan3GameDescription *p = ALAN3_GAMES;
+ while (p->_gameId && (md5 != p->_md5 || filesize != p->_filesize))
+ ++p;
+
+ DetectedGame gd;
+ if (!p->_gameId) {
+ const PlainGameDescriptor &desc = ALAN3_GAME_LIST[0];
+ gd = DetectedGame(desc.gameId, desc.description, Common::UNK_LANG, Common::kPlatformUnknown);
+ gd.canBeAdded = true;
+ gd.hasUnknownFiles = true;
+ FileProperties fp;
+ fp.md5 = md5;
+ fp.size = filesize;
+ gd.matchedFiles[filename] = fp;
+
+ } else {
+ PlainGameDescriptor gameDesc = findGame(p->_gameId);
+ gd = DetectedGame(p->_gameId, gameDesc.description, Common::EN_ANY, Common::kPlatformUnknown);
+ }
+
+ gd.addExtraEntry("filename", filename);
+ gameList.push_back(gd);
+ }
+
+ return !gameList.empty();
+}
+
+void Alan3MetaEngine::detectClashes(Common::StringMap &map) {
+ for (const PlainGameDescriptor *pd = ALAN3_GAME_LIST; pd->gameId; ++pd) {
+ if (map.contains(pd->gameId))
+ error("Duplicate game Id found - %s", pd->gameId);
+ map[pd->gameId] = "";
+ }
+}
+
+} // End of namespace Alan3
+} // End of namespace Glk
diff --git a/engines/glk/alan3/detection.h b/engines/glk/alan3/detection.h
new file mode 100644
index 0000000000..8fbed735e0
--- /dev/null
+++ b/engines/glk/alan3/detection.h
@@ -0,0 +1,63 @@
+/* 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_ALAN3_DETECTION
+#define GLK_ALAN3_DETECTION
+
+#include "common/fs.h"
+#include "common/hash-str.h"
+#include "engines/game.h"
+#include "glk/detection.h"
+
+namespace Glk {
+namespace Alan3 {
+
+/**
+ * Meta engine for Alan3 interpreter
+ */
+class Alan3MetaEngine {
+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 Alan3
+} // End of namespace Glk
+
+#endif
diff --git a/engines/glk/alan3/detection_tables.h b/engines/glk/alan3/detection_tables.h
new file mode 100644
index 0000000000..8762983e84
--- /dev/null
+++ b/engines/glk/alan3/detection_tables.h
@@ -0,0 +1,69 @@
+/* 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 Alan3 {
+
+/**
+ * Game description
+ */
+struct Alan3GameDescription {
+ const char *const _gameId;
+ const char *const _extra;
+ const char *const _md5;
+ size_t _filesize;
+ Common::Language _language;
+};
+
+const PlainGameDescriptor ALAN3_GAME_LIST[] = {
+ { "alan3", "Alan3 Game" },
+
+ { "christmasparty", "The Christmas Party" },
+ { "deadleaves", "City of Dead Leaves" },
+ { "fishmess", "Fish Mess" },
+ { "hwmurders", "Hollywood Murders" },
+ { "misguided", "Mis/Guided" },
+ { "room206", "Room 206" },
+
+ { 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 Alan3GameDescription ALAN3_GAMES[] = {
+ ENTRY0("christmasparty", "86b87969d124c213632398980ec87c23", 94892),
+ ENTRY0("deadleaves", "7c228698507508043d1d3938695e28cd", 90139),
+ ENTRY0("fishmess", "e9952cfbe2adef5dcef82abd57661f60", 312561),
+ ENTRY0("hwmurders", "abadbb15faf7f0b7324222fdea6bd495", 213539),
+ ENTRY0("misguided", "cc2c6e724d599e731efa9b7a34ae4f51", 672613),
+ ENTRY0("room206", "eb5711ecfad102ee4d9fda7fcb3ddf78", 364156),
+
+ TABLE_END_MARKER
+};
+
+} // End of namespace Alan3
+} // End of namespace Glk
diff --git a/engines/glk/alan3/glkio.cpp b/engines/glk/alan3/glkio.cpp
index b0671561f6..4d0963b65d 100644
--- a/engines/glk/alan3/glkio.cpp
+++ b/engines/glk/alan3/glkio.cpp
@@ -26,6 +26,9 @@
namespace Glk {
namespace Alan3 {
+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)
diff --git a/engines/glk/alan3/save.cpp b/engines/glk/alan3/save.cpp
index f1b7d0df4c..506cf9ded0 100644
--- a/engines/glk/alan3/save.cpp
+++ b/engines/glk/alan3/save.cpp
@@ -20,6 +20,9 @@
*
*/
+namespace Glk {
+namespace Alan3 {
+
#ifdef TODO
/*----------------------------------------------------------------------*/
@@ -352,5 +355,10 @@ void restore(void) {
fclose(saveFile);
}
-
+#else
+void save() {}
+void restore() {}
#endif
+
+} // End of namespace Alan3
+} // End of namespace Glk
diff --git a/engines/glk/detection.cpp b/engines/glk/detection.cpp
index beeb410830..33a15757ba 100644
--- a/engines/glk/detection.cpp
+++ b/engines/glk/detection.cpp
@@ -27,6 +27,8 @@
#include "glk/advsys/advsys.h"
#include "glk/alan2/detection.h"
#include "glk/alan2/alan2.h"
+#include "glk/alan3/detection.h"
+#include "glk/alan3/alan3.h"
#include "glk/frotz/detection.h"
#include "glk/frotz/frotz.h"
#include "glk/glulxe/detection.h"
@@ -121,6 +123,7 @@ Common::Error GlkMetaEngine::createInstance(OSystem *syst, Engine **engine) cons
else if ((*engine = create<Glk::Hugo::HugoMetaEngine, Glk::Hugo::Hugo>(syst, gameDesc)) != nullptr) {}
else if ((*engine = create<Glk::Scott::ScottMetaEngine, Glk::Scott::Scott>(syst, gameDesc)) != nullptr) {}
#ifndef RELEASE_BUILD
+ else if ((*engine = create<Glk::Alan3::Alan3MetaEngine, Glk::Alan3::Alan3>(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)
@@ -167,6 +170,7 @@ PlainGameList GlkMetaEngine::getSupportedGames() const {
Glk::Hugo::HugoMetaEngine::getSupportedGames(list);
Glk::Scott::ScottMetaEngine::getSupportedGames(list);
#ifndef RELEASE_BUILD
+ Glk::Alan3::Alan3MetaEngine::getSupportedGames(list);
Glk::Magnetic::MagneticMetaEngine::getSupportedGames(list);
Glk::TADS::TADSMetaEngine::getSupportedGames(list);
#endif
@@ -194,6 +198,8 @@ PlainGameDescriptor GlkMetaEngine::findGame(const char *gameId) const {
if (gd._description) return gd;
#ifndef RELEASE_BUILD
+ gd = Glk::Alan3::Alan3MetaEngine::findGame(gameId);
+ if (gd._description) return gd;
gd = Glk::Magnetic::MagneticMetaEngine::findGame(gameId);
if (gd._description) return gd;
@@ -217,6 +223,7 @@ DetectedGames GlkMetaEngine::detectGames(const Common::FSList &fslist) const {
Glk::Scott::ScottMetaEngine::detectGames(fslist, detectedGames);
#ifndef RELEASE_BUILD
+ Glk::Alan3::Alan3MetaEngine::detectGames(fslist, detectedGames);
Glk::Magnetic::MagneticMetaEngine::detectGames(fslist, detectedGames);
Glk::TADS::TADSMetaEngine::detectGames(fslist, detectedGames);
#endif
@@ -234,6 +241,7 @@ void GlkMetaEngine::detectClashes() const {
Glk::Scott::ScottMetaEngine::detectClashes(map);
#ifndef RELEASE_BUILD
+ Glk::Alan3::Alan3MetaEngine::detectClashes(map);
Glk::Magnetic::MagneticMetaEngine::detectClashes(map);
Glk::TADS::TADSMetaEngine::detectClashes(map);
#endif
diff --git a/engines/glk/module.mk b/engines/glk/module.mk
index ec6e0f88ea..902b9fc3bd 100644
--- a/engines/glk/module.mk
+++ b/engines/glk/module.mk
@@ -63,6 +63,7 @@ MODULE_OBJS := \
alan3/current.o \
alan3/debug.o \
alan3/decode.o \
+ alan3/detection.o \
alan3/dictionary.o \
alan3/event.o \
alan3/exe.o \