diff options
author | Travis Howell | 2007-07-28 07:52:24 +0000 |
---|---|---|
committer | Travis Howell | 2007-07-28 07:52:24 +0000 |
commit | bb2796c57a5bd6cfb417340e6cfda141eee9342e (patch) | |
tree | 4492df3bc4a51286f9409fdd06acf8dfd73c1730 | |
parent | 3d434b12335fd70659d5a99dd1dfe83b2145323f (diff) | |
download | scummvm-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
-rw-r--r-- | engines/agos/agos.cpp | 2 | ||||
-rw-r--r-- | engines/agos/res_snd.cpp | 55 | ||||
-rw-r--r-- | engines/parallaction/disk.h | 8 | ||||
-rw-r--r-- | engines/parallaction/disk_br.cpp | 2 | ||||
-rw-r--r-- | engines/parallaction/disk_ns.cpp | 4 | ||||
-rw-r--r-- | engines/parallaction/sound.cpp | 2 | ||||
-rw-r--r-- | sound/mods/module.cpp | 30 | ||||
-rw-r--r-- | sound/mods/module.h | 9 | ||||
-rw-r--r-- | sound/mods/protracker.cpp | 10 | ||||
-rw-r--r-- | sound/mods/protracker.h | 2 |
10 files changed, 98 insertions, 26 deletions
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp index ba429b510c..76e4378982 100644 --- a/engines/agos/agos.cpp +++ b/engines/agos/agos.cpp @@ -820,7 +820,7 @@ void AGOSEngine_Waxworks::setupGame() { _numTextBoxes = 10; _numVars = 255; - _numMusic = 9; + _numMusic = 26; AGOSEngine::setupGame(); } diff --git a/engines/agos/res_snd.cpp b/engines/agos/res_snd.cpp index 779ed67e58..beea0de473 100644 --- a/engines/agos/res_snd.cpp +++ b/engines/agos/res_snd.cpp @@ -139,9 +139,56 @@ void AGOSEngine::loadMusic(uint16 music) { _nextMusicToPlay = -1; } +struct ModuleOffs { + uint8 tune; + uint8 fileNum; + uint32 offs; +}; + +static const ModuleOffs amigaWaxworksOffs[20] = { + // Pyramid + {2, 2, 0, }, + {3, 2, 50980}, + {4, 2, 56160}, + {5, 2, 62364}, + {6, 2, 73688}, + + // Zombie + {8, 8, 0}, + {11, 8, 51156}, + {12, 8, 56336}, + {13, 8, 65612}, + {14, 8, 68744}, + + // Mine + {9, 9, 0}, + {15, 9, 47244}, + {16, 9, 52424}, + {17, 9, 59652}, + {18, 9, 62784}, + + // Jack + {10, 10, 0}, + {19, 10, 42054}, + {20, 10, 47234}, + {21, 10, 49342}, + {22, 10, 51450}, +}; + void AGOSEngine::playModule(uint16 music) { char filename[15]; File f; + uint32 offs = 0; + + if (getPlatform() == Common::kPlatformAmiga && getGameType() == GType_WW) { + // Multiple tunes are stored in music files for main locations + for (uint i = 0; i < 20; i++) { + if (amigaWaxworksOffs[i].tune == music) { + music = amigaWaxworksOffs[i].fileNum; + offs = amigaWaxworksOffs[i].offs; + } + } + } if (getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) sprintf(filename, "elvira2"); @@ -159,21 +206,21 @@ void AGOSEngine::playModule(uint16 music) { if (!(getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) && getFeatures() & GF_CRUNCHED) { - uint srcSize = f.size(); + uint32 srcSize = f.size(); byte *srcBuf = (byte *)malloc(srcSize); if (f.read(srcBuf, srcSize) != srcSize) error("playModule: Read failed"); - uint dstSize = READ_BE_UINT32(srcBuf + srcSize - 4); + uint32 dstSize = READ_BE_UINT32(srcBuf + srcSize - 4); byte *dstBuf = (byte *)malloc(dstSize); decrunchFile(srcBuf, dstBuf, srcSize); free(srcBuf); Common::MemoryReadStream stream(dstBuf, dstSize); - audioStream = Audio::makeProtrackerStream(&stream, _mixer->getOutputRate()); + audioStream = Audio::makeProtrackerStream(&stream, offs); free(dstBuf); } else { - audioStream = Audio::makeProtrackerStream(&f, _mixer->getOutputRate()); + audioStream = Audio::makeProtrackerStream(&f); } _mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_modHandle, audioStream); diff --git a/engines/parallaction/disk.h b/engines/parallaction/disk.h index d910201f27..ae572b1122 100644 --- a/engines/parallaction/disk.h +++ b/engines/parallaction/disk.h @@ -62,7 +62,7 @@ public: virtual void loadSlide(const char *filename) = 0; virtual void loadScenery(const char* background, const char* mask) = 0; virtual Table* loadTable(const char* name) = 0; - virtual Common::ReadStream* loadMusic(const char* name) = 0; + virtual Common::SeekableReadStream* loadMusic(const char* name) = 0; virtual Common::ReadStream* loadSound(const char* name) = 0; }; @@ -154,7 +154,7 @@ public: void loadSlide(const char *filename); void loadScenery(const char* background, const char* mask); Table* loadTable(const char* name); - Common::ReadStream* loadMusic(const char* name); + Common::SeekableReadStream* loadMusic(const char* name); Common::ReadStream* loadSound(const char* name); }; @@ -188,7 +188,7 @@ public: void loadSlide(const char *filename); void loadScenery(const char* background, const char* mask); Table* loadTable(const char* name); - Common::ReadStream* loadMusic(const char* name); + Common::SeekableReadStream* loadMusic(const char* name); Common::ReadStream* loadSound(const char* name); }; @@ -222,7 +222,7 @@ public: void loadSlide(const char *filename); void loadScenery(const char* background, const char* mask); Table* loadTable(const char* name); - Common::ReadStream* loadMusic(const char* name); + Common::SeekableReadStream* loadMusic(const char* name); Common::ReadStream* loadSound(const char* name); }; diff --git a/engines/parallaction/disk_br.cpp b/engines/parallaction/disk_br.cpp index 07d9954f23..452b74be51 100644 --- a/engines/parallaction/disk_br.cpp +++ b/engines/parallaction/disk_br.cpp @@ -119,7 +119,7 @@ Table* DosDisk_br::loadTable(const char* name) { return 0; } -Common::ReadStream* DosDisk_br::loadMusic(const char* name) { +Common::SeekableReadStream* DosDisk_br::loadMusic(const char* name) { debugC(5, kDebugDisk, "DosDisk_br::loadMusic"); return 0; } diff --git a/engines/parallaction/disk_ns.cpp b/engines/parallaction/disk_ns.cpp index bf9b0277cb..e500cd519b 100644 --- a/engines/parallaction/disk_ns.cpp +++ b/engines/parallaction/disk_ns.cpp @@ -674,7 +674,7 @@ Table* DosDisk_ns::loadTable(const char* name) { return t; } -Common::ReadStream* DosDisk_ns::loadMusic(const char* name) { +Common::SeekableReadStream* DosDisk_ns::loadMusic(const char* name) { char path[PATH_LEN]; sprintf(path, "%s.mid", name); @@ -1427,7 +1427,7 @@ Font* AmigaDisk_ns::loadFont(const char* name) { } -Common::ReadStream* AmigaDisk_ns::loadMusic(const char* name) { +Common::SeekableReadStream* AmigaDisk_ns::loadMusic(const char* name) { return openArchivedFile(name); } diff --git a/engines/parallaction/sound.cpp b/engines/parallaction/sound.cpp index 9976ec13a8..1026aa5f6a 100644 --- a/engines/parallaction/sound.cpp +++ b/engines/parallaction/sound.cpp @@ -379,7 +379,7 @@ void AmigaSoundMan::playMusic() { debugC(1, kDebugAudio, "AmigaSoundMan::playMusic()"); - Common::ReadStream *stream = _vm->_disk->loadMusic(_musicFile); + Common::SeekableReadStream *stream = _vm->_disk->loadMusic(_musicFile); _musicStream = Audio::makeProtrackerStream(stream); delete stream; 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 |