changeset 376:615e6b6f55c2

Merge
author Gloval
date Fri, 22 Feb 2013 20:03:15 +0400
parents c606cabd7cbf (current diff) edd2d8b7e3c4 (diff)
children 243418228760
files
diffstat 22 files changed, 301 insertions(+), 463 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Fri Feb 22 08:23:15 2013 +0400
+++ b/Actor.cpp	Fri Feb 22 20:03:15 2013 +0400
@@ -151,14 +151,14 @@
   NPCData *v4; // eax@1
   NPCData *v5; // ebp@1
   unsigned int v6; // eax@1
-  signed int v7; // eax@3
+  //signed int v7; // eax@3
   unsigned int v8; // eax@8
   int v9; // esi@8
   int v10; // eax@11
   GUIWindow *v11; // ecx@19
   signed int v12; // eax@21
   //int v13; // [sp-8h] [bp-44h]@34
-  const char *v14; // [sp-4h] [bp-40h]@4
+  //const char *v14; // [sp-4h] [bp-40h]@4
   //int v15; // [sp-4h] [bp-40h]@34
   signed int v16; // [sp-4h] [bp-40h]@35
   int v17; // [sp+10h] [bp-2Ch]@1
@@ -181,9 +181,9 @@
   v6 = v4->uFlags;
   if ( (v6 & 3) != 2 )
     v5->uFlags = v6 + 1;
-  v7 = const_2();
+  /*v7 = const_2();
   sprintf(pContainer, "evt%02d", v7);
-  if ( !pParty->uAlignment )
+  if (pParty->alignment == PartyAlignment_Good)
   {
     v14 = "-b";
     strcat(pContainer, v14);
@@ -192,7 +192,15 @@
   {
     v14 = "-c";
     strcat(pContainer, v14);
+  }*/
+
+  switch (pParty->alignment)
+  {
+    case PartyAlignment_Good:    sprintf(pContainer, "evt%02d-b", const_2()); break;
+    case PartyAlignment_Neutral: sprintf(pContainer, "evt%02d", const_2()); break;
+    case PartyAlignment_Evil:    sprintf(pContainer, "evt%02d-c", const_2()); break;
   }
+
   v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
   array_5913D8[6] = 0;
   uNumDialogueNPCPortraits = 1;
--- a/Events.cpp	Fri Feb 22 08:23:15 2013 +0400
+++ b/Events.cpp	Fri Feb 22 20:03:15 2013 +0400
@@ -25,6 +25,7 @@
 #include "Events.h"
 #include "Events2D.h"
 #include "Weather.h"
+#include "Party.h"
 
 
 
@@ -367,11 +368,11 @@
 				v16 = RemoveQuotes(Str);
 				VideoPlayer::MovieLoop(v16, 0, v14, 1);
 				if ( !_strcmpi(v16, "arbiter good") )
-					{
-					pParty->uAlignment = 0;
+                {
+                  pParty->alignment = PartyAlignment_Good;
 					v18 = 0;
 					LOBYTE(v17) = 1;
-					SetUserInterface(v18, v17);
+					SetUserInterface(PartyAlignment_Good, v17);
 					if ( !v15 || v128 == 3 )
 						{
 						pCurrentScreen = v128;
@@ -392,9 +393,9 @@
 				if ( !_strcmpi(v16, "arbiter evil") )
 					{
 					v18 = 2;
-					pParty->uAlignment = 2;
+					pParty->alignment = PartyAlignment_Evil;
 					LOBYTE(v17) = 1;
-					SetUserInterface(v18, v17);
+					SetUserInterface(PartyAlignment_Evil, v17);
 					if ( !v15 || v128 == 3 )
 						{
 						pCurrentScreen = v128;
--- a/GUIProgressBar.cpp	Fri Feb 22 08:23:15 2013 +0400
+++ b/GUIProgressBar.cpp	Fri Feb 22 20:03:15 2013 +0400
@@ -1,3 +1,5 @@
+#include <assert.h>
+
 #include "GUIProgressBar.h"
 #include "LOD.h"
 #include "Mouse.h"
@@ -23,8 +25,8 @@
   int v5; // ecx@8
   int v6; // edi@8
   int v7; // edx@14
-  const char *v8; // [sp-8h] [bp-84h]@20
-  unsigned int v9; // [sp-4h] [bp-80h]@20
+  //const char *v8; // [sp-8h] [bp-84h]@20
+  //unsigned int v9; // [sp-4h] [bp-80h]@20
   char Str1[64]; // [sp+4h] [bp-78h]@16
 
   if (type < 1 || type > 1)
@@ -74,7 +76,8 @@
     Draw();
     return true;
   }
-  if ( !pParty->uAlignment )
+
+  /*if ( !pParty->uAlignment )
   {
     v9 = 2;
     v8 = "bardata-b";
@@ -92,7 +95,15 @@
     v8 = "bardata-c";
 LABEL_23:
     pIcons_LOD->_410522(&pBardata, v8, v9);
+  }*/
+  switch (pParty->alignment)
+  {
+    case PartyAlignment_Good:    pIcons_LOD->_410522(&pBardata, "bardata-b", 2); break;
+    case PartyAlignment_Neutral: pIcons_LOD->_410522(&pBardata, "bardata", 2); break;
+    case PartyAlignment_Evil:    pIcons_LOD->_410522(&pBardata, "bardata-c", 2); break;
+    default: assert(false);
   }
+
   uProgressCurrent = 0;
   uProgressMax = 26;
   Draw();
--- a/GUIWindow.cpp	Fri Feb 22 08:23:15 2013 +0400
+++ b/GUIWindow.cpp	Fri Feb 22 20:03:15 2013 +0400
@@ -1040,11 +1040,11 @@
   int v9; // eax@50
   unsigned int v10; // [sp-10h] [bp-C8h]@53
   unsigned __int16 v11; // [sp-Ch] [bp-C4h]@53
-  unsigned int v12; // [sp-Ch] [bp-C4h]@60
+  //unsigned int v12; // [sp-Ch] [bp-C4h]@60
   char *v13; // [sp-8h] [bp-C0h]@50
-  unsigned int v14; // [sp-8h] [bp-C0h]@60
+  //unsigned int v14; // [sp-8h] [bp-C0h]@60
   unsigned int v15; // [sp-4h] [bp-BCh]@50
-  Texture *v16; // [sp-4h] [bp-BCh]@60
+  //Texture *v16; // [sp-4h] [bp-BCh]@60
   GUIWindow w; // [sp+Ch] [bp-ACh]@4
   GUIWindow v18; // [sp+60h] [bp-58h]@2
   int v19; // [sp+B4h] [bp-4h]@2
@@ -1057,7 +1057,7 @@
   v1 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
   v19 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u);
   pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background);
-  pRenderer->DrawTextureTransparent(0x1D4u, 0, (Texture *)(uTextureID_507B04 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507B04] : 0));
+  pRenderer->DrawTextureTransparent(0x1D4u, 0, &pIcons_LOD->pTextures[uTextureID_507B04]);
   if ( array_5913D8[6] != (NPCData *)uNumDialogueNPCPortraits || !uHouse_ExitPic )
   {
     w.uFrameWidth = 130;
@@ -1092,8 +1092,7 @@
       w.uFrameZ = 457;
       v5 = pFontArrus->CalcTextHeight(ptr_F8B1E8, &w, 13, 0);
       v6 = v5 + 7;
-      pRenderer->_4A6A68(8, 352 - (v5 + 7), (Texture *)(uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0),
-        (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - (v5 + 7));
+      pRenderer->_4A6A68(8, 352 - (v5 + 7), &pIcons_LOD->pTextures[uTextureID_Leather], pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight - (v5 + 7));
       pRenderer->DrawTextureIndexed(8u, 347 - v6, pTexture_591428);
       v7 = FitTextInAWindow(ptr_F8B1E8, pFontArrus, &w, 0xDu, 0);
       window_SpeakInHouse->DrawText(pFontArrus, 13, 354 - v6, 0, v7, 0, 0, 0);
@@ -1105,7 +1104,7 @@
     {
       pRenderer->DrawTextureIndexed(*(&pNPCPortraits_x + v8 + 6 * uNumDialogueNPCPortraits - 6) - 4,
         *(&pNPCPortraits_y + v8 + 6 * uNumDialogueNPCPortraits - 6) - 4,
-        (Texture *)(uTextureID_50795C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50795C] : 0));
+        &pIcons_LOD->pTextures[uTextureID_50795C]);
       pRenderer->DrawTextureIndexed(*(&pNPCPortraits_x + v8 + 6 * uNumDialogueNPCPortraits - 6),
         *(&pNPCPortraits_y + v8 + 6 * uNumDialogueNPCPortraits - 6), pDialogueNPCPortraits[v8]);
       if ( uNumDialogueNPCPortraits < 4 )
@@ -1143,8 +1142,7 @@
     goto LABEL_56;
   }
   v4 = (char *)array_5913D8[6] - 1;
-  pRenderer->DrawTextureIndexed(pNPCPortraits_x - 4, pNPCPortraits_y - 4,
-    (Texture *)(uTextureID_50795C != -1 ? &pIcons_LOD->pTextures[uTextureID_50795C] : 0));
+  pRenderer->DrawTextureIndexed(pNPCPortraits_x - 4, pNPCPortraits_y - 4, &pIcons_LOD->pTextures[uTextureID_50795C]);
   pRenderer->DrawTextureIndexed(pNPCPortraits_x, pNPCPortraits_y, pDialogueNPCPortraits[(signed int)v4]);
   if ( pCurrentScreen == SCREEN_E )
   {
@@ -1233,18 +1231,13 @@
 LABEL_58:
   if ( array_5913D8[6] == (NPCData *)uNumDialogueNPCPortraits && uHouse_ExitPic )
   {
-    pRenderer->DrawTextureIndexed(0x22Cu, 0x1C3u, (Texture *)(uTextureID_x_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_x_u] : 0));
-    v16 = (Texture *)(uTextureID_x_ok_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_ok_u] : 0);
-    v14 = 451;
-    v12 = 476;
+    pRenderer->DrawTextureIndexed(556, 451, &pIcons_LOD->pTextures[uTextureID_x_x_u]);
+    pRenderer->DrawTextureIndexed(476, 451, &pIcons_LOD->pTextures[uTextureID_x_ok_u]);
   }
   else
   {
-    v16 = (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0);
-    v14 = 445;
-    v12 = 471;
+    pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uTextureID_506438]);
   }
-  pRenderer->DrawTextureIndexed(v12, v14, v16);
 }
 
 
--- a/GUIWindow.h	Fri Feb 22 08:23:15 2013 +0400
+++ b/GUIWindow.h	Fri Feb 22 20:03:15 2013 +0400
@@ -190,7 +190,7 @@
   UIMSG_PlayerCreationRemoveUpSkill = 0x4A,
   UIMSG_PlayerCreationRemoveDownSkill = 0x4B,
   UIMSG_4E = 0x4E,
-  UIMSG_4F = 0x4F,
+  UIMSG_SPellbook_ShowHightlightedSpellInfo = 0x4F,
   UIMSG_51 = 0x51,
   UIMSG_LoadGame = 0x52,
   UIMSG_SaveGame = 0x53,
@@ -226,7 +226,7 @@
   UIMSG_InventoryLeftClick = 0x78,
   UIMSG_SkillUp = 0x79,
   UIMSG_7A = 0x7A,
-  UIMSG_7B = 0x7B,
+  UIMSG_GameMenu_ReturnToGame = 0x7B,
   UIMSG_StartNewGame = 0x7C,
   UIMSG_Game_OpenLoadGameDialog = 0x7D,
   UIMSG_Game_OpenSaveGameDialog = 0x7E,
@@ -240,7 +240,7 @@
   UIMSG_SelectDialogueOption = 0x88,
   UIMSG_8C = 0x8C,
   UIMSG_8D = 0x8D,
-  UIMSG_8E = 0x8E,
+  UIMSG_CastSpellFromBook = 0x8E,
   UIMSG_8F = 0x8F,
   UIMSG_PlayerCreation_VoicePrev = 0x90,
   UIMSG_PlayerCreation_VoiceNext = 0x91,
--- a/Party.cpp	Fri Feb 22 08:23:15 2013 +0400
+++ b/Party.cpp	Fri Feb 22 20:03:15 2013 +0400
@@ -555,9 +555,9 @@
   uNumGold = 200;
   uNumGoldInBank = 0;
   uNumFoodRations = 7;
-  uAlignment = 1;
 
-  SetUserInterface(uAlignment, true);
+  alignment = PartyAlignment_Neutral;
+  SetUserInterface(alignment, true);
 
   uTimePlayed = 0x21C00u;
   uLastRegenerationTime = 0x21C00;
--- a/Party.h	Fri Feb 22 08:23:15 2013 +0400
+++ b/Party.h	Fri Feb 22 20:03:15 2013 +0400
@@ -95,6 +95,12 @@
 
 
 
+enum PartyAlignment: unsigned __int32
+{
+  PartyAlignment_Good = 0,
+  PartyAlignment_Neutral = 1,
+  PartyAlignment_Evil = 2
+};
 
 
 
@@ -253,7 +259,7 @@
   unsigned int bTurnBasedModeOn;
   int field_880;
   int uFlags2;
-  unsigned int uAlignment;
+  PartyAlignment alignment;
   SpellBuff pPartyBuffs[20];
   Player pPlayers[4];
   NPCData pHirelings[2];
--- a/Player.cpp	Fri Feb 22 08:23:15 2013 +0400
+++ b/Player.cpp	Fri Feb 22 20:03:15 2013 +0400
@@ -1909,7 +1909,6 @@
   return result;
 }
 
-
 //----- (0049107D) --------------------------------------------------------
 int Player::GetBodybuilding()
 {
--- a/Render.cpp	Fri Feb 22 08:23:15 2013 +0400
+++ b/Render.cpp	Fri Feb 22 20:03:15 2013 +0400
@@ -10976,7 +10976,7 @@
       while ( v2 < (signed int)pObjectList->uNumObjects );
     }
     LOBYTE(v1) = 1;
-    SetUserInterface(pParty->uAlignment, v1);
+    SetUserInterface(pParty->alignment, v1);
     if ( pVideoPlayer->pVideoFrame.pPixels )
       pVideoPlayer->pVideoFrame.Load(pVideoPlayer->pVideoFrameTextureFilename, 1);
     if ( uCurrentMenuID )
--- a/SaveLoad.cpp	Fri Feb 22 08:23:15 2013 +0400
+++ b/SaveLoad.cpp	Fri Feb 22 20:03:15 2013 +0400
@@ -196,7 +196,7 @@
 
   viewparams->bRedrawGameUI = true;
 
-  SetUserInterface(pParty->uAlignment, true);
+  SetUserInterface(pParty->alignment, true);
 
   pEventTimer->Resume();
   pEventTimer->StopGameTime();
@@ -670,7 +670,8 @@
 //----- (0045E297) --------------------------------------------------------
 void SavegameList::Initialize(unsigned int bHideEmptySlots)
 {
-    memset(pSavegameList, 0, 0x3138);
+    //memset(pSavegameList, 0, 0x3138);
+  Reset();
     uNumSavegameFiles = 0;
 
   _chdir("saves");
--- a/SaveLoad.h	Fri Feb 22 08:23:15 2013 +0400
+++ b/SaveLoad.h	Fri Feb 22 20:03:15 2013 +0400
@@ -8,8 +8,16 @@
 {
   void Initialize(unsigned int a1);
 
+  inline void Reset()
+  {
+    for (int i = 0; i < 20; ++i)
+      field_0[i] = 0;
+    for (int i = 0; i < 44; ++i)
+      pSavesNames[i][0] = 0;
+  }
+
   char field_0[20];
-  char pSavesNames[40][280];
+  char pSavesNames[44][280];
 };
 #pragma pack(pop)
 
--- a/Texture.cpp	Fri Feb 22 08:23:15 2013 +0400
+++ b/Texture.cpp	Fri Feb 22 20:03:15 2013 +0400
@@ -169,12 +169,7 @@
 Texture *pTexture_RestUI_CurrentHourglassFrame; // idb
 
 
-unsigned int uTextureID_Optkb; // weak
-unsigned int uTextureID_Optkb_h; // weak
-unsigned int uTextureID_KeyResume1; // weak
-unsigned int uTextureID_Optkb_1; // weak
-unsigned int uTextureID_Optkb_2; // weak
-
+unsigned int uTextureID_Optkb[5];
 
 unsigned int uTextureID_507C10; // weak
 unsigned int uTextureID_507C14; // weak
@@ -186,15 +181,15 @@
 unsigned int uTextureID_507C50; // weak
 unsigned int uTextureID_507C54; // weak
 unsigned int uTextureID_507C58; // weak
-unsigned int uTextureID_ControlBG; // weak
-unsigned int uTextureID_Con_Smoo[3]; // weak
-unsigned int uTextureID_Con_ArrL; // weak
-unsigned int uTextureID_Con_ArrR; // weak
-unsigned int uTextureID_Option04; // weak
-unsigned int pTextureIDs_SoundLevels[10];
-unsigned int uTextureID_Option03; // weak
-unsigned int uTextureID_Option01;
-unsigned int uTextureID_Option02; // weak
+unsigned int uTextureID_ControlBG[23];
+//unsigned int uTextureID_Con_Smoo[3]; // weak
+//unsigned int uTextureID_Con_ArrL; // weak
+//unsigned int uTextureID_Con_ArrR; // weak
+//unsigned int uTextureID_Option04; // weak
+//unsigned int pTextureIDs_SoundLevels[10];
+//unsigned int uTextureID_Option03; // weak
+//unsigned int uTextureID_Option01;
+//unsigned int uTextureID_Option02; // weak
 
 
 unsigned int uTextureID_5118C8; // weak
--- a/Texture.h	Fri Feb 22 08:23:15 2013 +0400
+++ b/Texture.h	Fri Feb 22 20:03:15 2013 +0400
@@ -271,12 +271,7 @@
 extern Texture *pTexture_RestUI_CurrentHourglassFrame; // idb
 
 
-extern unsigned int uTextureID_Optkb; // weak
-extern unsigned int uTextureID_Optkb_h; // weak
-extern unsigned int uTextureID_KeyResume1; // weak
-extern unsigned int uTextureID_Optkb_1; // weak
-extern unsigned int uTextureID_Optkb_2; // weak
-
+extern unsigned int uTextureID_Optkb[5];
 
 extern unsigned int uTextureID_507C10; // weak
 extern unsigned int uTextureID_507C14; // weak
@@ -288,15 +283,15 @@
 extern unsigned int uTextureID_507C50; // weak
 extern unsigned int uTextureID_507C54; // weak
 extern unsigned int uTextureID_507C58; // weak
-extern unsigned int uTextureID_ControlBG; // weak
-extern unsigned int uTextureID_Con_Smoo[3]; // weak
-extern unsigned int uTextureID_Con_ArrL; // weak
-extern unsigned int uTextureID_Con_ArrR; // weak
-extern unsigned int uTextureID_Option04; // weak
-extern unsigned int pTextureIDs_SoundLevels[10];
-extern unsigned int uTextureID_Option03; // weak
-extern unsigned int uTextureID_Option01;
-extern unsigned int uTextureID_Option02; // weak
+extern unsigned int uTextureID_ControlBG[23]; // weak
+//extern unsigned int uTextureID_Con_Smoo[3]; // weak
+//extern unsigned int uTextureID_Con_ArrL; // weak
+//extern unsigned int uTextureID_Con_ArrR; // weak
+//extern unsigned int uTextureID_Option04; // weak
+//extern unsigned int pTextureIDs_SoundLevels[10];
+//extern unsigned int uTextureID_Option03; // weak
+//extern unsigned int uTextureID_Option01;
+//extern unsigned int uTextureID_Option02; // weak
 
 
 extern unsigned int uTextureID_5118C8; // weak
--- a/TurnEngine.h	Fri Feb 22 08:23:15 2013 +0400
+++ b/TurnEngine.h	Fri Feb 22 20:03:15 2013 +0400
@@ -6,6 +6,13 @@
 #pragma pack(push, 1)
 struct TurnBased_QueueElem
 {
+  inline TurnBased_QueueElem()
+  {
+    uPackedID = 0;
+    field_4 = 0;
+    uActionLength = 0;
+    field_C = 0;
+  }
   int uPackedID;
   int field_4;
   int uActionLength;
@@ -17,6 +24,18 @@
 #pragma pack(push, 1)
 struct stru262_TurnBased
 {
+  inline stru262_TurnBased()
+  {
+    field_0 = 0;
+    field_4 = 0;
+    field_8 = 0;
+    uActorQueueSize = 0;
+    field_10 = 0;
+    uActionPointsLeft = 0;
+    field_18 = 0;
+    field_1C = 0;
+  }
+
   signed int _404544();
   void _40471C();
   signed int Start();
--- a/mm7_1.cpp	Fri Feb 22 08:23:15 2013 +0400
+++ b/mm7_1.cpp	Fri Feb 22 20:03:15 2013 +0400
@@ -5,6 +5,8 @@
 */
 
 //#include <defs.h>
+#include <assert.h>
+
 #include "MM7.h"
 
 #include "MapInfo.h"
@@ -6115,21 +6117,16 @@
 // 4E28F8: using guessed type int pCurrentScreen;
 
 //----- (004226EF) --------------------------------------------------------
-void __fastcall SetUserInterface(int a1, bool bReplace)
+void SetUserInterface(PartyAlignment align, bool bReplace)
 {
-  int v2; // ecx@2
   unsigned int v3; // eax@7
   unsigned __int16 v4; // dx@7
   unsigned __int16 v5; // cx@7
   unsigned __int16 v6; // [sp-4h] [bp-14h]@7
 
-  if ( a1 )
-  {
-    v2 = a1 - 1;
-    if ( v2 )
-    {
-      if ( v2 != 1 )
-        return;
+
+    if (align == PartyAlignment_Evil)
+    {
       if ( bReplace )
       {
         pTexture_RightFrame->Reload("ib-r-C.pcx");
@@ -6213,7 +6210,7 @@
       v6 = 0;
       v5 = 10;
     }
-    else
+    else if (align == PartyAlignment_Neutral)
     {
       if ( bReplace )
       {
@@ -6309,8 +6306,7 @@
       v5 = 230;
       v6 = 193;
     }
-  }
-  else
+  else if (align == PartyAlignment_Good)
   {
     if ( bReplace )
     {
@@ -6361,6 +6357,8 @@
     v4 = 225;
     v6 = 255;
   }
+  else assert(false);
+
   uGameUIFontMain = v3;
   uGameUIFontShadow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v5, v4, v6);
 }
--- a/mm7_2.cpp	Fri Feb 22 08:23:15 2013 +0400
+++ b/mm7_2.cpp	Fri Feb 22 20:03:15 2013 +0400
@@ -13431,7 +13431,7 @@
       Rect.bottom = 246;
       ClipCursor(&Rect);
     }
-    SetUserInterface(1, false);
+    SetUserInterface(PartyAlignment_Neutral, false);
     ShowIntroVideo_and_LoadingScreen();
     WriteWindowsRegistryInt("Ran once", 1);
     dword_6BE364_game_settings_1 |= 0x4000;
--- a/mm7_3.cpp	Fri Feb 22 08:23:15 2013 +0400
+++ b/mm7_3.cpp	Fri Feb 22 20:03:15 2013 +0400
@@ -14670,14 +14670,14 @@
 //----- (00444C8F) --------------------------------------------------------
 GUIWindow *__cdecl UI_CreateTravelDialogue()
 {
-  signed int v0; // eax@1
+  //signed int v0; // eax@1
   unsigned int v1; // eax@6
   GUIWindow *result; // eax@9
-  const char *v3; // [sp-4h] [bp-2Ch]@2
+  //const char *v3; // [sp-4h] [bp-2Ch]@2
   char pContainer[32]; // [sp+0h] [bp-28h]@1
 
   pEventTimer->Pause();
-  v0 = const_2();
+  /*v0 = const_2();
   sprintf(pContainer, "evt%02d", v0);
   if ( pParty->uAlignment )
   {
@@ -14690,7 +14690,15 @@
     v3 = "-b";
   }
   strcat(pContainer, v3);
-LABEL_6:
+LABEL_6:*/
+  switch (pParty->alignment)
+  {
+    case PartyAlignment_Good:    sprintf(pContainer, "evt%02d-b", const_2());
+    case PartyAlignment_Neutral: sprintf(pContainer, "evt%02d", const_2());
+    case PartyAlignment_Evil:    sprintf(pContainer, "evt%02d-c", const_2());
+    default: assert(false);
+  }
+
   pTexture_Dialogue_Background = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE)];
   pTexture_outside = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("outside", TEXTURE_16BIT_PALETTE)];
   v1 = pMapStats->GetMapInfo(pCurrentMapName);
--- a/mm7_4.cpp	Fri Feb 22 08:23:15 2013 +0400
+++ b/mm7_4.cpp	Fri Feb 22 20:03:15 2013 +0400
@@ -5915,15 +5915,7 @@
             && uMouseY >= (signed int)pControlsHead->uY && uMouseY <= (signed int)pControlsHead->uW )//mouse movement
         {
           pControlParam = pControlsHead->uControlParam;
-          if ( (signed int)pNumMessage < 40 )
-          {
-            pMessageQueue_50CBD0->pMessages[pNumMessage].eType = (UIMessageType)pControlsHead->field_1C;
-            //pTexture = &pTexture_PCX;
-            pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = pControlParam;
-            *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-            pNumMessage = pMessageQueue_50CBD0->uNumMessages + 1;
-            ++pMessageQueue_50CBD0->uNumMessages;
-          }
+          pMessageQueue_50CBD0->SendMessage((UIMessageType)pControlsHead->field_1C, pControlParam, 0);
           v1 = 0;
         }
         pControlsHead = pControlsHead->pNext;
@@ -14771,7 +14763,7 @@
 {
   unsigned int v9; // ebx@1
   int v10; // edi@1
-  signed int v11; // eax@1
+  //signed int v11; // eax@1
   unsigned int v12; // eax@6
   const char *v13; // ST0C_4@6
   unsigned int v14; // eax@8
@@ -14779,7 +14771,7 @@
   unsigned int v16; // eax@16
   unsigned int result; // eax@26
   const char *v18; // [sp-8h] [bp-40h]@9
-  const char *v19; // [sp-4h] [bp-3Ch]@2
+  //const char *v19; // [sp-4h] [bp-3Ch]@2
   char *v20; // [sp-4h] [bp-3Ch]@9
   const char *v21; // [sp-4h] [bp-3Ch]@11
   char pContainer[40]; // [sp+Ch] [bp-2Ch]@1
@@ -14798,7 +14790,15 @@
   uCurrentHouse_Animation = v9;
   pEventTimer->Pause();
   pAudioPlayer->StopChannels(-1, -1);
-  v11 = const_2();
+
+  switch (pParty->alignment)
+  {
+    case PartyAlignment_Good:    sprintf(pContainer, "evt%02d-b", const_2()); break;
+    case PartyAlignment_Neutral: sprintf(pContainer, "evt%02d", const_2()); break;
+    case PartyAlignment_Evil:    sprintf(pContainer, "evt%02d-c", const_2()); break;
+    default: assert(false);
+  }
+  /*v11 = const_2();
   sprintf(pContainer, "evt%02d", v11);
   if ( pParty->uAlignment )
   {
@@ -14810,8 +14810,9 @@
   {
     v19 = "-b";
   }
-  strcat(pContainer, v19);
-LABEL_6:
+  strcat(pContainer, v19);*/
+
+//LABEL_6:
   v12 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
   v13 = pHouse_ExitPictures[v10];
   pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v12];
@@ -15007,12 +15008,12 @@
   //Player *v13; // esi@25
   int v14; // eax@25
   //Player *v15; // esi@27
-  signed int v16; // eax@32
+  //signed int v16; // eax@32
   unsigned int v17; // eax@37
   signed int v18; // edi@37
   signed int v19; // edi@41
   //unsigned int v20; // ecx@41
-  const char *v22; // [sp-4h] [bp-40h]@33
+  //const char *v22; // [sp-4h] [bp-40h]@33
   char pContainer[40]; // [sp+Ch] [bp-30h]@32
   unsigned int v24; // [sp+34h] [bp-8h]@5
   //enum HOUSE_TYPE v25; // [sp+38h] [bp-4h]@1
@@ -15130,7 +15131,8 @@
     ++pIcons_LOD->uTexturePacksCount;
     if ( !pIcons_LOD->uNumPrevLoadedFiles )
       pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
-    v16 = const_2();
+
+    /*v16 = const_2();
     sprintf(pContainer, "evt%02d", v16);
     if ( pParty->uAlignment )
     {
@@ -15142,8 +15144,16 @@
     {
       v22 = "-b";
     }
-    strcat(pContainer, v22);
-LABEL_37:
+    strcat(pContainer, v22);*/
+//LABEL_37:
+    switch (pParty->alignment)
+    {
+      case PartyAlignment_Good:    sprintf(pContainer, "evt%02d-b", const_2()); break;
+      case PartyAlignment_Neutral: sprintf(pContainer, "evt%02d", const_2()); break;
+      case PartyAlignment_Evil:    sprintf(pContainer, "evt%02d-c", const_2()); break;
+      default: assert(false);
+    }
+
     v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
     array_5913D8[6] = 0;
     pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v17];
--- a/mm7_5.cpp	Fri Feb 22 08:23:15 2013 +0400
+++ b/mm7_5.cpp	Fri Feb 22 20:03:15 2013 +0400
@@ -386,7 +386,6 @@
               memset(&actor, 0, 0x344u);
               actor.uNPC_ID += -1 - (unsigned __int8)pParty->field_709 - hireling_idx;
               pActor = &actor;
-//_actor_init_dlg:
               pActor->InitializeDialogue(v0);
             }
           }
@@ -415,7 +414,6 @@
               pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
             pGUIWindow_CurrentMenu->Release();
             uGameState = 4;
-LABEL_188:
             pCurrentScreen = SCREEN_GAME;
             viewparams->bRedrawGameUI = v0;
           }
@@ -425,7 +423,6 @@
             pAudioPlayer->PlaySound(SOUND_20001, 0, 0, -1, 0, 0, 0, 0);
             dword_6BE138 = 124;
           }
-//_release_tex_and_continue:
           stru_506E40.Release();
           continue;
         case UIMSG_Game_OpenLoadGameDialog:
@@ -453,11 +450,10 @@
           }
           else
           {
-            ShowStatusBarString(pGlobalTXT_LocalizationStrings[82], 2u);// "Are you sure?  Click again to quit"
+            ShowStatusBarString(pGlobalTXT_LocalizationStrings[82], 2);// "Are you sure?  Click again to quit"
             pAudioPlayer->PlaySound(SOUND_20001, 0, 0, -1, 0, 0, 0, 0);
             dword_6BE138 = 132;
           }
-          //goto _release_tex_and_continue;
           stru_506E40.Release();
           continue;
         case UIMSG_80:
@@ -465,63 +461,25 @@
           pIcons_LOD->_4114F2();
           pGUIWindow_CurrentMenu->Release();
           pCurrentScreen = SCREEN_OPTIONS;
-          v162 = 0;
-          v148 = 0;
-          pWindowType = (WindowType)8;
-          //goto LABEL_439;
-          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, pWindowType, v148, v162);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (WindowType)8, 0, 0);
           continue;
         case UIMSG_ArrowUp:
           --pSaveListPosition;
           if ( pSaveListPosition < 0 )
             pSaveListPosition = 0;
-          v163 = 0;
-          v8 = 199;
-          pButton2 = pBtnArrowUp;
-          //goto LABEL_60;
-          pWindowType1 = (WindowType)90;
-          v137 = 17;
-          v133 = 17;
-          v9 = 215;
-          //goto LABEL_733;
-          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          GUIWindow::Create(215, 199, 17, 17, (WindowType)90, (int)pBtnArrowUp, 0);
           continue;
         case UIMSG_DownArrow:
           ++pSaveListPosition;
           if ( pSaveListPosition >= uMessageParam )
             pSaveListPosition = uMessageParam - 1;
-          v163 = 0;
-          v8 = 323;
-          pButton2 = pBtnDownArrow;
-//LABEL_60:
-          pWindowType1 = (WindowType)90;
-          v137 = 17;
-          v133 = 17;
-          v9 = 215;
-          //goto LABEL_733;
-          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          GUIWindow::Create(215, 323, 17, 17, (WindowType)90, (int)pBtnDownArrow, 0);
           continue;
         case UIMSG_Cancel:
-          v163 = 0;
-          v8 = 302;
-          pButton2 = pBtnCancel;
-          v9 = 350;
-          pWindowType1 = (WindowType)96;
-          v137 = 42;
-          v133 = 106;
-          //goto LABEL_733;
-          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          GUIWindow::Create(350, 302, 106, 42, (WindowType)96, (int)pBtnCancel, 0);
           continue;
         case UIMSG_LoadSlot:
-          v163 = 0;
-          v8 = 302;
-          pButton2 = pBtnLoadSlot;
-          v9 = 241;
-          pWindowType1 = (WindowType)94;
-          v137 = 42;
-          v133 = 106;
-          //goto LABEL_733;
-          GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163);
+          GUIWindow::Create(241, 302, 106, 42, (WindowType)94, (int)pBtnLoadSlot, 0);
           continue;
         case UIMSG_SelectLoadSlot:
           if ( pGUIWindow_CurrentMenu->field_40 == v0 )
@@ -566,19 +524,15 @@
             LoadGame(uLoadGameUI_SelectedSlot);
             uGameState = 3;
           }
-          //goto _release_tex_and_continue;
           stru_506E40.Release();
           continue;
         case UIMSG_SaveGame:
           if ( pGUIWindow_CurrentMenu->field_40 == v0 )
           {
             pKeyActionMap->_459ED1(0);
-            strcpy(
-              (char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot,
-              (const char *)pKeyActionMap->pPressedKeysBuffer);
+            strcpy((char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot, (const char *)pKeyActionMap->pPressedKeysBuffer);
           }
           DoSavegame(uLoadGameUI_SelectedSlot);
-          //goto _release_tex_and_continue;
           stru_506E40.Release();
           continue;
         case UIMSG_Game_OpenSaveGameDialog:
@@ -586,75 +540,75 @@
           pCurrentScreen = SCREEN_SAVEGAME;
           GameUI_DrawSaveMenu();
           continue;
-        case UIMSG_Game_OpenOptionsDialog:
+        case UIMSG_Game_OpenOptionsDialog://Open
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           pGUIWindow_CurrentMenu->Release();
           viewparams->field_48 = v0;
           pCurrentScreen = SCREEN_OPTIONS;
-          uTextureID_ControlBG = pIcons_LOD->LoadTexture("ControlBG", TEXTURE_16BIT_PALETTE);
-          uTextureID_Con_Smoo[2] = pIcons_LOD->LoadTexture("con_16x", TEXTURE_16BIT_PALETTE);
-          uTextureID_Con_Smoo[1] = pIcons_LOD->LoadTexture("con_32x", TEXTURE_16BIT_PALETTE);
-          uTextureID_Con_ArrL = pIcons_LOD->LoadTexture("con_ArrL", TEXTURE_16BIT_PALETTE);
-          uTextureID_Con_ArrR = pIcons_LOD->LoadTexture("con_ArrR", TEXTURE_16BIT_PALETTE);
-          uTextureID_Con_Smoo[0] = pIcons_LOD->LoadTexture("con_Smoo", TEXTURE_16BIT_PALETTE);
-          pTextureIDs_SoundLevels[9] = pIcons_LOD->LoadTexture("convol00", TEXTURE_16BIT_PALETTE);
-          pTextureIDs_SoundLevels[0] = pIcons_LOD->LoadTexture("convol10", TEXTURE_16BIT_PALETTE);
-          pTextureIDs_SoundLevels[1] = pIcons_LOD->LoadTexture("convol20", TEXTURE_16BIT_PALETTE);
-          pTextureIDs_SoundLevels[2] = pIcons_LOD->LoadTexture("convol30", TEXTURE_16BIT_PALETTE);
-          pTextureIDs_SoundLevels[3] = pIcons_LOD->LoadTexture("convol40", TEXTURE_16BIT_PALETTE);
-          pTextureIDs_SoundLevels[4] = pIcons_LOD->LoadTexture("convol50", TEXTURE_16BIT_PALETTE);
-          pTextureIDs_SoundLevels[5] = pIcons_LOD->LoadTexture("convol60", TEXTURE_16BIT_PALETTE);
-          pTextureIDs_SoundLevels[6] = pIcons_LOD->LoadTexture("convol70", TEXTURE_16BIT_PALETTE);
-          pTextureIDs_SoundLevels[7] = pIcons_LOD->LoadTexture("convol80", TEXTURE_16BIT_PALETTE);
-          pTextureIDs_SoundLevels[8] = pIcons_LOD->LoadTexture("convol90", TEXTURE_16BIT_PALETTE);
-          uTextureID_Option04 = pIcons_LOD->LoadTexture("option04", TEXTURE_16BIT_PALETTE);
-          uTextureID_Option03 = pIcons_LOD->LoadTexture("option03", TEXTURE_16BIT_PALETTE);
-          uTextureID_Option02 = pIcons_LOD->LoadTexture("option02", TEXTURE_16BIT_PALETTE);
-          uTextureID_Option01 = pIcons_LOD->LoadTexture("option01", TEXTURE_16BIT_PALETTE);
+          uTextureID_ControlBG[0] = pIcons_LOD->LoadTexture("ControlBG", TEXTURE_16BIT_PALETTE);
+          uTextureID_ControlBG[3] = pIcons_LOD->LoadTexture("con_16x", TEXTURE_16BIT_PALETTE);
+          uTextureID_ControlBG[2] = pIcons_LOD->LoadTexture("con_32x", TEXTURE_16BIT_PALETTE);
+          uTextureID_ControlBG[4] = pIcons_LOD->LoadTexture("con_ArrL", TEXTURE_16BIT_PALETTE);
+          uTextureID_ControlBG[5] = pIcons_LOD->LoadTexture("con_ArrR", TEXTURE_16BIT_PALETTE);
+          uTextureID_ControlBG[1] = pIcons_LOD->LoadTexture("con_Smoo", TEXTURE_16BIT_PALETTE);
+          uTextureID_ControlBG[19] = pIcons_LOD->LoadTexture("convol00", TEXTURE_16BIT_PALETTE);
+          uTextureID_ControlBG[10] = pIcons_LOD->LoadTexture("convol10", TEXTURE_16BIT_PALETTE);
+          uTextureID_ControlBG[11] = pIcons_LOD->LoadTexture("convol20", TEXTURE_16BIT_PALETTE);
+          uTextureID_ControlBG[12] = pIcons_LOD->LoadTexture("convol30", TEXTURE_16BIT_PALETTE);
+          uTextureID_ControlBG[13] = pIcons_LOD->LoadTexture("convol40", TEXTURE_16BIT_PALETTE);
+          uTextureID_ControlBG[14] = pIcons_LOD->LoadTexture("convol50", TEXTURE_16BIT_PALETTE);
+          uTextureID_ControlBG[15] = pIcons_LOD->LoadTexture("convol60", TEXTURE_16BIT_PALETTE);
+          uTextureID_ControlBG[16] = pIcons_LOD->LoadTexture("convol70", TEXTURE_16BIT_PALETTE);
+          uTextureID_ControlBG[17] = pIcons_LOD->LoadTexture("convol80", TEXTURE_16BIT_PALETTE);
+          uTextureID_ControlBG[18] = pIcons_LOD->LoadTexture("convol90", TEXTURE_16BIT_PALETTE);
+          uTextureID_ControlBG[9] = pIcons_LOD->LoadTexture("option04", TEXTURE_16BIT_PALETTE);
+          uTextureID_ControlBG[20] = pIcons_LOD->LoadTexture("option03", TEXTURE_16BIT_PALETTE);
+          uTextureID_ControlBG[22] = pIcons_LOD->LoadTexture("option02", TEXTURE_16BIT_PALETTE);
+          uTextureID_ControlBG[21] = pIcons_LOD->LoadTexture("option01", TEXTURE_16BIT_PALETTE);
           pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Options, 0, 0);
           pGUIWindow_CurrentMenu->CreateButton(0x16u, 0x10Eu,
-            (uTextureID_Con_Smoo[2] != -1 ? pIcons_LOD->pTextures[uTextureID_Con_Smoo[2]].uTextureWidth : 24),
-            (uTextureID_Con_Smoo[2] != -1 ? pIcons_LOD->pTextures[uTextureID_Con_Smoo[2]].uTextureHeight : 26),
+            (uTextureID_ControlBG[3] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[3]].uTextureWidth : 24),
+            (uTextureID_ControlBG[3] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[3]].uTextureHeight : 26),
             v0, 0, 0xB8u, 0x80u, 0, v1, 0);
           pGUIWindow_CurrentMenu->CreateButton(0x5Du, 0x10Eu,
-            (uTextureID_Con_Smoo[1] != -1 ? pIcons_LOD->pTextures[uTextureID_Con_Smoo[1]].uTextureWidth : 24),
-            (uTextureID_Con_Smoo[1] != -1 ? pIcons_LOD->pTextures[uTextureID_Con_Smoo[1]].uTextureHeight : 26),
+            (uTextureID_ControlBG[2] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[2]].uTextureWidth : 24),
+            (uTextureID_ControlBG[2] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[2]].uTextureHeight : 26),
             v0, 0, 0xB8u, 0x40u, 0, v1, 0);
           pGUIWindow_CurrentMenu->CreateButton(0xA4u, 0x10Eu,
-            (uTextureID_Con_Smoo[0] != -1 ? pIcons_LOD->pTextures[uTextureID_Con_Smoo[0]].uTextureWidth : 24),
-            (uTextureID_Con_Smoo[0] != -1 ? pIcons_LOD->pTextures[uTextureID_Con_Smoo[0]].uTextureHeight : 26),
+            (uTextureID_ControlBG[1] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[1]].uTextureWidth : 24),
+            (uTextureID_ControlBG[1] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[1]].uTextureHeight : 26),
             v0, 0, 0xB8u, 0, 0, v1, 0);
           pGUIWindow_CurrentMenu->CreateButton(0x14u, 0x12Fu,
-            (uTextureID_Option01 != -1 ? pIcons_LOD->pTextures[uTextureID_Option01].uTextureWidth : 24),
-            (uTextureID_Option01 != -1 ? pIcons_LOD->pTextures[uTextureID_Option01].uTextureHeight : 26),
+            (uTextureID_ControlBG[21] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[21]].uTextureWidth : 24),
+            (uTextureID_ControlBG[21] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[21]].uTextureHeight : 26),
             v0, 0, 0xB9u, 0, 0, v1, 0);
           pGUIWindow_CurrentMenu->CreateButton(0x80u, 0x12Fu,
-            (uTextureID_Option02 != -1 ? pIcons_LOD->pTextures[uTextureID_Option02].uTextureWidth : 24),
-            (uTextureID_Option02 != -1 ? pIcons_LOD->pTextures[uTextureID_Option02].uTextureHeight : 26),
+            (uTextureID_ControlBG[22] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[22]].uTextureWidth : 24),
+            (uTextureID_ControlBG[22] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[22]].uTextureHeight : 26),
             v0, 0, 0xBBu, 0, 0, v1, 0);
           pGUIWindow_CurrentMenu->CreateButton(0x14u, 0x145u,
-            (uTextureID_Option03 != -1 ? pIcons_LOD->pTextures[uTextureID_Option03].uTextureWidth : 24),
-            (uTextureID_Option03 != -1 ? pIcons_LOD->pTextures[uTextureID_Option03].uTextureHeight : 26),
+            (uTextureID_ControlBG[20] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[20]].uTextureWidth : 24),
+            (uTextureID_ControlBG[20] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[20]].uTextureHeight : 26),
             v0, 0, 0xE1u, 0, 0, v1, 0);
           pGUIWindow_CurrentMenu->CreateButton(0x80u, 0x145u,
-            (uTextureID_Option04 != -1 ? pIcons_LOD->pTextures[uTextureID_Option04].uTextureWidth : 24),
-            (uTextureID_Option04 != -1 ? pIcons_LOD->pTextures[uTextureID_Option04].uTextureHeight : 26),
+            (uTextureID_ControlBG[9] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[9]].uTextureWidth : 24),
+            (uTextureID_ControlBG[9] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[9]].uTextureHeight : 26),
             v0, 0, 0xE2u, 0, 0, v1, 0);
           pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(243, 162, 16, 16, v0, 0, 111, 4, 0, v1,
-                         &pIcons_LOD->pTextures[uTextureID_Con_ArrL], 0);
+                         &pIcons_LOD->pTextures[uTextureID_ControlBG[4]], 0);
           pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0x1B3u, 0xA2u, 0x10u, 0x10u, v0, 0, 0x6Fu, 5, 0, v1,
-                         &pIcons_LOD->pTextures[uTextureID_Con_ArrR], 0);
+                         &pIcons_LOD->pTextures[uTextureID_ControlBG[5]], 0);
           pGUIWindow_CurrentMenu->CreateButton(0x107u, 0xA2u, 0xACu, 0x11u, v0, 0, 0x6Fu, 0, 0, v1, 0);
           pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(0xF3u, 0xD8u, 0x10u, 0x10u, v0, 0, 0x70u, 4, 0, v1,
-                         &pIcons_LOD->pTextures[uTextureID_Con_ArrL], 0);
+                         &pIcons_LOD->pTextures[uTextureID_ControlBG[4]], 0);
           pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0x1B3u, 0xD8u, 0x10u, 0x10u, v0, 0, 0x70u, 5, 0, v1,
-                         &pIcons_LOD->pTextures[uTextureID_Con_ArrR], 0);
+                         &pIcons_LOD->pTextures[uTextureID_ControlBG[5]], 0);
           pGUIWindow_CurrentMenu->CreateButton(0x107u, 0xD8u, 0xACu, 0x11u, v0, 0, 0x70u, 0, 0, v1, 0);
           pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(0xF3u, 0x10Eu, 0x10u, 0x10u, v0, 0, 0xBAu, 4, 0, v1,
-                         &pIcons_LOD->pTextures[uTextureID_Con_ArrL], 0);
+                         &pIcons_LOD->pTextures[uTextureID_ControlBG[4]], 0);
           pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0x1B3u, 0x10Eu, 0x10u, 0x10u, v0, 0, 0xBAu, 5u, 0, v1,
-                         &pIcons_LOD->pTextures[uTextureID_Con_ArrR], 0);
+                         &pIcons_LOD->pTextures[uTextureID_ControlBG[5]], 0);
           pGUIWindow_CurrentMenu->CreateButton(0x107u, 0x10Eu, 0xACu, 0x11u, v0, 0, 0xBAu, 0, 0, v1, 0);
           pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, v0, 0, 0x71u, 0, 0,
             pGlobalTXT_LocalizationStrings[619],// "Return to Game"
@@ -662,17 +616,17 @@
           pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x8Cu, 0xD6u, 0x28u, v0, 0, 0x19Fu, 0, 0x4Bu, v1, 0);
           pGUIWindow_CurrentMenu->CreateButton(19, 194, 214, 40, v0, 0, 421, 0, 86, v1, 0);
           continue;
-        case UIMSG_OpenKeyMappingOptions:
+        case UIMSG_OpenKeyMappingOptions://Open
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           pGUIWindow_CurrentMenu->Release();
           viewparams->field_48 = 1;
           pCurrentScreen = SCREEN_KEYBOARD_OPTIONS;
-          uTextureID_Optkb = pIcons_LOD->LoadTexture("optkb", TEXTURE_16BIT_PALETTE);
-          uTextureID_Optkb_h = pIcons_LOD->LoadTexture("optkb_h", TEXTURE_16BIT_PALETTE);
-          uTextureID_KeyResume1 = pIcons_LOD->LoadTexture("resume1", TEXTURE_16BIT_PALETTE);
-          uTextureID_Optkb_1 = pIcons_LOD->LoadTexture("optkb_1", TEXTURE_16BIT_PALETTE);
-          uTextureID_Optkb_2 = pIcons_LOD->LoadTexture("optkb_2", TEXTURE_16BIT_PALETTE);
+          uTextureID_Optkb[0] = pIcons_LOD->LoadTexture("optkb", TEXTURE_16BIT_PALETTE);
+          uTextureID_Optkb[1] = pIcons_LOD->LoadTexture("optkb_h", TEXTURE_16BIT_PALETTE);
+          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->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, 1, 0, 0x71u, 0, 0, "", 0);
           pGUIWindow_CurrentMenu->CreateButton(19u, 0x12Eu, 0x6Cu, 0x14u, 1, 0, 0x1A0u, 0, 0, "", 0);
@@ -695,15 +649,12 @@
           pGUIWindow_CurrentMenu->CreateButton(350u, 262u, 70u, 0x13u, 1, 0, 0x1A3u, 0xDu, 0, "", 0);
           dword_506E68 = -1;
           KeyboardPageNum = 1;
-          memset(word_506E6C, 0, 0x1Cu);
-          word_506E6C[14] = 0;
+          memset(KeyButtonFlagChangesArray, 0, sizeof(KeyButtonFlagChangesArray));
+          //*(_WORD *)KeyButtonArray[28] = 0;
           memcpy(pPrevVirtualCidesMapping, pKeyActionMap->pVirtualKeyCodesMapping, 0x78u);
-          //goto LABEL_90;
           v1 = "";
           v0 = 1;
           continue;
-        //default:
-          //continue;
         case UIMSG_ChangeKeyButton:
           if ( dword_506E68 != -1 )
           {
@@ -741,18 +692,11 @@
             v18 = uAction++;
             v13 = uAction > 28;
             v12 = uAction - 28 < 0;
-            *((char *)word_506E6C + v18) = 0;
+            KeyButtonFlagChangesArray[v18] = 0;
           }
           while ( v12 ^ v13 );
-          v165 = 0;
-          v151 = 0;
-          v144 = 0;
-          v139 = 0;
-          v135 = -1;
-          v132 = 0;
-          v130 = 0;
-          v127 = 219;
-          goto _play_sound_and_continue;
+          pAudioPlayer->PlaySound((SoundID)219, 0, 0, -1, 0, 0, 0, 0);
+          continue;
         case UIMSG_SelectKeyPage1:
           KeyboardPageNum = v0;
           continue;
@@ -801,19 +745,7 @@
                              &pIcons_LOD->pTextures[uTextureID_507C20], 0);
               pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0xD5u, 0xA1u, 0x10u, 0x10u, 1, 0, 0x1A9u, 5u, 0, v1,
                              &pIcons_LOD->pTextures[uTextureID_507C24], 0);
-              pTexture = 0;
-              v150 = v1;
-              v143 = 0;
-              v138 = 0;
-              v134 = 425;
-              v131 = 0;
-              v129 = 1;
-              v126 = 18;
-              v124 = 170;
-              v122 = 162;
-              v120 = 42;
-//LABEL_117:
-              pGUIWindow_CurrentMenu->CreateButton(v120, v122, v124, v126, v129, v131, v134, v138, v143, v150, pTexture);
+              pGUIWindow_CurrentMenu->CreateButton(42, 162, 170, 18, 1, 0, 425, 0, 0, v1, 0);
             }
           }
           continue;
@@ -824,37 +756,14 @@
             if ( (uGammaPos -- -1) < 0 )
             {
               uGammaPos = 0;
-              //goto LABEL_128;
-              v165 = 0;
-              v151 = 0;
-              v144 = 0;
-              v139 = 0;
-              v135 = -1;
-              v132 = 0;
-              v130 = 0;
-              v127 = 21;
-              goto _play_sound_and_continue;
+              pAudioPlayer->PlaySound((SoundID)21, 0, 0, -1, 0, 0, 0, 0);
+              continue;
             }
             v19 = (double)(signed int)uGammaPos * 0.1 + 0.6;
             pGame->pGammaController->Initialize(v19);
-            v166 = v0;
-            v152 = (int)pBtn_SliderLeft;
-            pWindowType2 = (WindowType)90;
-            v140 = 0;
-            v136 = 0;
-            v20 = 21;
-            //goto LABEL_122;
-            GUIWindow::Create(v20, 0xA1u, v136, v140, pWindowType2, v152, v166);
-            //goto LABEL_128;
-            v165 = 0;
-            v151 = 0;
-            v144 = 0;
-            v139 = 0;
-            v135 = -1;
-            v132 = 0;
-            v130 = 0;
-            v127 = 21;
-            goto _play_sound_and_continue;
+            GUIWindow::Create(21, 161, 0, 0, (WindowType)90, (int)pBtn_SliderLeft, v0);
+            pAudioPlayer->PlaySound((SoundID)21, 0, 0, -1, 0, 0, 0, 0);
+            continue;
           }
           if ( uMessageParam == 5 )
           {
@@ -863,24 +772,9 @@
             {
               v21 = (double)(signed int)uGammaPos * 0.1 + 0.6;
               pGame->pGammaController->Initialize(v21);
-              v20 = 213;
-              v166 = v0;
-              v152 = (int)pBtn_SliderRight;
-              pWindowType2 = (WindowType)90;
-              v140 = 0;
-              v136 = 0;
-//LABEL_122:
-              GUIWindow::Create(v20, 0xA1u, v136, v140, pWindowType2, v152, v166);
-              //goto LABEL_128;
-              v165 = 0;
-              v151 = 0;
-              v144 = 0;
-              v139 = 0;
-              v135 = -1;
-              v132 = 0;
-              v130 = 0;
-              v127 = 21;
-              goto _play_sound_and_continue;
+              GUIWindow::Create(213, 161, 0, 0, (WindowType)90, (int)pBtn_SliderRight, v0);
+              pAudioPlayer->PlaySound((SoundID)21, 0, 0, -1, 0, 0, 0, 0);
+              continue;
             }
             uGammaPos = 9;
           }
@@ -890,16 +784,8 @@
             v22 = (double)(signed int)uGammaPos * 0.1 + 0.6;
             pGame->pGammaController->Initialize(v22);
           }
-//LABEL_128:
-          v165 = 0;
-          v151 = 0;
-          v144 = 0;
-          v139 = 0;
-          v135 = -1;
-          v132 = 0;
-          v130 = 0;
-          v127 = 21;
-          goto _play_sound_and_continue;
+          pAudioPlayer->PlaySound((SoundID)21, 0, 0, -1, 0, 0, 0, 0);
+          continue;
         case UIMSG_ToggleBloodsplats:
           pGame->ToggleFlags2(0x20u);
           continue;
@@ -915,12 +801,7 @@
             --uMusicVolimeMultiplier;
             if ( (char)uMusicVolimeMultiplier < 1 )
               uMusicVolimeMultiplier = 0;
-            v167 = v0;
-            v23 = 243;
-            v153 = (int)pBtn_SliderLeft;
-//LABEL_136:
-            GUIWindow::Create(v23, 0xD8u, 0, 0, (enum WindowType)90, v153, v167);
-            //goto LABEL_143;
+            GUIWindow::Create(243, 0xD8u, 0, 0, (enum WindowType)90, (int)pBtn_SliderLeft, v0);
             if ( uMusicVolimeMultiplier )
               pAudioPlayer->PlaySound(SOUND_Bell, -1, 0, -1, 0, 0, pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0f, 0);
             pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0f);
@@ -931,12 +812,7 @@
             ++uMusicVolimeMultiplier;
             if ( (char)uMusicVolimeMultiplier > 9 )
               uMusicVolimeMultiplier = 9;
-            v167 = v0;
-            v23 = 435;
-            v153 = (int)pBtn_SliderRight;
-            //goto LABEL_136;
-            GUIWindow::Create(v23, 0xD8u, 0, 0, (enum WindowType)90, v153, v167);
-            //goto LABEL_143;
+            GUIWindow::Create(435, 0xD8u, 0, 0, (enum WindowType)90, (int)pBtn_SliderRight, v0);
             if ( uMusicVolimeMultiplier )
               pAudioPlayer->PlaySound(SOUND_Bell, -1, 0, -1, 0, 0, pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0f, 0);
             pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0f);
@@ -945,13 +821,12 @@
           uMusicVolimeMultiplier = (pMouse->GetCursorPos(&v202)->x - 263) / 17;
           if ( (char)uMusicVolimeMultiplier > 9 )
             uMusicVolimeMultiplier = 9;
-//LABEL_143:
           if ( uMusicVolimeMultiplier )
             pAudioPlayer->PlaySound(SOUND_Bell, -1, 0, -1, 0, 0, pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f, 0);
           pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f);
           continue;
         case UIMSG_ChangeSoundVolume:
-          if ( uMessageParam == 4 )//reduce sound level
+          if ( uMessageParam == 4 )//reduce sound level button left
           {
             --uSoundVolumeMultiplier;
             if ( (char)uSoundVolumeMultiplier < 1 )
@@ -961,7 +836,7 @@
             pAudioPlayer->PlaySound((SoundID)218, -1, 0, -1, 0, 0, 0, 0);
             continue;
           }
-          if ( uMessageParam == 5 )//Increase sound level 
+          if ( uMessageParam == 5 )//Increase sound level button right
           {
             ++uSoundVolumeMultiplier;
             if ( (char)uSoundVolumeMultiplier > 8 )
@@ -969,34 +844,17 @@
             v168 = v0;
             v24 = 435;
             v154 = (int)pBtn_SliderRight;
-            //goto LABEL_150;
             GUIWindow::Create(v24, 0xA2u, 0, 0, (enum WindowType)90, v154, v168);
-            //goto LABEL_157;
             pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f);
-            v165 = 0;
-            v151 = 0;
-            v144 = 0;
-            v139 = 0;
-            v135 = -1;
-            v132 = 0;
-            v130 = -1;
-            v127 = 218;
-            goto _play_sound_and_continue;
+            pAudioPlayer->PlaySound((SoundID)218, -1, 0, -1, 0, 0, 0, 0);
+            continue;
           }
           uSoundVolumeMultiplier = (pMouse->GetCursorPos(&v207)->x - 263) / 17;
           if ( (char)uSoundVolumeMultiplier > 8 )
             uSoundVolumeMultiplier = 9;
-//LABEL_157:
           pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f);
-          v165 = 0;
-          v151 = 0;
-          v144 = 0;
-          v139 = 0;
-          v135 = -1;
-          v132 = 0;
-          v130 = -1;
-          v127 = 218;
-          goto _play_sound_and_continue;
+          pAudioPlayer->PlaySound((SoundID)218, -1, 0, -1, 0, 0, 0, 0);
+          continue;
         case UIMSG_ToggleFlipOnExit:
           bFlipOnExit = bFlipOnExit == 0;
           continue;
@@ -1015,62 +873,30 @@
             --uVoicesVolumeMultiplier;
             if ( (char)uVoicesVolumeMultiplier < 1 )
               uVoicesVolumeMultiplier = 0;
-            v169 = v0;
-            v25 = 243;
-            v155 = (int)pBtn_SliderLeft;
-//LABEL_166:
-            GUIWindow::Create(v25, 0x10Eu, 0, 0, (enum WindowType)90, v155, v169);
-            //goto LABEL_173;
+            GUIWindow::Create(243, 270, 0, 0, (enum WindowType)90, (int)pBtn_SliderLeft, v0);
             if ( !uVoicesVolumeMultiplier )
               continue;
-            v165 = 0;
-            v151 = pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f;
-            v144 = 0;
-            v139 = 0;
-            v135 = -1;
-            v132 = 0;
-            v130 = -1;
-            v127 = 5788;
-            goto _play_sound_and_continue;
+            pAudioPlayer->PlaySound((SoundID)5788, -1, 0, -1, 0, 0, pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f, 0);
+            continue;
           }
           if ( uMessageParam == 5 )
           {
             ++uVoicesVolumeMultiplier;
             if ( (char)uVoicesVolumeMultiplier > 8 )
               uVoicesVolumeMultiplier = 9;
-            v169 = v0;
-            v25 = 435;
-            v155 = (int)pBtn_SliderRight;
-            //goto LABEL_166;
-            GUIWindow::Create(v25, 0x10Eu, 0, 0, (enum WindowType)90, v155, v169);
-            //goto LABEL_173;
+            GUIWindow::Create(435, 270, 0, 0, (enum WindowType)90, (int)pBtn_SliderRight, v0);
             if ( !uVoicesVolumeMultiplier )
               continue;
-            v165 = 0;
-            v151 = pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f;
-            v144 = 0;
-            v139 = 0;
-            v135 = -1;
-            v132 = 0;
-            v130 = -1;
-            v127 = 5788;
-            goto _play_sound_and_continue;
+            pAudioPlayer->PlaySound((SoundID)5788, -1, 0, -1, 0, 0, pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f, 0);
+            continue;
           }
           uVoicesVolumeMultiplier = (pMouse->GetCursorPos(&v205)->x - 263) / 17;
           if ( (char)uVoicesVolumeMultiplier > 8 )
             uVoicesVolumeMultiplier = 9;
-//LABEL_173:
           if ( !uVoicesVolumeMultiplier )
             continue;
-          v165 = 0;
-          v151 = pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f;
-          v144 = 0;
-          v139 = 0;
-          v135 = -1;
-          v132 = 0;
-          v130 = -1;
-          v127 = 5788;
-          goto _play_sound_and_continue;
+            pAudioPlayer->PlaySound((SoundID)5788, -1, 0, -1, 0, 0, pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f, 0);
+            continue;
         case UIMSG_SetTurnSpeed:
           if ( uMessageParam )
             pParty->sRotationY = uMessageParam * pParty->sRotationY / uMessageParam;
@@ -1080,7 +906,6 @@
           if ( !bUseLoResSprites )
           {
             byte_6BE388_graphicsmode = uMessageParam;
-//LABEL_184:
             MM7Initialization();
             continue;
           }
@@ -1096,16 +921,18 @@
                 continue;
               byte_6BE388_graphicsmode = 1;
             }
-            //goto LABEL_184;
             MM7Initialization();
             continue;
           }
           ModalWindow(pNPCTopics[453].pText, 0);
           continue;
-        case UIMSG_7B:
+        case UIMSG_GameMenu_ReturnToGame:
           pGUIWindow_CurrentMenu->Release();
           pEventTimer->Resume();
-          goto LABEL_188;
+          pCurrentScreen = SCREEN_GAME;
+          viewparams->bRedrawGameUI = v0;
+          stru_506E40.Release();
+          continue;
         case UIMSG_OpenQuestBook:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -1137,14 +964,8 @@
           viewparams->sPartyPosX = pParty->vPosition.x;
           viewparams->sPartyPosZ = pParty->vPosition.y;
           pAudioPlayer->StopChannels(-1, -1);
-          pWindow = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
-          v27 = 353;
-          v28 = 546;
-          v170 = 0;
-          v156 = (int)pBtn_Maps;
-          //goto LABEL_210;
-          pGUIWindow_CurrentMenu = pWindow;
-          pBooksWindow = GUIWindow::Create(v28, v27, 0, 0, (enum WindowType)99, v156, v170);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Book, uMessage, 0);
+          pBooksWindow = GUIWindow::Create(546, 353, 0, 0, (enum WindowType)99, (int)pBtn_Maps, 0);
           continue;
         case UIMSG_OpenCalendar:
           if ( pMessageQueue_50CBD0->uNumMessages )
@@ -1153,14 +974,8 @@
             pGUIWindow_CurrentMenu->Release();
           pEventTimer->Pause();
           pAudioPlayer->StopChannels(-1, -1);
-          pWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Book, uMessage, 0);
-          v27 = 354;
-          v28 = 570;
-          v170 = 0;
-          v156 = (int)pBtn_Calendar;
-//LABEL_210:
-          pGUIWindow_CurrentMenu = pWindow;
-          pBooksWindow = GUIWindow::Create(v28, v27, 0, 0, (enum WindowType)99, v156, v170);
+          pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Book, uMessage, 0);
+          pBooksWindow = GUIWindow::Create(570, 354, 0, 0, (enum WindowType)99, (int)pBtn_Calendar, 0);
           continue;
         case UIMSG_OpenHistoryBook:
           if ( pMessageQueue_50CBD0->uNumMessages )
@@ -1173,7 +988,7 @@
           pBooksWindow = GUIWindow::Create(0x258u, 0x169u, 0, 0, (enum WindowType)99, (int)pBtn_History, 0);
           bFlashHistoryBook = 0;
           continue;
-        case UIMSG_Escape:// нажатие Escape
+        case UIMSG_Escape:// нажатие Escape and return to game
           back_to_game();
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -1181,11 +996,9 @@
           {
             if ( pCurrentScreen >= SCREEN_CHANGE_LOCATION && (pCurrentScreen <= SCREEN_INPUT_BLV || pCurrentScreen == SCREEN_QUICK_REFERENCE) )
             {
-//LABEL_229:
               if ( dword_50CDC8 )
                 goto LABEL_232;
               CloseWindowBackground();
-              //goto LABEL_231;
               uMessageParam = v0;
               goto LABEL_232;
             }
@@ -1193,22 +1006,18 @@
           else
           {
             if ( pCurrentScreen >= SCREEN_E || pCurrentScreen == SCREEN_NPC_DIALOGUE || pCurrentScreen == SCREEN_CHEST )
-			{
-              //goto LABEL_229;
+            {
               if ( dword_50CDC8 )
                 goto LABEL_232;
               CloseWindowBackground();
-              //goto LABEL_231;
               uMessageParam = v0;
               goto LABEL_232;
-			}
+            }
             if ( pCurrentScreen == SCREEN_HOUSE && !dword_50CDC8 && !dword_5C35C8 )
             {
               CloseWindowBackground();
               dword_5C35C8 = 0;
-//LABEL_231:
               uMessageParam = v0;
-              goto LABEL_232;
             }
           }
 LABEL_232:
@@ -1249,7 +1058,6 @@
                         dword_50C9A8 = 0;
                         ptr_50C9A4 = 0;
                       }
-                      //goto LABEL_322;
                       if ( pGUIWindow_Settings )
                       {
                        if ( pCurrentScreen == SCREEN_CHARACTERS )
@@ -1282,7 +1090,6 @@
                       //crt_deconstruct_ptr_6A0118();
                       pBooksWindow = 0;
                       pEventTimer->Resume();
-                      //goto LABEL_322;
                       if ( pGUIWindow_Settings )
                       {
                         if ( pCurrentScreen == SCREEN_CHARACTERS )
@@ -1314,7 +1121,6 @@
                     case SCREEN_LOADGAME:
                       pIcons_LOD->_4114F2();
                       //crt_deconstruct_ptr_6A0118();
-                      //goto LABEL_291;
                       stru_506E40.Release();
                       break;
                     case SCREEN_F:
@@ -1322,7 +1128,6 @@
                       continue;
                     case SCREEN_CHEST:
                       pWindow2 = pChestWindow;
-                      //goto LABEL_249;
                       pWindow2->Release();
                       pIcons_LOD->_4114F2();
                       pCurrentScreen = SCREEN_GAME;
@@ -1331,14 +1136,13 @@
                       continue;
                     case SCREEN_19:
                       pWindow2 = ptr_507BC8;
-//LABEL_249:
                       pWindow2->Release();
                       pIcons_LOD->_4114F2();
                       pCurrentScreen = SCREEN_GAME;
                       viewparams->bRedrawGameUI = v0;
                       pEventTimer->Resume();
                       continue;
-                    case SCREEN_OPTIONS:
+                    case SCREEN_OPTIONS://Close
                       thisa = (signed int)&uTextureID_ControlBG;
                       do
                       {
@@ -1360,9 +1164,7 @@
                       if ( !uTurnSpeed )
                       {
                         v171 = 3;
-                        //goto LABEL_261;
                         v30 = v171;
-                        //goto LABEL_262;
                         v31 = "TurnDelta";
                         WriteWindowsRegistryInt(v31, v30);
                         stru_506E40.Release();
@@ -1371,26 +1173,20 @@
                       if ( uTurnSpeed == 64 )
                       {
                         v171 = 2;
-//LABEL_261:
                         v30 = v171;
-                        //goto LABEL_262;
                         v31 = "TurnDelta";
                         WriteWindowsRegistryInt(v31, v30);
                         stru_506E40.Release();
                         break;
                       }
                       if ( uTurnSpeed != 128 )
-                        //goto LABEL_291;
                         {
                           stru_506E40.Release();
                           break;
                         }
                       v30 = v0;
-//LABEL_262:
                       v31 = "TurnDelta";
-//LABEL_263:
                       WriteWindowsRegistryInt(v31, v30);
-//LABEL_291:
                       stru_506E40.Release();
                       break;
                     case SCREEN_MENU:
@@ -1398,7 +1194,6 @@
                       pIcons_LOD->_4114F2();
                       pIcons_LOD->_40F9C5();
                       pIcons_LOD->_4114F2();
-                      //goto LABEL_291;
                       stru_506E40.Release();
                       break;
                     case SCREEN_VIDEO_OPTIONS:
@@ -1409,21 +1204,19 @@
                         WriteWindowsRegistryInt("Bloodsplats", (LOBYTE(pGame->uFlags2) >> 5) & 1);
                       }
                       if ( pRenderer->bWindowMode )
-                        //goto LABEL_291;
                         {
                           stru_506E40.Release();
                           break;
                         }
                       v30 = uGammaPos;
                       v31 = "GammaPos";
-                      //goto LABEL_263;
                       WriteWindowsRegistryInt(v31, v30);
                       stru_506E40.Release();
                       break;
-                    case SCREEN_KEYBOARD_OPTIONS:
+                    case SCREEN_KEYBOARD_OPTIONS://Return to game
                       v197 = 1;
                       v32 = 0;
-                      while ( *((char *)word_506E6C + v32) != 1 )
+                      while ( KeyButtonFlagChangesArray[v32] != 1 )
                       {
                         ++v32;
                         if ( v32 >= 28 )
@@ -1465,13 +1258,11 @@
                           }
                           while ( uAction < 28 );
                           pKeyActionMap->StoreMappings();
-                          //goto LABEL_291;
                           stru_506E40.Release();
                           break;
                         }
                       }
-                      pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
-                      continue;
+                      break;
                     case SCREEN_REST:
                       if ( dword_506F14 )
                       {
@@ -1490,7 +1281,6 @@
                       _506F18_num_hours_to_sleep = 0;
                       dword_506F14 = 0;
                       dword_507B94 = v0;
-                      //goto LABEL_322;
                       if ( pGUIWindow_Settings )
                       {
                         if ( pCurrentScreen == SCREEN_CHARACTERS )
@@ -1540,7 +1330,6 @@
                       pAudioPlayer->PlaySound((SoundID)(SOUND_EnteringAHouse|0x1), 814, 0, -1, 0, 0, 0, 0);
                       pVideoPlayer->Unload();
                       pGUIWindow_CurrentMenu = window_SpeakInHouse;
-                      //goto LABEL_322;
                       if ( pGUIWindow_Settings )
                       {
                         if ( pCurrentScreen == SCREEN_CHARACTERS )
@@ -1572,7 +1361,6 @@
                       if ( uCurrentHouse_Animation == 153 )
                         HousePlaySomeSound(0x99u, 3);
                       pVideoPlayer->Unload();
-                      //goto LABEL_306;
                       if ( dword_5B65CC )
                       {
                         pParty->field_709 = 0;
@@ -1583,7 +1371,6 @@
                       }
                       goto LABEL_317;
                     case SCREEN_NPC_DIALOGUE:
-//LABEL_306:
                       if ( dword_5B65CC )
                       {
                         pParty->field_709 = 0;
@@ -1613,7 +1400,6 @@
                     case SCREEN_CHARACTERS:
                       goto LABEL_319;
                     default:
-                      //goto LABEL_322;
                       if ( pGUIWindow_Settings )
                       {
                         if ( pCurrentScreen == SCREEN_CHARACTERS )
@@ -1642,7 +1428,6 @@
                       pIcons_LOD->_4355F7();
                       continue;
                   }
-                  //goto LABEL_322;
                   if ( pGUIWindow_Settings )
                   {
                     if ( pCurrentScreen == SCREEN_CHARACTERS )
@@ -1677,7 +1462,6 @@
 LABEL_321:
                 pIcons_LOD->_4114F2();
               }
-//LABEL_322:
               if ( pGUIWindow_Settings )
               {
                 if ( pCurrentScreen == SCREEN_CHARACTERS )
@@ -1752,7 +1536,6 @@
               stru_506E40._40E55E("gamma.pcx", 0);
               continue;
             }
-            //goto LABEL_333;
             pWindow3->Release();
             pGUIWindow_Settings = 0;
             pMouse->SetCursorBitmap("MICON1");
@@ -2970,7 +2753,7 @@
 //_set_status_string_pTmpBuf_and_continue:
           sub_41C0B8_set_status_string(pTmpBuf);
           continue;
-        case UIMSG_4F:
+        case UIMSG_SPellbook_ShowHightlightedSpellInfo:
           if ( !uActiveCharacter || (uNumSeconds = (unsigned int)pPlayers[uActiveCharacter],
                 !*(char *)(uNumSeconds + 11 * *(char *)(uNumSeconds + 6734) + uMessageParam + 402)) )
             continue;
@@ -3124,17 +2907,12 @@
             }
           }
           continue;
-        case UIMSG_8E:
-          if ( pTurnEngine->field_4 == 3 )
-            continue;
-          v175 = 0;
-          v159 = 0;
-          v147 = 0;
-          //goto LABEL_678;
-          v80 = v199;
-          v79 = uMessageParam;
-          _42777D_CastSpell_UseWand_ShootArrow(v79, v80, v147, v159, v175);
-          continue;
+
+        case UIMSG_CastSpellFromBook:
+          if ( pTurnEngine->field_4 != 3 )
+            _42777D_CastSpell_UseWand_ShootArrow(uMessageParam, v199, 0, 0, 0);
+        continue;
+
         case UIMSG_92:
           if ( pTurnEngine->field_4 != 3 )
           {
@@ -6495,8 +6273,8 @@
   char pContainer[128]; // [sp+24h] [bp-14h]@12
 
   uTextureID_MAGNIF_B = pIcons_LOD->LoadTexture("MAGNIF-B", TEXTURE_16BIT_PALETTE);
-  if ( !pParty->uAlignment || pParty->uAlignment == 1 || pParty->uAlignment == 2 )
-    uTextureID_BACKDOLL = pIcons_LOD->LoadTexture("BACKDOLL", TEXTURE_16BIT_PALETTE);
+  //if ( !pParty->uAlignment || pParty->uAlignment == 1 || pParty->uAlignment == 2 )
+  uTextureID_BACKDOLL = pIcons_LOD->LoadTexture("BACKDOLL", TEXTURE_16BIT_PALETTE);
   uTextureID_507B04 = uTextureID_right_panel;
   v30 = 0;
   uTextureID_BACKHAND = pIcons_LOD->LoadTexture("BACKHAND", TEXTURE_16BIT_PALETTE);
@@ -14800,7 +14578,7 @@
   if ( pGUIWindow_CurrentMenu->field_40 == 2 )
   {
     pPrevVirtualCidesMapping[dword_506E68] = pKeyActionMap->pPressedKeysBuffer[0];
-    memset(word_506E6C, 0, 0x1Cu);
+    memset(&KeyButtonFlagChangesArray, 0, sizeof(KeyButtonFlagChangesArray));
     v4 = 0;
     do
     {
@@ -14809,8 +14587,8 @@
       {
         if ( v4 != v5 && pPrevVirtualCidesMapping[v4] == pPrevVirtualCidesMapping[v5] )
         {
-          *((char *)word_506E6C + v4) = 1;
-          *((char *)word_506E6C + v5) = 1;
+          KeyButtonFlagChangesArray[v4] = 1;
+          KeyButtonFlagChangesArray[v5] = 1;
         }
         ++v5;
       }
@@ -14821,10 +14599,10 @@
     dword_506E68 = -1;
     v3->field_40 = 0;
   }
-  pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_Optkb != -1 ? &pIcons_LOD->pTextures[uTextureID_Optkb] : 0));
+  pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_Optkb[0] != -1 ? &pIcons_LOD->pTextures[uTextureID_Optkb[0]] : 0));
   if ( KeyboardPageNum == 1 )
   {
-    pRenderer->DrawTextureIndexed(0x13, 0x12E, (Texture *)(uTextureID_Optkb_1 != -1 ? &pIcons_LOD->pTextures[uTextureID_Optkb_1] : 0));
+    pRenderer->DrawTextureIndexed(0x13, 0x12E, (Texture *)(uTextureID_Optkb[3] != -1 ? &pIcons_LOD->pTextures[uTextureID_Optkb[3]] : 0));
     pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 142, v0, ascii_4E2D5C, 0, 0, 0);
     v6 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[0]);
     v7 = sub_414D24(0);
@@ -14887,7 +14665,7 @@
   }
   else
   {
-    pRenderer->DrawTextureIndexed(0x7F, 0x12E, (Texture *)(uTextureID_Optkb_2 != -1 ? &pIcons_LOD->pTextures[uTextureID_Optkb_2] : 0));
+    pRenderer->DrawTextureIndexed(0x7F, 0x12E, (Texture *)(uTextureID_Optkb[4] != -1 ? &pIcons_LOD->pTextures[uTextureID_Optkb[4]] : 0));
     pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 142, v0, ascii_4E2CDC, 0, 0, 0);
     v33 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[14]);
     v34 = sub_414D24(14);
@@ -14974,7 +14752,7 @@
   }
   else
   {
-    if ( *((char *)word_506E6C + v1) )
+    if ( KeyButtonFlagChangesArray[v1] )
       result = dword_507C08;
   }
   return result;
@@ -15051,7 +14829,7 @@
   signed int v0; // eax@1
 
   pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_Options != -1 ? &pIcons_LOD->pTextures[uTextureID_Options] : 0));
-  pRenderer->DrawTextureIndexed(8, 132, (Texture *)(uTextureID_ControlBG != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG] : 0));
+  pRenderer->DrawTextureIndexed(8, 132, (Texture *)(uTextureID_ControlBG[0] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[0]] : 0));
   v0 = 0;
   if ( uTurnSpeed == 128 )
   {
@@ -15062,21 +14840,21 @@
     if ( uTurnSpeed == 64 )
       v0 = 1;
   }
-  pRenderer->DrawTextureIndexed(BtnTurnCoord[v0], 270, (Texture *)(uTextureID_Con_Smoo[v0] != -1 ? &pIcons_LOD->pTextures[uTextureID_Con_Smoo[v0]] : 0));
+  pRenderer->DrawTextureIndexed(BtnTurnCoord[v0], 270, (Texture *)(uTextureID_ControlBG[v0 + 1] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[v0 + 1]] : 0));
   if ( bWalkSound )
-    pRenderer->DrawTextureIndexed(20, 303, (Texture *)(uTextureID_Option01 != -1 ? &pIcons_LOD->pTextures[uTextureID_Option01] : 0));
+    pRenderer->DrawTextureIndexed(20, 303, (Texture *)(uTextureID_ControlBG[21] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[21]] : 0));
   if ( bShowDamage )
-    pRenderer->DrawTextureIndexed(128, 303, (Texture *)(uTextureID_Option02 != -1 ? &pIcons_LOD->pTextures[uTextureID_Option02] : 0));
+    pRenderer->DrawTextureIndexed(128, 303, (Texture *)(uTextureID_ControlBG[22] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[22]] : 0));
   if ( bFlipOnExit )
-    pRenderer->DrawTextureIndexed(128, 325, (Texture *)(uTextureID_Option04 != -1 ? &pIcons_LOD->pTextures[uTextureID_Option04] : 0));
+    pRenderer->DrawTextureIndexed(128, 325, (Texture *)(uTextureID_ControlBG[9] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[9]] : 0));
   if ( bAlwaysRun )
-    pRenderer->DrawTextureIndexed(20, 325, (Texture *)(uTextureID_Option03 != -1 ? &pIcons_LOD->pTextures[uTextureID_Option03] : 0));
+    pRenderer->DrawTextureIndexed(20, 325, (Texture *)(uTextureID_ControlBG[20] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[20]] : 0));
   pRenderer->DrawTextureIndexed(17 * (char)uSoundVolumeMultiplier + 265, 162,
-    (Texture *)(pTextureIDs_SoundLevels[(char)uSoundVolumeMultiplier] != -1 ? &pIcons_LOD->pTextures[pTextureIDs_SoundLevels[(char)uSoundVolumeMultiplier]] : 0));
+    (Texture *)(uTextureID_ControlBG[(char)uSoundVolumeMultiplier + 10] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[(char)uSoundVolumeMultiplier + 10]] : 0));
   pRenderer->DrawTextureIndexed(17 * (char)uMusicVolimeMultiplier + 265, 216,
-    (Texture *)(pTextureIDs_SoundLevels[(char)uMusicVolimeMultiplier] != -1 ? &pIcons_LOD->pTextures[pTextureIDs_SoundLevels[(char)uMusicVolimeMultiplier]] : 0));
+    (Texture *)(uTextureID_ControlBG[(char)uMusicVolimeMultiplier + 10] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[(char)uMusicVolimeMultiplier + 10]] : 0));
   pRenderer->DrawTextureIndexed(17 * (char)uVoicesVolumeMultiplier + 265, 270,
-    (Texture *)(pTextureIDs_SoundLevels[(char)uVoicesVolumeMultiplier] != -1 ? &pIcons_LOD->pTextures[pTextureIDs_SoundLevels[(char)uVoicesVolumeMultiplier]] : 0));
+    (Texture *)(uTextureID_ControlBG[(char)uVoicesVolumeMultiplier + 10] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[(char)uVoicesVolumeMultiplier + 10]] : 0));
 }
 
 
--- a/mm7_6.cpp	Fri Feb 22 08:23:15 2013 +0400
+++ b/mm7_6.cpp	Fri Feb 22 20:03:15 2013 +0400
@@ -42,6 +42,7 @@
 #include "texts.h"
 #include "StorylineTextTable.h"
 #include "Events2D.h"
+#include "Log.h"
 
 #include "mm7_data.h"
 
@@ -2172,7 +2173,7 @@
 //----- (0042777D) --------------------------------------------------------
 void _42777D_CastSpell_UseWand_ShootArrow(int a1, unsigned int uPlayerID, unsigned int a4, __int16 a5, int a6)
 {
-  bool result; // eax@2
+  //bool result; // eax@2
   __int16 v6; // bx@4
   Player *v7; // eax@4
   char v8; // zf@12
@@ -2202,9 +2203,16 @@
 
   a3a = uPlayerID;
   a2a = a1;
-  if ( pParty->bTurnBasedModeOn != 1
-    || (result = pTurnEngine->field_4, pTurnEngine->field_4 != 1) && pTurnEngine->field_4 != 3 )
+  
+  //if ( pParty->bTurnBasedModeOn != 1
+  //  || (result = pTurnEngine->field_4, pTurnEngine->field_4 != 1) && pTurnEngine->field_4 != 3 )
+  if (pParty->bTurnBasedModeOn)
   {
+    if (pTurnEngine->field_4 == 1 || pTurnEngine->field_4 == 3)
+      return;
+  }
+
+
     v6 = a5;
     v7 = &pParty->pPlayers[uPlayerID];
     if ( !(a5 & 0x10) )
@@ -2317,6 +2325,7 @@
           break;
       }
     }
+
     v15 = pStru277;
     if ( v6 & 0x3CA )
     {
@@ -2349,7 +2358,7 @@
       ++v15;
     }
     while ( (signed int)v15 < (signed int)&unk_50C190 );
-    result = pStru277->PushStru277(a2a, a3a, a4, v6, a6);
+    int result = pStru277->PushStru277(a2a, a3a, a4, v6, a6);
     if ( result != -1 )
     {
       if ( v6 & 2 )
@@ -2469,7 +2478,6 @@
         pGUIWindow_Settings->CreateButton(0x231u, 0x95u, 0x40u, 0x4Au, 1, 0, 0x8Fu, 5u, 0x36u, "", 0);
       }
     }
-  }
 }
 
 
--- a/mm7_data.cpp	Fri Feb 22 08:23:15 2013 +0400
+++ b/mm7_data.cpp	Fri Feb 22 20:03:15 2013 +0400
@@ -1779,7 +1779,7 @@
 int dword_506988; // weak
 int dword_50698C; // weak
 int dword_506E68; // weak
-__int16 word_506E6C[18]; // weak
+char KeyButtonFlagChangesArray[28]; // weak
 unsigned int pPrevVirtualCidesMapping[27];
 int KeyboardPageNum; // weak
 int dword_506F0C[777]; // idb
--- a/mm7_data.h	Fri Feb 22 08:23:15 2013 +0400
+++ b/mm7_data.h	Fri Feb 22 20:03:15 2013 +0400
@@ -1182,7 +1182,7 @@
 extern int dword_506988; // weak
 extern int dword_50698C; // weak
 extern int dword_506E68; // weak
-extern __int16 word_506E6C[18]; // weak
+extern char KeyButtonFlagChangesArray[28]; // weak
 extern unsigned int pPrevVirtualCidesMapping[27];
 extern int KeyboardPageNum; // weak
 extern int dword_506F0C[]; // idb
@@ -1915,7 +1915,7 @@
 void __cdecl sub_421EA6_OnInventoryLeftClick();
 void __cdecl OnGameViewportClick();
 bool PauseGameDrawing();
-void __fastcall SetUserInterface(int a1, bool bReplace);
+void SetUserInterface(enum PartyAlignment alignment, bool bReplace);
 void __cdecl reset_some_strus_flt_2Cs();
 void __cdecl j_sub_423B4A();
 void __cdecl sub_423B4A();