[Scummvm-git-logs] scummvm master -> 837ac7e7ecabcc0b90885759b5c4278ec800bf82

digitall dgturner at iee.org
Fri Aug 2 01:09:01 CEST 2019


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
837ac7e7ec TEENAGENT: Add debug commands to play voices and sound effects


Commit: 837ac7e7ecabcc0b90885759b5c4278ec800bf82
    https://github.com/scummvm/scummvm/commit/837ac7e7ecabcc0b90885759b5c4278ec800bf82
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2019-08-02T00:08:58+01:00

Commit Message:
TEENAGENT: Add debug commands to play voices and sound effects

Changed paths:
    engines/teenagent/console.cpp
    engines/teenagent/console.h
    engines/teenagent/inventory.cpp
    engines/teenagent/scene.cpp
    engines/teenagent/teenagent.cpp
    engines/teenagent/teenagent.h


diff --git a/engines/teenagent/console.cpp b/engines/teenagent/console.cpp
index 2304829..7192275 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 b569f98..39896b4 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 e854444..f77f6ed 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 bea8953..5a8589a 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 85c2104..12f5123 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 438f06d..f33c684 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();





More information about the Scummvm-git-logs mailing list