2006-10-02 22:21:57 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2005-2006 The ScummVM project
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#ifndef COMMON_ADVANCED_DETECTOR_H
|
|
|
|
#define COMMON_ADVANCED_DETECTOR_H
|
|
|
|
|
|
|
|
#include "common/fs.h"
|
|
|
|
|
2006-11-12 03:23:29 +00:00
|
|
|
#include "base/game.h" // For PlainGameDescriptor and GameList
|
2007-01-24 22:57:40 +00:00
|
|
|
#include "base/plugins.h" // For PluginError
|
2006-11-12 03:23:29 +00:00
|
|
|
|
|
|
|
|
2006-10-02 22:21:57 +00:00
|
|
|
namespace Common {
|
|
|
|
|
|
|
|
struct ADGameFileDescription {
|
|
|
|
const char *fileName;
|
2007-01-25 00:43:35 +00:00
|
|
|
uint16 fileType; // Optional. Not used during detection, only by engines.
|
|
|
|
const char *md5; // Optional. May be NULL.
|
|
|
|
const int32 fileSize; // Optional. Set to -1 to ignore.
|
2006-10-02 22:21:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ADGameDescription {
|
2006-12-19 23:37:03 +00:00
|
|
|
const char *gameid;
|
2006-10-02 22:21:57 +00:00
|
|
|
const char *extra;
|
2006-12-29 00:03:03 +00:00
|
|
|
const ADGameFileDescription filesDescriptions[14];
|
2006-10-02 22:21:57 +00:00
|
|
|
Language language;
|
|
|
|
Platform platform;
|
|
|
|
};
|
|
|
|
|
2006-11-10 22:43:10 +00:00
|
|
|
struct ADObsoleteGameID {
|
|
|
|
const char *from;
|
|
|
|
const char *to;
|
|
|
|
Common::Platform platform;
|
|
|
|
};
|
|
|
|
|
2007-01-24 22:24:52 +00:00
|
|
|
struct ADParams {
|
|
|
|
// Pointer to ADGameDescription or its superset structure
|
|
|
|
const byte *descs;
|
|
|
|
// Size of that superset structure
|
|
|
|
const int descItemSize;
|
|
|
|
// Number of bytes to compute MD5 sum for
|
|
|
|
const int md5Bytes;
|
|
|
|
// List of all engine targets
|
|
|
|
const PlainGameDescriptor *list;
|
|
|
|
// Structure for autoupgrading obsolete targets
|
|
|
|
const Common::ADObsoleteGameID *obsoleteList;
|
|
|
|
};
|
|
|
|
|
2006-10-02 22:21:57 +00:00
|
|
|
typedef Array<int> ADList;
|
2006-10-24 09:44:20 +00:00
|
|
|
typedef Array<const ADGameDescription*> ADGameDescList;
|
2006-10-02 22:21:57 +00:00
|
|
|
|
2007-01-24 22:42:44 +00:00
|
|
|
#define AD_ENTRY1(f, x) {{ f, 0, x, -1}, {NULL, 0, NULL, 0}}
|
2006-12-19 22:43:15 +00:00
|
|
|
|
|
|
|
|
2006-11-12 03:23:29 +00:00
|
|
|
// FIXME/TODO: Rename this function to something more sensible.
|
2006-12-20 00:08:51 +00:00
|
|
|
GameDescriptor ADVANCED_DETECTOR_FIND_GAMEID(
|
2006-11-12 03:23:29 +00:00
|
|
|
const char *gameid,
|
2007-01-24 22:24:52 +00:00
|
|
|
const Common::ADParams ¶ms
|
2006-11-12 03:23:29 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME/TODO: Rename this function to something more sensible.
|
2007-01-20 21:27:57 +00:00
|
|
|
GameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
|
2006-11-12 03:23:29 +00:00
|
|
|
const FSList &fslist,
|
2007-01-24 22:24:52 +00:00
|
|
|
const Common::ADParams ¶ms
|
2006-11-12 03:23:29 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME/TODO: Rename this function to something more sensible.
|
2006-12-19 23:57:04 +00:00
|
|
|
int ADVANCED_DETECTOR_DETECT_INIT_GAME(
|
2007-01-24 22:24:52 +00:00
|
|
|
const Common::ADParams ¶ms
|
2006-11-12 03:23:29 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// FIXME/TODO: Rename this function to something more sensible.
|
2006-12-20 00:08:51 +00:00
|
|
|
PluginError ADVANCED_DETECTOR_ENGINE_CREATE(
|
2007-01-20 21:27:57 +00:00
|
|
|
GameList (*detectFunc)(const FSList &fslist),
|
2007-01-24 22:24:52 +00:00
|
|
|
const Common::ADParams ¶ms
|
2006-11-12 03:23:29 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
2007-01-25 00:51:32 +00:00
|
|
|
#define ADVANCED_DETECTOR_DEFINE_PLUGIN(engine,className,detectFunc,params) \
|
2006-12-19 23:37:03 +00:00
|
|
|
GameList Engine_##engine##_gameIDList() { \
|
2007-01-24 22:24:52 +00:00
|
|
|
return GameList(params.list); \
|
2006-12-19 23:37:03 +00:00
|
|
|
} \
|
|
|
|
GameDescriptor Engine_##engine##_findGameID(const char *gameid) { \
|
2007-01-24 22:24:52 +00:00
|
|
|
return Common::ADVANCED_DETECTOR_FIND_GAMEID(gameid, params); \
|
2006-12-19 23:37:03 +00:00
|
|
|
} \
|
2007-01-20 21:27:57 +00:00
|
|
|
GameList Engine_##engine##_detectGames(const FSList &fslist) { \
|
2006-11-12 03:23:29 +00:00
|
|
|
return detectFunc(fslist); \
|
2006-11-10 22:43:10 +00:00
|
|
|
} \
|
|
|
|
PluginError Engine_##engine##_create(OSystem *syst, Engine **engine) { \
|
|
|
|
assert(syst); \
|
|
|
|
assert(engine); \
|
2007-01-24 22:24:52 +00:00
|
|
|
PluginError err = ADVANCED_DETECTOR_ENGINE_CREATE(detectFunc, params); \
|
2006-11-12 03:23:29 +00:00
|
|
|
if (err == kNoError) \
|
2007-01-25 00:51:32 +00:00
|
|
|
*engine = new className(syst); \
|
2006-11-12 03:23:29 +00:00
|
|
|
return err; \
|
2006-11-10 22:43:10 +00:00
|
|
|
} \
|
|
|
|
void dummyFuncToAllowTrailingSemicolon()
|
|
|
|
|
2006-11-12 03:23:29 +00:00
|
|
|
|
2006-10-02 22:21:57 +00:00
|
|
|
} // End of namespace Common
|
|
|
|
|
|
|
|
#endif
|