aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Howell2007-11-16 03:37:15 +0000
committerTravis Howell2007-11-16 03:37:15 +0000
commit3cb8d404b5440d6d4deff7085c61699f505e60a6 (patch)
tree081abd2f33709a4ddaf194f593e812b414c4809d
parente13e247612265ba4a0549c1414640bff9853453e (diff)
downloadscummvm-rg350-3cb8d404b5440d6d4deff7085c61699f505e60a6.tar.gz
scummvm-rg350-3cb8d404b5440d6d4deff7085c61699f505e60a6.tar.bz2
scummvm-rg350-3cb8d404b5440d6d4deff7085c61699f505e60a6.zip
Fix loading common sample data for modules in Waxworks.
svn-id: r29511
-rw-r--r--sound/mods/module.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/sound/mods/module.cpp b/sound/mods/module.cpp
index 90921d24d1..c2a6190308 100644
--- a/sound/mods/module.cpp
+++ b/sound/mods/module.cpp
@@ -112,8 +112,12 @@ const int16 Module::periods[16][60] = {
108 , 101 , 96 , 90 , 85 , 80 , 76 , 72 , 68 , 64 , 60 , 57 }};
bool Module::load(Common::SeekableReadStream &st, int offs) {
- st.seek(offs);
+ if (offs) {
+ // Load the module with the common sample data
+ load(st, 0);
+ }
+ st.seek(offs);
st.read(songname, 20);
songname[20] = '\0';
@@ -160,8 +164,17 @@ bool Module::load(Common::SeekableReadStream &st, int offs) {
}
for (int i = 0; i < NUM_SAMPLES; ++i) {
- if (offs == 0) {
- // Store locations for modules that use common samples
+ if (offs) {
+ // Restore information for modules that use common sample data
+ for (int j = 0; j < NUM_SAMPLES; ++j) {
+ if (!scumm_stricmp((const char *)commonSamples[j].name, (const char *)sample[i].name)) {
+ sample[i].len = commonSamples[j].len;
+ st.seek(commonSamples[j].offs);
+ break;
+ }
+ }
+ } else {
+ // Store information for modules that use common sample data
memcpy(commonSamples[i].name, sample[i].name, 22);
commonSamples[i].len = sample[i].len;
commonSamples[i].offs = st.pos();
@@ -171,17 +184,6 @@ bool Module::load(Common::SeekableReadStream &st, int offs) {
if (!sample[i].len) {
sample[i].data = 0;
} else {
- if (offs != 0) {
- // For modules that use common samples
- for (int j = 0; j < NUM_SAMPLES; ++j) {
- if (!scumm_stricmp((const char *)commonSamples[j].name, (const char *)sample[i].name)) {
- sample[i].len = commonSamples[j].len;
- st.seek(commonSamples[j].offs);
- break;
- }
- }
- }
-
sample[i].data = new int8[sample[i].len];
st.read((byte *)sample[i].data, sample[i].len);
}