diff options
author | Paul Gilbert | 2018-11-10 12:21:23 -0800 |
---|---|---|
committer | Paul Gilbert | 2018-12-08 19:05:59 -0800 |
commit | c589b807e2b4ae67928cfadb0a5b2e18cef38ff3 (patch) | |
tree | 058876d2136ccecd3af6dc4268c479d3fbe8d0b2 /engines/gargoyle/frotz | |
parent | 43cee5fb0f4fee9669098c21777ac9b41865bee1 (diff) | |
download | scummvm-rg350-c589b807e2b4ae67928cfadb0a5b2e18cef38ff3.tar.gz scummvm-rg350-c589b807e2b4ae67928cfadb0a5b2e18cef38ff3.tar.bz2 scummvm-rg350-c589b807e2b4ae67928cfadb0a5b2e18cef38ff3.zip |
GLK: FROTZ: Skeleton sub-engine for Frotz interpreter
Diffstat (limited to 'engines/gargoyle/frotz')
-rw-r--r-- | engines/gargoyle/frotz/detection.cpp | 83 | ||||
-rw-r--r-- | engines/gargoyle/frotz/detection.h | 43 | ||||
-rw-r--r-- | engines/gargoyle/frotz/frotz.cpp | 45 | ||||
-rw-r--r-- | engines/gargoyle/frotz/frotz.h | 65 | ||||
-rw-r--r-- | engines/gargoyle/frotz/frotz_types.h | 37 |
5 files changed, 273 insertions, 0 deletions
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 |