diff options
author | Johannes Schickel | 2007-10-13 06:57:47 +0000 |
---|---|---|
committer | Johannes Schickel | 2007-10-13 06:57:47 +0000 |
commit | da9479dfb80d1849a75ed106564360e6978e48bb (patch) | |
tree | 4a1eeb085f90c423178e82270995640ef122d8e8 /engines | |
parent | efcc80dffaf1dcdd4d02cf4417085f9b8a37a4f9 (diff) | |
download | scummvm-rg350-da9479dfb80d1849a75ed106564360e6978e48bb.tar.gz scummvm-rg350-da9479dfb80d1849a75ed106564360e6978e48bb.tar.bz2 scummvm-rg350-da9479dfb80d1849a75ed106564360e6978e48bb.zip |
- 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
svn-id: r29201
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/kyra.h | 3 | ||||
-rw-r--r-- | engines/kyra/kyra_v1.h | 6 | ||||
-rw-r--r-- | engines/kyra/kyra_v2.cpp | 58 | ||||
-rw-r--r-- | engines/kyra/kyra_v2.h | 20 | ||||
-rw-r--r-- | engines/kyra/scene_v2.cpp | 11 | ||||
-rw-r--r-- | engines/kyra/script_v2.cpp | 41 | ||||
-rw-r--r-- | engines/kyra/sound.cpp | 10 | ||||
-rw-r--r-- | engines/kyra/sound_v1.cpp | 10 | ||||
-rw-r--r-- | engines/kyra/text_v2.cpp | 27 |
9 files changed, 146 insertions, 40 deletions
diff --git a/engines/kyra/kyra.h b/engines/kyra/kyra.h index 95e48474ac..5bfb1696a8 100644 --- a/engines/kyra/kyra.h +++ b/engines/kyra/kyra.h @@ -117,6 +117,9 @@ public: 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); diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h index a7371ac510..734d81505e 100644 --- a/engines/kyra/kyra_v1.h +++ b/engines/kyra/kyra_v1.h @@ -275,12 +275,10 @@ public: 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(); diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp index c25836c1e7..a079a83737 100644 --- a/engines/kyra/kyra_v2.cpp +++ b/engines/kyra/kyra_v2.cpp @@ -57,6 +57,8 @@ KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngi _noScriptEnter = true; _currentChapter = 0; _newChapterFile = 1; + _oldTalkFile = -1; + _currentTalkFile = 0; _handItemSet = -1; _lastProcessedSceneScript = 0; _specialSceneScriptRunFlag = false; @@ -67,6 +69,9 @@ KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngi _newShapeCount = 0; _newShapeFiledata = 0; + _vocHigh = -1; + _chatVocHigh = -1; + _chatVocLow = -1; _chatText = 0; _chatObject = -1; @@ -218,11 +223,11 @@ void KyraEngine_v2::startup() { showMessageFromCCode(265, 150, 0); - // XXX - - showMessageFromCCode(0, 0, 207); + openTalkFile(0); + _currentTalkFile = 1; + openTalkFile(1); - // XXX + showMessage(0, 207); _screen->setShapePages(5, 3); @@ -1393,6 +1398,34 @@ void KyraEngine_v2::restoreGfxRect24x24(int x, int y) { #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 @@ void KyraEngine_v2::snd_loadSoundFile(int id) { _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 @@ void KyraEngine_v2::setupOpcodeTable() { 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), }; diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h index aebc8980e7..c0cdcb0c32 100644 --- a/engines/kyra/kyra_v2.h +++ b/engines/kyra/kyra_v2.h @@ -501,10 +501,13 @@ protected: 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 @@ protected: 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 @@ protected: 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 diff --git a/engines/kyra/scene_v2.cpp b/engines/kyra/scene_v2.cpp index 56f9bdc831..cb6326ce8b 100644 --- a/engines/kyra/scene_v2.cpp +++ b/engines/kyra/scene_v2.cpp @@ -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 @@ void KyraEngine_v2::fadeScenePal(int srcIndex, int delayTime) { const uint8 *src = _scenePal + (srcIndex << 4)*3; memcpy(dst, src, 48); - // TODO: original passes delay function too _screen->fadePalette(_screen->getPalette(0), delayTime, &_updateFunctor); } diff --git a/engines/kyra/script_v2.cpp b/engines/kyra/script_v2.cpp index a91a296f7c..5b45be410b 100644 --- a/engines/kyra/script_v2.cpp +++ b/engines/kyra/script_v2.cpp @@ -601,9 +601,10 @@ int KyraEngine_v2::o2_customChat(ScriptState *script) { 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 @@ int KyraEngine_v2::o2_customChatFinish(ScriptState *script) { 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; diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp index d9a3517519..2978475f0e 100644 --- a/engines/kyra/sound.cpp +++ b/engines/kyra/sound.cpp @@ -478,6 +478,16 @@ void KyraEngine::snd_playWanderScoreViaMap(int command, int restart) { _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[] = { diff --git a/engines/kyra/sound_v1.cpp b/engines/kyra/sound_v1.cpp index 3ac28701e1..9675eb2d33 100644 --- a/engines/kyra/sound_v1.cpp +++ b/engines/kyra/sound_v1.cpp @@ -87,14 +87,4 @@ void KyraEngine_v1::snd_voiceWaitForFinish(bool ingame) { } } -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 diff --git a/engines/kyra/text_v2.cpp b/engines/kyra/text_v2.cpp index 4bd27c14bc..bb8b65c476 100644 --- a/engines/kyra/text_v2.cpp +++ b/engines/kyra/text_v2.cpp @@ -126,12 +126,12 @@ int KyraEngine_v2::chatCalcDuration(const char *str) { 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 @@ void KyraEngine_v2::objectChat(const char *str, int object, int unk1, int unk2) //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 @@ void KyraEngine_v2::objectChatInit(const char *str, int object, int unk1, int un _chatEndTime = _system->getMillis(); } - //XXX + if (1/*voiceEnabled()*/) { + _chatVocHigh = vocHigh; + _chatVocLow = vocLow; + } else { + _chatVocHigh = _chatVocLow = -1; + } _screen->showMouse(); } @@ -254,8 +259,14 @@ void KyraEngine_v2::objectChatProcess(const char *script) { 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 @@ void KyraEngine_v2::objectChatWaitToFinish() { 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; |