aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2007-12-06 12:46:29 +0000
committerEugene Sandulenko2007-12-06 12:46:29 +0000
commit99acbe79af5603e86a0b2fc925520fa6dc3c890b (patch)
tree51dc33474a6e92c116074c906af760c99b6343bf
parent218dcf2c18cc0b0e88b83cd230ea6640a6c8ff1b (diff)
downloadscummvm-rg350-99acbe79af5603e86a0b2fc925520fa6dc3c890b.tar.gz
scummvm-rg350-99acbe79af5603e86a0b2fc925520fa6dc3c890b.tar.bz2
scummvm-rg350-99acbe79af5603e86a0b2fc925520fa6dc3c890b.zip
Move AGI engine back to custom line drawing routine as it caused regressions
svn-id: r29735
-rw-r--r--engines/agi/picture.cpp89
1 files changed, 89 insertions, 0 deletions
diff --git a/engines/agi/picture.cpp b/engines/agi/picture.cpp
index 30e7435908..4eaabdf7aa 100644
--- a/engines/agi/picture.cpp
+++ b/engines/agi/picture.cpp
@@ -68,6 +68,15 @@ static void drawProc(int x, int y, int c, void *data) {
((PictureMgr *)data)->putVirtPixel(x, y);
}
+/**
+ * Draw an AGI line.
+ * A line drawing routine sent by Joshua Neal, modified by Stuart George
+ * (fixed >>2 to >>1 and some other bugs like x1 instead of y1, etc.)
+ * @param x1 x coordinate of start point
+ * @param y1 y coordinate of start point
+ * @param x2 x coordinate of end point
+ * @param y2 y coordinate of end point
+ */
void PictureMgr::drawLine(int x1, int y1, int x2, int y2) {
/* CM: Do clipping */
#define clip(x, y) if ((x)>=(y)) (x)=(y)
@@ -76,7 +85,87 @@ void PictureMgr::drawLine(int x1, int y1, int x2, int y2) {
clip(y1, _height - 1);
clip(y2, _height - 1);
+#if 0
Graphics::drawLine(x1, y1, x2, y2, 0, drawProc, this);
+#else
+ int i, x, y, deltaX, deltaY, stepX, stepY, errorX, errorY, detdelta;
+
+ /* Vertical line */
+
+ if (x1 == x2) {
+ if (y1 > y2) {
+ y = y1;
+ y1 = y2;
+ y2 = y;
+ }
+
+ for (; y1 <= y2; y1++)
+ putVirtPixel(x1, y1);
+
+ return;
+ }
+
+ /* Horizontal line */
+
+ if (y1 == y2) {
+ if (x1 > x2) {
+ x = x1;
+ x1 = x2;
+ x2 = x;
+ }
+ for (; x1 <= x2; x1++)
+ putVirtPixel(x1, y1);
+ return;
+ }
+
+ y = y1;
+ x = x1;
+
+ stepY = 1;
+ deltaY = y2 - y1;
+ if (deltaY < 0) {
+ stepY = -1;
+ deltaY = -deltaY;
+ }
+
+ stepX = 1;
+ deltaX = x2 - x1;
+ if (deltaX < 0) {
+ stepX = -1;
+ deltaX = -deltaX;
+ }
+
+ if (deltaY > deltaX) {
+ i = deltaY;
+ detdelta = deltaY;
+ errorX = deltaY / 2;
+ errorY = 0;
+ } else {
+ i = deltaX;
+ detdelta = deltaX;
+ errorX = 0;
+ errorY = deltaX / 2;
+ }
+
+ putVirtPixel(x, y);
+
+ do {
+ errorY += deltaY;
+ if (errorY >= detdelta) {
+ errorY -= detdelta;
+ y += stepY;
+ }
+
+ errorX += deltaX;
+ if (errorX >= detdelta) {
+ errorX -= detdelta;
+ x += stepX;
+ }
+
+ putVirtPixel(x, y);
+ i--;
+ } while (i > 0);
+#endif
}
/**