diff options
Diffstat (limited to 'sound/mods/module.cpp')
-rw-r--r-- | sound/mods/module.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/sound/mods/module.cpp b/sound/mods/module.cpp index 3aea4797b7..96d977d422 100644 --- a/sound/mods/module.cpp +++ b/sound/mods/module.cpp @@ -113,7 +113,9 @@ const int16 Module::periods[16][60] = { 216 , 203 , 192 , 181 , 171 , 161 , 152 , 144 , 136 , 128 , 121 , 114, 108 , 101 , 96 , 90 , 85 , 80 , 76 , 72 , 68 , 64 , 60 , 57 }}; -bool Module::load(Common::ReadStream &st) { +bool Module::load(Common::SeekableReadStream &st, int offs) { + st.seek(offs); + st.read(songname, 20); songname[20] = '\0'; @@ -160,17 +162,33 @@ bool Module::load(Common::ReadStream &st) { } for (int i = 0; i < NUM_SAMPLES; ++i) { - if (!sample[i].len) + if (offs == 0) { + // Store locations for modules that use common samples + memcpy(commonSamples[i].name, sample[i].name, 22); + commonSamples[i].len = sample[i].len; + commonSamples[i].offs = st.pos(); + + } + + if (!sample[i].len) { sample[i].data = 0; - else { + } 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); } } - if (!st.eos()) - warning("Expected EOS on module stream"); - return true; } |