[Scummvm-cvs-logs] scummvm master -> 9b0bf9e21555fb1760d45792ab4bd6bcb67d08c6

dreammaster dreammaster at scummvm.org
Tue Aug 11 04:02:02 CEST 2015


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:
9b0bf9e215 SHERLOCK: RT: Beginnings of speech code


Commit: 9b0bf9e21555fb1760d45792ab4bd6bcb67d08c6
    https://github.com/scummvm/scummvm/commit/9b0bf9e21555fb1760d45792ab4bd6bcb67d08c6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-08-10T22:01:02-04:00

Commit Message:
SHERLOCK: RT: Beginnings of speech code

Changed paths:
    engines/sherlock/resources.cpp
    engines/sherlock/sound.cpp
    engines/sherlock/sound.h
    engines/sherlock/talk.cpp
    engines/sherlock/talk.h
    engines/sherlock/tattoo/tattoo_talk.cpp



diff --git a/engines/sherlock/resources.cpp b/engines/sherlock/resources.cpp
index 206d717..8ec2c8c 100644
--- a/engines/sherlock/resources.cpp
+++ b/engines/sherlock/resources.cpp
@@ -116,6 +116,10 @@ Resources::Resources(SherlockEngine *vm) : _vm(vm), _cache(vm) {
 }
 
 void Resources::addToCache(const Common::String &filename) {
+	// Return immediately if the library has already been loaded
+	if (_indexes.contains(filename))
+		return;
+	
 	_cache.load(filename);
 
 	// Check to see if the file is a library
@@ -218,6 +222,10 @@ void Resources::loadLibraryIndex(const Common::String &libFilename,
 		Common::SeekableReadStream *stream, bool isNewStyle) {
 	uint32 offset, nextOffset;
 
+	// Return immediately if the library has already been loaded
+	if (_indexes.contains(libFilename))
+		return;
+
 	// Create an index entry
 	_indexes[libFilename] = LibraryIndex();
 	LibraryIndex &index = _indexes[libFilename];
diff --git a/engines/sherlock/sound.cpp b/engines/sherlock/sound.cpp
index e63efee..ffc626c 100644
--- a/engines/sherlock/sound.cpp
+++ b/engines/sherlock/sound.cpp
@@ -57,6 +57,7 @@ Sound::Sound(SherlockEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) {
 	_voices = 0;
 	_diskSoundPlaying = false;
 	_soundPlaying = false;
+	_speechPlaying = false;
 	_soundIsOn = &_soundPlaying;
 	_curPriority = 0;
 	_digiBuf = nullptr;
@@ -174,15 +175,6 @@ bool Sound::playSound(const Common::String &name, WaitType waitType, int priorit
 
 			free(data);
 
-#if 0
-			// Debug : used to dump files
-			Common::DumpFile outFile;
-			outFile.open(filename);
-			outFile.write(decoded, (size - 2) * 2);
-			outFile.flush();
-			outFile.close();
-#endif
-
 			audioStream = Audio::makeRawStream(decoded, (size - 2) * 2, rate, Audio::FLAG_UNSIGNED, DisposeAfterUse::YES);
 		} else {
 			audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
@@ -270,5 +262,29 @@ void Sound::setVolume(int volume) {
 	warning("TODO: setVolume - %d", volume);
 }
 
+void Sound::playSpeech(const Common::String &name) {
+	Resources &res = *_vm->_res;
+	Scene &scene = *_vm->_scene;
+	stopSpeech();
+
+	Common::String libraryName = Common::String::format("speech%02d.lib", scene._currentScene);
+	res.addToCache(libraryName);
+
+	// TODO: Doesn't seem to be WAV files. Need to find out what format it is..
+	Common::SeekableReadStream *stream = res.load(name, libraryName);
+	Audio::AudioStream *audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
+	_mixer->playStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume);
+	_speechPlaying = true;
+}
+
+void Sound::stopSpeech() {
+	_mixer->stopHandle(_speechHandle);
+}
+
+bool Sound::isSpeechPlaying() {
+	_speechOn = _mixer->isSoundHandleActive(_speechHandle);
+	return _speechPlaying;
+}
+
 } // End of namespace Sherlock
 
diff --git a/engines/sherlock/sound.h b/engines/sherlock/sound.h
index d757646..a52de1c 100644
--- a/engines/sherlock/sound.h
+++ b/engines/sherlock/sound.h
@@ -47,6 +47,7 @@ private:
 	Audio::Mixer *_mixer;
 	Audio::SoundHandle _scalpelEffectsHandle;
 	Audio::SoundHandle _tattooEffectsHandle[MAX_MIXER_CHANNELS];
+	Audio::SoundHandle _speechHandle;
 	int _curPriority;
 
 	byte decodeSample(byte sample, byte& reference, int16& scale);
@@ -57,6 +58,7 @@ public:
 	bool _speechOn;
 	bool _diskSoundPlaying;
 	bool _soundPlaying;
+	bool _speechPlaying;
 	bool *_soundIsOn;
 	byte *_digiBuf;
 	int _soundVolume;
@@ -101,6 +103,21 @@ public:
 	Audio::SoundHandle getFreeSoundHandle();
 
 	void setVolume(int volume);
+
+	/**
+	 * Play a specified voice resource
+	 */
+	void playSpeech(const Common::String &name);
+
+	/**
+	 * Stop any currently playing speech
+	 */
+	void stopSpeech();
+
+	/**
+	 * Returns true if speech is currently playing
+	 */
+	bool isSpeechPlaying();
 };
 
 } // End of namespace Sherlock
diff --git a/engines/sherlock/talk.cpp b/engines/sherlock/talk.cpp
index 1b12c6a..a998c58 100644
--- a/engines/sherlock/talk.cpp
+++ b/engines/sherlock/talk.cpp
@@ -571,6 +571,10 @@ void Talk::loadTalkFile(const Common::String &filename) {
 	Common::String talkFile = chP ? Common::String(filename.c_str(), chP) + ".tlk" :
 		Common::String(filename.c_str(), filename.c_str() + 7) + ".tlk";
 
+	// Create the base of the sound filename used for talking in Rose Tattoo
+	if (IS_ROSE_TATTOO && _scriptMoreFlag != 1)
+		sound._talkSoundFile = filename + ".";
+
 	// Open the talk file for reading
 	Common::SeekableReadStream *talkStream = res.load(talkFile);
 	_converseNum = res.resourceIndex();
@@ -924,8 +928,13 @@ int Talk::waitForMore(int delay) {
 		events.setCursor(ui._lookScriptFlag ? MAGNIFY : ARROW);
 	}
 
+	if (sound._speechOn && !sound._talkSoundFile.empty()) {
+		sound.playSpeech(sound._talkSoundFile);
+		sound._talkSoundFile.setChar(sound._talkSoundFile.lastChar() + 1, sound._talkSoundFile.size() - 1);
+	}
+
 	do {
-		if (sound._speechOn && !*sound._soundIsOn)
+		if (IS_SERRATED_SCALPEL && sound._speechOn && !*sound._soundIsOn)
 			people._portrait._frameNumber = -1;
 
 		scene.doBgAnim();
@@ -992,6 +1001,7 @@ int Talk::waitForMore(int delay) {
 		break;
 	}
 
+
 	sound._speechOn = false;
 	events.setCursor(_talkToAbort ? ARROW : oldCursor);
 	events._pressed = events._released = false;
diff --git a/engines/sherlock/talk.h b/engines/sherlock/talk.h
index 767c7c8..87ed547 100644
--- a/engines/sherlock/talk.h
+++ b/engines/sherlock/talk.h
@@ -185,7 +185,6 @@ protected:
 	Common::Stack<SequenceEntry> _sequenceStack;
 	Common::Stack<ScriptStackEntry> _scriptStack;
 	Common::Array<TalkHistoryEntry> _talkHistory;
-	int _speaker;
 	int _talkIndex;
 	int _scriptSelect;
 	int _talkStealth;
@@ -276,6 +275,7 @@ public:
 	bool _moreTalkUp, _moreTalkDown;
 	int _converseNum;
 	const byte *_opcodes;
+	int _speaker;
 public:
 	static Talk *init(SherlockEngine *vm);
 	virtual ~Talk() {}
diff --git a/engines/sherlock/tattoo/tattoo_talk.cpp b/engines/sherlock/tattoo/tattoo_talk.cpp
index ddd863f..d16e26f 100644
--- a/engines/sherlock/tattoo/tattoo_talk.cpp
+++ b/engines/sherlock/tattoo/tattoo_talk.cpp
@@ -25,7 +25,7 @@
 #include "sherlock/tattoo/tattoo_people.h"
 #include "sherlock/tattoo/tattoo_scene.h"
 #include "sherlock/tattoo/tattoo_user_interface.h"
-#include "sherlock/sherlock.h"
+#include "sherlock/tattoo/tattoo.h"
 #include "sherlock/screen.h"
 
 namespace Sherlock {
@@ -184,9 +184,15 @@ TattooTalk::TattooTalk(SherlockEngine *vm) : Talk(vm), _talkWidget(vm), _passwor
 }
 
 void TattooTalk::talkInterface(const byte *&str) {
+	TattooEngine &vm = *(TattooEngine *)_vm;
+	Sound &sound = *_vm->_sound;
+	Talk &talk = *_vm->_talk;
 	TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
 	const byte *s = str;
 
+	if (!vm._textWindowsOn && sound._speechOn && talk._speaker != -1)
+		return;
+
 	// Move to past the end of the text string
 	_charCount = 0;
 	while ((*str < TATTOO_OPCODES[0] || *str == TATTOO_OPCODES[OP_NULL]) && *str) {






More information about the Scummvm-git-logs mailing list