changeset 693:e0a1fccc89b1

map render fixes
author Gloval
date Sun, 17 Mar 2013 01:50:34 +0400
parents 066e2b29b30f
children 52329962fcdb
files GUIWindow.cpp Game.cpp IndoorCameraD3D.cpp ParticleEngine.cpp Render.cpp Viewport.cpp Viewport.h Weather.cpp mm7_1.cpp mm7_2.cpp mm7_3.cpp mm7_4.cpp mm7_5.cpp mm7_6.cpp mm7_data.h stru6.cpp
diffstat 16 files changed, 488 insertions(+), 525 deletions(-) [+]
line wrap: on
line diff
--- a/GUIWindow.cpp	Sat Mar 16 21:57:32 2013 +0400
+++ b/GUIWindow.cpp	Sun Mar 17 01:50:34 2013 +0400
@@ -548,10 +548,10 @@
       pTex_tab_an_7b__zoot_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7b", TEXTURE_16BIT_PALETTE)];
       pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
       pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7a", TEXTURE_16BIT_PALETTE)];
-      pBtn_Book_1 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 1, pTex_tab_an_6b__zoom_on->uTextureWidth,
+      pBtn_Book_1 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, pTex_tab_an_6b__zoom_on->uTextureWidth,
           pTex_tab_an_6b__zoom_on->uTextureHeight, 1, 0, 0x47u, 0xBu, 0, pGlobalTXT_LocalizationStrings[192],// "Scroll Up"
           pTex_tab_an_6b__zoom_on, 0);
-      pBtn_Book_2 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 38, pTex_tab_an_7b__zoot_on->uTextureHeight,
+      pBtn_Book_2 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, pTex_tab_an_7b__zoot_on->uTextureHeight,
           pTex_tab_an_7b__zoot_on->uTextureHeight, 1, 0, 0x47u, 0xAu, 0, pGlobalTXT_LocalizationStrings[193],// "Scroll Down"
           pTex_tab_an_7b__zoot_on, 0);
       awards_count = 0;
@@ -590,21 +590,21 @@
       pTexture_506370 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-4a", TEXTURE_16BIT_PALETTE)];
       pTexture_50636C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-8b", TEXTURE_16BIT_PALETTE)];
       pTexture_506368 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-8a", TEXTURE_16BIT_PALETTE)];
-      pBtn_Book_1 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 1, 0x32u, 0x22u, 1, 0, 0x47u, 0xBu, 0,
+      pBtn_Book_1 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, 0x32u, 0x22u, 1, 0, 0x47u, 0xBu, 0,
           pGlobalTXT_LocalizationStrings[193], pTex_tab_an_6b__zoom_on, 0);
-      pBtn_Book_2 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 38, 0x32u, 0x22u, 1, 0, 0x47u, 0xAu, 0,
+      pBtn_Book_2 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, 0x32u, 0x22u, 1, 0, 0x47u, 0xAu, 0,
           pGlobalTXT_LocalizationStrings[192], pTex_tab_an_7b__zoot_on, 0);
-      pBtn_Book_3 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 113, 0x32u, 0x22u, 1, 0, 0x47u, 2u, 0,
+      pBtn_Book_3 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, 0x32u, 0x22u, 1, 0, 0x47u, 2u, 0,
           pGlobalTXT_LocalizationStrings[85], pTexture_506394, 0);// "Potion Notes"
-      pBtn_Book_4 = v1->CreateButton(pViewport->uViewportX + 399, pViewport->uViewportY + 150, 0x32u, 0x22u, 1, 0, 0x47u, 3u, 0,
+      pBtn_Book_4 = v1->CreateButton(pViewport->uViewportTL_X + 399, pViewport->uViewportTL_Y + 150, 0x32u, 0x22u, 1, 0, 0x47u, 3u, 0,
           pGlobalTXT_LocalizationStrings[137], pTexture_50638C, 0);// "Fountain Notes"
-      pBtn_Book_5 = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 188, 0x32u, 0x22u, 1, 0, 0x47u, 4u, 0,
+      pBtn_Book_5 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, 0x32u, 0x22u, 1, 0, 0x47u, 4u, 0,
           pGlobalTXT_LocalizationStrings[8], pTexture_506384, 0);// "Obelisk Notes"
-      pBtn_Book_6 = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 226, 0x32u, 0x22u, 1, 0, 0x47u, 5u, 0,
+      pBtn_Book_6 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, 0x32u, 0x22u, 1, 0, 0x47u, 5u, 0,
           pGlobalTXT_LocalizationStrings[141], pTexture_50637C, 0);// "Seer Notes"
-      pBtn_Autonotes_Misc = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 264, 0x32u, 0x22u, 1, 0, 0x47u, 6u, 0,
+      pBtn_Autonotes_Misc = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 264, 0x32u, 0x22u, 1, 0, 0x47u, 6u, 0,
           pGlobalTXT_LocalizationStrings[123], pTexture_506374, 0);// "Miscellaneous Notes"
-      v9 = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 302, 0x32u, 0x22u, 1, 0, 0x47u, 7u, 0,
+      v9 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 302, 0x32u, 0x22u, 1, 0, 0x47u, 7u, 0,
           pGlobalTXT_LocalizationStrings[662], pTexture_50636C, 0);// "Instructors"
       v10 = dword_506528;
       pBtn_Autonotes_Instructors = v9;
@@ -644,17 +644,17 @@
       pTexture_506380 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabEoff", TEXTURE_16BIT_PALETTE)];
       pTexture_50637C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabWon", TEXTURE_16BIT_PALETTE)];
       pTexture_506378 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabWoff", TEXTURE_16BIT_PALETTE)];
-      pBtn_Book_1 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 1, 0x32u, 0x22u, 1, 0, 0x47u, 0, 0,
+      pBtn_Book_1 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, 0x32u, 0x22u, 1, 0, 0x47u, 0, 0,
           pGlobalTXT_LocalizationStrings[251], pTex_tab_an_6b__zoom_on, 0);// "Zoom In"
-      pBtn_Book_2 = v1->CreateButton(pViewport->uViewportX + 398, pViewport->uViewportY + 38, 0x32u, 0x22u, 1, 0, 0x47u, 1, 0,
+      pBtn_Book_2 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, 0x32u, 0x22u, 1, 0, 0x47u, 1, 0,
           pGlobalTXT_LocalizationStrings[252], pTex_tab_an_7b__zoot_on, 0);// "Zoom Out"
-      pBtn_Book_3 = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 113, 0x32u, 0x22u, 1, 0, 0x47u, 2, 0,
+      pBtn_Book_3 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 113, 0x32u, 0x22u, 1, 0, 0x47u, 2, 0,
           pGlobalTXT_LocalizationStrings[192], (Texture *)"", 0);// Scroll Up
-      pBtn_Book_4 = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 150, 0x32u, 0x22u, 1, 0, 0x47u, 3, 0,
+      pBtn_Book_4 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 150, 0x32u, 0x22u, 1, 0, 0x47u, 3, 0,
           pGlobalTXT_LocalizationStrings[193], (Texture *)"", 0);// Scroll Down
-      pBtn_Book_5 = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 188, 0x32u, 0x22u, 1, 0, 0x47u, 4, 0,
+      pBtn_Book_5 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, 0x32u, 0x22u, 1, 0, 0x47u, 4, 0,
           pGlobalTXT_LocalizationStrings[573], (Texture *)"", 0);// "Scroll Right"
-      pBtn_Book_6 = v1->CreateButton(pViewport->uViewportX + 397, pViewport->uViewportY + 226, 0x32u, 0x22u, 1, 0, 0x47u, 5, 0,
+      pBtn_Book_6 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, 0x32u, 0x22u, 1, 0, 0x47u, 5, 0,
           pGlobalTXT_LocalizationStrings[572], (Texture *)"", 0);// "Scroll Left"
       }
       break;
@@ -675,8 +675,8 @@
       pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
       pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7a", TEXTURE_16BIT_PALETTE)];
       pBtn_Book_1 = v1->CreateButton(
-          pViewport->uViewportX + 398,
-          pViewport->uViewportY + 1,
+          pViewport->uViewportTL_X + 398,
+          pViewport->uViewportTL_Y + 1,
           pTex_tab_an_6b__zoom_on->uTextureWidth,
           pTex_tab_an_6b__zoom_on->uTextureHeight,
           1,
@@ -688,8 +688,8 @@
           pTex_tab_an_6b__zoom_on,
           0);
       pBtn_Book_2 = v1->CreateButton(
-          pViewport->uViewportX + 398,
-          pViewport->uViewportY + 38,
+          pViewport->uViewportTL_X + 398,
+          pViewport->uViewportTL_Y + 38,
           pTex_tab_an_7b__zoot_on->uTextureHeight,
           pTex_tab_an_7b__zoot_on->uTextureHeight,
           1,
@@ -782,10 +782,10 @@
   v3 = this;
   if ( arg0 )
   {
-    v4 = pViewport->uViewportX;
-    v5 = pViewport->uViewportZ;
-    v2 = pViewport->uViewportY;
-    v22 = pViewport->uViewportW;
+    v4 = pViewport->uViewportTL_X;
+    v5 = pViewport->uViewportBR_X;
+    v2 = pViewport->uViewportTL_Y;
+    v22 = pViewport->uViewportBR_Y;
   }
   else
   {
@@ -972,8 +972,8 @@
       continue;
 		v4= pPlayer->lastOpenedSpellbookPage;
       //v4 = (12 * pPlayer->lastOpenedSpellbookPage + pSpellbookSpellIndices[pPlayer->lastOpenedSpellbookPage][i + 1]);
-      CreateButton(pViewport->uViewportX +  pIconPos[v4][pSpellbookSpellIndices[v4][i+1]].Xpos,
-                   pViewport->uViewportY +  pIconPos[v4][pSpellbookSpellIndices[v4][i+1]].Ypos,  //dword_4E20D0
+      CreateButton(pViewport->uViewportTL_X +  pIconPos[v4][pSpellbookSpellIndices[v4][i+1]].Xpos,
+                   pViewport->uViewportTL_Y +  pIconPos[v4][pSpellbookSpellIndices[v4][i+1]].Ypos,  //dword_4E20D0
                    dword_506408[i + 1]->uTextureWidth,
                    dword_506408[i + 1]->uTextureHeight,
                    1, 79, 0x56u, i, 0, "", 0);
--- a/Game.cpp	Sat Mar 16 21:57:32 2013 +0400
+++ b/Game.cpp	Sun Mar 17 01:50:34 2013 +0400
@@ -142,8 +142,8 @@
     if (v4)
     {
       if ( !PauseGameDrawing() && pRenderer->pRenderD3D) // clear game viewport with transparent color
-        pRenderer->FillRectFast(pViewport->uViewportX, pViewport->uViewportY, pViewport->uViewportZ - pViewport->uViewportX,
-                                pViewport->uViewportW - pViewport->uViewportY + 1,
+        pRenderer->FillRectFast(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pViewport->uViewportBR_X - pViewport->uViewportTL_X,
+                                pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1,
                                 pRenderer->uTargetGMask | pRenderer->uTargetBMask);
       viewparams->field_48 = 0;
     }
--- a/IndoorCameraD3D.cpp	Sat Mar 16 21:57:32 2013 +0400
+++ b/IndoorCameraD3D.cpp	Sun Mar 17 01:50:34 2013 +0400
@@ -674,10 +674,10 @@
     }
     else
     {
-      if ( (double)(signed int)pViewport->uViewportX <= vert[0].vWorldViewProjX - 1.0
-        && (double)(signed int)pViewport->uViewportZ > vert[0].vWorldViewProjX + 2.0
-        && (double)(signed int)pViewport->uViewportY <= vert[0].vWorldViewProjY - 1.0
-        && (double)(signed int)pViewport->uViewportW > vert[0].vWorldViewProjY + 2.0
+      if ( (double)(signed int)pViewport->uViewportTL_X <= vert[0].vWorldViewProjX - 1.0
+        && (double)(signed int)pViewport->uViewportBR_X > vert[0].vWorldViewProjX + 2.0
+        && (double)(signed int)pViewport->uViewportTL_Y <= vert[0].vWorldViewProjY - 1.0
+        && (double)(signed int)pViewport->uViewportBR_Y > vert[0].vWorldViewProjY + 2.0
         && uNumD3DVertices > 0 )
       {
         v13 = (char *)&pD3DVertices[0].diffuse;
@@ -1609,7 +1609,7 @@
       v7 = 1.0 / pVertices[i].vWorldViewPosition.x;
 
       pVertices[i].vWorldViewProjX = pVertices[i].vWorldViewPosition.y * fov * v7 + screenCenterX;
-      pVertices[i].vWorldViewProjY = (signed int)pViewport->uViewportW - (pVertices[i].vWorldViewPosition.z * fov * v7 + screenCenterY);
+      pVertices[i].vWorldViewProjY = (signed int)pViewport->uViewportBR_Y - (pVertices[i].vWorldViewPosition.z * fov * v7 + screenCenterY);
     }
     else
     {
@@ -1620,12 +1620,12 @@
       if ( a4 )
       {
 //        __debugbreak();
-        v8 = (double)(signed int)pViewport->uViewportZ;
+        v8 = (double)(signed int)pViewport->uViewportBR_X;
         if ( v8 >= pVertices[i].vWorldViewProjX )
           v9 = pVertices[i].vWorldViewProjX;
         else
           v9 = v8;
-        v10 = (double)(signed int)pViewport->uViewportX;
+        v10 = (double)(signed int)pViewport->uViewportTL_X;
         if ( v10 <= v9 )
         {
           if ( v8 >= pVertices[i].vWorldViewProjX)
@@ -1637,12 +1637,12 @@
           v8 = uNumVerticesa;
         }
         pVertices[i].vWorldViewProjX = v8;
-        v11 = (double)(signed int)pViewport->uViewportW;
+        v11 = (double)(signed int)pViewport->uViewportBR_Y;
         if ( v11 >= pVertices[i].vWorldViewProjY)
           v12 = pVertices[i].vWorldViewProjY;
         else
           v12 = v11;
-        v13 = (double)(signed int)pViewport->uViewportY;
+        v13 = (double)(signed int)pViewport->uViewportTL_Y;
         if ( v13 <= v12 )
         {
           if ( v11 >= pVertices[i].vWorldViewProjY)
@@ -1678,7 +1678,7 @@
     *a5 = floorf(a2a + 0.5f);
     a2b = (double)z * fov * v6 + screenCenterY;
     //v8 = a2b + 6.7553994e15;
-    *a6 = pViewport->uViewportW - floorf(a2b + 0.5f);
+    *a6 = pViewport->uViewportBR_Y - floorf(a2b + 0.5f);
   }
   else
   {
--- a/ParticleEngine.cpp	Sat Mar 16 21:57:32 2013 +0400
+++ b/ParticleEngine.cpp	Sun Mar 17 01:50:34 2013 +0400
@@ -577,14 +577,14 @@
       v6->_screenspace_scale = (unsigned __int64)(_48B561_mess_with_scaling_along_z(/*v34, */v35) * (signed __int64)v6->_screenspace_scale) >> 16;
       v6->sZValue = X_4;
       v36 = v6->uScreenSpaceX;
-      if ( v36 >= (signed int)pViewport->uViewportX )
+      if ( v36 >= (signed int)pViewport->uViewportTL_X )
       {
-        if ( v36 < (signed int)pViewport->uViewportZ )
+        if ( v36 < (signed int)pViewport->uViewportBR_X )
         {
           v37 = v6->uScreenSpaceY;
-          if ( v37 >= (signed int)pViewport->uViewportY )
+          if ( v37 >= (signed int)pViewport->uViewportTL_Y )
           {
-            if ( v37 < (signed int)pViewport->uViewportW )
+            if ( v37 < (signed int)pViewport->uViewportBR_Y )
               return 1;
           }
         }
@@ -686,10 +686,10 @@
                        v11 = 30;
                     v12 = p->uScreenSpaceY - v11;
                     v13 = p->uScreenSpaceX - (v11 >> 1);
-                     if ( v13 + v11 < (signed int)pViewport->uViewportX
-                       || v13 >= (signed int)pViewport->uViewportZ
-                       || v12 + v11 < (signed int)pViewport->uViewportY
-                       || v12 >= (signed int)pViewport->uViewportW )
+                     if ( v13 + v11 < (signed int)pViewport->uViewportTL_X
+                       || v13 >= (signed int)pViewport->uViewportBR_X
+                       || v12 + v11 < (signed int)pViewport->uViewportTL_Y
+                       || v12 >= (signed int)pViewport->uViewportBR_Y )
                      {
                       ;
                      }
@@ -801,10 +801,10 @@
             v10 = 30;
           v11 = *(_DWORD *)(v7 - 18) - (v10 >> 1);
           v12 = *(_DWORD *)(v7 - 14) - v10;
-          if ( v11 + v10 < pViewport->uViewportX
-            || v11 >= pViewport->uViewportZ
-            || *(_DWORD *)(v7 - 14) < pViewport->uViewportY
-            || v12 >= (signed int)pViewport->uViewportW )
+          if ( v11 + v10 < pViewport->uViewportTL_X
+            || v11 >= pViewport->uViewportBR_X
+            || *(_DWORD *)(v7 - 14) < pViewport->uViewportTL_Y
+            || v12 >= (signed int)pViewport->uViewportBR_Y )
           {
             ;
           }
--- a/Render.cpp	Sat Mar 16 21:57:32 2013 +0400
+++ b/Render.cpp	Sun Mar 17 01:50:34 2013 +0400
@@ -332,7 +332,7 @@
           v5 = v4->pTexture;
           if ( v5 )
           {
-            if ( v3->field_8 >= (signed int)pViewport->uViewportX || v3->field_C != pViewport->uViewportX )
+            if ( v3->field_8 >= (signed int)pViewport->uViewportTL_X || v3->field_C != pViewport->uViewportTL_X )
             {
               LOBYTE(v4->field_32) |= 2u;
               v14 = *(int *)&v4->flags;
@@ -650,17 +650,17 @@
       v2 = (stru148 *)v30->field_E;
       if ( v2 != (stru148 *)unnamed_6BE060[1] )
       {
-        LOWORD(v2) = LOWORD(pViewport->uViewportX);
-        if ( v30->field_8 >= (signed int)pViewport->uViewportX )
+        LOWORD(v2) = LOWORD(pViewport->uViewportTL_X);
+        if ( v30->field_8 >= (signed int)pViewport->uViewportTL_X )
           goto LABEL_124;
-        if ( v30->field_C == pViewport->uViewportX )
+        if ( v30->field_C == pViewport->uViewportTL_X )
         {
           v30->field_E = LOWORD(unnamed_6BE060[1]);
         }
         else
         {
-          v30->field_8 = LOWORD(pViewport->uViewportX);
-          v30->field_C -= LOWORD(pViewport->uViewportX);
+          v30->field_8 = LOWORD(pViewport->uViewportTL_X);
+          v30->field_C -= LOWORD(pViewport->uViewportTL_X);
           if ( v30->field_C >= 0 )
           {
 LABEL_124:
@@ -693,13 +693,13 @@
       v2 = (stru148 *)v13->field_E;
       if ( v2 != (stru148 *)unnamed_6BE060[1] )
       {
-        LOWORD(v2) = LOWORD(pViewport->uViewportX);
-        if ( v13->field_8 >= (signed int)pViewport->uViewportX )
+        LOWORD(v2) = LOWORD(pViewport->uViewportTL_X);
+        if ( v13->field_8 >= (signed int)pViewport->uViewportTL_X )
           goto LABEL_109;
-        if ( v13->field_C != pViewport->uViewportX )
-        {
-          v13->field_8 = LOWORD(pViewport->uViewportX);
-          v13->field_C -= LOWORD(pViewport->uViewportX);
+        if ( v13->field_C != pViewport->uViewportTL_X )
+        {
+          v13->field_8 = LOWORD(pViewport->uViewportTL_X);
+          v13->field_C -= LOWORD(pViewport->uViewportTL_X);
           if ( v13->field_C >= 0 )
           {
 LABEL_109:
@@ -790,7 +790,7 @@
 
   v3 = a2;
   v4 = a1;
-  v5 = (double)(pViewport->uViewportZ - pViewport->uViewportX) * 0.5 / tan(0.6457717418670654) + 0.5;
+  v5 = (double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) * 0.5 / tan(0.6457717418670654) + 0.5;
   v35 = v5 + 6.7553994e15;
   if ( LODWORD(v35) )
   {
@@ -824,7 +824,7 @@
           break;
         v12 = a1a;
       }
-      if ( v11 <= (signed int)pViewport->uViewportY )
+      if ( v11 <= (signed int)pViewport->uViewportTL_Y )
         break;
       v9 = ((unsigned __int64)(v3->v_18.z * (signed __int64)v12) >> 16) + v3->v_18.x;
       --v54;
@@ -3004,10 +3004,10 @@
   billboard.pTarget = pRenderer->pTargetSurface;
   billboard.pTargetZ = pRenderer->pActiveZBuffer;
   billboard.uTargetPitch = pRenderer->uTargetSurfacePitch;
-  billboard.uViewportX = pViewport->uViewportX;
-  billboard.uViewportY = pViewport->uViewportY;
-  billboard.uViewportZ = pViewport->uViewportZ - 1;
-  billboard.uViewportW = pViewport->uViewportW;
+  billboard.uViewportX = pViewport->uViewportTL_X;
+  billboard.uViewportY = pViewport->uViewportTL_Y;
+  billboard.uViewportZ = pViewport->uViewportBR_X - 1;
+  billboard.uViewportW = pViewport->uViewportBR_Y;
   pOutdoorCamera->uNumBillboards = uNumBillboardsToDraw;
 
   for (int i = 0; i < ::uNumBillboardsToDraw; ++i)
@@ -3723,7 +3723,7 @@
                     v42 = pSprites_LOD->pSpriteHeaders[(signed __int16)*v37].uWidth >> 1;
                     b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16;
                   }
-                  if ( b + v25 >= (signed int)pViewport->uViewportX && v25 - b <= (signed int)pViewport->uViewportZ )
+                  if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X )
                   {
                     if (::uNumBillboardsToDraw >= 500)
                       return;
@@ -9244,11 +9244,11 @@
     a3 = v4 * 255.0;
     v39 = a3 + 6.7553994e15;
     LODWORD(v40) = LODWORD(v39);
-    v5 = (double)(signed int)pViewport->uViewportX;
+    v5 = (double)(signed int)pViewport->uViewportTL_X;
     v36[0].pos.x = v5;
-    v6 = (double)(signed int)pViewport->uViewportY;
+    v6 = (double)(signed int)pViewport->uViewportTL_Y;
     v7 = this_ | (LODWORD(v39) << 24);
-    this_ = pViewport->uViewportW + 1;
+    this_ = pViewport->uViewportBR_Y + 1;
     v36[0].specular = 0;
     v36[0].pos.y = v6;
     v36[0].diffuse = v7;
@@ -9263,13 +9263,13 @@
     v36[3].specular = 0;
     v36[0].texcoord.y = 0.0;
     v36[1].pos.x = v5;
-    v8 = (double)(pViewport->uViewportW + 1);
+    v8 = (double)(pViewport->uViewportBR_Y + 1);
     v36[1].pos.y = v8;
     v36[1].pos.z = 0.0;
     v36[1].rhw = 1.0;
     v36[1].texcoord.x = 0.0;
     v36[1].texcoord.y = 0.0;
-    v9 = (double)(signed int)pViewport->uViewportZ;
+    v9 = (double)(signed int)pViewport->uViewportBR_X;
     v36[2].pos.x = v9;
     v36[2].pos.y = v8;
     v36[2].pos.z = 0.0;
@@ -9308,10 +9308,10 @@
     v40 = (1.0 - a3) * 65536.0;
     v39 = v40 + 6.7553994e15;
     LODWORD(a3) = LODWORD(v39);
-    v38 = (signed int)(pViewport->uViewportZ - pViewport->uViewportX) >> 1;
-    HIDWORD(v39) = pViewport->uViewportW - pViewport->uViewportY + 1;
-    v13 = pViewport->uViewportX + ecx0->uTargetSurfacePitch - pViewport->uViewportZ;
-    v14 = &ecx0->pTargetSurface[pViewport->uViewportX + pViewport->uViewportY * ecx0->uTargetSurfacePitch];
+    v38 = (signed int)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) >> 1;
+    HIDWORD(v39) = pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1;
+    v13 = pViewport->uViewportTL_X + ecx0->uTargetSurfacePitch - pViewport->uViewportBR_X;
+    v14 = &ecx0->pTargetSurface[pViewport->uViewportTL_X + pViewport->uViewportTL_Y * ecx0->uTargetSurfacePitch];
     v37 = 2 * v13;
     LODWORD(v40) = (int)v14;
 
--- a/Viewport.cpp	Sat Mar 16 21:57:32 2013 +0400
+++ b/Viewport.cpp	Sun Mar 17 01:50:34 2013 +0400
@@ -35,17 +35,12 @@
     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;
+    this->uScreenHeight = br_y - tl_y + 1;
+    this->uScreenCenterX = (signed int)(br_x + tl_x) /2;
     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);
-        }
+        this->uScreenCenterY = this->uScreen_BR_Y - ((unsigned __int64)(this->field_30 * (signed __int64)(uScreenHeight)) >> 16);
     else
-        {
-        this->uScreenHeight = br_y - tl_y + 1;
-        this->uScreenCenterY = (signed int)(br_y + tl_y) >> 1;
-        }
+        this->uScreenCenterY = uScreenHeight/2;
     SetViewport(this->uScreen_TL_X, this->uScreen_TL_Y, this->uScreen_BR_X, this->uScreen_BR_Y);
     }
 
@@ -57,61 +52,61 @@
     }
 
 //----- (004C0312) --------------------------------------------------------
-void Viewport::SetViewport( signed int uX, signed int uY, signed int uZ, signed int uW )
+void Viewport::SetViewport( signed int sTL_X, signed int sTL_Y, signed int sBR_X, signed int sBR_Y )
     {
-    unsigned int x; // ebx@1
-    unsigned int y; // edi@3
-    unsigned int z; // edx@5
-    unsigned int w; // eax@7
+    signed int tl_x; // ebx@1
+    signed int tl_y; // edi@3
+    signed int br_x; // edx@5
+    signed int br_y; // 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;
+    tl_x = sTL_X;
+    if ( sTL_X < this->uScreen_TL_X )
+        tl_x = this->uScreen_TL_X;
+    tl_y = sTL_Y;
+    if ( sTL_Y < this->uScreen_TL_Y )
+        tl_y = this->uScreen_TL_Y;
+    br_x = sBR_X;
+    if ( sBR_X > this->uScreen_BR_X )
+        br_x = this->uScreen_BR_X;
+    br_y = sBR_Y;
+    if ( sBR_Y > this->uScreen_BR_Y )
+        br_y = this->uScreen_BR_Y;
+    this->uViewportTL_Y = tl_y;
+    this->uViewportTL_X = tl_x;
+    this->uViewportBR_X = br_x;
+    this->uViewportBR_Y = br_y;
     }
 
 //----- (00443219) --------------------------------------------------------
  void ViewingParams::_443219()
     {
-    this->sPartyPosZ += 512;
-    _4432E7();
+    this->sViewCenterY += 512;
+    AdjustPosition();
     }
 
 //----- (00443225) --------------------------------------------------------
 void ViewingParams::_443225()
     {
-    this->sPartyPosX -= 512;
-    _4432E7();
+    this->sViewCenterX -= 512;
+    AdjustPosition();
     }
 
 //----- (00443231) --------------------------------------------------------
 void ViewingParams::_443231()
     {
-    this->sPartyPosZ -= 512;
-    _4432E7();
+    this->sViewCenterY -= 512;
+    AdjustPosition();
     }
 
 //----- (0044323D) --------------------------------------------------------
 void ViewingParams::_44323D()
     {
-    this->sPartyPosX += 512;
-    _4432E7();
+    this->sViewCenterX += 512;
+    AdjustPosition();
     }
 
 //----- (00443249) --------------------------------------------------------
-void ViewingParams::_443249()
+void ViewingParams::CenterOnParty()
     {
     int v1; // edx@1
 
@@ -119,13 +114,13 @@
     this->field_2C = v1;
     if ( v1 < 384 )
         this->field_2C = 384;
-    this->sPartyPosX = pParty->vPosition.x;
-    this->sPartyPosZ = pParty->vPosition.y;
-    _4432E7();
+    this->sViewCenterX = pParty->vPosition.x;
+    this->sViewCenterY = pParty->vPosition.y;
+    AdjustPosition();
     }
 
 //----- (00443291) --------------------------------------------------------
-void ViewingParams::_443291()
+void ViewingParams::CenterOnParty2()
     {
     int v1; // edx@1
     int v2; // eax@1
@@ -137,13 +132,13 @@
         v2 = 3072;
     if ( v1 > v2 )
         this->field_2C = v2;
-    this->sPartyPosX = pParty->vPosition.x;
-    this->sPartyPosZ = pParty->vPosition.y;
-    _4432E7();
+    this->sViewCenterX = pParty->vPosition.x;
+    this->sViewCenterY = pParty->vPosition.y;
+    AdjustPosition();
     }
 
 //----- (004432E7) --------------------------------------------------------
-void ViewingParams::_4432E7()
+void ViewingParams::AdjustPosition()
     {
     ViewingParams *v1; // esi@1
     int v2; // ebx@1
@@ -152,27 +147,26 @@
     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;
+    if ( v1->sViewCenterY > v2 + v4 )
+        v1->sViewCenterY = v2 + v4;
 
     v5 = v1->field_38;
     v6 = (v3 - 44) << 9;
-    if ( v1->sPartyPosX < v5 + v6 )
-        v1->sPartyPosX = v5 + v6;
+    if ( v1->sViewCenterX < v5 + v6 )
+        v1->sViewCenterX = v5 + v6;
 
     v7 = v2 + v6;
-    if ( v1->sPartyPosZ < v7 )
-        v1->sPartyPosZ = v7;
+    if ( v1->sViewCenterY < v7 )
+        v1->sViewCenterY = v7;
 
-    result = v5 + v4;
-    if ( v1->sPartyPosX > v5 + v4 )
-        v1->sPartyPosX = result;
+    if ( v1->sViewCenterX > v5 + v4 )
+        v1->sViewCenterX = v5 + v4;
     }
 
 //----- (00443343) --------------------------------------------------------
--- a/Viewport.h	Sat Mar 16 21:57:32 2013 +0400
+++ b/Viewport.h	Sun Mar 17 01:50:34 2013 +0400
@@ -13,10 +13,10 @@
   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;
+  signed int uViewportTL_X;
+  signed int uViewportTL_Y;
+  signed int uViewportBR_X;
+  signed int uViewportBR_Y;
   int uScreenWidth;
   int uScreenHeight;
   int uScreenCenterX;
@@ -41,14 +41,14 @@
     draw_d3d_outlines = false;
   }
 
-  void _443291();
+  void CenterOnParty2();
   void  InitGrayPalette();
   void _443219();
   void  _443225();
   void  _443231();
   void _44323D();
-  void _443249();
-  void  _4432E7();
+  void CenterOnParty();
+  void  AdjustPosition();
   void _443365();
 
 
@@ -65,8 +65,8 @@
   unsigned int uMinimapZoom;
   int field_28;
   int field_2C;
-  int sPartyPosX;
-  int sPartyPosZ;
+  int sViewCenterX;
+  int sViewCenterY;
   __int16 field_38;
   __int16 field_3A;
   int field_3C;
--- a/Weather.cpp	Sat Mar 16 21:57:32 2013 +0400
+++ b/Weather.cpp	Sun Mar 17 01:50:34 2013 +0400
@@ -181,8 +181,8 @@
   v4 = pViewport->uScreen_BR_Y - pViewport->uScreen_TL_Y - 4;
   do
   {
-    v1->field_0[2 * v2++] = LOWORD(pViewport->uViewportX) + rand() % v3;
-    *((short *)v1 + 2 * v2 - 1) = LOWORD(pViewport->uViewportY) + rand() % v4;
+    v1->field_0[2 * v2++] = LOWORD(pViewport->uViewportTL_X) + rand() % v3;
+    *((short *)v1 + 2 * v2 - 1) = LOWORD(pViewport->uViewportTL_Y) + rand() % v4;
   }
   while ( v2 < 1000 );
   return 0;
--- a/mm7_1.cpp	Sat Mar 16 21:57:32 2013 +0400
+++ b/mm7_1.cpp	Sun Mar 17 01:50:34 2013 +0400
@@ -1459,7 +1459,7 @@
 void __cdecl draw_right_panel()
 {
   pRenderer->DrawTextureTransparent(
-    pViewport->uViewportZ,
+    pViewport->uViewportBR_X,
     0,
     (Texture *)(uTextureID_right_panel != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_right_panel] : 0));
 }
@@ -4693,31 +4693,31 @@
   CharacterUI_LoadPaperdollTextures();
   pCurrentScreen = v1;
   pWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_CharacterRecord, uActiveCharacter, 0);
-  pCharacterScreen_StatsBtn = pWindow->CreateButton(pViewport->uViewportX + 12, pViewport->uViewportY + 308,
+  pCharacterScreen_StatsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 12, pViewport->uViewportTL_Y + 308,
                                 (papredoll_dbrds[9] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[9]].uTextureWidth : 24),
                                 (papredoll_dbrds[9] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[9]].uTextureHeight : 26),
                                 1, 0, 0x73u, 0, 0x53u, pGlobalTXT_LocalizationStrings[216],// Stats
                                 (Texture *)(papredoll_dbrds[10] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[10]] : 0),
                                 papredoll_dbrds[9] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[9]] : 0, 0);
-  pCharacterScreen_SkillsBtn = pWindow->CreateButton(pViewport->uViewportX + 102, pViewport->uViewportY + 308,
+  pCharacterScreen_SkillsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 102, pViewport->uViewportTL_Y + 308,
                                  (papredoll_dbrds[7] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[7]].uTextureWidth : 24),
                                  (papredoll_dbrds[7] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[7]].uTextureHeight : 26),
                                  1, 0, 0x72u, 0, 0x4Bu, pGlobalTXT_LocalizationStrings[205],//Skills
                                  (Texture *)(papredoll_dbrds[8] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[8]] : 0),
                                  papredoll_dbrds[7] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[7]] : 0, 0);
-  pCharacterScreen_InventoryBtn = pWindow->CreateButton(pViewport->uViewportX + 192, pViewport->uViewportY + 308,
+  pCharacterScreen_InventoryBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 192, pViewport->uViewportTL_Y + 308,
                                     (papredoll_dbrds[5] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[5]].uTextureWidth : 24),
                                     (papredoll_dbrds[5] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[5]].uTextureHeight : 26),
                                     1, 0, 0x74u, 0, 0x49u, pGlobalTXT_LocalizationStrings[120], //Inventory
                                     (Texture *)(papredoll_dbrds[6] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[6]] : 0),
                                     papredoll_dbrds[5] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[5]] : 0, 0);
-  pCharacterScreen_AwardsBtn = pWindow->CreateButton(pViewport->uViewportX + 282, pViewport->uViewportY + 308,
+  pCharacterScreen_AwardsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 282, pViewport->uViewportTL_Y + 308,
                                  (papredoll_dbrds[3] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[3]].uTextureWidth : 24),
                                  (papredoll_dbrds[3] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[3]].uTextureHeight : 26),
                                  1, 0, 0x75u, 0, 0x41u, pGlobalTXT_LocalizationStrings[22], //Awards
                                  (Texture *)(papredoll_dbrds[4] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[4]] : 0),
                                  papredoll_dbrds[3] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[3]] : 0, 0);
-  pCharacterScreen_ExitBtn = pWindow->CreateButton(pViewport->uViewportX + 371, pViewport->uViewportY + 308,
+  pCharacterScreen_ExitBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 371, pViewport->uViewportTL_Y + 308,
                  (papredoll_dbrds[1] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[1]].uTextureWidth : 24),
                  (papredoll_dbrds[1] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[1]].uTextureHeight : 26),
                  1, 0, 0xA8u, 0, 0, pGlobalTXT_LocalizationStrings[79],//Exit
--- a/mm7_2.cpp	Sat Mar 16 21:57:32 2013 +0400
+++ b/mm7_2.cpp	Sun Mar 17 01:50:34 2013 +0400
@@ -579,10 +579,10 @@
   pRenderer->BeginScene();
   if ( pRenderer->pRenderD3D )
     pRenderer->FillRectFast(
-      pViewport->uViewportX,
-      pViewport->uViewportY,
-      pViewport->uViewportZ - pViewport->uViewportX,
-      pViewport->uViewportW - pViewport->uViewportY + 1,
+      pViewport->uViewportTL_X,
+      pViewport->uViewportTL_Y,
+      pViewport->uViewportBR_X - pViewport->uViewportTL_X,
+      pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1,
       pRenderer->uTargetGMask | pRenderer->uTargetBMask);
 
   auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : nullptr);
--- a/mm7_3.cpp	Sat Mar 16 21:57:32 2013 +0400
+++ b/mm7_3.cpp	Sun Mar 17 01:50:34 2013 +0400
@@ -4499,10 +4499,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;
@@ -4525,10 +4525,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;
@@ -6145,16 +6145,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;
@@ -6465,7 +6465,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;
@@ -6585,7 +6585,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:
@@ -12290,7 +12290,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
@@ -12320,7 +12320,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
@@ -12362,42 +12362,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 )
@@ -12416,92 +12425,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
   {
@@ -12511,7 +12480,7 @@
 	  uNumBlueFacesInBLVMinimap = 0;
 	  v8 = pIndoor->pMapOutlines->uNumOutlines == 0;
 	  v9 = pIndoor->pMapOutlines->uNumOutlines < 0;
-	  v94 = 0;
+	  screenWidth = 0;
 	  if ( !(v9 | v8) )
 	  {
 		i = 0;
@@ -12526,8 +12495,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);
 				}
@@ -12540,29 +12509,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 )
@@ -12579,17 +12548,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 )
@@ -12599,40 +12568,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 )
   {
@@ -12692,17 +12661,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 )
@@ -12722,9 +12691,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);
           }
@@ -12732,15 +12701,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));
@@ -12749,17 +12718,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;
@@ -12770,7 +12739,7 @@
           {
             if ( pOutdoor->_47F097(v81, v96) )
             {
-              if ( !((a5a + v85) % 2) )
+              if ( !((a5a + screenCenter_X) % 2) )
                 *a4a = i;
             }
             else
@@ -12783,26 +12752,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;
@@ -13433,8 +13402,8 @@
   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 )
   {
--- a/mm7_4.cpp	Sat Mar 16 21:57:32 2013 +0400
+++ b/mm7_4.cpp	Sun Mar 17 01:50:34 2013 +0400
@@ -1380,11 +1380,11 @@
 
   v0 = pSpans;
   stru_80C9D8.pSurf = &stru_80C980;
-  stru_80C9D8.field_0 = (double)(signed int)pViewport->uViewportX;
+  stru_80C9D8.field_0 = (double)(signed int)pViewport->uViewportTL_X;
   stru_80C9A4.pSurf = &stru_80C980;
   stru_80C980.pPrev = &stru_80C980;
   stru_80C980.pNext = &stru_80C980;
-  stru_80C9A4.field_0 = (double)(signed int)pViewport->uViewportZ;
+  stru_80C9A4.field_0 = (double)(signed int)pViewport->uViewportBR_X;
   stru_80C980.field_8 = 0.0;
   stru_80C980.field_4 = 0.0;
   stru_80C9D8.pNext = &stru_80C9A4;
@@ -1394,16 +1394,16 @@
   stru_80C9A4.pPrev = &stru_80C9D8;
   stru_80C9A4.field_8 = 0;
   LODWORD(stru_80C980.field_0) = 0xC97423F0u;
-  v27 = pViewport->uViewportY;
-  if ( (signed int)pViewport->uViewportY > (signed int)pViewport->uViewportW )
+  v27 = pViewport->uViewportTL_Y;
+  if ( (signed int)pViewport->uViewportTL_Y > (signed int)pViewport->uViewportBR_Y )
   {
 LABEL_51:
     v0->field_8 = -1;
   }
   else
   {
-    v1 = 52 * pViewport->uViewportY;
-    v24 = 52 * pViewport->uViewportY;
+    v1 = 52 * pViewport->uViewportTL_Y;
+    v24 = 52 * pViewport->uViewportTL_Y;
     while ( 1 )
     {
       v2 = *(Edge **)((char *)&pNewEdges->pNext + v1);
@@ -1560,7 +1560,7 @@
       ++v27;
       v1 = v24 + 52;
       v24 += 52;
-      if ( (signed int)v27 > (signed int)pViewport->uViewportW )
+      if ( (signed int)v27 > (signed int)pViewport->uViewportBR_Y )
         goto LABEL_51;
     }
     while ( 1 )
@@ -6502,15 +6502,15 @@
   v5 = a4;
   v23 = _z >> 16;
   z = x + v5;
-  if ( z >= (signed int)pViewport->uViewportX
-    && (signed int)x <= (signed int)pViewport->uViewportZ
-    && y >= (signed int)pViewport->uViewportY
-    && y <= (signed int)pViewport->uViewportW )
-  {
-    if ( (signed int)x < (signed int)pViewport->uViewportX )
-      x = pViewport->uViewportX;
-    if ( z > (signed int)pViewport->uViewportZ )
-      z = pViewport->uViewportZ;
+  if ( z >= (signed int)pViewport->uViewportTL_X
+    && (signed int)x <= (signed int)pViewport->uViewportBR_X
+    && y >= (signed int)pViewport->uViewportTL_Y
+    && y <= (signed int)pViewport->uViewportBR_Y )
+  {
+    if ( (signed int)x < (signed int)pViewport->uViewportTL_X )
+      x = pViewport->uViewportTL_X;
+    if ( z > (signed int)pViewport->uViewportBR_X )
+      z = pViewport->uViewportBR_X;
     pTarget = &pRenderer->pTargetSurface[x + y * pRenderer->uTargetSurfacePitch];
     v22 = z - x;
     pTargetZ = &pRenderer->pActiveZBuffer[x + 640 * y];
@@ -6631,48 +6631,48 @@
   {
     if ( pRenderer->field_40110 )
     {
-      a2.bottom = pViewport->uViewportY;
+      a2.bottom = pViewport->uViewportTL_Y;
       a2.left = 0;
       a2.top = 0;
       a2.right = 640;
       ErrD3D(pRenderer->pBackBuffer4->BltFast(0, 0, pRenderer->pColorKeySurface4, &a2, 16u));
       a2.right = 640;
       a2.left = 0;
-      a2.top = pViewport->uViewportW + 1;
+      a2.top = pViewport->uViewportBR_Y + 1;
       a2.bottom = 480;
       ErrD3D(pRenderer->pBackBuffer4->BltFast(
              0,
-             pViewport->uViewportW + 1,
+             pViewport->uViewportBR_Y + 1,
              pRenderer->pColorKeySurface4,
              &a2,
              16u));
-      a2.right = pViewport->uViewportX;
-      a2.bottom = pViewport->uViewportW + 1;
+      a2.right = pViewport->uViewportTL_X;
+      a2.bottom = pViewport->uViewportBR_Y + 1;
       a2.left = 0;
-      a2.top = pViewport->uViewportY;
+      a2.top = pViewport->uViewportTL_Y;
       ErrD3D(pRenderer->pBackBuffer4->BltFast(
              0,
-             pViewport->uViewportY,
+             pViewport->uViewportTL_Y,
              pRenderer->pColorKeySurface4,
              &a2,
              16u));
-      a2.left = pViewport->uViewportZ;
-      a2.top = pViewport->uViewportY;
+      a2.left = pViewport->uViewportBR_X;
+      a2.top = pViewport->uViewportTL_Y;
       a2.right = 640;
-      a2.bottom = pViewport->uViewportW + 1;
+      a2.bottom = pViewport->uViewportBR_Y + 1;
       ErrD3D(pRenderer->pBackBuffer4->BltFast(
-             pViewport->uViewportZ,
-             pViewport->uViewportY,
+             pViewport->uViewportBR_X,
+             pViewport->uViewportTL_Y,
              pRenderer->pColorKeySurface4,
              &a2,
              16u));
-      a2.right = pViewport->uViewportZ;
-      a2.bottom = pViewport->uViewportW + 1;
-      a2.left = pViewport->uViewportX;
-      a2.top = pViewport->uViewportY;
+      a2.right = pViewport->uViewportBR_X;
+      a2.bottom = pViewport->uViewportBR_Y + 1;
+      a2.left = pViewport->uViewportTL_X;
+      a2.top = pViewport->uViewportTL_Y;
       ErrD3D(pRenderer->pBackBuffer4->BltFast(
-             pViewport->uViewportX,
-             pViewport->uViewportY,
+             pViewport->uViewportTL_X,
+             pViewport->uViewportTL_Y,
              pRenderer->pColorKeySurface4,
              &a2,
              17u));
@@ -6756,11 +6756,11 @@
                  pSrc + y * 640, 640 * sizeof(__int16));
 
 
-        auto pSrc_x1y1 = pSrc + 640 * pViewport->uViewportY + pViewport->uViewportX;
+        auto pSrc_x1y1 = pSrc + 640 * pViewport->uViewportTL_Y + pViewport->uViewportTL_X;
         //_this = (unsigned int)&pSrc[2 * (((signed int)pViewport->uViewportX >> 1) + 320 * pViewport->uViewportY)];
-        auto pDst_x1y1 = pDst + Dst.lPitch * pViewport->uViewportY + pViewport->uViewportX;
+        auto pDst_x1y1 = pDst + Dst.lPitch * pViewport->uViewportTL_Y + pViewport->uViewportTL_X;
         //v23 = (unsigned __int32)((char *)v26 + 4 * (((signed int)pViewport->uViewportX >> 1) + (Dst.lPitch >> 2) * pViewport->uViewportY));
-        v9 = ((signed int)pViewport->uViewportX >> 1) - ((signed int)pViewport->uViewportZ >> 1);
+        v9 = ((signed int)pViewport->uViewportTL_X >> 1) - ((signed int)pViewport->uViewportBR_X >> 1);
         //v20 = ((signed int)pViewport->uViewportZ >> 1) - ((signed int)pViewport->uViewportX >> 1);
         v22 = 4 * ((Dst.lPitch / 4) + v9);
         v21 = 4 * v9 + 1280;
@@ -6769,14 +6769,14 @@
         //v26 = (LPVOID)(pViewport->uViewportW - pViewport->uViewportY + 1);
         v10 = (int)pSrc_x1y1;
         v11 = (int)pDst_x1y1;
-        auto uHalfWidth = v20 = (pViewport->uViewportZ - pViewport->uViewportX) / 2;
+        auto uHalfWidth = v20 = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2;
         v13 = v24;
 
-        for (uint y = pViewport->uViewportY; y < pViewport->uViewportW + 1; ++y)
+        for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y)
         {
           //memcpy(pDst + pViewport->uViewportX + y * Dst.lPitch / 2,
           //       pSrc + pViewport->uViewportX + y * 640, (pViewport->uViewportZ - pViewport->uViewportX) * sizeof(__int16));
-          for (uint x = pViewport->uViewportX; x < pViewport->uViewportZ; ++x)
+          for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x)
           {
             if (pSrc[y * 640 + x] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask))
               pDst[y * Dst.lPitch / 2 + x] = pSrc[y * 640 + x];
--- a/mm7_5.cpp	Sat Mar 16 21:57:32 2013 +0400
+++ b/mm7_5.cpp	Sun Mar 17 01:50:34 2013 +0400
@@ -963,8 +963,8 @@
           if ( pCurrentScreen )
             pGUIWindow_CurrentMenu->Release();
           pEventTimer->Pause();
-          viewparams->sPartyPosX = pParty->vPosition.x;
-          viewparams->sPartyPosZ = pParty->vPosition.y;
+          viewparams->sViewCenterX = pParty->vPosition.x;
+          viewparams->sViewCenterY = pParty->vPosition.y;
           pAudioPlayer->StopChannels(-1, -1);
           pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
           pBooksWindow = GUIWindow::Create(546, 353, 0, 0, (enum WindowType)99, (int)pBtn_Maps, 0);
@@ -13409,8 +13409,8 @@
           {
 			v7 = v0->lastOpenedSpellbookPage;
            // v7 =  (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v4]);
-            v19 = pViewport->uViewportY +  pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Ypos;
-            v17 = pViewport->uViewportX +  pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Xpos;
+            v19 = pViewport->uViewportTL_Y +  pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Ypos;
+            v17 = pViewport->uViewportTL_X +  pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Xpos;
             if ( BYTE1(v6->pBits) & 2 )
               pRenderer->DrawTextureTransparent(v17, v19, v6);
             else
@@ -13434,8 +13434,8 @@
       v21 = dword_5063D8[v10];
 	  v12 = v0->lastOpenedSpellbookPage;
     //  v12 = (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v10]);
-      v20 = pViewport->uViewportY +  pIconPos[v12][pSpellbookSpellIndices[v12][v10]].Ypos;
-      v18 = pViewport->uViewportX +  pIconPos[v12][pSpellbookSpellIndices[v12][v10]].Xpos;
+      v20 = pViewport->uViewportTL_Y +  pIconPos[v12][pSpellbookSpellIndices[v12][v10]].Ypos;
+      v18 = pViewport->uViewportTL_X +  pIconPos[v12][pSpellbookSpellIndices[v12][v10]].Xpos;
       if ( BYTE1(v11->pBits) & 2 )
         pRenderer->DrawTextureTransparent(v18, v20, v21);
       else
@@ -13570,31 +13570,31 @@
   Texture *v14; // [sp-4h] [bp-60h]@7
   GUIWindow a1; // [sp+8h] [bp-54h]@10
 
-  pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pSpellBookPagesTextr_11);
+  pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_11);
   if ( dword_506548 || !dword_506528 )
   {
     v13 = pTex_tab_an_6a__zoom_off;
-    v11 = pViewport->uViewportY + 2;
-    v0 = pViewport->uViewportX + 407;
+    v11 = pViewport->uViewportTL_Y + 2;
+    v0 = pViewport->uViewportTL_X + 407;
   }
   else
   {
     v13 = pTex_tab_an_6b__zoom_on;
-    v11 = pViewport->uViewportY + 1;
-    v0 = pViewport->uViewportX + 398;
+    v11 = pViewport->uViewportTL_Y + 1;
+    v0 = pViewport->uViewportTL_X + 398;
   }
   pRenderer->DrawTextureTransparent(v0, v11, v13);
   if ( dword_506544 || dword_506528 + awards_count >= awards_count2 )
   {
     v14 = pTex_tab_an_7a__zoot_off;
-    v12 = pViewport->uViewportY + 38;
-    v1 = pViewport->uViewportX + 407;
+    v12 = pViewport->uViewportTL_Y + 38;
+    v1 = pViewport->uViewportTL_X + 407;
   }
   else
   {
     v14 = pTex_tab_an_7b__zoot_on;
-    v12 = pViewport->uViewportY + 38;
-    v1 = pViewport->uViewportX + 398;
+    v12 = pViewport->uViewportTL_Y + 38;
+    v1 = pViewport->uViewportTL_X + 398;
   }
   pRenderer->DrawTextureTransparent(v1, v12, v14);
   if ( !byte_5C6D50[dword_506528] )
@@ -13676,31 +13676,31 @@
   Texture *v11; // [sp-4h] [bp-64h]@7
   GUIWindow a1; // [sp+Ch] [bp-54h]@9
 
-  pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pTexture_CurrentBook);
+  pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pTexture_CurrentBook);
   if ( dword_506548 || !dword_506528 )
   {
     v10 = pTex_tab_an_6a__zoom_off;
-    v8 = pViewport->uViewportY + 2;
-    v0 = pViewport->uViewportX + 407;
+    v8 = pViewport->uViewportTL_Y + 2;
+    v0 = pViewport->uViewportTL_X + 407;
   }
   else
   {
     v10 = pTex_tab_an_6b__zoom_on;
-    v8 = pViewport->uViewportY + 1;
-    v0 = pViewport->uViewportX + 398;
+    v8 = pViewport->uViewportTL_Y + 1;
+    v0 = pViewport->uViewportTL_X + 398;
   }
   pRenderer->DrawTextureTransparent(v0, v8, v10);
   if ( dword_506544 || dword_506528 + awards_count >= awards_count2 )
   {
     v11 = pTex_tab_an_7a__zoot_off;
-    v9 = pViewport->uViewportY + 38;
-    v1 = pViewport->uViewportX + 407;
+    v9 = pViewport->uViewportTL_Y + 38;
+    v1 = pViewport->uViewportTL_X + 407;
   }
   else
   {
     v11 = pTex_tab_an_7b__zoot_on;
-    v9 = pViewport->uViewportY + 38;
-    v1 = pViewport->uViewportX + 398;
+    v9 = pViewport->uViewportTL_Y + 38;
+    v1 = pViewport->uViewportTL_X + 398;
   }
   pRenderer->DrawTextureTransparent(v1, v9, v11);
   a1.uFrameWidth = 460;
@@ -13794,31 +13794,31 @@
   GUIWindow a1; // [sp+14h] [bp-54h]@46
 
   v31 = 0;
-  pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pTexture_AutonotesBook);
+  pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pTexture_AutonotesBook);
   if ( dword_506548 || !dword_506528 )
   {
     v24 = pTex_tab_an_6a__zoom_off;
-    v17 = pViewport->uViewportY + 2;
-    v0 = pViewport->uViewportX + 407;
+    v17 = pViewport->uViewportTL_Y + 2;
+    v0 = pViewport->uViewportTL_X + 407;
   }
   else
   {
     v24 = pTex_tab_an_6b__zoom_on;
-    v17 = pViewport->uViewportY + 1;
-    v0 = pViewport->uViewportX + 398;
+    v17 = pViewport->uViewportTL_Y + 1;
+    v0 = pViewport->uViewportTL_X + 398;
   }
   pRenderer->DrawTextureTransparent(v0, v17, v24);
   if ( dword_506544 || dword_506528 + awards_count >= awards_count2 )
   {
     v25 = pTex_tab_an_7a__zoot_off;
-    v18 = pViewport->uViewportY + 38;
-    v1 = pViewport->uViewportX + 407;
+    v18 = pViewport->uViewportTL_Y + 38;
+    v1 = pViewport->uViewportTL_X + 407;
   }
   else
   {
     v25 = pTex_tab_an_7b__zoot_on;
-    v18 = pViewport->uViewportY + 38;
-    v1 = pViewport->uViewportX + 398;
+    v18 = pViewport->uViewportTL_Y + 38;
+    v1 = pViewport->uViewportTL_X + 398;
   }
   pRenderer->DrawTextureTransparent(v1, v18, v25);
   if ( !dword_506540 )
@@ -13826,8 +13826,8 @@
     if ( dword_506568 )
     {
       pRenderer->DrawTextureTransparent(
-        pViewport->uViewportX + 408,
-        pViewport->uViewportY + 113,
+        pViewport->uViewportTL_X + 408,
+        pViewport->uViewportTL_Y + 113,
         pTexture_506390);
       v2 = 1;
       goto LABEL_16;
@@ -13845,7 +13845,7 @@
   pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
 LABEL_15:
   dword_506568 = 0;
-  pRenderer->DrawTextureTransparent(pViewport->uViewportX + 398, pViewport->uViewportY + 113, pTexture_506394);
+  pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, pTexture_506394);
 LABEL_16:
   if ( dword_50653C )
   {
@@ -13860,15 +13860,15 @@
     if ( dword_506568 != v2 )
     {
       v26 = pTexture_506388;
-      v19 = pViewport->uViewportY + 150;
-      v3 = pViewport->uViewportX + 408;
+      v19 = pViewport->uViewportTL_Y + 150;
+      v3 = pViewport->uViewportTL_X + 408;
       goto LABEL_22;
     }
   }
   v26 = pTexture_50638C;
   dword_506568 = v2;
-  v19 = pViewport->uViewportY + 150;
-  v3 = pViewport->uViewportX + 399;
+  v19 = pViewport->uViewportTL_Y + 150;
+  v3 = pViewport->uViewportTL_X + 399;
 LABEL_22:
   pRenderer->DrawTextureTransparent(v3, v19, v26);
   if ( dword_506538 )
@@ -13884,15 +13884,15 @@
     if ( dword_506568 != 2 )
     {
       v27 = pTexture_506380;
-      v20 = pViewport->uViewportY + 188;
-      v4 = pViewport->uViewportX + 408;
+      v20 = pViewport->uViewportTL_Y + 188;
+      v4 = pViewport->uViewportTL_X + 408;
       goto LABEL_28;
     }
   }
   v27 = pTexture_506384;
   dword_506568 = 2;
-  v20 = pViewport->uViewportY + 188;
-  v4 = pViewport->uViewportX + 397;
+  v20 = pViewport->uViewportTL_Y + 188;
+  v4 = pViewport->uViewportTL_X + 397;
 LABEL_28:
   pRenderer->DrawTextureTransparent(v4, v20, v27);
   if ( dword_506534 )
@@ -13908,15 +13908,15 @@
     if ( dword_506568 != 3 )
     {
       v28 = pTexture_506378;
-      v21 = pViewport->uViewportY + 226;
-      v5 = pViewport->uViewportX + 408;
+      v21 = pViewport->uViewportTL_Y + 226;
+      v5 = pViewport->uViewportTL_X + 408;
       goto LABEL_34;
     }
   }
   v28 = pTexture_50637C;
   dword_506568 = 3;
-  v21 = pViewport->uViewportY + 226;
-  v5 = pViewport->uViewportX + 397;
+  v21 = pViewport->uViewportTL_Y + 226;
+  v5 = pViewport->uViewportTL_X + 397;
 LABEL_34:
   pRenderer->DrawTextureTransparent(v5, v21, v28);
   if ( dword_506530 )
@@ -13932,15 +13932,15 @@
     if ( dword_506568 != 4 )
     {
       v29 = pTexture_506370;
-      v22 = pViewport->uViewportY + 263;
-      v6 = pViewport->uViewportX + 408;
+      v22 = pViewport->uViewportTL_Y + 263;
+      v6 = pViewport->uViewportTL_X + 408;
       goto LABEL_40;
     }
   }
   v29 = pTexture_506374;
   dword_506568 = 4;
-  v22 = pViewport->uViewportY + 264;
-  v6 = pViewport->uViewportX + 397;
+  v22 = pViewport->uViewportTL_Y + 264;
+  v6 = pViewport->uViewportTL_X + 397;
 LABEL_40:
   pRenderer->DrawTextureTransparent(v6, v22, v29);
   if ( dword_50652C )
@@ -13956,15 +13956,15 @@
     if ( dword_506568 != 5 )
     {
       v30 = pTexture_506368;
-      v23 = pViewport->uViewportY + 302;
-      v7 = pViewport->uViewportX + 408;
+      v23 = pViewport->uViewportTL_Y + 302;
+      v7 = pViewport->uViewportTL_X + 408;
       goto LABEL_46;
     }
   }
   v30 = pTexture_50636C;
   dword_506568 = 5;
-  v23 = pViewport->uViewportY + 302;
-  v7 = pViewport->uViewportX + 397;
+  v23 = pViewport->uViewportTL_Y + 302;
+  v7 = pViewport->uViewportTL_X + 397;
 LABEL_46:
   pRenderer->DrawTextureTransparent(v7, v23, v30);
   a1.uFrameWidth = 460;
@@ -14073,89 +14073,89 @@
   GUIWindow map_window; // [sp+84h] [bp-54h]@35
   unsigned int textrX, textrY;
 
-  pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pSpellBookPagesTextr_12);
+  pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_12);
   if ( dword_506548 || viewparams->field_2C / 128 >= 12 )
   {
     buttnTxtr = pTex_tab_an_6a__zoom_off;
-    textrY = pViewport->uViewportY + 2;
-    textrX = pViewport->uViewportX + 408;
+    textrY = pViewport->uViewportTL_Y + 2;
+    textrX = pViewport->uViewportTL_X + 408;
   }
   else
   {
     buttnTxtr = pTex_tab_an_6b__zoom_on;
-    textrY = pViewport->uViewportY + 1;
-    textrX = pViewport->uViewportX + 398;
+    textrY = pViewport->uViewportTL_Y + 1;
+    textrX = pViewport->uViewportTL_X + 398;
   }
   pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
   if ( dword_506544 || viewparams->field_2C / 128 <= 3 )
   {
     buttnTxtr = pTex_tab_an_7a__zoot_off;
-    textrY = pViewport->uViewportY + 38;
-    textrX = pViewport->uViewportX + 408;
+    textrY = pViewport->uViewportTL_Y + 38;
+    textrX = pViewport->uViewportTL_X + 408;
   }
   else
   {
     buttnTxtr = pTex_tab_an_7b__zoot_on;
-    textrY = pViewport->uViewportY + 38;
-    textrX = pViewport->uViewportX + 398;
+    textrY = pViewport->uViewportTL_Y + 38;
+    textrX = pViewport->uViewportTL_X + 398;
   }
   pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
   if ( dword_506540 )
   {
     buttnTxtr = pTexture_506390;
-    textrY = pViewport->uViewportY + 113;
-    textrX = pViewport->uViewportX + 408;
+    textrY = pViewport->uViewportTL_Y + 113;
+    textrX = pViewport->uViewportTL_X + 408;
   }
   else
   {
     buttnTxtr = pTexture_506394;
-    textrY = pViewport->uViewportY + 113;
-    textrX = pViewport->uViewportX + 398;
+    textrY = pViewport->uViewportTL_Y + 113;
+    textrX = pViewport->uViewportTL_X + 398;
   }
   pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
   if ( dword_50653C )
   {
     buttnTxtr = pTexture_506388;
-    textrY = pViewport->uViewportX + 150;
-    textrX = pViewport->uViewportY + 408;
+    textrY = pViewport->uViewportTL_X + 150;
+    textrX = pViewport->uViewportTL_Y + 408;
   }
   else
   {
     buttnTxtr = pTexture_50638C;
-    textrY = pViewport->uViewportX + 150;
-    textrX = pViewport->uViewportY + 399;
+    textrY = pViewport->uViewportTL_X + 150;
+    textrX = pViewport->uViewportTL_Y + 399;
   }
   pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
   if ( dword_506538 )
   {
     buttnTxtr = pTexture_506380;
-    textrY = pViewport->uViewportY + 188;
-    textrX = pViewport->uViewportX + 408;
+    textrY = pViewport->uViewportTL_Y + 188;
+    textrX = pViewport->uViewportTL_X + 408;
   }
   else
   {
     buttnTxtr = pTexture_506384;
-    textrY = pViewport->uViewportY + 188;
-    textrX = pViewport->uViewportX + 397;
+    textrY = pViewport->uViewportTL_Y + 188;
+    textrX = pViewport->uViewportTL_X + 397;
   }
   pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
   if ( dword_506534 )
   {
     buttnTxtr = pTexture_506378;
-    textrY = pViewport->uViewportY + 226;
-    textrX = pViewport->uViewportX + 408;
+    textrY = pViewport->uViewportTL_Y + 226;
+    textrX = pViewport->uViewportTL_X + 408;
   }
   else
   {
     buttnTxtr = pTexture_50637C;
-    textrY = pViewport->uViewportY + 226;
-    textrX = pViewport->uViewportX + 397;
+    textrY = pViewport->uViewportTL_Y + 226;
+    textrX = pViewport->uViewportTL_X + 397;
   }
   pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
   if ( dword_506544 )
-    viewparams->_443291();
+    viewparams->CenterOnParty2();
   if ( dword_506548 )
-    viewparams->_443249();
+    viewparams->CenterOnParty();
   if ( dword_506540 )
     viewparams->_443219();
   if ( dword_50653C )
@@ -14253,7 +14253,7 @@
   v0 = pParty->uCurrentHour;
   v6 = pMapStats->GetMapInfo(pCurrentMapName);
   a5 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x4Bu, 0x4Bu, 0x4Bu);
-  pRenderer->DrawTextureIndexed(pViewport->uViewportX, pViewport->uViewportY, pSpellBookPagesTextr_13);
+  pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_13);
   v7 = (unsigned __int8)pDayMoonPhase[pParty->uDaysPlayed];
   if ( (signed int)v0 <= 12 )
   {
@@ -15053,8 +15053,8 @@
 		case WINDOW_3:
 			{
 			pTexture = (Texture *)(uTextureID_Options != -1 ? &pIcons_LOD->pTextures[uTextureID_Options] : 0);//pWindowType == 3 (0x3)
-			pY = pViewport->uViewportY;
-			pX = pViewport->uViewportX;
+			pY = pViewport->uViewportTL_Y;
+			pX = pViewport->uViewportTL_X;
 			pRenderer->DrawTextureIndexed(pX, pY, pTexture);
 			viewparams->bRedrawGameUI = 1;
 			break;
@@ -15959,7 +15959,7 @@
 		if (GetCurrentMenuID() > 0)
 			break;
 
-		if ( (signed int)pY > (signed int)pViewport->uViewportW )
+		if ( (signed int)pY > (signed int)pViewport->uViewportBR_Y )
 		{
 			pWindow.ptr_1C = (void *)((signed int)pX / 118);
 			if ( (signed int)pX / 118 < 4 )
@@ -15973,7 +15973,7 @@
 				pWindow.DrawQuickCharRecord();
 			}
 		}
-		else if ( (signed int)pX > (signed int)pViewport->uViewportZ )
+		else if ( (signed int)pX > (signed int)pViewport->uViewportBR_X )
 		{
 			if ( (signed int)pY >= 130 )
 			{
@@ -16061,10 +16061,10 @@
     case SCREEN_BOOKS:
 		{
         if ( !dword_506364
-          || (signed int)pX < (signed int)pViewport->uViewportX
-          || (signed int)pX > (signed int)pViewport->uViewportZ
-          || (signed int)pY < (signed int)pViewport->uViewportY
-          || (signed int)pY > (signed int)pViewport->uViewportW
+          || (signed int)pX < (signed int)pViewport->uViewportTL_X
+          || (signed int)pX > (signed int)pViewport->uViewportBR_X
+          || (signed int)pY < (signed int)pViewport->uViewportTL_Y
+          || (signed int)pY > (signed int)pViewport->uViewportBR_Y
           || (v2 = (char *)sub_444564(), (pWindow.Hint = v2) == 0) )
           break;
         v30 = (double)(pFontArrus->GetLineWidth(v2) + 32);
@@ -16255,8 +16255,8 @@
   v4 = GetCurrentMenuID();
   x = pX;
   if ( (v4 & 0x80000000u) == 0
-    || (signed int)pX < (signed int)pViewport->uViewportX
-    || (signed int)pX > (signed int)pViewport->uViewportZ )
+    || (signed int)pX < (signed int)pViewport->uViewportTL_X
+    || (signed int)pX > (signed int)pViewport->uViewportBR_X )
   {
     y = pY;
 LABEL_30:
@@ -16311,7 +16311,7 @@
     goto LABEL_45;
   }
   y = pY;
-  if ( (signed int)pY < (signed int)pViewport->uViewportY || (signed int)pY > (signed int)pViewport->uViewportW )
+  if ( (signed int)pY < (signed int)pViewport->uViewportTL_Y || (signed int)pY > (signed int)pViewport->uViewportBR_Y )
     goto LABEL_30;
   if ( pRenderer->pRenderD3D )
     v5 = pGame->pVisInstance->get_picked_object_zbuf_val();
--- a/mm7_6.cpp	Sat Mar 16 21:57:32 2013 +0400
+++ b/mm7_6.cpp	Sun Mar 17 01:50:34 2013 +0400
@@ -684,12 +684,12 @@
   char *v139; // [sp+D4h] [bp-4h]@48
   char *v140; // [sp+D4h] [bp-4h]@65
 
-  v101 = (double)(signed int)pViewport->uViewportX;
-  v100 = (double)(signed int)pViewport->uViewportZ;
+  v101 = (double)(signed int)pViewport->uViewportTL_X;
+  v100 = (double)(signed int)pViewport->uViewportBR_X;
   v117 = a1;
   v136 = 1;
-  v104 = (double)(signed int)pViewport->uViewportY;
-  v102 = (double)(pViewport->uViewportW + 1);
+  v104 = (double)(signed int)pViewport->uViewportTL_Y;
+  v102 = (double)(pViewport->uViewportBR_Y + 1);
   if ( a1 <= 0 )
     return v117;
   v127 = a1;
@@ -711,7 +711,7 @@
   v110 = 0;
   memcpy(&array_50AC10[v1], array_50AC10, sizeof(array_50AC10[v1]));
   v4 = array_50AC10[0].vWorldViewProjX + 6.7553994e15;
-  v5 = SLODWORD(v4) >= (signed int)pViewport->uViewportX;
+  v5 = SLODWORD(v4) >= (signed int)pViewport->uViewportTL_X;
   if ( v117 < 1 )
     goto LABEL_112;
   v6 = (char *)&array_50A2B0[0].vWorldViewProjY;
@@ -724,11 +724,11 @@
   do
   {
     v103 = *((float *)v7 + 7) + 6.7553994e15;
-    v106 = SLODWORD(v103) >= (signed int)pViewport->uViewportX;
+    v106 = SLODWORD(v103) >= (signed int)pViewport->uViewportTL_X;
     if ( !(v5 ^ v106) )
       goto LABEL_25;
     v8 = v101;
-    if ( SLODWORD(v103) >= (signed int)pViewport->uViewportX )
+    if ( SLODWORD(v103) >= (signed int)pViewport->uViewportTL_X )
     {
       v9 = (v8 - *((float *)v7 - 5)) / (*((float *)v7 + 7) - *((float *)v7 - 5));
       *(float *)v6 = (*((float *)v7 + 8) - *((float *)v7 - 4)) * v9 + *((float *)v7 - 4);
@@ -802,7 +802,7 @@
     || (v115 = 0,
         memcpy(&array_50A2B0[v110], array_50A2B0, sizeof(array_50A2B0[v110])),
         v23 = array_50A2B0[0].vWorldViewProjX + 6.7553994e15,
-        v24 = SLODWORD(v23) <= (signed int)pViewport->uViewportZ,
+        v24 = SLODWORD(v23) <= (signed int)pViewport->uViewportBR_X,
         v110 < 1) )
     goto LABEL_112;
   v25 = (char *)&array_509950[0]._rhw;
@@ -817,12 +817,12 @@
   while ( 2 )
   {
     v97 = *((float *)v26 + 7) + 6.7553994e15;
-    v27 = SLODWORD(v97) <= (signed int)pViewport->uViewportZ;
-    v107 = SLODWORD(v97) <= (signed int)pViewport->uViewportZ;
+    v27 = SLODWORD(v97) <= (signed int)pViewport->uViewportBR_X;
+    v107 = SLODWORD(v97) <= (signed int)pViewport->uViewportBR_X;
     if ( v24 != v27 )
     {
       v28 = v100;
-      if ( SLODWORD(v97) <= (signed int)pViewport->uViewportZ )
+      if ( SLODWORD(v97) <= (signed int)pViewport->uViewportBR_X )
       {
         v29 = (v28 - *((float *)v26 - 5)) / (*((float *)v26 + 7) - *((float *)v26 - 5));
         *(float *)v122 = (*((float *)v26 + 8) - *((float *)v26 - 4)) * v29 + *((float *)v26 - 4);
@@ -899,7 +899,7 @@
     || (v123 = 0,
         memcpy(&array_509950[v115], array_509950, sizeof(array_509950[v115])),
         v42 = array_509950[0].vWorldViewProjY + 6.7553994e15,
-        v43 = SLODWORD(v42) >= (signed int)pViewport->uViewportY,
+        v43 = SLODWORD(v42) >= (signed int)pViewport->uViewportTL_Y,
         v115 < 1) )
     goto LABEL_112;
   v44 = (char *)&array_508FF0[0].vWorldViewProjX;
@@ -913,12 +913,12 @@
   while ( 2 )
   {
     v98 = *((float *)v45 + 8) + 6.7553994e15;
-    v46 = SLODWORD(v98) >= (signed int)pViewport->uViewportY;
-    v108 = SLODWORD(v98) >= (signed int)pViewport->uViewportY;
+    v46 = SLODWORD(v98) >= (signed int)pViewport->uViewportTL_Y;
+    v108 = SLODWORD(v98) >= (signed int)pViewport->uViewportTL_Y;
     if ( v43 != v46 )
     {
       v47 = v104;
-      if ( SLODWORD(v98) >= (signed int)pViewport->uViewportY )
+      if ( SLODWORD(v98) >= (signed int)pViewport->uViewportTL_Y )
       {
         v48 = (v47 - *((float *)v45 - 4)) / (*((float *)v45 + 8) - *((float *)v45 - 4));
         *(float *)v44 = (*((float *)v45 + 7) - *((float *)v45 - 5)) * v48 + *((float *)v45 - 5);
@@ -990,7 +990,7 @@
     || (v116 = 0,
         memcpy(&array_508FF0[v123], array_508FF0, sizeof(array_508FF0[v123])),
         v61 = array_508FF0[0].vWorldViewProjY + 6.7553994e15,
-        v62 = SLODWORD(v61) <= (signed int)pViewport->uViewportW,
+        v62 = SLODWORD(v61) <= (signed int)pViewport->uViewportBR_Y,
         v123 < 1) )
     goto LABEL_112;
   v63 = (char *)&array_508690[0].vWorldViewProjX;
@@ -1004,12 +1004,12 @@
   while ( 2 )
   {
     v99 = *((float *)v64 + 8) + 6.7553994e15;
-    v65 = SLODWORD(v99) <= (signed int)pViewport->uViewportW;
-    v109 = SLODWORD(v99) <= (signed int)pViewport->uViewportW;
+    v65 = SLODWORD(v99) <= (signed int)pViewport->uViewportBR_Y;
+    v109 = SLODWORD(v99) <= (signed int)pViewport->uViewportBR_Y;
     if ( v62 != v65 )
     {
       v66 = v102;
-      if ( SLODWORD(v99) <= (signed int)pViewport->uViewportW )
+      if ( SLODWORD(v99) <= (signed int)pViewport->uViewportBR_Y )
       {
         v67 = (v66 - *((float *)v64 - 4)) / (*((float *)v64 + 8) - *((float *)v64 - 4));
         *(float *)v63 = (*((float *)v64 + 7) - *((float *)v64 - 5)) * v67 + *((float *)v64 - 5);
@@ -1090,10 +1090,10 @@
       LODWORD(v83) = *(int *)v81;
       *((float *)v81 - 3) = 1.0 / *((float *)v81 + 2);
       v84 = v83 + 6.7553994e15;
-      if ( SLODWORD(v84) <= (signed int)pViewport->uViewportZ )
+      if ( SLODWORD(v84) <= (signed int)pViewport->uViewportBR_X )
       {
         v86 = *(float *)v81 + 6.7553994e15;
-        if ( SLODWORD(v86) >= (signed int)pViewport->uViewportX )
+        if ( SLODWORD(v86) >= (signed int)pViewport->uViewportTL_X )
           goto LABEL_88;
         v85 = v101;
       }
@@ -1104,7 +1104,7 @@
       *(int *)v81 = LODWORD(v85);
 LABEL_88:
       v87 = *((float *)v81 + 1) + 6.7553994e15;
-      if ( SLODWORD(v87) > (signed int)pViewport->uViewportW )
+      if ( SLODWORD(v87) > (signed int)pViewport->uViewportBR_Y )
       {
         v88 = v102;
 LABEL_92:
@@ -1112,7 +1112,7 @@
         goto LABEL_93;
       }
       v89 = *((float *)v81 + 1) + 6.7553994e15;
-      if ( SLODWORD(v89) < (signed int)pViewport->uViewportY )
+      if ( SLODWORD(v89) < (signed int)pViewport->uViewportTL_Y )
       {
         v88 = v104;
         goto LABEL_92;
--- a/mm7_data.h	Sat Mar 16 21:57:32 2013 +0400
+++ b/mm7_data.h	Sun Mar 17 01:50:34 2013 +0400
@@ -1998,7 +1998,7 @@
 void GameUI_DrawPartySpells();
 __int16 __fastcall sub_441A4E(int a1);
 void GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int bRedrawOdmMinimap);
-void DrawBook_Map_sub(unsigned int x, unsigned int y, unsigned int a4, int a5, int _48074); // idb
+void DrawBook_Map_sub(unsigned int tl_x, unsigned int tl_y, unsigned int br_x, int br_y, int _48074); // idb
 void Initialize2DA();
 
 void  LoadLevel_InitializeLevelStr();
--- a/stru6.cpp	Sat Mar 16 21:57:32 2013 +0400
+++ b/stru6.cpp	Sun Mar 17 01:50:34 2013 +0400
@@ -1456,22 +1456,22 @@
     uAnimLength -= pEventTimer->uTimeElapsed;
     if ( pRenderer->pRenderD3D )
     {
-      v12 = (double)(signed int)pViewport->uViewportX;
+      v12 = (double)(signed int)pViewport->uViewportTL_X;
       vd3d[0].pos.x = v12;
       vd3d[1].pos.x = v12;
-      v13 = (double)(signed int)pViewport->uViewportZ;
-      v26 = pViewport->uViewportW + 1;
+      v13 = (double)(signed int)pViewport->uViewportBR_X;
+      v26 = pViewport->uViewportBR_Y + 1;
       vd3d[0].diffuse = 0x7F7F7Fu;
       vd3d[1].diffuse = 0x7F7F7Fu;
       vd3d[2].pos.x = v13;
       vd3d[3].pos.x = v13;
-      v14 = (double)(signed int)pViewport->uViewportY;
+      v14 = (double)(signed int)pViewport->uViewportTL_Y;
       vd3d[2].diffuse = 0x7F7F7Fu;
       vd3d[3].diffuse = 0x7F7F7Fu;
       vd3d[0].specular = 0;
       vd3d[1].specular = 0;
       vd3d[0].pos.y = v14;
-      v15 = (double)(pViewport->uViewportW + 1);
+      v15 = (double)(pViewport->uViewportBR_Y + 1);
       vd3d[2].specular = 0;
       vd3d[3].specular = 0;
       vd3d[1].pos.y = v15;
@@ -1521,24 +1521,24 @@
       vsr.pTarget = pRenderer->pTargetSurface;
       vsr.uParentBillboardID = -1;
       vsr.pTargetZ = pRenderer->pActiveZBuffer;
-      vsr.uScreenSpaceX = (signed int)(pViewport->uViewportZ - pViewport->uViewportX) / 2;
-      vsr.uScreenSpaceY = pViewport->uViewportW;
+      vsr.uScreenSpaceX = (signed int)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2;
+      vsr.uScreenSpaceY = pViewport->uViewportBR_Y;
       v24 = 16777216;
       LODWORD(v18) = 0;
-      HIDWORD(v18) = (signed __int16)(LOWORD(pViewport->uViewportZ) - LOWORD(pViewport->uViewportX));
+      HIDWORD(v18) = (signed __int16)(LOWORD(pViewport->uViewportBR_X) - LOWORD(pViewport->uViewportTL_X));
       vsr._screenspace_x_scaler_packedfloat = v18 / 0x1000000;
       LODWORD(v18) = 0;
-      HIDWORD(v18) = (signed __int16)(LOWORD(pViewport->uViewportW) - LOWORD(pViewport->uViewportY));
+      HIDWORD(v18) = (signed __int16)(LOWORD(pViewport->uViewportBR_Y) - LOWORD(pViewport->uViewportTL_Y));
       v26 = v18 / 16777216;
       vsr._screenspace_y_scaler_packedfloat = v18 / 0x1000000;
       vsr.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v70->uPaletteIndex, 0, 1);
       vsr.uTargetPitch = pRenderer->uTargetSurfacePitch;
       vsr.uParentBillboardID = -1;
-      vsr.uViewportX = pViewport->uViewportX;
-      vsr.uViewportZ = pViewport->uViewportZ;
-      vsr.uViewportY = pViewport->uViewportY;
+      vsr.uViewportX = pViewport->uViewportTL_X;
+      vsr.uViewportZ = pViewport->uViewportBR_X;
+      vsr.uViewportY = pViewport->uViewportTL_Y;
       vsr.sZValue = 0;
-      vsr.uViewportW = pViewport->uViewportW;
+      vsr.uViewportW = pViewport->uViewportBR_Y;
       vsr.uFlags = 0;
       if ( v11 >= 0 )
         pSprites_LOD->pSpriteHeaders[v11]._4ACC38(&vsr, 1);