[Scummvm-cvs-logs] CVS: scummvm/scumm imuse.cpp,1.15,1.16 resource.cpp,1.14,1.15

James Brown ender at users.sourceforge.net
Sun Sep 29 08:15:09 CEST 2002


Update of /cvsroot/scummvm/scummvm/scumm
In directory usw-pr-cvs1:/tmp/cvs-serv21576/scumm

Modified Files:
	imuse.cpp resource.cpp 
Log Message:
Patch #616155: Set Monkey1VGA music instruments dynamically


Index: imuse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- imuse.cpp	29 Sep 2002 11:11:42 -0000	1.15
+++ imuse.cpp	29 Sep 2002 15:14:54 -0000	1.16
@@ -3678,16 +3678,21 @@
 
 	port = channel_mappings[chan];
 	adlib_write(port + 0x20, instr->flags_1);
-	adlib_write(port + 0x40, (instr->oplvl_1 | 0x3F) - vol_1);
-	adlib_write(port + 0x60, ~instr->atdec_1);
-	adlib_write(port + 0x80, ~instr->sustrel_1);
+
+	if ((g_scumm->_gameId != GID_MONKEY_VGA) || (instr->feedback & 1))
+		adlib_write(port + 0x40, (instr->oplvl_1 | 0x3F) - vol_1 );
+	else
+		adlib_write(port + 0x40, instr->oplvl_1);
+
+	adlib_write(port + 0x60, 0xff & (~instr->atdec_1));
+	adlib_write(port + 0x80, 0xff & (~instr->sustrel_1));
 	adlib_write(port + 0xE0, instr->waveform_1);
 
 	port = channel_mappings_2[chan];
 	adlib_write(port + 0x20, instr->flags_2);
-	adlib_write(port + 0x40, (instr->oplvl_2 | 0x3F) - vol_2);
-	adlib_write(port + 0x60, ~instr->atdec_2);
-	adlib_write(port + 0x80, ~instr->sustrel_2);
+	adlib_write(port + 0x40, (instr->oplvl_2 | 0x3F) - vol_2 );
+	adlib_write(port + 0x60, 0xff & (~instr->atdec_2));
+	adlib_write(port + 0x80, 0xff & (~instr->sustrel_2));
 	adlib_write(port + 0xE0, instr->waveform_2);
 
 	adlib_write((byte)chan + 0xC0, instr->feedback);

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- resource.cpp	29 Sep 2002 11:11:42 -0000	1.14
+++ resource.cpp	29 Sep 2002 15:14:54 -0000	1.15
@@ -743,9 +743,9 @@
 					"\x00"                  // part/channel
 					"\x01\x06\x02\x0a\x08\x09\x0d\x08\x04\x04"
 					"\x04\x06\x02\x02\x03\x07\x0f\x0d"
-					"\x05\x04\x0c\x00\x03\x0a\x01\x00"
+					"\x05\x04\x0c\x00\x03\x01\x01\x00"
 					"\x00\x00\x01\x01\x0e\x00\x02\x02"
-					"\x01\x00\x01\x00\x01\x02\x00\x0a"
+					"\x01\x00\x01\x00\x01\x02\x00\x01"
 					"\x08\x00\x00\x00\x01\x02\x04\x00"
 					"\x06\x02\x00\x00\x04\x00\x03\x02"
 					"\x04\x00\x00\xf7"
@@ -758,9 +758,9 @@
 					"\x01"                  // part/channel
 					"\x01\x06\x02\x0a\x08\x09\x0d\x08\x04\x04"
 					"\x04\x06\x02\x02\x03\x07\x0f\x0d"
-					"\x05\x04\x0c\x00\x03\x0a\x01\x00"
+					"\x05\x04\x0c\x00\x03\x01\x01\x00"
 					"\x00\x00\x01\x01\x0e\x00\x02\x02"
-					"\x01\x00\x01\x00\x01\x02\x00\x0a"
+					"\x01\x00\x01\x00\x01\x02\x00\x01"
 					"\x08\x00\x00\x00\x01\x02\x04\x00"
 					"\x06\x02\x00\x00\x04\x00\x03\x02"
 					"\x04\x00\x00\xf7"
@@ -773,9 +773,9 @@
 					"\x02"                  // part/channel
 					"\x01\x06\x02\x0a\x08\x09\x0d\x08\x04\x04"
 					"\x04\x06\x02\x02\x03\x07\x0f\x0d"
-					"\x05\x04\x0c\x00\x03\x0a\x01\x00"
+					"\x05\x04\x0c\x00\x03\x01\x01\x00"
 					"\x00\x00\x01\x01\x0e\x00\x02\x02"
-					"\x01\x00\x01\x00\x01\x02\x00\x0a"
+					"\x01\x00\x01\x00\x01\x02\x00\x01"
 					"\x08\x00\x00\x00\x01\x02\x04\x00"
 					"\x06\x02\x00\x00\x04\x00\x03\x02"
 					"\x04\x00\x00\xf7"
@@ -788,9 +788,9 @@
 					"\x03"                  // part/channel
 					"\x01\x06\x02\x0a\x08\x09\x0d\x08\x04\x04"
 					"\x04\x06\x02\x02\x03\x07\x0f\x0d"
-					"\x05\x04\x0c\x00\x03\x0a\x01\x00"
+					"\x05\x04\x0c\x00\x03\x01\x01\x00"
 					"\x00\x00\x01\x01\x0e\x00\x02\x02"
-					"\x01\x00\x01\x00\x01\x02\x00\x0a"
+					"\x01\x00\x01\x00\x01\x02\x00\x01"
 					"\x08\x00\x00\x00\x01\x02\x04\x00"
 					"\x06\x02\x00\x00\x04\x00\x03\x02"
 					"\x04\x00\x00\xf7"
@@ -803,9 +803,9 @@
 					"\x04"                  // part/channel
 					"\x01\x06\x02\x0a\x08\x09\x0d\x08\x04\x04"
 					"\x04\x06\x02\x02\x03\x07\x0f\x0d"
-					"\x05\x04\x0c\x00\x03\x0a\x01\x00"
+					"\x05\x04\x0c\x00\x03\x01\x01\x00"
 					"\x00\x00\x01\x01\x0e\x00\x02\x02"
-					"\x01\x00\x01\x00\x01\x02\x00\x0a"
+					"\x01\x00\x01\x00\x01\x02\x00\x01"
 					"\x08\x00\x00\x00\x01\x02\x04\x00"
 					"\x06\x02\x00\x00\x04\x00\x03\x02"
 					"\x04\x00\x00\xf7"
@@ -818,9 +818,9 @@
 					"\x05"                  // part/channel
 					"\x01\x06\x02\x0a\x08\x09\x0d\x08\x04\x04"
 					"\x04\x06\x02\x02\x03\x07\x0f\x0d"
-					"\x05\x04\x0c\x00\x03\x0a\x01\x00"
+					"\x05\x04\x0c\x00\x03\x01\x01\x00"
 					"\x00\x00\x01\x01\x0e\x00\x02\x02"
-					"\x01\x00\x01\x00\x01\x02\x00\x0a"
+					"\x01\x00\x01\x00\x01\x02\x00\x01"
 					"\x08\x00\x00\x00\x01\x02\x04\x00"
 					"\x06\x02\x00\x00\x04\x00\x03\x02"
 					"\x04\x00\x00\xf7"
@@ -833,9 +833,9 @@
 					"\x06"                  // part/channel
 					"\x01\x06\x02\x0a\x08\x09\x0d\x08\x04\x04"
 					"\x04\x06\x02\x02\x03\x07\x0f\x0d"
-					"\x05\x04\x0c\x00\x03\x0a\x01\x00"
+					"\x05\x04\x0c\x00\x03\x01\x01\x00"
 					"\x00\x00\x01\x01\x0e\x00\x02\x02"
-					"\x01\x00\x01\x00\x01\x02\x00\x0a"
+					"\x01\x00\x01\x00\x01\x02\x00\x01"
 					"\x08\x00\x00\x00\x01\x02\x04\x00"
 					"\x06\x02\x00\x00\x04\x00\x03\x02"
 					"\x04\x00\x00\xf7"
@@ -848,140 +848,19 @@
 					"\x07"                  // part/channel
 					"\x01\x06\x02\x0a\x08\x09\x0d\x08\x04\x04"
 					"\x04\x06\x02\x02\x03\x07\x0f\x0d"
-					"\x05\x04\x0c\x00\x03\x0a\x01\x00"
-					"\x00\x00\x01\x01\x0e\x00\x02\x02"
-					"\x01\x00\x01\x00\x01\x02\x00\x0a"
-					"\x08\x00\x00\x00\x01\x02\x04\x00"
-					"\x06\x02\x00\x00\x04\x00\x03\x02"
-					"\x04\x00\x00\xf7"
-					"\x00\xb7\x07\x64"      // Controller 7 = 100
-					// 8
-					"\x00\xf0\x14\x7d\x00"  // sysex 00: part on/off
-					"\x08\x00\x03"          // part/channel
-					"\x00\x00\x07\x0f\x00\x00\x08\x00\x00\x00\x00\x02\x00\x00\xf7"
-					"\x04\xf0\x41\x7d\x10"  // sysex 16: set instrument
-					"\x08"                  // part/channel
-					"\x01\x06\x02\x0a\x08\x09\x0d\x08\x04\x04"
-					"\x04\x06\x02\x02\x03\x07\x0f\x0d"
-					"\x05\x04\x0c\x00\x03\x0a\x01\x00"
-					"\x00\x00\x01\x01\x0e\x00\x02\x02"
-					"\x01\x00\x01\x00\x01\x02\x00\x0a"
-					"\x08\x00\x00\x00\x01\x02\x04\x00"
-					"\x06\x02\x00\x00\x04\x00\x03\x02"
-					"\x04\x00\x00\xf7"
-					"\x00\xb8\x07\x64"      // Controller 7 = 100
-					// 9
-					"\x00\xf0\x14\x7d\x00"  // sysex 00: part on/off
-					"\x09\x00\x03"          // part/channel
-					"\x00\x00\x07\x0f\x00\x00\x08\x00\x00\x00\x00\x02\x00\x00\xf7"
-					"\x04\xf0\x41\x7d\x10"  // sysex 16: set instrument
-					"\x09"                  // part/channel
-					"\x01\x06\x02\x0a\x08\x09\x0d\x08\x04\x04"
-					"\x04\x06\x02\x02\x03\x07\x0f\x0d"
-					"\x05\x04\x0c\x00\x03\x0a\x01\x00"
-					"\x00\x00\x01\x01\x0e\x00\x02\x02"
-					"\x01\x00\x01\x00\x01\x02\x00\x0a"
-					"\x08\x00\x00\x00\x01\x02\x04\x00"
-					"\x06\x02\x00\x00\x04\x00\x03\x02"
-					"\x04\x00\x00\xf7"
-					"\x00\xb9\x07\x64"      // Controller 7 = 100
-					// Channels after 9 realy necessary ?!?
-					// A
-					"\x00\xf0\x14\x7d\x00"  // sysex 00: part on/off
-					"\x0A\x00\x03"          // part/channel
-					"\x00\x00\x07\x0f\x00\x00\x08\x00\x00\x00\x00\x02\x00\x00\xf7"
-					"\x04\xf0\x41\x7d\x10"  // sysex 16: set instrument
-					"\x0A"                  // part/channel
-					"\x01\x06\x02\x0a\x08\x09\x0d\x08\x04\x04"
-					"\x04\x06\x02\x02\x03\x07\x0f\x0d"
-					"\x05\x04\x0c\x00\x03\x0a\x01\x00"
-					"\x00\x00\x01\x01\x0e\x00\x02\x02"
-					"\x01\x00\x01\x00\x01\x02\x00\x0a"
-					"\x08\x00\x00\x00\x01\x02\x04\x00"
-					"\x06\x02\x00\x00\x04\x00\x03\x02"
-					"\x04\x00\x00\xf7"
-					"\x00\xbA\x07\x64"      // Controller 7 = 100
-					// B
-					"\x00\xf0\x14\x7d\x00"  // sysex 00: part on/off
-					"\x0B\x00\x03"          // part/channel
-					"\x00\x00\x07\x0f\x00\x00\x08\x00\x00\x00\x00\x02\x00\x00\xf7"
-					"\x04\xf0\x41\x7d\x10"  // sysex 16: set instrument
-					"\x0B"                  // part/channel
-					"\x01\x06\x02\x0a\x08\x09\x0d\x08\x04\x04"
-					"\x04\x06\x02\x02\x03\x07\x0f\x0d"
-					"\x05\x04\x0c\x00\x03\x0a\x01\x00"
-					"\x00\x00\x01\x01\x0e\x00\x02\x02"
-					"\x01\x00\x01\x00\x01\x02\x00\x0a"
-					"\x08\x00\x00\x00\x01\x02\x04\x00"
-					"\x06\x02\x00\x00\x04\x00\x03\x02"
-					"\x04\x00\x00\xf7"
-					"\x00\xbB\x07\x64"      // Controller 7 = 100
-					// C
-					"\x00\xf0\x14\x7d\x00"  // sysex 00: part on/off
-					"\x0C\x00\x03"          // part/channel
-					"\x00\x00\x07\x0f\x00\x00\x08\x00\x00\x00\x00\x02\x00\x00\xf7"
-					"\x04\xf0\x41\x7d\x10"  // sysex 16: set instrument
-					"\x0C"                  // part/channel
-					"\x01\x06\x02\x0a\x08\x09\x0d\x08\x04\x04"
-					"\x04\x06\x02\x02\x03\x07\x0f\x0d"
-					"\x05\x04\x0c\x00\x03\x0a\x01\x00"
-					"\x00\x00\x01\x01\x0e\x00\x02\x02"
-					"\x01\x00\x01\x00\x01\x02\x00\x0a"
-					"\x08\x00\x00\x00\x01\x02\x04\x00"
-					"\x06\x02\x00\x00\x04\x00\x03\x02"
-					"\x04\x00\x00\xf7"
-					"\x00\xbC\x07\x64"      // Controller 7 = 100
-					// D
-					"\x00\xf0\x14\x7d\x00"  // sysex 00: part on/off
-					"\x0D\x00\x03"          // part/channel
-					"\x00\x00\x07\x0f\x00\x00\x08\x00\x00\x00\x00\x02\x00\x00\xf7"
-					"\x04\xf0\x41\x7d\x10"  // sysex 16: set instrument
-					"\x0D"                  // part/channel
-					"\x01\x06\x02\x0a\x08\x09\x0d\x08\x04\x04"
-					"\x04\x06\x02\x02\x03\x07\x0f\x0d"
-					"\x05\x04\x0c\x00\x03\x0a\x01\x00"
-					"\x00\x00\x01\x01\x0e\x00\x02\x02"
-					"\x01\x00\x01\x00\x01\x02\x00\x0a"
-					"\x08\x00\x00\x00\x01\x02\x04\x00"
-					"\x06\x02\x00\x00\x04\x00\x03\x02"
-					"\x04\x00\x00\xf7"
-					"\x00\xbD\x07\x64"      // Controller 7 = 100
-					// E
-					"\x00\xf0\x14\x7d\x00"  // sysex 00: part on/off
-					"\x0E\x00\x03"          // part/channel
-					"\x00\x00\x07\x0f\x00\x00\x08\x00\x00\x00\x00\x02\x00\x00\xf7"
-					"\x04\xf0\x41\x7d\x10"  // sysex 16: set instrument
-					"\x0E"                  // part/channel
-					"\x01\x06\x02\x0a\x08\x09\x0d\x08\x04\x04"
-					"\x04\x06\x02\x02\x03\x07\x0f\x0d"
-					"\x05\x04\x0c\x00\x03\x0a\x01\x00"
-					"\x00\x00\x01\x01\x0e\x00\x02\x02"
-					"\x01\x00\x01\x00\x01\x02\x00\x0a"
-					"\x08\x00\x00\x00\x01\x02\x04\x00"
-					"\x06\x02\x00\x00\x04\x00\x03\x02"
-					"\x04\x00\x00\xf7"
-					"\x00\xbE\x07\x64"      // Controller 7 = 100
-					// F
-					"\x00\xf0\x14\x7d\x00"  // sysex 00: part on/off
-					"\x0F\x00\x03"          // part/channel
-					"\x00\x00\x07\x0f\x00\x00\x08\x00\x00\x00\x00\x02\x00\x00\xf7"
-					"\x04\xf0\x41\x7d\x10"  // sysex 16: set instrument
-					"\x0F"                  // part/channel
-					"\x01\x06\x02\x0a\x08\x09\x0d\x08\x04\x04"
-					"\x04\x06\x02\x02\x03\x07\x0f\x0d"
-					"\x05\x04\x0c\x00\x03\x0a\x01\x00"
+					"\x05\x04\x0c\x00\x03\x01\x01\x00"
 					"\x00\x00\x01\x01\x0e\x00\x02\x02"
-					"\x01\x00\x01\x00\x01\x02\x00\x0a"
+					"\x01\x00\x01\x00\x01\x02\x00\x01"
 					"\x08\x00\x00\x00\x01\x02\x04\x00"
 					"\x06\x02\x00\x00\x04\x00\x03\x02"
 					"\x04\x00\x00\xf7"
-					"\x00\xbF\x07\x64";      // Controller 7 = 100
+					"\x00\xb7\x07\x64";     // Controller 7 = 100
 
 int Scumm::readSoundResourceSmallHeader(int type, int idx)
 {
 	uint32 pos, total_size, size, dw, tag;
 	uint32 best_size = 0, best_offs = 0;
-	byte *ptr, *track;
+	byte *ptr, *track, *instr;
 	uint16 ticks, skip;
 
 	debug(4, "readSoundResourceSmallHeader(%s,%d)", resTypeFromId(type), idx);
@@ -1048,6 +927,11 @@
 		} else {
 			skip = 0x98;
 		}
+
+		/* copy the instrument data in another memory area */
+		instr = (byte *)calloc(8 * 16, 1);
+		memcpy(instr, ptr + 0x19, 8*16);
+
 		ptr  += skip;                     // size + instruments
 		size -= skip;		          // drop instruments for now
 		CHECK_HEAP 
@@ -1056,6 +940,7 @@
 			error("Out of memory while allocating %d", size);
 		}
 		memcpy(track, ptr, size);         // saving MIDI track data
+
 		nukeResource(type, idx);
 
 		total_size = 8 + 16 + 14 + 8 + 7 + sizeof(OLD256_MIDI_HACK) - 1 + size;
@@ -1090,6 +975,57 @@
 		*ptr++ = (byte)((dw >> 8) & 0xFF);
 		*ptr++ = (byte)(dw & 0xFF);
 		memcpy(ptr, OLD256_MIDI_HACK, sizeof(OLD256_MIDI_HACK) - 1);
+
+		/* now fill in the instruments */
+		for (int i = 0; i < 8; i++) {
+
+			/* flags_1 */
+			ptr[95 * i + 30 + 0] = (instr[i * 16 + 3] >> 4) & 0xf;
+			ptr[95 * i + 30 + 1] = instr[i * 16 + 3] & 0xf;
+
+			/* oplvl_1 */
+			ptr[95 * i + 30 + 2] = (instr[i * 16 + 4] >> 4) & 0xf;
+			ptr[95 * i + 30 + 3] = instr[i * 16 + 4] & 0xf;
+
+			/* atdec_1 */
+			ptr[95 * i + 30 + 4] = ((~instr[i * 16 + 5]) >> 4) & 0xf;
+			ptr[95 * i + 30 + 5] = (~instr[i * 16 + 5]) & 0xf;
+
+			/* sustrel_1 */
+			ptr[95 * i + 30 + 6] = ((~instr[i * 16 + 6]) >> 4) & 0xf;
+			ptr[95 * i + 30 + 7] = (~instr[i * 16 + 6]) & 0xf;
+
+			/* waveform_1 */
+			ptr[95 * i + 30 + 8] = (instr[i * 16 + 7] >> 4) & 0xf;
+			ptr[95 * i + 30 + 9] = instr[i * 16 + 7] & 0xf;
+
+			/* flags_2 */
+			ptr[95 * i + 30 + 10] = (instr[i * 16 + 8] >> 4) & 0xf;
+			ptr[95 * i + 30 + 11] = instr[i * 16 + 8] & 0xf;
+
+			/* oplvl_2 */
+			ptr[95 * i + 30 + 12] = 3;
+			ptr[95 * i + 30 + 13] = 0xF;
+
+			/* atdec_2 */
+			ptr[95 * i + 30 + 14] = ((~instr[i * 16 + 10]) >> 4) & 0xf;
+			ptr[95 * i + 30 + 15] = (~instr[i * 16 + 10]) & 0xf;
+
+			/* sustrel_2 */
+			ptr[95 * i + 30 + 16] = ((~instr[i * 16 + 11]) >> 4) & 0xf;
+			ptr[95 * i + 30 + 17] = (~instr[i * 16 + 11]) & 0xf;
+
+			/* waveform_2 */
+			ptr[95 * i + 30 + 18] = (instr[i * 16 + 12] >> 4) & 0xf;
+			ptr[95 * i + 30 + 19] = instr[i * 16 + 12] & 0xf;
+
+			/* feedback */
+			ptr[95 * i + 30 + 20] = (instr[i * 16 + 2] >> 4) & 0xf;
+			ptr[95 * i + 30 + 21] = instr[i * 16 + 2] & 0xf;
+		}
+
+		free(instr);
+
 		ptr += sizeof(OLD256_MIDI_HACK) - 1;
 		memcpy(ptr, track, size);
 		free(track);





More information about the Scummvm-git-logs mailing list