[Scummvm-cvs-logs] SF.net SVN: scummvm: [24384] scummvm/trunk/engines/scumm

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Thu Oct 19 02:27:05 CEST 2006


Revision: 24384
          http://svn.sourceforge.net/scummvm/?rev=24384&view=rev
Author:   fingolfin
Date:     2006-10-18 17:26:55 -0700 (Wed, 18 Oct 2006)

Log Message:
-----------
SCUMM: Introduced V12_X_MULTIPLIER and V12_Y_MULTIPLIER to make it a bit easier to find spots where we convert between C64-style coordinates and pixel coordinates (but beware, this probably doesnt't cover all relevant instances)

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/actor.cpp
    scummvm/trunk/engines/scumm/actor.h
    scummvm/trunk/engines/scumm/boxes.cpp
    scummvm/trunk/engines/scumm/object.cpp
    scummvm/trunk/engines/scumm/script_v2.cpp
    scummvm/trunk/engines/scumm/script_v5.cpp

Modified: scummvm/trunk/engines/scumm/actor.cpp
===================================================================
--- scummvm/trunk/engines/scumm/actor.cpp	2006-10-19 00:06:59 UTC (rev 24383)
+++ scummvm/trunk/engines/scumm/actor.cpp	2006-10-19 00:26:55 UTC (rev 24384)
@@ -950,8 +950,8 @@
 			return abr;
 
 		bestDist = (_vm->_game.version >= 7) ? 0x7FFFFFFF : 0xFFFF;
-		if (_vm->_game.version <= 2)
-			bestDist *= 8*2;	// Adjust for the fact that we multiply x by 8 and y by 2
+		if (_vm->_game.version <= 2)	// Adjust for the fact that we multiply x by 8 and y by 2
+			bestDist *= V12_X_MULTIPLIER * V12_Y_MULTIPLIER;
 		bestBox = kInvalidBox;
 
 		// We iterate (backwards) over all boxes, searching the one closest

Modified: scummvm/trunk/engines/scumm/actor.h
===================================================================
--- scummvm/trunk/engines/scumm/actor.h	2006-10-19 00:06:59 UTC (rev 24383)
+++ scummvm/trunk/engines/scumm/actor.h	2006-10-19 00:26:55 UTC (rev 24384)
@@ -32,6 +32,12 @@
 
 namespace Scumm {
 
+
+enum {
+	V12_X_MULTIPLIER = 8,
+	V12_Y_MULTIPLIER = 2
+};
+
 enum MoveFlags {
 	MF_NEW_LEG = 1,
 	MF_IN_LEG = 2,

Modified: scummvm/trunk/engines/scumm/boxes.cpp
===================================================================
--- scummvm/trunk/engines/scumm/boxes.cpp	2006-10-19 00:06:59 UTC (rev 24383)
+++ scummvm/trunk/engines/scumm/boxes.cpp	2006-10-19 00:26:55 UTC (rev 24384)
@@ -596,25 +596,25 @@
 			SWAP(box->ll, box->lr);
 		}
 	} else if (_game.version == 0) {
-		box->ul.x = bp->c64.x1 * 8;
-		box->ul.y = bp->c64.y1 * 2;
-		box->ur.x = bp->c64.x2 * 8;
-		box->ur.y = bp->c64.y1 * 2;
+		box->ul.x = bp->c64.x1 * V12_X_MULTIPLIER;
+		box->ul.y = bp->c64.y1 * V12_Y_MULTIPLIER;
+		box->ur.x = bp->c64.x2 * V12_X_MULTIPLIER;
+		box->ur.y = bp->c64.y1 * V12_Y_MULTIPLIER;
 
-		box->ll.x = bp->c64.x1 * 8;
-		box->ll.y = bp->c64.y2 * 2;
-		box->lr.x = bp->c64.x2 * 8;
-		box->lr.y = bp->c64.y2 * 2;
+		box->ll.x = bp->c64.x1 * V12_X_MULTIPLIER;
+		box->ll.y = bp->c64.y2 * V12_Y_MULTIPLIER;
+		box->lr.x = bp->c64.x2 * V12_X_MULTIPLIER;
+		box->lr.y = bp->c64.y2 * V12_Y_MULTIPLIER;
 	} else if (_game.version <= 2) {
-		box->ul.x = bp->v2.ulx * 8;
-		box->ul.y = bp->v2.uy * 2;
-		box->ur.x = bp->v2.urx * 8;
-		box->ur.y = bp->v2.uy * 2;
+		box->ul.x = bp->v2.ulx * V12_X_MULTIPLIER;
+		box->ul.y = bp->v2.uy * V12_Y_MULTIPLIER;
+		box->ur.x = bp->v2.urx * V12_X_MULTIPLIER;
+		box->ur.y = bp->v2.uy * V12_Y_MULTIPLIER;
 
-		box->ll.x = bp->v2.llx * 8;
-		box->ll.y = bp->v2.ly * 2;
-		box->lr.x = bp->v2.lrx * 8;
-		box->lr.y = bp->v2.ly * 2;
+		box->ll.x = bp->v2.llx * V12_X_MULTIPLIER;
+		box->ll.y = bp->v2.ly * V12_Y_MULTIPLIER;
+		box->lr.x = bp->v2.lrx * V12_X_MULTIPLIER;
+		box->lr.y = bp->v2.ly * V12_Y_MULTIPLIER;
 	} else {
 		box->ul.x = (int16)READ_LE_UINT16(&bp->old.ulx);
 		box->ul.y = (int16)READ_LE_UINT16(&bp->old.uly);

Modified: scummvm/trunk/engines/scumm/object.cpp
===================================================================
--- scummvm/trunk/engines/scumm/object.cpp	2006-10-19 00:06:59 UTC (rev 24383)
+++ scummvm/trunk/engines/scumm/object.cpp	2006-10-19 00:26:55 UTC (rev 24384)
@@ -454,10 +454,10 @@
 		// For V1/V2 games, distances are measured in the original "character"
 		// based coordinate system, instead of pixels. Otherwise various scripts
 		// will break. See bugs #853874, #774529
-		x /= 8;
-		y /= 2;
-		x2 /= 8;
-		y2 /= 2;
+		x /= V12_X_MULTIPLIER;
+		y /= V12_Y_MULTIPLIER;
+		x2 /= V12_X_MULTIPLIER;
+		y2 /= V12_Y_MULTIPLIER;
 	}
 
 	return getDist(x, y, x2, y2);

Modified: scummvm/trunk/engines/scumm/script_v2.cpp
===================================================================
--- scummvm/trunk/engines/scumm/script_v2.cpp	2006-10-19 00:06:59 UTC (rev 24383)
+++ scummvm/trunk/engines/scumm/script_v2.cpp	2006-10-19 00:26:55 UTC (rev 24384)
@@ -818,6 +818,9 @@
 		break;
 
 	default: {	// New Verb
+		// FIXME: maybe use V12_X_MULTIPLIER here... maybe not. Depends
+		// on whether verbs can be handled separately from objects and
+		// actors or not when it comes to handling coordinates.
 		int x = fetchScriptByte() * 8;
 		int y = fetchScriptByte() * 8;
 		slot = getVarOrDirectByte(PARAM_1) + 1;
@@ -1130,8 +1133,8 @@
 
 	a = derefActor(act, "o2_walkActorTo");
 
-	x = getVarOrDirectByte(PARAM_2) * 8;
-	y = getVarOrDirectByte(PARAM_3) * 2;
+	x = getVarOrDirectByte(PARAM_2) * V12_X_MULTIPLIER;
+	y = getVarOrDirectByte(PARAM_3) * V12_Y_MULTIPLIER;
 
 	a->startWalkActor(x, y, -1);
 }
@@ -1143,8 +1146,8 @@
 
 	a = derefActor(act, "o2_putActor");
 
-	x = getVarOrDirectByte(PARAM_2) * 8;
-	y = getVarOrDirectByte(PARAM_3) * 2;
+	x = getVarOrDirectByte(PARAM_2) * V12_X_MULTIPLIER;
+	y = getVarOrDirectByte(PARAM_3) * V12_Y_MULTIPLIER;
 
 	if (_game.id == GID_MANIAC && _game.version <= 1 && _game.platform != Common::kPlatformNES)
 		a->setFacing(180);
@@ -1197,7 +1200,7 @@
 }
 
 void ScummEngine_v2::o2_panCameraTo() {
-	panCameraTo(getVarOrDirectByte(PARAM_1) * 8, 0);
+	panCameraTo(getVarOrDirectByte(PARAM_1) * V12_X_MULTIPLIER, 0);
 }
 
 void ScummEngine_v2::o2_walkActorToObject() {
@@ -1250,7 +1253,7 @@
 	getResultPos();
 	int act = getVarOrDirectByte(PARAM_1);
 	Actor *a = derefActor(act, "o2_getActorElevation");
-	setResult(a->getElevation() / 2);
+	setResult(a->getElevation() / V12_Y_MULTIPLIER);
 }
 
 void ScummEngine_v2::o2_setActorElevation() {
@@ -1258,22 +1261,22 @@
 	int elevation = (int8)getVarOrDirectByte(PARAM_2);
 
 	Actor *a = derefActor(act, "o2_setActorElevation");
-	a->setElevation(elevation * 2);
+	a->setElevation(elevation * V12_Y_MULTIPLIER);
 }
 
 void ScummEngine_v2::o2_actorFromPos() {
 	int x, y;
 	getResultPos();
-	x = getVarOrDirectByte(PARAM_1) * 8;
-	y = getVarOrDirectByte(PARAM_2) * 2;
+	x = getVarOrDirectByte(PARAM_1) * V12_X_MULTIPLIER;
+	y = getVarOrDirectByte(PARAM_2) * V12_Y_MULTIPLIER;
 	setResult(getActorFromPos(x, y));
 }
 
 void ScummEngine_v2::o2_findObject() {
 	int obj;
 	getResultPos();
-	int x = getVarOrDirectByte(PARAM_1) * 8;
-	int y = getVarOrDirectByte(PARAM_2) * 2;
+	int x = getVarOrDirectByte(PARAM_1) * V12_X_MULTIPLIER;
+	int y = getVarOrDirectByte(PARAM_2) * V12_Y_MULTIPLIER;
 	obj = findObject(x, y);
 	if (obj == 0 && (_game.platform == Common::kPlatformNES) && (_userState & 0x40)) {
 		if (_mouseOverBoxV2 >= 0 && _mouseOverBoxV2 < 4)
@@ -1287,7 +1290,7 @@
 	getResultPos();
 
 	a = getVarOrDirectByte(PARAM_1);
-	setResult(getObjX(a) / 8);
+	setResult(getObjX(a) / V12_X_MULTIPLIER);
 }
 
 void ScummEngine_v2::o2_getActorY() {
@@ -1295,7 +1298,7 @@
 	getResultPos();
 
 	a = getVarOrDirectByte(PARAM_1);
-	setResult(getObjY(a) / 2);
+	setResult(getObjY(a) / V12_Y_MULTIPLIER);
 }
 
 void ScummEngine_v2::o2_isGreater() {
@@ -1376,8 +1379,8 @@
 	a->putActor(0, 0, room);
 	_egoPositioned = false;
 
-	x = (int8)fetchScriptByte() * 8;
-	y = (int8)fetchScriptByte() * 2;
+	x = (int8)fetchScriptByte() * V12_X_MULTIPLIER;
+	y = (int8)fetchScriptByte() * V12_Y_MULTIPLIER;
 
 	startScene(a->_room, a, obj);
 
@@ -1428,7 +1431,7 @@
 }
 
 void ScummEngine_v2::o2_setCameraAt() {
-	setCameraAtEx(getVarOrDirectByte(PARAM_1) * 8);
+	setCameraAtEx(getVarOrDirectByte(PARAM_1) * V12_X_MULTIPLIER);
 }
 
 void ScummEngine_v2::o2_roomOps() {
@@ -1438,6 +1441,7 @@
 	_opcode = fetchScriptByte();
 	switch (_opcode & 0x1F) {
 	case 1:			// SO_ROOM_SCROLL
+		// FIXME: Use V12_X_MULTIPLIER... ?
 		a *= 8;
 		b *= 8;
 		if (a < (_screenWidth / 2))

Modified: scummvm/trunk/engines/scumm/script_v5.cpp
===================================================================
--- scummvm/trunk/engines/scumm/script_v5.cpp	2006-10-19 00:06:59 UTC (rev 24383)
+++ scummvm/trunk/engines/scumm/script_v5.cpp	2006-10-19 00:26:55 UTC (rev 24384)
@@ -1980,9 +1980,12 @@
 				int len = 256, cnt = 0;
 				ptr = (byte *)malloc(len);
 				while (ptr) {
-				  int r = file->read(ptr + cnt, len - cnt);
-				  if ((cnt += r) < len) break;
-				  ptr = (byte *)realloc(ptr, len *= 2);
+					int r = file->read(ptr + cnt, len - cnt);
+					cnt += r;
+					if (cnt < len)
+						break;
+					len *= 2;
+					ptr = (byte *)realloc(ptr, len);
 				}
 				ptr[cnt] = '\0';
 				loadPtrToResource(rtString, a, ptr);
@@ -2615,7 +2618,7 @@
 		return;
 
 	if (_game.version <= 2)
-		dist *= 8;
+		dist *= V12_X_MULTIPLIER;
 	else if (dist == 0xFF) {
 		dist = a->_scalex * a->_width / 0xFF;
 		dist += (a2->_scalex * a2->_width / 0xFF) / 2;


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