[Scummvm-cvs-logs] SF.net SVN: scummvm:[47335] scummvm/trunk/engines/sci/resource.cpp

waltervn at users.sourceforge.net waltervn at users.sourceforge.net
Sun Jan 17 03:13:40 CET 2010


Revision: 47335
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47335&view=rev
Author:   waltervn
Date:     2010-01-17 02:13:40 +0000 (Sun, 17 Jan 2010)

Log Message:
-----------
SCI: Cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/sci/resource.cpp

Modified: scummvm/trunk/engines/sci/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource.cpp	2010-01-16 21:36:08 UTC (rev 47334)
+++ scummvm/trunk/engines/sci/resource.cpp	2010-01-17 02:13:40 UTC (rev 47335)
@@ -2080,64 +2080,60 @@
 int SoundResource::getChannelFilterMask(int hardwareMask, bool wantsRhythm) {
 	byte *data = _innerResource->data;
 	int channelMask = 0;
-	int reverseHardwareMask = 0;
 
-	switch (_soundVersion) {
-	case SCI_VERSION_0_EARLY:
-		// TODO: MT32 driver uses no hardware mask at all and uses all channels
-		switch (hardwareMask) {
-		case 0x01: // AdLib needs an additional reverse check against bit 3
-			reverseHardwareMask = 0x08;
-			break;
-		}
-		data++; // Skip over digital sample flag
-		// Now all 16 channels follow. Each one is specified by a single byte
-		// Upper 4 bits of the byte is a voices count
-		// Lower 4 bits -> bit 0 means use as AdLib driver
-		//				   bit 1 means use as PCjr driver
-		//				   bit 3 means is control channel (bit 0 needs to be unset)
-		for (int channelNr = 0; channelNr < 16; channelNr++) {
-			channelMask = channelMask >> 1;
-			if (*data & hardwareMask) {
-				if ((reverseHardwareMask == 0) || ((*data & reverseHardwareMask) == 0)) {
-					// This Channel is supposed to get played for hardware
-					channelMask |= 0x8000;
-				}
-			}
-			if ((*data & 0x08) && ((*data & 0x01) == 0)) {
-				// This channel is control channel, so don't filter it
-				channelMask |= 0x8000;
-				// TODO: We need to accept this channel in parseNextEvent() for events
-			}
+	if (_soundVersion > SCI_VERSION_0_LATE)
+		return 0;
+
+	data++; // Skip over digital sample flag
+
+	for (int channelNr = 0; channelNr < 16; channelNr++) {
+		channelMask = channelMask >> 1;
+
+		byte flags;
+
+		if (_soundVersion == SCI_VERSION_0_EARLY) {
+			// Each channel is specified by a single byte
+			// Upper 4 bits of the byte is a voices count
+			// Lower 4 bits -> bit 0 set: use for AdLib
+			//				   bit 1 set: use for PCjr
+			//				   bit 2 set: use for PC speaker
+			//				   bit 3 set and bit 0 clear: control channel (15)
+			//				   bit 3 set and bit 0 set: rhythm channel (9)
+			flags = *data++;
+
+			// Get device bits
+			flags &= 0x7;
+		} else {
+			// Each channel is specified by 2 bytes
+			// 1st byte is voices count
+			// 2nd byte is play mask, which specifies if the channel is supposed to be played
+			// by the corresponding hardware
+
+			// Skip voice count
 			data++;
+
+			flags = *data++;
 		}
-		break;
 
-	case SCI_VERSION_0_LATE:
-		data++; // Skip over digital sample flag
-		// Now all 16 channels follow. Each one is specified by 2 bytes
-		// 1st byte is voices count
-		// 2nd byte is play mask, which specifies if the channel is supposed to be played
-		// by the corresponding hardware
-		for (int channelNr = 0; channelNr < 16; channelNr++) {
-			data++;
-			channelMask = channelMask >> 1;
-			if (*data & hardwareMask) {
-				// This Channel is supposed to be played by the hardware
-				channelMask |= 0x8000;
-			}
-			data++;
+		bool play;
+		switch (channelNr) {
+		case 15:
+			// Always play control channel
+			play = true;
+			break;
+		case 9:
+			// Play rhythm channel when requested
+			play = wantsRhythm;
+			break;
+		default:
+			// Otherwise check for flag
+			play = flags & hardwareMask;
 		}
-		// Play channel 15 at all times (control channel)
-		channelMask |= 0x8000;
 
-		channelMask &= ~(1 << 9);
-		if (wantsRhythm)
-			channelMask |= (1 << 9);
-
-		break;
-	default:
-		break;
+		if (play) {
+			// This Channel is supposed to be played by the hardware
+			channelMask |= 0x8000;
+		}
 	}
 
 	return channelMask;


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