void KyraEngine_v2::addItemToAnimList(int item) { assert(item >= 0 && item < _itemListSize); restorePage3(); AnimObj *animObj = _animItems + item; animObj->enabled = 1; animObj->needRefresh = 1; int itemId = _itemList[item].id; animObj->xPos2 = animObj->xPos1 = _itemList[item].x; animObj->yPos2 = animObj->yPos1 = _itemList[item].y; animObj->shapePtr = getShapePtr(itemId + _desc.itemShapeStart); animSetupPaletteEntry(animObj); animObj->shapeIndex2 = animObj->shapeIndex1 = itemId + _desc.itemShapeStart; int scaleY, scaleX; scaleY = scaleX = getScale(animObj->xPos1, animObj->yPos1); uint8 *shapePtr = getShapePtr(itemId + _desc.itemShapeStart); animObj->xPos3 = (animObj->xPos2 -= (screen_v2()->getShapeScaledWidth(shapePtr, scaleX) >> 1)); animObj->yPos3 = (animObj->yPos2 -= screen_v2()->getShapeScaledHeight(shapePtr, scaleY)); animObj->width2 = animObj->height2 = 0; _animList = addToAnimListSorted(_animList, animObj); animObj->needRefresh = 1; }
void KyraEngine_MR::initSceneAnims(int unk1) { for (int i = 0; i < 67; ++i) _animObjects[i].enabled = false; AnimObj *obj = &_animObjects[0]; if (_mainCharacter.animFrame != 87 && !unk1) _mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing]; obj->enabled = true; obj->xPos1 = _mainCharacter.x1; obj->yPos1 = _mainCharacter.y1; obj->shapePtr = getShapePtr(_mainCharacter.animFrame); obj->shapeIndex2 = obj->shapeIndex1 = _mainCharacter.animFrame; obj->xPos2 = _mainCharacter.x1; obj->yPos2 = _mainCharacter.y1; _charScale = getScale(_mainCharacter.x1, _mainCharacter.y1); obj->xPos3 = obj->xPos2 += (_malcolmShapeXOffset * _charScale) >> 8; obj->yPos3 = obj->yPos2 += (_malcolmShapeYOffset * _charScale) >> 8; _mainCharacter.x3 = _mainCharacter.x1 - (_charScale >> 4) - 1; _mainCharacter.y3 = _mainCharacter.y1 - (_charScale >> 6) - 1; obj->needRefresh = true; _animList = 0; for (int i = 0; i < 16; ++i) { const SceneAnim &anim = _sceneAnims[i]; obj = &_animObjects[i+1]; obj->enabled = false; obj->needRefresh = false; if (anim.flags & 1) { obj->enabled = true; obj->needRefresh = true; } obj->specialRefresh = (anim.flags & 0x20) ? 1 : 0; obj->flags = (anim.flags & 0x10) ? 0x800 : 0; if (anim.flags & 2) obj->flags |= 1; obj->xPos1 = anim.x; obj->yPos1 = anim.y; if ((anim.flags & 4) && anim.shapeIndex != -1) obj->shapePtr = _sceneShapes[anim.shapeIndex]; else obj->shapePtr = 0; if (anim.flags & 8) { obj->shapeIndex3 = anim.shapeIndex; obj->animNum = i; } 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 (anim.flags & 1) { if (_animList) _animList = addToAnimListSorted(_animList, obj); else _animList = initAnimList(_animList, obj); } } if (_animList) _animList = addToAnimListSorted(_animList, &_animObjects[0]); else _animList = initAnimList(_animList, &_animObjects[0]); for (int i = 0; i < 50; ++i) { obj = &_animObjects[i+17]; const ItemDefinition &item = _itemList[i]; if (item.id != kItemNone && item.sceneId == _mainCharacter.sceneId) { obj->xPos1 = item.x; obj->yPos1 = item.y; animSetupPaletteEntry(obj); obj->shapePtr = 0; obj->shapeIndex1 = obj->shapeIndex2 = item.id + 248; obj->xPos2 = item.x; obj->yPos2 = item.y; int scale = getScale(obj->xPos1, obj->yPos1); const uint8 *shape = getShapePtr(obj->shapeIndex1); obj->xPos3 = obj->xPos2 -= (_screen->getShapeScaledWidth(shape, scale) >> 1); obj->yPos3 = obj->yPos2 -= _screen->getShapeScaledHeight(shape, scale) - 1; obj->enabled = true; obj->needRefresh = true; if (_animList) _animList = addToAnimListSorted(_animList, obj); else _animList = initAnimList(_animList, obj); } else {