changeset 1292:24bc24b64ec2

Слияние
author Ritor1
date Fri, 14 Jun 2013 16:06:30 +0600
parents 1577d75db258 (diff) 33e360a9b4bf (current diff)
children 557c0c3cc314
files Events.cpp Indoor.cpp Indoor_stuff.h UIHouses.cpp UITransition.cpp mm7_1.cpp mm7_3.cpp mm7_4.cpp
diffstat 11 files changed, 678 insertions(+), 213 deletions(-) [+]
line wrap: on
line diff
--- a/Events.cpp	Thu Jun 13 23:41:42 2013 +0400
+++ b/Events.cpp	Fri Jun 14 16:06:30 2013 +0600
@@ -57,8 +57,7 @@
 std::array<char, 9216> pLevelEVT;
 std::array<EventIndex, 4400> pLevelEVT_Index;
 
-
-std::array<_2devent, 525> p2DEvents; // weak
+_2devent p2DEvents[525];
 
 
 
--- a/Events2D.h	Thu Jun 13 23:41:42 2013 +0400
+++ b/Events2D.h	Fri Jun 14 16:06:30 2013 +0600
@@ -63,5 +63,4 @@
 };
 #pragma pack(pop)
 
-
-extern std::array<_2devent, 525> p2DEvents; // weak
\ No newline at end of file
+extern _2devent p2DEvents[525];
\ No newline at end of file
--- a/Indoor.cpp	Thu Jun 13 23:41:42 2013 +0400
+++ b/Indoor.cpp	Fri Jun 14 16:06:30 2013 +0600
@@ -347,9 +347,9 @@
 		  v4 = pRenderer->uTargetSurfacePitch * pNode->field_C._viewport_space_y;
 		  if ( pNode->field_C._viewport_space_y <= pNode->field_C._viewport_space_w )
 		  {
-			//v5 = (char *)&pBspRenderer->nodes[0].field_C.array_3D8[pNode->field_C._viewport_space_y + v7];
-			v5 = &pNode->field_C.array_3D8[pNode->field_C._viewport_space_y];
-			v8 = &pNode->field_C.array_18[pNode->field_C._viewport_space_y];
+			//v5 = (char *)&pBspRenderer->nodes[0].field_C.viewport_right_side[pNode->field_C._viewport_space_y + v7];
+			v5 = &pNode->field_C.viewport_right_side[pNode->field_C._viewport_space_y];
+			v8 = &pNode->field_C.viewport_left_side[pNode->field_C._viewport_space_y];
 			do
 			{
 				v1[v4 + *v8] = 255;
@@ -875,29 +875,29 @@
                   v120 = 2 * stru_F8A590._viewport_space_y;
                   while ( 1 )
                   {
-                    a1 = *(__int16 *)((char *)stru_F8A590.array_18 + v24);
+                    a1 = *(__int16 *)((char *)stru_F8A590.viewport_left_side + v24);
                     sub_4AE313(a1, v21, &stru_F81018.field_0);
                     if ( LOBYTE(viewparams->field_20) )
                     {
                       v27 = v111 * (v24 - pBLVRenderParams->uViewportY);
                       pZPixel = &pBLVRenderParams->pTargetZBuffer[2
-                                                               * (*(__int16 *)((char *)stru_F8A590.array_18 + v24)
+                                                               * (*(__int16 *)((char *)stru_F8A590.viewport_left_side + v24)
                                                                 + 320 * (v24 - pBLVRenderParams->uViewportY))
                                                                - pBLVRenderParams->uViewportX];
                       pColorPixel = &pBLVRenderParams->pRenderTarget[v27
-                                                                  + 2 * *(__int16 *)((char *)stru_F8A590.array_18 + v24)
+                                                                  + 2 * *(__int16 *)((char *)stru_F8A590.viewport_left_side + v24)
                                                                   - pBLVRenderParams->uViewportX];
                       v26 = &pBLVRenderParams->pRenderTarget[v27
-                                                          + 2 * *(__int16 *)((char *)stru_F8A590.array_3D8 + v24)
+                                                          + 2 * *(__int16 *)((char *)stru_F8A590.viewport_right_side + v24)
                                                           - pBLVRenderParams->uViewportX];
                       v23 = v119;
                     }
                     else
                     {
-                      v25 = *(__int16 *)((char *)stru_F8A590.array_18 + v24);
+                      v25 = *(__int16 *)((char *)stru_F8A590.viewport_left_side + v24);
                       pZPixel = &pBLVRenderParams->pTargetZBuffer[v25 + v23];
                       pColorPixel = &pBLVRenderParams->pRenderTarget[v25 + v110];
-                      v26 = &pBLVRenderParams->pRenderTarget[v110 + *(__int16 *)((char *)stru_F8A590.array_3D8 + v24)];
+                      v26 = &pBLVRenderParams->pRenderTarget[v110 + *(__int16 *)((char *)stru_F8A590.viewport_right_side + v24)];
                     }
                     v131 = (unsigned int)v26;
                     HIWORD(v28) = HIWORD(stru_F81018.field_0.field_0);
@@ -1259,8 +1259,8 @@
   //stru170 *v4; // ebx@1
   //BLVFace *v5; // eax@1
   //int v6; // ecx@2
-  unsigned __int16 v7; // ax@11
-  Vec3_short_ *v8; // esi@15
+  unsigned __int16 TransitionSectorID; // ax@11
+  //Vec3_short_ *v8; // esi@15
   int v9; // edx@15
   //signed int v10; // eax@18
   //signed int v11; // edi@19
@@ -1326,16 +1326,16 @@
                                           + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y
                                           + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 ) // we sure are standing at the portal plane
       {
-        v7 = pFace->uSectorID;
-        if ( nodes[0].uSectorID == v7 )  // draw back sector
-          v7 = pFace->uBackSectorID;
-        nodes[num_nodes].uSectorID = v7;
+        TransitionSectorID = pFace->uSectorID;
+        if ( nodes[0].uSectorID == TransitionSectorID )  // draw back sector
+          TransitionSectorID = pFace->uBackSectorID;
+        nodes[num_nodes].uSectorID = TransitionSectorID;
         nodes[num_nodes].uFaceID = uFaceID;
         nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX;
         nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ;
         nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY;
         nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW;
-        nodes[num_nodes].field_C._43F9E1(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY,
+        nodes[num_nodes].field_C.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY,
                                          pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW);
         AddBspNodeToRenderList(++num_nodes - 1);
         return;
@@ -1344,10 +1344,10 @@
       //v6 = a0;
     }
 
-    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);
+    //  
+    v9 = pFace->pFacePlane_old.vNormal.x * (pIndoor->pVertices[pFace->pVertexIDs[0]].x - pBLVRenderParams->vPartyPos.x)
+       + pFace->pFacePlane_old.vNormal.y * (pIndoor->pVertices[pFace->pVertexIDs[0]].y - pBLVRenderParams->vPartyPos.y)
+       + pFace->pFacePlane_old.vNormal.z * (pIndoor->pVertices[pFace->pVertexIDs[0]].z - pBLVRenderParams->vPartyPos.z);
     if (p->uSectorID != pFace->uSectorID)
       v9 = -v9;
     if (v9 >= 0)
@@ -1491,7 +1491,7 @@
         v3->nodes[v3->num_nodes].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ);
         v3->nodes[v3->num_nodes].uViewportY = LOWORD(pBLVRenderParams->uViewportY);
         v3->nodes[v3->num_nodes].uViewportW = LOWORD(pBLVRenderParams->uViewportW);
-        v3->nodes[v3->num_nodes++].field_C._43F9E1(
+        v3->nodes[v3->num_nodes++].field_C.GetViewportData(
           SLOWORD(pBLVRenderParams->uViewportX),
           pBLVRenderParams->uViewportY,
           SLOWORD(pBLVRenderParams->uViewportZ),
@@ -1610,8 +1610,8 @@
               v6 = 640 * stru_F8A590._viewport_space_y;
               do
               {
-                v5[v6 + stru_F8A590.array_18[v4]] = -1;
-                v7 = v6 + stru_F8A590.array_3D8[v4];
+                v5[v6 + stru_F8A590.viewport_left_side[v4]] = -1;
+                v7 = v6 + stru_F8A590.viewport_right_side[v4];
                 v6 += 640;
                 v5[v7] = -1;
                 ++v4;
--- a/Indoor_stuff.h	Thu Jun 13 23:41:42 2013 +0400
+++ b/Indoor_stuff.h	Fri Jun 14 16:06:30 2013 +0600
@@ -8,7 +8,7 @@
 #pragma pack(push, 1)
 struct BspRenderer_stru2
 {
-  void _43F9E1(__int16 x, int y, __int16 z, int w);
+  void GetViewportData(__int16 x, int y, __int16 z, int w);
 
   int _viewport_space_y;
   int _viewport_space_w;
@@ -16,8 +16,8 @@
   int field_C;
   int field_10;
   int field_14;
-  __int16 array_18[480];
-  __int16 array_3D8[480];
+  __int16 viewport_left_side[480];
+  __int16 viewport_right_side[480];
 };
 #pragma pack(pop)
 extern BspRenderer_stru2 stru_F8A590;
--- a/UIHouses.cpp	Thu Jun 13 23:41:42 2013 +0400
+++ b/UIHouses.cpp	Fri Jun 14 16:06:30 2013 +0600
@@ -561,10 +561,10 @@
 void PlayHouseSound(unsigned int uHouseID, HouseSoundID sound)
 {
     //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) )
-    if ( pAnimatedRooms[p2DEvents[uHouseID - 1].uAnimationID].uRoomSoundId )
+    if ( pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId )
         pAudioPlayer->PlaySound(
         //(SoundID)(a2 + 100 * (BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) + 300)),
-        (SoundID)(sound + 100 * (pAnimatedRooms[p2DEvents[uHouseID - 1].uAnimationID].uRoomSoundId + 300)),
+        (SoundID)(sound + 100 * (pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId + 300)),
         806, 0, -1, 0, 0, 0, 0);
 }
 
--- a/UITransition.cpp	Thu Jun 13 23:41:42 2013 +0400
+++ b/UITransition.cpp	Fri Jun 14 16:06:30 2013 +0600
@@ -102,7 +102,7 @@
 LABEL_20:
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Transition, 0, (int)sHouseName.data());
   //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * v9]].field_C) )
-  if ( pAnimatedRooms[p2DEvents[anim_id - 1].uAnimationID].uRoomSoundId )
+  if ( pAnimatedRooms[p2DEvents[anim_id].uAnimationID].uRoomSoundId )
     PlayHouseSound(anim_id, HouseSound_Greeting);
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && uActiveCharacter && pParty->uFlags & 0x30 )
     pPlayers[uActiveCharacter]->PlaySound(SPEECH_47, 0);
--- a/mm7_1.cpp	Thu Jun 13 23:41:42 2013 +0400
+++ b/mm7_1.cpp	Fri Jun 14 16:06:30 2013 +0600
@@ -1489,6 +1489,468 @@
 int __fastcall sub_423B5D(unsigned int uFaceID)
 {
   BLVFace *pFace; // ebx@1
+  //Vec3_short_ *v2; // esi@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
+  //int v10; // eax@10
+  //int v11; // edx@11
+  //int v12; // ST28_4@12
+  //signed int v13; // edx@12
+  //signed __int64 v14; // qtt@12
+  //int *v15; // ebx@12
+  //int v16; // ST28_4@14
+  //signed int v17; // eax@14
+  //signed __int64 v18; // qtt@14
+  //signed int v19; // edx@15
+  //signed int v20; // edx@17
+  //signed int v21; // ebx@19
+  //signed int v22; // esi@20
+  int v23; // edi@21
+  int v24; // eax@21
+  //int v25; // eax@22
+  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 for_x_num_vertices; // 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 for_z_num_vertices; // ebx@41
+  //unsigned int v44; // eax@41
+  //signed int v45; // ecx@42
+  //int v46; // esi@42
+  int v47; // eax@44
+  signed int for_y_num_vertices; // 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 for_w_num_vertices; // 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 current_vertices_flag; // [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 length_num_vertices; // [sp+1Ch] [bp-Ch]@9
+  int v80; // [sp+1Ch] [bp-Ch]@76
+  bool next_vertices_flag; // [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
+  //unsigned int i; // [sp+24h] [bp-4h]@19
+  //signed int ix; // [sp+24h] [bp-4h]@31
+  //signed int iz; // [sp+24h] [bp-4h]@41
+  //signed int iy; // [sp+24h] [bp-4h]@51
+  //signed int iw; // [sp+24h] [bp-4h]@61
+
+  pFace = &pIndoor->pFaces[uFaceID];
+
+  if ( pFace->pFacePlane.vNormal.x * (pIndoor->pVertices[pFace->pVertexIDs[0]].x - pBLVRenderParams->vPartyPos.x)//check the angle of the vector and the plane
+     + pFace->pFacePlane.vNormal.y * (pIndoor->pVertices[pFace->pVertexIDs[0]].y - pBLVRenderParams->vPartyPos.y)
+     + pFace->pFacePlane.vNormal.z * (pIndoor->pVertices[pFace->pVertexIDs[0]].z - pBLVRenderParams->vPartyPos.z) < 0 )
+  {
+    stru_50B700.field_0 = 1;
+  }
+  else
+  {
+    stru_50B700.field_0 = 0;
+    if ( !pFace->Portal() )
+      return 0;
+  }
+  for (uint i = 0; i < pFace->uNumVertices; ++i)
+  {
+      //    ( ),          
+      pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(pIndoor->pVertices[pFace->pVertexIDs[i]].x,
+                         pIndoor->pVertices[pFace->pVertexIDs[i]].y, pIndoor->pVertices[pFace->pVertexIDs[i]].z,
+        &stru_50B700._view_transformed_xs[i], &stru_50B700._view_transformed_zs[i], &stru_50B700._view_transformed_ys[i], 0);
+  }
+
+  if (pFace->uNumVertices <= 0)
+    return 0;
+
+  bool bFound = false;
+  for (uint i = 0; i < pFace->uNumVertices; ++i)
+    if (stru_50B700._view_transformed_xs[i] >= 0x80000u)//   (cull for near clip plane)  z 
+    {
+      bFound = true;
+      break;
+    }
+  if (!bFound)
+    return 0;
+
+  int t;
+  //int new_point = 0;
+  length_num_vertices = 0;
+  stru_50B700._view_transformed_xs[pFace->uNumVertices] = stru_50B700._view_transformed_xs[0];//  
+  stru_50B700._view_transformed_zs[pFace->uNumVertices] = stru_50B700._view_transformed_zs[0];
+  stru_50B700._view_transformed_ys[pFace->uNumVertices] = stru_50B700._view_transformed_ys[0];
+
+  //maybe for near clip plane
+  current_vertices_flag = stru_50B700._view_transformed_xs[0] >= (signed int)0x80000u;//    >=  
+  for ( uint i = 1; i <= pFace->uNumVertices; ++i)
+  {
+    next_vertices_flag = stru_50B700._view_transformed_xs[i] >= (signed int)0x80000u;//  i-  >=  
+    if ( current_vertices_flag ^ next_vertices_flag )//    >  
+    {
+      if ( stru_50B700._view_transformed_xs[i] >= (signed int)0x80000u )//   thisa <  , a i-  >=  
+      {
+		  //t = (near_clip - v0.x)/(v1.x - v0.x)
+        t = (0x80000 - stru_50B700._view_transformed_xs[i - 1]) / (stru_50B700._view_transformed_xs[i] - stru_50B700._view_transformed_xs[i - 1]);
+        //z = (v1.z - v0.z)*t + v0.z
+        stru_50B700._view_transformed_zs[i] = ((unsigned __int64)((stru_50B700._view_transformed_zs[i] - stru_50B700._view_transformed_zs[i - 1])
+                * t)) + stru_50B700._view_transformed_zs[i - 1];
+        //y = (v1.y -v0.y)*(near_clip - v0.x)/(v1.x - v0.x)
+        stru_50B700._view_transformed_ys[i] = (unsigned __int64)((stru_50B700._view_transformed_ys[i] - stru_50B700._view_transformed_ys[i - 1])
+                * t) + stru_50B700._view_transformed_ys[i];
+        //stru_50B700._view_transformed_ys[i] = stru_50B700.field_38[new_point];
+        //stru_50B700._view_transformed_zs[i] = stru_50B700.field_128[new_point];
+      }
+      else//   thisa  >=  
+      {
+        t = (0x80000 - stru_50B700._view_transformed_xs[i]) / (stru_50B700._view_transformed_xs[i - 1] - stru_50B700._view_transformed_xs[i]);
+        //z = (v0.z - v1.z)*(near_clip - v1.x)/(v0.x - v1.x) + v1.z
+        stru_50B700._view_transformed_zs[i] = ((unsigned __int64)((stru_50B700._view_transformed_zs[i - 1] - stru_50B700._view_transformed_zs[i])
+                 * t)) + stru_50B700._view_transformed_zs[i];
+        //y = (v0.y - v1.y)*(near_clip - v1.x)/(v0.x - v1.x)
+        stru_50B700._view_transformed_ys[i] = (unsigned __int64)((stru_50B700._view_transformed_ys[i - 1] - stru_50B700._view_transformed_ys[i])
+                * t) + stru_50B700._view_transformed_ys[i];
+        //stru_50B700._view_transformed_ys[i] = stru_50B700.field_38[new_point];
+        //stru_50B700._view_transformed_zs[i] = stru_50B700.field_128[new_point];
+      }
+      //stru_50B700.field_218[new_point] 
+      //stru_50B700._view_transformed_xs[i] = 0x80000u;//z    = 8.0
+      stru_50B700._view_transformed_xs[i] = 0x80000u;//z    = 8.0
+      length_num_vertices++;
+      //new_point++;
+    }
+	/*if ( next_vertices_flag )
+    {
+      //v20 = v79++;
+      stru_50B700.field_218[length_num_vertices] = stru_50B700._view_transformed_xs[i];
+      stru_50B700.field_128[length_num_vertices] = stru_50B700._view_transformed_zs[i];
+      stru_50B700.field_38[length_num_vertices] = stru_50B700._view_transformed_ys[i];
+      length_num_vertices++;
+    }*/
+    /*else
+      length_num_vertices++;
+      stru_50B700.field_218[0] = stru_50B700._view_transformed_xs[i];
+      stru_50B700.field_128[0] = stru_50B700._view_transformed_zs[i];
+      stru_50B700.field_38[0] = stru_50B700._view_transformed_ys[i];*/
+    current_vertices_flag = next_vertices_flag;//i-  
+    length_num_vertices++;
+  }
+  //v21 = v79;
+  /*stru_50B700.field_218[length_num_vertices] = stru_50B700.field_218[0];//  (t1, t2)  
+  stru_50B700.field_128[length_num_vertices] = stru_50B700.field_128[0];
+  stru_50B700.field_38[length_num_vertices] = stru_50B700.field_38[0];*/
+
+  //maybe for far clip plane
+  for ( uint i = 0; i < length_num_vertices; ++i )
+  {
+    if ( abs(stru_50B700._view_transformed_zs[i]) <= abs(stru_50B700._view_transformed_xs[i]) )
+    {
+      //LODWORD(v28) = stru_50B700.field_128[i] << 16;
+      //HIDWORD(v28) = stru_50B700.field_128[i] >> 16;
+      v26 = stru_50B700._view_transformed_zs[i] / stru_50B700._view_transformed_xs[i];
+      v23 = 0;
+    }
+    else
+    {
+      v23 = 0;
+      v24 = 0;
+      if ( stru_50B700._view_transformed_zs[i] >= 0 )
+      {
+        LOBYTE(v24) = stru_50B700._view_transformed_xs[i] >= 0;
+        v26 = ((v24 - 1) & 0xFF800000) + 0x400000;
+      }
+      else
+      {
+        LOBYTE(v24) = stru_50B700._view_transformed_xs[i] >= 0;
+        v26 = ((v24 - 1) & 0x800000) - 0x400000;
+      }
+    }
+    stru_50B700._xs3[i] = v26;//    
+    if ( abs(stru_50B700._view_transformed_ys[i]) <= abs(stru_50B700._view_transformed_xs[i]) )
+    {
+      //LODWORD(v34) = stru_50B700.field_38[i] << 16;
+      //HIDWORD(v34) = stru_50B700.field_38[i] >> 16;
+      v32 = stru_50B700._view_transformed_ys[i] / stru_50B700._view_transformed_xs[i];
+    }
+    else
+    {
+      v30 = 0;
+      if ( stru_50B700._view_transformed_ys[i] >= v23 )
+      {
+        LOBYTE(v30) = stru_50B700._view_transformed_xs[i] >= v23;
+        v32 = ((v30 - 1) & 0xFF800000) + 0x400000;
+      }
+      else
+      {
+        LOBYTE(v30) = stru_50B700._view_transformed_xs[i] >= v23;
+        v32 = ((v30 - 1) & 0x800000) - 0x400000;
+      }
+    }
+    stru_50B700._ys2[i] = v32;
+    stru_50B700._xs3[i] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)stru_50B700._xs3[i]);
+    stru_50B700._xs3[i] = pBLVRenderParams->uViewportCenterX - stru_50B700._xs3[i];
+    stru_50B700._ys2[i] = pBLVRenderParams->uViewportCenterY - (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40)
+                           * (signed __int64)stru_50B700._ys2[i]);
+  }
+
+  for_x_num_vertices = 0;
+  stru_50B700._xs3[length_num_vertices] = stru_50B700._xs3[0];
+  stru_50B700._ys2[length_num_vertices] = stru_50B700._ys2[0];
+  if ( length_num_vertices < 1 )
+    return 0;
+
+  //maybe for left clip plane
+  current_vertices_flag = stru_50B700._xs3[0] >= (signed int)pBLVRenderParams->uViewportX;
+  for ( uint i = 1; i <= length_num_vertices; i++ )
+  {
+    next_vertices_flag = stru_50B700._xs3[i] >= (signed int)pBLVRenderParams->uViewportX;//    >=  
+    if ( current_vertices_flag ^ next_vertices_flag )
+    {
+      if ( stru_50B700._xs3[i] >= (signed int)pBLVRenderParams->uViewportX )
+      {
+		  //v67 = (a-b)*(c-d)/(e-f)
+        v67 = (signed int)(pBLVRenderParams->uViewportX - stru_50B700._xs3[i - 1])
+            * (signed __int64)(stru_50B700._ys2[i] - stru_50B700._ys2[i - 1]) / (stru_50B700._xs3[i] - stru_50B700._xs3[i - 1]);
+        v42 = stru_50B700._ys2[i - 1];//d
+      }
+      else
+      {
+		  //v67 = (a-e)*(d-c)/(f-e)
+        v67 = (signed int)(pBLVRenderParams->uViewportX - stru_50B700._xs3[i])
+            * (signed __int64)(stru_50B700._ys2[i - 1] - stru_50B700._ys2[i]) / (stru_50B700._xs3[i - 1] - stru_50B700._xs3[i]);
+        v42 = stru_50B700._ys2[i];//c
+      }
+      stru_50B700._ys[for_x_num_vertices] = v67 + v42;
+      stru_50B700._xs2[for_x_num_vertices] = pBLVRenderParams->uViewportX;
+      ++for_x_num_vertices;
+    }
+    current_vertices_flag = next_vertices_flag;
+    if ( next_vertices_flag )
+    {
+      stru_50B700._xs2[for_x_num_vertices] = stru_50B700._xs3[i];
+      stru_50B700._ys[for_x_num_vertices] = stru_50B700._ys2[i];
+      ++for_x_num_vertices;
+    }
+  }
+
+  if (for_x_num_vertices < 1)
+    return 0;
+
+  for_z_num_vertices = 0;
+  stru_50B700._xs2[for_x_num_vertices] = stru_50B700._xs2[0];
+  stru_50B700._ys[for_x_num_vertices] = stru_50B700._ys[0];
+
+  //maybe for right clip plane
+  thisd = stru_50B700._xs2[0] <= (signed int)pBLVRenderParams->uViewportZ;
+  for ( uint i = 1; i <= for_x_num_vertices; ++i )
+  {
+    v83 = stru_50B700._xs2[i] <= (signed int)pBLVRenderParams->uViewportZ;
+    if ( thisd ^ v83 )
+    {
+      if ( stru_50B700._xs2[i] <= (signed int)pBLVRenderParams->uViewportZ )
+      {
+		  //v68 = (a-b)*(c-d)/(e-b)
+        v68 = (signed int)(pBLVRenderParams->uViewportZ - stru_50B700._xs2[i - 1])
+            * (signed __int64)(stru_50B700._ys[i] - stru_50B700._ys[i - 1]) / (stru_50B700._xs2[i] - stru_50B700._xs2[i - 1]);
+        v47 = stru_50B700._ys[i - 1];//d
+      }
+      else
+      {
+		  //v68 = (a-e)*(d-c)/(b-e)
+        v68 = (signed int)(pBLVRenderParams->uViewportZ - stru_50B700._xs2[i])
+            * (signed __int64)(stru_50B700._ys[i - 1] - stru_50B700._ys[i]) / (stru_50B700._xs2[i - 1] - stru_50B700._xs2[i]);
+        v47 = stru_50B700._ys[i];//c
+      }
+      stru_50B700.field_2F0[for_z_num_vertices] = v68 + v47;
+      stru_50B700._xs[for_z_num_vertices] = pBLVRenderParams->uViewportZ;
+      ++for_z_num_vertices;
+    }
+    if ( v83 )
+    {
+      stru_50B700._xs[for_z_num_vertices] = stru_50B700._xs2[i];
+      stru_50B700.field_2F0[for_z_num_vertices++] = stru_50B700._ys[i];
+    }
+    thisd = v83;
+  }
+
+  if (for_z_num_vertices < 1)
+    return 0;
+
+  for_y_num_vertices = 0;
+  stru_50B700._xs[for_z_num_vertices] = stru_50B700._xs[0];
+  stru_50B700.field_2F0[for_z_num_vertices] = stru_50B700.field_2F0[0];
+  v50 = stru_50B700.field_2F0[0] < (signed int)pBLVRenderParams->uViewportY;
+
+  //maybr for top clip plane
+  LOBYTE(v50) = stru_50B700.field_2F0[0] >= (signed int)pBLVRenderParams->uViewportY;
+  for ( uint i = 1; i <= for_z_num_vertices; i++ )
+  {
+    v84 = stru_50B700.field_2F0[i] >= (signed int)pBLVRenderParams->uViewportY;
+    if ( v50 ^ v84 )
+    {
+      if ( stru_50B700.field_2F0[i] >= (signed int)pBLVRenderParams->uViewportY )
+      {
+		  //v69 = (a-b)*(c-d)/(e-b)
+        v69 = (signed int)(pBLVRenderParams->uViewportY - stru_50B700.field_2F0[i - 1])
+            * (signed __int64)(stru_50B700._xs[i] - stru_50B700._xs[i - 1]) / (stru_50B700.field_2F0[i] - stru_50B700.field_2F0[i - 1]);
+        v54 = stru_50B700._xs[i - 1];//d
+      }
+      else
+      {
+		  //v69 = (a-e)*(d-c)/(b-e)
+        v69 = (signed int)(pBLVRenderParams->uViewportY - stru_50B700.field_2F0[i])
+            * (signed __int64)(stru_50B700._xs[i - 1] - stru_50B700._xs[i]) / (stru_50B700.field_2F0[i - 1] - stru_50B700.field_2F0[i]);
+        v54 = stru_50B700._xs[i];//c
+      }
+      stru_50B700.field_3D4[for_y_num_vertices] = v69 + v54;
+      stru_50B700._xs[for_y_num_vertices + 1] = pBLVRenderParams->uViewportY;
+      ++for_y_num_vertices;
+    }
+    v50 = v84;
+    if ( v84 )
+    {
+      stru_50B700.field_3D4[for_y_num_vertices] = stru_50B700._xs[i];
+      stru_50B700._xs[for_y_num_vertices + 1] = stru_50B700.field_2F0[i];
+      for_y_num_vertices++;
+    }
+  }
+
+  if (for_y_num_vertices < 1)
+    return 0;
+
+  for_w_num_vertices = 0;
+  stru_50B700.field_3D4[for_y_num_vertices] = stru_50B700.field_3D4[0];
+  stru_50B700._xs[for_y_num_vertices + 1] = stru_50B700._xs[1];
+
+  //maybe for bottom clip plane
+  thise = stru_50B700._xs[1] <= (signed int)pBLVRenderParams->uViewportW;
+  for ( uint i = 1; i <= for_y_num_vertices; ++i )
+  {
+    v85 = stru_50B700._xs[i + 1] <= (signed int)pBLVRenderParams->uViewportW;
+    if ( thise ^ v85 )
+    {
+      if ( stru_50B700._xs[i + 1] <= (signed int)pBLVRenderParams->uViewportW )
+      {
+		  //v70 = (a-b)*(c-d)/(e-b)
+        v70 = (signed int)(pBLVRenderParams->uViewportW - stru_50B700._xs[i])
+            * (signed __int64)(stru_50B700.field_3D4[i] - stru_50B700.field_3D4[i - 1]) / (stru_50B700._xs[i + 1] - stru_50B700._xs[i]);
+        v59 = stru_50B700.field_3D4[i - 1];//d
+      }
+      else
+      {
+		  //v70 = (a-e)*(d-c)/(b-e)
+        v70 = (signed int)(pBLVRenderParams->uViewportW - stru_50B700._xs[i + 1])
+            * (signed __int64)(stru_50B700.field_3D4[i - 1] - stru_50B700.field_3D4[i]) / (stru_50B700._xs[i] - stru_50B700._xs[i + 1]);
+        v59 = stru_50B700.field_3D4[i];//c
+      }
+      stru_50B700._screen_space_x[for_w_num_vertices] = v70 + v59;
+      stru_50B700._screen_space_y[for_w_num_vertices] = pBLVRenderParams->uViewportW;
+      ++for_w_num_vertices;
+    }
+    if ( v85 )
+    {
+      stru_50B700._screen_space_x[for_w_num_vertices] = stru_50B700.field_3D4[i];
+      stru_50B700._screen_space_y[for_w_num_vertices++] = stru_50B700._xs[i + 1];
+    }
+    thise = v85;
+  }
+
+  if ( !for_w_num_vertices )
+    return 0;
+  v61 = pRenderer->pRenderD3D == 0;
+  stru_50B700._screen_space_x[for_w_num_vertices] = stru_50B700._screen_space_x[0];
+  stru_50B700._screen_space_y[for_w_num_vertices] = stru_50B700._screen_space_y[0];
+  if ( v61 && for_w_num_vertices > 3 )
+  {
+    stru_50B700._screen_space_x[for_w_num_vertices + 1] = stru_50B700._screen_space_x[1];
+    stru_50B700._screen_space_y[for_w_num_vertices + 1] = stru_50B700._screen_space_y[1];
+    thisf = 2 * (stru_50B700.field_0 != 0) - 1;
+    if ( for_w_num_vertices > 0 )
+    {
+      v62 = 1;
+      v71 = 1;
+      do
+      {
+        v63 = v62 - 1;
+        v64 = v62 + 1;
+        v80 = v62 + 1;
+        if ( v62 - 1 >= for_w_num_vertices )
+          v63 -= for_w_num_vertices;
+        if ( v62 >= for_w_num_vertices )
+          v62 -= for_w_num_vertices;
+        if ( v64 >= for_w_num_vertices )
+          v64 -= for_w_num_vertices;
+        if ( thisf * ((stru_50B700._screen_space_y[v64] - stru_50B700._screen_space_y[v63])
+                   * (stru_50B700._screen_space_x[v62] - stru_50B700._screen_space_x[v63])
+                   - (stru_50B700._screen_space_y[v62] - stru_50B700._screen_space_y[v63])
+                   * (stru_50B700._screen_space_x[v64] - stru_50B700._screen_space_x[v63])) < 0 )
+        {
+          v62 = v80;
+          v71 = v80;
+        }
+        else
+        {
+          v62 = v71;
+          v65 = v71;
+          if ( v71 < for_w_num_vertices || (v65 = v71 - for_w_num_vertices, v71 - for_w_num_vertices < for_w_num_vertices) )
+          {
+            memcpy(&stru_50B700._screen_space_y[v65], &stru_50B700._screen_space_y[v65 + 1], 4 * ((unsigned int)(4 * (for_w_num_vertices - v65)) >> 2));
+            memcpy(&stru_50B700._screen_space_x[v65], &stru_50B700._screen_space_x[v65 + 1], 4 * ((unsigned int)(4 * (for_w_num_vertices - v65)) >> 2));
+          }
+          --for_w_num_vertices;
+        }
+      }
+      while ( v62 - 1 < for_w_num_vertices );
+    }
+    stru_50B700._screen_space_x[for_w_num_vertices] = stru_50B700._screen_space_x[0];
+    stru_50B700._screen_space_y[for_w_num_vertices] = stru_50B700._screen_space_y[0];
+  }
+  return for_w_num_vertices;
+}
+
+//old function
+/*int __fastcall sub_423B5D(unsigned int uFaceID)
+{
+  BLVFace *v1; // ebx@1
   Vec3_short_ *v2; // esi@1
   //int v3; // ST28_4@1
   __int16 v4; // ST2C_2@1
@@ -1578,40 +2040,46 @@
   signed int id; // [sp+24h] [bp-4h]@51
   signed int ie; // [sp+24h] [bp-4h]@61
 
-  pFace = &pIndoor->pFaces[uFaceID];
+  v1 = &pIndoor->pFaces[uFaceID];
   //this = pGame->pIndoorCameraD3D;
-  v2 = &pIndoor->pVertices[pFace->pVertexIDs[0]];
+  v2 = &pIndoor->pVertices[v1->pVertexIDs[0]];
   //v3 = *(_DWORD *)&v2->x;
   v4 = v2->z;
   //v5 = 0;
-  if ( pFace->pFacePlane_old.vNormal.x * (v2->x - pBLVRenderParams->vPartyPos.x)
-     + pFace->pFacePlane_old.vNormal.y * (v2->y - pBLVRenderParams->vPartyPos.y)
-     + pFace->pFacePlane_old.vNormal.z * (v2->z - pBLVRenderParams->vPartyPos.z) < 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 * (v2->z - pBLVRenderParams->vPartyPos.z) < 0 )
   {
-    stru_50B700.field_0 = 1;
+    dword_50B700 = 1;
   }
   else
   {
-    stru_50B700.field_0 = 0;
-    if ( !pFace->Portal() )
+    dword_50B700 = 0;
+    if ( !v1->Portal() )
       return 0;
   }
   //v66 = v1->uNumVertices;
-  for (uint i = 0; i < pFace->uNumVertices; ++i)
+  for (uint i = 0; i < v1->uNumVertices; ++i)
   {
-      auto v6 = &pIndoor->pVertices[pFace->pVertexIDs[i]];
-      pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(v6->x, v6->y, v6->z,
-        &stru_50B700._view_transformed_xs[i], &stru_50B700._view_transformed_zs[i], &stru_50B700._view_transformed_ys[i], 0);
+      auto v6 = &pIndoor->pVertices[v1->pVertexIDs[i]];
+      pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(
+        v6->x,
+        v6->y,
+        v6->z,
+        &_50B924_view_transformed_xs[i],
+        &_50B834_view_transformed_zs[i],
+        &_50B744_view_transformed_ys[i],
+        0);
   }
 
   //v7 = v1->uNumVertices;
   //v8 = 0;
-  if (pFace->uNumVertices <= 0)
+  if (v1->uNumVertices <= 0)
     return 0;
 
   bool bFound = false;
-  for (uint i = 0; i < pFace->uNumVertices; ++i)
-    if (stru_50B700._view_transformed_xs[i] >= 0x80000u)
+  for (uint i = 0; i < v1->uNumVertices; ++i)
+    if (_50B924_view_transformed_xs[i] >= 0x80000u)
     {
       bFound = true;
       break;
@@ -1620,27 +2088,27 @@
     return 0;
 
   v79 = 0;
-  stru_50B700._view_transformed_xs[pFace->uNumVertices] = stru_50B700._view_transformed_xs[0];
-  stru_50B700._view_transformed_zs[pFace->uNumVertices] = stru_50B700._view_transformed_zs[0];
-  stru_50B700._view_transformed_ys[pFace->uNumVertices] = stru_50B700._view_transformed_ys[0];
-  thisa = stru_50B700._view_transformed_xs[0] >= (signed int)0x80000u;
+  _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] >= (signed int)0x80000u;
   //int i = 1;
-  for (uint i = 1; i <= pFace->uNumVertices; ++i)
+  for (uint i = 1; i <= v1->uNumVertices; ++i)
   {
-      v10 = stru_50B700._view_transformed_xs[i];
+      v10 = _50B924_view_transformed_xs[i];
       v81 = v10 >= (signed int)0x80000u;
       if ( thisa ^ v81 )
       {
-        v11 = stru_50B700._view_transformed_xs[i - 1];
+        v11 = _50B924_view_transformed_xs[i - 1];
         if ( v10 >= (signed int)0x80000u )
         {
           v12 = v10 - v11;
           v13 = 0x80000 - v11;
           LODWORD(v14) = v13 << 16;
           HIDWORD(v14) = v13 >> 16;
-          v15 = &stru_50B700._view_transformed_ys[i - 1];
-          stru_50B700.field_128[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[i] - stru_50B700._view_transformed_zs[i - 1]) * v14 / v12) >> 16) + stru_50B700._view_transformed_zs[i - 1];
-          thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[i] - stru_50B700._view_transformed_ys[i - 1]) * v14 / v12) >> 16;
+          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[i - 1];
+          thisb = (unsigned __int64)((_50B744_view_transformed_ys[i] - _50B744_view_transformed_ys[i - 1]) * v14 / v12) >> 16;
         }
         else
         {
@@ -1648,93 +2116,93 @@
           v17 = 0x80000 - v10;
           LODWORD(v18) = v17 << 16;
           HIDWORD(v18) = v17 >> 16;
-          v15 = &stru_50B700._view_transformed_ys[i];
-          stru_50B700.field_128[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[i - 1] - stru_50B700._view_transformed_zs[i]) * v18 / v16) >> 16) + stru_50B700._view_transformed_zs[i];
-          thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[i - 1] - stru_50B700._view_transformed_ys[i]) * v18 / v16) >> 16;
+          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[i - 1] - _50B744_view_transformed_ys[i]) * v18 / v16) >> 16;
         }
         v19 = v79++;
         //v7 = v66;
-        stru_50B700.field_38[v19] = thisb + *v15;
-        stru_50B700.field_218[v19] = 0x80000u;
+        dword_50B738[v19] = thisb + *v15;
+        dword_50B918[v19] = 0x80000u;
       }
       if ( v81 )
       {
         v20 = v79++;
-        stru_50B700.field_218[v20] = stru_50B700._view_transformed_xs[i];
-        stru_50B700.field_128[v20] = stru_50B700._view_transformed_zs[i];
-        stru_50B700.field_38[v20] = stru_50B700._view_transformed_ys[i];
+        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;
   }
   v21 = v79;
-  stru_50B700.field_218[v79] = stru_50B700.field_218[0];
-  stru_50B700.field_128[v79] = stru_50B700.field_128[0];
-  stru_50B700.field_38[v79] = stru_50B700.field_38[0];
+  dword_50B918[v79] = dword_50B918[0];
+  dword_50B828[v79] = dword_50B828[0];
+  dword_50B738[v79] = dword_50B738[0];
   for (ia = 0; ia < v79; ++ia)
   {
     v22 = ia;
-    thisc = abs(stru_50B700.field_218[ia]);
-    if ( abs(stru_50B700.field_128[ia]) >> 13 <= thisc )
+    thisc = abs(dword_50B918[ia]);
+    if ( abs(dword_50B828[ia]) >> 13 <= thisc )
     {
-      v27 = stru_50B700.field_128[v22];
+      v27 = dword_50B828[v22];
       LODWORD(v28) = v27 << 16;
       HIDWORD(v28) = v27 >> 16;
-      v26 = v28 / stru_50B700.field_218[v22];
+      v26 = v28 / dword_50B918[v22];
       v23 = 0;
     }
     else
     {
       v23 = 0;
       v24 = 0;
-      if ( stru_50B700.field_128[v22] >= 0 )
+      if ( dword_50B828[v22] >= 0 )
       {
-        LOBYTE(v24) = stru_50B700.field_218[v22] >= 0;
+        LOBYTE(v24) = dword_50B918[v22] >= 0;
         v26 = ((v24 - 1) & 0xFF800000) + 0x400000;
       }
       else
       {
-        LOBYTE(v24) = stru_50B700.field_218[v22] >= 0;
+        LOBYTE(v24) = dword_50B918[v22] >= 0;
         v25 = v24 - 1;
         v26 = (v25 & 0x800000) - 0x400000;
       }
     }
-    v29 = stru_50B700.field_38[v22];
-    stru_50B700._xs3[v22] = v26;
+    v29 = dword_50B738[v22];
+    dword_50BAF8_xs[v22] = v26;
     if ( abs(v29) >> 13 <= thisc )
     {
-      v33 = stru_50B700.field_38[v22];
+      v33 = dword_50B738[v22];
       LODWORD(v34) = v33 << 16;
       HIDWORD(v34) = v33 >> 16;
-      v32 = v34 / stru_50B700.field_218[v22];
+      v32 = v34 / dword_50B918[v22];
     }
     else
     {
       v30 = 0;
-      if ( stru_50B700.field_38[v22] >= v23 )
+      if ( dword_50B738[v22] >= v23 )
       {
-        LOBYTE(v30) = stru_50B700.field_218[v22] >= v23;
+        LOBYTE(v30) = dword_50B918[v22] >= v23;
         v32 = ((v30 - 1) & 0xFF800000) + 0x400000;
       }
       else
       {
-        LOBYTE(v30) = stru_50B700.field_218[v22] >= v23;
+        LOBYTE(v30) = dword_50B918[v22] >= v23;
         v31 = v30 - 1;
         v32 = (v31 & 0x800000) - 0x400000;
       }
     }
-    stru_50B700._ys2[v22] = v32;
-    stru_50B700._xs3[v22] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)stru_50B700._xs3[v22]) >> 16;
-    v35 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)stru_50B700._ys2[v22]) >> 16;
-    stru_50B700._xs3[v22] = pBLVRenderParams->uViewportCenterX - stru_50B700._xs3[v22];
-    stru_50B700._ys2[v22] = pBLVRenderParams->uViewportCenterY - v35;
+    dword_50BA08_ys[v22] = v32;
+    dword_50BAF8_xs[v22] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)dword_50BAF8_xs[v22]) >> 16;
+    v35 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)dword_50BA08_ys[v22]) >> 16;
+    dword_50BAF8_xs[v22] = pBLVRenderParams->uViewportCenterX - dword_50BAF8_xs[v22];
+    dword_50BA08_ys[v22] = pBLVRenderParams->uViewportCenterY - v35;
   }
   v36 = 0;
-  stru_50B700._xs3[v21] = stru_50B700._xs3[0];
-  stru_50B700._ys2[v21] = stru_50B700._ys2[0];
+  dword_50BAF8_xs[v21] = dword_50BAF8_xs[0];
+  dword_50BA08_ys[v21] = dword_50BA08_ys[0];
   v37 = pBLVRenderParams->uViewportX;
-  v38 = stru_50B700._xs3[0] < (signed int)pBLVRenderParams->uViewportX;
-  LOBYTE(v38) = stru_50B700._xs3[0] >= (signed int)pBLVRenderParams->uViewportX;
+  v38 = dword_50BAF8_xs[0] < (signed int)pBLVRenderParams->uViewportX;
+  LOBYTE(v38) = dword_50BAF8_xs[0] >= (signed int)pBLVRenderParams->uViewportX;
   v39 = 1;
   ib = 1;
   if ( v79 < 1 )
@@ -1742,30 +2210,30 @@
   do
   {
     v40 = v39;
-    v41 = stru_50B700._xs3[v40];
+    v41 = dword_50BAF8_xs[v40];
     v82 = v41 >= (signed int)v37;
     if ( v38 ^ v82 )
     {
       if ( v41 >= (signed int)v37 )
       {
-        v67 = (signed int)(v37 - stru_50B700._xs3[v40 - 1]) * (signed __int64)(stru_50B700._ys2[v40] - stru_50B700._ys2[v40 - 1]) / (v41 - stru_50B700._xs3[v40 - 1]);
-        v42 = stru_50B700._ys2[v40 - 1];
+        v67 = (signed int)(v37 - dword_50BAF8_xs[v40 - 1]) * (signed __int64)(dword_50BA08_ys[v40] - dword_50BA08_ys[v40 - 1]) / (v41 - dword_50BAF8_xs[v40 - 1]);
+        v42 = dword_50BA08_ys[v40 - 1];
       }
       else
       {
-        v67 = (signed int)(v37 - v41) * (signed __int64)(stru_50B700._ys2[v40 - 1] - stru_50B700._ys2[v40]) / (stru_50B700._xs3[v40 - 1] - v41);
-        v42 = stru_50B700._ys2[v40];
+        v67 = (signed int)(v37 - v41) * (signed __int64)(dword_50BA08_ys[v40 - 1] - dword_50BA08_ys[v40]) / (dword_50BAF8_xs[v40 - 1] - v41);
+        v42 = dword_50BA08_ys[v40];
       }
-      stru_50B700._ys[v36] = v67 + v42;
+      dword_50B9FC_ys[v36] = v67 + v42;
       v37 = pBLVRenderParams->uViewportX;
-      stru_50B700._xs2[v36] = pBLVRenderParams->uViewportX;
+      dword_50BAEC_xs[v36] = pBLVRenderParams->uViewportX;
       ++v36;
     }
     v38 = v82;
     if ( v82 )
     {
-      stru_50B700._xs2[v36] = stru_50B700._xs3[v40];
-      stru_50B700._ys[v36] = stru_50B700._ys2[v40];
+      dword_50BAEC_xs[v36] = dword_50BAF8_xs[v40];
+      dword_50B9FC_ys[v36] = dword_50BA08_ys[v40];
       ++v36;
     }
     v39 = ib++ + 1;
@@ -1776,38 +2244,38 @@
     return 0;
 
   v43 = 0;
-  stru_50B700._xs2[v36] = stru_50B700._xs2[0];
-  stru_50B700._ys[v36] = stru_50B700._ys[0];
+  dword_50BAEC_xs[v36] = dword_50BAEC_xs[0];
+  dword_50B9FC_ys[v36] = dword_50B9FC_ys[0];
   v44 = pBLVRenderParams->uViewportZ;
-  thisd = stru_50B700._xs2[0] <= (signed int)pBLVRenderParams->uViewportZ;
+  thisd = dword_50BAEC_xs[0] <= (signed int)pBLVRenderParams->uViewportZ;
   ic = 1;
 
   do
   {
     v45 = ic;
-    v46 = stru_50B700._xs2[ic];
+    v46 = dword_50BAEC_xs[ic];
     v83 = v46 <= (signed int)v44;
     if ( thisd ^ v83 )
     {
       if ( v46 <= (signed int)v44 )
       {
-        v68 = (signed int)(v44 - stru_50B700._xs2[v45 - 1]) * (signed __int64)(stru_50B700._ys[v45] - stru_50B700._ys[v45 - 1]) / (v46 - stru_50B700._xs2[v45 - 1]);
-        v47 = stru_50B700._ys[v45 - 1];
+        v68 = (signed int)(v44 - dword_50BAEC_xs[v45 - 1]) * (signed __int64)(dword_50B9FC_ys[v45] - dword_50B9FC_ys[v45 - 1]) / (v46 - dword_50BAEC_xs[v45 - 1]);
+        v47 = dword_50B9FC_ys[v45 - 1];
       }
       else
       {
-        v68 = (signed int)(v44 - v46) * (signed __int64)(stru_50B700._ys[v45 - 1] - stru_50B700._ys[v45]) / (stru_50B700._xs2[v45 - 1] - v46);
-        v47 = stru_50B700._ys[v45];
+        v68 = (signed int)(v44 - v46) * (signed __int64)(dword_50B9FC_ys[v45 - 1] - dword_50B9FC_ys[v45]) / (dword_50BAEC_xs[v45 - 1] - v46);
+        v47 = dword_50B9FC_ys[v45];
       }
-      stru_50B700.field_2F0[v43] = v68 + v47;
+      dword_50B9F0[v43] = v68 + v47;
       v44 = pBLVRenderParams->uViewportZ;
-      stru_50B700._xs[v43] = pBLVRenderParams->uViewportZ;
+      dword_50BAE0[v43] = pBLVRenderParams->uViewportZ;
       ++v43;
     }
     if ( v83 )
     {
-      stru_50B700._xs[v43] = stru_50B700._xs2[v45];
-      stru_50B700.field_2F0[v43++] = stru_50B700._ys[v45];
+      dword_50BAE0[v43] = dword_50BAEC_xs[v45];
+      dword_50B9F0[v43++] = dword_50B9FC_ys[v45];
     }
     ++ic;
     thisd = v83;
@@ -1818,41 +2286,40 @@
     return 0;
 
   v48 = 0;
-  stru_50B700._xs[v43] = stru_50B700._xs[0];
-  stru_50B700.field_2F0[v43] = stru_50B700.field_2F0[0];
+  dword_50BAE0[v43] = dword_50BAE0[0];
+  dword_50B9F0[v43] = dword_50B9F0[0];
   v49 = pBLVRenderParams->uViewportY;
-  v50 = stru_50B700.field_2F0[0] < (signed int)pBLVRenderParams->uViewportY;
-  LOBYTE(v50) = stru_50B700.field_2F0[0] >= (signed int)pBLVRenderParams->uViewportY;
+  v50 = dword_50B9F0[0] < (signed int)pBLVRenderParams->uViewportY;
+  LOBYTE(v50) = dword_50B9F0[0] >= (signed int)pBLVRenderParams->uViewportY;
   v51 = 1;
   id = 1;
   do
   {
     v52 = v51;
-    v53 = stru_50B700.field_2F0[v52];
+    v53 = dword_50B9F0[v52];
     v84 = v53 >= (signed int)v49;
     if ( v50 ^ v84 )
     {
       if ( v53 >= (signed int)v49 )
       {
-        v69 = (signed int)(v49 - stru_50B700.field_2F0[v52 - 1]) * (signed __int64)(stru_50B700._xs[v52] - stru_50B700._xs[v52 - 1]) / (v53 - stru_50B700.field_2F0[v52 - 1]);
-        v54 = stru_50B700._xs[v52 - 1];
+        v69 = (signed int)(v49 - dword_50B9F0[v52 - 1]) * (signed __int64)(dword_50BAE0[v52] - dword_50BAE0[v52 - 1]) / (v53 - dword_50B9F0[v52 - 1]);
+        v54 = dword_50BAE0[v52 - 1];
       }
       else
       {
-        v69 = (signed int)(v49 - v53) * (signed __int64)(stru_50B700._xs[v52 - 1] - stru_50B700._xs[v52]) / (stru_50B700.field_2F0[v52 - 1] - v53);
-        v54 = stru_50B700._xs[v52];
+        v69 = (signed int)(v49 - v53) * (signed __int64)(dword_50BAE0[v52 - 1] - dword_50BAE0[v52]) / (dword_50B9F0[v52 - 1] - v53);
+        v54 = dword_50BAE0[v52];
       }
-      stru_50B700.field_3D4[v48] = v69 + v54;
+      dword_50BAD4[v48] = v69 + v54;
       v49 = pBLVRenderParams->uViewportY;
-      stru_50B700._xs[v48+1] = pBLVRenderParams->uViewportY;
+      dword_50B9E4[v48] = pBLVRenderParams->uViewportY;
       ++v48;
     }
     v50 = v84;
     if ( v84 )
     {
-      stru_50B700.field_3D4[v48] = stru_50B700._xs[v52];
-      stru_50B700._xs[v48+1] = stru_50B700.field_2F0[v52];
-	  v48++;
+      dword_50BAD4[v48] = dword_50BAE0[v52];
+      dword_50B9E4[v48++] = dword_50B9F0[v52];
     }
     v51 = id++ + 1;
   }
@@ -1862,37 +2329,37 @@
     return 0;
 
   v55 = 0;
-  stru_50B700.field_3D4[v48] = stru_50B700.field_3D4[0];
-  stru_50B700._xs[v48+1] = stru_50B700._xs[1];
+  dword_50BAD4[v48] = dword_50BAD4[0];
+  dword_50B9E4[v48] = dword_50B9E4[0];
   v56 = pBLVRenderParams->uViewportW;
-  thise = stru_50B700._xs[1] <= (signed int)pBLVRenderParams->uViewportW;
+  thise = dword_50B9E4[0] <= (signed int)pBLVRenderParams->uViewportW;
   ie = 1;
   do
   {
     v57 = ie;
-    v58 = stru_50B700._xs[ie+1];
+    v58 = dword_50B9E4[ie];
     v85 = v58 <= (signed int)v56;
     if ( thise ^ v85 )
     {
       if ( v58 <= (signed int)v56 )
       {
-        v70 = (signed int)(v56 - stru_50B700._xs[v57]) * (signed __int64)(stru_50B700.field_3D4[v57] - stru_50B700.field_3D4[v57 - 1]) / (v58 - stru_50B700._xs[v57]);
-        v59 = stru_50B700.field_3D4[v57 - 1];
+        v70 = (signed int)(v56 - dword_50B9E4[v57 - 1]) * (signed __int64)(dword_50BAD4[v57] - dword_50BAD4[v57 - 1]) / (v58 - dword_50B9E4[v57 - 1]);
+        v59 = dword_50BAD4[v57 - 1];
       }
       else
       {
-        v70 = (signed int)(v56 - v58) * (signed __int64)(stru_50B700.field_3D4[v57 - 1] - stru_50B700.field_3D4[v57]) / (stru_50B700._xs[v57] - v58);
-        v59 = stru_50B700.field_3D4[v57];
+        v70 = (signed int)(v56 - v58) * (signed __int64)(dword_50BAD4[v57 - 1] - dword_50BAD4[v57]) / (dword_50B9E4[v57 - 1] - v58);
+        v59 = dword_50BAD4[v57];
       }
-      stru_50B700._screen_space_x[v55] = v70 + v59;
+      _50BAC8_screen_space_x[v55] = v70 + v59;
       v56 = pBLVRenderParams->uViewportW;
-      stru_50B700._screen_space_y[v55] = pBLVRenderParams->uViewportW;
+      _50B9D8_screen_space_y[v55] = pBLVRenderParams->uViewportW;
       ++v55;
     }
     if ( v85 )
     {
-      stru_50B700._screen_space_x[v55] = stru_50B700.field_3D4[v57];
-      stru_50B700._screen_space_y[v55++] = stru_50B700._xs[v57+1];
+      _50BAC8_screen_space_x[v55] = dword_50BAD4[v57];
+      _50B9D8_screen_space_y[v55++] = dword_50B9E4[v57];
     }
     ++ie;
     thise = v85;
@@ -1902,13 +2369,13 @@
   if ( !v55 )
     return 0;
   v61 = pRenderer->pRenderD3D == 0;
-  stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0];
-  stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0];
+  _50BAC8_screen_space_x[v55] = _50BAC8_screen_space_x[0];
+  _50B9D8_screen_space_y[v55] = _50B9D8_screen_space_y[0];
   if ( v61 && v55 > 3 )
   {
-    stru_50B700._screen_space_x[v55 + 1] = stru_50B700._screen_space_x[1];
-    stru_50B700._screen_space_y[v55 + 1] = stru_50B700._screen_space_y[1];
-    thisf = 2 * (stru_50B700.field_0 != 0) - 1;
+    _50BAC8_screen_space_x[v55 + 1] = _50BAC8_screen_space_x[1];
+    _50B9D8_screen_space_y[v55 + 1] = _50B9D8_screen_space_y[1];
+    thisf = 2 * (dword_50B700 != 0) - 1;
     if ( v55 > 0 )
     {
       v62 = 1;
@@ -1925,8 +2392,8 @@
         if ( v64 >= v55 )
           v64 -= v55;
         if ( thisf
-           * ((stru_50B700._screen_space_y[v64] - stru_50B700._screen_space_y[v63]) * (stru_50B700._screen_space_x[v62] - stru_50B700._screen_space_x[v63])
-            - (stru_50B700._screen_space_y[v62] - stru_50B700._screen_space_y[v63]) * (stru_50B700._screen_space_x[v64] - stru_50B700._screen_space_x[v63])) < 0 )
+           * ((_50B9D8_screen_space_y[v64] - _50B9D8_screen_space_y[v63]) * (_50BAC8_screen_space_x[v62] - _50BAC8_screen_space_x[v63])
+            - (_50B9D8_screen_space_y[v62] - _50B9D8_screen_space_y[v63]) * (_50BAC8_screen_space_x[v64] - _50BAC8_screen_space_x[v63])) < 0 )
         {
           v62 = v80;
           v71 = v80;
@@ -1937,19 +2404,19 @@
           v65 = v71;
           if ( v71 < v55 || (v65 = v71 - v55, v71 - v55 < v55) )
           {
-            memcpy(&stru_50B700._screen_space_y[v65], &stru_50B700._screen_space_y[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
-            memcpy(&stru_50B700._screen_space_x[v65], &stru_50B700._screen_space_x[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
+            memcpy(&_50B9D8_screen_space_y[v65], &_50B9D8_screen_space_y[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
+            memcpy(&_50BAC8_screen_space_x[v65], &_50BAC8_screen_space_x[v65 + 1], 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
           }
           --v55;
         }
       }
       while ( v62 - 1 < v55 );
     }
-    stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0];
-    stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0];
+    _50BAC8_screen_space_x[v55] = _50BAC8_screen_space_x[0];
+    _50B9D8_screen_space_y[v55] = _50B9D8_screen_space_y[0];
   }
   return v55;
-}
+}*/
 
 //----- (00424579) --------------------------------------------------------
 int __fastcall sub_424579(int uFaceID, stru320 *a2)
@@ -2368,7 +2835,7 @@
   {
     v62 = stru_50B700._screen_space_x[v55] << 16;
     v54 = ((stru_50B700._screen_space_x[v13] - stru_50B700._screen_space_x[v55]) << 16) / (stru_50B700._screen_space_y[v13] - stru_50B700._screen_space_y[v55]);
-    a2->array_18[min_y] = LOWORD(stru_50B700._screen_space_x[v55]);
+    a2->viewport_left_side[min_y] = LOWORD(stru_50B700._screen_space_x[v55]);
   }
   v15 = v65;
   v61 = v65;
@@ -2405,13 +2872,13 @@
   {
     v61 = stru_50B700._screen_space_x[v20] << 16;
     v53 = ((stru_50B700._screen_space_x[v19] - stru_50B700._screen_space_x[v20]) << 16) / stru_50B700._screen_space_y[v19] - stru_50B700._screen_space_y[v20];
-    a2->array_3D8[max_y] = LOWORD(stru_50B700._screen_space_x[v20]);
+    a2->viewport_right_side[max_y] = LOWORD(stru_50B700._screen_space_x[v20]);
   }
   v22 = min_y;
   if ( min_y <= max_y )
   {
-    //v56 = &a2->array_3D8[v7];
-    //v23 = &a2->array_18[v7];
+    //v56 = &a2->viewport_right_side[v7];
+    //v23 = &a2->viewport_left_side[v7];
     for ( v70 = min_y; v70 <= max_y; ++v70 )
     {
       v24 = v13;
@@ -2452,21 +2919,21 @@
           v61 = stru_50B700._screen_space_x[v29] << 16;
         }
       }
-	  //v34 = (char *)a2->array_18 - (char *)a2->array_3D8;
-	  //v35 = *(__int16 *)((char *)&a2->array_3D8[v70] + v34);
+	  //v34 = (char *)a2->viewport_left_side - (char *)a2->viewport_right_side;
+	  //v35 = *(__int16 *)((char *)&a2->viewport_right_side[v70] + v34);
       //v35 = HIWORD(v62);
-      a2->array_18[v70] = HIWORD(v62);
-      a2->array_3D8[v70] = HIWORD(v61);
+      a2->viewport_left_side[v70] = HIWORD(v62);
+      a2->viewport_right_side[v70] = HIWORD(v61);
       //v34 = &a2->array_3D8[v70];
       //v35 = a2->array_3D8[v70];
-      if ( a2->array_18[v70] > a2->array_3D8[v70] )
+      if ( a2->viewport_left_side[v70] > a2->viewport_right_side[v70] )
       {
-        v36 = a2->array_18[v70] ^ a2->array_3D8[v70];
-        v37 = a2->array_3D8[v70];
-        a2->array_18[v70] = v36;
+        v36 = a2->viewport_left_side[v70] ^ a2->viewport_right_side[v70];
+        v37 = a2->viewport_right_side[v70];
+        a2->viewport_left_side[v70] = v36;
         v38 = v37 ^ v36;
-        a2->array_18[v70] ^= v38;
-        a2->array_3D8[v70] = v38;
+        a2->viewport_left_side[v70] ^= v38;
+        a2->viewport_right_side[v70] = v38;
       }
       //++v56;
       v62 += v54;
@@ -2486,11 +2953,11 @@
   if ( min_y <= max_y )
   {
     //a3a = (char *)a2 - (char *)a3;
-    //v42 = &a3->array_3D8[v7];
+    //v42 = &a3->viewport_right_side[v7];
     //v57 = *(__int16 *)((char *)v42 + a3a);
     for ( v71 = min_y; v71 <= max_y; ++v71 )
     {
-      if ( a2->array_18[v71] >= a3->array_18[v71] && a2->array_18[v71] <= a3->array_3D8[v71] )
+      if ( a2->viewport_left_side[v71] >= a3->viewport_left_side[v71] && a2->viewport_left_side[v71] <= a3->viewport_right_side[v71] )
         break;
       //++v57;
       ++min_y;
@@ -2500,11 +2967,11 @@
   if ( max_y < min_y )
     return false;
   //a3a = (char *)a2 - (char *)a3;
-  //v43 = &a3->array_3D8[v8];
+  //v43 = &a3->viewport_right_side[v8];
   //v58 = *(__int16 *)((char *)v43 + a3a);
   for ( v72 = max_y; v72 >= min_y; --v72 )
   {
-    if ( a2->array_3D8[v72] >= a3->array_18[v72] && a2->array_18[v72] <= a3->array_3D8[v72] )
+    if ( a2->viewport_right_side[v72] >= a3->viewport_left_side[v72] && a2->viewport_left_side[v72] <= a3->viewport_right_side[v72] )
       break;
     //--v58;
     --max_y;
@@ -2515,40 +2982,40 @@
     return false;
   //a3b = (char *)a3 - (char *)a2;
   v59 = min_y;
-  //v45 = &a2->array_18[v7];
+  //v45 = &a2->viewport_left_side[v7];
   
   for ( v46 = max_y - min_y + 1; v46; --v46 )
   {
     //v47 = *(__int16 *)((char *)v45 + a3b);
-    if ( a2->array_18[v59] < a3->array_18[v59] )
-      a2->array_18[v59] = a3->array_18[v59];
-    if ( a2->array_3D8[v59] > a3->array_3D8[v59] )
-      a2->array_3D8[v59] = a3->array_3D8[v59];
+    if ( a2->viewport_left_side[v59] < a3->viewport_left_side[v59] )
+      a2->viewport_left_side[v59] = a3->viewport_left_side[v59];
+    if ( a2->viewport_right_side[v59] > a3->viewport_right_side[v59] )
+      a2->viewport_right_side[v59] = a3->viewport_right_side[v59];
     ++v59;
     //++v45;
   }
   a2->_viewport_space_y = min_y;
   a2->_viewport_space_w = max_y;
-  a2->field_8 = a2->array_18[min_y];
-  //v48 = a2->array_3D8[v7];
+  a2->field_8 = a2->viewport_left_side[min_y];
+  //v48 = a2->viewport_right_side[v7];
   a2->field_10 = min_y;
   a2->field_14 = min_y;
-  a2->field_C = a2->array_3D8[min_y];
+  a2->field_C = a2->viewport_right_side[min_y];
   v49 = min_y + 1;
   if ( v49 <= max_y )
   {
-    //v50 = &a2->array_3D8[v49];
+    //v50 = &a2->viewport_right_side[v49];
     for ( v49; v49 <= max_y; ++v49 )
     {
-      //v51 = a2->array_18[v49];
-      if ( a2->array_18[v49] < a2->field_8 )
+      //v51 = a2->viewport_left_side[v49];
+      if ( a2->viewport_left_side[v49] < a2->field_8 )
       {
-        a2->field_8 = a2->array_18[v49];
+        a2->field_8 = a2->viewport_left_side[v49];
         a2->field_10 = v49;
       }
-      if ( a2->array_3D8[v49] > a2->field_C )
+      if ( a2->viewport_right_side[v49] > a2->field_C )
       {
-        a2->field_C = a2->array_3D8[v49];
+        a2->field_C = a2->viewport_right_side[v49];
         a2->field_14 = v49;
       }
       //++v50;
--- a/mm7_3.cpp	Thu Jun 13 23:41:42 2013 +0400
+++ b/mm7_3.cpp	Fri Jun 14 16:06:30 2013 +0600
@@ -11019,7 +11019,7 @@
     pBspRenderer->nodes[0].uViewportZ = pBLVRenderParams->uViewportZ;
     pBspRenderer->nodes[0].uViewportY = pBLVRenderParams->uViewportY;
     pBspRenderer->nodes[0].uViewportX = pBLVRenderParams->uViewportX;
-    pBspRenderer->nodes[0].field_C._43F9E1(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY,
+    pBspRenderer->nodes[0].field_C.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY,
                                            pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW);
     pBspRenderer->nodes[0].uFaceID = -1;
     pBspRenderer->nodes[0].viewing_portal_id = -1;
@@ -11031,7 +11031,7 @@
 }
 
 //----- (0043F9E1) --------------------------------------------------------
-void BspRenderer_stru2::_43F9E1(__int16 x, int y, __int16 z, int w)
+void BspRenderer_stru2::GetViewportData(__int16 x, int y, __int16 z, int w)
 {
   _viewport_space_y = y;
   _viewport_space_w = w;
@@ -11040,13 +11040,13 @@
   {
     if ( i < y || i > w )
     {
-      array_18[i] = 640;
-      array_3D8[i] = -1;
+      viewport_left_side[i] = 640;
+      viewport_right_side[i] = -1;
     }
     else
     {
-      array_18[i] = x;
-      array_3D8[i] = z;
+      viewport_left_side[i] = x;
+      viewport_right_side[i] = z;
     } 
   }
 }
@@ -11428,7 +11428,7 @@
     pNode = &pIndoor->pNodes[uFirstNode];
     pFace = &pIndoor->pFaces[pSector->pFaceIDs[pNode->uCoplanarOffset]];
     v5 = 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;
+       + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z;//plane equation
     if (pFace->Portal() && pFace->uSectorID != node->uSectorID )
       v5 = -v5;
     //v11 = v5 > 0;
--- a/mm7_4.cpp	Thu Jun 13 23:41:42 2013 +0400
+++ b/mm7_4.cpp	Fri Jun 14 16:06:30 2013 +0600
@@ -4511,29 +4511,29 @@
                 v101 = 2 * stru_F8A590._viewport_space_y;
                 while ( 1 )
                 {
-                  a1 = *(__int16 *)((char *)stru_F8A590.array_18 + v12);
+                  a1 = *(__int16 *)((char *)stru_F8A590.viewport_left_side + v12);
                   sub_4AE313(a1, result, &stru_F81018.field_0);
                   if ( LOBYTE(viewparams->field_20) )
                   {
                     v15 = v95 * (v12 - pBLVRenderParams->uViewportY);
                     v119 = &pBLVRenderParams->pTargetZBuffer[2
-                                                          * (*(__int16 *)((char *)stru_F8A590.array_18 + v12)
+                                                          * (*(__int16 *)((char *)stru_F8A590.viewport_left_side + v12)
                                                            + 320 * (v12 - pBLVRenderParams->uViewportY))
                                                           - pBLVRenderParams->uViewportX];
                     v16 = &pBLVRenderParams->pRenderTarget[v15
-                                                        + 2 * *(__int16 *)((char *)stru_F8A590.array_18 + v12)
+                                                        + 2 * *(__int16 *)((char *)stru_F8A590.viewport_left_side + v12)
                                                         - pBLVRenderParams->uViewportX];
                     v14 = &pBLVRenderParams->pRenderTarget[v15
-                                                        + 2 * *(__int16 *)((char *)stru_F8A590.array_3D8 + v12)
+                                                        + 2 * *(__int16 *)((char *)stru_F8A590.viewport_right_side + v12)
                                                         - pBLVRenderParams->uViewportX];
                     v123 = (unsigned int)v16;
                   }
                   else
                   {
-                    v13 = *(__int16 *)((char *)stru_F8A590.array_18 + v12);
+                    v13 = *(__int16 *)((char *)stru_F8A590.viewport_left_side + v12);
                     v119 = &pBLVRenderParams->pTargetZBuffer[v13 + v99];
                     v123 = (unsigned int)&pBLVRenderParams->pRenderTarget[v13 + v11];
-                    v14 = &pBLVRenderParams->pRenderTarget[v11 + *(__int16 *)((char *)stru_F8A590.array_3D8 + v12)];
+                    v14 = &pBLVRenderParams->pRenderTarget[v11 + *(__int16 *)((char *)stru_F8A590.viewport_right_side + v12)];
                   }
                   v117 = (unsigned int)v14;
                   HIWORD(v17) = HIWORD(stru_F81018.field_0.field_0);
@@ -4999,7 +4999,7 @@
             v56 = 640 * stru_F8A590._viewport_space_y;
             for ( i = &stru_F83B80[stru_F8A590._viewport_space_y]; ; v14 = i )
             {
-              sub_4AE1E7(v12, *(__int16 *)((char *)stru_F8A590.array_18 + v13), v12);
+              sub_4AE1E7(v12, *(__int16 *)((char *)stru_F8A590.viewport_left_side + v13), v12);
               v14->field_0 += (GetTickCount() << 11) - (pBLVRenderParams->vPartyPos.x << 16);
               v15 = GetTickCount();
               v16 = v14->field_0;
@@ -5010,10 +5010,10 @@
               v52 = (unsigned __int64)(v17 * (signed __int64)-pBLVRenderParams->sSineY) >> 16;
               v53 = (unsigned __int64)(v17 * (signed __int64)pBLVRenderParams->sCosineY) >> 16;
               v18 = v14->field_28;
-              v19 = *(__int16 *)((char *)stru_F8A590.array_18 + v13);
+              v19 = *(__int16 *)((char *)stru_F8A590.viewport_left_side + v13);
               LOWORD(v18) = 0;
               v46 = stru_F8AD28.field_0 | v18;
-              v61 = *(__int16 *)((char *)stru_F8A590.array_3D8 + v13) - v19;
+              v61 = *(__int16 *)((char *)stru_F8A590.viewport_right_side + v13) - v19;
               if ( LOBYTE(viewparams->field_20) )
               {
                 v63 = &pBLVRenderParams->pTargetZBuffer[2 * (v19 + 320 * (v13 - pBLVRenderParams->uViewportY))
--- a/stru367.h	Thu Jun 13 23:41:42 2013 +0400
+++ b/stru367.h	Fri Jun 14 16:06:30 2013 +0600
@@ -8,33 +8,33 @@
 {
 	int field_0;
 	int field_4[13];
-	int field_38[2];
+	int field_38[2];//new point x for near plane
 	int _view_transformed_ys_minus1;
-	int _view_transformed_ys[57];
-	int field_128[2];
+	int _view_transformed_ys[57];//origin coordinates x
+	int field_128[2];//new point y for near plane
 	int _view_transformed_zs_minus1;
-	int _view_transformed_zs[57];
-	int field_218[2];
+	int _view_transformed_zs[57];//origin coordinates y
+	int field_218[2];//new point z for near plane
 	int _view_transformed_xs_minus1;
-	int _view_transformed_xs[45];
+	int _view_transformed_xs[45];//origin coordinates z
 	int _screen_space_y[2];
 	int field_2E0;
 	int field_2E4[2];
 	int field_2EC;
-	int field_2F0[2];
+	int field_2F0[2];//new point y for right plane
 	int field_2F8;
-	int _ys[3];
-	int _ys2[48];
+	int _ys[3];//new point x for left plane
+	int _ys2[48];//
 	int _screen_space_x[2];
 	int field_3D0;
-	int field_3D4[2];
+	int field_3D4[2];//new point x for top plane
 	int field_3DC;
 	//int field_3E0;
-	int _xs[54];
+	int _xs[54];//
 	int field_3E4;
 	int field_3E8;
-	int _xs2[3];
-	int _xs3[48];
+	int _xs2[3];//new point y for left plane
+	int _xs3[48];// 
 };
 #pragma pack(pop)
 
--- a/stru9.cpp	Thu Jun 13 23:41:42 2013 +0400
+++ b/stru9.cpp	Fri Jun 14 16:06:30 2013 +0600
@@ -110,7 +110,7 @@
           v19 = &pVertices2[i];
         }
         //v20 = v12;
-        if ( AreVectorsCollinear(&pVertices2[i], pPortalBounding, &static_AE3FA4) )//
+        if ( AreVectorsCollinear(&pVertices2[i], pPortalBounding, &static_AE3FA4) )
           AddVertex(&static_AE33A0, &pVertices2[i]);
         //pOutNumVertices = pOutNumVertices;
         //a3a++;