diff mm7_3.cpp @ 718:a5ee769b02c6

Слияние
author Ritor1
date Mon, 18 Mar 2013 01:51:31 +0600
parents d5473972234d af0332a32034
children 70c5a87a1307
line wrap: on
line diff
--- a/mm7_3.cpp	Mon Mar 18 01:50:50 2013 +0600
+++ b/mm7_3.cpp	Mon Mar 18 01:51:31 2013 +0600
@@ -4479,10 +4479,10 @@
           *((float *)v4 + 19) = v8 - v9;
         }
         *((int *)v4 + 21) = *((int *)v4 + 1);
-        if ( (double)(signed int)pViewport->uViewportX <= *((float *)v4 + 18)
-          && (double)(signed int)pViewport->uViewportZ > *((float *)v4 + 18)
-          && (double)(signed int)pViewport->uViewportY <= *((float *)v4 + 19)
-          && (double)(signed int)pViewport->uViewportW > *((float *)v4 + 19) )
+        if ( (double)(signed int)pViewport->uViewportTL_X <= *((float *)v4 + 18)
+          && (double)(signed int)pViewport->uViewportBR_X > *((float *)v4 + 18)
+          && (double)(signed int)pViewport->uViewportTL_Y <= *((float *)v4 + 19)
+          && (double)(signed int)pViewport->uViewportBR_Y > *((float *)v4 + 19) )
           v16 = 1;
         ++v3;
         v4 += 16;
@@ -4505,10 +4505,10 @@
         *((int *)v10 + 22) = LODWORD(v11);
         *((int *)v10 + 23) = *((int *)v10 + 3);
         *((float *)v10 + 21) = v13 - v14;
-        if ( (double)(signed int)pViewport->uViewportX <= *((float *)v10 + 20)
-          && (double)(signed int)pViewport->uViewportZ > *((float *)v10 + 20)
-          && (double)(signed int)pViewport->uViewportY <= *((float *)v10 + 21)
-          && (double)(signed int)pViewport->uViewportW > *((float *)v10 + 21) )
+        if ( (double)(signed int)pViewport->uViewportTL_X <= *((float *)v10 + 20)
+          && (double)(signed int)pViewport->uViewportBR_X > *((float *)v10 + 20)
+          && (double)(signed int)pViewport->uViewportTL_Y <= *((float *)v10 + 21)
+          && (double)(signed int)pViewport->uViewportBR_Y > *((float *)v10 + 21) )
           v16 = 1;
         ++v1;
         v10 += 16;
@@ -5844,8 +5844,8 @@
 draw:
     struct RenderVertexD3D3  v[6];
 
-    v[0].pos.x = pViewport->uScreenX;
-    v[0].pos.y = pViewport->uScreenY;
+    v[0].pos.x = pViewport->uScreen_TL_X;
+    v[0].pos.y = pViewport->uScreen_TL_Y;
     v[0].pos.z = 0.99989998;
     v[0].rhw = 1;
     v[0].diffuse = 0xFFFFFFFF;
@@ -5853,8 +5853,8 @@
     v[0].texcoord.x = 0;
     v[0].texcoord.y = 0;
     
-    v[1].pos.x = pViewport->uScreenX + pViewport->uScreenWidth;
-    v[1].pos.y = pViewport->uScreenY + pViewport->uScreenHeight;
+    v[1].pos.x = pViewport->uScreen_TL_X + pViewport->uScreenWidth;
+    v[1].pos.y = pViewport->uScreen_TL_Y + pViewport->uScreenHeight;
     v[1].pos.z = 0.99989998;
     v[1].rhw = 1;
     v[1].diffuse = 0xFFFFFFFF;
@@ -5862,8 +5862,8 @@
     v[1].texcoord.x = (float)pViewport->uScreenWidth / skybox_width;
     v[1].texcoord.y = (float)pViewport->uScreenHeight / skybox_height;
 
-    v[2].pos.x = pViewport->uScreenX + pViewport->uScreenWidth;
-    v[2].pos.y = pViewport->uScreenY;
+    v[2].pos.x = pViewport->uScreen_TL_X + pViewport->uScreenWidth;
+    v[2].pos.y = pViewport->uScreen_TL_Y;
     v[2].pos.z = 0.99989998;
     v[2].rhw = 1;
     v[2].diffuse = 0xFFFFFFFF;
@@ -5873,8 +5873,8 @@
 
     memcpy(&v[3], &v[0], sizeof(*v));
 
-    v[4].pos.x = pViewport->uScreenX;
-    v[4].pos.y = pViewport->uScreenY + pViewport->uScreenHeight;
+    v[4].pos.x = pViewport->uScreen_TL_X;
+    v[4].pos.y = pViewport->uScreen_TL_Y + pViewport->uScreenHeight;
     v[4].pos.z = 0.99989998;
     v[4].rhw = 1;
     v[4].diffuse = 0xFFFFFFFF;
@@ -6125,16 +6125,16 @@
   _this.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;
   _this.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;
 
-  array_50AC10[0].vWorldViewProjX = pViewport->uViewportX;
-  array_50AC10[0].vWorldViewProjY = pViewport->uViewportY;
-
-  array_50AC10[1].vWorldViewProjX = pViewport->uViewportX;
+  array_50AC10[0].vWorldViewProjX = pViewport->uViewportTL_X;
+  array_50AC10[0].vWorldViewProjY = pViewport->uViewportTL_Y;
+
+  array_50AC10[1].vWorldViewProjX = pViewport->uViewportTL_X;
   array_50AC10[1].vWorldViewProjY = v38;
 
-  array_50AC10[2].vWorldViewProjX = pViewport->uViewportZ;
-  array_50AC10[2].vWorldViewProjY = pViewport->uViewportY;
-
-  array_50AC10[3].vWorldViewProjX = pViewport->uViewportZ;
+  array_50AC10[2].vWorldViewProjX = pViewport->uViewportBR_X;
+  array_50AC10[2].vWorldViewProjY = pViewport->uViewportTL_Y;
+
+  array_50AC10[3].vWorldViewProjX = pViewport->uViewportBR_X;
   array_50AC10[3].vWorldViewProjY = v38;
 
   /*v36 = (double)(pViewport->uViewportZ - pViewport->uViewportX) * 0.5;
@@ -6445,7 +6445,7 @@
       v21 = abs(v19 >> 14);
       if ( v21 <= abs(X) )
         break;
-      if ( SLODWORD(v76) <= (signed int)pViewport->uViewportY )
+      if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y )
         break;
       v19 = v77;
       v20 = v79;
@@ -6565,7 +6565,7 @@
       v40 = abs(X);
       if ( abs((signed __int64)v65) <= v40 )
         break;
-      if ( SLODWORD(v76) <= (signed int)pViewport->uViewportY )
+      if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y )
         break;
       v39 = v78;
 LABEL_36:
@@ -12270,7 +12270,7 @@
 
 
 //----- (00442955) --------------------------------------------------------
-void DrawBook_Map_sub( unsigned int x, unsigned int y, unsigned int width, int height, int _48074 )
+void DrawBook_Map_sub( unsigned int tl_x, unsigned int tl_y, unsigned int br_x, int br_y, int _48074 )
     {
   int v5; // ebx@1
   int v6; // edi@1
@@ -12300,7 +12300,7 @@
   double v30; // st7@23
   signed __int64 v31; // qax@23
   unsigned short *v32; // edx@23
-  int v33; // esi@23
+  int textr_width; // esi@23
   signed int v34; // eax@23
   signed int v35; // ecx@23
   int v36; // esi@27
@@ -12342,42 +12342,51 @@
   unsigned int v72; // [sp-8h] [bp-4806Ch]@80
   signed int v73; // [sp-4h] [bp-48068h]@59
   unsigned __int16 v74; // [sp-4h] [bp-48068h]@79
-  unsigned short v75[131070]; // [sp+Ch] [bp-48058h]@23
+  unsigned short map_texture_16[147456]; // [sp+Ch] [bp-48058h]@23
   int v76; // [sp+4800Ch] [bp-58h]@23
   unsigned __int16 *v77; // [sp+48010h] [bp-54h]@27
-  unsigned __int16 *v78; // [sp+48014h] [bp-50h]@23
-  unsigned int v79; // [sp+48018h] [bp-4Ch]@1
-  unsigned int y_; // [sp+4801Ch] [bp-48h]@1
+  unsigned __int16 *pPalette_16; // [sp+48014h] [bp-50h]@23
+  unsigned int surfPitch; // [sp+48018h] [bp-4Ch]@1
+
   int v81; // [sp+48020h] [bp-44h]@23
-  unsigned int x_; // [sp+48024h] [bp-40h]@1
+  unsigned __int16* render16_data;
+  unsigned char* texture8_data;
+  unsigned char* curr_line;
+  int scale_increment;
+  int scaled_posX;
+  int scaled_posY;
+  int stepX_r;
+  int stepY_r;
+
+
   unsigned int teal; // [sp+48028h] [bp-3Ch]@8
   int v84; // [sp+4802Ch] [bp-38h]@1
-  int v85; // [sp+48030h] [bp-34h]@1
+  int screenCenter_X; // [sp+48030h] [bp-34h]@1
   int v86; // [sp+48034h] [bp-30h]@1
   int v87; // [sp+48038h] [bp-2Ch]@16
   unsigned int v88; // [sp+4803Ch] [bp-28h]@16
   int black; // [sp+48040h] [bp-24h]@8
-  int v90; // [sp+48044h] [bp-20h]@1
+  int screenCenterY; // [sp+48044h] [bp-20h]@1
   unsigned int i; // [sp+48048h] [bp-1Ch]@9
-  unsigned int v92; // [sp+4804Ch] [bp-18h]@16
+  unsigned int screenHeight; // [sp+4804Ch] [bp-18h]@16
   unsigned __int16 *v93; // [sp+48050h] [bp-14h]@16
-  signed int v94; // [sp+48054h] [bp-10h]@8
+  signed int screenWidth; // [sp+48054h] [bp-10h]@8
   unsigned int v95; // [sp+48058h] [bp-Ch]@16
   int v96; // [sp+4805Ch] [bp-8h]@10
   const void *v97; // [sp+48060h] [bp-4h]@16
   unsigned short *a4a; // [sp+4806Ch] [bp+8h]@85
   int a5a; // [sp+48070h] [bp+Ch]@86
 
-  x_ = x;
-  y_ = y;
-  v85 = (signed int)(x + width) >> 1;
-  v90 = (signed int)(y + height) >> 1;
-  v79 = pRenderer->uTargetSurfacePitch;
-  pRenderer->Clip_v2(x, y, width, height);
+  tl_x = tl_x;
+  tl_y = tl_y;
+  screenCenter_X = (signed int)(tl_x + br_x) >> 1;
+  screenCenterY = (signed int)(tl_y + br_y) >> 1;
+  surfPitch = pRenderer->uTargetSurfacePitch;
+  pRenderer->Clip_v2(tl_x, tl_y, br_x, br_y);
   v5 = viewparams->field_2C;
-  v6 = viewparams->sPartyPosX;
-  v86 = viewparams->sPartyPosX;
-  v84 = viewparams->sPartyPosZ;
+  v6 = viewparams->sViewCenterX;
+  v86 = viewparams->sViewCenterX;
+  v84 = viewparams->sViewCenterY;
   if ( viewparams->field_2C != 384 )
   {
     if ( viewparams->field_2C == 768 )
@@ -12396,92 +12405,52 @@
   }
   if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
   {
-    v94 = width - x_ + 1;
-    v92 = height - y_ + 1;
-    v93 = &pRenderer->pTargetSurface[x_ + y_ * v79];
-    v95 = (unsigned int)pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0;
-    v78 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
-    v87 = (1 << (pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2 + 16)) / v5;
+    screenWidth = br_x - tl_x + 1;
+    screenHeight = br_y - tl_y + 1;
+    render16_data = &pRenderer->pTargetSurface[tl_x + tl_y * surfPitch];
+    texture8_data = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0;
+    pPalette_16 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
+    scale_increment = (1 << (pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2 + 16)) / v5;
+
     v30 = (double)(1 << (16 - pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2));
-    black = 22528 / (v5 / 384);
-    teal = (unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16;
+
+
+    teal =               (unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16;
     v97 = (const void *)((unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16);
-    v96 = 32768 - black - v84;
-    v31 = (signed __int64)((double)v96 / v30);
-    v32 = v75;
-    v33 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth;
-    v34 = (int)v31 << 16;
-    v81 = (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30);
+
+    v32 = map_texture_16;
+    textr_width = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth;
+    stepY_r =            (int)(signed __int64)((double)(- v84 - 22528 / (v5 / 384)+ 32768) / v30) << 16;
+    v81 =   (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30);
     black = (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30);
-    v76 = v33;
-    v35 = v34 >> 16;
-    if ( v95 && (signed int)v92 > 0 )
-    {
-      v96 = v92;
-      do
-      {
-        v88 = 0;
-        if ( (signed int)v94 > 0 )
-        {
-          v36 = v95 + v35 * v76;
-          i = v94;
-          v88 = v94;
-          v37 = black;
-          v77 = (unsigned __int16 *)v36;
-          do
-          {
-            *(short *)v32 = v78[*((char *)v77 + v37)];//crash
-            ++v32;
-            v97 = (char *)v97 + v87;
-            v37 = (signed int)v97 >> 16;
-            --i;
-          }
-          while ( i );
-        }
-        v34 += v87;
-        v97 = (const void *)teal;
-        black = v81;
-        v32 += 2 * (v94 - v88);
-        v35 = v34 >> 16;
-        --v96;
-      }
-      while ( v96 );
-    }
-    v97 = &v75;
-    if ( (signed int)v92 > 0 )
-    {
-      v96 = v92;
-      v38 = 2 * (v79 - v94);
-      do
-      {
-        if ( (signed int)v94 > 0 )
-        {
-          v39 = v94;
-          v40 = (short *)v97;
-          v41 = (short *)v93;
-          v42 = v94 & 1;
-          v43 = v94 >> 1;
-          memcpy(v93, v97, 2 * (v94 >> 1));
-          v45 = &v40[2 * v43];
-          v44 = &v41[2 * v43];
-          v46 = v42;
-          v39 *= 2;
-          v93 = (unsigned __int16 *)((char *)v93 + v39);
-          v97 = (char *)v97 + v39;
-          while ( v46 )
-          {
-            *v44 = *v45;
-            ++v45;
-            ++v44;
-            --v46;
-          }
-          v6 = v86;
-        }
-        v93 = (unsigned __int16 *)((char *)v93 + v38);
-        --v96;
-      }
-      while ( v96 );
-    }
+
+    v76 = textr_width;
+    scaled_posY = stepY_r >> 16;
+    //nearest neiborhood scaling
+    if ( texture8_data)  
+    {
+     for(uint i=0; i<screenHeight;++i)
+         {
+         curr_line=&texture8_data[scaled_posY*textr_width];
+         stepX_r=teal;
+         for(uint j=0; j<screenWidth;++j)
+             {
+             scaled_posX=stepX_r>>16;
+             map_texture_16[i*screenWidth+j]=pPalette_16[*(curr_line+scaled_posX)];
+             stepX_r+=scale_increment;      
+             }
+         stepY_r+=scale_increment;
+         scaled_posY=stepY_r>>16;
+         }
+      }
+    //move visible square to render
+    for(uint i=0; i<screenHeight;++i)
+        {
+         if ( screenWidth > 0 )
+             {
+                memcpy((void*)&render16_data[surfPitch*i],(void*)&map_texture_16[i*screenWidth], screenWidth*2);
+             }
+        }
   }
   else
   {
@@ -12491,7 +12460,7 @@
 	  uNumBlueFacesInBLVMinimap = 0;
 	  v8 = pIndoor->pMapOutlines->uNumOutlines == 0;
 	  v9 = pIndoor->pMapOutlines->uNumOutlines < 0;
-	  v94 = 0;
+	  screenWidth = 0;
 	  if ( !(v9 | v8) )
 	  {
 		i = 0;
@@ -12506,8 +12475,8 @@
 			  {
 				if ( !(!(v96 & 0x80) && (v11 & 0x80u) == 0 ))
 				{
-					v96 = (signed int)v94 >> 3;
-					v13 = v94;
+					v96 = (signed int)screenWidth >> 3;
+					v13 = screenWidth;
 					*(short *)(v10 + 10) = v12 | 1;
 					pIndoor->_visible_outlines[v96] |= 1 << (7 - v13 % 8);
 				}
@@ -12520,29 +12489,29 @@
 				  v16 = v15->x;
 				  v17 = v15->y - v84;
 				  v93 = (unsigned __int16 *)(v16 - v6);
-				  v92 = v17;
+				  screenHeight = v17;
 				  v18 = &pIndoor->pVertices[*(short *)(v10 + 2)];
 				  v19 = v18->x;
 				  v20 = v18->y - v84;
 				  v95 = v19 - v6;
 				  v97 = (const void *)v20;
 				  v88 = (unsigned __int64)((v16 - v6) * (signed __int64)v5) >> 16;
-				  v87 = (unsigned __int64)((signed int)v92 * (signed __int64)v5) >> 16;
+				  v87 = (unsigned __int64)((signed int)screenHeight * (signed __int64)v5) >> 16;
 				  v93 = (unsigned __int16 *)((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16);
-				  v92 = (unsigned __int64)(v20 * (signed __int64)v5) >> 16;
+				  screenHeight = (unsigned __int64)(v20 * (signed __int64)v5) >> 16;
 				  pRenderer->Line2D(
-					v85 + v88,
-					v90 - v87,
-					v85 + ((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16),
-					v90 - v92,
+					screenCenter_X + v88,
+					screenCenterY - v87,
+					screenCenter_X + ((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16),
+					screenCenterY - screenHeight,
 					black);
 				  v7 = pIndoor->pMapOutlines;
 			  }
 		  }
-		  ++v94;
+		  ++screenWidth;
 		  i += 12;
 		}
-		while ( v94 < (signed int)v7->uNumOutlines );
+		while ( screenWidth < (signed int)v7->uNumOutlines );
 	  }
 	  v21 = 0;
 	  if ( (signed int)uNumBlueFacesInBLVMinimap > 0 )
@@ -12559,17 +12528,17 @@
 		  v28 = v24->y - v84;
 		  v29 = v25->y - v84;
 		  v93 = v27;
-		  v92 = v28;
+		  screenHeight = v28;
 		  v97 = (const void *)v29;
 		  v87 = (unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16;
 		  v88 = (unsigned __int64)(v28 * (signed __int64)v5) >> 16;
 		  i = (unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16;
 		  v95 = (unsigned __int64)(v29 * (signed __int64)v5) >> 16;
 		  pRenderer->Line2D(
-			v85 + ((unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16),
-			v90 - v88,
-			v85 + ((unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16),
-			v90 - v95,
+			screenCenter_X + ((unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16),
+			screenCenterY - v88,
+			screenCenter_X + ((unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16),
+			screenCenterY - v95,
 			teal);
 		  ++v21;
 		  if ( v21 >= (signed int)uNumBlueFacesInBLVMinimap )
@@ -12579,40 +12548,40 @@
 		v6 = v86;
 	  }
   }
-  v47 = ((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + v85 - 3;
+  v47 = ((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + screenCenter_X - 3;
   v81 = pParty->vPosition.y - v84;
   v97 = (const void *)((unsigned __int64)((pParty->vPosition.y - v84) * (signed __int64)v5) >> 16);
   v48 = 1;
-  v49 = v90 - (int)v97 - 3;
-  if ( v47 >= (signed int)x_ )
-  {
-    if ( v47 > (signed int)width )
-    {
-      if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + v85 - 6) > (signed int)width )
+  v49 = screenCenterY - (int)v97 - 3;
+  if ( v47 >= (signed int)tl_x )
+  {
+    if ( v47 > (signed int)br_x )
+    {
+      if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + screenCenter_X - 6) > (signed int)br_x )
         v48 = 0;
-      v47 = width;
-    }
-  }
-  else
-  {
-    if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + v85) < (signed int)x_ )
+      v47 = br_x;
+    }
+  }
+  else
+  {
+    if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + screenCenter_X) < (signed int)tl_x )
       v48 = 0;
-    v47 = x_;
-  }
-  if ( v49 >= (signed int)y_ )
-  {
-    if ( v49 > height )
-    {
-      if ( v90 - (signed int)v97 - 6 > height )
+    v47 = tl_x;
+  }
+  if ( v49 >= (signed int)tl_y )
+  {
+    if ( v49 > br_y )
+    {
+      if ( screenCenterY - (signed int)v97 - 6 > br_y )
         v48 = 0;
-      v49 = height;
-    }
-  }
-  else
-  {
-    if ( v90 - (signed int)v97 < (signed int)y_ )
+      v49 = br_y;
+    }
+  }
+  else
+  {
+    if ( screenCenterY - (signed int)v97 < (signed int)tl_y )
       v48 = 0;
-    v49 = y_;
+    v49 = tl_y;
   }
   if ( v48 == 1 )
   {
@@ -12672,17 +12641,17 @@
   v86 = result;
   if ( (signed int)uNumLevelDecorations > 0 )
   {
-    v94 = (unsigned int)&pLevelDecorations[0].vPosition;
+    screenWidth = (unsigned int)&pLevelDecorations[0].vPosition;
     do
     {
-      if ( *(char *)(v94 - 2) & 8 )
-      {
-        v53 = *(int *)(v94 + 4) - v84;
-        v93 = (unsigned __int16 *)(*(int *)v94 - v6);
-        v92 = v53;
-        v54 = ((unsigned __int64)((signed int)v93 * (signed __int64)v5) >> 16) + v85;
+      if ( *(char *)(screenWidth - 2) & 8 )
+      {
+        v53 = *(int *)(screenWidth + 4) - v84;
+        v93 = (unsigned __int16 *)(*(int *)screenWidth - v6);
+        screenHeight = v53;
+        v54 = ((unsigned __int64)((signed int)v93 * (signed __int64)v5) >> 16) + screenCenter_X;
         v97 = (const void *)((unsigned __int64)(v53 * (signed __int64)v5) >> 16);
-        v55 = v90 - (int)v97;
+        v55 = screenCenterY - (int)v97;
         if ( v54 >= pRenderer->field_1C_clipx )
         {
           if ( v54 <= pRenderer->field_24_width && v55 >= pRenderer->field_20_clipy && v55 <= pRenderer->field_28_height )
@@ -12702,9 +12671,9 @@
             }
             else
             {
-              v72 = v90 - (int)v97;
-              v71 = ((unsigned __int64)((signed int)v93 * (signed __int64)v5) >> 16) + v85;
-              v70 = v90 - (int)v97;
+              v72 = screenCenterY - (int)v97;
+              v71 = ((unsigned __int64)((signed int)v93 * (signed __int64)v5) >> 16) + screenCenter_X;
+              v70 = screenCenterY - (int)v97;
             }
             pRenderer->Line2D(v54, v70, v71, v72, v74);
           }
@@ -12712,15 +12681,15 @@
       }
       ++v95;
       result = v95;
-      v94 += 32;
+      screenWidth += 32;
     }
     while ( (signed int)v95 < (signed int)uNumLevelDecorations );
   }
   if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
   {
-    v90 = width - x_ + 1;
-    v95 = height - y_ + 1;
-    v77 = &pRenderer->pTargetSurface[x_ + y_ * v79];
+    screenCenterY = br_x - tl_x + 1;
+    v95 = br_y - tl_y + 1;
+    v77 = &pRenderer->pTargetSurface[tl_x + tl_y * surfPitch];
     v56 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2;
     black = (1 << (v56 + 16)) / v5;
     v57 = (double)(1 << (16 - v56));
@@ -12729,17 +12698,17 @@
     v60 = (int)v59 << 16;
     v97 = (const void *)((int)v59 << 16);
     v61 = (signed __int64)((double)(32768 - v58 - v84) / v57);
-    v78 = (unsigned __int16 *)(v60 >> 16);
+    pPalette_16 = (unsigned __int16 *)(v60 >> 16);
     v62 = (int)v61 << 16;
     teal = v60 >> 16;
     v63 = (signed __int16)v61;
-    a4a = v75;
+    a4a = map_texture_16;
     result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xCu, 0xCu, 0xCu);
-    v85 = 0;
-    for ( i = result; v85 < (signed int)v95; result = v85 )
+    screenCenter_X = 0;
+    for ( i = result; screenCenter_X < (signed int)v95; result = screenCenter_X )
     {
       a5a = 0;
-      if ( v90 > 0 )
+      if ( screenCenterY > 0 )
       {
         v96 = (v63 - 80) / 4;
         v64 = teal;
@@ -12750,7 +12719,7 @@
           {
             if ( pOutdoor->_47F097(v81, v96) )
             {
-              if ( !((a5a + v85) % 2) )
+              if ( !((a5a + screenCenter_X) % 2) )
                 *a4a = i;
             }
             else
@@ -12763,26 +12732,26 @@
           v64 = (signed int)v97 >> 16;
           ++a5a;
         }
-        while ( a5a < v90 );
+        while ( a5a < screenCenterY );
       }
       v62 += black;
       v97 = (const void *)v60;
-      a4a += v90 - a5a;
+      a4a += screenCenterY - a5a;
       v63 = v62 >> 16;
-      ++v85;
-      teal = (unsigned int)v78;
+      ++screenCenter_X;
+      teal = (unsigned int)pPalette_16;
     }
     v65 = v95;
-    v66 = v75;
+    v66 = map_texture_16;
     if ( (signed int)v95 > 0 )
     {
       v67 = v77;
-      result = 2 * (v79 - v90);
+      result = 2 * (surfPitch - screenCenterY);
       do
       {
-        if ( v90 > 0 )
-        {
-          v68 = v90;
+        if ( screenCenterY > 0 )
+        {
+          v68 = screenCenterY;
           do
           {
             v69 = *(short *)v66;
@@ -12802,188 +12771,7 @@
   }
 }
 
-//----- (00443219) --------------------------------------------------------
-void ViewingParams::_443219()
-    {
-  this->sPartyPosZ += 512;
-  _4432E7();
-}
-
-//----- (00443225) --------------------------------------------------------
-void ViewingParams::_443225()
-    {
-  this->sPartyPosX -= 512;
-  _4432E7();
-}
-
-//----- (00443231) --------------------------------------------------------
-void ViewingParams::_443231()
-    {
-  this->sPartyPosZ -= 512;
-   _4432E7();
-}
-
-//----- (0044323D) --------------------------------------------------------
-void ViewingParams::_44323D()
-    {
-  this->sPartyPosX += 512;
-   _4432E7();
-}
-
-//----- (00443249) --------------------------------------------------------
-void ViewingParams::_443249()
-    {
-  int v1; // edx@1
-
-  v1 = (unsigned __int64)((signed __int64)this->field_2C << 15) >> 16;
-  this->field_2C = v1;
-  if ( v1 < 384 )
-    this->field_2C = 384;
-  this->sPartyPosX = pParty->vPosition.x;
-  this->sPartyPosZ = pParty->vPosition.y;
-  _4432E7();
-}
-
-//----- (00443291) --------------------------------------------------------
-void ViewingParams::_443291()
-    {
-  int v1; // edx@1
-  int v2; // eax@1
-
-  v1 = 2 * this->field_2C;
-  v2 = 1536;
-  this->field_2C = v1;
-  if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
-    v2 = 3072;
-  if ( v1 > v2 )
-    this->field_2C = v2;
-  this->sPartyPosX = pParty->vPosition.x;
-  this->sPartyPosZ = pParty->vPosition.y;
-  _4432E7();
-}
-
-//----- (004432E7) --------------------------------------------------------
-void ViewingParams::_4432E7()
-    {
-  ViewingParams *v1; // esi@1
-  int v2; // ebx@1
-  signed int v3; // edx@1
-  int v4; // ecx@1
-  int v5; // edi@3
-  int v6; // eax@3
-  int v7; // eax@5
-  int result; // eax@7
-
-  v1 = this;
-  v2 = this->field_3A;
-  v3 = 88 >> this->field_2C / 384;
-  v4 = (44 - v3) << 9;
-  if ( v1->sPartyPosZ > v2 + v4 )
-    v1->sPartyPosZ = v2 + v4;
-
-  v5 = v1->field_38;
-  v6 = (v3 - 44) << 9;
-  if ( v1->sPartyPosX < v5 + v6 )
-    v1->sPartyPosX = v5 + v6;
-
-  v7 = v2 + v6;
-  if ( v1->sPartyPosZ < v7 )
-    v1->sPartyPosZ = v7;
-
-  result = v5 + v4;
-  if ( v1->sPartyPosX > v5 + v4 )
-    v1->sPartyPosX = result;
-}
-
-//----- (00443343) --------------------------------------------------------
-void ViewingParams::InitGrayPalette()
-    {
-  for  (unsigned short i=0; i<256; ++i)
-      pPalette[i]=GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(i, i, i);
-}
-
-//----- (00443365) --------------------------------------------------------
-int ViewingParams::_443365()
-{
-  ViewingParams *v1; // esi@1
-  __int16 *v2; // edi@3
-  Vec3_short_ *v3; // eax@4
-  unsigned int v4; // edx@4
-  signed int v5; // eax@8
-  Vec3_short_ *v6; // eax@12
-  signed int v7; // edi@12
-  signed int v8; // eax@16
-  char v9; // zf@20
-  int result; // eax@21
-  unsigned int v11; // [sp+4h] [bp-1Ch]@3
-  unsigned int *v12; // [sp+8h] [bp-18h]@3
-  unsigned int v13; // [sp+Ch] [bp-14h]@8
-  unsigned int v14; // [sp+10h] [bp-10h]@2
-  unsigned int v15; // [sp+14h] [bp-Ch]@2
-  unsigned int v16; // [sp+18h] [bp-8h]@2
-  unsigned int v17; // [sp+1Ch] [bp-4h]@2
-
-  v1 = this;
-  InitGrayPalette();
-  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-  {
-    v16 = 0x40000000u;
-    v14 = 0x40000000u;
-    v17 = 0xC0000000u;
-    v15 = 0xC0000000u;
-    if ( (signed int)pIndoor->pMapOutlines->uNumOutlines > 0 )
-    {
-      v2 = (__int16 *)(pIndoor->pMapOutlines->pOutlines);
-      v11 = pIndoor->pMapOutlines->uNumOutlines;
-      v12 = (uint *)pIndoor->pMapOutlines->pOutlines;
-      do
-      {
-        v3 = &pIndoor->pVertices[*v2];
-        v4 = v3->x;
-        if ( (signed int)v4 < (signed int)v16 )
-          v16 = v3->x;
-        if ( (signed int)v4 > (signed int)v17 )
-          v17 = v3->x;
-        v5 = v3->y;
-        v13 = v5;
-        if ( v5 < (signed int)v14 )
-          v14 = v4;
-        if ( v5 > (signed int)v15 )
-          v15 = v4;
-        v6 = &pIndoor->pVertices[v2[1]];
-        v7 = v6->x;
-        if ( v7 < (signed int)v16 )
-          v16 = v4;
-        if ( v7 > (signed int)v17 )
-          v17 = v4;
-        v8 = v6->y;
-        if ( v8 < (signed int)v14 )
-          v14 = v13;
-        if ( v8 > (signed int)v15 )
-          v15 = v13;
-        v2 = (__int16 *)(v12 + 3);
-        v9 = v11-- == 1;
-        v12 += 3;
-      }
-      while ( !v9 );
-    }
-    v1->uMinimapZoom = 1024;
-    v1->field_38 = (signed int)(v16 + v17) / 2;
-    v1->field_28 = 10;
-    result = (signed int)(v14 + v15) / 2;
-    v1->field_3A = result;
-  }
-  else
-  {
-    v1->field_38 = 0;
-    v1->field_3A = 0;
-    v1->uMinimapZoom = dword_576E2C;
-    result = dword_576E28;
-    v1->field_28 = dword_576E28;
-  }
-  v1->field_2C = 384;
-  return result;
-}
+
 
 
 //----- (00443801) --------------------------------------------------------
@@ -13573,11 +13361,9 @@
   int v1; // ebx@3
   int v2; // edi@3
   int v3; // eax@3
-  int v4; // esi@5
   int v5; // edi@6
   int v6; // eax@6
   int v7; // eax@6
-  BSPModel **v8; // ecx@6
   unsigned __int8 v9; // zf@7
   unsigned __int8 v10; // sf@7
   ODMFace *v11; // eax@9
@@ -13589,13 +13375,13 @@
   const char *v17; // [sp+4h] [bp-1Ch]@3
   unsigned int pY; // [sp+8h] [bp-18h]@3
   float v19; // [sp+Ch] [bp-14h]@1
-  int v20; // [sp+10h] [bp-10h]@1
+  int v20;
   int v21; // [sp+14h] [bp-Ch]@1
   unsigned int v22; // [sp+18h] [bp-8h]@8
   int pX; // [sp+1Ch] [bp-4h]@3
 
-  v20 = viewparams->sPartyPosX;
-  v21 = viewparams->sPartyPosZ;
+  v20 = viewparams->sViewCenterX;
+  v21 = viewparams->sViewCenterY;
   v19 = (double)viewparams->field_2C * 0.000015258789;
   if ( viewparams->field_2C == 384 )
   {
@@ -13610,29 +13396,25 @@
   LODWORD(v19) = (signed __int64)((double)v21 - (double)(signed int)(pY - 181) * v0);
   v2 = abs(v1 + 22528) / 512;
   v3 = abs((signed)LODWORD(v19) - 22528);
+  result = 0;
   if ( pOutdoor->_47F04C(v2, v3 / 512)
     && uCurrentlyLoadedLevelType == LEVEL_Outdoor
-    && (v4 = 0, v20 = 0, (signed int)v16 > 0) )
-  {
-    while ( 1 )
-    {
-      pX = *(int *)((char *)&pOutdoor->pBModels[v4].vBoundingCenter.x) - v1;
-      pY = *(int *)((char *)&pOutdoor->pBModels[v4].vBoundingCenter.y) - LODWORD(v19);
+    && (signed int)v16 > 0 )
+  {
+	for(int i = 0; i < pOutdoor->uNumBModels && !v17; i++)
+    {
+      pX = pOutdoor->pBModels[i].vBoundingCenter.x - v1;
+      pY = pOutdoor->pBModels[i].vBoundingCenter.y - LODWORD(v19);
       v5 = abs((signed)pY);
       v6 = abs((signed)pX);
       v7 = int_get_vector_length(v6, v5, 0);
-      v8 = &pOutdoor->pBModels;
-      if ( v7 < *(int *)((char *)&pOutdoor->pBModels[v4].sBoundingRadius) )
-      {
-        v9 = pOutdoor->pBModels[v4].uNumFaces == 0;
-        v10 = pOutdoor->pBModels[v4].uNumFaces < 0;
-        v21 = 0;
-        if ( !(v10 | v9) )
-        {
-          v22 = 0;
-          do
-          {
-            v11 = &v8[v4]->pFaces[v22 / 0x134];
+      if ( v7 < pOutdoor->pBModels[i].sBoundingRadius )
+      {
+        if ( pOutdoor->pBModels[i].uNumFaces > 0 )
+        {
+		  for(int j = 0; j < pOutdoor->pBModels[i].uNumFaces; j++)
+          {
+			v11 = &pOutdoor->pBModels[i].pFaces[j];//&v8[v4]->pFaces[v22 / 0x134];
             v12 = v11->sCogTriggeredID;
             if ( v12 )
             {
@@ -13647,26 +13429,11 @@
                 }
               }
             }
-            ++v21;
-            v8 = &pOutdoor->pBModels;
-            v22 += 308;
-          }
-          while ( v21 < pOutdoor->pBModels[v4].uNumFaces );
+          }
         }
         result = v17;
-        if ( v17 )
-          break;
-      }
-      ++v20;
-      v4 += 188;
-      if ( v20 >= (signed int)v16 )
-        goto LABEL_17;
-    }
-  }
-  else
-  {
-LABEL_17:
-    result = 0;
+      }
+    }
   }
   return result;
 }