2002-03-25 08:51:34 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2001 Ludvig Strigeus
|
2004-01-06 12:45:34 +00:00
|
|
|
* Copyright (C) 2001-2004 The ScummVM project
|
2002-03-25 08:51:34 +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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2002-03-23 20:34:47 +00:00
|
|
|
#include "stdafx.h"
|
2003-10-02 22:52:57 +00:00
|
|
|
|
|
|
|
#include "base/engine.h"
|
2003-09-17 22:41:01 +00:00
|
|
|
#include "base/gameDetector.h"
|
|
|
|
#include "base/plugins.h"
|
2003-10-02 22:52:57 +00:00
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
#include "common/config-manager.h"
|
2003-08-01 12:21:04 +00:00
|
|
|
#include "common/scaler.h" // Only for gfx_modes
|
2003-10-02 22:52:57 +00:00
|
|
|
|
2002-04-19 11:12:27 +00:00
|
|
|
#include "sound/mididrv.h"
|
2003-09-08 17:42:53 +00:00
|
|
|
#include "sound/mixer.h"
|
2002-04-19 11:12:27 +00:00
|
|
|
|
2003-05-18 13:39:02 +00:00
|
|
|
#if defined(HAVE_CONFIG_H)
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2003-11-07 02:31:44 +00:00
|
|
|
// DONT FIXME: DO NOT ORDER ALPHABETICALLY, THIS IS ORDERED BY IMPORTANCE/CATEGORY! :)
|
2003-04-30 12:43:56 +00:00
|
|
|
#ifdef __PALM_OS__
|
|
|
|
static const char USAGE_STRING[] = "NoUsageString"; // save more data segment space
|
|
|
|
#else
|
2002-04-12 10:34:46 +00:00
|
|
|
static const char USAGE_STRING[] =
|
2003-08-04 12:42:40 +00:00
|
|
|
"ScummVM - Graphical Adventure Game Interpreter\n"
|
2003-10-26 13:33:49 +00:00
|
|
|
"Usage: scummvm [OPTIONS]... [GAME]\n"
|
|
|
|
" -v, --version Display ScummVM version information and exit\n"
|
|
|
|
" -h, --help Display a brief help text and exit\n"
|
|
|
|
" -z, --list-games Display list of supported games and exit\n"
|
|
|
|
" -t, --list-targets Display list of configured targets and exit\n"
|
2002-12-28 12:20:55 +00:00
|
|
|
"\n"
|
2003-10-26 13:33:49 +00:00
|
|
|
" -p, --path=PATH Path to where the game is installed\n"
|
|
|
|
" -x, --save-slot[=NUM] Save game slot to load (default: autosave)\n"
|
|
|
|
" -f, --fullscreen Force full-screen mode\n"
|
|
|
|
" -F, --no-fullscreen Force windowed mode\n"
|
|
|
|
" -g, --gfx-mode=MODE Select graphics scaler (normal,2x,3x,2xsai,\n"
|
|
|
|
" super2xsai,supereagle,advmame2x,advmame3x,hq2x,\n"
|
|
|
|
" hq3x,tv2x,dotmatrix)\n"
|
|
|
|
" -e, --music-driver=MODE Select music driver (see README for details)\n"
|
2003-10-26 21:08:53 +00:00
|
|
|
" -q, --language=LANG Select language (en,de,fr,it,pt,es,jp,zh,kr,se,gb,\n"
|
2004-01-06 12:28:24 +00:00
|
|
|
" hb,ru,cz)\n"
|
2003-10-26 13:33:49 +00:00
|
|
|
" -m, --music-volume=NUM Set the music volume, 0-255 (default: 192)\n"
|
|
|
|
" -o, --master-volume=NUM Set the master volume, 0-255 (default: 192)\n"
|
|
|
|
" -s, --sfx-volume=NUM Set the sfx volume, 0-255 (default: 192)\n"
|
2003-12-02 08:09:14 +00:00
|
|
|
" -n, --subtitles Enable subtitles (use with games that have voice)\n"
|
2003-10-26 13:33:49 +00:00
|
|
|
" -b, --boot-param=NUM Pass number to the boot script (boot param)\n"
|
|
|
|
" -d, --debuglevel=NUM Set debug verbosity level\n"
|
|
|
|
" -u, --dump-scripts Enable script dumping if a directory called 'dumps'\n"
|
|
|
|
" exists in the current directory\n"
|
2002-12-28 12:20:55 +00:00
|
|
|
"\n"
|
2003-10-26 13:33:49 +00:00
|
|
|
" --cdrom=NUM CD drive to play CD audio from (default: 0 = first\n"
|
|
|
|
" drive)\n"
|
2003-12-27 13:52:48 +00:00
|
|
|
" --joystick[=NUM] Enable input with joystick (default: 0 = first\n"
|
2003-10-26 13:33:49 +00:00
|
|
|
" joystick)\n"
|
|
|
|
" --platform=WORD Specify version of game (allowed values: amiga,\n"
|
|
|
|
" atari, mac, pc)\n"
|
|
|
|
" --multi-midi Enable combination Adlib and native MIDI\n"
|
|
|
|
" --native-mt32 True Roland MT-32 (disable GM emulation)\n"
|
|
|
|
" --aspect-ratio Enable aspect ratio correction\n"
|
2002-12-28 12:20:55 +00:00
|
|
|
"\n"
|
2003-07-05 00:57:03 +00:00
|
|
|
#ifndef DISABLE_SKY
|
2003-10-26 13:33:49 +00:00
|
|
|
" --floppy-intro Use floppy version intro for Beneath a Steel Sky CD\n"
|
|
|
|
#endif
|
|
|
|
#ifndef DISABLE_SCUMM
|
2003-12-11 06:08:43 +00:00
|
|
|
" --copy-protection Enable the original copy protection in SCUMM games\n"
|
2003-10-26 13:33:49 +00:00
|
|
|
" --demo-mode Start demo mode of Maniac Mansion (Classic version)\n"
|
|
|
|
" --tempo=NUM Set music tempo (in percent, 50-200) for SCUMM games\n"
|
|
|
|
" (default: 100)\n"
|
|
|
|
" --talkspeed=NUM Set talk speed for SCUMM games (default: 60)\n"
|
2003-07-05 00:57:03 +00:00
|
|
|
#endif
|
2003-07-04 06:54:47 +00:00
|
|
|
"\n"
|
2003-10-26 21:08:53 +00:00
|
|
|
"The meaning of boolean long options can be inverted by prefixing them with\n"
|
|
|
|
"\"no-\", e.g. \"--no-aspect-ratio\".\n"
|
2002-04-12 10:34:46 +00:00
|
|
|
;
|
2003-04-30 12:43:56 +00:00
|
|
|
#endif
|
2003-03-01 22:04:48 +00:00
|
|
|
|
2003-03-06 16:27:06 +00:00
|
|
|
GameDetector::GameDetector() {
|
2003-05-17 03:06:16 +00:00
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
// Graphics
|
|
|
|
ConfMan.registerDefault("fullscreen", false);
|
|
|
|
ConfMan.registerDefault("aspect_ratio", false);
|
2002-09-30 00:55:47 +00:00
|
|
|
#ifndef _WIN32_WCE
|
2003-10-08 21:59:23 +00:00
|
|
|
ConfMan.registerDefault("gfx_mode", "2x");
|
2002-09-30 00:55:47 +00:00
|
|
|
#else
|
2003-10-08 21:59:23 +00:00
|
|
|
ConfMan.registerDefault("gfx_mode", "normal");
|
2002-09-30 00:55:47 +00:00
|
|
|
#endif
|
2003-09-05 16:30:05 +00:00
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
// Sound & Music
|
2003-10-15 23:16:52 +00:00
|
|
|
ConfMan.registerDefault("master_volume", 192);
|
|
|
|
ConfMan.registerDefault("music_volume", 192);
|
|
|
|
ConfMan.registerDefault("sfx_volume", 192);
|
2002-04-27 16:58:29 +00:00
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
ConfMan.registerDefault("multi_midi", false);
|
|
|
|
ConfMan.registerDefault("native_mt32", false);
|
|
|
|
// ConfMan.registerDefault("music_driver", ???);
|
2002-08-18 23:29:40 +00:00
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
ConfMan.registerDefault("cdrom", 0);
|
2003-10-01 10:47:19 +00:00
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
// Game specifc
|
|
|
|
ConfMan.registerDefault("path", "");
|
2004-01-29 21:54:03 +00:00
|
|
|
ConfMan.registerDefault("savepath", "");
|
2002-05-07 05:12:39 +00:00
|
|
|
|
2003-10-12 20:44:52 +00:00
|
|
|
// ConfMan.registerDefault("amiga", false);
|
2003-10-17 15:38:56 +00:00
|
|
|
ConfMan.registerDefault("platform", Common::kPlatformPC);
|
2003-10-08 21:59:23 +00:00
|
|
|
ConfMan.registerDefault("language", "en");
|
2003-12-02 08:09:14 +00:00
|
|
|
// ConfMan.registerDefault("nosubtitles", false);
|
2003-12-21 16:15:37 +00:00
|
|
|
ConfMan.registerDefault("subtitles", false);
|
2003-10-08 21:59:23 +00:00
|
|
|
ConfMan.registerDefault("boot_param", 0);
|
|
|
|
ConfMan.registerDefault("save_slot", -1);
|
2003-07-05 00:57:03 +00:00
|
|
|
|
2003-07-29 12:13:39 +00:00
|
|
|
#ifndef DISABLE_SCUMM
|
2003-12-11 06:08:43 +00:00
|
|
|
ConfMan.registerDefault("copy_protection", false);
|
2003-10-08 21:59:23 +00:00
|
|
|
ConfMan.registerDefault("demo_mode", false);
|
|
|
|
ConfMan.registerDefault("talkspeed", 60);
|
|
|
|
ConfMan.registerDefault("tempo", 0);
|
2003-07-29 12:13:39 +00:00
|
|
|
#endif
|
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
#ifndef DISABLE_SKY
|
|
|
|
ConfMan.registerDefault("floppy_intro", false);
|
|
|
|
#endif
|
2002-12-21 00:27:10 +00:00
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
// Miscellaneous
|
|
|
|
ConfMan.registerDefault("debuglevel", 0);
|
|
|
|
ConfMan.registerDefault("joystick_num", -1);
|
|
|
|
ConfMan.registerDefault("confirm_exit", false);
|
2003-12-11 14:38:43 +00:00
|
|
|
#ifdef USE_ALSA
|
|
|
|
ConfMan.registerDefault("alsa_port", "65:0");
|
|
|
|
#endif
|
2002-05-07 05:12:39 +00:00
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
_dumpScripts = false;
|
2003-05-17 03:06:16 +00:00
|
|
|
|
2003-10-28 17:07:25 +00:00
|
|
|
memset(&_game, 0, sizeof(_game));
|
2003-10-08 21:59:23 +00:00
|
|
|
_plugin = 0;
|
2002-04-27 16:58:29 +00:00
|
|
|
}
|
|
|
|
|
2003-10-17 16:04:46 +00:00
|
|
|
/** List all supported games, i.e. all games which any loaded plugin supports. */
|
|
|
|
void listGames() {
|
2003-10-08 22:10:59 +00:00
|
|
|
const PluginList &plugins = PluginManager::instance().getPlugins();
|
2002-10-18 07:08:45 +00:00
|
|
|
|
2003-10-17 16:04:46 +00:00
|
|
|
printf("Game ID Full Title \n"
|
|
|
|
"-------------------- ------------------------------------------------------\n");
|
2002-10-18 07:08:45 +00:00
|
|
|
|
2004-02-05 00:19:57 +00:00
|
|
|
PluginList::const_iterator iter = plugins.begin();
|
2003-10-05 14:03:07 +00:00
|
|
|
for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
|
2003-10-17 12:18:58 +00:00
|
|
|
GameList list = (*iter)->getSupportedGames();
|
2004-02-05 00:19:57 +00:00
|
|
|
for (GameList::iterator v = list.begin(); v != list.end(); ++v) {
|
2003-12-13 00:20:01 +00:00
|
|
|
printf("%-20s %s\n", v->name, v->description);
|
2003-09-08 17:13:40 +00:00
|
|
|
}
|
2002-10-18 07:08:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-17 16:04:46 +00:00
|
|
|
/** 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");
|
|
|
|
|
2004-02-05 00:19:57 +00:00
|
|
|
ConfigManager::DomainMap::const_iterator iter = domains.begin();
|
2003-10-17 16:04:46 +00:00
|
|
|
for (iter = domains.begin(); iter != domains.end(); ++iter) {
|
|
|
|
String name(iter->_key);
|
|
|
|
String description(iter->_value.get("description"));
|
|
|
|
|
|
|
|
if (description.isEmpty()) {
|
|
|
|
GameSettings g = GameDetector::findGame(name);
|
|
|
|
if (g.description)
|
|
|
|
description = g.description;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("%-20s %s\n", name.c_str(), description.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-17 12:18:58 +00:00
|
|
|
GameSettings GameDetector::findGame(const String &gameName, const Plugin **plugin) {
|
2003-10-12 18:40:12 +00:00
|
|
|
// Find the GameSettings for this target
|
2003-10-08 22:10:59 +00:00
|
|
|
const PluginList &plugins = PluginManager::instance().getPlugins();
|
2003-12-13 00:20:01 +00:00
|
|
|
GameSettings result = {NULL, NULL, 0};
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2004-02-05 00:19:57 +00:00
|
|
|
PluginList::const_iterator iter = plugins.begin();
|
2003-10-05 14:03:07 +00:00
|
|
|
for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
|
2003-10-17 12:18:58 +00:00
|
|
|
result = (*iter)->findGame(gameName.c_str());
|
2003-12-13 00:20:01 +00:00
|
|
|
if (result.name) {
|
2003-09-17 22:41:01 +00:00
|
|
|
if (plugin)
|
2003-10-05 14:03:07 +00:00
|
|
|
*plugin = *iter;
|
2003-10-17 12:18:58 +00:00
|
|
|
break;
|
2003-09-17 22:41:01 +00:00
|
|
|
}
|
2003-09-08 15:38:34 +00:00
|
|
|
}
|
2003-10-17 12:18:58 +00:00
|
|
|
return result;
|
2003-09-08 15:38:34 +00:00
|
|
|
}
|
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
//
|
|
|
|
// Various macros used by the command line parser.
|
|
|
|
//
|
|
|
|
|
|
|
|
#define DO_OPTION_OPT(shortCmd, longCmd) \
|
|
|
|
if (isLongCmd ? (!memcmp(s, longCmd"=", sizeof(longCmd"=") - 1)) : (shortCmdLower == shortCmd)) { \
|
|
|
|
if (isLongCmd) \
|
|
|
|
s += sizeof(longCmd"=") - 1; \
|
|
|
|
if ((*s != '\0') && (current_option != NULL)) goto ShowHelpAndExit; \
|
|
|
|
option = (*s != '\0') ? s : current_option; \
|
|
|
|
current_option = NULL;
|
|
|
|
|
|
|
|
#define DO_OPTION(shortCmd, longCmd) \
|
|
|
|
DO_OPTION_OPT(shortCmd, longCmd) \
|
|
|
|
if (option == NULL) goto ShowHelpAndExit;
|
|
|
|
|
|
|
|
#define DO_OPTION_BOOL(shortCmd, longCmd) \
|
|
|
|
if (isLongCmd ? (!strcmp(s, longCmd) || !strcmp(s, "no-"longCmd)) : (shortCmdLower == shortCmd)) { \
|
|
|
|
if (isLongCmd) { \
|
|
|
|
cmdValue = !strcmp(s, longCmd); \
|
|
|
|
s += cmdValue ? (sizeof(longCmd) - 1) : (sizeof("no-"longCmd) - 1); \
|
|
|
|
} \
|
|
|
|
if ((*s != '\0') || (current_option != NULL)) goto ShowHelpAndExit;
|
|
|
|
|
|
|
|
#define DO_OPTION_CMD(shortCmd, longCmd) \
|
|
|
|
if (isLongCmd ? (!strcmp(s, longCmd)) : (shortCmdLower == shortCmd)) { \
|
|
|
|
if (isLongCmd) \
|
|
|
|
s += sizeof(longCmd) - 1; \
|
|
|
|
if ((*s != '\0') || (current_option != NULL)) goto ShowHelpAndExit;
|
|
|
|
|
|
|
|
|
|
|
|
#define DO_LONG_OPTION_OPT(longCmd) DO_OPTION_OPT(0, longCmd)
|
|
|
|
#define DO_LONG_OPTION(longCmd) DO_OPTION(0, longCmd)
|
|
|
|
#define DO_LONG_OPTION_BOOL(longCmd) DO_OPTION_BOOL(0, longCmd)
|
|
|
|
#define DO_LONG_OPTION_CMD(longCmd) DO_OPTION_CMD(0, longCmd)
|
|
|
|
|
|
|
|
// End an option handler
|
|
|
|
#define END_OPTION \
|
|
|
|
continue; \
|
|
|
|
}
|
|
|
|
|
2003-11-10 23:17:11 +00:00
|
|
|
|
|
|
|
static const Common::String &kTransientDomain = Common::ConfigManager::kTransientDomain;
|
|
|
|
|
2003-03-06 16:27:06 +00:00
|
|
|
void GameDetector::parseCommandLine(int argc, char **argv) {
|
2002-04-11 17:19:16 +00:00
|
|
|
int i;
|
|
|
|
char *s;
|
2002-05-02 18:59:31 +00:00
|
|
|
char *current_option = NULL;
|
|
|
|
char *option = NULL;
|
2003-10-17 19:39:13 +00:00
|
|
|
char shortCmdLower;
|
|
|
|
bool isLongCmd, cmdValue;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2003-10-28 17:07:25 +00:00
|
|
|
// Iterate over all command line arguments, backwards.
|
2002-05-02 18:59:31 +00:00
|
|
|
for (i = argc - 1; i >= 1; i--) {
|
2002-04-11 17:19:16 +00:00
|
|
|
s = argv[i];
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
if (s[0] != '-' || s[1] == '\0') {
|
|
|
|
// Last argument: this could be a target name.
|
2003-12-13 00:20:01 +00:00
|
|
|
// To verify this, check if there is either a game domain (i.e.
|
2003-10-17 19:39:13 +00:00
|
|
|
// a configured target) matching this argument, or if we can
|
|
|
|
// find any target with that name.
|
2003-12-13 00:20:01 +00:00
|
|
|
if (i == (argc - 1) && (ConfMan.hasGameDomain(s) || findGame(s).name)) {
|
2003-10-17 19:39:13 +00:00
|
|
|
setTarget(s);
|
|
|
|
} else {
|
|
|
|
if (current_option == NULL)
|
|
|
|
current_option = s;
|
|
|
|
else
|
|
|
|
goto ShowHelpAndExit;
|
|
|
|
}
|
|
|
|
} else {
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
shortCmdLower = tolower(s[1]);
|
|
|
|
isLongCmd = (s[0] == '-' && s[1] == '-');
|
|
|
|
cmdValue = (shortCmdLower == s[1]);
|
|
|
|
s += 2;
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_OPTION('b', "boot-param")
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("boot_param", (int)strtol(option, 0, 10), kTransientDomain);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
|
|
|
|
|
|
|
DO_OPTION_OPT('d', "debuglevel")
|
2002-05-02 18:59:31 +00:00
|
|
|
if (option != NULL)
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("debuglevel", (int)strtol(option, 0, 10), kTransientDomain);
|
|
|
|
int debuglevel = ConfMan.getInt("debuglevel");
|
|
|
|
if (debuglevel)
|
|
|
|
printf("Debuglevel (from command line): %d\n", debuglevel);
|
2003-10-17 19:39:13 +00:00
|
|
|
else
|
2003-10-14 06:02:38 +00:00
|
|
|
printf("Debuglevel (from command line): 0 - Game only\n");
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
|
|
|
|
|
|
|
DO_OPTION('e', "music-driver")
|
2003-10-02 22:52:57 +00:00
|
|
|
// TODO: Instead of just showing the generic help text,
|
|
|
|
// maybe print a message like:
|
|
|
|
// "'option' is not a supported music driver on this machine.
|
|
|
|
// Available driver: ..."
|
2003-10-08 21:59:23 +00:00
|
|
|
if (parseMusicDriver(option) < 0)
|
2002-05-02 18:59:31 +00:00
|
|
|
goto ShowHelpAndExit;
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("music_driver", option, kTransientDomain);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_OPTION_BOOL('f', "fullscreen")
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("fullscreen", cmdValue, kTransientDomain);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_OPTION('g', "gfx-mode")
|
|
|
|
int gfx_mode = parseGraphicsMode(option);
|
2003-10-02 22:52:57 +00:00
|
|
|
// TODO: Instead of just showing the generic help text,
|
|
|
|
// maybe print a message like:
|
|
|
|
// "'option' is not a supported graphic mode on this machine.
|
|
|
|
// Available graphic modes: ..."
|
2003-10-17 19:39:13 +00:00
|
|
|
if (gfx_mode == -1)
|
2002-05-02 18:59:31 +00:00
|
|
|
goto ShowHelpAndExit;
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("gfx_mode", option, kTransientDomain);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_OPTION_CMD('h', "help")
|
|
|
|
printf(USAGE_STRING);
|
|
|
|
exit(0);
|
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_OPTION('m', "music-volume")
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("music_volume", (int)strtol(option, 0, 10), kTransientDomain);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-12-02 08:09:14 +00:00
|
|
|
DO_OPTION_BOOL('n', "subtitles")
|
|
|
|
ConfMan.set("subtitles", cmdValue, kTransientDomain);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_OPTION('o', "master-volume")
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("master_volume", (int)strtol(option, 0, 10), kTransientDomain);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_OPTION('p', "path")
|
|
|
|
// TODO: Verify whether the path is valid
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("path", option, kTransientDomain);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_OPTION('q', "language")
|
2003-10-17 15:35:46 +00:00
|
|
|
if (Common::parseLanguage(option) == Common::UNK_LANG)
|
2003-01-29 08:07:10 +00:00
|
|
|
goto ShowHelpAndExit;
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("language", option, kTransientDomain);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_OPTION('s', "sfx-volume")
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("sfx_volume", (int)strtol(option, 0, 10), kTransientDomain);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_OPTION_CMD('t', "list-targets")
|
|
|
|
listTargets();
|
|
|
|
exit(0);
|
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_OPTION_BOOL('u', "dump-scripts")
|
2002-12-31 02:09:57 +00:00
|
|
|
_dumpScripts = true;
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_OPTION_CMD('v', "version")
|
2003-07-15 02:16:33 +00:00
|
|
|
printf("%s\n", gScummVMFullVersion);
|
2003-10-08 21:59:23 +00:00
|
|
|
exit(0);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_OPTION('x', "save-slot")
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("save_slot", (option != NULL) ? (int)strtol(option, 0, 10) : 0, kTransientDomain);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_OPTION_CMD('z', "list-games")
|
2003-10-17 16:04:46 +00:00
|
|
|
listGames();
|
2003-10-10 11:15:14 +00:00
|
|
|
exit(0);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_LONG_OPTION("cdrom")
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("cdrom", (int)strtol(option, 0, 10), kTransientDomain);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-20 20:06:29 +00:00
|
|
|
DO_LONG_OPTION_OPT("joystick")
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("joystick_num", (option != NULL) ? (int)strtol(option, 0, 10) : 0, kTransientDomain);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_LONG_OPTION("platform")
|
|
|
|
int platform = Common::parsePlatform(option);
|
|
|
|
if (platform == Common::kPlatformUnknown)
|
|
|
|
goto ShowHelpAndExit;
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("platform", platform, kTransientDomain);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_LONG_OPTION_BOOL("multi-midi")
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("multi_midi", cmdValue, kTransientDomain);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_LONG_OPTION_BOOL("native-mt32")
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("native_mt32", cmdValue, kTransientDomain);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_LONG_OPTION_BOOL("aspect-ratio")
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("aspect_ratio", cmdValue, kTransientDomain);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2004-01-29 21:54:03 +00:00
|
|
|
DO_LONG_OPTION("savepath")
|
|
|
|
// TODO: Verify whether the path is valid
|
|
|
|
ConfMan.set("savepath", option, kTransientDomain);
|
|
|
|
END_OPTION
|
|
|
|
|
2003-07-29 12:13:39 +00:00
|
|
|
#ifndef DISABLE_SCUMM
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_LONG_OPTION("tempo")
|
|
|
|
// Use the special value '0' for the base in (int)strtol.
|
|
|
|
// Doing that makes it possible to enter hex values
|
|
|
|
// as "0x1234", but also decimal values ("123").
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("tempo", (int)strtol(option, 0, 0), kTransientDomain);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_LONG_OPTION("talkspeed")
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("talkspeed", (int)strtol(option, 0, 10), kTransientDomain);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-07-29 12:13:39 +00:00
|
|
|
|
2003-12-11 06:08:43 +00:00
|
|
|
DO_LONG_OPTION_BOOL("copy-protection")
|
|
|
|
ConfMan.set("copy_protection", cmdValue, kTransientDomain);
|
|
|
|
END_OPTION
|
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_LONG_OPTION_BOOL("demo-mode")
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("demo_mode", cmdValue, kTransientDomain);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
|
|
|
#endif
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-07-05 00:57:03 +00:00
|
|
|
#ifndef DISABLE_SKY
|
2003-10-17 19:39:13 +00:00
|
|
|
DO_LONG_OPTION_BOOL("floppy-intro")
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("floppy_intro", cmdValue, kTransientDomain);
|
2003-10-17 19:39:13 +00:00
|
|
|
END_OPTION
|
2003-07-05 00:57:03 +00:00
|
|
|
#endif
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 19:39:13 +00:00
|
|
|
// If we get till here, the option is unhandled and hence unknown.
|
|
|
|
goto ShowHelpAndExit;
|
2002-04-11 17:19:16 +00:00
|
|
|
}
|
|
|
|
}
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-18 00:25:13 +00:00
|
|
|
if (current_option) {
|
2003-03-06 16:27:06 +00:00
|
|
|
ShowHelpAndExit:
|
2003-10-18 00:25:13 +00:00
|
|
|
printf(USAGE_STRING);
|
|
|
|
exit(1);
|
|
|
|
}
|
2002-03-23 20:34:47 +00:00
|
|
|
}
|
|
|
|
|
2003-10-12 18:40:12 +00:00
|
|
|
void GameDetector::setTarget(const String &name) {
|
|
|
|
_targetName = name;
|
2003-10-08 21:59:23 +00:00
|
|
|
ConfMan.setActiveDomain(name);
|
2002-09-30 00:55:47 +00:00
|
|
|
}
|
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
int GameDetector::parseGraphicsMode(const String &str) {
|
2003-10-09 11:15:54 +00:00
|
|
|
if (str.isEmpty())
|
|
|
|
return -1;
|
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
const char *s = str.c_str();
|
2003-03-25 00:26:53 +00:00
|
|
|
const GraphicsMode *gm = gfx_modes;
|
2003-10-08 21:59:23 +00:00
|
|
|
while (gm->name) {
|
2003-03-18 06:53:47 +00:00
|
|
|
if (!scumm_stricmp(gm->name, s)) {
|
2002-04-12 21:26:59 +00:00
|
|
|
return gm->id;
|
2003-03-18 06:53:47 +00:00
|
|
|
}
|
2002-12-13 23:29:18 +00:00
|
|
|
gm++;
|
2002-04-12 21:26:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2003-03-06 16:27:06 +00:00
|
|
|
bool GameDetector::detectGame() {
|
2003-10-08 21:59:23 +00:00
|
|
|
String realGame;
|
2002-10-28 09:03:02 +00:00
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
if (ConfMan.hasKey("gameid"))
|
|
|
|
realGame = ConfMan.get("gameid");
|
|
|
|
else
|
2003-10-12 18:40:12 +00:00
|
|
|
realGame = _targetName;
|
2003-10-08 21:59:23 +00:00
|
|
|
printf("Looking for %s\n", realGame.c_str());
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-10-17 12:18:58 +00:00
|
|
|
_game = findGame(realGame, &_plugin);
|
2003-11-08 22:05:58 +00:00
|
|
|
|
2003-12-13 00:20:01 +00:00
|
|
|
if (_game.name) {
|
2003-09-08 15:38:34 +00:00
|
|
|
printf("Trying to start game '%s'\n", _game.description);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
printf("Failed game detection\n");
|
|
|
|
return false;
|
|
|
|
}
|
2002-03-23 20:34:47 +00:00
|
|
|
}
|
|
|
|
|
2003-10-18 00:22:46 +00:00
|
|
|
int GameDetector::detectMusicDriver(int midiFlags) {
|
|
|
|
int musicDriver = parseMusicDriver(ConfMan.get("music_driver"));
|
|
|
|
/* Use the adlib sound driver if auto mode is selected,
|
|
|
|
* and the game is one of those that want adlib as
|
|
|
|
* default, OR if the game is an older game that doesn't
|
|
|
|
* support anything else anyway. */
|
|
|
|
if (musicDriver == MD_AUTO || musicDriver < 0) {
|
|
|
|
if (midiFlags & MDT_PREFER_NATIVE) {
|
|
|
|
if (musicDriver == MD_AUTO) {
|
|
|
|
#if defined (WIN32) && !defined(_WIN32_WCE)
|
|
|
|
musicDriver = MD_WINDOWS; // MD_WINDOWS is default MidiDriver on windows targets
|
|
|
|
#elif defined(MACOSX)
|
|
|
|
musicDriver = MD_COREAUDIO;
|
|
|
|
#elif defined(__PALM_OS__) // must be before mac
|
2004-02-05 13:56:39 +00:00
|
|
|
musicDriver = MD_YPA1; // TODO : cahnge this and use Zodiac driver when needed
|
2003-10-18 00:22:46 +00:00
|
|
|
#elif defined(__MORPHOS__)
|
|
|
|
musicDriver = MD_ETUDE;
|
|
|
|
#elif defined (_WIN32_WCE) || defined(UNIX) || defined(X11_BACKEND)
|
|
|
|
// Always use MIDI emulation via adlib driver on CE and UNIX device
|
|
|
|
|
|
|
|
// TODO: We should, for the Unix targets, attempt to detect
|
|
|
|
// whether a sequencer is available, and use it instead.
|
|
|
|
musicDriver = MD_ADLIB;
|
|
|
|
#else
|
2003-11-08 22:05:58 +00:00
|
|
|
musicDriver = MD_NULL;
|
2003-10-18 00:22:46 +00:00
|
|
|
#endif
|
2003-10-25 14:36:09 +00:00
|
|
|
} else
|
|
|
|
musicDriver = MD_ADLIB;
|
2003-10-18 00:22:46 +00:00
|
|
|
} else
|
|
|
|
musicDriver = MD_TOWNS;
|
|
|
|
}
|
|
|
|
bool nativeMidiDriver =
|
|
|
|
(musicDriver != MD_NULL && musicDriver != MD_ADLIB &&
|
|
|
|
musicDriver != MD_PCSPK && musicDriver != MD_PCJR &&
|
|
|
|
musicDriver != MD_TOWNS);
|
|
|
|
|
|
|
|
if (nativeMidiDriver && !(midiFlags & MDT_NATIVE))
|
|
|
|
musicDriver = MD_TOWNS;
|
|
|
|
if (musicDriver == MD_TOWNS && !(midiFlags & MDT_TOWNS))
|
|
|
|
musicDriver = MD_ADLIB;
|
|
|
|
if (musicDriver == MD_ADLIB && !(midiFlags & MDT_ADLIB))
|
|
|
|
musicDriver = MD_PCJR;
|
|
|
|
if ((musicDriver == MD_PCSPK || musicDriver == MD_PCJR) && !(midiFlags & MDT_PCSPK))
|
|
|
|
musicDriver = MD_NULL;
|
|
|
|
|
|
|
|
return musicDriver;
|
|
|
|
}
|
|
|
|
|
2003-09-20 00:37:09 +00:00
|
|
|
bool GameDetector::detectMain() {
|
2003-10-12 18:40:12 +00:00
|
|
|
if (_targetName.isEmpty()) {
|
2002-03-25 00:45:09 +00:00
|
|
|
warning("No game was specified...");
|
2003-09-20 00:37:09 +00:00
|
|
|
return false;
|
2002-03-25 00:45:09 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!detectGame()) {
|
2003-10-20 20:06:29 +00:00
|
|
|
warning("%s is an invalid target. Use the --list-targets option to list targets", _targetName.c_str());
|
2003-09-20 00:37:09 +00:00
|
|
|
return false;
|
2002-04-11 17:19:16 +00:00
|
|
|
}
|
2002-03-25 00:45:09 +00:00
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
String gameDataPath(ConfMan.get("path"));
|
|
|
|
if (gameDataPath.isEmpty()) {
|
2002-04-16 15:49:21 +00:00
|
|
|
warning("No path was provided. Assuming the data files are in the current directory");
|
2003-04-30 12:43:56 +00:00
|
|
|
#ifndef __PALM_OS__ // add last slash also in File::fopenNoCase, so this is not needed
|
2003-10-08 21:59:23 +00:00
|
|
|
} else if (gameDataPath.lastChar() != '/'
|
2002-07-04 19:43:58 +00:00
|
|
|
#ifdef __MORPHOS__
|
2003-10-08 21:59:23 +00:00
|
|
|
&& gameDataPath.lastChar() != ':'
|
2002-07-04 19:43:58 +00:00
|
|
|
#endif
|
2003-10-08 21:59:23 +00:00
|
|
|
&& gameDataPath.lastChar() != '\\') {
|
|
|
|
gameDataPath += '/';
|
2003-11-10 23:17:11 +00:00
|
|
|
ConfMan.set("path", gameDataPath, kTransientDomain);
|
2003-04-30 12:43:56 +00:00
|
|
|
#endif
|
2002-04-11 17:19:16 +00:00
|
|
|
}
|
2002-03-23 20:34:47 +00:00
|
|
|
|
2003-09-20 00:37:09 +00:00
|
|
|
return true;
|
2002-04-11 17:19:16 +00:00
|
|
|
}
|
2002-04-13 18:34:11 +00:00
|
|
|
|
2003-10-09 14:05:09 +00:00
|
|
|
Engine *GameDetector::createEngine(OSystem *sys) {
|
2003-09-17 22:41:01 +00:00
|
|
|
assert(_plugin);
|
2003-10-09 14:05:09 +00:00
|
|
|
return _plugin->createInstance(this, sys);
|
2003-09-08 17:13:40 +00:00
|
|
|
}
|
|
|
|
|
2003-09-08 17:42:53 +00:00
|
|
|
SoundMixer *GameDetector::createMixer() {
|
|
|
|
return new SoundMixer();
|
|
|
|
}
|
|
|
|
|
2003-10-18 00:22:46 +00:00
|
|
|
MidiDriver *GameDetector::createMidi(int midiDriver) {
|
|
|
|
switch(midiDriver) {
|
2003-08-13 14:08:21 +00:00
|
|
|
case MD_NULL: return MidiDriver_NULL_create();
|
2003-10-05 15:36:52 +00:00
|
|
|
|
2003-05-16 22:00:33 +00:00
|
|
|
// In the case of Adlib, we won't specify anything.
|
|
|
|
// IMuse is designed to set up its own Adlib driver
|
|
|
|
// if need be, and we only have to specify a native
|
|
|
|
// driver.
|
2003-08-13 14:08:21 +00:00
|
|
|
case MD_ADLIB: return NULL;
|
|
|
|
|
2003-10-05 15:36:52 +00:00
|
|
|
case MD_TOWNS: return MidiDriver_YM2612_create(g_engine->_mixer);
|
|
|
|
|
2003-08-13 14:08:21 +00:00
|
|
|
// Right now PC Speaker and PCjr are handled
|
|
|
|
// outside the MidiDriver architecture, so
|
|
|
|
// don't create anything for now.
|
|
|
|
case MD_PCSPK:
|
|
|
|
case MD_PCJR: return NULL;
|
2003-06-17 08:50:15 +00:00
|
|
|
#if defined(__PALM_OS__)
|
2003-08-13 14:08:21 +00:00
|
|
|
case MD_YPA1: return MidiDriver_YamahaPa1_create();
|
2004-02-05 13:56:39 +00:00
|
|
|
case MD_ZODIAC: return MidiDriver_Zodiac_create();
|
2003-04-30 12:43:56 +00:00
|
|
|
#endif
|
2002-04-19 06:23:49 +00:00
|
|
|
#if defined(WIN32) && !defined(_WIN32_WCE)
|
2003-08-13 14:08:21 +00:00
|
|
|
case MD_WINDOWS: return MidiDriver_WIN_create();
|
2002-04-18 21:40:24 +00:00
|
|
|
#endif
|
2002-04-21 04:14:42 +00:00
|
|
|
#if defined(__MORPHOS__)
|
2003-08-13 14:08:21 +00:00
|
|
|
case MD_ETUDE: return MidiDriver_ETUDE_create();
|
2002-04-13 19:06:10 +00:00
|
|
|
#endif
|
2002-12-13 23:29:18 +00:00
|
|
|
#if defined(UNIX) && !defined(__BEOS__) && !defined(MACOSX)
|
2003-08-13 14:08:21 +00:00
|
|
|
case MD_SEQ: return MidiDriver_SEQ_create();
|
2002-04-26 13:18:49 +00:00
|
|
|
#endif
|
2003-04-30 12:43:56 +00:00
|
|
|
#if (defined(MACOSX) || defined(macintosh)) && !defined(__PALM_OS__)
|
2003-08-13 14:08:21 +00:00
|
|
|
case MD_QTMUSIC: return MidiDriver_QT_create();
|
2002-05-05 19:06:51 +00:00
|
|
|
#endif
|
2002-08-18 23:29:40 +00:00
|
|
|
#if defined(MACOSX)
|
2003-08-13 14:08:21 +00:00
|
|
|
case MD_COREAUDIO: return MidiDriver_CORE_create();
|
2002-05-16 06:46:50 +00:00
|
|
|
#endif
|
|
|
|
#if defined(UNIX) && defined(USE_ALSA)
|
2003-08-13 14:08:21 +00:00
|
|
|
case MD_ALSA: return MidiDriver_ALSA_create();
|
2002-04-21 04:14:42 +00:00
|
|
|
#endif
|
2002-04-13 18:34:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
error("Invalid midi driver selected");
|
|
|
|
return NULL;
|
2002-04-16 20:28:56 +00:00
|
|
|
}
|