[Scummvm-git-logs] scummvm master -> c8293df572bf4836b7f2f73bbcba7bc8a583c1ef

sev- sev at scummvm.org
Thu Aug 27 12:56:22 UTC 2020


This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
22593de73f SCI: Rename font.h/cpp to scifont.h/cpp
074118644b SCI: Manually construct engine options layout
e0b8d8e414 SCI: Replace native_fb01 Checkbox with PopUp
c8293df572 SCI: Add Roland D-110/D-10/D-20 support


Commit: 22593de73f6348a60a886ea9715fcd70369c5d10
    https://github.com/scummvm/scummvm/commit/22593de73f6348a60a886ea9715fcd70369c5d10
Author: Walter van Niftrik (walter at scummvm.org)
Date: 2020-08-27T14:56:17+02:00

Commit Message:
SCI: Rename font.h/cpp to scifont.h/cpp

This avoids an issue with MSVC where if (non-SCI) "graphics/font.h" is
included through another include file from the SCI engine root, it finds
"sci/graphics/font.h" first and uses that instead.

Changed paths:
  A engines/sci/graphics/scifont.cpp
  A engines/sci/graphics/scifont.h
  R engines/sci/graphics/font.cpp
  R engines/sci/graphics/font.h
    engines/sci/engine/kgraphics32.cpp
    engines/sci/graphics/cache.cpp
    engines/sci/graphics/controls16.cpp
    engines/sci/graphics/controls32.cpp
    engines/sci/graphics/fontsjis.cpp
    engines/sci/graphics/frameout.cpp
    engines/sci/graphics/menu.cpp
    engines/sci/graphics/paint16.cpp
    engines/sci/graphics/text16.cpp
    engines/sci/graphics/text32.cpp
    engines/sci/module.mk


diff --git a/engines/sci/engine/kgraphics32.cpp b/engines/sci/engine/kgraphics32.cpp
index 690da172ce..9768911613 100644
--- a/engines/sci/engine/kgraphics32.cpp
+++ b/engines/sci/engine/kgraphics32.cpp
@@ -50,7 +50,7 @@
 #include "sci/graphics/cursor32.h"
 #include "sci/graphics/celobj32.h"
 #include "sci/graphics/controls32.h"
-#include "sci/graphics/font.h"	// TODO: remove once kBitmap is moved in a separate class
+#include "sci/graphics/scifont.h"	// TODO: remove once kBitmap is moved in a separate class
 #include "sci/graphics/frameout.h"
 #include "sci/graphics/paint32.h"
 #include "sci/graphics/palette32.h"
diff --git a/engines/sci/graphics/cache.cpp b/engines/sci/graphics/cache.cpp
index 9c77f31a14..8ab62131de 100644
--- a/engines/sci/graphics/cache.cpp
+++ b/engines/sci/graphics/cache.cpp
@@ -28,7 +28,7 @@
 #include "sci/engine/state.h"
 #include "sci/engine/selector.h"
 #include "sci/graphics/cache.h"
-#include "sci/graphics/font.h"
+#include "sci/graphics/scifont.h"
 #include "sci/graphics/fontsjis.h"
 #include "sci/graphics/view.h"
 
diff --git a/engines/sci/graphics/controls16.cpp b/engines/sci/graphics/controls16.cpp
index ce50d59ba1..3ca06978e2 100644
--- a/engines/sci/graphics/controls16.cpp
+++ b/engines/sci/graphics/controls16.cpp
@@ -33,7 +33,7 @@
 #include "sci/graphics/compare.h"
 #include "sci/graphics/ports.h"
 #include "sci/graphics/paint16.h"
-#include "sci/graphics/font.h"
+#include "sci/graphics/scifont.h"
 #include "sci/graphics/screen.h"
 #include "sci/graphics/text16.h"
 #include "sci/graphics/controls16.h"
diff --git a/engines/sci/graphics/controls32.cpp b/engines/sci/graphics/controls32.cpp
index 6c349f1ef4..cb71a4e62f 100644
--- a/engines/sci/graphics/controls32.cpp
+++ b/engines/sci/graphics/controls32.cpp
@@ -32,7 +32,7 @@
 #include "sci/graphics/cache.h"
 #include "sci/graphics/compare.h"
 #include "sci/graphics/controls32.h"
-#include "sci/graphics/font.h"
+#include "sci/graphics/scifont.h"
 #include "sci/graphics/screen.h"
 #include "sci/graphics/text32.h"
 
diff --git a/engines/sci/graphics/fontsjis.cpp b/engines/sci/graphics/fontsjis.cpp
index 9c942eadd1..eab282f49a 100644
--- a/engines/sci/graphics/fontsjis.cpp
+++ b/engines/sci/graphics/fontsjis.cpp
@@ -23,7 +23,7 @@
 #include "sci/sci.h"
 #include "sci/engine/state.h"
 #include "sci/graphics/screen.h"
-#include "sci/graphics/font.h"
+#include "sci/graphics/scifont.h"
 #include "sci/graphics/fontsjis.h"
 
 namespace Sci {
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index 9dc76a9b60..52fc3a4678 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -44,7 +44,7 @@
 #include "sci/graphics/cache.h"
 #include "sci/graphics/compare.h"
 #include "sci/graphics/cursor32.h"
-#include "sci/graphics/font.h"
+#include "sci/graphics/scifont.h"
 #include "sci/graphics/frameout.h"
 #include "sci/graphics/helpers.h"
 #include "sci/graphics/paint32.h"
diff --git a/engines/sci/graphics/menu.cpp b/engines/sci/graphics/menu.cpp
index eb87f81c25..4433cd2b2c 100644
--- a/engines/sci/graphics/menu.cpp
+++ b/engines/sci/graphics/menu.cpp
@@ -33,7 +33,7 @@
 #include "sci/graphics/paint16.h"
 #include "sci/graphics/animate.h"
 #include "sci/graphics/cursor.h"
-#include "sci/graphics/font.h"
+#include "sci/graphics/scifont.h"
 #include "sci/graphics/text16.h"
 #include "sci/graphics/screen.h"
 #include "sci/graphics/menu.h"
diff --git a/engines/sci/graphics/paint16.cpp b/engines/sci/graphics/paint16.cpp
index 62812498c1..f8aaffca68 100644
--- a/engines/sci/graphics/paint16.cpp
+++ b/engines/sci/graphics/paint16.cpp
@@ -30,7 +30,7 @@
 #include "sci/graphics/ports.h"
 #include "sci/graphics/paint16.h"
 #include "sci/graphics/animate.h"
-#include "sci/graphics/font.h"
+#include "sci/graphics/scifont.h"
 #include "sci/graphics/picture.h"
 #include "sci/graphics/view.h"
 #include "sci/graphics/screen.h"
diff --git a/engines/sci/graphics/font.cpp b/engines/sci/graphics/scifont.cpp
similarity index 99%
rename from engines/sci/graphics/font.cpp
rename to engines/sci/graphics/scifont.cpp
index b6fb15c9cd..61fdb1e353 100644
--- a/engines/sci/graphics/font.cpp
+++ b/engines/sci/graphics/scifont.cpp
@@ -23,7 +23,7 @@
 #include "sci/sci.h"
 #include "sci/engine/state.h"
 #include "sci/graphics/screen.h"
-#include "sci/graphics/font.h"
+#include "sci/graphics/scifont.h"
 
 namespace Sci {
 
diff --git a/engines/sci/graphics/font.h b/engines/sci/graphics/scifont.h
similarity index 97%
rename from engines/sci/graphics/font.h
rename to engines/sci/graphics/scifont.h
index 8e42149c56..ddd8a55d5e 100644
--- a/engines/sci/graphics/font.h
+++ b/engines/sci/graphics/scifont.h
@@ -20,8 +20,8 @@
  *
  */
 
-#ifndef SCI_GRAPHICS_FONT_H
-#define SCI_GRAPHICS_FONT_H
+#ifndef SCI_GRAPHICS_SCIFONT_H
+#define SCI_GRAPHICS_SCIFONT_H
 
 #include "sci/graphics/helpers.h"
 #include "sci/util.h"
diff --git a/engines/sci/graphics/text16.cpp b/engines/sci/graphics/text16.cpp
index 323c8829f6..483211e7fd 100644
--- a/engines/sci/graphics/text16.cpp
+++ b/engines/sci/graphics/text16.cpp
@@ -32,7 +32,7 @@
 #include "sci/graphics/coordadjuster.h"
 #include "sci/graphics/ports.h"
 #include "sci/graphics/paint16.h"
-#include "sci/graphics/font.h"
+#include "sci/graphics/scifont.h"
 #include "sci/graphics/screen.h"
 #include "sci/graphics/text16.h"
 
diff --git a/engines/sci/graphics/text32.cpp b/engines/sci/graphics/text32.cpp
index d63b799dcf..2e66f61fee 100644
--- a/engines/sci/graphics/text32.cpp
+++ b/engines/sci/graphics/text32.cpp
@@ -32,7 +32,7 @@
 #include "sci/graphics/cache.h"
 #include "sci/graphics/celobj32.h"
 #include "sci/graphics/compare.h"
-#include "sci/graphics/font.h"
+#include "sci/graphics/scifont.h"
 #include "sci/graphics/frameout.h"
 #include "sci/graphics/screen.h"
 #include "sci/graphics/text32.h"
diff --git a/engines/sci/module.mk b/engines/sci/module.mk
index 1c4c07241f..f2fa5b762a 100644
--- a/engines/sci/module.mk
+++ b/engines/sci/module.mk
@@ -50,7 +50,6 @@ MODULE_OBJS := \
 	graphics/controls16.o \
 	graphics/coordadjuster.o \
 	graphics/cursor.o \
-	graphics/font.o \
 	graphics/fontsjis.o \
 	graphics/maciconbar.o \
 	graphics/menu.o \
@@ -60,6 +59,7 @@ MODULE_OBJS := \
 	graphics/portrait.o \
 	graphics/ports.o \
 	graphics/remap.o \
+	graphics/scifont.o \
 	graphics/screen.o \
 	graphics/text16.o \
 	graphics/transitions.o \


Commit: 074118644bbb3aeaf8bced6829748d4fd5707a3b
    https://github.com/scummvm/scummvm/commit/074118644bbb3aeaf8bced6829748d4fd5707a3b
Author: Walter van Niftrik (walter at scummvm.org)
Date: 2020-08-27T14:56:17+02:00

Commit Message:
SCI: Manually construct engine options layout

This allows for PopUp widgets to be added

Changed paths:
    engines/sci/detection.cpp


diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp
index 4d32508f88..4d1796f075 100644
--- a/engines/sci/detection.cpp
+++ b/engines/sci/detection.cpp
@@ -24,12 +24,15 @@
 #include "base/plugins.h"
 #include "common/config-manager.h"
 #include "common/file.h"
+#include "common/hashmap.h"
 #include "common/ptr.h"
 #include "common/savefile.h"
 #include "common/system.h"
 #include "common/translation.h"
 #include "graphics/thumbnail.h"
 #include "graphics/surface.h"
+#include "gui/ThemeEval.h"
+#include "gui/widget.h"
 
 #include "sci/sci.h"
 #include "sci/engine/kernel.h"
@@ -556,6 +559,55 @@ static const char *directoryGlobs[] = {
 	0
 };
 
+class OptionsWidget : public GUI::OptionsContainerWidget {
+public:
+	explicit OptionsWidget(GuiObject *boss, const Common::String &name, const Common::String &domain);
+
+	// OptionsContainerWidget API
+	void load() override;
+	bool save() override;
+
+private:
+	// OptionsContainerWidget API
+	void defineLayout(GUI::ThemeEval &layouts, const Common::String &layoutName, const Common::String &overlayedLayout) const override;
+
+	Common::String _guiOptions;
+	Common::HashMap<Common::String, GUI::CheckboxWidget *> _checkboxes;
+};
+
+OptionsWidget::OptionsWidget(GuiObject *boss, const Common::String &name, const Common::String &domain) :
+		OptionsContainerWidget(boss, name, "SciOptionsDialog", false, domain) {
+	_guiOptions = ConfMan.get("guioptions", domain);
+
+	for (const ADExtraGuiOptionsMap *entry = optionsList; entry->guioFlag; ++entry)
+		if (checkGameGUIOption(entry->guioFlag, _guiOptions))
+			_checkboxes[entry->option.configOption] = new GUI::CheckboxWidget(widgetsBoss(), _dialogLayout + "." + entry->option.configOption, entry->option.label, entry->option.tooltip);
+}
+
+void OptionsWidget::defineLayout(GUI::ThemeEval &layouts, const Common::String &layoutName, const Common::String &overlayedLayout) const {
+	layouts.addDialog(layoutName, overlayedLayout);
+	layouts.addLayout(GUI::ThemeLayout::kLayoutVertical).addPadding(16, 16, 16, 16);
+
+	for (const ADExtraGuiOptionsMap *entry = optionsList; entry->guioFlag; ++entry)
+		layouts.addWidget(entry->option.configOption, "Checkbox");
+
+	layouts.closeLayout().closeDialog();
+}
+
+void OptionsWidget::load() {
+	for (const ADExtraGuiOptionsMap *entry = optionsList; entry->guioFlag; ++entry)
+		if (checkGameGUIOption(entry->guioFlag, _guiOptions))
+			_checkboxes[entry->option.configOption]->setState(ConfMan.getBool(entry->option.configOption, _domain));
+}
+
+bool OptionsWidget::save() {
+	for (const ADExtraGuiOptionsMap *entry = optionsList; entry->guioFlag; ++entry)
+		if (checkGameGUIOption(entry->guioFlag, _guiOptions))
+			ConfMan.setBool(entry->option.configOption, _checkboxes[entry->option.configOption]->getState(), _domain);
+
+	return true;
+}
+
 class SciMetaEngine : public AdvancedMetaEngine {
 public:
 	SciMetaEngine() : AdvancedMetaEngine(Sci::SciGameDescriptions, sizeof(ADGameDescription), s_sciGameTitles, optionsList) {
@@ -589,8 +641,13 @@ public:
 	int getMaximumSaveSlot() const override;
 	void removeSaveState(const char *target, int slot) const override;
 	SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override;
+	GUI::OptionsContainerWidget *buildEngineOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override;
 };
 
+GUI::OptionsContainerWidget *SciMetaEngine::buildEngineOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const {
+	return new OptionsWidget(boss, name, target);
+}
+
 Common::Language charToScummVMLanguage(const char c) {
 	switch (c) {
 	case 'F':


Commit: e0b8d8e414e27da4be122e6fc065caade389115d
    https://github.com/scummvm/scummvm/commit/e0b8d8e414e27da4be122e6fc065caade389115d
Author: Walter van Niftrik (walter at scummvm.org)
Date: 2020-08-27T14:56:17+02:00

Commit Message:
SCI: Replace native_fb01 Checkbox with PopUp

Use a PopUp widget instead of a Checkbox, to allow for more devices
to be added in the future.

Changed paths:
    engines/sci/detection.cpp
    engines/sci/detection_tables.h
    engines/sci/sci.h
    engines/sci/sound/music.cpp


diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp
index 4d1796f075..b3e6400646 100644
--- a/engines/sci/detection.cpp
+++ b/engines/sci/detection.cpp
@@ -33,6 +33,7 @@
 #include "graphics/surface.h"
 #include "gui/ThemeEval.h"
 #include "gui/widget.h"
+#include "gui/widgets/popup.h"
 
 #include "sci/sci.h"
 #include "sci/engine/kernel.h"
@@ -463,17 +464,6 @@ static const ADExtraGuiOptionsMap optionsList[] = {
 			false
 		}
 	},
-
-	{
-		GAMEOPTION_FB01_MIDI,
-		{
-			_s("Use IMF/Yamaha FB-01 for MIDI output"),
-			_s("Use an IBM Music Feature card or a Yamaha FB-01 FM synth module for MIDI output"),
-			"native_fb01",
-			false
-		}
-	},
-
 	// Jones in the Fast Lane - CD audio tracks or resource.snd
 	{
 		GAMEOPTION_JONES_CDAUDIO,
@@ -531,6 +521,46 @@ static const ADExtraGuiOptionsMap optionsList[] = {
 	AD_EXTRA_GUI_OPTIONS_TERMINATOR
 };
 
+struct PopUpOptionsItem {
+	const char *label;
+	int configValue;
+};
+
+#define POPUP_OPTIONS_ITEMS_TERMINATOR { nullptr, 0 }
+
+struct PopUpOptionsMap {
+	const char *guioFlag;
+	const char *label;
+	const char *tooltip;
+	const char *configOption;
+	int defaultState;
+	PopUpOptionsItem items[10];
+};
+
+#define POPUP_OPTIONS_TERMINATOR { nullptr, nullptr, nullptr, nullptr, 0, { POPUP_OPTIONS_ITEMS_TERMINATOR } }
+
+static const PopUpOptionsMap popUpOptionsList[] = {
+	{
+		GAMEOPTION_MIDI_MODE,
+		_s("MIDI mode:"),
+		_s("When using external MIDI devices (e.g. through USB-MIDI), select your device here"),
+		"midi_mode",
+		kMidiModeStandard,
+		{
+			{
+				_s("Standard (GM / MT-32)"),
+				kMidiModeStandard
+			},
+			{
+				_s("Yamaha FB-01"),
+				kMidiModeFB01
+			},
+			POPUP_OPTIONS_ITEMS_TERMINATOR
+		}
+	},
+	POPUP_OPTIONS_TERMINATOR
+};
+
 /**
  * The fallback game descriptor used by the SCI engine's fallbackDetector.
  * Contents of this struct are overwritten by the fallbackDetector.
@@ -542,7 +572,7 @@ static ADGameDescription s_fallbackDesc = {
 	Common::UNK_LANG,
 	Common::kPlatformDOS,
 	ADGF_NO_FLAGS,
-	GUIO3(GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)
+	GUIO3(GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)
 };
 
 static char s_fallbackGameIdBuf[256];
@@ -573,6 +603,7 @@ private:
 
 	Common::String _guiOptions;
 	Common::HashMap<Common::String, GUI::CheckboxWidget *> _checkboxes;
+	Common::HashMap<Common::String, GUI::PopUpWidget *> _popUps;
 };
 
 OptionsWidget::OptionsWidget(GuiObject *boss, const Common::String &name, const Common::String &domain) :
@@ -582,6 +613,17 @@ OptionsWidget::OptionsWidget(GuiObject *boss, const Common::String &name, const
 	for (const ADExtraGuiOptionsMap *entry = optionsList; entry->guioFlag; ++entry)
 		if (checkGameGUIOption(entry->guioFlag, _guiOptions))
 			_checkboxes[entry->option.configOption] = new GUI::CheckboxWidget(widgetsBoss(), _dialogLayout + "." + entry->option.configOption, entry->option.label, entry->option.tooltip);
+
+	for (const PopUpOptionsMap *entry = popUpOptionsList; entry->guioFlag; ++entry)
+		if (checkGameGUIOption(entry->guioFlag, _guiOptions)) {
+			GUI::StaticTextWidget *textWidget = new GUI::StaticTextWidget(widgetsBoss(), _dialogLayout + "." + entry->configOption + "_desc", entry->label, entry->tooltip);
+			textWidget->setAlign(Graphics::kTextAlignRight);
+
+			_popUps[entry->configOption] = new GUI::PopUpWidget(widgetsBoss(), _dialogLayout + "." + entry->configOption);
+
+			for (uint i = 0; entry->items[i].label; ++i)
+				_popUps[entry->configOption]->appendEntry(entry->items[i].label, entry->items[i].configValue);
+		}
 }
 
 void OptionsWidget::defineLayout(GUI::ThemeEval &layouts, const Common::String &layoutName, const Common::String &overlayedLayout) const {
@@ -591,6 +633,12 @@ void OptionsWidget::defineLayout(GUI::ThemeEval &layouts, const Common::String &
 	for (const ADExtraGuiOptionsMap *entry = optionsList; entry->guioFlag; ++entry)
 		layouts.addWidget(entry->option.configOption, "Checkbox");
 
+	for (const PopUpOptionsMap *entry = popUpOptionsList; entry->guioFlag; ++entry) {
+		layouts.addLayout(GUI::ThemeLayout::kLayoutHorizontal).addPadding(0, 0, 0, 0);
+		layouts.addWidget(Common::String(entry->configOption) + "_desc", "OptionsLabel");
+		layouts.addWidget(entry->configOption, "PopUp").closeLayout();
+	}
+
 	layouts.closeLayout().closeDialog();
 }
 
@@ -598,6 +646,14 @@ void OptionsWidget::load() {
 	for (const ADExtraGuiOptionsMap *entry = optionsList; entry->guioFlag; ++entry)
 		if (checkGameGUIOption(entry->guioFlag, _guiOptions))
 			_checkboxes[entry->option.configOption]->setState(ConfMan.getBool(entry->option.configOption, _domain));
+
+	for (const PopUpOptionsMap *entry = popUpOptionsList; entry->guioFlag; ++entry)
+		if (checkGameGUIOption(entry->guioFlag, _guiOptions))
+			_popUps[entry->configOption]->setSelectedTag(ConfMan.getInt(entry->configOption, _domain));
+
+	// If the deprecated native_fb01 option is set, use it to set midi_mode
+	if (ConfMan.hasKey("native_fb01", _domain) && ConfMan.getBool("native_fb01", _domain))
+		_popUps["midi_mode"]->setSelectedTag(kMidiModeFB01);
 }
 
 bool OptionsWidget::save() {
@@ -605,6 +661,13 @@ bool OptionsWidget::save() {
 		if (checkGameGUIOption(entry->guioFlag, _guiOptions))
 			ConfMan.setBool(entry->option.configOption, _checkboxes[entry->option.configOption]->getState(), _domain);
 
+	for (const PopUpOptionsMap *entry = popUpOptionsList; entry->guioFlag; ++entry)
+		if (checkGameGUIOption(entry->guioFlag, _guiOptions))
+			ConfMan.setInt(entry->configOption, _popUps[entry->configOption]->getSelectedTag(), _domain);
+
+	// Remove deprecated option
+	ConfMan.removeKey("native_fb01", _domain);
+
 	return true;
 }
 
@@ -641,9 +704,17 @@ public:
 	int getMaximumSaveSlot() const override;
 	void removeSaveState(const char *target, int slot) const override;
 	SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override;
+	void registerDefaultSettings(const Common::String &target) const override;
 	GUI::OptionsContainerWidget *buildEngineOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override;
 };
 
+void SciMetaEngine::registerDefaultSettings(const Common::String &target) const {
+	AdvancedMetaEngine::registerDefaultSettings(target);
+
+	for (const PopUpOptionsMap *entry = popUpOptionsList; entry->guioFlag; ++entry)
+		ConfMan.registerDefault(entry->configOption, entry->defaultState);
+}
+
 GUI::OptionsContainerWidget *SciMetaEngine::buildEngineOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const {
 	return new OptionsWidget(boss, name, target);
 }
@@ -678,7 +749,7 @@ ADDetectedGame SciMetaEngine::fallbackDetect(const FileMap &allFiles, const Comm
 	s_fallbackDesc.flags = ADGF_NO_FLAGS;
 	s_fallbackDesc.platform = Common::kPlatformDOS;	// default to PC platform
 	s_fallbackDesc.gameId = "sci";
-	s_fallbackDesc.guiOptions = GUIO3(GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI);
+	s_fallbackDesc.guiOptions = GUIO3(GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE);
 
 	if (allFiles.contains("resource.map") || allFiles.contains("Data1")
 	    || allFiles.contains("resmap.000") || allFiles.contains("resmap.001")) {
@@ -803,7 +874,7 @@ ADDetectedGame SciMetaEngine::fallbackDetect(const FileMap &allFiles, const Comm
 	const bool isCD = (s_fallbackDesc.flags & ADGF_CD);
 
 	if (!isCD)
-		s_fallbackDesc.guiOptions = GUIO4(GUIO_NOSPEECH, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI);
+		s_fallbackDesc.guiOptions = GUIO4(GUIO_NOSPEECH, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE);
 
 	if (gameId.hasSuffix("sci")) {
 		s_fallbackDesc.extra = "SCI";
diff --git a/engines/sci/detection_tables.h b/engines/sci/detection_tables.h
index 519fcdfefa..b70bafd445 100644
--- a/engines/sci/detection_tables.h
+++ b/engines/sci/detection_tables.h
@@ -24,11 +24,11 @@ namespace Sci {
 
 #include "sci/sci.h"
 
-#define GUIO_STD16 GUIO4(GUIO_NOSPEECH, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)
-#define GUIO_STD16_UNDITHER GUIO5(GUIO_NOSPEECH, GAMEOPTION_EGA_UNDITHER, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)
-#define GUIO_STD16_SPEECH GUIO3(GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)
-#define GUIO_STD16_MAC GUIO3(GUIO_NOSPEECH, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_FB01_MIDI)
-#define GUIO_STD16_MAC_UNDITHER GUIO4(GUIO_NOSPEECH, GAMEOPTION_EGA_UNDITHER, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_FB01_MIDI)
+#define GUIO_STD16 GUIO4(GUIO_NOSPEECH, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)
+#define GUIO_STD16_UNDITHER GUIO5(GUIO_NOSPEECH, GAMEOPTION_EGA_UNDITHER, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)
+#define GUIO_STD16_SPEECH GUIO3(GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)
+#define GUIO_STD16_MAC GUIO3(GUIO_NOSPEECH, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_MIDI_MODE)
+#define GUIO_STD16_MAC_UNDITHER GUIO4(GUIO_NOSPEECH, GAMEOPTION_EGA_UNDITHER, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_MIDI_MODE)
 
 #define FANMADE_L(name, resMapMd5, resMapSize, resMd5, resSize, resVol, lang) \
 	{"sci-fanmade", name, { \
@@ -178,7 +178,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.000", 0, "27ec5fa09cd12a7fd16e86d96a2ed245", 548272},
 		{"resource.001", 0, "7c3e82c390e934de9b7afcab6de9cec4", 1117317},
 		AD_LISTEND},
-		Common::JA_JPN, Common::kPlatformPC98, ADGF_ADDENGLISH, GUIO5(GUIO_NOSPEECH, GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::JA_JPN, Common::kPlatformPC98, ADGF_ADDENGLISH, GUIO5(GUIO_NOSPEECH, GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 #ifdef ENABLE_SCI32
 	// Inside the Chest / Behind the Developer's Shield
@@ -300,7 +300,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.003", 0, "1f2f79e399098859c73e49ac6a3545d8", 622122},
 		{"resource.004", 0, "64f342463f6f35ba71b3509ef696ae3f", 669179},
 		AD_LISTEND},
-		Common::EN_ANY, Common::kPlatformDOS, 0, GUIO5(GUIO_NOSPEECH, GAMEOPTION_EGA_UNDITHER, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::EN_ANY, Common::kPlatformDOS, 0, GUIO5(GUIO_NOSPEECH, GAMEOPTION_EGA_UNDITHER, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 	// Codename: Iceman - English DOS (supplied by ssburnout in bug report #3049193)
 	// 1.022 9x5.25" (label: Int#0.000.668)
@@ -540,7 +540,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.map", 0, "a4b73d5d2b55bdb6e44345e99c8fbdd0", 4804},
 		{"resource.000", 0, "d908dbef56816ac6c60dd145fdeafb2b", 3536046},
 		AD_LISTEND},
-		Common::EN_ANY, Common::kPlatformWindows, ADGF_CD, GUIO4(GUIO_MIDIGM, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::EN_ANY, Common::kPlatformWindows, ADGF_CD, GUIO4(GUIO_MIDIGM, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 	// Eco Quest - English DOS Floppy (reported by misterhands in bug #6599)
 	// Game v1.10, interpreter 2.000.286, INT #6.12.92
@@ -1370,7 +1370,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.map", 0, "459f5b04467bc2107aec02f5c4b71b37", 4878},
 		{"resource.001", 0, "3876da2ce16fb7dea2f5d943d946fa84", 1652150},
 		AD_LISTEND},
-		Common::EN_ANY, Common::kPlatformWindows, ADGF_CD, GUIO4(GUIO_MIDIGM, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_FB01_MIDI, GAMEOPTION_JONES_CDAUDIO)	},
+		Common::EN_ANY, Common::kPlatformWindows, ADGF_CD, GUIO4(GUIO_MIDIGM, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_MIDI_MODE, GAMEOPTION_JONES_CDAUDIO)	},
 
 	// Jones in the Fast Lane - English DOS US CD (alternate version)
 	// Supplied by collector9 in bug #3614668
@@ -1387,7 +1387,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.map", 0, "4344ff3f796707843b992adec2c87663", 4878},
 		{"resource.001", 0, "3876da2ce16fb7dea2f5d943d946fa84", 1652062},
 		AD_LISTEND},
-		Common::EN_ANY, Common::kPlatformWindows, ADGF_CD, GUIO4(GUIO_MIDIGM, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_FB01_MIDI, GAMEOPTION_JONES_CDAUDIO)	},
+		Common::EN_ANY, Common::kPlatformWindows, ADGF_CD, GUIO4(GUIO_MIDIGM, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_MIDI_MODE, GAMEOPTION_JONES_CDAUDIO)	},
 
 	// King's Quest 1 SCI Remake - English Amiga (from www.back2roots.org)
 	// Executable scanning reports "1.003.007"
@@ -1614,7 +1614,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.000", 0, "449471bfd77be52f18a3773c7f7d843d", 571368},
 		{"resource.001", 0, "b45a581ff8751e052c7e364f58d3617f", 16800210},
 		AD_LISTEND},
-		Common::EN_ANY, Common::kPlatformWindows, ADGF_CD, GUIO4(GUIO_MIDIGM, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::EN_ANY, Common::kPlatformWindows, ADGF_CD, GUIO4(GUIO_MIDIGM, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 	// King's Quest 5 - English DOS Floppy
 	// SCI interpreter version 1.000.060
@@ -1855,7 +1855,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.004", 0, "e114ce8f884601c43308fb5cbbea4874", 1174129},
 		{"resource.005", 0, "349ad9438172265d00680075c5a988d0", 1019669},
 		AD_LISTEND},
-		Common::JA_JPN, Common::kPlatformPC98, ADGF_ADDENGLISH, GUIO5(GUIO_NOSPEECH, GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::JA_JPN, Common::kPlatformPC98, ADGF_ADDENGLISH, GUIO5(GUIO_NOSPEECH, GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 	// King's Quest 6 - English DOS Non-Interactive Demo
 	// Executable scanning reports "1.001.055", VERSION file reports "1.000.000"
@@ -1876,7 +1876,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.map", 0, "eb9e177281b7cde188dc0d83194cd365", 8960},
 		{"resource.msg", 0, "3cf5de44de36191f109d425b8450efc8", 259510},
 		AD_LISTEND},
-		Common::EN_ANY, Common::kPlatformDOS, ADGF_CD | ADGF_DEMO, GUIO5(GUIO_NOSPEECH, GAMEOPTION_HIGH_RESOLUTION_GRAPHICS, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::EN_ANY, Common::kPlatformDOS, ADGF_CD | ADGF_DEMO, GUIO5(GUIO_NOSPEECH, GAMEOPTION_HIGH_RESOLUTION_GRAPHICS, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 	// King's Quest 6 - English DOS Floppy
 	// SCI interpreter version 1.001.054
@@ -1931,7 +1931,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.000", 0, "233394a5f33b475ae5975e7e9a420865", 8376008},
 		{"resource.msg", 0, "3cf5de44de36191f109d425b8450efc8", 259510},
 		AD_LISTEND},
-		Common::EN_ANY, Common::kPlatformDOS, ADGF_CD, GUIO4(GAMEOPTION_HIGH_RESOLUTION_GRAPHICS, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::EN_ANY, Common::kPlatformDOS, ADGF_CD, GUIO4(GAMEOPTION_HIGH_RESOLUTION_GRAPHICS, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 	// King's Quest 6 - English Windows CD (supplied by trembyle)
 	// Executable scanning reports "1.001.069", VERSION file reports "1.000.000"
@@ -1940,7 +1940,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.000", 0, "233394a5f33b475ae5975e7e9a420865", 8376008},
 		{"resource.msg", 0, "3cf5de44de36191f109d425b8450efc8", 259510},
 		AD_LISTEND},
-		Common::EN_ANY, Common::kPlatformWindows, ADGF_CD, GUIO6(GUIO_NOASPECT, GAMEOPTION_HIGH_RESOLUTION_GRAPHICS, GAMEOPTION_KQ6_WINDOWS_CURSORS, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::EN_ANY, Common::kPlatformWindows, ADGF_CD, GUIO6(GUIO_NOASPECT, GAMEOPTION_HIGH_RESOLUTION_GRAPHICS, GAMEOPTION_KQ6_WINDOWS_CURSORS, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 	// King's Quest 6 - English DOS CD (same version included in King's Quest Collection)
 	// Executable scanning reports "1.cfs.158", VERSION file reports "1.000.00G"
@@ -1949,7 +1949,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.map", 0, "7a550ebfeae2575ca00d47703a6a774c", 9215},
 		{"resource.000", 0, "233394a5f33b475ae5975e7e9a420865", 8376352},
 		AD_LISTEND},
-		Common::EN_ANY, Common::kPlatformDOS, ADGF_CD, GUIO4(GAMEOPTION_HIGH_RESOLUTION_GRAPHICS, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::EN_ANY, Common::kPlatformDOS, ADGF_CD, GUIO4(GAMEOPTION_HIGH_RESOLUTION_GRAPHICS, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 	// King's Quest 6 - English Windows CD (same version included in King's Quest Collection)
 	// Executable scanning reports "1.001.069", VERSION file reports "1.000.00G"
@@ -1957,7 +1957,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.map", 0, "7a550ebfeae2575ca00d47703a6a774c", 9215},
 		{"resource.000", 0, "233394a5f33b475ae5975e7e9a420865", 8376352},
 		AD_LISTEND},
-		Common::EN_ANY, Common::kPlatformWindows, ADGF_CD, GUIO6(GUIO_NOASPECT, GAMEOPTION_HIGH_RESOLUTION_GRAPHICS, GAMEOPTION_KQ6_WINDOWS_CURSORS, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::EN_ANY, Common::kPlatformWindows, ADGF_CD, GUIO6(GUIO_NOASPECT, GAMEOPTION_HIGH_RESOLUTION_GRAPHICS, GAMEOPTION_KQ6_WINDOWS_CURSORS, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 	// King's Quest 6 - English Macintosh Floppy
 	// VERSION file reports "1.0"
@@ -2287,7 +2287,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.000", 0, "57084910bc923bff5d6d9bc1b56e9604", 5028766},
 		{"resource.msg", 0, "c28ba1d0326d06eab69f94d9a70f5389", 285797},
 		AD_LISTEND},
-		Common::ES_ESP, Common::kPlatformDOS, 0, GUIO4(GUIO_NOSPEECH, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::ES_ESP, Common::kPlatformDOS, 0, GUIO4(GUIO_NOSPEECH, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 	// Laura Bow 2 - Spanish DOS CD (from jvprat)
 	// Executable scanning reports "2.000.274", VERSION file reports "1.000.000, May 10, 1994"
@@ -2544,7 +2544,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{ "resource.004", 0, "17bfd686d59accc3fb3f079ad9278e66", 658874 },
 		{ "resource.005", 0, "17bfd686d59accc3fb3f079ad9278e66", 794252 },
 		AD_LISTEND },
-		Common::DE_DEU, Common::kPlatformAmiga, ADGF_ADDENGLISH, GUIO4(GUIO_NOSPEECH, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI) },
+		Common::DE_DEU, Common::kPlatformAmiga, ADGF_ADDENGLISH, GUIO4(GUIO_NOSPEECH, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE) },
 
 	// Larry 3 - English Atari ST
 	// Game version 1.021, 1990-01-27
@@ -3327,7 +3327,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.map", 0, "b11e971ccd2040bebba59dfb409a08ef", 5772},
 		{"resource.001", 0, "d49625d9b8005ec01c852f8322a82867", 4330713},
 		AD_LISTEND},
-		Common::JA_JPN, Common::kPlatformFMTowns, ADGF_ADDENGLISH, GUIO4(GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::JA_JPN, Common::kPlatformFMTowns, ADGF_ADDENGLISH, GUIO4(GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 #ifdef ENABLE_SCI32
 
@@ -3795,7 +3795,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.002", 0, "77f02def3094af804fd2371db25b7100", 334283},
 		{"resource.003", 0, "77f02def3094af804fd2371db25b7100", 308044},
 		AD_LISTEND},
-		Common::EN_ANY, Common::kPlatformDOS, 0, GUIO5(GUIO_NOSPEECH, GAMEOPTION_EGA_UNDITHER, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::EN_ANY, Common::kPlatformDOS, 0, GUIO5(GUIO_NOSPEECH, GAMEOPTION_EGA_UNDITHER, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 	// Police Quest 2 - English Atari ST
 	// Game version 1.001.006 1989-01-16 13:30
@@ -3817,7 +3817,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.002", 0, "05fdee43a228dd6ea4d1a92ccae3f788", 637662},
 		{"resource.003", 0, "05fdee43a228dd6ea4d1a92ccae3f788", 684395},
 		AD_LISTEND},
-		Common::JA_JPN, Common::kPlatformPC98, ADGF_ADDENGLISH, GUIO6(GUIO_NOSPEECH, GUIO_NOASPECT, GAMEOPTION_EGA_UNDITHER, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::JA_JPN, Common::kPlatformPC98, ADGF_ADDENGLISH, GUIO6(GUIO_NOSPEECH, GUIO_NOASPECT, GAMEOPTION_EGA_UNDITHER, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 	// Police Quest 3 - English Amiga
 	// Executable scanning reports "1.004.024"
@@ -4669,7 +4669,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resmap.000", 0, "d8659188b84beaef076bd869837cd530", 634},
 		{"ressci.000", 0, "7fbac0807a044c9543e8ac376d200e59", 4925003},
 		AD_LISTEND},
-		Common::EN_ANY, Common::kPlatformWindows, ADGF_DEMO | ADGF_UNSTABLE, GUIO5(GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::EN_ANY, Common::kPlatformWindows, ADGF_DEMO | ADGF_UNSTABLE, GUIO5(GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 	// Shivers 2 - English Windows (from abevi)
 	// VERSION.TXT Version 1.0 (3/25/97)
@@ -4677,7 +4677,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"ressci.001", 0, "a79d03d6eb75be0a79324f14e3d2ace4", 95346793},
 		{"resmap.001", 0, "a4804d436d90c4ec2e46b537f5e954db", 6268},
 		AD_LISTEND},
-		Common::EN_ANY, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO6(GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, GUIO_NOSPEECH, GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::EN_ANY, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO6(GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, GUIO_NOSPEECH, GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 #endif
 
@@ -4753,7 +4753,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.003", 0, "da52b87ce225d12a3aa35e6b157e785c", 1214406},
 		{"resource.004", 0, "424f08b7593e54aa0ae22478b73e628a", 1208608},
 		AD_LISTEND},
-		Common::RU_RUS, Common::kPlatformDOS, 0, GUIO4(GUIO_NOSPEECH, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::RU_RUS, Common::kPlatformDOS, 0, GUIO4(GUIO_NOSPEECH, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 
 	// Space Quest 1 VGA Remake - English Mac (from Fingolfin)
@@ -4888,7 +4888,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.003", 0, "8b55c4875298f45ea5696a5ee8f6a7fe", 330305},
 		{"resource.004", 0, "8b55c4875298f45ea5696a5ee8f6a7fe", 325779},
 		AD_LISTEND},
-		Common::EN_ANY, Common::kPlatformDOS, 0, GUIO5(GUIO_NOSPEECH, GAMEOPTION_EGA_UNDITHER, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::EN_ANY, Common::kPlatformDOS, 0, GUIO5(GUIO_NOSPEECH, GAMEOPTION_EGA_UNDITHER, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 	// Space Quest 3 - English DOS (from telanus, bug report Trac#9626)
 	// Game version 1.0P 1989-03-22
@@ -5106,7 +5106,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.001", 0, "454684e3a7a68cbca073945e50778447", 1187088},
 		{"resource.002", 0, "6dc668326cc22cb9e8bd8ca9e68d2a66", 1181249},
 		AD_LISTEND},
-		Common::JA_JPN, Common::kPlatformPC98, ADGF_ADDENGLISH, GUIO5(GUIO_NOSPEECH, GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::JA_JPN, Common::kPlatformPC98, ADGF_ADDENGLISH, GUIO5(GUIO_NOSPEECH, GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 	// Space Quest 4 - Japanese PC-98 5.25" Floppy (also includes english language)
 	// SCI interpreter version 1.000.1068
@@ -5116,7 +5116,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.001", 0, "454684e3a7a68cbca073945e50778447", 1187088},
 		{"resource.002", 0, "6dc668326cc22cb9e8bd8ca9e68d2a66", 1181249},
 		AD_LISTEND},
-		Common::EN_ANY, Common::kPlatformPC98, ADGF_ADDENGLISH, GUIO5(GUIO_NOSPEECH, GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::EN_ANY, Common::kPlatformPC98, ADGF_ADDENGLISH, GUIO5(GUIO_NOSPEECH, GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 	// Space Quest 4 - English DOS CD (from the Space Quest Collection)
 	// Executable scanning reports "1.001.064", VERSION file reports "1.0"
@@ -5124,7 +5124,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.map", 0, "ed90a8e3ccc53af6633ff6ab58392bae", 7054},
 		{"resource.000", 0, "63247e3901ab8963d4eece73747832e0", 5157378},
 		AD_LISTEND},
-		Common::EN_ANY, Common::kPlatformDOS, ADGF_CD, GUIO4(GAMEOPTION_SQ4_SILVER_CURSORS, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::EN_ANY, Common::kPlatformDOS, ADGF_CD, GUIO4(GAMEOPTION_SQ4_SILVER_CURSORS, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 	// Space Quest 4 - English Windows CD (from the Space Quest Collection)
 	// Executable scanning reports "1.001.064", VERSION file reports "1.0"
@@ -5134,7 +5134,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.map", 0, "ed90a8e3ccc53af6633ff6ab58392bae", 7054},
 		{"resource.000", 0, "63247e3901ab8963d4eece73747832e0", 5157378},
 		AD_LISTEND},
-		Common::EN_ANY, Common::kPlatformWindows, ADGF_CD, GUIO5(GUIO_MIDIGM, GAMEOPTION_SQ4_SILVER_CURSORS, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::EN_ANY, Common::kPlatformWindows, ADGF_CD, GUIO5(GUIO_MIDIGM, GAMEOPTION_SQ4_SILVER_CURSORS, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 	// Space Quest 4 - English DOS CD patch 1.2 (unofficial - NRS) - THIS VERSION IS PIRATED/CRACKED AND REPACKAGED =DO NOT RE-ADD=
 	// In essence, this "patch" includes a mixture the CD and floppy versions (the whole game), without the speech file
@@ -5142,7 +5142,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.map", 0, "38287a646458a1dabded55d094407793", 7139},
 		{"resource.000", 0, "231fd8421e1f211e1bcf9d7b8b6408e7", 9525849},
 		AD_LISTEND},
-		Common::EN_ANY, Common::kPlatformDOS, ADGF_PIRATED, GUIO4(GAMEOPTION_SQ4_SILVER_CURSORS, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::EN_ANY, Common::kPlatformDOS, ADGF_PIRATED, GUIO4(GAMEOPTION_SQ4_SILVER_CURSORS, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 	// Space Quest 4 - Spanish DOS CD (from jvprat, is still text only, not talkie, also includes english language)
 	// Executable scanning reports "1.SQ4.057", VERSION file reports "1.000"
@@ -5156,7 +5156,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.004", 0, "776fba81c110d1908776232cbe190e20", 1253752},
 		{"resource.005", 0, "55fae26c2a92f16ef72c1e216e827c0f", 1098328},
 		AD_LISTEND},
-		Common::ES_ESP, Common::kPlatformDOS, ADGF_ADDENGLISH, GUIO4(GAMEOPTION_SQ4_SILVER_CURSORS, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
+		Common::ES_ESP, Common::kPlatformDOS, ADGF_ADDENGLISH, GUIO4(GAMEOPTION_SQ4_SILVER_CURSORS, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_MIDI_MODE)	},
 
 	// Space Quest 4 - Spanish DOS Floppy (from jvprat, also includes english language)
 	// Executable scanning reports "1.SQ4.056", VERSION file reports "1.000"
diff --git a/engines/sci/sci.h b/engines/sci/sci.h
index 127dc32d8c..2a54be393d 100644
--- a/engines/sci/sci.h
+++ b/engines/sci/sci.h
@@ -48,7 +48,7 @@ namespace Sci {
 // GUI-options, primarily used by detection_tables.h
 #define GAMEOPTION_PREFER_DIGITAL_SFX       GUIO_GAMEOPTIONS1
 #define GAMEOPTION_ORIGINAL_SAVELOAD        GUIO_GAMEOPTIONS2
-#define GAMEOPTION_FB01_MIDI                GUIO_GAMEOPTIONS3
+#define GAMEOPTION_MIDI_MODE                GUIO_GAMEOPTIONS3
 #define GAMEOPTION_JONES_CDAUDIO            GUIO_GAMEOPTIONS4
 #define GAMEOPTION_KQ6_WINDOWS_CURSORS      GUIO_GAMEOPTIONS5
 #define GAMEOPTION_SQ4_SILVER_CURSORS       GUIO_GAMEOPTIONS6
@@ -247,6 +247,12 @@ enum kLanguage {
 	K_LANG_PORTUGUESE = 351
 };
 
+/** MIDI devices */
+enum kMidiMode {
+	kMidiModeStandard,
+	kMidiModeFB01
+};
+
 class SciEngine : public Engine {
 	friend class Console;
 public:
diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp
index 9e9d5df096..8a24429b30 100644
--- a/engines/sci/sound/music.cpp
+++ b/engines/sci/sound/music.cpp
@@ -138,7 +138,8 @@ void SciMusic::init() {
 		_pMidiDrv = MidiPlayer_PC9801_create(_soundVersion);
 		break;
 	default:
-		if (ConfMan.getBool("native_fb01"))
+		if (ConfMan.getInt("midi_mode") == kMidiModeFB01
+		    || (ConfMan.hasKey("native_fb01") && ConfMan.getBool("native_fb01")))
 			_pMidiDrv = MidiPlayer_Fb01_create(_soundVersion);
 		else
 			_pMidiDrv = MidiPlayer_Midi_create(_soundVersion);


Commit: c8293df572bf4836b7f2f73bbcba7bc8a583c1ef
    https://github.com/scummvm/scummvm/commit/c8293df572bf4836b7f2f73bbcba7bc8a583c1ef
Author: Walter van Niftrik (walter at scummvm.org)
Date: 2020-08-27T14:56:17+02:00

Commit Message:
SCI: Add Roland D-110/D-10/D-20 support

Changed paths:
    engines/sci/detection.cpp
    engines/sci/resource.h
    engines/sci/resource_audio.cpp
    engines/sci/sci.cpp
    engines/sci/sci.h
    engines/sci/sound/drivers/midi.cpp


diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp
index b3e6400646..b47191b7c0 100644
--- a/engines/sci/detection.cpp
+++ b/engines/sci/detection.cpp
@@ -551,6 +551,10 @@ static const PopUpOptionsMap popUpOptionsList[] = {
 				_s("Standard (GM / MT-32)"),
 				kMidiModeStandard
 			},
+			{
+				_s("Roland D-110 / D-10 / D-20"),
+				kMidiModeD110
+			},
 			{
 				_s("Yamaha FB-01"),
 				kMidiModeFB01
diff --git a/engines/sci/resource.h b/engines/sci/resource.h
index 8e7b13e664..cab7859ea7 100644
--- a/engines/sci/resource.h
+++ b/engines/sci/resource.h
@@ -414,6 +414,7 @@ public:
 	 * applied per game, if applicable.
 	 */
 	void addNewGMPatch(SciGameId gameId);
+	void addNewD110Patch(SciGameId gameId);
 
 #ifdef ENABLE_SCI32
 	/**
diff --git a/engines/sci/resource_audio.cpp b/engines/sci/resource_audio.cpp
index 5f9ff5d896..6703f4feae 100644
--- a/engines/sci/resource_audio.cpp
+++ b/engines/sci/resource_audio.cpp
@@ -199,6 +199,48 @@ void ResourceManager::addNewGMPatch(SciGameId gameId) {
 	}
 }
 
+void ResourceManager::addNewD110Patch(SciGameId gameId) {
+	Common::String patchFile;
+
+	switch (gameId) {
+	case GID_CAMELOT:
+		patchFile = "CAMELOT.000";
+		break;
+	case GID_HOYLE1:
+		patchFile = "HOYLE.000";
+		break;
+	case GID_QFG1:
+		patchFile = "HQ1.000";
+		break;
+	case GID_ICEMAN:
+		patchFile = "ICEMAN.000"; // Also ICE.000, but let's go with this one
+		break;
+	case GID_KQ4:
+		patchFile = "KQ4.000";
+		break;
+	case GID_LSL2:
+		patchFile = "LSL2.000";
+		break;
+	case GID_LSL3:
+		patchFile = "LSL3.000";
+		break;
+	case GID_PQ2:
+		patchFile = "PQ2.000";
+		break;
+	case GID_SQ3:
+		patchFile = "SQ3.000";
+		break;
+	default:
+		// There's also a CB.000, but unfortunately that file contains an MT-32 patch
+		break;
+	}
+
+	if (!patchFile.empty() && Common::File::exists(patchFile)) {
+		ResourceSource *psrcPatch = new PatchResourceSource(patchFile);
+		processPatch(psrcPatch, kResourceTypePatch, 0);
+	}
+}
+
 void ResourceManager::processWavePatch(ResourceId resourceId, const Common::String &name) {
 	ResourceSource *resSrc = new WaveResourceSource(name);
 	Common::File file;
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index 3bffefdfeb..8bed5e1ee5 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -276,8 +276,9 @@ Common::Error SciEngine::run() {
 	// Reset, so that error()s before SoundCommandParser is initialized wont cause a crash
 	_soundCmd = NULL;
 
-	// Add the after market GM patches for the specified game, if they exist
+	// Add the after market patches for the specified game, if they exist
 	_resMan->addNewGMPatch(_gameId);
+	_resMan->addNewD110Patch(_gameId);
 	_gameObjectAddress = _resMan->findGameObject(true, isBE());
 
 	_scriptPatcher = new ScriptPatcher();
diff --git a/engines/sci/sci.h b/engines/sci/sci.h
index 2a54be393d..135abbff8f 100644
--- a/engines/sci/sci.h
+++ b/engines/sci/sci.h
@@ -250,7 +250,8 @@ enum kLanguage {
 /** MIDI devices */
 enum kMidiMode {
 	kMidiModeStandard,
-	kMidiModeFB01
+	kMidiModeFB01,
+	kMidiModeD110
 };
 
 class SciEngine : public Engine {
diff --git a/engines/sci/sound/drivers/midi.cpp b/engines/sci/sound/drivers/midi.cpp
index 0f4c5838a4..73ce45f35d 100644
--- a/engines/sci/sound/drivers/midi.cpp
+++ b/engines/sci/sound/drivers/midi.cpp
@@ -137,7 +137,8 @@ public:
 	enum Mt32Type {
 		kMt32TypeNone,
 		kMt32TypeReal,
-		kMt32TypeEmulated
+		kMt32TypeEmulated,
+		kMt32TypeD110
 	};
 
 	MidiPlayer_Midi(SciVersion version);
@@ -162,12 +163,15 @@ public:
 	void setReverb(int8 reverb) override;
 	void playSwitch(bool play) override;
 	void initTrack(SciSpan<const byte> &) override;
+	const char *reportMissingFiles() override { return _missingFiles; }
 
 private:
 	bool isMt32GmPatch(const SciSpan<const byte> &data);
 	void readMt32GmPatch(const SciSpan<const byte> &data);
 	void readMt32Patch(const SciSpan<const byte> &data);
 	void readMt32DrvData();
+	bool readD110DrvData();
+	bool readD110SysEx();
 
 	void mapMt32ToGm(const SciSpan<const byte> &data);
 	uint8 lookupGmInstrument(const char *iname);
@@ -199,6 +203,7 @@ private:
 	};
 
 	Mt32Type _mt32Type;
+	uint _mt32LCDSize;
 	bool _useMT32Track;
 	bool _hasReverb;
 	bool _playSwitch;
@@ -218,15 +223,20 @@ private:
 	uint8 _pitchBendRange[128];
 	uint8 _percussionVelocityScale[128];
 
-	byte _goodbyeMsg[20];
+	byte _goodbyeMsg[32];
 	byte _sysExBuf[kMaxSysExSize];
+
+	const char *_missingFiles;
 };
 
-MidiPlayer_Midi::MidiPlayer_Midi(SciVersion version) : MidiPlayer(version), _playSwitch(true), _masterVolume(15), _mt32Type(kMt32TypeNone), _hasReverb(false), _defaultReverb(-1), _useMT32Track(true) {
+MidiPlayer_Midi::MidiPlayer_Midi(SciVersion version) : MidiPlayer(version), _playSwitch(true), _masterVolume(15), _mt32Type(kMt32TypeNone), _mt32LCDSize(20), _hasReverb(false), _defaultReverb(-1), _useMT32Track(true), _missingFiles(nullptr) {
 	MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI);
 	_driver = MidiDriver::createMidi(dev);
 
-	if (MidiDriver::getMusicType(dev) == MT_MT32 || ConfMan.getBool("native_mt32")) {
+	if (ConfMan.getInt("midi_mode") == kMidiModeD110) {
+		_mt32Type = kMt32TypeD110;
+		_mt32LCDSize = 32;
+	} else if (MidiDriver::getMusicType(dev) == MT_MT32 || ConfMan.getBool("native_mt32")) {
 		if (MidiDriver::getDeviceString(dev, MidiDriver::kDriverId) == "mt32") {
 			_mt32Type = kMt32TypeEmulated;
 		} else {
@@ -674,12 +684,12 @@ void MidiPlayer_Midi::readMt32Patch(const SciSpan<const byte> &data) {
 	Common::MemoryReadStream stream(data.toStream());
 
 	// Send before-SysEx text
-	stream.seek(20);
-	sendMt32SysEx(0x200000, stream, 20);
+	stream.seek(_mt32LCDSize);
+	sendMt32SysEx(0x200000, stream, _mt32LCDSize);
 
 	// Save goodbye message
-	assert(sizeof(_goodbyeMsg) == 20);
-	stream.read(_goodbyeMsg, 20);
+	assert(sizeof(_goodbyeMsg) >= _mt32LCDSize);
+	stream.read(_goodbyeMsg, _mt32LCDSize);
 
 	const uint8 volume = MIN<uint16>(stream.readUint16LE(), 100);
 	setMt32Volume(volume);
@@ -726,11 +736,13 @@ void MidiPlayer_Midi::readMt32Patch(const SciSpan<const byte> &data) {
 
 	// Send after-SysEx text
 	stream.seek(0);
-	sendMt32SysEx(0x200000, stream, 20);
+	sendMt32SysEx(0x200000, stream, _mt32LCDSize);
 
-	// Send the mystery SysEx
-	Common::MemoryReadStream mystery((const byte *)"\x16\x16\x16\x16\x16\x16", 6);
-	sendMt32SysEx(0x52000a, mystery, 6);
+	if (_mt32Type != kMt32TypeD110) {
+		// Send the mystery SysEx
+		Common::MemoryReadStream mystery((const byte *)"\x16\x16\x16\x16\x16\x16", 6);
+		sendMt32SysEx(0x52000a, mystery, 6);
+	}
 }
 
 void MidiPlayer_Midi::readMt32GmPatch(const SciSpan<const byte> &data) {
@@ -898,6 +910,142 @@ void MidiPlayer_Midi::readMt32DrvData() {
 	}
 }
 
+bool MidiPlayer_Midi::readD110DrvData() {
+	const char *fileName;
+
+	// Only one driver is known to exist
+	switch (g_sci->getGameId()) {
+	case GID_KQ4:
+		fileName = "DKQ4.DRV";
+		break;
+	default:
+		error("No D-110 driver is known to exist for this game");
+	}
+
+	Common::File f;
+	if (!f.open(fileName)) {
+		_missingFiles = fileName;
+		return false;
+	}
+
+	if (f.size() != 3500)
+		error("Unknown '%s' size (%d)", fileName, f.size());
+
+	f.seek(42);
+
+	// Send before-SysEx text
+	sendMt32SysEx(0x200000, f, 32);
+
+	// Timbres
+	f.seek(2761);
+	sendMt32SysEx(0x50000, f, 256);
+	sendMt32SysEx(0x50200, f, 128);
+
+	// Rhythm
+	sendMt32SysEx(0x30110, f, 256);
+	sendMt32SysEx(0x30310, f, 84);
+
+	f.seek(75);
+
+	// Send after-SysEx text
+	sendMt32SysEx(0x200000, f, 32);
+
+	f.read(_goodbyeMsg, 32);
+
+	byte reverbSysEx[13];
+	f.read(reverbSysEx, 13);
+	sysEx(reverbSysEx + 1, 11);
+
+	_hasReverb = false;
+
+	if (f.err() || f.eos())
+		error("Error reading '%s'", fileName);
+
+	f.close();
+
+	return true;
+}
+
+bool MidiPlayer_Midi::readD110SysEx() {
+	// These patches contain SysEx messages that were meant to be sent to the
+	// device with a 3rd party tool before starting the game with MT-32 music.
+	// In order to prevent the MT-32 patches from interfering with the
+	// D-110/D-10/D-20 patches, these SysEx use unit #18. The user would be
+	// required to change the unit number on their device. Since we can avoid
+	// sending the MT-32 patch, we override the unit number back to 17 here.
+
+	// The D-110 versions of these patches use Patch Memory at 0x060000,
+	// which is not available on the D-10/D-20. Additionally, this method
+	// requires user interaction on the device between SysEx upload and
+	// starting the game. We therefore use the D-20 patches instead.
+
+	// Patches for later games (using patch 4 format with GENMIDI.DRV) appear
+	// to have been distributed on the Sierra BBS in file GEND110.EXE. So far
+	// this file has not been recovered.
+
+	// Note: there was also aftermarket support for E-mu Proteus 1/2, but those
+	// files appear to have been lost in the mists of time as well.
+
+	const char *fileName;
+
+	switch (g_sci->getGameId()) {
+	case GID_KQ5:
+		fileName = "KQ5D20";
+		break;
+	case GID_QFG2:
+		fileName = "QFG2D20";
+		break;
+	default:
+		error("No aftermarket D-110 patch is known to exist for this game");
+	}
+
+	Common::File sysExFile;
+
+	if (!sysExFile.open(fileName)) {
+		_missingFiles = fileName;
+		return false;
+	}
+
+	byte sysExBuf[kMaxSysExSize + 2];
+
+	while (true) {
+		byte b = sysExFile.readByte();
+
+		if (sysExFile.err())
+			error("Error reading '%s'", fileName);
+
+		if (sysExFile.eos())
+			break;
+
+		if (b != 0xf0)
+			error("Unexpected data found in SysEx file '%s'", fileName);
+
+		uint sysExLen = 0;
+		sysExBuf[sysExLen++] = b;
+
+		while (sysExLen < ARRAYSIZE(sysExBuf) && b != 0xf7) {
+			b = sysExFile.readByte();
+			sysExBuf[sysExLen++] = b;
+		}
+
+		if (b != 0xf7 || sysExLen < 10)
+			error("SysEx has invalid size in SysEx file '%s'", fileName);
+
+		// Use unit #17
+		sysExBuf[2] = 0x10;
+		sysEx(sysExBuf + 1, sysExLen - 2);
+	}
+
+	// The D-10/D-20 have fixed MIDI channel assignments, so we need to set the D-110
+	// manually here
+	Common::MemoryReadStream s((const byte *)"\x01\x02\x03\x04\x05\x06\x07\x08\x09", 9);
+	sendMt32SysEx(0x10000d, s, 9);
+
+	memcpy(_goodbyeMsg, "    ScummVM                     ", 32);
+
+	return true;
+}
+
 byte MidiPlayer_Midi::lookupGmInstrument(const char *iname) {
 	int i = 0;
 
@@ -1120,7 +1268,30 @@ int MidiPlayer_Midi::open(ResourceManager *resMan) {
 		}
 	}
 
-	if (_mt32Type != kMt32TypeNone) {
+	if (_mt32Type == kMt32TypeD110) {
+		// D-110, no reset SysEx exists
+		for (uint i = 0; i < MIDI_CHANNELS; ++i) {
+			_driver->send(0xb0 | i, 0x7b, 0); // All notes off
+			_driver->send(0xb0 | i, 0x79, 0); // Reset all controllers
+		}
+
+		if (getSciVersion() == SCI_VERSION_0_EARLY) {
+			if (!readD110DrvData())
+				return MidiDriver::MERR_DEVICE_NOT_AVAILABLE;
+		} else if (getSciVersion() == SCI_VERSION_0_LATE) {
+			res = resMan->findResource(ResourceId(kResourceTypePatch, 0), false);
+
+			if (!res) {
+				_missingFiles = "PATCH.000";
+				return MidiDriver::MERR_DEVICE_NOT_AVAILABLE;
+			}
+
+			readMt32Patch(*res);
+		} else {
+			if (!readD110SysEx())
+				return MidiDriver::MERR_DEVICE_NOT_AVAILABLE;
+		}
+	} else if (_mt32Type != kMt32TypeNone) {
 		// MT-32
 		resetMt32();
 
@@ -1229,7 +1400,7 @@ int MidiPlayer_Midi::open(ResourceManager *resMan) {
 void MidiPlayer_Midi::close() {
 	if (_mt32Type != kMt32TypeNone) {
 		// Send goodbye message
-		sendMt32SysEx(0x200000, SciSpan<const byte>(_goodbyeMsg, 20), true);
+		sendMt32SysEx(0x200000, SciSpan<const byte>(_goodbyeMsg, _mt32LCDSize), true);
 	}
 
 	_driver->setTimerCallback(NULL, NULL);




More information about the Scummvm-git-logs mailing list