[Scummvm-cvs-logs] CVS: scummvm/scumm imuse_digi.cpp,1.4,1.5 sound.cpp,1.65,1.66 sound.h,1.22,1.23

Pawel Kolodziejski aquadran at users.sourceforge.net
Sat Dec 28 17:29:03 CET 2002


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

Modified Files:
	imuse_digi.cpp sound.cpp sound.h 
Log Message:
fixed play CMI music

Index: imuse_digi.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- imuse_digi.cpp	28 Dec 2002 21:48:19 -0000	1.4
+++ imuse_digi.cpp	29 Dec 2002 01:28:44 -0000	1.5
@@ -1066,7 +1066,7 @@
 					if ((_comiStateMusicTable[l].index == b)) {
 						debug(2, "Play imuse music: %s, %s, %s", _comiStateMusicTable[l].name, _comiStateMusicTable[l].title, _comiStateMusicTable[l].filename);
 						if (_comiStateMusicTable[l].filename[0] != 0) {
-//							_scumm->_sound->playBundleMusic((char*)&_comiStateMusicTable[l].filename);
+							_scumm->_sound->playBundleMusic((char*)&_comiStateMusicTable[l].filename);
 						}
 						return 0;
 					}
@@ -1113,7 +1113,7 @@
 					if ((_comiSeqMusicTable[l].index == b)) {
 						debug(2, "Play imuse music: %s, %s, %s", _comiSeqMusicTable[l].name, _comiSeqMusicTable[l].title, _comiSeqMusicTable[l].filename);
 						if (_comiSeqMusicTable[l].filename[0] != 0) {
-//							_scumm->_sound->playBundleMusic((char*)&_comiSeqMusicTable[l].filename);
+							_scumm->_sound->playBundleMusic((char*)&_comiSeqMusicTable[l].filename);
 						}
 						return 0;
 					}

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- sound.cpp	28 Dec 2002 21:55:32 -0000	1.65
+++ sound.cpp	29 Dec 2002 01:28:44 -0000	1.66
@@ -951,8 +951,6 @@
 	g_scumm->_sound->bundleMusicHandler(g_scumm);
 }
 
-#define OUTPUT_SIZE 66150 // ((22050 * 2 * 2) / 4) * 3
-
 void Sound::playBundleMusic(char * song) {
 
 	if (_scumm->_silentDigitalImuse == true) {
@@ -961,16 +959,18 @@
 
 	if (_nameBundleMusic == NULL) {
 		// FIXME: we have MUSDISK1.BUN and MUSDISK2.BUN in COMI.
+		_outputMixerSize = 66150; // ((22050 * 2 * 2) / 4) * 3
 		if (_scumm->_gameId == GID_CMI) {
 			printf("Opening bundle\n");
 			if (_scumm->_bundle->openMusicFile("musdisk1.bun", _scumm->getGameDataPath()) == false)
 				return;
+			_outputMixerSize = 88140; // ((22050 * 2 * 2)
 		} else {
 			if (_scumm->_bundle->openMusicFile("digmusic.bun", _scumm->getGameDataPath()) == false)
 				return;
 		}
-		_musicBundleBufFinal = (byte*)malloc(OUTPUT_SIZE);
-		_musicBundleBufOutput = (byte*)malloc(10 * 0x2000);
+		_musicBundleBufFinal = (byte*)malloc(_outputMixerSize);
+		_musicBundleBufOutput = (byte*)malloc(((_outputMixerSize / 0x2000) + 1) * _outputMixerSize);
 		_currentSampleBundleMusic = 0;
 		_offsetSampleBundleMusic = 0;
 		_offsetBufBundleMusic = 0;
@@ -1001,7 +1001,7 @@
 void Sound::bundleMusicHandler(Scumm * scumm) {
 	byte * ptr;
 	int32 l, num = _numberSamplesBundleMusic, length, k;
-	int32 rate = 22050, channels;
+	int32 rate = 22050;
 	int32 tag, size = -1, header_size = 0;
 	
 	if (_pauseBundleMusic)
@@ -1037,7 +1037,7 @@
 	ptr = _musicBundleBufOutput;
 
 	for (k = 0, l = _currentSampleBundleMusic; l < num; k++) {
-		length = _scumm->_bundle->decompressMusicSampleByName(_nameBundleMusic, l, (_musicBundleBufOutput + ((k * 0x2000) + _offsetBufBundleMusic)), channels);
+		length = _scumm->_bundle->decompressMusicSampleByName(_nameBundleMusic, l, (_musicBundleBufOutput + ((k * 0x2000) + _offsetBufBundleMusic)), _bundleSampleChannels);
 		_offsetSampleBundleMusic += length;
 
 		if (l == 0) {
@@ -1056,7 +1056,7 @@
 					ptr += 12;
 					_bundleMusicSampleBits = READ_BE_UINT32(ptr); ptr += 4;
 					rate = READ_BE_UINT32(ptr); ptr += 4;
-					channels = READ_BE_UINT32(ptr); ptr += 4;
+					_bundleSampleChannels = READ_BE_UINT32(ptr); ptr += 4;
 				break;
 				case MKID_BE('TEXT'):
 				case MKID_BE('REGN'):
@@ -1083,10 +1083,10 @@
 		l++;
 		_currentSampleBundleMusic = l;
 
-		if (_offsetSampleBundleMusic >= OUTPUT_SIZE + header_size) {
-			memcpy(_musicBundleBufFinal, (_musicBundleBufOutput + header_size), OUTPUT_SIZE);
-			_offsetBufBundleMusic = _offsetSampleBundleMusic - OUTPUT_SIZE - header_size;
-			memcpy(_musicBundleBufOutput, (_musicBundleBufOutput + (OUTPUT_SIZE + header_size)), _offsetBufBundleMusic);
+		if (_offsetSampleBundleMusic >= _outputMixerSize + header_size) {
+			memcpy(_musicBundleBufFinal, (_musicBundleBufOutput + header_size), _outputMixerSize);
+			_offsetBufBundleMusic = _offsetSampleBundleMusic - _outputMixerSize - header_size;
+			memcpy(_musicBundleBufOutput, (_musicBundleBufOutput + (_outputMixerSize + header_size)), _offsetBufBundleMusic);
 			_offsetSampleBundleMusic = _offsetBufBundleMusic;
 			break;
 		}
@@ -1098,17 +1098,16 @@
 		_offsetBufBundleMusic = 0;
 	}
 
-	size = OUTPUT_SIZE;
 	ptr = _musicBundleBufFinal;
 
 	byte * buffer = NULL;
 	uint32 final_size;
 	if (_bundleMusicSampleBits == 12) {
-		final_size = decode12BitsSample(ptr, &buffer, size);
+		final_size = decode12BitsSample(ptr, &buffer, _outputMixerSize);
 	} else if (_bundleMusicSampleBits == 16) {
-		buffer = (byte*)malloc(size);
-		final_size = size;
-		memcpy(buffer, ptr, size);
+		buffer = (byte*)malloc(_outputMixerSize);
+		final_size = _outputMixerSize;
+		memcpy(buffer, ptr, _outputMixerSize);
 	} else {
 		warning("Sound::bundleMusicHandler  to do more playStream options...");
 		return;

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- sound.h	28 Dec 2002 21:46:49 -0000	1.22
+++ sound.h	29 Dec 2002 01:28:44 -0000	1.23
@@ -55,6 +55,8 @@
 	bool _musicBundleToBeChanged;
 	bool _musicBundleToBeRemoved;
 	int32 _bundleMusicSampleBits;
+	int32 _outputMixerSize;
+	int32 _bundleSampleChannels;
 
 	File *_sfxFile;
 	uint32 _talk_sound_a1, _talk_sound_a2, _talk_sound_b1, _talk_sound_b2;





More information about the Scummvm-git-logs mailing list