[Scummvm-cvs-logs] CVS: scummvm/scumm/imuse_digi dimuse.cpp,1.16,1.17 dimuse_bndmgr.cpp,1.12,1.13 dimuse_bndmgr.h,1.4,1.5 dimuse_sndmgr.cpp,1.14,1.15

Jonathan Gray khalek at users.sourceforge.net
Fri Jan 9 05:17:01 CET 2004


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

Modified Files:
	dimuse.cpp dimuse_bndmgr.cpp dimuse_bndmgr.h dimuse_sndmgr.cpp 
Log Message:
commit on aquadran's behalf that fixes music distortion

Index: dimuse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi/dimuse.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- dimuse.cpp	8 Jan 2004 20:37:26 -0000	1.16
+++ dimuse.cpp	9 Jan 2004 13:16:06 -0000	1.17
@@ -154,6 +154,10 @@
 						if (_sound->getChannels(_track[l].soundHandle) == 1) {
 							result &= ~1;
 						}
+						if (_sound->getChannels(_track[l].soundHandle) == 2) {
+							if (result & 2)
+								result &= ~2;
+						}
 					} else if (bits == 8) {
 						result = _sound->getDataFromRegion(_track[l].soundHandle, _track[l].curRegion, &data, _track[l].regionOffset, mixer_size);
 						if (_sound->getChannels(_track[l].soundHandle) == 2) {
@@ -194,6 +198,11 @@
 		return;
 	}
 
+				if (_track[track].idSound == 2312) {
+					_track[track].curRegion = 4;
+					_track[track].regionOffset = 0;
+					return;
+				}
 	if (++_track[track].curRegion == num_regions) {
 		_track[track].toBeRemoved = true;
 		return;

Index: dimuse_bndmgr.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi/dimuse_bndmgr.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- dimuse_bndmgr.cpp	8 Jan 2004 23:22:51 -0000	1.12
+++ dimuse_bndmgr.cpp	9 Jan 2004 13:16:06 -0000	1.13
@@ -159,13 +159,14 @@
 	}
 }
 
-int32 BundleMgr::decompressSampleByCurIndex(int32 offset, int32 size, byte **comp_final, int header_size) {
-	return decompressSampleByIndex(_curSample, offset, size, comp_final, header_size);
+int32 BundleMgr::decompressSampleByCurIndex(int32 offset, int32 size, byte **comp_final, int header_size, bool header_outside) {
+	return decompressSampleByIndex(_curSample, offset, size, comp_final, header_size, header_outside);
 }
 
-int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size, byte **comp_final, int header_size) {
+int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size, byte **comp_final, int header_size, bool header_outside) {
 	int32 i, tag, num, final_size, output_size;
 	byte *comp_input, *comp_output;
+	int skip, first_block, last_block;
 	
 	if (index != -1)
 		_curSample = index;
@@ -197,14 +198,24 @@
 		_compTableLoaded = true;
 	}
 
-	int first_block = (offset + header_size) / 0x2000;
-	int last_block = (offset + size + header_size - 1) / 0x2000;
+	if (header_outside) {
+		first_block = offset / 0x2000;
+		last_block = (offset + size - 1) / 0x2000;
+	} else {
+		first_block = (offset + header_size) / 0x2000;
+		last_block = (offset + size + header_size - 1) / 0x2000;
+	}
 
 	comp_output = (byte *)malloc(0x2000);
-	*comp_final = (byte *)malloc(0x2000 * (1 + last_block - first_block));
+	int32 blocks_final_size = 0x2000 * (1 + last_block - first_block);
+	*comp_final = (byte *)malloc(blocks_final_size);
 	final_size = 0;
 
-	int skip = offset - (first_block * 0x2000) + header_size;
+	if (header_outside) {
+		skip = offset - (first_block * 0x2000);
+	} else {
+		skip = offset - (first_block * 0x2000) + header_size;
+	}
 
 	for (i = first_block; i <= last_block; i++) {
 		byte *curBuf;
@@ -227,11 +238,21 @@
 			curBuf = _blockChache;
 		}
 
-		if ((header_size != 0) && (skip >= header_size))
+		if (header_outside) {
+			if ((header_size != 0) && (i == 0))
+				skip += header_size;
 			output_size -= skip;
+		} else {
+			if ((header_size != 0) && (skip >= header_size))
+				output_size -= skip;
+		}
+
 		if (output_size > size)
 			output_size = size;
 
+		if (final_size + output_size > blocks_final_size)
+			error("");
+
 		memcpy(*comp_final + final_size, curBuf + skip, output_size);
 
 		final_size += output_size;
@@ -246,7 +267,7 @@
 	return final_size;
 }
 
-int32 BundleMgr::decompressSampleByName(const char *name, int32 offset, int32 size, byte **comp_final) {
+int32 BundleMgr::decompressSampleByName(const char *name, int32 offset, int32 size, byte **comp_final, bool header_outside) {
 	int32 final_size = 0, i;
 
 	if (!_file.isOpen()) {
@@ -256,7 +277,7 @@
 
 	for (i = 0; i < _numFiles; i++) {
 		if (!scumm_stricmp(name, _bundleTable[i].filename)) {
-			final_size = decompressSampleByIndex(i, offset, size, comp_final, 0);
+			final_size = decompressSampleByIndex(i, offset, size, comp_final, 0, header_outside);
 			return final_size;
 		}
 	}

Index: dimuse_bndmgr.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi/dimuse_bndmgr.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- dimuse_bndmgr.h	8 Jan 2004 12:14:48 -0000	1.4
+++ dimuse_bndmgr.h	9 Jan 2004 13:16:06 -0000	1.5
@@ -79,9 +79,9 @@
 
 	bool openFile(const char *filename, const char *directory);
 	void closeFile();
-	int32 decompressSampleByName(const char *name, int32 offset, int32 size, byte **comp_final);
-	int32 decompressSampleByIndex(int32 index, int32 offset, int32 size, byte **comp_final, int header_size);
-	int32 decompressSampleByCurIndex(int32 offset, int32 size, byte **comp_final, int header_size);
+	int32 decompressSampleByName(const char *name, int32 offset, int32 size, byte **comp_final, bool header_outside);
+	int32 decompressSampleByIndex(int32 index, int32 offset, int32 size, byte **comp_final, int header_size, bool header_outside);
+	int32 decompressSampleByCurIndex(int32 offset, int32 size, byte **comp_final, int header_size, bool header_outside);
 };
 
 namespace BundleCodecs {

Index: dimuse_sndmgr.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi/dimuse_sndmgr.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- dimuse_sndmgr.cpp	8 Jan 2004 22:54:06 -0000	1.14
+++ dimuse_sndmgr.cpp	9 Jan 2004 13:16:06 -0000	1.15
@@ -219,13 +219,14 @@
 			_sounds[slot].resPtr = ptr;
 			result = true;
 		} else if (soundType == IMUSE_BUNDLE) {
+			bool header_outside = _vm->_gameId != GID_DIG;
 			if (soundGroup == IMUSE_VOICE)
 				result = openVoiceBundle(slot);
 			else if (soundGroup == IMUSE_MUSIC)
 				result = openMusicBundle(slot);
 			else 
 				error("ImuseDigiSndMgr::openSound() Don't know how load sound: %d", soundId);
-			_sounds[slot]._bundle->decompressSampleByIndex(soundId, 0, 0x2000, &ptr, 0);
+			_sounds[slot]._bundle->decompressSampleByIndex(soundId, 0, 0x2000, &ptr, 0, header_outside);
 			_sounds[slot].name[0] = 0;
 			_sounds[slot].soundId = soundId;
 		} else {
@@ -233,13 +234,14 @@
 		}
 	} else if (soundName != NULL) {
 		if (soundType == IMUSE_BUNDLE) {
+			bool header_outside = _vm->_gameId != GID_DIG;
 			if (soundGroup == IMUSE_VOICE)
 				result = openVoiceBundle(slot);
 			else if (soundGroup == IMUSE_MUSIC)
 				result = openMusicBundle(slot);
 			else
 				error("ImuseDigiSndMgr::openSound() Don't know how load sound: %d", soundId);
-			_sounds[slot]._bundle->decompressSampleByName(soundName, 0, 0x2000, &ptr);
+			_sounds[slot]._bundle->decompressSampleByName(soundName, 0, 0x2000, &ptr, header_outside);
 			strcpy(_sounds[slot].name, soundName);
 			_sounds[slot].soundId = soundId;
 		} else {
@@ -394,9 +396,9 @@
 	}
 
 	int header_size = soundHandle->offsetData;
-
+	bool header_outside = _vm->_gameId != GID_DIG;
 	if (soundHandle->_bundle) {
-		size = soundHandle->_bundle->decompressSampleByCurIndex(start + offset, size, buf, header_size);
+		size = soundHandle->_bundle->decompressSampleByCurIndex(start + offset, size, buf, header_size, header_outside);
 	} else if (soundHandle->resPtr) {
 		*buf = (byte *)malloc(size);
 		memcpy(*buf, soundHandle->resPtr + start + offset + header_size, size);





More information about the Scummvm-git-logs mailing list