aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/sfx/softseq/adlib.cpp
diff options
context:
space:
mode:
authorWalter van Niftrik2009-10-10 01:38:45 +0000
committerWalter van Niftrik2009-10-10 01:38:45 +0000
commit4b3c1645bcbe19ba55a3e6f16c4b32b2332caab3 (patch)
treed16dbcdf0ace623721c44a5d2e5ac787578456cc /engines/sci/sfx/softseq/adlib.cpp
parent8ae420637338c32b377c6518b4373302d6d8ee77 (diff)
downloadscummvm-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/sci/sfx/softseq/adlib.cpp')
-rw-r--r--engines/sci/sfx/softseq/adlib.cpp51
1 files changed, 37 insertions, 14 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);
}