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

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sat Oct 13 08:57:47 CEST 2007


Revision: 29201
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29201&view=rev
Author:   lordhoto
Date:     2007-10-12 23:57:47 -0700 (Fri, 12 Oct 2007)

Log Message:
-----------
- moved some voice functionallity from KyraEngine_v1 to KyraEngine
HoF:
- added voice support
- implemented opcodes
  -> o2_setVocHigh 167
  -> o2_getVocHigh 168
  -> o2_isVoiceEnabled 170
  -> o2_isVoicePlaying 171
  -> o2_stopVoicePlaying 172
  -> o2_getGameLanguage 173

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/kyra.h
    scummvm/trunk/engines/kyra/kyra_v1.h
    scummvm/trunk/engines/kyra/kyra_v2.cpp
    scummvm/trunk/engines/kyra/kyra_v2.h
    scummvm/trunk/engines/kyra/scene_v2.cpp
    scummvm/trunk/engines/kyra/script_v2.cpp
    scummvm/trunk/engines/kyra/sound.cpp
    scummvm/trunk/engines/kyra/sound_v1.cpp
    scummvm/trunk/engines/kyra/text_v2.cpp

Modified: scummvm/trunk/engines/kyra/kyra.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra.h	2007-10-12 23:10:09 UTC (rev 29200)
+++ scummvm/trunk/engines/kyra/kyra.h	2007-10-13 06:57:47 UTC (rev 29201)
@@ -117,6 +117,9 @@
 	virtual void snd_playTheme(int file, int track = 0);
 	virtual void snd_playSoundEffect(int id);
 	virtual void snd_playWanderScoreViaMap(int command, int restart);
+	virtual void snd_playVoiceFile(int id) = 0;
+	virtual bool snd_voiceIsPlaying();
+	virtual void snd_stopVoice();
 	
 	// delay functionallity
 	virtual void delayUntil(uint32 timestamp, bool updateGameTimers = false, bool update = false, bool isMainLoop = false);

Modified: scummvm/trunk/engines/kyra/kyra_v1.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v1.h	2007-10-12 23:10:09 UTC (rev 29200)
+++ scummvm/trunk/engines/kyra/kyra_v1.h	2007-10-13 06:57:47 UTC (rev 29201)
@@ -275,12 +275,10 @@
 	void readSettings();
 	void writeSettings();
 
-	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);
+	virtual void snd_playVoiceFile(int id);
+	void snd_voiceWaitForFinish(bool ingame = true);
 
 	bool speechEnabled();
 	bool textEnabled();

Modified: scummvm/trunk/engines/kyra/kyra_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.cpp	2007-10-12 23:10:09 UTC (rev 29200)
+++ scummvm/trunk/engines/kyra/kyra_v2.cpp	2007-10-13 06:57:47 UTC (rev 29201)
@@ -57,6 +57,8 @@
 	_noScriptEnter = true;
 	_currentChapter = 0;
 	_newChapterFile = 1;
+	_oldTalkFile = -1;
+	_currentTalkFile = 0;
 	_handItemSet = -1;
 	_lastProcessedSceneScript = 0;
 	_specialSceneScriptRunFlag = false;
@@ -67,6 +69,9 @@
 	_newShapeCount = 0;
 	_newShapeFiledata = 0;
 
+	_vocHigh = -1;
+	_chatVocHigh = -1;
+	_chatVocLow = -1;
 	_chatText = 0;
 	_chatObject = -1;
 	
@@ -218,12 +223,12 @@
 	
 	showMessageFromCCode(265, 150, 0);
 	
-	// XXX
+	openTalkFile(0);
+	_currentTalkFile = 1;
+	openTalkFile(1);
 	
-	showMessageFromCCode(0, 0, 207);
+	showMessage(0, 207);
 	
-	// XXX
-	
 	_screen->setShapePages(5, 3);
 
 	memset(&_mainCharacter, 0, sizeof(_mainCharacter));
@@ -1393,6 +1398,34 @@
 
 #pragma mark -
 
+void KyraEngine_v2::openTalkFile(int newFile) {
+	char talkFilename[16];
+
+	if (_oldTalkFile > 0) {
+		sprintf(talkFilename, "CH%dVOC.TLK", _oldTalkFile);
+		_res->unloadPakFile(talkFilename);
+		_oldTalkFile = -1;
+	}
+
+	if (newFile == 0) {
+		strcpy(talkFilename, "ANYTALK.TLK");
+		_res->loadPakFile(talkFilename);
+	} else {
+		sprintf(talkFilename, "CH%dVOC.TLK", newFile);
+		_res->loadPakFile(talkFilename);
+	}
+
+	_oldTalkFile = newFile;
+}
+
+void KyraEngine_v2::snd_playVoiceFile(int id) {
+	debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine_v2::snd_playVoiceFile(%d)", id);
+	char vocFile[9];
+	assert(id >= 0 && id <= 9999999);
+	sprintf(vocFile, "%07d", id);
+	_sound->voicePlay(vocFile);
+}
+
 void KyraEngine_v2::snd_loadSoundFile(int id) {
 	if (id < 0 || !_trackMap)
 		return;
@@ -1403,6 +1436,11 @@
 	_sound->loadSoundFile(file);
 }
 
+void KyraEngine_v2::playVoice(int high, int low) {
+	int vocFile = high * 10000 + low * 10;
+	snd_playVoiceFile(vocFile);
+}
+
 #pragma mark -
 
 typedef Functor1Mem<ScriptState*, int, KyraEngine_v2> OpcodeV2;
@@ -1619,15 +1657,15 @@
 		OpcodeUnImpl(),
 		OpcodeUnImpl(),
 		OpcodeUnImpl(),
-		OpcodeUnImpl(),
+		Opcode(o2_setVocHigh),
 		// 0xa8
-		OpcodeUnImpl(),
+		Opcode(o2_getVocHigh),
 		Opcode(o2_zanthiaChat),
-		OpcodeUnImpl(),
-		OpcodeUnImpl(),
+		Opcode(o2_isVoiceEnabled),
+		Opcode(o2_isVoicePlaying),
 		// 0xac
-		OpcodeUnImpl(),
-		OpcodeUnImpl(),
+		Opcode(o2_stopVoicePlaying),
+		Opcode(o2_getGameLanguage),
 		Opcode(o2_dummy),
 		Opcode(o2_dummy),
 	};

Modified: scummvm/trunk/engines/kyra/kyra_v2.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.h	2007-10-12 23:10:09 UTC (rev 29200)
+++ scummvm/trunk/engines/kyra/kyra_v2.h	2007-10-13 06:57:47 UTC (rev 29201)
@@ -501,10 +501,13 @@
 	int _msgUnk1;
 
 	// chat
+	int _vocHigh;
+
 	const char *_chatText;
 	int _chatObject;
 	bool _chatIsNote;
 	uint32 _chatEndTime;
+	int _chatVocHigh, _chatVocLow;
 
 	ScriptData _chatScriptData;
 	ScriptState _chatScriptState;
@@ -512,14 +515,21 @@
 	int chatGetType(const char *text);
 	int chatCalcDuration(const char *text);
 
-	void objectChat(const char *text, int object, int unk1, int unk2);
-	void objectChatInit(const char *text, int object, int unk1, int unk2);
+	void objectChat(const char *text, int object, int vocHigh, int vocLow);
+	void objectChatInit(const char *text, int object, int vocHigh, int vocLow);
 	void objectChatPrintText(const char *text, int object);
 	void objectChatProcess(const char *script);
 	void objectChatWaitToFinish();
 
 	// sound
+	int _oldTalkFile;
+	int _currentTalkFile;
+	void openTalkFile(int newFile);
+
+	virtual void snd_playVoiceFile(int id);
 	void snd_loadSoundFile(int id);
+
+	void playVoice(int high, int low);
 	
 	// timer
 	void timerFunc2(int);
@@ -584,7 +594,13 @@
 	int o2_querySpecialSceneScriptState(ScriptState *script);
 	int o2_customChat(ScriptState *script);
 	int o2_customChatFinish(ScriptState *script);
+	int o2_setVocHigh(ScriptState *script);
+	int o2_getVocHigh(ScriptState *script);
 	int o2_zanthiaChat(ScriptState *script);
+	int o2_isVoiceEnabled(ScriptState *script);
+	int o2_isVoicePlaying(ScriptState *script);
+	int o2_stopVoicePlaying(ScriptState *script);
+	int o2_getGameLanguage(ScriptState *script);
 	int o2_dummy(ScriptState *script);
 
 	// opcodes temporary

Modified: scummvm/trunk/engines/kyra/scene_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/scene_v2.cpp	2007-10-12 23:10:09 UTC (rev 29200)
+++ scummvm/trunk/engines/kyra/scene_v2.cpp	2007-10-13 06:57:47 UTC (rev 29201)
@@ -33,7 +33,15 @@
 namespace Kyra {
 
 void KyraEngine_v2::enterNewScene(uint16 newScene, int facing, int unk1, int unk2, int unk3) {
-	// XXX
+	if (_newChapterFile != _currentTalkFile) {
+		_currentTalkFile = _newChapterFile;
+		showMessageFromCCode(265, 150, 0);
+		_screen->updateScreen();
+		openTalkFile(_currentTalkFile);
+		showMessage(0, 207);
+		_screen->updateScreen();
+	}
+
 	_screen->hideMouse();
 	
 	if (!unk3) {
@@ -897,7 +905,6 @@
 	const uint8 *src = _scenePal + (srcIndex << 4)*3;
 	memcpy(dst, src, 48);
 
-	// TODO: original passes delay function too
 	_screen->fadePalette(_screen->getPalette(0), delayTime, &_updateFunctor);
 }
 

Modified: scummvm/trunk/engines/kyra/script_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/script_v2.cpp	2007-10-12 23:10:09 UTC (rev 29200)
+++ scummvm/trunk/engines/kyra/script_v2.cpp	2007-10-13 06:57:47 UTC (rev 29201)
@@ -601,9 +601,10 @@
 	strcpy((char*)_unkBuf500Bytes, stackPosString(0));
 	_chatText = (char*)_unkBuf500Bytes;
 	_chatObject = stackPos(1);
-	//XXX
-	objectChatInit(_chatText, _chatObject, 0/*_unk11*/, stackPos(2));
-	//XXX
+
+	_chatVocHigh = _chatVocLow = -1;
+	objectChatInit(_chatText, _chatObject, _vocHigh, stackPos(2));
+	playVoice(_vocHigh, stackPos(2));
 	return 0;
 }
 
@@ -615,12 +616,44 @@
 	return 0;
 }
 
+int KyraEngine_v2::o2_setVocHigh(ScriptState *script) {
+	debugC(3, kDebugLevelScriptFuncs, "o2_setVocHigh(%p) (%d)", (const void *)script, stackPos(0));
+	_vocHigh = stackPos(0);
+	return _vocHigh;
+}
+
+int KyraEngine_v2::o2_getVocHigh(ScriptState *script) {
+	debugC(3, kDebugLevelScriptFuncs, "o2_getVocHigh(%p) ()", (const void *)script);
+	return _vocHigh;
+}
+
 int KyraEngine_v2::o2_zanthiaChat(ScriptState *script) {
 	debugC(3, kDebugLevelScriptFuncs, "o2_zanthiaChat(%p) ('%s', %d)", (const void *)script, stackPosString(0), stackPos(1));
-	objectChat(stackPosString(0), 0, /*_unk11*/0, stackPos(1));
+	objectChat(stackPosString(0), 0, _vocHigh, stackPos(1));
 	return 0;
 }
 
+int KyraEngine_v2::o2_isVoiceEnabled(ScriptState *script) {
+	debugC(3, kDebugLevelScriptFuncs, "o2_isVoiceEnabled(%p) ()", (const void *)script);
+	return 1/*voiceEnabled()*/;
+}
+
+int KyraEngine_v2::o2_isVoicePlaying(ScriptState *script) {
+	debugC(3, kDebugLevelScriptFuncs, "o2_isVoicePlaying(%p) ()", (const void *)script);
+	return snd_voiceIsPlaying() ? 1 : 0;
+}
+
+int KyraEngine_v2::o2_stopVoicePlaying(ScriptState *script) {
+	debugC(3, kDebugLevelScriptFuncs, "o2_stopVoicePlaying(%p) ()", (const void *)script);
+	snd_stopVoice();
+	return 0;
+}
+
+int KyraEngine_v2::o2_getGameLanguage(ScriptState *script) {
+	debugC(3, kDebugLevelScriptFuncs, "o2_getGameLanguage(%p) ()", (const void *)script);
+	return _lang;
+}
+
 int KyraEngine_v2::o2_dummy(ScriptState *script) {
 	debugC(3, kDebugLevelScriptFuncs, "o2_dummy(%p) ()", (const void *)script);
 	return 0;

Modified: scummvm/trunk/engines/kyra/sound.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound.cpp	2007-10-12 23:10:09 UTC (rev 29200)
+++ scummvm/trunk/engines/kyra/sound.cpp	2007-10-13 06:57:47 UTC (rev 29201)
@@ -478,6 +478,16 @@
 	_lastMusicCommand = command;
 }
 
+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/sound_v1.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_v1.cpp	2007-10-12 23:10:09 UTC (rev 29200)
+++ scummvm/trunk/engines/kyra/sound_v1.cpp	2007-10-13 06:57:47 UTC (rev 29201)
@@ -87,14 +87,4 @@
 	}
 }
 
-void KyraEngine_v1::snd_stopVoice() {
-	debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine_v1::snd_stopVoice()");
-	_sound->voiceStop();
-}
-
-bool KyraEngine_v1::snd_voiceIsPlaying() {
-	debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine_v1::snd_voiceIsPlaying()");
-	return _sound->voiceIsPlaying();
-}
-
 } // end of namespace Kyra

Modified: scummvm/trunk/engines/kyra/text_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/text_v2.cpp	2007-10-12 23:10:09 UTC (rev 29200)
+++ scummvm/trunk/engines/kyra/text_v2.cpp	2007-10-13 06:57:47 UTC (rev 29201)
@@ -126,12 +126,12 @@
 	return MIN<int>(strlen(str) << 3, 120);
 }
 
-void KyraEngine_v2::objectChat(const char *str, int object, int unk1, int unk2) {
+void KyraEngine_v2::objectChat(const char *str, int object, int vocHigh, int vocLow) {
 	//setNextIdleAnimTimer();
 
-	//XXX
+	_chatVocHigh = _chatVocLow = -1;
 	
-	objectChatInit(str, object, unk1, unk2);
+	objectChatInit(str, object, vocHigh, vocLow);
 	_chatText = str;
 	_chatObject = object;
 	_chatIsNote = (chatGetType(str) == -1);
@@ -179,7 +179,7 @@
 	//setNextIdelAnimTimer();
 }
 
-void KyraEngine_v2::objectChatInit(const char *str, int object, int unk1, int unk2) {
+void KyraEngine_v2::objectChatInit(const char *str, int object, int vocHigh, int vocLow) {
 	str = _text->preprocessString(str);
 	int lineNum = _text->buildMessageSubstrings(str);
 
@@ -216,7 +216,12 @@
 		_chatEndTime = _system->getMillis();
 	}
 
-	//XXX
+	if (1/*voiceEnabled()*/) {
+		_chatVocHigh = vocHigh;
+		_chatVocLow = vocLow;
+	} else {
+		_chatVocHigh = _chatVocLow = -1;
+	}
 	
 	_screen->showMouse();
 }
@@ -254,8 +259,14 @@
 	uint8 *shapeBuffer = _res->fileData(_newShapeFilename, 0);
 	if (shapeBuffer) {
 		int shapeCount = initNewShapes(shapeBuffer);
-		//XXX
+
+		if (_chatVocHigh >= 0) {
+			playVoice(_chatVocHigh, _chatVocLow);
+			_chatVocHigh = _chatVocLow = -1;
+		}
+
 		objectChatWaitToFinish();
+
 		resetNewShapes(shapeCount, shapeBuffer);
 	} else {
 		warning("couldn't load file '%s'", _newShapeFilename);
@@ -300,11 +311,11 @@
 			if (inputFlag == 198 || inputFlag == 199) {
 				//XXX
 				_skipFlag = true;
+				snd_stopVoice();
 			}
 
 			const uint32 curTime = _system->getMillis();
-			//XXX
-			if (curTime > endTime || _skipFlag) {
+			if ((1/*textEnabled()*/ && curTime > endTime) || (1/*voiceEnabled()*/ && !snd_voiceIsPlaying()) || _skipFlag) {
 				_skipFlag = false;
 				nextFrame = curTime;
 				running = false;


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