[Scummvm-cvs-logs] SF.net SVN: scummvm: [32785] scummvm/trunk/engines/cine

buddha_ at users.sourceforge.net buddha_ at users.sourceforge.net
Wed Jun 25 17:09:24 CEST 2008


Revision: 32785
          http://scummvm.svn.sourceforge.net/scummvm/?rev=32785&view=rev
Author:   buddha_
Date:     2008-06-25 08:09:24 -0700 (Wed, 25 Jun 2008)

Log Message:
-----------
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?

Modified Paths:
--------------
    scummvm/trunk/engines/cine/object.cpp
    scummvm/trunk/engines/cine/object.h
    scummvm/trunk/engines/cine/script_os.cpp

Modified: scummvm/trunk/engines/cine/object.cpp
===================================================================
--- scummvm/trunk/engines/cine/object.cpp	2008-06-25 14:19:56 UTC (rev 32784)
+++ scummvm/trunk/engines/cine/object.cpp	2008-06-25 15:09:24 UTC (rev 32785)
@@ -219,6 +219,29 @@
 	}
 }
 
+/**
+ * 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);

Modified: scummvm/trunk/engines/cine/object.h
===================================================================
--- scummvm/trunk/engines/cine/object.h	2008-06-25 14:19:56 UTC (rev 32784)
+++ scummvm/trunk/engines/cine/object.h	2008-06-25 15:09:24 UTC (rev 32785)
@@ -69,6 +69,8 @@
 
 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

Modified: scummvm/trunk/engines/cine/script_os.cpp
===================================================================
--- scummvm/trunk/engines/cine/script_os.cpp	2008-06-25 14:19:56 UTC (rev 32784)
+++ scummvm/trunk/engines/cine/script_os.cpp	2008-06-25 15:09:24 UTC (rev 32785)
@@ -596,16 +596,17 @@
 /*! \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;
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list