diff mm7_2.cpp @ 3:540178ef9b18

Main menu functionality
author Nomad
date Wed, 10 Oct 2012 19:10:15 +0200
parents 2ca04ccb612a
children 4acbadf78023
line wrap: on
line diff
--- a/mm7_2.cpp	Wed Oct 10 14:21:15 2012 +0200
+++ b/mm7_2.cpp	Wed Oct 10 19:10:15 2012 +0200
@@ -5256,8 +5256,7 @@
   bGameoverLoop = 0;
   return result;
 }
-// 6BE364: using guessed type int dword_6BE364_game_settings_1;
-// F8BC10: using guessed type int bGameoverLoop;
+
 
 //----- (004C0262) --------------------------------------------------------
 void Viewport::SetScreen(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW)
@@ -6456,14 +6455,14 @@
           while ( 1 )
           {
             a6s = (double)a6a / v221 * v212;
-            v151 = floorf(a6s);//a6s + 6.7553994e15;
+            v151 = floorf(a6s + 0.5f);//a6s + 6.7553994e15;
             v203 = v14 + 1;
             a6t = (double)(v14 + 1) / v221 * v212;
-            v142 = floorf(a6t);//a6t + 6.7553994e15;
+            v142 = floorf(a6t + 0.5f);//a6t + 6.7553994e15;
             v17 = (double)v231 / v15 * v16;
-            v133 = floorf(v17);//v17 + 6.7553994e15;
+            v133 = floorf(v17 + 0.5f);//v17 + 6.7553994e15;
             v18 = (double)(v231 + 1) / v15 * v16;
-            v124 = floorf(v18);//v18 + 6.7553994e15;
+            v124 = floorf(v18 + 0.5f);//v18 + 6.7553994e15;
             v19 = (LODWORD(v124) - LODWORD(v133)) * (LODWORD(v142) - LODWORD(v151));
             v252 = 0;
             a6b = 0;
@@ -6865,18 +6864,18 @@
       while ( 1 )
       {
         a6ba = (double)a6i / v225 * v216;
-        _v128 = floorf(a6ba);
+        _v128 = floorf(a6ba + 0.5f);
         //v128 = a6ba + 6.7553994e15;
         v207 = v62 + 1;
         a6bb = (double)(v62 + 1) / v225 * v216;
         //v137 = a6bb + 6.7553994e15;
-        _v137 = floorf(a6bb);
+        _v137 = floorf(a6bb + 0.5f);
         v65 = (double)v235 / v63 * v64;
         //v146 = v65 + 6.7553994e15;
-        _v146 = floorf(v65);
+        _v146 = floorf(v65 + 0.5f);
         v66 = (double)(v235 + 1) / v63 * v64;
         //v155 = v66 + 6.7553994e15;
-        _v155 = floorf(v66);
+        _v155 = floorf(v66 + 0.5f);
         //v67 = (LODWORD(v155) - LODWORD(v146)) * (LODWORD(v137) - LODWORD(v128));
         v67 = (_v155 - _v146) * (_v137 - _v128);
         v256 = 0;
@@ -11436,369 +11435,8 @@
 }
 
 
-//----- (0045E361) --------------------------------------------------------
-void __fastcall GameUI_DrawLoadMenu(unsigned int uDialogueType)
-{
-  unsigned int v1; // ebp@5
-  unsigned int v2; // eax@5
-  signed int v3; // ebp@11
-  FILE *v4; // eax@14
-  FILE *v5; // eax@18
-  unsigned int v6; // eax@25
-  GUIButton *v7; // eax@27
-  const char *v8; // [sp-8h] [bp-26Ch]@25
-  char *v9; // [sp-4h] [bp-268h]@19
-  enum TEXTURE_TYPE v10; // [sp-4h] [bp-268h]@25
-  unsigned int uDialogueType_; // [sp+10h] [bp-254h]@1
-  RGBTexture *pTex; // [sp+10h] [bp-254h]@12
-  SavegameHeader *Dest; // [sp+14h] [bp-250h]@12
-  const char *Str1; // [sp+18h] [bp-24Ch]@12
-  LODWriteableFile v15; // [sp+1Ch] [bp-248h]@1
-  int v16; // [sp+260h] [bp-4h]@1
-
-  uDialogueType_ = uDialogueType;
-  dword_6BE138 = -1;
-  ++pIcons_LOD->uTexturePacksCount;
-  v16 = 0;
-  if ( !pIcons_LOD->uNumPrevLoadedFiles )
-    pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
-  memset(pSavegameUsedSlots, 0, 0xB4u);
-  memset(&pSavegameThumbnails, 0, 0x708u);
-  uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE);
-  uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE);
-  uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE);
-  uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE);
-  uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE);
-  uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE);
-  if ( uDialogueType_ )
-  {
-    pRenderer->DrawTextureIndexed(
-      8u,
-      8u,
-      (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
-    if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 11 )
-    {
-      v1 = uTextureID_save_up;
-      v2 = uTextureID_LS_saveU;
-    }
-    else
-    {
-      v1 = uTextureID_load_up;
-      v2 = uTextureID_LS_loadU;
-    }
-    pRenderer->DrawTextureIndexed(241u, 302u, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0));
-    pRenderer->DrawTextureIndexed(18u, 141u, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0));
-    pRenderer->DrawTextureIndexed(
-      351u,
-      302u,
-      (Texture *)(uTextureID_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_u] : 0));
-  }
-  else
-  {
-    pRenderer->DrawTextureRGB(0, 0, &stru_506F20);
-  }
-  pGUIWindow_CurrentMenu = GUIWindow::Create(
-                             saveload_dlg_xs[uDialogueType_],
-                             saveload_dlg_ys[uDialogueType_],
-                             saveload_dlg_zs[uDialogueType_],
-                             saveload_dlg_ws[uDialogueType_],
-                             (enum WindowType)24,
-                             0,
-                             0);
-  pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);// "Reading..."
-  pRenderer->Present();
-  pSavegameList->Initialize(0);
-  if ( dword_6A0C9C > (signed int)uNumSavegameFiles )
-  {
-    dword_6A0C9C = 0;
-    uLoadGameUI_SelectedSlot = 0;
-  }
-  v15.AllocSubIndicesAndIO(0x12Cu, 0);
-  v3 = 0;
-  if ( (signed int)uNumSavegameFiles > 0 )
-  {
-    Dest = pSavegameHeader;
-    pTex = pSavegameThumbnails;
-    Str1 = (const char *)pSavegameList->pSavesNames;
-    while ( 1 )
-    {
-      sprintfex(pTmpBuf, "saves\\%s", Str1);
-      if ( _access(pTmpBuf, 6) )
-        break;
-      v15.LoadFile(pTmpBuf, 1);
-      v4 = v15.FindContainer("header.bin", 1);
-      if ( v4 )
-        fread(Dest, 0x64u, 1u, v4);
-      if ( !_strcmpi(Str1, pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7"
-        strcpy(Dest->pName, pGlobalTXT_LocalizationStrings[16]);// "Autosave"
-      v5 = v15.FindContainer("image.pcx", 1);
-      if ( !v5 )
-      {
-        v9 = nullstring;
-LABEL_22:
-        pSavegameUsedSlots[v3] = 0;
-        strcpy(Dest->pName, v9);
-        goto LABEL_23;
-      }
-      pTex->LoadFromFILE(v5, 0, 1u);
-      v15.CloseWriteFile();
-      pSavegameUsedSlots[v3] = 1;
-LABEL_23:
-      Str1 += 280;
-      ++pTex;
-      ++Dest;
-      ++v3;
-      if ( v3 >= (signed int)uNumSavegameFiles )
-        goto LABEL_24;
-    }
-    v9 = pGlobalTXT_LocalizationStrings[72];    // "Empty"
-    goto LABEL_22;
-  }
-LABEL_24:
-  v15.FreeSubIndexAndIO();
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 11 )
-  {
-    v6 = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
-    v10 = (TEXTURE_TYPE)2;
-    v8 = "LS_saveD";
-  }
-  else
-  {
-    v6 = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
-    v10 = (TEXTURE_TYPE)2;
-    v8 = "LS_loadD";
-  }
-  uTextureID_x_d = v6;
-  uTextureID_LS_ = pIcons_LOD->LoadTexture(v8, v10);
-  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->CreateButton(21u, 198u, 191u, 18u, 1, 0, 0xA5u, 0, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 219u, 191u, 18u, 1, 0, 0xA5u, 1u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 240u, 191u, 18u, 1, 0, 0xA5u, 2u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 261u, 191u, 18u, 1, 0, 0xA5u, 3u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 282u, 191u, 18u, 1, 0, 0xA5u, 4u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 303u, 191u, 18u, 1, 0, 0xA5u, 5u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 324u, 191u, 18u, 1, 0, 0xA5u, 6u, 0, nullstring, 0);
-  ptr_69BD64 = pGUIWindow_CurrentMenu->CreateButton(
-                 241u,
-                 302u,
-                 105u,
-                 40u,
-                 1,
-                 0,
-                 0xA4u,
-                 0,
-                 0,
-                 nullstring,
-                 (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0),
-                 0);
-  ptr_69BD60 = pGUIWindow_CurrentMenu->CreateButton(
-                 350u,
-                 302u,
-                 105u,
-                 40u,
-                 1,
-                 0,
-                 0xA6u,
-                 0,
-                 0,
-                 nullstring,
-                 (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0),
-                 0);
-  ptr_69BD5C = pGUIWindow_CurrentMenu->CreateButton(
-                 215u,
-                 199u,
-                 17u,
-                 17u,
-                 1,
-                 0,
-                 0xA2u,
-                 0,
-                 0,
-                 nullstring,
-                 (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0),
-                 0);
-  v7 = pGUIWindow_CurrentMenu->CreateButton(
-         215u,
-         0x143u,
-         0x11u,
-         0x11u,
-         1,
-         0,
-         0xA3u,
-         uNumSavegameFiles,
-         0,
-         nullstring,
-         (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0),
-         0);
-  v16 = -1;
-  ptr_69BD58 = v7;
-}
-// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
-// 6A0C9C: using guessed type int dword_6A0C9C;
-// 6BE138: using guessed type int dword_6BE138;
-
-//----- (0045E93E) --------------------------------------------------------
-void __cdecl GameUI_DrawSaveMenu()
-{
-  unsigned int v0; // ebp@4
-  unsigned int v1; // eax@4
-  unsigned int *v2; // ebp@6
-  char *v3; // eax@7
-  FILE *v4; // eax@11
-  FILE *v5; // eax@11
-  const char *v6; // ST64_4@14
-  GUIButton *v7; // eax@16
-  char *v8; // [sp+10h] [bp-254h]@6
-  SavegameHeader *Dest; // [sp+14h] [bp-250h]@6
-  RGBTexture *this_; // [sp+18h] [bp-24Ch]@6
-  LODWriteableFile v11; // [sp+1Ch] [bp-248h]@1
-  int v12; // [sp+260h] [bp-4h]@1
-
-  ++pIcons_LOD->uTexturePacksCount;
-  v12 = 0;
-  if ( !pIcons_LOD->uNumPrevLoadedFiles )
-    pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
-  memset(pSavegameUsedSlots, 0, 0xB4u);
-  memset(&pSavegameThumbnails, 0, 0x708u);
-  uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE);
-  uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE);
-  uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE);
-  uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE);
-  uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE);
-  uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE);
-  pRenderer->DrawTextureIndexed(
-    8u,
-    8u,
-    (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
-  if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions == 11 )
-  {
-    v0 = uTextureID_save_up;
-    v1 = uTextureID_LS_saveU;
-  }
-  else
-  {
-    v0 = uTextureID_load_up;
-    v1 = uTextureID_LS_loadU;
-  }
-  pRenderer->DrawTextureIndexed(0xF1u, 0x12Eu, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0));
-  pRenderer->DrawTextureIndexed(
-    0x15Fu,
-    0x12Eu,
-    (Texture *)(uTextureID_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_u] : 0));
-  pRenderer->DrawTextureIndexed(0x12u, 0x8Du, (Texture *)(v0 != -1 ? (int)&pIcons_LOD->pTextures[v0] : 0));
-  pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);
-  pRenderer->Present();
-  SavegameList::Initialize(1u);
-  v11.AllocSubIndicesAndIO(0x12Cu, 0);
-  v2 = pSavegameUsedSlots;
-  Dest = pSavegameHeader;
-  this_ = pSavegameThumbnails;
-  v8 = (char *)pSavegameList->pSavesNames;
-  do
-  {
-    v3 = v8;
-    if ( !*v8 )
-      v3 = "1.mm7";
-    sprintfex(pTmpBuf, "saves\\%s", v3);
-    if ( _access(pTmpBuf, 0) || _access(pTmpBuf, 6) )
-    {
-      v6 = pGlobalTXT_LocalizationStrings[72];
-      *v2 = 0;
-      strcpy(Dest->pName, v6);
-    }
-    else
-    {
-      v11.LoadFile(pTmpBuf, 1);
-      v4 = v11.FindContainer("header.bin", 1);
-      fread(Dest, 0x64u, 1u, v4);
-      v5 = v11.FindContainer("image.pcx", 1);
-      if ( v5 )
-      {
-        this_->LoadFromFILE(v5, 0, 1u);
-        v11.CloseWriteFile();
-        *v2 = 1;
-      }
-      else
-      {
-        *v2 = 0;
-      }
-    }
-    v8 += 280;
-    ++this_;
-    ++Dest;
-    ++v2;
-  }
-  while ( (signed int)v8 < (signed int)&_69FBB4_ptr_iterator_end );
-  v11.FreeSubIndexAndIO();
-  uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE);
-  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, (WindowType)(WINDOW_Chest|WINDOW_MainMenu|0x2), 0, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 0xBFu, 0x12u, 1, 0, 0xA5u, 0, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 218u, 0xBFu, 0x12u, 1, 0, 0xA5u, 1u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 238u, 0xBFu, 0x12u, 1, 0, 0xA5u, 2u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 258u, 0xBFu, 0x12u, 1, 0, 0xA5u, 3u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 278u, 0xBFu, 0x12u, 1, 0, 0xA5u, 4u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 298u, 0xBFu, 0x12u, 1, 0, 0xA5u, 5u, 0, nullstring, 0);
-  pGUIWindow_CurrentMenu->CreateButton(21u, 318u, 0xBFu, 0x12u, 1, 0, 0xA5u, 6u, 0, nullstring, 0);
-  ptr_69BD64 = pGUIWindow_CurrentMenu->CreateButton(
-                 0xF1u,
-                 0x12Eu,
-                 0x69u,
-                 0x28u,
-                 1,
-                 0,
-                 0xA4u,
-                 0,
-                 0,
-                 nullstring,
-                 (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0),
-                 0);
-  ptr_69BD60 = pGUIWindow_CurrentMenu->CreateButton(
-                 0x15Eu,
-                 0x12Eu,
-                 0x69u,
-                 0x28u,
-                 1,
-                 0,
-                 0xA6u,
-                 0,
-                 0,
-                 nullstring,
-                 (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0),
-                 0);
-  ptr_69BD5C = pGUIWindow_CurrentMenu->CreateButton(
-                 0xD7u,
-                 0xC7u,
-                 0x11u,
-                 0x11u,
-                 1,
-                 0,
-                 0xA2u,
-                 0,
-                 0,
-                 nullstring,
-                 (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0),
-                 0);
-  v7 = pGUIWindow_CurrentMenu->CreateButton(
-         0xD7u,
-         0x143u,
-         0x11u,
-         0x11u,
-         1,
-         0,
-         0xA3u,
-         0x22u,
-         0,
-         nullstring,
-         (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0),
-         0);
-  v12 = -1;
-  ptr_69BD58 = v7;
-}
-// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
+
+
 
 //----- (0045EE8A) --------------------------------------------------------
 void __fastcall LoadGame(unsigned int uSlot)
@@ -12054,7 +11692,7 @@
     Abortf(pTmpBuf, v30, v31, v32);
   }
   strcpy(pCurrentMapName, &pContainer);
-  LOWORD(dword_6BE364_game_settings_1) = dword_6BE364_game_settings_1 | 0x2001;
+  dword_6BE364_game_settings_1 |= 0x2001;
   v27 = 0;
   if ( (signed int)uNumSavegameFiles > 0 )
   {
@@ -12068,9 +11706,9 @@
     while ( v27 < (signed int)uNumSavegameFiles );
   }
   pIcons_LOD->_4114F2();
-  v32 = (signed __int64)(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0);
+  v32 = (signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0);
   v24->SetMusicVolume(v32);
-  v32 = (signed __int64)(pSoundVolumeLevels[(char)uSoundVolumeMultiplier] * 128.0);
+  v32 = (signed __int64)(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0);
   v24->SetMasterVolume(v32);
   if ( uTurnSpeed )
     pParty->sRotationY = uTurnSpeed * pParty->sRotationY / (signed int)uTurnSpeed;
@@ -12078,11 +11716,7 @@
   bFlashQuestBook = 0;
   viewparams->bRedrawGameUI = 1;
 }
-// 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
-// 4ED498: using guessed type char byte_4ED498;
-// 50794A: using guessed type char bFlashQuestBook;
-// 5B65C8: using guessed type int dword_5B65C8;
-// 6BE364: using guessed type int dword_6BE364_game_settings_1;
+
 
 //----- (0045F469) --------------------------------------------------------
 int __fastcall SaveGame(int a1, __int16 *a2)
@@ -12558,7 +12192,7 @@
 // 4E28F8: using guessed type int uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions;
 
 //----- (004601B7) --------------------------------------------------------
-void __fastcall sub_4601B7(int a1)
+void GameUI_MainMenu_DoDrawLoad(int a1)
 {
   unsigned __int16 v1; // bx@1
   unsigned int v2; // edi@4
@@ -12601,15 +12235,15 @@
 
   v1 = 255;
   a4 = a1;
-  GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0xFF);
+  GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0x9B);
   pRenderer->BeginScene();
   if ( GetCurrentMenuID() != MENU_SAVELOAD && GetCurrentMenuID() != MENU_LOAD )
   {
     pRenderer->DrawTextureIndexed(
       8u,
       8u,
-      (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
+      (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
     if ( a4 )
     {
       v2 = uTextureID_save_up;
@@ -12641,7 +12275,7 @@
     Dst.uFrameHeight = v5;
     Dst.uFrameW = v5 + v4 - 1;
     v6 = uLoadGameUI_SelectedSlot;
-    if ( *((int *)&pSavegameThumbnails->pPixels + 10 * uLoadGameUI_SelectedSlot) )
+    if (pSavegameThumbnails[uLoadGameUI_SelectedSlot].pPixels)
     {
       pRenderer->DrawTextureRGB(
         pGUIWindow_CurrentMenu->uFrameX + 276,
@@ -12649,16 +12283,10 @@
         pSavegameThumbnails + uLoadGameUI_SelectedSlot);
       v6 = uLoadGameUI_SelectedSlot;
     }
-    v7 = pMapStats->GetMapInfo(&pSavegameHeader->pLocationName[100 * v6]);
+    v7 = pMapStats->GetMapInfo(pSavegameHeader[v6].pLocationName);
     Dst.DrawText2(pFontSmallnum, 0, 0, 0, pMapStats->pInfos[v7].pName, 3u);
-    v8 = (signed __int64)((double)*(signed __int64 *)((char *)&pSavegameHeader->uWordTime + 100
-                                                                                         * uLoadGameUI_SelectedSlot)
-                        * 0.234375)
-       / 60;
-    HIDWORD(v32) = (unsigned __int64)((signed __int64)((double)*(signed __int64 *)((char *)&pSavegameHeader->uWordTime
-                                                                                 + 100 * uLoadGameUI_SelectedSlot)
-                                                     * 0.234375)
-                                    / 60) >> 32;
+    v8 = (signed __int64)(pSavegameHeader[uLoadGameUI_SelectedSlot].uWordTime * 0.234375) / 60;
+    HIDWORD(v32) = (unsigned __int64)((signed __int64)(pSavegameHeader[uLoadGameUI_SelectedSlot].uWordTime * 0.234375) / 60) >> 32;
     v9 = v8;
     v8 /= 60i64;
     v35 = v8;
@@ -12699,15 +12327,17 @@
     v17 = v15;
     v34 = v14;
 LABEL_23:
-    sprintfex(
-      pTmpBuf,
-      "%s %d:%02d%s\n%d %s %d",
-      aDayNames[HIDWORD(v15) % 7],
+    auto _d = aDayNames[HIDWORD(v15) % 7];
+    auto _a = aAMPMNames[HIDWORD(v35)];
+    auto _m = aMonthNames[v33];
+    sprintf(pTmpBuf, "%s %d:%02d%s\n%d %s %d", _d, v17, (int)32, _a, 3, _m, v36);
+    sprintf(pTmpBuf, "%s %d:%02d%s\n%d %s %d",
+      _d,
       v17,
-      v32,
-      aAMPMNames[HIDWORD(v35)],
+      (int)v32,
+      _a,
       7 * v16 + HIDWORD(v15) % 7 + 1,
-      aMonthNames[v33],
+      _m,
       v36);
     Dst.DrawText2(pFontSmallnum, 0, 0, 0, pTmpBuf, 3u);
     v1 = 255;
@@ -12729,7 +12359,7 @@
     if ( pGUIWindow_CurrentMenu->field_40 == 3 )
       pGUIWindow_CurrentMenu->field_40 = 0;
   }
-  if ( GetCurrentMenuID() == 9 )
+  if (GetCurrentMenuID() == MENU_LOAD)
   {
     v18 = pGlobalTXT_LocalizationStrings[135];
     v19 = pFontSmallnum->AlignText_Center(0xBAu, pGlobalTXT_LocalizationStrings[135]);
@@ -12751,18 +12381,19 @@
       v34 = uNumSavegameFiles;
     a4 = 199;
     v36 = dword_6A0C9C;
-    v24 = (const char *)(&pSavegameHeader + dword_6A0C9C);
+    v24 = (const char *)(&pSavegameHeader[dword_6A0C9C]);
     do
     {
       if ( v36 >= (signed int)v34 )
         break;
-      HIDWORD(v35) = v36 == uLoadGameUI_SelectedSlot ? GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(
+      short clr;
+      HIDWORD(v35) = clr = (v36 == uLoadGameUI_SelectedSlot ? GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(
                                                          v1,
                                                          v1,
-                                                         0x64u) : 0;
+                                                         0x64) : 0);
       if ( pGUIWindow_CurrentMenu->field_40 != 1 || v36 != uLoadGameUI_SelectedSlot )
       {
-        pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, 0x1Bu, a4, HIDWORD(v35), v24, 185, 0);
+        pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, 0x1Bu, a4, clr, v24, 185, 0);
       }
       else
       {
@@ -12770,7 +12401,7 @@
                 pFontSmallnum,
                 0x1Bu,
                 a4,
-                HIDWORD(v35),
+                clr,
                 (const char *)pKeyActionMap->pPressedKeysBuffer,
                 175,
                 1);
@@ -12787,15 +12418,15 @@
 // 6A0C9C: using guessed type int dword_6A0C9C;
 
 //----- (004606F7) --------------------------------------------------------
-void __cdecl sub_4606F7()
-{
-  sub_4601B7(0);
+void __cdecl GameUI_MainMenu_DrawLoad()
+{
+  GameUI_MainMenu_DoDrawLoad(0);
 }
 
 //----- (004606FE) --------------------------------------------------------
 void __cdecl sub_4606FE()
 {
-  sub_4601B7(1);
+  GameUI_MainMenu_DoDrawLoad(1);
 }
 
 //----- (00460706) --------------------------------------------------------
@@ -13288,19 +12919,6 @@
     }
   }
 }
-// 4E94D0: using guessed type char byte_4E94D0;
-// 519AB4: using guessed type int uNumStationaryLightsApplied;
-// 6807E0: using guessed type int _6807E0_num_decorations_6807B8;
-// 6A0D0C: using guessed type int 6A0D0C_txt_lod_loading;
-// 6BE13C: using guessed type int dword_6BE13C_uCurrentlyLoadedLocationID;
-// 6BE35C: using guessed type int uLevel_StartingPointType;
-// 6BE364: using guessed type int dword_6BE364_game_settings_1;
-// 6BE3C4: using guessed type char bUnderwater;
-// 6BE3C5: using guessed type char bNoNPCHiring;
-// A750D8: using guessed type __int64 qword_A750D8;
-// A750E0: using guessed type __int16 word_A750E0;
-// A750E2: using guessed type __int16 word_A750E2;
-// 460A78: using guessed type int var_2C[4];
 
 //----- (004610AA) --------------------------------------------------------
 void __fastcall PrepareToLoadODM(unsigned int bLoading, OutdoorCamera *a2)
@@ -13561,58 +13179,9 @@
   return (11 * a2 >> 5) + a1 + (v4 >> 2);
 }
 
-//----- (0046224A) --------------------------------------------------------
-int __cdecl sub_46224A()
-{
-  int result; // eax@1
-
-  result = 0;
-  _702AC4_unused = 0;
-  _702ACC_unused = 0;
-  _702AC0_unused = 0;
-  return result;
-}
-// 702AC0: using guessed type int 702AC0_unused;
-// 702AC4: using guessed type int 702AC4_unused;
-// 702ACC: using guessed type char 702ACC_unused;
-
-
-
-//----- (00462620) --------------------------------------------------------
-int __cdecl crt_init_globals_462620()
-{
-  int result; // eax@1
-
-  result = 0;
-  dword_6BE364_game_settings_1 = 0;
-  bUseLoResSprites = 0;
-  uCurrentlyLoadedLevelType = (LEVEL_TYPE)0;
-  return result;
-}
-// 6BE364: using guessed type int dword_6BE364_game_settings_1;
-
-
-
-
-
-//----- (00462659) --------------------------------------------------------
-void __cdecl crt_init_globals_462659()
-{
-  fWalkSpeedMultiplier = 1.0;
-  fBackwardMovementSlowdownMultiplier = 1.0;
-  fTurnSpeedMultiplier = 1.0;
-  flt_6BE150_look_up_down_dangle = 1.0;
-}
-// 6BE144: using guessed type float fWalkSpeedMultiplier;
-// 6BE148: using guessed type float fBackwardMovementSlowdownMultiplier;
-// 6BE14C: using guessed type float fTurnSpeedMultiplier;
-// 6BE150: using guessed type float flt_6BE150_look_up_down_dangle;
-
-//----- (0046269B) --------------------------------------------------------
-void __cdecl crt_init_globals_46269B()
-{
-  unnamed_6BE060[1] = 1;
-}
+
+
+
 
 
 OPENFILENAMEA ofn;
@@ -13664,17 +13233,17 @@
   ++pIcons_LOD->uTexturePacksCount;
   if ( !pIcons_LOD->uNumPrevLoadedFiles )
     pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
-  pWindow_Credits = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
+  pWindow_MainMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
 
   auto pNew = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE);
   //v0 = pIcons_LOD->LoadTexture("title_new", TEXTURE_16BIT_PALETTE);
   //v1 = (Texture *)(v0 != -1 ? &pIcons_LOD->pTextures[v0] : 0);
-  pMainMenu_BtnNew = pWindow_Credits->CreateButton(495, 172,
+  pMainMenu_BtnNew = pWindow_MainMenu->CreateButton(495, 172,
                                                    pNew->uTextureWidth,
                                                    pNew->uTextureHeight,
                                                    1,
                                                    0,
-                                                   54,
+                                                   UIMSG_MainMenu_ShowPartyCreationWnd,
                                                    0,
                                                    78,
                                                    "",
@@ -13683,12 +13252,12 @@
   //v2 = pIcons_LOD->LoadTexture("title_load", TEXTURE_16BIT_PALETTE);
   //v3 = (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0);
   auto pLoad = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE);
-  pMainMenu_BtnLoad = pWindow_Credits->CreateButton(495, 227,
+  pMainMenu_BtnLoad = pWindow_MainMenu->CreateButton(495, 227,
                                                     pLoad->uTextureWidth,
                                                     pLoad->uTextureHeight,
                                                     1,
                                                     0,
-                                                    55,
+                                                    UIMSG_MainMenu_ShowLoadWindow,
                                                     1,
                                                     76,
                                                     "",
@@ -13697,12 +13266,12 @@
   //v4 = pIcons_LOD->LoadTexture("title_cred", TEXTURE_16BIT_PALETTE);
   //v5 = (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0);
   auto pCredits = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE);
-  pMainMenu_BtnCredits = pWindow_Credits->CreateButton(495, 282,
+  pMainMenu_BtnCredits = pWindow_MainMenu->CreateButton(495, 282,
                                                        pCredits->uTextureWidth,
                                                        pCredits->uTextureHeight,
                                                        1,
                                                        0,
-                                                       56,
+                                                       UIMSG_ShowCredits,
                                                        2,
                                                        67,
                                                        "",
@@ -13711,12 +13280,12 @@
   //v6 = pIcons_LOD->LoadTexture("title_exit", TEXTURE_16BIT_PALETTE);
   //v7 = (Texture *)(v6 != -1 ? (int)&pIcons_LOD->pTextures[v6] : 0);
   auto pExit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE);
-  pMainMenu_BtnExit = pWindow_Credits->CreateButton(495, 337,
+  pMainMenu_BtnExit = pWindow_MainMenu->CreateButton(495, 337,
                                                     pExit->uTextureWidth,
                                                     pExit->uTextureHeight,
                                                     1,
                                                     0,
-                                                    57,
+                                                    UIMSG_ExitToWindows,
                                                     3,
                                                     0,
                                                     "",
@@ -13729,14 +13298,14 @@
   SetForegroundWindow(hWnd);
   SendMessageA(hWnd, WM_ACTIVATEAPP, 1, 0);
   while (uCurrentMenuID == MENU_MAIN ||
-         uCurrentMenuID == MENU_LOAD)
+         uCurrentMenuID == MENU_SAVELOAD)
   {
     POINT pt;
     pMouse->GetCursorPos(&pt);
     //uMouseX = pMouse->GetCursorPos(&v18)->x;
     //uMouseY = pMouse->GetCursorPos(&v19)->y;
-    v15 = pWindow_Credits;
-    if ( uCurrentMenuID == MENU_LOAD)
+    v15 = pWindow_MainMenu;
+    if ( uCurrentMenuID == MENU_SAVELOAD)
     {
       if ( uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions != 12 )
       {
@@ -13771,10 +13340,10 @@
       GUI_UpdateWindows();
       if (pAsyncMouse)
         pAsyncMouse->_46B736_consume_click_lists(1);
-      if ( uCurrentMenuID )
+      if (GetCurrentMenuID() != MENU_MAIN)
       {
 LABEL_45:
-        if ( uCurrentMenuID == 9 )
+        if (GetCurrentMenuID() == MENU_LOAD)
         {
           pIcons_LOD->_4114F2();
           crt_deconstruct_ptr_6A0118();
@@ -13798,7 +13367,7 @@
                 && pt.x <= (signed int)v8->uZ
                 && pt.y >= (signed int)v8->uY
                 && pt.y <= (signed int)v8->uW
-                && v15 == pWindow_Credits )
+                && v15 == pWindow_MainMenu )
               {
                 v9 = v8->uControlParam;
                 if ( v9 )
@@ -13858,7 +13427,7 @@
     pGUIWindow2->Release();
     pGUIWindow2 = 0;
   }
-  pWindow_Credits->Release();
+  pWindow_MainMenu->Release();
   pIcons_LOD->_4114F2();
 }
 
@@ -13936,7 +13505,7 @@
           pVideoPlayer->bStopBeforeSchedule = 1;
         if ( !pAsyncMouse )
           pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
-        if ( uCurrentMenuID != 6 )
+        if (GetCurrentMenuID() != MENU_CREATEPARTY)
           goto LABEL_230;
         goto LABEL_229;
       case WM_RBUTTONDOWN:
@@ -15406,15 +14975,14 @@
   pRenderer->Present();
 
   uSoundVolumeMultiplier = ReadWindowsRegistryInt("soundflag", 9);
-  if (uSoundVolumeMultiplier < 0 || uSoundVolumeMultiplier > 9)
+  if (uSoundVolumeMultiplier > 9)
     uSoundVolumeMultiplier = 9;
   uMusicVolimeMultiplier = ReadWindowsRegistryInt("musicflag", 9);
-  if (uMusicVolimeMultiplier < 0 || uMusicVolimeMultiplier > 9)
+  if (uMusicVolimeMultiplier > 9)
     uMusicVolimeMultiplier = 9;
   uVoicesVolumeMultiplier = ReadWindowsRegistryInt("CharVoices", 9);
-  if (uVoicesVolumeMultiplier < 0 || uVoicesVolumeMultiplier > 9)
+  if (uVoicesVolumeMultiplier > 9)
     uVoicesVolumeMultiplier = 9;
-  bWalkSound = ReadWindowsRegistryInt("WalkSound", 1) != 0;
   bShowDamage = ReadWindowsRegistryInt("ShowDamage", 1) != 0;
   byte_6BE388_graphicsmode = ReadWindowsRegistryInt("graphicsmode", 1);
   if (byte_6BE388_graphicsmode < 0 || byte_6BE388_graphicsmode > 2)
@@ -15433,7 +15001,7 @@
   uTurnSpeed = ReadWindowsRegistryInt("TurnDelta", 0);
   dword_6BE384_2dacceloff = ReadWindowsRegistryInt("2dacceloff", 0);
 
-  if ( !(dword_6BE364_game_settings_1 & 0x10) )
+  if (!bNoSound)
     pAudioPlayer->Initialize(hWnd);
 
   pVideoPlayer = new VideoPlayer;
@@ -15494,7 +15062,7 @@
   pSprites_LOD->field_ECAC = 1;
   pObjectList->InitializeSprites();
   pOverlayList->InitializeSprites();
-  if ( !(dword_6BE364_game_settings_1 & 0x10) )
+  if (!bNoSound)
     pSoundList->Initialize();
 
   static const char *pUIAnimNames[4] =
@@ -15616,8 +15184,17 @@
       bDebugResouces = 1;
     if (wcsstr(pCmdLine, L"-window"))
       dword_6BE368_debug_settings_2 |= 1u;
+
+    if (wcsstr(pCmdLine, L"-nointro"))
+      bNoIntro = true;//dword_6BE364_game_settings_1 |= 4;
+    if (wcsstr(pCmdLine, L"-nologo"))
+      bNoLogo = true;//dword_6BE364_game_settings_1 |= 8;
     if (wcsstr(pCmdLine, L"-nosound"))
-      dword_6BE364_game_settings_1 |= 0x10u;
+      bNoSound = true; //dword_6BE364_game_settings_1 |= 0x10;
+
+    bWalkSound = ReadWindowsRegistryInt("WalkSound", 1) != 0;
+    if (wcsstr(pCmdLine, L"-nowalksound"))
+      bWalkSound = false;//dword_6BE364_game_settings_1 |= 0x20;
     if (wcsstr(pCmdLine, L"-noanim"))
     {
       dword_6BE364_game_settings_1 |= 0x40;
@@ -15664,10 +15241,17 @@
       uGameState = 0;
       while ( 1 )
       {
-        if ( uGameState == 1 )
-        {
+        switch (uGameState)
+        {
+          case GAME_FINISHED:
             pGame->Deinitialize();
-          return true;
+            return true;
+        }
+
+        if (GetCurrentMenuID() == MENU_FINISHED)
+        {
+          uGameState = GAME_FINISHED;
+          continue;
         }
         if (GetCurrentMenuID() == MENU_NEWGAME)
         {
@@ -15697,20 +15281,15 @@
           MaybeDoAutosave();
           goto LABEL_48;
         }
-        if ( uCurrentMenuID == 2 )
+        if (GetCurrentMenuID() == MENU_CREDITS)
           break;
-        if ( uCurrentMenuID == 4 )
-        {
-          uGameState = 1;
-          goto LABEL_49;
-        }
-        if ( uCurrentMenuID == 5 || uCurrentMenuID == 9 )
+        if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LOAD)
         {
           uGameState = 0;
         }
         else
         {
-          if ( uCurrentMenuID != 10 )
+          if (GetCurrentMenuID() != MENU_10)
             goto LABEL_49;
           pMouse->Activate(0);
           if (pAsyncMouse)
@@ -15767,7 +15346,7 @@
       CreditsMenu__Loop();
 
 LABEL_53:
-      if ( !(dword_6BE364_game_settings_1 & 0x10) && pAudioPlayer->hAILRedbook )
+      if (!bNoSound && pAudioPlayer->hAILRedbook)
       {
         pAudioPlayer->SetMusicVolume(
           (signed __int64)(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0));
@@ -15853,16 +15432,7 @@
   if ( pAudioPlayer->uMixerChannels > 16 )
     pAudioPlayer->uMixerChannels = 16;
 
-  if (GetPrivateProfileIntW(L"settings", L"nointro", 0, pIniFilename))
-    dword_6BE364_game_settings_1 |= 4;
-  if (GetPrivateProfileIntW(L"settings", L"nosound", 0, pIniFilename))
-    dword_6BE364_game_settings_1 |= 0x10;
-  if (GetPrivateProfileIntW(L"settings", L"nowalksound", 0, pIniFilename))
-    dword_6BE364_game_settings_1 |= 0x20;
-  if (GetPrivateProfileIntW(L"settings", L"nologo", 0, pIniFilename))
-    dword_6BE364_game_settings_1 |= 8;
-  if (GetPrivateProfileIntW(L"settings", L"nointro", 0, pIniFilename))
-    dword_6BE364_game_settings_1 |= 4;
+
   if (GetPrivateProfileIntW(L"debug", L"nomonster", 0, pIniFilename))
     dword_6BE368_debug_settings_2 |= 4;
   if (bUseRegistry)