changeset 1176:dac817fbf85a

Слияние
author Ritor1
date Mon, 03 Jun 2013 09:32:05 +0600
parents 9e3bacdbec56 (current diff) 8ce08eea96ed (diff)
children ce5ff6d32200
files Render.cpp Vis.cpp
diffstat 10 files changed, 360 insertions(+), 1327 deletions(-) [+]
line wrap: on
line diff
--- a/Arcomage.cpp	Mon Jun 03 09:10:21 2013 +0600
+++ b/Arcomage.cpp	Mon Jun 03 09:32:05 2013 +0600
@@ -1602,7 +1602,7 @@
     while ( v2 );
     v0 += 47;
   }
-  while ( (signed int)v0 < (signed int)&pArcomageGame->msg.pt.y );
+  while ( (signed int)v0 < 2 );//(signed int)&pArcomageGame->msg.pt.y );
   v4 = 0;
   do
   {
@@ -1616,7 +1616,7 @@
     *v7 = 1;
     dword_505314[v4] = dword_505554[v6];
     result = byte_5054E8[v6];
-    array_4FAC10[9].field_4[v4++ + 4232] = result;
+    array_4FAC10[9].field_4[v4++ + 4232] = result;// pArcomageGame
   }
   while ( v4 < 108 );
   dword_4FABC8 = 0;
@@ -5801,7 +5801,7 @@
     v5->_40DFD1();
     ++v5;
   }
-  while ( (signed int)v5 < (signed int)&unk_5052C8 );
+  while ( (signed int)v5 < 10 );//(signed int)&unk_5052C8 );
   dword_4FABBC = -1;
   amuint_4FAA4C = -1;
   byte_4FAA74 = 0;
--- a/Indoor.cpp	Mon Jun 03 09:10:21 2013 +0600
+++ b/Indoor.cpp	Mon Jun 03 09:32:05 2013 +0600
@@ -299,10 +299,10 @@
     for (uint i = 0; i < pBspRenderer->num_faces; ++i)
     {
       v2 = pBspRenderer->faces[i].uNodeID;
-      if (pBspRenderer->nodes[v2].viewing_portal_id == -1)
+      //if (pBspRenderer->nodes[v2].viewing_portal_id == -1)
         IndoorLocation::ExecDraw_d3d(pBspRenderer->faces[i].uFaceID, nullptr, 4, nullptr);
-      else
-        IndoorLocation::ExecDraw_d3d(pBspRenderer->faces[i].uFaceID, pBspRenderer->nodes[v2].std__vector_0007AC, 4, pBspRenderer->nodes[v2].pPortalBounding);
+      //else
+        //IndoorLocation::ExecDraw_d3d(pBspRenderer->faces[i].uFaceID, pBspRenderer->nodes[v2].std__vector_0007AC, 4, pBspRenderer->nodes[v2].pPortalBounding);
     }
   }
   else for (uint j = 0; j < pBspRenderer->num_faces; ++j )
@@ -1373,9 +1373,11 @@
       if (face_max_screenspace_y < stru_50B700._screen_space_y[i])
         face_max_screenspace_y = stru_50B700._screen_space_y[i];
     }
-
+	  //_screen_space_x = 719, 568, 493
+	  //savegame: qw , 0Bh and 0x1D4h
+	  //problem here when standing near/on portal, condition is false because of face_min_screenspace_x > p->uViewportZ
       if (face_max_screenspace_x >= p->uViewportX &&
-          face_min_screenspace_x <= p->uViewportZ &&
+//          face_min_screenspace_x <= p->uViewportZ &&
           face_max_screenspace_y >= p->uViewportY &&
           face_min_screenspace_y <= p->uViewportW &&
           sub_424829(num_vertices, &nodes[num_nodes].field_C, &p->field_C, uFaceID))
@@ -1420,7 +1422,7 @@
                                                   nodes[num_nodes].std__vector_0007AC,
                                                   nodes[num_nodes].pPortalBounding);
           }
-          if ( v29 )
+          if ( 1 )
           {
             assert(num_nodes < 150);
 
--- a/Math.h	Mon Jun 03 09:10:21 2013 +0600
+++ b/Math.h	Mon Jun 03 09:32:05 2013 +0600
@@ -1,5 +1,7 @@
 #pragma once
-
+#include <cassert>
+#include <limits>
+#include <float.h>
 
 
 /*  186 */
@@ -29,5 +31,52 @@
 int fixpoint_mul(int, int);
 int fixpoint_from_float(float value);
 
+#ifndef ROUNDING_EPSILON
+#define ROUNDING_EPSILON 0.0000001
+#endif
+
+#include <cmath>
+#include <cstdlib>
+#include <ciso646>
+
+template <typename FloatType>
+int bankersRounding(
+  const FloatType& value
+  ) {
+    assert("Method unsupported for this type" && false);
+    return value;
+}
+
+template<> static int bankersRounding<float>(const float& inValue)
+{
+  union Cast
+  {
+    double d;
+    long l;
+  };
+  volatile Cast c;
+  c.d = inValue + 6755399441055744.0;
+  return c.l;
+}
+
+#pragma push_macro("max")
+#undef max
+
+template<> static int bankersRounding<double>(const double& inValue)
+{
+  double maxValue = std::numeric_limits<int>::max();
+  assert(maxValue - 6755399441055744.0 >= inValue);
+  union Cast
+  {
+    double d;
+    long l;
+  };
+  volatile Cast c;
+  c.d = inValue + 6755399441055744.0;
+  return c.l;
+}
+
+
+#pragma pop_macro("max")
 
 extern struct stru193_math *stru_5C6E00;
\ No newline at end of file
--- a/Outdoor.cpp	Mon Jun 03 09:10:21 2013 +0600
+++ b/Outdoor.cpp	Mon Jun 03 09:32:05 2013 +0600
@@ -184,7 +184,6 @@
 }
 
 
-
 //----- (00441CFF) --------------------------------------------------------
 void OutdoorLocation::Draw()
 {
@@ -198,7 +197,6 @@
   array_5118E8._440F07();
 }
 
-
 //----- (00488E23) --------------------------------------------------------
 double OutdoorLocation::GetFogDensityByTime()
 {
--- a/Render.cpp	Mon Jun 03 09:10:21 2013 +0600
+++ b/Render.cpp	Mon Jun 03 09:32:05 2013 +0600
@@ -8727,26 +8727,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));
       }
@@ -8812,14 +8801,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 )
@@ -8830,36 +8819,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();
   }
 }
@@ -8867,16 +8847,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 )
       {
@@ -9132,22 +9106,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 )
@@ -9155,76 +9120,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;
     }
   }
 }
--- a/UICharacter.cpp	Mon Jun 03 09:10:21 2013 +0600
+++ b/UICharacter.cpp	Mon Jun 03 09:32:05 2013 +0600
@@ -87,7 +87,7 @@
 int paperdoll_cloak_collar_texture[4][10]; // weak
 int paperdoll_cloak_texture[4][10];
 int paperdoll_helm_texture[2][16]; //511698
-int paperdoll_belt_texture[2][7];  //511718
+int paperdoll_belt_texture[4][7];  //511718
 
 
 const int paperdoll_Weapon[4][16][2] = {//4E4C30
@@ -934,7 +934,7 @@
       item_MainHand4 = &pPlayers[uPlayerID]->pInventoryItems[pMainHandNum4 - 1];
       pX_MainHand4 = pPaperdoll_BodyX + paperdoll_Weapon[pBodyComplection][1][0] - pItemsTable->pItems[item_MainHand4->uItemID].uEquipX;
       pY_MainHand4 = pPaperdoll_BodyY + paperdoll_Weapon[pBodyComplection][1][1] - pItemsTable->pItems[item_MainHand4->uItemID].uEquipY;
-      if ( item_MainHand4->uItemID == 64 )
+      if ( item_MainHand4->uItemID == 64 )  //blaster
         v166 = "item64v1";
       else
         v166 = pItemsTable->pItems[item_MainHand4->uItemID].pIconName;
@@ -1323,9 +1323,9 @@
     pMainHandNum = pPlayers[uPlayerID]->pEquipment.uMainHand;
     if ( !pMainHandNum || (v70 = *(int *)&pPlayers[uPlayerID]->pInventoryItems[pMainHandNum -1], pItemsTable->pItems[v70].uEquipType != 1)
         && (pItemsTable->pItems[v70].uSkillType != 4 || pPlayers[uPlayerID]->pEquipment.uShield) )
-      pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_LeftHand[pBodyComplection][0],
-            pPaperdoll_BodyY + pPaperdoll_LeftHand[pBodyComplection][1],
-                     pIcons_LOD->GetTexture(papredoll_dlads[uPlayerID - 1]));
+                pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_LeftHand[pBodyComplection][0],
+                                                  pPaperdoll_BodyY + pPaperdoll_LeftHand[pBodyComplection][1],
+                                                   pIcons_LOD->GetTexture(papredoll_dlads[uPlayerID - 1]));
         pBeltNum = pPlayers[uPlayerID]->pEquipment.uBelt;//  
         if ( pBeltNum )
         {
@@ -1392,12 +1392,12 @@
       pMainHandNum2 = pPlayers[uPlayerID]->pEquipment.uMainHand;
       if ( pMainHandNum2 )
       {
-        v83 = *(int *)&pPlayers[uPlayerID]->pInventoryItems[pMainHandNum2 - 1];
+        v83 = pPlayers[uPlayerID]->pInventoryItems[pMainHandNum2 - 1].uItemID;
         if ( pItemsTable->pItems[v83].uEquipType == 1
-             || pItemsTable->pItems[v83].uSkillType == 4 && !pPlayers[uPlayerID]->pEquipment.uShield )
+             || pItemsTable->pItems[v83].uSkillType == PLAYER_SKILL_SPEAR && !pPlayers[uPlayerID]->pEquipment.uShield )
           pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[pBodyComplection][0],
-             pPaperdoll_BodyY + pPaperdoll_SecondLeftHand[pBodyComplection][1],
-             pIcons_LOD->GetTexture(papredoll_dlaus[uPlayerID - 1]));
+                                            pPaperdoll_BodyY + pPaperdoll_SecondLeftHand[pBodyComplection][1],
+                                            pIcons_LOD->GetTexture(papredoll_dlaus[uPlayerID - 1]));
       }
       pCloakCollarNum = pPlayers[uPlayerID]->pEquipment.uCloak;//  
       if ( pCloakCollarNum )
@@ -1674,8 +1674,12 @@
   if ( pMainHandNum5 )
   {
     item_MainHand5 = &pPlayers[uPlayerID]->pInventoryItems[pMainHandNum5 - 1];
-    if ( pItemsTable->pItems[item_MainHand5->uItemID].uEquipType == 1 || pItemsTable->pItems[item_MainHand5->uItemID].uSkillType == 4 && !pPlayers[uPlayerID]->pEquipment.uShield )
-      pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_SecondLeftHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_dlhus[uPlayerID - 1]));
+    if ( pItemsTable->pItems[item_MainHand5->uItemID].uEquipType == 1 || 
+        pItemsTable->pItems[item_MainHand5->uItemID].uSkillType == PLAYER_SKILL_SPEAR && 
+         !pPlayers[uPlayerID]->pEquipment.uShield )
+      pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[pBodyComplection][0], 
+                                        pPaperdoll_BodyY + pPaperdoll_SecondLeftHand[pBodyComplection][1], 
+                                        pIcons_LOD->GetTexture(papredoll_dlhus[uPlayerID - 1]));
   }
   if ( !bRingsShownInCharScreen )// 
     pRenderer->DrawTextureTransparent(603, 299, pIcons_LOD->GetTexture(uTextureID_MAGNIF_B));
@@ -1931,25 +1935,20 @@
     }
     else
     {
-      v6 = v30;
       papredoll_dbods[v30] = pIcons_LOD->LoadTexture(dbod_texnames_by_face[pPlayers[v30 + 1]->uCurrentFace], TEXTURE_16BIT_PALETTE);
       papredoll_dlads[v30] = pIcons_LOD->LoadTexture(dlad_texnames_by_face[pPlayers[v30 + 1]->uCurrentFace], TEXTURE_16BIT_PALETTE);
       papredoll_dlaus[v30] = pIcons_LOD->LoadTexture(dlau_texnames_by_face[pPlayers[v30 + 1]->uCurrentFace], TEXTURE_16BIT_PALETTE);
       papredoll_drhs[v30] = pIcons_LOD->LoadTexture(drh_texnames_by_face[pPlayers[v30 + 1]->uCurrentFace], TEXTURE_16BIT_PALETTE);
       papredoll_dlhs[v30] = pIcons_LOD->LoadTexture(dlh_texnames_by_face[pPlayers[v30 + 1]->uCurrentFace], TEXTURE_16BIT_PALETTE);
-      v7 = pIcons_LOD->LoadTexture(dlhu_texnames_by_face[pPlayers[v30 + 1]->uCurrentFace], TEXTURE_16BIT_PALETTE);
-      pPlayer2 = pPlayers[v30 + 1];
-      papredoll_dlhus[v30] = v7;
-      v9 = (char *)&pPlayer2->uCurrentFace;
-      v10 = *v9;
-      if ( *v9 == 12 || v10 == 13 )
+      papredoll_dlhus[v30] = pIcons_LOD->LoadTexture(dlhu_texnames_by_face[pPlayers[v30 + 1]->uCurrentFace], TEXTURE_16BIT_PALETTE);
+      v10 = pPlayers[v30 + 1]->uCurrentFace;
+      if ( v10 == 12 || v10 == 13 )
       {
         wsprintfA(pContainer, "pc%02dbrd", v10 + 1);
-        v9 = (char *)&pPlayers[v6 + 1]->uCurrentFace;
-        papredoll_dbrds[*v9] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+        papredoll_dbrds[v10] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       }
-      wsprintfA(pContainer, "item281pc%02d", *v9 + 1);
-      papredoll_flying_feet[pPlayers[v6 + 1]->uCurrentFace] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+      wsprintfA(pContainer, "item281pc%02d", v10 + 1);
+      papredoll_flying_feet[pPlayers[v30 + 1]->uCurrentFace] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       IsPlayerWearingWatersuit[v30 + 1] = 0;
     }
     ++v30;
--- a/Vis.h	Mon Jun 03 09:10:21 2013 +0600
+++ b/Vis.h	Mon Jun 03 09:32:05 2013 +0600
@@ -60,7 +60,7 @@
   Vis_SelectionList();
   //----- (004C0585) --------------------------------------------------------
   ~Vis_SelectionList() {}
-  Vis_ObjectInfo *sub_4C2551(int a2, int a3);
+  Vis_ObjectInfo *SelectionPointers(int a2, int a3);
   void            create_object_pointers(PointerCreationType type = All);
 
   inline void AddObject(void *object, VisObjectType type, int packed_zval)
--- a/mm7_1.cpp	Mon Jun 03 09:10:21 2013 +0600
+++ b/mm7_1.cpp	Mon Jun 03 09:32:05 2013 +0600
@@ -2225,44 +2225,44 @@
 }
 
 //----- (00424829) --------------------------------------------------------
-bool sub_424829(int a1, BspRenderer_stru2 *a2, BspRenderer_stru2 *a3, int a4)
+bool sub_424829(int pNumVertices, BspRenderer_stru2 *a2, BspRenderer_stru2 *a3, int uFaceID)
 {
-  int v4; // edi@1
-  BspRenderer_stru2 *v5; // ebx@1
+  //int v4; // edi@1
+  //BspRenderer_stru2 *v5; // ebx@1
   int v6; // eax@3
   int v7; // esi@5
   int v8; // edx@5
-  int v9; // ecx@6
+  //int v9; // ecx@6
   int v10; // eax@12
   int v11; // edi@13
-  int v12; // edx@18
+  //int v12; // edx@18
   int v13; // eax@22
-  int v14; // edi@28
+  //int v14; // edi@28
   int v15; // ecx@29
   int v16; // edi@30
-  int v17; // edx@35
+  //int v17; // edx@35
   int v18; // eax@39
   int v19; // eax@44
   int v20; // ecx@44
-  int v21; // edi@45
+  //int v21; // edi@45
   int v22; // edi@46
   __int16 *v23; // ecx@47
   int v24; // edx@48
   int v25; // eax@50
   int v26; // eax@55
   signed int v27; // edi@55
-  int v28; // edx@56
+  //int v28; // edx@56
   int v29; // edx@57
   int v30; // eax@59
   int v31; // eax@64
   signed int v32; // edi@64
-  int v33; // edx@65
+  //int v33; // edx@65
   __int16 *v34; // eax@66
   __int16 v35; // dx@66
   __int16 v36; // dx@67
   __int16 v37; // di@67
   __int16 v38; // dx@67
-  BspRenderer_stru2 *v39; // ecx@69
+  //BspRenderer_stru2 *v39; // ecx@69
   int v40; // edx@69
   int v41; // edi@70
   __int16 *v42; // eax@76
@@ -2274,7 +2274,7 @@
   int v49; // esi@93
   __int16 *v50; // ecx@94
   int v51; // eax@95
-  int v52; // eax@97
+  //int v52; // eax@97
   int v53; // [sp+Ch] [bp-34h]@44
   int v54; // [sp+10h] [bp-30h]@0
   int v55; // [sp+14h] [bp-2Ch]@12
@@ -2282,7 +2282,7 @@
   __int16 *v57; // [sp+14h] [bp-2Ch]@76
   __int16 *v58; // [sp+14h] [bp-2Ch]@81
   __int16 *v59; // [sp+14h] [bp-2Ch]@87
-  BspRenderer_stru2 *v60; // [sp+18h] [bp-28h]@1
+  //BspRenderer_stru2 *v60; // [sp+18h] [bp-28h]@1
   int v61; // [sp+1Ch] [bp-24h]@29
   int v62; // [sp+20h] [bp-20h]@0
   signed int v63; // [sp+24h] [bp-1Ch]@3
@@ -2296,27 +2296,34 @@
   int v71; // [sp+34h] [bp-Ch]@75
   int v72; // [sp+34h] [bp-Ch]@80
   int v73; // [sp+38h] [bp-8h]@11
-  int v74; // [sp+3Ch] [bp-4h]@1
+  //int v74; // [sp+3Ch] [bp-4h]@1
   int a3a; // [sp+48h] [bp+8h]@76
   int a3b; // [sp+48h] [bp+8h]@87
 
-  v4 = a1;
-  v5 = a2;
-  v74 = a1;
-  v60 = a2;
-  if ( !a1
-    || (!stru_50B700.field_0 ? (v64 = -1, v6 = 1, v63 = 1) : (v6 = 1, v63 = -1, v64 = 1),
-        v7 = stru_50B700._screen_space_y[0],
-        v65 = 0,
-        v8 = stru_50B700._screen_space_y[0],
-        a1 <= v6) )
-    return 0;
-  do
+  //try graphic engine with function returning 1 always, and without
+  //return true;
+  if ( !pNumVertices )
+    return false;
+  v7 = stru_50B700._screen_space_y[0];
+  v65 = 0;
+  v8 = stru_50B700._screen_space_y[0];
+  if ( !stru_50B700.field_0 )
   {
-    v9 = stru_50B700._screen_space_y[v6];
-    if ( v9 >= v7 )
+    v63 = 1;
+    v64 = -1;
+  }
+  else 
+  {
+    v63 = -1;
+    v64 = 1;
+  }
+  if ( pNumVertices <= 1 )
+    return false;
+  for ( v6 = 1; v6 < pNumVertices; ++v6 )
+  {
+    if ( stru_50B700._screen_space_y[v6] >= v7 )
     {
-      if ( v9 > v8 )
+      if ( stru_50B700._screen_space_y[v6] > v8 )
         v8 = stru_50B700._screen_space_y[v6];
     }
     else
@@ -2324,152 +2331,136 @@
       v65 = v6;
       v7 = stru_50B700._screen_space_y[v6];
     }
-    ++v6;
   }
-  while ( v6 < v4 );
   v73 = v8;
   if ( v8 == v7 )
-    return 0;
+    return false;
   v10 = v65;
-  v68 = 0;
-  v5->_viewport_space_y = v7;
-  v5->_viewport_space_w = v8;
+  a2->_viewport_space_y = v7;
+  a2->_viewport_space_w = v8;
   v55 = v65;
-  if ( v4 > 0 )
+  if ( pNumVertices > 0 )
   {
     v11 = v65;
-    do
+    for ( v68 = 0; v68 < pNumVertices; ++v68 )
     {
       v10 += v64;
-      if ( v10 < v74 )
+      if ( v10 < pNumVertices )
       {
         if ( v10 < 0 )
-          v10 += v74;
+          v10 += pNumVertices;
       }
       else
       {
-        v10 -= v74;
+        v10 -= pNumVertices;
       }
-      v12 = stru_50B700._screen_space_y[v10];
-      if ( v12 <= stru_50B700._screen_space_y[v11] )
+      if ( stru_50B700._screen_space_y[v10] <= stru_50B700._screen_space_y[v11] )
       {
         v55 = v10;
         v11 = v10;
       }
-      if ( v12 == v73 )
+      if ( stru_50B700._screen_space_y[v10] == v73 )
         break;
-      ++v68;
     }
-    while ( v68 < v74 );
   }
   v13 = v55 + v64;
   v67 = v55 + v64;
-  if ( v55 + v64 < v74 )
+  if ( v55 + v64 < pNumVertices )
   {
     if ( v13 >= 0 )
       goto LABEL_27;
-    v13 += v74;
+    v13 += pNumVertices;
   }
   else
   {
-    v13 -= v74;
+    v13 -= pNumVertices;
   }
   v67 = v13;
 LABEL_27:
   if ( stru_50B700._screen_space_y[v13] != stru_50B700._screen_space_y[v55] )
   {
-    v14 = stru_50B700._screen_space_x[v55];
-    v62 = v14 << 16;
-    v54 = ((stru_50B700._screen_space_x[v13] - v14) << 16) / (stru_50B700._screen_space_y[v13] - stru_50B700._screen_space_y[v55]);
-    v5->array_18[v7] = LOWORD(stru_50B700._screen_space_x[v55]);
+    v62 = stru_50B700._screen_space_x[v55] << 16;
+    v54 = ((stru_50B700._screen_space_x[v13] - stru_50B700._screen_space_x[v55]) << 16) / (stru_50B700._screen_space_y[v13] - stru_50B700._screen_space_y[v55]);
+    a2->array_18[v7] = LOWORD(stru_50B700._screen_space_x[v55]);
   }
   v15 = v65;
-  v69 = 0;
   v61 = v65;
-  if ( v74 > 0 )
+  if ( pNumVertices > 0 )
   {
     v16 = v65;
-    do
+    for ( v69 = 0; v69 < pNumVertices; ++v69 )
     {
       v15 += v63;
-      if ( v15 < v74 )
+      if ( v15 < pNumVertices )
       {
         if ( v15 < 0 )
-          v15 += v74;
+          v15 += pNumVertices;
       }
       else
       {
-        v15 -= v74;
+        v15 -= pNumVertices;
       }
-      v17 = stru_50B700._screen_space_y[v15];
-      if ( v17 <= stru_50B700._screen_space_y[v16] )
+      if ( stru_50B700._screen_space_y[v15] <= stru_50B700._screen_space_y[v16] )
       {
         v61 = v15;
         v16 = v15;
       }
-      if ( v17 == v73 )
+      if ( stru_50B700._screen_space_y[v15] == v73 )
         break;
-      ++v69;
     }
-    while ( v69 < v74 );
   }
   v18 = v63 + v61;
   v66 = v63 + v61;
-  if ( v63 + v61 < v74 )
+  if ( v63 + v61 < pNumVertices )
   {
     if ( v18 >= 0 )
       goto LABEL_44;
-    v18 += v74;
+    v18 += pNumVertices;
   }
   else
   {
-    v18 -= v74;
+    v18 -= pNumVertices;
   }
   v66 = v18;
 LABEL_44:
   v19 = v18;
   v20 = v61;
-  v53 = stru_50B700._screen_space_y[v19] - stru_50B700._screen_space_y[v61];
   if ( stru_50B700._screen_space_y[v19] != stru_50B700._screen_space_y[v61] )
   {
-    v21 = stru_50B700._screen_space_x[v20];
-    v5 = v60;
-    v61 = v21 << 16;
-    v53 = ((stru_50B700._screen_space_x[v19] - v21) << 16) / v53;
-    v60->array_3D8[v73] = LOWORD(stru_50B700._screen_space_x[v20]);
+    v61 = stru_50B700._screen_space_x[v20] << 16;
+    v53 = ((stru_50B700._screen_space_x[v19] - stru_50B700._screen_space_x[v20]) << 16) / stru_50B700._screen_space_y[v19] - stru_50B700._screen_space_y[v20];
+    a2->array_3D8[v73] = LOWORD(stru_50B700._screen_space_x[v20]);
   }
   v22 = v7;
-  v70 = v7;
   if ( v7 <= v73 )
   {
-    v56 = &v5->array_3D8[v7];
-    v23 = &v5->array_18[v7];
-    do
+    v56 = &a2->array_3D8[v7];
+    v23 = &a2->array_18[v7];
+    for ( v70 = v7; v70 <= v73; ++v70 )
     {
       v24 = v67;
       if ( v22 < stru_50B700._screen_space_y[v67] || v22 == v73 )
         goto LABEL_57;
       v25 = v64 + v67;
       v67 = v25;
-      if ( v25 < v74 )
+      if ( v25 < pNumVertices )
       {
         if ( v25 >= 0 )
           goto LABEL_55;
-        v25 += v74;
+        v25 += pNumVertices;
       }
       else
       {
-        v25 -= v74;
+        v25 -= pNumVertices;
       }
       v67 = v25;
 LABEL_55:
       v26 = v25;
-      v27 = stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24];
+      //v27 = stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24];
       if ( stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24] > 0 )
       {
-        v28 = stru_50B700._screen_space_x[v24];
-        v54 = ((stru_50B700._screen_space_x[v26] - v28) << 16) / v27;
-        v62 = v28 << 16;
+        v54 = ((stru_50B700._screen_space_x[v26] - stru_50B700._screen_space_x[v24]) << 16) / stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24];
+        v62 = stru_50B700._screen_space_x[v24] << 16;
       }
 LABEL_57:
       v29 = v66;
@@ -2477,27 +2468,26 @@
       {
         v30 = v63 + v66;
         v66 += v63;
-        if ( v66 >= v74 )
+        if ( v66 >= pNumVertices )
         {
-          v30 -= v74;
+          v30 -= pNumVertices;
           goto LABEL_63;
         }
         if ( v30 < 0 )
         {
-          v30 += v74;
+          v30 += pNumVertices;
 LABEL_63:
           v66 = v30;
         }
         v31 = v30;
-        v32 = stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29];
+        //v32 = stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29];
         if ( stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29] > 0 )
         {
-          v33 = stru_50B700._screen_space_x[v29];
-          v53 = ((stru_50B700._screen_space_x[v31] - v33) << 16) / v32;
-          v61 = v33 << 16;
+          v53 = ((stru_50B700._screen_space_x[v31] - stru_50B700._screen_space_x[v29]) << 16) / stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29];
+          v61 = stru_50B700._screen_space_x[v29] << 16;
         }
       }
-      *(__int16 *)((char *)v56 + (int)(char *)v5->array_18 - (char *)v5->array_3D8) = HIWORD(v62);
+      *(__int16 *)((char *)v56 + (int)(char *)a2->array_18 - (char *)a2->array_3D8) = HIWORD(v62);
       *v56 = HIWORD(v61);
       v34 = v23 + 480;
       v35 = v23[480];
@@ -2515,14 +2505,11 @@
       v22 = v70 + 1;
       v61 += v53;
       ++v23;
-      ++v70;
     }
-    while ( v70 <= v73 );
   }
-  v39 = a3;
   v40 = v73;
   if ( v73 < a3->_viewport_space_y || (v41 = a3->_viewport_space_w, v7 > v41) )
-    return 0;
+    return false;
   if ( v7 < a3->_viewport_space_y )
     v7 = a3->_viewport_space_y;
   if ( v73 > v41 )
@@ -2530,46 +2517,40 @@
     v40 = a3->_viewport_space_w;
     v73 = a3->_viewport_space_w;
   }
-  v71 = v7;
   if ( v7 <= v40 )
   {
-    a3a = (char *)v5 - (char *)a3;
-    v57 = &v5->array_18[v7];
-    v42 = &v39->array_3D8[v7];
-    do
+    a3a = (char *)a2 - (char *)a3;
+    v57 = &a2->array_18[v7];
+    v42 = &a3->array_3D8[v7];
+    for ( v71 = v7; v71 <= v40; ++v71 )
     {
-      if ( *(__int16 *)((char *)v42 + a3a) >= *(v42 - 480) && *v57 <= *v42 )
+      if ( *(__int16 *)((char *)v42 + a3a) >= *(v42 - 480) && a2->array_18[v71] <= a3->array_3D8[v71] )
         break;
       ++v57;
       ++v7;
-      ++v71;
       ++v42;
     }
-    while ( v71 <= v40 );
   }
-  v72 = v40;
   if ( v40 < v7 )
-    return 0;
-  v58 = &v5->array_18[v40];
-  v43 = &v39->array_3D8[v40];
-  do
+    return false;
+  v58 = &a2->array_18[v40];
+  v43 = &a3->array_3D8[v40];
+  for ( v72 = v40; v72 >= v7; --v72 )
   {
-    if ( *(__int16 *)((char *)v43 + (int)(char *)v5 - (char *)v39) >= *(v43 - 480) && *v58 <= *v43 )
+    if ( *(__int16 *)((char *)v43 + (int)(char *)a2 - (char *)a3) >= *(v43 - 480) && *v58 <= a3->array_3D8[v72] )
       break;
     --v58;
     --v40;
-    --v72;
     --v43;
     v73 = v40;
   }
-  while ( v72 >= v7 );
   if ( v7 >= v40 )
-    return 0;
-  a3b = (char *)v39 - (char *)v5;
-  v59 = &v39->array_3D8[v7];
-  v45 = &v5->array_18[v7];
-  v46 = v73 - v7 + 1;
-  do
+    return false;
+  a3b = (char *)a3 - (char *)a2;
+  v59 = &a3->array_3D8[v7];
+  v45 = &a2->array_18[v7];
+  
+  for ( v46 = v73 - v7 + 1; v46; --v46 )
   {
     v47 = *(__int16 *)((char *)v45 + a3b);
     if ( *v45 < v47 )
@@ -2578,40 +2559,35 @@
       v45[480] = *v59;
     ++v59;
     ++v45;
-    --v46;
   }
-  while ( v46 );
-  v5->_viewport_space_y = v7;
-  v5->_viewport_space_w = v73;
-  v5->field_8 = v5->array_18[v7];
-  v48 = v5->array_3D8[v7];
-  v5->field_10 = v7;
-  v5->field_14 = v7;
+  a2->_viewport_space_y = v7;
+  a2->_viewport_space_w = v73;
+  a2->field_8 = a2->array_18[v7];
+  v48 = a2->array_3D8[v7];
+  a2->field_10 = v7;
+  a2->field_14 = v7;
+  a2->field_C = v48;
   v49 = v7 + 1;
-  v5->field_C = v48;
   if ( v49 <= v73 )
   {
-    v50 = &v5->array_3D8[v49];
-    do
+    v50 = &a2->array_3D8[v49];
+    for ( v49; v49 <= v73; ++v49 )
     {
       v51 = *(v50 - 480);
-      if ( v51 < v5->field_8 )
+      if ( v51 < a2->field_8 )
       {
-        v5->field_8 = v51;
-        v5->field_10 = v49;
+        a2->field_8 = v51;
+        a2->field_10 = v49;
       }
-      v52 = *v50;
-      if ( v52 > v5->field_C )
+      if ( a2->array_3D8[v49] > a2->field_C )
       {
-        v5->field_C = v52;
-        v5->field_14 = v49;
+        a2->field_C = a2->array_3D8[v49];
+        a2->field_14 = v49;
       }
-      ++v49;
       ++v50;
     }
-    while ( v49 <= v73 );
   }
-  return 1;
+  return true;
 }
 // 50B700: using guessed type int stru_50B700.field_0;
 
--- a/mm7_2.cpp	Mon Jun 03 09:10:21 2013 +0600
+++ b/mm7_2.cpp	Mon Jun 03 09:32:05 2013 +0600
@@ -2163,1053 +2163,125 @@
 }
 
 //----- (00451007) --------------------------------------------------------
-int stru350::sub_451007_scale_image_bicubic(unsigned short *pSrc, int srcWidth, int srcHeight, int srcPitch,
+int stru350::sub_451007_scale_image_bicubic(unsigned short *pSrc, int srcWidth, int srcHeight, int srcPitch,          //changing this to some library function might be a good idea
                                             unsigned short *pDst, int dstWidth, int dstHeight, int dstPitch,
                                             int a10, int a11)
 {
-  int v11; // esi@1
   int result; // eax@1
-  int v13; // edi@8
-  int v14; // ecx@10
-  double v15; // st7@11
-  double v16; // st6@11
   float v17; // ST3C_4@12
   float v18; // ST38_4@12
   unsigned int v19; // esi@12
-  int v20; // eax@16
   int v21; // eax@18
   unsigned int v22; // ecx@25
   unsigned int v23; // eax@29
-  unsigned __int16 *v24; // ecx@29
-  int v25; // edi@33
-  int v26; // ecx@35
-  double v27; // st7@36
-  double v28; // st6@36
-  float v29; // ST34_4@37
-  float v30; // ST30_4@37
-  unsigned int v31; // esi@37
-  int v32; // eax@41
-  int v33; // eax@43
-  unsigned int v34; // ecx@50
-  unsigned __int16 v35; // ax@54
-  unsigned __int16 *v36; // ecx@54
-  int v37; // edi@58
-  int v38; // ecx@60
-  double v39; // st7@61
-  double v40; // st6@61
-  float v41; // ST34_4@62
-  float v42; // ST30_4@62
-  unsigned int v43; // esi@62
-  int v44; // eax@66
-  int v45; // eax@68
-  unsigned int v46; // ecx@75
-  char v47; // al@79
-  unsigned __int16 *v48; // ecx@79
-  int v49; // edi@86
-  int v50; // ecx@88
-  double v51; // st7@89
-  double v52; // st6@89
-  float v53; // ST34_4@90
-  float v54; // ST30_4@90
-  unsigned int v55; // esi@90
-  int v56; // eax@94
-  int v57; // eax@96
-  unsigned int v58; // ecx@103
-  unsigned int v59; // eax@107
-  unsigned __int16 *v60; // ecx@107
-  int v61; // edi@111
-  int v62; // ecx@113
-  double v63; // st7@114
-  double v64; // st6@114
-  float v65; // ST34_4@115
-  float v66; // ST30_4@115
-  unsigned int v67; // esi@115
-  int v68; // eax@119
-  int v69; // eax@121
-  unsigned int v70; // ecx@128
-  unsigned __int16 v71; // ax@132
-  unsigned __int16 *v72; // ecx@132
-  int v73; // edi@136
-  int v74; // ecx@138
-  double v75; // st7@139
-  double v76; // st6@139
-  float v77; // ST34_4@140
-  float v78; // ST30_4@140
-  unsigned int v79; // esi@140
-  int v80; // eax@144
-  int v81; // eax@146
-  unsigned int v82; // ecx@153
-  char v83; // al@157
-  unsigned __int16 *v84; // ecx@157
-  int v85; // edi@164
-  int v86; // ecx@166
-  double v87; // st7@167
-  double v88; // st6@167
-  float v89; // ST34_4@168
-  float v90; // ST30_4@168
-  unsigned int v91; // esi@168
-  signed int v92; // eax@170
-  int v93; // eax@171
-  int v94; // eax@173
-  unsigned int v95; // ecx@181
-  unsigned int v96; // eax@185
-  unsigned __int16 *v97; // ecx@185
-  int v98; // edi@189
-  int v99; // ecx@191
-  double v100; // st7@192
-  double v101; // st6@192
-  float v102; // ST34_4@193
-  float v103; // ST30_4@193
-  unsigned int v104; // esi@193
-  signed int v105; // eax@195
-  int v106; // eax@196
-  int v107; // eax@198
-  unsigned int v108; // ecx@206
-  unsigned __int16 v109; // ax@210
-  unsigned __int16 *v110; // ecx@210
-  int v111; // edi@214
-  int v112; // ecx@216
-  double v113; // st7@217
-  double v114; // st6@217
-  float v115; // ST34_4@218
-  float v116; // ST30_4@218
-  unsigned int v117; // esi@218
-  signed int v118; // eax@220
-  int v119; // eax@221
-  int v120; // eax@223
-  unsigned int v121; // ecx@231
-  char v122; // al@235
-  unsigned __int16 *v123; // ecx@235
-  double v124; // [sp+Ch] [bp-7Ch]@12
-  double v125; // [sp+Ch] [bp-7Ch]@37
-  double v126; // [sp+Ch] [bp-7Ch]@62
-  double v127; // [sp+Ch] [bp-7Ch]@90
-  //double v128; // [sp+Ch] [bp-7Ch]@115
-  uint _v128;
-  double v129; // [sp+Ch] [bp-7Ch]@140
-  double v130; // [sp+Ch] [bp-7Ch]@168
-  double v131; // [sp+Ch] [bp-7Ch]@193
-  double v132; // [sp+Ch] [bp-7Ch]@218
-  double v133; // [sp+14h] [bp-74h]@12
-  double v134; // [sp+14h] [bp-74h]@37
-  double v135; // [sp+14h] [bp-74h]@62
-  double v136; // [sp+14h] [bp-74h]@90
-  //double v137; // [sp+14h] [bp-74h]@115
-  uint _v137;
-  double v138; // [sp+14h] [bp-74h]@140
-  double v139; // [sp+14h] [bp-74h]@168
-  double v140; // [sp+14h] [bp-74h]@193
-  double v141; // [sp+14h] [bp-74h]@218
-  double v142; // [sp+1Ch] [bp-6Ch]@12
-  double v143; // [sp+1Ch] [bp-6Ch]@37
-  double v144; // [sp+1Ch] [bp-6Ch]@62
-  double v145; // [sp+1Ch] [bp-6Ch]@90
-  //double v146; // [sp+1Ch] [bp-6Ch]@115
-  uint _v146;
-  double v147; // [sp+1Ch] [bp-6Ch]@140
-  double v148; // [sp+1Ch] [bp-6Ch]@168
-  double v149; // [sp+1Ch] [bp-6Ch]@193
-  double v150; // [sp+1Ch] [bp-6Ch]@218
-  double v151; // [sp+24h] [bp-64h]@12
-  double v152; // [sp+24h] [bp-64h]@37
-  double v153; // [sp+24h] [bp-64h]@62
-  double v154; // [sp+24h] [bp-64h]@90
-  //double v155; // [sp+24h] [bp-64h]@115
-  uint _v155;
-  double v156; // [sp+24h] [bp-64h]@140
-  double v157; // [sp+24h] [bp-64h]@168
-  double v158; // [sp+24h] [bp-64h]@193
-  double v159; // [sp+24h] [bp-64h]@218
+  unsigned int heightRatioPlusOne; // [sp+Ch] [bp-7Ch]@12
+  unsigned int widthRatio; // [sp+Ch] [bp-7Ch]@218
+  unsigned int heightRatio; // [sp+14h] [bp-74h]@12
+  unsigned int widthRatioPlusOne; // [sp+14h] [bp-74h]@218
   int v160; // [sp+3Ch] [bp-4Ch]@13
-  int v161; // [sp+40h] [bp-48h]@15
-  int v162; // [sp+44h] [bp-44h]@40
-  int v163; // [sp+44h] [bp-44h]@65
-  int v164; // [sp+44h] [bp-44h]@93
-  int v165; // [sp+44h] [bp-44h]@118
-  int v166; // [sp+44h] [bp-44h]@143
-  int v167; // [sp+44h] [bp-44h]@169
-  int v168; // [sp+44h] [bp-44h]@194
-  int v169; // [sp+44h] [bp-44h]@219
-  int v170; // [sp+48h] [bp-40h]@38
-  int v171; // [sp+48h] [bp-40h]@63
-  int v172; // [sp+48h] [bp-40h]@91
-  int v173; // [sp+48h] [bp-40h]@116
-  int v174; // [sp+48h] [bp-40h]@141
   unsigned __int16 *v175; // [sp+4Ch] [bp-3Ch]@13
-  int *v176; // [sp+50h] [bp-38h]@15
-  int *v177; // [sp+50h] [bp-38h]@40
-  int *v178; // [sp+50h] [bp-38h]@65
-  int *v179; // [sp+50h] [bp-38h]@93
-  int *v180; // [sp+50h] [bp-38h]@118
-  int *v181; // [sp+50h] [bp-38h]@143
-  char *v182; // [sp+50h] [bp-38h]@169
-  char *v183; // [sp+50h] [bp-38h]@194
-  char *v184; // [sp+50h] [bp-38h]@219
-  unsigned __int16 *v185; // [sp+54h] [bp-34h]@38
-  unsigned __int16 *v186; // [sp+54h] [bp-34h]@63
-  unsigned __int16 *v187; // [sp+54h] [bp-34h]@91
-  unsigned __int16 *v188; // [sp+54h] [bp-34h]@116
-  unsigned __int16 *v189; // [sp+54h] [bp-34h]@141
-  signed int v190; // [sp+54h] [bp-34h]@170
-  signed int v191; // [sp+54h] [bp-34h]@195
-  signed int v192; // [sp+54h] [bp-34h]@220
   unsigned __int16 *v193; // [sp+5Ch] [bp-2Ch]@7
-  unsigned __int16 *v194; // [sp+5Ch] [bp-2Ch]@32
-  unsigned __int16 *v195; // [sp+5Ch] [bp-2Ch]@57
-  unsigned __int16 *v196; // [sp+5Ch] [bp-2Ch]@85
-  unsigned __int16 *v197; // [sp+5Ch] [bp-2Ch]@110
-  unsigned __int16 *v198; // [sp+5Ch] [bp-2Ch]@135
-  unsigned __int16 *v199; // [sp+5Ch] [bp-2Ch]@163
-  unsigned __int16 *v200; // [sp+5Ch] [bp-2Ch]@188
-  unsigned __int16 *v201; // [sp+5Ch] [bp-2Ch]@213
-  //stru350 *v202; // [sp+60h] [bp-28h]@1
-  int v203; // [sp+64h] [bp-24h]@12
-  int v204; // [sp+64h] [bp-24h]@37
-  int v205; // [sp+64h] [bp-24h]@62
-  int v206; // [sp+64h] [bp-24h]@90
-  int v207; // [sp+64h] [bp-24h]@115
-  int v208; // [sp+64h] [bp-24h]@140
-  int v209; // [sp+64h] [bp-24h]@168
-  int v210; // [sp+64h] [bp-24h]@193
-  int v211; // [sp+64h] [bp-24h]@218
-  float v212; // [sp+6Ch] [bp-1Ch]@11
-  float v213; // [sp+6Ch] [bp-1Ch]@36
-  float v214; // [sp+6Ch] [bp-1Ch]@61
-  float v215; // [sp+6Ch] [bp-1Ch]@89
-  float v216; // [sp+6Ch] [bp-1Ch]@114
-  float v217; // [sp+6Ch] [bp-1Ch]@139
-  float v218; // [sp+6Ch] [bp-1Ch]@167
-  float v219; // [sp+6Ch] [bp-1Ch]@192
-  float v220; // [sp+6Ch] [bp-1Ch]@217
-  float v221; // [sp+70h] [bp-18h]@11
-  float v222; // [sp+70h] [bp-18h]@36
-  float v223; // [sp+70h] [bp-18h]@61
-  float v224; // [sp+70h] [bp-18h]@89
-  float v225; // [sp+70h] [bp-18h]@114
-  float v226; // [sp+70h] [bp-18h]@139
-  float v227; // [sp+70h] [bp-18h]@167
-  float v228; // [sp+70h] [bp-18h]@192
-  float v229; // [sp+70h] [bp-18h]@217
-  signed int v230; // [sp+74h] [bp-14h]@1
   signed int v231; // [sp+78h] [bp-10h]@7
-  signed int v232; // [sp+78h] [bp-10h]@32
-  signed int v233; // [sp+78h] [bp-10h]@57
-  signed int v234; // [sp+78h] [bp-10h]@85
-  signed int v235; // [sp+78h] [bp-10h]@110
-  signed int v236; // [sp+78h] [bp-10h]@135
-  signed int v237; // [sp+78h] [bp-10h]@163
-  signed int v238; // [sp+78h] [bp-10h]@188
-  signed int v239; // [sp+78h] [bp-10h]@213
   __int64 v240; // [sp+7Ch] [bp-Ch]@12
-  __int64 v241; // [sp+7Ch] [bp-Ch]@37
-  __int64 v242; // [sp+7Ch] [bp-Ch]@62
-  __int64 v243; // [sp+7Ch] [bp-Ch]@90
-  __int64 v244; // [sp+7Ch] [bp-Ch]@115
-  __int64 v245; // [sp+7Ch] [bp-Ch]@140
-  unsigned int v246; // [sp+7Ch] [bp-Ch]@168
-  unsigned int v247; // [sp+7Ch] [bp-Ch]@193
-  unsigned int v248; // [sp+7Ch] [bp-Ch]@218
-  unsigned int v249; // [sp+80h] [bp-8h]@168
-  unsigned int v250; // [sp+80h] [bp-8h]@193
   unsigned int v251; // [sp+80h] [bp-8h]@218
-  unsigned int v252; // [sp+84h] [bp-4h]@12
-  unsigned int v253; // [sp+84h] [bp-4h]@37
-  unsigned int v254; // [sp+84h] [bp-4h]@62
-  unsigned int v255; // [sp+84h] [bp-4h]@90
-  unsigned int v256; // [sp+84h] [bp-4h]@115
-  unsigned int v257; // [sp+84h] [bp-4h]@140
-  unsigned int v258; // [sp+84h] [bp-4h]@168
-  unsigned int v259; // [sp+84h] [bp-4h]@193
-  unsigned int v260; // [sp+84h] [bp-4h]@218
-  signed int a6a; // [sp+A0h] [bp+18h]@10
-  float a6s; // [sp+A0h] [bp+18h]@12
-  float a6t; // [sp+A0h] [bp+18h]@12
-  unsigned int a6b; // [sp+A0h] [bp+18h]@12
-  signed int a6c; // [sp+A0h] [bp+18h]@35
-  float a6u; // [sp+A0h] [bp+18h]@37
-  float a6v; // [sp+A0h] [bp+18h]@37
-  unsigned int a6d; // [sp+A0h] [bp+18h]@37
-  signed int a6e; // [sp+A0h] [bp+18h]@60
-  float a6w; // [sp+A0h] [bp+18h]@62
-  float a6x; // [sp+A0h] [bp+18h]@62
-  unsigned int a6f; // [sp+A0h] [bp+18h]@62
-  signed int a6g; // [sp+A0h] [bp+18h]@88
-  float a6y; // [sp+A0h] [bp+18h]@90
-  float a6z; // [sp+A0h] [bp+18h]@90
-  unsigned int a6h; // [sp+A0h] [bp+18h]@90
-  signed int a6i; // [sp+A0h] [bp+18h]@113
-  float a6ba; // [sp+A0h] [bp+18h]@115
-  float a6bb; // [sp+A0h] [bp+18h]@115
-  unsigned int a6j; // [sp+A0h] [bp+18h]@115
-  signed int a6k; // [sp+A0h] [bp+18h]@138
-  float a6bc; // [sp+A0h] [bp+18h]@140
-  float a6bd; // [sp+A0h] [bp+18h]@140
-  unsigned int a6l; // [sp+A0h] [bp+18h]@140
-  signed int a6m; // [sp+A0h] [bp+18h]@166
-  float a6be; // [sp+A0h] [bp+18h]@168
-  float a6bf; // [sp+A0h] [bp+18h]@168
-  unsigned int a6n; // [sp+A0h] [bp+18h]@168
-  signed int a6o; // [sp+A0h] [bp+18h]@191
-  float a6bg; // [sp+A0h] [bp+18h]@193
-  float a6bh; // [sp+A0h] [bp+18h]@193
-  unsigned int a6p; // [sp+A0h] [bp+18h]@193
-  signed int a6q; // [sp+A0h] [bp+18h]@216
-  float a6bi; // [sp+A0h] [bp+18h]@218
-  float a6bj; // [sp+A0h] [bp+18h]@218
-  unsigned int a6r; // [sp+A0h] [bp+18h]@218
-  int a9a; // [sp+ACh] [bp+24h]@8
-  int a9b; // [sp+ACh] [bp+24h]@33
-  int a9c; // [sp+ACh] [bp+24h]@86
-  int a9d; // [sp+ACh] [bp+24h]@111
-  int a9e; // [sp+ACh] [bp+24h]@164
-  int a9f; // [sp+ACh] [bp+24h]@189
-  int vxx;
-
-  v11 = 0;
-  result = this->field_0.field_C;
-  //v202 = this;
-  v230 = 0;
-  if ( result != 8 )
-  {
-    if ( result != 16 )
-    {
-      if ( result != 32 )
-        return result;
-      result = this->field_20.field_C;
-      if ( result != 8 )
-      {
-        if ( result != 16 )
-        {
-          if ( result != 32 || (result = (int)pDst, v193 = pDst, v231 = 0, dstHeight <= 0) )
-            return result;
-          v13 = dstWidth;
-          a9a = 4 * (dstPitch - dstWidth);
-          while ( 1 )
-          {
-            v14 = 0;
-            a6a = 0;
-            if ( dstWidth > v11 )
-              break;
-LABEL_30:
-            v193 = (unsigned __int16 *)((char *)v193 + a9a);
-            ++v231;
-            result = v231;
-            if ( v231 >= dstHeight )
-              return result;
-            v11 = 0;
-          }
-          v221 = (double)dstWidth;
-          v212 = (double)srcWidth;
-          v15 = (double)dstHeight;
-          v16 = (double)srcHeight;
-          while ( 1 )
-          {
-            a6s = (double)a6a / v221 * v212;
-            v151 = floorf(a6s + 0.5f);//a6s + 6.7553994e15;
-            v203 = v14 + 1;
-            a6t = (double)(v14 + 1) / v221 * v212;
-            v142 = floorf(a6t + 0.5f);//a6t + 6.7553994e15;
-            v17 = (double)v231 / v15 * v16;
-            v133 = floorf(v17 + 0.5f);//v17 + 6.7553994e15;
-            v18 = (double)(v231 + 1) / v15 * v16;
-            v124 = floorf(v18 + 0.5f);//v18 + 6.7553994e15;
-            v19 = (LODWORD(v124) - LODWORD(v133)) * (LODWORD(v142) - LODWORD(v151));
-            v252 = 0;
-            a6b = 0;
-            v240 = 0i64;
-            if ( SLODWORD(v133) < SLODWORD(v124) )
-              break;
-LABEL_25:
-            v22 = (unsigned int)v240 / ((LODWORD(v124) - LODWORD(v133)) * (LODWORD(v142) - LODWORD(v151)));
-            if ( v19 )
-            {
-              a6b /= v19;
-              v252 /= v19;
-              HIDWORD(v240) /= v19;
-            }
-            if ( v22 != 255 )
-              v22 &= 0x7FFFFFFFu;
-            v23 = _450F55(HIDWORD(v240) | ((v252 | ((a6b | (v22 << 8)) << 8)) << 8));
-            v24 = v193;
-            v193 += 2;
-            *(_DWORD *)v24 = v23;
-            v14 = v203;
-            a6a = v203;
-            if ( v203 >= dstWidth )
-              goto LABEL_30;
-          }
-          v160 = LODWORD(v124) - LODWORD(v133);
-          v175 = &pSrc[2 * (LODWORD(v151) + srcPitch * LODWORD(v133))];
-          while ( SLODWORD(v151) >= SLODWORD(v142) )
-          {
-LABEL_24:
-            v175 += 2 * srcPitch;
-            --v160;
-            if ( !v160 )
-              goto LABEL_25;
-          }
-          v176 = (int *)v175;
-          v161 = LODWORD(v142) - LODWORD(v151);
-          while ( 1 )
-          {
-            v20 = *v176;
-            if ( a10 )
-            {
-              v230 = 1;
-              v13 = v20 != a11 ? 0xFF : 0;
-            }
-            v21 = _450FB1(v20);
-            if ( !v230 )
-              break;
-            LODWORD(v240) = v13 + v240;
-            v230 = 0;
-            if ( v13 )
-              goto LABEL_22;
-            --v19;
-LABEL_23:
-            ++v176;
-            --v161;
-            if ( !v161 )
-              goto LABEL_24;
-          }
-          LODWORD(v240) = ((unsigned int)v21 >> 24) + v240;
-LABEL_22:
+  unsigned int v252; // [sp+84h] [bp-4h]@218
+  float a6s; // [sp+A0h] [bp+18h]@218
+  float a6t; // [sp+A0h] [bp+18h]@218
+  unsigned int a6b; // [sp+A0h] [bp+18h]@218
+  int field_0_bits;
+  int field_20_bits;
+  
+  int field0value = this->field_0.field_C;
+  switch(field0value)
+  {
+  case 8: field_0_bits = 1;
+    break;
+  case 16: field_0_bits = 2;
+    break;
+  case 32: field_0_bits = 4;
+    break;
+  default:
+    return field0value;
+  }
+  int field20value = this->field_20.field_C;
+  switch(field20value)
+  {
+  case 8: field_20_bits = 1;
+    break;
+  case 16: field_20_bits = 2;
+    break;
+  case 32: field_20_bits = 4;
+    break;
+  default:
+    return field20value;
+  }
+
+  result = (int)pDst;
+  v193 = pDst;
+  v231 = 0;
+  if ( dstHeight <= 0 )
+    return result;
+  do
+  {
+    for (int counter = 0; counter < dstWidth; counter++)
+    {
+      a6s = (double)counter / (double)dstWidth * (double)srcWidth;
+      widthRatio = bankersRounding(a6s);
+      a6t = (double)(counter + 1) / (double)dstWidth * (double)srcWidth;
+      widthRatioPlusOne = bankersRounding(a6t);
+      v17 = (double)v231 / (double)dstHeight * (double)srcHeight;
+      heightRatio = bankersRounding(v17);
+      v18 = (double)(v231 + 1) / (double)dstHeight * (double)srcHeight;
+      heightRatioPlusOne = bankersRounding(v18);
+      v251 = 0;
+      v19 = (heightRatioPlusOne - heightRatio) * (widthRatioPlusOne - widthRatio);
+      v252 = 0;
+      a6b = 0;
+      v240 = 0i64;
+
+      v175 = (unsigned short*)((char *)pSrc + field_0_bits * (widthRatio + srcPitch * heightRatio));
+      for (int heightDiff = 0; heightDiff < heightRatioPlusOne - heightRatio; heightDiff++)
+      {
+        int ratioDiff = widthRatioPlusOne - widthRatio;
+        for(int i = 0; i < ratioDiff; i++)
+        {
+          if(field0value == 32)
+            v21 = _450FB1((int)v175[i]);
+          else if(field0value == 16)
+            v21 = _450FB1((_WORD)v175[i]);
+          else
+            v21 = _450FB1((unsigned __int8)v175[i]);
+          v240 += ((unsigned int)v21 >> 24);
           a6b += BYTE2(v21);
           v252 += BYTE1(v21);
-          HIDWORD(v240) += (unsigned __int8)v21;
-          goto LABEL_23;
-        }
-        result = (int)pDst;
-        v194 = pDst;
-        v232 = 0;
-        if ( dstHeight <= 0 )
-          return result;
-        v25 = dstWidth;
-        a9b = 2 * (dstPitch - dstWidth);
-        while ( 1 )
-        {
-          v26 = 0;
-          a6c = 0;
-          if ( dstWidth > v11 )
-            break;
-LABEL_55:
-          v194 = (unsigned __int16 *)((char *)v194 + a9b);
-          ++v232;
-          result = v232;
-          if ( v232 >= dstHeight )
-            return result;
-          v11 = 0;
-        }
-        v222 = (double)dstWidth;
-        v213 = (double)srcWidth;
-        v27 = (double)dstHeight;
-        v28 = (double)srcHeight;
-        while ( 1 )
-        {
-          a6u = (double)a6c / v222 * v213;
-          v125 = a6u + 6.7553994e15;
-          v204 = v26 + 1;
-          a6v = (double)(v26 + 1) / v222 * v213;
-          v134 = a6v + 6.7553994e15;
-          v29 = (double)v232 / v27 * v28;
-          v143 = v29 + 6.7553994e15;
-          v30 = (double)(v232 + 1) / v27 * v28;
-          v152 = v30 + 6.7553994e15;
-          v31 = (LODWORD(v152) - LODWORD(v143)) * (LODWORD(v134) - LODWORD(v125));
-          v253 = 0;
-          a6d = 0;
-          v241 = 0i64;
-          if ( SLODWORD(v143) < SLODWORD(v152) )
-            break;
-LABEL_50:
-          v34 = (unsigned int)v241 / ((LODWORD(v152) - LODWORD(v143)) * (LODWORD(v134) - LODWORD(v125)));
-          if ( v31 )
-          {
-            a6d /= v31;
-            v253 /= v31;
-            HIDWORD(v241) /= v31;
-          }
-          if ( v34 != 255 )
-            v34 &= 0x7FFFFFFFu;
-          v35 = _450F55(HIDWORD(v241) | ((v253 | ((a6d | (v34 << 8)) << 8)) << 8));
-          v36 = v194;
-          ++v194;
-          *v36 = v35;
-          v26 = v204;
-          a6c = v204;
-          if ( v204 >= dstWidth )
-            goto LABEL_55;
-        }
-        v170 = LODWORD(v152) - LODWORD(v143);
-        v185 = &pSrc[2 * (LODWORD(v125) + srcPitch * LODWORD(v143))];
-        while ( SLODWORD(v125) >= SLODWORD(v134) )
-        {
-LABEL_49:
-          v185 += 2 * srcPitch;
-          --v170;
-          if ( !v170 )
-            goto LABEL_50;
-        }
-        v177 = (int *)v185;
-        v162 = LODWORD(v134) - LODWORD(v125);
-        while ( 1 )
-        {
-          v32 = *v177;
-          if ( a10 )
-          {
-            v230 = 1;
-            v25 = v32 != a11 ? 0xFF : 0;
-          }
-          v33 = _450FB1(v32);
-          if ( !v230 )
-            break;
-          LODWORD(v241) = v25 + v241;
-          v230 = 0;
-          if ( v25 )
-            goto LABEL_47;
-          --v31;
-LABEL_48:
-          ++v177;
-          --v162;
-          if ( !v162 )
-            goto LABEL_49;
-        }
-        LODWORD(v241) = ((unsigned int)v33 >> 24) + v241;
-LABEL_47:
-        a6d += BYTE2(v33);
-        v253 += BYTE1(v33);
-        HIDWORD(v241) += (unsigned __int8)v33;
-        goto LABEL_48;
-      }
-      result = (int)pDst;
-      v195 = pDst;
-      v233 = 0;
-      if ( dstHeight <= 0 )
-        return result;
-      v37 = dstWidth;
-      while ( 1 )
-      {
-        v38 = 0;
-        a6e = 0;
-        if ( dstWidth > v11 )
-          break;
-LABEL_80:
-        v195 = (unsigned __int16 *)((char *)v195 + dstPitch - dstWidth);
-        ++v233;
-        result = v233;
-        if ( v233 >= dstHeight )
-          return result;
-        v11 = 0;
-      }
-      v223 = (double)dstWidth;
-      v214 = (double)srcWidth;
-      v39 = (double)dstHeight;
-      v40 = (double)srcHeight;
-      while ( 1 )
-      {
-        a6w = (double)a6e / v223 * v214;
-        v126 = a6w + 6.7553994e15;
-        v205 = v38 + 1;
-        a6x = (double)(v38 + 1) / v223 * v214;
-        v135 = a6x + 6.7553994e15;
-        v41 = (double)v233 / v39 * v40;
-        v144 = v41 + 6.7553994e15;
-        v42 = (double)(v233 + 1) / v39 * v40;
-        v153 = v42 + 6.7553994e15;
-        v43 = (LODWORD(v153) - LODWORD(v144)) * (LODWORD(v135) - LODWORD(v126));
-        v254 = 0;
-        a6f = 0;
-        v242 = 0i64;
-        if ( SLODWORD(v144) < SLODWORD(v153) )
-          break;
-LABEL_75:
-        v46 = (unsigned int)v242 / ((LODWORD(v153) - LODWORD(v144)) * (LODWORD(v135) - LODWORD(v126)));
-        if ( v43 )
-        {
-          a6f /= v43;
-          v254 /= v43;
-          HIDWORD(v242) /= v43;
-        }
-        if ( v46 != 255 )
-          v46 &= 0x7FFFFFFFu;
-        v47 = _450F55(HIDWORD(v242) | ((v254 | ((a6f | (v46 << 8)) << 8)) << 8));
-        v48 = v195;
-        v195 = (unsigned __int16 *)((char *)v195 + 1);
-        *(_BYTE *)v48 = v47;
-        v38 = v205;
-        a6e = v205;
-        if ( v205 >= dstWidth )
-          goto LABEL_80;
-      }
-      v171 = LODWORD(v153) - LODWORD(v144);
-      v186 = &pSrc[2 * (LODWORD(v126) + srcPitch * LODWORD(v144))];
-      while ( SLODWORD(v126) >= SLODWORD(v135) )
-      {
-LABEL_74:
-        v186 += 2 * srcPitch;
-        --v171;
-        if ( !v171 )
-          goto LABEL_75;
-      }
-      v178 = (int *)v186;
-      v163 = LODWORD(v135) - LODWORD(v126);
-      while ( 1 )
-      {
-        v44 = *v178;
-        if ( a10 )
-        {
-          v230 = 1;
-          v37 = v44 != a11 ? 0xFF : 0;
-        }
-        v45 = _450FB1(v44);
-        if ( !v230 )
-          break;
-        LODWORD(v242) = v37 + v242;
-        v230 = 0;
-        if ( v37 )
-          goto LABEL_72;
-        --v43;
-LABEL_73:
-        ++v178;
-        --v163;
-        if ( !v163 )
-          goto LABEL_74;
-      }
-      LODWORD(v242) = ((unsigned int)v45 >> 24) + v242;
-LABEL_72:
-      a6f += BYTE2(v45);
-      v254 += BYTE1(v45);
-      HIDWORD(v242) += (unsigned __int8)v45;
-      goto LABEL_73;
-    }
-    result = this->field_20.field_C;
-    if ( result != 8 )
-    {
-      if ( result != 16 )
-      {
-        if ( result != 32 || (result = (int)pDst, v196 = pDst, v234 = 0, dstHeight <= 0) )
-          return result;
-        v49 = dstWidth;
-        a9c = 4 * (dstPitch - dstWidth);
-        while ( 1 )
-        {
-          v50 = 0;
-          a6g = 0;
-          if ( dstWidth > v11 )
-            break;
-LABEL_108:
-          v196 = (unsigned __int16 *)((char *)v196 + a9c);
-          ++v234;
-          result = v234;
-          if ( v234 >= dstHeight )
-            return result;
-          v11 = 0;
-        }
-        v224 = (double)dstWidth;
-        v215 = (double)srcWidth;
-        v51 = (double)dstHeight;
-        v52 = (double)srcHeight;
-        while ( 1 )
-        {
-          a6y = (double)a6g / v224 * v215;
-          v127 = a6y + 6.7553994e15;
-          v206 = v50 + 1;
-          a6z = (double)(v50 + 1) / v224 * v215;
-          v136 = a6z + 6.7553994e15;
-          v53 = (double)v234 / v51 * v52;
-          v145 = v53 + 6.7553994e15;
-          v54 = (double)(v234 + 1) / v51 * v52;
-          v154 = v54 + 6.7553994e15;
-          v55 = (LODWORD(v154) - LODWORD(v145)) * (LODWORD(v136) - LODWORD(v127));
-          v255 = 0;
-          a6h = 0;
-          v243 = 0i64;
-          if ( SLODWORD(v145) < SLODWORD(v154) )
-            break;
-LABEL_103:
-          v58 = (unsigned int)v243 / ((LODWORD(v154) - LODWORD(v145)) * (LODWORD(v136) - LODWORD(v127)));
-          if ( v55 )
-          {
-            a6h /= v55;
-            v255 /= v55;
-            HIDWORD(v243) /= v55;
-          }
-          if ( v58 != 255 )
-            v58 &= 0x7FFFFFFFu;
-          v59 = _450F55(HIDWORD(v243) | ((v255 | ((a6h | (v58 << 8)) << 8)) << 8));
-          v60 = v196;
-          v196 += 2;
-          *(_DWORD *)v60 = v59;
-          v50 = v206;
-          a6g = v206;
-          if ( v206 >= dstWidth )
-            goto LABEL_108;
-        }
-        v172 = LODWORD(v154) - LODWORD(v145);
-        v187 = &pSrc[LODWORD(v127) + srcPitch * LODWORD(v145)];
-        while ( SLODWORD(v127) >= SLODWORD(v136) )
-        {
-LABEL_102:
-          v187 += srcPitch;
-          --v172;
-          if ( !v172 )
-            goto LABEL_103;
-        }
-        v179 = (int *)v187;
-        v164 = LODWORD(v136) - LODWORD(v127);
-        while ( 1 )
-        {
-          v56 = *(_WORD *)v179;
-          if ( a10 )
-          {
-            v230 = 1;
-            v49 = v56 != a11 ? 0xFF : 0;
-          }
-          v57 = _450FB1(v56);
-          if ( !v230 )
-            break;
-          LODWORD(v243) = v49 + v243;
-          v230 = 0;
-          if ( v49 )
-            goto LABEL_100;
-          --v55;
-LABEL_101:
-          v179 = (int *)((char *)v179 + 2);
-          --v164;
-          if ( !v164 )
-            goto LABEL_102;
-        }
-        LODWORD(v243) = ((unsigned int)v57 >> 24) + v243;
-LABEL_100:
-        a6h += BYTE2(v57);
-        v255 += BYTE1(v57);
-        HIDWORD(v243) += (unsigned __int8)v57;
-        goto LABEL_101;
-      }
-      result = (int)pDst;
-      v197 = pDst;
-      v235 = 0;
-      if ( dstHeight <= 0 )
-        return result;
-      v61 = dstWidth;
-      a9d = 2 * (dstPitch - dstWidth);
-      while ( 1 )
-      {
-        v62 = 0;
-        a6i = 0;
-        if ( dstWidth > v11 )
-          break;
-LABEL_133:
-        v197 = (unsigned __int16 *)((char *)v197 + a9d);
-        ++v235;
-        result = v235;
-        if ( v235 >= dstHeight )
-          return result;
-        v11 = 0;
-      }
-      v225 = (double)dstWidth;
-      v216 = (double)srcWidth;
-      v63 = (double)dstHeight;
-      v64 = (double)srcHeight;
-      while ( 1 )
-      {
-        a6ba = (double)a6i / v225 * v216;
-        _v128 = ceilf(a6ba - 0.5f);
-        //v128 = a6ba + 6.7553994e15;
-        v207 = v62 + 1;
-        a6bb = (double)(v62 + 1) / v225 * v216;
-        //v137 = a6bb + 6.7553994e15;
-        _v137 = ceilf(a6bb - 0.5f);
-        v65 = (double)v235 / v63 * v64;
-        //v146 = v65 + 6.7553994e15;
-        _v146 = ceilf(v65 - 0.5f);
-        v66 = (double)(v235 + 1) / v63 * v64;
-        //v155 = v66 + 6.7553994e15;
-        _v155 = ceilf(v66 - 0.5f);
-        v67 = (_v155 - _v146) * (_v137 - _v128);
-        v256 = 0;
-        a6j = 0;
-        v244 = 0i64;
-        //if ( SLODWORD(v146) < SLODWORD(v155) )
-        if (_v146 < _v155)
-          break;
-LABEL_128:
-        //v70 = (unsigned int)v244 / ((LODWORD(v155) - LODWORD(v146)) * (LODWORD(v137) - LODWORD(v128)));
-        v70 = (unsigned int)v244 / ((_v155 - _v146) * (_v137 - _v128));
-        if ( v67 )
-        {
-          a6j /= v67;
-          v256 /= v67;
-          HIDWORD(v244) /= v67;
-        }
-        if ( v70 != 255 )
-          v70 &= 0x7FFFFFFFu;
-        v71 = _450F55(HIDWORD(v244) | ((v256 | ((a6j | (v70 << 8)) << 8)) << 8));
-        *v197 = v71;
-        ++v197;
-        v62 = v207;
-        a6i = v207;
-        if ( v207 >= dstWidth )
-          goto LABEL_133;
-      }
-      //v173 = LODWORD(v155) - LODWORD(v146);
-      v173 = _v155 - _v146;
-      //v188 = &pSrc[LODWORD(v128) + srcPitch * LODWORD(v146)];
-      v188 = &pSrc[_v128 + srcPitch * _v146];
-      //while ( SLODWORD(v128) >= SLODWORD(v137) )
-      while (_v128 >= _v137)
-      {
-LABEL_127:
-        v188 += srcPitch;
-        --v173;
-        if ( !v173 )
-          goto LABEL_128;
-      }
-      v180 = (int *)v188;
-      //v165 = LODWORD(v137) - LODWORD(v128);
-      v165 = _v137 - _v128;
-      while ( 1 )
-      {
-        v68 = *(_WORD *)v180;
-        if ( a10 )
-        {
-          v230 = 1;
-          v61 = v68 != a11 ? 0xFF : 0;
-        }
-        v69 = _450FB1(v68);
-        if ( !v230 )
-          break;
-        LODWORD(v244) = v61 + v244;
-        v230 = 0;
-        if ( v61 )
-          goto LABEL_125;
-        --v67;
-LABEL_126:
-        v180 = (int *)((char *)v180 + 2);
-        --v165;
-        if ( !v165 )
-          goto LABEL_127;
-      }
-      LODWORD(v244) = ((unsigned int)v69 >> 24) + v244;
-LABEL_125:
-      a6j += BYTE2(v69);
-      v256 += BYTE1(v69);
-      HIDWORD(v244) += (unsigned __int8)v69;
-      goto LABEL_126;
-    }
-    result = (int)pDst;
-    v198 = pDst;
-    v236 = 0;
-    if ( dstHeight <= 0 )
-      return result;
-    v73 = dstWidth;
-    while ( 1 )
-    {
-      v74 = 0;
-      a6k = 0;
-      if ( dstWidth > v11 )
-        break;
-LABEL_158:
-      v198 = (unsigned __int16 *)((char *)v198 + dstPitch - dstWidth);
-      ++v236;
-      result = v236;
-      if ( v236 >= dstHeight )
-        return result;
-      v11 = 0;
-    }
-    v226 = (double)dstWidth;
-    v217 = (double)srcWidth;
-    v75 = (double)dstHeight;
-    v76 = (double)srcHeight;
-    while ( 1 )
-    {
-      a6bc = (double)a6k / v226 * v217;
-      v129 = a6bc + 6.7553994e15;
-      v208 = v74 + 1;
-      a6bd = (double)(v74 + 1) / v226 * v217;
-      v138 = a6bd + 6.7553994e15;
-      v77 = (double)v236 / v75 * v76;
-      v147 = v77 + 6.7553994e15;
-      v78 = (double)(v236 + 1) / v75 * v76;
-      v156 = v78 + 6.7553994e15;
-      v257 = 0;
-      v79 = (LODWORD(v156) - LODWORD(v147)) * (LODWORD(v138) - LODWORD(v129));
-      a6l = 0;
-      v245 = 0i64;
-      if ( SLODWORD(v147) < SLODWORD(v156) )
-        break;
-LABEL_153:
-      v82 = (unsigned int)v245 / ((LODWORD(v156) - LODWORD(v147)) * (LODWORD(v138) - LODWORD(v129)));
-      if ( v79 )
-      {
-        a6l /= v79;
-        v257 /= v79;
-        HIDWORD(v245) /= v79;
-      }
-      if ( v82 != 255 )
-        v82 &= 0x7FFFFFFFu;
-      v83 = _450F55(HIDWORD(v245) | ((v257 | ((a6l | (v82 << 8)) << 8)) << 8));
-      *v198 = v83;
-      v198 = (unsigned __int16 *)((char *)v198 + 1);
-      v74 = v208;
-      a6k = v208;
-      if ( v208 >= dstWidth )
-        goto LABEL_158;
-    }
-    v174 = LODWORD(v156) - LODWORD(v147);
-    v189 = &pSrc[LODWORD(v129) + srcPitch * LODWORD(v147)];
-    while ( SLODWORD(v129) >= SLODWORD(v138) )
-    {
-LABEL_152:
-      v189 += srcPitch;
-      --v174;
-      if ( !v174 )
-        goto LABEL_153;
-    }
-    v166 = LODWORD(v138) - LODWORD(v129);
-    v181 = (int *)v189;
-    while ( 1 )
-    {
-      v80 = *(_WORD *)v181;
-      if ( a10 )
-      {
-        v230 = 1;
-        v73 = v80 != a11 ? 0xFF : 0;
-      }
-      v81 = _450FB1(v80);
-      if ( !v230 )
-        break;
-      LODWORD(v245) = v73 + v245;
-      v230 = 0;
-      if ( v73 )
-        goto LABEL_150;
-      --v79;
-LABEL_151:
-      v181 = (int *)((char *)v181 + 2);
-      --v166;
-      if ( !v166 )
-        goto LABEL_152;
-    }
-    LODWORD(v245) = ((unsigned int)v81 >> 24) + v245;
-LABEL_150:
-    a6l += BYTE2(v81);
-    v257 += BYTE1(v81);
-    HIDWORD(v245) += (unsigned __int8)v81;
-    goto LABEL_151;
-  }
-
-  result = this->field_20.field_C;
-  switch(result)
-  {
-  case 8: vxx = dstPitch - dstWidth;
-    break;
-  case 16: vxx = 2 * (dstPitch - dstWidth);
-    break;
-  case 32: vxx = 4 * (dstPitch - dstWidth);
-    break;
-  default:
-    return result;
-  }
-  if ( result == 8 )
-  {
-    result = (int)pDst;
-    v201 = pDst;
-    v239 = 0;
-    if ( dstHeight <= 0 )
-      return result;
-    v111 = dstWidth;
-    while ( 1 )
-    {
-      v112 = 0;
-      a6q = 0;
-      if ( dstWidth <= v11 )
-        goto LABEL_236;
-      v229 = (double)dstWidth;
-      v220 = (double)srcWidth;
-      v113 = (double)dstHeight;
-      v114 = (double)srcHeight;
-      do
-      {
-        a6bi = (double)a6q / v229 * v220;
-        v132 = a6bi + 6.7553994e15;
-        v211 = v112 + 1;
-        a6bj = (double)(v112 + 1) / v229 * v220;
-        v141 = a6bj + 6.7553994e15;
-        v115 = (double)v239 / v113 * v114;
-        v150 = v115 + 6.7553994e15;
-        v116 = (double)(v239 + 1) / v113 * v114;
-        v159 = v116 + 6.7553994e15;
-        v251 = 0;
-        v117 = (LODWORD(v159) - LODWORD(v150)) * (LODWORD(v141) - LODWORD(v132));
-        v260 = 0;
-        a6r = 0;
-        v248 = 0;
-        if ( SLODWORD(v150) >= SLODWORD(v159) )
-          goto LABEL_231;
-        v169 = LODWORD(v159) - LODWORD(v150);
-        v184 = (char *)pSrc + srcPitch * LODWORD(v150);
-        do
-        {
-          v118 = LODWORD(v132);
-          while ( v118 < SLODWORD(v141) )
-          {
-            v119 = (unsigned __int8)v184[v118];
-            if ( a10 )
-            {
-              v230 = 1;
-              v111 = v119 != a11 ? 0xFF : 0;
-            }
-            v120 = _450FB1(v119);
-            if ( v230 )
-            {
-              v248 += v111;
-              v230 = 0;
-              if ( !v111 )
-              {
-                --v117;
-                goto LABEL_228;
-              }
-            }
-            else
-            {
-              v248 += (unsigned int)v120 >> 24;
-            }
-            a6r += BYTE2(v120);
-            v260 += BYTE1(v120);
-            v251 += (unsigned __int8)v120;
-LABEL_228:
-            ++v118;
-          }
-          v184 += srcPitch;
-          --v169;
-        }
-        while ( v169 );
-LABEL_231:
-        v121 = v248 / ((LODWORD(v159) - LODWORD(v150)) * (LODWORD(v141) - LODWORD(v132)));
-        if ( v117 )
-        {
-          a6r /= v117;
-          v260 /= v117;
-          v251 /= v117;
-        }
-        if ( v121 != 255 )
-          v121 &= 0x7FFFFFFFu;
-        v122 = _450F55(v251 | ((v260 | ((a6r | (v121 << 8)) << 8)) << 8));
-        *v201 = v122;
-        v201 = (unsigned __int16 *)((char *)v201 + 1);
-        v112 = v211;
-        a6q = v211;
-      }
-      while ( v211 < dstWidth );
-LABEL_236:
-      v201 = (unsigned __int16 *)((char *)v201 + vxx);
-      ++v239;
-      result = v239;
-      if ( v239 >= dstHeight )
-        return result;
-      v11 = 0;
-    }
-  }
+          v251 += (unsigned __int8)v21;
+        }
+        if(field0value == 32)
+          v175 += 2 * srcPitch;
+        else if(field0value == 16)
+          v175 += srcPitch;   
+        else
+          v175 = (unsigned short*)((char *)v175 + 2 * srcPitch);
+      }
+      v22 = (unsigned int)v240 / ((heightRatioPlusOne - heightRatio) * (widthRatioPlusOne - widthRatio));
+      if ( v19 )
+      {
+        a6b /= v19;
+        v252 /= v19;
+        v251 /= v19;
+      }
+      if ( v22 != 255 )
+        v22 &= 0x7FFFFFFFu;
+      v23 = _450F55(v251 | ((v252 | ((a6b | (v22 << 8)) << 8)) << 8));
+      *(_DWORD *)v193 = v23;
+      v193 = (unsigned __int16 *)((char *)v193 + field_20_bits);
+    }
+    v193 = (unsigned __int16 *)((char *)v193 + field_20_bits * (dstPitch - dstWidth));
+    ++v231;
+    result = v231;
+  }
+  while(v231 < dstHeight);
+  return result;
 }
 
 //----- (0044E1EC) --------------------------------------------------------
@@ -10327,13 +9399,13 @@
       if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
       {
         int bmodel_id = a1 >> 9,
-            face_id = PID_ID(a1) &0x3F;
+            face_id = PID_ID(a1) & 0x3F;
         if (bmodel_id >= pOutdoor->uNumBModels)
           return 1;
         auto face = &pOutdoor->pBModels[bmodel_id].pFaces[face_id];
-        if (face->uAttributes & 0x100000 || (v6 = face->sCogTriggeredID) == 0 )
+        if (face->uAttributes & 0x100000 || face->sCogTriggeredID == 0 )
           return 1;
-        EventProcessor((signed __int16)v6, v2, 1);
+        EventProcessor((signed __int16)face->sCogTriggeredID, v2, 1);
       }
       else
       {
--- a/mm7_data.h	Mon Jun 03 09:10:21 2013 +0600
+++ b/mm7_data.h	Mon Jun 03 09:32:05 2013 +0600
@@ -1258,7 +1258,7 @@
 void __cdecl sub_423B4A();
 int __fastcall sub_423B5D(unsigned int uFaceID);
 signed int __fastcall sub_424579(int uFaceID, struct stru320 *a2);
-bool sub_424829(int a1, struct BspRenderer_stru2 *a2, struct BspRenderer_stru2 *a3, int a4);
+bool sub_424829(int pNumVertices, struct BspRenderer_stru2 *a2, struct BspRenderer_stru2 *a3, int uFaceID);
 signed int __fastcall sr_424CD7(unsigned int uVertexID); // idb
 signed int __fastcall sr_424EE0_MakeFanFromTriangle(unsigned int uVertexID); // idb
 signed int __fastcall sr_4250FE(unsigned int uVertexID); // idb