105Close107
PpHdOn the 2009-07-28 at 09:57pm
Patch:
--- a/src/c/clipline.c
+++ b/src/c/clipline.c
@@ -55,7 +55,7 @@ typedef union {
         swap(y1,y2);                                                    \
         dx = -dx;                                                       \
       }                                                                 \
-    if ((x1 > Clip.Right) || (x2 < Clip.Left) || (y1 > Clip.Down) || (y2 < Clip.Up)) \
+    if ((x1 > Clip.Right) || (x2 < Clip.Left) || (y1 > Clip.Down && y2 > Clip.Down ) || (y2 < Clip.Up && y1 < Clip.Up)) \
       return;                                                           \
     dy = y2 - y1;                                                       \
     if (dx == 0)                                                        \
@@ -111,42 +111,41 @@ typedef union {
           }                                                             \
       }                                                                 \
     else       {                                                       \
-      dy = - dy;                                                        \
       if (x1 < Clip.Left)                                               \
         {                                                               \
-          if ((y1 > Clip.Down) && ((t = x1 + dx *(y1-Clip.Down)/dy) >= Clip.Left)) \
+          if ((y1 > Clip.Down) && ((t = x1 + dx *(Clip.Down-y1)/dy) >= Clip.Left)) \
             {                                                           \
               x1 = t;                                                   \
               y1 = Clip.Down;                                           \
               if (x1 > Clip.Right) return;                              \
             }                                                           \
           else {                                                       \
-            y1 += dy * (Clip.Left-x1) / dx;                             \
+            y1 = y1 + dy * (Clip.Left-x1) / dx;                         \
             x1 = Clip.Left;                                             \
             if (y1 < Clip.Up) return;                                   \
           }                                                             \
         }                                                               \
       else if (y1 > Clip.Down)                                          \
         {                                                               \
-          x1 += dx * (y1-Clip.Down) / dy;                               \
+          x1 = x1 + dx * (Clip.Down-y1) / dy;                           \
           y1 = Clip.Down;                                               \
           if (x1 > Clip.Right) return;                                  \
         }                                                               \
       if (x2 > Clip.Right)                                              \
         {                                                               \
-          if ((y2 < Clip.Up) && ((t = x2 - dx*(Clip.Up-y2)/dy) <= Clip.Right)) \
+          if ((y2 < Clip.Up) && ((t = x2 + dx*(Clip.Up-y2)/dy) <= Clip.Right)) \
             {                                                           \
               x2 = t;                                                   \
               y2 = Clip.Up;                                             \
             }                                                           \
           else {                                                       \
-            y2 -= dy * (x2-Clip.Right) / dx;                            \
+            y2 = y2 + dy * (Clip.Right-x2) / dx;                        \
             x2 = Clip.Right;                                            \
           }                                                             \
         }                                                               \
       else if (y2 < Clip.Up)                                            \
         {                                                               \
-          x2 -= dx * (Clip.Up-y2) / dy;                                 \
+          x2 = x2 + dx * (Clip.Up-y2) / dy;                             \
           y2 = Clip.Up;                                                 \
         }                                                               \
     }                                                                   \
@@ -165,5 +164,7 @@ void DrawClipLine (const WIN_RECT *Line, const SCR_RECT *clip, short Attr)
   Clip.Right = clip->xy.x1;
   Clip.Down = clip->xy.y1;
   ClipLine(x1, y1, x2, y2);
+  //if (x1 < 0 || x2 >239 || y1 < 0 || y1 > 127 || y2 < 0 || y2 > 127)
+  //  asm ("toto: bra toto\n");
   DrawLine(x1,y1,x2,y2,Attr);
 }