aboutsummaryrefslogtreecommitdiff
path: root/engines/m4/animation.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2010-06-13 08:53:06 +0000
committerPaul Gilbert2010-06-13 08:53:06 +0000
commit02ed880180a83a46ec72f69879df565f42c840db (patch)
tree893cece5aa1c4b854852308b2e736a83e6dd01d2 /engines/m4/animation.cpp
parentd1993773880143d234f3355dd5a03f778e35b78c (diff)
downloadscummvm-rg350-02ed880180a83a46ec72f69879df565f42c840db.tar.gz
scummvm-rg350-02ed880180a83a46ec72f69879df565f42c840db.tar.bz2
scummvm-rg350-02ed880180a83a46ec72f69879df565f42c840db.zip
Added logic for handling the rate of animation background scrolling, and miscellaneous extra fields
svn-id: r49627
Diffstat (limited to 'engines/m4/animation.cpp')
-rw-r--r--engines/m4/animation.cpp36
1 files changed, 23 insertions, 13 deletions
diff --git a/engines/m4/animation.cpp b/engines/m4/animation.cpp
index adb802ee0e..cf2d201b81 100644
--- a/engines/m4/animation.cpp
+++ b/engines/m4/animation.cpp
@@ -44,6 +44,7 @@ MadsAnimation::MadsAnimation(MadsM4Engine *vm, MadsView *view): Animation(vm), _
_currentFrame = 0;
_oldFrameEntry = 0;
_nextFrameTimer = _madsVm->_currentTimer;
+ _nextScrollTimer = 0;
}
MadsAnimation::~MadsAnimation() {
@@ -89,7 +90,8 @@ void MadsAnimation::initialise(const Common::String &filename, uint16 flags, M4S
_spriteListIndex = animStream->readUint16LE();
_scrollX = animStream->readSint16LE();
_scrollY = animStream->readSint16LE();
- animStream->skip(10);
+ _scrollTicks = animStream->readUint16LE();
+ animStream->skip(8);
animStream->read(buffer, 13);
_interfaceFile = Common::String(buffer, 13);
@@ -180,7 +182,7 @@ void MadsAnimation::initialise(const Common::String &filename, uint16 flags, M4S
for (int i = 0; i < miscEntriesCount; ++i) {
AnimMiscEntry rec;
rec.soundNum = animStream->readByte();
- animStream->skip(1);
+ rec.msgIndex = animStream->readSByte();
rec.numTicks = animStream->readUint16LE();
rec.posAdjust.x = animStream->readUint16LE();
rec.posAdjust.y = animStream->readUint16LE();
@@ -232,6 +234,9 @@ void MadsAnimation::initialise(const Common::String &filename, uint16 flags, M4S
int idx = _frameEntries[i].spriteSlot.spriteListIndex;
_frameEntries[i].spriteSlot.spriteListIndex = _spriteListIndexes[idx];
}
+
+ if (hasScroll())
+ _nextScrollTimer = _madsVm->_currentTimer + _scrollTicks;
}
/**
@@ -282,9 +287,24 @@ void MadsAnimation::update() {
load1(newIndex);
}
+ // Check for scroll change
+ bool screenChanged = false;
+
+ // Handle any scrolling of the screen surface
+ if (hasScroll() && (_madsVm->_currentTimer >= _nextScrollTimer)) {
+ _view->_bgSurface->scrollX(_scrollX);
+ _view->_bgSurface->scrollY(_scrollY);
+
+ _nextScrollTimer = _madsVm->_currentTimer + _scrollTicks;
+ screenChanged = true;
+ }
+
// If it's not time for the next frame, then exit
- if (_madsVm->_currentTimer < _nextFrameTimer)
+ if (_madsVm->_currentTimer < _nextFrameTimer) {
+ if (screenChanged)
+ _view->_spriteSlots.fullRefresh();
return;
+ }
// Loop checks for any prior animation sprite slots to be expired
for (int slotIndex = 0; slotIndex < _view->_spriteSlots.startIndex; ++slotIndex) {
@@ -311,16 +331,6 @@ void MadsAnimation::update() {
if (misc.soundNum)
_vm->_sound->playSound(misc.soundNum);
- bool screenChanged = false;
-
- // Handle any scrolling of the screen surface
- if ((_scrollX != 0) || (_scrollY != 0)) {
- _view->_bgSurface->scrollX(_scrollX);
- _view->_bgSurface->scrollY(_scrollY);
-
- screenChanged = true;
- }
-
// Handle any offset adjustment for sprites as of this frame
if (_view->_posAdjust.x != misc.posAdjust.x) {
misc.posAdjust.x = _view->_posAdjust.x;