diff options
author | Paul Gilbert | 2019-10-19 21:26:04 -0700 |
---|---|---|
committer | Paul Gilbert | 2019-11-11 18:20:29 -0800 |
commit | 0b3f59c3f87debc8fc25cb5e540be87904207cbb (patch) | |
tree | 32c287d3596a0c833b57954397de0561927e66a2 /engines/glk | |
parent | 95ed614f5f0e19d7a2c1cada56d8ba211a401c63 (diff) | |
download | scummvm-rg350-0b3f59c3f87debc8fc25cb5e540be87904207cbb.tar.gz scummvm-rg350-0b3f59c3f87debc8fc25cb5e540be87904207cbb.tar.bz2 scummvm-rg350-0b3f59c3f87debc8fc25cb5e540be87904207cbb.zip |
GLK: ARCHETYPE: Skeleton engine
Diffstat (limited to 'engines/glk')
-rw-r--r-- | engines/glk/archetype/archetype.cpp | 58 | ||||
-rw-r--r-- | engines/glk/archetype/archetype.h | 88 | ||||
-rw-r--r-- | engines/glk/archetype/detection.cpp | 93 | ||||
-rw-r--r-- | engines/glk/archetype/detection.h | 60 | ||||
-rw-r--r-- | engines/glk/archetype/detection_tables.h | 49 | ||||
-rw-r--r-- | engines/glk/configure.engine | 3 | ||||
-rw-r--r-- | engines/glk/detection.cpp | 21 | ||||
-rw-r--r-- | engines/glk/glk_types.h | 1 | ||||
-rw-r--r-- | engines/glk/module.mk | 6 |
9 files changed, 378 insertions, 1 deletions
diff --git a/engines/glk/archetype/archetype.cpp b/engines/glk/archetype/archetype.cpp new file mode 100644 index 0000000000..d2409bfce3 --- /dev/null +++ b/engines/glk/archetype/archetype.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/archetype/archetype.h" +#include "common/config-manager.h" + +namespace Glk { +namespace Archetype { + +Archetype *g_vm; + +Archetype::Archetype(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gameDesc), + _saveSlot(-1) { + g_vm = this; +} + +void Archetype::runGame() { + +} + +bool Archetype::initialize() { + return true; +} + +void Archetype::deinitialize() { +} + +Common::Error Archetype::readSaveData(Common::SeekableReadStream *rs) { + // TODO + return Common::kReadingFailed; +} + +Common::Error Archetype::writeGameData(Common::WriteStream *ws) { + // TODO + return Common::kWritingFailed; +} + +} // End of namespace Archetype +} // End of namespace Glk diff --git a/engines/glk/archetype/archetype.h b/engines/glk/archetype/archetype.h new file mode 100644 index 0000000000..709ebc643b --- /dev/null +++ b/engines/glk/archetype/archetype.h @@ -0,0 +1,88 @@ +/* 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 ARCHETYPE_ARCHETYPE +#define ARCHETYPE_ARCHETYPE + +#include "glk/glk_api.h" + +namespace Glk { +namespace Archetype { + +/** + * Archetype game interpreter + */ +class Archetype : public GlkAPI { +private: + int _saveSlot; +private: + /** + * Engine initialization + */ + bool initialize(); + + /** + * Engine cleanup + */ + void deinitialize(); +public: + /** + * Constructor + */ + Archetype(OSystem *syst, const GlkGameDescription &gameDesc); + + /** + * Run the game + */ + virtual void runGame() override; + + /** + * Returns the running interpreter type + */ + virtual InterpreterType getInterpreterType() const override { + return INTERPRETER_ARCHETYPE; + } + + /** + * Savegames aren't supported for Archetype games + */ + virtual Common::Error readSaveData(Common::SeekableReadStream *rs) override; + + /** + * Savegames aren't supported for Archetype 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 Archetype *g_vm; + +} // End of namespace Archetype +} // End of namespace Glk + +#endif diff --git a/engines/glk/archetype/detection.cpp b/engines/glk/archetype/detection.cpp new file mode 100644 index 0000000000..c5f7e19468 --- /dev/null +++ b/engines/glk/archetype/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/archetype/detection.h" +#include "glk/archetype/detection_tables.h" +#include "common/debug.h" +#include "common/file.h" +#include "common/md5.h" +#include "engines/game.h" + +namespace Glk { +namespace Archetype { + +void ArchetypeMetaEngine::getSupportedGames(PlainGameList &games) { + for (const PlainGameDescriptor *pd = ARCHETYPE_GAME_LIST; pd->gameId; ++pd) + games.push_back(*pd); +} + +GameDescriptor ArchetypeMetaEngine::findGame(const char *gameId) { + for (const PlainGameDescriptor *pd = ARCHETYPE_GAME_LIST; pd->gameId; ++pd) { + if (!strcmp(gameId, pd->gameId)) + return *pd; + } + + return GameDescriptor::empty(); +} + +bool ArchetypeMetaEngine::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(".acx")) + 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 Archetype game list for a match + const GlkDetectionEntry *p = ARCHETYPE_GAMES; + while (p->_md5 && p->_filesize != filesize && md5 != p->_md5) + ++p; + + if (!p->_gameId) { + const PlainGameDescriptor &desc = ARCHETYPE_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 ArchetypeMetaEngine::detectClashes(Common::StringMap &map) { + for (const PlainGameDescriptor *pd = ARCHETYPE_GAME_LIST; pd->gameId; ++pd) { + if (map.contains(pd->gameId)) + error("Duplicate game Id found - %s", pd->gameId); + map[pd->gameId] = ""; + } +} + +} // End of namespace Archetype +} // End of namespace Glk diff --git a/engines/glk/archetype/detection.h b/engines/glk/archetype/detection.h new file mode 100644 index 0000000000..05b3a96956 --- /dev/null +++ b/engines/glk/archetype/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 ARCHETYPE_DETECTION +#define ARCHETYPE_DETECTION + +#include "common/fs.h" +#include "common/hash-str.h" +#include "engines/game.h" +#include "glk/detection.h" + +namespace Glk { +namespace Archetype { + +class ArchetypeMetaEngine { +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 Archetype +} // End of namespace Glk + +#endif diff --git a/engines/glk/archetype/detection_tables.h b/engines/glk/archetype/detection_tables.h new file mode 100644 index 0000000000..fdee12b467 --- /dev/null +++ b/engines/glk/archetype/detection_tables.h @@ -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 "engines/game.h" +#include "common/gui_options.h" +#include "common/language.h" + +namespace Glk { +namespace Archetype { + +const PlainGameDescriptor ARCHETYPE_GAME_LIST[] = { + { "archetype", "Archetype IF Game" }, + + { "guesstheanimal", "Guess the Animal" }, + { "gorreven", "The Gorreven Papers" }, + { "starshipsolitaire", "The Starship Solitaire adventure" }, + + { nullptr, nullptr } +}; + +const GlkDetectionEntry ARCHETYPE_GAMES[] = { + DT_ENTRY0("guesstheanimal", "f1c4d7ba35db9f217eacd84181b4bb33", 1266), + DT_ENTRY0("gorreven", "073a996b158474a2c419bc1d9dc8d44b", 66793), + DT_ENTRY0("starshipsolitaire", "6c86208d0d84fb11f81bf5b1f6fedb84", 55762), + + DT_END_MARKER +}; + +} // End of namespace Archetype +} // End of namespace Glk diff --git a/engines/glk/configure.engine b/engines/glk/configure.engine index 727aa59d65..507bcfec58 100644 --- a/engines/glk/configure.engine +++ b/engines/glk/configure.engine @@ -1,10 +1,11 @@ # 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_level9 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_archetype 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 add_engine glk_alan3 "Alan3" no +add_engine glk_archetype "Archetype" no add_engine glk_frotz "Frotz" no add_engine glk_glulxe "Glulxe" no add_engine glk_hugo "Hugo" no diff --git a/engines/glk/detection.cpp b/engines/glk/detection.cpp index 1e465e9827..9cbda0f519 100644 --- a/engines/glk/detection.cpp +++ b/engines/glk/detection.cpp @@ -44,6 +44,11 @@ #include "glk/alan3/alan3.h" #endif +#ifdef ENABLE_GLK_ARCHETYPE +#include "glk/archetype/archetype.h" +#include "glk/archetype/detection.h" +#endif + #ifdef ENABLE_GLK_FROTZ #include "glk/frotz/detection.h" #include "glk/frotz/frotz.h" @@ -217,6 +222,10 @@ Common::Error GlkMetaEngine::createInstance(OSystem *syst, Engine **engine) cons if ((*engine = create<Glk::Alan3::Alan3MetaEngine, Glk::Alan3::Alan3>(syst, gameDesc)) != nullptr) {} else #endif +#ifdef ENABLE_GLK_ARCHETYPE + if ((*engine = create<Glk::Archetype::ArchetypeMetaEngine, Glk::Archetype::Archetype>(syst, gameDesc)) != nullptr) {} + else +#endif #ifdef ENABLE_GLK_FROTZ if ((*engine = create<Glk::Frotz::FrotzMetaEngine, Glk::Frotz::Frotz>(syst, gameDesc)) != nullptr) {} else @@ -300,6 +309,9 @@ PlainGameList GlkMetaEngine::getSupportedGames() const { #ifdef ENABLE_GLK_ALAN3 Glk::Alan3::Alan3MetaEngine::getSupportedGames(list); #endif +#ifdef ENABLE_GLK_ARCHETYPE + Glk::Archetype::ArchetypeMetaEngine::getSupportedGames(list); +#endif #ifdef ENABLE_GLK_FROTZ Glk::Frotz::FrotzMetaEngine::getSupportedGames(list); #endif @@ -348,6 +360,9 @@ PlainGameDescriptor GlkMetaEngine::findGame(const char *gameId) const { #ifdef ENABLE_GLK_ALAN3 FIND_GAME(Alan3); #endif +#ifdef ENABLE_GLK_ARCHETYPE + FIND_GAME(Archetype); +#endif #ifdef ENABLE_GLK_FROTZ FIND_GAME(Frotz); #endif @@ -398,6 +413,9 @@ DetectedGames GlkMetaEngine::detectGames(const Common::FSList &fslist) const { #ifdef ENABLE_GLK_ALAN3 Glk::Alan3::Alan3MetaEngine::detectGames(fslist, detectedGames); #endif +#ifdef ENABLE_GLK_ARCHETYPE + Glk::Archetype::ArchetypeMetaEngine::detectGames(fslist, detectedGames); +#endif #ifdef ENABLE_GLK_FROTZ Glk::Frotz::FrotzMetaEngine::detectGames(fslist, detectedGames); #endif @@ -443,6 +461,9 @@ void GlkMetaEngine::detectClashes() const { #ifdef ENABLE_GLK_ALAN3 Glk::Alan3::Alan3MetaEngine::detectClashes(map); #endif +#ifdef ENABLE_GLK_ARCHETYPE + Glk::Archetype::ArchetypeMetaEngine::detectClashes(map); +#endif #ifdef ENABLE_GLK_FROTZ Glk::Frotz::FrotzMetaEngine::detectClashes(map); #endif diff --git a/engines/glk/glk_types.h b/engines/glk/glk_types.h index d3db3d44a3..e730f15ccf 100644 --- a/engines/glk/glk_types.h +++ b/engines/glk/glk_types.h @@ -40,6 +40,7 @@ enum InterpreterType { INTERPRETER_AGILITY, INTERPRETER_ALAN2, INTERPRETER_ALAN3, + INTERPRETER_ARCHETYPE, INTERPRETER_BOCFEL, INTERPRETER_FROTZ, INTERPRETER_GEAS, diff --git a/engines/glk/module.mk b/engines/glk/module.mk index 840a1d89af..449607cdf0 100644 --- a/engines/glk/module.mk +++ b/engines/glk/module.mk @@ -143,6 +143,12 @@ MODULE_OBJS += \ alan3/word.o endif +ifdef ENABLE_GLK_ARCHETYPE +MODULE_OBJS += \ + archetype/archetype.o \ + archetype/detection.o +endif + ifdef ENABLE_GLK_FROTZ MODULE_OBJS += \ frotz/bitmap_font.o \ |