diff options
author | Johannes Schickel | 2008-04-22 18:08:56 +0000 |
---|---|---|
committer | Johannes Schickel | 2008-04-22 18:08:56 +0000 |
commit | 8a18ddb3cae4fa89479225d40984e80c92635b2e (patch) | |
tree | 655d68aee69a431c6067ca842badece9479e7ebf | |
parent | 52f43fcff44e4dee4eb25965e2ea2affe9583a1d (diff) | |
download | scummvm-rg350-8a18ddb3cae4fa89479225d40984e80c92635b2e.tar.gz scummvm-rg350-8a18ddb3cae4fa89479225d40984e80c92635b2e.tar.bz2 scummvm-rg350-8a18ddb3cae4fa89479225d40984e80c92635b2e.zip |
Implemented opcodes:
- 32: o3_setHandItem
- 33: o3_removeHandItem
- 50: o3_wipeDownMouseItem
- 116: o3_runActorScript
- 136: o3_countItemInstances
svn-id: r31657
-rw-r--r-- | engines/kyra/animator_v3.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/items_v3.cpp | 42 | ||||
-rw-r--r-- | engines/kyra/kyra_v3.cpp | 12 | ||||
-rw-r--r-- | engines/kyra/kyra_v3.h | 14 | ||||
-rw-r--r-- | engines/kyra/script_v3.cpp | 104 |
5 files changed, 166 insertions, 8 deletions
diff --git a/engines/kyra/animator_v3.cpp b/engines/kyra/animator_v3.cpp index e28d6ab8ec..67b6e2ac2e 100644 --- a/engines/kyra/animator_v3.cpp +++ b/engines/kyra/animator_v3.cpp @@ -193,7 +193,7 @@ void KyraEngine_v3::drawSceneAnimObject(AnimObj *obj, int x, int y, int layer) { if (obj->shapeIndex == 0xFFFF) return; int scale = getScale(obj->xPos1, obj->yPos1); - _screen->drawShape(2, getShapePtr(obj->shapeIndex), x, y, 2, obj->flags | 104, _paletteOverlay, obj->palette, layer, scale, scale); + _screen->drawShape(2, getShapePtr(obj->shapeIndex), x, y, 2, obj->flags | 0x104, _paletteOverlay, obj->palette, layer, scale, scale); } else { if (obj->shapePtr) { _screen->drawShape(2, obj->shapePtr, x, y, 2, obj->flags, 7); diff --git a/engines/kyra/items_v3.cpp b/engines/kyra/items_v3.cpp index 993a6599f7..38359de446 100644 --- a/engines/kyra/items_v3.cpp +++ b/engines/kyra/items_v3.cpp @@ -90,13 +90,53 @@ int KyraEngine_v3::checkItemCollision(int x, int y) { return itemIndex; } +void KyraEngine_v3::setMouseCursor(uint16 item) { + debugC(9, kDebugLevelMain, "KyraEngine_v3::setMouseCursor(%u)", item); + int shape = 0; + int hotX = 1; + int hotY = 1; + + if (item != 0xFFFF) { + hotX = 12; + hotY = 19; + shape = item+248; + } + + if ((int16)item != _itemInHand) + _screen->setMouseCursor(hotX, hotY, getShapePtr(shape)); +} + void KyraEngine_v3::setItemMouseCursor() { debugC(9, kDebugLevelMain, "KyraEngine_v3::setItemMouseCursor()"); _handItemSet = _itemInHand; if (_itemInHand == -1) _screen->setMouseCursor(0, 0, _gameShapes[0]); else - _screen->setMouseCursor(0xC, 0x13, _gameShapes[_itemInHand+248]); + _screen->setMouseCursor(12, 19, _gameShapes[_itemInHand+248]); +} + +void KyraEngine_v3::setHandItem(uint16 item) { + debugC(9, kDebugLevelMain, "KyraEngine_v3::setHandItem(%u)", item); + _screen->hideMouse(); + + if (item == 0xFFFF) { + removeHandItem(); + } else { + setMouseCursor(item); + _itemInHand = item; + } + + _screen->showMouse(); +} + +void KyraEngine_v3::removeHandItem() { + debugC(9, kDebugLevelMain, "KyraEngine_v3::removeHandItem()"); + _screen->hideMouse(); + _screen->setMouseCursor(0, 0, _gameShapes[0]); + _itemInHand = -1; + _handItemSet = -1; + _screen->showMouse(); } } // end of namespace Kyra + diff --git a/engines/kyra/kyra_v3.cpp b/engines/kyra/kyra_v3.cpp index d499dbeee9..aafe6fb14e 100644 --- a/engines/kyra/kyra_v3.cpp +++ b/engines/kyra/kyra_v3.cpp @@ -1430,6 +1430,18 @@ int KyraEngine_v3::getScale(int x, int y) { #pragma mark - +void KyraEngine_v3::backUpGfxRect32x32(int x, int y) { + debugC(9, kDebugLevelMain, "KyraEngine_v3::backUpGfxRect32x32(%d, %d)", x, y); + _screen->copyRegionToBuffer(_screen->_curPage, x, y, 32, 32, _gfxBackUpRect); +} + +void KyraEngine_v3::restoreGfxRect32x32(int x, int y) { + debugC(9, kDebugLevelMain, "KyraEngine_v3::restoreGfxRect32x32(%d, %d)", x, y); + _screen->copyBlockToPage(_screen->_curPage, x, y, 32, 32, _gfxBackUpRect); +} + +#pragma mark - + char *KyraEngine_v3::appendLanguage(char *buf, int lang, int bufSize) { debugC(9, kDebugLevelMain, "KyraEngine_v3::appendLanguage([%p|'%s'], %d, %d)", (const void*)buf, buf, lang, bufSize); assert(lang < _languageExtensionSize); diff --git a/engines/kyra/kyra_v3.h b/engines/kyra/kyra_v3.h index 1005547433..1e08016a2a 100644 --- a/engines/kyra/kyra_v3.h +++ b/engines/kyra/kyra_v3.h @@ -280,7 +280,11 @@ private: int checkItemCollision(int x, int y); + void setMouseCursor(uint16 item); + // -> hand item + void setHandItem(uint16 item); + void removeHandItem(); void setItemMouseCursor(); int _itemInHand; @@ -516,7 +520,6 @@ private: // unk uint8 *_costPalBuffer; uint8 *_screenBuffer; - uint8 *_gfxBackUpRect; uint8 *_paletteOverlay; bool _useActorBuffer; int _curChapter; @@ -527,6 +530,10 @@ private: void loadShadowShape(); void loadExtrasShapes(); + uint8 *_gfxBackUpRect; + void backUpGfxRect32x32(int x, int y); + void restoreGfxRect32x32(int x, int y); + // opcodes int o3_getMalcolmShapes(ScriptState *script); int o3_setCharacterPos(ScriptState *script); @@ -546,12 +553,15 @@ private: int o3_queryGameFlag(ScriptState *script); int o3_resetGameFlag(ScriptState *script); int o3_setGameFlag(ScriptState *script); + int o3_setHandItem(ScriptState *script); + int o3_removeHandItem(ScriptState *script); int o3_getHandItem(ScriptState *script); int o3_hideMouse(ScriptState *script); int o3_addSpecialExit(ScriptState *script); int o3_setMousePos(ScriptState *script); int o3_showMouse(ScriptState *script); int o3_badConscienceChat(ScriptState *script); + int o3_wipeDownMouseItem(ScriptState *script); int o3_delay(ScriptState *script); int o3_setSceneFilename(ScriptState *script); int o3_drawSceneShape(ScriptState *script); @@ -567,7 +577,9 @@ private: int o3_setSpecialSceneScriptRunTime(ScriptState *script); int o3_defineSceneAnim(ScriptState *script); int o3_updateSceneAnim(ScriptState *script); + int o3_runActorScript(ScriptState *script); int o3_defineScene(ScriptState *script); + int o3_countItemInstances(ScriptState *script); int o3_setSpecialSceneScriptState(ScriptState *script); int o3_clearSpecialSceneScriptState(ScriptState *script); int o3_querySpecialSceneScriptState(ScriptState *script); diff --git a/engines/kyra/script_v3.cpp b/engines/kyra/script_v3.cpp index e309b1ee1c..3c27152bcf 100644 --- a/engines/kyra/script_v3.cpp +++ b/engines/kyra/script_v3.cpp @@ -190,6 +190,18 @@ int KyraEngine_v3::o3_setGameFlag(ScriptState *script) { return 1; } +int KyraEngine_v3::o3_setHandItem(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_setHandItem(%p) (%d)", (const void *)script, stackPos(0)); + setHandItem(stackPos(0)); + return 0; +} + +int KyraEngine_v3::o3_removeHandItem(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_removeHandItem(%p) ()", (const void *)script); + removeHandItem(); + return 0; +} + int KyraEngine_v3::o3_getHandItem(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_getHandItem(%p) ()", (const void *)script); return _itemInHand; @@ -235,6 +247,33 @@ int KyraEngine_v3::o3_badConscienceChat(ScriptState *script) { return 0; } +int KyraEngine_v3::o3_wipeDownMouseItem(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v2::o3_wipeDownMouseItem(%p) (-, %d, %d)", (const void *)script, stackPos(1), stackPos(2)); + _screen->hideMouse(); + const int x = stackPos(1) - 12; + const int y = stackPos(2) - 19; + + if (_itemInHand >= 0) { + backUpGfxRect32x32(x, y); + uint8 *shape = getShapePtr(_itemInHand+248); + for (int curY = y, height = 20; height > 0; height -= 2, curY += 2) { + restoreGfxRect32x32(x, y); + _screen->setNewShapeHeight(shape, height); + uint32 waitTime = _system->getMillis() + _tickLength; + _screen->drawShape(0, shape, x, curY, 0, 0); + _screen->updateScreen(); + delayUntil(waitTime); + } + restoreGfxRect32x32(x, y); + _screen->resetShapeHeight(shape); + } + + _screen->showMouse(); + removeHandItem(); + + return 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; @@ -455,6 +494,40 @@ int KyraEngine_v3::o3_updateSceneAnim(ScriptState *script) { return 0; } +int KyraEngine_v3::o3_runActorScript(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_runActorScript(%p) ()", (const void *)script); + ScriptData data; + ScriptState state; + memset(&data, 0, sizeof(data)); + memset(&state, 0, sizeof(state)); + + _res->exists("_ACTOR.EMC", true); + _scriptInterpreter->loadScript("_ACTOR.EMC", &data, &_opcodes); + _scriptInterpreter->initScript(&state, &data); + _scriptInterpreter->startScript(&state, 0); + + state.regs[4] = _itemInHand; + state.regs[0] = _mainCharacter.sceneId; + + int vocHigh = _vocHigh; + _vocHigh = 200; + _useActorBuffer = true; + + while (_scriptInterpreter->validScript(&state)) + _scriptInterpreter->runScript(&state); + + _useActorBuffer = false; + _vocHigh = vocHigh; + _scriptInterpreter->unloadScript(&data); + + if (queryGameFlag(0x218)) { + resetGameFlag(0x218); + enterNewScene(78, -1, 0, 0, 0); + } + + return 0; +} + int KyraEngine_v3::o3_defineScene(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_defineScene(%p) (%d, '%s', %d, %d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPosString(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6), stackPos(7)); @@ -481,6 +554,27 @@ int KyraEngine_v3::o3_defineScene(ScriptState *script) { return 0; } +int KyraEngine_v3::o3_countItemInstances(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_countItemInstances(%p) (%d)", (const void *)script, stackPos(0)); + int count = 0; + const int16 item = stackPos(0); + + for (int i = 0; i < 10; ++i) { + if (_mainCharacter.inventory[i] == item) + ++count; + } + + if (_itemInHand == item) + ++count; + + for (int i = 0; i < 50; ++i) { + if (_itemList[i].id == item) + ++count; + } + + return count; +} + int KyraEngine_v3::o3_setSpecialSceneScriptState(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_setSpecialSceneScriptState(%p) (%d)", (const void *)script, stackPos(0)); _specialSceneScriptState[stackPos(0)] = 1; @@ -641,8 +735,8 @@ void KyraEngine_v3::setupOpcodeTable() { // 0x28 Opcode(o3_resetGameFlag); Opcode(o3_setGameFlag); - OpcodeUnImpl(); - OpcodeUnImpl(); + Opcode(o3_setHandItem); + Opcode(o3_removeHandItem); // 0x2c Opcode(o3_getHandItem); Opcode(o3_hideMouse); @@ -651,7 +745,7 @@ void KyraEngine_v3::setupOpcodeTable() { // 0x30 Opcode(o3_showMouse); Opcode(o3_badConscienceChat); - OpcodeUnImpl(); + Opcode(o3_wipeDownMouseItem); Opcode(o3_dummy); // 0x34 OpcodeUnImpl(); @@ -734,7 +828,7 @@ void KyraEngine_v3::setupOpcodeTable() { Opcode(o3_updateSceneAnim); Opcode(o3_dummy); // 0x74 - OpcodeUnImpl(); + Opcode(o3_runActorScript); OpcodeUnImpl(); OpcodeUnImpl(); OpcodeUnImpl(); @@ -759,7 +853,7 @@ void KyraEngine_v3::setupOpcodeTable() { Opcode(o3_dummy); Opcode(o3_dummy); // 0x88 - OpcodeUnImpl(); + Opcode(o3_countItemInstances); Opcode(o3_dummy); OpcodeUnImpl(); Opcode(o3_dummy); |