diff options
author | Paul Gilbert | 2014-08-11 21:34:39 -0400 |
---|---|---|
committer | Paul Gilbert | 2014-08-11 21:34:39 -0400 |
commit | 7d4180c3e2b70ab3efa8d82f071e427a71adb1f0 (patch) | |
tree | 27e834513051ef8e92632410872a68e1a0dcaad8 /engines | |
parent | 768e144683847734cc16c9a7ec786379be6301e2 (diff) | |
download | scummvm-rg350-7d4180c3e2b70ab3efa8d82f071e427a71adb1f0.tar.gz scummvm-rg350-7d4180c3e2b70ab3efa8d82f071e427a71adb1f0.tar.bz2 scummvm-rg350-7d4180c3e2b70ab3efa8d82f071e427a71adb1f0.zip |
ACCESS: Implemented Animation setFrame code
Diffstat (limited to 'engines')
-rw-r--r-- | engines/access/access.h | 10 | ||||
-rw-r--r-- | engines/access/animation.cpp | 44 | ||||
-rw-r--r-- | engines/access/animation.h | 6 |
3 files changed, 50 insertions, 10 deletions
diff --git a/engines/access/access.h b/engines/access/access.h index 26ae88e6fb..f84a7bd1ca 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -70,6 +70,15 @@ enum AccessDebugChannels { struct AccessGameDescription; +class ImageEntry { +public: + int _field0; + SpriteResource *_spritesPtr; + int _priority; + Common::Point _position; + int _flags; +}; + class AccessEngine : public Engine { private: /** @@ -128,6 +137,7 @@ public: Common::Array<Common::Rect> _newRect; Common::Array<Common::Rect> _oldRect; Common::Array<ExtraCell> _extraCells; + Common::Array<ImageEntry> _images; int _pCount; int _selectCommand; bool _normalMouse; diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index 6c9f300931..a17c30f495 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -55,15 +55,15 @@ Animation::Animation(AccessEngine *vm, Common::MemoryReadStream &stream): uint32 startOfs = stream.pos(); _type = stream.readByte(); - _scaling = stream.readByte(); + _scaling = stream.readSByte(); stream.readByte(); // unk _frameNumber = stream.readByte(); _initialTicks = stream.readUint16LE(); stream.readUint16LE(); // unk stream.readUint16LE(); // unk - _loopCount = stream.readUint16LE(); + _loopCount = stream.readSint16LE(); _countdownTicks = stream.readUint16LE(); - _currentLoopCount = stream.readUint16LE(); + _currentLoopCount = stream.readSint16LE(); stream.readUint16LE(); // unk Common::Array<uint16> frameOffsets; @@ -206,13 +206,39 @@ AnimationFrame *Animation::calcFrame1() { } void Animation::setFrame(AnimationFrame *frame) { - error("TODO"); + _countdownTicks += frame->_frameDelay; + setFrame1(frame); } -void Animation::setFrame1(AnimationFrame *frame) { - error("TODO"); +static bool sortImagesY(const ImageEntry &ie1, const ImageEntry &ie2) { + return ie1._priority < ie2._priority; } +void Animation::setFrame1(AnimationFrame *frame) { + _vm->_animation->_base.x = frame->_baseX; + _vm->_animation->_base.y = frame->_baseY; + + // Loop to add image draw requests for the parts of the frame + for (uint i = 0; i < frame->_parts.size(); ++i) { + AnimationFramePart *part = frame->_parts[i]; + ImageEntry ie; + + // Set the flags + ie._flags = part->_flags & 0xF7; + if (_vm->_animation->_frameScale == -1) + ie._flags |= 8; + + // Set the other fields + ie._spritesPtr = _vm->_objectsTable[part->_spritesIndex]; + ie._field0 = part->_frameIndex; + ie._position = part->_position + _vm->_animation->_base; + ie._priority = part->_priority - ie._position.y; + + assert(_vm->_images.size() < 35); + _vm->_images.push_back(ie); + Common::sort(_vm->_images.begin(), _vm->_images.end(), sortImagesY); + } +} /*------------------------------------------------------------------------*/ @@ -244,8 +270,8 @@ AnimationFrame::~AnimationFrame() { AnimationFramePart::AnimationFramePart(Common::MemoryReadStream &stream) { _flags = stream.readByte(); - _slotIndex = stream.readByte(); - _spriteIndex = stream.readByte(); + _spritesIndex = stream.readByte(); + _frameIndex = stream.readByte(); _position.x = stream.readUint16LE(); _position.y = stream.readUint16LE(); _priority = stream.readUint16LE(); @@ -256,6 +282,7 @@ AnimationFramePart::AnimationFramePart(Common::MemoryReadStream &stream) { AnimationManager::AnimationManager(AccessEngine *vm) : Manager(vm) { _animation = nullptr; _animStart = nullptr; + _frameScale = 0; } AnimationManager::~AnimationManager() { @@ -306,6 +333,7 @@ Animation *AnimationManager::findAnimation(int animId) { void AnimationManager::animate(int animId) { Animation *anim = findAnimation(animId); + _frameScale = anim->_scaling; anim->animate(); } diff --git a/engines/access/animation.h b/engines/access/animation.h index d9b10085ce..c1b44a5621 100644 --- a/engines/access/animation.h +++ b/engines/access/animation.h @@ -41,6 +41,8 @@ private: AnimationResource *_animation; public: Animation *_animStart; + Common::Point _base; + int _frameScale; public: AnimationManager(AccessEngine *vm); ~AnimationManager(); @@ -113,8 +115,8 @@ public: class AnimationFramePart { public: byte _flags; - int _slotIndex; - int _spriteIndex; + int _spritesIndex; + int _frameIndex; Common::Point _position; int _priority; public: |