diff options
Diffstat (limited to 'engines/kyra')
-rw-r--r-- | engines/kyra/kyra_v2.cpp | 4 | ||||
-rw-r--r-- | engines/kyra/kyra_v2.h | 53 | ||||
-rw-r--r-- | engines/kyra/scene_v2.cpp | 18 | ||||
-rw-r--r-- | engines/kyra/script_v2.cpp | 29 | ||||
-rw-r--r-- | engines/kyra/text_v2.cpp | 37 |
5 files changed, 97 insertions, 44 deletions
diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp index 55d79c3ed0..45de6a3672 100644 --- a/engines/kyra/kyra_v2.cpp +++ b/engines/kyra/kyra_v2.cpp @@ -1912,7 +1912,7 @@ void KyraEngine_v2::setupOpcodeTable() { // 0x74 Opcode(o2_useItemOnMainChar), Opcode(o2_startDialogue), - OpcodeUnImpl(), + Opcode(o2_zanthRandomChat), Opcode(o2_setupDialogue), // 0x78 Opcode(o2_getDlgIndex), @@ -1951,7 +1951,7 @@ void KyraEngine_v2::setupOpcodeTable() { Opcode(o2_setHiddenItemsEntry), // 0x94 Opcode(o2_getHiddenItemsEntry), - OpcodeUnImpl(), + Opcode(o2_mushroomEffect), Opcode(o2_wsaClose), OpcodeUnImpl(), // 0x98 diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h index b42da7ba51..24765be863 100644 --- a/engines/kyra/kyra_v2.h +++ b/engines/kyra/kyra_v2.h @@ -495,8 +495,6 @@ protected: void runSceneScript6(); void runSceneScript7(); - void sceneStartupChat(); - void initSceneAnims(int unk1); void initSceneScreen(int unk1); @@ -556,7 +554,7 @@ protected: void setHandItem(uint16 item); void removeHandItem(); - // inventroy + // inventory static const int _inventoryX[]; static const int _inventoryY[]; @@ -656,6 +654,9 @@ protected: void objectChatWaitToFinish(); void startDialogue(int dlgIndex); + + void zanthSceneStartupChat(); + void zanthRandomChat(); void updateDlgBuffer(); void loadDlgHeader(int &csEntry, int &vocH, int &scIndex1, int &scIndex2); void processDialogue(int dlgOffset, int vocH = 0, int csEntry = 0); @@ -668,6 +669,28 @@ protected: int8 **_conversationState; uint8 *_dlgBuffer; + // Talk object handling + void initTalkObject(int index); + void deinitTalkObject(int index); + + struct TalkObject { + char filename[13]; + int8 scriptId; + int16 x, y; + int8 color; + }; + TalkObject *_talkObjectList; + + struct TalkSections { + uint8 *STATim; + uint8 *TLKTim; + uint8 *ENDTim; + }; + TalkSections _currentTalkSections; + + char _TLKFilename[13]; + bool _objectChatFinished; + // tim sequence void tim_setupOpcodes(); uint8 *tim_loadFile(const char *filename, uint8 *buffer, int32 bufferSize); @@ -726,28 +749,6 @@ protected: const char *_timChatText; int _timChatObject; - // Talk object handling - void initTalkObject(int index); - void deinitTalkObject(int index); - - struct TalkObject { - char filename[13]; - int8 scriptId; - int16 x, y; - int8 color; - }; - TalkObject *_talkObjectList; - - struct TalkSections { - uint8 *STATim; - uint8 *TLKTim; - uint8 *ENDTim; - }; - TalkSections _currentTalkSections; - - char _TLKFilename[13]; - bool _objectChatFinished; - // sound int _oldTalkFile; int _currentTalkFile; @@ -859,6 +860,7 @@ protected: int o2_updateSceneAnim(ScriptState *script); int o2_useItemOnMainChar(ScriptState *script); int o2_startDialogue(ScriptState *script); + int o2_zanthRandomChat(ScriptState *script); int o2_setupDialogue(ScriptState *script); int o2_getDlgIndex(ScriptState *script); int o2_defineRoom(ScriptState *script); @@ -881,6 +883,7 @@ protected: int o2_querySpecialSceneScriptState(ScriptState *script); int o2_setHiddenItemsEntry(ScriptState *script); int o2_getHiddenItemsEntry(ScriptState *script); + int o2_mushroomEffect(ScriptState *script); int o2_customChat(ScriptState *script); int o2_customChatFinish(ScriptState *script); int o2_getBoolFromStack(ScriptState *script); diff --git a/engines/kyra/scene_v2.cpp b/engines/kyra/scene_v2.cpp index 55252c3201..d14b2eeda3 100644 --- a/engines/kyra/scene_v2.cpp +++ b/engines/kyra/scene_v2.cpp @@ -251,7 +251,7 @@ void KyraEngine_v2::enterNewSceneUnk2(int unk1) { if (!unk1) { runSceneScript4(0); - sceneStartupChat(); + zanthSceneStartupChat(); } _unk4 = 0; @@ -507,22 +507,6 @@ void KyraEngine_v2::runSceneScript7() { _screen->_curPage = oldPage; } -void KyraEngine_v2::sceneStartupChat() { - int tableIndex = _mainCharacter.sceneId - READ_LE_UINT16(&_ingameTalkObjIndex[5 + _newChapterFile]); - if (queryGameFlag(0x159) || _newSceneDlgState[tableIndex]) - return; - - int csEntry, vocH, scIndex1, scIndex2; - updateDlgBuffer(); - loadDlgHeader(csEntry, vocH, scIndex1, scIndex2); - - uint8 bufferIndex = 8 + scIndex1 * 6 + scIndex2 * 4 + tableIndex * 2; - int offs = READ_LE_UINT16(_dlgBuffer + bufferIndex); - processDialogue(offs, vocH, csEntry); - - _newSceneDlgState[tableIndex] = 1; -} - void KyraEngine_v2::initSceneAnims(int unk1) { for (int i = 0; i < ARRAYSIZE(_animObjects); ++i) _animObjects[i].enabled = 0; diff --git a/engines/kyra/script_v2.cpp b/engines/kyra/script_v2.cpp index 49a66e537f..2bb33b333c 100644 --- a/engines/kyra/script_v2.cpp +++ b/engines/kyra/script_v2.cpp @@ -647,6 +647,12 @@ int KyraEngine_v2::o2_startDialogue(ScriptState *script) { return 0; } +int KyraEngine_v2::o2_zanthRandomChat(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_zanthRandomChat(%p)", (const void *)script); + zanthRandomChat(); + return 0; +} + int KyraEngine_v2::o2_setupDialogue(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "o2_setupDialogue(%p) (%d)", (const void *)script, stackPos(0)); setNewDlgIndex(stackPos(0)); @@ -822,6 +828,29 @@ int KyraEngine_v2::o2_getHiddenItemsEntry(ScriptState *script) { return _hiddenItems[stackPos(0)]; } +int KyraEngine_v2::o2_mushroomEffect(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_mushroomEffect(%p)", (const void *)script); + memcpy(_screen->getPalette(1), _screen->_currentPalette, 768); + + for (int i = 1; i < 768; i += 3) + _screen->_currentPalette[i] = 0; + snd_playSoundEffect(106); + _screen->fadePalette(_screen->_currentPalette, 90, &_updateFunctor); + memcpy(_screen->_currentPalette, _screen->getPalette(1), 768); + + for (int i = 0; i < 768; i += 3) { + _screen->_currentPalette[i] = _screen->_currentPalette[i + 1] = 0; + _screen->_currentPalette[i + 2] += (((int8)_screen->_currentPalette[i + 2]) >> 1); + if (_screen->_currentPalette[i + 2] > 63) + _screen->_currentPalette[i + 2] = 63; + } + snd_playSoundEffect(106); + _screen->fadePalette(_screen->_currentPalette, 90, &_updateFunctor); + _screen->fadePalette(_screen->getPalette(1), 30, &_updateFunctor); + + return 0; +} + int KyraEngine_v2::o2_customChat(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "o2_customChat(%p) ('%s', %d, %d)", (const void *)script, stackPosString(0), stackPos(1), stackPos(2)); strcpy((char*)_unkBuf500Bytes, stackPosString(0)); diff --git a/engines/kyra/text_v2.cpp b/engines/kyra/text_v2.cpp index c5252d78aa..5e888fa972 100644 --- a/engines/kyra/text_v2.cpp +++ b/engines/kyra/text_v2.cpp @@ -364,6 +364,43 @@ void KyraEngine_v2::startDialogue(int dlgIndex) { processDialogue(offs, vocH, csEntry); } +void KyraEngine_v2::zanthSceneStartupChat() { + int tableIndex = _mainCharacter.sceneId - READ_LE_UINT16(&_ingameTalkObjIndex[5 + _newChapterFile]); + if (queryGameFlag(0x159) || _newSceneDlgState[tableIndex]) + return; + + int csEntry, vocH, scIndex1, scIndex2; + updateDlgBuffer(); + loadDlgHeader(csEntry, vocH, scIndex1, scIndex2); + + uint8 bufferIndex = 8 + scIndex1 * 6 + scIndex2 * 4 + tableIndex * 2; + int offs = READ_LE_UINT16(_dlgBuffer + bufferIndex); + processDialogue(offs, vocH, csEntry); + + _newSceneDlgState[tableIndex] = 1; +} + +void KyraEngine_v2::zanthRandomChat() { + int tableIndex = _mainCharacter.sceneId - READ_LE_UINT16(&_ingameTalkObjIndex[5 + _newChapterFile]); + if (queryGameFlag(0x164)) + return; + + int csEntry, vocH, scIndex1, unused; + updateDlgBuffer(); + loadDlgHeader(csEntry, vocH, scIndex1, unused); + + if (_unkFlag1) { + _unkFlag1 = 0; + tableIndex += 2; + } else { + _unkFlag1 = 1; + } + + uint8 bufferIndex = 8 + scIndex1 * 6 + tableIndex * 2; + int offs = READ_LE_UINT16(_dlgBuffer + bufferIndex); + processDialogue(offs, vocH, csEntry); +} + void KyraEngine_v2::updateDlgBuffer() { static const char DlgFileTemplate[] = "CH**-S**.DLG"; char filename[13]; |