[Scummvm-cvs-logs] CVS: scummvm/simon midi.cpp,1.48,1.49 midi.h,1.20,1.21 simon.cpp,1.248,1.249

Jamieson Christian jamieson630 at users.sourceforge.net
Mon Jul 14 01:30:08 CEST 2003


Update of /cvsroot/scummvm/scummvm/simon
In directory sc8-pr-cvs1:/tmp/cvs-serv15742/scummvm/simon

Modified Files:
	midi.cpp midi.h simon.cpp 
Log Message:
Feature [770161] SIMON: Remap instruments to GM

Apparently Simon 1 (all versions) uses MT32 instruments,
so now we map them to GM *unless* the --native-mt32
option was specified.

Index: midi.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/midi.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- midi.cpp	25 May 2003 21:32:11 -0000	1.48
+++ midi.cpp	14 Jul 2003 08:29:17 -0000	1.49
@@ -34,6 +34,21 @@
 
 
 
+// Instrument mapping for MT32 tracks emulated under GM.
+static const byte mt32_to_gm[128] = {
+//    0    1    2    3    4    5    6    7    8    9    A    B    C    D    E    F
+	  0,   1,   0,   2,   4,   4,   5,   3,  16,  17,  18,  16,  16,  19,  20,  21, // 0x
+	  6,   6,   6,   7,   7,   7,   8, 112,  62,  62,  63,  63,  38,  38,  39,  39, // 1x
+	 88,  95,  52,  98,  97,  99,  14,  54, 102,  96,  53, 102,  81, 100,  14,  80, // 2x
+	 48,  48,  49,  45,  41,  40,  42,  42,  43,  46,  45,  24,  25,  28,  27, 104, // 3x
+	 32,  32,  34,  33,  36,  37,  35,  35,  79,  73,  72,  72,  74,  75,  64,  65, // 4x
+	 66,  67,  71,  71,  68,  69,  70,  22,  56,  59,  57,  57,  60,  60,  58,  61, // 5x
+	 61,  11,  11,  98,  14,   9,  14,  13,  12, 107, 107,  77,  78,  78,  76,  76, // 6x
+	 47, 117, 127, 118, 118, 116, 115, 119, 115, 112,  55, 124, 123,   0,  14, 117  // 7x
+};
+
+
+
 MidiPlayer::MidiPlayer (OSystem *system) {
 	// Since initialize() is called every time the music changes,
 	// this is where we'll initialize stuff that must persist
@@ -41,6 +56,7 @@
 	_system = system;
 	_mutex = system->create_mutex();
 	_driver = 0;
+	_map_mt32_to_gm = false;
 	
 	_enable_sfx = true;
 	_current = 0;
@@ -95,6 +111,8 @@
 		volume = (byte) ((b >> 16) & 0xFF) * _masterVolume / 255;
 		_volumeTable [b & 0xF] = volume;
 		b = (b & 0xFF00FFFF) | (volume << 16);
+	} else if ((b & 0xF0) == 0xC0 && _map_mt32_to_gm) {
+		b = (b & 0xFFFF00FF) | (mt32_to_gm [(b >> 8) & 0xFF] << 8);
 	} else if ((b & 0xFFF0) == 0x007BB0) {
 		// Only respond to an All Notes Off if this channel
 		// has already been allocated.
@@ -244,6 +262,12 @@
 	if (_driver)
 		return;
 	_driver = md;
+}
+
+void MidiPlayer::mapMT32toGM (bool map) {
+	_system->lock_mutex (_mutex);
+	_map_mt32_to_gm = map;
+	_system->unlock_mutex (_mutex);
 }
 
 void MidiPlayer::setLoop (bool loop) {

Index: midi.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/midi.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- midi.h	5 Jul 2003 15:19:11 -0000	1.20
+++ midi.h	14 Jul 2003 08:29:17 -0000	1.21
@@ -50,6 +50,7 @@
 	OSystem *_system;
 	OSystem::MutexRef _mutex;
 	MidiDriver *_driver;
+	bool _map_mt32_to_gm;
 
 	MusicInfo _music;
 	MusicInfo _sfx;
@@ -82,6 +83,7 @@
 	void loadXMIDI (File *in, bool sfx = false);
 	void loadS1D (File *in, bool sfx = false);
 
+	void mapMT32toGM (bool map);
 	void setLoop (bool loop);
 	void startTrack(int track);
 	void queueTrack (int track, bool loop);

Index: simon.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simon.cpp,v
retrieving revision 1.248
retrieving revision 1.249
diff -u -d -r1.248 -r1.249
--- simon.cpp	21 Jun 2003 15:53:27 -0000	1.248
+++ simon.cpp	14 Jul 2003 08:29:17 -0000	1.249
@@ -434,6 +434,7 @@
 	// Setup midi driver
 	if (!driver)
 		driver = MidiDriver_ADLIB_create();
+	midi.mapMT32toGM (!(_game & GF_SIMON2) && !detector->_native_mt32)
 	midi.set_driver(driver);
 	int ret = midi.open();
 	if (ret)





More information about the Scummvm-git-logs mailing list