aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/teenagent/console.cpp37
-rw-r--r--engines/teenagent/console.h2
-rw-r--r--engines/teenagent/inventory.cpp2
-rw-r--r--engines/teenagent/scene.cpp2
-rw-r--r--engines/teenagent/teenagent.cpp6
-rw-r--r--engines/teenagent/teenagent.h3
6 files changed, 46 insertions, 6 deletions
diff --git a/engines/teenagent/console.cpp b/engines/teenagent/console.cpp
index 2304829782..719227577a 100644
--- a/engines/teenagent/console.cpp
+++ b/engines/teenagent/console.cpp
@@ -21,6 +21,7 @@
*/
#include "teenagent/console.h"
+#include "teenagent/resources.h"
#include "teenagent/teenagent.h"
namespace TeenAgent {
@@ -33,6 +34,8 @@ Console::Console(TeenAgentEngine *engine) : _engine(engine) {
registerCmd("animation", WRAP_METHOD(Console, playAnimation));
registerCmd("actor_animation", WRAP_METHOD(Console, playActorAnimation));
registerCmd("call", WRAP_METHOD(Console, call));
+ registerCmd("playSound", WRAP_METHOD(Console, playSound));
+ registerCmd("playVoice", WRAP_METHOD(Console, playVoice));
}
bool Console::enableObject(int argc, const char **argv) {
@@ -163,4 +166,38 @@ bool Console::call(int argc, const char **argv) {
return true;
}
+bool Console::playSound(int argc, const char **argv) {
+ uint32 fileCount = _engine->res->sam_sam.fileCount();
+ if (argc < 2) {
+ debugPrintf("usage: %s index(1-%d)\n", argv[0], fileCount);
+ return true;
+ }
+
+ uint index = atoi(argv[1]);
+ if (index <= 0 || index > fileCount) {
+ debugPrintf("invalid value\n");
+ return true;
+ }
+
+ _engine->playSoundNow(&_engine->res->sam_sam, index);
+ return true;
+}
+
+bool Console::playVoice(int argc, const char **argv) {
+ uint32 fileCount = _engine->res->voices.fileCount();
+ if (argc < 2) {
+ debugPrintf("usage: %s index(1-%d)\n", argv[0], fileCount);
+ return true;
+ }
+
+ uint index = atoi(argv[1]);
+ if (index <= 0 || index > fileCount) {
+ debugPrintf("invalid value\n");
+ return true;
+ }
+
+ _engine->playSoundNow(&_engine->res->voices, index);
+ return true;
+}
+
}
diff --git a/engines/teenagent/console.h b/engines/teenagent/console.h
index b569f98d8f..39896b4e08 100644
--- a/engines/teenagent/console.h
+++ b/engines/teenagent/console.h
@@ -40,6 +40,8 @@ private:
bool playAnimation(int argc, const char **argv);
bool playActorAnimation(int argc, const char **argv);
bool call(int argc, const char **argv);
+ bool playSound(int argc, const char **argv);
+ bool playVoice(int argc, const char **argv);
TeenAgentEngine *_engine;
};
diff --git a/engines/teenagent/inventory.cpp b/engines/teenagent/inventory.cpp
index e8544446dc..f77f6ed382 100644
--- a/engines/teenagent/inventory.cpp
+++ b/engines/teenagent/inventory.cpp
@@ -222,7 +222,7 @@ bool Inventory::processEvent(const Common::Event &event) {
remove(id2);
debugC(0, kDebugInventory, "adding object %u", newObj);
add(newObj);
- _vm->playSoundNow(69);
+ _vm->playSoundNow(&_vm->res->sam_sam, 69);
}
uint16 msg = READ_LE_UINT16(table + 3);
_vm->displayMessage(msg);
diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp
index bea8953f21..5a8589a7cd 100644
--- a/engines/teenagent/scene.cpp
+++ b/engines/teenagent/scene.cpp
@@ -891,7 +891,7 @@ bool Scene::render(bool tickGame, bool tickMark, uint32 messageDelta) {
Sound &sound = *i;
if (sound.delay == 0) {
debugC(1, kDebugScene, "sound %u started", sound.id);
- _vm->playSoundNow(sound.id);
+ _vm->playSoundNow(&_vm->res->sam_sam, sound.id);
i = sounds.erase(i);
} else {
sound.delay -= gameDelta;
diff --git a/engines/teenagent/teenagent.cpp b/engines/teenagent/teenagent.cpp
index 85c21041ea..12f5123ad0 100644
--- a/engines/teenagent/teenagent.cpp
+++ b/engines/teenagent/teenagent.cpp
@@ -1032,15 +1032,15 @@ void TeenAgentEngine::wait(uint16 frames) {
scene->push(event);
}
-void TeenAgentEngine::playSoundNow(byte id) {
- uint size = res->sam_sam.getSize(id);
+void TeenAgentEngine::playSoundNow(Pack *pack, byte id) {
+ uint size = pack->getSize(id);
if (size == 0) {
warning("skipping invalid sound %u", id);
return;
}
byte *data = (byte *)malloc(size);
- res->sam_sam.read(id, data, size);
+ pack->read(id, data, size);
debug(3, "playing %u samples...", size);
Audio::AudioStream *stream = Audio::makeRawStream(data, size, 11025, 0);
diff --git a/engines/teenagent/teenagent.h b/engines/teenagent/teenagent.h
index 438f06d189..f33c684afd 100644
--- a/engines/teenagent/teenagent.h
+++ b/engines/teenagent/teenagent.h
@@ -61,6 +61,7 @@ class Scene;
class MusicPlayer;
class Resources;
class Inventory;
+class Pack;
// Engine Debug Flags
enum {
@@ -137,7 +138,7 @@ public:
void playMusic(byte id); //schedules play
void playSound(byte id, byte skipFrames);
- void playSoundNow(byte id);
+ void playSoundNow(Pack *pack, byte id);
void enableObject(byte id, byte sceneId = 0);
void disableObject(byte id, byte sceneId = 0);
void hideActor();