[Scummvm-cvs-logs] CVS: scummvm/scumm sound.cpp,1.279,1.280

Max Horn fingolfin at users.sourceforge.net
Sun Dec 14 02:52:05 CET 2003


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

Modified Files:
	sound.cpp 
Log Message:
* don't call a variable 'bit' which stores a byte'
* fix off-by-one loop length
* loopStart seems to be specified in samples, not bytes, fixing that (but I don't know of any place where I could test it...)
* Indy3Towns uses sound type 255, not 1, for Euphony music, it seems empirically
* print a warning if we encounter an unknown/unsupported sound sub-type


Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.279
retrieving revision 1.280
diff -u -d -r1.279 -r1.280
--- sound.cpp	10 Dec 2003 23:44:25 -0000	1.279
+++ sound.cpp	13 Dec 2003 20:01:35 -0000	1.280
@@ -283,22 +283,24 @@
 		_scumm->_mixer->playRaw(NULL, sound, size, rate, flags, soundID);
 	}
 	else if ((_scumm->_features & GF_FMTOWNS) || READ_UINT32(ptr) == MKID('SOUN') || READ_UINT32(ptr) == MKID('TOWS')) {
+
 		bool tows = READ_UINT32(ptr) == MKID('TOWS');
-		if (_scumm->_features & GF_FMTOWNS)
+		if (_scumm->_features & GF_FMTOWNS) {
 			size = READ_LE_UINT32(ptr);
-		else
-		{
+		} else {
 			size = READ_BE_UINT32(ptr + 4) - 2;
 			if (tows)
 				size += 8;
 			ptr += 2;
 		}
+
 		rate = 11025;
 		int type = *(ptr + 0x0D);
 		int numInstruments;
 
 		if (tows)
 			type = 0;
+
 		switch (type) {
 		case 0:	// Sound effect
 			numInstruments = *(ptr + 0x14);
@@ -306,12 +308,12 @@
 				numInstruments = 1;
 			ptr += 0x16;
 			size -= 0x16;
+
 			while (numInstruments--) {
 				int waveSize = READ_LE_UINT32(ptr + 0x0C);
-				int loopStart = READ_LE_UINT32(ptr + 0x10);
-				int loopEnd = READ_LE_UINT32(ptr + 0x14);
+				int loopStart = READ_LE_UINT32(ptr + 0x10) * 2;
+				int loopEnd = READ_LE_UINT32(ptr + 0x14) - 1;
 				rate = READ_LE_UINT32(ptr + 0x18) * 1000 / 0x62;
-
 				ptr += 0x20;
 				size -= 0x20;
 				if (size < waveSize) {
@@ -320,11 +322,11 @@
 				}
 				sound = (char *)malloc(waveSize);
 				for (int x = 0; x < waveSize; x++) {
-					int bit = *ptr++;
-					if (bit < 0x80)
-						sound[x] = 0x7F - bit;
+					int b = *ptr++;
+					if (b < 0x80)
+						sound[x] = 0x7F - b;
 					else
-						sound[x] = bit;
+						sound[x] = b;
 				}
 				size -= waveSize;
 
@@ -335,6 +337,7 @@
 			}
 			break;
 		case 1:
+		case 255:	// 255 is the type used in Indy3 FMTowns
 			// Music (Euphony format)
 			if (_scumm->_musicEngine)
 				_scumm->_musicEngine->startSound(soundID);
@@ -356,6 +359,9 @@
 			}
 
 			_currentCDSound = soundID;
+			break;
+		default: // Unsupported sound type
+			warning("Unsupported sound sub-type %d", type);
 			break;
 		}
 	}





More information about the Scummvm-git-logs mailing list