aboutsummaryrefslogtreecommitdiff
path: root/sound/mods/module.cpp
diff options
context:
space:
mode:
authorTravis Howell2007-07-28 07:52:24 +0000
committerTravis Howell2007-07-28 07:52:24 +0000
commitbb2796c57a5bd6cfb417340e6cfda141eee9342e (patch)
tree4492df3bc4a51286f9409fdd06acf8dfd73c1730 /sound/mods/module.cpp
parent3d434b12335fd70659d5a99dd1dfe83b2145323f (diff)
downloadscummvm-rg350-bb2796c57a5bd6cfb417340e6cfda141eee9342e.tar.gz
scummvm-rg350-bb2796c57a5bd6cfb417340e6cfda141eee9342e.tar.bz2
scummvm-rg350-bb2796c57a5bd6cfb417340e6cfda141eee9342e.zip
Add support for multi-tune Protracker modules used in the Amiga version of Waxworks.
svn-id: r28256
Diffstat (limited to 'sound/mods/module.cpp')
-rw-r--r--sound/mods/module.cpp30
1 files changed, 24 insertions, 6 deletions
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;
}