changeset 2215:e9625ad08541

fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
author Ritor1
date Fri, 14 Feb 2014 18:08:30 +0600
parents 20995bb8895a
children 3f375342de12
files Arcomage.cpp CastSpellInfo.cpp Chest.cpp Events.cpp GUIButton.cpp GUIWindow.cpp Game.cpp Indoor.cpp LOD.cpp Mouse.cpp NPC.cpp Render.cpp UI/UICharacter.cpp UI/UIHouses.cpp UI/UIMainMenu.cpp UI/UIPartyCreation.cpp UI/UIRest.cpp UI/UISaveLoad.cpp UI/UIShops.cpp UI/UITransition.cpp UI/UiGame.cpp VideoPlayer.cpp mm7_2.cpp mm7_3.cpp mm7_4.cpp mm7_5.cpp mm7_data.cpp
diffstat 27 files changed, 310 insertions(+), 337 deletions(-) [+]
line wrap: on
line diff
--- a/Arcomage.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/Arcomage.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -455,8 +455,8 @@
 
   pSrcRect.left   = 0;
   pSrcRect.top    = 0;
-  pSrcRect.right  = 640;
-  pSrcRect.bottom = 480;
+  pSrcRect.right  = window->GetWidth();
+  pSrcRect.bottom = window->GetHeight();
 
   pRenderer->BeginScene();
   pArcomageGame->pBlit_Copy_pixels = pPixels;
@@ -1607,9 +1607,9 @@
       pTargetXY.x = 0;
       pTargetXY.y = 0;
       pSrcXYZW.left = 0;
-      pSrcXYZW.right = 640;
+      pSrcXYZW.right = window->GetWidth();
       pSrcXYZW.top = 0;
-      pSrcXYZW.bottom = 480;
+      pSrcXYZW.bottom = window->GetHeight();
       am_BeginScene(pArcomageGame->pBackgroundPixels, -1, 1);
       pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
       am_EndScene();
@@ -2126,8 +2126,8 @@
 
   v0 = GetPlayerHandCardCount(current_player_num);
   pTargetXY.y = 327;
-  v24 = (640 - 96 * v0) / (v0 + 1);
-  pTargetXY.x = (640 - 96 * v0) / (v0 + 1);
+  v24 = (window->GetWidth() - 96 * v0) / (v0 + 1);
+  pTargetXY.x = (window->GetWidth() - 96 * v0) / (v0 + 1);
   for ( v2 = 0; v2 < v0; ++v2 )
   {
     //v3 = current_player_num;
@@ -2266,7 +2266,7 @@
       am_uint_4FAA44_blt_xy.y = 18;
       am_uint_4FAA44_blt_xy.x = 120;
       v1 = GetPlayerHandCardCount(current_player_num);
-      v2 = (640 - 96 * v1) / v1 + 96;
+      v2 = (window->GetWidth() - 96 * v1) / v1 + 96;
       if ( am_byte_4E185D )
       {
         // v3 = 188 * current_player_num + 8 * amuint_4FAA4C;
@@ -2467,7 +2467,7 @@
       v5 = GetPlayerHandCardCount(player_num);
       pXYZW.top = 327;
       pXYZW.bottom = 455;
-      pXYZW.left = (640 - 96 * v5) / (v5 + 1);
+      pXYZW.left = (window->GetWidth() - 96 * v5) / (v5 + 1);
       var18 = pXYZW.left + 96;
       pXYZW.right = pXYZW.left + 96;
       for( hand_index = 0; hand_index < v5; hand_index++)
@@ -2549,7 +2549,7 @@
   {
     ArcomageGame::PlaySound(22);
     v8 = GetPlayerHandCardCount(current_player_num);
-    v10 = am_Players[player_num].card_shift[i].x + (640 - 96 * v8) / (v8 + 1);
+    v10 = am_Players[player_num].card_shift[i].x + (window->GetWidth() - 96 * v8) / (v8 + 1);
     amuint_4FAA5C_blt_xy.x = v10;
     amuint_4FAA5C_blt_xy.y = am_Players[player_num].card_shift[i].y + 327;//v11;
     v12 = 0;
@@ -2612,7 +2612,7 @@
     cards_at_hand = GetPlayerHandCardCount(current_player_num);
     pArcomageGame->field_F6 = 1;
     v12 =  am_Players[player_num].card_shift[card_index].x + 
-         (640 - 96 * cards_at_hand) / (cards_at_hand + 1)+ 
+         (window->GetWidth() - 96 * cards_at_hand) / (cards_at_hand + 1)+ 
          96 * card_index ;
         
   //  v13 = *(int *)((char *)&am_Players[0].arr_6C[0][1] + v10) + 327;
@@ -3585,9 +3585,9 @@
   pXY.y = 0;
   ArcomageGame::LoadBackground();
   pXYZW.left = 0;
-  pXYZW.right = 640;
+  pXYZW.right = window->GetWidth();
   pXYZW.top = 0;
-  pXYZW.bottom = 480;
+  pXYZW.bottom = window->GetHeight();
   am_BeginScene(pArcomageGame->pBackgroundPixels, -1, 1);
   pRenderer->am_Blt_Copy(&pXYZW, &pXY, 2);
   am_EndScene();
--- a/CastSpellInfo.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/CastSpellInfo.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -3543,7 +3543,7 @@
       {
         if ( pGUIWindow_Settings )
           return;
-        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0);
+        pGUIWindow_Settings = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0);
         pGUIWindow_Settings->CreateButton(52, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 0, 49, "", 0);
         pGUIWindow_Settings->CreateButton(165, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 1, 50, "", 0);
         pGUIWindow_Settings->CreateButton(280, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 2, 51, "", 0);
@@ -3556,7 +3556,7 @@
         if ( pGUIWindow_Settings )
           return;
 
-        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0);
+        pGUIWindow_Settings = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0);
         pGUIWindow_Settings->CreateButton(game_viewport_x, game_viewport_y, game_viewport_width, game_viewport_height, 1, 0, UIMSG_CastSpell_Shoot_Monster, 0, 0, "", 0);
         pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem();
         return;
@@ -3566,7 +3566,7 @@
         if ( pGUIWindow_Settings )
           return;
 
-        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0);
+        pGUIWindow_Settings = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0);
         pGUIWindow_Settings->CreateButton(game_viewport_x, game_viewport_y, game_viewport_width, game_viewport_height, 1, 0, UIMSG_CastSpell_Telekinesis, 0, 0, "", 0);
         pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem();
         return;
@@ -3588,7 +3588,7 @@
       {
         if ( pGUIWindow_Settings )
           return;
-        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0);
+        pGUIWindow_Settings = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0);
         pGUIWindow_Settings->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_CastSpell_Character_Small_Improvement, 0, 0x31u, "", 0);
         pGUIWindow_Settings->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_CastSpell_Character_Small_Improvement, 1, 0x32u, "", 0);
         pGUIWindow_Settings->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_CastSpell_Character_Small_Improvement, 2, 0x33u, "", 0);
@@ -3598,7 +3598,7 @@
       }
       if ( HIBYTE(a5) & 2 && !pGUIWindow_Settings )
       {
-        pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0);
+        pGUIWindow_Settings = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0);
         pBtn_NPCLeft = pGUIWindow_Settings->CreateButton(469, 178,
                        pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureWidth,
                        pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureHeight,
--- a/Chest.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/Chest.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -183,7 +183,7 @@
       pPlayers[uActiveCharacter]->PlaySound(SPEECH_4, 0);
   }
   OpenedTelekinesis = false;
-  pChestWindow = pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Chest, uChestID, 0);
+  pChestWindow = pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Chest, uChestID, 0);
   pBtn_ExitCancel = pChestWindow->CreateButton(471, 445, 169,  35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], pIcons_LOD->GetTexture(uExitCancelTextureId), 0);// Exit
                     pChestWindow->CreateButton(  7,   8, 460, 343, 1, 0, UIMSG_CHEST_ClickItem, 0, 0, "", 0);
   pCurrentScreen = SCREEN_CHEST;
--- a/Events.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/Events.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -710,7 +710,7 @@
                   if ( EnterHouse(HOUSE_DARK_GUILD_PIT) )
                   {
                     pAudioPlayer->StopChannels(-1, -1);
-                    window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 170, 0);
+                    window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_HouseInterior, 170, 0);
                     window_SpeakInHouse->CreateButton( 61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1, '1',  "", 0);
                     window_SpeakInHouse->CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2, '2',  "", 0);
                     window_SpeakInHouse->CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3, '3',  "", 0);
@@ -809,7 +809,7 @@
             if ( EnterHouse(HOUSE_BODY_GUILD_ERATHIA) )
               {
               pAudioPlayer->PlaySound((SoundID)0, 0, 0, -1, 0, 0, 0, 0);
-              window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0);
+              window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_HouseInterior, 165, 0);
               v48 = window_SpeakInHouse->pControlsHead;
               if ( v48 )
                 {
@@ -1481,7 +1481,7 @@
           v104 = 187;
           if ( uCurrentHouse_Animation != 167 )
             v104 = EVT_DWORD(_evt->v5);
-          window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, v104, 0);
+          window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_HouseInterior, v104, 0);
           window_SpeakInHouse->CreateButton( 61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1,  '1', "", 0);
           window_SpeakInHouse->CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2,  '2', "", 0);
           window_SpeakInHouse->CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3,  '3', "", 0);
--- a/GUIButton.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/GUIButton.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -4,7 +4,7 @@
 #include "mm7_data.h"
 #include "LOD.h"
 #include "Texts.h"
-
+#include "OSWindow.h"
 
 
 
@@ -248,7 +248,7 @@
 void UI_CreateEndConversationButton()
 {
   pDialogueWindow->Release();
-  pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0);
+  pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), 345, WINDOW_MainMenu, 0, 0);
   pBtn_ExitCancel = pDialogueWindow->CreateButton( 471, 445,  169, 35, 1, 0, UIMSG_Escape,  0,  0,
                  pGlobalTXT_LocalizationStrings[74],  //"End Conversation"
                  pIcons_LOD->GetTexture(uExitCancelTextureId), 0);
--- a/GUIWindow.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/GUIWindow.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -186,7 +186,7 @@
 		return result;
 	  }
 	}
-	if ( !v4->uFrameX && !v4->uFrameY && (v4->uFrameWidth == 640 && v4->uFrameHeight == 480) )
+	if ( !v4->uFrameX && !v4->uFrameY && (v4->uFrameWidth == window->GetWidth() && v4->uFrameHeight == window->GetWidth()) )
 	  break;
   }
   return 0;
@@ -680,8 +680,8 @@
   else
   {
     v4 = 0;
-    v5 = 640;
-    v22 = 480;
+    v5 = window->GetWidth();
+    v22 = window->GetHeight();
   }
   v6 = this->uFrameX;
   if ( (signed int)this->uFrameX >= v4 )
@@ -1146,7 +1146,7 @@
     v13 = (signed int)(v8 - pFont->GetLineWidth(Stra)) >> 1;
     if ( v13 < 0 )
       v13 = 0;
-    pFont->DrawTextLine(uDefaultColor, v11 + v13, v12, Stra, 640);
+    pFont->DrawTextLine(uDefaultColor, v11 + v13, v12, Stra, window->GetWidth());
     v12 += pFont->uFontHeight - uLineSpacing;
     Stra = strtok(0, "\n");
   }
@@ -1789,7 +1789,7 @@
   current_npc_text = (char *)pNPCTopics[pEventCode + 99].pText;
   ContractSelectText(pEventCode);
   pDialogueWindow->Release();
-  pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15E, WINDOW_MainMenu, pEventCode, 0);
+  pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), 350, WINDOW_MainMenu, pEventCode, 0);
   pBtn_ExitCancel = pDialogueWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape,                    0, 0, pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uExitCancelTextureId), 0); // Cancel
                     pDialogueWindow->CreateButton(  0,   0,   0,  0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
                     pDialogueWindow->CreateButton(480, 160, 140, 30, 1, 0, UIMSG_ClickNPCTopic,             0x52u, 0, pGlobalTXT_LocalizationStrings[122], 0);
@@ -2029,9 +2029,9 @@
         if ( pWindow->Hint != (char *)1 )
           pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
         pButton = (GUIButton *)pWindow->ptr_1C;
-        if ( pButton->uX >= 0 && pButton->uX <= 640 )
+        if ( pButton->uX >= 0 && pButton->uX <= window->GetWidth() )
         {
-          if ( pButton->uY >= 0 && pButton->uY <= 480 )
+          if ( pButton->uY >= 0 && pButton->uY <= window->GetHeight() )
           {
             pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[0]);
             viewparams->bRedrawGameUI = 1;
@@ -2264,7 +2264,7 @@
 {
   pEventTimer->Pause();
   modal_window_prev_screen = pCurrentScreen;
-  pModalWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_ModalWindow, OnRelease_message, pStrHint);
+  pModalWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_ModalWindow, OnRelease_message, pStrHint);
   pCurrentScreen = SCREEN_MODAL_WINDOW;
 }
 
@@ -2352,7 +2352,7 @@
     if ( mscroll_id <= 782 )
     {
       uTextureID_720980 = pIcons_LOD->LoadTexture("leather", TEXTURE_16BIT_PALETTE);
-      pGUIWindow_ScrollWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Scroll, v1 - 700, 0);
+      pGUIWindow_ScrollWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Scroll, v1 - 700, 0);
     }
   }
 }
--- a/Game.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/Game.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -1486,7 +1486,7 @@
           pIcons_LOD->RemoveTexturesPackFromTextureList();
           pGUIWindow_CurrentMenu->Release();
           pCurrentScreen = SCREEN_OPTIONS;
-          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_8, 0, 0);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_8, 0, 0);
           continue;
         case UIMSG_ArrowUp:
           --pSaveListPosition;
@@ -1578,7 +1578,7 @@
           options_menu_skin.uTextureID_ShowDamage     = pIcons_LOD->LoadTexture("option02", TEXTURE_16BIT_PALETTE);
           options_menu_skin.uTextureID_WalkSound      = pIcons_LOD->LoadTexture("option01", TEXTURE_16BIT_PALETTE);
 
-          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Options, 0, 0);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Options, 0, 0);
           pGUIWindow_CurrentMenu->CreateButton(22, 270,
                                                pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[2])->uTextureWidth,
                                                pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[2])->uTextureHeight,
@@ -1637,7 +1637,7 @@
           uTextureID_Optkb[2] = pIcons_LOD->LoadTexture("resume1", TEXTURE_16BIT_PALETTE);
           uTextureID_Optkb[3] = pIcons_LOD->LoadTexture("optkb_1", TEXTURE_16BIT_PALETTE);
           uTextureID_Optkb[4] = pIcons_LOD->LoadTexture("optkb_2", TEXTURE_16BIT_PALETTE);
-          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_KeyMappingOptions, 0, 0);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_KeyMappingOptions, 0, 0);
           pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, 1, 0, UIMSG_Escape, 0, 0, "", 0);
           pGUIWindow_CurrentMenu->CreateButton(19u, 0x12Eu, 0x6Cu, 0x14u, 1, 0, UIMSG_SelectKeyPage1, 0, 0, "", 0);
           pGUIWindow_CurrentMenu->CreateButton(127u, 0x12Eu, 0x6Cu, 0x14u, 1, 0, UIMSG_SelectKeyPage2, 0, 0, "", 0);
@@ -1738,7 +1738,7 @@
           not_available_bloodsplats_texture_id = pIcons_LOD->LoadTexture("opvdG-bs", TEXTURE_16BIT_PALETTE);
           not_available_us_colored_lights_texture_id = pIcons_LOD->LoadTexture("opvdG-cl", TEXTURE_16BIT_PALETTE);
           not_available_tinting_texture_id = pIcons_LOD->LoadTexture("opvdG-tn", TEXTURE_16BIT_PALETTE);
-          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_VideoOptions, 0, 0);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_VideoOptions, 0, 0);
           pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, 1, 0, UIMSG_Escape, 0, 0, "", 0);
           //if ( pRenderer->pRenderD3D )
           {
@@ -1952,7 +1952,7 @@
             pGUIWindow_CurrentMenu->Release();
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
-          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Book, uMessage, 0);
           pBooksWindow = GUIWindow::Create(493u, 355u, 0, 0, WINDOW_BooksWindow, (int)pBtn_Quests, 0);
           bFlashQuestBook = 0;
           continue;
@@ -1963,7 +1963,7 @@
             pGUIWindow_CurrentMenu->Release();
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
-          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Book, uMessage, 0);
           pBooksWindow = GUIWindow::Create(527u, 353u, 0, 0, WINDOW_BooksWindow, (int)pBtn_Autonotes, 0);
           bFlashAutonotesBook = 0;
           continue;
@@ -1976,7 +1976,7 @@
           viewparams->sViewCenterX = pParty->vPosition.x;
           viewparams->sViewCenterY = pParty->vPosition.y;
           pAudioPlayer->StopChannels(-1, -1);
-          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Book, uMessage, 0);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Book, uMessage, 0);
           pBooksWindow = GUIWindow::Create(546, 353, 0, 0, WINDOW_BooksWindow, (int)pBtn_Maps, 0);
           continue;
         case UIMSG_OpenCalendar:
@@ -1986,7 +1986,7 @@
             pGUIWindow_CurrentMenu->Release();
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
-          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Book, uMessage, 0);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Book, uMessage, 0);
           pBooksWindow = GUIWindow::Create(570, 354, 0, 0, WINDOW_BooksWindow, (int)pBtn_Calendar, 0);
           continue;
         case UIMSG_OpenHistoryBook:
@@ -1996,7 +1996,7 @@
             pGUIWindow_CurrentMenu->Release();
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
-          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Book, uMessage, 0);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Book, uMessage, 0);
           pBooksWindow = GUIWindow::Create(0x258u, 0x169u, 0, 0, WINDOW_BooksWindow, (int)pBtn_History, 0);
           bFlashHistoryBook = 0;
           continue;
@@ -2557,7 +2557,7 @@
               if ( !pIcons_LOD->uNumPrevLoadedFiles )
                 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
 
-              pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_OptionsButtons, 0, 0);
+              pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_OptionsButtons, 0, 0);
               uTextureID_Options = pIcons_LOD->LoadTexture("options", TEXTURE_16BIT_PALETTE);
               uTextureID_New1 = pIcons_LOD->LoadTexture("new1", TEXTURE_16BIT_PALETTE);
               uTextureID_Load1 = pIcons_LOD->LoadTexture("load1", TEXTURE_16BIT_PALETTE);
@@ -2975,12 +2975,12 @@
 
         case UIMSG_OnCastTownPortal:
           pAudioPlayer->StopChannels(-1, -1);
-          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Book, WINDOW_TownPortal, (char *)uMessageParam);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Book, WINDOW_TownPortal, (char *)uMessageParam);
         continue;
 
         case UIMSG_OnCastLloydsBeacon:
           pAudioPlayer->StopChannels(-1, -1);
-          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Book, WINDOW_LloydsBeacon, 0);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Book, WINDOW_LloydsBeacon, 0);
         continue;
 
         case UIMSG_LloydsBeacon_FlippingBtn:
@@ -3424,7 +3424,7 @@
 			__debugbreak();
           if ( !uActiveCharacter || pCurrentScreen )
             continue;
-          ptr_507BC8 = GUIWindow::Create(0, 0, 640, 480, WINDOW_68, uMessageParam, 0);
+          ptr_507BC8 = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_68, uMessageParam, 0);
           pCurrentScreen = SCREEN_19;
           pEventTimer->Pause();
           continue;
@@ -3796,7 +3796,7 @@
                 GUIWindow::Create(476, 450, 0, 0, WINDOW_PressedButton2, (int)pBtn_CastSpell, 0);
                 pCurrentScreen = SCREEN_SPELL_BOOK;
                 pEventTimer->Pause();
-                pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_SpellBook, 0, 0);
+                pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_SpellBook, 0, 0);
                 pAudioPlayer->PlaySound((SoundID)48, 0, 0, -1, 0, 0, 0, 0);
                 viewparams->field_48 = 1;
                 continue;
@@ -3808,7 +3808,7 @@
                 GUIWindow::Create(476, 450, 0, 0, WINDOW_PressedButton2, (int)pBtn_CastSpell, 0);
                 pCurrentScreen = SCREEN_SPELL_BOOK;
                 pEventTimer->Pause();
-                pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_SpellBook, 0, 0);
+                pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_SpellBook, 0, 0);
                 pAudioPlayer->PlaySound((SoundID)48, 0, 0, -1, 0, 0, 0, 0);
                 viewparams->field_48 = 1;
                 continue;
@@ -3829,7 +3829,7 @@
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
           pCurrentScreen = SCREEN_QUICK_REFERENCE;
-          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_QuickReference, 5, 0);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_QuickReference, 5, 0);
           papredoll_dbrds[2] = pIcons_LOD->LoadTexture("BUTTEXI1", TEXTURE_16BIT_PALETTE);
           pBtn_ExitCancel = pGUIWindow_CurrentMenu->CreateButton(0x187u, 0x13Cu, 0x4Bu, 0x21u, 1, 0, UIMSG_Escape, 0, 0,
                          pGlobalTXT_LocalizationStrings[79],// "Exit"
--- a/Indoor.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/Indoor.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -280,8 +280,8 @@
   this->fov_rad_fixpoint = fixpoint_from_int(_calc_fov(uViewportWidth, 65), 0);
   this->fov_rad_inv_fixpoint = 0x100000000i64 / this->fov_rad_fixpoint;
   this->pRenderTarget = pRenderer->pTargetSurface;
-  this->uTargetWidth = 640;
-  this->uTargetHeight = 480;
+  this->uTargetWidth = window->GetWidth();
+  this->uTargetHeight = window->GetHeight();
   this->pTargetZBuffer = pRenderer->pActiveZBuffer;
   this->field_8C = 0;
   this->field_84 = 0;
@@ -4285,11 +4285,11 @@
   _viewport_space_y = y;
   _viewport_space_w = w;
 
-  for (uint i = 0; i < 480; ++i)
+  for (uint i = 0; i < window->GetHeight(); ++i)
   {
     if ( i < y || i > w )
     {
-      viewport_left_side[i] = 640;
+      viewport_left_side[i] = window->GetWidth();
       viewport_right_side[i] = -1;
     }
     else
@@ -5105,7 +5105,7 @@
       {
         if ( pParty->pPickedItem.uItemID )
           return 1;
-        sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v17].pUnidentifiedName);//You found an item (%s)!
+        sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[pSpriteObjects[v17].stru_24.uItemID].pUnidentifiedName);//You found an item (%s)!
         ShowStatusBarString(pTmpBuf2.data(), 2);
         if ( pSpriteObjects[v17].stru_24.uItemID == 506 )//artefact
           _449B7E_toggle_bit(pParty->_quest_bits, 184, 1);
--- a/LOD.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/LOD.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -618,20 +618,17 @@
       v67 = v87 * ((unsigned __int64)(LOWORD(this->pSpriteLines[v35].dword_0) * (signed __int64)v58) >> 16);
       v38 = v9 - v60;
       v77 = v9 - v60;
-      if ( v9 - v60 <= (signed int)(v9
-                                  - ((unsigned __int64)(HIWORD(this->pSpriteLines[v35].dword_0) * (signed __int64)v58) >> 16))
+      if ( v9 - v60 <= (signed int)(v9 - ((unsigned __int64)(HIWORD(this->pSpriteLines[v35].dword_0) * (signed __int64)v58) >> 16))
         || v68 >= v37 )
       {
         v89 -= v69;
         v34 = v89;
 LABEL_84:
-        v86 -= 640;
+        v86 -= window->GetWidth();
         goto LABEL_85;
       }
       if ( v38 < v37 )
-      {
         v81 = (v87 >> 1) + v87 * (v37 - v38);
-      }
       else
       {
         v77 = v37;
@@ -679,7 +676,7 @@
 LABEL_81:
       v89 += v9 - v77 - v60 - v69;
       v34 = v89;
-      v86 = v86 + v9 - v77 - v60 - 640;
+      v86 = v86 + v9 - v77 - v60 - window->GetWidth();
 LABEL_85:
       result = v52;
       v71 += v52;
@@ -714,7 +711,7 @@
       if ( LOWORD(v20->dword_0) != -1 )
         break;
       v18 -= v69;
-      v85 = v19 - 640;
+      v85 = v19 - window->GetWidth();
       v88 = v18;
 LABEL_54:
       result = v52;
@@ -732,7 +729,7 @@
     if ( v68 >= (v58 * v54 + 32768) >> 16 || v22 <= v21 )
     {
       v88 -= v69;
-      v85 -= 640;
+      v85 -= window->GetWidth();
       goto LABEL_51;
     }
     if ( v68 > v21 )
@@ -741,7 +738,7 @@
     }
     else
     {
-      v76 = (v58 * LOWORD(v20->dword_0) + 32768) >> 16;
+      v76 = (v58 * LOWORD(v20->dword_0) + 0x8000) >> 16;
       v23 = v21 - v68;
       v88 += v23;
       v24 = v87 >> 1;
@@ -808,7 +805,7 @@
     *v27 = v61[v31];
 LABEL_50:
     v88 += v68 - v76 - v69;
-    v85 = v85 + v68 - v76 - 640;
+    v85 = v85 + v68 - v76 - window->GetWidth();
 LABEL_51:
     v18 = v88;
     goto LABEL_54;
@@ -1374,7 +1371,7 @@
 
 
 //----- (004621A7) --------------------------------------------------------
-bool LODWriteableFile::_4621A7()
+bool LODWriteableFile::_4621A7()//закрыть и загрузить записываемый ф-л(при сохранении)
 {
   CloseWriteFile();
   return LoadFile(pLODName, 0);
--- a/Mouse.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/Mouse.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -238,7 +238,7 @@
 
     //if ( pRenderer->bWindowMode )
     {
-      if ( this->uMouseClickX < 0 || this->uMouseClickY < 0 || this->uMouseClickX > 639 || this->uMouseClickY > 479 )
+      if ( this->uMouseClickX < 0 || this->uMouseClickY < 0 || this->uMouseClickX > window->GetWidth() - 1 || this->uMouseClickY > window->GetHeight() - 1 )
       {
         this->field_F4 = 0;
         return;
@@ -256,17 +256,17 @@
         this->uMouseClickY = 479;
     }*/
     this->pCursorBitmapRect.x = this->uMouseClickX;
-    this->pCursorBitmapRect.w = this->uMouseClickY + this->field_5C[0];
+    this->pCursorBitmapRect.w = this->uMouseClickY + this->field_5C[0];//I think this error
     this->pCursorBitmapRect.y = this->uMouseClickY;
-    this->pCursorBitmapRect.z = this->uMouseClickX + this->uCursorBitmapPitch;
+    this->pCursorBitmapRect.z = this->uMouseClickX + this->uCursorBitmapPitch;//and this error
     if ( this->uMouseClickX < 0 )
       this->pCursorBitmapRect.x = 0;
     if ( this->uMouseClickY < 0 )
       this->pCursorBitmapRect.y = 0;
-    if ( this->pCursorBitmapRect.z > 640 )
-      this->pCursorBitmapRect.z = 640;
-    if ( this->pCursorBitmapRect.w > 480 )
-      this->pCursorBitmapRect.w = 480;
+    if ( this->pCursorBitmapRect.z > window->GetWidth() )
+      this->pCursorBitmapRect.z = window->GetWidth();
+    if ( this->pCursorBitmapRect.w > window->GetHeight() )
+      this->pCursorBitmapRect.w = window->GetHeight();
     this->bActive = 0;
     this->uCursorBitmapWidth = this->pCursorBitmapRect.z - this->pCursorBitmapRect.x;
     this->uCursorBitmapHeight = this->pCursorBitmapRect.w - this->pCursorBitmapRect.y;
@@ -350,7 +350,7 @@
     v6 = v5;
     a2 = v4;
     v15 = v5;
-    if ( (signed int)v4 <= 639 && (signed int)v5 <= 479 )
+    if ( (signed int)v4 <= window->GetWidth() - 1 && (signed int)v5 <= window->GetHeight() - 1 )
     {
       if ( (v4 & 0x80000000u) != 0 )
         a2 = 0;
@@ -359,19 +359,19 @@
         v6 = 0;
         v15 = 0;
       }
-      if ( (signed int)(pTexture->uTextureWidth + a2) <= 640 )
+      if ( (signed int)(pTexture->uTextureWidth + a2) <= window->GetWidth() )
         pTextureWidth = pTexture->uTextureWidth;
       else
-        pTextureWidth = 640 - a2;
-      if ( (signed int)(pTexture->uTextureHeight + v6) <= 480 )
+        pTextureWidth = window->GetWidth() - a2;
+      if ( (signed int)(pTexture->uTextureHeight + v6) <= window->GetHeight() )
       {
         v19 = pTexture->uTextureHeight;
         v7 = pTexture->uTextureHeight;
       }
       else
       {
-        v7 = 480 - v6;
-        v19 = 480 - v6;
+        v7 = window->GetHeight() - v6;
+        v19 = window->GetHeight() - v6;
       }
       if ( !this->pCursorBitmap3_sysmembits_16bit
         || a2 != this->field_40
--- a/NPC.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/NPC.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -1591,15 +1591,15 @@
   v0 = 0;
   v1 = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) )];//- 1
   pDialogueWindow->Release();
-  pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15Eu, WINDOW_MainMenu, 0, 0);
-  pBtn_ExitCancel = pDialogueWindow->CreateButton( 0x1D7u, 0x1BDu,  0xA9u,   0x23u,  1,  0,  UIMSG_Escape,  0,   0,
+  pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), 350, WINDOW_MainMenu, 0, 0);
+  pBtn_ExitCancel = pDialogueWindow->CreateButton( 471, 0x1BDu,  0xA9u,   0x23u,  1,  0,  UIMSG_Escape,  0,   0,
                  pGlobalTXT_LocalizationStrings[34], //"Cancel"
                  pIcons_LOD->GetTexture(uExitCancelTextureId),
                  0);
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
   if ( pNPCStats->pProfessions[v1->uProfession].pBenefits)//*(&pNPCStats->field_13A5C + 5 * v1->uProfession) )
   {
-    pDialogueWindow->CreateButton( 0x1E0u,  0xA0u,  0x8Cu,  0x1Eu,   1,  0,  UIMSG_ClickNPCTopic,  0x4Du,   0,
+    pDialogueWindow->CreateButton( 480,  0xA0u,  0x8Cu,  0x1Eu,   1,  0,  UIMSG_ClickNPCTopic,  0x4Du,   0,
       pGlobalTXT_LocalizationStrings[407], 0);//"More Information"   
     v0 = 1;
   }
@@ -1628,7 +1628,7 @@
   if ( _this + 1 == uNumDialogueNPCPortraits && uHouse_ExitPic )
   {
     pDialogueWindow->Release();
-    pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
+    pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0);
     sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[LOCSTR_ENTER_S], pMapStats->pInfos[uHouse_ExitPic].pName);
     pBtn_ExitCancel = pDialogueWindow->CreateButton(566, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 'N', pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);// "Cancel"
     pBtn_YES        = pDialogueWindow->CreateButton(486, 445, 75, 33, 1, 0, UIMSG_BF,     1, 'Y', sHouseName.data(), pIcons_LOD->GetTexture(uTextureID_BUTTYES2), 0);
@@ -1647,7 +1647,7 @@
       for ( i = 0; i < uNumDialogueNPCPortraits; ++i )
         HouseNPCPortraitsButtonsList[i]->Release();
     }
-    pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0);
+    pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), 345, WINDOW_MainMenu, 0, 0);
     pBtn_ExitCancel = pDialogueWindow->CreateButton(  471,  445,  169, 35,  1,   0, UIMSG_Escape,  0,  0,
                    pGlobalTXT_LocalizationStrings[74],// "End Conversation"
                    pIcons_LOD->GetTexture(uExitCancelTextureId),   0);
--- a/Render.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/Render.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -666,9 +666,7 @@
     memcpy(v20.pGUID, lpGUID, 0x10u);
   }
   else
-  {
     v20.pGUID = 0;
-  }
 
   if (FAILED(DirectDrawCreate(v20.pGUID, &pDirectDraw, 0)))
   {
@@ -690,10 +688,8 @@
     else
     {
       pDirectDraw->Release();
-      if (FAILED( pDirectDraw4->GetDeviceIdentifier(&ddDevId, 1u)))
-      {
+      if (FAILED( pDirectDraw4->GetDeviceIdentifier(&ddDevId, 1)))
         v20.pDDraw4DevDesc = 0;
-      }
       else
       {
         v7 = strlen(ddDevId.szDescription);
@@ -701,24 +697,17 @@
         strcpy(v20.pDDraw4DevDesc, ddDevId.szDescription);
       }
       memset(&ddsCaps, 0, 0x10u);
-      if (FAILED(pDirectDraw4->GetAvailableVidMem(
-             &ddsCaps,
-             (LPDWORD)&v20.uVideoMem,
-             (LPDWORD)&uFreeVideoMem)))
+      if (FAILED(pDirectDraw4->GetAvailableVidMem(&ddsCaps, (LPDWORD)&v20.uVideoMem, (LPDWORD)&uFreeVideoMem)))
         v20.uVideoMem = 0;
       memset(&v10, 0, 0x7Cu);
       v10.dwSize = 124;
       v10.dwFlags = 6;
-      v10.dwHeight = 640;
-      v10.dwWidth = 480;
+      v10.dwHeight = window->GetWidth();
+      v10.dwWidth = window->GetHeight();
       v10.ddpfPixelFormat.dwSize = 32;
 
       v19 = 0;
-      if ( FAILED(pDirectDraw4->EnumDisplayModes(
-             0,
-             0,
-             &v19,
-             (LPDDENUMMODESCALLBACK2)DDrawDisplayModesEnumerator))
+      if ( FAILED(pDirectDraw4->EnumDisplayModes(0, 0, &v19, (LPDDENUMMODESCALLBACK2)DDrawDisplayModesEnumerator))
         || !v19
         || FAILED(pDirectDraw4->QueryInterface(IID_IDirect3D3, (LPVOID *)&pDirect3D3)))
       {
@@ -839,28 +828,17 @@
     result = 0;
   }
   else
-  {
     result = 1;
-  }
   return result;
 }
 
 //----- (0047A95E) --------------------------------------------------------
 void Render::PrepareDecorationsRenderList_ODM()
 {
-  //char *v0; // esi@2
-  //DecorationDesc *v1; // ebx@6
-  __int16 v2; // ax@6
-  double v3; // st7@7
-  //int v4; // eax@9
-  //int v5; // edx@9
   unsigned int v6; // edi@9
   int v7; // eax@9
   SpriteFrame *v8; // eax@9
-  //SpriteFrame *v9; // edi@9
   unsigned __int16 *v10; // eax@9
-  int v11; // ecx@9
-  int v12; // eax@9
   int v13; // ecx@9
   int v14; // ecx@20
   char v15; // dl@20
@@ -871,57 +849,32 @@
   int v20; // ecx@24
   int v21; // ebx@26
   int v22; // eax@26
-  int v23; // eax@30
   signed __int64 v24; // qtt@31
   int v25; // ebx@31
-  int v26; // ecx@32
-  RenderBillboard *v27; // eax@37
-  __int16 v28; // dx@37
   __int16 v29; // cx@37
   int v30; // ecx@37
   int v31; // ebx@37
   Particle_sw local_0; // [sp+Ch] [bp-98h]@7
-  //int x; // [sp+74h] [bp-30h]@9
-  //int y; // [sp+78h] [bp-2Ch]@9
-  //int v35; // [sp+7Ch] [bp-28h]@1
-  //int v36; // [sp+80h] [bp-24h]@9
   unsigned __int16 *v37; // [sp+84h] [bp-20h]@9
   int v38; // [sp+88h] [bp-1Ch]@9
-  int v39; // [sp+8Ch] [bp-18h]@24
   int v40; // [sp+90h] [bp-14h]@24
   int v41; // [sp+94h] [bp-10h]@24
   int v42; // [sp+98h] [bp-Ch]@9
-  int a5; // [sp+9Ch] [bp-8h]@9
   int b; // [sp+A0h] [bp-4h]@22
 
-  //v35 = 0;
-  //if ( (signed int)uNumLevelDecorations > 0 )
-  //{
-    //v0 = (char *)&pLevelDecorations[0].vPosition.y;
-    //do
   for (int i = 0; i < uNumLevelDecorations; ++i)
   {
     LevelDecoration* decor = &pLevelDecorations[i];
-    char* v0 = (char *)&pLevelDecorations[i].vPosition.y;
-
     if ((!(decor->uFlags & LEVEL_DECORATION_OBELISK_CHEST) || decor->IsObeliskChestActive()) && !(decor->uFlags & LEVEL_DECORATION_INVISIBLE))
     {
-      //v1 = &pDecorationList->pDecorations[decor->uDecorationDescID];
       DecorationDesc* decor_desc = pDecorationList->pDecorations + decor->uDecorationDescID;
-      v2 = decor_desc->uFlags;
-      if ( (char)v2 >= 0 )
-      {
-        if ( !(v2 & 0x22) )
+      if ( (char)decor_desc->uFlags >= 0 )
+      {
+        if ( !(decor_desc->uFlags & 0x22) )
         {
-          //v4 = decor->vPosition.x;
-          //v5 = decor->vPosition.z;
           v6 = pMiscTimer->uTotalGameTimeElapsed;
-          //y = decor->vPosition.y;
-          //x = decor->vPosition.x;
-          //v36 = decor->vPosition.z;
           v7 = abs(decor->vPosition.x + decor->vPosition.y);
 
-
           #pragma region "New: seasons change"
           extern bool change_seasons;
           if (change_seasons)
@@ -989,26 +942,20 @@
           #pragma endregion
           //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7);
 
-          //v9 = v8;
-          v42 = v8->uFlags;
-          a5 = v8->uGlowRadius;
           v10 = (unsigned __int16 *)stru_5C6E00->Atan2(decor->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x,
                                                        decor->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y);
-          v11 = *((int *)v0 + 2);
-          v37 = v10;
-          v12 = v42;
           v38 = 0;
-          v13 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + v11 - (signed int)v37) >> 8) & 7;
+          v13 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + decor->field_10_y_rot - (signed int)v10) >> 8) & 7;
           v37 = (unsigned __int16 *)v13;
-          if ( v42 & 2 )
+          if ( v8->uFlags & 2 )
             v38 = 2;
-          if ( (256 << v13) & v42 )
-            v38 |= 4u;
-          if ( v12 & 0x40000 )
-            v38 |= 0x40u;
-          if ( v12 & 0x20000 )
+          if ( (256 << v13) & v8->uFlags )
+            v38 |= 4;
+          if ( v8->uFlags & 0x40000 )
+            v38 |= 0x40;
+          if ( v8->uFlags & 0x20000 )
             LOBYTE(v38) = v38 | 0x80;
-          if ( a5 )
+          if ( v8->uGlowRadius )
           {
             if ( pRenderer->pRenderD3D && pRenderer->bUseColoredLights )
             {
@@ -1022,119 +969,125 @@
               v14 = 255;
               v15 = 255;
             }
-            b = v16;
             pStationaryLightsStack->AddLight(decor->vPosition.x, decor->vPosition.y, decor->vPosition.z + decor_desc->uDecorationHeight / 2,
-              a5, v14, v15, v16, _4E94D0_light_type);
+              v8->uGlowRadius, v14, v15, v16, _4E94D0_light_type);
           }
           v17 = (decor->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16;
           if (pGame->pIndoorCameraD3D->sRotationX)
           {
             v40 = (decor->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16;
             v18 = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y);
-            v42 = v18;
-            b = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_sine_y);
-            a5 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y);
-            v40 = (decor->vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16;
-            v41 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_x);
+            v41 = fixpoint_mul((decor->vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x);
             v19 = fixpoint_mul(v18, pGame->pIndoorCameraD3D->int_cosine_x);
-            v20 = v19 + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_x);
-            v39 = v19 + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_x);
+            v20 = v19 + fixpoint_mul((decor->vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x);
             if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 )
             {
-              v21 = a5 - b;
-              v41 = a5 - b;
-              //a5 = fixpoint_mul(v42, pGame->pIndoorCameraD3D->int_sine_x);
-              b = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_x);
-              v22 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_x) - fixpoint_mul(v42, pGame->pIndoorCameraD3D->int_sine_x);
-LABEL_30:
-              v42 = v22;
-              v40 = 2 * abs(v20);
-              v23 = abs(v21);
-              if ( v40 >= v23 )
+              v21 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_sine_y);
+              v22 = fixpoint_mul((decor->vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_cosine_x) - fixpoint_mul(v18, pGame->pIndoorCameraD3D->int_sine_x);
+              if ( 2 * abs(v20) >= abs(v21) )
               {
                 LODWORD(v24) = 0;
                 HIDWORD(v24) = SLOWORD(pODMRenderParams->int_fov_rad);
-                a5 = v24 / v39;
-                v25 = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v24 / v39, v41) + 0x8000) >> 16);
-                b = fixpoint_mul(a5, v42);
-                v41 = v24 / v39;
-                v40 = pViewport->uScreenCenterY - ((signed int)(fixpoint_mul(a5, v42) + 0x8000) >> 16);
-                //v42 = v8->scale;
-                v41 = fixpoint_mul(v8->scale, v24 / v39);
-                v37 = (unsigned __int16 *)&v8->pHwSpriteIDs[(int)v37];
+                v25 = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v24 / v20, v21) + 0x8000) >> 16);
+                v40 = pViewport->uScreenCenterY - ((signed int)(fixpoint_mul(v24 / v20, v22) + 0x8000) >> 16);
+                v41 = fixpoint_mul(v8->scale, v24 / v20);
                 if ( pRenderer->pRenderD3D )
-                {
-                  v26 = v41;
-                  //v42 = pSprites_LOD->pHardwareSprites[(signed __int16)*v37].uBufferWidth / 2;
-                  b = fixpoint_mul(pSprites_LOD->pHardwareSprites[(signed __int16)*v37].uBufferWidth / 2, v41);
-                }
+                  b = fixpoint_mul(pSprites_LOD->pHardwareSprites[v8->pHwSpriteIDs[(int)v37]].uBufferWidth / 2, v41);
                 else
-                {
-                  v26 = v41;
-                  //v42 = pSprites_LOD->pSpriteHeaders[(signed __int16)*v37].uWidth / 2;
-                  b = fixpoint_mul(pSprites_LOD->pSpriteHeaders[(signed __int16)*v37].uWidth / 2, v41);
-                }
+                  b = fixpoint_mul(pSprites_LOD->pSpriteHeaders[v8->pHwSpriteIDs[(int)v37]].uWidth / 2, v41);
                 if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X )
                 {
                   if (::uNumBillboardsToDraw >= 500)
                     return;
-                  v27 = &pBillboardRenderList[::uNumBillboardsToDraw++];
-                  ++uNumDecorationsDrawnThisFrame;
-                  v27->uHwSpriteID = *v37;
-                  v28 = v8->uPaletteIndex;
-                  v27->_screenspace_x_scaler_packedfloat = v26;
-                  v27->_screenspace_y_scaler_packedfloat = v26;
+                  pBillboardRenderList[::uNumBillboardsToDraw].uHwSpriteID = v8->pHwSpriteIDs[(int)v37];
+                  pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = v41;
+                  pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = v41;
                   v29 = v38;
-                  v27->uScreenSpaceX = v25;
-                  HIBYTE(v29) |= 2u;
-                  v27->uPalette = v28;
-                  v27->field_1E = v29;
-                  v27->world_x = decor->vPosition.x;
-                  v27->world_y = decor->vPosition.y;
-                  v27->world_z = decor->vPosition.z;
-                  v27->uScreenSpaceY = v40;
-                  HIWORD(v30) = HIWORD(v39);
+                  pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = v25;
+                  HIBYTE(v29) |= 2;
+                  pBillboardRenderList[::uNumBillboardsToDraw].uPalette = v8->uPaletteIndex;
+                  pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v29;
+                  pBillboardRenderList[::uNumBillboardsToDraw].world_x = decor->vPosition.x;
+                  pBillboardRenderList[::uNumBillboardsToDraw].world_y = decor->vPosition.y;
+                  pBillboardRenderList[::uNumBillboardsToDraw].world_z = decor->vPosition.z;
+                  pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = v40;
+                  HIWORD(v30) = HIWORD(v20);
                   v31 = PID(OBJECT_Decoration,i);
                   LOWORD(v30) = 0;
-                  v27->uIndoorSectorID = 0;
-                  v27->sZValue = v30 + v31;
-                  v27->dimming_level = 0;
-                  v27->pSpriteFrame = v8;
-                  v27->sTintColor = 0;
+                  pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = 0;
+                  pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v30 + v31;
+                  pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0;
+                  pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = v8;
+                  pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0;
+                  ::uNumBillboardsToDraw++;
+                  ++uNumDecorationsDrawnThisFrame;
                 }
               }
-              goto LABEL_38;
+              continue;
             }
           }
           else
           {
             v42 = (decor->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16;
             v40 = (decor->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16;
-            b = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y);
-            a5 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y);
-            v20 = b + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y);
-            v39 = b + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y);
+            v20 = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y);
             if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 )
             {
-              a5 = fixpoint_mul(v42, pGame->pIndoorCameraD3D->int_sine_y);
-              b = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y);
-              v21 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - a5;
-              v41 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - a5;
+              v21 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - fixpoint_mul(v42, pGame->pIndoorCameraD3D->int_sine_y);
               v22 = (decor->vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16;
-              goto LABEL_30;
+              v42 = v22;
+              if ( 2 * abs(v20) >= abs(v21) )
+              {
+                LODWORD(v24) = 0;
+                HIDWORD(v24) = SLOWORD(pODMRenderParams->int_fov_rad);
+                v25 = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v24 / v20, v21) + 0x8000) >> 16);
+                v40 = pViewport->uScreenCenterY - ((signed int)(fixpoint_mul(v24 / v20, v42) + 0x8000) >> 16);
+                v41 = fixpoint_mul(v8->scale, v24 / v20);
+                if ( pRenderer->pRenderD3D )
+                  b = fixpoint_mul(pSprites_LOD->pHardwareSprites[v8->pHwSpriteIDs[(int)v37]].uBufferWidth / 2, v41);
+                else
+                  b = fixpoint_mul(pSprites_LOD->pSpriteHeaders[v8->pHwSpriteIDs[(int)v37]].uWidth / 2, v41);
+                if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X )
+                {
+                  if (::uNumBillboardsToDraw >= 500)
+                    return;
+                  pBillboardRenderList[::uNumBillboardsToDraw].uHwSpriteID = v8->pHwSpriteIDs[(int)v37];
+                  pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_x_scaler_packedfloat = v41;
+                  pBillboardRenderList[::uNumBillboardsToDraw]._screenspace_y_scaler_packedfloat = v41;
+                  v29 = v38;
+                  pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceX = v25;
+                  HIBYTE(v29) |= 2;
+                  pBillboardRenderList[::uNumBillboardsToDraw].uPalette = v8->uPaletteIndex;
+                  pBillboardRenderList[::uNumBillboardsToDraw].field_1E = v29;
+                  pBillboardRenderList[::uNumBillboardsToDraw].world_x = decor->vPosition.x;
+                  pBillboardRenderList[::uNumBillboardsToDraw].world_y = decor->vPosition.y;
+                  pBillboardRenderList[::uNumBillboardsToDraw].world_z = decor->vPosition.z;
+                  pBillboardRenderList[::uNumBillboardsToDraw].uScreenSpaceY = v40;
+                  HIWORD(v30) = HIWORD(v20);
+                  v31 = PID(OBJECT_Decoration,i);
+                  LOWORD(v30) = 0;
+                  pBillboardRenderList[::uNumBillboardsToDraw].uIndoorSectorID = 0;
+                  pBillboardRenderList[::uNumBillboardsToDraw].sZValue = v30 + v31;
+                  pBillboardRenderList[::uNumBillboardsToDraw].dimming_level = 0;
+                  pBillboardRenderList[::uNumBillboardsToDraw].pSpriteFrame = v8;
+                  pBillboardRenderList[::uNumBillboardsToDraw].sTintColor = 0;
+                  ::uNumBillboardsToDraw++;
+                  ++uNumDecorationsDrawnThisFrame;
+                }
+              }
+              continue;
             }
           }
         }
       }
       else
       {
-        memset(&local_0, 0, 0x68u);
-        v3 = (double)*((signed int *)v0 - 1);
+        memset(&local_0, 0, 0x68);
         local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
         local_0.uDiffuse = 0xFF3C1E;
-        local_0.x = v3;
-        local_0.y = (double)*(signed int *)v0;
-        local_0.z = (double)*((signed int *)v0 + 1);
+        local_0.x = (double)decor->vPosition.x;
+        local_0.y = (double)decor->vPosition.y;
+        local_0.z = (double)decor->vPosition.z;
         local_0.r = 0.0;
         local_0.g = 0.0;
         local_0.b = 0.0;
@@ -1144,30 +1097,23 @@
         pGame->pParticleEngine->AddParticle(&local_0);
       }
     }
-LABEL_38:
-      ;
-      //++v35;
-      //v0 += 32;
-  }
-    //while ( v35 < (signed int)uNumLevelDecorations );
+  }
 }
 
 //----- (0049D717) --------------------------------------------------------
 HRESULT __stdcall D3DZBufferFormatEnumerator(DDPIXELFORMAT *Src, DDPIXELFORMAT *Dst)
 {
-  HRESULT v2; // esi@2
-
   if ( Src->dwFlags & (0x400 | 0x2000))
   {
-    v2 = 0;
     if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask )
-      goto LABEL_6;
+    {
+      memcpy(Dst, Src, sizeof(DDPIXELFORMAT));
+      return 0;
+    }
     if ( !Dst->dwSize )
     {
-      v2 = 1;
-LABEL_6:
       memcpy(Dst, Src, sizeof(DDPIXELFORMAT));
-      return v2;
+      return 1;
     }
   }
   return 1;
@@ -1483,7 +1429,7 @@
     sprintf(pErrorMessage, v23);
     goto LABEL_65;
   }
-  if (pHost->SetDisplayMode(640u, 480u, 16u, 0, 0) )
+  if (pHost->SetDisplayMode(window->GetWidth(), window->GetHeight(), 16, 0, 0) )
   {
     v23 = "Init - Failed to set display mode.\n";
     sprintf(pErrorMessage, v23);
@@ -1653,7 +1599,7 @@
   if (bClearDepth)
     uClearFlags |= D3DCLEAR_ZBUFFER;
   
-  D3DRECT rects[] = {{0, 0, 640, 480}};
+  D3DRECT rects[] = {{0, 0, window->GetWidth(), window->GetHeight()}};
   if (uClearFlags)
     pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0);
 }
@@ -1666,8 +1612,8 @@
 
   v5.left = 0;
   v5.top = 0;
-  v5.bottom = 480;
-  v5.right = 640;
+  v5.bottom = window->GetHeight();
+  v5.right = window->GetWidth();
 
   if (bWindowed || bForceBlit)
   {
@@ -2784,9 +2730,9 @@
     v3 = v2->pBackBuffer4;
     v4 = v2->pFrontBuffer4;
     v5.top = 0;
-    v5.bottom = 480;
+    v5.bottom = window->GetHeight();
     v5.left = 0;
-    v5.right = 640;
+    v5.right = window->GetWidth();
     v3->BltFast(0, 0, v4, &v5, 16u);
   }
 }
@@ -3027,22 +2973,22 @@
         for (uint y = 0; y < 8; ++y)
           memcpy(pDst + y * Dst.lPitch / 2,
 
-		  pSrc + y * 640, 640 * sizeof(__int16));
+		  pSrc + y * window->GetWidth(), window->GetWidth() * sizeof(__int16));
 
         for (uint y = 8; y < 352; ++y)
         {
           memcpy(pDst + y * Dst.lPitch / 2,
-                 pSrc + y * 640, 8 * sizeof(__int16));
+                 pSrc + y * window->GetWidth(), 8 * sizeof(__int16));
           memcpy(pDst + 8 + game_viewport_width/*462*/ + y * Dst.lPitch / 2,
-                 pSrc + 8 + game_viewport_width/*462*/ + y * 640, 174/*172*/ * sizeof(__int16));
+                 pSrc + 8 + game_viewport_width/*462*/ + y * window->GetWidth(), 174/*172*/ * sizeof(__int16));
         }
 
-        for (uint y = 352; y < 480; ++y)
+        for (uint y = 352; y < window->GetHeight(); ++y)
           memcpy(pDst + y * Dst.lPitch / 2,
-                 pSrc + y * 640, 640 * sizeof(__int16));
-
-
-        ushort* pSrc_x1y1 = pSrc + 640 * pViewport->uViewportTL_Y + pViewport->uViewportTL_X;
+                 pSrc + y * window->GetWidth(), window->GetWidth() * sizeof(__int16));
+
+
+        ushort* pSrc_x1y1 = pSrc + window->GetWidth() * pViewport->uViewportTL_Y + pViewport->uViewportTL_X;
         //_this = (unsigned int)&pSrc[2 * (((signed int)pViewport->uViewportX >> 1) + 320 * pViewport->uViewportY)];
         short* 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));
@@ -3064,8 +3010,8 @@
           //       pSrc + pViewport->uViewportX + y * 640, (pViewport->uViewportZ - pViewport->uViewportX) * sizeof(__int16));
           for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x)
           {
-            if (pSrc[y * 640 + x] != (g_mask | b_mask))
-              pDst[y * Dst.lPitch / 2 + x] = pSrc[y * 640 + x];
+            if (pSrc[y * window->GetWidth() + x] != (g_mask | b_mask))
+              pDst[y * Dst.lPitch / 2 + x] = pSrc[y * window->GetWidth() + x];
           }
         }
         }
@@ -3328,7 +3274,7 @@
     {
       pTargetSurface = 0;
       pTargetSurface_unaligned = 0;
-      pTargetSurface_unaligned = (unsigned int *)malloc(640 * 480 * 2 + 32);
+      pTargetSurface_unaligned = (unsigned int *)malloc(window->GetWidth() * window->GetHeight() * 2 + 32);
       if ( !pTargetSurface_unaligned
         || (memset(&pDesc, 0, 0x7Cu),
             pDesc.dwSize = 124,
@@ -3338,7 +3284,7 @@
       v22 = (int *)pTargetSurface_unaligned + 4;
       v23 = (unsigned int)pDesc.lpSurface & 7;
       LOBYTE(v22) = (unsigned __int8)v22 & 0xF8;
-      uTargetSurfacePitch = 640;
+      uTargetSurfacePitch = window->GetWidth();
       pBeforePresentFunction = Present_NoColorKey;
       v15 = 1;
       pTargetSurface = (unsigned __int32 *)((char *)v22 + 2 * v23);
@@ -4050,8 +3996,8 @@
     a2.dwFlags = 7;
     v7 = 0;
     a2.ddsCaps.dwCaps = 2112;
-    a2.dwWidth = 640;
-    a2.dwHeight = 480;
+    a2.dwWidth = window->GetWidth();
+    a2.dwHeight = window->GetHeight();
     v6 = 2387;
     ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4;
     v4 = (struct _DDSURFACEDESC *)&a2;
@@ -6541,7 +6487,7 @@
   this->uClipX = 0;
   this->bClip = 1;
   this->uClipW = 480;
-  this->uClipZ = 640;
+  this->uClipZ = window->GetWidth();
 }
 
 unsigned __int32 Color32(unsigned __int16 color16)
@@ -7796,7 +7742,7 @@
     {
       v6 = uOutY;
       v7 = pTexture->uTextureHeight;
-      pZBuffer = &this->pActiveZBuffer[uOutX + 640 * uOutY];
+      pZBuffer = &this->pActiveZBuffer[uOutX + window->GetWidth() * uOutY];
       uOutYa = v5->pLevelOfDetail0_prolly_alpha_mask;
       v8 = v5->uTextureWidth;
       v20 = v5->uTextureWidth;
@@ -7817,7 +7763,7 @@
         {
           uOutYa += v19 * (v11 - v6);
           v7 += v6 - v11;
-          pZBuffer += 640 * (v11 - v6);
+          pZBuffer += window->GetWidth() * (v11 - v6);
           v8 = v20;
         }
         v12 = this->uClipX;
@@ -7861,7 +7807,7 @@
             }
             while ( v18 );
           }
-          pZBuffer += 640 - v8;
+          pZBuffer += window->GetWidth() - v8;
           uOutYa += v19 - v8;
           --uOutXa;
         }
@@ -7944,7 +7890,7 @@
           memset32(v8, a5, pTexturea);
           v8 = (char *)v8 + 4 * pTexturea;
         }
-        v8 = (char *)v8 + 4 * (640 - pTexturea);
+        v8 = (char *)v8 + 4 * (window->GetWidth() - pTexturea);
         --v6;
       }
       while ( v6 );
--- a/UI/UICharacter.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/UI/UICharacter.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -394,7 +394,7 @@
   CharacterUI_LoadPaperdollTextures();
   pCurrentScreen = _this;
 
-  pWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_CharacterRecord, uActiveCharacter, 0);
+  pWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CharacterRecord, uActiveCharacter, 0);
   pCharacterScreen_StatsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 12, pViewport->uViewportTL_Y + 308,
                                 pIcons_LOD->GetTexture(papredoll_dbrds[9])->uTextureWidth,
                                 pIcons_LOD->GetTexture(papredoll_dbrds[9])->uTextureHeight,
@@ -425,9 +425,9 @@
                  1, 0, UIMSG_ClickExitCharacterWindowBtn, 0, 0, pGlobalTXT_LocalizationStrings[79],//Exit
                  pIcons_LOD->GetTexture(papredoll_dbrds[2]),
                  pIcons_LOD->GetTexture(papredoll_dbrds[1]), 0);
-  pWindow->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, UIMSG_InventoryLeftClick, 0, 0, "", 0);
-  pCharacterScreen_DetalizBtn = pWindow->CreateButton(0x258u, 0x12Cu, 30, 30, 1, 0, UIMSG_ChangeDetaliz, 0, 0, pGlobalTXT_LocalizationStrings[64], 0);
-  pCharacterScreen_DollBtn = pWindow->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, UIMSG_ClickPaperdoll, 0, 0, "", 0);
+  pWindow->CreateButton(0, 0, 476, 345, 1, 122, UIMSG_InventoryLeftClick, 0, 0, "", 0);
+  pCharacterScreen_DetalizBtn = pWindow->CreateButton(600, 300, 30, 30, 1, 0, UIMSG_ChangeDetaliz, 0, 0, pGlobalTXT_LocalizationStrings[64], 0);
+  pCharacterScreen_DollBtn = pWindow->CreateButton(476, 0, 164, 345, 1, 0, UIMSG_ClickPaperdoll, 0, 0, "", 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);
@@ -449,7 +449,7 @@
   bRingsShownInCharScreen = 0;
   CharacterUI_LoadPaperdollTextures();
   pCurrentScreen = SCREEN_CASTING;
-  CS_inventory_window = GUIWindow::Create(0, 0, 640, 480, WINDOW_CastSpell_InInventory, (int)this, 0);
+  CS_inventory_window = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell_InInventory, (int)this, 0);
   pCharacterScreen_ExitBtn = CS_inventory_window->CreateButton(394, 318, 75, 33, 1, 0, UIMSG_ClickExitCharacterWindowBtn, 0, 0,
                  pGlobalTXT_LocalizationStrings[79], // Close
                  pIcons_LOD->GetTexture(papredoll_dbrds[2]),
--- a/UI/UIHouses.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/UI/UIHouses.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -1008,7 +1008,7 @@
         return;
       }
       pDialogueWindow->Release();
-      pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0);
+      pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), 345, WINDOW_MainMenu, 0, 0);
       pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation"
                                                        pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);
       pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", nullptr);
@@ -1020,7 +1020,7 @@
           || in_current_building_type != BuildingType_Temple || uMessageParam != BuildingType_MindGuild )
       {
         pDialogueWindow->Release();
-        pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0);
+        pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), 345, WINDOW_MainMenu, 0, 0);
         pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation"
                                                          pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);
         pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", nullptr);
--- a/UI/UIMainMenu.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/UI/UIMainMenu.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -23,8 +23,8 @@
   pPaletteManager->SetColorChannelInfo(5, 6, 5);
   pPaletteManager->RecalculateAll();
 
-  for (uint i = 0; i < 480; ++i)
-    pSRZBufferLineOffsets[i] = 640 * i;
+  for (uint i = 0; i < window->GetHeight(); ++i)
+    pSRZBufferLineOffsets[i] = window->GetWidth() * i;
 
   pRenderer->ResetTextureClipRect();
 
@@ -101,7 +101,7 @@
   uTextureID_BUTTMAKE = pIcons_LOD->LoadTexture("BUTTMAKE", TEXTURE_16BIT_PALETTE);
   uTextureID_BUTTMAKE2 = pIcons_LOD->LoadTexture("BUTTMAKE2", TEXTURE_16BIT_PALETTE);
 
-  pPrimaryWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
+  pPrimaryWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0);
   pPrimaryWindow->CreateButton(7, 8, 460, 343, 1, 0, UIMSG_MouseLeftClickInGame, 0, 0, "", 0);
 
   pPrimaryWindow->CreateButton(61, 424, 31, 80, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0);//buttons for portraits
@@ -284,7 +284,7 @@
     cred_texture.uHeight, Color16(0x70u, 0x8Fu, 0xFEu), Color16(0xECu, 0xE6u, 0x9Cu), pString, cred_texture.pPixels, cred_texture.uWidth);
   free(pString);
 
-  pWindow_MainMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, cred_texturet);
+  pWindow_MainMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, cred_texturet);
   pWindow_MainMenu->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_Escape, 0, 27, "", 0);
   pCurrentScreen = SCREEN_CREATORS;
   SetCurrentMenuID(MENU_CREDITSPROC);
--- a/UI/UIPartyCreation.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/UI/UIPartyCreation.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -101,7 +101,7 @@
   pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX);
   uPlayerCreationUI_SkySliderPos = (GetTickCount() % 12800) / 20;
   pRenderer->DrawTextureIndexed(uPlayerCreationUI_SkySliderPos, 2, pTexture_MAKESKY);
-  pRenderer->DrawTextureIndexed(uPlayerCreationUI_SkySliderPos - 640, 2, pTexture_MAKESKY);
+  pRenderer->DrawTextureIndexed(uPlayerCreationUI_SkySliderPos - window->GetWidth(), 2, pTexture_MAKESKY);
   pRenderer->DrawTextureTransparent(0, 0, pTexture_MAKETOP);
 
   uPlayerCreationUI_SelectedCharacter = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) / 7;
@@ -115,7 +115,7 @@
       Error("Invalid selected character");
   }
 
-  pTextCenter = pFontCChar->AlignText_Center(640, pGlobalTXT_LocalizationStrings[51]);
+  pTextCenter = pFontCChar->AlignText_Center(window->GetWidth(), pGlobalTXT_LocalizationStrings[51]);
   pGUIWindow_CurrentMenu->DrawText(pFontCChar, pTextCenter + 1, 0, 0, pGlobalTXT_LocalizationStrings[51], 0, 0, 0);//С О З Д А Т Ь  О Т Р Я Д
   pRenderer->DrawTextureTransparent(17, 35, pPlayerPortraits[pParty->pPlayers[0].uCurrentFace]);
   pRenderer->DrawTextureTransparent(176, 35, pPlayerPortraits[pParty->pPlayers[1].uCurrentFace]);
@@ -426,7 +426,7 @@
     pTextures_arrowr[uControlParam] = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE);
   }
   while ( ++uControlParam < 20 );
-  pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
+  pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0);
   uControlParam = 0;
   uX = 8;
   do
@@ -435,7 +435,7 @@
     uX += 158;
     ++uControlParam;
   }
-  while ( (signed int)uX < 640 );
+  while ( (signed int)uX < window->GetWidth() );
 
   pCreationUI_BtnPressLeft[0]   = pGUIWindow_CurrentMenu->CreateButton( 10,  32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev,  0, 0, "", pTexture_presleft, 0);
   pCreationUI_BtnPressLeft[1]   = pGUIWindow_CurrentMenu->CreateButton(169,  32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev,  1, 0, "", pTexture_presleft, 0);
@@ -465,7 +465,7 @@
     uX += 158;
     ++uControlParam;
   }
-  while ( (signed int)uX < 640 );
+  while ( (signed int)uX < window->GetWidth() );
 
   pGUIWindow_CurrentMenu->CreateButton(  5, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 0, '1', "", 0);
   pGUIWindow_CurrentMenu->CreateButton(163, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 1, '2', "", 0);
--- a/UI/UIRest.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/UI/UIRest.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -63,7 +63,7 @@
   uTextureID_RestUI_restb4 = pIcons_LOD->LoadTexture("restb4", TEXTURE_16BIT_PALETTE);
   uTextureID_RestUI_restexit = pIcons_LOD->LoadTexture("restexit", TEXTURE_16BIT_PALETTE);
   LoadActualSkyFrame();
-  pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Rest, 0, 0);
+  pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Rest, 0, 0);
   pButton_RestUI_Exit          = pGUIWindow_CurrentMenu->CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest,       0,   0, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restexit), 0);
   pButton_RestUI_Main          = pGUIWindow_CurrentMenu->CreateButton( 24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour,      0, 'R', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb4), 0);
   pButton_RestUI_WaitUntilDawn = pGUIWindow_CurrentMenu->CreateButton( 61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 'D', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb1), 0);
--- a/UI/UISaveLoad.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/UI/UISaveLoad.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -308,7 +308,7 @@
   uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD", TEXTURE_16BIT_PALETTE);
   uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
   uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
-  pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_SaveLoadButtons, 0, 0);
+  pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_SaveLoadButtons, 0, 0);
   pGUIWindow_CurrentMenu->CreateButton(21, 198, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0);
   pGUIWindow_CurrentMenu->CreateButton(21, 218, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 1, 0, "", 0);
   pGUIWindow_CurrentMenu->CreateButton(21, 238, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 2, 0, "", 0);
--- a/UI/UIShops.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/UI/UIShops.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -79,7 +79,7 @@
         if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID)
         {
           pRenderer->DrawTextureTransparent((60 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_X, weapons_Ypos[i] + 30, ItemsInShopTexture[i]);
-          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[(60 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_X + 640 * (weapons_Ypos[i] + 30)], ItemsInShopTexture[i], i + 1);
+          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[(60 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_X + window->GetWidth() * (weapons_Ypos[i] + 30)], ItemsInShopTexture[i], i + 1);
         }
         item_X += 70;
       }
@@ -130,7 +130,7 @@
         if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID)
         {
           pRenderer->DrawTextureTransparent((60 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_X, weapons_Ypos[i] + 30, ItemsInShopTexture[i]);
-          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[(60 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_X + 640 * (weapons_Ypos[i] + 30)], ItemsInShopTexture[i], i + 1);
+          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[(60 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_X + window->GetWidth() * (weapons_Ypos[i] + 30)], ItemsInShopTexture[i], i + 1);
         }
         item_X += 70;
       }
@@ -412,7 +412,7 @@
           else
           {
             pRenderer->DrawTextureTransparent(( 86 - (ItemsInShopTexture[i]->uTextureWidth / 2)) + item_x, 98 -  ItemsInShopTexture[i]->uTextureHeight, ItemsInShopTexture[i]);
-            v59 = item_x + (86 - (ItemsInShopTexture[i]->uTextureWidth / 2)) + 640 * (98 -  ItemsInShopTexture[i]->uTextureHeight);
+            v59 = item_x + (86 - (ItemsInShopTexture[i]->uTextureWidth / 2)) + window->GetWidth() * (98 -  ItemsInShopTexture[i]->uTextureHeight);
           }
           ZBuffer_DoFill(&pRenderer->pActiveZBuffer[v59], ItemsInShopTexture[i], i + 1);
         }
@@ -471,7 +471,7 @@
           else
           {
             pRenderer->DrawTextureTransparent(86 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2) + item_x, 98 - ItemsInShopTexture[i]->uTextureHeight, ItemsInShopTexture[i]);
-            v59 = (86 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_x + 640 * (98 - ItemsInShopTexture[i]->uTextureHeight);
+            v59 = (86 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_x + window->GetWidth() * (98 - ItemsInShopTexture[i]->uTextureHeight);
           }
           ZBuffer_DoFill(&pRenderer->pActiveZBuffer[v59], ItemsInShopTexture[i], i + 1);
         }
@@ -765,7 +765,7 @@
           else if ( (signed int)product_width_1row < 18 )
             product_width_1row = 18;
           pRenderer->DrawTextureTransparent(product_width_1row, product_height_1row, ItemsInShopTexture[i]);
-          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_1row + 640 * product_height_1row], ItemsInShopTexture[i], i + 1);
+          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_1row + window->GetWidth() * product_height_1row], ItemsInShopTexture[i], i + 1);
         }
       }
       for ( uint i = 0; i < 6; ++i )
@@ -790,7 +790,7 @@
               product_width_2row = 18;
           }
           pRenderer->DrawTextureTransparent(product_width_2row, product_height_2row, ItemsInShopTexture[i + 6]);
-          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_2row + 640 * product_height_2row], ItemsInShopTexture[i + 6], i + 7);
+          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_2row + window->GetWidth() * product_height_2row], ItemsInShopTexture[i + 6], i + 7);
         }
       }
       if ( HouseUI_CheckIfPlayerCanInteract() )
@@ -853,7 +853,7 @@
               product_width_1row = 18;
           }
           pRenderer->DrawTextureTransparent(product_width_1row, product_height_1row, ItemsInShopTexture[i]);
-          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_1row + 640 * product_height_1row], ItemsInShopTexture[i], i + 1);
+          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_1row + window->GetWidth() * product_height_1row], ItemsInShopTexture[i], i + 1);
         }
       }
       for ( uint i = 0; i < 6; ++i )
@@ -878,7 +878,7 @@
               product_width_2row = 18;
           }
           pRenderer->DrawTextureTransparent(product_width_2row, product_height_2row, ItemsInShopTexture[i + 6]);
-          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_2row + 640 * product_height_2row], ItemsInShopTexture[i + 6], i + 7);
+          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_2row + window->GetWidth() * product_height_2row], ItemsInShopTexture[i + 6], i + 7);
         }
       }
       if ( HouseUI_CheckIfPlayerCanInteract() )
@@ -1142,7 +1142,7 @@
             product_width_1row = 18;
         }
         pRenderer->DrawTextureTransparent(product_width_1row, product_height_1row, ItemsInShopTexture[i]);
-        ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_1row + 640 * product_height_1row], ItemsInShopTexture[i], i + 1);
+        ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_1row + window->GetWidth() * product_height_1row], ItemsInShopTexture[i], i + 1);
       }
     }
     for ( uint i = 0; i < 6; ++i )
@@ -1165,7 +1165,7 @@
             product_width_2row = 18;
         }
         pRenderer->DrawTextureTransparent(product_width_2row, product_height_2row, ItemsInShopTexture[i + 6]);
-        ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_2row + 640 * product_height_2row], ItemsInShopTexture[i + 6], i + 7);
+        ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_2row + window->GetWidth() * product_height_2row], ItemsInShopTexture[i + 6], i + 7);
       }
     }
     if ( HouseUI_CheckIfPlayerCanInteract() )
@@ -1228,7 +1228,7 @@
             product_width_1row = 18;
         }
         pRenderer->DrawTextureTransparent(product_width_1row, product_height_1row, ItemsInShopTexture[i]);
-        ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_1row + 640 * product_height_1row], ItemsInShopTexture[i], i + 1);
+        ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_1row + window->GetWidth() * product_height_1row], ItemsInShopTexture[i], i + 1);
       }
     }
     for ( uint i = 0; i < 6; ++i )
@@ -1253,7 +1253,7 @@
             product_width_2row = 18;
         }
         pRenderer->DrawTextureTransparent(product_width_2row, product_height_2row, ItemsInShopTexture[i + 6]);
-        ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_2row + 640 * product_height_2row], ItemsInShopTexture[i + 6], i + 7);
+        ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_2row + window->GetWidth() * product_height_2row], ItemsInShopTexture[i + 6], i + 7);
       }
     }
     if ( HouseUI_CheckIfPlayerCanInteract() )
--- a/UI/UITransition.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/UI/UITransition.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -56,7 +56,7 @@
     if ( pMapStats->GetMapInfo(pCurrentMapName) )
     {
       sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)].pName); // "Leave %s"
-      pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Transition, 0, sHouseName.data());
+      pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Transition, 0, sHouseName.data());
       //if ( pAnimatedRooms[p2DEvents[anim_id].uAnimationID].uRoomSoundId )
         //PlayHouseSound(anim_id, HouseSound_Greeting);
       if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && uActiveCharacter && pParty->uFlags & 0x30 )
@@ -66,7 +66,7 @@
       return;
     }
     strcpy(sHouseName.data(), pGlobalTXT_LocalizationStrings[79]);
-    pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Transition, 0, sHouseName.data());
+    pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Transition, 0, sHouseName.data());
     //if ( pAnimatedRooms[p2DEvents[anim_id].uAnimationID].uRoomSoundId )
       //PlayHouseSound(anim_id, HouseSound_Greeting);
     if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && uActiveCharacter && pParty->uFlags & 0x30 )
@@ -81,7 +81,7 @@
   if ( pMapStats->GetMapInfo(v15) )
   {
     sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[411], pMapStats->pInfos[pMapStats->GetMapInfo(v15)].pName);//Войти в ^Pv[%s]
-    pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Transition, 0, sHouseName.data());
+    pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Transition, 0, sHouseName.data());
     if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && uActiveCharacter && pParty->uFlags & 0x30 )
       pPlayers[uActiveCharacter]->PlaySound(SPEECH_47, 0);
     if ( IndoorLocation::GetLocationIndex(pLocationName) )
@@ -89,7 +89,7 @@
     return;
   }
   strcpy(sHouseName.data(), pGlobalTXT_LocalizationStrings[73]);//Войти
-  pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Transition, 0, sHouseName.data());
+  pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Transition, 0, sHouseName.data());
   //if ( pAnimatedRooms[p2DEvents[anim_id].uAnimationID].uRoomSoundId )
     //PlayHouseSound(anim_id, HouseSound_Greeting);
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && uActiveCharacter && pParty->uFlags & 0x30 )
@@ -119,7 +119,7 @@
     sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)].pName);// "Leave %s"
   else
     strcpy(sHouseName.data(), pGlobalTXT_LocalizationStrings[79]);// "Exit"
-  pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_ChangeLocation, 0, sHouseName.data());
+  pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_ChangeLocation, 0, sHouseName.data());
 }
 
 //----- (00444DCA) --------------------------------------------------------
--- a/UI/UiGame.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/UI/UiGame.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -306,7 +306,7 @@
   }
   if (sDialogue_SpeakingActorNPC_ID < 0)
     v9 = 4;
-  pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Dialogue, 3, 0);//pNumberContacts = 1, v9 = 0; pNumberContacts = 2, v9 = 3;
+  pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(),  window->GetHeight(), WINDOW_Dialogue, 3, 0);//pNumberContacts = 1, v9 = 0; pNumberContacts = 2, v9 = 3;
   if (pNPCInfo->Hired() && !pNPCInfo->bHasUsedTheAbility)
   {
     if (pNPCInfo->uProfession == 10 ||    //Healer
--- a/VideoPlayer.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/VideoPlayer.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -1218,7 +1218,7 @@
     if ( EnterHouse(HOUSE_BODY_GUILD_ERATHIA) )
     {
       pAudioPlayer->PlaySound(SOUND_Invalid, 0, 0, -1, 0, 0, 0, 0);
-      window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0);
+      window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_HouseInterior, 165, 0);
       window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, 0x31u, "", 0);
       window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, 0x32u, "", 0);
       window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3u, 0x33u, "", 0);
--- a/mm7_2.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/mm7_2.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -256,7 +256,7 @@
 
   uDialogueType = 83;
   pDialogueWindow->Release();
-  pDialogueWindow = GUIWindow::Create(0, 0, 640, 350, WINDOW_MainMenu, 0, 0);
+  pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), 350, WINDOW_MainMenu, 0, 0);
   pBtn_ExitCancel = pDialogueWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34],// "Cancel"
                  pIcons_LOD->GetTexture(uExitCancelTextureId), 0);
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
@@ -730,7 +730,7 @@
   pRenderer->EndScene();
   free(_this.pPixels);
   _this.pPixels = 0;
-  window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
+  window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0);
   pWindow.uFrameX = 75;
   pWindow.uFrameY = 60;
   pWindow.uFrameWidth = 469;
@@ -2866,7 +2866,7 @@
 
   pIcons_LOD->_inlined_sub2();
 
-  pWindow_MainMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
+  pWindow_MainMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0);
   Texture* pNew = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE);
   Texture* pLoad = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE);
   Texture* pCredits = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE);
@@ -2893,7 +2893,7 @@
       {
         pTexture_PCX.Release();
         pTexture_PCX.Load("lsave640.pcx", 0);
-        pGUIWindow2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
+        pGUIWindow2 = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0);
         pCurrentScreen = SCREEN_LOADGAME;
         LoadUI_Load(0);
       }
@@ -4157,7 +4157,7 @@
 
   constructors();
 
-  if (!MM7_Initialize(640, 480))
+  if (!MM7_Initialize(640, 480))//задаётся размер окна
   {
     Log::Warning(L"MM init: failed");
     pGame->Deinitialize();
@@ -4451,9 +4451,7 @@
     }
   }
   else
-  {
     LOBYTE(viewparams->field_20) = 0;
-  }
   pParty->uFlags |= 2;
   viewparams->uSomeY = viewparams->uScreen_topL_Y;
   viewparams->uSomeX = viewparams->uScreen_topL_X;
--- a/mm7_3.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/mm7_3.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -2821,43 +2821,75 @@
 //----- (0047C3D7) --------------------------------------------------------
 int __fastcall sub_47C3D7_get_fog_specular(int a1, int a2, float a3)
 {
-  double v5; // st7@10
+  int v3; // ecx@1
   signed int v7; // ecx@11
-  double v8; // st6@12
-  double v9; // st7@15
-  double v10; // st6@16
-  float v11; // ST14_4@17
-  double v12; // ST08_8@17
-
+
+  v3 = pWeather->bNight;
+  if ( bUnderwater == 1 )
+    v3 = 0;
   if ( pParty->armageddon_timer || !(day_attrib & DAY_ATTRIB_FOG) && !bUnderwater )
     return 0xFF000000;
-  if ( a3 == 0.0 )
-    return (unsigned int)(-1 - 216) << 24;
-  if ( a2 )
-    return (unsigned int)(-1 - 248) << 24;
-  if (a3 < (double)day_fogrange_1)
-    return (unsigned int)(-1) << 24;
-  if (a3 < (double)day_fogrange_2)
-    return (unsigned int)(-1 - 216) << 24;
-
-  if ( pWeather->bNight && !bUnderwater)
+  if ( v3 )
   {
-    v5 = (double)day_fogrange_1;
-    v8 = (double)day_fogrange_2;
-    v7 = (signed __int64)((a3 - v5) / (v8 - v5) * 216.0);
+    if ( a3 < (double)day_fogrange_1 )
+    {
+      v7 = 0;
+      if ( a3 == 0.0 )
+        v7 = 216;
+      if ( a2 )
+        v7 = 248;
+      return (-1 - v7) << 24;
+    }
+    else
+    {
+      if ( a3 > (double)day_fogrange_2 )
+      {
+        v7 = 216;
+        if ( a3 == 0.0 )
+          v7 = 216;
+        if ( a2 )
+          v7 = 248;
+        return (-1 - v7) << 24;
+      }
+      v7 = (signed __int64)((a3 - (double)day_fogrange_1) / ((double)day_fogrange_2 - (double)day_fogrange_1) * 216.0);
+    }
   }
   else
   {
-    v9 = (double)day_fogrange_1;
-    v10 = (double)day_fogrange_2;
-    v11 = (a3 - v9) * 216.0 / (v10 - v9);
-    v7 = bankersRounding(v11);
+    if ( a3 < (double)day_fogrange_1 )
+    {
+      v7 = 0;
+      if ( a3 == 0.0 )
+        v7 = 216;
+      if ( a2 )
+        v7 = 248;
+      return (-1 - v7) << 24;
+    }
+    else
+    {
+      if ( a3 > (double)day_fogrange_2 )
+      {
+        v7 = 216;
+        if ( a3 == 0.0 )
+          v7 = 216;
+        if ( a2 )
+          v7 = 248;
+        return (-1 - v7) << 24;
+      }
+      else
+        v7 = floorf(((a3 - (double)day_fogrange_1) * 216.0 / ((double)day_fogrange_2 - (double)day_fogrange_1)) + 0.5f);
+    }
   }
   if ( v7 > 216 )
+    v7 = 216;
+  else
   {
-    v7 = 216;
+    if ( a3 == 0.0 )
+      v7 = 216;
   }
-  return ( -1 - v7) << 24;
+  if ( a2 )
+    v7 = 248;
+  return (-1 - v7) << 24;
 }
 
 //----- (0047C4FC) --------------------------------------------------------
@@ -3849,7 +3881,7 @@
     dword_5C3418 = a1;
     dword_5C341C = a2;
     _591094_decoration = activeLevelDecoration;
-    pGUIWindow2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_GreetingNPC, a4, 0);
+    pGUIWindow2 = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_GreetingNPC, a4, 0);
     pGUIWindow2->CreateButton( 61, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0);
     pGUIWindow2->CreateButton(177, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0);
     pGUIWindow2->CreateButton(292, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0);
--- a/mm7_4.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/mm7_4.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -2324,7 +2324,7 @@
   v1 = 0;
   pDialogueWindow->eWindowType = WINDOW_MainMenu;
   pDialogueWindow->Release();
-  pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Dialogue, 1, 0);
+  pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Dialogue, 1, 0);
   if ( pNPCStats->pProfessions[v0->uProfession].pBenefits)//*(&pNPCStats->field_13A5C + 5 * v0->uProfession) )
   {
     pDialogueWindow->CreateButton(480, 160, 140, 28, 1, 0, UIMSG_SelectNPCDialogueOption, 77, 0, pGlobalTXT_LocalizationStrings[407], 0);
@@ -2345,7 +2345,7 @@
   current_npc_text = (char *)pNPCTopics[a4 + 168].pText;
   _4B254D_SkillMasteryTeacher(a4);
   pDialogueWindow->Release();
-  pDialogueWindow = GUIWindow::Create(0, 0, 640, 350, WINDOW_MainMenu, a4, 0);
+  pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), 350, WINDOW_MainMenu, a4, 0);
   pBtn_ExitCancel = pDialogueWindow->CreateButton( 471, 445, 169,  35,   1,  0, UIMSG_Escape, 0,   0,
                  pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uExitCancelTextureId), 0);
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
--- a/mm7_5.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/mm7_5.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -1065,7 +1065,7 @@
         *pZBuffer = uZValue;
       ++pZBuffer;
     }
-    pZBuffer += 640 - pTex->uTextureWidth;
+    pZBuffer += window->GetWidth() - pTex->uTextureWidth;
   }
   if ( pIcons_LOD->dword_011BA4 )
   {
@@ -1094,7 +1094,7 @@
       *pZBuffer = a3;
       ++pZBuffer;
     }
-    pZBuffer += 640 - a2->uTextureWidth;
+    pZBuffer += window->GetWidth() - a2->uTextureWidth;
   }
   if ( pIcons_LOD->dword_011BA4 )
   {
--- a/mm7_data.cpp	Thu Feb 13 23:02:32 2014 +0600
+++ b/mm7_data.cpp	Fri Feb 14 18:08:30 2014 +0600
@@ -2,7 +2,7 @@
 
 #include "GUIWindow.h"
 #include "Party.h"
-
+#include "OSWindow.h"
 
 
 void ErrHR(HRESULT hr, const char *pAPI, const char *pFunction, const char *pFile, int line)