aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra/sound_adlib.cpp
diff options
context:
space:
mode:
authorJohannes Schickel2007-02-16 16:57:59 +0000
committerJohannes Schickel2007-02-16 16:57:59 +0000
commit940e89d00e26bec98b6a61f0913c0491ec931472 (patch)
tree368893ae0841a59bb25390f2f185ff854335e0f4 /engines/kyra/sound_adlib.cpp
parentd849f4762ce09dc6d83b6ef31179c2a587d2ded7 (diff)
downloadscummvm-rg350-940e89d00e26bec98b6a61f0913c0491ec931472.tar.gz
scummvm-rg350-940e89d00e26bec98b6a61f0913c0491ec931472.tar.bz2
scummvm-rg350-940e89d00e26bec98b6a61f0913c0491ec931472.zip
Added support for Kyrandia 2 ADL files.
svn-id: r25634
Diffstat (limited to 'engines/kyra/sound_adlib.cpp')
-rw-r--r--engines/kyra/sound_adlib.cpp39
1 files changed, 29 insertions, 10 deletions
diff --git a/engines/kyra/sound_adlib.cpp b/engines/kyra/sound_adlib.cpp
index c308d1ba54..dc092a5a2e 100644
--- a/engines/kyra/sound_adlib.cpp
+++ b/engines/kyra/sound_adlib.cpp
@@ -60,7 +60,7 @@ namespace Kyra {
class AdlibDriver : public Audio::AudioStream {
public:
- AdlibDriver(Audio::Mixer *mixer);
+ AdlibDriver(Audio::Mixer *mixer, bool v2);
~AdlibDriver();
int callback(int opcode, ...);
@@ -241,7 +241,7 @@ private:
}
uint8 *getInstrument(int instrumentId) {
- return _soundData + READ_LE_UINT16(_soundData + 500 + 2 * instrumentId);
+ return _soundData + READ_LE_UINT16(_soundData + (_v2 ? 1000 : 500) + 2 * instrumentId);
}
void setupPrograms();
@@ -407,14 +407,18 @@ private:
Common::Mutex _mutex;
Audio::Mixer *_mixer;
+ bool _v2;
+
void lock() { _mutex.lock(); }
void unlock() { _mutex.unlock(); }
};
-AdlibDriver::AdlibDriver(Audio::Mixer *mixer) {
+AdlibDriver::AdlibDriver(Audio::Mixer *mixer, bool v2) {
setupOpcodeList();
setupParserOpcodeTable();
+ _v2 = v2;
+
_mixer = mixer;
_flags = 0;
@@ -2209,7 +2213,8 @@ const int SoundAdlibPC::_kyra1NumSoundTriggers = ARRAYSIZE(SoundAdlibPC::_kyra1S
SoundAdlibPC::SoundAdlibPC(KyraEngine *engine, Audio::Mixer *mixer)
: Sound(engine, mixer), _driver(0), _trackEntries(), _soundDataPtr(0) {
memset(_trackEntries, 0, sizeof(_trackEntries));
- _driver = new AdlibDriver(mixer);
+ _v2 = (_engine->gameFlags().gameID == GI_KYRA2);
+ _driver = new AdlibDriver(mixer, _v2);
assert(_driver);
_sfxPlayingSound = -1;
@@ -2279,14 +2284,21 @@ void SoundAdlibPC::playSoundEffect(uint8 track) {
}
void SoundAdlibPC::play(uint8 track) {
- uint8 soundId = _trackEntries[track];
- if ((int8)soundId == -1 || !_soundDataPtr)
+ uint16 soundId = 0;
+
+ if (_v2)
+ soundId = READ_LE_UINT16(&_trackEntries[track<<1]);
+ else
+ soundId = _trackEntries[track];
+
+ if ((soundId == 0xFFFF && _v2) || (soundId == 0xFF && !_v2) || !_soundDataPtr)
return;
- soundId &= 0xFF;
+
while ((_driver->callback(16, 0) & 8)) {
// We call the system delay and not the game delay to avoid concurrency issues.
_engine->_system->delayMillis(10);
}
+
if (_sfxPlayingSound != -1) {
// Restore the sounds's normal values.
_driver->callback(10, _sfxPlayingSound, int(1), int(_sfxPriority));
@@ -2350,11 +2362,18 @@ void SoundAdlibPC::loadSoundFile(uint file) {
_driver->callback(8, int(-1));
_soundDataPtr = 0;
+ int soundDataSize = file_size;
uint8 *p = file_data;
- memcpy(_trackEntries, p, 120*sizeof(uint8));
- p += 120;
- int soundDataSize = file_size - 120;
+ if (_v2) {
+ memcpy(_trackEntries, p, 500);
+ p += 500;
+ soundDataSize -= 500;
+ } else {
+ memcpy(_trackEntries, p, 120);
+ p += 120;
+ soundDataSize -= 120;
+ }
_soundDataPtr = new uint8[soundDataSize];
assert(_soundDataPtr);