[Scummvm-cvs-logs] CVS: scummvm actor.cpp,1.80,1.81
Max Horn
fingolfin at users.sourceforge.net
Fri Jun 7 09:55:04 CEST 2002
Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv9519
Modified Files:
actor.cpp
Log Message:
moved the code that enforces all actors to be redrawn on a full redraw to a more appropriate location; fixed the rendering sort algorithm (it now uses a stable sort algorithm, namely bubble sort) - it used to produce a 'flicker' effect in some cases previously
Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/actor.cpp,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- actor.cpp 4 Jun 2002 23:32:50 -0000 1.80
+++ actor.cpp 7 Jun 2002 16:54:11 -0000 1.81
@@ -943,11 +943,13 @@
#endif
}
+#define DRAW_ORDER(x) ((x)->y - ((x)->layer << 11))
+
void Scumm::processActors()
{
int i;
- Actor *actors[MAX_ACTORS], *a, **ac, **ac2, *tmp;
- int numactors = 0, cnt, cnt2;
+ Actor *actors[MAX_ACTORS], *a, **ac, **ac2, *tmp, **end;
+ int numactors = 0;
// Make a list of all actors in this room
for (i = 1; i < NUM_ACTORS; i++) {
@@ -957,36 +959,31 @@
}
if (!numactors)
return;
+
+ end = actors + numactors;
// Sort actors by position before we draw them (to ensure that actors in
// front are drawn after those "behind" them).
- ac = actors;
- cnt = numactors;
- do {
- ac2 = actors;
- cnt2 = numactors;
- do {
- if ((*ac2)->y - ((*ac2)->layer << 11) > (*ac)->y - ((*ac)->layer << 11)) {
- tmp = *ac;
- *ac = *ac2;
+ for (ac = end-1; ac >= actors; --ac) {
+ for (ac2 = actors; ac2 != ac; ++ac2)
+ {
+ if (DRAW_ORDER(*ac2) > DRAW_ORDER(*(ac2+1))) {
+ tmp = *(ac2+1);
+ *(ac2+1) = *ac2;
*ac2 = tmp;
}
- } while (ac2++, --cnt2);
- } while (ac++, --cnt);
+ }
+ }
- // Finally draw all the actors in this room
- ac = actors;
- cnt = numactors;
- do {
+ // Finally draw the now sorted actors
+ for (ac = actors; ac != end; ++ac) {
a = *ac;
if (a->costume) {
CHECK_HEAP getMaskFromBox(a->walkbox);
- if (_fullRedraw)
- a->needRedraw = true;
a->drawActorCostume();
CHECK_HEAP a->actorAnimate();
}
- } while (ac++, --cnt);
+ }
}
void Actor::drawActorCostume()
@@ -1119,14 +1116,22 @@
int i, j;
uint32 bits;
- for (i = 0; i < 40; i++) {
- bits = gfxUsageBits[_screenStartStrip + i];
- if (bits & 0x3FFFFFFF) {
- for (j = 0; j < NUM_ACTORS; j++) {
- if ((bits & (1 << j)) && bits != (uint32)(1 << j)) {
- Actor *a = derefActor(j);
- a->needRedraw = true;
- a->needBgReset = true;
+ if (_fullRedraw) {
+ for (j = 0; j < NUM_ACTORS; j++) {
+ Actor *a = derefActor(j);
+ a->needRedraw = true;
+ a->needBgReset = true;
+ }
+ } else {
+ for (i = 0; i < 40; i++) {
+ bits = gfxUsageBits[_screenStartStrip + i];
+ if (bits & 0x3FFFFFFF) {
+ for (j = 0; j < NUM_ACTORS; j++) {
+ if ((bits & (1 << j)) && bits != (uint32)(1 << j)) {
+ Actor *a = derefActor(j);
+ a->needRedraw = true;
+ a->needBgReset = true;
+ }
}
}
}
More information about the Scummvm-git-logs
mailing list