2002-04-21 17:46:42 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2001 Ludvig Strigeus
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2001-2006 The ScummVM project
|
2002-04-21 17:46:42 +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.
|
|
|
|
|
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-04-21 17:46:42 +00:00
|
|
|
*
|
2006-02-11 09:53:21 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2002-04-21 17:46:42 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2003-05-29 23:13:15 +00:00
|
|
|
/*! \mainpage %ScummVM Source Reference
|
|
|
|
*
|
|
|
|
* These pages contains a cross referenced documentation for the %ScummVM source code,
|
|
|
|
* generated with Doxygen (http://www.doxygen.org) directly from the source.
|
|
|
|
* Currently not much is actually properly documented, but at least you can get an overview
|
|
|
|
* of almost all the classes, methods and variables, and how they interact.
|
|
|
|
*/
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-06-24 15:23:51 +00:00
|
|
|
#include "common/stdafx.h"
|
2003-09-18 02:07:18 +00:00
|
|
|
#include "base/engine.h"
|
2003-09-17 22:41:01 +00:00
|
|
|
#include "base/gameDetector.h"
|
|
|
|
#include "base/plugins.h"
|
2004-02-09 01:27:27 +00:00
|
|
|
#include "base/version.h"
|
2003-10-08 21:59:23 +00:00
|
|
|
#include "common/config-manager.h"
|
2004-08-05 11:13:00 +00:00
|
|
|
#include "common/file.h"
|
2005-01-10 22:06:49 +00:00
|
|
|
#include "common/system.h"
|
2003-09-27 23:59:00 +00:00
|
|
|
#include "common/timer.h"
|
2002-09-26 12:29:10 +00:00
|
|
|
#include "gui/newgui.h"
|
|
|
|
#include "gui/message.h"
|
2004-12-14 01:02:55 +00:00
|
|
|
#include "sound/mididrv.h"
|
2002-04-12 21:26:59 +00:00
|
|
|
|
2006-04-02 09:56:11 +00:00
|
|
|
#if defined(_WIN32_WCE)
|
2005-07-30 21:11:48 +00:00
|
|
|
#include "backends/wince/CELauncherDialog.h"
|
2006-04-02 09:56:11 +00:00
|
|
|
#elif defined(__DC__)
|
2004-08-26 21:51:26 +00:00
|
|
|
#include "backends/dc/DCLauncherDialog.h"
|
2006-04-02 09:56:11 +00:00
|
|
|
#else
|
|
|
|
#include "gui/launcher.h"
|
2004-08-26 21:51:26 +00:00
|
|
|
#endif
|
|
|
|
|
2006-04-23 11:38:48 +00:00
|
|
|
|
2006-04-25 21:31:55 +00:00
|
|
|
#define DETECTOR_TESTING_HACK
|
2006-04-23 11:38:48 +00:00
|
|
|
|
|
|
|
#ifdef DETECTOR_TESTING_HACK
|
|
|
|
#include "backends/fs/fs.h"
|
|
|
|
#endif
|
|
|
|
|
2005-09-03 16:05:28 +00:00
|
|
|
#ifdef PALMOS_68K
|
2004-11-09 10:37:28 +00:00
|
|
|
#include "args.h"
|
|
|
|
#endif
|
|
|
|
|
2006-04-02 00:18:33 +00:00
|
|
|
#ifdef __SYMBIAN32__
|
|
|
|
#include "gui/Actions.h"
|
|
|
|
#endif
|
|
|
|
|
2006-04-02 21:06:49 +00:00
|
|
|
/** List all supported game IDs, i.e. all games which any loaded plugin supports. */
|
|
|
|
void listGames() {
|
|
|
|
const PluginList &plugins = PluginManager::instance().getPlugins();
|
|
|
|
|
|
|
|
printf("Game ID Full Title \n"
|
|
|
|
"-------------------- ------------------------------------------------------\n");
|
|
|
|
|
|
|
|
PluginList::const_iterator iter = plugins.begin();
|
|
|
|
for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
|
|
|
|
GameList list = (*iter)->getSupportedGames();
|
|
|
|
for (GameList::iterator v = list.begin(); v != list.end(); ++v) {
|
|
|
|
printf("%-20s %s\n", v->gameid.c_str(), v->description.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** List all targets which are configured in the config file. */
|
|
|
|
void listTargets() {
|
|
|
|
using namespace Common;
|
|
|
|
const ConfigManager::DomainMap &domains = ConfMan.getGameDomains();
|
|
|
|
|
|
|
|
printf("Target Description \n"
|
|
|
|
"-------------------- ------------------------------------------------------\n");
|
|
|
|
|
|
|
|
ConfigManager::DomainMap::const_iterator iter = domains.begin();
|
|
|
|
for (iter = domains.begin(); iter != domains.end(); ++iter) {
|
2006-04-21 20:50:28 +00:00
|
|
|
Common::String name(iter->_key);
|
|
|
|
Common::String description(iter->_value.get("description"));
|
2006-04-02 21:06:49 +00:00
|
|
|
|
|
|
|
if (description.empty()) {
|
|
|
|
// FIXME: At this point, we should check for a "gameid" override
|
|
|
|
// to find the proper desc. In fact, the platform probably should
|
|
|
|
// be taken into account, too.
|
2006-04-21 20:50:28 +00:00
|
|
|
Common::String gameid(name);
|
2006-04-02 21:06:49 +00:00
|
|
|
GameDescriptor g = GameDetector::findGame(gameid);
|
|
|
|
if (g.description.size() > 0)
|
|
|
|
description = g.description;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("%-20s %s\n", name.c_str(), description.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-08 18:37:28 +00:00
|
|
|
static void setupDummyPalette(OSystem &system) {
|
2002-09-30 00:55:47 +00:00
|
|
|
// FIXME - mouse cursors are currently always set via 8 bit data.
|
|
|
|
// Thus for now we need to setup a dummy palette. On the long run, we might
|
2004-03-28 16:30:50 +00:00
|
|
|
// want to add a setMouseCursor_overlay() method to OSystem, which would serve
|
2002-09-30 00:55:47 +00:00
|
|
|
// two purposes:
|
|
|
|
// 1) allow for 16 bit mouse cursors in overlay mode
|
|
|
|
// 2) no need to backup & restore the mouse cursor before/after the overlay is shown
|
|
|
|
const byte dummy_palette[] = {
|
2005-07-30 21:11:48 +00:00
|
|
|
0, 0, 0, 0,
|
|
|
|
0, 0, 171, 0,
|
|
|
|
0, 171, 0, 0,
|
|
|
|
0, 171, 171, 0,
|
|
|
|
171, 0, 0, 0,
|
|
|
|
171, 0, 171, 0,
|
|
|
|
171, 87, 0, 0,
|
|
|
|
171, 171, 171, 0,
|
|
|
|
87, 87, 87, 0,
|
|
|
|
87, 87, 255, 0,
|
|
|
|
87, 255, 87, 0,
|
|
|
|
87, 255, 255, 0,
|
|
|
|
255, 87, 87, 0,
|
|
|
|
255, 87, 255, 0,
|
|
|
|
255, 255, 87, 0,
|
|
|
|
255, 255, 255, 0,
|
2002-09-30 00:55:47 +00:00
|
|
|
};
|
|
|
|
|
2005-01-01 18:53:47 +00:00
|
|
|
system.setPalette(dummy_palette, 0, 16);
|
2005-01-08 18:37:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool launcherDialog(GameDetector &detector, OSystem &system) {
|
|
|
|
|
|
|
|
system.beginGFXTransaction();
|
|
|
|
// Set the user specified graphics mode (if any).
|
|
|
|
system.setGraphicsMode(ConfMan.get("gfx_mode").c_str());
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-03-09 23:07:32 +00:00
|
|
|
// Make GUI 640 x 400
|
2006-04-15 13:51:49 +00:00
|
|
|
system.initSize(320, 200, (ConfMan.getBool("force_1x_overlay") ? 1 : 2));
|
2005-01-08 18:37:28 +00:00
|
|
|
system.endGFXTransaction();
|
|
|
|
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-01-08 18:37:28 +00:00
|
|
|
// Clear the main screen
|
|
|
|
system.clearScreen();
|
|
|
|
|
|
|
|
// Setup a dummy palette, for the mouse cursor
|
|
|
|
setupDummyPalette(system);
|
2002-09-30 00:55:47 +00:00
|
|
|
|
2004-08-26 21:51:26 +00:00
|
|
|
#if defined(_WIN32_WCE)
|
2004-01-26 07:32:25 +00:00
|
|
|
CELauncherDialog dlg(detector);
|
2004-08-26 21:51:26 +00:00
|
|
|
#elif defined(__DC__)
|
|
|
|
DCLauncherDialog dlg(detector);
|
|
|
|
#else
|
|
|
|
GUI::LauncherDialog dlg(detector);
|
2004-01-26 07:32:25 +00:00
|
|
|
#endif
|
2004-12-25 22:13:44 +00:00
|
|
|
return (dlg.runModal() != -1);
|
2002-09-30 00:55:47 +00:00
|
|
|
}
|
|
|
|
|
2006-04-15 20:36:41 +00:00
|
|
|
static int runGame(const Plugin *plugin, OSystem &system, const Common::String &edebuglevels) {
|
2006-03-25 04:17:17 +00:00
|
|
|
// We add it here, so MD5-based detection will be able to
|
|
|
|
// read mixed case files
|
2006-04-25 23:07:59 +00:00
|
|
|
if (ConfMan.hasKey("path")) {
|
2006-04-26 08:36:55 +00:00
|
|
|
Common::String path(ConfMan.get("path"));
|
|
|
|
FilesystemNode dir(path);
|
|
|
|
if (!dir.isValid() || !dir.isDirectory()) {
|
|
|
|
warning("Game directory does not exist (%s)", path.c_str());
|
2006-04-25 23:07:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2006-04-26 08:36:55 +00:00
|
|
|
Common::File::addDefaultDirectory(path);
|
2006-04-25 23:07:59 +00:00
|
|
|
} else {
|
2006-04-04 23:30:41 +00:00
|
|
|
Common::File::addDefaultDirectory(".");
|
2006-04-25 23:07:59 +00:00
|
|
|
}
|
2006-03-25 04:17:17 +00:00
|
|
|
|
2005-05-05 12:03:40 +00:00
|
|
|
// Create the game engine
|
2006-04-29 00:27:20 +00:00
|
|
|
Engine *engine = 0;
|
|
|
|
PluginError err = plugin->createInstance(&system, &engine);
|
|
|
|
if (!engine || err != kNoError) {
|
2005-05-05 12:03:40 +00:00
|
|
|
// TODO: Show an error dialog or so?
|
2006-04-29 00:27:20 +00:00
|
|
|
// TODO: Also take 'err' into consideration...
|
2005-05-05 12:03:40 +00:00
|
|
|
//GUI::MessageDialog alert("ScummVM could not find any game in the specified directory!");
|
|
|
|
//alert.runModal();
|
2006-04-15 20:36:41 +00:00
|
|
|
warning("Failed to instantiate engine for target %s", ConfMan.getActiveDomainName().c_str());
|
2005-05-05 12:03:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-02-14 23:31:25 +00:00
|
|
|
// Now the engine should've set up all debug levels so we can use the command line arugments here
|
2006-02-23 18:14:41 +00:00
|
|
|
Common::enableSpecialDebugLevelList(edebuglevels);
|
2005-05-05 12:03:40 +00:00
|
|
|
|
2004-01-15 14:01:57 +00:00
|
|
|
// Set the window caption to the game name
|
2006-04-15 20:36:41 +00:00
|
|
|
Common::String caption(ConfMan.get("description"));
|
2004-01-15 14:01:57 +00:00
|
|
|
|
2006-04-15 17:39:14 +00:00
|
|
|
Common::String desc = GameDetector::findGame(ConfMan.get("gameid")).description;
|
2006-03-28 09:42:54 +00:00
|
|
|
if (caption.empty() && !desc.empty())
|
2006-02-18 12:50:48 +00:00
|
|
|
caption = desc;
|
2006-03-28 09:42:54 +00:00
|
|
|
if (caption.empty())
|
2006-04-15 20:36:41 +00:00
|
|
|
caption = ConfMan.getActiveDomainName(); // Use the domain (=target) name
|
2006-03-28 09:42:54 +00:00
|
|
|
if (!caption.empty()) {
|
2005-01-01 18:53:47 +00:00
|
|
|
system.setWindowCaption(caption.c_str());
|
2004-01-15 14:01:57 +00:00
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-04-04 23:30:41 +00:00
|
|
|
if (ConfMan.hasKey("path"))
|
|
|
|
Common::File::addDefaultDirectoryRecursive(ConfMan.get("path"));
|
|
|
|
else
|
2006-04-05 06:58:18 +00:00
|
|
|
Common::File::addDefaultDirectory(".");
|
2006-03-25 04:17:17 +00:00
|
|
|
|
2004-11-23 00:03:25 +00:00
|
|
|
// Add extrapath (if any) to the directory search list
|
|
|
|
if (ConfMan.hasKey("extrapath"))
|
2006-03-25 04:17:17 +00:00
|
|
|
Common::File::addDefaultDirectoryRecursive(ConfMan.get("extrapath"));
|
2004-11-23 00:03:25 +00:00
|
|
|
|
|
|
|
if (ConfMan.hasKey("extrapath", Common::ConfigManager::kApplicationDomain))
|
2006-03-25 04:17:17 +00:00
|
|
|
Common::File::addDefaultDirectoryRecursive(ConfMan.get("extrapath", Common::ConfigManager::kApplicationDomain));
|
|
|
|
|
2006-03-25 19:30:10 +00:00
|
|
|
// As a last resort add current directory
|
|
|
|
Common::File::addDefaultDirectory(".");
|
2004-11-23 00:03:25 +00:00
|
|
|
|
|
|
|
int result;
|
|
|
|
|
2004-11-24 00:14:21 +00:00
|
|
|
// Init the engine (this might change the screen parameters
|
2006-04-15 20:36:41 +00:00
|
|
|
result = engine->init();
|
2004-02-25 08:03:31 +00:00
|
|
|
|
2004-11-23 00:03:25 +00:00
|
|
|
// Run the game engine if the initialization was successful.
|
|
|
|
if (result == 0) {
|
|
|
|
result = engine->go();
|
|
|
|
}
|
2004-01-15 14:01:57 +00:00
|
|
|
|
2006-02-14 23:31:25 +00:00
|
|
|
// We clear all debug levels again even though the engine should do it
|
|
|
|
Common::clearAllSpecialDebugLevels();
|
|
|
|
|
2004-01-15 14:01:57 +00:00
|
|
|
// Free up memory
|
|
|
|
delete engine;
|
2004-06-20 19:23:04 +00:00
|
|
|
|
|
|
|
// Stop all sound processing now (this prevents some race conditions later on)
|
2005-01-01 18:53:47 +00:00
|
|
|
system.clearSoundCallback();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-04-01 21:52:33 +00:00
|
|
|
// Reset the file/directory mappings
|
|
|
|
Common::File::resetDefaultDirectories();
|
|
|
|
|
2004-11-23 00:03:25 +00:00
|
|
|
return result;
|
2004-03-16 23:51:41 +00:00
|
|
|
}
|
2004-01-15 14:01:57 +00:00
|
|
|
|
2006-04-25 21:31:55 +00:00
|
|
|
#ifdef DETECTOR_TESTING_HACK
|
|
|
|
static void runDetectorTest() {
|
|
|
|
// HACK: The following code can be used to test the detection code of our
|
|
|
|
// engines. Basically, it loops over all targets, and calls the detector
|
|
|
|
// for the given path. It then prints out the result and also checks
|
|
|
|
// whether the result agrees with the settings of the target.
|
|
|
|
|
|
|
|
const Common::ConfigManager::DomainMap &domains = ConfMan.getGameDomains();
|
|
|
|
Common::ConfigManager::DomainMap::const_iterator iter = domains.begin();
|
|
|
|
int success = 0, failure = 0;
|
|
|
|
for (iter = domains.begin(); iter != domains.end(); ++iter) {
|
|
|
|
Common::String name(iter->_key);
|
|
|
|
Common::String gameid(iter->_value.get("gameid"));
|
|
|
|
Common::String path(iter->_value.get("path"));
|
|
|
|
printf("Looking at target '%s', gameid '%s', path '%s' ...\n",
|
|
|
|
name.c_str(), gameid.c_str(), path.c_str());
|
|
|
|
if (path.empty()) {
|
|
|
|
printf(" ... no path specified, skipping\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (gameid.empty()) {
|
|
|
|
gameid = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
FilesystemNode dir(path);
|
|
|
|
|
|
|
|
if (!dir.isValid() || !dir.isDirectory()) {
|
|
|
|
printf(" ... invalid path, skipping\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
FSList files = dir.listDir(FilesystemNode::kListAll);
|
|
|
|
DetectedGameList candidates(PluginManager::instance().detectGames(files));
|
|
|
|
|
|
|
|
bool gameidDiffers = false;
|
|
|
|
for (DetectedGameList::iterator x = candidates.begin(); x != candidates.end(); ++x) {
|
|
|
|
gameidDiffers |= scumm_stricmp(gameid.c_str(), x->gameid.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (candidates.empty()) {
|
|
|
|
printf(" FAILURE: No games detected\n");
|
|
|
|
failure++;
|
|
|
|
} else if (candidates.size() > 1) {
|
|
|
|
if (gameidDiffers) {
|
|
|
|
printf(" FAILURE: Multiple games detected, some/all with wrong gameid\n");
|
|
|
|
} else {
|
|
|
|
printf(" FAILURE: Multiple games detected, but all have the same gameid\n");
|
|
|
|
}
|
|
|
|
failure++;
|
|
|
|
} else if (gameidDiffers) {
|
|
|
|
printf(" FAILURE: Wrong gameid detected\n");
|
|
|
|
failure++;
|
|
|
|
} else {
|
|
|
|
printf(" SUCCESS: Game was detected correctly\n");
|
|
|
|
success++;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (DetectedGameList::iterator x = candidates.begin(); x != candidates.end(); ++x) {
|
|
|
|
printf(" gameid '%s', desc '%s', language '%s', platform '%s'\n",
|
|
|
|
x->gameid.c_str(),
|
|
|
|
x->description.c_str(),
|
|
|
|
Common::getLanguageCode(x->language),
|
|
|
|
Common::getPlatformCode(x->platform));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int total = domains.size();
|
|
|
|
printf("Detector test run: %d fail, %d success, %d skipped, out of %d\n",
|
|
|
|
failure, success, total - failure - success, total);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-04-02 00:08:22 +00:00
|
|
|
extern "C" int scummvm_main(int argc, char *argv[]) {
|
2006-04-02 20:27:56 +00:00
|
|
|
Common::String specialDebug;
|
2006-04-02 21:06:49 +00:00
|
|
|
Common::String command;
|
2004-11-11 14:01:11 +00:00
|
|
|
bool running = true;
|
2002-05-14 11:32:16 +00:00
|
|
|
|
2006-04-02 20:27:56 +00:00
|
|
|
// Verify that the backend has been initialized (i.e. g_system has been set).
|
2006-04-02 14:16:31 +00:00
|
|
|
assert(g_system);
|
|
|
|
OSystem &system = *g_system;
|
|
|
|
|
2006-04-02 20:27:56 +00:00
|
|
|
// Parse the command line
|
|
|
|
Common::StringMap settings;
|
2006-04-02 21:06:49 +00:00
|
|
|
command = GameDetector::parseCommandLine(settings, argc, argv);
|
2006-04-02 14:16:31 +00:00
|
|
|
|
2006-04-02 20:27:56 +00:00
|
|
|
// Load the config file (possibly overriden via command line):
|
|
|
|
if (settings.contains("config")) {
|
|
|
|
ConfMan.loadConfigFile(settings["config"]);
|
|
|
|
settings.erase("config");
|
|
|
|
} else {
|
2004-12-25 19:03:13 +00:00
|
|
|
ConfMan.loadDefaultConfigFile();
|
2006-04-02 20:27:56 +00:00
|
|
|
}
|
2004-02-07 04:53:59 +00:00
|
|
|
|
2006-04-02 21:38:36 +00:00
|
|
|
// Update the config file
|
|
|
|
ConfMan.set("versioninfo", gScummVMVersion, Common::ConfigManager::kApplicationDomain);
|
|
|
|
|
2006-04-02 21:32:23 +00:00
|
|
|
if (settings.contains("debuglevel")) {
|
|
|
|
gDebugLevel = (int)strtol(settings["debuglevel"].c_str(), 0, 10);
|
|
|
|
printf("Debuglevel (from command line): %d\n", gDebugLevel);
|
|
|
|
settings.erase("debuglevel"); // This option should not be passed to ConfMan.
|
|
|
|
} else if (ConfMan.hasKey("debuglevel"))
|
2005-04-23 13:52:27 +00:00
|
|
|
gDebugLevel = ConfMan.getInt("debuglevel");
|
2004-12-27 21:54:20 +00:00
|
|
|
|
2006-04-02 20:27:56 +00:00
|
|
|
// Look for special debug flags
|
|
|
|
if (settings.contains("debugflags")) {
|
|
|
|
specialDebug = settings["debugflags"];
|
|
|
|
settings.erase("debugflags");
|
2006-02-14 23:31:25 +00:00
|
|
|
}
|
|
|
|
|
2003-09-08 17:13:40 +00:00
|
|
|
// Load the plugins
|
2003-10-08 22:10:59 +00:00
|
|
|
PluginManager::instance().loadPlugins();
|
2006-04-02 21:06:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Handle commands passed via the command line (like --list-targets and
|
|
|
|
// --list-games). This must be done after the config file and the plugins
|
|
|
|
// have been loaded.
|
|
|
|
// FIXME: The way are are doing this is rather arbitrary at this time.
|
|
|
|
// E.g. --version and --help are very similar, but are still handled
|
|
|
|
// inside parseCommandLine. This should be unified.
|
|
|
|
if (command == "list-targets") {
|
|
|
|
listTargets();
|
2006-04-14 14:26:34 +00:00
|
|
|
return 0;
|
2006-04-02 21:06:49 +00:00
|
|
|
} else if (command == "list-games") {
|
|
|
|
listGames();
|
2006-04-14 14:26:34 +00:00
|
|
|
return 0;
|
2006-04-02 21:06:49 +00:00
|
|
|
}
|
2006-04-23 11:38:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef DETECTOR_TESTING_HACK
|
2006-04-25 21:31:55 +00:00
|
|
|
else if (command == "test-detector") {
|
|
|
|
runDetectorTest();
|
|
|
|
return 0;
|
2006-04-23 11:38:48 +00:00
|
|
|
}
|
|
|
|
#endif
|
2006-04-02 21:06:49 +00:00
|
|
|
|
2003-03-06 16:27:06 +00:00
|
|
|
|
2006-04-02 21:38:36 +00:00
|
|
|
// Process the remaining command line settings
|
2003-09-08 17:13:40 +00:00
|
|
|
GameDetector detector;
|
2006-04-02 21:28:01 +00:00
|
|
|
detector.processSettings(command, settings);
|
2005-07-05 20:22:56 +00:00
|
|
|
|
2006-04-12 19:04:10 +00:00
|
|
|
#if defined(__SYMBIAN32__) || defined(_WIN32_WCE)
|
2005-07-05 20:22:56 +00:00
|
|
|
// init keymap support here: we wanna move this somewhere else?
|
2006-04-21 20:50:28 +00:00
|
|
|
GUI::Actions::init();
|
2005-07-05 20:22:56 +00:00
|
|
|
#endif
|
|
|
|
|
2005-09-03 16:05:28 +00:00
|
|
|
#ifdef PALMOS_68K
|
2004-11-09 10:37:28 +00:00
|
|
|
ArgsFree(argv);
|
|
|
|
#endif
|
|
|
|
|
2005-04-19 20:22:50 +00:00
|
|
|
// Init the backend. Must take place after all config data (including
|
|
|
|
// the command line params) was read.
|
|
|
|
system.initBackend();
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-05 13:10:28 +00:00
|
|
|
// Create the timer services
|
2005-05-10 23:17:38 +00:00
|
|
|
Common::g_timer = new Common::Timer(&system);
|
2002-04-12 21:26:59 +00:00
|
|
|
|
2002-11-14 14:20:41 +00:00
|
|
|
// Set initial window caption
|
2005-01-01 18:53:47 +00:00
|
|
|
system.setWindowCaption(gScummVMFullVersion);
|
2002-11-14 14:20:41 +00:00
|
|
|
|
2006-04-02 09:56:11 +00:00
|
|
|
// Setup a dummy palette, for the mouse cursor, in case an error
|
|
|
|
// dialog has to be shown. See bug #1097467.
|
|
|
|
setupDummyPalette(system);
|
|
|
|
|
2002-09-30 00:55:47 +00:00
|
|
|
// Unless a game was specified, show the launcher dialog
|
2006-04-15 20:36:41 +00:00
|
|
|
if (ConfMan.getActiveDomainName().empty()) {
|
2006-04-15 13:21:02 +00:00
|
|
|
running = launcherDialog(detector, system);
|
|
|
|
|
2006-04-15 13:12:03 +00:00
|
|
|
// Discard any command line options. Those that affect the graphics
|
|
|
|
// mode etc. already have should have been handled by the backend at
|
|
|
|
// this point. And the others (like bootparam etc.) should not
|
|
|
|
// blindly be passed to the first game launched from the launcher.
|
|
|
|
ConfMan.getDomain(Common::ConfigManager::kTransientDomain)->clear();
|
|
|
|
}
|
2002-09-30 00:55:47 +00:00
|
|
|
|
2004-10-10 16:31:15 +00:00
|
|
|
// FIXME: We're now looping the launcher. This, of course, doesn't
|
|
|
|
// work as well as it should. In theory everything should be destroyed
|
|
|
|
// cleanly, so this is now enabled to encourage people to fix bits :)
|
2004-11-20 01:55:53 +00:00
|
|
|
while (running) {
|
2004-01-15 14:01:57 +00:00
|
|
|
// Verify the given game name is a valid supported game
|
2006-04-15 16:37:48 +00:00
|
|
|
const Plugin *plugin = detector.detectMain();
|
|
|
|
if (plugin) {
|
2004-08-29 19:08:08 +00:00
|
|
|
// Unload all plugins not needed for this game,
|
|
|
|
// to save memory
|
2006-04-15 16:37:48 +00:00
|
|
|
PluginManager::instance().unloadPluginsExcept(plugin);
|
2004-08-29 19:08:08 +00:00
|
|
|
|
2006-04-15 20:36:41 +00:00
|
|
|
int result = runGame(plugin, system, specialDebug);
|
2004-12-05 17:35:24 +00:00
|
|
|
if (result == 0)
|
|
|
|
break;
|
2003-10-05 14:37:16 +00:00
|
|
|
|
2006-04-15 13:12:03 +00:00
|
|
|
// Discard any command line options. It's unlikely that the user
|
|
|
|
// wanted to apply them to *all* games ever launched.
|
|
|
|
ConfMan.getDomain(Common::ConfigManager::kTransientDomain)->clear();
|
|
|
|
|
|
|
|
// TODO: Reset the game detector fully
|
2004-10-13 08:49:33 +00:00
|
|
|
|
2004-08-29 19:08:08 +00:00
|
|
|
// PluginManager::instance().unloadPlugins();
|
2004-11-11 14:01:11 +00:00
|
|
|
PluginManager::instance().loadPlugins();
|
2003-10-05 14:37:16 +00:00
|
|
|
}
|
2004-11-11 14:01:11 +00:00
|
|
|
|
2004-12-25 22:13:44 +00:00
|
|
|
running = launcherDialog(detector, system);
|
2004-10-10 16:31:15 +00:00
|
|
|
}
|
2003-08-19 15:03:27 +00:00
|
|
|
|
2006-04-02 14:31:23 +00:00
|
|
|
// Deinit the timer
|
2005-05-10 23:17:38 +00:00
|
|
|
delete Common::g_timer;
|
2005-01-01 18:53:47 +00:00
|
|
|
|
2002-04-12 21:26:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|