diff options
author | Johannes Schickel | 2007-10-09 08:44:45 +0000 |
---|---|---|
committer | Johannes Schickel | 2007-10-09 08:44:45 +0000 |
commit | dd1b43a5a91da0051a32938807d7a7fa157caa2a (patch) | |
tree | a7d943acb1d03065f3e5f900e8982204065cd038 | |
parent | d73ffa3b03ba4f67aed82466951709e970141e8a (diff) | |
download | scummvm-rg350-dd1b43a5a91da0051a32938807d7a7fa157caa2a.tar.gz scummvm-rg350-dd1b43a5a91da0051a32938807d7a7fa157caa2a.tar.bz2 scummvm-rg350-dd1b43a5a91da0051a32938807d7a7fa157caa2a.zip |
HoF:
- More input handling (should be rather complete now, not finished but nearlly)
- Implemented the following opcodes:
-> o2_trySceneChange 0x0d
-> o2_setHandItem 0x2a
-> o2_handItemSet 0x2c
-> o2_setCharPalEntry 0x3c
-> o2_drawSceneShape 0x3e
-> o2_update 0x4b
-> o2_fadeScenePal 0x4d
-> o2_enterNewSceneEx 0x50
-> o2_setZanthiaPos 0x56
-> o2_runTemporaryScript 0x6e
-> o2t_defineNewShape 0x00
-> o2t_setCurrentFrame 0x01
-> o2t_setShapeFlag 0x04
svn-id: r29178
-rw-r--r-- | engines/kyra/animator_v2.cpp | 22 | ||||
-rw-r--r-- | engines/kyra/items_v2.cpp | 13 | ||||
-rw-r--r-- | engines/kyra/kyra_v2.cpp | 201 | ||||
-rw-r--r-- | engines/kyra/kyra_v2.h | 50 | ||||
-rw-r--r-- | engines/kyra/scene_v2.cpp | 9 | ||||
-rw-r--r-- | engines/kyra/script.h | 4 | ||||
-rw-r--r-- | engines/kyra/script_v2.cpp | 162 |
7 files changed, 444 insertions, 17 deletions
diff --git a/engines/kyra/animator_v2.cpp b/engines/kyra/animator_v2.cpp index 2333a1a81b..eb1e93a6a2 100644 --- a/engines/kyra/animator_v2.cpp +++ b/engines/kyra/animator_v2.cpp @@ -191,6 +191,11 @@ void KyraEngine_v2::refreshAnimObjectsIfNeed() { } } +void KyraEngine_v2::flagAnimObjsForRefresh() { + for (AnimObj *curEntry = _animList; curEntry; curEntry = curEntry->nextObject) + curEntry->needRefresh = 1; +} + void KyraEngine_v2::updateCharFacing() { if (_mainCharacter.x1 > _mouseX) _mainCharacter.facing = 5; @@ -369,4 +374,21 @@ void KyraEngine_v2::deleteItemAnimEntry(int item) { _animList = deleteAnimListEntry(_animList, animObj); } +void KyraEngine_v2::setCharacterAnimDim(int w, int h) { + restorePage3(); + + _animObj0Width = _animObjects[0].width; + _animObj0Height = _animObjects[0].height; + + _animObjects[0].width = w; + _animObjects[0].height = h; +} + +void KyraEngine_v2::resetCharacterAnimDim() { + restorePage3(); + + _animObjects[0].width = _animObj0Width; + _animObjects[0].height = _animObj0Height; +} + } // end of namespace Kyra diff --git a/engines/kyra/items_v2.cpp b/engines/kyra/items_v2.cpp index d291f69bb8..37261e1706 100644 --- a/engines/kyra/items_v2.cpp +++ b/engines/kyra/items_v2.cpp @@ -422,6 +422,19 @@ void KyraEngine_v2::setMouseCursor(uint16 item) { _screen->setMouseCursor(hotX, hotY, getShapePtr(shape)); } +void KyraEngine_v2::setHandItem(uint16 item) { + _screen->hideMouse(); + + if (item == 0xFFFF) { + removeHandItem(); + } else { + setMouseCursor(item); + _itemInHand = item; + } + + _screen->showMouse(); +} + void KyraEngine_v2::removeHandItem() { _screen->hideMouse(); _screen->setMouseCursor(0, 0, _defaultShapeTable[0]); diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp index f47357f237..e39267f962 100644 --- a/engines/kyra/kyra_v2.cpp +++ b/engines/kyra/kyra_v2.cpp @@ -63,6 +63,8 @@ KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngi _unkHandleSceneChangeFlag = false; _pathfinderFlag = 0; _mouseX = _mouseY = 0; + _newShapeCount = 0; + _newShapeFiledata = 0; memset(&_sceneScriptData, 0, sizeof(_sceneScriptData)); } @@ -234,14 +236,14 @@ void KyraEngine_v2::startup() { memset(_shapeDescTable, 0, sizeof(ShapeDesc)*55); for (int i = 9; i <= 32; ++i) { - _shapeDescTable[i-9].unk5 = 30; - _shapeDescTable[i-9].unk7 = 55; + _shapeDescTable[i-9].width = 30; + _shapeDescTable[i-9].height = 55; _shapeDescTable[i-9].xAdd = -15; _shapeDescTable[i-9].yAdd = -50; } for (int i = 19; i <= 24; ++i) { - _shapeDescTable[i-9].unk7 = 53; + _shapeDescTable[i-9].width = 53; _shapeDescTable[i-9].yAdd = -51; } @@ -363,7 +365,7 @@ void KyraEngine_v2::handleInput(int x, int y) { if (checkItemCollision(x, y) == -1) { resetGameFlag(0x1EF); - //skipHandling = sub_153D6(x, y); + skipHandling = handleInputUnkSub(x, y) ? 1 : 0; if (queryGameFlag(0x1EF)) { resetGameFlag(0x1EF); @@ -406,6 +408,38 @@ void KyraEngine_v2::handleInput(int x, int y) { } } +bool KyraEngine_v2::handleInputUnkSub(int x, int y) { + if (y >= 143/* || _unk1 > -1 */|| queryGameFlag(0x164)) + return false; + + if (_handItemSet <= -3 && findItem(_mainCharacter.sceneId, 13) >= 0) { + updateCharFacing(); + //sub_277FA(getTableString(0xFC, _cCodeBuffer, 1), 0, 0x83, 0xFC); + return true; + } else { + _scriptInterpreter->initScript(&_sceneScriptState, &_sceneScriptData); + + _sceneScriptState.regs[1] = x; + _sceneScriptState.regs[2] = y; + _sceneScriptState.regs[3] = 0; + _sceneScriptState.regs[4] = _itemInHand; + + _scriptInterpreter->startScript(&_sceneScriptState, 1); + + while (_scriptInterpreter->validScript(&_sceneScriptState)) + _scriptInterpreter->runScript(&_sceneScriptState); + + //XXXsys_unkKeyboad (flush? wait? whatever...) + + if (queryGameFlag(0x1ED)) { + // XXX + _quitFlag = true; + } + + return _sceneScriptState.regs[3] != 0; + } +} + int KyraEngine_v2::update() { updateInput(); @@ -604,6 +638,8 @@ void KyraEngine_v2::cleanup() { delete [] _screenBuffer; delete [] _unkBuf200kByte; + resetNewShapes(_newShapeCount, _newShapeFiledata); + for (int i = 0; i < ARRAYSIZE(_defaultShapeTable); ++i) delete [] _defaultShapeTable[i]; freeSceneShapePtrs(); @@ -899,6 +935,49 @@ void KyraEngine_v2::loadNPCScript() { _scriptInterpreter->loadScript(filename, &_npcScriptData, &_opcodes); } +void KyraEngine_v2::runTemporaryScript(const char *filename, int unk1, int unk2, int newShapes, int shapeUnload) { + memset(&_temporaryScriptData, 0, sizeof(_temporaryScriptData)); + memset(&_temporaryScriptState, 0, sizeof(_temporaryScriptState)); + + if (!_scriptInterpreter->loadScript(filename, &_temporaryScriptData, &_opcodesTemporary)) + error("couldn't load temporary script '%s'", filename); + + _scriptInterpreter->initScript(&_temporaryScriptState, &_temporaryScriptData); + _scriptInterpreter->startScript(&_temporaryScriptState, 0); + + _newShapeFlag = -1; + + while (_scriptInterpreter->validScript(&_temporaryScriptState)) + _scriptInterpreter->runScript(&_temporaryScriptState); + + uint8 *fileData = 0; + + if (newShapes) { + _newShapeFiledata = _res->fileData(_newShapeFilename, 0); + assert(_newShapeFiledata); + } + + fileData = _newShapeFiledata; + + if (!fileData) + return; + + if (newShapes) + _newShapeCount = initNewShapes(fileData); + + processNewShapes(unk1, unk2); + + if (shapeUnload) { + resetNewShapes(_newShapeCount, fileData); + _newShapeCount = 0; + _newShapeFiledata = 0; + } + + _scriptInterpreter->unloadScript(&_temporaryScriptData); +} + +#pragma mark - + void KyraEngine_v2::resetScaleTable() { for (int i = 0; i < ARRAYSIZE(_scaleTable); ++i) _scaleTable[i] = 0x100; @@ -959,6 +1038,16 @@ void KyraEngine_v2::updateCharPal(int unk1) { } } +void KyraEngine_v2::setCharPalEntry(int entry, int value) { + if (entry > 15 || entry < 1) + entry = 1; + if (value > 8 || value < 0) + value = 0; + _charPalTable[entry] = value; + _useCharPal = 1; + _charPalEntry = 0; +} + int KyraEngine_v2::inputSceneChange(int x, int y, int unk1, int unk2) { bool refreshNPC = false; uint16 curScene = _mainCharacter.sceneId; @@ -1180,6 +1269,78 @@ int KyraEngine_v2::checkCharCollision(int x, int y) { return -1; } +int KyraEngine_v2::initNewShapes(uint8 *filedata) { + const int lastEntry = MIN(_newShapeLastEntry, 31); + for (int i = 0; i < lastEntry; ++i) { + _defaultShapeTable[33+i] = _screen->getPtrToShape(filedata, i); + ShapeDesc *desc = &_shapeDescTable[24+i]; + desc->xAdd = _newShapeXAdd; + desc->yAdd = _newShapeYAdd; + desc->width = _newShapeWidth; + desc->height = _newShapeHeight; + } + return lastEntry; +} + +void KyraEngine_v2::processNewShapes(int unk1, int unk2) { + setCharacterAnimDim(_newShapeWidth, _newShapeHeight); + + _scriptInterpreter->initScript(&_temporaryScriptState, &_temporaryScriptData); + _scriptInterpreter->startScript(&_temporaryScriptState, 1); + + while (_scriptInterpreter->validScript(&_temporaryScriptState) && !_skipFlag) { + _temporaryScriptExecBit = false; + while (_scriptInterpreter->validScript(&_temporaryScriptState) && !_temporaryScriptExecBit) + _scriptInterpreter->runScript(&_temporaryScriptState); + + if (_newShapeAnimFrame < 0) + continue; + + _mainCharacter.animFrame = _newShapeAnimFrame + 33; + updateCharacterAnim(0); + //if (dword_30BB2) + // sub_159D6(); + //else + update(); + + uint32 delayEnd = _system->getMillis() + _newShapeDelay * _tickLength; + + while (!_skipFlag && _system->getMillis() < delayEnd) { + // XXX skipFlag handling, unk1 seems to make a scene not skipable + + //if (dword_30BB2) + // sub_159D6(); + //else + update(); + + delay(10); + } + } + + if (unk2) { + if (_newShapeFlag >= 0) { + _mainCharacter.animFrame = _newShapeFlag + 33; + updateCharacterAnim(0); + //if (dword_30BB2) + // sub_159D6(); + //else + update(); + } + + _mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing]; + updateCharacterAnim(0); + } + + _newShapeFlag = -1; + resetCharacterAnimDim(); +} + +void KyraEngine_v2::resetNewShapes(int count, uint8 *filedata) { + Common::set_to(_defaultShapeTable+33, _defaultShapeTable+33+count, (uint8*)0); + delete [] filedata; + //setNextIdleAnimTimer(); +} + #pragma mark - void KyraEngine_v2::backUpGfxRect24x24(int x, int y) { @@ -1214,7 +1375,7 @@ void KyraEngine_v2::setupOpcodeTable() { OpcodeUnImpl(), // 0x0c OpcodeUnImpl(), - OpcodeUnImpl(), + Opcode(o2_trySceneChange), OpcodeUnImpl(), OpcodeUnImpl(), // 0x10 @@ -1250,10 +1411,10 @@ void KyraEngine_v2::setupOpcodeTable() { // 0x28 Opcode(o2_resetGameFlag), Opcode(o2_setGameFlag), - OpcodeUnImpl(), + Opcode(o2_setHandItem), OpcodeUnImpl(), // 0x2c - OpcodeUnImpl(), + Opcode(o2_handItemSet), Opcode(o2_hideMouse), Opcode(o2_addSpecialExit), OpcodeUnImpl(), @@ -1273,9 +1434,9 @@ void KyraEngine_v2::setupOpcodeTable() { Opcode(o2_setScaleTableItem), Opcode(o2_setDrawLayerTableItem), // 0x3c + Opcode(o2_setCharPalEntry), OpcodeUnImpl(), - OpcodeUnImpl(), - OpcodeUnImpl(), + Opcode(o2_drawSceneShape), Opcode(o2_drawSceneShapeOnPage), // 0x40 OpcodeUnImpl(), @@ -1291,21 +1452,21 @@ void KyraEngine_v2::setupOpcodeTable() { OpcodeUnImpl(), OpcodeUnImpl(), OpcodeUnImpl(), - OpcodeUnImpl(), + Opcode(o2_update), // 0x4c OpcodeUnImpl(), - OpcodeUnImpl(), + Opcode(o2_fadeScenePal), Opcode(o2_dummy), Opcode(o2_dummy), // 0x50 - OpcodeUnImpl(), + Opcode(o2_enterNewSceneEx), OpcodeUnImpl(), OpcodeUnImpl(), OpcodeUnImpl(), // 0x54 OpcodeUnImpl(), Opcode(o2_setLayerFlag), - OpcodeUnImpl(), + Opcode(o2_setZanthiaPos), OpcodeUnImpl(), // 0x58 OpcodeUnImpl(), @@ -1335,7 +1496,7 @@ void KyraEngine_v2::setupOpcodeTable() { // 0x6c Opcode(o2_encodeShape), Opcode(o2_defineRoomEntrance), - OpcodeUnImpl(), + Opcode(o2_runTemporaryScript), Opcode(o2_setSpecialSceneScriptRunTime), // 0x70 Opcode(o2_defineSceneAnim), @@ -1421,6 +1582,18 @@ void KyraEngine_v2::setupOpcodeTable() { for (int i = 0; i < ARRAYSIZE(opcodeTable); ++i) _opcodes.push_back(&opcodeTable[i]); + + static const OpcodeV2 opcodeTemporaryTable[] = { + Opcode(o2t_defineNewShapes), + Opcode(o2t_setCurrentFrame), + OpcodeUnImpl(), + OpcodeUnImpl(), + Opcode(o2t_setShapeFlag), + Opcode(o2_dummy) + }; + + for (int i = 0; i < ARRAYSIZE(opcodeTemporaryTable); ++i) + _opcodesTemporary.push_back(&opcodeTemporaryTable[i]); } } // end of namespace Kyra diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h index b8ea7234ce..e7d3f6c2d0 100644 --- a/engines/kyra/kyra_v2.h +++ b/engines/kyra/kyra_v2.h @@ -169,6 +169,7 @@ protected: int checkInput(void *p); void removeInputTop(); void handleInput(int x, int y); + bool handleInputUnkSub(int x, int y); int inputSceneChange(int x, int y, int unk1, int unk2); @@ -199,7 +200,7 @@ protected: struct ShapeDesc { uint8 unk0, unk1, unk2, unk3, unk4; - uint16 unk5, unk7; + uint16 width, height; int16 xAdd, yAdd; }; @@ -243,6 +244,20 @@ protected: int _drawLayerTable[15]; int _layerFlagTable[16]; // seems to indicate layers where items get destroyed when dropped to (TODO: check this!) + + char _newShapeFilename[13]; + int _newShapeLastEntry; + int _newShapeWidth, _newShapeHeight; + int _newShapeXAdd, _newShapeYAdd; + int _newShapeFlag; + uint8 *_newShapeFiledata; + int _newShapeCount; + int _newShapeAnimFrame; + int _newShapeDelay; + + int initNewShapes(uint8 *filedata); + void processNewShapes(int unk1, int unk2); + void resetNewShapes(int count, uint8 *filedata); // animator struct AnimObj { @@ -286,6 +301,8 @@ protected: void refreshAnimObjects(int force); void refreshAnimObjectsIfNeed(); + + void flagAnimObjsForRefresh(); void updateCharFacing(); void updateCharacterAnim(int); @@ -293,6 +310,10 @@ protected: void addItemToAnimList(int item); void deleteItemAnimEntry(int item); + + int _animObj0Width, _animObj0Height; + void setCharacterAnimDim(int w, int h); + void resetCharacterAnimDim(); // scene struct SceneDesc { @@ -323,6 +344,8 @@ protected: void loadScenePal(); void loadSceneMsc(); + + void fadeScenePal(int srcIndex, int delay); void startSceneScript(int unk1); void runSceneScript2(); @@ -388,6 +411,7 @@ protected: int getItemCommandStringPickUp(uint16 item); void setMouseCursor(uint16 item); + void setHandItem(uint16 item); void removeHandItem(); // inventroy @@ -437,6 +461,7 @@ protected: int _charPalEntry; uint8 _charPalTable[16]; void updateCharPal(int unk1); + void setCharPalEntry(int entry, int value); void moveCharacter(int facing, int x, int y); int updateCharPos(int *table); @@ -479,6 +504,7 @@ protected: int o2_getCharacterY(ScriptState *script); int o2_getCharacterFacing(ScriptState *script); int o2_setSceneComment(ScriptState *script); + int o2_trySceneChange(ScriptState *script); int o2_showChapterMessage(ScriptState *script); int o2_wsaClose(ScriptState *script); int o2_displayWsaFrame(ScriptState *script); @@ -488,17 +514,27 @@ protected: int o2_queryGameFlag(ScriptState *script); int o2_resetGameFlag(ScriptState *script); int o2_setGameFlag(ScriptState *script); + int o2_setHandItem(ScriptState *script); + int o2_handItemSet(ScriptState *script); int o2_hideMouse(ScriptState *script); int o2_addSpecialExit(ScriptState *script); int o2_showMouse(ScriptState *script); + int o2_delay(ScriptState *script); int o2_setScaleTableItem(ScriptState *script); int o2_setDrawLayerTableItem(ScriptState *script); + int o2_setCharPalEntry(ScriptState *script); + int o2_drawSceneShape(ScriptState *script); int o2_drawSceneShapeOnPage(ScriptState *script); int o2_restoreBackBuffer(ScriptState *script); + int o2_update(ScriptState *script); + int o2_fadeScenePal(ScriptState *script); + int o2_enterNewSceneEx(ScriptState *script); int o2_setLayerFlag(ScriptState *script); + int o2_setZanthiaPos(ScriptState *script); int o2_getRand(ScriptState *script); int o2_encodeShape(ScriptState *script); int o2_defineRoomEntrance(ScriptState *script); + int o2_runTemporaryScript(ScriptState *script); int o2_setSpecialSceneScriptRunTime(ScriptState *script); int o2_defineSceneAnim(ScriptState *script); int o2_updateSceneAnim(ScriptState *script); @@ -507,6 +543,11 @@ protected: int o2_clearSpecialSceneScriptState(ScriptState *script); int o2_querySpecialSceneScriptState(ScriptState *script); int o2_dummy(ScriptState *script); + + // opcodes temporary + int o2t_defineNewShapes(ScriptState *script); + int o2t_setCurrentFrame(ScriptState *script); + int o2t_setShapeFlag(ScriptState *script); // script void runStartScript(int script, int unk1); @@ -519,6 +560,13 @@ protected: ScriptData _sceneScriptData; ScriptState _sceneScriptState; + ScriptData _temporaryScriptData; + ScriptState _temporaryScriptState; + bool _temporaryScriptExecBit; + Common::Array<const Opcode*> _opcodesTemporary; + + void runTemporaryScript(const char *filename, int unk1, int unk2, int newShapes, int shapeUnload); + // pathfinder int _pathfinderFlag; diff --git a/engines/kyra/scene_v2.cpp b/engines/kyra/scene_v2.cpp index 002327efae..b3b4e6e3b3 100644 --- a/engines/kyra/scene_v2.cpp +++ b/engines/kyra/scene_v2.cpp @@ -884,4 +884,13 @@ void KyraEngine_v2::pathfinderUnk5(int *moveTable, int tableLen, int x, int y, i } } +void KyraEngine_v2::fadeScenePal(int srcIndex, int delayTime) { + uint8 *dst = _screen->getPalette(0) + 336; + const uint8 *src = _scenePal + (srcIndex << 4)*3; + memcpy(dst, src, 48); + + // TODO: original passes delay function too + _screen->fadePalette(_screen->getPalette(0), delayTime); +} + } // end of namespace Kyra diff --git a/engines/kyra/script.h b/engines/kyra/script.h index 3396712a24..293f328483 100644 --- a/engines/kyra/script.h +++ b/engines/kyra/script.h @@ -52,8 +52,8 @@ struct ScriptState { int16 stack[61]; // VM stack }; -#define stackPos(x) script->stack[script->sp+x] -#define stackPosString(x) (const char*)&script->dataPtr->text[READ_BE_UINT16(&((uint16 *)script->dataPtr->text)[stackPos(x)])] +#define stackPos(x) (script->stack[script->sp+x]) +#define stackPosString(x) ((const char*)&script->dataPtr->text[READ_BE_UINT16(&((uint16 *)script->dataPtr->text)[stackPos(x)])]) class ScriptFileParser { public: diff --git a/engines/kyra/script_v2.cpp b/engines/kyra/script_v2.cpp index 9e407e1ef2..1e17aed3c5 100644 --- a/engines/kyra/script_v2.cpp +++ b/engines/kyra/script_v2.cpp @@ -89,6 +89,25 @@ int KyraEngine_v2::o2_setSceneComment(ScriptState *script) { return 0; } +int KyraEngine_v2::o2_trySceneChange(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_trySceneChange(%p) (%d, %d, %d, %d)", (const void *)script, + stackPos(0), stackPos(1), stackPos(2), stackPos(3)); + + _unkHandleSceneChangeFlag = 1; + int success = inputSceneChange(stackPos(0), stackPos(1), stackPos(2), stackPos(3)); + _unkHandleSceneChangeFlag = 0; + + if (success) { + _scriptInterpreter->initScript(script, script->dataPtr); + _unk4 = 0; + _unk3 = -1; + _unk5 = 1; + return 0; + } else { + return (_unk4 != 0) ? 1 : 0; + } +} + int KyraEngine_v2::o2_showChapterMessage(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "o2_showChapterMessage(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); showChapterMessage(stackPos(0), stackPos(1)); @@ -230,6 +249,17 @@ int KyraEngine_v2::o2_setGameFlag(ScriptState *script) { return setGameFlag(stackPos(0)); } +int KyraEngine_v2::o2_setHandItem(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_setHandItem(%p) (%d)", (const void *)script, stackPos(0)); + setHandItem(stackPos(0)); + return 0; +} + +int KyraEngine_v2::o2_handItemSet(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_handItemSet(%p) ()", (const void *)script); + return _handItemSet; +} + int KyraEngine_v2::o2_hideMouse(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "o2_hideMouse(%p) ()", (const void *)script); _screen->hideMouse(); @@ -256,6 +286,15 @@ int KyraEngine_v2::o2_showMouse(ScriptState *script) { return 0; } +int KyraEngine_v2::o2_delay(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_delay(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + //if (stackPos(1)) + // sub_27100(stackPos(0) * _tickLength); + //else + delay(stackPos(0) * _tickLength); + return 0; +} + int KyraEngine_v2::o2_setScaleTableItem(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "o2_setScaleTableItem(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); setScaleTableItem(stackPos(0), stackPos(1)); @@ -268,6 +307,37 @@ int KyraEngine_v2::o2_setDrawLayerTableItem(ScriptState *script) { return 0; } +int KyraEngine_v2::o2_setCharPalEntry(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_setCharPalEntry(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + setCharPalEntry(stackPos(0), stackPos(1)); + return 0; +} + +int KyraEngine_v2::o2_drawSceneShape(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_drawSceneShape(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), + stackPos(2), stackPos(3)); + + int shape = stackPos(0); + int x = stackPos(1); + int y = stackPos(2); + int flag = (stackPos(3) != 0) ? 1 : 0; + + _screen->hideMouse(); + restorePage3(); + + _screen->drawShape(2, _sceneShapeTable[shape], x, y, 2, flag); + + memcpy(_gamePlayBuffer, _screen->getCPagePtr(3), 46080); + + _screen->drawShape(0, _sceneShapeTable[shape], x, y, 2, flag); + + //sub_B521(); + flagAnimObjsForRefresh(); + refreshAnimObjectsIfNeed(); + _screen->showMouse(); + return 0; +} + int KyraEngine_v2::o2_drawSceneShapeOnPage(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "o2_drawSceneShapeOnPage(%p) (%d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); @@ -294,6 +364,45 @@ int KyraEngine_v2::o2_restoreBackBuffer(ScriptState *script) { return 0; } +int KyraEngine_v2::o2_update(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_update(%p) (%d)", (const void *)script, stackPos(0)); + + int times = stackPos(0); + while (times--) { + //if (dword_30BB2) + // sub_159D6(); + //else + update(); + } + + return 0; +} + +int KyraEngine_v2::o2_fadeScenePal(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_fadeScenePal(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + fadeScenePal(stackPos(0), stackPos(1)); + return 0; +} + +int KyraEngine_v2::o2_enterNewSceneEx(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_enterNewSceneEx(%p) (%d, %d, %d, %d, %d)", (const void *)script, stackPos(0), + stackPos(1), stackPos(2), stackPos(3), stackPos(4)); + + enterNewScene(stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); + + if (!stackPos(3)) + runSceneScript4(0); + + _unk5 = 1; + + if (_mainCharX == -1 || _mainCharY == -1) { + _mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing]; + updateCharacterAnim(0); + } + + return 0; +} + int KyraEngine_v2::o2_setLayerFlag(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "o2_setLayerFlag(%p) (%d)", (const void *)script, stackPos(0)); int layer = stackPos(0); @@ -302,6 +411,19 @@ int KyraEngine_v2::o2_setLayerFlag(ScriptState *script) { return 0; } +int KyraEngine_v2::o2_setZanthiaPos(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_setZanthiaPos(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + _mainCharX = stackPos(0); + _mainCharY = stackPos(1); + + if (_mainCharX == -1 && _mainCharY == -1) + _mainCharacter.animFrame = 32; + else + _mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing]; + + return 0; +} + int KyraEngine_v2::o2_getRand(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "o2_getRand(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); assert(stackPos(0) < stackPos(1)); @@ -344,6 +466,15 @@ int KyraEngine_v2::o2_defineRoomEntrance(ScriptState *script) { return 0; } +int KyraEngine_v2::o2_runTemporaryScript(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_runTemporaryScript(%p) ('%s', %d, %d, %d)", (const void *)script, stackPosString(0), stackPos(1), + stackPos(2), stackPos(3)); + + runTemporaryScript(stackPosString(0), stackPos(2) ? 1 : 0, stackPos(1), stackPos(2), stackPos(3)); + + return 0; +} + int KyraEngine_v2::o2_setSpecialSceneScriptRunTime(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "o2_setSpecialSceneScriptRunTime(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); assert(stackPos(0) >= 0 && stackPos(0) < 10); @@ -435,4 +566,35 @@ int KyraEngine_v2::o2_dummy(ScriptState *script) { return 0; } +#pragma mark - + +int KyraEngine_v2::o2t_defineNewShapes(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2t_defineNewShapes(%p) ('%s', %d, %d, %d, %d, %d, %d)", (const void *)script, stackPosString(0), + stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6)); + + strcpy(_newShapeFilename, stackPosString(0)); + _newShapeLastEntry = stackPos(1); + _newShapeWidth = stackPos(2); + _newShapeHeight = stackPos(3); + _newShapeXAdd = stackPos(4); + _newShapeYAdd = stackPos(5); + //word_324EB = stackPos(6); <- never used + + return 0; +} + +int KyraEngine_v2::o2t_setCurrentFrame(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2t_setCurrentFrame(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + _newShapeAnimFrame = stackPos(0); + _newShapeDelay = stackPos(1); + _temporaryScriptExecBit = true; + return 0; +} + +int KyraEngine_v2::o2t_setShapeFlag(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2t_setShapeFlag(%p) (%d)", (const void *)script, stackPos(0)); + _newShapeFlag = stackPos(0); + return 0; +} + } // end of namespace Kyra |