Simplify the detection code

This commit is contained in:
Jordi Vilalta Prat 2010-01-24 22:34:53 +08:00 committed by Scott Thomas
parent 18e3e02316
commit 27cc3ca035
3 changed files with 42 additions and 111 deletions

View file

@ -23,132 +23,70 @@
* *
*/ */
#include "base/plugins.h"
#include "engines/advancedDetector.h"
#include "engines/stark/stark.h" #include "engines/stark/stark.h"
namespace Stark { namespace Stark {
struct StarkGameDescription {
ADGameDescription desc;
uint8 gameType;
uint32 features;
uint16 version;
};
uint32 StarkEngine::getFeatures() const {
return _gameDescription->features;
}
Common::Platform StarkEngine::getPlatform() const {
return _gameDescription->desc.platform;
}
uint16 StarkEngine::getVersion() const {
return _gameDescription->version;
}
int StarkEngine::getGameID() const {
return _gameDescription->gameType;
}
Common::Language StarkEngine::getLanguage() const {
return _gameDescription->desc.language;
}
} // End of Namespace Stark
static const PlainGameDescriptor starkGames[] = { static const PlainGameDescriptor starkGames[] = {
{"stark", "Stark Game"}, {"stark", "Stark Game"},
{"tlj", "The Longest Journey"}, {"tlj", "The Longest Journey"},
{0, 0} {0, 0}
}; };
static const ADGameDescription gameDescriptions[] = {
namespace Stark {
static const StarkGameDescription gameDescriptions[] = {
// The Longest Journey // The Longest Journey
// English 4CD // English 4CD
{ {
{ "tlj", "",
"tlj", AD_ENTRY1("x.xarc", "a0559457126caadab0cadac02d35f26f"),
"", Common::EN_ANY,
AD_ENTRY1("x.xarc", "a0559457126caadab0cadac02d35f26f"), Common::kPlatformWindows,
Common::EN_ANY, ADGF_NO_FLAGS,
Common::kPlatformWindows, Common::GUIO_NONE
ADGF_NO_FLAGS,
Common::GUIO_NONE
},
GID_TLJ,
0,
0
}, },
// The Longest Journey // The Longest Journey
// English DVD // English DVD
{ {
{ "tlj", "DVD",
"tlj", AD_ENTRY1("x.xarc", "de8327850d7bba90b690b141eaa23f61"),
"DVD", Common::EN_ANY,
AD_ENTRY1("x.xarc", "de8327850d7bba90b690b141eaa23f61"), Common::kPlatformWindows,
Common::EN_ANY,
Common::kPlatformWindows,
ADGF_NO_FLAGS,
Common::GUIO_NONE
},
GID_TLJ,
GF_DVD, GF_DVD,
0 Common::GUIO_NONE
}, },
// The Longest Journey // The Longest Journey
// English Demo // English Demo
{ {
{ "tlj", "",
"tlj", AD_ENTRY1("x.xarc", "97abc1bb9239dee4c208e533f3c97e1c"),
"", Common::EN_ANY,
AD_ENTRY1("x.xarc", "97abc1bb9239dee4c208e533f3c97e1c"), Common::kPlatformWindows,
Common::EN_ANY, ADGF_DEMO,
Common::kPlatformWindows, Common::GUIO_NONE
ADGF_NO_FLAGS,
Common::GUIO_NONE
},
GID_TLJ,
GF_DEMO,
0
}, },
// The Longest Journey // The Longest Journey
// English DVD Demo // English DVD Demo
{ {
{ "tlj", "DVD",
"tlj", AD_ENTRY1("x.xarc", "61093bcd499b386ed5c0345c52f48909"),
"", Common::EN_ANY,
AD_ENTRY1("x.xarc", "61093bcd499b386ed5c0345c52f48909"), Common::kPlatformWindows,
Common::EN_ANY, ADGF_DEMO | GF_DVD,
Common::kPlatformWindows, Common::GUIO_NONE
ADGF_NO_FLAGS,
Common::GUIO_NONE
},
GID_TLJ,
GF_DVD | GF_DEMO,
0
}, },
{ AD_TABLE_END_MARKER, 0, 0, 0 } AD_TABLE_END_MARKER
}; };
} // End of namespace Stark
static const ADParams detectionParams = { static const ADParams detectionParams = {
// Pointer to ADGameDescription or its superset structure // Pointer to ADGameDescription or its superset structure
(const byte *)Stark::gameDescriptions, (const byte *)gameDescriptions,
// Size of that superset structure // Size of that superset structure
sizeof(Stark::StarkGameDescription), sizeof(ADGameDescription),
// Number of bytes to compute MD5 sum for // Number of bytes to compute MD5 sum for
5000, 5000,
// List of all engine targets // List of all engine targets
@ -181,16 +119,16 @@ public:
}; };
bool StarkMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { bool StarkMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
const Stark::StarkGameDescription *gd = (const Stark::StarkGameDescription *)desc; if (desc)
*engine = new StarkEngine(syst, desc);
if (gd) return desc != 0;
*engine = new Stark::StarkEngine(syst, gd);
return gd != 0;
} }
} // End of namespace Stark
#if PLUGIN_ENABLED_DYNAMIC(STARK) #if PLUGIN_ENABLED_DYNAMIC(STARK)
REGISTER_PLUGIN_DYNAMIC(STARK, PLUGIN_TYPE_ENGINE, StarkMetaEngine); REGISTER_PLUGIN_DYNAMIC(STARK, PLUGIN_TYPE_ENGINE, Stark::StarkMetaEngine);
#else #else
REGISTER_PLUGIN_STATIC(STARK, PLUGIN_TYPE_ENGINE, StarkMetaEngine); REGISTER_PLUGIN_STATIC(STARK, PLUGIN_TYPE_ENGINE, Stark::StarkMetaEngine);
#endif #endif

View file

@ -40,7 +40,7 @@ namespace Stark {
StarkEngine *g_stark = NULL; StarkEngine *g_stark = NULL;
GfxBase *g_driver = NULL; GfxBase *g_driver = NULL;
StarkEngine::StarkEngine(OSystem *syst, const StarkGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) { StarkEngine::StarkEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
_mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, 127); _mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, 127);
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume")); _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume"));

21
stark.h
View file

@ -26,6 +26,7 @@
#ifndef STARK_H #ifndef STARK_H
#define STARK_H #define STARK_H
#include "engines/advancedDetector.h"
#include "engines/engine.h" #include "engines/engine.h"
#include "engines/stark/archive.h" #include "engines/stark/archive.h"
@ -33,34 +34,25 @@
namespace Stark { namespace Stark {
/*
enum StarkGameID { enum StarkGameID {
GID_TLJ = 0, GID_TLJ = 0,
GID_DREAM GID_DREAM
}; };
*/
enum StarkGameFeatures { enum StarkGameFeatures {
GF_DEMO = (1 << 0), GF_DVD = (1 << 31)
GF_DVD = (1 << 1)
}; };
struct StarkGameDescription;
class StarkEngine : public Engine { class StarkEngine : public Engine {
public: public:
StarkEngine(OSystem *syst, const StarkGameDescription *gameDesc); StarkEngine(OSystem *syst, const ADGameDescription *gameDesc);
virtual ~StarkEngine(); virtual ~StarkEngine();
void updateDisplayScene(); void updateDisplayScene();
void doFlip(); void doFlip();
int getGameID() const;
uint16 getVersion() const;
uint32 getFeatures() const;
Common::Language getLanguage() const;
Common::Platform getPlatform() const;
const StarkGameDescription *_gameDescription;
void mainLoop(); void mainLoop();
protected: protected:
@ -68,8 +60,9 @@ protected:
virtual Common::Error run(); virtual Common::Error run();
private: private:
XARCArchive _xArchive; const ADGameDescription *_gameDescription;
XARCArchive _xArchive;
}; };
} // end of namespace Stark } // end of namespace Stark