diff options
Diffstat (limited to 'engines/parallaction')
-rw-r--r-- | engines/parallaction/callables_ns.cpp | 42 | ||||
-rw-r--r-- | engines/parallaction/debug.cpp | 4 | ||||
-rw-r--r-- | engines/parallaction/exec_ns.cpp | 32 | ||||
-rw-r--r-- | engines/parallaction/graphics.cpp | 2 | ||||
-rw-r--r-- | engines/parallaction/objects.h | 28 | ||||
-rw-r--r-- | engines/parallaction/parallaction.cpp | 30 | ||||
-rw-r--r-- | engines/parallaction/parallaction_ns.cpp | 6 | ||||
-rw-r--r-- | engines/parallaction/parser_br.cpp | 25 | ||||
-rw-r--r-- | engines/parallaction/parser_ns.cpp | 26 | ||||
-rw-r--r-- | engines/parallaction/saveload.cpp | 4 | ||||
-rw-r--r-- | engines/parallaction/walk.cpp | 8 |
11 files changed, 108 insertions, 99 deletions
diff --git a/engines/parallaction/callables_ns.cpp b/engines/parallaction/callables_ns.cpp index 7e9395ef1f..0f89ca22d1 100644 --- a/engines/parallaction/callables_ns.cpp +++ b/engines/parallaction/callables_ns.cpp @@ -211,21 +211,17 @@ void Parallaction_ns::_c_moveSarc(void *parm) { } } - _introSarcData1 = _introSarcData3 - _moveSarcZone1->_left; - a->_z = _introSarcData3; - a->_frame = _moveSarcZone1->_top - (_introSarcData1 / 20); - _introSarcData3 = _moveSarcZone1->_left; + _introSarcData1 = _introSarcData3 - _moveSarcZone1->getX(); + a->setZ(_introSarcData3); + a->setF(_moveSarcZone1->getY() - (_introSarcData1 / 20)); + _introSarcData3 = _moveSarcZone1->getX(); if (_introSarcData1 > 0) { - a->_left = _introSarcData1 / 2; + a->setX(_introSarcData1 / 2); + a->setY(2); } else { - a->_left = -_introSarcData1 / 2; - } - - if (_introSarcData1 > 0) { - a->_top = 2; - } else { - a->_top = -2; + a->setX(-_introSarcData1 / 2); + a->setY(-2); } return; @@ -236,11 +232,11 @@ void Parallaction_ns::_c_moveSarc(void *parm) { _moveSarcZone1->translate(_introSarcData1, -_introSarcData1 / 20); _moveSarcZone0->translate(_introSarcData1, -_introSarcData1 / 20); - if (_moveSarcZones[0]->_left == 35 && - _moveSarcZones[1]->_left == 68 && - _moveSarcZones[2]->_left == 101 && - _moveSarcZones[3]->_left == 134 && - _moveSarcZones[4]->_left == 167) { + if (_moveSarcZones[0]->getX() == 35 && + _moveSarcZones[1]->getX() == 68 && + _moveSarcZones[2]->getX() == 101 && + _moveSarcZones[3]->getX() == 134 && + _moveSarcZones[4]->getX() == 167) { a = findAnimation("finito"); @@ -482,8 +478,8 @@ void Parallaction_ns::_c_sketch(void *parm) { Graphics::drawLine(oldx, oldy, newx, newy, 0, zeroMask, &_gfx->_backgroundInfo); - _rightHandAnim->_left = newx; - _rightHandAnim->_top = newy - 20; + _rightHandAnim->setX(newx); + _rightHandAnim->setY(newy - 20); index++; @@ -496,10 +492,10 @@ void Parallaction_ns::_c_sketch(void *parm) { void Parallaction_ns::_c_shade(void *parm) { Common::Rect r( - _rightHandAnim->_left - 36, - _rightHandAnim->_top - 36, - _rightHandAnim->_left, - _rightHandAnim->_top + _rightHandAnim->getX() - 36, + _rightHandAnim->getY() - 36, + _rightHandAnim->getX(), + _rightHandAnim->getY() ); uint16 _di = r.left/4 + r.top * _gfx->_backgroundInfo->mask.internalWidth; diff --git a/engines/parallaction/debug.cpp b/engines/parallaction/debug.cpp index 625c28dd5f..623cb3224c 100644 --- a/engines/parallaction/debug.cpp +++ b/engines/parallaction/debug.cpp @@ -157,7 +157,7 @@ bool Debugger::Cmd_Zones(int argc, const char **argv) { "+--------------------+---+---+---+---+--------+--------+\n"); for ( ; b != e; b++) { ZonePtr z = *b; - DebugPrintf("|%-20s|%3i|%3i|%3i|%3i|%8x|%8x|\n", z->_name, z->_left, z->_top, z->_right, z->_bottom, z->_type, z->_flags ); + DebugPrintf("|%-20s|%3i|%3i|%3i|%3i|%8x|%8x|\n", z->_name, z->getX(), z->getY(), z->getX() + z->width(), z->getY() + z->height(), z->_type, z->_flags ); } DebugPrintf("+--------------------+---+---+---+---+--------+--------+\n"); @@ -175,7 +175,7 @@ bool Debugger::Cmd_Animations(int argc, const char **argv) { "+--------------------+---+---+---+---+--------+--------+\n"); for ( ; b != e; b++) { AnimationPtr a = *b; - DebugPrintf("|%-20s|%3i|%3i|%3i|%3i|%8x|%8x|\n", a->_name, a->_left, a->_top, a->_z, a->_frame, a->_type, a->_flags ); + DebugPrintf("|%-20s|%3i|%3i|%3i|%3i|%8x|%8x|\n", a->_name, a->getX(), a->getY(), a->getZ(), a->getF(), a->_type, a->_flags ); } DebugPrintf("+--------------------+---+---+---+---+--------+--------+\n"); diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp index d63582f8d1..873c235a1a 100644 --- a/engines/parallaction/exec_ns.cpp +++ b/engines/parallaction/exec_ns.cpp @@ -126,7 +126,7 @@ DECLARE_INSTRUCTION_OPCODE(put) { Graphics::Surface v18; v18.w = inst->_a->width(); v18.h = inst->_a->height(); - v18.pixels = inst->_a->getFrameData(inst->_a->_frame); + v18.pixels = inst->_a->getFrameData(inst->_a->getF()); int16 x = inst->_opA.getValue(); int16 y = inst->_opB.getValue(); @@ -331,14 +331,14 @@ void Parallaction_ns::drawAnimations() { if (anim->_flags & kFlagsNoMasked) layer = LAYER_FOREGROUND; else - layer = _gfx->_backgroundInfo->getLayer(anim->_top + anim->height()); + layer = _gfx->_backgroundInfo->getLayer(anim->getY() + anim->height()); if (obj) { _gfx->showGfxObj(obj, true); - obj->frame = anim->_frame; - obj->x = anim->_left; - obj->y = anim->_top; - obj->z = anim->_z; + obj->frame = anim->getF(); + obj->x = anim->getX(); + obj->y = anim->getY(); + obj->z = anim->getZ(); obj->layer = layer; } } @@ -401,7 +401,7 @@ void ProgramExec::runScripts(ProgramList::iterator first, ProgramList::iterator AnimationPtr a = (*it)->_anim; if (a->_flags & kFlagsCharacter) - a->_z = a->_top + a->height(); + a->setZ(a->getY() + a->height()); if ((a->_flags & kFlagsActing) == 0) continue; @@ -409,7 +409,7 @@ void ProgramExec::runScripts(ProgramList::iterator first, ProgramList::iterator runScript(*it, a); if (a->_flags & kFlagsCharacter) - a->_z = a->_top + a->height(); + a->setZ(a->getY() + a->height()); } _modCounter++; @@ -680,7 +680,7 @@ ZonePtr Parallaction::hitZone(uint32 type, uint16 x, uint16 y) { if (!r.contains(_si, _di)) { // out of Zone, so look for special values - if ((z->_left == -2) || (z->_left == -3)) { + if ((z->getX() == -2) || (z->getX() == -3)) { // WORKAROUND: this huge condition is needed because we made TypeData a collection of structs // instead of an union. So, merge->_obj1 and get->_icon were just aliases in the original engine, @@ -699,15 +699,15 @@ ZonePtr Parallaction::hitZone(uint32 type, uint16 x, uint16 y) { } } - if (z->_left != -1) + if (z->getX() != -1) continue; - if (_si < _char._ani->_left) + if (_si < _char._ani->getX()) continue; - if (_si > (_char._ani->_left + _char._ani->width())) + if (_si > (_char._ani->getX() + _char._ani->width())) continue; - if (_di < _char._ani->_top) + if (_di < _char._ani->getY()) continue; - if (_di > (_char._ani->_top + _char._ani->height())) + if (_di > (_char._ani->getY() + _char._ani->height())) continue; } @@ -729,8 +729,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->_left + a->width()) || (_si <= a->_left)) ? 0 : 1; // _e: horizontal range - _f = ((_di >= a->_top + a->height()) || (_di <= a->_top)) ? 0 : 1; // _f: vertical range + _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 _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 c19d6ae5e5..29c07b2793 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -441,7 +441,7 @@ void Gfx::updateScreen() { for (; b != e; b++) { ZonePtr z = *b; if (z->_type & kZonePath) { - surf->frameRect(Common::Rect(z->_left, z->_top, z->_right, z->_bottom), 2); + surf->frameRect(Common::Rect(z->getX(), z->getY(), z->getX() + z->width(), z->getY() + z->height()), 2); } } g_system->unlockScreen(); diff --git a/engines/parallaction/objects.h b/engines/parallaction/objects.h index 1a724dcd77..96145578fc 100644 --- a/engines/parallaction/objects.h +++ b/engines/parallaction/objects.h @@ -297,12 +297,15 @@ struct TypeData { #define ZONENAME_LENGTH 32 struct Zone { - char _name[ZONENAME_LENGTH]; - +protected: int16 _left; int16 _top; int16 _right; int16 _bottom; + +public: + char _name[ZONENAME_LENGTH]; + uint32 _type; uint32 _flags; uint _label; @@ -323,6 +326,20 @@ struct Zone { void translate(int16 x, int16 y); virtual uint16 width() const; virtual uint16 height() const; + + void setBox(int16 left, int16 top, int16 right, int16 bottom) { + setX(left); + setY(top); + _right = right; + _bottom = bottom; + } + + // getters/setters + virtual int16 getX() { return _left; } + virtual void setX(int16 value) { _left = value; } + + virtual int16 getY() { return _top; } + virtual void setY(int16 value) { _top = value; } }; @@ -479,12 +496,13 @@ typedef Common::SharedPtr<Program> ProgramPtr; typedef Common::List<ProgramPtr> ProgramList; struct Animation : public Zone { - - GfxObj *gfxobj; - char *_scriptName; +protected: int16 _frame; int16 _z; +public: + GfxObj *gfxobj; + char *_scriptName; Animation(); virtual ~Animation(); diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index 195dc7a89a..e8621d5fd7 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -352,9 +352,9 @@ void Parallaction::runGame() { if (_input->_inputMode == Input::kInputModeGame) { _programExec->runScripts(_location._programs.begin(), _location._programs.end()); - _char._ani->_z = _char._ani->height() + _char._ani->_top; + _char._ani->setZ(_char._ani->height() + _char._ani->getY()); if (_char._ani->gfxobj) { - _char._ani->gfxobj->z = _char._ani->_z; + _char._ani->gfxobj->z = _char._ani->getZ(); } _char._walker->walk(); drawAnimations(); @@ -452,7 +452,7 @@ void Parallaction::freeZones() { // NOTE : this condition has been relaxed compared to the original, to allow the engine // to retain special - needed - zones that were lost across location switches. ZonePtr z = *it; - if (((z->_top == -1) || (z->_left == -2)) && ((_engineFlags & kEngineQuit) == 0)) { + if (((z->getY() == -1) || (z->getX() == -2)) && ((_engineFlags & kEngineQuit) == 0)) { debugC(2, kDebugExec, "freeZones preserving zone '%s'", z->_name); it++; } else { @@ -510,10 +510,10 @@ Character::Character(Parallaction *vm) : _vm(vm), _ani(new Animation) { _dummy = false; - _ani->_left = 150; - _ani->_top = 100; - _ani->_z = 10; - _ani->_frame = 0; + _ani->setX(150); + _ani->setY(100); + _ani->setZ(10); + _ani->setF(0); _ani->_flags = kFlagsActive | kFlagsNoName; _ani->_type = kZoneYou; strncpy(_ani->_name, "yourself", ZONENAME_LENGTH); @@ -540,18 +540,18 @@ Character::~Character() { void Character::getFoot(Common::Point &foot) { Common::Rect rect; - _ani->gfxobj->getRect(_ani->_frame, rect); + _ani->gfxobj->getRect(_ani->getF(), rect); - foot.x = _ani->_left + (rect.left + rect.width() / 2); - foot.y = _ani->_top + (rect.top + rect.height()); + foot.x = _ani->getX() + (rect.left + rect.width() / 2); + foot.y = _ani->getY() + (rect.top + rect.height()); } void Character::setFoot(const Common::Point &foot) { Common::Rect rect; - _ani->gfxobj->getRect(_ani->_frame, rect); + _ani->gfxobj->getRect(_ani->getF(), rect); - _ani->_left = foot.x - (rect.left + rect.width() / 2); - _ani->_top = foot.y - (rect.top + rect.height()); + _ani->setX(foot.x - (rect.left + rect.width() / 2)); + _ani->setY(foot.y - (rect.top + rect.height())); } #if 0 @@ -675,7 +675,7 @@ void Character::updateDirection(const Common::Point& pos, const Common::Point& t _step++; if (dist.x == 0 && dist.y == 0) { - _ani->_frame = frames->stillFrame[_direction]; + _ani->setF(frames->stillFrame[_direction]); return; } @@ -685,7 +685,7 @@ void Character::updateDirection(const Common::Point& pos, const Common::Point& t dist.y = -dist.y; _direction = (dist.x > dist.y) ? ((to.x > pos.x) ? WALK_LEFT : WALK_RIGHT) : ((to.y > pos.y) ? WALK_DOWN : WALK_UP); - _ani->_frame = frames->firstWalkFrame[_direction] + (_step / frames->frameRepeat[_direction]) % frames->numWalkFrames[_direction]; + _ani->setF(frames->firstWalkFrame[_direction] + (_step / frames->frameRepeat[_direction]) % frames->numWalkFrames[_direction]); } diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp index b95fcf68b2..61f2859e8a 100644 --- a/engines/parallaction/parallaction_ns.cpp +++ b/engines/parallaction/parallaction_ns.cpp @@ -319,9 +319,9 @@ void Parallaction_ns::changeLocation(char *location) { parseLocation(_saveData1); if (_location._startPosition.x != -1000) { - _char._ani->_left = _location._startPosition.x; - _char._ani->_top = _location._startPosition.y; - _char._ani->_frame = _location._startFrame; + _char._ani->setX(_location._startPosition.x); + _char._ani->setY(_location._startPosition.y); + _char._ani->setF(_location._startFrame); _location._startPosition.y = -1000; _location._startPosition.x = -1000; } diff --git a/engines/parallaction/parser_br.cpp b/engines/parallaction/parser_br.cpp index 7b208feb95..1de69a78b5 100644 --- a/engines/parallaction/parser_br.cpp +++ b/engines/parallaction/parser_br.cpp @@ -331,14 +331,14 @@ DECLARE_LOCATION_PARSER(location) { // TODO: handle background horizontal flip (via a context parameter) if (_tokens[nextToken][0] != '\0') { - _vm->_char._ani->_left = atoi(_tokens[nextToken]); + _vm->_char._ani->setX(atoi(_tokens[nextToken])); nextToken++; - _vm->_char._ani->_top = atoi(_tokens[nextToken]); + _vm->_char._ani->setY(atoi(_tokens[nextToken])); nextToken++; } if (_tokens[nextToken][0] != '\0') { - _vm->_char._ani->_frame = atoi(_tokens[nextToken]); + _vm->_char._ani->setF(atoi(_tokens[nextToken])); } } @@ -716,10 +716,7 @@ DECLARE_ZONE_PARSER(limits) { ctxt.z->_linkedAnim = _vm->findAnimation(_tokens[1]); ctxt.z->_linkedName = strdup(_tokens[1]); } else { - ctxt.z->_left = atoi(_tokens[1]); - ctxt.z->_top = atoi(_tokens[2]); - ctxt.z->_right = atoi(_tokens[3]); - ctxt.z->_bottom = atoi(_tokens[4]); + ctxt.z->setBox(atoi(_tokens[1]), atoi(_tokens[2]), atoi(_tokens[3]), atoi(_tokens[4])); } } @@ -824,10 +821,10 @@ DECLARE_ANIM_PARSER(file) { DECLARE_ANIM_PARSER(position) { debugC(7, kDebugParser, "ANIM_PARSER(position) "); - ctxt.a->_left = atoi(_tokens[1]); - ctxt.a->_top = atoi(_tokens[2]); - ctxt.a->_z = atoi(_tokens[3]); - ctxt.a->_frame = atoi(_tokens[4]); + ctxt.a->setX(atoi(_tokens[1])); + ctxt.a->setY(atoi(_tokens[2])); + ctxt.a->setZ(atoi(_tokens[3])); + ctxt.a->setF(atoi(_tokens[4])); } @@ -843,12 +840,14 @@ DECLARE_ANIM_PARSER(moveto) { DECLARE_ANIM_PARSER(endanimation) { debugC(7, kDebugParser, "ANIM_PARSER(endanimation) "); - +#if 0 + // I have disabled the following code since it seems useless. + // I will remove it after mask processing is done. if (ctxt.a->gfxobj) { ctxt.a->_right = ctxt.a->width(); ctxt.a->_bottom = ctxt.a->height(); } - +#endif ctxt.a->_flags |= 0x1000000; _parser->popTables(); diff --git a/engines/parallaction/parser_ns.cpp b/engines/parallaction/parser_ns.cpp index f252f7ffdd..4b90e2364f 100644 --- a/engines/parallaction/parser_ns.cpp +++ b/engines/parallaction/parser_ns.cpp @@ -264,9 +264,9 @@ DECLARE_ANIM_PARSER(file) { DECLARE_ANIM_PARSER(position) { debugC(7, kDebugParser, "ANIM_PARSER(position) "); - ctxt.a->_left = atoi(_tokens[1]); - ctxt.a->_top = atoi(_tokens[2]); - ctxt.a->_z = atoi(_tokens[3]); + ctxt.a->setX(atoi(_tokens[1])); + ctxt.a->setY(atoi(_tokens[2])); + ctxt.a->setZ(atoi(_tokens[3])); } @@ -985,12 +985,12 @@ DECLARE_LOCATION_PARSER(location) { _vm->switchBackground(_vm->_location._name, mask); if (_tokens[2][0] != '\0') { - _vm->_char._ani->_left = atoi(_tokens[2]); - _vm->_char._ani->_top = atoi(_tokens[3]); + _vm->_char._ani->setX(atoi(_tokens[2])); + _vm->_char._ani->setY(atoi(_tokens[3])); } if (_tokens[4][0] != '\0') { - _vm->_char._ani->_frame = atoi(_tokens[4]); + _vm->_char._ani->setF(atoi(_tokens[4])); } } @@ -1309,11 +1309,7 @@ DECLARE_ZONE_PARSER(endzone) { DECLARE_ZONE_PARSER(limits) { debugC(7, kDebugParser, "ZONE_PARSER(limits) "); - - ctxt.z->_left = atoi(_tokens[1]); - ctxt.z->_top = atoi(_tokens[2]); - ctxt.z->_right = atoi(_tokens[3]); - ctxt.z->_bottom = atoi(_tokens[4]); + ctxt.z->setBox(atoi(_tokens[1]), atoi(_tokens[2]), atoi(_tokens[3]), atoi(_tokens[4])); } @@ -1404,8 +1400,8 @@ void LocationParser_ns::parseGetData(ZonePtr z) { GfxObj *obj = _vm->_gfx->loadGet(_tokens[1]); obj->frame = 0; - obj->x = z->_left; - obj->y = z->_top; + obj->x = z->getX(); + obj->y = z->getY(); _vm->_gfx->showGfxObj(obj, visible); data->gfxobj = obj; @@ -1467,8 +1463,8 @@ void LocationParser_ns::parseDoorData(ZonePtr z) { GfxObj *obj = _vm->_gfx->loadDoor(_tokens[1]); obj->frame = frame; - obj->x = z->_left; - obj->y = z->_top; + obj->x = z->getX(); + obj->y = z->getY(); _vm->_gfx->showGfxObj(obj, true); data->gfxobj = obj; diff --git a/engines/parallaction/saveload.cpp b/engines/parallaction/saveload.cpp index c07d976a3c..25cf3c8cf0 100644 --- a/engines/parallaction/saveload.cpp +++ b/engines/parallaction/saveload.cpp @@ -207,9 +207,9 @@ void Parallaction_ns::doSaveGame(uint16 slot, const char* name) { sprintf(s, "%s\n", _saveData1); f->writeString(s); - sprintf(s, "%d\n", _char._ani->_left); + sprintf(s, "%d\n", _char._ani->getX()); f->writeString(s); - sprintf(s, "%d\n", _char._ani->_top); + sprintf(s, "%d\n", _char._ani->getY()); f->writeString(s); sprintf(s, "%d\n", _score); f->writeString(s); diff --git a/engines/parallaction/walk.cpp b/engines/parallaction/walk.cpp index bf8f423fd5..5fd67d26dc 100644 --- a/engines/parallaction/walk.cpp +++ b/engines/parallaction/walk.cpp @@ -479,7 +479,7 @@ void PathWalker_BR::finalizeWalk() { _char.setFoot(foot); #endif - _ch->_ani->_frame = _dirFrame; // temporary solution + _ch->_ani->setF(_dirFrame); // temporary solution #if 0 // TODO: support scrolling ;) @@ -515,7 +515,7 @@ void PathWalker_BR::walk() { GfxObj *obj = _ch->_ani->gfxobj; Common::Rect rect; - obj->getRect(_ch->_ani->_frame, rect); + obj->getRect(_ch->_ani->getF(), rect); uint scale; if (rect.bottom > _vm->_location._zeta0) { @@ -609,11 +609,11 @@ void PathWalker_BR::walk() { if (_fieldC) { debugC(9, kDebugWalk, "PathWalker_BR::walk, foot moved from (%i, %i) to (%i, %i)\n", _startFoot.x, _startFoot.y, newpos.x, newpos.y); - _ch->_ani->_frame = walkFrame + _dirFrame + 1; + _ch->_ani->setF(walkFrame + _dirFrame + 1); _startFoot.x = newpos.x; _startFoot.y = newpos.y; _ch->setFoot(_startFoot); - _ch->_ani->_z = newpos.y; + _ch->_ani->setZ(newpos.y); } if (_fieldC || !_ch->_walkPath.empty()) { |