aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2018-11-10 12:21:23 -0800
committerPaul Gilbert2018-12-08 19:05:59 -0800
commitc589b807e2b4ae67928cfadb0a5b2e18cef38ff3 (patch)
tree058876d2136ccecd3af6dc4268c479d3fbe8d0b2
parent43cee5fb0f4fee9669098c21777ac9b41865bee1 (diff)
downloadscummvm-rg350-c589b807e2b4ae67928cfadb0a5b2e18cef38ff3.tar.gz
scummvm-rg350-c589b807e2b4ae67928cfadb0a5b2e18cef38ff3.tar.bz2
scummvm-rg350-c589b807e2b4ae67928cfadb0a5b2e18cef38ff3.zip
GLK: FROTZ: Skeleton sub-engine for Frotz interpreter
-rw-r--r--engines/gargoyle/detection.cpp21
-rw-r--r--engines/gargoyle/frotz/detection.cpp83
-rw-r--r--engines/gargoyle/frotz/detection.h43
-rw-r--r--engines/gargoyle/frotz/frotz.cpp45
-rw-r--r--engines/gargoyle/frotz/frotz.h65
-rw-r--r--engines/gargoyle/frotz/frotz_types.h37
-rw-r--r--engines/gargoyle/module.mk2
-rw-r--r--engines/gargoyle/scott/detection.cpp4
-rw-r--r--engines/gargoyle/scott/detection.h4
9 files changed, 298 insertions, 6 deletions
diff --git a/engines/gargoyle/detection.cpp b/engines/gargoyle/detection.cpp
index 245790a69f..f3b7ca0036 100644
--- a/engines/gargoyle/detection.cpp
+++ b/engines/gargoyle/detection.cpp
@@ -69,6 +69,7 @@ const Common::String &GargoyleEngine::getGameMD5() const {
} // End of namespace Gargoyle
static const PlainGameDescriptor gargoyleGames[] = {
+ {"zcode", "Zcode Games" },
{"scottadams", "Scott Adams Games"},
// Scott Adams games
@@ -94,6 +95,8 @@ static const PlainGameDescriptor gargoyleGames[] = {
#include "common/config-manager.h"
#include "common/file.h"
#include "gargoyle/detection_tables.h"
+#include "gargoyle/frotz/detection.h"
+#include "gargoyle/frotz/frotz.h"
#include "gargoyle/scott/detection.h"
#include "gargoyle/scott/scott.h"
@@ -145,6 +148,9 @@ bool GargoyleMetaEngine::createInstance(OSystem *syst, Engine **engine, const AD
const Gargoyle::GargoyleGameDescription *gd = (const Gargoyle::GargoyleGameDescription *)desc;
switch (gd->_interpType) {
+ case Gargoyle::INTERPRETER_FROTZ:
+ *engine = new Gargoyle::Frotz::Frotz(syst, gd);
+ break;
case Gargoyle::INTERPRETER_SCOTT:
*engine = new Gargoyle::Scott::Scott(syst, gd);
break;
@@ -216,6 +222,7 @@ SaveStateDescriptor GargoyleMetaEngine::querySaveMetaInfos(const char *target, i
DetectedGames GargoyleMetaEngine::detectGames(const Common::FSList &fslist) const {
DetectedGames detectedGames;
+ Gargoyle::Frotz::FrotzMetaEngine::detectGames(fslist, detectedGames);
Gargoyle::Scott::ScottMetaEngine::detectGames(fslist, detectedGames);
return detectedGames;
@@ -234,11 +241,19 @@ ADDetectedGames GargoyleMetaEngine::detectGame(const Common::FSNode &parent, con
ADDetectedGames results;
Common::File f;
- Gargoyle::Scott::ScottMetaEngine::detectGames(fslist, detectedGames);
- if (detectedGames.size() > 0 && f.open(parent.getChild(filename))) {
+ // Check each sub-engine for any detected games
+ if (Gargoyle::Frotz::FrotzMetaEngine::detectGames(fslist, detectedGames))
+ gameDescription._interpType = Gargoyle::INTERPRETER_FROTZ;
+ else if (Gargoyle::Scott::ScottMetaEngine::detectGames(fslist, detectedGames))
+ gameDescription._interpType = Gargoyle::INTERPRETER_SCOTT;
+ else
+ // No match found, so return no results
+ return results;
+
+ // Set up the game description and return it
+ if (f.open(parent.getChild(filename))) {
DetectedGame gd = detectedGames.front();
- gameDescription._interpType = Gargoyle::INTERPRETER_SCOTT;
gameDescription._desc.gameId = gameId;
gameDescription._desc.language = gd.language;
gameDescription._desc.platform = gd.platform;
diff --git a/engines/gargoyle/frotz/detection.cpp b/engines/gargoyle/frotz/detection.cpp
new file mode 100644
index 0000000000..676077778e
--- /dev/null
+++ b/engines/gargoyle/frotz/detection.cpp
@@ -0,0 +1,83 @@
+/* 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 "gargoyle/frotz/detection.h"
+#include "common/file.h"
+#include "common/md5.h"
+
+namespace Gargoyle {
+namespace Frotz {
+
+struct FrotzGame {
+ const char *_md5;
+ const char *_gameId;
+ int32 _filesize;
+ const char *_desc;
+};
+
+const FrotzGame FROTZ_GAMES[] = {
+ { nullptr, nullptr, 0, nullptr }
+};
+
+bool FrotzMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) {
+ Common::File gameFile;
+ Common::String md5;
+ const char *const EXTENSIONS[9] = { ".z1", ".z2", ".z3", ".z4", ".z5", ".z6", ".z7", ".z8", ".zblorb" };
+
+ // 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 < 9 && !hasExt; ++idx)
+ hasExt = filename.hasSuffixIgnoreCase(EXTENSIONS[idx]);
+ if (!hasExt)
+ continue;
+
+ // Check for known game
+ if (gameFile.open(*file)) {
+ md5 = Common::computeStreamMD5AsString(gameFile, 5000);
+
+ // Scan through the game list for a match
+ const FrotzGame *p = FROTZ_GAMES;
+ while (p->_md5 && p->_filesize != gameFile.size() && md5 != p->_md5)
+ ++p;
+
+ if (p->_filesize) {
+ // Found a match
+ DetectedGame gd(p->_gameId, p->_desc, Common::EN_ANY, Common::kPlatformUnknown);
+ gd.addExtraEntry("filename", file->getName());
+
+ gameList.push_back(gd);
+ }
+
+ gameFile.close();
+ }
+ }
+
+ return !gameList.empty();
+}
+
+} // End of namespace Frotz
+} // End of namespace Gargoyle
diff --git a/engines/gargoyle/frotz/detection.h b/engines/gargoyle/frotz/detection.h
new file mode 100644
index 0000000000..2e70d7cc88
--- /dev/null
+++ b/engines/gargoyle/frotz/detection.h
@@ -0,0 +1,43 @@
+/* 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 GARGOYLE_FROTZ_DETECTION
+#define GARGOYLE_FROTZ_DETECTION
+
+#include "common/fs.h"
+#include "engines/game.h"
+
+namespace Gargoyle {
+namespace Frotz {
+
+class FrotzMetaEngine {
+public:
+ /**
+ * Detect supported games
+ */
+ static bool detectGames(const Common::FSList &fslist, DetectedGames &gameList);
+};
+
+} // End of namespace Frotz
+} // End of namespace Gargoyle
+
+#endif
diff --git a/engines/gargoyle/frotz/frotz.cpp b/engines/gargoyle/frotz/frotz.cpp
new file mode 100644
index 0000000000..c13f5b284d
--- /dev/null
+++ b/engines/gargoyle/frotz/frotz.cpp
@@ -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 "gargoyle/frotz/frotz.h"
+#include "gargoyle/frotz/frotz_types.h"
+
+namespace Gargoyle {
+namespace Frotz {
+
+Frotz::Frotz(OSystem *syst, const GargoyleGameDescription *gameDesc) : Glk(syst, gameDesc) {
+}
+
+void Frotz::runGame(Common::SeekableReadStream *gameFile) {
+ // TODO
+}
+
+Common::Error Frotz::loadGameState(int slot) {
+ return Common::kNoError;
+}
+
+Common::Error Frotz::saveGameState(int slot, const Common::String &desc) {
+ return Common::kNoError;
+}
+
+} // End of namespace Scott
+} // End of namespace Gargoyle
diff --git a/engines/gargoyle/frotz/frotz.h b/engines/gargoyle/frotz/frotz.h
new file mode 100644
index 0000000000..8aa2ce73b3
--- /dev/null
+++ b/engines/gargoyle/frotz/frotz.h
@@ -0,0 +1,65 @@
+/* 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 GARGOYLE_FROTZ_FROTZ
+#define GARGOYLE_FROTZ_FROTZ
+
+#include "gargoyle/glk.h"
+#include "gargoyle/frotz/frotz_types.h"
+
+namespace Gargoyle {
+namespace Frotz {
+
+/**
+ * Frotz interpreter for Z-code games
+ */
+class Frotz : public Glk {
+private:
+ /**
+ *
+ */
+public:
+ /**
+ * Constructor
+ */
+ Frotz(OSystem *syst, const GargoyleGameDescription *gameDesc);
+
+ /**
+ * Execute the game
+ */
+ virtual void runGame(Common::SeekableReadStream *gameFile) override;
+
+ /**
+ * Load a savegame
+ */
+ virtual Common::Error loadGameState(int slot) override;
+
+ /**
+ * Save the game
+ */
+ virtual Common::Error saveGameState(int slot, const Common::String &desc) override;
+};
+
+} // End of namespace Frotz
+} // End of namespace Gargoyle
+
+#endif
diff --git a/engines/gargoyle/frotz/frotz_types.h b/engines/gargoyle/frotz/frotz_types.h
new file mode 100644
index 0000000000..d4a6d8c25e
--- /dev/null
+++ b/engines/gargoyle/frotz/frotz_types.h
@@ -0,0 +1,37 @@
+/* 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 GARGOYLE_FROTZ_FROTZ_TYPES
+#define GARGOYLE_FROTZ_FROTZ_TYPES
+
+#include "gargoyle/glk_types.h"
+
+namespace Gargoyle {
+namespace Frotz {
+
+typedef byte zbyte;
+typedef uint16 zword;
+
+} // End of namespace Frotz
+} // End of namespace Gargoyle
+
+#endif
diff --git a/engines/gargoyle/module.mk b/engines/gargoyle/module.mk
index d24a041f7c..135b39c6ca 100644
--- a/engines/gargoyle/module.mk
+++ b/engines/gargoyle/module.mk
@@ -20,6 +20,8 @@ MODULE_OBJS := \
window_pair.o \
window_text_buffer.o \
window_text_grid.o \
+ frotz/detection.o \
+ frotz/frotz.o \
scott/detection.o \
scott/scott.o
diff --git a/engines/gargoyle/scott/detection.cpp b/engines/gargoyle/scott/detection.cpp
index 04d4f83bea..1b8041a52f 100644
--- a/engines/gargoyle/scott/detection.cpp
+++ b/engines/gargoyle/scott/detection.cpp
@@ -53,7 +53,7 @@ const ScottGame SCOTT_GAMES[] = {
{ nullptr, nullptr, 0, nullptr }
};
-void ScottMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) {
+bool ScottMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) {
Common::File gameFile;
Common::String md5;
@@ -81,6 +81,8 @@ void ScottMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &g
gameFile.close();
}
}
+
+ return !gameList.empty();
}
} // End of namespace Scott
diff --git a/engines/gargoyle/scott/detection.h b/engines/gargoyle/scott/detection.h
index e2aa93ed1b..01e1ffe64d 100644
--- a/engines/gargoyle/scott/detection.h
+++ b/engines/gargoyle/scott/detection.h
@@ -32,9 +32,9 @@ namespace Scott {
class ScottMetaEngine {
public:
/**
- * Detect Scott Adams games
+ * Detect supported games
*/
- static void detectGames(const Common::FSList &fslist, DetectedGames &gameList);
+ static bool detectGames(const Common::FSList &fslist, DetectedGames &gameList);
};
} // End of namespace Scott