diff Render.cpp @ 2198:d9caf2b3d8d5

draw FlyAction and WaterWalk icons
author Ritor1
date Sun, 02 Feb 2014 00:10:40 +0600
parents d0e321190c86
children 3445abad44c5
line wrap: on
line diff
--- a/Render.cpp	Fri Jan 31 17:30:36 2014 +0600
+++ b/Render.cpp	Sun Feb 02 00:10:40 2014 +0600
@@ -3658,7 +3658,8 @@
 //----- (004A0BEE) --------------------------------------------------------
 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 lower_bound; // eax@17
+  signed int left_bound;
   //signed int v19; // qax@41
   //int v20; // edi@41
   unsigned int v21; // edi@46
@@ -3674,7 +3675,7 @@
   int v31; // edx@61
   int v32; // edi@61
   __int64 v36; // [sp+14h] [bp-8h]@1
-  signed int v37; // [sp+18h] [bp-4h]@28
+  signed int upper_bound; // [sp+18h] [bp-4h]@28
   unsigned int uXa; // [sp+24h] [bp+8h]@49
   //unsigned int uYa; // [sp+28h] [bp+Ch]@28
   int uYb; // [sp+28h] [bp+Ch]@47
@@ -3712,7 +3713,7 @@
     v21 = pRenderer->uTargetSurfacePitch;
     if ( pRenderer->uTargetSurfacePitch )
     {
-      v12 = uX + uY * pRenderer->uTargetSurfacePitch;
+      //v12 = uX + uY * pRenderer->uTargetSurfacePitch;
       v22 = uW - uY;
       v23 = v22;
       uYb = v22;
@@ -3744,7 +3745,7 @@
           {
             v31 = 2 * v24;
             v32 = 2 * v21;
-            v12 = (int)&v26[v12];
+            //v12 = (int)&v26[v12];
             int y = 0;
             int x = 0;
             for ( v30; v30; --v30 )
@@ -3778,7 +3779,7 @@
             v29 = 2 * v24;
             int y = 0;
             int x = 0;
-            v12 = (int)&v26[v12];
+            //v12 = (int)&v26[v12];
             for ( v27; v27; --v27 )
             {
               v25 += uYb;
@@ -3806,7 +3807,7 @@
     return;
   }
 
-  if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 )//левая и 
+  if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 )//for left and right(левая и правая)
   {
     if ( BYTE4(v36) & 8 )//left_border = true;
     {
@@ -3829,28 +3830,28 @@
     else
     {
       uW += ((uY - uW) * (this->raster_clip_z - uZ)) / (uX - uZ);
-      uY = this->raster_clip_z;
-    }
-  }
-  v37 = 0;
+      uZ = this->raster_clip_z;
+    }
+  }
+
+  upper_bound = 0;
   if ( uY < this->raster_clip_y )
-    v37 = 2;
+    upper_bound = 2;
   if ( uY > this->raster_clip_w )
-    v37 |= 1;
-
-  if ( uW >= this->raster_clip_y )
-    v12 = 0;
-  else
-    v12 = 2;
+    upper_bound |= 1;
+
+  lower_bound = 0;
+  if ( uW < this->raster_clip_y )
+    lower_bound = 2;
   if ( uW > this->raster_clip_w )
-    v12 |= 1;
-
-  if ( !(v12 & v37) )
-  {
-    v12 ^= v37;
-    if ( v12 & 2 )
-    {
-      if ( v37 & 2 )
+    lower_bound |= 1;
+
+  if ( !(lower_bound & upper_bound) )//for up and down(для верха и низа)
+  {
+    lower_bound ^= upper_bound;
+    if ( lower_bound & 2 )
+    {
+      if ( upper_bound & 2 )
       {
         uX += ((uZ - uX) * (this->raster_clip_y - uY)) / (uW - uY);
         uY = this->raster_clip_y;
@@ -3861,9 +3862,9 @@
         uW = this->raster_clip_y;
       }
     }
-    if ( v12 & 1 )
-    {
-      if ( v37 & 1 )
+    if ( lower_bound & 1 )
+    {
+      if ( upper_bound & 1 )
       {
         uX += ((uZ - uX) * (this->raster_clip_w - uY)) / (uW - uY);
         uY = this->raster_clip_w;
@@ -7485,96 +7486,77 @@
 //----- (004A65CC) --------------------------------------------------------
 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8)
 {
-  //unsigned __int16 *v8; // esi@6
-  unsigned int v9; // edi@6
-  unsigned int v10; // eax@7
-  unsigned int v11; // eax@8
-  unsigned int v12; // eax@9
-  unsigned int v13; // eax@10
+  unsigned int uHeight; // edi@6
   unsigned int v14; // edx@11
-  unsigned int v15; // eax@13
   unsigned int v16; // edx@14
   unsigned int v17; // edx@17
-  unsigned int v18; // eax@19
   unsigned int v19; // edx@20
   int v20; // eax@27
   int v21; // edx@29
-  int v22; // [sp+Ch] [bp-Ch]@6
   int v23; // [sp+Ch] [bp-Ch]@24
   unsigned __int8 *v24; // [sp+14h] [bp-4h]@6
   int xa; // [sp+20h] [bp+8h]@26
   unsigned int ya; // [sp+24h] [bp+Ch]@24
-  int v27; // [sp+2Ch] [bp+14h]@6
+  int Width; // [sp+2Ch] [bp+14h]@6
 
   if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 )
   {
-    //v8 = &this->pTargetSurface[x + y * this->uTargetSurfacePitch];
     v24 = a4->pLevelOfDetail0_prolly_alpha_mask;
-    v27 = a4->uTextureWidth;
-    v9 = a4->uTextureHeight;
-    v22 = a4->uTextureWidth;
+    Width = a4->uTextureWidth;
+    uHeight = a4->uTextureHeight;
     int clipped_out_x = x;
     int clipped_out_y = y;
     if ( this->bClip )
     {
-      v10 = this->uClipX;
-      if ( (signed int)x < (signed int)v10 )
-      {
-        v11 = v10 - x;
-        v24 += v11;
-        v27 += x - this->uClipX;
-        //v8 += v11;
+      if ( (signed int)x < (signed int)this->uClipX )
+      {
+        v24 += this->uClipX - x;
+        Width += x - this->uClipX;
         clipped_out_x = uClipX;
       }
-      v12 = this->uClipY;
-      if ( (signed int)y < (signed int)v12 )
-      {
-        v13 = v12 - y;
-        v24 += v22 * v13;
-        v9 = y - this->uClipY + a4->uTextureHeight;
-        //v8 += this->uTargetSurfacePitch * v13;
+      if ( (signed int)y < (signed int)this->uClipY )
+      {
+        v24 += a4->uTextureWidth * (this->uClipY - y);
+        uHeight = y - this->uClipY + a4->uTextureHeight;
         clipped_out_y = uClipY;
       }
       v14 = this->uClipX;
-      if ( (signed int)v14 < (signed int)x )
+      if ( (signed int)this->uClipX < (signed int)x )
         v14 = x;
-      v15 = this->uClipZ;
-      if ( (signed int)(v27 + v14) > (signed int)v15 )
+      if ( (signed int)(Width + v14) > (signed int)this->uClipZ )
       {
         v16 = this->uClipX;
-        if ( (signed int)v16 < (signed int)x )
+        if ( (signed int)this->uClipX < (signed int)x )
           v16 = x;
-        v27 = v15 - v16;
+        Width = this->uClipZ - v16;
       }
       v17 = this->uClipY;
-      if ( (signed int)v17 < (signed int)y )
+      if ( (signed int)this->uClipY < (signed int)y )
         v17 = y;
-      v18 = this->uClipW;
-      if ( (signed int)(v9 + v17) > (signed int)v18 )
+      if ( (signed int)(uHeight + v17) > (signed int)this->uClipW )
       {
         v19 = this->uClipY;
         if ( (signed int)v19 < (signed int)y )
           v19 = y;
-        v9 = v18 - v19;
-      }
-    }
-
-    for (int dy = 0; dy < v9; ++dy)
-    {
-      for (int dx = 0; dx < v27; ++dx)
-      {
-            v20 = *v24;
-            if ( v20 >= a7 && v20 <= a8 )
-            {
-              v21 = a7 + (a6 + v20) % (2 * (a8 - a7));
-              if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 )
-                v21 = 2 * a8 - v21 - a7;
-              //*v8 = a4->pPalette16[v21];
-              WritePixel16(clipped_out_x + dx, clipped_out_y + dy, a4->pPalette16[v21]);
-            }
-            ++v24;
-      }
-        v24 += v22 - v27;
+        uHeight = this->uClipW - v19;
+      }
+    }
+
+    for (int dy = 0; dy < uHeight; ++dy)
+    {
+      for (int dx = 0; dx < Width; ++dx)
+      {
+        v20 = *v24;
+        if ( v20 >= a7 && v20 <= a8 )
+        {
+          v21 = a7 + (a6 + v20) % (2 * (a8 - a7));
+          if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 )
+            v21 = 2 * a8 - v21 - a7;
+          WritePixel16(clipped_out_x + dx, clipped_out_y + dy, a4->pPalette16[v21]);
+        }
+        ++v24;
+      }
+      v24 += a4->uTextureWidth - Width;
     }
     /*if ( (signed int)v9 > 0 )
     {
@@ -7613,31 +7595,20 @@
 //----- (004A63E6) --------------------------------------------------------
 void Render::DrawAura(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8)
 {
-  Texture *v8; // eax@2
-  //Texture *v9; // ebx@4
-  //unsigned __int16 *v10; // esi@6
-  unsigned int v11; // edi@7
-  unsigned int v12; // eax@9
-  unsigned int v13; // eax@10
   unsigned int v14; // edx@11
-  unsigned int v15; // eax@13
   unsigned int v16; // edx@14
   unsigned int v17; // edx@17
-  unsigned int v18; // eax@19
   unsigned int v19; // edx@20
   int v20; // eax@27
   int v21; // edx@29
-  int v22; // [sp+Ch] [bp-Ch]@6
   int v23; // [sp+Ch] [bp-Ch]@24
-  int v24; // [sp+10h] [bp-8h]@6
-  int v25; // [sp+14h] [bp-4h]@6
-  int i; // [sp+20h] [bp+8h]@25
+  int Height; // [sp+10h] [bp-8h]@6
+  int Width; // [sp+14h] [bp-4h]@6
   int v27; // [sp+24h] [bp+Ch]@23
   unsigned __int8 *v28; // [sp+28h] [bp+10h]@6
 
   if ( this->uNumSceneBegins )
   {
-    v8 = a4;
     if ( a4 )
     {
       if ( a4->pPalette16 )
@@ -7646,61 +7617,54 @@
         {
           if ( a5->pPalette16 )
           {
-            //v10 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
             v28 = a4->pLevelOfDetail0_prolly_alpha_mask;
-            v25 = v8->uTextureWidth;
-            v24 = v8->uTextureHeight;
-            v22 = v8->uTextureWidth;
-
+            Width = a4->uTextureWidth;
+            Height = a4->uTextureHeight;
             int clipped_out_x = a2;
             int clipped_out_y = a3;
             if ( this->bClip )
             {
-              v11 = this->uClipX;
-              if ( (signed int)a2 < (signed int)v11 )
+              if ( (signed int)a2 < (signed int)this->uClipX )
               {
-                v28 += v11 - a2;
-                v25 += a2 - v11;
-                //v10 += v11 - a2;
+                v28 += this->uClipX - a2;
+                Width += a2 - this->uClipX;
                 clipped_out_x = uClipX;
               }
-              v12 = this->uClipY;
-              if ( (signed int)a3 < (signed int)v12 )
+
+              if ( (signed int)a3 < (signed int)this->uClipY )
               {
-                v13 = v12 - a3;
-                v28 += v22 * v13;
-                v24 += a3 - this->uClipY;
-                //v10 += this->uTargetSurfacePitch * v13;
+                v28 += a4->uTextureWidth * (this->uClipY - a3);
+                Height += a3 - this->uClipY;
                 clipped_out_y = uClipY;
               }
+
               v14 = this->uClipX;
-              if ( (signed int)v14 < (signed int)a2 )
+              if ( (signed int)this->uClipX < (signed int)a2 )
                 v14 = a2;
-              v15 = this->uClipZ;
-              if ( (signed int)(v25 + v14) > (signed int)v15 )
+              if ( (signed int)(Width + v14) > (signed int)this->uClipZ )
               {
                 v16 = this->uClipX;
-                if ( (signed int)v16 < (signed int)a2 )
+                if ( (signed int)this->uClipX < (signed int)a2 )
                   v16 = a2;
-                v25 = v15 - v16;
+                Width = this->uClipZ - v16;
               }
+
               v17 = this->uClipY;
-              if ( (signed int)v17 < (signed int)a3 )
+              if ( (signed int)this->uClipY < (signed int)a3 )
                 v17 = a3;
-              v18 = this->uClipW;
-              if ( (signed int)(v24 + v17) > (signed int)v18 )
+              if ( (signed int)(Height + v17) > (signed int)this->uClipW )
               {
                 v19 = this->uClipY;
-                if ( (signed int)v19 < (signed int)a3 )
+                if ( (signed int)this->uClipY < (signed int)a3 )
                   v19 = a3;
-                v24 = v18 - v19;
+                Height = this->uClipW - v19;
               }
             }
 
             v27 = 0;
-            for (int y = 0; y < v24; ++y)
+            for (int y = 0; y < Height; ++y)
             {
-              for (int x = 0; x < v25; ++x)
+              for (int x = 0; x < Width; ++x)
               {
                   if ( *v28 )
                   {
@@ -7720,7 +7684,7 @@
                   }
                   v28++;
               }
-                v28 += v22 - v25;
+                v28 += a4->uTextureWidth - Width;
             }
 
             /*if ( v24 > 0 )
@@ -7755,8 +7719,6 @@
               while ( v27 < v24 );
             }*/
 
-
-
           }
         }
       }
@@ -7767,98 +7729,75 @@
 //----- (004A6274) --------------------------------------------------------
 void Render::DrawTextureTransparent(unsigned int uX, unsigned int uY, Texture *pTexture)
 {
-  Texture *pCurrentTexture; // edi@2
   int uHeight; // ebx@4
-  //unsigned __int16 *v6; // eax@4
-  unsigned int v7; // edx@5
-  unsigned int v8; // edx@6
-  unsigned int v9; // edx@7
-  unsigned int v10; // edx@8
   unsigned int v11; // edx@9
   unsigned int v12; // esi@12
   unsigned int v13; // esi@15
-  unsigned int v14; // edx@17
   unsigned int v15; // esi@18
-  unsigned __int8 *v16; // ebx@22
-  char uFlag; // zf@28
-  int v18; // [sp+10h] [bp-10h]@4
   unsigned __int8 *v19; // [sp+18h] [bp-8h]@4
   int uWidth; // [sp+1Ch] [bp-4h]@4
-  int uXa; // [sp+28h] [bp+8h]@24
-  unsigned int uYa; // [sp+2Ch] [bp+Ch]@22
-  unsigned int pTexturea; // [sp+30h] [bp+10h]@11
 
   if ( this->uNumSceneBegins )
   {
-    pCurrentTexture = pTexture;
     if ( pTexture )
     {
       if ( pTexture->pPalette16 )
       {
         uHeight = pTexture->uTextureHeight;
-        //v6 = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch];
         v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask;
         uWidth = pTexture->uTextureWidth;
-        v18 = pTexture->uTextureWidth;
 
         int clipped_out_x = uX;
         int clipped_out_y = uY;
         if ( this->bClip )
         {
-          v7 = this->uClipX;
-          if ( (signed int)uX < (signed int)v7 )
+          if ( (signed int)uX < (signed int)this->uClipX )
           {
-            v8 = v7 - uX;
-            v19 += v8;
+            v19 += this->uClipX - uX;
             uWidth += uX - this->uClipX;
-            //v6 += v8;
             clipped_out_x = uClipX;
           }
-          v9 = this->uClipY;
+
           uHeight = pTexture->uTextureHeight;
-          if ( (signed int)uY < (signed int)v9 )
+          if ( (signed int)uY < (signed int)this->uClipY )
           {
-            v10 = v9 - uY;
-            v19 += v18 * v10;
+            v19 += pTexture->uTextureWidth * (this->uClipY - uY);
             uHeight = uY - this->uClipY + pTexture->uTextureHeight;
-            pCurrentTexture = pTexture;
-            //v6 += this->uTargetSurfacePitch * v10;
             clipped_out_y = uClipY;
           }
           v11 = this->uClipX;
-          if ( (signed int)v11 < (signed int)uX )
+          if ( (signed int)this->uClipX < (signed int)uX )
             v11 = uX;
-          pTexturea = this->uClipZ;
-          if ( (signed int)(v11 + uWidth) > (signed int)pTexturea )
+
+          if ( (signed int)(v11 + uWidth) > (signed int)this->uClipZ )
           {
             v12 = this->uClipX;
-            if ( (signed int)v12 < (signed int)uX )
+            if ( (signed int)this->uClipX < (signed int)uX )
               v12 = uX;
-            uWidth = pTexturea - v12;
+            uWidth = this->uClipZ - v12;
           }
           v13 = this->uClipY;
-          if ( (signed int)v13 < (signed int)uY )
+          if ( (signed int)this->uClipY < (signed int)uY )
             v13 = uY;
-          v14 = this->uClipW;
-          if ( (signed int)(uHeight + v13) > (signed int)v14 )
+
+          if ( (signed int)(uHeight + v13) > (signed int)this->uClipW )
           {
             v15 = this->uClipY;
-            if ( (signed int)v15 < (signed int)uY )
+            if ( (signed int)this->uClipY < (signed int)uY )
               v15 = uY;
-            uHeight = v14 - v15;
+            uHeight = this->uClipW - v15;
           }
         }
-        
-          v16 = v19;
+
         for (int y = 0; y < uHeight; ++y)
         {
           for (int x = 0; x < uWidth; ++x)
           {
-                if ( *v16 )
-                  WritePixel16(clipped_out_x + x, clipped_out_y + y, pCurrentTexture->pPalette16[*v16]);
-                ++v16;
+            if ( *v19 )
+              WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v19]);
+            ++v19;
           }
-            v16 += v18 - uWidth;
+          v19 += pTexture->uTextureWidth - uWidth;
         }
         /*if ( (signed int)uHeight > 0 )
         {
@@ -8078,30 +8017,22 @@
 //----- (004A5EB2) --------------------------------------------------------
 void Render::DrawTextureIndexed(unsigned int uX, unsigned int uY, Texture *a4)
 {
-  Texture *v4; // edi@2
   int v5; // ebx@4
-  //unsigned __int16 *pTarget; // eax@4
-  unsigned int v7; // edx@5
   unsigned int v8; // edx@6
-  unsigned int v9; // edx@7
   unsigned int v10; // edx@8
   unsigned int v11; // edx@9
   unsigned int v12; // esi@12
   unsigned int v13; // esi@15
-  //unsigned int v14; // edx@17
   unsigned int v15; // esi@18
-  unsigned __int8 *v16; // edx@22
   char v17; // zf@26
   int v18; // [sp+10h] [bp-10h]@4
   unsigned __int8 *v19; // [sp+18h] [bp-8h]@4
   int v20; // [sp+1Ch] [bp-4h]@4
   int uXa; // [sp+28h] [bp+8h]@24
   unsigned int uYa; // [sp+2Ch] [bp+Ch]@22
-  unsigned int v23; // [sp+30h] [bp+10h]@11
 
   if ( this->uNumSceneBegins )
   {
-    v4 = a4;
     if ( a4 )
     {
       if ( a4->pPalette16 )
@@ -8116,37 +8047,36 @@
         int clipped_out_y = uY;
         if ( this->bClip )
         {
-          v7 = this->uClipX;
-          if ( (signed int)uX < (signed int)v7 )
+          if ( (signed int)uX < (signed int)this->uClipX )
           {
-            v8 = v7 - uX;
+            v8 = this->uClipX - uX;
             v19 += v8;
             v20 += uX - this->uClipX;
-            //pTarget += v8;
             clipped_out_x = uClipX;
           }
-          v9 = this->uClipY;
+
           v5 = a4->uTextureHeight;
-          if ( (signed int)uY < (signed int)v9 )
+          if ( (signed int)uY < (signed int)this->uClipY )
           {
-            v10 = v9 - uY;
+            v10 = this->uClipY - uY;
             v19 += v18 * v10;
             v5 = uY - this->uClipY + a4->uTextureHeight;
-            v4 = a4;
-            //pTarget += this->uTargetSurfacePitch * v10;
+            //v4 = a4;
             clipped_out_y = uClipY;
           }
+
           v11 = this->uClipX;
           if ( (signed int)v11 < (signed int)uX )
             v11 = uX;
-          v23 = this->uClipZ;
-          if ( (signed int)(v11 + v20) > (signed int)v23 )
+
+          if ( (signed int)(v11 + v20) > (signed int)this->uClipZ )
           {
             v12 = this->uClipX;
             if ( (signed int)v12 < (signed int)uX )
               v12 = uX;
-            v20 = v23 - v12;
+            v20 = this->uClipZ - v12;
           }
+
           v13 = this->uClipY;
           if ( (signed int)v13 < (signed int)uY )
             v13 = uY;
@@ -8159,16 +8089,16 @@
             v5 = uClipW - v15;
           }
         }
-        
-          v16 = v19;
+
         for (int y = 0; y < v5; ++y)
         {
           for (int x = 0; x < v20; ++x)
           {
-                WritePixel16(clipped_out_x + x, clipped_out_y + y, v4->pPalette16[*v16]);
-                ++v16;
+            if ( a4->pPalette16[*v19] != 0x7FF )// 2047
+              WritePixel16(clipped_out_x + x, clipped_out_y + y, a4->pPalette16[*v19]);
+            ++v19;
           }
-            v16 += v18 - v20;
+          v19 += v18 - v20;
         }
         /*if ( (signed int)v5 > 0 )
         {