changeset 1223:336f0d008666

Слияние
author Ritor1
date Sun, 02 Jun 2013 22:02:33 +0600
parents b89a20cd8a54 (current diff) d8b455c81917 (diff)
children 23632c91ed0a
files
diffstat 1 files changed, 58 insertions(+), 121 deletions(-) [+]
line wrap: on
line diff
--- a/Render.cpp	Sun Jun 02 22:02:26 2013 +0600
+++ b/Render.cpp	Sun Jun 02 22:02:33 2013 +0600
@@ -8728,26 +8728,15 @@
         bMipMaps = 0;
         v13 = pHWLTexture->pPixels;
         v14 = (unsigned __int16 *)desc.lpSurface;
-        if ( desc.dwHeight )
-        {
-          do
+        for(int bMipMaps = 0; bMipMaps < desc.dwHeight; bMipMaps++)
+        {
+          for (v15 = 0; v15 < desc.dwWidth; v15++)
           {
-            v15 = 0;
-            if ( desc.dwWidth )
-            {
-              do
-              {
-                ++v15;
-                *v14 = *v13;
-                ++v14;
-                ++v13;
-              }
-              while ( v15 < desc.dwWidth );
-            }
-            ++bMipMaps;
-            v14 += (desc.lPitch >> 1) - desc.dwWidth;
+            *v14 = *v13;
+            ++v14;
+            ++v13;
           }
-          while ( bMipMaps < desc.dwHeight );
+          v14 += (desc.lPitch >> 1) - desc.dwWidth;
         }
         ErrD3D((*pOutSurface)->Unlock(0));
       }
@@ -8813,14 +8802,14 @@
 //----- (004A51CB) --------------------------------------------------------
 void Render::BeginScene()
 {
-  Render *v1; // esi@1
+  //Render *v1; // esi@1
   unsigned int v2; // eax@1
-  int v3; // eax@5
+/*int v3; // eax@5
   unsigned __int16 **v4; // edi@6
-  char *v5; // ebx@7
+  char *v5; // ebx@7*/
   DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4
 
-  v1 = this;
+  //v1 = this;
   v2 = this->uNumSceneBegins;
   this->uNumSceneBegins = v2 + 1;
   if ( !v2 )
@@ -8831,36 +8820,27 @@
       {
         memset(&Dst, 0, 0x7Cu);
         Dst.dwSize = 124;
-        if ( LockSurface_DDraw4(v1->pColorKeySurface4, &Dst, 0x800 | DDLOCK_WAIT) )
-        {
-          v1->pTargetSurface = (unsigned __int16 *)Dst.lpSurface;
-          v3 = Dst.lPitch >> 1;
-          v1->uTargetSurfacePitch = Dst.lPitch >> 1;
-LABEL_10:
-          v1->field_18_locked_pitch = v3;
-          goto LABEL_11;
-        }
-        goto LABEL_8;
+        if ( LockSurface_DDraw4(this->pColorKeySurface4, &Dst, 0x800 | DDLOCK_WAIT) )
+        {
+          this->pTargetSurface = (unsigned __int16 *)Dst.lpSurface;
+          this->uTargetSurfacePitch = Dst.lPitch >> 1;
+          this->field_18_locked_pitch = Dst.lPitch >> 1;
+        }
+        --this->uNumSceneBegins;
       }
     }
     else
     {
-      v4 = &this->pTargetSurface;
       if ( !this->pTargetSurface )
       {
-        v5 = (char *)&this->uTargetSurfacePitch;
         LockRenderSurface((void **)&this->pTargetSurface, &this->uTargetSurfacePitch);
-        if ( *v4 )
-        {
-          v3 = *(int *)v5;
-          goto LABEL_10;
-        }
-LABEL_8:
-        --v1->uNumSceneBegins;
-        return;
-      }
-    }
-LABEL_11:
+        if ( this->pTargetSurface )
+        {
+          this->field_18_locked_pitch = this->uTargetSurfacePitch;
+        }
+        --this->uNumSceneBegins;
+      }
+    }
     RestoreFrontBuffer();
   }
 }
@@ -8868,16 +8848,10 @@
 //----- (004A527D) --------------------------------------------------------
 void Render::EndScene()
 {
-  unsigned int v1; // edx@1
-  unsigned int v2; // edx@2
-  HRESULT v3; // eax@5
-
-  v1 = this->uNumSceneBegins;
-  if ( v1 )
-  {
-    v2 = v1 - 1;
-    this->uNumSceneBegins = v2;
-    if ( !v2 )
+  if ( this->uNumSceneBegins )
+  {
+    this->uNumSceneBegins--;
+    if ( !this->uNumSceneBegins )
     {
       if ( this->pRenderD3D )
       {
@@ -9133,22 +9107,13 @@
   int v4; // edi@3
   unsigned __int16 *v5; // edx@3
   unsigned __int16 *v6; // esi@3
-  unsigned int v7; // ebx@4
   unsigned int v8; // eax@5
   unsigned int v9; // ebx@5
-  unsigned int v10; // eax@6
   unsigned int v11; // eax@7
   unsigned int v12; // ebx@8
-  unsigned int v13; // eax@10
-  unsigned int v14; // edi@11
   unsigned int v15; // eax@14
-  unsigned int v16; // ebx@17
-  int v17; // eax@23
-  char v18; // zf@25
   int v19; // [sp+10h] [bp-8h]@3
-  int v20; // [sp+14h] [bp-4h]@3
   unsigned int uOutXa; // [sp+20h] [bp+8h]@16
-  int uOutXb; // [sp+20h] [bp+8h]@21
   int v23; // [sp+28h] [bp+10h]@3
 
   if ( this->uNumSceneBegins && a4 )
@@ -9156,76 +9121,48 @@
     v4 = a4->uWidth;
     v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch];
     v6 = a4->pPixels;
-    v20 = v4;
     v23 = a4->uHeight;
     v19 = v4;
     if ( this->bClip )
     {
-      v7 = this->uClipX;
-      if ( (signed int)uOutX < (signed int)v7 )
-      {
-        v8 = v7 - uOutX;
-        v9 = uOutX - v7;
+      if ( (signed int)uOutX < (signed int)this->uClipX )
+      {
+        v8 = this->uClipX - uOutX;
+        v9 = uOutX - this->uClipX;
         v8 *= 2;
         v4 += v9;
         v6 = (unsigned __int16 *)((char *)v6 + v8);
-        v20 += v9;
         v5 = (unsigned __int16 *)((char *)v5 + v8);
       }
-      v10 = this->uClipY;
-      if ( (signed int)uOutY < (signed int)v10 )
-      {
-        v11 = v10 - uOutY;
+      if ( (signed int)uOutY < (signed int)this->uClipY )
+      {
+        v11 = this->uClipY - uOutY;
         v6 += v19 * v11;
         v23 += uOutY - this->uClipY;
-        v4 = v20;
         v5 += this->uTargetSurfacePitch * v11;
       }
-      v12 = this->uClipX;
-      if ( (signed int)v12 < (signed int)uOutX )
-        v12 = uOutX;
-      v13 = this->uClipZ;
-      if ( (signed int)(v4 + v12) > (signed int)v13 )
-      {
-        v14 = this->uClipX;
-        if ( (signed int)v14 < (signed int)uOutX )
-          v14 = uOutX;
-        v4 = v13 - v14;
-      }
-      v15 = this->uClipY;
-      if ( (signed int)v15 < (signed int)uOutY )
-        v15 = uOutY;
-      uOutXa = this->uClipW;
-      if ( (signed int)(v15 + v23) > (signed int)uOutXa )
-      {
-        v16 = this->uClipY;
-        if ( (signed int)v16 < (signed int)uOutY )
-          v16 = uOutY;
-        v23 = uOutXa - v16;
-      }
-    }
-    if ( v23 > 0 )
-    {
-      uOutXb = v23;
-      do
-      {
-        if ( v4 > 0 )
-        {
-          v17 = v4;
-          do
-          {
-            *v5 = *v6;
-            ++v5;
-            ++v6;
-            --v17;
-          }
-          while ( v17 );
-        }
-        v6 += v19 - v4;
-        v18 = uOutXb-- == 1;
-        v5 += this->uTargetSurfacePitch - v4;
-      }
-      while ( !v18 );
+      v12 = max(this->uClipX, uOutX);
+      if ( (signed int)(v4 + v12) > (signed int)this->uClipZ )
+      {
+        v4 = this->uClipZ - max(this->uClipX, uOutX);
+      }
+      v15 = max(this->uClipY, uOutY);
+      if ( (signed int)(v15 + v23) > (signed int)this->uClipW )
+      {
+        v23 = this->uClipW - max(this->uClipY, uOutY);
+      }
+    }
+
+    for (int outerCounter = 0; outerCounter < v23; outerCounter++)
+    {
+      for (int counter = 0; counter < v4; counter++)
+      {
+        *v5 = *v6;
+        ++v5;
+        ++v6;
+      }
+      v6 += v19 - v4;
+      v5 += this->uTargetSurfacePitch - v4;
     }
   }
 }