diff --git a/src/devctxt.c b/src/devctxt.c index ed6f0ed..6c7bfe9 100755 --- a/src/devctxt.c +++ b/src/devctxt.c @@ -21,7 +21,7 @@ inline static BYTE line_clip_outcode(INT32 x, INT32 y, INT32 xmin, INT32 ymin, I static BOOL line_clip(PINT32 output, INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 xmin, INT32 ymin, INT32 xmax, INT32 ymax) { - BYTE outcode1, outcode2, tmpb; + BYTE outcode1, outcode2; INT32 tmp; Log(LDEBUG, "clipping line from (%d, %d) to (%d, %d) against bounding box (%d, %d, %d, %d)", x1 >> 16, y1 >> 16, x2 >> 16, y2 >> 16, @@ -51,9 +51,7 @@ static BOOL line_clip(PINT32 output, INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT tmp = y1; y1 = y2; y2 = tmp; - tmpb = outcode1; - outcode1 = outcode2; - outcode2 = tmpb; + outcode1 = outcode2; /* we don't reference outcode2 in the rest of the loop */ } if (outcode1 & 0x8) { @@ -78,6 +76,10 @@ static BOOL line_clip(PINT32 output, INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT } else if (outcode1 & 0x1) { + int term1 = y2 - y1; + int term2 = xmin - x1; + int term3 = x2 - x1; + Log(LDEBUG, "term1=%d term2=%d term3=%d", term1 >> 16, term2 >> 16, term3 >> 16); tmp = (y2 - y1) * ((xmin - x1) / (x2 - x1)); y1 -= tmp; x1 = xmin;