diff options
author | Johannes Schickel | 2008-04-24 13:05:14 +0000 |
---|---|---|
committer | Johannes Schickel | 2008-04-24 13:05:14 +0000 |
commit | ffc1e56cbd6dc4c9b09f5a23869ecbb5360a667b (patch) | |
tree | d71de7a0b5002c32f434459b03fa034c9e770c65 | |
parent | e14746db3c7d5ad3749af4aa2449f4eef966646a (diff) | |
download | scummvm-rg350-ffc1e56cbd6dc4c9b09f5a23869ecbb5360a667b.tar.gz scummvm-rg350-ffc1e56cbd6dc4c9b09f5a23869ecbb5360a667b.tar.bz2 scummvm-rg350-ffc1e56cbd6dc4c9b09f5a23869ecbb5360a667b.zip |
More kyra3 item drop down code.
svn-id: r31685
-rw-r--r-- | engines/kyra/animator_v3.cpp | 17 | ||||
-rw-r--r-- | engines/kyra/gui_v3.cpp | 23 | ||||
-rw-r--r-- | engines/kyra/items_v3.cpp | 113 | ||||
-rw-r--r-- | engines/kyra/kyra_v3.h | 8 | ||||
-rw-r--r-- | engines/kyra/scene_v3.cpp | 14 | ||||
-rw-r--r-- | engines/kyra/staticres.cpp | 8 |
6 files changed, 178 insertions, 5 deletions
diff --git a/engines/kyra/animator_v3.cpp b/engines/kyra/animator_v3.cpp index 5acfb76196..078b914e86 100644 --- a/engines/kyra/animator_v3.cpp +++ b/engines/kyra/animator_v3.cpp @@ -636,5 +636,22 @@ void KyraEngine_v3::addItemToAnimList(int item) { animObj->needRefresh = 1; } +void KyraEngine_v3::deleteItemAnimEntry(int item) { + debugC(9, kDebugLevelAnimator, "KyraEngine_v3::deleteItemAnimEntry(%d)", item); + AnimObj *animObj = &_animObjects[17+item]; + + restorePage3(); + + animObj->shapePtr = 0; + animObj->shapeIndex = 0xFFFF; + animObj->shapeIndex2 = 0xFFFF; + animObj->needRefresh = 1; + + refreshAnimObjectsIfNeed(); + + animObj->enabled = 0; + _animList = deleteAnimListEntry(_animList, animObj); +} + } // end of namespace Kyra diff --git a/engines/kyra/gui_v3.cpp b/engines/kyra/gui_v3.cpp index 315be352e9..c797ca0812 100644 --- a/engines/kyra/gui_v3.cpp +++ b/engines/kyra/gui_v3.cpp @@ -50,6 +50,29 @@ void KyraEngine_v3::showMessage(const char *string, uint8 c0, uint8 c1) { _screen->showMouse(); } +void KyraEngine_v3::showMessageFromCCode(int string, uint8 c0, int) { + debugC(9, kDebugLevelMain, "KyraEngine_v3::showMessageFromCCode(%d, %d, -)", string, c0); + showMessage((const char*)getTableEntry(_cCodeFile, string), c0, 0xF0); +} + +void KyraEngine_v3::updateItemCommand(int item, int str, uint8 c0) { + debugC(9, kDebugLevelMain, "KyraEngine_v3::updateItemCommand(%d, %d, %d)", item, str, c0); + char buffer[100]; + char *src = (char*)getTableEntry(_itemFile, item); + + while (*src != ' ') + ++src; + ++src; + + *src = toupper(*src); + + strcpy(buffer, src); + strcat(buffer, " "); + strcat(buffer, (const char*)getTableEntry(_cCodeFile, str)); + + showMessage(buffer, c0, 0xF0); +} + void KyraEngine_v3::updateCommandLine() { debugC(9, kDebugLevelMain, "KyraEngine_v3::updateCommandLine()"); if (_restoreCommandLine) { diff --git a/engines/kyra/items_v3.cpp b/engines/kyra/items_v3.cpp index 8cb3980356..931367657b 100644 --- a/engines/kyra/items_v3.cpp +++ b/engines/kyra/items_v3.cpp @@ -24,6 +24,7 @@ */ #include "kyra/kyra_v3.h" +#include "kyra/timer.h" namespace Kyra { @@ -187,8 +188,8 @@ bool KyraEngine_v3::dropItem(int unk1, uint16 item, int x, int y, int unk2) { if (processItemDrop(_mainCharacter.sceneId, item, x, y, unk1, unk2)) return true; - //if (countAllItems() >= 50) - //showMessageFromCCode(14, 0xB3, 0); + if (countAllItems() >= 50) + showMessageFromCCode(14, 0xB3, 0); } if (!_chatText) @@ -294,10 +295,10 @@ bool KyraEngine_v3::processItemDrop(uint16 sceneId, uint16 item, int x, int y, i itemDropDown(x, y, itemX, itemY, freeItemSlot, item, (unk1 == 0) ? 1 : 0); if (!unk1 && unk2) { - //int itemStr = 1; + int itemStr = 1; //if (_lang == 1) // itemStr = getItemCommandStringDrop(item); - //updateCommandLineEx(item+54, itemStr, 0xD6); + updateItemCommand(item, itemStr, 0xFF); } return true; @@ -390,7 +391,35 @@ void KyraEngine_v3::itemDropDown(int startX, int startY, int dstX, int dstY, int void KyraEngine_v3::exchangeMouseItem(int itemPos, int runScript) { debugC(9, kDebugLevelMain, "KyraEngine_v3::exchangeMouseItem(%d, %d)", itemPos, runScript); - //XXX + _screen->hideMouse(); + + if (itemListMagic(_itemInHand, itemPos)) + return; + + if (_itemInHand == 43) { + removeHandItem(); + return; + } + + deleteItemAnimEntry(itemPos); + + int itemId = _itemList[itemPos].id; + _itemList[itemPos].id = _itemInHand; + _itemInHand = itemId; + + addItemToAnimList(itemPos); + playSoundEffect(0x0B, 0xC8); + setMouseCursor(_itemInHand); + int str2 = 0; + + //if (_lang == 1) + // str2 = getItemCommandStringPickUp(itemId); + + updateItemCommand(itemId, str2, 0xFF); + _screen->showMouse(); + + if (runScript) + runSceneScript6(); } bool KyraEngine_v3::isDropable(int x, int y) { @@ -408,5 +437,79 @@ bool KyraEngine_v3::isDropable(int x, int y) { return true; } +bool KyraEngine_v3::itemListMagic(int handItem, int itemSlot) { + debugC(9, kDebugLevelMain, "KyraEngine_v3::itemListMagic(%d, %d)", handItem, itemSlot); + + uint16 item = _itemList[itemSlot].id; + if (_curChapter == 1 && handItem == 3 && item == 3 && queryGameFlag(0x76)) { + //eelScript(); + return true; + } else if ((handItem == 6 || handItem == 7) && item == 2) { + int animObjIndex = -1; + for (int i = 17; i <= 66; ++i) { + if (_animObjects[i].shapeIndex2 == 250) + animObjIndex = i; + } + + assert(animObjIndex != -1); + + _screen->hideMouse(); + playSoundEffect(0x93, 0xC8); + for (int i = 109; i <= 141; ++i) { + _animObjects[animObjIndex].shapeIndex = i+248; + _animObjects[animObjIndex].needRefresh = true; + delay(1, true); + } + + deleteItemAnimEntry(itemSlot); + _itemList[itemSlot].id = 0xFFFF; + _screen->showMouse(); + return true; + } + + if (_mainCharacter.sceneId == 51 && queryGameFlag(0x19B) && !queryGameFlag(0x19C) + && ((item == 63 && handItem == 56) || (item == 56 && handItem == 63))) { + + if (queryGameFlag(0x1AC)) { + setGameFlag(0x19C); + setGameFlag(0x1AD); + } else { + setGameFlag(0x1AE); + } + + _timer->setCountdown(12, 1); + _timer->enable(12); + } + + for (int i = 0; _itemMagicTable[i] != 0xFF; i += 4) { + if (_itemMagicTable[i+0] != handItem || _itemMagicTable[i+1] != item) + continue; + + uint8 resItem = _itemMagicTable[i+2]; + uint8 newItem = _itemMagicTable[i+3]; + + playSoundEffect(0x0F, 0xC8); + + _itemList[itemSlot].id = resItem; + + _screen->hideMouse(); + deleteItemAnimEntry(itemSlot); + addItemToAnimList(itemSlot); + + if (newItem == 0xFE) + removeHandItem(); + else if (newItem != 0xFF) + setHandItem(newItem); + _screen->showMouse(); + + if (_lang != 1) + updateItemCommand(resItem, 3, 0xFF); + + return true; + } + + return false; +} + } // end of namespace Kyra diff --git a/engines/kyra/kyra_v3.h b/engines/kyra/kyra_v3.h index dd7164a668..b7718adcba 100644 --- a/engines/kyra/kyra_v3.h +++ b/engines/kyra/kyra_v3.h @@ -237,6 +237,7 @@ private: void showIdleAnim(); void addItemToAnimList(int item); + void deleteItemAnimEntry(int item); // interface uint8 *_interface; @@ -246,6 +247,9 @@ private: void loadInterface(); void showMessage(const char *string, uint8 c0, uint8 c1); + void showMessageFromCCode(int string, uint8 c0, int); + void updateItemCommand(int item, int str, uint8 c0); + void updateCommandLine(); void restoreCommandLine(); void updateCLState(); @@ -320,6 +324,9 @@ private: bool isDropable(int x, int y); + static const uint8 _itemMagicTable[]; + bool itemListMagic(int handItem, int itemSlot); + // -> hand item void setMouseCursor(uint16 item); @@ -414,6 +421,7 @@ private: int runSceneScript2(); bool _noStartupChat; void runSceneScript4(int unk1); + void runSceneScript6(); void runSceneScript8(); int _sceneMinX, _sceneMaxX; diff --git a/engines/kyra/scene_v3.cpp b/engines/kyra/scene_v3.cpp index 08dded4801..27144ff505 100644 --- a/engines/kyra/scene_v3.cpp +++ b/engines/kyra/scene_v3.cpp @@ -822,6 +822,20 @@ void KyraEngine_v3::runSceneScript4(int unk1) { _noStartupChat = true; } +void KyraEngine_v3::runSceneScript6() { + debugC(9, kDebugLevelMain, "KyraEngine_v3::runSceneScript6()"); + _scriptInterpreter->initScript(&_sceneScriptState, &_sceneScriptData); + + _sceneScriptState.regs[0] = _mainCharacter.sceneId; + _sceneScriptState.regs[1] = _mouseX; + _sceneScriptState.regs[2] = _mouseY; + _sceneScriptState.regs[3] = _itemInHand; + + _scriptInterpreter->startScript(&_sceneScriptState, 6); + while (_scriptInterpreter->validScript(&_sceneScriptState)) + _scriptInterpreter->runScript(&_sceneScriptState); +} + void KyraEngine_v3::runSceneScript8() { debugC(9, kDebugLevelMain, "KyraEngine_v3::runSceneScript8()"); _scriptInterpreter->startScript(&_sceneScriptState, 8); diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index 2d564393ef..1bbafd481b 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -2342,6 +2342,14 @@ const uint8 KyraEngine_v3::_trashItemList[] = { 0x39, 0x40, 0x3E, 0x3D, 0x3C, 0x3F, 0xFF }; +const uint8 KyraEngine_v3::_itemMagicTable[] = { + 0x06, 0x05, 0x07, 0xFE, 0x05, 0x06, 0x07, 0xFE, + 0x03, 0x00, 0x22, 0xFE, 0x00, 0x03, 0x22, 0xFE, + 0x10, 0x00, 0x20, 0x0F, 0x00, 0x10, 0x0F, 0x20, + 0x10, 0x22, 0x21, 0x0F, 0x22, 0x10, 0x0F, 0x21, + 0xFF, 0xFF, 0xFF, 0xFF +}; + } // End of namespace Kyra |