diff options
-rw-r--r-- | actor.cpp | 25 | ||||
-rw-r--r-- | boxes.cpp | 50 | ||||
-rw-r--r-- | boxes.h | 10 | ||||
-rw-r--r-- | script_v1.cpp | 6 |
4 files changed, 51 insertions, 40 deletions
@@ -199,12 +199,12 @@ int Actor::remapDirection(int dir) flipY = (walkdata.YXFactor > 0); // Check for X-Flip - if ((flags & 0x08) || isInClass(30)) { + if ((flags & kBoxXFlip) || isInClass(30)) { dir = 360 - dir; flipX = !flipX; } // Check for Y-Flip - if ((flags & 0x10) || isInClass(29)) { + if ((flags & kBoxYFlip) || isInClass(29)) { dir = 180 - dir; flipY = !flipY; } @@ -348,7 +348,7 @@ void Actor::setupActorScale() if (ignoreBoxes != 0) return; - if (_vm->getBoxFlags(walkbox) & 0x20) + if (_vm->getBoxFlags(walkbox) & kBoxPlayerOnly) return; scale = _vm->getBoxScale(walkbox); @@ -587,22 +587,29 @@ AdjustBoxResult Actor::adjustXYToBeInBox(int dstX, int dstY, int pathfrom) if (!(_vm->_features & GF_OLD256) || box) for (j = box; j >= firstValidBox; j--) { + flags = _vm->getBoxFlags(j); + + if (flags & kBoxLocked && (!(flags & kBoxPlayerOnly))) + continue; + + if (flags & kBoxInvisible && (!(flags & kBoxPlayerOnly) || isInClass(31))) + continue; + if (pathfrom >= firstValidBox) { - flags = _vm->getBoxFlags(j); - if (flags & 0x80 && (!(flags & 0x20) || isInClass(31))) - continue; - + i = _vm->getPathToDestBox(pathfrom, j); if (i == -1) continue; - + if (_vm->_features & GF_OLD256) { // FIXME - we check here if the box suggested by getPathToDestBox // is locked or not. This prevents us from walking thru // closed doors in some cases in Zak256. However a better fix // would be to recompute the box matrix whenever flags change. flags = _vm->getBoxFlags(i); - if (flags & 0x80 && (!(flags & 0x20) || isInClass(31))) + if (flags & kBoxLocked && (!(flags & kBoxPlayerOnly))) + continue; + if (flags & kBoxInvisible && (!(flags & kBoxPlayerOnly) || isInClass(31))) continue; } } @@ -54,6 +54,8 @@ struct PathVertex { /* Linked list of walkpath nodes */ PathNode *right; }; +#define BOX_MATRIX_SIZE 2000 + PathVertex *unkMatrixProc1(PathVertex *vtx, PathNode *node); @@ -67,6 +69,20 @@ byte Scumm::getMaskFromBox(int box) return ptr->mask; } +void Scumm::setBoxFlags(int box, int val) +{ + debug(1, "setBoxFlags(%d, 0x%02x)", box, val); + + /* FULL_THROTTLE stuff */ + if (val & 0xC000) { + assert(box >= 0 && box < 65); + _extraBoxFlags[box] = val; + } else { + Box *b = getBoxBaseAddr(box); + b->flags = val; + } +} + byte Scumm::getBoxFlags(int box) { Box *ptr = getBoxBaseAddr(box); @@ -75,6 +91,12 @@ byte Scumm::getBoxFlags(int box) return ptr->flags; } +void Scumm::setBoxScale(int box, int scale) +{ + Box *b = getBoxBaseAddr(box); + b->scale = scale; +} + int Scumm::getBoxScale(int box) { if (_features & GF_NO_SCALLING) @@ -119,7 +141,7 @@ int Scumm::getSpecialBox(int param1, int param2) for (i = numOfBoxes; i >= 0; i--) { flag = getBoxFlags(i); - if (!(flag & 0x80) && (flag & 0x20)) + if (!(flag & kBoxInvisible) && (flag & kBoxPlayerOnly)) return (-1); if (checkXYInBoxBounds(i, param1, param2)) @@ -541,26 +563,6 @@ bool Scumm::findPathTowards(Actor *a, byte box1nr, byte box2nr, byte box3nr, int return false; } -void Scumm::setBoxFlags(int box, int val) -{ - /* FULL_THROTTLE stuff */ - if (val & 0xC000) { - assert(box >= 0 && box < 65); - _extraBoxFlags[box] = val; - } else { - Box *b = getBoxBaseAddr(box); - b->flags = val; - } -} - -void Scumm::setBoxScale(int box, int scale) -{ - Box *b = getBoxBaseAddr(box); - b->scale = scale; -} - -#define BOX_MATRIX_SIZE 2000 - void Scumm::createBoxMatrix() { byte *matrix_ptr; @@ -603,7 +605,7 @@ void Scumm::createBoxMatrix() for (j = 0; j < num; j++) { flags = getBoxFlags(j); - if (flags & 0x80) { + if (flags & kBoxInvisible) { addToBoxMatrix(0xFF); addToBoxMatrix(j); addToBoxMatrix(j); @@ -612,7 +614,7 @@ void Scumm::createBoxMatrix() vtx = addPathVertex(); for (i = 0; i < num; i++) { flags = getBoxFlags(j); - if (!(flags & 0x80)) { + if (!(flags & kBoxInvisible)) { node = unkMatrixProc2(vtx, i); if (i == j) node2 = node; @@ -752,7 +754,7 @@ bool Scumm::areBoxesNeighbours(int box1nr, int box2nr) BoxCoords box; BoxCoords box2; - if (getBoxFlags(box1nr) & 0x80 || getBoxFlags(box2nr) & 0x80) + if (getBoxFlags(box1nr) & kBoxInvisible || getBoxFlags(box2nr) & kBoxInvisible) return false; getBoxCoordinates(box1nr, &box2); @@ -25,8 +25,16 @@ #define SIZEOF_BOX 20 +typedef enum { + kBoxXFlip = 0x08, + kBoxYFlip = 0x10, + kBoxPlayerOnly = 0x20, + kBoxLocked = 0x40, + kBoxInvisible = 0x80, +} BoxFlags; + struct AdjustBoxResult { /* Result type of AdjustBox functions */ - int16 x,y; + int16 x, y; uint16 dist; }; diff --git a/script_v1.cpp b/script_v1.cpp index a06556f9e1..172fef7844 100644 --- a/script_v1.cpp +++ b/script_v1.cpp @@ -1608,12 +1608,6 @@ void Scumm::o5_matrixOps() if (_features & GF_OLD256) { a = getVarOrDirectByte(0x80); b = fetchScriptByte(); - - if (b & 0x40) { // We don't use the locked - b &= ~0x40; // flag, so convert it to - b |= 0x80; // invisible - } - setBoxFlags(a, b); return; } |