aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction/parallaction.cpp
diff options
context:
space:
mode:
authorNicola Mettifogo2009-02-23 11:50:10 +0000
committerNicola Mettifogo2009-02-23 11:50:10 +0000
commitedaf382d2fb46403fa437e6113c90754230dc2e9 (patch)
tree7e2da7757ca6d8ee83db30ca51b9dec9e9288f66 /engines/parallaction/parallaction.cpp
parente7fd931afa88e4b9afdf7da303bd4db76e288083 (diff)
downloadscummvm-rg350-edaf382d2fb46403fa437e6113c90754230dc2e9.tar.gz
scummvm-rg350-edaf382d2fb46403fa437e6113c90754230dc2e9.tar.bz2
scummvm-rg350-edaf382d2fb46403fa437e6113c90754230dc2e9.zip
* Refactored drawAnimations to be more easily extensible when adding game-specific features.
* Added a new zonesToUpdate list to keep track of movable zones. svn-id: r38815
Diffstat (limited to 'engines/parallaction/parallaction.cpp')
-rw-r--r--engines/parallaction/parallaction.cpp117
1 files changed, 63 insertions, 54 deletions
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index 93ad60824a..e04c6fb925 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -337,12 +337,8 @@ void Parallaction::runGameFrame(int event) {
_programExec->runScripts(_location._programs.begin(), _location._programs.end());
_char._ani->resetZ();
-// if (_char._ani->gfxobj) {
-// _char._ani->gfxobj->z = _char._ani->getZ();
-// }
_char._walker->walk();
- drawAnimations();
-
+ updateZones();
}
void Parallaction::runGame() {
@@ -403,7 +399,7 @@ void Parallaction::doLocationEnterTransition() {
_gfx->setPalette(pal);
_programExec->runScripts(_location._programs.begin(), _location._programs.end());
- drawAnimations();
+ updateZones();
showLocationComment(_location._comment, false);
_gfx->updateScreen();
@@ -443,66 +439,79 @@ uint32 Parallaction::getLocationFlags() {
-void Parallaction::drawAnimations() {
- debugC(9, kDebugExec, "Parallaction_ns::drawAnimations()\n");
-
- uint16 layer = 0, scale = 100;
+void Parallaction::drawAnimation(AnimationPtr anim) {
+ if ((anim->_flags & kFlagsActive) == 0) {
+ return;
+ }
- for (AnimationList::iterator it = _location._animations.begin(); it != _location._animations.end(); it++) {
+ GfxObj *obj = anim->gfxobj;
+ if (!obj) {
+ return;
+ }
- AnimationPtr anim = *it;
- GfxObj *obj = anim->gfxobj;
+ // animation display defaults to topmost and no scaling
+ uint16 layer = LAYER_FOREGROUND;
+ uint16 scale = 100;
- if ((anim->_flags & kFlagsActive) && ((anim->_flags & kFlagsRemove) == 0)) {
+ switch (getGameType()) {
+ case GType_Nippon:
+ if ((anim->_flags & kFlagsNoMasked) == 0) {
+ // Layer in NS depends on where the animation is on the screen, for each animation.
+ layer = _gfx->_backgroundInfo->getMaskLayer(anim->getBottom());
+ }
+ break;
- if (anim->_flags & kFlagsNoMasked) {
- layer = LAYER_FOREGROUND;
- } else {
- if (getGameType() == GType_Nippon) {
- // Layer in NS depends on where the animation is on the screen, for each animation.
- layer = _gfx->_backgroundInfo->getMaskLayer(anim->getBottom());
- } else {
- // Layer in BRA is calculated from Z value. For characters it is the same as NS,
- // but other animations can have Z set from scripts independently from their
- // position on the screen.
- layer = _gfx->_backgroundInfo->getMaskLayer(anim->getZ());
- }
- }
+ case GType_BRA:
+ if ((anim->_flags & kFlagsNoMasked) == 0) {
+ // Layer in BRA is calculated from Z value. For characters it is the same as NS,
+ // but other animations can have Z set from scripts independently from their
+ // position on the screen.
+ layer = _gfx->_backgroundInfo->getMaskLayer(anim->getZ());
+ }
+ if (anim->_flags & (kFlagsScaled | kFlagsCharacter)) {
+ scale = _location.getScale(anim->getZ());
+ }
+ break;
+ }
- scale = 100;
- if (getGameType() == GType_BRA) {
- if (anim->_flags & (kFlagsScaled | kFlagsCharacter)) {
- scale = _location.getScale(anim->getZ());
- }
- }
+ // updates the data for display
+ _gfx->showGfxObj(obj, true);
+ obj->frame = anim->getF();
+ obj->x = anim->getX();
+ obj->y = anim->getY();
+ obj->z = anim->getZ();
+ obj->layer = layer;
+ obj->scale = scale;
+}
- if (obj) {
- _gfx->showGfxObj(obj, true);
- obj->frame = anim->getF();
- obj->x = anim->getX();
- obj->y = anim->getY();
- obj->z = anim->getZ();
- obj->layer = layer;
- obj->scale = scale;
- }
- }
+void Parallaction::updateZones() {
+ debugC(9, kDebugExec, "Parallaction::updateZones()\n");
- if (((anim->_flags & kFlagsActive) == 0) && (anim->_flags & kFlagsRemove)) {
- anim->_flags &= ~kFlagsRemove;
+ // go through all animations and mark/unmark each of them for display
+ for (AnimationList::iterator ait = _location._animations.begin(); ait != _location._animations.end(); ait++) {
+ AnimationPtr anim = *ait;
+ if ((anim->_flags & kFlagsRemove) != 0) {
+ // marks the animation as invisible for this frame
+ _gfx->showGfxObj(anim->gfxobj, false);
+ anim->_flags &= ~(kFlagsActive | kFlagsRemove);
+ } else {
+ // updates animation parameters
+ drawAnimation(anim);
}
+ }
- if ((anim->_flags & kFlagsActive) && (anim->_flags & kFlagsRemove)) {
- anim->_flags &= ~kFlagsActive;
- anim->_flags |= kFlagsRemove;
- if (obj) {
- _gfx->showGfxObj(obj, false);
- }
+ // examine the list of get zones to update
+ for (ZoneList::iterator zit = _zonesToUpdate.begin(); zit != _zonesToUpdate.end(); zit++) {
+ ZonePtr z = *zit;
+ if ((z->_type & 0xFFFF) == kZoneGet) {
+ GfxObj *obj = z->u.get->gfxobj;
+ obj->x = z->getX();
+ obj->y = z->getY();
}
}
+ _zonesToUpdate.clear();
- debugC(9, kDebugExec, "Parallaction_ns::drawAnimations done()\n");
-
- return;
+ debugC(9, kDebugExec, "Parallaction::updateZones done()\n");
}