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/object.cpp | |
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/object.cpp')
-rw-r--r-- | engines/cine/object.cpp | 23 |
1 files changed, 23 insertions, 0 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); |