예제 #1
0
void KyraEngine_HoF::updateCharacterAnim(int) {
	Character *c = &_mainCharacter;
	AnimObj *animState = _animObjects;

	animState->needRefresh = 1;
	animState->specialRefresh = 1;

	if (c->facing >= 1 && c->facing <= 3)
		animState->flags |= 1;
	else if (c->facing >= 5 && c->facing <= 7)
		animState->flags &= ~1;

	animState->xPos2 = animState->xPos1 = c->x1;
	animState->yPos2 = animState->yPos1 = c->y1;
	animState->shapePtr = getShapePtr(c->animFrame);
	animState->shapeIndex1 = animState->shapeIndex2 = c->animFrame;

	int xAdd = _shapeDescTable[c->animFrame-9].xAdd;
	int yAdd = _shapeDescTable[c->animFrame-9].yAdd;

	_charScale = getScale(c->x1, c->y1);

	animState->xPos2 += (xAdd * _charScale) >> 8;
	animState->yPos2 += (yAdd * _charScale) >> 8;
	animState->width2 = 8;
	animState->height2 = 10;

	_animList = deleteAnimListEntry(_animList, animState);
	if (_animList)
		_animList = addToAnimListSorted(_animList, animState);
	else
		_animList = initAnimList(_animList, animState);

	updateCharPal(1);
}
예제 #2
0
void KyraEngine_MR::updateCharacterAnim(int charId) {
	AnimObj *obj = &_animObjects[0];
	obj->needRefresh = true;
	obj->flags &= ~1;
	obj->xPos1 = _mainCharacter.x1;
	obj->yPos1 = _mainCharacter.y1;
	obj->shapePtr = getShapePtr(_mainCharacter.animFrame);
	obj->shapeIndex1 = obj->shapeIndex2 = _mainCharacter.animFrame;

	int shapeOffsetX = 0, shapeOffsetY = 0;
	if (_mainCharacter.animFrame >= 50 && _mainCharacter.animFrame <= 87) {
		shapeOffsetX = _malcolmShapeXOffset;
		shapeOffsetY = _malcolmShapeYOffset;
	} else {
		shapeOffsetX = _animShapeXAdd;
		shapeOffsetY = _animShapeYAdd;
	}

	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;
	if (_charBackUpWidth2 == -1) {
		obj->width2 = 4;
		obj->height2 = 10;
	}

	for (int i = 1; i <= 16; ++i) {
		if (_animObjects[i].enabled && _animObjects[i].specialRefresh)
			_animObjects[i].needRefresh = true;
	}

	_animList = deleteAnimListEntry(_animList, obj);
	if (_animList)
		_animList = addToAnimListSorted(_animList, obj);
	else
		_animList = initAnimList(_animList, obj);

	if (!_loadingState)
		updateCharPal(1);
}
예제 #3
0
void KyraEngine_HoF::updateSceneAnim(int anim, int newFrame) {
	AnimObj *animObject = &_animObjects[1+anim];
	if (!animObject->enabled)
		return;

	animObject->needRefresh = 1;
	animObject->specialRefresh = 1;
	animObject->flags = 0;

	if (_sceneAnims[anim].flags & 2)
		animObject->flags |= 0x800;
	else
		animObject->flags &= ~0x800;

	if (_sceneAnims[anim].flags & 4)
		animObject->flags |= 1;
	else
		animObject->flags &= ~1;

	if (_sceneAnims[anim].flags & 0x20) {
		animObject->shapePtr = _sceneShapeTable[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 & 2) {
		_animList = deleteAnimListEntry(_animList, animObject);
		if (!_animList)
			_animList = initAnimList(_animList, animObject);
		else
			_animList = addToAnimListSorted(_animList, animObject);
	}
}
예제 #4
0
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 {
예제 #5
0
void KyraEngine_HoF::initSceneAnims(int unk1) {
	for (int i = 0; i < 41; ++i)
		_animObjects[i].enabled = 0;

	bool animInit = false;

	AnimObj *animState = &_animObjects[0];

	if (_mainCharacter.animFrame != 32)
		_mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing];

	animState->enabled = 1;
	animState->xPos1 = _mainCharacter.x1;
	animState->yPos1 = _mainCharacter.y1;
	animState->shapePtr = getShapePtr(_mainCharacter.animFrame);
	animState->shapeIndex1 = animState->shapeIndex2 = _mainCharacter.animFrame;

	int frame = _mainCharacter.animFrame - 9;
	int shapeX = _shapeDescTable[frame].xAdd;
	int shapeY = _shapeDescTable[frame].yAdd;

	animState->xPos2 = _mainCharacter.x1;
	animState->yPos2 = _mainCharacter.y1;

	_charScale = getScale(_mainCharacter.x1, _mainCharacter.y1);

	int shapeXScaled = (shapeX * _charScale) >> 8;
	int shapeYScaled = (shapeY * _charScale) >> 8;

	animState->xPos2 += shapeXScaled;
	animState->yPos2 += shapeYScaled;
	animState->xPos3 = animState->xPos2;
	animState->yPos3 = animState->yPos2;
	animState->needRefresh = 1;
	animState->specialRefresh = 1;

	_animList = 0;

	AnimObj *charAnimState = animState;

	for (int i = 0; i < 10; ++i) {
		animState = &_animObjects[i+1];
		animState->enabled = 0;
		animState->needRefresh = 0;
		animState->specialRefresh = 0;

		if (_sceneAnims[i].flags & 1) {
			animState->enabled = 1;
			animState->needRefresh = 1;
			animState->specialRefresh = 1;
		}

		animState->animFlags = _sceneAnims[i].flags & 8;

		if (_sceneAnims[i].flags & 2)
			animState->flags = 0x800;
		else
			animState->flags = 0;

		if (_sceneAnims[i].flags & 4)
			animState->flags |= 1;

		animState->xPos1 = _sceneAnims[i].x;
		animState->yPos1 = _sceneAnims[i].y;

		if (_sceneAnims[i].flags & 0x20)
			animState->shapePtr = _sceneShapeTable[_sceneAnims[i].shapeIndex];
		else
			animState->shapePtr = 0;

		if (_sceneAnims[i].flags & 0x40) {
			animState->shapeIndex3 = _sceneAnims[i].shapeIndex;
			animState->animNum = i;
		} else {
			animState->shapeIndex3 = 0xFFFF;
			animState->animNum = 0xFFFF;
		}

		animState->shapeIndex2 = 0xFFFF;

		animState->xPos3 = animState->xPos2 = _sceneAnims[i].x2;
		animState->yPos3 = animState->yPos2 = _sceneAnims[i].y2;
		animState->width = _sceneAnims[i].width;
		animState->height = _sceneAnims[i].height;
		animState->width2 = animState->height2 = _sceneAnims[i].specialSize;

		if (_sceneAnims[i].flags & 1) {
			if (animInit) {
				_animList = addToAnimListSorted(_animList, animState);
			} else {
				_animList = initAnimList(_animList, animState);
				animInit = true;
			}
		}
	}

	if (animInit) {
		_animList = addToAnimListSorted(_animList, charAnimState);
	} else {
		_animList = initAnimList(_animList, charAnimState);
		animInit = true;
	}

	for (int i = 0; i < 30; ++i) {
		animState = &_animObjects[i+11];

		uint16 shapeIndex = _itemList[i].id;
		if (shapeIndex == 0xFFFF || _itemList[i].sceneId != _mainCharacter.sceneId) {
			animState->enabled = 0;
			animState->needRefresh = 0;
			animState->specialRefresh = 0;
		} else {
			animState->xPos1 = _itemList[i].x;
			animState->yPos1 = _itemList[i].y;
			animState->shapePtr = getShapePtr(64+shapeIndex);
			animState->shapeIndex1 = animState->shapeIndex2 = shapeIndex+64;

			animState->xPos2 = _itemList[i].x;
			animState->yPos2 = _itemList[i].y;
			int objectScale = getScale(animState->xPos2, animState->yPos2);

			const uint8 *shape = getShapePtr(animState->shapeIndex1);
			animState->xPos2 -= (_screen->getShapeScaledWidth(shape, objectScale) >> 1);
			animState->yPos2 -= (_screen->getShapeScaledHeight(shape, objectScale) >> 1);
			animState->xPos3 = animState->xPos2;
			animState->yPos3 = animState->yPos2;

			animState->enabled = 1;
			animState->needRefresh = 1;
			animState->specialRefresh = 1;

			if (animInit) {
				_animList = addToAnimListSorted(_animList, animState);
			} else {
				_animList = initAnimList(_animList, animState);
				animInit = true;
			}
		}
	}

	_animObjects[0].specialRefresh = 1;
	_animObjects[0].needRefresh = 1;

	for (int i = 1; i < 41; ++i) {
		if (_animObjects[i].enabled) {
			_animObjects[i].needRefresh = 1;
			_animObjects[i].specialRefresh = 1;
		}
	}

	restorePage3();
	drawAnimObjects();
	_screen->hideMouse();
	initSceneScreen(unk1);
	_screen->showMouse();
	refreshAnimObjects(0);
}