[Scummvm-cvs-logs] CVS: scummvm/scumm imuse.cpp,1.18,1.19 sound.cpp,1.18,1.19

Pawe? Ko?odziejski aquadran at users.sourceforge.net
Mon Sep 30 12:11:18 CEST 2002


Update of /cvsroot/scummvm/scummvm/scumm
In directory usw-pr-cvs1:/tmp/cvs-serv9963

Modified Files:
	imuse.cpp sound.cpp 
Log Message:
synced with local sources (imuse)

Index: imuse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- imuse.cpp	30 Sep 2002 06:04:50 -0000	1.18
+++ imuse.cpp	30 Sep 2002 19:10:33 -0000	1.19
@@ -4846,7 +4846,7 @@
 IMuseDigital::IMuseDigital(Scumm *scumm) {
 	memset(_channel, 0, sizeof(channel) * MAX_DIGITAL_CHANNELS);
 	_scumm = scumm;
-	_scumm->_timer->installProcedure(imus_digital_handler, 100);
+	_scumm->_timer->installProcedure(imus_digital_handler, 200);
 }
 
 IMuseDigital::~IMuseDigital() {
@@ -4865,13 +4865,19 @@
 				continue;
 			}
 
+			uint32 new_size = _channel[l]._mixerSize;
 			if (_channel[l]._offset + _channel[l]._mixerSize > _channel[l]._size) {
-				_channel[l]._mixerSize = _channel[l]._size - _channel[l]._offset;
-				_channel[l]._toBeRemoved = true;
+				new_size = _channel[l]._size - _channel[l]._offset;
+				if(_channel[l]._isLoop == false) {
+					_channel[l]._toBeRemoved = true;
+				}
 			}
 
 			byte *buf = (byte*)malloc(_channel[l]._mixerSize);
-			memcpy(buf, _channel[l]._data + _channel[l]._offset, _channel[l]._mixerSize);
+			memcpy(buf, _channel[l]._data + _channel[l]._offset, new_size);
+			if ((new_size != _channel[l]._mixerSize) && (_channel[l]._isLoop == true)) {
+				memcpy(buf, _channel[l]._data, _channel[l]._mixerSize - new_size);
+			}
 
 			new_mixer = false;
 			if (_channel[l]._mixerTrack == -1) {
@@ -4898,7 +4904,11 @@
 			}
 			_scumm->_system->unlock_mutex(_scumm->_mixer->_mutex);
 
-			_channel[l]._offset += _channel[l]._mixerSize;
+			if ((new_size != _channel[l]._mixerSize) && (_channel[l]._isLoop == true)) {
+				_channel[l]._offset = _channel[l]._mixerSize - new_size;
+			} else {
+				_channel[l]._offset += _channel[l]._mixerSize;
+			}
 		}
 	}
 }
@@ -4955,7 +4965,7 @@
 			}
 
 			_channel[l]._mixerTrack = -1;
-			_channel[l]._mixerSize = 22050 / 10;
+			_channel[l]._mixerSize = 22050 / 5;
 			_channel[l]._mixerFlags = SoundMixer::FLAG_AUTOFREE;
 			if (_channel[l]._bits == 12) {
 				_channel[l]._mixerSize *= 2;

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- sound.cpp	29 Sep 2002 15:12:18 -0000	1.18
+++ sound.cpp	30 Sep 2002 19:10:35 -0000	1.19
@@ -837,25 +837,23 @@
 }
 
 uint32 Sound::decode12BitsSample(byte * src, byte ** dst, uint32 size) {
-	uint32 s_size = (size * 4) / 3;
-	byte * ptr = *dst = (byte*)malloc (s_size + 4);
-
-	uint32 r = 0, tmp, l;
-	for (l = 0; l < size; l += 3) {
-		tmp = (src[l + 1] & 0x0f) << 8;
-		tmp = (tmp | src[l + 0]) << 4;
-		tmp -= 0x8000;
-		ptr[r++] = (byte)((tmp >> 8) & 0xff);
-		ptr[r++] = (byte)(tmp & 0xff);
+	uint32 s_size = (size / 3) * 4;
+	uint32 loop_size = s_size / 4;
+	byte *ptr = *dst = (byte*)malloc(s_size);
 
-		tmp = (src[l + 1] & 0xf0) << 4;
-		tmp = (tmp | src[l + 2]) << 4;
-		tmp -= 0x8000;
-		ptr[r++] = (byte)((tmp >> 8) & 0xff);
-		ptr[r++] = (byte)(tmp & 0xff);
+	uint32 tmp;
+	while(loop_size--) {
+		byte v1 = *src++;
+		byte v2 = *src++;
+		byte v3 = *src++;
+		tmp = ((((v2 & 0x0f) << 8) | v1) << 4) - 0x8000;
+		*ptr++ = (byte)((tmp >> 8) & 0xff);
+		*ptr++ = (byte)(tmp & 0xff);
+		tmp = ((((v2 & 0xf0) << 4) | v3) << 4) - 0x8000;
+		*ptr++ = (byte)((tmp >> 8) & 0xff);
+		*ptr++ = (byte)(tmp & 0xff);
 	}
-
-	return r;
+	return s_size;
 }
 
 static void music_handler (void * engine) {





More information about the Scummvm-git-logs mailing list