diff options
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/imuse.cpp | 22 | ||||
-rw-r--r-- | scumm/sound.cpp | 34 |
2 files changed, 32 insertions, 24 deletions
diff --git a/scumm/imuse.cpp b/scumm/imuse.cpp index c2972c7bbc..5eaebba43f 100644 --- a/scumm/imuse.cpp +++ b/scumm/imuse.cpp @@ -4846,7 +4846,7 @@ static void imus_digital_handler(void * engine) { 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 @@ void IMuseDigital::handler() { 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 @@ void IMuseDigital::handler() { } _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 @@ void IMuseDigital::startSound(int sound) { } _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; diff --git a/scumm/sound.cpp b/scumm/sound.cpp index 1ffb870b56..634a77bb7d 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -837,25 +837,23 @@ bool Sound::isSfxFinished() { } 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); - - 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 s_size = (size / 3) * 4; + uint32 loop_size = s_size / 4; + byte *ptr = *dst = (byte*)malloc(s_size); + + 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) { |