changeset 692:066e2b29b30f

viewport.cpp added
author Gloval
date Sat, 16 Mar 2013 21:57:32 +0400
parents c93f29773f84
children e0a1fccc89b1
files Game.cpp Indoor.cpp IndoorCameraD3D.cpp Viewport.cpp Viewport.h Vis.cpp Weather.cpp mm7_1.cpp mm7_2.cpp mm7_3.cpp mm7_6.cpp
diffstat 11 files changed, 354 insertions(+), 352 deletions(-) [+]
line wrap: on
line diff
--- a/Game.cpp	Sat Mar 16 14:33:23 2013 +0200
+++ b/Game.cpp	Sat Mar 16 21:57:32 2013 +0400
@@ -1034,10 +1034,10 @@
     return false;
   }
 
-  if (uMouseX >= (signed int)pViewport->uScreenX &&
-      uMouseX <= (signed int)pViewport->uScreenZ &&
-      uMouseY >= (signed int)pViewport->uScreenY &&
-      uMouseY <= (signed int)pViewport->uScreenW)
+  if (uMouseX >= (signed int)pViewport->uScreen_TL_X &&
+      uMouseX <= (signed int)pViewport->uScreen_BR_X &&
+      uMouseY >= (signed int)pViewport->uScreen_TL_Y &&
+      uMouseY <= (signed int)pViewport->uScreen_BR_Y)
   {
     pVisInstance->PickMouse(fPickDepth, uMouseX, uMouseY, sprite_filter, face_filter);
 
--- a/Indoor.cpp	Sat Mar 16 14:33:23 2013 +0200
+++ b/Indoor.cpp	Sat Mar 16 21:57:32 2013 +0400
@@ -380,10 +380,10 @@
   _this.sRotationX = pParty->sRotationX;
   _this.sRotationY = pParty->sRotationY;
   _this.pRenderTarget = pRenderer->pTargetSurface;
-  _this.uViewportX = pViewport->uScreenX;
-  _this.uViewportY = pViewport->uScreenY;
-  _this.uViewportZ = pViewport->uScreenZ;
-  _this.uViewportW = pViewport->uScreenW;
+  _this.uViewportX = pViewport->uScreen_TL_X;
+  _this.uViewportY = pViewport->uScreen_TL_Y;
+  _this.uViewportZ = pViewport->uScreen_BR_X;
+  _this.uViewportW = pViewport->uScreen_BR_Y;
   _this.field_3C = pViewport->field_30;
 
   _this.uTargetWidth = 640;
--- a/IndoorCameraD3D.cpp	Sat Mar 16 14:33:23 2013 +0200
+++ b/IndoorCameraD3D.cpp	Sat Mar 16 21:57:32 2013 +0400
@@ -1064,7 +1064,7 @@
   if ( fov_x > fov )
     fov = fov_x;
   screenCenterX = (double)pViewport->uScreenCenterX;
-  screenCenterY = (double)(pViewport->uScreenCenterY - pViewport->uScreenY);
+  screenCenterY = (double)(pViewport->uScreenCenterY - pViewport->uScreen_TL_Y);
 }
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Viewport.cpp	Sat Mar 16 21:57:32 2013 +0400
@@ -0,0 +1,264 @@
+#include "Viewport.h"
+
+#include "Party.h"
+#include "VectorTypes.h"
+#include "Indoor.h"
+#include "Render.h"
+#include "mm7_data.h"
+
+
+//----- (004C0262) --------------------------------------------------------
+void Viewport::SetScreen( signed int sTL_X, signed int sTL_Y, signed int sBR_X, signed int sBR_Y )
+    {
+    unsigned int tl_x; // edx@1
+    unsigned int br_x; // esi@1
+    unsigned int tl_y; // edi@3
+    unsigned int br_y; // eax@3
+    int v10; // eax@7
+
+    tl_x = sTL_X;
+    br_x = sBR_X;
+    if ( sTL_X > sBR_X )
+        {
+        br_x = sBR_X ^ sTL_X ^ sBR_X;                           // swap x's
+        tl_x = br_x ^ sBR_X ^ sTL_X;
+        }
+    tl_y = sTL_Y;
+    br_y = sBR_Y;
+    if ( (signed int)sTL_Y > (signed int)sBR_Y )
+        {
+        br_y = sBR_Y ^ sTL_Y ^ sBR_Y;                           // swap y's 
+        tl_y = br_y ^ sBR_Y ^ sTL_Y;
+        }
+    this->uScreen_TL_X = tl_x;
+    this->uScreen_TL_Y = tl_y;
+    this->uScreen_BR_X = br_x;
+    this->uScreen_BR_Y = br_y;
+    this->uScreenWidth = br_x - tl_x + 1;
+    this->uScreenCenterX = (signed int)(br_x + tl_x) >> 1;
+    if ( pRenderer->pRenderD3D == 0 )
+        {
+        this->uScreenHeight = br_y - tl_y + 1;
+        this->uScreenCenterY = this->uScreen_BR_Y - ((unsigned __int64)(this->field_30 * (signed __int64)(br_y - tl_y + 1)) >> 16);
+        }
+    else
+        {
+        this->uScreenHeight = br_y - tl_y + 1;
+        this->uScreenCenterY = (signed int)(br_y + tl_y) >> 1;
+        }
+    SetViewport(this->uScreen_TL_X, this->uScreen_TL_Y, this->uScreen_BR_X, this->uScreen_BR_Y);
+    }
+
+//----- (004C02F8) --------------------------------------------------------
+void Viewport::_4C02F8(int a2)
+    {
+    this->field_30 = a2;
+    SetScreen(this->uScreen_TL_X, this->uScreen_TL_Y, this->uScreen_BR_X, this->uScreen_BR_Y);
+    }
+
+//----- (004C0312) --------------------------------------------------------
+void Viewport::SetViewport( signed int uX, signed int uY, signed int uZ, signed int uW )
+    {
+    unsigned int x; // ebx@1
+    unsigned int y; // edi@3
+    unsigned int z; // edx@5
+    unsigned int w; // eax@7
+
+    x = uX;
+    if ( uX < this->uScreen_TL_X )
+        x = this->uScreen_TL_X;
+    y = uY;
+    if ( uY < this->uScreen_TL_Y )
+        y = this->uScreen_TL_Y;
+    z = uZ;
+    if ( uZ > this->uScreen_BR_X )
+        z = this->uScreen_BR_X;
+    w = uW;
+    if ( uW > this->uScreen_BR_Y )
+        w = this->uScreen_BR_Y;
+    this->uViewportY = y;
+    this->uViewportX = x;
+    this->uViewportZ = z;
+    this->uViewportW = w;
+    }
+
+//----- (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) --------------------------------------------------------
+void 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;
+        v1->field_28 = dword_576E28;
+        }
+    v1->field_2C = 384;
+    }
\ No newline at end of file
--- a/Viewport.h	Sat Mar 16 14:33:23 2013 +0200
+++ b/Viewport.h	Sat Mar 16 21:57:32 2013 +0400
@@ -4,19 +4,19 @@
 #pragma pack(push, 1)
 struct Viewport
 {
-  void SetScreen(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW);
+  void SetScreen(signed int uX, signed int uY, signed int uZ, signed int uW);
   void _4C02F8(int a2);
-  void SetViewport(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW);
+  void SetViewport(signed int uX, signed int uY, signed int uZ, signed int uW);
 
 
-  unsigned int uScreenX;
-  unsigned int uScreenY;
-  unsigned int uScreenZ;
-  unsigned int uScreenW;
-  unsigned int uViewportX;
-  unsigned int uViewportY;
-  unsigned int uViewportZ;
-  unsigned int uViewportW;
+  signed int uScreen_TL_X;
+  signed int uScreen_TL_Y;
+  signed int uScreen_BR_X;
+  signed int uScreen_BR_Y;
+  signed int uViewportX;
+  signed int uViewportY;
+  signed int uViewportZ;
+  signed int uViewportW;
   int uScreenWidth;
   int uScreenHeight;
   int uScreenCenterX;
@@ -49,7 +49,7 @@
   void _44323D();
   void _443249();
   void  _4432E7();
-  int _443365();
+  void _443365();
 
 
 
@@ -57,10 +57,10 @@
   int uSomeY;
   int uSomeZ;
   int uSomeW;
-  unsigned int uScreenX;
-  unsigned int uScreenY;
-  unsigned int uScreenZ;
-  unsigned int uScreenW;
+  unsigned int uScreen_topL_X;
+  unsigned int uScreen_topL_Y;
+  unsigned int uScreen_BttmR_X;
+  unsigned int uScreen_BttmR_Y;
   int field_20;
   unsigned int uMinimapZoom;
   int field_28;
--- a/Vis.cpp	Sat Mar 16 14:33:23 2013 +0200
+++ b/Vis.cpp	Sat Mar 16 21:57:32 2013 +0400
@@ -1743,10 +1743,10 @@
        if (Vis_static_stru_F91E10.object_pointers[0]->actual_z > pBillboardRenderList[v3].actual_z)
          return 1;
     }
-    else if ((double)(pViewport->uScreenX) <= *(float *)&v35 &&
-             (double)pViewport->uScreenZ >= *(float *)&v35 &&
-             (double)pViewport->uScreenY <= *(float *)&v36 &&
-             (double)pViewport->uScreenW >= *(float *)&v36)
+    else if ((double)(pViewport->uScreen_TL_X) <= *(float *)&v35 &&
+             (double)pViewport->uScreen_BR_X >= *(float *)&v35 &&
+             (double)pViewport->uScreen_TL_Y <= *(float *)&v36 &&
+             (double)pViewport->uScreen_BR_Y >= *(float *)&v36)
       return 1;
       v40 = 0;
       v10 = (int)&pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[0].pos.y;
@@ -1757,13 +1757,13 @@
         v11 = *(float *)v10;
         v13 = *(float *)(v10 - 4);
         Vis_static_stru_F91E10.uNumPointers = 0;
-        if ( v13 >= (double)(pViewport->uScreenX))
+        if ( v13 >= (double)(pViewport->uScreen_TL_X))
         {
-          if ( v12 <= (double)pViewport->uScreenZ )
+          if ( v12 <= (double)pViewport->uScreen_BR_X )
           {
-            if ( v11 >= (double)pViewport->uScreenY )
+            if ( v11 >= (double)pViewport->uScreen_TL_Y )
             {
-              if ( v11 <= (double)pViewport->uScreenW )
+              if ( v11 <= (double)pViewport->uScreen_BR_Y )
               {
                 v14 = v11;
                 v15 = v12;
@@ -1811,10 +1811,10 @@
             v41 = v38;
           Vis_static_stru_F91E10.uNumPointers = 0;
           v23 = (v20 - v21) * 0.5;
-          if ( v23 < (double)(pViewport->uScreenX)
-            || v23 > (double)pViewport->uScreenZ
-            || (double)pViewport->uScreenY > v41
-            || (double)pViewport->uScreenW < v41
+          if ( v23 < (double)(pViewport->uScreen_TL_X)
+            || v23 > (double)pViewport->uScreen_BR_X
+            || (double)pViewport->uScreen_TL_Y > v41
+            || (double)pViewport->uScreen_BR_Y < v41
             || ((v25 = v23, CastPickRay(local_80, SLODWORD(v25), v41, fDepth), uCurrentlyLoadedLevelType != 1) ? 
              (PickOutdoorFaces_Mouse(fDepth, local_80, &Vis_static_stru_F91E10, &vis_face_filter, false)) : 
              (PickIndoorFaces_Mouse(fDepth, local_80, &Vis_static_stru_F91E10, &vis_face_filter)),
--- a/Weather.cpp	Sat Mar 16 14:33:23 2013 +0200
+++ b/Weather.cpp	Sat Mar 16 21:57:32 2013 +0400
@@ -49,13 +49,13 @@
   signed int v32; // [sp+28h] [bp-4h]@10
 
   v26 = this;
-  v25 = viewparams->uScreenZ;
-  v28 = viewparams->uScreenY;
+  v25 = viewparams->uScreen_BttmR_X;
+  v28 = viewparams->uScreen_topL_Y;
   v31 = 0;
   v1 = pRenderer->pTargetSurface;
-  v29 = viewparams->uScreenX;
-  v23 = viewparams->uScreenW;
-  v24 = viewparams->uScreenZ - viewparams->uScreenX;
+  v29 = viewparams->uScreen_topL_X;
+  v23 = viewparams->uScreen_BttmR_Y;
+  v24 = viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X;
   do
   {
     v2 = &v26->field_0[2 * v31];
@@ -177,8 +177,8 @@
 
   v1 = this;
   v2 = 0;
-  v3 = pViewport->uScreenZ - pViewport->uScreenX - 4;
-  v4 = pViewport->uScreenW - pViewport->uScreenY - 4;
+  v3 = pViewport->uScreen_BR_X - pViewport->uScreen_TL_X - 4;
+  v4 = pViewport->uScreen_BR_Y - pViewport->uScreen_TL_Y - 4;
   do
   {
     v1->field_0[2 * v2++] = LOWORD(pViewport->uViewportX) + rand() % v3;
@@ -211,11 +211,11 @@
   v10 = this;
   if ( this->bRenderSnow != 1 )
     return 0;
-  HIWORD(v3) = HIWORD(viewparams->uScreenX);
+  HIWORD(v3) = HIWORD(viewparams->uScreen_topL_X);
   v4 = 0;
-  screen_width = viewparams->uScreenZ - viewparams->uScreenX;
-  screen_x = viewparams->uScreenX;
-  screen_z_minus_4 = viewparams->uScreenZ - 4;
+  screen_width = viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X;
+  screen_x = viewparams->uScreen_topL_X;
+  screen_z_minus_4 = viewparams->uScreen_BttmR_X - 4;
 
   auto _this = this->field_0;
   while ( 1 )
--- a/mm7_1.cpp	Sat Mar 16 14:33:23 2013 +0200
+++ b/mm7_1.cpp	Sat Mar 16 21:57:32 2013 +0400
@@ -4063,10 +4063,10 @@
     if ( pRenderer->pRenderD3D )
     {
       v18 = pGame->pVisInstance->get_picked_object_zbuf_val();
-      if ( (signed int)pX < (signed int)pViewport->uScreenX
-        || (signed int)pX > (signed int)pViewport->uScreenZ
-        || (signed int)pY < (signed int)pViewport->uScreenY
-        || (signed int)pY > (signed int)pViewport->uScreenW )
+      if ( (signed int)pX < (signed int)pViewport->uScreen_TL_X
+        || (signed int)pX > (signed int)pViewport->uScreen_BR_X
+        || (signed int)pY < (signed int)pViewport->uScreen_TL_Y
+        || (signed int)pY > (signed int)pViewport->uScreen_BR_Y )
         v18 = -1;
       if ( v18 == -1 )
         //goto LABEL_61;
--- a/mm7_2.cpp	Sat Mar 16 14:33:23 2013 +0200
+++ b/mm7_2.cpp	Sat Mar 16 21:57:32 2013 +0400
@@ -2884,87 +2884,6 @@
 }
 
 
-//----- (004C0262) --------------------------------------------------------
-void Viewport::SetScreen(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW)
-{
-  unsigned int x; // edx@1
-  unsigned int z; // esi@1
-  unsigned int y; // edi@3
-  unsigned int w; // eax@3
-  char no_3d; // zf@5
-  int v10; // eax@7
-
-  x = uX;
-  z = uZ;
-  if ( (signed int)uX > (signed int)uZ )
-  {
-    z = uZ ^ uX ^ uZ;                           // swap x and z
-    x = z ^ uZ ^ uX;
-  }
-  y = uY;
-  w = uW;
-  if ( (signed int)uY > (signed int)uW )
-  {
-    w = uW ^ uY ^ uW;                           // swap y and w
-    y = w ^ uW ^ uY;
-  }
-  this->uScreenX = x;
-  this->uScreenY = y;
-  this->uScreenZ = z;
-  this->uScreenW = w;
-  no_3d = pRenderer->pRenderD3D == 0;
-  this->uScreenWidth = z - x + 1;
-  this->uScreenCenterX = (signed int)(z + x) >> 1;
-  if ( no_3d )
-  {
-    v10 = w - y + 1;
-    this->uScreenHeight = v10;
-    this->uScreenCenterY = this->uScreenW - ((unsigned __int64)(this->field_30 * (signed __int64)v10) >> 16);
-  }
-  else
-  {
-    this->uScreenHeight = w - y + 1;
-    this->uScreenCenterY = (signed int)(w + y) >> 1;
-  }
-  SetViewport(this->uScreenX, this->uScreenY, this->uScreenZ, this->uScreenW);
-}
-
-//----- (004C02F8) --------------------------------------------------------
-void Viewport::_4C02F8(int a2)
-{
-  unsigned int v2; // ST0C_4@1
-
-  v2 = this->uScreenW;
-  this->field_30 = a2;
-  SetScreen(this->uScreenX, this->uScreenY, this->uScreenZ, v2);
-}
-
-//----- (004C0312) --------------------------------------------------------
-void Viewport::SetViewport(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW)
-{
-  unsigned int x; // ebx@1
-  unsigned int y; // edi@3
-  unsigned int z; // edx@5
-  unsigned int w; // eax@7
-
-  x = uX;
-  if ( (signed int)uX < (signed int)this->uScreenX )
-    x = this->uScreenX;
-  y = uY;
-  if ( (signed int)uY < (signed int)this->uScreenY )
-    y = this->uScreenY;
-  z = uZ;
-  if ( (signed int)uZ > (signed int)this->uScreenZ )
-    z = this->uScreenZ;
-  w = uW;
-  if ( (signed int)uW > (signed int)this->uScreenW )
-    w = this->uScreenW;
-  this->uViewportY = y;
-  this->uViewportX = x;
-  this->uViewportZ = z;
-  this->uViewportW = w;
-}
-
 
 
 
@@ -9834,8 +9753,8 @@
   pIndoorCamera = new IndoorCamera;
   pIndoorCamera->Initialize(
     65,
-    viewparams->uScreenZ - viewparams->uScreenX + 1,
-    viewparams->uScreenW - viewparams->uScreenY + 1);
+    viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X + 1,
+    viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y + 1);
 
   InitializeTurnBasedAnimations(&stru_50C198);
   pBitmaps_LOD->dword_11B84 = pBitmaps_LOD->uNumLoadedFiles;
@@ -11196,10 +11115,10 @@
   //_getcwd(v5, 120);
   //sprintfex(pIniFilename, "%s\\mm6.ini", v5);
   viewparams = new ViewingParams;
-  viewparams->uScreenX = GetPrivateProfileIntW(L"screen", L"vx1", 8, pIniFilename);
-  viewparams->uScreenY = GetPrivateProfileIntW(L"screen", L"vy1", 8, pIniFilename);
-  viewparams->uScreenZ = GetPrivateProfileIntW(L"screen", L"vx2", 468, pIniFilename);
-  viewparams->uScreenW = GetPrivateProfileIntW(L"screen", L"vy2", 351, pIniFilename);
+  viewparams->uScreen_topL_X = GetPrivateProfileIntW(L"screen", L"vx1", 8, pIniFilename);
+  viewparams->uScreen_topL_Y = GetPrivateProfileIntW(L"screen", L"vy1", 8, pIniFilename);
+  viewparams->uScreen_BttmR_X = GetPrivateProfileIntW(L"screen", L"vx2", 468, pIniFilename);
+  viewparams->uScreen_BttmR_Y = GetPrivateProfileIntW(L"screen", L"vy2", 351, pIniFilename);
 
 
   pAudioPlayer = new AudioPlayer;
@@ -11352,12 +11271,12 @@
     LOBYTE(viewparams->field_20) = 0;
   }
   pParty->uFlags |= 2u;
-  viewparams->uSomeY = viewparams->uScreenY;
-  viewparams->uSomeX = viewparams->uScreenX;
-  viewparams->uSomeZ = viewparams->uScreenZ;
-  viewparams->uSomeW = viewparams->uScreenW;
-
-  pViewport->SetScreen(viewparams->uScreenX, viewparams->uScreenY, viewparams->uScreenZ, viewparams->uScreenW);
+  viewparams->uSomeY = viewparams->uScreen_topL_Y;
+  viewparams->uSomeX = viewparams->uScreen_topL_X;
+  viewparams->uSomeZ = viewparams->uScreen_BttmR_X;
+  viewparams->uSomeW = viewparams->uScreen_BttmR_Y;
+
+  pViewport->SetScreen(viewparams->uScreen_topL_X, viewparams->uScreen_topL_Y, viewparams->uScreen_BttmR_X, viewparams->uScreen_BttmR_Y);
   if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
     pOutdoorCamera->_485F64();
 }
@@ -12685,15 +12604,15 @@
       DoInteractionWithTopmostZObject((unsigned __int16)v1, (signed int)(unsigned __int16)v1 >> 3);
   }
   v22 = 0;
-  v1 = (int *)((signed int)(viewparams->uScreenZ + viewparams->uScreenX) >> 1);
-  if ( (signed int)viewparams->uScreenY < (signed int)viewparams->uScreenW )
+  v1 = (int *)((signed int)(viewparams->uScreen_BttmR_X + viewparams->uScreen_topL_X) >> 1);
+  if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y )
   {
 	  v2 = (char *)v1 - 50;
 	  v1 = (int *)((char *)v1 + 50);
-	  v3 = 640 * viewparams->uScreenY;
+	  v3 = 640 * viewparams->uScreen_topL_Y;
 	  v17 = v2;
 	  v20 = v1;
-	  v18 = ((viewparams->uScreenW - viewparams->uScreenY - 1) >> 1) + 1;
+	  v18 = ((viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y - 1) >> 1) + 1;
 	  do
 	  {
 		if ( (signed int)v2 < (signed int)v20 )
@@ -12979,12 +12898,12 @@
   else
   {
     v16 = 0;
-    v4 = viewparams->uScreenX;
-    v12 = viewparams->uScreenZ;
-    if ( (signed int)viewparams->uScreenY < (signed int)viewparams->uScreenW )
-    {
-      v15 = &pRenderer->pActiveZBuffer[viewparams->uScreenX + 640 * viewparams->uScreenY];
-      v13 = ((viewparams->uScreenW - viewparams->uScreenY - 1) >> 1) + 1;
+    v4 = viewparams->uScreen_topL_X;
+    v12 = viewparams->uScreen_BttmR_X;
+    if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y )
+    {
+      v15 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y];
+      v13 = ((viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y - 1) >> 1) + 1;
       do
       {
         if ( (signed int)v4 < (signed int)v12 )
@@ -13225,8 +13144,8 @@
   int v32; // [sp+20h] [bp-4h]@1
 
   v0 = 0;
-  v1 = (signed int)(viewparams->uScreenW + viewparams->uScreenY) >> 1;
-  v2 = (signed int)(viewparams->uScreenX + viewparams->uScreenZ) >> 1;
+  v1 = (signed int)(viewparams->uScreen_BttmR_Y + viewparams->uScreen_topL_Y) >> 1;
+  v2 = (signed int)(viewparams->uScreen_topL_X + viewparams->uScreen_BttmR_X) >> 1;
   v3 = v1 - 50;
   v32 = 0;
   v4 = 100;
--- a/mm7_3.cpp	Sat Mar 16 14:33:23 2013 +0200
+++ b/mm7_3.cpp	Sat Mar 16 21:57:32 2013 +0400
@@ -5864,8 +5864,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;
@@ -5873,8 +5873,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;
@@ -5882,8 +5882,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;
@@ -5893,8 +5893,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;
@@ -12822,188 +12822,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) --------------------------------------------------------
--- a/mm7_6.cpp	Sat Mar 16 14:33:23 2013 +0200
+++ b/mm7_6.cpp	Sat Mar 16 21:57:32 2013 +0400
@@ -7897,13 +7897,13 @@
     v30 = 0;
     if ( pRenderer->pActiveZBuffer )
     {
-      v29 = viewparams->uScreenX;
-      v23 = viewparams->uScreenZ;
-      if ( (signed int)viewparams->uScreenY < (signed int)viewparams->uScreenW )
+      v29 = viewparams->uScreen_topL_X;
+      v23 = viewparams->uScreen_BttmR_X;
+      if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y )
       {
-        v25 = viewparams->uScreenW - viewparams->uScreenY;
-        v9 = &pRenderer->pActiveZBuffer[viewparams->uScreenX + 640 * viewparams->uScreenY];
-        v26 = &pRenderer->pActiveZBuffer[viewparams->uScreenX + 640 * viewparams->uScreenY];
+        v25 = viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y;
+        v9 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y];
+        v26 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y];
         do
         {
           if ( (signed int)v29 < (signed int)v23 )