diff options
| -rw-r--r-- | graphics/video/coktelvideo/coktelvideo.cpp | 43 | ||||
| -rw-r--r-- | graphics/video/coktelvideo/coktelvideo.h | 1 | 
2 files changed, 37 insertions, 7 deletions
| diff --git a/graphics/video/coktelvideo/coktelvideo.cpp b/graphics/video/coktelvideo/coktelvideo.cpp index c02b0528d5..384d23136a 100644 --- a/graphics/video/coktelvideo/coktelvideo.cpp +++ b/graphics/video/coktelvideo/coktelvideo.cpp @@ -1904,17 +1904,46 @@ void Vmd::filledSoundSlice(uint32 size) {  		_audioStream->queueBuffer(sound, size);  } -void Vmd::filledSoundSlices(uint32 size, uint32 mask) { -	int n = MIN<int>(_soundSlicesCount - 1, 31); -	for (int i = 0; i < n; i++) { +uint8 Vmd::evaluateMask(uint32 mask, bool *fillInfo, uint8 &max) { +	max = MIN<int>(_soundSlicesCount - 1, 31); -		if (mask & 1) -			emptySoundSlice(_soundDataSize * _soundBytesPerSample); -		else -			filledSoundSlice(_soundDataSize + _soundHeaderSize); +	uint8 n = 0; +	for (int i = 0; i < max; i++) { + +		if (!(mask & 1)) { +			n++; +			*fillInfo++ = true; +		} else +			*fillInfo++ = false;  		mask >>= 1;  	} + +	return n; +} + +void Vmd::filledSoundSlices(uint32 size, uint32 mask) { +	bool fillInfo[32]; + +	uint8 max; +	uint8 n = evaluateMask(mask, fillInfo, max); + +	int32 extraSize; + +	extraSize = size - n * _soundDataSize; + +	if (_soundSlicesCount > 32) +		extraSize -= (_soundSlicesCount - 32) * _soundDataSize; + +	if (n > 0) +		extraSize /= n; + +	for (uint8 i = 0; i < max; i++) +		if (fillInfo[i]) +			filledSoundSlice(_soundDataSize + extraSize); +		else +			emptySoundSlice(_soundDataSize * _soundBytesPerSample); +  	if (_soundSlicesCount > 32)  		filledSoundSlice((_soundSlicesCount - 32) * _soundDataSize + _soundHeaderSize);  } diff --git a/graphics/video/coktelvideo/coktelvideo.h b/graphics/video/coktelvideo/coktelvideo.h index 6637b045ee..aaa0ea6c96 100644 --- a/graphics/video/coktelvideo/coktelvideo.h +++ b/graphics/video/coktelvideo/coktelvideo.h @@ -433,6 +433,7 @@ protected:  	byte *sound16bitDPCM(uint32 &size);  	byte *sound16bitADPCM(uint32 &size); +	uint8 evaluateMask(uint32 mask, bool *fillInfo, uint8 &max);  	void emptySoundSlice(uint32 size);  	void filledSoundSlice(uint32 size);  	void filledSoundSlices(uint32 size, uint32 mask); | 
