diff options
author | Walter van Niftrik | 2009-10-10 01:38:45 +0000 |
---|---|---|
committer | Walter van Niftrik | 2009-10-10 01:38:45 +0000 |
commit | 4b3c1645bcbe19ba55a3e6f16c4b32b2332caab3 (patch) | |
tree | d16dbcdf0ace623721c44a5d2e5ac787578456cc /engines | |
parent | 8ae420637338c32b377c6518b4373302d6d8ee77 (diff) | |
download | scummvm-rg350-4b3c1645bcbe19ba55a3e6f16c4b32b2332caab3.tar.gz scummvm-rg350-4b3c1645bcbe19ba55a3e6f16c4b32b2332caab3.tar.bz2 scummvm-rg350-4b3c1645bcbe19ba55a3e6f16c4b32b2332caab3.zip |
SCI: Adlib: Add support for loading patch data from adl.drv
svn-id: r44859
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/sfx/softseq/adlib.cpp | 51 | ||||
-rw-r--r-- | engines/sci/sfx/softseq/adlib.h | 2 |
2 files changed, 38 insertions, 15 deletions
diff --git a/engines/sci/sfx/softseq/adlib.cpp b/engines/sci/sfx/softseq/adlib.cpp index d2a5cb9001..7afe632300 100644 --- a/engines/sci/sfx/softseq/adlib.cpp +++ b/engines/sci/sfx/softseq/adlib.cpp @@ -608,19 +608,26 @@ void MidiDriver_Adlib::playSwitch(bool play) { renewNotes(-1, play); } -void MidiDriver_Adlib::loadResource(Resource *res) { +bool MidiDriver_Adlib::loadResource(const byte *data, uint size) { + if ((size != 1344) && (size != 2690) && (size != 5382)) { + warning("ADLIB: Unsupported patch format (%i bytes)", size); + return false; + } + for (int i = 0; i < 48; i++) - loadInstrument(res->data + (28 * i)); + loadInstrument(data + (28 * i)); - if (res->size == 2690) { + if (size == 2690) { for (int i = 48; i < 96; i++) - loadInstrument(res->data + 2 + (28 * i)); - } else if (res->size == 5382) { + loadInstrument(data + 2 + (28 * i)); + } else if (size == 5382) { for (int i = 48; i < 190; i++) - loadInstrument(res->data + (28 * i)); + loadInstrument(data + (28 * i)); _rhythmKeyMap = new byte[kRhythmKeys]; - memcpy(_rhythmKeyMap, res->data + 5320, kRhythmKeys); + memcpy(_rhythmKeyMap, data + 5320, kRhythmKeys); } + + return true; } int MidiPlayer_Adlib::open(ResourceManager *resMan) { @@ -628,19 +635,35 @@ int MidiPlayer_Adlib::open(ResourceManager *resMan) { // Load up the patch.003 file, parse out the instruments Resource *res = resMan->findResource(ResourceId(kResourceTypePatch, 3), 0); + bool ok = false; - if (!res) { - warning("ADLIB: Failed to load patch.003"); - return -1; + if (res) { + ok = static_cast<MidiDriver_Adlib *>(_driver)->loadResource(res->data, res->size); + } else { + // Early SCI0 games have the sound bank embedded in the adlib driver + + Common::File f; + + if (f.open("ADL.DRV")) { + int size = f.size(); + const uint patchSize = 1344; + + if ((size == 5684) || (size == 5720) || (size == 5727)) { + byte *buf = new byte[patchSize]; + + if (f.seek(0x45a) && (f.read(buf, patchSize) == patchSize)) + ok = static_cast<MidiDriver_Adlib *>(_driver)->loadResource(buf, patchSize); + + delete[] buf; + } + } } - if ((res->size != 1344) && (res->size != 2690) && (res->size != 5382)) { - warning("ADLIB: Unsupported patch format (%i bytes)", res->size); + if (!ok) { + warning("ADLIB: Failed to load patch.003"); return -1; } - static_cast<MidiDriver_Adlib *>(_driver)->loadResource(res); - return static_cast<MidiDriver_Adlib *>(_driver)->open(getSciVersion() <= SCI_VERSION_0_LATE); } diff --git a/engines/sci/sfx/softseq/adlib.h b/engines/sci/sfx/softseq/adlib.h index 3432816058..771bdc3927 100644 --- a/engines/sci/sfx/softseq/adlib.h +++ b/engines/sci/sfx/softseq/adlib.h @@ -54,7 +54,7 @@ public: void setVolume(byte volume); void playSwitch(bool play); - void loadResource(Resource *res); + bool loadResource(const byte *data, uint size); private: enum ChannelID { |