[Scummvm-cvs-logs] CVS: scummvm/scumm sound.cpp,1.257,1.258 resource.cpp,1.160,1.161

Jamieson Christian jamieson630 at users.sourceforge.net
Tue Sep 30 10:54:08 CEST 2003


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

Modified Files:
	sound.cpp resource.cpp 
Log Message:
Support for FMTowns versions of MI1/2,
submitted by Hibernatus.

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.257
retrieving revision 1.258
diff -u -d -r1.257 -r1.258
--- sound.cpp	30 Sep 2003 16:45:50 -0000	1.257
+++ sound.cpp	30 Sep 2003 17:53:42 -0000	1.258
@@ -195,15 +195,6 @@
 		assert(_scumm->_musicEngine);
 		_scumm->_musicEngine->startSound(soundID);
 	}
-	else if (READ_UINT32(ptr) == MKID('SOUN')) {
-		ptr += 24;
-		int track = ptr[0];
-		int loops = ptr[1];
-		int start = (ptr[2] * 60 + ptr[3]) * 75 + ptr[4];
-		playCDTrack(track, loops == 0xff ? -1 : loops, start, 0);
-
-		_currentCDSound = soundID;
-	}
 	// Support for SFX in Monkey Island 1, Mac version
 	// This is rather hackish right now, but works OK. SFX are not sounding
 	// 100% correct, though, not sure right now what is causing this.
@@ -328,16 +319,28 @@
 		memcpy(sound, ptr + 33, size);
 		_scumm->_mixer->playRaw(NULL, sound, size, rate, flags, soundID);
 	}
-	else if (_scumm->_features & GF_FMTOWNS) {
-		size = READ_LE_UINT32(ptr);
+	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)
+			size = READ_LE_UINT32(ptr);
+		else
+		{
+			size = READ_BE_UINT32(ptr + 4) - 2;
+			if (tows)
+				size += 8;
+			ptr += 2;
+		}
 		rate = 11025;
 		int type = *(ptr + 0x0D);
-
 		int numInstruments;
 
-		switch(type) {
+		if (tows)
+			type = 0;
+		switch (type) {
 		case 0:	// Sound effect
 			numInstruments = *(ptr + 0x14);
+			if (tows)
+				numInstruments = 1;
 			ptr += 0x16;
 			size -= 0x16;
 			while (numInstruments--) {
@@ -372,7 +375,7 @@
 		case 1:
 			// Music (Euphony format)
 			if (_scumm->_musicEngine)
-				_scumm->_musicEngine->startSound (soundID);
+				_scumm->_musicEngine->startSound(soundID);
 			break;
 		case 2: // CD track resource
 			ptr += 0x16;
@@ -387,7 +390,7 @@
 				int start = (ptr[2] * 60 + ptr[3]) * 75 + ptr[4];
 				int end = (ptr[5] * 60 + ptr[6]) * 75 + ptr[7];
 
-				playCDTrack(track, loops == 0xff ? -1 : loops, start, end - start);
+				playCDTrack(track, loops == 0xff ? -1 : loops, start, end <= start ? 0 : end - start);
 			}
 
 			_currentCDSound = soundID;

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource.cpp,v
retrieving revision 1.160
retrieving revision 1.161
diff -u -d -r1.160 -r1.161
--- resource.cpp	14 Sep 2003 20:34:48 -0000	1.160
+++ resource.cpp	30 Sep 2003 17:53:42 -0000	1.161
@@ -666,8 +666,6 @@
 		}
 	} else {
 		if (type == rtSound) {
-			_fileHandle.readUint32LE();
-			_fileHandle.readUint32LE();
 			return readSoundResource(type, idx);
 		}
 
@@ -699,7 +697,7 @@
 }
 
 int Scumm::readSoundResource(int type, int idx) {
-	uint32 pos, total_size, size, tag, basetag;
+	uint32 pos, total_size, size, tag, basetag, max_total_size;
 	int pri, best_pri;
 	uint32 best_size = 0, best_offs = 0;
 
@@ -707,6 +705,8 @@
 
 	pos = 0;
 
+	_fileHandle.readUint32LE();
+	max_total_size = _fileHandle.readUint32BE() - 8;
 	basetag = fileReadDword();
 	total_size = _fileHandle.readUint32BE();
 
@@ -731,6 +731,9 @@
 			pri = -1;
 
 			switch (tag) {
+			case MKID('TOWS'):
+				pri = 16;
+				break;
 			case MKID('SBL '):
 				pri = 15;
 				break;
@@ -780,12 +783,6 @@
 			_fileHandle.read(createResource(type, idx, best_size), best_size);
 			return 1;
 		}
-	} else if (FROM_LE_32(basetag) == 24) {
-		_fileHandle.seek(-12, SEEK_CUR);
-		total_size = _fileHandle.readUint32BE();
-		_fileHandle.seek(-8, SEEK_CUR);
-		_fileHandle.read(createResource(type, idx, total_size), total_size);
-		return 1;
 	} else if (basetag == MKID('Mac0')) {
 		_fileHandle.seek(-12, SEEK_CUR);
 		total_size = _fileHandle.readUint32BE() - 8;
@@ -850,7 +847,12 @@
 		total_size = _fileHandle.readUint32BE();
 		_fileHandle.read(createResource(type, idx, total_size), total_size - 8);
 		return 1;
-		
+	} else if (FROM_LE_32(basetag) == max_total_size) {
+		_fileHandle.seek(-12, SEEK_CUR);
+		total_size = _fileHandle.readUint32BE();
+		_fileHandle.seek(-8, SEEK_CUR);
+		_fileHandle.read(createResource(type, idx, total_size), total_size);
+		return 1;
 	} else {
 		warning("Unrecognized base tag 0x%08x in sound %d", basetag, idx);
 	}





More information about the Scummvm-git-logs mailing list