aboutsummaryrefslogtreecommitdiff
path: root/engines/zvision
diff options
context:
space:
mode:
authorrichiesams2013-08-05 00:14:20 -0500
committerrichiesams2013-08-05 00:14:20 -0500
commit6515e2d31bbbad55168b8b27142cdc50f366795d (patch)
tree6679c0923d74bb9da3eb9bb1f7670ad42327dbb5 /engines/zvision
parent20c892092907e66c6c13d1598b973486ba2fc95c (diff)
downloadscummvm-rg350-6515e2d31bbbad55168b8b27142cdc50f366795d.tar.gz
scummvm-rg350-6515e2d31bbbad55168b8b27142cdc50f366795d.tar.bz2
scummvm-rg350-6515e2d31bbbad55168b8b27142cdc50f366795d.zip
ZVISION: Add ActionMusic
Diffstat (limited to 'engines/zvision')
-rw-r--r--engines/zvision/actions.cpp59
-rw-r--r--engines/zvision/actions.h19
-rw-r--r--engines/zvision/scr_file_handling.cpp3
3 files changed, 78 insertions, 3 deletions
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp
index 9a8dee0e32..cd84a6b85e 100644
--- a/engines/zvision/actions.cpp
+++ b/engines/zvision/actions.cpp
@@ -22,11 +22,16 @@
#include "common/scummsys.h"
+#include "common/file.h"
+
+#include "audio/decoders/wave.h"
+
#include "zvision/actions.h"
#include "zvision/zvision.h"
#include "zvision/script_manager.h"
#include "zvision/render_manager.h"
#include "zvision/action_node.h"
+#include "zvision/zork_raw.h"
namespace ZVision {
@@ -103,6 +108,60 @@ bool ActionCrossfade::execute(ZVision *engine) {
//////////////////////////////////////////////////////////////////////////////
+// ActionMusic
+//////////////////////////////////////////////////////////////////////////////
+
+ActionMusic::ActionMusic(const Common::String &line) : _volume(255) {
+ uint type;
+ char fileNameBuffer[25];
+ uint loop;
+ uint volume = 255;
+
+ sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%u %25s %u %u)", &_key, &type, fileNameBuffer, &loop, &volume);
+
+ // type 4 are midi sound effect files
+ if (type == 4) {
+ _soundType = Audio::Mixer::kSFXSoundType;
+ _fileName = Common::String::format("midi/%s/%u.wav", fileNameBuffer, loop);
+ _loop = false;
+ } else {
+ // TODO: See what the other types are so we can specify the correct Mixer::SoundType. In the meantime use kPlainSoundType
+ _soundType = Audio::Mixer::kPlainSoundType;
+ _fileName = Common::String(fileNameBuffer);
+ _loop = loop == 1 ? true : false;
+ }
+
+ // Volume is optional. If it doesn't appear, assume full volume
+ if (volume != 255) {
+ // Volume in the script files is mapped to [0, 100], but the ScummVM mixer uses [0, 255]
+ _volume = volume * 255 / 100;
+ }
+}
+
+bool ActionMusic::execute(ZVision *engine) {
+ Audio::RewindableAudioStream *audioStream;
+
+ if (_fileName.contains(".wav")) {
+ Common::File file;
+ if (file.open(_fileName)) {
+ audioStream = Audio::makeWAVStream(&file, DisposeAfterUse::NO);
+ }
+ } else {
+ audioStream = makeRawZorkStream(_fileName, engine);
+ }
+
+ if (_loop) {
+ Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES);
+ engine->_mixer->playStream(_soundType, 0, loopingAudioStream, -1, _volume);
+ } else {
+ engine->_mixer->playStream(_soundType, 0, audioStream, -1, _volume);
+ }
+
+ return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
// ActionPreloadAnimation
//////////////////////////////////////////////////////////////////////////////
diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h
index 46b31e9bed..76db25adf0 100644
--- a/engines/zvision/actions.h
+++ b/engines/zvision/actions.h
@@ -25,7 +25,11 @@
#include "common/scummsys.h"
-#include "common/str.h"
+#include "audio/mixer.h"
+
+namespace Common {
+class String;
+}
namespace ZVision {
@@ -194,6 +198,19 @@ public:
private:
};
+class ActionMusic : public ResultAction {
+public:
+ ActionMusic(const Common::String &line);
+ bool execute(ZVision *engine);
+
+private:
+ uint32 _key;
+ Audio::Mixer::SoundType _soundType;
+ Common::String _fileName;
+ bool _loop;
+ byte _volume;
+};
+
class ActionPlayAnimation : public ResultAction {
public:
ActionPlayAnimation(const Common::String &line);
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index cd3cfe4269..9759fd89b1 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -200,8 +200,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (line.matchString("*:music*", true)) {
-
-
+ actionList.push_back(Common::SharedPtr<ResultAction>(new ActionMusic(line)));
} else if (line.matchString("*:pan_track*", true)) {