diff options
-rw-r--r-- | engines/kyra/scene_v2.cpp | 11 | ||||
-rw-r--r-- | engines/kyra/script_v2.cpp | 18 | ||||
-rw-r--r-- | engines/kyra/sound.h | 23 |
3 files changed, 47 insertions, 5 deletions
diff --git a/engines/kyra/scene_v2.cpp b/engines/kyra/scene_v2.cpp index bff7d6b6db..4b3242b724 100644 --- a/engines/kyra/scene_v2.cpp +++ b/engines/kyra/scene_v2.cpp @@ -81,9 +81,10 @@ void KyraEngine_v2::enterNewScene(uint16 newScene, int facing, int unk1, int unk } bool newSoundFile = false; + uint32 waitTime = 0; if (_sceneList[newScene].sound != _lastMusicCommand) { newSoundFile = true; - //XXX + waitTime = _system->getMillis() + 1000; _sound->beginFadeOut(); } @@ -113,7 +114,13 @@ void KyraEngine_v2::enterNewScene(uint16 newScene, int facing, int unk1, int unk _sceneExit4 = scene.exit4; if (newSoundFile) { - //XXX while (snd_isPlaying()) ; + if (_sound->getMusicType() == Sound::kAdlib) { + while (0/*snd_isPlaying()*/) + _system->delayMillis(10); + } else { + while (waitTime > _system->getMillis()) + _system->delayMillis(10); + } snd_loadSoundFile(_sceneList[newScene].sound); } diff --git a/engines/kyra/script_v2.cpp b/engines/kyra/script_v2.cpp index cde2bb51d5..77efc780a7 100644 --- a/engines/kyra/script_v2.cpp +++ b/engines/kyra/script_v2.cpp @@ -1675,7 +1675,14 @@ int KyraEngine_v2::o2_getBoolFromStack(ScriptState *script) { int KyraEngine_v2::o2_getSfxDriver(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v2::o2_getSfxDriver(%p) ()", (const void *)script); - return 1; // HACK: this is AdLib driver, maybe we should return 6 for MT-32 or 7 for General MIDI too when we're using that + if (_sound->getSfxType() == Sound::kAdlib) + return 1; + else if (_sound->getSfxType() == Sound::kMidiMT32) + return 6; + else if (_sound->getSfxType() == Sound::kMidiGM) + return 7; + // TODO: find nice default value + return 0; } int KyraEngine_v2::o2_getVocSupport(ScriptState *script) { @@ -1686,7 +1693,14 @@ int KyraEngine_v2::o2_getVocSupport(ScriptState *script) { int KyraEngine_v2::o2_getMusicDriver(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v2::o2_getMusicDriver(%p) ()", (const void *)script); - return 1; // HACK: this is AdLib driver, maybe we should return 6 for MT-32 or 7 for General MIDI too when we're using that + if (_sound->getMusicType() == Sound::kAdlib) + return 1; + else if (_sound->getMusicType() == Sound::kMidiMT32) + return 6; + else if (_sound->getMusicType() == Sound::kMidiGM) + return 7; + // TODO: find nice default value + return 0; } int KyraEngine_v2::o2_setVocHigh(ScriptState *script) { diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h index 11c5bf6ad6..29308f5b04 100644 --- a/engines/kyra/sound.h +++ b/engines/kyra/sound.h @@ -69,6 +69,16 @@ public: Sound(KyraEngine *vm, Audio::Mixer *mixer); virtual ~Sound(); + enum kType { + kAdlib, + kMidiMT32, + kMidiGM, + kTowns + }; + + virtual kType getMusicType() const = 0; + virtual kType getSfxType() const { return getMusicType(); } + /** * Initializes the output device. * @@ -221,6 +231,8 @@ public: SoundAdlibPC(KyraEngine *vm, Audio::Mixer *mixer); ~SoundAdlibPC(); + kType getMusicType() const { return kAdlib; } + bool init(); void process(); @@ -273,6 +285,8 @@ public: SoundMidiPC(KyraEngine *vm, Audio::Mixer *mixer, MidiDriver *driver); ~SoundMidiPC(); + kType getMusicType() const { return isMT32() ? kMidiMT32 : kMidiGM; } + bool init() { return true; } void updateVolumeSettings() { /*XXX*/ } @@ -302,7 +316,7 @@ public: void setPassThrough(bool b) { _passThrough = b; } void hasNativeMT32(bool nativeMT32); - bool isMT32() { return _nativeMT32; } + bool isMT32() const { return _nativeMT32; } private: void setVolume(int vol); @@ -343,6 +357,8 @@ public: SoundTowns(KyraEngine *vm, Audio::Mixer *mixer); ~SoundTowns(); + kType getMusicType() const { return kTowns; } + bool init(); void process(); @@ -398,6 +414,8 @@ public: SoundTowns_v2(KyraEngine *vm, Audio::Mixer *mixer); ~SoundTowns_v2(); + kType getMusicType() const { return kTowns; } + bool init(); void process(); @@ -424,6 +442,9 @@ public: MixedSoundDriver(KyraEngine *vm, Audio::Mixer *mixer, Sound *music, Sound *sfx) : Sound(vm, mixer), _music(music), _sfx(sfx) {} ~MixedSoundDriver() { delete _music; delete _sfx; } + kType getMusicType() const { return _music->getMusicType(); } + kType getSfxType() const { return _sfx->getSfxType(); } + bool init() { return (_music->init() && _sfx->init()); } void process() { _music->process(); _sfx->process(); } |