diff options
author | Paul Gilbert | 2015-01-11 19:30:02 -0500 |
---|---|---|
committer | Paul Gilbert | 2015-01-11 19:30:02 -0500 |
commit | 1b3473d3431ae8fcac15526f1a59f1dfd0c9fc58 (patch) | |
tree | 7b6d65f429186b8a10edbf1faa4cb043166347c3 | |
parent | 892a504009e0d7d6d6304d485bf2fad9519781e9 (diff) | |
download | scummvm-rg350-1b3473d3431ae8fcac15526f1a59f1dfd0c9fc58.tar.gz scummvm-rg350-1b3473d3431ae8fcac15526f1a59f1dfd0c9fc58.tar.bz2 scummvm-rg350-1b3473d3431ae8fcac15526f1a59f1dfd0c9fc58.zip |
XEEN: Implement frame update loop of draw3d
-rw-r--r-- | engines/xeen/interface.cpp | 26 | ||||
-rw-r--r-- | engines/xeen/interface.h | 3 | ||||
-rw-r--r-- | engines/xeen/map.cpp | 19 | ||||
-rw-r--r-- | engines/xeen/map.h | 29 | ||||
-rw-r--r-- | engines/xeen/resources.cpp | 4 | ||||
-rw-r--r-- | engines/xeen/resources.h | 2 |
6 files changed, 51 insertions, 32 deletions
diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp index 665ce6728d..9e02806750 100644 --- a/engines/xeen/interface.cpp +++ b/engines/xeen/interface.cpp @@ -361,7 +361,8 @@ Interface::Interface(XeenEngine *vm) : ButtonContainer(), _vm(vm) { _intrIndex1 = 0; _flipWtr = false; _flag1 = false; - _flag2 = false; + _animCounter = 0; + _isAnimReset = false; _tillMove = 0; _objNumber = 0; @@ -868,15 +869,30 @@ void Interface::draw3d(bool flag) { moveMonsters(); } - int e3 = 0xE302 + _objNumber * 8; - Direction dir = _vm->_party._mazeDirection; - bool flag2 = _flag2; + MazeObject &objObject = _vm->_map->_mobData._objects[_objNumber]; + Direction partyDirection = _vm->_party._mazeDirection; int objNum = _objNumber - 1; for (uint i = 0; i < _vm->_map->_mobData._objects.size(); ++i) { - if (flag2) { + MazeObject &mazeObject = _vm->_map->_mobData._objects[i]; + AnimationEntry &animEntry = _vm->_map->_animationInfo[mazeObject._spriteId]; + int directionIndex = DIRECTION_ANIM_POSITIONS[mazeObject._direction][partyDirection]; + if (_isAnimReset) { + mazeObject._frame = animEntry._frame1._frames[directionIndex]; + } else { + ++mazeObject._frame; + if (i == objNum && _animCounter > 0 && ( + objObject._spriteId == (_vm->_files->_isDarkCc ? 15 : 16) || + objObject._spriteId == 58 || objObject._spriteId == 73)) { + if (mazeObject._frame > 4 || mazeObject._spriteId == 58) + mazeObject._frame = 1; + } else if (mazeObject._frame == animEntry._frame2._frames[directionIndex]) { + mazeObject._frame = animEntry._frame2._frames[directionIndex]; + } } + + mazeObject._flipped = animEntry._flipped._flags[directionIndex]; } // TODO: more diff --git a/engines/xeen/interface.h b/engines/xeen/interface.h index 404beca2f1..d161169d68 100644 --- a/engines/xeen/interface.h +++ b/engines/xeen/interface.h @@ -96,7 +96,8 @@ private: int _intrIndex1; bool _flipWtr; bool _flag1; - bool _flag2; + int _animCounter; + bool _isAnimReset; byte _tillMove; int _objNumber; byte _wp[20]; diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp index 836680c24f..b8ea36b698 100644 --- a/engines/xeen/map.cpp +++ b/engines/xeen/map.cpp @@ -810,22 +810,15 @@ void HeadData::synchronize(Common::SeekableReadStream &s) { /*------------------------------------------------------------------------*/ /** - * Synchronize data for an entry within an animation entry - */ -void AnimationFrame::synchronize(Common::SeekableReadStream &s) { - _left = s.readByte(); - _back = s.readByte(); - _right = s.readByte(); - _front = s.readByte(); -} - -/** * Synchronize data for an animation entry */ void AnimationEntry::synchronize(Common::SeekableReadStream &s) { - _frame1.synchronize(s); - _flipped.synchronize(s); - _frame2.synchronize(s); + for (int i = 0; i < 4; ++i) + _frame1._frames[i] = s.readByte(); + for (int i = 0; i < 4; ++i) + _flipped._flags[i] = s.readByte() != 0; + for (int i = 0; i < 4; ++i) + _frame2._frames[i] = s.readByte(); } /** diff --git a/engines/xeen/map.h b/engines/xeen/map.h index 228dfb8e22..7255552d5d 100644 --- a/engines/xeen/map.h +++ b/engines/xeen/map.h @@ -311,18 +311,21 @@ public: void synchronize(Common::SeekableReadStream &s); }; -struct AnimationFrame { - int _front, _left, _back, _right; - - AnimationFrame(): _front(0), _left(0), _back(0), _right(0) {} - - void synchronize(Common::SeekableReadStream &s); -}; - +struct AnimationFrame { int _front, _left, _back, _right; }; +struct AnimationFlipped { bool _front, _left, _back, _right; }; struct AnimationEntry { - AnimationFrame _frame1; - AnimationFrame _flipped; - AnimationFrame _frame2; + union { + AnimationFrame _positions; + int _frames[4]; + } _frame1; + union { + AnimationFlipped _positions; + bool _flags[4]; + } _flipped; + union { + AnimationFrame _positions; + int _frames[4]; + } _frame2; void synchronize(Common::SeekableReadStream &s); }; @@ -339,8 +342,6 @@ private: XeenEngine *_vm; MazeData _mazeData[9]; Common::String _mazeName; - HeadData _headData; - AnimationInfo _animationInfo; MonsterData _monsterData; SpriteResource _wallPicSprites; int _townPortalSide; @@ -358,6 +359,8 @@ public: bool _isOutdoors; MonsterObjectData _mobData; MazeEvents _events; + HeadData _headData; + AnimationInfo _animationInfo; bool _currentIsGrate; bool _currentCantRest; bool _currentIsDrain; diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp index 35fa2cb2bf..e660014ec3 100644 --- a/engines/xeen/resources.cpp +++ b/engines/xeen/resources.cpp @@ -350,4 +350,8 @@ const int OUTDOOR_OBJECT_Y[2][12] = { { 70, 71, 72, 73, 74, 75, 90, 91, 92, 93, 94, 112 } }; +const int DIRECTION_ANIM_POSITIONS[4][4] = { + { 0, 1, 2, 3 }, { 3, 0, 1, 2 }, { 2, 3, 0, 1 }, { 1, 2, 3, 0 } +}; + } // End of namespace Xeen diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h index d8cc93b9f4..35b82566b3 100644 --- a/engines/xeen/resources.h +++ b/engines/xeen/resources.h @@ -78,6 +78,8 @@ extern const int OUTDOOR_OBJECT_X[2][12]; extern const int OUTDOOR_OBJECT_Y[2][12]; +extern const int DIRECTION_ANIM_POSITIONS[4][4]; + } // End of namespace Xeen #endif /* XEEN_RESOURCES_H */ |