diff options
-rw-r--r-- | common/util.cpp | 1 | ||||
-rw-r--r-- | common/util.h | 5 | ||||
-rw-r--r-- | engines/gob/gob.cpp | 2 | ||||
-rw-r--r-- | gui/options.cpp | 41 | ||||
-rw-r--r-- | gui/options.h | 6 | ||||
-rw-r--r-- | sound/mididrv.cpp | 23 | ||||
-rw-r--r-- | sound/mididrv.h | 32 | ||||
-rw-r--r-- | sound/musicplugin.cpp | 2 | ||||
-rw-r--r-- | sound/null.cpp | 7 | ||||
-rw-r--r-- | sound/null.h | 2 | ||||
-rw-r--r-- | sound/softsynth/pcspk.cpp | 2 |
11 files changed, 73 insertions, 50 deletions
diff --git a/common/util.cpp b/common/util.cpp index 70499a984f..b6f7bcd58f 100644 --- a/common/util.cpp +++ b/common/util.cpp @@ -305,6 +305,7 @@ const struct GameOpt { { GUIO_MIDIPCJR, "midiPCJr" }, { GUIO_MIDIADLIB, "midiAdLib" }, { GUIO_MIDITOWNS, "midiTowns" }, + { GUIO_MIDIPC98, "midiPC98" }, { GUIO_MIDIMT32, "midiMt32" }, { GUIO_MIDIGM, "midiGM" }, diff --git a/common/util.h b/common/util.h index d7d68cc1ca..823788ca04 100644 --- a/common/util.h +++ b/common/util.h @@ -224,8 +224,9 @@ enum GameGUIOption { GUIO_MIDIPCJR = (1 << 8), GUIO_MIDIADLIB = (1 << 9), GUIO_MIDITOWNS = (1 << 10), - GUIO_MIDIMT32 = (1 << 11), - GUIO_MIDIGM = (1 << 12) + GUIO_MIDIPC98 = (1 << 11), + GUIO_MIDIMT32 = (1 << 12), + GUIO_MIDIGM = (1 << 13) }; bool checkGameGUIOption(GameGUIOption option, const String &str); diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index fba616b166..ddeac25baa 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -346,7 +346,7 @@ void GobEngine::pauseGame() { bool GobEngine::initGameParts() { // just detect some devices some of which will be always there if the music is not disabled - _noMusic = MidiDriver::detectDevice(MDT_PCSPK | MDT_MIDI | MDT_ADLIB) ? false : true; + _noMusic = MidiDriver::getMusicType(MidiDriver::detectDevice(MDT_PCSPK | MDT_MIDI | MDT_ADLIB)) == MT_NULL ? true : false; _saveLoad = 0; _global = new Global(this); diff --git a/gui/options.cpp b/gui/options.cpp index 41a82ca89c..cd6eb73adb 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -136,18 +136,18 @@ void OptionsDialog::init() { } } -template<class T> bool prdEqualsDeviceProperty(MusicDevices::iterator d, T lookupProp, Common::MemFunc0<T, MusicDevice> devicePropFunc) { +template<class T> bool equalsDeviceProperty(MusicDevices::iterator d, T lookupProp, Common::MemFunc0<T, MusicDevice> devicePropFunc) { return lookupProp == devicePropFunc(&*d); } -bool prdMidiDefault(MusicDevices::iterator d, Common::String dom, bool, MusicPlugin::List::const_iterator&) { - return !(dom == Common::ConfigManager::kApplicationDomain && d->getMusicType() == MT_TOWNS) ? true : false; +bool musicDeviceSkipSettingDefault(MusicDevices::iterator d, Common::String dom, MusicPlugin::List::const_iterator &m, uint32 guio) { + return (dom == Common::ConfigManager::kApplicationDomain && d->getMusicType() != MT_TOWNS) || (dom != Common::ConfigManager::kApplicationDomain && (!guio || (guio & (MidiDriver::musicType2GUIO(d->getMusicType()))))) || d->getMusicDriverId() == "auto" || d->getMusicDriverId() == "null" ? true : false; } -bool prdMidiSpec(MusicDevices::iterator d, Common::String, bool isAutoPlugin, MusicPlugin::List::const_iterator &m) { - if (isAutoPlugin) +bool musicDeviceSkipSettingSpec(MusicDevices::iterator d, Common::String, MusicPlugin::List::const_iterator &m, uint32) { + if (d->getMusicDriverId() == "auto") m++; - return ((d->getMusicType() >= MT_GM) || isAutoPlugin) ? true : false; + return ((d->getMusicType() >= MT_GM) || d->getMusicDriverId() == "auto") ? true : false; } void OptionsDialog::open() { @@ -208,21 +208,21 @@ void OptionsDialog::open() { } // Audio options - if (!loadMusicDeviceSetting(_midiPopUp, "music_driver", prdMidiDefault)) + if (!loadMusicDeviceSetting(_midiPopUp, "music_driver", musicDeviceSkipSettingDefault)) _midiPopUp->setSelected(0); - if (!loadMusicDeviceSetting(_mt32DevicePopUp, "mt32_device", prdMidiSpec)) { + if (!loadMusicDeviceSetting(_mt32DevicePopUp, "mt32_device", musicDeviceSkipSettingSpec)) { if (_domain.equals(Common::ConfigManager::kApplicationDomain)) { - if (!loadMusicDeviceSetting(_mt32DevicePopUp, "", prdMidiSpec, MT_MT32)) + if (!loadMusicDeviceSetting(_mt32DevicePopUp, "", musicDeviceSkipSettingSpec, MT_MT32)) _mt32DevicePopUp->setSelected(0); } else { _mt32DevicePopUp->setSelected(0); } } - if (!loadMusicDeviceSetting(_gmDevicePopUp, "gm_device", prdMidiSpec)) { + if (!loadMusicDeviceSetting(_gmDevicePopUp, "gm_device", musicDeviceSkipSettingSpec)) { if (_domain.equals(Common::ConfigManager::kApplicationDomain)) { - if (!loadMusicDeviceSetting(_gmDevicePopUp, "", prdMidiSpec, MT_GM)) + if (!loadMusicDeviceSetting(_gmDevicePopUp, "", musicDeviceSkipSettingSpec, MT_GM)) _gmDevicePopUp->setSelected(0); } else { _gmDevicePopUp->setSelected(0); @@ -364,9 +364,9 @@ void OptionsDialog::close() { } // Audio options - saveMusicDeviceSetting(_midiPopUp, "music_driver", prdMidiDefault); - saveMusicDeviceSetting(_mt32DevicePopUp, "mt32_device", prdMidiSpec); - saveMusicDeviceSetting(_gmDevicePopUp, "gm_device", prdMidiSpec); + saveMusicDeviceSetting(_midiPopUp, "music_driver", musicDeviceSkipSettingDefault); + saveMusicDeviceSetting(_mt32DevicePopUp, "mt32_device", musicDeviceSkipSettingSpec); + saveMusicDeviceSetting(_gmDevicePopUp, "gm_device", musicDeviceSkipSettingSpec); if (_oplPopUp) { if (_enableAudioSettings) { @@ -667,7 +667,8 @@ void OptionsDialog::addAudioControls(GuiObject *boss, const Common::String &pref for (MusicDevices::iterator d = i.begin(); d != i.end(); d++) { if ((_domain == Common::ConfigManager::kApplicationDomain && d->getMusicType() != MT_TOWNS) || // global dialog - skip useless FM-Towns option there (_domain != Common::ConfigManager::kApplicationDomain && !(_guioptions & allFlags)) || // No flags are specified - _guioptions & (MidiDriver::musicType2GUIO(d->getMusicType()))) // flag is present + _guioptions & (MidiDriver::musicType2GUIO(d->getMusicType())) // flag is present + || d->getMusicDriverId() == "auto" || d->getMusicDriverId() == "null") // always add default and null device _midiPopUp->appendEntry(d->getCompleteName(), musicId++); if (d->getMusicType() >= MT_GM || m == p.begin()) { _mt32DevicePopUp->appendEntry(d->getCompleteName(), midiId); @@ -790,7 +791,7 @@ void OptionsDialog::addVolumeControls(GuiObject *boss, const Common::String &pre _enableVolumeSettings = true; } -bool OptionsDialog::loadMusicDeviceSetting(PopUpWidget *popup, Common::String setting, MidiSettingsExtraPred pred, MusicType preferredType) { +bool OptionsDialog::loadMusicDeviceSetting(PopUpWidget *popup, Common::String setting, MusicDeviceSkipFunc skipfunc, MusicType preferredType) { if (!popup || !popup->isEnabled()) return true; @@ -801,11 +802,11 @@ bool OptionsDialog::loadMusicDeviceSetting(PopUpWidget *popup, Common::String se for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end() && id != -1; m++) { MusicDevices i = (**m)->getDevices(); for (MusicDevices::iterator d = i.begin(); d != i.end(); d++) { - if ((setting.empty() && preferredType) ? prdEqualsDeviceProperty(d, preferredType, Common::mem_fun(&MusicDevice::getMusicType)) : prdEqualsDeviceProperty(d, drv, Common::mem_fun(&MusicDevice::getCompleteId))) { + if ((setting.empty()) ? equalsDeviceProperty(d, preferredType, Common::mem_fun(&MusicDevice::getMusicType)) : equalsDeviceProperty(d, drv, Common::mem_fun(&MusicDevice::getCompleteId))) { popup->setSelected(id); id = -1; break; - } else if (pred(d, _domain, m == p.begin(), m)) { + } else if (skipfunc(d, _domain, m, _guioptions)) { id++; } } @@ -820,7 +821,7 @@ bool OptionsDialog::loadMusicDeviceSetting(PopUpWidget *popup, Common::String se return true; } -void OptionsDialog::saveMusicDeviceSetting(PopUpWidget *popup, Common::String setting, MidiSettingsExtraPred pred) { +void OptionsDialog::saveMusicDeviceSetting(PopUpWidget *popup, Common::String setting, MusicDeviceSkipFunc skipfunc) { if (!popup || !_enableAudioSettings) return; @@ -834,7 +835,7 @@ void OptionsDialog::saveMusicDeviceSetting(PopUpWidget *popup, Common::String se ConfMan.set(setting, d->getCompleteId(), _domain); found = true; break; - } else if (pred(d, _domain, m == p.begin(), m)) { + } else if (skipfunc(d, _domain, m, _guioptions)) { id++; } } diff --git a/gui/options.h b/gui/options.h index 268b535e8a..baaf6471c9 100644 --- a/gui/options.h +++ b/gui/options.h @@ -79,9 +79,9 @@ protected: void setVolumeSettingsState(bool enabled); void setSubtitleSettingsState(bool enabled); - typedef bool (MidiSettingsExtraPred)(MusicDevices::iterator, Common::String, bool, MusicPlugin::List::const_iterator&); - bool loadMusicDeviceSetting(PopUpWidget *popup, Common::String setting, MidiSettingsExtraPred pred, MusicType preferredType = MT_NULL); - void saveMusicDeviceSetting(PopUpWidget *popup, Common::String setting, MidiSettingsExtraPred pred); + typedef bool (MusicDeviceSkipFunc)(MusicDevices::iterator, Common::String, MusicPlugin::List::const_iterator&, uint32); + bool loadMusicDeviceSetting(PopUpWidget *popup, Common::String setting, MusicDeviceSkipFunc skipfunc, MusicType preferredType = MT_AUTO); + void saveMusicDeviceSetting(PopUpWidget *popup, Common::String setting, MusicDeviceSkipFunc skipfunc); TabWidget *_tabWidget; int _graphicsTabId; diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp index d185626f62..0fa64e8b03 100644 --- a/sound/mididrv.cpp +++ b/sound/mididrv.cpp @@ -95,7 +95,7 @@ MusicType MidiDriver::getMusicType(MidiDriver::DeviceHandle handle) { } } - return MT_NULL; + return MT_AUTO; } Common::String MidiDriver::getDeviceString(DeviceHandle handle, DeviceStringType type) { @@ -139,6 +139,11 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { if (flags & MDT_PCJR) return hdl; break; + + case MT_CMS: + if (flags & MDT_CMS) + return hdl; + break; case MT_ADLIB: if (flags & MDT_ADLIB) @@ -150,14 +155,20 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { return hdl; break; + case MT_PC98: + if (flags & MDT_PC98) + return hdl; + break; + case MT_GM: case MT_GS: case MT_MT32: if (flags & MDT_MIDI) return hdl; + break; + case MT_NULL: - if (getDeviceString(hdl, MidiDriver::kDriverId).equals("null")) - return 0; + return hdl; default: break; @@ -172,7 +183,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { if ((flags & MDT_MIDI) && (l == 1)) { // If a preferred MT32 or GM device has been selected that device gets returned hdl = getDeviceHandle(ConfMan.get((flags & MDT_PREFER_MT32) ? "mt32_device" : ((flags & MDT_PREFER_GM) ? "gm_device" : "auto"), Common::ConfigManager::kApplicationDomain)); - if (getMusicType(hdl) != MT_NULL) { + if (getMusicType(hdl) != MT_AUTO) { if (flags & MDT_PREFER_MT32) // If we have a preferred MT32 device we disable the gm/mt32 mapping (more about this in mididrv.h) _forceTypeMT32 = true; @@ -203,7 +214,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { } } - MusicType tp = MT_NULL; + MusicType tp = MT_AUTO; if (flags & MDT_TOWNS) tp = MT_TOWNS; else if (flags & MDT_ADLIB) @@ -211,7 +222,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { else if (flags & MDT_PCSPK) tp = MT_PCSPK; else - tp = MT_NULL; + tp = MT_AUTO; for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); m++) { MusicDevices i = (**m)->getDevices(); diff --git a/sound/mididrv.h b/sound/mididrv.h index ee8ef449f0..de3a38f87d 100644 --- a/sound/mididrv.h +++ b/sound/mididrv.h @@ -50,14 +50,17 @@ namespace Common { class String; } * Music types that music drivers can implement and engines can rely on. */ enum MusicType { - MT_NULL = 0, // Null / Auto - MT_PCSPK = 1, // PC Speaker - MT_PCJR = 2, // PCjr - MT_ADLIB = 3, // AdLib - MT_TOWNS = 4, // FM-TOWNS - MT_GM = 5, // General MIDI - MT_MT32 = 6, // MT-32 - MT_GS = 7 // Roland GS + MT_AUTO = 0, // Auto + MT_NULL, // Null + MT_PCSPK, // PC Speaker + MT_PCJR, // PCjr + MT_CMS, // CMS + MT_ADLIB, // AdLib + MT_TOWNS, // FM-TOWNS + MT_PC98, // PC98 + MT_GM, // General MIDI + MT_MT32, // MT-32 + MT_GS // Roland GS }; /** @@ -75,12 +78,13 @@ enum MidiDriverFlags { MDT_PCSPK = 1 << 0, // PC Speaker: Maps to MD_PCSPK and MD_PCJR MDT_CMS = 1 << 1, // Creative Music System / Gameblaster: Maps to MD_CMS MDT_PCJR = 1 << 2, // Tandy/PC Junior driver - MDT_ADLIB = 1 << 3, // AdLib: Maps to MD_ADLIB - MDT_TOWNS = 1 << 4, // FM-TOWNS: Maps to MD_TOWNS - MDT_MIDI = 1 << 5, // Real MIDI - MDT_PREFER_MIDI = 1 << 6, // Real MIDI output is preferred - MDT_PREFER_MT32 = 1 << 7, // MT-32 output is preferred - MDT_PREFER_GM = 1 << 8 // GM output is preferred + MDT_ADLIB = 1 << 3, // AdLib: Maps to MT_ADLIB + MDT_TOWNS = 1 << 4, // FM-TOWNS: Maps to MT_TOWNS + MDT_PC98 = 1 << 5, // FM-TOWNS: Maps to MT_PC98 + MDT_MIDI = 1 << 6, // Real MIDI + MDT_PREFER_MIDI = 1 << 7, // Real MIDI output is preferred + MDT_PREFER_MT32 = 1 << 8, // MT-32 output is preferred + MDT_PREFER_GM = 1 << 9 // GM output is preferred }; /** diff --git a/sound/musicplugin.cpp b/sound/musicplugin.cpp index 7b5b6608ea..8078094616 100644 --- a/sound/musicplugin.cpp +++ b/sound/musicplugin.cpp @@ -60,7 +60,5 @@ Common::String MusicDevice::getCompleteId() { } MidiDriver::DeviceHandle MusicDevice::getHandle() { - if (_musicDriverId.equals("auto") || _musicDriverId.equals("null")) - return 0; return (MidiDriver::DeviceHandle)Common::hashit(getCompleteId().c_str()); } diff --git a/sound/null.cpp b/sound/null.cpp index c61add2c02..9be545ab76 100644 --- a/sound/null.cpp +++ b/sound/null.cpp @@ -45,8 +45,15 @@ public: const char *getId() const { return "auto"; } + MusicDevices getDevices() const; }; +MusicDevices AutoMusicPlugin::getDevices() const { + MusicDevices devices; + devices.push_back(MusicDevice(this, _s(""), MT_AUTO)); + return devices; +} + //#if PLUGIN_ENABLED_DYNAMIC(NULL) //REGISTER_PLUGIN_DYNAMIC(NULL, PLUGIN_TYPE_MUSIC, NullMusicPlugin); //#else diff --git a/sound/null.h b/sound/null.h index f8d0a91e2d..d9343701fa 100644 --- a/sound/null.h +++ b/sound/null.h @@ -53,4 +53,4 @@ public: Common::Error createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle = 0) const; }; -#endif
\ No newline at end of file +#endif diff --git a/sound/softsynth/pcspk.cpp b/sound/softsynth/pcspk.cpp index 8f66578a0b..fae2b7eef3 100644 --- a/sound/softsynth/pcspk.cpp +++ b/sound/softsynth/pcspk.cpp @@ -184,4 +184,4 @@ MusicDevices PCjrMusicPlugin::getDevices() const { //REGISTER_PLUGIN_DYNAMIC(PCJR, PLUGIN_TYPE_MUSIC, PCjrMusicPlugin); //#else REGISTER_PLUGIN_STATIC(PCJR, PLUGIN_TYPE_MUSIC, PCjrMusicPlugin); -//#endif
\ No newline at end of file +//#endif |