2008-04-14 20:20:51 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
#include "kyra/kyra_mr.h"
|
|
|
|
#include "kyra/resource.h"
|
2008-04-16 20:28:27 +00:00
|
|
|
#include "kyra/wsamovie.h"
|
2008-04-14 20:20:51 +00:00
|
|
|
|
|
|
|
namespace Kyra {
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::restorePage3() {
|
|
|
|
debugC(9, kDebugLevelAnimator, "KyraEngine_MR::restorePage3()");
|
|
|
|
screen()->copyBlockToPage(2, 0, 0, 320, 200, _gamePlayBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void KyraEngine_MR::clearAnimObjects() {
|
|
|
|
debugC(9, kDebugLevelAnimator, "KyraEngine_MR::clearAnimObjects()");
|
2008-04-14 20:20:51 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < 67; ++i)
|
|
|
|
_animObjects[i].enabled = false;
|
|
|
|
|
|
|
|
_animObjects[0].index = 0;
|
|
|
|
_animObjects[0].type = 0;
|
|
|
|
_animObjects[0].enabled = true;
|
2008-05-02 14:46:30 +00:00
|
|
|
_animObjects[0].specialRefresh = 1;
|
2008-04-14 20:20:51 +00:00
|
|
|
_animObjects[0].flags = 0x800;
|
|
|
|
_animObjects[0].width = 57;
|
|
|
|
_animObjects[0].height = 91;
|
|
|
|
_animObjects[0].width2 = 4;
|
|
|
|
_animObjects[0].height2 = 10;
|
|
|
|
|
|
|
|
for (int i = 1; i < 17; ++i) {
|
2008-04-18 21:41:55 +00:00
|
|
|
_animObjects[i].index = i;
|
2008-04-14 20:20:51 +00:00
|
|
|
_animObjects[i].type = 2;
|
|
|
|
_animObjects[i].flags = 0;
|
|
|
|
_animObjects[i].enabled = false;
|
|
|
|
_animObjects[i].needRefresh = 0;
|
2008-05-02 14:46:30 +00:00
|
|
|
_animObjects[i].specialRefresh = 1;
|
2008-04-14 20:20:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 17; i <= 66; ++i) {
|
2008-04-18 21:41:55 +00:00
|
|
|
_animObjects[i].index = i;
|
2008-04-14 20:20:51 +00:00
|
|
|
_animObjects[i].type = 1;
|
2008-05-02 14:46:30 +00:00
|
|
|
_animObjects[i].specialRefresh = 1;
|
2008-04-14 20:20:51 +00:00
|
|
|
_animObjects[i].flags = 0x800;
|
|
|
|
_animObjects[i].width = 24;
|
|
|
|
_animObjects[i].height = 20;
|
|
|
|
_animObjects[i].width2 = 0;
|
|
|
|
_animObjects[i].height2 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::animSetupPaletteEntry(AnimObj *anim) {
|
|
|
|
debugC(9, kDebugLevelAnimator, "KyraEngine_MR::animSetupPaletteEntry(%p)", (const void*)anim);
|
2008-04-16 20:28:27 +00:00
|
|
|
int layer = _screen->getLayer(anim->xPos1, anim->yPos1) - 1;
|
|
|
|
int16 count = 0;
|
|
|
|
for (int i = 0; i < 3; ++i)
|
|
|
|
count += _sceneDatPalette[layer*3+i];
|
|
|
|
count /= 3;
|
|
|
|
count *= -1;
|
|
|
|
count = MAX<int16>(0, MIN<int16>(count, 10));
|
|
|
|
anim->palette = count / 3;
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::drawAnimObjects() {
|
|
|
|
debugC(9, kDebugLevelAnimator, "KyraEngine_MR::drawAnimObjects()");
|
2008-04-16 20:28:27 +00:00
|
|
|
for (AnimObj *curObject = _animList; curObject; curObject = curObject->nextObject) {
|
|
|
|
if (!curObject->enabled)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
int x = curObject->xPos2 - (_screen->getScreenDim(2)->sx << 3);
|
|
|
|
int y = curObject->yPos2 - _screen->getScreenDim(2)->sy;
|
|
|
|
int layer = 7;
|
|
|
|
|
|
|
|
if (curObject->flags & 0x800) {
|
2008-05-02 14:46:30 +00:00
|
|
|
if (!curObject->specialRefresh)
|
2008-04-16 20:28:27 +00:00
|
|
|
layer = 0;
|
|
|
|
else
|
|
|
|
layer = getDrawLayer(curObject->xPos1, curObject->yPos1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (curObject->index)
|
|
|
|
drawSceneAnimObject(curObject, x, y, layer);
|
|
|
|
else
|
|
|
|
drawCharacterAnimObject(curObject, x, y, layer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::drawSceneAnimObject(AnimObj *obj, int x, int y, int layer) {
|
|
|
|
debugC(9, kDebugLevelAnimator, "KyraEngine_MR::drawSceneAnimObject(%p, %d, %d, %d)", (const void*)obj, x, y, layer);
|
2008-04-16 20:28:27 +00:00
|
|
|
if (obj->type == 1) {
|
2008-05-02 14:46:30 +00:00
|
|
|
if (obj->shapeIndex1 == 0xFFFF)
|
2008-04-16 20:28:27 +00:00
|
|
|
return;
|
|
|
|
int scale = getScale(obj->xPos1, obj->yPos1);
|
2008-05-02 14:46:30 +00:00
|
|
|
_screen->drawShape(2, getShapePtr(obj->shapeIndex1), x, y, 2, obj->flags | 0x104, _paletteOverlay, obj->palette, layer, scale, scale);
|
2008-04-16 20:28:27 +00:00
|
|
|
} else {
|
|
|
|
if (obj->shapePtr) {
|
|
|
|
_screen->drawShape(2, obj->shapePtr, x, y, 2, obj->flags, 7);
|
|
|
|
} else {
|
|
|
|
if (obj->shapeIndex3 == 0xFFFF || obj->animNum == 0xFFFF)
|
|
|
|
return;
|
|
|
|
uint16 flags = 0x4000;
|
|
|
|
if (obj->flags & 0x800)
|
|
|
|
flags |= 0x8000;
|
2008-04-16 23:09:07 +00:00
|
|
|
x = obj->xPos2 - _sceneAnimMovie[obj->animNum]->xAdd();
|
|
|
|
y = obj->yPos2 - _sceneAnimMovie[obj->animNum]->yAdd();
|
2008-04-16 20:28:27 +00:00
|
|
|
_sceneAnimMovie[obj->animNum]->setDrawPage(2);
|
|
|
|
_sceneAnimMovie[obj->animNum]->setX(x);
|
|
|
|
_sceneAnimMovie[obj->animNum]->setY(y);
|
|
|
|
_sceneAnimMovie[obj->animNum]->displayFrame(obj->shapeIndex3, flags | layer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::drawCharacterAnimObject(AnimObj *obj, int x, int y, int layer) {
|
|
|
|
debugC(9, kDebugLevelAnimator, "KyraEngine_MR::drawCharacterAnimObject(%p, %d, %d, %d)", (const void*)obj, x, y, layer);
|
2008-04-16 20:28:27 +00:00
|
|
|
if (_drawNoShapeFlag)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (_mainCharacter.animFrame < 9)
|
|
|
|
_mainCharacter.animFrame = 87;
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
if (obj->shapeIndex1 == 0xFFFF || _mainCharacter.animFrame == 87)
|
2008-04-16 20:28:27 +00:00
|
|
|
return;
|
|
|
|
|
2008-04-20 02:11:10 +00:00
|
|
|
_screen->drawShape(2, getShapePtr(421), _mainCharacter.x3, _mainCharacter.y3, 2, obj->flags | 0x304, _paletteOverlay, 3, layer, _charScale, _charScale);
|
2008-04-16 20:28:27 +00:00
|
|
|
uint8 *shape = getShapePtr(_mainCharacter.animFrame);
|
|
|
|
if (shape)
|
2008-04-16 21:17:23 +00:00
|
|
|
_screen->drawShape(2, shape, x, y, 2, obj->flags | 4, layer, _charScale, _charScale);
|
2008-04-16 20:28:27 +00:00
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::refreshAnimObjects(int force) {
|
|
|
|
debugC(9, kDebugLevelAnimator, "KyraEngine_MR::refreshAnimObjects(%d)", force);
|
2008-04-16 20:28:27 +00:00
|
|
|
for (AnimObj *curObject = _animList; curObject; curObject = curObject->nextObject) {
|
|
|
|
if (!curObject->enabled)
|
|
|
|
continue;
|
|
|
|
if (!curObject->needRefresh && !force)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
const int scale = (curObject->index == 0) ? _charScale : 0;
|
|
|
|
|
|
|
|
int x = curObject->xPos2 - curObject->width2;
|
|
|
|
if (scale)
|
|
|
|
x -= (0x100 - scale) >> 4;
|
|
|
|
|
|
|
|
if (x < 0)
|
|
|
|
x = 0;
|
|
|
|
if (x >= 320)
|
|
|
|
x = 319;
|
|
|
|
|
|
|
|
int y = curObject->yPos2 - curObject->height2;
|
|
|
|
if (scale)
|
|
|
|
y -= (0x100 - scale) >> 3;
|
|
|
|
if (y < 0)
|
|
|
|
y = 0;
|
|
|
|
if (y >= 187)
|
|
|
|
y = 186;
|
|
|
|
|
|
|
|
int width = curObject->width + curObject->width2 + 8;
|
|
|
|
int height = curObject->height + curObject->height2*2;
|
|
|
|
if (width + x > 320)
|
|
|
|
width -= width + x - 322;
|
|
|
|
|
|
|
|
const int maxY = _inventoryState ? 143 : 187;
|
|
|
|
if (height + y > maxY)
|
|
|
|
height -= height + y - (maxY + 1);
|
|
|
|
|
|
|
|
if (height > 0) {
|
|
|
|
_screen->hideMouse();
|
|
|
|
_screen->copyRegion(x, y, x, y, width, height, 2, 0, Screen::CR_NO_P_CHECK);
|
|
|
|
_screen->showMouse();
|
|
|
|
}
|
|
|
|
|
|
|
|
curObject->needRefresh = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-10 14:12:48 +00:00
|
|
|
void KyraEngine_MR::updateItemAnimations() {
|
2008-05-10 17:41:34 +00:00
|
|
|
debugC(9, kDebugLevelAnimator, "KyraEngine_MR::updateItemAnimations()");
|
2008-05-10 14:12:48 +00:00
|
|
|
bool nextFrame = false;
|
|
|
|
|
|
|
|
if (_itemAnimData[0].itemIndex == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const ItemAnimData_v2 *s = &_itemAnimData[_nextAnimItem];
|
|
|
|
ActiveItemAnim *a = &_activeItemAnim[_nextAnimItem];
|
|
|
|
|
|
|
|
if (++_nextAnimItem == 10) {
|
|
|
|
_nextAnimItem = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 ctime = _system->getMillis();
|
|
|
|
if (ctime < a->nextFrame)
|
|
|
|
return;
|
|
|
|
|
|
|
|
uint16 shpIdx = s->frames[a->currentFrame].index + 248;
|
2008-05-10 17:41:34 +00:00
|
|
|
if (s->itemIndex == _handItemSet && s->itemIndex == _itemInHand && _screen->isMouseVisible()) {
|
2008-05-10 14:12:48 +00:00
|
|
|
nextFrame = true;
|
|
|
|
_screen->setMouseCursor(12, 19, getShapePtr(shpIdx));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_inventoryState) {
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
if (s->itemIndex == _mainCharacter.inventory[i]) {
|
|
|
|
nextFrame = true;
|
|
|
|
_screen->drawShape(2, getShapePtr(422 + i), 9, 0, 0, 0);
|
|
|
|
_screen->drawShape(2, getShapePtr(shpIdx), 9, 0, 0, 0);
|
|
|
|
_screen->hideMouse();
|
|
|
|
_screen->copyRegion(9, 0, _inventoryX[i], _inventoryY[i], 24, 20, 2, 0, Screen::CR_NO_P_CHECK);
|
|
|
|
_screen->showMouse();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_screen->updateScreen();
|
|
|
|
|
|
|
|
for (int i = 17; i < 66; i++) {
|
|
|
|
AnimObj *animObject = &_animObjects[i];
|
|
|
|
if (animObject->shapeIndex2 == s->itemIndex + 248) {
|
|
|
|
animObject->shapePtr = getShapePtr(shpIdx);
|
|
|
|
animObject->shapeIndex1 = shpIdx;
|
2008-05-10 17:41:34 +00:00
|
|
|
animObject->needRefresh = true;
|
2008-05-10 14:12:48 +00:00
|
|
|
nextFrame = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nextFrame) {
|
|
|
|
a->nextFrame = _system->getMillis() + (s->frames[a->currentFrame].delay * _tickLength);
|
|
|
|
a->currentFrame = ++a->currentFrame % s->numFrames;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::updateCharacterAnim(int charId) {
|
|
|
|
debugC(9, kDebugLevelAnimator, "KyraEngine_MR::updateCharacterAnim(%d)", charId);
|
2008-04-16 20:28:27 +00:00
|
|
|
|
|
|
|
AnimObj *obj = &_animObjects[0];
|
|
|
|
obj->needRefresh = true;
|
|
|
|
obj->flags &= ~1;
|
|
|
|
obj->xPos1 = _mainCharacter.x1;
|
|
|
|
obj->yPos1 = _mainCharacter.y1;
|
|
|
|
obj->shapePtr = getShapePtr(_mainCharacter.animFrame);
|
2008-05-02 14:46:30 +00:00
|
|
|
obj->shapeIndex1 = obj->shapeIndex2 = _mainCharacter.animFrame;
|
2008-04-16 20:28:27 +00:00
|
|
|
|
|
|
|
int shapeOffsetX = 0, shapeOffsetY = 0;
|
2008-04-20 02:11:10 +00:00
|
|
|
if (_mainCharacter.animFrame >= 50 && _mainCharacter.animFrame <= 87) {
|
2008-04-16 20:28:27 +00:00
|
|
|
shapeOffsetX = _malcolmShapeXOffset;
|
|
|
|
shapeOffsetY = _malcolmShapeYOffset;
|
2008-04-20 02:11:10 +00:00
|
|
|
} else {
|
2008-05-03 19:23:45 +00:00
|
|
|
shapeOffsetX = _animShapeXAdd;
|
|
|
|
shapeOffsetY = _animShapeYAdd;
|
2008-04-20 02:11:10 +00:00
|
|
|
}
|
2008-04-16 20:28:27 +00:00
|
|
|
|
|
|
|
obj->xPos2 = _mainCharacter.x1;
|
|
|
|
obj->yPos2 = _mainCharacter.y1;
|
|
|
|
_charScale = getScale(_mainCharacter.x1, _mainCharacter.y1);
|
|
|
|
obj->xPos2 += (shapeOffsetX * _charScale) >> 8;
|
|
|
|
obj->yPos2 += (shapeOffsetY * _charScale) >> 8;
|
|
|
|
_mainCharacter.x3 = _mainCharacter.x1 - (_charScale >> 4) - 1;
|
|
|
|
_mainCharacter.y3 = _mainCharacter.y1 - (_charScale >> 6) - 1;
|
2008-04-20 02:11:10 +00:00
|
|
|
if (_charBackUpWidth2 == -1) {
|
2008-04-16 20:28:27 +00:00
|
|
|
obj->width2 = 4;
|
|
|
|
obj->height2 = 10;
|
2008-04-20 02:11:10 +00:00
|
|
|
}
|
2008-04-16 20:28:27 +00:00
|
|
|
|
|
|
|
for (int i = 1; i <= 16; ++i) {
|
2008-05-02 14:46:30 +00:00
|
|
|
if (_animObjects[i].enabled && _animObjects[i].specialRefresh)
|
2008-04-16 20:28:27 +00:00
|
|
|
_animObjects[i].needRefresh = true;
|
|
|
|
}
|
|
|
|
|
2008-04-16 21:13:52 +00:00
|
|
|
_animList = deleteAnimListEntry(_animList, obj);
|
2008-04-16 20:28:27 +00:00
|
|
|
if (_animList)
|
|
|
|
_animList = addToAnimListSorted(_animList, obj);
|
|
|
|
else
|
|
|
|
_animList = initAnimList(_animList, obj);
|
|
|
|
|
|
|
|
if (!_loadingState)
|
|
|
|
updateCharPal(1);
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::updateSceneAnim(int anim, int newFrame) {
|
|
|
|
debugC(9, kDebugLevelAnimator, "KyraEngine_MR::updateSceneAnim(%d, %d)", anim, newFrame);
|
2008-04-16 23:09:07 +00:00
|
|
|
AnimObj *animObject = &_animObjects[1+anim];
|
|
|
|
if (!animObject->enabled)
|
|
|
|
return;
|
|
|
|
|
2008-04-17 13:38:44 +00:00
|
|
|
animObject->needRefresh = true;
|
2008-04-16 23:09:07 +00:00
|
|
|
|
|
|
|
if (_sceneAnims[anim].flags & 2)
|
|
|
|
animObject->flags |= 1;
|
|
|
|
else
|
|
|
|
animObject->flags &= ~1;
|
|
|
|
|
|
|
|
if (_sceneAnims[anim].flags & 4) {
|
|
|
|
animObject->shapePtr = _sceneShapes[newFrame];
|
|
|
|
animObject->shapeIndex2 = 0xFFFF;
|
|
|
|
animObject->shapeIndex3 = 0xFFFF;
|
|
|
|
animObject->animNum = 0xFFFF;
|
|
|
|
} else {
|
|
|
|
animObject->shapePtr = 0;
|
|
|
|
animObject->shapeIndex3 = newFrame;
|
|
|
|
animObject->animNum = anim;
|
|
|
|
}
|
|
|
|
|
|
|
|
animObject->xPos1 = _sceneAnims[anim].x;
|
|
|
|
animObject->yPos1 = _sceneAnims[anim].y;
|
|
|
|
animObject->xPos2 = _sceneAnims[anim].x2;
|
|
|
|
animObject->yPos2 = _sceneAnims[anim].y2;
|
|
|
|
|
|
|
|
if (_sceneAnims[anim].flags & 0x20) {
|
|
|
|
_animList = deleteAnimListEntry(_animList, animObject);
|
|
|
|
if (!_animList)
|
|
|
|
_animList = initAnimList(_animList, animObject);
|
|
|
|
else
|
|
|
|
_animList = addToAnimListSorted(_animList, animObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::setupSceneAnimObject(int animId, uint16 flags, int x, int y, int x2, int y2, int w,
|
2008-04-20 00:11:42 +00:00
|
|
|
int h, int unk10, int specialSize, int unk14, int shape, const char *filename) {
|
2008-05-02 14:46:30 +00:00
|
|
|
debugC(9, kDebugLevelAnimator, "KyraEngine_MR::setupSceneAnimObject(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, '%s')",
|
2008-04-20 00:30:39 +00:00
|
|
|
animId, flags, x, y, x2, y2, w, h, unk10, specialSize, unk14, shape, filename);
|
2008-04-20 00:11:42 +00:00
|
|
|
restorePage3();
|
|
|
|
SceneAnim &anim = _sceneAnims[animId];
|
|
|
|
anim.flags = flags;
|
|
|
|
anim.x = x;
|
|
|
|
anim.y = y;
|
|
|
|
anim.x2 = x2;
|
|
|
|
anim.y2 = y2;
|
|
|
|
anim.width = w;
|
|
|
|
anim.height = h;
|
|
|
|
anim.specialSize = specialSize;
|
|
|
|
anim.shapeIndex = shape;
|
|
|
|
if (filename)
|
|
|
|
strcpy(anim.filename, filename);
|
|
|
|
|
|
|
|
if (flags & 8) {
|
|
|
|
_sceneAnimMovie[animId]->open(filename, 1, 0);
|
|
|
|
musicUpdate(0);
|
|
|
|
if (_sceneAnimMovie[animId]->opened()) {
|
|
|
|
anim.wsaFlag = 1;
|
|
|
|
if (x2 == -1)
|
|
|
|
x2 = _sceneAnimMovie[animId]->xAdd();
|
|
|
|
if (y2 == -1)
|
|
|
|
y2 = _sceneAnimMovie[animId]->yAdd();
|
|
|
|
if (w == -1)
|
|
|
|
w = _sceneAnimMovie[animId]->width();
|
|
|
|
if (h == -1)
|
|
|
|
h = _sceneAnimMovie[animId]->height();
|
|
|
|
if (x == -1)
|
|
|
|
x = (w >> 1) + x2;
|
|
|
|
if (y == -1)
|
|
|
|
y = y2 + h - 1;
|
|
|
|
|
|
|
|
anim.x = x;
|
|
|
|
anim.y = y;
|
|
|
|
anim.x2 = x2;
|
|
|
|
anim.y2 = y2;
|
|
|
|
anim.width = w;
|
|
|
|
anim.height = h;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimObj *obj = &_animObjects[1+animId];
|
|
|
|
obj->enabled = true;
|
|
|
|
obj->needRefresh = true;
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
obj->specialRefresh = (anim.flags & 0x20) ? 1 : 0;
|
2008-04-20 00:11:42 +00:00
|
|
|
obj->flags = (anim.flags & 0x10) ? 0x800 : 0;
|
|
|
|
if (anim.flags & 2)
|
|
|
|
obj->flags |= 1;
|
|
|
|
|
|
|
|
obj->xPos1 = anim.x;
|
|
|
|
obj->yPos1 = anim.y;
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
if ((anim.flags & 4) && anim.shapeIndex != -1)
|
2008-04-20 00:11:42 +00:00
|
|
|
obj->shapePtr = _sceneShapes[anim.shapeIndex];
|
|
|
|
else
|
|
|
|
obj->shapePtr = 0;
|
|
|
|
|
|
|
|
if (anim.flags & 8) {
|
|
|
|
obj->shapeIndex3 = anim.shapeIndex;
|
|
|
|
obj->animNum = animId;
|
|
|
|
} else {
|
|
|
|
obj->shapeIndex3 = 0xFFFF;
|
|
|
|
obj->animNum = 0xFFFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
obj->xPos3 = obj->xPos2 = anim.x2;
|
|
|
|
obj->yPos3 = obj->yPos2 = anim.y2;
|
|
|
|
obj->width = anim.width;
|
|
|
|
obj->height = anim.height;
|
|
|
|
obj->width2 = obj->height2 = anim.specialSize;
|
|
|
|
|
|
|
|
if (_animList)
|
|
|
|
_animList = addToAnimListSorted(_animList, obj);
|
|
|
|
else
|
|
|
|
_animList = initAnimList(_animList, obj);
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::removeSceneAnimObject(int anim, int refresh) {
|
|
|
|
debugC(9, kDebugLevelAnimator, "KyraEngine_MR::removeSceneAnimObject(%d, %d)", anim, refresh);
|
2008-04-17 13:38:44 +00:00
|
|
|
AnimObj *obj = &_animObjects[anim+1];
|
|
|
|
restorePage3();
|
|
|
|
obj->shapeIndex3 = 0xFFFF;
|
|
|
|
obj->animNum = 0xFFFF;
|
|
|
|
obj->needRefresh = true;
|
|
|
|
|
|
|
|
if (refresh)
|
|
|
|
refreshAnimObjectsIfNeed();
|
|
|
|
|
|
|
|
obj->enabled = false;
|
|
|
|
_animList = deleteAnimListEntry(_animList, obj);
|
|
|
|
_sceneAnimMovie[anim]->close();
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::setCharacterAnimDim(int w, int h) {
|
|
|
|
debugC(9, kDebugLevelAnimator, "KyraEngine_MR::setCharacterAnimDim(%d, %d)", w, h);
|
2008-04-19 22:22:00 +00:00
|
|
|
restorePage3();
|
|
|
|
_charBackUpWidth = _animObjects[0].width;
|
|
|
|
_charBackUpWidth2 = _animObjects[0].width2;
|
|
|
|
_charBackUpHeight = _animObjects[0].height;
|
|
|
|
_charBackUpHeight2 = _animObjects[0].height2;
|
|
|
|
|
|
|
|
_animObjects[0].width2 = (w - _charBackUpWidth) / 2;
|
|
|
|
_animObjects[0].height2 = h - _charBackUpHeight;
|
|
|
|
_animObjects[0].width = w;
|
|
|
|
_animObjects[0].height = h;
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::resetCharacterAnimDim() {
|
|
|
|
debugC(9, kDebugLevelAnimator, "KyraEngine_MR::resetCharacterAnimDim()");
|
2008-04-19 22:22:00 +00:00
|
|
|
restorePage3();
|
|
|
|
_animObjects[0].width2 = _charBackUpWidth2;
|
|
|
|
_animObjects[0].height2 = _charBackUpHeight2;
|
|
|
|
_animObjects[0].width = _charBackUpWidth;
|
|
|
|
_animObjects[0].height = _charBackUpHeight;
|
|
|
|
_charBackUpWidth2 = _charBackUpHeight2 = -1;
|
|
|
|
_charBackUpWidth = _charBackUpHeight = -1;
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::showIdleAnim() {
|
|
|
|
debugC(9, kDebugLevelMain | kDebugLevelAnimator, "KyraEngine_MR::showIdleAnim()");
|
2008-04-23 19:24:02 +00:00
|
|
|
|
|
|
|
if (_mainCharacter.sceneId == 20 || _mainCharacter.sceneId == 21
|
|
|
|
|| _mainCharacter.sceneId == 12 || _mainCharacter.sceneId == 11)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (_mainCharacter.animFrame == 87)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!_nextIdleType && !talkObjectsInCurScene()) {
|
2008-05-04 13:07:13 +00:00
|
|
|
randomSceneChat();
|
2008-04-23 19:24:02 +00:00
|
|
|
} else {
|
|
|
|
static const char *facingTable[] = {
|
|
|
|
"A", "R", "R", "FR", "FX", "FL", "L", "L"
|
|
|
|
};
|
|
|
|
|
|
|
|
char filename[14];
|
2008-05-02 15:21:51 +00:00
|
|
|
snprintf(filename, 14, "MI0%s%.02d.EMC", facingTable[_mainCharacter.facing], _characterShapeFile);
|
2008-04-23 19:24:02 +00:00
|
|
|
|
|
|
|
if (_res->exists(filename))
|
2008-05-03 19:23:45 +00:00
|
|
|
runAnimationScript(filename, 1, 1, 1, 1);
|
2008-04-23 19:24:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_nextIdleType = !_nextIdleType;
|
|
|
|
}
|
|
|
|
|
2008-04-14 20:20:51 +00:00
|
|
|
} // end of namespace Kyra
|
2008-04-19 22:22:00 +00:00
|
|
|
|