diff Render.cpp @ 2108:16f5a7ca289a

Merge
author Grumpy7
date Fri, 20 Dec 2013 01:28:39 +0100
parents 0db53678ff48
children 68fbaf45ef66
line wrap: on
line diff
--- a/Render.cpp	Fri Dec 20 01:25:52 2013 +0100
+++ b/Render.cpp	Fri Dec 20 01:28:39 2013 +0100
@@ -3561,16 +3561,11 @@
 }
 
 //----- (004A0BEE) --------------------------------------------------------
-char Render::RasterLine2D(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned __int16 uColor)
-{
-  unsigned int v8; // ebx@5
-  unsigned int v10; // ecx@9
-  unsigned int v11; // esi@13
-  int v12; // eax@17
-  int v13; // eax@21
-  int v16; // eax@27
-  signed __int64 v19; // qax@41
-  int v20; // edi@41
+void Render::RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor)
+{
+  signed int v12; // eax@17
+  //signed int v19; // qax@41
+  //int v20; // edi@41
   unsigned int v21; // edi@46
   int v22; // esi@47
   int v23; // ebx@47
@@ -3586,45 +3581,44 @@
   __int64 v36; // [sp+14h] [bp-8h]@1
   signed int v37; // [sp+18h] [bp-4h]@28
   unsigned int uXa; // [sp+24h] [bp+8h]@49
-  unsigned int uYa; // [sp+28h] [bp+Ch]@28
+  //unsigned int uYa; // [sp+28h] [bp+Ch]@28
   int uYb; // [sp+28h] [bp+Ch]@47
-  int uZa; // [sp+2Ch] [bp+10h]@38
+  //int uZa; // [sp+2Ch] [bp+10h]@38
+  bool left_border;
 
   v36 = 0i64;
-  if ( (signed int)uX < this->raster_clip_x )
-    HIDWORD(v36) = 8;
-  if ( (signed int)uX > this->raster_clip_z )
-    HIDWORD(v36) |= 4;
-
-  v8 = uY;
-  if ( (signed int)uY < this->raster_clip_y )
-    HIDWORD(v36) |= 2;
-  if ( (signed int)uY > this->raster_clip_w )
-    HIDWORD(v36) |= 1;
-
-  v10 = uZ;
-  if ( (signed int)uZ < this->raster_clip_x )
-    LODWORD(v36) = 8;
-  if ( (signed int)uZ > this->raster_clip_z )
-    LODWORD(v36) = v36 | 4;
-
-  v11 = uW;
-  if ( (signed int)uW < this->raster_clip_y )
-    LODWORD(v36) = v36 | 2;
-  if ( (signed int)uW > this->raster_clip_w )
-    LODWORD(v36) = v36 | 1;
-
-  LOBYTE(v12) = v36;
+  if ( uX < this->raster_clip_x )// x выходит за рамки левой границы
+    HIDWORD(v36) = 8; //left_border = true;
+  if ( uX > this->raster_clip_z )// x выходит за рамки правой границы
+    HIDWORD(v36) |= 4;//right_border = true;
+
+  if ( uZ < this->raster_clip_x )// z выходит за рамки левой границы
+    LODWORD(v36) = 8;//
+  if ( uZ > this->raster_clip_z )// z выходит за рамки правой границы
+    LODWORD(v36) |= 4;
+
+  if ( uY < this->raster_clip_y )// y выходит за рамки верхней границы
+    HIDWORD(v36) |= 2;//upper_border = true;
+  if ( uY > this->raster_clip_w )// y выходит за рамки нижней границы
+    HIDWORD(v36) |= 1;//bottom_border = true;
+
+  if ( uW < this->raster_clip_y )// w выходит за рамки верхней границы
+    LODWORD(v36) |= 2;
+  if ( uW > this->raster_clip_w )// w выходит за рамки нижней границы
+    LODWORD(v36) |= 1;
+
+  //LOBYTE(v12) = v36;
   if ( (unsigned int)v36 & HIDWORD(v36) )
-    return v12;
-  if ( !v36 )
+    return;
+
+  if ( !v36 ) //полностью в рамках
   {
 LABEL_46:
     v21 = pRenderer->uTargetSurfacePitch;
     if ( pRenderer->uTargetSurfacePitch )
     {
       v12 = uX + uY * pRenderer->uTargetSurfacePitch;
-      v22 = v11 - v8;
+      v22 = uW - uY;
       v23 = v22;
       uYb = v22;
       if ( v22 < 0 )
@@ -3633,7 +3627,7 @@
         uYb = -v22;
         v21 = -pRenderer->uTargetSurfacePitch;
       }
-      uXa = v10 - uX;
+      uXa = uZ - uX;
       if ( (uXa & 0x80000000u) == 0 )
       {
         v24 = 1;
@@ -3646,8 +3640,6 @@
       v25 = 0;
 
       v26 = (unsigned __int16 *)this->pTargetSurface;
-      int y = 0;
-      int x = 0;
       if ( v26 )
       {
         if ( (signed int)uXa <= v23 )//рисуем вертикальную линию
@@ -3658,6 +3650,8 @@
             v31 = 2 * v24;
             v32 = 2 * v21;
             v12 = (int)&v26[v12];
+            int y = 0;
+            int x = 0;
             for ( v30; v30; --v30 )
             {
               v25 += uXa;
@@ -3683,11 +3677,12 @@
         else//рисуем горизонтальную линию
         {
           v27 = uXa + 1;
-          int x = 0;
           if ( (signed int)(uXa + 1) > 0 )
           {
             v28 = 2 * v21;
             v29 = 2 * v24;
+            int y = 0;
+            int x = 0;
             v12 = (int)&v26[v12];
             for ( v27; v27; --v27 )
             {
@@ -3713,87 +3708,80 @@
         }
       }
     }
-    return v12;
-  }
-  if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 )
-  {
-    if ( BYTE4(v36) & 8 )
-    {
-      v13 = (signed int)((uW - uY) * (this->raster_clip_x - uX)) / (signed int)(uZ - uX);
-      v8 = v13 + uY;
+    return;
+  }
+
+  if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 )//левая и 
+  {
+    if ( BYTE4(v36) & 8 )//left_border = true;
+    {
+      uY += ((uW - uY) * (this->raster_clip_x - uX)) / (uZ - uX);
       uX = this->raster_clip_x;
-      goto LABEL_24;
-    }
-    v10 = this->raster_clip_x;
-    v11 = (signed int)((uY - uW) * (this->raster_clip_x - uZ)) / (signed int)(uX - uZ) + uW;
-  }
-LABEL_24:
+    }
+    else
+    {
+      uZ = this->raster_clip_x;
+      uW += ((uY - uW) * (this->raster_clip_x - uZ)) / (uX - uZ);
+    }
+  }
   if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 )
   {
-    //v15 = this->raster_clip_z;
-    if ( BYTE4(v36) & 4 )
-    {
-      v8 += (signed int)((v11 - v8) * (this->raster_clip_z - uX)) / (signed int)(v10 - uX);
+    if ( BYTE4(v36) & 4 ) //right_border = true
+    {
+      uY += ((uW - uY) * (this->raster_clip_z - uX)) / (uZ - uX);
       uX = this->raster_clip_z;
     }
     else
     {
-      v16 = (signed int)((v8 - v11) * (this->raster_clip_z - v10)) / (signed int)(uX - v10);
-      v10 = this->raster_clip_z;
-      v11 += v16;
+      uW += ((uY - uW) * (this->raster_clip_z - uZ)) / (uX - uZ);
+      uY = this->raster_clip_z;
     }
   }
   v37 = 0;
-  uYa = this->raster_clip_y;
-  if ( (signed int)v8 < this->raster_clip_y )
+  if ( uY < this->raster_clip_y )
     v37 = 2;
-  if ( (signed int)v8 > this->raster_clip_w )
+  if ( uY > this->raster_clip_w )
     v37 |= 1;
-  if ( (signed int)v11 >= this->raster_clip_y )
+
+  if ( uW >= this->raster_clip_y )
     v12 = 0;
   else
     v12 = 2;
-  if ( (signed int)v11 > this->raster_clip_w )
-    LOBYTE(v12) = v12 | 1;
+  if ( uW > this->raster_clip_w )
+    v12 |= 1;
+
   if ( !(v12 & v37) )
   {
     v12 ^= v37;
-    uZa = v12;
     if ( v12 & 2 )
     {
       if ( v37 & 2 )
       {
-        uX += (signed int)((v10 - uX) * (uYa - v8)) / (signed int)(v11 - v8);
-        LOBYTE(v12) = (char)this;
-        v8 = this->raster_clip_y;
+        uX += ((uZ - uX) * (this->raster_clip_y - uY)) / (uW - uY);
+        uY = this->raster_clip_y;
       }
       else
       {
-        v19 = (signed int)((uX - v10) * (uYa - v11));
-        v20 = v8 - v11;
-        v11 = uYa;
-        v12 = v19 / v20;
-        v10 += v12;
-      }
-    }
-    if ( uZa & 1 )
+        uZ += (uX - uZ) * (this->raster_clip_y - uW) / (uY - uW);
+        uW = this->raster_clip_y;
+      }
+    }
+    if ( v12 & 1 )
     {
       if ( v37 & 1 )
       {
-        uX += (signed int)((v10 - uX) * (this->raster_clip_w - v8)) / (signed int)(v11 - v8);
-        LOBYTE(v12) = (char)this;
-        v8 = this->raster_clip_w;
+        uX += ((uZ - uX) * (this->raster_clip_w - uY)) / (uW - uY);
+        uY = this->raster_clip_w;
       }
       else
       {
-        v12 = (signed int)((uX - v10) * (this->raster_clip_w - v11)) / (signed int)(v8 - v11);
-        v11 = this->raster_clip_w;
-        v10 += v12;
+        uZ += ((uX - uZ) * (this->raster_clip_w - uW)) / (uY - uW);
+        uW = this->raster_clip_w;
       }
     }
     goto LABEL_46;
   }
-  return v12;
+  return;
 }
 
 //----- (004A0E80) --------------------------------------------------------
@@ -7838,7 +7826,7 @@
               {
                   if ( *v28 )
                   {
-                    v20 = *(&a5->pLevelOfDetail0_prolly_alpha_mask[i & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1));
+                    v20 = *(&a5->pLevelOfDetail0_prolly_alpha_mask[x & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1));
                     if ( v20 >= a7 )
                     {
                       if ( v20 <= a8 )