diff options
author | Dmitry Iskrich | 2016-06-14 19:03:11 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | 2387e721040335db27a1f8f46a73cdf047c27a6e (patch) | |
tree | d8223909f4596b75d8bd94ebaad021d6ef3592db | |
parent | 82094ed5c99bc96418efdde1b75018482c61e888 (diff) | |
download | scummvm-rg350-2387e721040335db27a1f8f46a73cdf047c27a6e.tar.gz scummvm-rg350-2387e721040335db27a1f8f46a73cdf047c27a6e.tar.bz2 scummvm-rg350-2387e721040335db27a1f8f46a73cdf047c27a6e.zip |
DIRECTOR: Play sound from MCI command
-rw-r--r-- | engines/director/director.cpp | 6 | ||||
-rw-r--r-- | engines/director/director.h | 6 | ||||
-rw-r--r-- | engines/director/lingo/lingo-funcs.cpp | 27 | ||||
-rw-r--r-- | engines/director/lingo/lingo.cpp | 2 | ||||
-rw-r--r-- | engines/director/lingo/lingo.h | 8 | ||||
-rw-r--r-- | engines/director/sound.cpp | 5 | ||||
-rw-r--r-- | engines/director/sound.h | 3 |
7 files changed, 45 insertions, 12 deletions
diff --git a/engines/director/director.cpp b/engines/director/director.cpp index 8a7cf7e615..577b15d915 100644 --- a/engines/director/director.cpp +++ b/engines/director/director.cpp @@ -68,8 +68,8 @@ DirectorEngine::~DirectorEngine() { Common::Error DirectorEngine::run() { debug("Starting v%d Director game", getVersion()); - _lingo = new Lingo(); - + _lingo = new Lingo(this); + _soundManager = new DirectorSound(); _lingo->parse("mci \"open MM\\T005045a.wav type WaveAudio alias T005045a\"\n\ mci \"play T005045a from 22710 to 32872\""); @@ -80,7 +80,7 @@ Common::Error DirectorEngine::run() { -- some more\n"); #endif - _soundManager = new DirectorSound(); + //FIXME _mainArchive = new RIFFArchive(); diff --git a/engines/director/director.h b/engines/director/director.h index 9750ad9cc8..fa854f1e4f 100644 --- a/engines/director/director.h +++ b/engines/director/director.h @@ -26,7 +26,7 @@ #include "common/scummsys.h" #include "engines/engine.h" - +#include "engines/director/sound.h" class OSystem; namespace Common { @@ -42,7 +42,7 @@ enum DirectorGameID { class Archive; struct DirectorGameDescription; class Lingo; -class DirectorSound; + class DirectorEngine : public ::Engine { public: @@ -56,7 +56,7 @@ public: Common::Platform getPlatform() const; Common::Language getLanguage() const; Common::String getEXEName() const; - + DirectorSound *getSoundManager() const { return _soundManager; } bool hasFeature(EngineFeature f) const; protected: diff --git a/engines/director/lingo/lingo-funcs.cpp b/engines/director/lingo/lingo-funcs.cpp index 1a878869d9..059671b04d 100644 --- a/engines/director/lingo/lingo-funcs.cpp +++ b/engines/director/lingo/lingo-funcs.cpp @@ -21,9 +21,10 @@ */ #include "engines/director/lingo/lingo.h" +#include "common/file.h" +#include "audio/decoders/wave.h" namespace Director { - enum MCITokenType { kMCITokenNone, @@ -119,11 +120,31 @@ int Lingo::func_mci(Common::String *s) { } switch (command) { - case kMCITokenOpen: + case kMCITokenOpen: { warning("MCI open file: %s, type: %s, alias: %s buffer: %s", params[0].c_str(), params[1].c_str(), params[2].c_str(), params[3].c_str()); + Common::File *file = new Common::File(); + if (!file->open(params[0])) { + warning("Failed to open %s", params[0].c_str()); + delete file; + return 0; + } + if (params[1] == "waveaudio") { + Audio::AudioStream *sound = Audio::makeWAVStream(file, DisposeAfterUse::YES); + _audioAliases[params[2]] = sound; + } + else + warning("Unhandled audio type %s", params[2].c_str()); + } break; - case kMCITokenPlay: + case kMCITokenPlay: { warning("MCI play file: %s, from: %s, to: %s, repeat: %s", params[0].c_str(), params[1].c_str(), params[2].c_str(), params[3].c_str()); + if (!_audioAliases.contains(params[0])) { + warning("Unknown alias %s", params[0].c_str()); + return 0; + } + //TODO seek + _vm->getSoundManager()->playMCI(*_audioAliases[params[0]]); + } break; default: warning("Unhandled MCI command: %s", s->c_str()); diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp index 3c80608685..7296e7496d 100644 --- a/engines/director/lingo/lingo.cpp +++ b/engines/director/lingo/lingo.cpp @@ -66,7 +66,7 @@ struct EventHandlerType { { kEventNone, 0 }, }; -Lingo::Lingo() { +Lingo::Lingo(DirectorEngine *vm) : _vm(vm) { g_lingo = this; for (const EventHandlerType *t = &eventHanlerDescs[0]; t->handler != kEventNone; ++t) diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index 4f66cee0b0..4f7f925c54 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -25,6 +25,10 @@ #include "common/debug.h" #include "common/hashmap.h" +#include "common/hash-str.h" +#include "audio/audiostream.h" +#include "common/str.h" +#include "engines/director/director.h" namespace Director { @@ -67,7 +71,7 @@ enum LEvent { class Lingo { public: - Lingo(); + Lingo(DirectorEngine *vm); ~Lingo(); void processEvent(LEvent event, int entityId); @@ -78,6 +82,8 @@ public: private: Common::HashMap<uint32, const char *> _eventHandlerTypes; + Common::HashMap<Common::String, Audio::AudioStream *> _audioAliases; + DirectorEngine *_vm; }; } // End of namespace Director diff --git a/engines/director/sound.cpp b/engines/director/sound.cpp index 8c757e256d..ea8b78e1a4 100644 --- a/engines/director/sound.cpp +++ b/engines/director/sound.cpp @@ -32,6 +32,7 @@ namespace Director { DirectorSound::DirectorSound() { _sound1 = new Audio::SoundHandle(); _sound2 = new Audio::SoundHandle(); + _scriptSound = new Audio::SoundHandle(); _mixer = g_system->getMixer(); } @@ -66,6 +67,10 @@ void DirectorSound::playAIFF(Common::String filename, uint8 soundChannel) { _mixer->playStream(Audio::Mixer::kSFXSoundType, _sound2, sound); } +void DirectorSound::playMCI(Audio::AudioStream &stream) { + _mixer->playStream(Audio::Mixer::kSFXSoundType, _scriptSound, &stream); +} + bool DirectorSound::isChannelActive(uint8 channelID) { if (channelID == 1) { return _mixer->isSoundHandleActive(*_sound1); diff --git a/engines/director/sound.h b/engines/director/sound.h index 8f36a3e247..3a56c989a6 100644 --- a/engines/director/sound.h +++ b/engines/director/sound.h @@ -34,7 +34,7 @@ class DirectorSound { private: Audio::SoundHandle *_sound1; Audio::SoundHandle *_sound2; - + Audio::SoundHandle *_scriptSound; Audio::Mixer *_mixer; public: @@ -42,6 +42,7 @@ public: void playWAV(Common::String filename, uint8 channelID); void playAIFF(Common::String filename, uint8 channelID); + void playMCI(Audio::AudioStream &stream); bool isChannelActive(uint8 channelID); void stopSound(); }; |