aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/touche/plugin.cpp191
-rw-r--r--engines/touche/touche.cpp26
-rw-r--r--engines/touche/touche.h4
3 files changed, 87 insertions, 134 deletions
diff --git a/engines/touche/plugin.cpp b/engines/touche/plugin.cpp
index cb1b9de8ed..17d8894d7c 100644
--- a/engines/touche/plugin.cpp
+++ b/engines/touche/plugin.cpp
@@ -22,162 +22,107 @@
#include "common/stdafx.h"
#include "common/config-manager.h"
-#include "common/fs.h"
-#include "common/md5.h"
+#include "common/advancedDetector.h"
#include "base/plugins.h"
#include "touche/touche.h"
-struct GameVersion {
- const char *description;
- uint32 filesize;
- const char *md5digest;
- Common::Language language;
- Common::Platform platform;
+namespace Touche {
+static GameList GAME_detectGames(const FSList &fslist);
+}
+
+
+static const PlainGameDescriptor toucheGames[] = {
+ {"touche", "Touche: The Adventures of the Fifth Musketeer"},
+ {"touche-fr", "Touche: Les Aventures du Cinquieme Mousquetaire"},
+ {"touche-de", "Touche - Die Abenteuer des funften Musketiers"},
+ {"touche-it", "Touche: The Adventures of the Fifth Musketeer"},
+ {0, 0}
};
-static const GameVersion toucheGameVersionsTable[] = {
+namespace Touche {
+
+static const Common::ADGameDescription gameDescriptions[] = {
{ // retail version
- "Touche: The Adventures of the Fifth Musketeer",
- 26350211,
- "2af0177f8887e3430f345e6b4d8b1414",
+ "touche",
+ "",
+ AD_ENTRY1s("touche.dat", "2af0177f8887e3430f345e6b4d8b1414", 26350211),
Common::EN_ANY,
- Common::kPlatformPC
+ Common::kPlatformPC,
},
{ // retail version - tracker item #1601818
- "Touche: The Adventures of the Fifth Musketeer",
- 26350190,
- "95967f0b51d2e813e99ca00325098340",
+ "touche",
+ "",
+ AD_ENTRY1s("touche.dat", "95967f0b51d2e813e99ca00325098340", 26350190),
Common::EN_ANY,
- Common::kPlatformWindows
+ Common::kPlatformPC,
},
{ // retail version
- "Touche: Les Aventures du Cinquieme Mousquetaire",
- 26558232,
- "1caa20bb4d4fc2ce8eb867b6610082b3",
+ "touche-fr",
+ "",
+ AD_ENTRY1s("touche.dat", "1caa20bb4d4fc2ce8eb867b6610082b3", 26558232),
Common::FR_FRA,
- Common::kPlatformPC
+ Common::kPlatformPC,
},
{ // retail version - tracker item #1598643
- "Touche - Die Abenteuer des funften Musketiers",
- 26625537,
- "be2ae6454b3325e410946f2322547cd4",
+ "touche-de",
+ "",
+ AD_ENTRY1s("touche.dat", "be2ae6454b3325e410946f2322547cd4", 26625537),
Common::DE_DEU,
- Common::kPlatformPC
+ Common::kPlatformPC,
},
{ // fan-made translation (http://www.iagtg.net/) - tracker item #1602360
- "Touche: The Adventures of the Fifth Musketeer",
- 26367792,
- "1f442331d4b327c3488a9f6ffe9bdd25",
+ "touche-it",
+ "",
+ AD_ENTRY1s("touche.dat", "1f442331d4b327c3488a9f6ffe9bdd25", 26367792),
Common::IT_ITA,
- Common::kPlatformPC
+ Common::kPlatformPC,
},
{ // demo version
- "Touche: The Adventures of the Fifth Musketeer (Demo)",
- 8720683,
- "ddaed436445b2e77294ed19e8ae4aa2c",
+ "touche",
+ "Demo",
+ AD_ENTRY1s("touche.dat", "ddaed436445b2e77294ed19e8ae4aa2c", 8720683),
Common::EN_ANY,
- Common::kPlatformPC
- }
+ Common::kPlatformPC,
+ },
+ { NULL, NULL, { { NULL, 0, NULL, 0 } }, Common::UNK_LANG, Common::kPlatformUnknown }
};
-static const PlainGameDescriptor toucheGameDescriptor = {
- "touche", "Touche: The Adventures of the Fifth Musketeer"
+}
+
+static const Common::ADParams detectionParams = {
+ // Pointer to ADGameDescription or its superset structure
+ (const byte *)Touche::gameDescriptions,
+ // Size of that superset structure
+ sizeof(Common::ADGameDescription),
+ // Number of bytes to compute MD5 sum for
+ 4096,
+ // List of all engine targets
+ toucheGames,
+ // Structure for autoupgrading obsolete targets
+ 0,
+ // Name of single gameid (optional)
+ "touche",
+ // Flags
+ 0
};
-static const char *toucheDetectFileName = "TOUCHE.DAT";
-
-static Common::String Engine_TOUCHE_md5digest(const FilesystemNode *file) {
- static const int md5DataSize = 4096;
- uint8 md5digest[16];
- if (Common::md5_file(*file, md5digest, md5DataSize)) {
- char md5sum[32 + 1];
- for (int i = 0; i < 16; ++i) {
- sprintf(md5sum + i * 2, "%02x", (int)md5digest[i]);
- }
- return md5sum;
- }
- return "";
-}
+ADVANCED_DETECTOR_DEFINE_PLUGIN(TOUCHE, Touche::ToucheEngine, Touche::GAME_detectGames, detectionParams);
-static uint32 Engine_TOUCHE_filesize(const FilesystemNode *file) {
- Common::File f;
- if (f.open(file->path().c_str())) {
- return f.size();
- }
- return 0;
-}
+REGISTER_PLUGIN(TOUCHE, "Touche Engine", "Touche: The Adventures of the 5th Musketeer (C) Clipper Software");
-GameList Engine_TOUCHE_gameIDList() {
- GameList games;
- games.push_back(toucheGameDescriptor);
- return games;
-}
+namespace Touche {
-GameDescriptor Engine_TOUCHE_findGameID(const char *gameid) {
- if (scumm_stricmp(toucheGameDescriptor.gameid, gameid) == 0) {
- return toucheGameDescriptor;
- }
- return GameDescriptor();
-}
+bool ToucheEngine::detectGame() {
+ int i = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
-GameList Engine_TOUCHE_detectGames(const FSList &fslist) {
- bool foundFile = false;
- FSList::const_iterator file;
- for (file = fslist.begin(); file != fslist.end(); ++file) {
- if (file->isDirectory()) {
- continue;
- }
- for (int i = 0; i < ARRAYSIZE(toucheGameVersionsTable); ++i) {
- if (file->name().equalsIgnoreCase(toucheDetectFileName)) {
- foundFile = true;
- break;
- }
- }
- if (foundFile) {
- break;
- }
- }
- GameList detectedGames;
- if (foundFile) {
- // Currently, the detection code is based on a MD5 checksum. If all known versions
- // have a different file size for TOUCHE.DAT, we may consider using this to do the
- // detection.
- Common::String md5digest = Engine_TOUCHE_md5digest(file);
- if (!md5digest.empty()) {
- for (int i = 0; i < ARRAYSIZE(toucheGameVersionsTable); ++i) {
- const GameVersion *gv = &toucheGameVersionsTable[i];
- if (md5digest.equalsIgnoreCase(gv->md5digest)) {
- GameDescriptor dg(toucheGameDescriptor.gameid, gv->description, gv->language, gv->platform);
- detectedGames.push_back(dg);
- break;
- }
- }
- if (detectedGames.empty()) {
- const uint32 filesize = Engine_TOUCHE_filesize(file);
- printf("Datafile size (%d) and MD5 (%s) are unknown !\n", filesize, md5digest.c_str());
- printf("Please report the details (language, platform, etc.) of this game to the ScummVM team.\n");
- detectedGames.push_back(toucheGameDescriptor);
- }
- }
- }
- return detectedGames;
+ _language = gameDescriptions[i].language;
+ return true;
}
-PluginError Engine_TOUCHE_create(OSystem *system, Engine **engine) {
- FSList fslist;
- FilesystemNode dir(ConfMan.get("path"));
- if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) {
- return kInvalidPathError;
- }
- GameList game = Engine_TOUCHE_detectGames(fslist);
- if (game.size() != 1) {
- return kNoGameDataFoundError;
- }
- assert(engine);
- *engine = new Touche::ToucheEngine(system, game[0].language());
- return kNoError;
+GameList GAME_detectGames(const FSList &fslist) {
+ return Common::AdvancedDetector::detectAllGames(fslist, detectionParams);
}
-REGISTER_PLUGIN(TOUCHE, "Touche Engine", "Touche: The Adventures of the 5th Musketeer (C) Clipper Software");
+} // End of namespace Touche
diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp
index 1c7953fb1e..c317091de5 100644
--- a/engines/touche/touche.cpp
+++ b/engines/touche/touche.cpp
@@ -32,8 +32,8 @@
namespace Touche {
-ToucheEngine::ToucheEngine(OSystem *system, Common::Language language)
- : Engine(system), _language(language) {
+ToucheEngine::ToucheEngine(OSystem *system)
+ : Engine(system) {
_saveLoadCurrentPage = 0;
_saveLoadCurrentSlot = 0;
@@ -63,19 +63,11 @@ ToucheEngine::ToucheEngine(OSystem *system, Common::Language language)
_menuRedrawCounter = 0;
memset(_paletteBuffer, 0, sizeof(_paletteBuffer));
- Graphics::setupFont(_language);
-
- setupOpcodes();
-
Common::addSpecialDebugLevel(kDebugEngine, "Engine", "Engine debug level");
Common::addSpecialDebugLevel(kDebugGraphics, "Graphics", "Graphics debug level");
Common::addSpecialDebugLevel(kDebugResource, "Resource", "Resource debug level");
Common::addSpecialDebugLevel(kDebugOpcodes, "Opcodes", "Opcodes debug level");
Common::addSpecialDebugLevel(kDebugUserIntf, "UserIntf", "UserInterface debug level");
-
- int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI);
- MidiDriver *driver = MidiDriver::createMidi(midiDriver);
- _midiPlayer = new MidiPlayer(driver);
}
ToucheEngine::~ToucheEngine() {
@@ -89,6 +81,20 @@ int ToucheEngine::init() {
_system->initSize(kScreenWidth, kScreenHeight);
_system->endGFXTransaction();
+ // Detect game
+ if (!detectGame()) {
+ GUIErrorMessage("No valid games were found in the specified directory.");
+ return -1;
+ }
+
+ Graphics::setupFont(_language);
+
+ setupOpcodes();
+
+ int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI);
+ MidiDriver *driver = MidiDriver::createMidi(midiDriver);
+ _midiPlayer = new MidiPlayer(driver);
+
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume"));
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, Audio::Mixer::kMaxMixerVolume);
diff --git a/engines/touche/touche.h b/engines/touche/touche.h
index 97830dffbd..7dafe43ef5 100644
--- a/engines/touche/touche.h
+++ b/engines/touche/touche.h
@@ -347,7 +347,7 @@ public:
typedef void (ToucheEngine::*OpcodeProc)();
- ToucheEngine(OSystem *system, Common::Language language);
+ ToucheEngine(OSystem *system);
virtual ~ToucheEngine();
virtual int init();
@@ -355,6 +355,8 @@ public:
protected:
+ bool detectGame();
+
void restart();
void readConfigurationSettings();
void writeConfigurationSettings();