aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorJonathan Gray2004-01-09 13:16:06 +0000
committerJonathan Gray2004-01-09 13:16:06 +0000
commit93f3c0df348b77d284d66309e36d775df4765c99 (patch)
treee55523164c4ca430f064c38ce16f84558932bf19 /scumm
parentee53fb439171c4e2f9c2c76d6c654bd781207921 (diff)
downloadscummvm-rg350-93f3c0df348b77d284d66309e36d775df4765c99.tar.gz
scummvm-rg350-93f3c0df348b77d284d66309e36d775df4765c99.tar.bz2
scummvm-rg350-93f3c0df348b77d284d66309e36d775df4765c99.zip
commit on aquadran's behalf that fixes music distortion
svn-id: r12275
Diffstat (limited to 'scumm')
-rw-r--r--scumm/imuse_digi/dimuse.cpp9
-rw-r--r--scumm/imuse_digi/dimuse_bndmgr.cpp41
-rw-r--r--scumm/imuse_digi/dimuse_bndmgr.h6
-rw-r--r--scumm/imuse_digi/dimuse_sndmgr.cpp10
4 files changed, 49 insertions, 17 deletions
diff --git a/scumm/imuse_digi/dimuse.cpp b/scumm/imuse_digi/dimuse.cpp
index b0b45daf37..55de775bf7 100644
--- a/scumm/imuse_digi/dimuse.cpp
+++ b/scumm/imuse_digi/dimuse.cpp
@@ -154,6 +154,10 @@ void IMuseDigital::callback() {
if (_sound->getChannels(_track[l].soundHandle) == 1) {
result &= ~1;
}
+ if (_sound->getChannels(_track[l].soundHandle) == 2) {
+ if (result & 2)
+ result &= ~2;
+ }
} else if (bits == 8) {
result = _sound->getDataFromRegion(_track[l].soundHandle, _track[l].curRegion, &data, _track[l].regionOffset, mixer_size);
if (_sound->getChannels(_track[l].soundHandle) == 2) {
@@ -194,6 +198,11 @@ void IMuseDigital::switchToNextRegion(int track) {
return;
}
+ if (_track[track].idSound == 2312) {
+ _track[track].curRegion = 4;
+ _track[track].regionOffset = 0;
+ return;
+ }
if (++_track[track].curRegion == num_regions) {
_track[track].toBeRemoved = true;
return;
diff --git a/scumm/imuse_digi/dimuse_bndmgr.cpp b/scumm/imuse_digi/dimuse_bndmgr.cpp
index 22c64db4e3..ef4cef9098 100644
--- a/scumm/imuse_digi/dimuse_bndmgr.cpp
+++ b/scumm/imuse_digi/dimuse_bndmgr.cpp
@@ -159,13 +159,14 @@ void BundleMgr::closeFile() {
}
}
-int32 BundleMgr::decompressSampleByCurIndex(int32 offset, int32 size, byte **comp_final, int header_size) {
- return decompressSampleByIndex(_curSample, offset, size, comp_final, header_size);
+int32 BundleMgr::decompressSampleByCurIndex(int32 offset, int32 size, byte **comp_final, int header_size, bool header_outside) {
+ return decompressSampleByIndex(_curSample, offset, size, comp_final, header_size, header_outside);
}
-int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size, byte **comp_final, int header_size) {
+int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size, byte **comp_final, int header_size, bool header_outside) {
int32 i, tag, num, final_size, output_size;
byte *comp_input, *comp_output;
+ int skip, first_block, last_block;
if (index != -1)
_curSample = index;
@@ -197,14 +198,24 @@ int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size,
_compTableLoaded = true;
}
- int first_block = (offset + header_size) / 0x2000;
- int last_block = (offset + size + header_size - 1) / 0x2000;
+ if (header_outside) {
+ first_block = offset / 0x2000;
+ last_block = (offset + size - 1) / 0x2000;
+ } else {
+ first_block = (offset + header_size) / 0x2000;
+ last_block = (offset + size + header_size - 1) / 0x2000;
+ }
comp_output = (byte *)malloc(0x2000);
- *comp_final = (byte *)malloc(0x2000 * (1 + last_block - first_block));
+ int32 blocks_final_size = 0x2000 * (1 + last_block - first_block);
+ *comp_final = (byte *)malloc(blocks_final_size);
final_size = 0;
- int skip = offset - (first_block * 0x2000) + header_size;
+ if (header_outside) {
+ skip = offset - (first_block * 0x2000);
+ } else {
+ skip = offset - (first_block * 0x2000) + header_size;
+ }
for (i = first_block; i <= last_block; i++) {
byte *curBuf;
@@ -227,11 +238,21 @@ int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size,
curBuf = _blockChache;
}
- if ((header_size != 0) && (skip >= header_size))
+ if (header_outside) {
+ if ((header_size != 0) && (i == 0))
+ skip += header_size;
output_size -= skip;
+ } else {
+ if ((header_size != 0) && (skip >= header_size))
+ output_size -= skip;
+ }
+
if (output_size > size)
output_size = size;
+ if (final_size + output_size > blocks_final_size)
+ error("");
+
memcpy(*comp_final + final_size, curBuf + skip, output_size);
final_size += output_size;
@@ -246,7 +267,7 @@ int32 BundleMgr::decompressSampleByIndex(int32 index, int32 offset, int32 size,
return final_size;
}
-int32 BundleMgr::decompressSampleByName(const char *name, int32 offset, int32 size, byte **comp_final) {
+int32 BundleMgr::decompressSampleByName(const char *name, int32 offset, int32 size, byte **comp_final, bool header_outside) {
int32 final_size = 0, i;
if (!_file.isOpen()) {
@@ -256,7 +277,7 @@ int32 BundleMgr::decompressSampleByName(const char *name, int32 offset, int32 si
for (i = 0; i < _numFiles; i++) {
if (!scumm_stricmp(name, _bundleTable[i].filename)) {
- final_size = decompressSampleByIndex(i, offset, size, comp_final, 0);
+ final_size = decompressSampleByIndex(i, offset, size, comp_final, 0, header_outside);
return final_size;
}
}
diff --git a/scumm/imuse_digi/dimuse_bndmgr.h b/scumm/imuse_digi/dimuse_bndmgr.h
index 11dd678b2b..b30c8f9c38 100644
--- a/scumm/imuse_digi/dimuse_bndmgr.h
+++ b/scumm/imuse_digi/dimuse_bndmgr.h
@@ -79,9 +79,9 @@ public:
bool openFile(const char *filename, const char *directory);
void closeFile();
- int32 decompressSampleByName(const char *name, int32 offset, int32 size, byte **comp_final);
- int32 decompressSampleByIndex(int32 index, int32 offset, int32 size, byte **comp_final, int header_size);
- int32 decompressSampleByCurIndex(int32 offset, int32 size, byte **comp_final, int header_size);
+ int32 decompressSampleByName(const char *name, int32 offset, int32 size, byte **comp_final, bool header_outside);
+ int32 decompressSampleByIndex(int32 index, int32 offset, int32 size, byte **comp_final, int header_size, bool header_outside);
+ int32 decompressSampleByCurIndex(int32 offset, int32 size, byte **comp_final, int header_size, bool header_outside);
};
namespace BundleCodecs {
diff --git a/scumm/imuse_digi/dimuse_sndmgr.cpp b/scumm/imuse_digi/dimuse_sndmgr.cpp
index 1a36837e61..bd5c297eae 100644
--- a/scumm/imuse_digi/dimuse_sndmgr.cpp
+++ b/scumm/imuse_digi/dimuse_sndmgr.cpp
@@ -219,13 +219,14 @@ ImuseDigiSndMgr::soundStruct *ImuseDigiSndMgr::openSound(int32 soundId, const ch
_sounds[slot].resPtr = ptr;
result = true;
} else if (soundType == IMUSE_BUNDLE) {
+ bool header_outside = _vm->_gameId != GID_DIG;
if (soundGroup == IMUSE_VOICE)
result = openVoiceBundle(slot);
else if (soundGroup == IMUSE_MUSIC)
result = openMusicBundle(slot);
else
error("ImuseDigiSndMgr::openSound() Don't know how load sound: %d", soundId);
- _sounds[slot]._bundle->decompressSampleByIndex(soundId, 0, 0x2000, &ptr, 0);
+ _sounds[slot]._bundle->decompressSampleByIndex(soundId, 0, 0x2000, &ptr, 0, header_outside);
_sounds[slot].name[0] = 0;
_sounds[slot].soundId = soundId;
} else {
@@ -233,13 +234,14 @@ ImuseDigiSndMgr::soundStruct *ImuseDigiSndMgr::openSound(int32 soundId, const ch
}
} else if (soundName != NULL) {
if (soundType == IMUSE_BUNDLE) {
+ bool header_outside = _vm->_gameId != GID_DIG;
if (soundGroup == IMUSE_VOICE)
result = openVoiceBundle(slot);
else if (soundGroup == IMUSE_MUSIC)
result = openMusicBundle(slot);
else
error("ImuseDigiSndMgr::openSound() Don't know how load sound: %d", soundId);
- _sounds[slot]._bundle->decompressSampleByName(soundName, 0, 0x2000, &ptr);
+ _sounds[slot]._bundle->decompressSampleByName(soundName, 0, 0x2000, &ptr, header_outside);
strcpy(_sounds[slot].name, soundName);
_sounds[slot].soundId = soundId;
} else {
@@ -394,9 +396,9 @@ int32 ImuseDigiSndMgr::getDataFromRegion(soundStruct *soundHandle, int region, b
}
int header_size = soundHandle->offsetData;
-
+ bool header_outside = _vm->_gameId != GID_DIG;
if (soundHandle->_bundle) {
- size = soundHandle->_bundle->decompressSampleByCurIndex(start + offset, size, buf, header_size);
+ size = soundHandle->_bundle->decompressSampleByCurIndex(start + offset, size, buf, header_size, header_outside);
} else if (soundHandle->resPtr) {
*buf = (byte *)malloc(size);
memcpy(*buf, soundHandle->resPtr + start + offset + header_size, size);