From d262073193906c1d60050c2a24a2c3200026581e Mon Sep 17 00:00:00 2001 From: Florian Kagerer Date: Fri, 6 Mar 2009 23:59:12 +0000 Subject: LOL: - some opcodes for the first throne room sequence svn-id: r39168 --- engines/kyra/items_lol.cpp | 28 +++++++++++++++++++++ engines/kyra/lol.h | 7 ++++++ engines/kyra/script_lol.cpp | 60 ++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 89 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/kyra/items_lol.cpp b/engines/kyra/items_lol.cpp index 8bbcc91332..7faee163e1 100644 --- a/engines/kyra/items_lol.cpp +++ b/engines/kyra/items_lol.cpp @@ -139,6 +139,34 @@ int LoLEngine::makeItem(int itemIndex, int curFrame, int flags) { return slot; } +bool LoLEngine::addItemToInventory(int itemIndex) { + int pos = 0; + int i = 0; + + for (; i < 48; i++) { + pos = _inventoryCurItem + i; + if (pos > 47) + pos -= 48; + + if (!_inventory[pos]) + break; + } + + if (i == 48) + return false; + + while ((_inventoryCurItem > pos) || ((_inventoryCurItem + 9) <= pos)) { + if (++_inventoryCurItem > 47) + _inventoryCurItem -= 48; + gui_drawInventory(); + } + + _inventory[pos] = itemIndex; + gui_drawInventory(); + + return true; +} + bool LoLEngine::testUnkItemFlags(int itemIndex) { if (!(_itemsInPlay[itemIndex].shpCurFrame_flg & 0x4000)) return false; diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h index dd1ce58df3..83acd708dc 100644 --- a/engines/kyra/lol.h +++ b/engines/kyra/lol.h @@ -501,6 +501,7 @@ private: int olol_loadLevelGraphics(EMCState *script); int olol_loadCmzFile(EMCState *script); int olol_loadMonsterShapes(EMCState *script); + int olol_deleteHandItem(EMCState *script); int olol_allocItemPropertiesBuffer(EMCState *script); int olol_setItemProperty(EMCState *script); int olol_makeItem(EMCState *script); @@ -560,9 +561,14 @@ private: int tlol_initDialogueSequence(const TIM *tim, const uint16 *param); int tlol_restoreSceneAfterDialogueSequence(const TIM *tim, const uint16 *param); + int tlol_giveItem(const TIM *tim, const uint16 *param); + int tlol_setPartyPosition(const TIM *tim, const uint16 *param); int tlol_fadeClearWindow(const TIM *tim, const uint16 *param); int tlol_update(const TIM *tim, const uint16 *param); + int tlol_loadSoundFile(const TIM *tim, const uint16 *param); + int tlol_playMusicTrack(const TIM *tim, const uint16 *param); int tlol_playDialogueTalkText(const TIM *tim, const uint16 *param); + int tlol_playSoundEffect(const TIM *tim, const uint16 *param); Common::Array _timIngameOpcodes; @@ -883,6 +889,7 @@ private: // items void giveCredits(int credits, int redraw); int makeItem(int itemIndex, int curFrame, int flags); + bool addItemToInventory(int itemIndex); bool testUnkItemFlags(int itemIndex); void deleteItem(int itemIndex); ItemInPlay *findItem(uint16 index); diff --git a/engines/kyra/script_lol.cpp b/engines/kyra/script_lol.cpp index 622332cd3c..6cc26d23c4 100644 --- a/engines/kyra/script_lol.cpp +++ b/engines/kyra/script_lol.cpp @@ -157,6 +157,14 @@ int LoLEngine::olol_loadMonsterShapes(EMCState *script) { return 1; } +int LoLEngine::olol_deleteHandItem(EMCState *script) { + debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_deleteHandItem(%p) ()", (const void *)script); + int r = _itemInHand; + deleteItem(_itemInHand); + setHandItem(0); + return r; +} + int LoLEngine::olol_allocItemPropertiesBuffer(EMCState *script) { debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_allocItemPropertiesBuffer(%p) (%d)", (const void *)script, stackPos(0)); delete[] _itemProperties; @@ -902,6 +910,28 @@ int LoLEngine::tlol_restoreSceneAfterDialogueSequence(const TIM *tim, const uint return 1; } +int LoLEngine::tlol_giveItem(const TIM *tim, const uint16 *param) { + debugC(3, kDebugLevelScriptFuncs, "LoLEngine::tlol_giveItem(%p, %p) (%d)", (const void*)tim, (const void*)param, param[0]); + int item = makeItem(param[0], param[1], param[2]); + if (addItemToInventory(item)) + return 1; + + deleteItem(item); + return 0; +} + +int LoLEngine::tlol_setPartyPosition(const TIM *tim, const uint16 *param) { + debugC(3, kDebugLevelScriptFuncs, "LoLEngine::tlol_setPartyPosition(%p, %p) (%d, %d)", (const void*)tim, (const void*)param, param[0], param[1]); + if (param[0] == 1) { + _currentDirection = param[1]; + } else if (param[0] == 0) { + _currentBlock = param[1]; + calcCoordinates(_partyPosX, _partyPosY, _currentBlock, 0x80, 0x80); + } + + return 1; +} + int LoLEngine::tlol_fadeClearWindow(const TIM *tim, const uint16 *param) { debugC(3, kDebugLevelScriptFuncs, "LoLEngine::tlol_fadeClearWindow(%p, %p) (%d)", (const void*)tim, (const void*)param, param[0]); uint8 *tmp = 0; @@ -958,6 +988,18 @@ int LoLEngine::tlol_update(const TIM *tim, const uint16 *param) { return 1; } +int LoLEngine::tlol_loadSoundFile(const TIM *tim, const uint16 *param) { + debugC(3, kDebugLevelScriptFuncs, "LoLEngine::tlol_loadSoundFile(%p, %p) (%d)", (const void*)tim, (const void*)param, param[0]); + snd_loadSoundFile(param[0]); + return 1; +} + +int LoLEngine::tlol_playMusicTrack(const TIM *tim, const uint16 *param) { + debugC(3, kDebugLevelScriptFuncs, "LoLEngine::tlol_playMusicTrack(%p, %p) (%d)", (const void*)tim, (const void*)param, param[0]); + snd_playTrack(param[0]); + return 1; +} + int LoLEngine::tlol_playDialogueTalkText(const TIM *tim, const uint16 *param) { debugC(3, kDebugLevelScriptFuncs, "LoLEngine::tlol_playDialogueTalkText(%p, %p) (%d)", (const void*)tim, (const void*)param, param[0]); if (!snd_playCharacterSpeech(param[0], 0, 0) || textEnabled()) @@ -965,6 +1007,12 @@ int LoLEngine::tlol_playDialogueTalkText(const TIM *tim, const uint16 *param) { return 1; } +int LoLEngine::tlol_playSoundEffect(const TIM *tim, const uint16 *param) { + debugC(3, kDebugLevelScriptFuncs, "LoLEngine::tlol_playSoundEffect(%p, %p) (%d)", (const void*)tim, (const void*)param, param[0]); + snd_playSoundEffect(param[0], -1); + return 1; +} + #pragma mark - typedef Common::Functor1Mem OpcodeV2; @@ -1000,7 +1048,7 @@ void LoLEngine::setupOpcodeTable() { Opcode(olol_loadMonsterShapes); // 0x0C - OpcodeUnImpl(); + Opcode(olol_deleteHandItem); Opcode(olol_allocItemPropertiesBuffer); Opcode(olol_setItemProperty); Opcode(olol_makeItem); @@ -1290,10 +1338,10 @@ void LoLEngine::setupOpcodeTable() { OpcodeTim(tlol_initDialogueSequence); OpcodeTim(tlol_restoreSceneAfterDialogueSequence); OpcodeTimUnImpl(); - OpcodeTimUnImpl(); + OpcodeTim(tlol_giveItem); // 0x04 - OpcodeTimUnImpl(); + OpcodeTim(tlol_setPartyPosition); OpcodeTim(tlol_fadeClearWindow); OpcodeTimUnImpl(); OpcodeTimUnImpl(); @@ -1302,12 +1350,12 @@ void LoLEngine::setupOpcodeTable() { OpcodeTimUnImpl(); OpcodeTim(tlol_update); OpcodeTimUnImpl(); - OpcodeTimUnImpl(); + OpcodeTim(tlol_loadSoundFile); // 0x0C - OpcodeTimUnImpl(); + OpcodeTim(tlol_playMusicTrack); OpcodeTim(tlol_playDialogueTalkText); - OpcodeTimUnImpl(); + OpcodeTim(tlol_playSoundEffect); OpcodeTimUnImpl(); // 0x10 -- cgit v1.2.3