[Scummvm-cvs-logs] SF.net SVN: scummvm: [25313] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Wed Jan 31 19:35:51 CET 2007


Revision: 25313
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25313&view=rev
Author:   lordhoto
Date:     2007-01-31 10:35:50 -0800 (Wed, 31 Jan 2007)

Log Message:
-----------
Fix for bug #Fix for bug #1523200 ("KYRA1: Voice-only mode has no lips animation").

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/gui.cpp
    scummvm/trunk/engines/kyra/kyra.h
    scummvm/trunk/engines/kyra/script_v1.cpp
    scummvm/trunk/engines/kyra/sequences_v1.cpp
    scummvm/trunk/engines/kyra/sound.cpp
    scummvm/trunk/engines/kyra/text.cpp

Modified: scummvm/trunk/engines/kyra/gui.cpp
===================================================================
--- scummvm/trunk/engines/kyra/gui.cpp	2007-01-31 17:48:26 UTC (rev 25312)
+++ scummvm/trunk/engines/kyra/gui.cpp	2007-01-31 18:35:50 UTC (rev 25313)
@@ -204,34 +204,19 @@
 		return 1;
 	if (_itemInHand != -1) {
 		assert(_putDownFirst);
-		if (speechEnabled()) {
-			snd_voiceWaitForFinish();
-			snd_playVoiceFile(2000);
-		}
-		if (textEnabled())	
-			characterSays(_putDownFirst[0], 0, -2);
+		characterSays(2000, _putDownFirst[0], 0, -2);
 		return 1;
 	}
 	if (queryGameFlag(0xF1)) {
 		assert(_waitForAmulet);
-		if (speechEnabled()) {
-			snd_voiceWaitForFinish();
-			snd_playVoiceFile(2001);
-		}
-		if (textEnabled())	
-			characterSays(_waitForAmulet[0], 0, -2);	
+		characterSays(2001, _waitForAmulet[0], 0, -2);	
 		return 1;
 	}
 	if (!queryGameFlag(0x55+jewel)) {
 		assert(_blackJewel);
 		_animator->makeBrandonFaceMouse();
 		drawJewelPress(jewel, 1);
-		if (speechEnabled()) {
-			snd_voiceWaitForFinish();
-			snd_playVoiceFile(2002);
-		}
-		if (textEnabled())	
-			characterSays(_blackJewel[0], 0, -2);
+		characterSays(2002, _blackJewel[0], 0, -2);
 		return 1;
 	}
 	drawJewelPress(jewel, 0);
@@ -258,12 +243,7 @@
 		} else if (_brandonStatusBit == 0) {
 			seq_brandonHealing();
 			assert(_healingTip);
-			if (speechEnabled()) {
-				snd_voiceWaitForFinish();
-				snd_playVoiceFile(2003);
-			}
-			if (textEnabled())	
-				characterSays(_healingTip[0], 0, -2);
+			characterSays(2003, _healingTip[0], 0, -2);
 		}
 		break;
 		
@@ -274,12 +254,8 @@
 	case 2:
 		if (_brandonStatusBit & 1) {
 			assert(_wispJewelStrings);
-			if (speechEnabled()) {
-				snd_voiceWaitForFinish();
-				snd_playVoiceFile(2004);
-			}
 			if (textEnabled())	
-				characterSays(_wispJewelStrings[0], 0, -2);
+				characterSays(2004, _wispJewelStrings[0], 0, -2);
 		} else {
 			if (_brandonStatusBit & 2) {
 				// XXX
@@ -303,12 +279,7 @@
 	case 3:
 		seq_dispelMagicAnimation();
 		assert(_magicJewelString);
-		if (speechEnabled()) {
-			snd_voiceWaitForFinish();
-			snd_playVoiceFile(2007);
-		}
-		if (textEnabled())	
-			characterSays(_magicJewelString[0], 0, -2);
+		characterSays(2007, _magicJewelString[0], 0, -2);
 		break;
 		
 	default:

Modified: scummvm/trunk/engines/kyra/kyra.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra.h	2007-01-31 17:48:26 UTC (rev 25312)
+++ scummvm/trunk/engines/kyra/kyra.h	2007-01-31 18:35:50 UTC (rev 25313)
@@ -289,6 +289,8 @@
 	void snd_playTheme(int file, int track = 0);
 	void snd_playVoiceFile(int id);
 	void snd_voiceWaitForFinish(bool ingame = true);
+	bool snd_voiceIsPlaying();
+	void snd_stopVoice();
 	void snd_playSoundEffect(int track);
 	void snd_playWanderScoreViaMap(int command, int restart);
 
@@ -487,8 +489,8 @@
 	void backupChatPartnerAnimFrame(int8 charNum);
 	void restoreChatPartnerAnimFrame(int8 charNum);
 	void endCharacterChat(int8 charNum, int16 arg_4);
-	void waitForChatToFinish(int16 chatDuration, const char *str, uint8 charNum);
-	void characterSays(const char *chatStr, int8 charNum, int8 chatDuration);
+	void waitForChatToFinish(int vocFile, int16 chatDuration, const char *str, uint8 charNum);
+	void characterSays(int vocFile, const char *chatStr, int8 charNum, int8 chatDuration);
 
 	void setCharactersPositions(int character);
 	int setGameFlag(int flag);

Modified: scummvm/trunk/engines/kyra/script_v1.cpp
===================================================================
--- scummvm/trunk/engines/kyra/script_v1.cpp	2007-01-31 17:48:26 UTC (rev 25312)
+++ scummvm/trunk/engines/kyra/script_v1.cpp	2007-01-31 18:35:50 UTC (rev 25313)
@@ -45,15 +45,10 @@
 	_skipFlag = false;
 	if (_flags.isTalkie) {
 		debugC(3, kDebugLevelScriptFuncs, "o1_characterSays(%p) (%d, '%s', %d, %d)", (const void *)script, stackPos(0), stackPosString(1), stackPos(2), stackPos(3));
-		if (speechEnabled()) {
-			snd_voiceWaitForFinish();
-			snd_playVoiceFile(stackPos(0));
-		}
-		if (textEnabled())
-			characterSays(stackPosString(1), stackPos(2), stackPos(3));
+		characterSays(stackPos(0), stackPosString(1), stackPos(2), stackPos(3));
 	} else {
 		debugC(3, kDebugLevelScriptFuncs, "o1_characterSays(%p) ('%s', %d, %d)", (const void *)script, stackPosString(0), stackPos(1), stackPos(2));
-		characterSays(stackPosString(0), stackPos(1), stackPos(2));
+		characterSays(-1, stackPosString(0), stackPos(1), stackPos(2));
 	}
 
 	return 0;
@@ -644,6 +639,8 @@
 
 int KyraEngine::o1_restoreCustomPrintBackground(ScriptState *script) {
 	debugC(3, kDebugLevelScriptFuncs, "o1_restoreCustomPrintBackground(%p) ()", (const void *)script);
+	snd_voiceWaitForFinish();
+	snd_stopVoice();
 	_text->restoreTalkTextMessageBkgd(2, 0);
 	return 0;
 }

Modified: scummvm/trunk/engines/kyra/sequences_v1.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sequences_v1.cpp	2007-01-31 17:48:26 UTC (rev 25312)
+++ scummvm/trunk/engines/kyra/sequences_v1.cpp	2007-01-31 18:35:50 UTC (rev 25313)
@@ -363,18 +363,8 @@
 	freeShapes123();
 	_screen->showMouse();
 	assert(_poisonGone);
-	if (speechEnabled()) {
-		snd_voiceWaitForFinish();
-		snd_playVoiceFile(2010);
-	}
-	if (textEnabled())
-		characterSays(_poisonGone[0], 0, -2);
-	if (speechEnabled()) {
-		snd_voiceWaitForFinish();
-		snd_playVoiceFile(2011);
-	}
-	if (textEnabled())
-		characterSays(_poisonGone[1], 0, -2);
+	characterSays(2010, _poisonGone[0], 0, -2);
+	characterSays(2011, _poisonGone[1], 0, -2);
 }
 
 void KyraEngine::seq_poisonDeathNow(int now) {
@@ -387,34 +377,14 @@
 	if (_poisonDeathCounter >= 2) {
 		snd_playWanderScoreViaMap(1, 1);
 		assert(_thePoison);
-		if (speechEnabled()) {
-			snd_voiceWaitForFinish();
-			snd_playVoiceFile(7000);
-		}
-		if (textEnabled())
-			characterSays(_thePoison[0], 0, -2);
-		if (speechEnabled()) {
-			snd_voiceWaitForFinish();
-			snd_playVoiceFile(7001);
-		}
-		if (textEnabled())
-			characterSays(_thePoison[1], 0, -2);
+		characterSays(7000, _thePoison[0], 0, -2);
+		characterSays(7001, _thePoison[1], 0, -2);
 		seq_poisonDeathNowAnim();
 		_deathHandler = 3;
 	} else {
 		assert(_thePoison);
-		if (speechEnabled()) {
-			snd_voiceWaitForFinish();
-			snd_playVoiceFile(7002);
-		}
-		if (textEnabled())
-			characterSays(_thePoison[2], 0, -2);
-		if (speechEnabled()) {
-			snd_voiceWaitForFinish();
-			snd_playVoiceFile(7004);
-		}
-		if (textEnabled())
-			characterSays(_thePoison[3], 0, -2);
+		characterSays(7002, _thePoison[2], 0, -2);
+		characterSays(7004, _thePoison[3], 0, -2);
 	}
 }
 
@@ -506,20 +476,10 @@
 	
 	if (soundType == 1) {
 		assert(_fluteString);
-		if (speechEnabled()) {
-			snd_voiceWaitForFinish();
-			snd_playVoiceFile(1000);
-		}
-		if (textEnabled())
-			characterSays(_fluteString[0], 0, -2);
+		characterSays(1000, _fluteString[0], 0, -2);
 	} else if (soundType == 2) {
 		assert(_fluteString);
-		if (speechEnabled()) {
-			snd_voiceWaitForFinish();
-			snd_playVoiceFile(1001);
-		}
-		if (textEnabled())
-			characterSays(_fluteString[1], 0, -2);
+		characterSays(1001, _fluteString[1], 0, -2);
 	}
 }
 
@@ -790,12 +750,7 @@
 	
 	if (item >= 60 && item <= 77) {
 		assert(_flaskFull);
-		if (speechEnabled()) {
-			snd_voiceWaitForFinish();
-			snd_playVoiceFile(8006);
-		}
-		if (textEnabled())
-			characterSays(_flaskFull[0], 0, -2);
+		characterSays(8006, _flaskFull[0], 0, -2);
 	} else if (item == 78) {
 		assert(type >= 0 && type < ARRAYSIZE(flaskTable1));
 		newItem = flaskTable1[type];
@@ -813,16 +768,11 @@
 	_itemInHand = newItem;
 	assert(_fullFlask);
 	assert(type < _fullFlask_Size && type >= 0);
-	if (speechEnabled()) {
-		snd_voiceWaitForFinish();
-		static const uint16 voiceEntries[] = {
-			0x1F40, 0x1F41, 0x1F42, 0x1F45
-		};
-		assert(type < ARRAYSIZE(voiceEntries));
-		snd_playVoiceFile(voiceEntries[type]);
-	}
-	if (textEnabled())
-		characterSays(_fullFlask[type], 0, -2);
+	static const uint16 voiceEntries[] = {
+		0x1F40, 0x1F41, 0x1F42, 0x1F45
+	};
+	assert(type < ARRAYSIZE(voiceEntries));
+	characterSays(voiceEntries[type], _fullFlask[type], 0, -2);
 }
 
 void KyraEngine::seq_playDrinkPotionAnim(int item, int unk2, int flags) {

Modified: scummvm/trunk/engines/kyra/sound.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound.cpp	2007-01-31 17:48:26 UTC (rev 25312)
+++ scummvm/trunk/engines/kyra/sound.cpp	2007-01-31 18:35:50 UTC (rev 25313)
@@ -538,6 +538,16 @@
 	}
 }
 
+void KyraEngine::snd_stopVoice() {
+	debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine::snd_stopVoice()");
+	_sound->voiceStop();
+}
+
+bool KyraEngine::snd_voiceIsPlaying() {
+	debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine::snd_voiceIsPlaying()");
+	return _sound->voiceIsPlaying();
+}
+
 // static res
 
 const Sound::SpeechCodecs Sound::_supportedCodes[] = {

Modified: scummvm/trunk/engines/kyra/text.cpp
===================================================================
--- scummvm/trunk/engines/kyra/text.cpp	2007-01-31 17:48:26 UTC (rev 25312)
+++ scummvm/trunk/engines/kyra/text.cpp	2007-01-31 18:35:50 UTC (rev 25313)
@@ -32,10 +32,11 @@
 
 namespace Kyra {
 
-void KyraEngine::waitForChatToFinish(int16 chatDuration, const char *chatStr, uint8 charNum) {
+void KyraEngine::waitForChatToFinish(int vocFile, int16 chatDuration, const char *chatStr, uint8 charNum) {
 	debugC(9, kDebugLevelMain, "KyraEngine::waitForChatToFinish(%i, %s, %i)", chatDuration, chatStr, charNum); 
 	bool hasUpdatedNPCs = false;
 	bool runLoop = true;
+	bool drawText = textEnabled();
 	uint8 currPage;
 	OSystem::Event event;
 
@@ -61,6 +62,11 @@
 	if (chatDuration != -1)
 		chatDuration *= _tickLength;
 
+	if (vocFile != -1) {
+		snd_voiceWaitForFinish();
+		snd_playVoiceFile(vocFile);
+	}
+
 	disableTimer(14);
 	disableTimer(18);
 	disableTimer(19);
@@ -93,16 +99,18 @@
 		_animator->preserveAnyChangedBackgrounds();
 		_animator->prepDrawAllObjects();
 
-		currPage = _screen->_curPage;
-		_screen->_curPage = 2;
-		_text->printCharacterText(chatStr, charNum, _characterList[charNum].x1);
-		_animator->_updateScreen = true;
-		_screen->_curPage = currPage;
+		if (drawText) {
+			currPage = _screen->_curPage;
+			_screen->_curPage = 2;
+			_text->printCharacterText(chatStr, charNum, _characterList[charNum].x1);
+			_animator->_updateScreen = true;
+			_screen->_curPage = currPage;
+		}
 
 		_animator->copyChangedObjectsForward(0);
 		updateTextFade();
 
-		if ((chatDuration < (int16)(_system->getMillis() - timeAtStart)) && chatDuration != -1)
+		if ((chatDuration < (int16)(_system->getMillis() - timeAtStart)) && chatDuration != -1 && (!drawText || !snd_voiceIsPlaying()))
 			break;
 
 		uint32 nextTime = loopStart + _gameSpeed;
@@ -136,6 +144,9 @@
 			runLoop = false;
 	}
 
+	snd_voiceWaitForFinish();
+	snd_stopVoice();
+
 	enableTimer(14);
 	enableTimer(15);
 	enableTimer(18);
@@ -247,7 +258,7 @@
 	return returnValue;
 }
 
-void KyraEngine::characterSays(const char *chatStr, int8 charNum, int8 chatDuration) {
+void KyraEngine::characterSays(int vocFile, const char *chatStr, int8 charNum, int8 chatDuration) {
 	debugC(9, kDebugLevelMain, "KyraEngine::characterSays('%s', %i, %d)", chatStr, charNum, chatDuration);
 	uint8 startAnimFrames[] =  { 0x10, 0x32, 0x56, 0x0, 0x0, 0x0 };
 
@@ -287,32 +298,39 @@
 
 	_text->_talkMessageY = yPos;
 	_text->_talkMessageH = lineNum * 10;
-	_animator->restoreAllObjectBackgrounds();
+	
+	if (textEnabled()) {
+		_animator->restoreAllObjectBackgrounds();
 
-	_screen->copyRegion(12, _text->_talkMessageY, 12, 136, 296, _text->_talkMessageH, 2, 2);
-	_screen->hideMouse();
+		_screen->copyRegion(12, _text->_talkMessageY, 12, 136, 296, _text->_talkMessageH, 2, 2);
+		_screen->hideMouse();
 
-	_text->printCharacterText(processedString, charNum, _characterList[charNum].x1);
-	_screen->showMouse();
+		_text->printCharacterText(processedString, charNum, _characterList[charNum].x1);
+		_screen->showMouse();
+	}
 
 	if (chatDuration == -2)
 		chatTicks = strlen(processedString) * 9;
 	else
 		chatTicks = chatDuration;
 
-	waitForChatToFinish(chatTicks, chatStr, charNum);
+	if (!speechEnabled())
+		vocFile = -1;
+	waitForChatToFinish(vocFile, chatTicks, chatStr, charNum);
 
-	_animator->restoreAllObjectBackgrounds();
+	if (textEnabled()) {
+		_animator->restoreAllObjectBackgrounds();
 
-	_screen->copyRegion(12, 136, 12, _text->_talkMessageY, 296, _text->_talkMessageH, 2, 2);
-	_animator->preserveAllBackgrounds();
-	_animator->prepDrawAllObjects();
-	_screen->hideMouse();
+		_screen->copyRegion(12, 136, 12, _text->_talkMessageY, 296, _text->_talkMessageH, 2, 2);
+		_animator->preserveAllBackgrounds();
+		_animator->prepDrawAllObjects();
+		_screen->hideMouse();
 
-	_screen->copyRegion(12, _text->_talkMessageY, 12, _text->_talkMessageY, 296, _text->_talkMessageH, 2, 0);
-	_screen->showMouse();
-	_animator->flagAllObjectsForRefresh();
-	_animator->copyChangedObjectsForward(0);
+		_screen->copyRegion(12, _text->_talkMessageY, 12, _text->_talkMessageY, 296, _text->_talkMessageH, 2, 0);
+		_screen->showMouse();
+		_animator->flagAllObjectsForRefresh();
+		_animator->copyChangedObjectsForward(0);
+	}
 
 	if (chatPartnerNum != -1 && chatPartnerNum < 5)
 		restoreChatPartnerAnimFrame(chatPartnerNum);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list