diff options
Diffstat (limited to 'engines/glk')
-rw-r--r-- | engines/glk/configure.engine | 3 | ||||
-rw-r--r-- | engines/glk/detection.cpp | 21 | ||||
-rw-r--r-- | engines/glk/level9/detection.cpp | 99 | ||||
-rw-r--r-- | engines/glk/level9/detection.h | 63 | ||||
-rw-r--r-- | engines/glk/level9/detection_tables.h | 42 | ||||
-rw-r--r-- | engines/glk/level9/level9.cpp | 49 | ||||
-rw-r--r-- | engines/glk/level9/level9.h | 84 | ||||
-rw-r--r-- | engines/glk/module.mk | 6 |
8 files changed, 366 insertions, 1 deletions
diff --git a/engines/glk/configure.engine b/engines/glk/configure.engine index e964787e3c..727aa59d65 100644 --- a/engines/glk/configure.engine +++ b/engines/glk/configure.engine @@ -1,6 +1,6 @@ # This file is included from the main "configure" script # add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] -add_engine glk "Glk Interactive Fiction games" no "glk_adrift glk_advsys glk_alan2 glk_alan3 glk_frotz glk_glulxe glk_hugo glk_jacl glk_magnetic glk_quest glk_scott glk_tads" "Base" "16bit freetype2 jpeg png" +add_engine glk "Glk Interactive Fiction games" no "glk_adrift glk_advsys glk_alan2 glk_alan3 glk_frotz glk_glulxe glk_hugo glk_jacl glk_level9 glk_magnetic glk_quest glk_scott glk_tads" "Base" "16bit freetype2 jpeg png" add_engine glk_adrift "ADRIFT" no add_engine glk_advsys "AdvSys" no add_engine glk_alan2 "Alan2" no @@ -9,6 +9,7 @@ add_engine glk_frotz "Frotz" no add_engine glk_glulxe "Glulxe" no add_engine glk_hugo "Hugo" no add_engine glk_jacl "JACL" no +add_engine glk_level9 "Level9" no add_engine glk_magnetic "Magnetic" no add_engine glk_quest "Quest" no add_engine glk_scott "Scott" no diff --git a/engines/glk/detection.cpp b/engines/glk/detection.cpp index 6de2a6f145..b4d5bff84c 100644 --- a/engines/glk/detection.cpp +++ b/engines/glk/detection.cpp @@ -64,6 +64,11 @@ #include "glk/jacl/jacl.h" #endif +#ifdef ENABLE_GLK_LEVEL9 +#include "glk/level9/detection.h" +#include "glk/level9/level9.h" +#endif + #ifdef ENABLE_GLK_MAGNETIC #include "glk/magnetic/detection.h" #include "glk/magnetic/magnetic.h" @@ -228,6 +233,10 @@ Common::Error GlkMetaEngine::createInstance(OSystem *syst, Engine **engine) cons if ((*engine = create<Glk::JACL::JACLMetaEngine, Glk::JACL::JACL>(syst, gameDesc)) != nullptr) {} else #endif +#ifdef ENABLE_GLK_LEVEL9 + if ((*engine = create<Glk::Level9::Level9MetaEngine, Glk::Level9::Level9>(syst, gameDesc)) != nullptr) {} + else +#endif #ifdef ENABLE_GLK_MAGNETIC if ((*engine = create<Glk::Magnetic::MagneticMetaEngine, Glk::Magnetic::Magnetic>(syst, gameDesc)) != nullptr) {} else @@ -303,6 +312,9 @@ PlainGameList GlkMetaEngine::getSupportedGames() const { #ifdef ENABLE_GLK_JACL Glk::JACL::JACLMetaEngine::getSupportedGames(list); #endif +#ifdef ENABLE_GLK_LEVEL9 + Glk::Level9::Level9MetaEngine::getSupportedGames(list); +#endif #ifdef ENABLE_GLK_MAGNETIC Glk::Magnetic::MagneticMetaEngine::getSupportedGames(list); #endif @@ -348,6 +360,9 @@ PlainGameDescriptor GlkMetaEngine::findGame(const char *gameId) const { #ifdef ENABLE_GLK_JACL FIND_GAME(JACL); #endif +#ifdef ENABLE_GLK_LEVEL9 + FIND_GAME(Level9); +#endif #ifdef ENABLE_GLK_MAGNETIC FIND_GAME(Magnetic); #endif @@ -395,6 +410,9 @@ DetectedGames GlkMetaEngine::detectGames(const Common::FSList &fslist) const { #ifdef ENABLE_GLK_JACL Glk::JACL::JACLMetaEngine::detectGames(fslist, detectedGames); #endif +#ifdef ENABLE_GLK_LEVEL9 + Glk::Level9::Level9MetaEngine::detectGames(fslist, detectedGames); +#endif #ifdef ENABLE_GLK_MAGNETIC Glk::Magnetic::MagneticMetaEngine::detectGames(fslist, detectedGames); #endif @@ -437,6 +455,9 @@ void GlkMetaEngine::detectClashes() const { #ifdef ENABLE_GLK_JACL Glk::JACL::JACLMetaEngine::detectClashes(map); #endif +#ifdef ENABLE_GLK_LEVEL9 + Glk::Level9::Level9MetaEngine::detectClashes(map); +#endif #ifdef ENABLE_GLK_MAGNETIC Glk::Magnetic::MagneticMetaEngine::detectClashes(map); #endif diff --git a/engines/glk/level9/detection.cpp b/engines/glk/level9/detection.cpp new file mode 100644 index 0000000000..9904091d97 --- /dev/null +++ b/engines/glk/level9/detection.cpp @@ -0,0 +1,99 @@ +/* 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/level9/detection.h" +#include "glk/level9/detection_tables.h" +#include "glk/blorb.h" +#include "common/debug.h" +#include "common/file.h" +#include "common/md5.h" +#include "engines/game.h" + +namespace Glk { +namespace Level9 { + +void Level9MetaEngine::getSupportedGames(PlainGameList &games) { + for (const PlainGameDescriptor *pd = LEVEL9_GAME_LIST; pd->gameId; ++pd) { + games.push_back(*pd); + } +} + +GameDescriptor Level9MetaEngine::findGame(const char *gameId) { + for (const PlainGameDescriptor *pd = LEVEL9_GAME_LIST; pd->gameId; ++pd) { + if (!strcmp(gameId, pd->gameId)) + return *pd; + } + + return PlainGameDescriptor(); +} + +bool Level9MetaEngine::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(".l9")) + 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.seek(0); + bool isBlorb = Blorb::isBlorb(gameFile, ID_ADRI); + gameFile.close(); + + if (!isBlorb && Blorb::hasBlorbExt(filename)) + continue; + + // Check for known games + const GlkDetectionEntry *p = LEVEL9_GAMES; + while (p->_gameId && (md5 != p->_md5 || filesize != p->_filesize)) + ++p; + + if (!p->_gameId) { + const PlainGameDescriptor &desc = LEVEL9_GAME_LIST[0]; + gameList.push_back(GlkDetectedGame(desc.gameId, desc.description, filename, md5, filesize)); + } else { + PlainGameDescriptor gameDesc = findGame(p->_gameId); + gameList.push_back(GlkDetectedGame(p->_gameId, gameDesc.description, p->_extra, filename, p->_language)); + } + } + + return !gameList.empty(); +} + +void Level9MetaEngine::detectClashes(Common::StringMap &map) { + for (const PlainGameDescriptor *pd = LEVEL9_GAME_LIST; pd->gameId; ++pd) { + if (map.contains(pd->gameId)) + error("Duplicate game Id found - %s", pd->gameId); + map[pd->gameId] = ""; + } +} + +} // End of namespace Level9 +} // End of namespace Glk diff --git a/engines/glk/level9/detection.h b/engines/glk/level9/detection.h new file mode 100644 index 0000000000..386e4755e9 --- /dev/null +++ b/engines/glk/level9/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_LEVEL9_DETECTION +#define GLK_LEVEL9_DETECTION + +#include "common/fs.h" +#include "common/hash-str.h" +#include "engines/game.h" +#include "glk/detection.h" + +namespace Glk { +namespace Level9 { + +/** + * Meta engine for Level 9 interpreter + */ +class Level9MetaEngine { +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 Level9 +} // End of namespace Glk + +#endif diff --git a/engines/glk/level9/detection_tables.h b/engines/glk/level9/detection_tables.h new file mode 100644 index 0000000000..12b3b0e136 --- /dev/null +++ b/engines/glk/level9/detection_tables.h @@ -0,0 +1,42 @@ +/* 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 Level9 { + +// TODO: The list of Level 9 games and detection entries needs to be filled out +const PlainGameDescriptor LEVEL9_GAME_LIST[] = { + { "level9", "Level 9 IF Game" }, + + { nullptr, nullptr } +}; + +const GlkDetectionEntry LEVEL9_GAMES[] = { + DT_END_MARKER +}; + +} // End of namespace Level9 +} // End of namespace Glk diff --git a/engines/glk/level9/level9.cpp b/engines/glk/level9/level9.cpp new file mode 100644 index 0000000000..5cae3dcf84 --- /dev/null +++ b/engines/glk/level9/level9.cpp @@ -0,0 +1,49 @@ +/* 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/level9/level9.h" + +namespace Glk { +namespace Level9 { + +Level9 *g_vm = nullptr; + +Level9::Level9(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gameDesc) { + g_vm = this; +} + +void Level9::runGame() { + // TODO +} + +Common::Error Level9::readSaveData(Common::SeekableReadStream *rs) { + // TODO + return Common::kNoError; +} + +Common::Error Level9::writeGameData(Common::WriteStream *ws) { + // TODO + return Common::kNoError; +} + +} // End of namespace Level9 +} // End of namespace Glk diff --git a/engines/glk/level9/level9.h b/engines/glk/level9/level9.h new file mode 100644 index 0000000000..90c441e74f --- /dev/null +++ b/engines/glk/level9/level9.h @@ -0,0 +1,84 @@ +/* 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_LEVEL9_LEVEL9 +#define GLK_LEVEL9_LEVEL9 + +#include "common/scummsys.h" +#include "common/serializer.h" +#include "common/stack.h" +#include "glk/glk_api.h" + +namespace Glk { +namespace Level9 { + +/** + * Level 9 game interpreter + */ +class Level9 : public GlkAPI { +private: + /** + * Initialization + */ + bool initialize(); + + /** + * Deinitialization + */ + void deinitialize(); +public: + /** + * Constructor + */ + Level9(OSystem *syst, const GlkGameDescription &gameDesc); + + /** + * Run the game + */ + void runGame(); + + /** + * Returns the running interpreter type + */ + virtual InterpreterType getInterpreterType() const override { + return INTERPRETER_LEVEL9; + } + + /** + * Load a savegame from the passed Quetzal file chunk stream + */ + virtual Common::Error readSaveData(Common::SeekableReadStream *rs) override; + + /** + * Save the game. The passed write stream represents access to the UMem chunk + * in the Quetzal save file that will be created + */ + virtual Common::Error writeGameData(Common::WriteStream *ws) override; + +}; + +extern Level9 *g_vm; + +} // End of namespace Alan2 +} // End of namespace Glk + +#endif diff --git a/engines/glk/module.mk b/engines/glk/module.mk index 4da10029d3..3e474ccf4c 100644 --- a/engines/glk/module.mk +++ b/engines/glk/module.mk @@ -226,6 +226,12 @@ MODULE_OBJS += \ jacl/utils.o endif +ifdef ENABLE_GLK_LEVEL9 +MODULE_OBJS += \ + level9/detection.o \ + level9/level9.o +endif + ifdef ENABLE_GLK_MAGNETIC MODULE_OBJS += \ magnetic/detection.o \ |