aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/touche/midi.cpp9
-rw-r--r--engines/touche/midi.h5
-rw-r--r--engines/touche/staticres.cpp11
-rw-r--r--engines/touche/touche.cpp3
4 files changed, 24 insertions, 4 deletions
diff --git a/engines/touche/midi.cpp b/engines/touche/midi.cpp
index 29e68a4562..b90d4082c5 100644
--- a/engines/touche/midi.cpp
+++ b/engines/touche/midi.cpp
@@ -32,8 +32,8 @@
namespace Touche {
-MidiPlayer::MidiPlayer(MidiDriver *driver)
- : _driver(driver), _parser(0), _midiData(0), _isLooping(false), _isPlaying(false), _masterVolume(0) {
+MidiPlayer::MidiPlayer(MidiDriver *driver, bool nativeMT32)
+ : _driver(driver), _parser(0), _midiData(0), _isLooping(false), _isPlaying(false), _masterVolume(0), _nativeMT32(nativeMT32) {
assert(_driver);
memset(_channelsTable, 0, sizeof(_channelsTable));
memset(_channelsVolume, 0, sizeof(_channelsVolume));
@@ -129,6 +129,11 @@ void MidiPlayer::send(uint32 b) {
return;
}
break;
+ default:
+ if ((b & 0xF0) == 0xC0 && _nativeMT32) { // program change
+ b = (b & 0xFFFF00FF) | (_gmToRol[(b >> 8) & 0x7F] << 8);
+ }
+ break;
}
if (!_channelsTable[ch]) {
_channelsTable[ch] = (ch == 9) ? _driver->getPercussionChannel() : _driver->allocateChannel();
diff --git a/engines/touche/midi.h b/engines/touche/midi.h
index 808ecfb205..3b128593db 100644
--- a/engines/touche/midi.h
+++ b/engines/touche/midi.h
@@ -46,7 +46,7 @@ public:
NUM_CHANNELS = 16
};
- MidiPlayer(MidiDriver *driver);
+ MidiPlayer(MidiDriver *driver, bool nativeMT32);
~MidiPlayer();
void play(Common::ReadStream &stream, int size, bool loop = false);
@@ -77,9 +77,12 @@ private:
bool _isLooping;
bool _isPlaying;
int _masterVolume;
+ bool _nativeMT32;
MidiChannel *_channelsTable[NUM_CHANNELS];
uint8 _channelsVolume[NUM_CHANNELS];
Common::Mutex _mutex;
+
+ static const uint8 _gmToRol[];
};
} // namespace Touche
diff --git a/engines/touche/staticres.cpp b/engines/touche/staticres.cpp
index 4c3ea4855f..eb3ddc15ff 100644
--- a/engines/touche/staticres.cpp
+++ b/engines/touche/staticres.cpp
@@ -27,6 +27,7 @@
#include "touche/graphics.h"
#include "touche/touche.h"
+#include "touche/midi.h"
namespace Touche {
@@ -1332,5 +1333,15 @@ int Graphics::_fontSize = Graphics::_engFontSize;
const uint8 *Graphics::_fontData = Graphics::_engFontData;
+const uint8 MidiPlayer::_gmToRol[] = {
+ 0x01, 0x02, 0x03, 0x08, 0x04, 0x05, 0x11, 0x14, 0x66, 0x66, 0x66, 0x62, 0x69, 0x68, 0x67, 0x26,
+ 0x09, 0x0A, 0x0B, 0x0E, 0x0F, 0x10, 0x10, 0x10, 0x3C, 0x3D, 0x3D, 0x3D, 0x3D, 0x3E, 0x3F, 0x3F,
+ 0x47, 0x41, 0x42, 0x48, 0x45, 0x46, 0x1D, 0x1E, 0x35, 0x36, 0x37, 0x39, 0x33, 0x34, 0x3A, 0x71,
+ 0x31, 0x32, 0x31, 0x32, 0x23, 0x23, 0x23, 0x7B, 0x59, 0x5B, 0x5F, 0x5A, 0x5D, 0x60, 0x19, 0x1A,
+ 0x4F, 0x50, 0x51, 0x52, 0x55, 0x56, 0x57, 0x53, 0x4B, 0x49, 0x4D, 0x4E, 0x6F, 0x6C, 0x6D, 0x6E,
+ 0x30, 0x19, 0x4E, 0x2B, 0x28, 0x23, 0x19, 0x30, 0x21, 0x25, 0x1C, 0x21, 0x24, 0x22, 0x21, 0x22,
+ 0x2A, 0x25, 0x24, 0x26, 0x2E, 0x22, 0x29, 0x21, 0x40, 0x40, 0x6A, 0x6A, 0x68, 0x10, 0x35, 0x10,
+ 0x7F, 0x6B, 0x69, 0x75, 0x76, 0x72, 0x74, 0x01, 0x01, 0x70, 0x01, 0x7D, 0x7C, 0x01, 0x01, 0x01
+};
} // namespace Touche
diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp
index 086671d371..c67b1e9be3 100644
--- a/engines/touche/touche.cpp
+++ b/engines/touche/touche.cpp
@@ -97,8 +97,9 @@ int ToucheEngine::init() {
setupOpcodes();
int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI);
+ bool native_mt32 = ((midiDriver == MD_MT32) || ConfMan.getBool("native_mt32"));
MidiDriver *driver = MidiDriver::createMidi(midiDriver);
- _midiPlayer = new MidiPlayer(driver);
+ _midiPlayer = new MidiPlayer(driver, native_mt32);
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume"));