[Scummvm-cvs-logs] CVS: scummvm/scumm script_v80he.cpp,2.110,2.111

Max Horn fingolfin at users.sourceforge.net
Tue May 10 07:03:41 CEST 2005


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17433

Modified Files:
	script_v80he.cpp 
Log Message:
Cleaned up code a bit

Index: script_v80he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v80he.cpp,v
retrieving revision 2.110
retrieving revision 2.111
diff -u -d -r2.110 -r2.111
--- script_v80he.cpp	10 May 2005 11:50:01 -0000	2.110
+++ script_v80he.cpp	10 May 2005 14:00:59 -0000	2.111
@@ -613,118 +613,104 @@
 	displayWizImage(&wi);	
 }
 
-void ScummEngine_v80he::drawLine(int x1, int y1, int x, int y, int unk2, int type, int id) {
-	debug(0,"drawLine: x1 %d y1 %d x %d y %d, unk2 %d type %d id %d", x1, y1, x, y, unk2, type, id);	
-
-	int eax, ebx, ecx, edp, esi, edx;
-	int var_C;
-
-	ebx = 0;
-	var_C = 0;
+/**
+ * Draw a 'line' between two points.
+ *
+ * @param x1	the starting x coordinate
+ * @param y1	the starting y coordinate
+ * @param x		the ending x coordinate
+ * @param y		the ending y coordinate
+ * @param step	the step size used to render the line, only ever 'step'th point is drawn
+ * @param type	the line type -- points are rendered by drawing actors (type == 2),
+ *              wiz images (type == 3), or pixels (any other type)
+ * @param id	the (optional) id of an actor or wizimage
+ */
+void ScummEngine_v80he::drawLine(int x1, int y1, int x, int y, int step, int type, int id) {
+	debug(0,"drawLine: x1 %d y1 %d x %d y %d, step %d type %d id %d", x1, y1, x, y, step, type, id);	
 
-	if (unk2 < 0) {
-		unk2 = -unk2;
+	if (step < 0) {
+		step = -step;
 	}
-	if (unk2 == 0) {
-		unk2 = 1;
+	if (step == 0) {
+		step = 1;
 	}
 
-	eax = x;
-	ecx = x1;
-	int edi = y1;
-
 	const int dx = x - x1;
 	const int dy = y - y1;
 
-	edp = ABS(dx);
-	eax = ABS(dy);
+	const int absDX = ABS(dx);
+	const int absDY = ABS(dy);
 
-	if (eax > edp) {
-		esi = eax;
-	} else {
-		esi = edp;
-	}
+	const int maxDist = MAX(absDX, absDY);
 
-	y1 = eax;
+	y = y1;
 	x = x1;
-	x1 = 0;
+
+	const int tmpA = absDY;
+	int tmbB = 0;
 
 	if (type == 2) {
 		Actor *a = derefActor(id, "drawLine");
-		a->drawActorToBackBuf(ecx, edi);
+		a->drawActorToBackBuf(x, y);
 	} else if (type == 3) {
 		WizImage wi;
 		wi.flags = 0;
-		wi.y1 = edi;
-		wi.x1 = ecx;
+		wi.y1 = y;
+		wi.x1 = x;
 		wi.resNum = id;
 		wi.state = 0;
 		displayWizImage(&wi);
 	} else {
-		drawPixel(ecx, edi, id);
+		drawPixel(x, y, id);
 	}
 
-	for (int i = 0; i <= esi; i++) {
-		ecx = x1;
-		eax = y1;	
-		ebx += edp;
-		ecx += eax;
-
-		eax ^= eax;
-		x1 = ecx;
+	int var_C = 0;
+	int ebx = 0;
+	for (int i = 0; i <= maxDist; i++) {
+		ebx += absDX;
+		tmbB += tmpA;
 
-		if (ebx > esi) {
-			edx = dx;
-			edx -= esi;
+		int eax = 0;
 
+		if (ebx > maxDist) {
 			eax = 1;
-			int tmp = edx;
-			edx = x;
-			if (tmp >= 0) {
-				edx++;
+			if (dx >= maxDist) {
+				x++;
 			} else {
-				edx--;
+				x--;
 			}
-
-			x = edx;
 		}
-		if (ecx > esi) {
+		if (tmbB > maxDist) {
 			eax = dy;
-			ecx -= esi;
+			tmbB -= maxDist;
 
-			x1 = ecx;
-			if (eax >= 0) {
-				edi++;
+			if (dy >= 0) {
+				y++;
 			} else {
-				edi--;
+				y--;
 			}
 		}
 
 		if (eax == 0)
 			continue;
 
-		ecx = var_C;
-		eax = ecx;
-		edx = eax % unk2;
-		ecx++;
-		var_C = ecx;
-
-		if (edx != 0 && esi != i)
+		var_C++;
+		if (((var_C - 1) % step) != 0 && maxDist != i)
 			continue;
 
 		if (type == 2) {
 			Actor *a = derefActor(id, "drawLine");
-			a->drawActorToBackBuf(x, edi);
+			a->drawActorToBackBuf(x, y);
 		} else if (type == 3) {
 			WizImage wi;
 			wi.flags = 0;
-			wi.y1 = edi;
+			wi.y1 = y;
 			wi.x1 = x;
 			wi.resNum = id;
 			wi.state = 0;
 			displayWizImage(&wi);
 		} else {
-			drawPixel(x, edi, id);
+			drawPixel(x, y, id);
 		}
 	}		
 }
@@ -763,9 +749,9 @@
 }
 
 void ScummEngine_v80he::o80_drawLine() {
-	int id, unk2, x, y, x1, y1;
+	int id, step, x, y, x1, y1;
 
-	unk2 = pop();
+	step = pop();
 	id = pop();
 	y = pop();
 	x = pop();
@@ -776,13 +762,13 @@
 
 	switch (subOp) {
 	case 55:
-		drawLine(x1, y1, x, y, unk2, 2, id);
+		drawLine(x1, y1, x, y, step, 2, id);
 		break;
 	case 63:
-		drawLine(x1, y1, x, y, unk2, 3, id);
+		drawLine(x1, y1, x, y, step, 3, id);
 		break;
 	case 66:
-		drawLine(x1, y1, x, y, unk2, 1, id);
+		drawLine(x1, y1, x, y, step, 1, id);
 		break;
 	default:
 		error("o80_drawLine: default case %d", subOp);





More information about the Scummvm-git-logs mailing list