aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction
diff options
context:
space:
mode:
authorNicola Mettifogo2008-08-15 08:44:41 +0000
committerNicola Mettifogo2008-08-15 08:44:41 +0000
commit22eaffcb343c688defbcd53445ad111390edb71d (patch)
tree3b0cb32a54def2af1e6e2deb00fda2dbbcf4de7c /engines/parallaction
parent0606fef24e03580d2d2f3c34f9fd254f361d7623 (diff)
downloadscummvm-rg350-22eaffcb343c688defbcd53445ad111390edb71d.tar.gz
scummvm-rg350-22eaffcb343c688defbcd53445ad111390edb71d.tar.bz2
scummvm-rg350-22eaffcb343c688defbcd53445ad111390edb71d.zip
Updated layer calculation: animations are now hidden properly by background elements (but not items yet).
svn-id: r33894
Diffstat (limited to 'engines/parallaction')
-rw-r--r--engines/parallaction/debug.cpp10
-rw-r--r--engines/parallaction/exec_ns.cpp33
-rw-r--r--engines/parallaction/graphics.cpp6
-rw-r--r--engines/parallaction/objects.cpp21
-rw-r--r--engines/parallaction/objects.h12
-rw-r--r--engines/parallaction/parallaction.cpp2
-rw-r--r--engines/parallaction/parser_br.cpp7
7 files changed, 62 insertions, 29 deletions
diff --git a/engines/parallaction/debug.cpp b/engines/parallaction/debug.cpp
index 623cb3224c..0ff38913f7 100644
--- a/engines/parallaction/debug.cpp
+++ b/engines/parallaction/debug.cpp
@@ -187,19 +187,19 @@ bool Debugger::Cmd_GfxObjects(int argc, const char **argv) {
const char *objType[] = { "DOOR", "GET", "ANIM" };
- DebugPrintf("+--------------------+-----+-----+-----+-----+--------+--------+\n"
- "| name | x | y | z | f | type | visi |\n"
- "+--------------------+-----+-----+-----+-----+--------+--------+\n");
+ DebugPrintf("+--------------------+-----+-----+-----+-------+-----+--------+--------+\n"
+ "| name | x | y | z | layer | f | type | visi |\n"
+ "+--------------------+-----+-----+-----+-------+-----+--------+--------+\n");
GfxObjList::iterator b = _vm->_gfx->_gfxobjList.begin();
GfxObjList::iterator e = _vm->_gfx->_gfxobjList.end();
for ( ; b != e; b++) {
GfxObj *obj = *b;
- DebugPrintf("|%-20s|%5i|%5i|%5i|%5i|%8s|%8x|\n", obj->getName(), obj->x, obj->y, obj->z, obj->frame, objType[obj->type], obj->isVisible() );
+ DebugPrintf("|%-20s|%5i|%5i|%5i|%7i|%5i|%8s|%8x|\n", obj->getName(), obj->x, obj->y, obj->z, obj->layer, obj->frame, objType[obj->type], obj->isVisible() );
}
- DebugPrintf("+--------------------+-----+-----+-----+-----+--------+--------+\n");
+ DebugPrintf("+--------------------+-----+-----+-----+-------+-----+--------+--------+\n");
return true;
}
diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp
index 873c235a1a..bf0423bbd1 100644
--- a/engines/parallaction/exec_ns.cpp
+++ b/engines/parallaction/exec_ns.cpp
@@ -330,12 +330,21 @@ void Parallaction_ns::drawAnimations() {
if (anim->_flags & kFlagsNoMasked)
layer = LAYER_FOREGROUND;
- else
- layer = _gfx->_backgroundInfo->getLayer(anim->getY() + anim->height());
+ else {
+ if (getGameType() == GType_Nippon) {
+ // Layer in NS depends on where the animation is on the screen, for each animation.
+ layer = _gfx->_backgroundInfo->getLayer(anim->getFrameY() + anim->height());
+ } 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->getLayer(anim->getZ());
+ }
+ }
if (obj) {
_gfx->showGfxObj(obj, true);
- obj->frame = anim->getF();
+ obj->frame = anim->getF();
obj->x = anim->getX();
obj->y = anim->getY();
obj->z = anim->getZ();
@@ -401,7 +410,7 @@ void ProgramExec::runScripts(ProgramList::iterator first, ProgramList::iterator
AnimationPtr a = (*it)->_anim;
if (a->_flags & kFlagsCharacter)
- a->setZ(a->getY() + a->height());
+ a->setZ(a->getFrameY() + a->height());
if ((a->_flags & kFlagsActing) == 0)
continue;
@@ -409,7 +418,7 @@ void ProgramExec::runScripts(ProgramList::iterator first, ProgramList::iterator
runScript(*it, a);
if (a->_flags & kFlagsCharacter)
- a->setZ(a->getY() + a->height());
+ a->setZ(a->getFrameY() + a->height());
}
_modCounter++;
@@ -671,7 +680,7 @@ ZonePtr Parallaction::hitZone(uint32 type, uint16 x, uint16 y) {
if (z->_flags & kFlagsRemove) continue;
Common::Rect r;
- z->getRect(r);
+ z->getBox(r);
r.right++; // adjust border because Common::Rect doesn't include bottom-right edge
r.bottom++;
@@ -701,13 +710,13 @@ ZonePtr Parallaction::hitZone(uint32 type, uint16 x, uint16 y) {
if (z->getX() != -1)
continue;
- if (_si < _char._ani->getX())
+ if (_si < _char._ani->getFrameX())
continue;
- if (_si > (_char._ani->getX() + _char._ani->width()))
+ if (_si > (_char._ani->getFrameX() + _char._ani->width()))
continue;
- if (_di < _char._ani->getY())
+ if (_di < _char._ani->getFrameY())
continue;
- if (_di > (_char._ani->getY() + _char._ani->height()))
+ if (_di > (_char._ani->getFrameY() + _char._ani->height()))
continue;
}
@@ -729,8 +738,8 @@ ZonePtr Parallaction::hitZone(uint32 type, uint16 x, uint16 y) {
AnimationPtr a = *ait;
_a = (a->_flags & kFlagsActive) ? 1 : 0; // _a: active Animation
- _e = ((_si >= a->getX() + a->width()) || (_si <= a->getX())) ? 0 : 1; // _e: horizontal range
- _f = ((_di >= a->getY() + a->height()) || (_di <= a->getY())) ? 0 : 1; // _f: vertical range
+ _e = ((_si >= a->getFrameX() + a->width()) || (_si <= a->getFrameX())) ? 0 : 1; // _e: horizontal range
+ _f = ((_di >= a->getFrameY() + a->height()) || (_di <= a->getFrameY())) ? 0 : 1; // _f: vertical range
_b = ((type != 0) || (a->_type == kZoneYou)) ? 0 : 1; // _b: (no type specified) AND (Animation is not the character)
_c = (a->_type & 0xFFFF0000) ? 0 : 1; // _c: Animation is not an object
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp
index 29c07b2793..1c2cb58b5b 100644
--- a/engines/parallaction/graphics.cpp
+++ b/engines/parallaction/graphics.cpp
@@ -377,6 +377,12 @@ void Gfx::beginFrame() {
*data++ = _backgroundInfo->mask.getValue(x, y);
}
}
+#if 1
+ Common::DumpFile dump;
+ dump.open("maskdump.bin");
+ dump.write(_bitmapMask.pixels, _bitmapMask.w * _bitmapMask.h);
+ dump.close();
+#endif
break;
}
}
diff --git a/engines/parallaction/objects.cpp b/engines/parallaction/objects.cpp
index 6aeae3a92f..d2332643ed 100644
--- a/engines/parallaction/objects.cpp
+++ b/engines/parallaction/objects.cpp
@@ -71,6 +71,20 @@ uint16 Animation::height() const {
return r.height();
}
+int16 Animation::getFrameX() const {
+ if (!gfxobj) return _left;
+ Common::Rect r;
+ gfxobj->getRect(_frame, r);
+ return r.left + _left;
+}
+
+int16 Animation::getFrameY() const {
+ if (!gfxobj) return _top;
+ Common::Rect r;
+ gfxobj->getRect(_frame, r);
+ return r.top + _top;
+}
+
uint16 Animation::getFrameNum() const {
if (!gfxobj) return 0;
return gfxobj->getNum();
@@ -198,13 +212,6 @@ Zone::~Zone() {
free(_linkedName);
}
-void Zone::getRect(Common::Rect& r) const {
- r.left = _left;
- r.right = _right;
- r.top = _top;
- r.bottom = _bottom;
-}
-
void Zone::translate(int16 x, int16 y) {
_left += x;
_right += x;
diff --git a/engines/parallaction/objects.h b/engines/parallaction/objects.h
index 96145578fc..d06eaf1a03 100644
--- a/engines/parallaction/objects.h
+++ b/engines/parallaction/objects.h
@@ -322,7 +322,6 @@ public:
Zone();
virtual ~Zone();
- void getRect(Common::Rect& r) const;
void translate(int16 x, int16 y);
virtual uint16 width() const;
virtual uint16 height() const;
@@ -334,6 +333,14 @@ public:
_bottom = bottom;
}
+ void getBox(Common::Rect& r) {
+ r.left = getX();
+ r.right = getX() + width();
+ r.top = getY();
+ r.bottom = getY() + height();
+ }
+
+
// getters/setters
virtual int16 getX() { return _left; }
virtual void setX(int16 value) { _left = value; }
@@ -513,6 +520,9 @@ public:
void validateScriptVars();
+ int16 getFrameX() const;
+ int16 getFrameY() const;
+
// getters/setters used by scripts
int16 getX() { return _left; }
void setX(int16 value) { _left = value; }
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index e8621d5fd7..c810d22b33 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -352,7 +352,7 @@ void Parallaction::runGame() {
if (_input->_inputMode == Input::kInputModeGame) {
_programExec->runScripts(_location._programs.begin(), _location._programs.end());
- _char._ani->setZ(_char._ani->height() + _char._ani->getY());
+ _char._ani->setZ(_char._ani->height() + _char._ani->getFrameY());
if (_char._ani->gfxobj) {
_char._ani->gfxobj->z = _char._ani->getZ();
}
diff --git a/engines/parallaction/parser_br.cpp b/engines/parallaction/parser_br.cpp
index 1de69a78b5..b9df3a2aa2 100644
--- a/engines/parallaction/parser_br.cpp
+++ b/engines/parallaction/parser_br.cpp
@@ -466,9 +466,10 @@ DECLARE_LOCATION_PARSER(mask) {
debugC(7, kDebugParser, "LOCATION_PARSER(mask) ");
ctxt.maskName = strdup(_tokens[1]);
- ctxt.info->layers[0] = atoi(_tokens[2]);
- ctxt.info->layers[1] = atoi(_tokens[3]);
- ctxt.info->layers[2] = atoi(_tokens[4]);
+ ctxt.info->layers[0] = 0;
+ ctxt.info->layers[1] = atoi(_tokens[2]);
+ ctxt.info->layers[2] = atoi(_tokens[3]);
+ ctxt.info->layers[3] = atoi(_tokens[4]);
}