changeset 50:fde5c5acb66e

BLV render
author Nomad
date Tue, 23 Oct 2012 23:38:05 +0200
parents 8a8dd0164b12
children 4211cceb3813
files DecalBuilder.cpp DecalBuilder.h Indoor.cpp Indoor.h IndoorCameraD3D.cpp Indoor_stuff.h LightmapBuilder.cpp LightmapBuilder.h Monsters.h OSAPI.cpp Render.cpp Vis.cpp mm7_1.cpp mm7_3.cpp mm7_4.cpp mm7_5.cpp mm7_data.cpp mm7_data.h stru10.cpp stru10.h
diffstat 20 files changed, 946 insertions(+), 1367 deletions(-) [+]
line wrap: on
line diff
--- a/DecalBuilder.cpp	Tue Oct 23 13:51:21 2012 +0200
+++ b/DecalBuilder.cpp	Tue Oct 23 23:38:05 2012 +0200
@@ -107,7 +107,7 @@
 }
 
 //----- (0049B540) --------------------------------------------------------
-char DecalBuilder::ApplyDecals(int a2, char a3, stru154 *a4, int a5, RenderVertexSoft *a6, int a7, char a8, int a9)
+char DecalBuilder::ApplyDecals(int a2, char a3, stru154 *a4, int a5, RenderVertexSoft *a6, IndoorCameraD3D_Vec4 *a7, char a8, unsigned int uSectorID)
 {
   char *v9; // eax@3
   signed int v10; // ecx@3
@@ -146,6 +146,8 @@
   DecalBuilder *thisa; // [sp+40h] [bp-8h]@1
   RenderVertexSoft *a11; // [sp+44h] [bp-4h]@8
 
+  auto a9 = uSectorID;
+
   thisa = this;
   if ( !a5 )
     return 0;
@@ -217,7 +219,7 @@
   {
       MessageBoxW(nullptr, L"Error: Failed to get the facet orientation", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:101", 0);
   }
-  a7 = 0;
+  int _a7 = 0;
   if ( thisa->uNumDecals > 0 )
   {
     a6 = (RenderVertexSoft *)thisa->std__vector_30B00C;
@@ -266,10 +268,10 @@
       {
       MessageBoxW(nullptr, L"Error: Failed to build decal geometry", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:114", 0);
       }
-      ++a7;
+      ++_a7;
       a6 = (RenderVertexSoft *)((char *)a6 + 4);
     }
-    while ( a7 < v31->uNumDecals );
+    while ( _a7 < v31->uNumDecals );
   }
   return 1;
 }
--- a/DecalBuilder.h	Tue Oct 23 13:51:21 2012 +0200
+++ b/DecalBuilder.h	Tue Oct 23 23:38:05 2012 +0200
@@ -91,7 +91,7 @@
 
   bool AddBloodsplat(float x, float y, float z, float r, float g, float b, float radius, int a8, int a9);
   void Reset(unsigned int bPreserveBloodsplats);
-  char ApplyDecals(int a2, char a3, struct stru154 *a4, int a5, struct RenderVertexSoft *a6, int a7, char a8, int a9);
+  char ApplyDecals(int a2, char a3, struct stru154 *a4, int a5, struct RenderVertexSoft *a6, struct IndoorCameraD3D_Vec4 *a7, char a8, unsigned int uSectorID);
   char _49B790_build_decal_geometry(int a2, char a3, int a4, int a5, int a6, unsigned int uColorMultiplier, struct RenderVertexSoft *a8, struct stru314 *a9, signed int a10, struct RenderVertexSoft *a11, char uClipFlags);
   char ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID);
   char ApplyDecals_OutdoorFace(ODMFace *pFace);
--- a/Indoor.cpp	Tue Oct 23 13:51:21 2012 +0200
+++ b/Indoor.cpp	Tue Oct 23 23:38:05 2012 +0200
@@ -114,11 +114,11 @@
   PrepareItemsRenderList_BLV();
   PrepareActorRenderList_BLV();
   v6 = 0;
-  for ( i = 0; i < pStru170->field_53730; ++i )
+  for ( i = 0; i < pStru170->uNumVisibleNotEmptySectors; ++i )
   {
-    v7 = pStru170->pSectorIDs_toDrawDecorationsFrom[v6];
+    v7 = pStru170->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v6];
     v12 = 0;
-    v8 = &pIndoor->pSectors[pStru170->pSectorIDs_toDrawDecorationsFrom[v6]];
+    v8 = &pIndoor->pSectors[pStru170->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v6]];
     v9 = v8->pDecorationIDs;
     if ( v8->uNumDecorations > 0 )
     {
@@ -261,19 +261,17 @@
 }
 
 //----- (00440B44) --------------------------------------------------------
-void IndoorLocation::ExecDraw(char a1)
+void IndoorLocation::ExecDraw(bool bD3D)
 {
-  signed int i; // esi@2
   int v2; // eax@3
   IndoorCameraD3D_Vec4 *v3; // edx@4
-  signed int j; // esi@8
   unsigned int v5; // ecx@9
   RenderVertexSoft *v6; // [sp-4h] [bp-8h]@4
 
-  if ( a1 )
+  if (bD3D)
   {
     pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.z, pParty->vPosition.y);
-    for ( i = 0; i < (signed int)pStru170->uNumFaceIDs; ++i )
+    for (uint i = 0; i < pStru170->uNumFaceIDs; ++i)
     {
       v2 = pStru170->pFaceIDs[2 * i + 1];
       if ( pStru170->field_FA8[v2].std__vector_0007A8 == -1 )
@@ -286,16 +284,16 @@
         v3 = pStru170->field_FA8[v2].std__vector_0007AC;
         v6 = pStru170->field_FA8[v2].pVertices;
       }
-      IndoorLocation::ExecDraw_sub0(pStru170->pFaceIDs[2 * i], v3, 4u, v6);
+      IndoorLocation::ExecDraw_d3d(pStru170->pFaceIDs[2 * i], v3, 4u, v6);
     }
   }
   else
   {
-    for ( j = 0; j < (signed int)pStru170->uNumFaceIDs; ++j )
+    for (uint j = 0; j < pStru170->uNumFaceIDs; ++j )
     {
       v5 = pStru170->pFaceIDs[2 * j];
       pBLVRenderParams->field_7C = &pStru170->field_FA8[pStru170->pFaceIDs[2 * j + 1]].field_C;
-      IndoorLocation::ExecDraw_sub1(v5);
+      IndoorLocation::ExecDraw_sw(v5);
     }
   }
 }
@@ -432,21 +430,21 @@
 }
 
 //----- (004B0A25) --------------------------------------------------------
-void IndoorLocation::ExecDraw_sub0(unsigned int uFaceID, IndoorCameraD3D_Vec4 *pVertices, unsigned int uNumVertices, RenderVertexSoft *a4)
+void IndoorLocation::ExecDraw_d3d(unsigned int uFaceID, IndoorCameraD3D_Vec4 *pVertices, unsigned int uNumVertices, RenderVertexSoft *a4)
 {
-  unsigned int v4; // esi@1
+  //unsigned int v4; // esi@1
   char *v5; // eax@4
   signed int v6; // ecx@4
   char *v7; // eax@8
   signed int v8; // ecx@8
-  BLVFace *v9; // esi@13
-  IndoorCameraD3D *v10; // edi@16
-  int v11; // ebx@17
-  Vec3_short_ *v12; // ecx@18
-  char *v13; // edx@18
-  int v14; // eax@19
-  unsigned __int8 v15; // sf@19
-  unsigned __int8 v16; // of@19
+  //BLVFace *v9; // esi@13
+  //IndoorCameraD3D *v10; // edi@16
+  //int v11; // ebx@17
+  //Vec3_short_ *v12; // ecx@18
+  //char *v13; // edx@18
+  //int v14; // eax@19
+  //unsigned __int8 v15; // sf@19
+  //unsigned __int8 v16; // of@19
   int v17; // ebx@25
   double v18; // st7@27
   double v19; // st6@27
@@ -460,93 +458,73 @@
   IDirect3DTexture2 *v27; // eax@42
   Texture *v28; // [sp+Ch] [bp-1Ch]@15
   int i; // [sp+10h] [bp-18h]@38
-  LightmapBuilder *pStru4; // [sp+14h] [bp-14h]@16
-  IndoorCameraD3D *v31; // [sp+18h] [bp-10h]@16
-  IndoorCameraD3D_Vec4 *a7; // [sp+1Ch] [bp-Ch]@1
-  unsigned int uFaceID_; // [sp+20h] [bp-8h]@1
+  //LightmapBuilder *pStru4; // [sp+14h] [bp-14h]@16
+  //IndoorCameraD3D *v31; // [sp+18h] [bp-10h]@16
+  //IndoorCameraD3D_Vec4 *a7; // [sp+1Ch] [bp-Ch]@1
+  //unsigned int uFaceID_; // [sp+20h] [bp-8h]@1
   unsigned int uNumVerticesa; // [sp+24h] [bp-4h]@17
   int a4a; // [sp+34h] [bp+Ch]@25
   unsigned int a4b; // [sp+34h] [bp+Ch]@38
 
-  v4 = uFaceID;
-  a7 = pVertices;
-  uFaceID_ = uFaceID;
-  if ( (uFaceID & 0x80000000u) == 0 && (signed int)uFaceID < (signed int)pIndoor->uNumFaces )
-  {
-
-    static RenderVertexSoft static_vertices_F7C228[64];
-    static bool __init_flag1 = false;
-    if (!__init_flag1)
-    {
-      __init_flag1 = true;
-
-      for (uint i = 0; i < 64; ++i)
-        static_vertices_F7C228[i].flt_2C = 0.0f;
-    }
-
-    static RenderVertexSoft static_vertices_F7B628[64];
-    static bool __init_flag2 = false;
-    if (!__init_flag2)
-    {
-      __init_flag2 = true;
-
-      for (uint i = 0; i < 64; ++i)
-        static_vertices_F7B628[i].flt_2C = 0.0f;
-    }
-
-    static stru154 stru_F7B60C; // idb
-    /*static bool __init_flag3 = false;
-    if (!__init_flag3)
-    {
-      __init_flag3 = true;
-
-      stru154::stru154(&stru_F7B60C);
-    }*/
-
-    v9 = &pIndoor->pFaces[v4];
-    if ( v9->uNumVertices >= 3u )
-    {
-      if ( !(BYTE1(v9->uAttributes) & 0x20) )
+  //v4 = uFaceID;
+  //a7 = pVertices;
+  //uFaceID_ = uFaceID;
+  if (uFaceID >= pIndoor->uNumFaces)
+    return;
+
+  static RenderVertexSoft static_vertices_F7C228[64];
+  static RenderVertexSoft static_vertices_F7B628[64];
+  static stru154 stru_F7B60C; // idb
+
+    //v9 = &pIndoor->pFaces[uFaceID];
+  auto pFace = &pIndoor->pFaces[uFaceID];
+  if (pFace->uNumVertices < 3)
+    return;
+
+
+      if ( !(pFace->uAttributes & 0x2000) )
       {
         ++pBLVRenderParams->field_80;
-        LOBYTE(v9->uAttributes) |= 0x80u;
-        v28 = v9->GetTexture();
+        LOBYTE(pFace->uAttributes) |= 0x80u;
+        v28 = pFace->GetTexture();
         if ( v28 )
         {
-          v10 = pGame->pIndoorCameraD3D;
-          v31 = pGame->pIndoorCameraD3D;
-          pStru4 = pGame->pLightmapBuilder;
-          if ( !pGame->pIndoorCameraD3D->IsFaceFacedTowardsCamera(v9) )
+          //v10 = pGame->pIndoorCameraD3D;
+          //v31 = pGame->pIndoorCameraD3D;
+          //pStru4 = pGame->pLightmapBuilder;
+          if ( !pGame->pIndoorCameraD3D->IsFaceFacedTowardsCamera(pFace) )
           {
-            v11 = 0;
-            uNumVerticesa = v9->uNumVertices;
-            if ( (signed int)uNumVerticesa > 0 )
+            //v11 = 0;
+            //uNumVerticesa = pFace->uNumVertices;
+              //v12 = pIndoor->pVertices;
+              //v13 = (char *)&static_vertices_F7C228[0].vWorldPosition.z;
+            for (uint i = 0; i < pFace->uNumVertices; ++i)
             {
-              v12 = pIndoor->pVertices;
-              v13 = (char *)&static_vertices_F7C228[0].vWorldPosition.z;
-              do
-              {
-                v14 = v11++;
-                *((float *)v13 - 2) = (double)v12[v9->pVertexIDs[v14]].x;
-                *((float *)v13 - 1) = (double)v12[v9->pVertexIDs[v14]].y;
-                *(float *)v13 = (double)v12[v9->pVertexIDs[v14]].z;
-                v13 += 48;
-                v16 = __OFSUB__(v11, uNumVerticesa);
-                v15 = ((v11 - uNumVerticesa) & 0x80000000u) != 0;
-                *((float *)v13 - 5) = (double)v9->pVertexUIDs[v14];
-                *((float *)v13 - 4) = (double)v9->pVertexVIDs[v14];
-              }
-              while ( v15 ^ v16 );
-              v10 = v31;
+              static_vertices_F7C228[i].vWorldPosition.x = pIndoor->pVertices[pFace->pVertexIDs[i]].x;
+              static_vertices_F7C228[i].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[i]].y;
+              static_vertices_F7C228[i].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[i]].z;
+              static_vertices_F7C228[i].u = pFace->pVertexUIDs[i];
+              static_vertices_F7C228[i].v = pFace->pVertexUIDs[i];
+                //v14 = v11++;
+                //*((float *)v13 - 2) = (double)v12[v9->pVertexIDs[v14]].x;
+                //*((float *)v13 - 1) = (double)v12[v9->pVertexIDs[v14]].y;
+                //*(float *)v13 = (double)v12[v9->pVertexIDs[v14]].z;
+                //v13 += 48;
+                //v16 = __OFSUB__(v11, uNumVerticesa);
+                //v15 = ((v11 - uNumVerticesa) & 0x80000000u) != 0;
+                //*((float *)v13 - 5) = (double)v9->pVertexUIDs[v14];
+                //*((float *)v13 - 4) = (double)v9->pVertexVIDs[v14];
+              //while ( v15 ^ v16 );
+              //v10 = v31;
             }
-            if ( !a7
-              || (pGame->pStru9Instance->_498377(a4, 4u, a7, static_vertices_F7C228, &uNumVerticesa), uNumVerticesa) )
+            if ( !pVertices
+              || (pGame->pStru9Instance->_498377(a4, 4u, pVertices, static_vertices_F7C228, &uNumVerticesa), uNumVerticesa) )
             {
-              if ( v10->_437285_prolly_colide_vertices_against_frustrum(
+              if ( pGame->pIndoorCameraD3D->_437285_prolly_colide_vertices_against_frustrum(
                      static_vertices_F7C228,
                      &uNumVerticesa,
                      static_vertices_F7B628,
-                     v10->std__vector_000034_prolly_frustrum,
+                     pGame->pIndoorCameraD3D->std__vector_000034_prolly_frustrum,
                      4,
                      0,
                      0) != 1
@@ -554,31 +532,31 @@
               {
                 a4a = SHIWORD(stru_F8AD28.field_2C);
                 v17 = (248 - 8 * SHIWORD(stru_F8AD28.field_2C)) | (((248 - 8 * SHIWORD(stru_F8AD28.field_2C)) | ((248 - 8 * SHIWORD(stru_F8AD28.field_2C)) << 8)) << 8);
-                sub_4B0E07(uFaceID_);
-                pStru4->ApplyLights_IndoorFace(uFaceID_);
-                pDecalBuilder->ApplyBloodsplatDecals_IndoorFace(uFaceID_);
-                v31->_4364C5(static_vertices_F7B628, uNumVerticesa, array_507D30, &stru_F8AD28);
-                v31->_436BB7_project_and_stuff(array_507D30, uNumVerticesa, 0);
-                pStru4->std__vector_000004_size = 0;
+                sub_4B0E07(uFaceID);
+                pGame->pLightmapBuilder->ApplyLights_IndoorFace(uFaceID);
+                pDecalBuilder->ApplyBloodsplatDecals_IndoorFace(uFaceID);
+                pGame->pIndoorCameraD3D->_4364C5(static_vertices_F7B628, uNumVerticesa, array_507D30, &stru_F8AD28);
+                pGame->pIndoorCameraD3D->_436BB7_project_and_stuff(array_507D30, uNumVerticesa, 0);
+                pGame->pLightmapBuilder->std__vector_000004_size = 0;
                 if ( stru_F8AD28.field_AC > 0 || pDecalBuilder->uNumDecals > 0 )
                 {
-                  v18 = v9->pFacePlane.dist;
-                  v19 = v9->pFacePlane.vNormal.z;
-                  v20 = v9->pFacePlane.vNormal.y;
-                  v21 = v9->uPolygonType;
-                  stru_F7B60C.vNormal.x = v9->pFacePlane.vNormal.x;
+                  v18 = pFace->pFacePlane.dist;
+                  v19 = pFace->pFacePlane.vNormal.z;
+                  v20 = pFace->pFacePlane.vNormal.y;
+                  v21 = pFace->uPolygonType;
+                  stru_F7B60C.vNormal.x = pFace->pFacePlane.vNormal.x;
                   stru_F7B60C.field_14 = v21;
                   stru_F7B60C.vNormal.y = v20;
                   stru_F7B60C.vNormal.z = v19;
                   stru_F7B60C.field_10 = v18;
                 }
-                if ( stru_F8AD28.field_AC > 0 && !(BYTE2(v9->uAttributes) & 0x40) )
-                  pStru4->ApplyLights(
+                if ( stru_F8AD28.field_AC > 0 && !(BYTE2(pFace->uAttributes) & 0x40) )
+                  pGame->pLightmapBuilder->ApplyLights(
                     &stru_F8AD28,
                     &stru_F7B60C,
                     uNumVerticesa,
                     array_507D30,
-                    *(float *)&a7,
+                    pVertices,
                     0);
                 if ( pDecalBuilder->uNumDecals > 0 )
                   pDecalBuilder->ApplyDecals(
@@ -587,15 +565,16 @@
                     &stru_F7B60C,
                     uNumVerticesa,
                     array_507D30,
-                    (int)a7,
+                    pVertices,
                     0,
-                    v9->uSectorID);
-                if ( v9->uAttributes & 0x10 && v9->uBitmapID == pRenderer->field_1036AC_bitmapid )
+                    pFace->uSectorID);
+                if (pFace->uAttributes & 0x10 &&
+                    pFace->uBitmapID == pRenderer->field_1036AC_bitmapid )
                 {
                   v23 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid];
                   goto LABEL_42;
                 }
-                if ( v9->uAttributes & 0x10 )
+                if ( pFace->uAttributes & 0x10 )
                 {
                   v24 = GetTickCount() >> 2;
                   if ( (signed int)uNumVerticesa > 0 )
@@ -605,7 +584,7 @@
                     a4b = uNumVerticesa;
                     for ( i = v25; ; v25 = i )
                     {
-                      *(float *)v26 = (double)(pBitmaps_LOD->pTextures[v9->uBitmapID].uHeightMinus1 & (unsigned int)(stru_5C6E00->SinCos(v25) >> 8))
+                      *(float *)v26 = (double)(pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 & (unsigned int)(stru_5C6E00->SinCos(v25) >> 8))
                                     + *(float *)v26;
                       v26 += 48;
                       --a4b;
@@ -616,37 +595,32 @@
                 }
                 else
                 {
-                  v22 = v9->uAttributes;
+                  v22 = pFace->uAttributes;
                   if ( BYTE1(v22) & 0x40 )
                   {
                     v23 = pTextureFrameTable->GetFrameTexture(
-                            v9->uBitmapID,
+                            pFace->uBitmapID,
                             pBLVRenderParams->field_0_timer_);
 LABEL_42:
                     v27 = pBitmaps_LOD->pHardwareTextures[v23];
-                    if ( BYTE2(v9->uAttributes) & 0x40 )
-                      sub_479A53(uNumVerticesa, uFaceID_);
+                    if ( BYTE2(pFace->uAttributes) & 0x40 )
+                      sub_479A53(uNumVerticesa, uFaceID);
                     else
-                      pRenderer->DrawIndoorPolygon(uNumVerticesa, v9, v27, v28, 8 * uFaceID_ | 6, v17, 0);
+                      pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, 8 * uFaceID | 6, v17, 0);
                     return;
                   }
                 }
-                v23 = v9->uBitmapID;
+                v23 = pFace->uBitmapID;
                 goto LABEL_42;
               }
             }
           }
         }
       }
-    }
-  }
 }
-// F7CE28: using guessed type char static_init_flag__F7C228_bit1__F7B628_bit2__F7B60C_bit3;
-
-
 
 //----- (004AFF79) --------------------------------------------------------
-void IndoorLocation::ExecDraw_sub1(unsigned int uFaceID)
+void IndoorLocation::ExecDraw_sw(unsigned int uFaceID)
 {
   unsigned int v1; // ebx@1
   BLVFace *v2; // esi@3
@@ -1306,12 +1280,12 @@
 
 
 //----- (004B0EA8) --------------------------------------------------------
-void stru170::_4B0EA8(signed int a2, unsigned int uFaceID)
+void stru170::PrepareFaceRenderList_d3d(int a2, unsigned int uFaceID)
 {
-  unsigned int v3; // edx@1
-  stru170 *v4; // ebx@1
-  BLVFace *v5; // eax@1
-  int v6; // ecx@2
+  //unsigned int v3; // edx@1
+  //stru170 *v4; // ebx@1
+  //BLVFace *v5; // eax@1
+  //int v6; // ecx@2
   unsigned __int16 v7; // ax@11
   Vec3_short_ *v8; // esi@15
   int v9; // edx@15
@@ -1321,79 +1295,83 @@
   signed int v13; // esi@19
   signed int v14; // edx@20
   int v15; // edx@24
-  int v16; // esi@29
-  BLVFace *v17; // edi@34
+  //int v16; // esi@29
+  //BLVFace *v17; // edi@34
   unsigned __int16 v18; // ax@34
   char *v19; // eax@38
   signed int v20; // ecx@38
   char *v21; // eax@42
   signed int v22; // ecx@42
-  signed int v23; // edx@45
-  char *v24; // ecx@46
-  int v25; // eax@47
-  Vec3_short_ *v26; // eax@47
-  double v27; // st7@47
-  signed int v28; // ST28_4@47
+  //signed int v23; // edx@45
+  //char *v24; // ecx@46
+  //int v25; // eax@47
+  //Vec3_short_ *v26; // eax@47
+  //double v27; // st7@47
+  //signed int v28; // ST28_4@47
   char v29; // al@48
   signed int v30; // eax@51
   int v31; // eax@52
-  unsigned int v32; // eax@55
-  __int16 v33; // cx@56
+  //unsigned int v32; // eax@55
+  //__int16 v33; // cx@56
   signed int v34; // [sp+Ch] [bp-14h]@18
-  int a0; // [sp+14h] [bp-Ch]@2
-  IndoorCameraD3D *a0a; // [sp+14h] [bp-Ch]@36
+  //int a0; // [sp+14h] [bp-Ch]@2
+  //IndoorCameraD3D *a0a; // [sp+14h] [bp-Ch]@36
   signed int v37; // [sp+18h] [bp-8h]@19
-  stru10 *v38; // [sp+18h] [bp-8h]@36
-  BLVFace *v39; // [sp+1Ch] [bp-4h]@1
-
-  v3 = uFaceID;
-  v4 = this;
-  v5 = &pIndoor->pFaces[uFaceID];
-  this->field_FA8[this->std__vector_000FA8].std__vector_0007A8 = -1;
-  v39 = v5;
-  if ( v5->uAttributes & 1 )
+  //stru10 *v38; // [sp+18h] [bp-8h]@36
+  //BLVFace *v39; // [sp+1Ch] [bp-4h]@1
+
+  //v3 = uFaceID;
+  //v4 = this;
+  //v5 = &pIndoor->pFaces[uFaceID];
+  field_FA8[std__vector_000FA8].std__vector_0007A8 = -1;
+  //v39 = &pIndoor->pFaces[uFaceID];
+
+  auto pFace = &pIndoor->pFaces[uFaceID];
+
+  if (pFace->uAttributes & 1)
   {
-    v6 = (int)((char *)this + 2252 * a2);
-    a0 = v6;
-    if ( v3 == *(short *)(v6 + 5964) )          // stru170_stru0[a2]::uFaceID
+    auto p = &field_FA8[a2];
+    //v6 = (int)((char *)this + 2252 * a2);
+    //a0 = v6;
+    if (p->uFaceID == uFaceID)
       return;
-    if ( !a2
-      && pBLVRenderParams->vPartyPos.x >= v5->pBounding.x1 - 16
-      && pBLVRenderParams->vPartyPos.x <= v5->pBounding.x2 + 16
-      && pBLVRenderParams->vPartyPos.y >= v5->pBounding.y1 - 16
-      && pBLVRenderParams->vPartyPos.y <= v5->pBounding.y2 + 16
-      && pBLVRenderParams->vPartyPos.z >= v5->pBounding.z1 - 16
-      && pBLVRenderParams->vPartyPos.z <= v5->pBounding.z2 + 16 )
+    if (!a2 &&
+        pBLVRenderParams->vPartyPos.x >= pFace->pBounding.x1 - 16 &&
+        pBLVRenderParams->vPartyPos.x <= pFace->pBounding.x2 + 16 &&
+        pBLVRenderParams->vPartyPos.y >= pFace->pBounding.y1 - 16 &&
+        pBLVRenderParams->vPartyPos.y <= pFace->pBounding.y2 + 16 &&
+        pBLVRenderParams->vPartyPos.z >= pFace->pBounding.z1 - 16 &&
+        pBLVRenderParams->vPartyPos.z <= pFace->pBounding.z2 + 16 )
     {
-      if ( abs(v5->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * v5->pFacePlane_old.vNormal.x
-                                       + pBLVRenderParams->vPartyPos.y * v5->pFacePlane_old.vNormal.y
-                                       + pBLVRenderParams->vPartyPos.z * v5->pFacePlane_old.vNormal.z) <= 589824 )
+      if ( abs(pFace->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * pFace->pFacePlane_old.vNormal.x
+                                       + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y
+                                       + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 )
       {
-        v7 = v39->uSectorID;
-        if ( v4->field_FA8[0].uSectorID == v7 )
-          v7 = v39->uBackSectorID;
-        v4->field_FA8[v4->std__vector_000FA8].uSectorID = v7;
-        v4->field_FA8[v4->std__vector_000FA8].uFaceID = uFaceID;
-        v4->field_FA8[v4->std__vector_000FA8].uViewportX = LOWORD(pBLVRenderParams->uViewportX);
-        v4->field_FA8[v4->std__vector_000FA8].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ);
-        v4->field_FA8[v4->std__vector_000FA8].uViewportY = LOWORD(pBLVRenderParams->uViewportY);
-        v4->field_FA8[v4->std__vector_000FA8].uViewportW = LOWORD(pBLVRenderParams->uViewportW);
-        v4->field_FA8[v4->std__vector_000FA8++].field_C._43F9E1(
-          SLOWORD(pBLVRenderParams->uViewportX),
+        v7 = pFace->uSectorID;
+        if ( field_FA8[0].uSectorID == v7 )
+          v7 = pFace->uBackSectorID;
+        field_FA8[std__vector_000FA8].uSectorID = v7;
+        field_FA8[std__vector_000FA8].uFaceID = uFaceID;
+        field_FA8[std__vector_000FA8].uViewportX = pBLVRenderParams->uViewportX;
+        field_FA8[std__vector_000FA8].uViewportZ = pBLVRenderParams->uViewportZ;
+        field_FA8[std__vector_000FA8].uViewportY = pBLVRenderParams->uViewportY;
+        field_FA8[std__vector_000FA8].uViewportW = pBLVRenderParams->uViewportW;
+        field_FA8[std__vector_000FA8++].field_C._43F9E1(
+          pBLVRenderParams->uViewportX,
           pBLVRenderParams->uViewportY,
-          SLOWORD(pBLVRenderParams->uViewportZ),
+          pBLVRenderParams->uViewportZ,
           pBLVRenderParams->uViewportW);
-        sub_440639(v4->std__vector_000FA8 - 1);
+        sub_440639(std__vector_000FA8 - 1);
         return;
       }
-      v5 = v39;
-      v6 = a0;
+      //v5 = v39;
+      //v6 = a0;
     }
-    v8 = &pIndoor->pVertices[*v5->pVertexIDs];
-    v9 = v5->pFacePlane_old.vNormal.x * ((signed __int16)*(int *)&v8->x - pBLVRenderParams->vPartyPos.x)
-       + v5->pFacePlane_old.vNormal.y * ((signed __int16)(*(int *)&v8->x >> 16) - pBLVRenderParams->vPartyPos.y)
-       + v5->pFacePlane_old.vNormal.z * (v8->z - pBLVRenderParams->vPartyPos.z);
-    if ( *(short *)(v6 + 4008) != v5->uSectorID )// stru170_stru0[a2]::uSectorID
+    v8 = &pIndoor->pVertices[pFace->pVertexIDs[0]];
+    v9 = pFace->pFacePlane_old.vNormal.x * (v8->x - pBLVRenderParams->vPartyPos.x)
+       + pFace->pFacePlane_old.vNormal.y * (v8->y - pBLVRenderParams->vPartyPos.y)
+       + pFace->pFacePlane_old.vNormal.z * (v8->z - pBLVRenderParams->vPartyPos.z);
+    if (p->uSectorID != pFace->uSectorID)
       v9 = -v9;
     if ( v9 < 0 )
     {
@@ -1425,122 +1403,102 @@
           }
           while ( v13 < v34 );
         }
-        v16 = a0;
-        if ( v11 >= *(short *)(a0 + 4010)       // stru170_stru0[a2]::uViewportX
-          && a2 <= *(short *)(a0 + 4014)        // stru170_stru0[a2]::uViewportZ
-          && v12 >= *(short *)(a0 + 4012)       // stru170_stru0[a2]::uViewportY
-          && v37 <= *(short *)(a0 + 4016)       // stru170_stru0[a2]::uViewportW
-          && sub_424829(v10, &v4->field_FA8[v4->std__vector_000FA8].field_C, (stru170_stru2 *)(a0 + 4020), uFaceID) )
+        //v16 = a0;
+        if (v11 >= p->uViewportX &&
+            a2 <= p->uViewportZ &&
+            v12 >= p->uViewportY &&
+            v37 <= p->uViewportW &&
+            sub_424829(v10, &field_FA8[std__vector_000FA8].field_C, &p->field_C, uFaceID))
         {
-          v17 = v39;
-          v18 = v39->uSectorID;
-          if ( *(short *)(a0 + 4008) == v18 )
-            v18 = v39->uBackSectorID;
-          v4->field_FA8[v4->std__vector_000FA8].uSectorID = v18;
-          v4->field_FA8[v4->std__vector_000FA8].uFaceID = uFaceID;
-          v4->field_FA8[v4->std__vector_000FA8].uViewportX = LOWORD(pBLVRenderParams->uViewportX);
-          v4->field_FA8[v4->std__vector_000FA8].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ);
-          v4->field_FA8[v4->std__vector_000FA8].uViewportY = LOWORD(pBLVRenderParams->uViewportY);
-          v4->field_FA8[v4->std__vector_000FA8].uViewportW = LOWORD(pBLVRenderParams->uViewportW);
-          v38 = pGame->pStru10Instance;
-          a0a = pGame->pIndoorCameraD3D;
-          if ( *(int *)(v16 + 5968) == -1 )  // [a2]::std__vector_0007A8
+          //v17 = v39;
+          v18 = pFace->uSectorID;
+          if (p->uSectorID == v18 )
+            v18 = pFace->uBackSectorID;
+          field_FA8[std__vector_000FA8].uSectorID = v18;
+          field_FA8[std__vector_000FA8].uFaceID = uFaceID;
+          field_FA8[std__vector_000FA8].uViewportX = pBLVRenderParams->uViewportX;
+          field_FA8[std__vector_000FA8].uViewportZ = pBLVRenderParams->uViewportZ;
+          field_FA8[std__vector_000FA8].uViewportY = pBLVRenderParams->uViewportY;
+          field_FA8[std__vector_000FA8].uViewportW = pBLVRenderParams->uViewportW;
+          //v38 = pGame->pStru10Instance;
+          //a0a = pGame->pIndoorCameraD3D;
+          if (p->std__vector_0007A8 == -1 )
           {
-            v29 = pGame->pStru10Instance->_49C681(
-                    v39,
-                    v4->field_FA8[v4->std__vector_000FA8].std__vector_0007AC,
-                    v4->field_FA8[v4->std__vector_000FA8].pVertices);
+            v29 = pGame->pStru10Instance->_49C681_DrawDebugStuff(
+                    pFace,
+                    field_FA8[std__vector_000FA8].std__vector_0007AC,
+                    field_FA8[std__vector_000FA8].pVertices);
           }
           else
           {
-
-            static RenderVertexSoft static_sub_4B0EA8_stru_F7AA08[64];
-            static bool __init_flag1 = false;
-            if (!__init_flag1)
+            static RenderVertexSoft static_subPrepareFaceRenderList_d3d_stru_F7AA08[64];
+            static RenderVertexSoft static_subPrepareFaceRenderList_d3d_stru_F79E08[64];
+
+            //v23 = 0;
+            a2 = pFace->uNumVertices;
+            for (uint k = 0; k < pFace->uNumVertices; ++k)
             {
-              __init_flag1 = true;
-
-              for (uint i = 0; i < 64; ++i)
-                static_sub_4B0EA8_stru_F7AA08[i].flt_2C = 0.0f;
-            }
-            
-            static RenderVertexSoft static_sub_4B0EA8_stru_F79E08[64];
-            static bool __init_flag2 = false;
-            if (!__init_flag2)
-            {
-              __init_flag2 = true;
-
-              for (uint i = 0; i < 64; ++i)
-                static_sub_4B0EA8_stru_F79E08[i].flt_2C = 0.0f;
+              //v24 = (char *)&static_subPrepareFaceRenderList_d3d_stru_F7AA08[0].vWorldPosition.z;
+              //do
+              //{
+                //v25 = pFace->pVertexIDs[k];
+                //v26 = &pIndoor->pVertices[pFace->pVertexIDs[k]];
+                auto pVertex = &pIndoor->pVertices[pFace->pVertexIDs[k]];
+                //v27 = (double)v26->z;
+                //v28 = v26->y;
+                //v17 = v39;
+                static_subPrepareFaceRenderList_d3d_stru_F7AA08[k].vWorldPosition.x = pVertex->x;
+                static_subPrepareFaceRenderList_d3d_stru_F7AA08[k].vWorldPosition.y = pVertex->y;
+                static_subPrepareFaceRenderList_d3d_stru_F7AA08[k].vWorldPosition.z = pVertex->z;
+                //v24 += 48;
+              //}
+              //while ( v23 < a2 );
             }
-
-            v23 = 0;
-            a2 = v39->uNumVertices;
-            if ( a2 > 0 )
-            {
-              v24 = (char *)&static_sub_4B0EA8_stru_F7AA08[0].vWorldPosition.z;
-              do
-              {
-                v25 = v17->pVertexIDs[v23++];
-                v26 = &pIndoor->pVertices[v25];
-                v27 = (double)v26->z;
-                v28 = v26->y;
-                v17 = v39;
-                *((float *)v24 - 2) = (double)v26->x;
-                *((float *)v24 - 1) = (double)v28;
-                *(float *)v24 = v27;
-                v24 += 48;
-              }
-              while ( v23 < a2 );
-            }
-            a0a->_437285_prolly_colide_vertices_against_frustrum(
-              static_sub_4B0EA8_stru_F7AA08,
+            pGame->pIndoorCameraD3D->_437285_prolly_colide_vertices_against_frustrum(
+              static_subPrepareFaceRenderList_d3d_stru_F7AA08,
               (unsigned int *)&a2,
-              static_sub_4B0EA8_stru_F79E08,
-              (IndoorCameraD3D_Vec4 *)(v16 + 5972),
+              static_subPrepareFaceRenderList_d3d_stru_F79E08,
+              p->std__vector_0007AC,
               4,
               0,
               0);
-            v29 = v38->_49C5DA(
-                    v17,
-                    static_sub_4B0EA8_stru_F79E08,
+            v29 = pGame->pStru10Instance->_49C5DA(
+                    pFace,
+                    static_subPrepareFaceRenderList_d3d_stru_F79E08,
                     &a2,
-                    v4->field_FA8[v4->std__vector_000FA8].std__vector_0007AC,
-                    v4->field_FA8[v4->std__vector_000FA8].pVertices);
+                    field_FA8[std__vector_000FA8].std__vector_0007AC,
+                    field_FA8[std__vector_000FA8].pVertices);
           }
           if ( v29 )
           {
-            v4->field_FA8[v4->std__vector_000FA8].std__vector_0007A8 = uFaceID;
-            v30 = v4->std__vector_000FA8;
+            field_FA8[std__vector_000FA8].std__vector_0007A8 = uFaceID;
+            v30 = std__vector_000FA8;
             if ( v30 < 150 )
             {
               v31 = v30 + 1;
-              v4->std__vector_000FA8 = v31;
+              std__vector_000FA8 = v31;
               sub_440639(v31 - 1);
             }
           }
           if ( pBLVRenderParams->uFlags & 1 )
-            a0a->PrepareAndDrawDebugOutline(v17, 0x1E1EFFu);
+            pGame->pIndoorCameraD3D->PrepareAndDrawDebugOutline(pFace, 0x1E1EFF);
         }
       }
     }
   }
   else
   {
-    v32 = this->uNumFaceIDs;
-    if ( (signed int)this->uNumFaceIDs < 1000 )
+    if (uNumFaceIDs < 1000 )
     {
-      v33 = a2;
-      v4->pFaceIDs[2 * v32] = v3;
-      v4->pFaceIDs[2 * v4->uNumFaceIDs++ + 1] = v33;
+      pFaceIDs[2 * uNumFaceIDs] = uFaceID;
+      pFaceIDs[2 * uNumFaceIDs++ + 1] = a2;
     }
   }
 }
-// F7B608: using guessed type char static_sub_4B0EA8_byte_F7B608_init_flags;
 
 
 //----- (004AFB86) --------------------------------------------------------
-void stru170::_4AFB86(int a2, unsigned int uFaceID)
+void stru170::PrepareFaceRenderList_sw(int a2, unsigned int uFaceID)
 {
   stru170 *v3; // ebx@1
   BLVFace *v4; // eax@1
@@ -3218,9 +3176,9 @@
 int IndoorLocation::GetSector(int sX, int sY, int sZ)
 {
   int v4; // esi@1
-  unsigned __int8 v5; // zf@1
-  unsigned __int8 v6; // sf@1
-  unsigned __int8 v7; // of@1
+  //unsigned __int8 v5; // zf@1
+  //unsigned __int8 v6; // sf@1
+  //unsigned __int8 v7; // of@1
   BLVSector *v8; // eax@3
   int v9; // edi@9
   int v10; // eax@9
@@ -3274,14 +3232,15 @@
   int v59; // [sp+110h] [bp-4h]@16
 
   v4 = 0;
-  v7 = __OFSUB__(this->uNumSectors, 1);
-  v5 = this->uNumSectors == 1;
-  v6 = this->uNumSectors - 1 < 0;
+  //v7 = __OFSUB__(this->uNumSectors, 1);
+  //v5 = this->uNumSectors == 1;
+  //v6 = this->uNumSectors - 1 < 0;
   v55 = 0;
   v43[0] = 0;
   v56 = 1;
-  if ( (unsigned __int8)(v6 ^ v7) | v5 )
+  if (uNumSectors < 2)
     return 0;
+
   v52 = 116;
   do
   {
@@ -3328,9 +3287,9 @@
                       v20 = v19[*pVertexIDs].y;
                       v54 = 0;
                       v57 = 0;
-                      v5 = v16->uNumVertices == 0;
+                      //v5 = v16->uNumVertices == 0;
                       v59 = v20 >= sY;
-                      if ( !v5 )
+                      if (v16->uNumVertices)
                       {
                         v21 = pVertexIDs + 1;
                         do
@@ -3395,11 +3354,11 @@
                     }
                     v11 = v48 + 1;
                     v12 = v53 + 2;
-                    v7 = __OFSUB__(v48 + 1, v51);
-                    v6 = v48++ + 1 - v51 < 0;
+                    //v7 = __OFSUB__(v48 + 1, v51);
+                    //v6 = v48++ + 1 - v51 < 0;
                     v53 += 2;
                   }
-                  while ( v6 ^ v7 );
+                  while ( ++v48 < v51 );
                   v4 = v43[0];
                 }
               }
--- a/Indoor.h	Tue Oct 23 13:51:21 2012 +0200
+++ b/Indoor.h	Tue Oct 23 23:38:05 2012 +0200
@@ -424,9 +424,9 @@
   void ToggleLight(unsigned int uLightID, unsigned int bToggle);
 
   static unsigned int GetLocationIndex(const char *Str1);
-  static void ExecDraw(char a1);
-  static void ExecDraw_sub1(unsigned int uFaceID);
-  static void ExecDraw_sub0(unsigned int uFaceID, struct IndoorCameraD3D_Vec4 *pVertices, unsigned int uNumVertices, struct RenderVertexSoft *a4);
+  static void ExecDraw(bool bD3D);
+  static void ExecDraw_sw(unsigned int uFaceID);
+  static void ExecDraw_d3d(unsigned int uFaceID, struct IndoorCameraD3D_Vec4 *pVertices, unsigned int uNumVertices, struct RenderVertexSoft *a4);
 
   char pFilename[32];
   char field_20[48];
--- a/IndoorCameraD3D.cpp	Tue Oct 23 13:51:21 2012 +0200
+++ b/IndoorCameraD3D.cpp	Tue Oct 23 23:38:05 2012 +0200
@@ -1234,23 +1234,15 @@
   Vec3_float_ a5; // [sp+18h] [bp-3Ch]@12
   float v17; // [sp+44h] [bp-10h]@1
   int v18; // [sp+48h] [bp-Ch]@5
-  stru9 *thisa; // [sp+4Ch] [bp-8h]@1
+  //stru9 *thisa; // [sp+4Ch] [bp-8h]@1
   int a7a; // [sp+53h] [bp-1h]@5
   bool a6a; // [sp+70h] [bp+1Ch]@5
 
   v17 = 0.0;
-  thisa = pGame->pStru9Instance;
+  //thisa = pGame->pStru9Instance;
 
   
   static RenderVertexSoft sr_vertices_50D9D8[64];
-  static bool __init_flag1 = false;
-  if (!__init_flag1)
-  {
-    __init_flag1 = true;
-
-    for (uint i = 0; i < 64; ++i)
-      sr_vertices_50D9D8[i].flt_2C = 0.0f;
-  }
 
   result = 0;
   LOBYTE(a7a) = 0;
@@ -1284,7 +1276,7 @@
       a5.x = *((float *)v13 - 1);
       a5.y = *(float *)v13;
       a5.z = *((float *)v13 + 1);
-      result = thisa->_4985FB(v15, v12, v14, pOutNumVertices, &a5, *((float *)v13 + 2), (char *)&a7a, _unused);
+      result = pGame->pStru9Instance->_4985FB(v15, v12, v14, pOutNumVertices, &a5, *((float *)v13 + 2), (char *)&a7a, _unused);
       v12 = *pOutNumVertices;
       if ( (signed int)*pOutNumVertices < v18 )
         break;
@@ -1680,8 +1672,8 @@
 void IndoorCameraD3D::Project(signed int x, signed int y, signed int z, int *a5, int *a6)
 {
   double v6; // ST00_8@2
-  double v7; // ST08_8@2
-  double v8; // ST00_8@2
+  //double v7; // ST08_8@2
+  //double v8; // ST00_8@2
   signed __int64 v9; // qtt@3
   int v10; // ST04_4@3
   float a2a; // [sp+18h] [bp+8h]@2
@@ -1690,12 +1682,12 @@
   if ( pRenderer->pRenderD3D )
   {
     v6 = 1.0 / (double)x;
-    a2a = (double)y * this->flt_fov * v6 + this->field_C8;
-    v7 = a2a + 6.7553994e15;
-    *a5 = LODWORD(v7);
-    a2b = (double)z * this->flt_fov * v6 + this->field_CC;
-    v8 = a2b + 6.7553994e15;
-    *a6 = pViewport->uViewportW - LODWORD(v8);
+    a2a = (double)y * flt_fov * v6 + field_C8;
+    //v7 = a2a + 6.7553994e15;
+    *a5 = floorf(a2a + 0.5f);
+    a2b = (double)z * flt_fov * v6 + field_CC;
+    //v8 = a2b + 6.7553994e15;
+    *a6 = pViewport->uViewportW - floorf(a2b + 0.5f);
   }
   else
   {
--- a/Indoor_stuff.h	Tue Oct 23 13:51:21 2012 +0200
+++ b/Indoor_stuff.h	Tue Oct 23 23:38:05 2012 +0200
@@ -76,20 +76,20 @@
    //    (void (__thiscall *)(void *))stru170_stru0::dtor);
     uNumFaceIDs = 0;
     std__vector_000FA8 = 0;
-    field_53730 = 0;
+    uNumVisibleNotEmptySectors = 0;
   }
 
-  void _4AFB86(int a2, unsigned int uFaceID);
-  void _4B0EA8(signed int a2, unsigned int uFaceID);
-  void RenderWalls();
+  void PrepareFaceRenderList_sw(int a2, unsigned int uFaceID);
+  void PrepareFaceRenderList_d3d(signed int a2, unsigned int uFaceID);
+  void MakeVisibleSectorList();
 
   unsigned int uNumFaceIDs;
   __int16 pFaceIDs[150];
   char field_130[3700];
   unsigned int std__vector_000FA8;
   stru170_stru0 field_FA8[150];
-  int field_53730;
-  unsigned __int16 pSectorIDs_toDrawDecorationsFrom[6];
+  unsigned int uNumVisibleNotEmptySectors;
+  unsigned __int16 pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[6];
 };
 #pragma pack(pop)
 
--- a/LightmapBuilder.cpp	Tue Oct 23 13:51:21 2012 +0200
+++ b/LightmapBuilder.cpp	Tue Oct 23 23:38:05 2012 +0200
@@ -48,7 +48,7 @@
 
 
 //----- (0045BC07) --------------------------------------------------------
-char LightmapBuilder::ApplyLights(stru320 *a2, stru154 *a3, unsigned int uNumVertices, RenderVertexSoft *a5, float a6, char a7)
+char LightmapBuilder::ApplyLights(stru320 *a2, stru154 *a3, unsigned int uNumVertices, RenderVertexSoft *a5, IndoorCameraD3D_Vec4 *a6, char a7)
 {
   char *v7; // eax@3
   signed int v8; // ecx@3
@@ -97,7 +97,7 @@
   }
 
   a9 = (int)a5;
-  if ( a6 == 0.0 )
+  if ( !a6)
   {
     v14 = a3;
   }
@@ -161,18 +161,19 @@
       v29 = *v19;
       v30 = v19[60];
       v21 = *(v19 - 60);
-      a6 = v20;
+      //a6 = v20;
       v36 = v21;
       v37 = v19[20];
+      auto _a6_1 = floorf(v20 + 0.5f);
       //v33 = a6 + 6.7553994e15;
-      a6 = *((float *)v19 + 100) * 255.0;
+      auto _a6_2 = *((float *)v19 + 100) * 255.0;
       //v32 = a6 + 6.7553994e15;
-      a6 = *((float *)v19 + 120) * 255.0;
+      auto _a6_3 = *((float *)v19 + 120) * 255.0;
       //v31 = a6 + 6.7553994e15;
       //v38 = __PAIR__(LODWORD(v32), LODWORD(v31));
-      v38 = __PAIR__((int)floorf(a6 + 0.5f), (int)floorf(a6 + 0.5f));
+      v38 = __PAIR__((int)floorf(_a6_2 + 0.5f), (int)floorf(_a6_3 + 0.5f));
       //v22 = LODWORD(v31) | ((LODWORD(v32) | (LODWORD(v33) << 8)) << 8);
-      v22 = (int)floorf(a6 + 0.5f) | (((int)floorf(a6 + 0.5f) | ((int)floorf(a6 + 0.5f) << 8)) << 8);
+      v22 = (int)floorf(_a6_3 + 0.5f) | (((int)floorf(_a6_2 + 0.5f) | ((int)floorf(_a6_1 + 0.5f) << 8)) << 8);
       if (!v22)
         v22 = 0x00FFFFFF;
       v27 = a7;
--- a/LightmapBuilder.h	Tue Oct 23 13:51:21 2012 +0200
+++ b/LightmapBuilder.h	Tue Oct 23 23:38:05 2012 +0200
@@ -54,7 +54,7 @@
   int _45C6D6(int a2, struct RenderVertexSoft *a3, Lightmap *pLightmap);
   int _45C4B9(int a2, struct RenderVertexSoft *a3, Lightmap *pLightmap);
   char _45BE86_build_light_polygon(int arg0, float a4, unsigned int uColorMask, float a5, int uLightType, struct stru314 *a7, signed int a2, RenderVertexSoft *a9, char uClipFlag);
-  char ApplyLights(struct stru320 *a2, struct stru154 *a3, unsigned int uNumVertices, struct RenderVertexSoft *a5, float a6, char a7);
+  char ApplyLights(struct stru320 *a2, struct stru154 *a3, unsigned int uNumVertices, struct RenderVertexSoft *a5, struct IndoorCameraD3D_Vec4 *, char a7);
 
 
   void (__thiscall ***vdestructor_ptr)(LightmapBuilder *, bool);
--- a/Monsters.h	Tue Oct 23 13:51:21 2012 +0200
+++ b/Monsters.h	Tue Oct 23 23:38:05 2012 +0200
@@ -177,7 +177,7 @@
   unsigned __int16 uMonsterRadius;
   unsigned __int16 uMovementSpeed;
   __int16 uToHitRadius;
-  int uTintColor;
+  unsigned int uTintColor;
   unsigned __int16 pSoundSampleIDs[4];
   char pMonsterName[32];
   char pSpriteNames[10][10];
--- a/OSAPI.cpp	Tue Oct 23 13:51:21 2012 +0200
+++ b/OSAPI.cpp	Tue Oct 23 23:38:05 2012 +0200
@@ -9,8 +9,9 @@
 int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE, wchar_t *lpCmdLine, int nShowCmd)
 {
   Log::Initialize();
-
-  if (HWND hMM7Window = FindWindowW(L"MM7", 0))
+  
+  //if (HWND hMM7Window = FindWindowW(L"MM7", 0))
+  if (HWND hMM7Window = FindWindowW(L"M&MTrilogy", 0))
   {
     if (IsIconic(hMM7Window))
       ShowWindow(hMM7Window, SW_RESTORE);
--- a/Render.cpp	Tue Oct 23 13:51:21 2012 +0200
+++ b/Render.cpp	Tue Oct 23 23:38:05 2012 +0200
@@ -2020,7 +2020,7 @@
               -1);
         }
         if ( stru_F8AD28.field_AC > 0 )
-          pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0.0, v33);
+          pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33);
         v34 = a5;
         v35 = byte_4D864C == 0;
         v16->uNumVertices = a5;
@@ -2170,7 +2170,7 @@
         &static_sub_0048034E_stru_76D590,
         uNumVertices,
         array_50AC10,
-        0.0,
+        0,
         (char)a8);
     v55 = uNumVertices;
     v35 = byte_4D864C == 0;
@@ -2307,7 +2307,7 @@
           -1);
     }
     if ( stru_F8AD28.field_AC > 0 )
-      v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0.0, v70);
+      v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70);
     v71 = a8;
     v72 = v100;
     v35 = byte_4D864C == 0;
--- a/Vis.cpp	Tue Oct 23 13:51:21 2012 +0200
+++ b/Vis.cpp	Tue Oct 23 23:38:05 2012 +0200
@@ -361,7 +361,6 @@
   v17 = 0;
   for ( a1.flt_2C = 0.0; v17 < (signed int)pStru170->uNumFaceIDs; ++v17 )
   {
-    __debugbreak();
     v6 = pStru170->pFaceIDs[2 * v5];
     if ( v6 >= 0 )
     {
--- a/mm7_1.cpp	Tue Oct 23 13:51:21 2012 +0200
+++ b/mm7_1.cpp	Tue Oct 23 23:38:05 2012 +0200
@@ -6394,13 +6394,13 @@
 {
   BLVFace *v1; // ebx@1
   Vec3_short_ *v2; // esi@1
-  int v3; // ST28_4@1
+  //int v3; // ST28_4@1
   __int16 v4; // ST2C_2@1
-  signed int v5; // esi@1
-  Vec3_short_ *v6; // eax@4
-  signed int v7; // edi@5
-  signed int v8; // eax@5
-  signed int i_; // ecx@10
+  //signed int v5; // esi@1
+  //Vec3_short_ *v6; // eax@4
+  //signed int v7; // edi@5
+  //signed int v8; // eax@5
+  //signed int i_; // ecx@10
   int v10; // eax@10
   int v11; // edx@11
   int v12; // ST28_4@12
@@ -6417,64 +6417,65 @@
   int v23; // edi@21
   int v24; // eax@21
   int v25; // eax@22
-  signed int v26; // ST30_4@24
-  signed __int64 v27; // qtt@24
-  int v28; // ST18_4@25
-  int v29; // eax@26
-  int v30; // eax@27
-  signed int v31; // ST30_4@29
-  signed __int64 v32; // qtt@29
-  int v33; // ST30_4@30
-  signed int v34; // edi@31
-  unsigned int v35; // eax@31
-  bool v36; // edx@31
-  int v37; // ecx@31
-  int v38; // ecx@32
-  int v39; // esi@32
-  int v40; // eax@34
-  signed int v41; // ebx@41
-  unsigned int v42; // eax@41
-  signed int v43; // ecx@42
-  int v44; // esi@42
-  int v45; // eax@44
-  signed int v46; // edi@51
-  unsigned int v47; // eax@51
-  bool v48; // edx@51
-  int v49; // ecx@51
-  int v50; // ecx@52
-  signed int v51; // esi@52
-  int v52; // eax@54
-  int v53; // ebx@61
-  unsigned int v54; // eax@61
-  signed int v55; // ecx@62
-  int v56; // esi@62
-  int v57; // eax@64
-  char v59; // zf@72
-  signed int v60; // edx@75
-  int v61; // ecx@76
-  int v62; // esi@76
-  int v63; // ecx@83
-  signed int v64; // [sp+14h] [bp-14h]@3
-  int v65; // [sp+14h] [bp-14h]@34
-  int v66; // [sp+14h] [bp-14h]@44
-  int v67; // [sp+14h] [bp-14h]@54
-  int v68; // [sp+14h] [bp-14h]@64
-  signed int v69; // [sp+14h] [bp-14h]@75
-  IndoorCameraD3D *_this; // [sp+18h] [bp-10h]@1
+  int v26; // eax@22
+  signed int v27; // ST30_4@24
+  signed __int64 v28; // qtt@24
+  int v29; // ST18_4@25
+  int v30; // eax@26
+  int v31; // eax@27
+  int v32; // eax@27
+  signed int v33; // ST30_4@29
+  signed __int64 v34; // qtt@29
+  int v35; // ST30_4@30
+  signed int v36; // edi@31
+  unsigned int v37; // eax@31
+  bool v38; // edx@31
+  int v39; // ecx@31
+  int v40; // ecx@32
+  int v41; // esi@32
+  int v42; // eax@34
+  signed int v43; // ebx@41
+  unsigned int v44; // eax@41
+  signed int v45; // ecx@42
+  int v46; // esi@42
+  int v47; // eax@44
+  signed int v48; // edi@51
+  unsigned int v49; // eax@51
+  bool v50; // edx@51
+  int v51; // ecx@51
+  int v52; // ecx@52
+  signed int v53; // esi@52
+  int v54; // eax@54
+  int v55; // ebx@61
+  unsigned int v56; // eax@61
+  signed int v57; // ecx@62
+  int v58; // esi@62
+  int v59; // eax@64
+  char v61; // zf@72
+  signed int v62; // edx@75
+  int v63; // ecx@76
+  int v64; // esi@76
+  int v65; // ecx@83
+  //signed int v66; // [sp+14h] [bp-14h]@3
+  int v67; // [sp+14h] [bp-14h]@34
+  int v68; // [sp+14h] [bp-14h]@44
+  int v69; // [sp+14h] [bp-14h]@54
+  int v70; // [sp+14h] [bp-14h]@64
+  signed int v71; // [sp+14h] [bp-14h]@75
   bool thisa; // [sp+18h] [bp-10h]@9
   int thisb; // [sp+18h] [bp-10h]@12
   int thisc; // [sp+18h] [bp-10h]@20
   bool thisd; // [sp+18h] [bp-10h]@41
   bool thise; // [sp+18h] [bp-10h]@61
   int thisf; // [sp+18h] [bp-10h]@74
-  signed int v77; // [sp+1Ch] [bp-Ch]@9
-  int v78; // [sp+1Ch] [bp-Ch]@76
-  bool v79; // [sp+20h] [bp-8h]@10
-  bool v80; // [sp+20h] [bp-8h]@32
-  bool v81; // [sp+20h] [bp-8h]@42
-  bool v82; // [sp+20h] [bp-8h]@52
-  bool v83; // [sp+20h] [bp-8h]@62
-  signed int i; // [sp+24h] [bp-4h]@9
+  signed int v79; // [sp+1Ch] [bp-Ch]@9
+  int v80; // [sp+1Ch] [bp-Ch]@76
+  bool v81; // [sp+20h] [bp-8h]@10
+  bool v82; // [sp+20h] [bp-8h]@32
+  bool v83; // [sp+20h] [bp-8h]@42
+  bool v84; // [sp+20h] [bp-8h]@52
+  bool v85; // [sp+20h] [bp-8h]@62
+  //signed int i; // [sp+24h] [bp-4h]@9
   signed int ia; // [sp+24h] [bp-4h]@19
   signed int ib; // [sp+24h] [bp-4h]@31
   signed int ic; // [sp+24h] [bp-4h]@41
@@ -6482,13 +6483,13 @@
   signed int ie; // [sp+24h] [bp-4h]@61
 
   v1 = &pIndoor->pFaces[uFaceID];
-  _this = pGame->pIndoorCameraD3D;
+  //this = pGame->pIndoorCameraD3D;
   v2 = &pIndoor->pVertices[*v1->pVertexIDs];
-  v3 = *(int *)&v2->x;
+  //v3 = *(_DWORD *)&v2->x;
   v4 = v2->z;
-  v5 = 0;
-  if ( v1->pFacePlane_old.vNormal.x * ((signed __int16)v3 - pBLVRenderParams->vPartyPos.x)
-     + v1->pFacePlane_old.vNormal.y * (SHIWORD(v3) - pBLVRenderParams->vPartyPos.y)
+  //v5 = 0;
+  if ( v1->pFacePlane_old.vNormal.x * (v2->x - pBLVRenderParams->vPartyPos.x)
+     + v1->pFacePlane_old.vNormal.y * (v2->y - pBLVRenderParams->vPartyPos.y)
      + v1->pFacePlane_old.vNormal.z * (v4 - pBLVRenderParams->vPartyPos.z) < 0 )
   {
     dword_50B700 = 1;
@@ -6499,110 +6500,103 @@
     if ( !(v1->uAttributes & 1) )
       return 0;
   }
-  v64 = v1->uNumVertices;
-  if ( (signed int)v1->uNumVertices > 0 )
-  {
-    do
-    {
-      v6 = &pIndoor->pVertices[v1->pVertexIDs[v5]];
-      _this->ApplyViewTransform_TrueIfStillVisible(
+  //v66 = v1->uNumVertices;
+  for (uint i = 0; i < v1->uNumVertices; ++i)
+  {
+      auto v6 = &pIndoor->pVertices[v1->pVertexIDs[i]];
+      pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(
         v6->x,
         v6->y,
         v6->z,
-        &_50B924_view_transformed_xs[v5],
-        &_50B834_view_transformed_zs[v5],
-        &_50B744_view_transformed_ys[v5],
+        &_50B924_view_transformed_xs[i],
+        &_50B834_view_transformed_zs[i],
+        &_50B744_view_transformed_ys[i],
         0);
-      ++v5;
-    }
-    while ( v5 < v64 );
-  }
-  v7 = v64;
-  v8 = 0;
-  if ( v64 <= 0 )
+  }
+
+  //v7 = v1->uNumVertices;
+  //v8 = 0;
+  if (v1->uNumVertices <= 0)
     return 0;
-  do
-  {
-    if ( _50B924_view_transformed_xs[v8] >= 524288 )
+
+  bool bFound = false;
+  for (uint i = 0; i < v1->uNumVertices; ++i)
+    if (_50B924_view_transformed_xs[i] >= 0x80000u)
+    {
+      bFound = true;
       break;
-    ++v8;
-  }
-  while ( v8 < v64 );
-  if ( v8 >= v64 )
+    }
+  if (!bFound)
     return 0;
-  v77 = 0;
-  _50B924_view_transformed_xs[v64] = _50B924_view_transformed_xs[0];
-  _50B834_view_transformed_zs[v64] = _50B834_view_transformed_zs[0];
-  _50B744_view_transformed_ys[v64] = _50B744_view_transformed_ys[0];
-  thisa = _50B924_view_transformed_xs[0] >= 524288;
-  i = 1;
-  if ( v64 >= 1 )
-  {
-    do
-    {
-      i_ = i;
+
+  v79 = 0;
+  _50B924_view_transformed_xs[v1->uNumVertices] = _50B924_view_transformed_xs[0];
+  _50B834_view_transformed_zs[v1->uNumVertices] = _50B834_view_transformed_zs[0];
+  _50B744_view_transformed_ys[v1->uNumVertices] = _50B744_view_transformed_ys[0];
+  thisa = _50B924_view_transformed_xs[0] >= 0x80000u;
+  //int i = 1;
+  for (uint i = 1; i < v1->uNumVertices; ++i)
+  {
       v10 = _50B924_view_transformed_xs[i];
-      v79 = v10 >= 524288;
-      if ( thisa ^ v79 )
-      {
-        v11 = _50B924_view_transformed_xs_minus1[i_];
-        if ( v10 >= 524288 )
+      v81 = v10 >= (signed int)0x80000u;
+      if ( thisa ^ v81 )
+      {
+        v11 = _50B924_view_transformed_xs[i - 1];
+        if ( v10 >= (signed int)0x80000u )
         {
           v12 = v10 - v11;
-          v13 = 524288 - v11;
+          v13 = 0x80000 - v11;
           LODWORD(v14) = v13 << 16;
           HIDWORD(v14) = v13 >> 16;
-          v15 = &_50B744_view_transformed_ys_minus1[i_];
-          dword_50B828[v77] = ((unsigned __int64)((_50B834_view_transformed_zs[i_] - _50B834_view_transformed_zs_minus1[i_])
+          v15 = &_50B744_view_transformed_ys[i - 1];
+          dword_50B828[v79] = ((unsigned __int64)((_50B834_view_transformed_zs[i] - _50B834_view_transformed_zs[i - 1])
                                                 * v14
                                                 / v12) >> 16)
-                            + _50B834_view_transformed_zs_minus1[i_];
-          thisb = (unsigned __int64)((_50B744_view_transformed_ys[i_] - _50B744_view_transformed_ys_minus1[i_]) * v14 / v12) >> 16;
+                            + _50B834_view_transformed_zs[i - 1];
+          thisb = (unsigned __int64)((_50B744_view_transformed_ys[i] - _50B744_view_transformed_ys[i - 1]) * v14 / v12) >> 16;
         }
         else
         {
           v16 = v11 - v10;
-          v17 = 524288 - v10;
+          v17 = 0x80000 - v10;
           LODWORD(v18) = v17 << 16;
           HIDWORD(v18) = v17 >> 16;
-          v15 = &_50B744_view_transformed_ys[i_];
-          dword_50B828[v77] = ((unsigned __int64)((_50B834_view_transformed_zs_minus1[i_] - _50B834_view_transformed_zs[i_])
+          v15 = &_50B744_view_transformed_ys[i];
+          dword_50B828[v79] = ((unsigned __int64)((_50B834_view_transformed_zs[i - 1] - _50B834_view_transformed_zs[i])
                                                 * v18
                                                 / v16) >> 16)
-                            + _50B834_view_transformed_zs[i_];
-          thisb = (unsigned __int64)((_50B744_view_transformed_ys_minus1[i_] - _50B744_view_transformed_ys[i_]) * v18 / v16) >> 16;
+                            + _50B834_view_transformed_zs[i];
+          thisb = (unsigned __int64)((_50B744_view_transformed_ys[i - 1] - _50B744_view_transformed_ys[i]) * v18 / v16) >> 16;
         }
-        v19 = v77++;
-        v7 = v64;
+        v19 = v79++;
+        //v7 = v66;
         dword_50B738[v19] = thisb + *v15;
-        dword_50B918[v19] = 524288;
-      }
-      if ( v79 )
-      {
-        v20 = v77++;
-        dword_50B918[v20] = _50B924_view_transformed_xs[i_];
-        dword_50B828[v20] = _50B834_view_transformed_zs[i_];
-        dword_50B738[v20] = _50B744_view_transformed_ys[i_];
-      }
-      ++i;
-      thisa = v79;
-    }
-    while ( i <= v7 );
+        dword_50B918[v19] = 0x80000u;
+      }
+      if ( v81 )
+      {
+        v20 = v79++;
+        dword_50B918[v20] = _50B924_view_transformed_xs[i];
+        dword_50B828[v20] = _50B834_view_transformed_zs[i];
+        dword_50B738[v20] = _50B744_view_transformed_ys[i];
+      }
+      //++i;
+      thisa = v81;
   }
   ia = 0;
-  v21 = v77;
-  dword_50B918[v77] = dword_50B918[0];
-  dword_50B828[v77] = dword_50B828[0];
-  for ( dword_50B738[v77] = dword_50B738[0]; ia < v77; dword_50BA08[v22] = pBLVRenderParams->uViewportCenterY - v33 )
+  v21 = v79;
+  dword_50B918[v79] = dword_50B918[0];
+  dword_50B828[v79] = dword_50B828[0];
+  for ( dword_50B738[v79] = dword_50B738[0]; ia < v79; dword_50BA08[v22] = pBLVRenderParams->uViewportCenterY - v35 )
   {
     v22 = ia;
     thisc = abs(dword_50B918[ia]);
     if ( abs(dword_50B828[ia]) >> 13 <= thisc )
     {
-      v26 = dword_50B828[v22];
-      LODWORD(v27) = v26 << 16;
-      HIDWORD(v27) = v26 >> 16;
-      v25 = v27 / dword_50B918[v22];
+      v27 = dword_50B828[v22];
+      LODWORD(v28) = v27 << 16;
+      HIDWORD(v28) = v27 >> 16;
+      v26 = v28 / dword_50B918[v22];
       v23 = 0;
     }
     else
@@ -6612,272 +6606,277 @@
       if ( dword_50B828[v22] >= 0 )
       {
         LOBYTE(v24) = dword_50B918[v22] >= 0;
-        v25 = ((v24 - 1) & 0xFF800000) + 0x400000;
+        v26 = ((v24 - 1) & 0xFF800000) + 0x400000;
       }
       else
       {
         LOBYTE(v24) = dword_50B918[v22] >= 0;
-        v25 = ((unsigned int)&array_77EC08[1975].pEdgeList1[1] & (v24 - 1)) - 4194304;
-      }
-    }
-    v28 = dword_50B738[v22];
-    dword_50BAF8_xs[v22] = v25;
-    if ( abs(v28) >> 13 <= thisc )
-    {
-      v31 = dword_50B738[v22];
-      LODWORD(v32) = v31 << 16;
-      HIDWORD(v32) = v31 >> 16;
-      v30 = v32 / dword_50B918[v22];
+        v25 = v24 - 1;
+        v26 = (v25 & 0x800000) - 0x400000;
+      }
+    }
+    v29 = dword_50B738[v22];
+    dword_50BAF4_xs[v22 + 1] = v26;
+    if ( abs(v29) >> 13 <= thisc )
+    {
+      v33 = dword_50B738[v22];
+      LODWORD(v34) = v33 << 16;
+      HIDWORD(v34) = v33 >> 16;
+      v32 = v34 / dword_50B918[v22];
     }
     else
     {
-      v29 = 0;
+      v30 = 0;
       if ( dword_50B738[v22] >= v23 )
       {
-        LOBYTE(v29) = dword_50B918[v22] >= v23;
-        v30 = ((v29 - 1) & 0xFF800000) + 4194304;
+        LOBYTE(v30) = dword_50B918[v22] >= v23;
+        v32 = ((v30 - 1) & 0xFF800000) + 0x400000;
       }
       else
       {
-        LOBYTE(v29) = dword_50B918[v22] >= v23;
-        v30 = ((unsigned int)&array_77EC08[1975].pEdgeList1[1] & (v29 - 1)) - 4194304;
-      }
-    }
-    dword_50BA08[v22] = v30;
-    dword_50BAF8_xs[v22] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)dword_50BAF8_xs[v22]) >> 16;
-    v33 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)dword_50BA08[v22]) >> 16;
-    dword_50BAF8_xs[v22] = pBLVRenderParams->uViewportCenterX - dword_50BAF8_xs[v22];
+        LOBYTE(v30) = dword_50B918[v22] >= v23;
+        v31 = v30 - 1;
+        v32 = (v31 & 0x800000) - 0x400000;
+      }
+    }
+    dword_50BA08[v22] = v32;
+    dword_50BAF4_xs[v22 + 1] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40)
+                                                * (signed __int64)dword_50BAF4_xs[v22 + 1]) >> 16;
+    v35 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)dword_50BA08[v22]) >> 16;
+    dword_50BAF4_xs[v22 + 1] = pBLVRenderParams->uViewportCenterX - dword_50BAF4_xs[v22 + 1];
     ++ia;
   }
-  v34 = 0;
-  dword_50BAF8_xs[v21] = dword_50BAF8_xs[0];
+  v36 = 0;
+  dword_50BAF4_xs[v21 + 1] = dword_50BAF4_xs[1];
   dword_50BA08[v21] = dword_50BA08[0];
-  v35 = pBLVRenderParams->uViewportX;
-  v36 = dword_50BAF8_xs[0] < (signed int)pBLVRenderParams->uViewportX;
-  LOBYTE(v36) = dword_50BAF8_xs[0] >= (signed int)pBLVRenderParams->uViewportX;
-  v37 = 1;
+  v37 = pBLVRenderParams->uViewportX;
+  v38 = dword_50BAF4_xs[1] < (signed int)pBLVRenderParams->uViewportX;
+  LOBYTE(v38) = dword_50BAF4_xs[1] >= (signed int)pBLVRenderParams->uViewportX;
+  v39 = 1;
   ib = 1;
-  if ( v77 < 1 )
+  if ( v79 < 1 )
     return 0;
   do
   {
-    v38 = v37;
-    v39 = dword_50BAF8_xs[v38];
-    v80 = v39 >= (signed int)v35;
-    if ( v36 ^ v80 )
-    {
-      if ( v39 >= (signed int)v35 )
-      {
-        v65 = (signed int)(v35 - dword_50BAF4[v38])
-            * (signed __int64)(dword_50BA08[v38] - dword_50B9F8[v38 + 3])
-            / (v39 - dword_50BAF4[v38]);
-        v40 = dword_50B9F8[v38 + 3];
+    v40 = v39;
+    v41 = dword_50BAF4_xs[v40 + 1];
+    v82 = v41 >= (signed int)v37;
+    if ( v38 ^ v82 )
+    {
+      if ( v41 >= (signed int)v37 )
+      {
+        v67 = (signed int)(v37 - dword_50BAF4_xs[v40])
+            * (signed __int64)(dword_50BA08[v40] - dword_50B9F8[v40 + 3])
+            / (v41 - dword_50BAF4_xs[v40]);
+        v42 = dword_50B9F8[v40 + 3];
       }
       else
       {
-        v65 = (signed int)(v35 - v39)
-            * (signed __int64)(dword_50B9F8[v38 + 3] - dword_50BA08[v38])
-            / (dword_50BAF4[v38] - v39);
-        v40 = dword_50BA08[v38];
-      }
-      ++v34;
-      dword_50B9F8[v34] = v65 + v40;
-      v35 = pBLVRenderParams->uViewportX;
-      dword_50BAE8[v34] = pBLVRenderParams->uViewportX;
-    }
-    v36 = v80;
-    if ( v80 )
-    {
-      dword_50BAEC_xs[v34] = dword_50BAF8_xs[v38];
-      dword_50B9F8[v34++ + 1] = dword_50BA08[v38];
-    }
-    v37 = ib++ + 1;
-  }
-  while ( ib <= v77 );
-  if ( !v34
-    || (v41 = 0,
-        dword_50BAEC_xs[v34] = dword_50BAEC_xs[0],
-        dword_50B9F8[v34 + 1] = dword_50B9F8[1],
-        v42 = pBLVRenderParams->uViewportZ,
-        thisd = dword_50BAEC_xs[0] <= (signed int)pBLVRenderParams->uViewportZ,
+        v67 = (signed int)(v37 - v41)
+            * (signed __int64)(dword_50B9F8[v40 + 3] - dword_50BA08[v40])
+            / (dword_50BAF4_xs[v40] - v41);
+        v42 = dword_50BA08[v40];
+      }
+      ++v36;
+      dword_50B9F8[v36] = v67 + v42;
+      v37 = pBLVRenderParams->uViewportX;
+      dword_50BAE8_xs[v36] = pBLVRenderParams->uViewportX;
+    }
+    v38 = v82;
+    if ( v82 )
+    {
+      dword_50BAE8_xs[v36 + 1] = dword_50BAF4_xs[v40 + 1];
+      dword_50B9F8[v36++ + 1] = dword_50BA08[v40];
+    }
+    v39 = ib++ + 1;
+  }
+  while ( ib <= v79 );
+
+  if ( !v36
+    || (v43 = 0,
+        dword_50BAE8_xs[v36 + 1] = dword_50BAE8_xs[1],
+        dword_50B9F8[v36 + 1] = dword_50B9F8[1],
+        v44 = pBLVRenderParams->uViewportZ,
+        thisd = dword_50BAE8_xs[1] <= (signed int)pBLVRenderParams->uViewportZ,
         ic = 1,
-        v34 < 1) )
+        v36 < 1) )
     return 0;
+
   do
   {
-    v43 = ic;
-    v44 = dword_50BAEC_xs[ic];
-    v81 = v44 <= (signed int)v42;
-    if ( thisd ^ v81 )
-    {
-      if ( v44 <= (signed int)v42 )
-      {
-        v66 = (signed int)(v42 - dword_50BAE8[v43])
-            * (signed __int64)(dword_50B9F8[v43 + 1] - dword_50B9F8[v43])
-            / (v44 - dword_50BAE8[v43]);
-        v45 = dword_50B9F8[v43];
+    v45 = ic;
+    v46 = dword_50BAE8_xs[ic + 1];
+    v83 = v46 <= (signed int)v44;
+    if ( thisd ^ v83 )
+    {
+      if ( v46 <= (signed int)v44 )
+      {
+        v68 = (signed int)(v44 - dword_50BAE8_xs[v45])
+            * (signed __int64)(dword_50B9F8[v45 + 1] - dword_50B9F8[v45])
+            / (v46 - dword_50BAE8_xs[v45]);
+        v47 = dword_50B9F8[v45];
       }
       else
       {
-        v66 = (signed int)(v42 - v44)
-            * (signed __int64)(dword_50B9F8[v43] - dword_50B9F8[v43 + 1])
-            / (dword_50BAE8[v43] - v44);
-        v45 = dword_50B9F8[v43 + 1];
-      }
-      ++v41;
-      dword_50B9EC[v41] = v66 + v45;
-      v42 = pBLVRenderParams->uViewportZ;
-      dword_50BADC_xs[v41] = pBLVRenderParams->uViewportZ;
-    }
-    if ( v81 )
-    {
-      dword_50BAE0[v41] = dword_50BAEC_xs[v43];
-      dword_50B9F0[v41++] = dword_50B9F8[v43 + 1];
+        v68 = (signed int)(v44 - v46)
+            * (signed __int64)(dword_50B9F8[v45] - dword_50B9F8[v45 + 1])
+            / (dword_50BAE8_xs[v45] - v46);
+        v47 = dword_50B9F8[v45 + 1];
+      }
+      ++v43;
+      dword_50B9EC[v43] = v68 + v47;
+      v44 = pBLVRenderParams->uViewportZ;
+      dword_50BADC_xs[v43] = pBLVRenderParams->uViewportZ;
+    }
+    if ( v83 )
+    {
+      dword_50BAE0[v43] = dword_50BAE8_xs[v45 + 1];
+      dword_50B9F0[v43++] = dword_50B9F8[v45 + 1];
     }
     ++ic;
-    thisd = v81;
-  }
-  while ( ic <= v34 );
-  if ( !v41
-    || (v46 = 0,
-        dword_50BAE0[v41] = dword_50BAE0[0],
-        dword_50B9F0[v41] = dword_50B9F0[0],
-        v47 = pBLVRenderParams->uViewportY,
-        v48 = dword_50B9F0[0] < (signed int)pBLVRenderParams->uViewportY,
-        LOBYTE(v48) = dword_50B9F0[0] >= (signed int)pBLVRenderParams->uViewportY,
-        v49 = 1,
+    thisd = v83;
+  }
+  while ( ic <= v36 );
+  if ( !v43
+    || (v48 = 0,
+        dword_50BAE0[v43] = dword_50BAE0[0],
+        dword_50B9F0[v43] = dword_50B9F0[0],
+        v49 = pBLVRenderParams->uViewportY,
+        v50 = dword_50B9F0[0] < (signed int)pBLVRenderParams->uViewportY,
+        LOBYTE(v50) = dword_50B9F0[0] >= (signed int)pBLVRenderParams->uViewportY,
+        v51 = 1,
         id = 1,
-        v41 < 1) )
+        v43 < 1) )
     return 0;
   do
   {
-    v50 = v49;
-    v51 = dword_50B9F0[v50];
-    v82 = v51 >= (signed int)v47;
-    if ( v48 ^ v82 )
-    {
-      if ( v51 >= (signed int)v47 )
-      {
-        v67 = (signed int)(v47 - dword_50B9EC[v50])
-            * (signed __int64)(dword_50BAE0[v50] - dword_50BADC_xs[v50])
-            / (v51 - dword_50B9EC[v50]);
-        v52 = dword_50BADC_xs[v50];
+    v52 = v51;
+    v53 = dword_50B9F0[v52];
+    v84 = v53 >= (signed int)v49;
+    if ( v50 ^ v84 )
+    {
+      if ( v53 >= (signed int)v49 )
+      {
+        v69 = (signed int)(v49 - dword_50B9EC[v52])
+            * (signed __int64)(dword_50BAE0[v52] - dword_50BADC_xs[v52])
+            / (v53 - dword_50B9EC[v52]);
+        v54 = dword_50BADC_xs[v52];
       }
       else
       {
-        v67 = (signed int)(v47 - v51)
-            * (signed __int64)(dword_50BADC_xs[v50] - dword_50BAE0[v50])
-            / (dword_50B9EC[v50] - v51);
-        v52 = dword_50BAE0[v50];
-      }
-      ++v46;
-      dword_50BAD0[v46] = v67 + v52;
-      v47 = pBLVRenderParams->uViewportY;
-      dword_50B9E0_ys[v46] = pBLVRenderParams->uViewportY;
-    }
-    v48 = v82;
-    if ( v82 )
-    {
-      dword_50BAD4[v46] = dword_50BAE0[v50];
-      dword_50B9E0_ys[v46++ + 1] = dword_50B9F0[v50];
-    }
-    v49 = id++ + 1;
-  }
-  while ( id <= v41 );
-  if ( !v46
-    || (v53 = 0,
-        dword_50BAD4[v46] = dword_50BAD4[0],
-        dword_50B9E0_ys[v46 + 1] = dword_50B9E0_ys[1],
-        v54 = pBLVRenderParams->uViewportW,
+        v69 = (signed int)(v49 - v53)
+            * (signed __int64)(dword_50BADC_xs[v52] - dword_50BAE0[v52])
+            / (dword_50B9EC[v52] - v53);
+        v54 = dword_50BAE0[v52];
+      }
+      ++v48;
+      dword_50BAD0[v48] = v69 + v54;
+      v49 = pBLVRenderParams->uViewportY;
+      dword_50B9E0_ys[v48] = pBLVRenderParams->uViewportY;
+    }
+    v50 = v84;
+    if ( v84 )
+    {
+      dword_50BAD4[v48] = dword_50BAE0[v52];
+      dword_50B9E0_ys[v48++ + 1] = dword_50B9F0[v52];
+    }
+    v51 = id++ + 1;
+  }
+  while ( id <= v43 );
+  if ( !v48
+    || (v55 = 0,
+        dword_50BAD4[v48] = dword_50BAD4[0],
+        dword_50B9E0_ys[v48 + 1] = dword_50B9E0_ys[1],
+        v56 = pBLVRenderParams->uViewportW,
         thise = dword_50B9E0_ys[1] <= (signed int)pBLVRenderParams->uViewportW,
         ie = 1,
-        v46 < 1) )
+        v48 < 1) )
     return 0;
   do
   {
-    v55 = ie;
-    v56 = dword_50B9E0_ys[ie + 1];
-    v83 = v56 <= (signed int)v54;
-    if ( thise ^ v83 )
-    {
-      if ( v56 <= (signed int)v54 )
-      {
-        v68 = (signed int)(v54 - dword_50B9E0_ys[v55])
-            * (signed __int64)(dword_50BAD4[v55] - dword_50BAD0[v55])
-            / (v56 - dword_50B9E0_ys[v55]);
-        v57 = dword_50BAD0[v55];
+    v57 = ie;
+    v58 = dword_50B9E0_ys[ie + 1];
+    v85 = v58 <= (signed int)v56;
+    if ( thise ^ v85 )
+    {
+      if ( v58 <= (signed int)v56 )
+      {
+        v70 = (signed int)(v56 - dword_50B9E0_ys[v57])
+            * (signed __int64)(dword_50BAD4[v57] - dword_50BAD0[v57])
+            / (v58 - dword_50B9E0_ys[v57]);
+        v59 = dword_50BAD0[v57];
       }
       else
       {
-        v68 = (signed int)(v54 - v56)
-            * (signed __int64)(dword_50BAD0[v55] - dword_50BAD4[v55])
-            / (dword_50B9E0_ys[v55] - v56);
-        v57 = dword_50BAD4[v55];
-      }
-      ++v53;
-      dword_50BAC4[v53] = v68 + v57;
-      v54 = pBLVRenderParams->uViewportW;
-      unk_50B9D4[v53] = pBLVRenderParams->uViewportW;
-    }
-    if ( v83 )
-    {
-      dword_50BAC8[v53] = dword_50BAD4[v55];
-      dword_50B9D8_ys[v53++] = dword_50B9E0_ys[v55 + 1];
+        v70 = (signed int)(v56 - v58)
+            * (signed __int64)(dword_50BAD0[v57] - dword_50BAD4[v57])
+            / (dword_50B9E0_ys[v57] - v58);
+        v59 = dword_50BAD4[v57];
+      }
+      ++v55;
+      dword_50BAC4[v55] = v70 + v59;
+      v56 = pBLVRenderParams->uViewportW;
+      unk_50B9D4[v55] = pBLVRenderParams->uViewportW;
+    }
+    if ( v85 )
+    {
+      dword_50BAC8[v55] = dword_50BAD4[v57];
+      dword_50B9D8_ys[v55++] = dword_50B9E0_ys[v57 + 1];
     }
     ++ie;
-    thise = v83;
-  }
-  while ( ie <= v46 );
-  if ( !v53 )
+    thise = v85;
+  }
+  while ( ie <= v48 );
+  if ( !v55 )
     return 0;
-  v59 = pRenderer->pRenderD3D == 0;
-  dword_50BAC8[v53] = dword_50BAC8[0];
-  dword_50B9D8_ys[v53] = dword_50B9D8_ys[0];
-  if ( v59 && v53 > 3 )
-  {
-    dword_50BAC8[v53 + 1] = dword_50BAC8[1];
-    dword_50B9D8_ys[v53 + 1] = dword_50B9D8_ys[1];
+  v61 = pRenderer->pRenderD3D == 0;
+  dword_50BAC8[v55] = dword_50BAC8[0];
+  dword_50B9D8_ys[v55] = dword_50B9D8_ys[0];
+  if ( v61 && v55 > 3 )
+  {
+    dword_50BAC8[v55 + 1] = dword_50BAC8[1];
+    dword_50B9D8_ys[v55 + 1] = dword_50B9D8_ys[1];
     thisf = 2 * (dword_50B700 != 0) - 1;
-    if ( v53 > 0 )
-    {
-      v60 = 1;
-      v69 = 1;
+    if ( v55 > 0 )
+    {
+      v62 = 1;
+      v71 = 1;
       do
       {
-        v61 = v60 - 1;
-        v62 = v60 + 1;
-        v78 = v60 + 1;
-        if ( v60 - 1 >= v53 )
-          v61 -= v53;
-        if ( v60 >= v53 )
-          v60 -= v53;
-        if ( v62 >= v53 )
-          v62 -= v53;
+        v63 = v62 - 1;
+        v64 = v62 + 1;
+        v80 = v62 + 1;
+        if ( v62 - 1 >= v55 )
+          v63 -= v55;
+        if ( v62 >= v55 )
+          v62 -= v55;
+        if ( v64 >= v55 )
+          v64 -= v55;
         if ( thisf
-           * ((dword_50B9D8_ys[v62] - dword_50B9D8_ys[v61]) * (dword_50BAC8[v60] - dword_50BAC8[v61])
-            - (dword_50B9D8_ys[v60] - dword_50B9D8_ys[v61]) * (dword_50BAC8[v62] - dword_50BAC8[v61])) < 0 )
+           * ((dword_50B9D8_ys[v64] - dword_50B9D8_ys[v63]) * (dword_50BAC8[v62] - dword_50BAC8[v63])
+            - (dword_50B9D8_ys[v62] - dword_50B9D8_ys[v63]) * (dword_50BAC8[v64] - dword_50BAC8[v63])) < 0 )
         {
-          v60 = v78;
-          v69 = v78;
+          v62 = v80;
+          v71 = v80;
         }
         else
         {
-          v60 = v69;
-          v63 = v69;
-          if ( v69 < v53 || (v63 = v69 - v53, v69 - v53 < v53) )
+          v62 = v71;
+          v65 = v71;
+          if ( v71 < v55 || (v65 = v71 - v55, v71 - v55 < v55) )
           {
-            memcpy(&dword_50B9D8_ys[v63], &dword_50B9D8_ys[v63 + 1], 4 * ((unsigned int)(4 * (v53 - v63)) >> 2));
-            memcpy(&dword_50BAC8[v63], &dword_50BAC8[v63 + 1], 4 * ((unsigned int)(4 * (v53 - v63)) >> 2));
+            memcpy(&dword_50B9D8_ys[v65], &dword_50B9D8_ys[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
+            memcpy(&dword_50BAC8[v65], &dword_50BAC8[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
           }
-          --v53;
+          --v55;
         }
       }
-      while ( v60 - 1 < v53 );
-    }
-    dword_50BAC8[v53] = dword_50BAC8[0];
-    dword_50B9D8_ys[v53] = dword_50B9D8_ys[0];
-  }
-  return v53;
+      while ( v62 - 1 < v55 );
+    }
+    dword_50BAC8[v55] = dword_50BAC8[0];
+    dword_50B9D8_ys[v55] = dword_50B9D8_ys[0];
+  }
+  return v55;
 }
 
 
--- a/mm7_3.cpp	Tue Oct 23 13:51:21 2012 +0200
+++ b/mm7_3.cpp	Tue Oct 23 23:38:05 2012 +0200
@@ -7032,7 +7032,7 @@
             &static_RenderBuildingsD3D_stru_73C834,
             uNumVertices,
             array_50AC10,
-            0.0,
+            0,
             (char)v31);
         if ( v50 )
         {
@@ -12921,7 +12921,7 @@
     pStru170->std__vector_000FA8 = 1;
     sub_440639(0);
   }
-  pStru170->RenderWalls();
+  pStru170->MakeVisibleSectorList();
 }
 
 //----- (0043F9E1) --------------------------------------------------------
@@ -13297,7 +13297,10 @@
     if ( v3->uNumNonBSPFaces > 0 )
     {
       do
-        pStru170->_4B0EA8(v1, v3->pFaceIDs[v2++]);
+      {
+        Log::Warning(L"Non-BSP face: %X", v3->pFaceIDs[v2]);
+        pStru170->PrepareFaceRenderList_d3d(v1, v3->pFaceIDs[v2++]);
+      }
       while ( v2 < v3->uNumNonBSPFaces );
     }
   }
@@ -13306,7 +13309,7 @@
     if ( v3->uNumNonBSPFaces > 0 )
     {
       do
-        pStru170->_4AFB86(v1, v3->pFaceIDs[v2++]);
+        pStru170->PrepareFaceRenderList_sw(v1, v3->pFaceIDs[v2++]);
       while ( v2 < v3->uNumNonBSPFaces );
     }
   }
@@ -13329,6 +13332,8 @@
   bool v11; // [sp+14h] [bp-8h]@5
   stru170_stru0 *v12; // [sp+18h] [bp-4h]@1
 
+  Log::Warning(L"sub_4406BC(%u, %u)", a1, uFirstNode);
+
   v10 = a1;
   v12 = &pStru170->field_FA8[a1];
   while ( 1 )
@@ -13351,15 +13356,18 @@
       sub_4406BC(v10, v6);
     v7 = v3->uCoplanarOffset;
     v8 = v7 + v3->uCoplanarSize;
+
+    Log::Warning(L"Node %u: %X to %X (%hX)", uFirstNode, v7, v8, v2->pFaceIDs[v7]);
+    
     if ( pRenderer->pRenderD3D )
     {
       while ( v7 < v8 )
-        pStru170->_4B0EA8(v10, v2->pFaceIDs[v7++]);
+        pStru170->PrepareFaceRenderList_d3d(v10, v2->pFaceIDs[v7++]);
     }
     else
     {
       while ( v7 < v8 )
-        pStru170->_4AFB86(v10, v2->pFaceIDs[v7++]);
+        pStru170->PrepareFaceRenderList_sw(v10, v2->pFaceIDs[v7++]);
     }
     v9 = v11 ? v3->uFront : v3->uBack;
     if ( v9 == -1 )
@@ -13481,12 +13489,11 @@
 {
   if ( uActiveCharacter )
     pRenderer->DrawTextureTransparent(
-      pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing__negindex[uActiveCharacter] - 9,
+      pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[uActiveCharacter - 1] - 9,
       0x17Cu,
       &pIcons_LOD->pTextures[dword_50C98C]);
 }
-// 4ED746: using guessed type __int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing__negindex[];
-// 50C98C: using guessed type int dword_50C98C;
+
 
 //----- (004415C5) --------------------------------------------------------
 void __cdecl Load_isn_spells_21_27()
--- a/mm7_4.cpp	Tue Oct 23 13:51:21 2012 +0200
+++ b/mm7_4.cpp	Tue Oct 23 23:38:05 2012 +0200
@@ -7336,11 +7336,12 @@
         v1 = pRenderer->pTargetSurface;
         v2 = Dst.lpSurface;
 
+
         for (uint y = 0; y < 480; ++y)
         {
           auto pDst = (unsigned short *)((char *)Dst.lpSurface + y * Dst.lPitch);
           for (uint x = 0; x < 640; ++x)
-            pDst[x] = pRenderer->uTargetGMask | pRenderer->uTargetBMask;
+            pDst[x] = pRenderer->uTargetRMask | pRenderer->uTargetBMask;
         }
         
         auto pSrc = pRenderer->pTargetSurface;
@@ -15114,10 +15115,10 @@
   SpriteFrame *v10; // ebx@18
   int *v11; // eax@18
   int v12; // ecx@28
-  IndoorCameraD3D **v14; // eax@36
+  //IndoorCameraD3D **v14; // eax@36
   double v15; // st7@36
   float v16; // eax@36
-  double v17; // ST30_8@36
+  //double v17; // ST30_8@36
   signed __int64 v18; // qtt@36
   int v19; // ST5C_4@36
   signed __int64 v20; // qtt@37
@@ -15127,8 +15128,8 @@
   signed int v24; // ecx@40
   int v25; // edx@44
   __int16 v26; // ax@44
-  MonsterDesc *v27; // edx@44
-  int v28; // ecx@44
+  //MonsterDesc *v27; // edx@44
+  //int v28; // ecx@44
   unsigned __int8 v29; // zf@44
   unsigned __int8 v30; // sf@44
   unsigned int v31; // [sp-8h] [bp-5Ch]@15
@@ -15186,7 +15187,7 @@
     if (p->pActorBuffs[5].uExpireTime > 0i64 || p->pActorBuffs[6].uExpireTime > 0i64 )
       v8 = 0;
     v31 = p->pSpriteIDs[v5];
-    if (p->uAIState == 16 )
+    if (p->uAIState == Resurrected)
       v9 = pSpriteFrameTable->GetFrameBy_x(v31, v8);
     else
       v9 = pSpriteFrameTable->GetFrame(v31, v8);
@@ -15217,13 +15218,13 @@
         v11);
     }
     v12 = 0;
-    if ( pStru170->field_53730 <= 0 )
+    if ( pStru170->uNumVisibleNotEmptySectors <= 0 )
       continue;
-    while (pStru170->pSectorIDs_toDrawDecorationsFrom[v12] != p->uSectorID)
+    while (pStru170->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v12] != p->uSectorID)
     {
       ++v12;
-      if ( v12 >= pStru170->field_53730 )
-        continue;
+      if ( v12 >= pStru170->uNumVisibleNotEmptySectors )
+        goto _continue;
     }
     if ( !pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(a1a, a2, a3, &x, &y, &z, 1)
       || (v0 = (RenderBillboard *)abs(x), (signed int)v0 < abs(y)) )
@@ -15250,14 +15251,14 @@
     }
     else
     {
-      v14 = &pGame->pIndoorCameraD3D;
+      //v14 = &pGame->pIndoorCameraD3D;
       v0->flt_8 = pGame->pIndoorCameraD3D->flt_D0;
-      v15 = (*v14)->flt_D4;
+      v15 = pGame->pIndoorCameraD3D->flt_D4;
       v16 = v0->flt_8;
       v0->flt_C = v15;
-      v17 = v16 + 6.7553994e15;
+      //v17 = v16 + 6.7553994e15;
       LODWORD(v18) = 0;
-      HIDWORD(v18) = SLOWORD(v17);
+      HIDWORD(v18) = floorf(v16 + 0.5f);
       v19 = v18 / x;
       v0->field_0 = (unsigned __int64)(v10->scale * v18 / x) >> 16;
       a5a = (unsigned __int64)(v10->scale * (signed __int64)v19) >> 16;
@@ -15295,18 +15296,21 @@
     LOWORD(v25) = 0;
     LOBYTE(v26) = v41;
     v0->sZValue = v25 + (8 * i | 3);
-    v27 = pMonsterList->pMonsters;
-    v28 = p->pMonsterInfo.uID;
+    //v27 = pMonsterList->pMonsters;
+    //v28 = p->pMonsterInfo.uID;
     v29 = HIDWORD(p->pActorBuffs[5].uExpireTime) == 0;
     v30 = HIDWORD(p->pActorBuffs[5].uExpireTime) < 0;
     v0->field_1E = v41;
     v0->pSpriteFrame = v10;
-    v0->uTintColor = *((_DWORD *)&v27[v28] - 36);
+    v0->uTintColor = pMonsterList->pMonsters[p->pMonsterInfo.uID - 1].uTintColor;
     if ( !v30 && (!(v30 | v29) || LODWORD(p->pActorBuffs[5].uExpireTime)) )
     {
       HIBYTE(v26) = HIBYTE(v41) | 1;
       v0->field_1E = v26;
     }
+    
+_continue:
+    ;
   }
 }
 
--- a/mm7_5.cpp	Tue Oct 23 13:51:21 2012 +0200
+++ b/mm7_5.cpp	Tue Oct 23 23:38:05 2012 +0200
@@ -8957,27 +8957,27 @@
 
 
 //----- (0043F333) --------------------------------------------------------
-void stru170::RenderWalls()
+void stru170::MakeVisibleSectorList()
 {
   int v6; // ebx@3
 
-  field_53730 = 0;
+  uNumVisibleNotEmptySectors = 0;
   for (uint i = 0; i < std__vector_000FA8; ++i)
   {
       v6 = 0;
-      if (!field_53730)
+      if (!uNumVisibleNotEmptySectors)
       {
 LABEL_7:
-        pSectorIDs_toDrawDecorationsFrom[field_53730++] = field_FA8[i].uSectorID;
+        pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = field_FA8[i].uSectorID;
       }
       else
       {
-        while (pSectorIDs_toDrawDecorationsFrom[v6] != field_FA8[i].uSectorID )
+        while (pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v6] != field_FA8[i].uSectorID )
         {
           ++v6;
-          if ( v6 >= field_53730)
-          {
-            pSectorIDs_toDrawDecorationsFrom[field_53730++] = field_FA8[i].uSectorID;
+          if ( v6 >= uNumVisibleNotEmptySectors)
+          {
+            pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = field_FA8[i].uSectorID;
             continue;
           }
         }
--- a/mm7_data.cpp	Tue Oct 23 13:51:21 2012 +0200
+++ b/mm7_data.cpp	Tue Oct 23 23:38:05 2012 +0200
@@ -350,6 +350,7 @@
 int amuint_4E1870; // weak
 int dword_4E1874; // weak
 int dword_4E1878; // weak
+float flt_4D84E8 = 0.0f;
 int dword_4E187C; // weak
 int dword_4E1880; // weak
 int dword_4E1884; // weak
@@ -481,8 +482,8 @@
 int dword_4E2A50[12];
 int _4E2A80_skills[9];
 unsigned __int8 pAwardsTextColors[20];
-unsigned int pHealthBarPos[4];
-unsigned int pManaBarPos[4];
+unsigned int pHealthBarPos[4] = {22, 137, 251, 366};
+unsigned int pManaBarPos[4] = {102, 217, 331, 447};
 char _4E2AD8_ui_colors[72];
 char _4E2B21_buff_spell_tooltip_colors[80];
 char byte_4E2B70[777]; // weak
@@ -1692,8 +1693,7 @@
 const char *dlhu_texnames_by_face[25];
 _UNKNOWN unk_4ED3D8; // weak
 unsigned char byte_4ED498 = 15; // weak
-__int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing__negindex[777]; // weak
-__int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[4];
+__int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[4] = {34, 149, 264, 379};
 char byte_4ED970_skill_learn_ability_by_class_table[32][37];
 int dword_4EDEA0[777]; // weak
 int dword_4EDEB4[777]; // weak
@@ -1701,8 +1701,8 @@
 __int16 word_4EDED8[777]; // weak
 __int16 word_4EDEDC; // weak
 _UNKNOWN unk_4EDF40; // weak
-unsigned int pHiredNPCsIconsOffsetsX[2];
-unsigned int pHiredNPCsIconsOffsetsY[2];
+unsigned int pHiredNPCsIconsOffsetsX[2] = {489, 559};
+unsigned int pHiredNPCsIconsOffsetsY[2] = {152, 152};
 int dword_4EE07C[2]; // weak
 _UNKNOWN unk_4EE084; // weak
 __int16 word_4EE088_sound_ids[100] =
@@ -2073,19 +2073,18 @@
 int dword_50B638[777]; // weak
 int dword_50B700; // weak
 int dword_50B738[777]; // idb
-int _50B744_view_transformed_ys_minus1[777]; // weak
 int _50B744_view_transformed_ys[43];
 int dword_50B828[777];
-int _50B834_view_transformed_zs_minus1[777]; // weak
 int _50B834_view_transformed_zs[43];
 int dword_50B918[777];
-int _50B924_view_transformed_xs_minus1[777]; // idb
 int _50B924_view_transformed_xs[43];
 int unk_50B9D4[777]; // idb
 int dword_50B9D8_ys[777];
 int dword_50B9E0_ys[777]; // idb
 int dword_50B9EC[777]; // idb
 int dword_50B9F0[2]; // idb
+int dword_50BAE8_xs[777];
+int dword_50BAF4_xs[777];
 int dword_50B9F8[777]; // idb
 int dword_50BA08[777]; // idb
 int dword_50BAC4[777]; // weak
--- a/mm7_data.h	Tue Oct 23 13:51:21 2012 +0200
+++ b/mm7_data.h	Tue Oct 23 23:38:05 2012 +0200
@@ -337,6 +337,7 @@
 extern int amuint_4E1870; // weak
 extern int dword_4E1874; // weak
 extern int dword_4E1878; // weak
+extern float flt_4D84E8;
 extern int dword_4E187C; // weak
 extern int dword_4E1880; // weak
 extern int dword_4E1884; // weak
@@ -1661,7 +1662,6 @@
 extern const char *dlhu_texnames_by_face[25];
 extern _UNKNOWN unk_4ED3D8; // weak
 extern unsigned char byte_4ED498; // weak
-extern __int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing__negindex[]; // weak
 extern __int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[4];
 extern char byte_4ED970_skill_learn_ability_by_class_table[32][37];
 extern int dword_4EDEA0[]; // weak
@@ -2026,19 +2026,18 @@
 extern int dword_50B638[]; // weak
 extern int dword_50B700; // weak
 extern int dword_50B738[]; // idb
-extern int _50B744_view_transformed_ys_minus1[]; // weak
 extern int _50B744_view_transformed_ys[43];
 extern int dword_50B828[];
-extern int _50B834_view_transformed_zs_minus1[]; // weak
 extern int _50B834_view_transformed_zs[43];
 extern int dword_50B918[];
-extern int _50B924_view_transformed_xs_minus1[]; // idb
 extern int _50B924_view_transformed_xs[43];
 extern int unk_50B9D4[]; // idb
 extern int dword_50B9D8_ys[];
 extern int dword_50B9E0_ys[]; // idb
 extern int dword_50B9EC[]; // idb
 extern int dword_50B9F0[2]; // idb
+extern int dword_50BAE8_xs[];
+extern int dword_50BAF4_xs[];
 extern int dword_50B9F8[]; // idb
 extern int dword_50BA08[]; // idb
 extern int dword_50BAC4[]; // weak
--- a/stru10.cpp	Tue Oct 23 13:51:21 2012 +0200
+++ b/stru10.cpp	Tue Oct 23 23:38:05 2012 +0200
@@ -94,7 +94,7 @@
     --v6;
   }
   while ( v6 );
-  stru10::_49D379(pFace, a2a);
+  stru10::CalcPolygonBoundingBox(pFace, a2a);
   v7 = pFace->uAttributes;
   if ( v7 & 0x100 )
   {
@@ -417,674 +417,312 @@
 }
 
 //----- (0049D379) --------------------------------------------------------
-int stru10::_49D379(BLVFace *pFace, RenderVertexSoft *pVertices)
+void stru10::CalcPolygonBoundingBox(BLVFace *pFace, RenderVertexSoft *pOutVertices)
 {
-  BLVFace *v3; // edx@1
-  Vec3_short_ *v4; // ecx@1
-  int v5; // eax@2
-  unsigned __int16 *v6; // esi@3
-  char *v7; // eax@3
-  int v8; // ebx@4
-  int v9; // edi@4
-  int v10; // ebx@4
-  int v11; // edi@4
-  double v12; // st7@4
-  int v13; // edi@4
-  unsigned __int16 *v14; // esi@7
-  char *v15; // eax@7
-  int v16; // ebx@8
-  int v17; // edi@8
-  int v18; // ebx@8
-  int v19; // edi@8
-  double v20; // st7@8
-  int v21; // edi@8
-  unsigned __int16 *v22; // esi@11
-  char *v23; // eax@11
-  int v24; // ebx@12
-  int v25; // edi@12
-  int v26; // ebx@12
-  int v27; // edi@12
-  double v28; // st7@12
-  int v29; // edi@12
-  int v30; // eax@13
-  double v31; // st7@13
-  char *v32; // esi@14
-  int v33; // edi@14
-  int v34; // eax@24
-  Vec3_short_ *v35; // eax@24
-  signed int v36; // ecx@24
-  signed int v37; // eax@24
-  Vec3_short_ *v38; // eax@24
-  signed int v39; // ecx@24
-  signed int v40; // eax@24
-  Vec3_short_ *v41; // eax@24
-  signed int v42; // ecx@24
-  signed int v43; // eax@24
-  Vec3_short_ *v44; // eax@24
-  signed int v45; // ecx@24
-  signed int result; // eax@24
-  char v47; // [sp+10h] [bp-350h]@3
-  RenderVertexSoft v48; // [sp+30Ch] [bp-54h]@24
-  int v49; // [sp+33Ch] [bp-24h]@16
-  int v50; // [sp+340h] [bp-20h]@20
-  int v51; // [sp+344h] [bp-1Ch]@18
-  int v52; // [sp+348h] [bp-18h]@22
-  unsigned __int16 *v53; // [sp+34Ch] [bp-14h]@3
-  Vec3_short_ *v54; // [sp+350h] [bp-10h]@3
-  float v55; // [sp+354h] [bp-Ch]@1
-  float v56; // [sp+358h] [bp-8h]@4
-  Vec3_short_ *v57; // [sp+35Ch] [bp-4h]@4
-  int pFacea; // [sp+368h] [bp+8h]@2
-  int pFaceb; // [sp+368h] [bp+8h]@6
-  int pFacec; // [sp+368h] [bp+8h]@10
-  float pFaced; // [sp+368h] [bp+8h]@13
-  signed int pFacee; // [sp+368h] [bp+8h]@24
-  signed int pFacef; // [sp+368h] [bp+8h]@24
-  signed int pFaceg; // [sp+368h] [bp+8h]@24
-  signed int pFaceh; // [sp+368h] [bp+8h]@24
+  struct
+  {
+    float x;
+    float y;
+    int c;
+  } v46[40]; //[sp+0C];
 
-  v3 = pFace;
-  v4 = pIndoor->pVertices;
-  LODWORD(v55) = pFace->uAttributes;
-  if ( BYTE1(v55) & 1 )
+  if (pFace->uAttributes & 0x0100)
   {
-    v5 = pFace->uNumVertices;
-    pFacea = 0;
-    if ( v5 > 0 )
+    for (uint i = 0; i < pFace->uNumVertices; ++i)
+    {
+      v46[i].x = pIndoor->pVertices[pFace->pVertexIDs[i]].x + pFace->pXInterceptDisplacements[i];
+      v46[i].y = pIndoor->pVertices[pFace->pVertexIDs[i]].y + pFace->pYInterceptDisplacements[i];
+      v46[i].c = i;
+    }
+  }
+  if (pFace->uAttributes & 0x0200)
+  {
+    for (uint i = 0; i < pFace->uNumVertices; ++i)
     {
-      v6 = v3->pVertexIDs;
-      v7 = &v47;
-      v53 = (unsigned short *)((char *)v3->pXInterceptDisplacements - (char *)v6);
-      v54 = (Vec3_short_ *)((char *)v3->pYInterceptDisplacements - (char *)v6);
-      do
-      {
-        v8 = *(unsigned __int16 *)((char *)v53 + (int)v6);
-        v57 = &v4[*v6];
-        LODWORD(v56) = v57->x + v8;
-        v9 = *(__int16 *)((char *)&v54->x + (int)v6);
-        v10 = v57->y;
-        *((float *)v7 - 1) = (double)SLODWORD(v56);
-        v57 = (Vec3_short_ *)(v10 + v9);
-        v11 = pFacea;
-        v12 = (double)(signed int)v57;
-        ++pFacea;
-        *((int *)v7 + 1) = v11;
-        v13 = v3->uNumVertices;
-        *(float *)v7 = v12;
-        v7 += 12;
-        ++v6;
-      }
-      while ( pFacea < v13 );
+      v46[i].x = pIndoor->pVertices[pFace->pVertexIDs[i]].x + pFace->pXInterceptDisplacements[i];
+      v46[i].y = pIndoor->pVertices[pFace->pVertexIDs[i]].y + pFace->pZInterceptDisplacements[i];
+      v46[i].c = i;
+    }
+  }
+  if (pFace->uAttributes & 0x0400)
+  {
+    for (uint i = 0; i < pFace->uNumVertices; ++i)
+    {
+      v46[i].x = pIndoor->pVertices[pFace->pVertexIDs[i]].x + pFace->pYInterceptDisplacements[i];
+      v46[i].y = pIndoor->pVertices[pFace->pVertexIDs[i]].y + pFace->pZInterceptDisplacements[i];
+      v46[i].c = i;
     }
   }
-  if ( BYTE1(v55) & 2 )
+
+  float x_min = FLT_MAX;
+  uint  x_min_idx = 0;
+
+  float x_max = FLT_MIN;
+  uint  x_max_idx = 0;
+
+  float y_min = FLT_MAX;
+  uint  y_min_idx = 0;
+
+  float y_max = FLT_MIN;
+  uint  y_max_idx = 0;
+
+  for (uint i = 0; i < pFace->uNumVertices; ++i)
   {
-    pFaceb = 0;
-    if ( (signed int)v3->uNumVertices > 0 )
+    if (v46[i].x < x_min)
     {
-      v14 = v3->pVertexIDs;
-      v15 = &v47;
-      v53 = (unsigned short *)((char *)v3->pXInterceptDisplacements - (char *)v14);
-      LODWORD(v56) = (char *)v3->pZInterceptDisplacements - (char *)v14;
-      do
-      {
-        v16 = *(unsigned __int16 *)((char *)v53 + (int)v14);
-        v54 = &v4[*v14];
-        v57 = (Vec3_short_ *)(v54->x + v16);
-        v17 = *(signed __int16 *)((char *)v14 + LODWORD(v56));
-        v18 = v54->z;
-        *((float *)v15 - 1) = (double)(signed int)v57;
-        v57 = (Vec3_short_ *)(v18 + v17);
-        v19 = pFaceb;
-        v20 = (double)(signed int)v57;
-        ++pFaceb;
-        *((int *)v15 + 1) = v19;
-        v21 = v3->uNumVertices;
-        *(float *)v15 = v20;
-        v15 += 12;
-        ++v14;
-      }
-      while ( pFaceb < v21 );
+      x_min = v46[i].x;
+      x_min_idx = v46[i].c;
     }
-  }
-  if ( BYTE1(v55) & 4 )
-  {
-    pFacec = 0;
-    if ( (signed int)v3->uNumVertices > 0 )
+    if (v46[i].x > x_max)
+    {
+      x_max = v46[i].x;
+      x_max_idx = v46[i].c;
+    }
+
+    if (v46[i].y < y_min)
     {
-      v22 = v3->pVertexIDs;
-      v23 = &v47;
-      v54 = (Vec3_short_ *)((char *)v3->pYInterceptDisplacements - (char *)v22);
-      LODWORD(v56) = (char *)v3->pZInterceptDisplacements - (char *)v22;
-      do
-      {
-        v24 = *(__int16 *)((char *)&v54->x + (int)v22);
-        LODWORD(v55) = (unsigned int)&v4[*v22];
-        v57 = (Vec3_short_ *)(*(short *)(LODWORD(v55) + 2) + v24);
-        v25 = *(signed __int16 *)((char *)v22 + LODWORD(v56));
-        v26 = *(short *)(LODWORD(v55) + 4);
-        *((float *)v23 - 1) = (double)(signed int)v57;
-        v57 = (Vec3_short_ *)(v26 + v25);
-        v27 = pFacec;
-        v28 = (double)(signed int)v57;
-        ++pFacec;
-        *((int *)v23 + 1) = v27;
-        v29 = v3->uNumVertices;
-        *(float *)v23 = v28;
-        v23 += 12;
-        ++v22;
-      }
-      while ( pFacec < v29 );
+      y_min = v46[i].y;
+      y_min_idx = v46[i].c;
+    }
+    if (v46[i].y > y_max)
+    {
+      y_max = v46[i].y;
+      y_max_idx = v46[i].c;
     }
   }
-  v30 = v3->uNumVertices;
-  pFaced = 3.4028235e38;
-  v56 = 3.4028235e38;
-  v31 = -3.4028235e38;
-  v55 = -3.4028235e38;
-  if ( v30 > 0 )
-  {
-    v32 = &v47;
-    v33 = v30;
-    do
-    {
-      if ( *((float *)v32 - 1) < (double)pFaced )
-      {
-        LODWORD(pFaced) = *((int *)v32 - 1);
-        v49 = *((int *)v32 + 1);
-      }
-      if ( *((float *)v32 - 1) > (double)v55 )
-      {
-        LODWORD(v55) = *((int *)v32 - 1);
-        v51 = *((int *)v32 + 1);
-      }
-      if ( *(float *)v32 < (double)v56 )
-      {
-        LODWORD(v56) = *(int *)v32;
-        v50 = *((int *)v32 + 1);
-      }
-      if ( v31 < *(float *)v32 )
-      {
-        v31 = *(float *)v32;
-        v52 = *((int *)v32 + 1);
-      }
-      v32 += 12;
-      --v33;
-    }
-    while ( v33 );
-  }
-  v34 = v3->pVertexIDs[v49];
-  v48.flt_2C = 0.0;
-  v35 = &v4[v34];
-  pFacee = v35->x;
-  v36 = v35->y;
-  v37 = v35->z;
-  v48.vWorldPosition.x = (double)pFacee;
-  v48.vWorldPosition.y = (double)v36;
-  v48.vWorldPosition.z = (double)v37;
-  memcpy(pVertices, &v48, 0x30u);
-  v48.flt_2C = 0.0;
-  v38 = &pIndoor->pVertices[v3->pVertexIDs[v50]];
-  pFacef = v38->x;
-  v39 = v38->y;
-  v40 = v38->z;
-  v48.vWorldPosition.x = (double)pFacef;
-  v48.vWorldPosition.y = (double)v39;
-  v48.vWorldPosition.z = (double)v40;
-  memcpy(&pVertices[1], &v48, sizeof(pVertices[1]));
-  v48.flt_2C = 0.0;
-  v41 = &pIndoor->pVertices[v3->pVertexIDs[v51]];
-  pFaceg = v41->x;
-  v42 = v41->y;
-  v43 = v41->z;
-  v48.vWorldPosition.x = (double)pFaceg;
-  v48.vWorldPosition.y = (double)v42;
-  v48.vWorldPosition.z = (double)v43;
-  memcpy(&pVertices[2], &v48, sizeof(pVertices[2]));
-  v48.flt_2C = 0.0;
-  v44 = &pIndoor->pVertices[v3->pVertexIDs[v52]];
-  pFaceh = v44->x;
-  v45 = v44->y;
-  result = v44->z;
-  v48.vWorldPosition.x = (double)pFaceh;
-  v48.vWorldPosition.y = (double)v45;
-  v48.vWorldPosition.z = (double)result;
-  memcpy(&pVertices[3], &v48, sizeof(pVertices[3]));
-  return result;
+
+
+
+  auto p1 = &pIndoor->pVertices[pFace->pVertexIDs[x_min_idx]];
+  RenderVertexSoft v1; // [sp+30Ch] [bp-54h]@24
+  v1.vWorldPosition.x = (float)p1->x;
+  v1.vWorldPosition.y = (float)p1->y;
+  v1.vWorldPosition.z = (float)p1->z;
+  memcpy(pOutVertices + 0, &v1, sizeof(RenderVertexSoft));
+
+  auto p2 = &pIndoor->pVertices[pFace->pVertexIDs[y_min_idx]];
+  RenderVertexSoft v2; // [sp+30Ch] [bp-54h]@24
+  v2.vWorldPosition.x = (float)p2->x;
+  v2.vWorldPosition.y = (float)p2->y;
+  v2.vWorldPosition.z = (float)p2->z;
+  memcpy(pOutVertices + 1, &v2, sizeof(RenderVertexSoft));
+
+  auto p3 = &pIndoor->pVertices[pFace->pVertexIDs[x_max_idx]];
+  RenderVertexSoft v3; // [sp+30Ch] [bp-54h]@24
+  v3.vWorldPosition.x = (float)p3->x;
+  v3.vWorldPosition.y = (float)p3->y;
+  v3.vWorldPosition.z = (float)p3->z;
+  memcpy(pOutVertices + 2, &v3, sizeof(RenderVertexSoft));
+
+  auto p4 = &pIndoor->pVertices[pFace->pVertexIDs[y_max_idx]];
+  RenderVertexSoft v4; // [sp+30Ch] [bp-54h]@24
+  v4.vWorldPosition.x = (double)p4->x;
+  v4.vWorldPosition.y = (double)p4->y;
+  v4.vWorldPosition.z = (double)p4->z;
+  memcpy(pOutVertices + 3, &v4, sizeof(RenderVertexSoft));
 }
 
 
 //----- (0049C9E3) --------------------------------------------------------
-bool stru10::_49C9E3(BLVFace *a3, RenderVertexSoft *arg4, unsigned int uNumVertices, RenderVertexSoft *arg0)
+bool stru10::_49C9E3(BLVFace *pFace, RenderVertexSoft *pFaceBounding, unsigned int uNumVertices, RenderVertexSoft *arg0)
 {
-  __debugbreak();
-  return 0;
-  /*IndoorCameraD3D *v6; // edi@1
-  PolygonType v7; // al@1
-  unsigned int v8; // edx@7
-  char v10; // zf@10
-  float v13; // ST14_4@20
-  stru10 *v15; // ecx@21
-  RenderVertexSoft *v16; // ST0C_4@21
-  bool result; // eax@21
-  float v18; // ST14_4@24
-  stru10 *v19; // edi@29
-  float v20; // ST14_4@30
-  float v21; // ST14_4@30
-  float v22; // ST14_4@30
-  float v23; // ST14_4@30
-  float v24; // ST14_4@31
-  RenderVertexSoft v25; // [sp+10h] [bp-90h]@24
-  RenderVertexSoft v26; // [sp+40h] [bp-60h]@20
-  IndoorCameraD3D *thisa; // [sp+70h] [bp-30h]@1
-  stru10 *v31; // [sp+84h] [bp-1Ch]@1
+  //IndoorCameraD3D *v6; // edi@1
+  //PolygonType v7; // al@1
+  //unsigned int v8; // edx@7
+  //char v10; // zf@10
+  //float v13; // ST14_4@20
+  //stru10 *v15; // ecx@21
+  //RenderVertexSoft *v16; // ST0C_4@21
+  //bool result; // eax@21
+  //float v18; // ST14_4@24
+  //stru10 *v19; // edi@29
+  //float v20; // ST14_4@30
+  //float v21; // ST14_4@30
+  //float v22; // ST14_4@30
+  //float v23; // ST14_4@30
+  //float v24; // ST14_4@31
+  //RenderVertexSoft v25; // [sp+10h] [bp-90h]@24
+  //RenderVertexSoft v26; // [sp+40h] [bp-60h]@20
+  //IndoorCameraD3D *thisa; // [sp+70h] [bp-30h]@1
+  //stru10 *v31; // [sp+84h] [bp-1Ch]@1
   float v32; // [sp+88h] [bp-18h]@8
   Vec3_float_ a1; // [sp+8Ch] [bp-14h]@1
   float v35; // [sp+9Ch] [bp-4h]@8
 
-  _ESI = a3;
-  v31 = this;
-  __asm
-  {
-    fld     dword ptr [esi]
-    fld     dword ptr [esi+4]
-    fldz
-  }
-  v6 = pGame->pIndoorCameraD3D;
-  v7 = a3->uPolygonType;
-  __asm
-  {
-    fstp    [ebp+var_28]
-    fldz
-  }
-  thisa = v6;
-  __asm
+  //auto a3 = pFace;
+  //auto arg4 = pFaceBounding;
+
+  //_ESI = a3;
+  //v31 = this;
+  //v6 = pGame->pIndoorCameraD3D;
+  //v7 = a3->uPolygonType;
+
+  a1.x = 0.0f;
+  a1.y = 0.0f;
+  a1.z = 0.0f;
+
+  float var_28;
+  float var_24;
+  if (pFace->uPolygonType == POLYGON_VerticalWall)
   {
-    fstp    [ebp+var_24]
-    fldz
-    fstp    [ebp+a1.x]
-    fldz
-    fstp    [ebp+a1.y]
-    fldz
-    fstp    [ebp+a1.z]
+    a1.x = -pFace->pFacePlane.vNormal.y;
+    a1.y = pFace->pFacePlane.vNormal.x;
+    a1.z = 0.0f;
+    a1.Normalize();
+
+    var_28 = 0;
+    var_24 = 1;
   }
-  if ( v7 == 1 )
+  else if (pFace->uPolygonType == POLYGON_Floor ||
+           pFace->uPolygonType == POLYGON_Ceiling)
   {
-    __asm
-    {
-      fchs
-      fstp    [ebp+a1.x]
-      fstp    [ebp+a1.y]
-      fldz
-      fstp    [ebp+a1.z]
-    }
-    a1.Normalize();
-    __asm
-    {
-      fldz
-      fstp    [ebp+var_28]
-      fld1
-    }
-LABEL_6:
-    __asm { fstp    [ebp+var_24] }
-    goto LABEL_7;
+    a1.x = 1;
+    a1.y = 0;
+    a1.z = 0.0f;
+
+    var_28 = 1;
+    var_24 = 0;
   }
-  __asm
-  {
-    fstp    st
-    fstp    st
-  }
-  if ( v7 == 3 || v7 == 5 )
+
+
+  float arg_4;
+  float var_18;
+  float var_4;
+  float a3;
+  float var_8;
+  //v8 = _ESI->uAttributes;
+  //_ECX = pFaceBounding;
+  //__asm { fld     0.5 }
+  if (pFace->uAttributes & 0x0100)
   {
-    __asm
-    {
-      fld1
-      fstp    [ebp+a1.x]
-      fldz
-      fstp    [ebp+a1.y]
-      fldz
-      fstp    [ebp+a1.z]
-      fld1
-      fstp    [ebp+var_28]
-      fldz
-    }
-    goto LABEL_6;
+    arg_4 = (pFaceBounding[0].vWorldPosition.x + pFaceBounding[2].vWorldPosition.x) / 2;
+    var_18 = (pFaceBounding[3].vWorldPosition.y + pFaceBounding[1].vWorldPosition.y) / 2;
+    var_4 = (pFaceBounding[0].vWorldPosition.z + pFaceBounding[2].vWorldPosition.z) / 2;
+
+    a3 = arg_4 - pFaceBounding[0].vWorldPosition.x;
+    var_8 = var_18 - pFaceBounding[1].vWorldPosition.y;
   }
-LABEL_7:
-  v8 = _ESI->uAttributes;
-  _ECX = arg4;
-  __asm { fld     ds:flt_4D84F0 }
-  if ( BYTE1(v8) & 1 )
+  if (pFace->uAttributes & 0x0200)
   {
-    __asm
+    arg_4 = (pFaceBounding[0].vWorldPosition.x + pFaceBounding[2].vWorldPosition.x) / 2;
+    var_18 = (pFaceBounding[0].vWorldPosition.y + pFaceBounding[2].vWorldPosition.y) / 2;
+    var_4 = (pFaceBounding[1].vWorldPosition.z + pFaceBounding[3].vWorldPosition.z) / 2;
+
+    a3 = arg_4 - pFaceBounding[0].vWorldPosition.x;
+    var_8 = var_4 - pFaceBounding[1].vWorldPosition.z;
+
+    if (pFace->uPolygonType == POLYGON_VerticalWall)
+      a3 /= a1.x;
+  }
+  if (pFace->uAttributes & 0x0400)
+  {
+    arg_4 = (pFaceBounding[0].vWorldPosition.x + pFaceBounding[2].vWorldPosition.x) / 2;
+    var_18 = (pFaceBounding[0].vWorldPosition.y + pFaceBounding[2].vWorldPosition.y) / 2;
+    var_4 = (pFaceBounding[1].vWorldPosition.z + pFaceBounding[3].vWorldPosition.z) / 2;
+
+    a3 = var_18 - pFaceBounding[0].vWorldPosition.y;
+    var_8 = var_4 - pFaceBounding[1].vWorldPosition.z;
+                                       // [0.5]
+    if (pFace->uPolygonType == POLYGON_VerticalWall)
     {
-      fld     dword ptr [ecx+60h]
-      fadd    dword ptr [ecx]
-      fmul    st, st(1)
-      fstp    [ebp+arg4]
-      fld     dword ptr [ecx+94h]
-      fadd    dword ptr [ecx+34h]
-      fmul    st, st(1)
-      fstp    [ebp+var_18]
-      fld     dword ptr [ecx+68h]
-      fadd    dword ptr [ecx+8]
-      fmul    st, st(1)
-      fstp    [ebp+var_4]
-      fld     [ebp+arg4]
-      fsub    dword ptr [ecx]
-      fstp    [ebp+a3]
-      fld     [ebp+var_18]
-      fsub    dword ptr [ecx+34h]
-      fstp    [ebp+var_8]
+      if (a1.x != 1.0f)
+        a3 /= a1.y;
     }
   }
-  if ( BYTE1(v8) & 2 )
-  {
-    __asm
-    {
-      fld     dword ptr [ecx+60h]
-      fadd    dword ptr [ecx]
-    }
-    v10 = _ESI->uPolygonType == 1;
-    __asm
-    {
-      fmul    st, st(1)
-      fstp    [ebp+arg4]
-      fld     dword ptr [ecx+64h]
-      fadd    dword ptr [ecx+4]
-      fmul    st, st(1)
-      fstp    [ebp+var_18]
-      fld     dword ptr [ecx+98h]
-      fadd    dword ptr [ecx+38h]
-      fmul    st, st(1)
-      fstp    [ebp+var_4]
-      fld     [ebp+arg4]
-      fsub    dword ptr [ecx]
-      fstp    [ebp+a3]
-      fld     [ebp+var_4]
-      fsub    dword ptr [ecx+38h]
-      fstp    [ebp+var_8]
-    }
-    if ( v10 )
-    {
-      __asm
-      {
-        fld     [ebp+a1.x]
-        fcomp   ds:dword_4D84A8
-        fnstsw  ax
-      }
-      if ( __SETP__(HIBYTE(_AX) & 0x44, 0) )
-      {
-        __asm
-        {
-          fld     [ebp+a3]
-          fdiv    [ebp+a1.x]
-          fstp    [ebp+a3]
-        }
-      }
-    }
-  }
-  if ( BYTE1(v8) & 4 )
-  {
-    __asm
-    {
-      fld     dword ptr [ecx+60h]
-      fadd    dword ptr [ecx]
-    }
-    v10 = _ESI->uPolygonType == 1;
-    __asm
-    {
-      fmul    st, st(1)
-      fstp    [ebp+arg4]
-      fld     dword ptr [ecx+64h]
-      fadd    dword ptr [ecx+4]
-      fmul    st, st(1)
-      fstp    [ebp+var_18]
-      fld     dword ptr [ecx+98h]
-      fadd    dword ptr [ecx+38h]
-      fmul    st, st(1)
-      fstp    [ebp+var_4]
-      fstp    st
-      fld     [ebp+var_18]
-      fsub    dword ptr [ecx+4]
-      fstp    [ebp+a3]
-      fld     [ebp+var_4]
-      fsub    dword ptr [ecx+38h]
-      fstp    [ebp+var_8]
-    }
-    if ( v10 )
-    {
-      __asm
-      {
-        fld     [ebp+a1.x]
-        fcomp   ds:dword_4D84A8
-        fnstsw  ax
-      }
-      if ( __SETP__(HIBYTE(_AX) & 0x44, 0) )
-      {
-        __asm
-        {
-          fld     [ebp+a3]
-          fdiv    [ebp+a1.y]
-          fstp    [ebp+a3]
-        }
-      }
-    }
-  }
-  else
-  {
-    __asm { fstp    st }
-  }
+
+
   if ( byte_4D864C && pGame->uFlags & 8 )
   {
-    __asm { fldz }
-    LODWORD(v26.vWorldPosition.x) = arg4;
-    __asm { fstp    [ebp+var_60.flt_2C] }
+    RenderVertexSoft v26; // [sp+40h] [bp-60h]@20
+    v26.vWorldPosition.x = arg_4;
     v26.vWorldPosition.y = v32;
-    __asm { fldz }
     v26.vWorldPosition.z = v35;
-    __asm { fstp    [esp+0A0h+var_A0] }
-    v6->do_draw_debug_line_sw(_ECX, 0xFF00u, &v26, 0xFF0000u, 0, v13);
+
+    pGame->pIndoorCameraD3D->do_draw_debug_line_sw(pFaceBounding, 0xFF00u, &v26, 0xFF0000u, 0, 0);
   }
-  __asm
-  {
-    fld     [ebp+var_8]
-    fmul    ds:flt_4D84E8
-    fld     [ebp+var_8]
-    fmul    [ebp+var_28]
-    fld     [ebp+var_8]
-    fmul    [ebp+var_24]
-  }
-  _EBX = arg0;
-  v15 = v31;
-  __asm
-  {
-    fst     [ebp+var_20]
-    fld     [ebp+a3]
-    fmul    [ebp+a1.x]
-    fld     [ebp+a3]
-    fmul    [ebp+a1.y]
-    fld     [ebp+a3]
-    fmul    [ebp+a1.z]
-  }
-  v16 = arg0;
-  __asm
+
+  //_EBX = arg0;
+  //v15 = v31;
+  //v16 = arg0;
+  float var_20 = var_8 * var_24;
+  var_8 = a3 * a1.z;
+  float arg_0 = var_8 + var_4;
+
+  arg0[0].vWorldPosition.x = arg_4 - a3 * a1.x + var_8 * flt_4D84E8;
+  arg0[0].vWorldPosition.y = var_18 - a3 * a1.y + var_8 * var_28;
+  arg0[0].vWorldPosition.z = var_4 - var_8 + var_8 * var_24;
+  arg0[1].vWorldPosition.x = arg_4 - a3 * a1.x - var_8 * flt_4D84E8;
+  arg0[1].vWorldPosition.y = var_18 - a3 * a1.y - var_8 * var_28;
+  arg0[1].vWorldPosition.z = (var_4 - var_8) - var_8 * var_24;
+  arg0[2].vWorldPosition.x = a3 * a1.x + arg_4 - var_8 * flt_4D84E8;
+  arg0[2].vWorldPosition.y = a3 * a1.y + var_18 - var_8 * var_28;
+  arg0[2].vWorldPosition.z = var_8 + var_4 - var_20;
+  arg0[3].vWorldPosition.x = (a3 * a1.x + arg_4) + var_8 * flt_4D84E8;
+  arg0[3].vWorldPosition.y = a3 * a1.y + var_18 + var_8 * var_28;
+  arg0[3].vWorldPosition.z = arg_0 + var_20;
+
+  a3 = (var_4 - var_8);
+  a3 = (a3 * a1.x + arg_4);
+
+  a1.x = 0.0f;
+  a1.y = 0.0f;
+  a1.z = 0.0f;
+
+  if (!_49C8DC(arg0, &a1, &a3))
+    return false;
+
+
+  if ( byte_4D864C )
   {
-    fstp    [ebp+var_8]
-    fld     [ebp+arg4]
-    fsub    st, st(2)
-    fld     st
-    fadd    st, st(6)
-    fstp    dword ptr [ebx]
-    fld     [ebp+var_18]
-    fsub    st, st(2)
-    fld     st
-    fadd    st, st(6)
-    fstp    dword ptr [ebx+4]
-    fld     [ebp+var_4]
-    fsub    [ebp+var_8]
-    fst     [ebp+a3]
-    fadd    st, st(5)
-    fstp    dword ptr [ebx+8]
-    fld     st(1)
-    fsub    st, st(7)
-    fstp    dword ptr [ebx+30h]
-    fsub    st, st(5)
-    fstp    dword ptr [ebx+34h]
-    fstp    st
-    fld     [ebp+a3]
-    fsub    st, st(3)
-    fstp    dword ptr [ebx+38h]
-    fld     st(1)
-    fadd    [ebp+arg4]
-    fst     [ebp+a3]
-    fsub    st, st(5)
-    fstp    dword ptr [ebx+60h]
-    fadd    [ebp+var_18]
-    fstp    st(2)
-    fstp    st
-    fld     st
-    fsub    st, st(2)
-    fstp    dword ptr [ebx+64h]
-    fld     [ebp+var_8]
-    fadd    [ebp+var_4]
-    fst     [ebp+arg0]
-    fsub    [ebp+var_20]
-    fstp    dword ptr [ebx+68h]
-    fld     [ebp+a3]
-    fadd    st, st(3)
-    fstp    dword ptr [ebx+90h]
-    fadd    st, st(1)
-    fstp    dword ptr [ebx+94h]
-    fstp    st
-    fstp    st
-    fld     [ebp+arg0]
-    fadd    [ebp+var_20]
-    fstp    dword ptr [ebx+98h]
-    fldz
-    fstp    [ebp+a1.x]
-    fldz
-    fstp    [ebp+a1.y]
-    fldz
-    fstp    [ebp+a1.z]
-  }
-  result = this->_49C8DC(v16, &a1, (float *)&a3);
-  if ( result )
-  {
-    if ( byte_4D864C )
-    {
-      HIWORD(result) = HIWORD(pGame);
       if ( pGame->uFlags & 8 )
       {
-        __asm
-        {
-          fldz
-          fstp    [ebp+var_60.flt_2C]
-          fld     ds:flt_4D8770
-          fld     [ebp+a1.x]
-          fmul    st, st(1)
-        }
-        LODWORD(v25.vWorldPosition.x) = (uint)arg4;
+        RenderVertexSoft v25; // [sp+10h] [bp-90h]@20
+        RenderVertexSoft v26; // [sp+40h] [bp-60h]@20
+
+        v25.vWorldPosition.x = arg_4;
         v25.vWorldPosition.y = v32;
-        __asm
-        {
-          fstp    [ebp+var_60.vWorldPosition.x]
-          fld     [ebp+a1.y]
-          fmul    st, st(1)
-        }
         v25.vWorldPosition.z = v35;
-        __asm
-        {
-          fstp    [ebp+var_60.vWorldPosition.y]
-          fld     [ebp+a1.z]
-          fmul    st, st(1)
-          fstp    [ebp+var_60.vWorldPosition.z]
-          fstp    st
-          fldz
-          fstp    [ebp+var_90.flt_2C]
-          fldz
-          fstp    [esp+0A0h+var_A0]
-        }
-        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v25, 0xFFFFFFFFu, &v26, 0xFFFF00u, 0, v18);
+
+        v26.vWorldPosition.x = a1.x * 30.0f;
+        v26.vWorldPosition.y = a1.y * 30.0f;
+        v26.vWorldPosition.z = a1.z * 30.0f;
+
+        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v25, 0xFFFFFFFFu, &v26, 0xFFFF00u, 0, 0);
       }
-    }
-    __asm { fild    pBLVRenderParams->vPartyPos.z }
-    memcpy(&v25, _EBX, sizeof(v25));
-    __asm
-    {
-      fsubr   [ebp+var_90.vWorldPosition.z]
-      fmul    [ebp+a1.z]
-      fild    pBLVRenderParams->vPartyPos.y
-      fsubr   [ebp+var_90.vWorldPosition.y]
-      fmul    [ebp+a1.y]
-      faddp   st(1), st
-      fild    pBLVRenderParams->vPartyPos.x
-      fsubr   [ebp+var_90.vWorldPosition.x]
-      fmul    [ebp+a1.x]
-      faddp   st(1), st
-      fcomp   ds:flt_4D84E8
-      fnstsw  ax
-    }
-    if ( !__SETP__(BYTE1(result) & 5, 0) )
-    {
-      result = (bool)&_EBX[1];
-      memcpy(&v25, &_EBX[1], sizeof(v25));
-      memcpy(&_EBX[1], &_EBX[3], sizeof(_EBX[1]));
-      memcpy(&_EBX[3], &v25, sizeof(_EBX[3]));
-    }
+  }
+
+
+  RenderVertexSoft v25; // [sp+10h] [bp-90h]@20
+  memcpy(&v25, arg0, sizeof(RenderVertexSoft));
+
+  float _dp = (v25.vWorldPosition.x - pBLVRenderParams->vPartyPos.x) * a1.x +
+              (v25.vWorldPosition.y - pBLVRenderParams->vPartyPos.y) * a1.y +
+              (v25.vWorldPosition.z - pBLVRenderParams->vPartyPos.z) * a1.z;
+  if (fabs(_dp) < 1e-6f)
+  {
+    memcpy(&v25, arg0 + 1, sizeof(RenderVertexSoft));
+    memcpy(arg0 + 1, arg0 + 3, sizeof(RenderVertexSoft));
+    memcpy(arg0 + 3, &v25, sizeof(RenderVertexSoft));
+  }
+
     if ( byte_4D864C && pGame->uFlags & 8 )
     {
-      v19 = v31;
-      if ( !LOBYTE(v31->field_4) )
+      RenderVertexSoft v26; // [sp+40h] [bp-60h]@20
+      if ( !LOBYTE(field_4) )
       {
-        __asm
-        {
-          fldz
-          fstp    [ebp+var_60.flt_2C]
-          fild    pParty->vPosition.x
-        }
-        a3 = (BLVFace *)(pParty->vPosition.y + pParty->sEyelevel);
-        __asm
-        {
-          fstp    [ebp+var_60.vWorldPosition.x]
-          fild    pParty->vPosition.z
-          fstp    [ebp+var_60.vWorldPosition.y]
-          fild    [ebp+a3]
-          fstp    [ebp+var_60.vWorldPosition.z]
-          fldz
-          fstp    [esp+0A0h+var_A0]
-        }
-        IndoorCameraD3D::do_draw_debug_line_sw(pGame->pIndoorCameraD3D, &v26, 0xFF0000u, _EBX, 0xFF0000u, 0, v20);
-        __asm
-        {
-          fldz
-          fstp    [esp+0A0h+var_A0]
-        }
-        IndoorCameraD3D::do_draw_debug_line_sw(pGame->pIndoorCameraD3D, &v26, 0xFF00u, _EBX + 1, 0xFF00u, 0, v21);
-        __asm
-        {
-          fldz
-          fstp    [esp+0A0h+var_A0]
-        }
-        IndoorCameraD3D::do_draw_debug_line_sw(pGame->pIndoorCameraD3D, &v26, 0xFFu, _EBX + 2, 0xFFu, 0, v22);
-        __asm
-        {
-          fldz
-          fstp    [esp+0A0h+var_A0]
-        }
-        IndoorCameraD3D::do_draw_debug_line_sw(pGame->pIndoorCameraD3D, &v26, 0xFFFFFFu, _EBX + 3, 0xFFFFFFu, 0, v23);
-        LOBYTE(v19->field_4) = 1;
+        v26.vWorldPosition.x = pParty->vPosition.x;
+        v26.vWorldPosition.y = pParty->vPosition.z;
+        v26.vWorldPosition.z = pParty->vPosition.y + pParty->sEyelevel;
+
+        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF0000u, arg0, 0xFF0000u, 0, 0);
+        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF00u, arg0 + 1, 0xFF00u, 0, 0);
+        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFu, arg0 + 2, 0xFFu, 0, 0);
+        pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFFFFFu, arg0 + 3, 0xFFFFFFu, 0, 0);
+        LOBYTE(field_4) = 1;
       }
-      __asm
-      {
-        fld     ds:flt_4D86E8
-        fstp    [esp+0A0h+var_A0]
-      }
-      IndoorCameraD3D::debug_outline_sw(thisa, _EBX, uNumVertices, 0x1EFF1Eu, v24);
+      pGame->pIndoorCameraD3D->debug_outline_sw(arg0, uNumVertices, 0x1EFF1Eu, 0.00019999999);
     }
-    LOBYTE(result) = 1;
-  }
-  return result;*/
+  return true;
 }
 
 
@@ -1132,33 +770,16 @@
 // 4D864C: using guessed type char byte_4D864C;
 
 //----- (0049C681) --------------------------------------------------------
-char stru10::_49C681(BLVFace *pFace, IndoorCameraD3D_Vec4 *a3, RenderVertexSoft *pArrayOf4)
+char stru10::_49C681_DrawDebugStuff(BLVFace *pFace, IndoorCameraD3D_Vec4 *a3, RenderVertexSoft *pArrayOf4)
 {
-  stru10 *v4; // edi@1
-  char *v5; // eax@1
-  signed int v6; // ecx@1
-  IndoorCameraD3D *v7; // esi@3
-  char result; // al@6
-  RenderVertexSoft a2a[4]; // [sp+Ch] [bp-C0h]@1
+  RenderVertexSoft pBounding[4]; // [sp+Ch] [bp-C0h]@1
 
-  v4 = this;
-  v5 = (char *)&a2a[0].flt_2C;
-  v6 = 4;
-  do
-  {
-    *(float *)v5 = 0.0;
-    v5 += 48;
-    --v6;
-  }
-  while ( v6 );
-  v7 = pGame->pIndoorCameraD3D;
-  _49D379(pFace, a2a);
+  CalcPolygonBoundingBox(pFace, pBounding);
   if ( byte_4D864C && pGame->uFlags & 8 )
-    pGame->pIndoorCameraD3D->debug_outline_sw(a2a, 4u, 0xFF1E1Eu, 0.000099999997);
-  result = _49C9E3(pFace, a2a, 4u, pArrayOf4);
-  if ( result )
-    result = _49C720(pArrayOf4, a3);
-  return result;
+    pGame->pIndoorCameraD3D->debug_outline_sw(pBounding, 4, 0xFF1E1E, 0.000099999997);
+  if (_49C9E3(pFace, pBounding, 4, pArrayOf4))
+    return _49C720(pArrayOf4, a3);
+  return false;
 }
 // 4D864C: using guessed type char byte_4D864C;
 
@@ -1300,7 +921,7 @@
   a1.z = result->z;
   if ( a1.x != 0.0
     || a1.y != 0.0
-    || (/*UNDEF(v8),*/ v9 = a1.z < 0.0, v10 = 0, v11 = a1.z == 0.0, BYTE1(result) = HIBYTE(v8), a1.z != 0.0) )
+    || (/*UNDEF(v8),*/ v9 = a1.z < 0.0, v10 = 0, v11 = a1.z == 0.0, /*BYTE1(result) = HIBYTE(v8),*/ a1.z != 0.0) )
   {
     a1.Normalize();
     v12 = a1.y;
@@ -1311,11 +932,7 @@
     a2->z = a1.z;
     result = (Vec3_float_ *)a3;
     *a3 = -(v13 + v14 + v19 * a1.x);
-    LOBYTE(result) = 1;
+    return true;
   }
-  else
-  {
-    LOBYTE(result) = 0;
-  }
-  return (bool)result;
+  return false;
 }
--- a/stru10.h	Tue Oct 23 13:51:21 2012 +0200
+++ b/stru10.h	Tue Oct 23 23:38:05 2012 +0200
@@ -8,12 +8,12 @@
   stru10();
   virtual ~stru10();
   char _49C5DA(struct BLVFace *a2, struct RenderVertexSoft *a3, int *a4, struct IndoorCameraD3D_Vec4 *a5, struct RenderVertexSoft *a6);
-  char _49C681(struct BLVFace *pFace, struct IndoorCameraD3D_Vec4 *a3, struct RenderVertexSoft *pArrayOf4);
+  char _49C681_DrawDebugStuff(struct BLVFace *pFace, struct IndoorCameraD3D_Vec4 *a3, struct RenderVertexSoft *pArrayOf4);
   char _49C720(struct RenderVertexSoft *a2, struct IndoorCameraD3D_Vec4 *a4);
   bool _49C7C5(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct Vec3_float_ *a3, struct IndoorCameraD3D_Vec4 *a4);
   bool _49C8DC(struct RenderVertexSoft *arg0, struct Vec3_float_ *a2, float *a3);
   bool _49C9E3(struct BLVFace *a3, struct RenderVertexSoft *arg4, unsigned int uNumVertices, struct RenderVertexSoft *arg0);
-  int _49D379(struct BLVFace *pFace, struct RenderVertexSoft *pVertices);
+  void CalcPolygonBoundingBox(struct BLVFace *pFace, struct RenderVertexSoft pOutVertices[4]);
   void _49CE9E(struct BLVFace *pFace, struct RenderVertexSoft *a2, signed int a3, RenderVertexSoft *a4);