[Scummvm-cvs-logs] CVS: scummvm/scumm resource.cpp,1.73,1.74 instrument.h,2.6,2.7 instrument.cpp,2.12,2.13

Jamieson Christian jamieson630 at users.sourceforge.net
Wed May 7 12:25:11 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv1820

Modified Files:
	resource.cpp instrument.h instrument.cpp 
Log Message:
..\..\msg.txt

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource.cpp,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- resource.cpp	3 May 2003 12:48:18 -0000	1.73
+++ resource.cpp	7 May 2003 19:24:14 -0000	1.74
@@ -724,8 +724,9 @@
 					pri = 2;
 				break;
 			case MKID('SPK '):
-				if (!_use_adlib)
-					pri = 0;
+				pri = -1;
+//				if (!_use_adlib)
+//					pri = 0;
 				break;
 			}
 

Index: instrument.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/instrument.h,v
retrieving revision 2.6
retrieving revision 2.7
diff -u -d -r2.6 -r2.7
--- instrument.h	6 Mar 2003 21:46:03 -0000	2.6
+++ instrument.h	7 May 2003 19:24:14 -0000	2.7
@@ -34,6 +34,7 @@
 	virtual void saveOrLoad (Serializer *s) = 0;
 	virtual void send (MidiChannel *mc) = 0;
 	virtual void copy_to (Instrument *dest) = 0;
+	virtual bool is_valid() = 0;
 };
 
 class Instrument {
@@ -58,6 +59,7 @@
 	void roland (byte *instrument);
 
 	byte getType() { return _type; }
+	bool isValid() { return (_instrument ? _instrument->is_valid() : false); }
 	void saveOrLoad (Serializer *s);
 	void send (MidiChannel *mc) { if (_instrument) _instrument->send (mc); }
 };

Index: instrument.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/instrument.cpp,v
retrieving revision 2.12
retrieving revision 2.13
diff -u -d -r2.12 -r2.13
--- instrument.cpp	6 Mar 2003 21:46:02 -0000	2.12
+++ instrument.cpp	7 May 2003 19:24:14 -0000	2.13
@@ -135,6 +135,7 @@
 	void saveOrLoad (Serializer *s);
 	void send (MidiChannel *mc);
 	void copy_to (Instrument *dest) { dest->program (_program, _mt32); }
+	bool is_valid() { return (_program < 128); }
 };
 
 class Instrument_Adlib : public InstrumentInternal {
@@ -164,6 +165,7 @@
 	void saveOrLoad (Serializer *s);
 	void send (MidiChannel *mc);
 	void copy_to (Instrument *dest) { dest->adlib ((byte *) &_instrument); }
+	bool is_valid() { return true; }
 };
 
 class Instrument_Roland : public InstrumentInternal {
@@ -228,12 +230,15 @@
 
 	char _instrument_name [11];
 
+	uint8 getEquivalentGM();
+
 public:
 	Instrument_Roland (byte *data);
 	Instrument_Roland (Serializer *s);
 	void saveOrLoad (Serializer *s);
 	void send (MidiChannel *mc);
 	void copy_to (Instrument *dest) { dest->roland ((byte *) &_instrument); }
+	bool is_valid() { return (NATIVE_MT32 ? true : (_instrument_name[0] != '\0')); }
 };
 
 ////////////////////////////////////////
@@ -377,6 +382,10 @@
 	memcpy (&_instrument, data, sizeof (_instrument));
 	memcpy (&_instrument_name, &_instrument.common.name, sizeof (_instrument.common.name));
 	_instrument_name[10] = '\0';
+	if (!NATIVE_MT32 && getEquivalentGM() >= 128) {
+		warning ("MT-32 instrument \"%s\" not supported yet", _instrument_name);
+		_instrument_name[0] = '\0';
+	}
 }
 
 Instrument_Roland::Instrument_Roland (Serializer *s) {
@@ -388,12 +397,17 @@
 }
 
 void Instrument_Roland::saveOrLoad (Serializer *s) {
-	if (s->isSaving())
+	if (s->isSaving()) {
 		s->saveBytes (&_instrument, sizeof (_instrument));
-	else
+	} else {
 		s->loadBytes (&_instrument, sizeof (_instrument));
-	memcpy (&_instrument_name, &_instrument.common.name, sizeof (_instrument.common.name));
-	_instrument_name[10] = '\0';
+		memcpy (&_instrument_name, &_instrument.common.name, sizeof (_instrument.common.name));
+		_instrument_name[10] = '\0';
+		if (!NATIVE_MT32 && getEquivalentGM() >= 128) {
+			warning ("MT-32 instrument \"%s\" not supported yet", _instrument_name);
+			_instrument_name[0] = '\0';
+		}
+	} // end if
 }
 
 void Instrument_Roland::send (MidiChannel *mc) {
@@ -402,14 +416,17 @@
 		mc->device()->sysEx ((byte *) &_instrument, sizeof (_instrument));
 	} else {
 		// Convert to a GM program change.
-		byte i;
-		for (i = 0; i != ARRAYSIZE(roland_to_gm_map); ++i) {
-			if (!memcmp (roland_to_gm_map[i].name, _instrument.common.name, 10)) {
-				mc->programChange (roland_to_gm_map[i].program);
-				return;
-			}
-		}
-		warning ("MT-32 instrument \"%s\" not supported yet", _instrument_name);
-		mc->programChange (0);
+		byte program = getEquivalentGM();
+		if (program < 128)
+			mc->programChange (program);
+	}
+}
+
+uint8 Instrument_Roland::getEquivalentGM() {
+	byte i;
+	for (i = 0; i != ARRAYSIZE(roland_to_gm_map); ++i) {
+		if (!memcmp (roland_to_gm_map[i].name, _instrument.common.name, 10))
+			return roland_to_gm_map[i].program;
 	}
+	return 255;
 }





More information about the Scummvm-git-logs mailing list