changeset 2216:3f375342de12

window->GetWidth() continue
author Ritor1
date Sat, 15 Feb 2014 16:00:19 +0600
parents e9625ad08541
children 744ed51880ed
files Arcomage.cpp GUIWindow.cpp Game.cpp IndoorCameraD3D.cpp Mouse.cpp Mouse.h ParticleEngine.cpp Render.cpp UI/UIPartyCreation.cpp UI/UIPopup.cpp UI/UiGame.cpp VideoPlayer.cpp _deleted.cpp mm7_2.cpp mm7_3.cpp mm7_5.cpp
diffstat 16 files changed, 330 insertions(+), 459 deletions(-) [+]
line wrap: on
line diff
--- a/Arcomage.cpp	Fri Feb 14 18:08:30 2014 +0600
+++ b/Arcomage.cpp	Sat Feb 15 16:00:19 2014 +0600
@@ -651,7 +651,8 @@
       {
         if ( *src_surf_pos != v10 )
         {
-          if ( pTargetPoint->x + j >= 0 && pTargetPoint->x + j <= 639 && pTargetPoint->y + i >= 0 && pTargetPoint->y + i <= 479)
+          if ( pTargetPoint->x + j >= 0 && pTargetPoint->x + j <= window->GetWidth() - 1 
+            && pTargetPoint->y + i >= 0 && pTargetPoint->y + i <= window->GetHeight() - 1)
             WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, *src_surf_pos);
         }
         ++src_surf_pos;
@@ -668,7 +669,8 @@
       {
         if ( *src_surf_pos != v10 )
         {
-          if ( pTargetPoint->x + j >= 0 && pTargetPoint->x + j <= 639 && pTargetPoint->y + i >= 0 && pTargetPoint->y + i <= 479)
+          if ( pTargetPoint->x + j >= 0 && pTargetPoint->x + j <= window->GetWidth() - 1
+            && pTargetPoint->y + i >= 0 && pTargetPoint->y + i <= window->GetHeight() - 1)
           //WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, (v21 & (ReadPixel16(pTargetPoint->x + j, pTargetPoint->y + i) >> 1)) + (v21 & (*src_surf_pos >> 1)));
             WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, (0x7BEF & (*src_surf_pos / 2)));
         }
@@ -724,7 +726,8 @@
       { 
         if ( *src_surf_pos != v21 )
         {
-          if ( pTargetPoint->x + j >= 0 && pTargetPoint->x + j <= 639 && pTargetPoint->y + i >= 0 && pTargetPoint->y + i <= 479)
+          if ( pTargetPoint->x + j >= 0 && pTargetPoint->x + j <= window->GetWidth() - 1 
+            && pTargetPoint->y + i >= 0 && pTargetPoint->y + i <= window->GetHeight() - 1)
             WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, *src_surf_pos);
         }
         ++src_surf_pos;
@@ -741,7 +744,8 @@
       {
         if ( *src_surf_pos != v21 )
         {
-          if ( pTargetPoint->x + j >= 0 && pTargetPoint->x + j <= 639 && pTargetPoint->y + i >= 0 && pTargetPoint->y + i <= 479)
+          if ( pTargetPoint->x + j >= 0 && pTargetPoint->x + j <= window->GetWidth() - 1
+            && pTargetPoint->y + i >= 0 && pTargetPoint->y + i <= window->GetHeight() - 1)
           //WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, (v21 & (ReadPixel16(pTargetPoint->x + j, pTargetPoint->y + i) / 2)) + (v21 & (*src_surf_pos / 2)));
             WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, (0x7BEF & (*src_surf_pos / 2)));
         }
@@ -3662,22 +3666,19 @@
 //----- (0040DB27) --------------------------------------------------------
 void DrawRect( RECT *pXYZW, unsigned __int16 uColor, char bSolidFill )
 {
-  RECT *v3; // esi@1
-
-  v3 = pXYZW;
   pRenderer->BeginScene();
-  pRenderer->SetRasterClipRect(0, 0, 639, 479);
+  pRenderer->SetRasterClipRect(0, 0, window->GetWidth() - 1, window->GetHeight() - 1);
   if ( bSolidFill )
   {
-    for ( int i = v3->top; i <= v3->bottom;  ++i )
-      pRenderer->RasterLine2D(v3->left, i, v3->right, i, uColor);
+    for ( int i = pXYZW->top; i <= pXYZW->bottom;  ++i )
+      pRenderer->RasterLine2D(pXYZW->left, i, pXYZW->right, i, uColor);
   }
   else
   {
-    pRenderer->RasterLine2D(v3->left, v3->top, v3->right, v3->top, uColor);
-    pRenderer->RasterLine2D(v3->right, v3->top, v3->right, v3->bottom, uColor);
-    pRenderer->RasterLine2D(v3->right, v3->bottom, v3->left, v3->bottom, uColor);
-    pRenderer->RasterLine2D(v3->left, v3->bottom, v3->left, v3->top, uColor);
+    pRenderer->RasterLine2D(pXYZW->left, pXYZW->top, pXYZW->right, pXYZW->top, uColor);
+    pRenderer->RasterLine2D(pXYZW->right, pXYZW->top, pXYZW->right, pXYZW->bottom, uColor);
+    pRenderer->RasterLine2D(pXYZW->right, pXYZW->bottom, pXYZW->left, pXYZW->bottom, uColor);
+    pRenderer->RasterLine2D(pXYZW->left, pXYZW->bottom, pXYZW->left, pXYZW->top, uColor);
   }
   pRenderer->EndScene();
 }
@@ -3687,7 +3688,8 @@
   pRenderer->BeginScene();
   //if ( uNumSceneBegins )
   {
-    if ( pTargetXY->x >= 0 && pTargetXY->x <= 639 && pTargetXY->y >= 0 && pTargetXY->y <= 479)
+    if ( pTargetXY->x >= 0 && pTargetXY->x <= window->GetWidth() - 1
+      && pTargetXY->y >= 0 && pTargetXY->y <= window->GetHeight() - 1)
     {
       pRenderer->WritePixel16(pTargetXY->x,     pTargetXY->y, uColor);
       pRenderer->WritePixel16(pTargetXY->x + 1, pTargetXY->y, uColor);
@@ -3704,7 +3706,8 @@
   pRenderer->BeginScene();
   //if ( pRenderer->uNumSceneBegins )
   {
-    if ( pTargetXY->x >= 0 && pTargetXY->x <= 639 && pTargetXY->y >= 0 && pTargetXY->y <= 479)
+    if ( pTargetXY->x >= 0 && pTargetXY->x <= window->GetWidth() - 1
+      && pTargetXY->y >= 0 && pTargetXY->y <= window->GetHeight() - 1)
     {
       pRenderer->WritePixel16(pTargetXY->x, pTargetXY->y, uColor);
     /*int xVal = pTargetXY->x;
--- a/GUIWindow.cpp	Fri Feb 14 18:08:30 2014 +0600
+++ b/GUIWindow.cpp	Sat Feb 15 16:00:19 2014 +0600
@@ -1520,7 +1520,7 @@
 
 //----- (00459C2B) --------------------------------------------------------
 void GUIWindow::DrawFlashingInputCursor( signed int uX, int uY, struct GUIFont *a2 )
-    {
+{
   if ( GetTickCount() % 1000 > 500 )
     DrawText(a2, uX, uY, 0, "_", 0, 0, 0);
 }
@@ -1760,17 +1760,17 @@
     }
     if (eWindowType == WINDOW_Scroll)
     {
-      pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, '1', "", 0);
-      pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, '2', "", 0);
-      pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3u, '3', "", 0);
-      pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4u, '4', "", 0);
+      pWindow->CreateButton(61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0);
+      pWindow->CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0);
+      pWindow->CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0);
+      pWindow->CreateButton(407, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0);
       pWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, '\t', "", 0);
       return pWindow;
     }
     if (eWindowType == WINDOW_CastSpell_InInventory)
     {
       pMouse->SetCursorBitmap("MICON2");
-      pBtn_ExitCancel = pWindow->CreateButton(0x188u, 0x13Eu, 0x4Bu, 0x21u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34],//Отмена
+      pBtn_ExitCancel = pWindow->CreateButton(392, 318, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34],//Отмена
                      pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);
       ShowStatusBarString(pGlobalTXT_LocalizationStrings[39], 2);//Выбрать цель
       ++pIcons_LOD->uTexturePacksCount;
--- a/Game.cpp	Fri Feb 14 18:08:30 2014 +0600
+++ b/Game.cpp	Sat Feb 15 16:00:19 2014 +0600
@@ -256,9 +256,9 @@
   _unused_5B5924_is_travel_ui_drawn = false;
   if (v4)
     pMouse->bRedraw = true;
-  pMouse->_469EA4();
+  pMouse->ReadCursorWithItem();
   pMouse->DrawCursor();
-  pMouse->_469E1C();
+  pMouse->Activate();
   pRenderer->EndScene();
   pRenderer->Present();
   pParty->uFlags &= ~2;
@@ -2298,9 +2298,7 @@
                       if ( pGUIWindow_Settings )
                       {
                         if ( pCurrentScreen == SCREEN_CHARACTERS )
-                        {
                           pMouse->SetCursorBitmap("MICON2");
-                        }
                         else
                         {
                           pGUIWindow_Settings->Release();
@@ -2348,9 +2346,7 @@
                       if ( pGUIWindow_Settings )
                       {
                         if ( pCurrentScreen == SCREEN_CHARACTERS )
-                        {
                           pMouse->SetCursorBitmap("MICON2");
-                        }
                         else
                         {
                           pGUIWindow_Settings->Release();
@@ -2432,9 +2428,7 @@
                       if ( pGUIWindow_Settings )
                       {
                         if ( pCurrentScreen == SCREEN_CHARACTERS )
-                        {
                           pMouse->SetCursorBitmap("MICON2");
-                        }
                         else
                         {
                           pGUIWindow_Settings->Release();
@@ -2460,9 +2454,7 @@
                       if ( pGUIWindow_Settings )
                       {
                         if ( pCurrentScreen == SCREEN_CHARACTERS )
-                        {
                           pMouse->SetCursorBitmap("MICON2");
-                        }
                         else
                         {
                           pGUIWindow_Settings->Release();
@@ -2488,9 +2480,7 @@
                   if ( pGUIWindow_Settings )
                   {
                     if ( pCurrentScreen == SCREEN_CHARACTERS )
-                    {
                       pMouse->SetCursorBitmap("MICON2");
-                    }
                     else
                     {
                       pGUIWindow_Settings->Release();
@@ -2520,9 +2510,7 @@
               if ( pGUIWindow_Settings )
               {
                 if ( pCurrentScreen == SCREEN_CHARACTERS )
-                {
                   pMouse->SetCursorBitmap("MICON2");
-                }
                 else
                 {
                   pGUIWindow_Settings->Release();
--- a/IndoorCameraD3D.cpp	Fri Feb 14 18:08:30 2014 +0600
+++ b/IndoorCameraD3D.cpp	Sat Feb 15 16:00:19 2014 +0600
@@ -166,8 +166,6 @@
          - (unsigned __int64)(to_y * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y);
     //}
     a3a = (z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16;
-    //a2b = fixpoin_mul(to_z, pGame->pIndoorCameraD3D->int_sine_x);
-    //v10 = pOutX;
     *pOutX = fixpoint_mul(v14, pGame->pIndoorCameraD3D->int_cosine_x) - fixpoint_mul(to_z, pGame->pIndoorCameraD3D->int_sine_x);
     *pOutZ = v9;
     *pOutY = fixpoint_mul(v14, pGame->pIndoorCameraD3D->int_sine_x) + fixpoint_mul(a3a, pGame->pIndoorCameraD3D->int_cosine_x);
--- a/Mouse.cpp	Fri Feb 14 18:08:30 2014 +0600
+++ b/Mouse.cpp	Sat Feb 15 16:00:19 2014 +0600
@@ -57,7 +57,7 @@
   if ( _stricmp("MICON2", pName) )
     pGame->uFlags2 &= 0xFFFFFFEFu;
   else
-    pGame->uFlags2 |= 0x10u;
+    pGame->uFlags2 |= 0x10;
   if ( _stricmp(this->pCurrentCursorName, pName) )
     strcpy(this->pCurrentCursorName, pName);
   ClearCursor();
@@ -86,12 +86,10 @@
 //----- (00469AE4) --------------------------------------------------------
 LONG Mouse::_469AE4()
 {
-  Mouse *v1; // esi@1
   LONG v2; // ecx@2
   LONG result; // eax@2
   struct tagPOINT Point; // [sp+Ch] [bp-8h]@2
 
-  v1 = this;
   this->field_8 = 1;
   /*if (pAsyncMouse)
   {
@@ -107,8 +105,8 @@
     result = Point.y;
     v2 = Point.x;
   //}
-  v1->uMouseClickX = v2;
-  v1->uMouseClickY = result;
+  this->uMouseClickX = v2;
+  this->uMouseClickY = result;
   if ( true/*pRenderer->bWindowMode*/)
     goto LABEL_16;
   //if (pAsyncMouse)
@@ -117,22 +115,22 @@
     v2 = 0;
   if ( result < 0 )
     result = 0;
-  if ( v2 > 639 )
-    v2 = 639;
-  if ( result > 479 )
+  if ( v2 > window->GetWidth() - 1 )
+    v2 = window->GetWidth() - 1;
+  if ( result > window->GetHeight() - 1 )
   {
-    result = 479;
+    result = window->GetHeight() - 1;
 LABEL_16:
     //if (pAsyncMouse)
     //  goto LABEL_24;
-    if (true/*pRenderer->bWindowMode*/ && (v2 < 0 || result < 0 || v2 > 639 || result > 479) )
+    if (true/*pRenderer->bWindowMode*/ && (v2 < 0 || result < 0 || v2 > window->GetWidth() -1 || result > window->GetHeight() - 1) )
       goto LABEL_23;
   }
-  if ( v1->field_C )
+  if ( this->field_C )
 LABEL_23:
-    v1->bActive = 0;
+    this->bActive = 0;
 LABEL_24:
-  v1->field_8 = 0;
+  this->field_8 = 0;
   return result;
 }
 
@@ -193,6 +191,12 @@
   this->window = window;
   this->bActive = false;
   this->bInitialized = true;
+
+  //this->field_8 = 0;//Ritor1: result incorrect uMouseClickX, this->uMouseClickY in _469AE4()
+  this->uCursorBitmapPitch = 0;//Ritor1: it's include
+  for ( uint i = 0; i < 13; i++ )
+    this->field_5C[i] = 0;
+
   this->pCursorBitmapPos.x = 0;
   this->pCursorBitmapPos.y = 0;
   this->uMouseClickX = 0;
@@ -228,7 +232,7 @@
   if ( this->bInitialized )
   {
     if ( !this->field_8 && this->bActive && !this->field_C )
-      pMouse->_469AE4();
+      pMouse->_469AE4();//Ritor1: странная, непонятная функция
     this->field_F4 = 1;
     if ( this->field_C )
     {
@@ -256,9 +260,9 @@
         this->uMouseClickY = 479;
     }*/
     this->pCursorBitmapRect.x = this->uMouseClickX;
-    this->pCursorBitmapRect.w = this->uMouseClickY + this->field_5C[0];//I think this error
+    this->pCursorBitmapRect.w = this->uMouseClickY + this->field_5C[0]; //Ritor1: Maybe this->field_5C[0] - cursor width
     this->pCursorBitmapRect.y = this->uMouseClickY;
-    this->pCursorBitmapRect.z = this->uMouseClickX + this->uCursorBitmapPitch;//and this error
+    this->pCursorBitmapRect.z = this->uMouseClickX + this->uCursorBitmapPitch; //Ritor1: Maybe this->uCursorBitmapPitch - cursor height
     if ( this->uMouseClickX < 0 )
       this->pCursorBitmapRect.x = 0;
     if ( this->uMouseClickY < 0 )
@@ -284,7 +288,7 @@
 }
 
 //----- (00469E1C) --------------------------------------------------------
-void Mouse::_469E1C()
+void Mouse::Activate()
 {
   bActive = true;
 }
@@ -306,101 +310,69 @@
     return;
 
   ushort* pSrc = pCursorBitmap3_sysmembits_16bit;
-  for (uint y = field_44; y < field_4C; ++y)
-    for (uint x = field_40; x < field_48; ++x)
+  for (uint y = uCursorWithItemY; y < uCursorWithItemZ; ++y)
+    for (uint x = uCursorWithItemX; x < uCursorWithItemW; ++x)
       //pRenderer->pTargetSurface[y * pRenderer->uTargetSurfacePitch + x] = *pSrc++;
         pRenderer->WritePixel16(x, y, *pSrc++);
 }
 
 //----- (00469EA4) --------------------------------------------------------
-void Mouse::_469EA4()
+void Mouse::ReadCursorWithItem()
 {
-  //Mouse *v1; // esi@1
   unsigned int pTextureID; // eax@2
   Texture *pTexture; // edi@2
-  unsigned int v4; // ecx@3
-  unsigned int v5; // eax@3
-  unsigned int v6; // ebx@5
-  int v7; // ecx@15
   int v8; // ecx@25
   int v9; // ebx@26
   unsigned int v10; // eax@26
   int v11; // edx@27
-  //unsigned __int16 *v12; // edx@29
-  //unsigned __int16 *v13; // ebx@29
-  unsigned int a2; // [sp+Ch] [bp-1Ch]@5
-  unsigned int v15; // [sp+10h] [bp-18h]@5
-  //unsigned int v16; // [sp+14h] [bp-14h]@25
-  //unsigned __int16 *v17; // [sp+18h] [bp-10h]@25
-  //int v18; // [sp+1Ch] [bp-Ch]@27
-  int v19; // [sp+20h] [bp-8h]@15
+  int pTextureHeight; // [sp+20h] [bp-8h]@15
   unsigned __int16 *v20; // [sp+20h] [bp-8h]@28
   int pTextureWidth; // [sp+24h] [bp-4h]@12
   unsigned __int16 *v22; // [sp+24h] [bp-4h]@25
 
-  //v1 = this;
   if ( pParty->pPickedItem.uItemID )
   {
     pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE);
     pTexture = (Texture *)(pTextureID != -1 ? (int)&pIcons_LOD->pTextures[pTextureID] : 0);
 
-      v4 = pMouse->uMouseClickX;
-      v5 = pMouse->uMouseClickY;
-
-    v6 = v5;
-    a2 = v4;
-    v15 = v5;
-    if ( (signed int)v4 <= window->GetWidth() - 1 && (signed int)v5 <= window->GetHeight() - 1 )
+    if ( (signed int)pMouse->uMouseClickX <= window->GetWidth() - 1 && (signed int)pMouse->uMouseClickY <= window->GetHeight() - 1 )
     {
-      if ( (v4 & 0x80000000u) != 0 )
+      /*if ( (v4 & 0x80000000u) != 0 )
         a2 = 0;
       if ( (v5 & 0x80000000u) != 0 )
       {
-        v6 = 0;
+        //v6 = 0;
         v15 = 0;
-      }
-      if ( (signed int)(pTexture->uTextureWidth + a2) <= window->GetWidth() )
+      }	*/
+      if ( (signed int)(pTexture->uTextureWidth + pMouse->uMouseClickX) <= window->GetWidth() )
         pTextureWidth = pTexture->uTextureWidth;
       else
-        pTextureWidth = window->GetWidth() - a2;
-      if ( (signed int)(pTexture->uTextureHeight + v6) <= window->GetHeight() )
-      {
-        v19 = pTexture->uTextureHeight;
-        v7 = pTexture->uTextureHeight;
-      }
+        pTextureWidth = window->GetWidth() - pMouse->uMouseClickX;
+      if ( (signed int)(pTexture->uTextureHeight + pMouse->uMouseClickY) <= window->GetHeight() )
+        pTextureHeight = pTexture->uTextureHeight;
       else
-      {
-        v7 = window->GetHeight() - v6;
-        v19 = window->GetHeight() - v6;
-      }
+        pTextureHeight = window->GetHeight() - pMouse->uMouseClickY;
       if ( !this->pCursorBitmap3_sysmembits_16bit
-        || a2 != this->field_40
-        || v6 != this->field_44
-        || a2 + pTextureWidth != this->field_48
-        || v6 + v7 != this->field_4C )
+        || pMouse->uMouseClickX != this->uCursorWithItemX
+        || pMouse->uMouseClickY != this->uCursorWithItemY
+        || pMouse->uMouseClickX + pTextureWidth != this->uCursorWithItemW
+        || pMouse->uMouseClickY + pTextureHeight != this->uCursorWithItemZ )
       {
         if ( this->pCursorBitmap3_sysmembits_16bit )
           free(this->pCursorBitmap3_sysmembits_16bit);
         this->pCursorBitmap3_sysmembits_16bit = (unsigned __int16 *)malloc(2 * pTexture->uTextureHeight * pTexture->uTextureWidth);
-        this->field_40 = a2;
-        this->field_48 = a2 + pTextureWidth;
-        this->field_44 = v6;
-        this->field_4C = v6 + v19;
+        this->uCursorWithItemX = pMouse->uMouseClickX;
+        this->uCursorWithItemW = pMouse->uMouseClickX + pTextureWidth;
+        this->uCursorWithItemY = pMouse->uMouseClickY;
+        this->uCursorWithItemZ = pMouse->uMouseClickY + pTextureHeight;
       }
-      v8 = this->field_44;
       v22 = this->pCursorBitmap3_sysmembits_16bit;
-      //v17 = pRenderer->pTargetSurface;
-      //v16 = pRenderer->uTargetSurfacePitch;
-      
-        v10 = pRenderer->uTargetSurfacePitch * v8;
-          v11 = this->field_40;
-      for (int y = this->field_44; y < this->field_4C; ++y)
+
+      for (int y = this->uCursorWithItemY; y < this->uCursorWithItemZ; ++y)
       {
-            //v20 = &v17[v10 + v11];
-        for (int x = this->field_40; x < this->field_48; ++x)
+        for (int x = this->uCursorWithItemX; x < this->uCursorWithItemW; ++x)
         {
-              //++v18;
-              *v22++ = pRenderer->ReadPixel16(x, y);
+          *v22++ = pRenderer->ReadPixel16(x, y);
         }
       }
       /*if ( v8 < this->field_4C )
@@ -430,13 +402,12 @@
         v6 = v15;
       }*/
 
-      v6 = v15;
       if (pParty->pPickedItem.IsBroken())
-        pRenderer->DrawTransparentRedShade(a2, v6, pTexture);
+        pRenderer->DrawTransparentRedShade(pMouse->uMouseClickX, pMouse->uMouseClickY, pTexture);
       else if (!pParty->pPickedItem.IsIdentified())
-        pRenderer->DrawTransparentGreenShade(a2, v6, pTexture);
+        pRenderer->DrawTransparentGreenShade(pMouse->uMouseClickX, pMouse->uMouseClickY, pTexture);
       else
-        pRenderer->DrawTextureTransparent(a2, v6, pTexture);
+        pRenderer->DrawTextureTransparent(pMouse->uMouseClickX, pMouse->uMouseClickY, pTexture);
     }
   }
   else
@@ -450,9 +421,9 @@
 }
 
 //----- (0046A080) --------------------------------------------------------
-void Mouse::Activate(int bActive)
+void Mouse::ChangeActivation(int a1)
 {
-  bActive = bActive;
+  this->bActive = a1;
 }
 
 //----- (0046A08A) --------------------------------------------------------
@@ -818,9 +789,7 @@
         break;
       }
       default:
-      {
         break;
-      }
     }
   }
 }
\ No newline at end of file
--- a/Mouse.h	Fri Feb 14 18:08:30 2014 +0600
+++ b/Mouse.h	Sat Feb 15 16:00:19 2014 +0600
@@ -73,11 +73,11 @@
   void SetActive(bool active);
   void Deactivate();
   void DrawCursor();
-  void _469E1C();
+  void Activate();
   void _469E24();
   void DrawCursorToTarget();
-  void _469EA4();
-  void Activate(int bActive);
+  void ReadCursorWithItem();
+  void ChangeActivation(int a1);
   void SetMouseClick(int x, int y);
 
 
@@ -98,10 +98,10 @@
   int field_34;
   unsigned __int8 *pCursorBitmap2_sysmem;
   unsigned __int16 *pCursorBitmap3_sysmembits_16bit;
-  int field_40;
-  int field_44;
-  int field_48;
-  int field_4C;
+  int uCursorWithItemX;
+  int uCursorWithItemY;
+  int uCursorWithItemW;
+  int uCursorWithItemZ;
   int field_50;
   int field_54;
   int uCursorBitmapPitch;
--- a/ParticleEngine.cpp	Fri Feb 14 18:08:30 2014 +0600
+++ b/ParticleEngine.cpp	Sat Feb 15 16:00:19 2014 +0600
@@ -454,178 +454,101 @@
 //----- (0048B5B3) --------------------------------------------------------
 bool ParticleEngine::ViewProject_TrueIfStillVisible_ODM(unsigned int uID)
 {
-  //ParticleEngine *v2; // ST18_4@1
   int v3; // ebx@1
   int v4; // edi@1
   int v5; // ecx@1
-  //Particle *v6; // esi@1
-  //double v7; // ST14_8@2
-  //double v8; // ST34_8@4
-  //double v9; // ST3C_8@4
-  //int v10; // ST50_4@4
   int v11; // ST44_4@4
-  //double v12; // ST48_8@4
   signed __int64 v13; // qtt@4
-  //int v14; // eax@4
-  //int v15; // ST28_4@4
   int v16; // edi@6
   int v17; // eax@6
-  //double v18; // ST2C_8@8
-  //double v19; // ST34_8@8
-  //int v20; // ST50_4@8
-  //double v21; // ST34_8@8
   signed __int64 v22; // qtt@8
-  //int v23; // eax@8
-  //int v24; // ST28_4@8
-  //int v25; // edx@8
   int v26; // edx@9
-  //int v27; // eax@9
   int v28; // ebx@12
   signed __int64 v29; // qtt@13
-  //int v30; // eax@13
-  //int v31; // ST1C_4@13
-  //double v32; // st7@13
-  //signed int v33; // eax@13
-  //int v34; // ecx@13
-  //float v35; // ST04_4@13
-  //int v36; // eax@13
-  //int v37; // esi@15
-  //double v39; // [sp+10h] [bp-40h]@2
   int v40; // [sp+14h] [bp-3Ch]@12
-  //int v41; // [sp+1Ch] [bp-34h]@2
-  //double v42; // [sp+20h] [bp-30h]@2
-  //int v43; // [sp+24h] [bp-2Ch]@5
   int v44; // [sp+2Ch] [bp-24h]@1
   int v45; // [sp+40h] [bp-10h]@5
   int X_4; // [sp+48h] [bp-8h]@5
-  //int v47; // [sp+4Ch] [bp-4h]@5
-  //int v48; // [sp+4Ch] [bp-4h]@9
-  //int uIDc; // [sp+58h] [bp+8h]@4
-  //int uIDd; // [sp+58h] [bp+8h]@4
-  //int uIDe; // [sp+58h] [bp+8h]@5
-  //int uIDa; // [sp+58h] [bp+8h]@5
-  //int uIDf; // [sp+58h] [bp+8h]@8
-  //int uIDb; // [sp+58h] [bp+8h]@9
 
   v3 = stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX);
   v44 = stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX);
   v4 = stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY);
   v5 = stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY);
 
-  //v6 = &pParticles[uID];
   if (pParticles[uID].type == ParticleType_Invalid)
     return false;
 
-    //v7 = v6->x + 6.7553994e15;
-    //v41 = LODWORD(v7);
-    //v39 = v6->y + 6.7553994e15;
-    //v42 = v6->z + 6.7553994e15;
-    if ( v3 )
+  if ( v3 )
+  {
+    if (pParticles[uID].type & ParticleType_Line)
     {
-      if (pParticles[uID].type & ParticleType_Line)
-      {
-        //v8 = v6->_x + 6.7553994e15;
-        //uIDc = (LODWORD(v8) - pIndoorCamera->pos.x) << 16;
-        //v9 = v6->_y + 6.7553994e15;
-        //v10 = (LODWORD(v9) - pIndoorCamera->pos.y) << 16;
-        v11 = fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v4)
-            + fixpoint_sub_unknown(pParticles[uID].y - pGame->pIndoorCameraD3D->vPartyPos.y, v5);
-        //HIDWORD(v8) = fixpoint_sub_unknown(v6->x - pIndoorCamera->pos.x, v5);
-        //v12 = v6->_z + 6.7553994e15;
-        //uIDd = (LODWORD(v12) - pIndoorCamera->pos.z) << 16;
-        long long _hidword_v12 = fixpoint_mul(v11, v3) + fixpoint_sub_unknown(pParticles[uID].z - pGame->pIndoorCameraD3D->vPartyPos.z, v44);
-        LODWORD(v13) = 0;
-        HIDWORD(v13) = SLOWORD(pODMRenderParams->int_fov_rad);
-        //v14 = v13 / _hidword_v12;
-        pParticles[uID]._screenspace_scale = v13 / _hidword_v12;
-        //v15 = v6->_screenspace_scale;
-        pParticles[uID].uScreenSpaceX = pViewport->uScreenCenterX
-                                      - ((signed int)fixpoint_mul(pParticles[uID]._screenspace_scale, (fixpoint_sub_unknown(pParticles[uID].y
-                                      - pGame->pIndoorCameraD3D->vPartyPos.y, v4)
-                                      - fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v5))) >> 16);
-        pParticles[uID].uScreenSpaceY = pViewport->uScreenCenterY
-                                      - ((signed int)fixpoint_mul(pParticles[uID]._screenspace_scale, (fixpoint_sub_unknown(pParticles[uID].z
-                                      - pGame->pIndoorCameraD3D->vPartyPos.z, v3)
-                                      - fixpoint_mul(v11, v44))) >> 16);
-        pParticles[uID].sZValue = _hidword_v12;
-      }
-      //uIDe = (v41 - pIndoorCamera->pos.x) << 16;
-      //v47 = (LODWORD(v39) - pIndoorCamera->pos.y) << 16;
-      v45 = fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v4) + fixpoint_sub_unknown(pParticles[uID].y
-                                                   - pGame->pIndoorCameraD3D->vPartyPos.y, v5);
-      //HIDWORD(v42) = fixpoint_sub_unknown(v6->x - pIndoorCamera->pos.x, v5);
-      //uIDa = (LODWORD(v42) - pIndoorCamera->pos.z) << 16;
-      X_4 = fixpoint_sub_unknown(pParticles[uID].z - pGame->pIndoorCameraD3D->vPartyPos.z, v44) + fixpoint_mul(v45, v3);
-      if ( X_4 < 0x40000 )
-        return 0;
-      v16 = fixpoint_sub_unknown(pParticles[uID].y - pGame->pIndoorCameraD3D->vPartyPos.y, v4)
-          - fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v5);
-      v17 = fixpoint_sub_unknown(pParticles[uID].z - pGame->pIndoorCameraD3D->vPartyPos.z, v3) - fixpoint_mul(v45, v44);
+      v11 = fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v4)
+          + fixpoint_sub_unknown(pParticles[uID].y - pGame->pIndoorCameraD3D->vPartyPos.y, v5);
+      long long _hidword_v12 = fixpoint_mul(v11, v3) + fixpoint_sub_unknown(pParticles[uID].z - pGame->pIndoorCameraD3D->vPartyPos.z, v44);
+      LODWORD(v13) = 0;
+      HIDWORD(v13) = SLOWORD(pODMRenderParams->int_fov_rad);
+      pParticles[uID]._screenspace_scale = v13 / _hidword_v12;
+      pParticles[uID].uScreenSpaceX = pViewport->uScreenCenterX
+                                    - ((signed int)fixpoint_mul(pParticles[uID]._screenspace_scale, (fixpoint_sub_unknown(pParticles[uID].y
+                                    - pGame->pIndoorCameraD3D->vPartyPos.y, v4)
+                                    - fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v5))) >> 16);
+      pParticles[uID].uScreenSpaceY = pViewport->uScreenCenterY
+                                    - ((signed int)fixpoint_mul(pParticles[uID]._screenspace_scale, (fixpoint_sub_unknown(pParticles[uID].z
+                                    - pGame->pIndoorCameraD3D->vPartyPos.z, v3)
+                                    - fixpoint_mul(v11, v44))) >> 16);
+      pParticles[uID].sZValue = _hidword_v12;
     }
-    else
+    v45 = fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v4) + fixpoint_sub_unknown(pParticles[uID].y
+                                                 - pGame->pIndoorCameraD3D->vPartyPos.y, v5);
+    X_4 = fixpoint_sub_unknown(pParticles[uID].z - pGame->pIndoorCameraD3D->vPartyPos.z, v44) + fixpoint_mul(v45, v3);
+    if ( X_4 < 0x40000 )
+      return 0;
+    v16 = fixpoint_sub_unknown(pParticles[uID].y - pGame->pIndoorCameraD3D->vPartyPos.y, v4)
+        - fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v5);
+    v17 = fixpoint_sub_unknown(pParticles[uID].z - pGame->pIndoorCameraD3D->vPartyPos.z, v3) - fixpoint_mul(v45, v44);
+  }
+  else
+  {
+    if (pParticles[uID].type & ParticleType_Line)
     {
-      if (pParticles[uID].type & ParticleType_Line)
-      {
-        //v18 = v6->_x + 6.7553994e15;
-        //uIDf = (LODWORD(v18) - pIndoorCamera->pos.x) << 16;
-        //v19 = v6->_y + 6.7553994e15;
-        //v20 = (LODWORD(v19) - pIndoorCamera->pos.y) << 16;
-        //v21 = v6->_z + 6.7553994e15;
-        LODWORD(v22) = 0;
-        HIDWORD(v22) = SLOWORD(pODMRenderParams->int_fov_rad);
-        long long _var_123 = fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v4)
-                           + fixpoint_sub_unknown(pParticles[uID].y - pGame->pIndoorCameraD3D->vPartyPos.y, v5);
-        //v23 = v22 / _var_123;
-        pParticles[uID]._screenspace_scale = v22 / _var_123;
-        //v24 = v6->_screenspace_scale;
-        pParticles[uID].uScreenSpaceX = pViewport->uScreenCenterX
-                          - ((signed int)fixpoint_mul(pParticles[uID]._screenspace_scale, (fixpoint_sub_unknown(pParticles[uID].y
-                          - pGame->pIndoorCameraD3D->vPartyPos.y, v4)
-                          - fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v5))) >> 16);
-        pParticles[uID].uScreenSpaceY = pViewport->uScreenCenterY - (fixpoint_sub_unknown(pParticles[uID].z, pParticles[uID]._screenspace_scale) >> 16);
-        pParticles[uID].sZValue = _var_123;
-      }
-      //uIDb = (v41 - pIndoorCamera->pos.x) << 16;
-      //v48 = (LODWORD(v39) - pIndoorCamera->pos.y) << 16;
-      v26 = fixpoint_sub_unknown(pParticles[uID].y - pGame->pIndoorCameraD3D->vPartyPos.y, v5);
-      //v27 = v26 + ((unsigned __int64)(uIDb * (signed __int64)v4) >> 16);
-      X_4 = v26 + fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v4);
-      if ( X_4 < 0x40000 || X_4 > (pODMRenderParams->uPickDepth - 1000) << 16 )
-        return 0;
-      v17 = pParticles[uID].z;
-      v16 = fixpoint_sub_unknown(pParticles[uID].y - pGame->pIndoorCameraD3D->vPartyPos.y, v4)
-          - fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v5);
+      LODWORD(v22) = 0;
+      HIDWORD(v22) = SLOWORD(pODMRenderParams->int_fov_rad);
+      long long _var_123 = fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v4)
+                         + fixpoint_sub_unknown(pParticles[uID].y - pGame->pIndoorCameraD3D->vPartyPos.y, v5);
+      pParticles[uID]._screenspace_scale = v22 / _var_123;
+      pParticles[uID].uScreenSpaceX = pViewport->uScreenCenterX
+                        - ((signed int)fixpoint_mul(pParticles[uID]._screenspace_scale, (fixpoint_sub_unknown(pParticles[uID].y
+                        - pGame->pIndoorCameraD3D->vPartyPos.y, v4)
+                        - fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v5))) >> 16);
+      pParticles[uID].uScreenSpaceY = pViewport->uScreenCenterY - (fixpoint_sub_unknown(pParticles[uID].z, pParticles[uID]._screenspace_scale) >> 16);
+      pParticles[uID].sZValue = _var_123;
     }
-    v40 = v17;
-    v28 = abs(v16);
-    if ( abs(X_4) >= v28 )
-    {
-      LODWORD(v29) = 0;
-      HIDWORD(v29) = SLOWORD(pODMRenderParams->int_fov_rad);
-      //v30 = v29 / X_4;
-      pParticles[uID]._screenspace_scale = v29 / X_4;
-      //v31 = v6->_screenspace_scale;
-      pParticles[uID].uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)fixpoint_mul(pParticles[uID]._screenspace_scale, v16) >> 16);
-      //v33 = (signed int)fixpiont_mul(v6->_screenspace_scale, v40) >> 16;
-      //v34 = pViewport->uScreenCenterY - v33;
-      pParticles[uID].uScreenSpaceY = pViewport->uScreenCenterY - (signed int)fixpoint_mul(pParticles[uID]._screenspace_scale, v40) >> 16;
-      pParticles[uID]._screenspace_scale = fixpoint_mul(fixpoint_from_float(pParticles[uID].flt_28), pParticles[uID]._screenspace_scale);
-      pParticles[uID].sZValue = X_4;
-      //v36 = v6->uScreenSpaceX;
-      if ( pParticles[uID].uScreenSpaceX >= (signed int)pViewport->uViewportTL_X )
-      {
-        if ( pParticles[uID].uScreenSpaceX < (signed int)pViewport->uViewportBR_X )
-        {
-          //v37 = v6->uScreenSpaceY;
-          if ( pParticles[uID].uScreenSpaceY >= (signed int)pViewport->uViewportTL_Y )
-          {
-            if ( pParticles[uID].uScreenSpaceY < (signed int)pViewport->uViewportBR_Y )
-              return 1;
-          }
-        }
-      }
-    }
-    return false;
+    v26 = fixpoint_sub_unknown(pParticles[uID].y - pGame->pIndoorCameraD3D->vPartyPos.y, v5);
+    X_4 = v26 + fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v4);
+    if ( X_4 < 0x40000 || X_4 > (pODMRenderParams->uPickDepth - 1000) << 16 )
+      return 0;
+    v17 = pParticles[uID].z;
+    v16 = fixpoint_sub_unknown(pParticles[uID].y - pGame->pIndoorCameraD3D->vPartyPos.y, v4)
+        - fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v5);
+  }
+  v40 = v17;
+  v28 = abs(v16);
+  if ( abs(X_4) >= v28 )
+  {
+    LODWORD(v29) = 0;
+    HIDWORD(v29) = SLOWORD(pODMRenderParams->int_fov_rad);
+    pParticles[uID]._screenspace_scale = v29 / X_4;
+    pParticles[uID].uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)fixpoint_mul(pParticles[uID]._screenspace_scale, v16) >> 16);
+    pParticles[uID].uScreenSpaceY = pViewport->uScreenCenterY - ((signed int)fixpoint_mul(pParticles[uID]._screenspace_scale, v40) >> 16);
+    pParticles[uID]._screenspace_scale = fixpoint_mul(fixpoint_from_float(pParticles[uID].flt_28), pParticles[uID]._screenspace_scale);
+    pParticles[uID].sZValue = X_4;
+    if ( pParticles[uID].uScreenSpaceX >= (signed int)pViewport->uViewportTL_X
+      && pParticles[uID].uScreenSpaceX < (signed int)pViewport->uViewportBR_X
+      && pParticles[uID].uScreenSpaceY >= (signed int)pViewport->uViewportTL_Y
+      && pParticles[uID].uScreenSpaceY < (signed int)pViewport->uViewportBR_Y )
+      return true;
+  }
+  return false;
 }
 
 //----- (0048BBA6) --------------------------------------------------------
--- a/Render.cpp	Fri Feb 14 18:08:30 2014 +0600
+++ b/Render.cpp	Sat Feb 15 16:00:19 2014 +0600
@@ -1954,11 +1954,11 @@
 //----- (0049E992) --------------------------------------------------------
 Render::Render()
 {
-  Render *v1; // esi@1
+  //Render *v1; // esi@1
   int v2; // eax@1
   char v3; // zf@1
 
-  v1 = this;
+  //v1 = this;
   this->pDirectDraw4 = 0;
   this->pFrontBuffer4 = 0;
   this->pBackBuffer4 = 0;
@@ -1969,41 +1969,41 @@
   //this->pSomeSurface2 = 0;
   //RenderHWLContainer::RenderHWLContainer(&this->pD3DBitmaps);
   //RenderHWLContainer::RenderHWLContainer(&v1->pD3DSprites);
-  v1->bWindowMode = 1;
-  //v1->field_40054 = 0;
-  //v1->field_10 = 640;
-  //v1->field_14 = 480;
-  //v1->field_40030 = 0;
-  //v1->field_4002C = 0;
-  v1->pActiveZBuffer = 0;
-  v1->pDefaultZBuffer = 0;
-  v1->raster_clip_y = 0;
-  v1->raster_clip_x = 0;
-  v1->raster_clip_z = 639;
-  v1->raster_clip_w = 479;
-  //v1->field_4003C = 0x004EED80;
-  //v1->field_40040 = dword_4EED78;
-  v1->uClipZ = 640;
-  //v1->field_40044 = 2;
-  //v1->field_40048 = 6;
-  v1->pFrontBuffer4 = 0;
-  v1->pBackBuffer4 = 0;
-  //v1->pColorKeySurface4 = 0;
-  v1->pDirectDraw4 = 0;
-  v1->pRenderD3D = 0;
-  v1->uNumSceneBegins = 0;
-  v1->uNumD3DSceneBegins = 0;
-  v1->using_software_screen_buffer = 0;
-  v1->pTargetSurface = 0;
-  v1->uTargetSurfacePitch = 0;
-  v1->uClipY = 0;
-  v1->uClipX = 0;
-  v1->uClipW = 480;
-  v1->bClip = 1;
-  //v1->bColorKeySupported = 0;
-  v1->bRequiredTextureStagesAvailable = 0;
-  v1->bTinting = 1;
-  //LOBYTE(v1->field_103668) = 0;
+  this->bWindowMode = 1;
+  //this->field_40054 = 0;
+  //this->field_10 = 640;
+  //this->field_14 = 480;
+  //this->field_40030 = 0;
+  //this->field_4002C = 0;
+  this->pActiveZBuffer = 0;
+  this->pDefaultZBuffer = 0;
+  this->raster_clip_y = 0;
+  this->raster_clip_x = 0;
+  this->raster_clip_z = 639;
+  this->raster_clip_w = 479;
+  //this->field_4003C = 0x004EED80;
+  //this->field_40040 = dword_4EED78;
+  this->uClipZ = 640;
+  //this->field_40044 = 2;
+  //this->field_40048 = 6;
+  this->pFrontBuffer4 = 0;
+  this->pBackBuffer4 = 0;
+  //this->pColorKeySurface4 = 0;
+  this->pDirectDraw4 = 0;
+  this->pRenderD3D = 0;
+  this->uNumSceneBegins = 0;
+  this->uNumD3DSceneBegins = 0;
+  this->using_software_screen_buffer = 0;
+  this->pTargetSurface = 0;
+  this->uTargetSurfacePitch = 0;
+  this->uClipY = 0;
+  this->uClipX = 0;
+  this->uClipW = 480;
+  this->bClip = 1;
+  //this->bColorKeySupported = 0;
+  this->bRequiredTextureStagesAvailable = 0;
+  this->bTinting = 1;
+  //LOBYTE(this->field_103668) = 0;
   uNumBillboardsToDraw = 0;
   bFogEnabled = false;
 
--- a/UI/UIPartyCreation.cpp	Fri Feb 14 18:08:30 2014 +0600
+++ b/UI/UIPartyCreation.cpp	Sat Feb 15 16:00:19 2014 +0600
@@ -580,9 +580,7 @@
       DispatchMessageA(&Msg);
     }
     if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE)
-    {
       WaitMessage();
-    }
     else
     {
       PlayerCreationUI_Draw();
--- a/UI/UIPopup.cpp	Fri Feb 14 18:08:30 2014 +0600
+++ b/UI/UIPopup.cpp	Sat Feb 15 16:00:19 2014 +0600
@@ -425,7 +425,7 @@
 // 506128: using guessed type int areWeLoadingTexture;
 
 //----- (0041E360) --------------------------------------------------------
-void MonsterPopup_Draw(unsigned int uActorID, GUIWindow *window)
+void MonsterPopup_Draw(unsigned int uActorID, GUIWindow *pWindow)
 {
   int v8; // eax@4
   unsigned __int16 v9; // dx@4
@@ -512,18 +512,18 @@
   v106.pTarget = pRenderer->pTargetSurface;
   v106.pTargetZ = pRenderer->pActiveZBuffer;
   v106.uTargetPitch = pRenderer->uTargetSurfacePitch;
-  v106.uViewportX = window->uFrameX + 13;
-  v106.uViewportY = window->uFrameY + 52;
-  v106.uViewportW = (window->uFrameY + 52) + 128;
+  v106.uViewportX = pWindow->uFrameX + 13;
+  v106.uViewportY = pWindow->uFrameY + 52;
+  v106.uViewportW = (pWindow->uFrameY + 52) + 128;
   v106.uViewportZ = v106.uViewportX + 128;
   v106.uScreenSpaceX = (signed int)(v106.uViewportX + 128 + v106.uViewportX) / 2;
   v106._screenspace_x_scaler_packedfloat = 65536;
   v106._screenspace_y_scaler_packedfloat = 65536;
-  v106.uScreenSpaceY = v115 + (window->uFrameY + 52) + pSprites_LOD->pSpriteHeaders[v10->pHwSpriteIDs[0]].uHeight;
+  v106.uScreenSpaceY = v115 + (pWindow->uFrameY + 52) + pSprites_LOD->pSpriteHeaders[v10->pHwSpriteIDs[0]].uHeight;
   v106.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v10->uPaletteIndex, 0, 1);
   v106.sZValue = 0;
   v106.uFlags = 0;
-  pRenderer->SetRasterClipRect(0, 0, 639, 479);
+  pRenderer->SetRasterClipRect(0, 0, window->GetWidth() - 1, window->GetHeight() - 1);
   pRenderer->RasterLine2D(v106.uViewportX - 1, v106.uViewportY - 1, v106.uViewportX + 129, v106.uViewportY - 1, Color16(0xE1u, 255, 0x9Bu));//горизонтальная верхняя линия
   pRenderer->RasterLine2D(v106.uViewportX - 1, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportY - 1, Color16(0xE1u, 255, 0x9Bu));//горизонтальная нижняя линия
   pRenderer->RasterLine2D(v106.uViewportX + 129, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportW + 1, Color16(0xE1u, 255, 0x9Bu));//левая вертикальная линия
@@ -662,9 +662,9 @@
     else
       strncpy(pTmpBuf.data(), pMonsterStats->pInfos[pActors[uActorID].pMonsterInfo.uID].pName, 2000);
   }
-  window->DrawTitleText(pFontComic, 0, 0xCu, Color16(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
+  pWindow->DrawTitleText(pFontComic, 0, 0xCu, Color16(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
   //health bar
-  Actor::DrawHealthBar(&pActors[uActorID], window);
+  Actor::DrawHealthBar(&pActors[uActorID], pWindow);
 
   normal_level = 0;
   expert_level = 0;
@@ -734,9 +734,9 @@
     for_effects = 1;
   }
 
-  window->DrawText(pFontSmallnum, 12, 196, Color16(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[631], 0, 0, 0);//Effects
+  pWindow->DrawText(pFontSmallnum, 12, 196, Color16(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[631], 0, 0, 0);//Effects
   if ( !for_effects && false)
-    window->DrawText(pFontSmallnum, 28, LOBYTE(pFontSmallnum->uFontHeight) + 193, Color16(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[630], 0, 0, 0);//?
+    pWindow->DrawText(pFontSmallnum, 28, LOBYTE(pFontSmallnum->uFontHeight) + 193, Color16(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[630], 0, 0, 0);//?
   else
   {
     pText = "";
@@ -834,30 +834,30 @@
         }
         if ( _stricmp(pText, "" ))
         {
-          window->DrawText(pFontSmallnum, 28, pTextHeight, GetSpellColor(pTextColorID), pText, 0, 0, 0);
+          pWindow->DrawText(pFontSmallnum, 28, pTextHeight, GetSpellColor(pTextColorID), pText, 0, 0, 0);
           pTextHeight = pTextHeight + *(char *)((int)pFontSmallnum + 5) - 3;
         }
       }
     }
     if ( !_stricmp(pText,"" ))
-      window->DrawText(pFontSmallnum, 28, pTextHeight, Color16(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[153], 0, 0, 0);//Нет
+      pWindow->DrawText(pFontSmallnum, 28, pTextHeight, Color16(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[153], 0, 0, 0);//Нет
   }
 
   if ( normal_level )
   {
     sprintf(pTmpBuf.data(), "%s\f%05u\t100%d\n", pGlobalTXT_LocalizationStrings[108], 0, pActors[uActorID].pMonsterInfo.uHP);
-    window->DrawText(pFontSmallnum, 150, (int)v106.uViewportY, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+    pWindow->DrawText(pFontSmallnum, 150, (int)v106.uViewportY, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
     pTextHeight = v106.uViewportY + LOBYTE(pFontSmallnum->uFontHeight) - 3;
     sprintf(pTmpBuf.data(), "%s\f%05u\t100%d\n", pGlobalTXT_LocalizationStrings[12], 0, pActors[uActorID].pMonsterInfo.uAC);//Armor Class
   }
   else
   {
     sprintf(pTmpBuf.data(), "%s\f%05u\t100%s\n", pGlobalTXT_LocalizationStrings[108], 0, pGlobalTXT_LocalizationStrings[630]);//?   - [630] actually displays a question mark
-    window->DrawText(pFontSmallnum, 150, (int)v106.uViewportY, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+    pWindow->DrawText(pFontSmallnum, 150, (int)v106.uViewportY, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
     pTextHeight = v106.uViewportY + LOBYTE(pFontSmallnum->uFontHeight) - 3;
     sprintf(pTmpBuf.data(), "%s\f%05u\t100%s\n", pGlobalTXT_LocalizationStrings[12], 0, pGlobalTXT_LocalizationStrings[630]);//?   - [630] actually displays a question mark
   }
-  window->DrawText(pFontSmallnum, 150, pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+  pWindow->DrawText(pFontSmallnum, 150, pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
   pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 6 + LOBYTE(pFontSmallnum->uFontHeight);
 
   content[0] = pGlobalTXT_LocalizationStrings[87];
@@ -875,7 +875,7 @@
   if ( expert_level )
   {
     sprintf(pTmpBuf.data(), "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[18], 0, content[pActors[uActorID].pMonsterInfo.uAttack1Type]);//Attack
-    window->DrawText(pFontSmallnum, 150, (int)pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+    pWindow->DrawText(pFontSmallnum, 150, (int)pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
     pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
     if ( pActors[uActorID].pMonsterInfo.uAttack1DamageBonus )
       sprintf(pTmpBuf.data(), "%s\f%05u\t080%dd%d+%d\n", pGlobalTXT_LocalizationStrings[53],
@@ -887,17 +887,17 @@
   else
   {
     sprintf(pTmpBuf.data(), "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[18], 0, pGlobalTXT_LocalizationStrings[630]);
-    window->DrawText(pFontSmallnum, 150, (int)pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+    pWindow->DrawText(pFontSmallnum, 150, (int)pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
     pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
     sprintf(pTmpBuf.data(), "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[53], 0, pGlobalTXT_LocalizationStrings[630]);
   }
-  window->DrawText(pFontSmallnum, 150, pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+  pWindow->DrawText(pFontSmallnum, 150, pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
   pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 6 + LOBYTE(pFontSmallnum->uFontHeight);
 
   if ( !master_level )
   {
     sprintf(pTmpBuf.data(), "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[628], 0, pGlobalTXT_LocalizationStrings[630]);//"Spell" "?"
-    window->DrawText(pFontSmallnum, 150, (int)pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+    pWindow->DrawText(pFontSmallnum, 150, (int)pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
     pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
   }
   else
@@ -908,24 +908,24 @@
     if ( pActors[uActorID].pMonsterInfo.uSpell1ID )
     {
       sprintf(pTmpBuf.data(), "%s\f%05u\t070%s\n", pText, 0, pSpellStats->pInfos[pActors[uActorID].pMonsterInfo.uSpell1ID].pShortName);//"%s\f%05u\t060%s\n"
-      window->DrawText(pFontSmallnum, 150, (int)pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+      pWindow->DrawText(pFontSmallnum, 150, (int)pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
       pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
     }
     if ( pActors[uActorID].pMonsterInfo.uSpell2ID )
     {
       sprintf(pTmpBuf.data(), "\f%05u\t070%s\n", 0, pSpellStats->pInfos[pActors[uActorID].pMonsterInfo.uSpell2ID].pShortName);//"%s\f%05u\t060%s\n"
-      window->DrawText(pFontSmallnum, 150, (int)pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+      pWindow->DrawText(pFontSmallnum, 150, (int)pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
       pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
     }
     if ( !pActors[uActorID].pMonsterInfo.uSpell1ID && !pActors[uActorID].pMonsterInfo.uSpell2ID )
     {
       sprintf(pTmpBuf.data(), "%s\f%05u\t070%s\n", pGlobalTXT_LocalizationStrings[628], 0, pGlobalTXT_LocalizationStrings[153]);//"%s\f%05u\t060%s\n"
-      window->DrawText(pFontSmallnum, 150, (int)pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+      pWindow->DrawText(pFontSmallnum, 150, (int)pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
       pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
     }
   }
   pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
-  window->DrawText(pFontSmallnum, 150, pTextHeight, Color16(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[626], 0, 0, 0);//Immune
+  pWindow->DrawText(pFontSmallnum, 150, pTextHeight, Color16(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[626], 0, 0, 0);//Immune
   pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
 
   string_name[0] = pGlobalTXT_LocalizationStrings[87];//Fire
@@ -966,7 +966,7 @@
           pText = pGlobalTXT_LocalizationStrings[153];//None
       }
       sprintf(pTmpBuf.data(), "%s\f%05u\t070%s\n", string_name[i], 0, pText);
-      window->DrawText(pFontSmallnum, 170, pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+      pWindow->DrawText(pFontSmallnum, 170, pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
       pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
     }
   }
@@ -975,7 +975,7 @@
     for ( uint i = 0; i < 10; ++i )
     {
       sprintf(pTmpBuf.data(), "%s\f%05u\t070%s\n", string_name[i], 0, pGlobalTXT_LocalizationStrings[630]); // "?"
-      window->DrawText(pFontSmallnum, 170, pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+      pWindow->DrawText(pFontSmallnum, 170, pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
       pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
     }
   }
@@ -984,7 +984,7 @@
   {
     sprintf(pTmpBuf.data(), "%s: %d", pGlobalTXT_LocalizationStrings[650], pActors[uActorID].sCurrentHP);//Current Hit Points
     pFontSmallnum->GetLineWidth(pTmpBuf.data());
-    window->DrawTitleText(pFontSmallnum, 0, window->uFrameHeight - LOBYTE(pFontSmallnum->uFontHeight) - 12, 0, pTmpBuf.data(), 3);
+    pWindow->DrawTitleText(pFontSmallnum, 0, pWindow->uFrameHeight - LOBYTE(pFontSmallnum->uFontHeight) - 12, 0, pTmpBuf.data(), 3);
   }
 }
 
--- a/UI/UiGame.cpp	Fri Feb 14 18:08:30 2014 +0600
+++ b/UI/UiGame.cpp	Sat Feb 15 16:00:19 2014 +0600
@@ -1164,7 +1164,7 @@
 
   pMouse->uPointingObjectID = 0;
   pMouse->GetClickPos(&pX, &pY);
-  if ( pX < 0 || pX > 639 || pY < 0 || pY > 479 )//границы окна игры
+  if ( pX < 0 || pX > window->GetWidth() - 1 || pY < 0 || pY > window->GetHeight() - 1 )//границы окна игры
     return;
   if ( pX <= 467 && pY <= 351 )//пределы основной области
   {
@@ -1441,7 +1441,7 @@
       }
     }
   }//конец пределов основного экрана------------------------
-  if ( pX > 467 && pX <=639 && pY <= 479 )//пределы правой области
+  if ( pX > 467 && pX <= window->GetWidth() - 1 && pY <= window->GetHeight() - 1 )//пределы правой области
   {
     if ( pCurrentScreen == SCREEN_GAME )
     {
--- a/VideoPlayer.cpp	Fri Feb 14 18:08:30 2014 +0600
+++ b/VideoPlayer.cpp	Sat Feb 15 16:00:19 2014 +0600
@@ -858,7 +858,7 @@
         pRenderer->BeginScene();
         pMouse->DrawCursorToTarget();
         SmackUpdatePalette();
-        pMouse->_469EA4();
+        pMouse->ReadCursorWithItem();
         pRenderer->EndScene();
       }
       else if ( pBinkMovie && !BinkWait(pBinkMovie) )
@@ -866,7 +866,7 @@
         pRenderer->BeginScene();
         pMouse->DrawCursorToTarget();
         BinkUpdatePalette();
-        pMouse->_469EA4();
+        pMouse->ReadCursorWithItem();
         pRenderer->EndScene();
       }
 	  */
@@ -875,7 +875,7 @@
 		pRenderer->BeginScene();
 		pMouse->DrawCursorToTarget();
 		UpdatePalette();
-		pMouse->_469EA4();
+		pMouse->ReadCursorWithItem();
 		pRenderer->EndScene();
 	}
 }
--- a/_deleted.cpp	Fri Feb 14 18:08:30 2014 +0600
+++ b/_deleted.cpp	Sat Feb 15 16:00:19 2014 +0600
@@ -12282,7 +12282,7 @@
     pRenderer->ChangeBetweenWinFullscreenModes();
   vsprintf(pTmpBuf.data(), Format, va);
   if ( pMouse )
-    pMouse->Activate(0);
+    pMouse->ChangeActivation(0);
   ClipCursor(0);
   MessageBoxA(0, pTmpBuf.data(), "Error", 0x30u);
   Game_DeinitializeAndTerminate(1);
--- a/mm7_2.cpp	Fri Feb 14 18:08:30 2014 +0600
+++ b/mm7_2.cpp	Sat Feb 15 16:00:19 2014 +0600
@@ -2861,8 +2861,8 @@
   pCurrentScreen = SCREEN_GAME;
 
   pGUIWindow2 = 0;
-  pAudioPlayer->StopChannels(-1, -1);
-  pMouse->RemoveHoldingItem();
+  pAudioPlayer->StopChannels(-1, -1);//остановить/подготовить канал
+  pMouse->RemoveHoldingItem();//установть курсор
 
   pIcons_LOD->_inlined_sub2();
 
@@ -4146,7 +4146,6 @@
       bNoMargareth = true;
   }
 
-
   /*v8 = _4AC1C9_get_cpu_speed(0, (Vec4_int_ *)a2);
   Rect.left = *(int *)v8;
   Rect.top = *(int *)(v8 + 4);
@@ -4164,134 +4163,127 @@
     return 1;
   }
 
-    pEventTimer->Pause();
-
-    SetUserInterface(PartyAlignment_Neutral, false);
-    ShowIntroVideo_and_LoadingScreen();
-    WriteWindowsRegistryInt("Ran once", 1);
-    dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000;
-    pGame->InitializeGammaController();
-    SecondaryInitialization();
-    pRenderer->SetRasterClipRect(0, 0, 639, 479);
-    FinalInitialization();
-
-    Log::Warning(L"MM: entering main loop");
+  pEventTimer->Pause();
+
+  SetUserInterface(PartyAlignment_Neutral, false);
+  ShowIntroVideo_and_LoadingScreen();
+  WriteWindowsRegistryInt("Ran once", 1);
+  dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000;
+  pGame->InitializeGammaController();
+  SecondaryInitialization();
+  pRenderer->SetRasterClipRect(0, 0, window->GetWidth() - 1, window->GetHeight() - 1);
+  FinalInitialization();
+  Log::Warning(L"MM: entering main loop");
+  while ( 1 )
+  {
+    MainMenuWindow* main_menu_window = MainMenuWindow::Create();
+    window->AddControl(main_menu_window);
+    MainMenu_Loop();
+    uGameState = GAME_STATE_PLAYING;
     while ( 1 )
     {
-      MainMenuWindow* main_menu_window = MainMenuWindow::Create();
-      window->AddControl(main_menu_window);
-
-      MainMenu_Loop();
-      uGameState = GAME_STATE_PLAYING;
-      while ( 1 )
+      if (uGameState == GAME_FINISHED || GetCurrentMenuID() == MENU_EXIT_GAME)
+      {
+        pGame->Deinitialize();
+        return true;
+      }
+
+      if (GetCurrentMenuID() == MENU_NEWGAME)
       {
-        if (uGameState == GAME_FINISHED || GetCurrentMenuID() == MENU_EXIT_GAME)
+        if ( pAudioPlayer->hAILRedbook )
+          AIL_redbook_stop(pAudioPlayer->hAILRedbook);
+        pParty->Reset();
+        pOtherOverlayList->Reset();
+        strcpy(pCurrentMapName, pStartingMapName);
+        pParty->CreateDefaultParty(0);
+        PlayerCreationUI_Initialize();
+        if ( PlayerCreationUI_Loop() )
         {
-          pGame->Deinitialize();
-          return true;
-        }
-
-        if (GetCurrentMenuID() == MENU_NEWGAME)
-        {
-          if ( pAudioPlayer->hAILRedbook )
-            AIL_redbook_stop(pAudioPlayer->hAILRedbook);
-          pParty->Reset();
-          pOtherOverlayList->Reset();
-
-          strcpy(pCurrentMapName, pStartingMapName);
-          pParty->CreateDefaultParty(0);
-          PlayerCreationUI_Initialize();
-          if ( PlayerCreationUI_Loop() )
-          {
-            DeleteCCharFont();
-            break;
-          }
           DeleteCCharFont();
-          bFlashQuestBook = true;
-          PlayFullscreenMovie(MOVIE_Emerald);
-          //pGame->pCShow->PlayMovie(MOVIE_Emerald, 0);
-          SaveNewGame();
-
-          if (bNoMargareth)
-            _449B7E_toggle_bit(pParty->_quest_bits, PARTY_QUEST_EMERALD_MARGARETH_OFF, 1);
-          pGame->Loop();
-
-          if (uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU)
-          {
-            SetCurrentMenuID(MENU_NEWGAME);
-            uGameState = GAME_STATE_PLAYING;
-            continue;
-          }
-          else if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU)
-            break;
-
-          assert(false && "Invalid game state");
-        }
-        if (GetCurrentMenuID() == MENU_CREDITS)
-        {
-         if ( pAudioPlayer->hAILRedbook )
-          AIL_redbook_stop(pAudioPlayer->hAILRedbook);
-         MainMenuUI_Credits_Loop();
-         break;
-        }
-        if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu)
-        {
-          uGameState = GAME_STATE_PLAYING;
-		  pGame->Loop();
+          break;
         }
-        else
-        {
-          if (GetCurrentMenuID() == MENU_DebugBLVLevel)
-		  {
-			  pMouse->Activate(0);
-
-			  pParty->Reset();
-			  pParty->CreateDefaultParty(1);
-              
-              __debugbreak();
-              /*extern void CreateDefaultBLVLevel();
-			  CreateDefaultBLVLevel();
-
-			  OPENFILENAMEA ofn;
-			  if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) )
-			  {
-				pMouse->Activate(1);
-				break;
-			  }
-			  _chdir("..\\");
-			  strcpy(pCurrentMapName, ofn.lpstrFileTitle);*/
-			  pMouse->Activate(1);
-			  pGame->Loop();
-		  }
-        }
-        if ( uGameState == GAME_STATE_LOADING_GAME )
-        {
-          SetCurrentMenuID(MENU_5);
-          uGameState = GAME_STATE_PLAYING;
-          continue;
-        }
-        if ( uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU )
+        DeleteCCharFont();
+        bFlashQuestBook = true;
+        PlayFullscreenMovie(MOVIE_Emerald);
+        //pGame->pCShow->PlayMovie(MOVIE_Emerald, 0);
+        SaveNewGame();
+        if (bNoMargareth)
+          _449B7E_toggle_bit(pParty->_quest_bits, PARTY_QUEST_EMERALD_MARGARETH_OFF, 1);
+        pGame->Loop();
+        if (uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU)
         {
           SetCurrentMenuID(MENU_NEWGAME);
           uGameState = GAME_STATE_PLAYING;
           continue;
         }
-        if ( uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU)// from the loaded game
+        else if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU)
+          break;
+        assert(false && "Invalid game state");
+      }
+      if (GetCurrentMenuID() == MENU_CREDITS)
+      {
+        if ( pAudioPlayer->hAILRedbook )
+          AIL_redbook_stop(pAudioPlayer->hAILRedbook);
+        MainMenuUI_Credits_Loop();
+        break;
+      }
+      if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu)
+      {
+        uGameState = GAME_STATE_PLAYING;
+        pGame->Loop();
+      }
+      else
+      {
+        if (GetCurrentMenuID() == MENU_DebugBLVLevel)
         {
-          pAudioPlayer->StopChannels(-1, -1);
-          uGameState = GAME_STATE_PLAYING;
-          break;
+          pMouse->ChangeActivation(0);
+          pParty->Reset();
+          pParty->CreateDefaultParty(1);
+
+          __debugbreak();
+          /*extern void CreateDefaultBLVLevel();
+          CreateDefaultBLVLevel();
+
+          OPENFILENAMEA ofn;
+          if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) )
+          {
+            pMouse->ChangeActivation(1);
+            break;
+          }
+          _chdir("..\\");
+          strcpy(pCurrentMapName, ofn.lpstrFileTitle);*/
+          pMouse->ChangeActivation(1);
+          pGame->Loop();
         }
       }
-      if (!bNoSound && pAudioPlayer->hAILRedbook)
+      if ( uGameState == GAME_STATE_LOADING_GAME )
+      {
+        SetCurrentMenuID(MENU_5);
+        uGameState = GAME_STATE_PLAYING;
+        continue;
+      }
+      if ( uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU )
       {
-        pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f);
-        AIL_redbook_stop(pAudioPlayer->hAILRedbook);
-        unsigned int startms, end_ms;
-        AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 0xE, &startms, &end_ms);
-        AIL_redbook_play(pAudioPlayer->hAILRedbook, startms + 1, end_ms);
+        SetCurrentMenuID(MENU_NEWGAME);
+        uGameState = GAME_STATE_PLAYING;
+        continue;
+      }
+      if ( uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU)// from the loaded game
+      {
+        pAudioPlayer->StopChannels(-1, -1);
+        uGameState = GAME_STATE_PLAYING;
+        break;
       }
     }
+    if (!bNoSound && pAudioPlayer->hAILRedbook)
+    {
+      pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f);
+      AIL_redbook_stop(pAudioPlayer->hAILRedbook);
+      unsigned int startms, end_ms;
+      AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &startms, &end_ms);
+      AIL_redbook_play(pAudioPlayer->hAILRedbook, startms + 1, end_ms);
+    }
+  }
   //lua_close(L);
   pGame->Deinitialize();
   return 1;
--- a/mm7_3.cpp	Fri Feb 14 18:08:30 2014 +0600
+++ b/mm7_3.cpp	Sat Feb 15 16:00:19 2014 +0600
@@ -3369,8 +3369,8 @@
   v2 = a1;
   v10.uViewportX = 0;
   v10.uViewportY = 0;
-  v10.uViewportZ = 639;
-  v10.uViewportW = 479;
+  v10.uViewportZ = window->GetWidth() - 1;
+  v10.uViewportW = window->GetHeight() - 1;
   v12 = 0;
   //v3 = (char *)&pOtherOverlayList->pOverlays[0].field_C;
   //do
--- a/mm7_5.cpp	Fri Feb 14 18:08:30 2014 +0600
+++ b/mm7_5.cpp	Sat Feb 15 16:00:19 2014 +0600
@@ -134,7 +134,7 @@
     else //damage from spells(повреждения от заклов(метеоритный дождь))
     {
       v23 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id];
-      v24 = ((signed int)pParty->uPartyHeight >> 1) - AttackerInfo.pZs[attacker_id];
+      v24 = ((signed int)pParty->uPartyHeight / 2) - AttackerInfo.pZs[attacker_id];
       a1 = pParty->vPosition.x - AttackerInfo.pXs[attacker_id];
       v48 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id];
       if ( a1 * a1 + v23 * v23 + (pParty->vPosition.z + v24) * (pParty->vPosition.z + v24) < (unsigned int)((AttackerInfo.field_324[attacker_id] + 32) * (AttackerInfo.field_324[attacker_id] + 32)) )