aboutsummaryrefslogtreecommitdiff
path: root/sword1/sound.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sword1/sound.cpp')
-rw-r--r--sword1/sound.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/sword1/sound.cpp b/sword1/sound.cpp
index c5b76a6718..3c752f887e 100644
--- a/sword1/sound.cpp
+++ b/sword1/sound.cpp
@@ -31,7 +31,7 @@ namespace Sword1 {
#define SOUND_SPEECH_ID 1
#define SPEECH_FLAGS (SoundMixer::FLAG_16BITS | SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_LITTLE_ENDIAN)
-Sound::Sound(const char *searchPath, SoundMixer *mixer, ResMan *pResMan) {
+Sound::Sound(const char *searchPath, SoundMixer *mixer, ResMan *pResMan, bool isDemo) {
strcpy(_filePath, searchPath);
_mixer = mixer;
_resMan = pResMan;
@@ -39,6 +39,7 @@ Sound::Sound(const char *searchPath, SoundMixer *mixer, ResMan *pResMan) {
_endOfQueue = 0;
_currentCowFile = 0;
_speechVolL = _speechVolR = _sfxVolL = _sfxVolR = 192;
+ _isDemo = isDemo;
}
int Sound::addToQueue(int32 fxNo) {
@@ -185,13 +186,13 @@ int16 *Sound::uncompressSpeech(uint32 index, uint32 cSize, uint32 *size) {
while ((READ_BE_UINT32(fBuf + headerPos) != 'data') && (headerPos < 100))
headerPos++;
if (headerPos < 100) {
- uint32 resSize = READ_LE_UINT32(fBuf + headerPos + 4) >> 1;
+ int32 resSize;
// Demo uses slightly different headers
- if (resSize > cSize) {
+ if (_isDemo) {
resSize = READ_LE_UINT32(fBuf + headerPos + 6) >> 1;
headerPos += 2;
- }
-
+ } else
+ resSize = READ_LE_UINT32(fBuf + headerPos + 4) >> 1;
int16 *srcData = (int16*)(fBuf + headerPos + 8);
int16 *dstData = (int16*)malloc(resSize * 2);
uint32 srcPos = 0;