[Scummvm-cvs-logs] SF.net SVN: scummvm:[47304] scummvm/trunk/engines/sci/sound

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Fri Jan 15 08:40:08 CET 2010


Revision: 47304
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47304&view=rev
Author:   thebluegr
Date:     2010-01-15 07:40:07 +0000 (Fri, 15 Jan 2010)

Log Message:
-----------
When unloading a song, only reset the channels that it actually used, not all channels

Modified Paths:
--------------
    scummvm/trunk/engines/sci/sound/midiparser_sci.cpp
    scummvm/trunk/engines/sci/sound/midiparser_sci.h

Modified: scummvm/trunk/engines/sci/sound/midiparser_sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/midiparser_sci.cpp	2010-01-15 03:59:45 UTC (rev 47303)
+++ scummvm/trunk/engines/sci/sound/midiparser_sci.cpp	2010-01-15 07:40:07 UTC (rev 47304)
@@ -80,6 +80,8 @@
 	_tracks[0] = _mixedData;
 	setTrack(0);
 	_loopTick = 0;
+	_channelsUsed = 0;
+
 	return true;
 }
 
@@ -95,17 +97,20 @@
 	}
 
 	// Center the pitch wheels and hold pedal in preparation for the next piece of music
-	// TODO: We should monitor what channels are used by each song, and only
-	// reset these channels, not all of them!
 	if (_driver) {
 		for (int i = 0; i < 16; ++i) {
-			_driver->send(0xE0 | i, 0, 0x40);	// Reset pitch wheel
-			_driver->send(0xB0 | i, 0x40, 0);	// Reset hold pedal
+			if (_channelsUsed & (1 << i)) {
+				_driver->send(0xE0 | i, 0, 0x40);	// Reset pitch wheel
+				_driver->send(0xB0 | i, 0x40, 0);	// Reset hold pedal
+			}
 		}
 	}
 }
 
 void MidiParser_SCI::parseNextEvent(EventInfo &info) {
+	// Monitor which channels are used by this song
+	_channelsUsed |= (1 << info.channel());
+
 	// Set signal AFTER waiting for delta, otherwise we would set signal too soon resulting in all sorts of bugs
 	if (_signalSet) {
 		_signalSet = false;
@@ -186,7 +191,7 @@
 			case 0x46: // LSL3 - binoculars
 			case 0x61: // Iceman (Adlib?)
 			case 0x73: // Hoyle
-			case 0xd1: // KQ4, when riding the unicorn
+			case 0xD1: // KQ4, when riding the unicorn
 				// Obscure SCI commands - ignored
 				break;
 			// Standard MIDI commands

Modified: scummvm/trunk/engines/sci/sound/midiparser_sci.h
===================================================================
--- scummvm/trunk/engines/sci/sound/midiparser_sci.h	2010-01-15 03:59:45 UTC (rev 47303)
+++ scummvm/trunk/engines/sci/sound/midiparser_sci.h	2010-01-15 07:40:07 UTC (rev 47304)
@@ -84,6 +84,10 @@
 
 	bool _signalSet;
 	int16 _signalToSet;
+
+	// A 16-bit mask, containing the channels used
+	// by the currently parsed song
+	uint16 _channelsUsed;
 };
 
 } // End of namespace Sci


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list