aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/parallaction/defs.h25
-rw-r--r--engines/parallaction/exec_ns.cpp12
-rw-r--r--engines/parallaction/gfxbase.cpp36
-rw-r--r--engines/parallaction/graphics.cpp2
-rw-r--r--engines/parallaction/graphics.h5
-rw-r--r--engines/parallaction/parallaction.cpp10
-rw-r--r--engines/parallaction/parallaction.h1
7 files changed, 46 insertions, 45 deletions
diff --git a/engines/parallaction/defs.h b/engines/parallaction/defs.h
index 2f78ec6133..c8ae3bc2d7 100644
--- a/engines/parallaction/defs.h
+++ b/engines/parallaction/defs.h
@@ -75,30 +75,6 @@ public:
Common_List::insert(it, element);
}
- // FIXME: this routine is a copy of the sort routine that can be found in common/func.cpp
- // That wasn't usable because the 'less than' operator was hardcoded. Any comments or
- // suggestions are welcome.
- void sort(CompareFunction compare) {
- iterator first = Common_List::begin();
- iterator last = Common_List::end();
-
- if (first == last)
- return;
-
- // Simple selection sort
- iterator i(first);
- for (; i != last; ++i) {
- iterator minElem(i);
- iterator j(i);
- ++j;
- for (; j != last; ++j)
- if (compare(*j, *minElem) < 0)
- minElem = j;
- if (minElem != i)
- SWAP(*minElem, *i);
- }
- }
-
};
} // namespace Parallaction
@@ -110,3 +86,4 @@ public:
+
diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp
index b5d6bb03eb..93a0e9ab25 100644
--- a/engines/parallaction/exec_ns.cpp
+++ b/engines/parallaction/exec_ns.cpp
@@ -320,7 +320,7 @@ DECLARE_COMMAND_OPCODE(stop) {
void Parallaction_ns::drawAnimations() {
- uint16 _si = 0;
+ uint16 layer = 0;
for (AnimationList::iterator it = _animations.begin(); it != _animations.end(); it++) {
@@ -331,16 +331,17 @@ void Parallaction_ns::drawAnimations() {
int16 frame = CLIP((int)v18->_frame, 0, v18->getFrameNum()-1);
if (v18->_flags & kFlagsNoMasked)
- _si = 3;
+ layer = 3;
else
- _si = _gfx->queryMask(v18->_top + v18->height());
+ layer = _gfx->queryMask(v18->_top + v18->height());
_gfx->showGfxObj(obj, true);
obj->frame = frame;
obj->x = v18->_left;
obj->y = v18->_top;
- obj->z = _si;
+ obj->z = v18->_z;
+ obj->layer = layer;
}
if (((v18->_flags & kFlagsActive) == 0) && (v18->_flags & kFlagsRemove)) {
@@ -426,7 +427,8 @@ label1:
a->_z = a->_top + a->height();
}
- sortAnimations();
+ _char._ani._z = _char._ani.height() + _char._ani._top;
+ _char._ani.gfxobj->z = _char._ani._z;
modCounter++;
return;
diff --git a/engines/parallaction/gfxbase.cpp b/engines/parallaction/gfxbase.cpp
index a3fd8c413b..fd581cda0e 100644
--- a/engines/parallaction/gfxbase.cpp
+++ b/engines/parallaction/gfxbase.cpp
@@ -29,7 +29,7 @@
namespace Parallaction {
-GfxObj::GfxObj(uint objType, Frames *frames, const char* name) : type(objType), _frames(frames), x(0), y(0), z(3), frame(0), _flags(0), _keep(true) {
+GfxObj::GfxObj(uint objType, Frames *frames, const char* name) : type(objType), _frames(frames), x(0), y(0), z(0), frame(0), layer(3), _flags(0), _keep(true) {
if (name) {
_name = strdup(name);
} else {
@@ -121,12 +121,42 @@ void Gfx::showGfxObj(GfxObj* obj, bool visible) {
}
+
+
+int compareAnimationZ(const GfxObj* a1, const GfxObj* a2) {
+ if (a1->z == a2->z) return 0;
+ return (a1->z < a2->z ? -1 : 1);
+}
+
+void Gfx::sortAnimations() {
+
+ GfxObjList::iterator first = _gfxobjList[kGfxObjTypeAnim].begin();
+ GfxObjList::iterator last = _gfxobjList[kGfxObjTypeAnim].end();
+
+ if (first == last)
+ return;
+
+ // Simple selection sort
+ GfxObjList::iterator i(first);
+ for (; i != last; ++i) {
+ GfxObjList::iterator minElem(i);
+ GfxObjList::iterator j(i);
+ ++j;
+ for (; j != last; ++j)
+ if (compareAnimationZ(*j, *minElem) < 0)
+ minElem = j;
+ if (minElem != i)
+ SWAP(*minElem, *i);
+ }
+
+}
+
void Gfx::drawGfxObjects(Graphics::Surface &surf) {
Common::Rect rect;
byte *data;
- // TODO: sort animations before drawing
+ sortAnimations();
// TODO: some zones don't appear because of wrong masking (3 or 0?)
// TODO: Dr.Ki is not visible inside the club
@@ -142,7 +172,7 @@ void Gfx::drawGfxObjects(Graphics::Surface &surf) {
obj->getRect(obj->frame, rect);
rect.moveTo(obj->x, obj->y);
data = obj->getData(obj->frame);
- blt(rect, data, &surf, obj->z, 0);
+ blt(rect, data, &surf, obj->layer, 0);
}
}
}
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp
index ec5cc904f0..2ed4a99405 100644
--- a/engines/parallaction/graphics.cpp
+++ b/engines/parallaction/graphics.cpp
@@ -857,7 +857,7 @@ void Gfx::grabRect(byte *dst, const Common::Rect& r, Gfx::Buffers srcbuffer, uin
}
-int16 Gfx::queryMask(int16 v) {
+uint16 Gfx::queryMask(uint16 v) {
for (uint16 _si = 0; _si < 3; _si++) {
if (_bgLayers[_si+1] > v) return _si;
diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h
index f4f9dc1203..1af1d1e8ea 100644
--- a/engines/parallaction/graphics.h
+++ b/engines/parallaction/graphics.h
@@ -270,6 +270,7 @@ public:
uint16 z;
uint type;
uint frame;
+ uint layer;
GfxObj(uint type, Frames *frames, const char *name = NULL);
virtual ~GfxObj();
@@ -312,6 +313,7 @@ public:
void showGfxObj(GfxObj* obj, bool visible);
GfxObjList _gfxobjList[3];
void drawGfxObjects(Graphics::Surface &surf);
+ void sortAnimations();
public:
@@ -368,7 +370,7 @@ public:
void setProjectorPos(int x, int y);
// misc
- int16 queryMask(int16 v);
+ uint16 queryMask(uint16 v);
void swapBuffers();
void updateScreen();
void setBackground(Graphics::Surface *surf);
@@ -464,3 +466,4 @@ protected:
+
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index b310d970f2..acf01cf433 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -678,16 +678,6 @@ void Parallaction::freeAnimations() {
return;
}
-int compareAnimationZ(const AnimationPointer &a1, const AnimationPointer &a2) {
- if (a1->_z == a2->_z) return 0;
- return (a1->_z < a2->_z ? -1 : 1);
-}
-
-void Parallaction::sortAnimations() {
- _char._ani._z = _char._ani.height() + _char._ani._top;
- _animations.sort(compareAnimationZ);
- return;
-}
void Parallaction::allocateLocationSlot(const char *name) {
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index 03aebb7fcc..b77d30e41e 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -361,7 +361,6 @@ public:
void runCommands(CommandList& list, Zone *z = NULL);
Animation *findAnimation(const char *name);
- void sortAnimations();
void freeAnimations();
void setBackground(const char *background, const char *mask, const char *path);