/* Residual - A 3D game interpreter * * Residual 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 library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library 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 * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * * $URL$ * $Id$ * */ #include "engines/advancedDetector.h" #include "engines/grim/grim.h" #include "engines/grim/colormap.h" #include "engines/grim/savegame.h" #include "common/system.h" #include "common/savefile.h" namespace Grim { struct GrimGameDescription { ADGameDescription desc; GrimGameType gameType; }; static const PlainGameDescriptor grimGames[] = { {"grim", "Grim Fandango"}, {"monkey4", "Escape From Monkey Island"}, {0, 0} }; using Common::GUIO_NONE; static const GrimGameDescription gameDescriptions[] = { { // Grim Fandango English version { "grim", "", AD_ENTRY1s("grim.tab", "cfb333d6aec260c905151b6b98ef71e8", 362212), Common::EN_ANY, Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO_NONE }, GType_GRIM }, { // Grim Fandango English version (Adventure-bundle, possibly patched) { "grim", "", AD_ENTRY1s("grim.tab", "cfb333d6aec260c905151b6b98ef71e8", 362164), Common::EN_ANY, Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO_NONE }, GType_GRIM }, { // Grim Fandango German version { "grim", "", AD_ENTRY1s("grim.tab", "464138caf47e580cbb237dee10674b16", 398592), Common::DE_DEU, Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO_NONE }, GType_GRIM }, { // Grim Fandango German version (patched) { "grim", "", AD_ENTRY1s("grim.tab", "464138caf47e580cbb237dee10674b16", 398671), Common::DE_DEU, Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO_NONE }, GType_GRIM }, { // Grim Fandango Spanish version { "grim", "", AD_ENTRY1s("grim.tab", "b1460cd029f13718f7f62c2403e047ec", 372709), Common::ES_ESP, Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO_NONE }, GType_GRIM }, { // Grim Fandango Italian version { "grim", "", AD_ENTRY1s("grim.tab", "2d99c796b7a4e5c421cae49dc29dab6c", 369071), Common::IT_ITA, Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO_NONE }, GType_GRIM }, { // Grim Fandango patched Italian version { "grim", "", AD_ENTRY1s("grim.tab", "2d99c796b7a4e5c421cae49dc29dab6c", 369242), Common::IT_ITA, Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO_NONE }, GType_GRIM }, { // Grim Fandango French version { "grim", "", AD_ENTRY1s("grim.tab", "3bd00ca87214862c012ac99e1758dd83", 386292), Common::FR_FRA, Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO_NONE }, GType_GRIM }, { // Grim Fandango English demo version { "grim", "Demo", AD_ENTRY1s("gfdemo01.lab", "755cdac083f7f751bec7506402278f1a", 29489930), Common::EN_ANY, Common::kPlatformWindows, ADGF_DEMO, GUIO_NONE }, GType_GRIM }, { // Escape from Monkey Island English { "monkey4", "", AD_ENTRY1s("voiceAll.m4b", "c66cc6b656a2b1abae373b61d3115342", 17325629), Common::EN_ANY, Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO_NONE }, GType_MONKEY4 }, { // Escape from Monkey Island German { "monkey4", "", AD_ENTRY1s("voiceAll.m4b", "63b4724afc9d94a5aa71b46e6b1b7551", 19999850), Common::DE_DEU, Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO_NONE }, GType_MONKEY4 }, { // Escape from Monkey Island Italian { "monkey4", "", AD_ENTRY1s("voiceAll.m4b", "d4b9659a0853e707fdb7c7a68c7604d2", 21206992), Common::IT_ITA, Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO_NONE }, GType_MONKEY4 }, { // Escape from Monkey Island Spanish { "monkey4", "", AD_ENTRY1s("voiceAll.m4b", "0b48fba32e47f372712ed06365678c2b", 18486773), Common::ES_ESP, Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO_NONE }, GType_MONKEY4 }, { // Escape from Monkey Island French { "monkey4", "", AD_ENTRY1s("voiceAll.m4b", "e75ca3a03515e009dc2e4426010d8ebb", 20044753), Common::FR_FRA, Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO_NONE }, GType_MONKEY4 }, { // Escape from Monkey Island English PS2 { "monkey4", "", AD_ENTRY1s("voiceAll.m4b", "c03391279486f0158c75398f5117ad73", 15095808), Common::EN_ANY, Common::kPlatformPS2, ADGF_NO_FLAGS, GUIO_NONE }, GType_MONKEY4 }, { // Escape from Monkey Island German PS2 { "monkey4", "", AD_ENTRY1s("voiceAll.m4b", "6bdd08f3f313765c610fbbe39d18797f", 17262912), Common::DE_DEU, Common::kPlatformPS2, ADGF_NO_FLAGS, GUIO_NONE }, GType_MONKEY4 }, { // Escape from Monkey Island Italian PS2 { "monkey4", "", AD_ENTRY1s("voiceAll.m4b", "342fc0288a7d0e25a7284a04b98ede83", 18128960), Common::IT_ITA, Common::kPlatformPS2, ADGF_NO_FLAGS, GUIO_NONE }, GType_MONKEY4 }, { // Escape from Monkey Island Spanish PS2 { "monkey4", "", AD_ENTRY1s("voiceAll.m4b", "782ca7d9357577a4c5eefc37974661cc", 15789184), Common::ES_ESP, Common::kPlatformPS2, ADGF_NO_FLAGS, GUIO_NONE }, GType_MONKEY4 }, { // Escape from Monkey Island French PS2 { "monkey4", "", AD_ENTRY1s("voiceAll.m4b", "ef0905bc590e1afbe2eef1535bde7a6b", 16768512), Common::FR_FRA, Common::kPlatformPS2, ADGF_NO_FLAGS, GUIO_NONE }, GType_MONKEY4 }, { // Escape from Monkey Island demo { "monkey4", "Demo", AD_ENTRY1s("magdemo.lab", "9e7eaa1b9317ff47d5deeda0b2c42ce3", 19826116), Common::EN_ANY, Common::kPlatformWindows, ADGF_DEMO, GUIO_NONE }, GType_MONKEY4 }, { AD_TABLE_END_MARKER, GType_GRIM } }; static const ADObsoleteGameID obsoleteGameIDsTable[] = { {"grimdemo", "grim", Common::kPlatformWindows}, {0, 0, Common::kPlatformUnknown} }; static const ADParams detectionParams = { // Pointer to ADGameDescription or its superset structure (const byte *)gameDescriptions, // Size of that superset structure sizeof(GrimGameDescription), // Number of bytes to compute MD5 sum for 5000, // List of all engine targets grimGames, // Structure for autoupgrading obsolete targets obsoleteGameIDsTable, // Name of single gameid (optional) 0, // List of files for file-based fallback detection (optional) 0, // Flags 0, // Additional GUI options (for every game} Common::GUIO_NOMIDI, // Maximum directory depth 1, // List of directory globs 0 }; class GrimMetaEngine : public AdvancedMetaEngine { public: GrimMetaEngine() : AdvancedMetaEngine(detectionParams) {} virtual const char *getName() const { return "Grim Engine"; } virtual const char *getOriginalCopyright() const { return "LucasArts GrimE Games (C) LucasArts"; } virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const; virtual bool hasFeature(MetaEngineFeature f) const; virtual SaveStateList listSaves(const char *target) const; }; bool GrimMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { const GrimGameDescription *gd = (const GrimGameDescription *)desc; if (gd) *engine = new GrimEngine(syst, gd->desc.flags, gd->gameType, gd->desc.platform, gd->desc.language); return gd != 0; } bool GrimMetaEngine::hasFeature(MetaEngineFeature f) const { return (f == kSupportsListSaves) || (f == kSupportsLoadingDuringStartup); } SaveStateList GrimMetaEngine::listSaves(const char *target) const { Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); Common::StringArray filenames; Common::String saveDesc; Common::String pattern = "grim??.gsv"; filenames = saveFileMan->listSavefiles(pattern); sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) SaveStateList saveList; char str[256]; int32 strSize; for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) { // Obtain the last 2 digits of the filename, since they correspond to the save slot int slotNum = atoi(file->c_str() + 4); if (slotNum >= 0 && slotNum <= 99) { SaveGame *savedState = new SaveGame((*file).c_str(), false); if (savedState) { if (savedState->saveVersion() != SaveGame::SAVEGAME_VERSION) { delete savedState; continue; } savedState->beginSection('SUBS'); strSize = savedState->readLESint32(); savedState->read(str, strSize); saveDesc = str; saveList.push_back(SaveStateDescriptor(slotNum, saveDesc)); delete savedState; } } } return saveList; } } // End of namespace Grim #if PLUGIN_ENABLED_DYNAMIC(GRIM) REGISTER_PLUGIN_DYNAMIC(GRIM, PLUGIN_TYPE_ENGINE, Grim::GrimMetaEngine); #else REGISTER_PLUGIN_STATIC(GRIM, PLUGIN_TYPE_ENGINE, Grim::GrimMetaEngine); #endif