[Scummvm-cvs-logs] CVS: scummvm/base gameDetector.cpp,1.38,1.39 gameDetector.h,1.16,1.17

Max Horn fingolfin at users.sourceforge.net
Fri Oct 17 17:23:34 CEST 2003


Update of /cvsroot/scummvm/scummvm/base
In directory sc8-pr-cvs1:/tmp/cvs-serv12549/base

Modified Files:
	gameDetector.cpp gameDetector.h 
Log Message:
We proudly present the latest installment of our hit series 'Untangle the mess': 'Help! Space Invaders refactored the music detector'... in other news, I obviously need to sleep now

Index: gameDetector.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/base/gameDetector.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- gameDetector.cpp	17 Oct 2003 19:39:13 -0000	1.38
+++ gameDetector.cpp	18 Oct 2003 00:22:46 -0000	1.39
@@ -178,7 +178,6 @@
 	ConfMan.registerDefault("confirm_exit", false);
 
 	_dumpScripts = false;
-	_midi_driver = MD_AUTO;
 
 	_game.features = 0;
 	_plugin = 0;
@@ -492,23 +491,6 @@
 	return -1;
 }
 
-int GameDetector::parseMusicDriver(const String &str) {
-	if (str.isEmpty())
-		return -1;
-
-	const char *s = str.c_str();
-	const MidiDriverDescription *md = getAvailableMidiDrivers();
-
-	while (md->name) {
-		if (!scumm_stricmp(md->name, s)) {
-			return md->id;
-		}
-		md++;
-	}
-
-	return -1;
-}
-
 bool GameDetector::detectGame() {
 	String realGame;
 
@@ -529,6 +511,53 @@
 	}
 }
 
+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
+					musicDriver = MD_YPA1;
+				#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
+				    musicDriver = MD_NULL;
+				#endif
+			}
+		} 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;
+}
+
 bool GameDetector::detectMain() {
 	if (_targetName.isEmpty()) {
 		warning("No game was specified...");
@@ -540,30 +569,6 @@
 		return false;
 	}
 
-	/* 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. */
-	_midi_driver = parseMusicDriver(ConfMan.get("music_driver"));
-	if (_midi_driver == MD_AUTO || _midi_driver < 0) {
-		if (_game.midi & MDT_PREFER_NATIVE)
-			_midi_driver = getMidiDriverType();
-		else
-			_midi_driver = MD_TOWNS;
-	}
-	bool nativeMidiDriver =
-		(_midi_driver != MD_NULL && _midi_driver != MD_ADLIB &&
-		 _midi_driver != MD_PCSPK && _midi_driver != MD_PCJR &&
-		 _midi_driver != MD_TOWNS);
-	if (nativeMidiDriver && !(_game.midi & MDT_NATIVE))
-		_midi_driver = MD_TOWNS;
-	if (_midi_driver == MD_TOWNS && !(_game.midi & MDT_TOWNS))
-		_midi_driver = MD_ADLIB;
-	if (_midi_driver == MD_ADLIB && !(_game.midi & MDT_ADLIB))
-		_midi_driver = MD_PCJR;
-	if ((_midi_driver == MD_PCSPK || _midi_driver == MD_PCJR) && !(_game.midi & MDT_PCSPK))
-		_midi_driver = MD_NULL;
-
 	String gameDataPath(ConfMan.get("path"));
 	if (gameDataPath.isEmpty()) {
 		warning("No path was provided. Assuming the data files are in the current directory");
@@ -611,38 +616,12 @@
 	return _plugin->createInstance(this, sys);
 }
 
-int GameDetector::getMidiDriverType() {
-
-	if (_midi_driver != MD_AUTO) return _midi_driver;
-
-#if defined (WIN32) && !defined(_WIN32_WCE)
-		return MD_WINDOWS; // MD_WINDOWS is default MidiDriver on windows targets
-#elif defined(MACOSX)
-		return MD_COREAUDIO;
-#elif defined(__PALM_OS__)	// must be before mac
-		return MD_YPA1;
-#elif defined(macintosh)
-		return MD_QTMUSIC;
-#elif defined(__MORPHOS__)
-		return 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.
-	return MD_ADLIB;
-#endif
-    return MD_NULL;
-}
-
 SoundMixer *GameDetector::createMixer() {
 	return new SoundMixer();
 }
 
-MidiDriver *GameDetector::createMidi() {
-	int drv = getMidiDriverType();
-
-	switch(drv) {
+MidiDriver *GameDetector::createMidi(int midiDriver) {
+	switch(midiDriver) {
 	case MD_NULL:      return MidiDriver_NULL_create();
 
 	// In the case of Adlib, we won't specify anything.

Index: gameDetector.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/base/gameDetector.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- gameDetector.h	17 Oct 2003 17:05:19 -0000	1.16
+++ gameDetector.h	18 Oct 2003 00:22:46 -0000	1.17
@@ -71,20 +71,17 @@
 	
 	bool _dumpScripts;
 
-	int _midi_driver;
-
 public:
-	OSystem *createSystem();
-	Engine *createEngine(OSystem *system);
+	void setTarget(const String &name);
 
-	SoundMixer *createMixer();
-	MidiDriver *createMidi();
-	int getMidiDriverType();	// FIXME: Try to get rid of this, only Sky frontend uses it
+	Engine *createEngine(OSystem *system);
 
-	void setTarget(const String &name);
+	static OSystem *createSystem();
+	static SoundMixer *createMixer();
+	static MidiDriver *createMidi(int midiDriver);
 
 	static int parseGraphicsMode(const String &s);	// Used in main()
-	static int parseMusicDriver(const String &s);
+	static int detectMusicDriver(int midiFlags);
 	
 	static GameSettings findGame(const String &gameName, const Plugin **plugin = NULL);
 





More information about the Scummvm-git-logs mailing list