From bb2796c57a5bd6cfb417340e6cfda141eee9342e Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sat, 28 Jul 2007 07:52:24 +0000 Subject: Add support for multi-tune Protracker modules used in the Amiga version of Waxworks. svn-id: r28256 --- sound/mods/module.cpp | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'sound/mods/module.cpp') diff --git a/sound/mods/module.cpp b/sound/mods/module.cpp index 3aea4797b7..ce12ce9382 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[i].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; } -- cgit v1.2.3