diff options
author | Kari Salminen | 2008-06-25 15:09:24 +0000 |
---|---|---|
committer | Kari Salminen | 2008-06-25 15:09:24 +0000 |
commit | a2e6f35310b7f4fc4f4a1aa6ca3d5e7ab618b85d (patch) | |
tree | e5a71b56b4f31a1b51c9dcbd234c6c11a1738145 /engines/cine | |
parent | ef07d7e8a770f9ecd85d0915782775481acfef92 (diff) | |
download | scummvm-rg350-a2e6f35310b7f4fc4f4a1aa6ca3d5e7ab618b85d.tar.gz scummvm-rg350-a2e6f35310b7f4fc4f4a1aa6ca3d5e7ab618b85d.tar.bz2 scummvm-rg350-a2e6f35310b7f4fc4f4a1aa6ca3d5e7ab618b85d.zip |
Implemented opcode:
- 0x8D: o2_op8D (Didn't come up with a descriptive name yet)
Compares ranges of x, y and mask parameters between two objects.
Possibly some kind of an intersection testing function?
svn-id: r32785
Diffstat (limited to 'engines/cine')
-rw-r--r-- | engines/cine/object.cpp | 23 | ||||
-rw-r--r-- | engines/cine/object.h | 2 | ||||
-rw-r--r-- | engines/cine/script_os.cpp | 21 |
3 files changed, 36 insertions, 10 deletions
diff --git a/engines/cine/object.cpp b/engines/cine/object.cpp index 96048f5214..b00a636ae6 100644 --- a/engines/cine/object.cpp +++ b/engines/cine/object.cpp @@ -219,6 +219,29 @@ void modifyObjectParam(byte objIdx, byte paramIdx, int16 newValue) { } } +/** + * Check if at least one of the range B's endpoints is inside range A, + * not counting the starting and ending points of range A. + * Used at least by Operation Stealth's opcode 0x8D i.e. 141. + */ +bool compareRanges(uint16 aStart, uint16 aEnd, uint16 bStart, uint16 bEnd) { + return (bStart > aStart && bStart < aEnd) || (bEnd > aStart && bEnd < aEnd); +} + +uint16 compareObjectParamRanges(uint16 objIdx1, uint16 xAdd1, uint16 yAdd1, uint16 maskAdd1, uint16 objIdx2, uint16 xAdd2, uint16 yAdd2, uint16 maskAdd2) { + assert(objIdx1 < NUM_MAX_OBJECT && objIdx2 < NUM_MAX_OBJECT); + const objectStruct &obj1 = objectTable[objIdx1]; + const objectStruct &obj2 = objectTable[objIdx2]; + + if (compareRanges(obj1.x, obj1.x + xAdd1, obj2.x, obj2.x + xAdd2) && + compareRanges(obj1.y, obj1.y + yAdd1, obj2.y, obj2.y + yAdd2) && + compareRanges(obj1.mask, obj1.mask + maskAdd1, obj2.mask, obj2.mask + maskAdd2)) { + return kCmpEQ; + } else { + return 0; + } +} + uint16 compareObjectParam(byte objIdx, byte type, int16 value) { uint16 compareResult = 0; int16 objectParam = getObjectParam(objIdx, type); diff --git a/engines/cine/object.h b/engines/cine/object.h index 6252a628cb..12e72927e1 100644 --- a/engines/cine/object.h +++ b/engines/cine/object.h @@ -69,6 +69,8 @@ int16 getObjectParam(uint16 objIdx, uint16 paramIdx); void addObjectParam(byte objIdx, byte paramIdx, int16 newValue); void subObjectParam(byte objIdx, byte paramIdx, int16 newValue); +bool compareRanges(uint16 aStart, uint16 aEnd, uint16 bStart, uint16 bEnd); +uint16 compareObjectParamRanges(uint16 objIdx1, uint16 xAdd1, uint16 yAdd1, uint16 maskAdd1, uint16 objIdx2, uint16 xAdd2, uint16 yAdd2, uint16 maskAdd2); uint16 compareObjectParam(byte objIdx, byte param1, int16 param2); } // End of namespace Cine diff --git a/engines/cine/script_os.cpp b/engines/cine/script_os.cpp index ffc0da5790..09ab5188a0 100644 --- a/engines/cine/script_os.cpp +++ b/engines/cine/script_os.cpp @@ -596,16 +596,17 @@ int FWScript::o2_stopObjectScript() { /*! \todo Implement this instruction */ int FWScript::o2_op8D() { - uint16 a = getNextWord(); - uint16 b = getNextWord(); - uint16 c = getNextWord(); - uint16 d = getNextWord(); - uint16 e = getNextWord(); - uint16 f = getNextWord(); - uint16 g = getNextWord(); - uint16 h = getNextWord(); - warning("STUB: o2_op8D(%x, %x, %x, %x, %x, %x, %x, %x)", a, b, c, d, e, f, g, h); - // _currentScriptElement->compareResult = ... + uint16 objIdx1 = getNextWord(); + uint16 xAdd1 = getNextWord(); + uint16 yAdd1 = getNextWord(); + uint16 maskAdd1 = getNextWord(); + uint16 objIdx2 = getNextWord(); + uint16 xAdd2 = getNextWord(); + uint16 yAdd2 = getNextWord(); + uint16 maskAdd2 = getNextWord(); + debugC(5, kCineDebugScript, "Line: %d: o2_op8D(%d, %d, %d, %d, %d, %d, %d, %d)", _line, objIdx1, xAdd1, yAdd1, maskAdd1, objIdx2, xAdd2, yAdd2, maskAdd2); + + _compare = compareObjectParamRanges(objIdx1, xAdd1, yAdd1, maskAdd1, objIdx2, xAdd2, yAdd2, maskAdd2); return 0; } |