Updated layer calculation: animations are now hidden properly by background elements (but not items yet).

svn-id: r33894
This commit is contained in:
Nicola Mettifogo 2008-08-15 08:44:41 +00:00
parent 0606fef24e
commit 22eaffcb34
7 changed files with 62 additions and 29 deletions

View file

@ -187,19 +187,19 @@ bool Debugger::Cmd_GfxObjects(int argc, const char **argv) {
const char *objType[] = { "DOOR", "GET", "ANIM" }; const char *objType[] = { "DOOR", "GET", "ANIM" };
DebugPrintf("+--------------------+-----+-----+-----+-----+--------+--------+\n" DebugPrintf("+--------------------+-----+-----+-----+-------+-----+--------+--------+\n"
"| name | x | y | z | f | type | visi |\n" "| name | x | y | z | layer | f | type | visi |\n"
"+--------------------+-----+-----+-----+-----+--------+--------+\n"); "+--------------------+-----+-----+-----+-------+-----+--------+--------+\n");
GfxObjList::iterator b = _vm->_gfx->_gfxobjList.begin(); GfxObjList::iterator b = _vm->_gfx->_gfxobjList.begin();
GfxObjList::iterator e = _vm->_gfx->_gfxobjList.end(); GfxObjList::iterator e = _vm->_gfx->_gfxobjList.end();
for ( ; b != e; b++) { for ( ; b != e; b++) {
GfxObj *obj = *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; return true;
} }

View file

@ -330,8 +330,17 @@ void Parallaction_ns::drawAnimations() {
if (anim->_flags & kFlagsNoMasked) if (anim->_flags & kFlagsNoMasked)
layer = LAYER_FOREGROUND; layer = LAYER_FOREGROUND;
else else {
layer = _gfx->_backgroundInfo->getLayer(anim->getY() + anim->height()); 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) { if (obj) {
_gfx->showGfxObj(obj, true); _gfx->showGfxObj(obj, true);
@ -401,7 +410,7 @@ void ProgramExec::runScripts(ProgramList::iterator first, ProgramList::iterator
AnimationPtr a = (*it)->_anim; AnimationPtr a = (*it)->_anim;
if (a->_flags & kFlagsCharacter) if (a->_flags & kFlagsCharacter)
a->setZ(a->getY() + a->height()); a->setZ(a->getFrameY() + a->height());
if ((a->_flags & kFlagsActing) == 0) if ((a->_flags & kFlagsActing) == 0)
continue; continue;
@ -409,7 +418,7 @@ void ProgramExec::runScripts(ProgramList::iterator first, ProgramList::iterator
runScript(*it, a); runScript(*it, a);
if (a->_flags & kFlagsCharacter) if (a->_flags & kFlagsCharacter)
a->setZ(a->getY() + a->height()); a->setZ(a->getFrameY() + a->height());
} }
_modCounter++; _modCounter++;
@ -671,7 +680,7 @@ ZonePtr Parallaction::hitZone(uint32 type, uint16 x, uint16 y) {
if (z->_flags & kFlagsRemove) continue; if (z->_flags & kFlagsRemove) continue;
Common::Rect r; Common::Rect r;
z->getRect(r); z->getBox(r);
r.right++; // adjust border because Common::Rect doesn't include bottom-right edge r.right++; // adjust border because Common::Rect doesn't include bottom-right edge
r.bottom++; r.bottom++;
@ -701,13 +710,13 @@ ZonePtr Parallaction::hitZone(uint32 type, uint16 x, uint16 y) {
if (z->getX() != -1) if (z->getX() != -1)
continue; continue;
if (_si < _char._ani->getX()) if (_si < _char._ani->getFrameX())
continue; continue;
if (_si > (_char._ani->getX() + _char._ani->width())) if (_si > (_char._ani->getFrameX() + _char._ani->width()))
continue; continue;
if (_di < _char._ani->getY()) if (_di < _char._ani->getFrameY())
continue; continue;
if (_di > (_char._ani->getY() + _char._ani->height())) if (_di > (_char._ani->getFrameY() + _char._ani->height()))
continue; continue;
} }
@ -729,8 +738,8 @@ ZonePtr Parallaction::hitZone(uint32 type, uint16 x, uint16 y) {
AnimationPtr a = *ait; AnimationPtr a = *ait;
_a = (a->_flags & kFlagsActive) ? 1 : 0; // _a: active Animation _a = (a->_flags & kFlagsActive) ? 1 : 0; // _a: active Animation
_e = ((_si >= a->getX() + a->width()) || (_si <= a->getX())) ? 0 : 1; // _e: horizontal range _e = ((_si >= a->getFrameX() + a->width()) || (_si <= a->getFrameX())) ? 0 : 1; // _e: horizontal range
_f = ((_di >= a->getY() + a->height()) || (_di <= a->getY())) ? 0 : 1; // _f: vertical 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) _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 _c = (a->_type & 0xFFFF0000) ? 0 : 1; // _c: Animation is not an object

View file

@ -377,6 +377,12 @@ void Gfx::beginFrame() {
*data++ = _backgroundInfo->mask.getValue(x, y); *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; break;
} }
} }

View file

@ -71,6 +71,20 @@ uint16 Animation::height() const {
return r.height(); 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 { uint16 Animation::getFrameNum() const {
if (!gfxobj) return 0; if (!gfxobj) return 0;
return gfxobj->getNum(); return gfxobj->getNum();
@ -198,13 +212,6 @@ Zone::~Zone() {
free(_linkedName); 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) { void Zone::translate(int16 x, int16 y) {
_left += x; _left += x;
_right += x; _right += x;

View file

@ -322,7 +322,6 @@ public:
Zone(); Zone();
virtual ~Zone(); virtual ~Zone();
void getRect(Common::Rect& r) const;
void translate(int16 x, int16 y); void translate(int16 x, int16 y);
virtual uint16 width() const; virtual uint16 width() const;
virtual uint16 height() const; virtual uint16 height() const;
@ -334,6 +333,14 @@ public:
_bottom = bottom; _bottom = bottom;
} }
void getBox(Common::Rect& r) {
r.left = getX();
r.right = getX() + width();
r.top = getY();
r.bottom = getY() + height();
}
// getters/setters // getters/setters
virtual int16 getX() { return _left; } virtual int16 getX() { return _left; }
virtual void setX(int16 value) { _left = value; } virtual void setX(int16 value) { _left = value; }
@ -513,6 +520,9 @@ public:
void validateScriptVars(); void validateScriptVars();
int16 getFrameX() const;
int16 getFrameY() const;
// getters/setters used by scripts // getters/setters used by scripts
int16 getX() { return _left; } int16 getX() { return _left; }
void setX(int16 value) { _left = value; } void setX(int16 value) { _left = value; }

View file

@ -352,7 +352,7 @@ void Parallaction::runGame() {
if (_input->_inputMode == Input::kInputModeGame) { if (_input->_inputMode == Input::kInputModeGame) {
_programExec->runScripts(_location._programs.begin(), _location._programs.end()); _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) { if (_char._ani->gfxobj) {
_char._ani->gfxobj->z = _char._ani->getZ(); _char._ani->gfxobj->z = _char._ani->getZ();
} }

View file

@ -466,9 +466,10 @@ DECLARE_LOCATION_PARSER(mask) {
debugC(7, kDebugParser, "LOCATION_PARSER(mask) "); debugC(7, kDebugParser, "LOCATION_PARSER(mask) ");
ctxt.maskName = strdup(_tokens[1]); ctxt.maskName = strdup(_tokens[1]);
ctxt.info->layers[0] = atoi(_tokens[2]); ctxt.info->layers[0] = 0;
ctxt.info->layers[1] = atoi(_tokens[3]); ctxt.info->layers[1] = atoi(_tokens[2]);
ctxt.info->layers[2] = atoi(_tokens[4]); ctxt.info->layers[2] = atoi(_tokens[3]);
ctxt.info->layers[3] = atoi(_tokens[4]);
} }