From 31ea2154478ed4cb0344711861f835c848e97dde Mon Sep 17 00:00:00 2001 From: lukaslw Date: Sat, 21 Jun 2014 20:23:17 +0200 Subject: PRINCE: Hero animations fix - frame height calculation --- engines/prince/animation.cpp | 21 +++++++++++++++++++++ engines/prince/animation.h | 3 +++ engines/prince/hero.cpp | 21 +++++++++++++++++---- 3 files changed, 41 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/prince/animation.cpp b/engines/prince/animation.cpp index a4df4e30cc..adf96b5f00 100644 --- a/engines/prince/animation.cpp +++ b/engines/prince/animation.cpp @@ -57,6 +57,27 @@ void Animation::clear() { } } +// AH_ID +bool Animation::testId() const { + char id[2]; + id[0] = (char)READ_LE_UINT16(_data); + id[1] = (char)READ_LE_UINT16(_data + 1); + if (id[0] == 'A' && id[1] == 'N') { + return true; // normal animation + } + return false; +} + +// AH_ID - x diff +int8 Animation::getIdXDiff() const { + return (int8)READ_LE_UINT16(_data); +} + +// AH_ID - y diff +int8 Animation::getIdYDiff() const { + return (int8)READ_LE_UINT16(_data + 1); +} + // AH_Loop int16 Animation::getLoopCount() const { return READ_LE_UINT16(_data + 2); diff --git a/engines/prince/animation.h b/engines/prince/animation.h index acf689e05f..09ebf7d8b9 100644 --- a/engines/prince/animation.h +++ b/engines/prince/animation.h @@ -37,6 +37,9 @@ public: Animation(); Animation(byte *data, uint32 dataSize); ~Animation(); + bool testId() const; + int8 getIdXDiff() const; + int8 getIdYDiff() const; int16 getLoopCount() const; int16 getBaseX() const; int16 getBaseY() const; diff --git a/engines/prince/hero.cpp b/engines/prince/hero.cpp index eadfd899b6..44bd07f12a 100644 --- a/engines/prince/hero.cpp +++ b/engines/prince/hero.cpp @@ -196,11 +196,20 @@ void Hero::countDrawPosition() { } else { tempMiddleY = _middleY; } - _frameXSize = _moveSet[_moveSetType]->getFrameWidth(_phase); - _frameYSize = _moveSet[_moveSetType]->getFrameHeight(_phase); + int phaseFrameIndex = _moveSet[_moveSetType]->getPhaseFrameIndex(_phase); + _frameXSize = _moveSet[_moveSetType]->getFrameWidth(phaseFrameIndex); + _frameYSize = _moveSet[_moveSetType]->getFrameHeight(phaseFrameIndex); _scaledFrameXSize = getScaledValue(_frameXSize); _scaledFrameYSize = getScaledValue(_frameYSize); + // any use of this? + /* + if (!_moveSet[_moveSetType]->testId()) { + int diffX = _moveSet[_moveSetType]->getIdXDiff(); + int diffY = _moveSet[_moveSetType]->getIdYDiff(); + } + */ + if (_zoomFactor != 0) { //notfullSize _drawX = _middleX - _scaledFrameXSize / 2; @@ -525,10 +534,14 @@ void Hero::showHeroShadow(Graphics::Surface *heroFrame) { } void Hero::showHeroAnimFrame() { - if (_phase < _moveSet[_moveSetType]->getFrameCount() - 1) { + if (_phase < _moveSet[_moveSetType]->getPhaseCount() - 1) { _phase++; } else { - _phase = 0; + if (_state == TALK) { + _phase = _moveSet[_moveSetType]->getLoopCount(); + } else { + _phase = 0; + } } countDrawPosition(); } -- cgit v1.2.3