diff options
Diffstat (limited to 'engines/kyra')
-rw-r--r-- | engines/kyra/kyra_v3.cpp | 1 | ||||
-rw-r--r-- | engines/kyra/kyra_v3.h | 7 | ||||
-rw-r--r-- | engines/kyra/script.cpp | 1 | ||||
-rw-r--r-- | engines/kyra/script_v3.cpp | 228 | ||||
-rw-r--r-- | engines/kyra/text_v3.cpp | 49 |
5 files changed, 281 insertions, 5 deletions
diff --git a/engines/kyra/kyra_v3.cpp b/engines/kyra/kyra_v3.cpp index 58c2a66df3..f1d7a9deb5 100644 --- a/engines/kyra/kyra_v3.cpp +++ b/engines/kyra/kyra_v3.cpp @@ -120,6 +120,7 @@ KyraEngine_v3::KyraEngine_v3(OSystem *system, const GameFlags &flags) : KyraEngi memset(&_dialogScriptData, 0, sizeof(_dialogScriptData)); memset(&_dialogScriptState, 0, sizeof(_dialogScriptState)); _dialogScriptFuncStart = _dialogScriptFuncProc = _dialogScriptFuncEnd = 0; + _malcolmsSpirit = 1; } KyraEngine_v3::~KyraEngine_v3() { diff --git a/engines/kyra/kyra_v3.h b/engines/kyra/kyra_v3.h index 767e3efb43..cc497cb43d 100644 --- a/engines/kyra/kyra_v3.h +++ b/engines/kyra/kyra_v3.h @@ -454,6 +454,8 @@ private: bool checkCharCollision(int x, int y); + int _malcolmsSpirit; + // talk object struct TalkObject { char filename[13]; @@ -523,6 +525,7 @@ private: int o3d_delay(ScriptState *script); void malcolmRandomChat(); + void runDialog(int dlgIndex, int funcNum); // conscience bool _badConscienceShown; @@ -582,6 +585,7 @@ private: int o3_getCharacterY(ScriptState *script); int o3_getCharacterFacing(ScriptState *script); int o3_getCharacterScene(ScriptState *script); + int o3_getMalcolmsSpirit(ScriptState *script); int o3_trySceneChange(ScriptState *script); int o3_showSceneFileMessage(ScriptState *script); int o3_showBadConscience(ScriptState *script); @@ -602,10 +606,12 @@ private: int o3_showMouse(ScriptState *script); int o3_badConscienceChat(ScriptState *script); int o3_wipeDownMouseItem(ScriptState *script); + int o3_setMalcolmsSpirit(ScriptState *script); int o3_delay(ScriptState *script); int o3_setSceneFilename(ScriptState *script); int o3_drawSceneShape(ScriptState *script); int o3_checkInRect(ScriptState *script); + int o3_updateConversations(ScriptState *script); int o3_setSceneDim(ScriptState *script); int o3_update(ScriptState *script); int o3_enterNewScene(ScriptState *script); @@ -619,6 +625,7 @@ private: int o3_defineSceneAnim(ScriptState *script); int o3_updateSceneAnim(ScriptState *script); int o3_runActorScript(ScriptState *script); + int o3_runDialog(ScriptState *script); int o3_malcolmRandomChat(ScriptState *script); int o3_setDlgIndex(ScriptState *script); int o3_getDlgIndex(ScriptState *script); diff --git a/engines/kyra/script.cpp b/engines/kyra/script.cpp index 169c84f763..8db71a7b5e 100644 --- a/engines/kyra/script.cpp +++ b/engines/kyra/script.cpp @@ -221,6 +221,7 @@ bool ScriptHelper::runScript(ScriptState *script) { void ScriptFileParser::setFile(const char *filename, Resource *res) { destroy(); + res->exists(filename, true); _stream = res->getFileStream(filename); assert(_stream); _startOffset = 0; diff --git a/engines/kyra/script_v3.cpp b/engines/kyra/script_v3.cpp index 8193553e59..40367af5d4 100644 --- a/engines/kyra/script_v3.cpp +++ b/engines/kyra/script_v3.cpp @@ -108,6 +108,11 @@ int KyraEngine_v3::o3_getCharacterScene(ScriptState *script) { return _mainCharacter.sceneId; } +int KyraEngine_v3::o3_getMalcolmsSpirit(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_getMalcolmsSpirit(%p) ()", (const void *)script); + return _malcolmsSpirit; +} + int KyraEngine_v3::o3_trySceneChange(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_trySceneChange(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); @@ -283,6 +288,11 @@ int KyraEngine_v3::o3_wipeDownMouseItem(ScriptState *script) { return 0; } +int KyraEngine_v3::o3_setMalcolmsSpirit(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_setMalcolmsSpirit(%p) (%d)", (const void *)script, stackPos(0)); + return (_malcolmsSpirit = stackPos(0)); +} + int KyraEngine_v3::o3_delay(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_delay(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); const uint32 delayTime = stackPos(0) * _tickLength; @@ -337,6 +347,210 @@ int KyraEngine_v3::o3_checkInRect(ScriptState *script) { } } +int KyraEngine_v3::o3_updateConversations(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_updateConversations(%p) (%d)", (const void *)script, stackPos(0)); + int dlgIndex = stackPos(0); + switch (_curChapter-2) { + case 0: + dlgIndex -= 34; + break; + + case 1: + dlgIndex -= 54; + break; + + case 2: + dlgIndex -= 55; + break; + + case 3: + dlgIndex -= 70; + break; + + default: + break; + } + + int convs[4]; + Common::set_to(convs, convs+4, -1); + + if (_curChapter == 1) { + switch (_mainCharacter.dlgIndex) { + case 0: + convs[0] = 6; + convs[1] = 12; + break; + + case 2: + convs[0] = 8; + convs[1] = 14; + break; + + case 3: + convs[0] = 9; + convs[1] = 15; + break; + + case 4: + convs[0] = 10; + convs[1] = 16; + break; + + case 5: + convs[0] = 11; + convs[1] = 17; + break; + + case 6: + convs[0] = 0; + convs[1] = 12; + break; + + case 8: + convs[0] = 2; + convs[1] = 14; + break; + + case 9: + convs[0] = 3; + convs[1] = 15; + break; + + case 10: + convs[0] = 4; + convs[1] = 16; + break; + + case 11: + convs[0] = 5; + convs[1] = 17; + break; + + case 12: + convs[0] = 0; + convs[1] = 6; + break; + + case 14: + convs[0] = 2; + convs[1] = 8; + break; + + case 15: + convs[0] = 3; + convs[1] = 9; + break; + + case 16: + convs[0] = 4; + convs[1] = 10; + break; + + case 17: + convs[0] = 5; + convs[1] = 11; + break; + + default: + break; + } + } else if (_curChapter == 2) { + switch (_mainCharacter.dlgIndex) { + case 0: + convs[0] = 4; + convs[1] = 8; + convs[2] = 5; + convs[3] = 9; + break; + + case 1: + convs[0] = 4; + convs[1] = 8; + convs[2] = 0; + convs[3] = 5; + break; + + case 2: + convs[0] = 6; + convs[2] = 11; + break; + + case 3: + convs[0] = 7; + convs[2] = 12; + break; + + case 4: + convs[0] = 0; + convs[1] = 8; + convs[2] = 1; + convs[3] = 9; + break; + + case 5: + convs[0] = 0; + convs[1] = 8; + convs[2] = 4; + convs[3] = 1; + break; + + case 6: + convs[0] = 2; + convs[1] = 10; + break; + + case 7: + convs[0] = 3; + convs[1] = 11; + break; + + case 8: + convs[0] = 0; + convs[1] = 4; + convs[2] = 1; + break; + + case 9: + convs[0] = 0; + convs[1] = 4; + convs[2] = 0; + convs[4] = 1; + break; + + case 10: + convs[0] = 2; + convs[1] = 6; + break; + + case 11: + convs[0] = 3; + convs[1] = 7; + break; + + default: + break; + } + } else if (_curChapter == 4) { + if (_malcolmsSpirit == 0) { + convs[0] = _mainCharacter.dlgIndex - 10; + convs[1] = _mainCharacter.dlgIndex - 5; + } else if (_malcolmsSpirit == 1) { + convs[0] = _mainCharacter.dlgIndex + 5; + convs[1] = _mainCharacter.dlgIndex + 10; + } else if (_malcolmsSpirit == 2) { + convs[0] = _mainCharacter.dlgIndex - 5; + convs[1] = _mainCharacter.dlgIndex + 5; + } + } + + for (int i = 0; i < 4; ++i) { + if (convs[i] != -1) + _conversationState[dlgIndex][convs[i]] = 0; + } + + return 1; +} + int KyraEngine_v3::o3_setSceneDim(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_setSceneDim(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); _sceneMinX = stackPos(0); @@ -544,6 +758,12 @@ int KyraEngine_v3::o3_runActorScript(ScriptState *script) { return 0; } +int KyraEngine_v3::o3_runDialog(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_runDialog(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + runDialog(stackPos(0), stackPos(1)); + return 0; +} + int KyraEngine_v3::o3_malcolmRandomChat(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_malcolmRandomChat(%p) ()", (const void *)script); malcolmRandomChat(); @@ -751,7 +971,7 @@ void KyraEngine_v3::setupOpcodeTable() { Opcode(o3_getCharacterFacing); Opcode(o3_getCharacterScene); // 0x08 - OpcodeUnImpl(); + Opcode(o3_getMalcolmsSpirit); Opcode(o3_dummy); Opcode(o3_dummy); OpcodeUnImpl(); @@ -806,7 +1026,7 @@ void KyraEngine_v3::setupOpcodeTable() { Opcode(o3_wipeDownMouseItem); Opcode(o3_dummy); // 0x34 - OpcodeUnImpl(); + Opcode(o3_setMalcolmsSpirit); OpcodeUnImpl(); Opcode(o3_dummy); Opcode(o3_delay); @@ -822,7 +1042,7 @@ void KyraEngine_v3::setupOpcodeTable() { Opcode(o3_drawSceneShape); // 0x40 Opcode(o3_checkInRect); - OpcodeUnImpl(); + Opcode(o3_updateConversations); OpcodeUnImpl(); Opcode(o3_dummy); // 0x44 @@ -887,7 +1107,7 @@ void KyraEngine_v3::setupOpcodeTable() { Opcode(o3_dummy); // 0x74 Opcode(o3_runActorScript); - OpcodeUnImpl(); + Opcode(o3_runDialog); Opcode(o3_malcolmRandomChat); Opcode(o3_setDlgIndex); // 0x78 diff --git a/engines/kyra/text_v3.cpp b/engines/kyra/text_v3.cpp index d42ec9efe3..17f6f0699f 100644 --- a/engines/kyra/text_v3.cpp +++ b/engines/kyra/text_v3.cpp @@ -516,7 +516,7 @@ void KyraEngine_v3::processDialog(int vocHighIndex, int vocHighBase, int funcNum while (running) { uint16 cmd = _cnvFile->readUint16LE(); - int object = cmd - 14; + int object = cmd - 12; if (cmd == 10) { break; @@ -668,5 +668,52 @@ void KyraEngine_v3::malcolmRandomChat() { processDialog(vocHighIndex, vocHighBase, 0); } +void KyraEngine_v3::runDialog(int dlgIndex, int funcNum) { + debugC(9, kDebugLevelMain, "KyraEngine_v3::runDialog(%d, %d)", dlgIndex, funcNum); + + switch (_curChapter-2) { + case 0: + dlgIndex -= 34; + break; + + case 1: + dlgIndex -= 54; + break; + + case 2: + dlgIndex -= 55; + break; + + case 3: + dlgIndex -= 70; + break; + + default: + break; + } + + updateDlgBuffer(); + + int vocHighBase = 0, vocHighIndex = 0, index1 = 0, index2 = 0; + loadDlgHeader(vocHighBase, vocHighIndex, index1, index2); + + int convState = _conversationState[dlgIndex][vocHighBase]; + uint32 offset = ((vocHighIndex == 1) ? dlgIndex - 1 : dlgIndex) * 6; + if (convState == -1) { + _cnvFile->seek(offset, SEEK_CUR); + _conversationState[dlgIndex][vocHighBase] = 0; + } else if (convState == 0 || convState == 2) { + _cnvFile->seek(offset+2, SEEK_CUR); + _conversationState[dlgIndex][vocHighBase] = 1; + } else { + _cnvFile->seek(offset+4, SEEK_CUR); + _conversationState[dlgIndex][vocHighBase] = 2; + } + + _cnvFile->seek(_cnvFile->readUint16LE(), SEEK_SET); + + processDialog(vocHighIndex, vocHighBase, funcNum); +} + } // end of namespace Kyra |