aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
Diffstat (limited to 'sound')
-rw-r--r--sound/mods/module.cpp30
-rw-r--r--sound/mods/module.h9
-rw-r--r--sound/mods/protracker.cpp10
-rw-r--r--sound/mods/protracker.h2
4 files changed, 38 insertions, 13 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;
}
diff --git a/sound/mods/module.h b/sound/mods/module.h
index 041eebc269..0d2282f770 100644
--- a/sound/mods/module.h
+++ b/sound/mods/module.h
@@ -53,12 +53,19 @@ struct sample_t {
int8 *data;
};
+struct sample_offs {
+ byte name[23];
+ uint16 len;
+ uint32 offs;
+};
+
class Module {
public:
byte songname[21];
static const int NUM_SAMPLES = 31;
sample_t sample[NUM_SAMPLES];
+ sample_offs commonSamples[NUM_SAMPLES];
byte songlen;
byte undef;
@@ -69,7 +76,7 @@ public:
Module();
~Module();
- bool load(Common::ReadStream &stream);
+ bool load(Common::SeekableReadStream &stream, int offs);
static byte periodToNote(int16 period, byte finetune = 0);
static int16 noteToPeriod(byte note, byte finetune = 0);
diff --git a/sound/mods/protracker.cpp b/sound/mods/protracker.cpp
index 46ee3aabf7..271e3d8e3e 100644
--- a/sound/mods/protracker.cpp
+++ b/sound/mods/protracker.cpp
@@ -90,7 +90,7 @@ private:
} _track[4];
public:
- ProtrackerStream(Common::ReadStream *stream, int rate, bool stereo);
+ ProtrackerStream(Common::SeekableReadStream *stream, int offs, int rate, bool stereo);
private:
void interrupt();
@@ -145,9 +145,9 @@ const int16 ProtrackerStream::sinetable[64] = {
-180, -161, -141, -120, -97, -74, -49, -24
};
-ProtrackerStream::ProtrackerStream(Common::ReadStream *stream, int rate, bool stereo) :
+ProtrackerStream::ProtrackerStream(Common::SeekableReadStream *stream, int offs, int rate, bool stereo) :
Paula(stereo, rate, rate/50) {
- bool result = _module.load(*stream);
+ bool result = _module.load(*stream, offs);
assert(result);
_tick = _row = _pos = 0;
@@ -461,8 +461,8 @@ void ProtrackerStream::interrupt(void) {
namespace Audio {
-AudioStream *makeProtrackerStream(Common::ReadStream *stream, int rate, bool stereo) {
- return new Modules::ProtrackerStream(stream, rate, stereo);
+AudioStream *makeProtrackerStream(Common::SeekableReadStream *stream, int offs, int rate, bool stereo) {
+ return new Modules::ProtrackerStream(stream, offs, rate, stereo);
}
} // End of namespace Audio
diff --git a/sound/mods/protracker.h b/sound/mods/protracker.h
index 73955a723c..23e90f0954 100644
--- a/sound/mods/protracker.h
+++ b/sound/mods/protracker.h
@@ -44,7 +44,7 @@ class AudioStream;
* @param stereo TODO
* @return a new AudioStream, or NULL, if an error occured
*/
-AudioStream *makeProtrackerStream(Common::ReadStream *stream, int rate = 44100, bool stereo = true);
+AudioStream *makeProtrackerStream(Common::SeekableReadStream *stream, int offs = 0, int rate = 44100, bool stereo = true);
} // End of namespace Audio