2007-05-30 21:56:52 +00:00
|
|
|
/* 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.
|
2006-12-19 01:11:41 +00:00
|
|
|
*
|
|
|
|
* 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.
|
2014-02-18 02:34:17 +01:00
|
|
|
*
|
2006-12-19 01:11:41 +00:00
|
|
|
* 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.
|
2014-02-18 02:34:17 +01:00
|
|
|
*
|
2006-12-19 01:11:41 +00:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-03-27 00:21:16 +03:00
|
|
|
#include "common/translation.h"
|
2020-08-03 04:30:58 +05:30
|
|
|
#include "common/system.h"
|
|
|
|
#include "common/debug.h"
|
2012-03-27 00:21:16 +03:00
|
|
|
|
2020-08-03 04:30:58 +05:30
|
|
|
#include "base/plugins.h"
|
|
|
|
#include "engines/advancedDetector.h"
|
2011-06-04 18:12:26 +03:00
|
|
|
|
2020-08-03 04:30:58 +05:30
|
|
|
#include "agi/detection_enums.h"
|
|
|
|
#include "agi/detection.h"
|
|
|
|
#include "agi/wagparser.h" // for fallback detection
|
2006-12-19 01:11:41 +00:00
|
|
|
|
|
|
|
static const PlainGameDescriptor agiGames[] = {
|
2007-01-29 23:25:51 +00:00
|
|
|
{"agi", "Sierra AGI game"},
|
|
|
|
{"agi-fanmade", "Fanmade AGI game"},
|
|
|
|
{"agidemo", "AGI Demo"},
|
2007-02-04 13:40:11 +00:00
|
|
|
{"bc", "The Black Cauldron"},
|
2007-01-30 00:22:58 +00:00
|
|
|
{"caitlyn", "Caitlyn's Destiny"},
|
2007-01-29 23:25:51 +00:00
|
|
|
{"ddp", "Donald Duck's Playground"},
|
2007-02-04 13:40:11 +00:00
|
|
|
{"goldrush", "Gold Rush!"},
|
|
|
|
{"kq1", "King's Quest I: Quest for the Crown"},
|
|
|
|
{"kq2", "King's Quest II: Romancing the Throne"},
|
|
|
|
{"kq3", "King's Quest III: To Heir Is Human"},
|
|
|
|
{"kq4", "King's Quest IV: The Perils of Rosella"},
|
|
|
|
{"lsl1", "Leisure Suit Larry in the Land of the Lounge Lizards"},
|
2007-09-01 14:58:46 +00:00
|
|
|
{"mickey", "Mickey\'s Space Adventure"},
|
2007-01-29 23:25:51 +00:00
|
|
|
{"mixedup", "Mixed-Up Mother Goose"},
|
2007-02-04 13:40:11 +00:00
|
|
|
{"mh1", "Manhunter 1: New York"},
|
|
|
|
{"mh2", "Manhunter 2: San Francisco"},
|
2007-02-09 13:06:57 +00:00
|
|
|
{"pq1", "Police Quest I: In Pursuit of the Death Angel"},
|
2007-01-30 00:22:58 +00:00
|
|
|
{"serguei1", "Serguei's Destiny 1"},
|
|
|
|
{"serguei2", "Serguei's Destiny 2"},
|
2007-02-09 13:06:57 +00:00
|
|
|
{"sq0", "Space Quest 0: Replicated"},
|
2007-02-04 13:40:11 +00:00
|
|
|
{"sq1", "Space Quest I: The Sarien Encounter"},
|
|
|
|
{"sq2", "Space Quest II: Vohaul's Revenge"},
|
2007-02-09 13:06:57 +00:00
|
|
|
{"sqx", "Space Quest X: The Lost Chapter"},
|
2007-01-30 00:22:58 +00:00
|
|
|
{"tetris", "AGI Tetris"},
|
2007-09-18 16:20:44 +00:00
|
|
|
{"troll", "Troll\'s Tale"},
|
2007-09-06 10:48:00 +00:00
|
|
|
{"winnie", "Winnie the Pooh in the Hundred Acre Wood"},
|
2007-01-29 23:25:51 +00:00
|
|
|
{"xmascard", "Xmas Card"},
|
2007-01-29 23:57:55 +00:00
|
|
|
|
2006-12-19 01:11:41 +00:00
|
|
|
{0, 0}
|
|
|
|
};
|
|
|
|
|
2010-06-15 10:15:08 +00:00
|
|
|
#include "agi/detection_tables.h"
|
2007-05-26 15:16:21 +00:00
|
|
|
|
2015-05-15 04:09:55 +02:00
|
|
|
static const ADExtraGuiOptionsMap optionsList[] = {
|
|
|
|
{
|
|
|
|
GAMEOPTION_ORIGINAL_SAVELOAD,
|
|
|
|
{
|
|
|
|
_s("Use original save/load screens"),
|
2016-11-29 20:02:50 +01:00
|
|
|
_s("Use the original save/load screens instead of the ScummVM ones"),
|
2015-05-15 04:09:55 +02:00
|
|
|
"originalsaveload",
|
|
|
|
false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
GAMEOPTION_AMIGA_ALTERNATIVE_PALETTE,
|
|
|
|
{
|
|
|
|
_s("Use an alternative palette"),
|
|
|
|
_s("Use an alternative palette, common for all Amiga games. This was the old behavior"),
|
|
|
|
"altamigapalette",
|
|
|
|
false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
GAMEOPTION_DISABLE_MOUSE,
|
|
|
|
{
|
2015-05-15 05:10:08 +02:00
|
|
|
_s("Mouse support"),
|
|
|
|
_s("Enables mouse support. Allows to use mouse for movement and in game menus."),
|
|
|
|
"mousesupport",
|
2015-05-15 04:09:55 +02:00
|
|
|
true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-02-27 21:44:21 +01:00
|
|
|
{
|
|
|
|
GAMEOPTION_USE_HERCULES_FONT,
|
|
|
|
{
|
|
|
|
_s("Use Hercules hires font"),
|
|
|
|
_s("Uses Hercules hires font, when font file is available."),
|
|
|
|
"herculesfont",
|
|
|
|
false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-02-28 15:50:25 +01:00
|
|
|
{
|
|
|
|
GAMEOPTION_COMMAND_PROMPT_WINDOW,
|
|
|
|
{
|
2016-02-28 15:57:22 +01:00
|
|
|
_s("Pause when entering commands"),
|
2016-02-28 15:50:25 +01:00
|
|
|
_s("Shows a command prompt window and pauses the game (like in SCI) instead of a real-time prompt."),
|
|
|
|
"commandpromptwindow",
|
|
|
|
false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-06-17 21:43:23 +03:00
|
|
|
{
|
|
|
|
GAMEOPTION_APPLE2GS_ADD_SPEED_MENU,
|
|
|
|
{
|
|
|
|
_s("Add speed menu"),
|
|
|
|
_s("Add game speed menu (similar to PC version)"),
|
|
|
|
"apple2gs_speedmenu",
|
|
|
|
false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-05-15 04:09:55 +02:00
|
|
|
AD_EXTRA_GUI_OPTIONS_TERMINATOR
|
|
|
|
};
|
|
|
|
|
2008-03-15 15:25:49 +00:00
|
|
|
using namespace Agi;
|
|
|
|
|
2009-01-29 22:13:01 +00:00
|
|
|
class AgiMetaEngine : public AdvancedMetaEngine {
|
2016-02-02 18:43:36 +01:00
|
|
|
mutable Common::String _gameid;
|
|
|
|
mutable Common::String _extra;
|
2008-03-15 15:25:49 +00:00
|
|
|
|
|
|
|
public:
|
2015-05-15 04:09:55 +02:00
|
|
|
AgiMetaEngine() : AdvancedMetaEngine(Agi::gameDescriptions, sizeof(Agi::AGIGameDescription), agiGames, optionsList) {
|
2016-03-08 18:30:58 +01:00
|
|
|
_guiOptions = GUIO1(GUIO_NOSPEECH);
|
2011-06-10 15:53:50 +02:00
|
|
|
}
|
2008-03-15 15:25:49 +00:00
|
|
|
|
2020-01-31 12:44:55 +01:00
|
|
|
const char *getEngineId() const override {
|
2016-09-15 18:23:35 +02:00
|
|
|
return "agi";
|
|
|
|
}
|
|
|
|
|
2020-02-09 12:05:27 +01:00
|
|
|
const char *getName() const override {
|
2011-05-15 15:50:09 +01:00
|
|
|
return "AGI preAGI + v2 + v3";
|
2008-03-15 15:25:49 +00:00
|
|
|
}
|
2016-09-15 18:23:35 +02:00
|
|
|
|
2020-02-09 12:05:27 +01:00
|
|
|
const char *getOriginalCopyright() const override {
|
2008-03-15 15:25:49 +00:00
|
|
|
return "Sierra AGI Engine (C) Sierra On-Line Software";
|
|
|
|
}
|
|
|
|
|
2017-12-02 17:14:22 +01:00
|
|
|
ADDetectedGame fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const override;
|
2008-03-15 15:25:49 +00:00
|
|
|
};
|
|
|
|
|
2017-12-02 17:14:22 +01:00
|
|
|
ADDetectedGame AgiMetaEngine::fallbackDetect(const FileMap &allFilesXXX, const Common::FSList &fslist) const {
|
2008-06-11 06:00:56 +00:00
|
|
|
typedef Common::HashMap<Common::String, int32> IntMap;
|
2007-05-26 15:16:21 +00:00
|
|
|
IntMap allFiles;
|
2007-06-12 12:22:25 +00:00
|
|
|
bool matchedUsingFilenames = false;
|
2007-06-14 12:06:12 +00:00
|
|
|
bool matchedUsingWag = false;
|
|
|
|
int wagFileCount = 0;
|
|
|
|
WagFileParser wagFileParser;
|
2008-10-02 16:58:59 +00:00
|
|
|
Common::FSNode wagFileNode;
|
2008-03-15 15:25:49 +00:00
|
|
|
Common::String description;
|
2007-06-12 12:22:25 +00:00
|
|
|
|
2008-03-15 15:25:49 +00:00
|
|
|
// // Set the defaults for gameid and extra
|
|
|
|
_gameid = "agi-fanmade";
|
|
|
|
_extra.clear();
|
|
|
|
|
2007-06-12 12:22:25 +00:00
|
|
|
// Set the default values for the fallback descriptor's ADGameDescription part.
|
|
|
|
g_fallbackDesc.desc.language = Common::UNK_LANG;
|
2013-05-02 18:26:58 -04:00
|
|
|
g_fallbackDesc.desc.platform = Common::kPlatformDOS;
|
2009-01-29 22:13:01 +00:00
|
|
|
g_fallbackDesc.desc.flags = ADGF_NO_FLAGS;
|
2007-05-26 15:16:21 +00:00
|
|
|
|
2007-06-12 12:22:25 +00:00
|
|
|
// Set default values for the fallback descriptor's AGIGameDescription part.
|
|
|
|
g_fallbackDesc.gameID = GID_FANMADE;
|
|
|
|
g_fallbackDesc.features = GF_FANMADE;
|
|
|
|
g_fallbackDesc.version = 0x2917;
|
2007-05-26 15:16:21 +00:00
|
|
|
|
2007-06-14 12:06:12 +00:00
|
|
|
// First grab all filenames and at the same time count the number of *.wag files
|
2008-11-06 13:59:39 +00:00
|
|
|
for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
|
2007-05-26 15:16:21 +00:00
|
|
|
if (file->isDirectory()) continue;
|
2007-06-23 18:51:33 +00:00
|
|
|
Common::String filename = file->getName();
|
2007-06-12 12:22:25 +00:00
|
|
|
filename.toLowercase();
|
2011-06-04 19:16:50 +03:00
|
|
|
allFiles[filename] = true; // Save the filename in a hash table
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-06-14 12:06:12 +00:00
|
|
|
if (filename.hasSuffix(".wag")) {
|
|
|
|
// Save latest found *.wag file's path (Can be used to open the file, the name can't)
|
2008-09-30 16:38:46 +00:00
|
|
|
wagFileNode = *file;
|
2007-06-14 12:06:12 +00:00
|
|
|
wagFileCount++; // Count found *.wag files
|
|
|
|
}
|
2007-05-26 15:16:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (allFiles.contains("logdir") && allFiles.contains("object") &&
|
2016-02-02 18:43:36 +01:00
|
|
|
allFiles.contains("picdir") && allFiles.contains("snddir") &&
|
|
|
|
allFiles.contains("viewdir") && allFiles.contains("vol.0") &&
|
|
|
|
allFiles.contains("words.tok")) { // Check for v2
|
2007-06-12 12:22:25 +00:00
|
|
|
|
|
|
|
// The default AGI interpreter version 0x2917 is okay for v2 games
|
|
|
|
// so we don't have to change it here.
|
|
|
|
matchedUsingFilenames = true;
|
|
|
|
|
2008-02-12 15:20:47 +00:00
|
|
|
// Check for AGIPAL by checking for existence of any of the files "pal.100" - "pal.109"
|
|
|
|
bool agipal = false;
|
|
|
|
char agipalFile[] = "pal.xxx";
|
|
|
|
for (uint i = 100; i <= 109; i++) {
|
|
|
|
sprintf(agipalFile, "pal.%d", i);
|
|
|
|
if (allFiles.contains(agipalFile)) {
|
|
|
|
agipal = true; // We found a file "pal.x" where 100 <= x <= 109 so it's AGIPAL
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (agipal) { // Check if it is AGIPAL
|
2007-06-12 12:22:25 +00:00
|
|
|
description = "Unknown v2 AGIPAL Game";
|
|
|
|
} else { // Not AGIPAL so just plain v2
|
|
|
|
description = "Unknown v2 Game";
|
2007-09-19 08:40:12 +00:00
|
|
|
}
|
2007-05-26 15:16:21 +00:00
|
|
|
} else { // Try v3
|
|
|
|
char name[8];
|
|
|
|
|
|
|
|
for (IntMap::const_iterator f = allFiles.begin(); f != allFiles.end(); ++f) {
|
|
|
|
if (f->_key.hasSuffix("vol.0")) {
|
|
|
|
memset(name, 0, 8);
|
2007-06-06 13:35:41 +00:00
|
|
|
strncpy(name, f->_key.c_str(), MIN((uint)8, f->_key.size() > 5 ? f->_key.size() - 5 : f->_key.size()));
|
2007-05-26 15:16:21 +00:00
|
|
|
|
|
|
|
if (allFiles.contains("object") && allFiles.contains("words.tok") &&
|
2016-02-02 18:43:36 +01:00
|
|
|
allFiles.contains(Common::String(name) + "dir")) {
|
2007-06-12 12:22:25 +00:00
|
|
|
matchedUsingFilenames = true;
|
|
|
|
description = "Unknown v3 Game";
|
|
|
|
g_fallbackDesc.version = 0x3149; // Set the default AGI version for an AGI v3 game
|
2007-05-26 15:16:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-06-14 12:06:12 +00:00
|
|
|
|
|
|
|
// WinAGI produces *.wag file with interpreter version, game name and other parameters.
|
|
|
|
// If there's exactly one *.wag file and it parses successfully then we'll use its information.
|
2008-09-30 16:38:46 +00:00
|
|
|
if (wagFileCount == 1 && wagFileParser.parse(wagFileNode)) {
|
2007-06-14 12:06:12 +00:00
|
|
|
matchedUsingWag = true;
|
|
|
|
|
|
|
|
const WagProperty *wagAgiVer = wagFileParser.getProperty(WagProperty::PC_INTVERSION);
|
|
|
|
const WagProperty *wagGameID = wagFileParser.getProperty(WagProperty::PC_GAMEID);
|
|
|
|
const WagProperty *wagGameDesc = wagFileParser.getProperty(WagProperty::PC_GAMEDESC);
|
|
|
|
const WagProperty *wagGameVer = wagFileParser.getProperty(WagProperty::PC_GAMEVERSION);
|
|
|
|
const WagProperty *wagGameLastEdit = wagFileParser.getProperty(WagProperty::PC_GAMELAST);
|
|
|
|
|
|
|
|
// If there is an AGI version number in the *.wag file then let's use it
|
|
|
|
if (wagAgiVer != NULL && wagFileParser.checkAgiVersionProperty(*wagAgiVer)) {
|
|
|
|
// TODO/FIXME: Check that version number is something we support before trying to use it.
|
|
|
|
// If the version number is unsupported then it'll get switched to 0x2917 later.
|
|
|
|
// But there's the possibility that file based detection has detected something else
|
|
|
|
// than a v2 AGI game. So there's a possibility for conflicting information.
|
|
|
|
g_fallbackDesc.version = wagFileParser.convertToAgiVersionNumber(*wagAgiVer);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set gameid according to *.wag file information if it's present and it doesn't contain whitespace.
|
|
|
|
if (wagGameID != NULL && !Common::String(wagGameID->getData()).contains(" ")) {
|
2008-03-15 15:25:49 +00:00
|
|
|
_gameid = wagGameID->getData();
|
|
|
|
debug(3, "Agi::fallbackDetector: Using game id (%s) from WAG file", _gameid.c_str());
|
2007-06-14 12:06:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set game description and extra according to *.wag file information if they're present
|
|
|
|
if (wagGameDesc != NULL) {
|
|
|
|
description = wagGameDesc->getData();
|
|
|
|
debug(3, "Agi::fallbackDetector: Game description (%s) from WAG file", wagGameDesc->getData());
|
|
|
|
|
|
|
|
// If there's game version in the *.wag file, set extra to it
|
|
|
|
if (wagGameVer != NULL) {
|
2008-03-15 15:25:49 +00:00
|
|
|
_extra = wagGameVer->getData();
|
2007-06-14 12:06:12 +00:00
|
|
|
debug(3, "Agi::fallbackDetector: Game version (%s) from WAG file", wagGameVer->getData());
|
|
|
|
}
|
|
|
|
|
|
|
|
// If there's game last edit date in the *.wag file, add it to extra
|
|
|
|
if (wagGameLastEdit != NULL) {
|
2010-10-12 04:19:58 +00:00
|
|
|
if (!_extra.empty())
|
|
|
|
_extra += " ";
|
2008-03-15 15:25:49 +00:00
|
|
|
_extra += wagGameLastEdit->getData();
|
2007-06-14 12:06:12 +00:00
|
|
|
debug(3, "Agi::fallbackDetector: Game's last edit date (%s) from WAG file", wagGameLastEdit->getData());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (wagFileCount > 1) { // More than one *.wag file, confusing! So let's not use them.
|
|
|
|
warning("More than one (%d) *.wag files found. WAG files ignored", wagFileCount);
|
|
|
|
}
|
|
|
|
|
2007-06-12 12:22:25 +00:00
|
|
|
// Check that the AGI interpreter version is a supported one
|
|
|
|
if (!(g_fallbackDesc.version >= 0x2000 && g_fallbackDesc.version < 0x4000)) {
|
|
|
|
warning("Unsupported AGI interpreter version 0x%x in AGI's fallback detection. Using default 0x2917", g_fallbackDesc.version);
|
|
|
|
g_fallbackDesc.version = 0x2917;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set game type (v2 or v3) according to the AGI interpreter version number
|
|
|
|
if (g_fallbackDesc.version >= 0x2000 && g_fallbackDesc.version < 0x3000)
|
|
|
|
g_fallbackDesc.gameType = GType_V2;
|
|
|
|
else if (g_fallbackDesc.version >= 0x3000 && g_fallbackDesc.version < 0x4000)
|
|
|
|
g_fallbackDesc.gameType = GType_V3;
|
|
|
|
|
|
|
|
// Check if we found a match with any of the fallback methods
|
2007-06-14 12:06:12 +00:00
|
|
|
if (matchedUsingWag || matchedUsingFilenames) {
|
2008-03-15 15:25:49 +00:00
|
|
|
_extra = description + (!_extra.empty() ? " " : "") + _extra; // Let's combine the description and extra
|
2009-01-01 15:06:43 +00:00
|
|
|
|
|
|
|
// Override the gameid & extra values in g_fallbackDesc.desc. This only works
|
2008-03-15 15:25:49 +00:00
|
|
|
// until the fallback detector is called again, and while the MetaEngine instance
|
|
|
|
// is alive (as else the string storage is modified/deleted).
|
2016-03-08 18:53:55 +01:00
|
|
|
g_fallbackDesc.desc.gameId = _gameid.c_str();
|
2008-03-15 15:25:49 +00:00
|
|
|
g_fallbackDesc.desc.extra = _extra.c_str();
|
2007-05-26 15:16:21 +00:00
|
|
|
|
2012-08-15 09:51:55 +02:00
|
|
|
Common::String fallbackWarning;
|
|
|
|
|
|
|
|
fallbackWarning = "Your game version has been detected using fallback matching as a\n";
|
2016-03-08 18:53:55 +01:00
|
|
|
fallbackWarning += Common::String::format("variant of %s (%s).\n", g_fallbackDesc.desc.gameId, g_fallbackDesc.desc.extra);
|
2012-08-15 09:51:55 +02:00
|
|
|
fallbackWarning += "If this is an original and unmodified version or new made Fanmade game,\n";
|
|
|
|
fallbackWarning += "please report any, information previously printed by ScummVM to the team.\n";
|
|
|
|
|
|
|
|
g_system->logMessage(LogMessageType::kWarning, fallbackWarning.c_str());
|
2007-06-12 12:22:25 +00:00
|
|
|
|
2017-12-02 17:14:22 +01:00
|
|
|
return ADDetectedGame(&g_fallbackDesc.desc);
|
2007-05-26 15:16:21 +00:00
|
|
|
}
|
|
|
|
|
2017-12-02 17:14:22 +01:00
|
|
|
return ADDetectedGame();
|
2007-09-01 14:58:46 +00:00
|
|
|
}
|
2007-01-24 22:42:44 +00:00
|
|
|
|
2020-08-03 04:30:58 +05:30
|
|
|
REGISTER_PLUGIN_STATIC(AGI_DETECTION, PLUGIN_TYPE_METAENGINE, AgiMetaEngine);
|