aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorTravis Howell2006-01-06 05:40:40 +0000
committerTravis Howell2006-01-06 05:40:40 +0000
commit86bc87c70a600b7063a33cd37c9824e3b328d4b3 (patch)
treee85a93b516637945be2d1d071bd92c45f9be45b9 /scumm
parent2746e5be8c194b805f0ac99635bd168a775d320c (diff)
downloadscummvm-rg350-86bc87c70a600b7063a33cd37c9824e3b328d4b3.tar.gz
scummvm-rg350-86bc87c70a600b7063a33cd37c9824e3b328d4b3.tar.bz2
scummvm-rg350-86bc87c70a600b7063a33cd37c9824e3b328d4b3.zip
Adjustments to createSound().
svn-id: r19925
Diffstat (limited to 'scumm')
-rw-r--r--scumm/resource_v7he.cpp23
-rw-r--r--scumm/sound.cpp2
2 files changed, 16 insertions, 9 deletions
diff --git a/scumm/resource_v7he.cpp b/scumm/resource_v7he.cpp
index 49e6080be9..5aee8af021 100644
--- a/scumm/resource_v7he.cpp
+++ b/scumm/resource_v7he.cpp
@@ -1817,7 +1817,9 @@ void ScummEngine_v80he::createSound(int snd1id, int snd2id) {
res.lock(rtSound, snd2id);
snd1Ptr = getResourceAddress(rtSound, snd1id);
+ assert(snd1Ptr);
snd2Ptr = getResourceAddress(rtSound, snd2id);
+ assert(snd2Ptr);
int i;
int chan = -1;
@@ -1837,8 +1839,11 @@ void ScummEngine_v80he::createSound(int snd1id, int snd2id) {
dst = sbng1Ptr + 8;
size = READ_BE_UINT32(sbng1Ptr + 4);
len = sbng1Ptr - snd1Ptr + size - curOffs;
- memcpy(dst, src, len);
+ byte *data = (byte *)malloc(len);
+ memcpy(data, src, len);
+ memcpy(dst, data, len);
+ free(data);
dst = sbng1Ptr + 8;
while ((offs = READ_LE_UINT16(dst)) != 0)
@@ -1878,6 +1883,8 @@ void ScummEngine_v80he::createSound(int snd1id, int snd2id) {
size1 = READ_BE_UINT32(sdat1Ptr + 4) - 8 - _sndOffs1;
size2 = READ_BE_UINT32(sdat2Ptr + 4) - 8;
+ debug(0, "SDAT size1 %d size2 %d", size1, size2);
+
if (size2 < size1) {
src = sdat2Ptr + 8;
dst = sdat1Ptr + 8 + _sndOffs1;
@@ -1894,17 +1901,17 @@ void ScummEngine_v80he::createSound(int snd1id, int snd2id) {
memcpy(dst, src, len);
- int tmp3 = size2 - size1;
- if (tmp3 != 0) {
- // TODO: Additional copy
+ if (size2 != size1) {
+ src = sdat2Ptr + 8 + size1;
+ dst = sdat1Ptr + 8;
+ len = size2 - size1;
+
+ memcpy(dst, src, len);
}
- _sndOffs1 += tmp3;
+ _sndOffs1 += size2 - size1;
_sndOffs2 += size2;
}
-
- res.unlock(rtSound, snd1id);
- res.unlock(rtSound, snd2id);
}
} // End of namespace Scumm
diff --git a/scumm/sound.cpp b/scumm/sound.cpp
index ea0a248b36..158beaafe5 100644
--- a/scumm/sound.cpp
+++ b/scumm/sound.cpp
@@ -1283,7 +1283,7 @@ int ScummEngine::readSoundResource(int type, int idx) {
_fileHandle->seek(-16, SEEK_CUR);
total_size = max_total_size + 8;
ptr = res.createResource(type, idx, total_size);
- _fileHandle->read(ptr, total_size - 8);
+ _fileHandle->read(ptr, total_size);
//dumpResource("sound-", idx, ptr);
return 1;