From 509cc5f4c4214d0111339a4fe211f82f89d1df56 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Thu, 8 Dec 2011 18:42:57 -0500 Subject: SCI: Add preliminary support for SCI1 early Amiga sound patches As used by KQ1 and MUMG. Sound still seems a bit off, but it's close. --- engines/sci/sound/drivers/amigamac.cpp | 55 +++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/engines/sci/sound/drivers/amigamac.cpp b/engines/sci/sound/drivers/amigamac.cpp index 3c750401b9..41697d4a07 100644 --- a/engines/sci/sound/drivers/amigamac.cpp +++ b/engines/sci/sound/drivers/amigamac.cpp @@ -130,7 +130,7 @@ private: }; bool _isSci1; - bool _isSci1Early; // KQ1 Amiga, patch 5 + bool _isSci1Early; // KQ1/MUMG Amiga, patch 5 bool _playSwitch; int _masterVolume; int _frequency; @@ -586,12 +586,12 @@ int MidiDriver_AmigaMac::open() { } else { ResourceManager *resMan = g_sci->getResMan(); - Resource *resource = resMan->findResource(ResourceId(kResourceTypePatch, 7), false); // Mac + Resource *resource = resMan->findResource(ResourceId(kResourceTypePatch, 7), false); // Mac if (!resource) - resource = resMan->findResource(ResourceId(kResourceTypePatch, 9), false); // Amiga + resource = resMan->findResource(ResourceId(kResourceTypePatch, 9), false); // Amiga if (!resource) { - resource = resMan->findResource(ResourceId(kResourceTypePatch, 5), false); // KQ1 Amiga + resource = resMan->findResource(ResourceId(kResourceTypePatch, 5), false); // KQ1/MUMG Amiga if (resource) _isSci1Early = true; } @@ -892,7 +892,7 @@ bool MidiDriver_AmigaMac::loadInstrumentsSCI1(Common::SeekableReadStream &file) _bank.size = 128; if (_isSci1Early) - file.skip(4); // TODO: What is this offset for? + file.readUint32BE(); // Skip size of bank Common::Array instrumentOffsets; instrumentOffsets.resize(_bank.size); @@ -911,12 +911,6 @@ bool MidiDriver_AmigaMac::loadInstrumentsSCI1(Common::SeekableReadStream &file) // Read in the instrument name file.read(_bank.instruments[i].name, 10); // last two bytes are always 0 - // TODO: Finish off support of SCI1 early patches (patch.005 - KQ1 Amiga) - if (_isSci1Early) { - warning("Music patch 5 isn't supported yet - ignoring instrument %d", i); - continue; - } - for (uint32 j = 0; ; j++) { InstrumentSample *sample = new InstrumentSample; memset(sample, 0, sizeof(InstrumentSample)); @@ -943,16 +937,30 @@ bool MidiDriver_AmigaMac::loadInstrumentsSCI1(Common::SeekableReadStream &file) int16 loop = file.readSint16BE(); uint32 nextSamplePos = file.pos(); - file.seek(samplePtr); + file.seek(samplePtr + (_isSci1Early ? 4 : 0)); file.read(sample->name, 8); - sample->isUnsigned = file.readUint16BE() == 0; - uint16 phase1Offset = file.readUint16BE(); - uint16 phase1End = file.readUint16BE(); - uint16 phase2Offset = file.readUint16BE(); - uint16 phase2End = file.readUint16BE(); - sample->baseNote = file.readUint16BE(); - uint32 periodTableOffset = file.readUint32BE(); + uint16 phase1Offset, phase1End; + uint16 phase2Offset, phase2End; + + if (_isSci1Early) { + sample->isUnsigned = false; + file.readUint32BE(); // skip total sample size + phase2Offset = file.readUint16BE(); + phase2End = file.readUint16BE(); + sample->baseNote = file.readUint16BE(); + phase1Offset = file.readUint16BE(); + phase1End = file.readUint16BE(); + } else { + sample->isUnsigned = file.readUint16BE() == 0; + phase1Offset = file.readUint16BE(); + phase1End = file.readUint16BE(); + phase2Offset = file.readUint16BE(); + phase2End = file.readUint16BE(); + sample->baseNote = file.readUint16BE(); + } + + uint32 periodTableOffset = _isSci1Early ? 0 : file.readUint32BE(); uint32 sampleDataPos = file.pos(); sample->size = phase1End - phase1Offset + 1; @@ -974,8 +982,13 @@ bool MidiDriver_AmigaMac::loadInstrumentsSCI1(Common::SeekableReadStream &file) _bank.instruments[i].push_back(sample); - file.seek(periodTableOffset + 0xe0); - sample->baseFreq = file.readUint16BE(); + if (_isSci1Early) { + // There's no frequency specified by the sample and is hardcoded like in SCI0 + sample->baseFreq = 11000; + } else { + file.seek(periodTableOffset + 0xe0); + sample->baseFreq = file.readUint16BE(); + } file.seek(nextSamplePos); } -- cgit v1.2.3