cleanup & restructuring; in particular move the midi driver list to its own source file

svn-id: r10550
This commit is contained in:
Max Horn 2003-10-02 22:52:57 +00:00
parent 3f55f2669d
commit bb6765f85d
8 changed files with 212 additions and 161 deletions

7
TODO
View file

@ -111,6 +111,13 @@ Descumm
* Rewrite code to use 2 passes; first pass builds an intermediate graph, the
second pass then tries to detect loops, break/continue statements etc.
Backend
=======
* Several of the backend factory functions take config parameters. It should
be possible to get rid of those once the config system rewrite (see above)
has been done. In that case, the backends simply can query the config
manager for these parameters (or any others they might like :-).
SDL backend
===========
* Maybe change the shortcuts? One idea (add ctrl-alt in all cases):

View file

@ -21,12 +21,15 @@
*/
#include "stdafx.h"
#include "backends/intern.h"
#include "base/engine.h"
#include "base/gameDetector.h"
#include "base/plugins.h"
#include "common/config-file.h"
#include "base/engine.h"
#include "common/scaler.h" // Only for gfx_modes
#include "sound/mididrv.h"
#include "sound/mixer.h"
@ -51,52 +54,50 @@ static const char USAGE_STRING[] = "NoUsageString"; // save more data segment sp
static const char USAGE_STRING[] =
"ScummVM - Graphical Adventure Game Interpreter\n"
"Syntax:\n"
"\tscummvm [OPTIONS] [game]\n"
" scummvm [OPTIONS] [game]\n"
"Options:\n"
"\t-p<path> - Look for game in <path>\n"
"\t-x[num] - Load this savegame (default: 0 - autosave)\n"
"\t-f - Full-screen mode (-F forces window mode.)\n"
"\t-g<mode> - Graphics mode (normal,2x,3x,2xsai,super2xsai,\n"
"\t supereagle,advmame2x,advmame3x,hq2x,hq3x,\n"
"\t tv2x,dotmatrix)\n"
"\t-e<mode> - Set music engine (see README for details)\n"
"\t-q<lang> - Specify language (en,de,fr,it,pt,es,jp,zh,kr,se,\n"
"\t gb,hb)\n"
" -p<path> - Look for game in <path>\n"
" -x[num] - Load this savegame (default: 0 - autosave)\n"
" -f - Full-screen mode (-F forces window mode.)\n"
" -g<mode> - Graphics mode (normal,2x,3x,2xsai,super2xsai,supereagle,\n"
" advmame2x,advmame3x,hq2x,hq3x,tv2x,dotmatrix)\n"
" -e<mode> - Set music engine (see README for details)\n"
" -q<lang> - Specify language (en,de,fr,it,pt,es,jp,zh,kr,se,gb,hb)\n"
"\n"
"\t-c<num> - Use cdrom <num> for cd audio\n"
"\t-j[num] - Enable input with joystick (default: 0 - 1st joystick)\n"
"\t-m<num> - Set music volume to <num> (0-255)\n"
"\t-o<num> - Set master volume to <num> (0-255)\n"
"\t-s<num> - Set sfx volume to <num> (0-255)\n"
"\t-t<num> - Set music tempo (50-200, default 100%%)\n"
" -c<num> - Use cdrom <num> for cd audio\n"
" -j[num] - Enable input with joystick (default: 0 - first joystick)\n"
" -m<num> - Set music volume to <num> (0-255)\n"
" -o<num> - Set master volume to <num> (0-255)\n"
" -s<num> - Set sfx volume to <num> (0-255)\n"
" -t<num> - Set music tempo (50-200, default 100%%)\n"
"\n"
"\t-n - No subtitles for speech\n"
"\t-y - Set text speed (default: 60)\n"
" -n - No subtitles for speech\n"
" -y - Set text speed (default: 60)\n"
"\n"
"\t-l<file> - Load config file instead of default\n"
" -l<file> - Load config file instead of default\n"
#if defined(UNIX)
"\t-w[file] - Write to config file [~/.scummvmrc]\n"
" -w[file] - Write to config file [~/.scummvmrc]\n"
#else
"\t-w[file] - Write to config file [scummvm.ini]\n"
" -w[file] - Write to config file [scummvm.ini]\n"
#endif
"\t-v - Show version info and exit\n"
"\t-h - Display this text and exit\n"
"\t-z - Display list of games\n"
" -v - Show version info and exit\n"
" -h - Display this text and exit\n"
" -z - Display list of games\n"
"\n"
"\t-b<num> - Pass number to the boot script (boot param)\n"
"\t-d[num] - Enable debug output (debug level [0])\n"
"\t-u - Dump scripts\n"
" -b<num> - Pass number to the boot script (boot param)\n"
" -d[num] - Enable debug output (debug level [0])\n"
" -u - Dump scripts\n"
"\n"
"\t--platform= - Specify version of game (amiga,atari-st,macintosh)\n"
"\t--multi-midi - Enable combination Adlib and native MIDI\n"
"\t--native-mt32 - True Roland MT-32 (disable GM emulation)\n"
"\t--fullscreen - Full-screen mode (same as -f)\n"
"\t--aspect-ratio - Enable aspect ratio correction\n"
" --platform= - Specify version of game (amiga,atari-st,macintosh)\n"
" --multi-midi - Enable combination Adlib and native MIDI\n"
" --native-mt32 - True Roland MT-32 (disable GM emulation)\n"
" --fullscreen - Full-screen mode (same as -f)\n"
" --aspect-ratio - Enable aspect ratio correction\n"
#ifndef DISABLE_SCUMM
"\t--demo-mode - Start demo mode of Maniac Mansion (Classic version)\n"
" --demo-mode - Start demo mode of Maniac Mansion (Classic version)\n"
#endif
#ifndef DISABLE_SKY
"\t--floppy-intro - Use floppy version intro for Beneath a Steel Sky CD\n"
" --floppy-intro - Use floppy version intro for Beneath a Steel Sky CD\n"
#endif
"\n"
"The meaning of long options can be inverted by prefixing them with \"no-\",\n"
@ -104,6 +105,20 @@ static const char USAGE_STRING[] =
;
#endif
struct GraphicsMode {
const char *name;
const char *description;
int id;
};
/**
* List of graphic 'modes' we potentially support. Potentially because not all
* backends actually support all the filters listed here. At this point only
* the SDL backend supports all (except for the PalmOS ones of course).
* @todo Remove this explicit list of graphic modes and rather extend the
* OSystem API to allow querying a backend for the modes it supports.
*/
static const struct GraphicsMode gfx_modes[] = {
{"normal", "Normal (no scaling)", GFX_NORMAL},
{"1x", "Normal (no scaling)", GFX_NORMAL},
@ -128,6 +143,12 @@ static const struct GraphicsMode gfx_modes[] = {
{0, 0, 0}
};
struct Language {
const char *name;
const char *description;
int id;
};
static const struct Language languages[] = {
{"en", "English", EN_USA},
{"de", "German", DE_DEU},
@ -144,25 +165,6 @@ static const struct Language languages[] = {
{0, 0, 0}
};
static const struct MusicDriver music_drivers[] = {
{"auto", "Default", MD_AUTO},
{"null", "No music", MD_NULL},
#ifndef __PALM_OS__ // reduce contant data size
{"windows", "Windows MIDI", MD_WINDOWS},
{"seq", "SEQ", MD_SEQ},
{"qt", "QuickTime", MD_QTMUSIC},
{"core", "CoreAudio", MD_COREAUDIO},
{"etude", "Etude", MD_ETUDE},
{"alsa", "ALSA", MD_ALSA},
{"adlib", "Adlib", MD_ADLIB},
{"pcspk", "PC Speaker", MD_PCSPK},
{"pcjr", "IBM PCjr", MD_PCJR},
#else
{"ypa1", "Yamaha Pa1", MD_YPA1},
#endif
{0, 0, 0}
};
GameDetector::GameDetector() {
_fullScreen = false;
@ -363,6 +365,10 @@ void GameDetector::parseCommandLine(int argc, char **argv) {
break;
case 'e':
HANDLE_OPTION();
// 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: ..."
if (!parseMusicDriver(option))
goto ShowHelpAndExit;
g_config->set("music_driver", option);
@ -376,6 +382,10 @@ void GameDetector::parseCommandLine(int argc, char **argv) {
case 'g':
HANDLE_OPTION();
_gfx_mode = parseGraphicsMode(option);
// 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: ..."
if (_gfx_mode == -1)
goto ShowHelpAndExit;
g_config->set("gfx_mode", option);
@ -593,46 +603,8 @@ int GameDetector::parseLanguage(const char *s) {
return -1;
}
bool GameDetector::isMusicDriverAvailable(int drv) {
switch(drv) {
case MD_AUTO:
case MD_NULL: return true;
#ifndef __PALM_OS__ // don't show it on palmos
case MD_ADLIB:
case MD_PCSPK:
case MD_PCJR: return true;
#else
case MD_YPA1: return true;
#endif
#if defined(WIN32) && !defined(_WIN32_WCE)
case MD_WINDOWS: return true;
#endif
#if defined(__MORPHOS__)
case MD_ETUDE: return true;
#endif
#if defined(UNIX) && !defined(__BEOS__) && !defined(MACOSX)
case MD_SEQ: return true;
#endif
#if defined(MACOSX) || defined(macintosh)
case MD_QTMUSIC: return true;
#endif
#if defined(MACOSX)
case MD_COREAUDIO: return true;
#endif
#if defined(UNIX) && defined(USE_ALSA)
case MD_ALSA: return true;
#endif
}
return false;
}
const MusicDriver *GameDetector::getMusicDrivers() {
return music_drivers;
}
bool GameDetector::parseMusicDriver(const char *s) {
const MusicDriver *md = music_drivers;
const MidiDriverDescription *md = getAvailableMidiDrivers();
while (md->name) {
if (!scumm_stricmp(md->name, s)) {

View file

@ -46,9 +46,10 @@ enum {
GF_DEFAULT_TO_1X_SCALER = 1 << 31
};
/* Languages
* note: values 0->8 are are _needed_ for scripts in comi please don't
* remove/change fixed numbers from this enum
/**
* List of language ids.
* @note The order and mappings of the values 0..8 are *required* to stay the
* way they are now, as scripts in COMI rely on them. So don't touch them.
*/
enum {
EN_USA = 0,
@ -82,33 +83,9 @@ struct TargetSettings {
const char *detectname;
};
struct MusicDriver {
const char *name;
const char *description;
int id;
};
struct GraphicsMode {
const char *name;
const char *description;
int id;
};
struct Language {
const char *name;
const char *description;
int id;
};
typedef Engine *(*EngineFactory)(GameDetector *detector, OSystem *syst);
class GameDetector {
typedef Common::String String;
public:
static const MusicDriver *getMusicDrivers();
static bool isMusicDriverAvailable(int drv);
public:
GameDetector();

View file

@ -26,6 +26,9 @@
#include "common/util.h"
typedef Engine *(*EngineFactory)(GameDetector *detector, OSystem *syst);
#ifdef DYNAMIC_MODULES
#ifdef UNIX

View file

@ -19,15 +19,16 @@
*/
#include "stdafx.h"
#include "browser.h"
#include "chooser.h"
#include "newgui.h"
#include "options.h"
#include "PopUpWidget.h"
#include "gui/browser.h"
#include "gui/chooser.h"
#include "gui/newgui.h"
#include "gui/options.h"
#include "gui/PopUpWidget.h"
#include "backends/fs/fs.h"
#include "common/config-file.h"
#include "base/gameDetector.h"
#include "common/config-file.h"
#include "sound/mididrv.h"
#if (!( defined(__DC__) || defined(__GP32__)) && !defined(_MSC_VER))
#include <unistd.h>
@ -90,14 +91,12 @@ GlobalOptionsDialog::GlobalOptionsDialog(NewGui *gui, GameDetector &detector)
int midiSelected = 0, i = 0;;
// Populate it
const MusicDriver *md = GameDetector::getMusicDrivers();
const MidiDriverDescription *md = getAvailableMidiDrivers();
while (md->name) {
if (GameDetector::isMusicDriverAvailable(md->id)) {
_midiPopUp->appendEntry(md->description, md->id);
if (md->id == _detector._midi_driver)
midiSelected = i;
i++;
}
_midiPopUp->appendEntry(md->description, md->id);
if (md->id == _detector._midi_driver)
midiSelected = i;
i++;
md++;
}
_midiPopUp->setSelected(midiSelected);
@ -205,7 +204,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
break;
case kPopUpItemSelectedCmd:
if (sender == _midiPopUp) {
const MusicDriver *md = GameDetector::getMusicDrivers();
const MidiDriverDescription *md = getAvailableMidiDrivers();
for (; md->name; md++) {
if (md->id == (int) data) {
g_config->set ("music_driver", md->name, "_USER_OVERRIDES");

68
sound/mididrv.cpp Normal file
View file

@ -0,0 +1,68 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2001 Ludvig Strigeus
* Copyright (C) 2001-2003 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header$
*
*/
#include "stdafx.h"
#include "sound/mididrv.h"
/** Internal list of all available 'midi' drivers. */
static const struct MidiDriverDescription midiDrivers[] = {
{"auto", "Default", MD_AUTO},
{"null", "No music", MD_NULL},
#if defined(WIN32) && !defined(_WIN32_WCE)
{"windows", "Windows MIDI", MD_WINDOWS},
#endif
#if defined(UNIX) && !defined(__BEOS__) && !defined(MACOSX)
{"seq", "SEQ", MD_SEQ},
#endif
#if defined(MACOSX)
{"qt", "QuickTime", MD_QTMUSIC},
{"core", "CoreAudio", MD_COREAUDIO},
#endif
#if defined(__MORPHOS__)
{"etude", "Etude", MD_ETUDE},
#endif
#if defined(UNIX) && defined(USE_ALSA)
{"alsa", "ALSA", MD_ALSA},
#endif
#if !defined(__PALM_OS__)
{"adlib", "Adlib", MD_ADLIB},
{"pcspk", "PC Speaker", MD_PCSPK},
{"pcjr", "IBM PCjr", MD_PCJR},
#endif
#if defined(__PALM_OS__)
{"ypa1", "Yamaha Pa1", MD_YPA1},
#endif
{0, 0, 0}
};
const MidiDriverDescription *getAvailableMidiDrivers() {
return midiDrivers;
}

View file

@ -28,13 +28,53 @@
class MidiChannel;
class SoundMixer;
// Abstract MIDI Driver Class
/** MIDI Driver Types */
enum {
MD_AUTO = 0,
MD_NULL = 1,
MD_WINDOWS = 2,
MD_TIMIDITY = 3,
MD_SEQ = 4,
MD_QTMUSIC = 5,
MD_ETUDE = 6,
MD_COREAUDIO = 7,
MD_MIDIEMU = 8,
MD_ALSA = 9,
MD_ADLIB = 10,
MD_PCSPK = 11,
MD_PCJR = 12,
MD_YPA1 = 100 // palmos
};
/**
* Abstract description of a MIDI driver. Used by the config file and command
* line parsing code, and also to be able to give the user a list of available
* drivers.
*/
struct MidiDriverDescription {
const char *name;
const char *description;
int id;
};
/**
* Get a list of all available MidiDriver types.
* @return list of all available midi drivers, terminated by a zero entry
*/
extern const MidiDriverDescription *getAvailableMidiDrivers();
/** Abstract MIDI Driver Class */
class MidiDriver {
public:
virtual ~MidiDriver() { }
// Error codes returned by open.
// Can be converted to a string with getErrorName()
/**
* Error codes returned by open.
* Can be converted to a string with getErrorName().
*/
enum {
MERR_CANNOT_CONNECT = 1,
// MERR_STREAMING_NOT_AVAILABLE = 2,
@ -48,20 +88,22 @@ public:
PROP_CHANNEL_MASK = 3
};
// Open the midi driver.
// Returns 0 if successful, otherwise an error code.
/**
* Open the midi driver.
* @return 0 if successful, otherwise an error code.
*/
virtual int open() = 0;
// Close the midi driver
/** Close the midi driver. */
virtual void close() = 0;
// Output a packed midi command to the midi stream
/** Output a packed midi command to the midi stream. */
virtual void send(uint32 b) = 0;
// Get or set a property
/** Get or set a property. */
virtual uint32 property(int prop, uint32 param) { return 0; }
// Retrieve a string representation of an error code
/** Retrieve a string representation of an error code. */
static const char *getErrorName(int error_code);
// HIGH-LEVEL SEMANTIC METHODS
@ -117,24 +159,6 @@ public:
virtual void sysEx_customInstrument (uint32 type, byte *instr) = 0;
};
// MIDI Driver Types
enum {
MD_AUTO = 0,
MD_NULL = 1,
MD_WINDOWS = 2,
MD_TIMIDITY = 3,
MD_SEQ = 4,
MD_QTMUSIC = 5,
MD_ETUDE = 6,
MD_COREAUDIO = 7,
MD_MIDIEMU = 8,
MD_ALSA = 9,
MD_ADLIB = 10,
MD_PCSPK = 11,
MD_PCJR = 12,
MD_YPA1 = 100 // palmos
};
// Factory functions, for faster compile
extern MidiDriver *MidiDriver_NULL_create();

View file

@ -3,6 +3,7 @@ MODULE := sound
MODULE_OBJS := \
sound/audiostream.o \
sound/fmopl.o \
sound/mididrv.o \
sound/midiparser.o \
sound/midiparser_smf.o \
sound/midiparser_xmidi.o \