changeset 3:540178ef9b18

Main menu functionality
author Nomad
date Wed, 10 Oct 2012 19:10:15 +0200
parents 2ca04ccb612a
children 4acbadf78023 5983336e1300
files AIL.cpp AIL.h AudioPlayer.cpp AudioPlayer.h GUIFont.cpp GUIWindow.cpp GUIWindow.h Game.cpp Game.h Indoor.cpp Indoor.h IndoorCameraD3D.cpp LOD.cpp LOD.h LightmapBuilder.cpp Might and Magic Trilogy.vcxproj.filters OutdoorCamera.h Party.cpp Render.cpp Render.h SaveLoad.cpp SaveLoad.h VideoPlayer.cpp Vis.cpp mm7_1.cpp mm7_2.cpp mm7_3.cpp mm7_4.cpp mm7_5.cpp mm7_data.cpp mm7_data.h
diffstat 31 files changed, 384 insertions(+), 806 deletions(-) [+]
line wrap: on
line diff
--- a/AIL.cpp	Wed Oct 10 14:21:15 2012 +0200
+++ b/AIL.cpp	Wed Oct 10 19:10:15 2012 +0200
@@ -37,6 +37,7 @@
 AILFILETYPE (__stdcall *mss32_AIL_file_type)(void *, int) = 0;
 int (__stdcall *mss32_AIL_WAV_info)(void *, AILSOUNDINFO *) = 0;
 int (__stdcall *mss32_AIL_decompress_ADPCM)(AILSOUNDINFO *, void *, void *) = 0;
+HREDBOOK (__stdcall *mss32_AIL_redbook_open)(int) = 0;
 void MSS32_DLL_Initialize()
 {
  HMODULE pDll = LoadLibraryW(L"mss32.dll");
@@ -75,6 +76,7 @@
  mss32_AIL_file_type = (AILFILETYPE (__stdcall *)(void *, int))GetProcAddress(pDll, "_AIL_file_type@8");
  mss32_AIL_WAV_info = (int (__stdcall *)(void *, AILSOUNDINFO *))GetProcAddress(pDll, "_AIL_WAV_info@8");
  mss32_AIL_decompress_ADPCM = (int (__stdcall *)(AILSOUNDINFO *, void *, void *))GetProcAddress(pDll, "_AIL_decompress_ADPCM@12");
+ mss32_AIL_redbook_open = (HREDBOOK (__stdcall *)(int))GetProcAddress(pDll, "_AIL_redbook_open@4");
 }
 
 
@@ -98,7 +100,10 @@
 {
  return (mss32_AIL_enumerate_3D_providers)(a1, pOutProv, pOutName);
 }
-
+HREDBOOK __stdcall AIL_redbook_open(int w)
+{
+ return (mss32_AIL_redbook_open)(w);
+}
 
 
 int __stdcall AIL_sample_volume(HSAMPLE s)
--- a/AIL.h	Wed Oct 10 14:21:15 2012 +0200
+++ b/AIL.h	Wed Oct 10 19:10:15 2012 +0200
@@ -229,6 +229,7 @@
 
 int __stdcall AIL_startup();
 HREDBOOK __stdcall AIL_redbook_open_drive(long drive);
+HREDBOOK __stdcall AIL_redbook_open(int);
 int __stdcall AIL_set_preference(unsigned int number, int value);
 int __stdcall AIL_waveOutOpen(HDIGDRIVER *drv, HWAVEOUT *phWaveOut, int wDeviceID, WAVEFORMAT *pFormat);
 int __stdcall AIL_get_preference(unsigned int number);
--- a/AudioPlayer.cpp	Wed Oct 10 14:21:15 2012 +0200
+++ b/AudioPlayer.cpp	Wed Oct 10 19:10:15 2012 +0200
@@ -38,9 +38,9 @@
 
 
 
-unsigned __int8 uSoundVolumeMultiplier;
-unsigned __int8 uVoicesVolumeMultiplier;
-unsigned __int8 uMusicVolimeMultiplier;
+unsigned __int8 uSoundVolumeMultiplier = 4;
+unsigned __int8 uVoicesVolumeMultiplier = 4;
+unsigned __int8 uMusicVolimeMultiplier = 4;
 int bWalkSound; // idb
 
 float pSoundVolumeLevels[777]; // idb
@@ -146,7 +146,7 @@
   int a2; // [sp+A8h] [bp-4h]@2
 
   v3 = this;
-  if ( dword_6BE364_game_settings_1 & 0x10
+  if (bNoSound
     || (v4 = this->uNumSounds,
         v5 = 1,
         v8 = __OFSUB__(this->uNumSounds, 1),
@@ -212,7 +212,6 @@
   v3->pSounds[v12].p3DSound = v3->pSounds[v12].pSoundData[0];
   return a2;
 }
-// 6BE364: using guessed type int dword_6BE364_game_settings_1;
 
 //----- (004A9BBD) --------------------------------------------------------
 int SoundList::LoadSound(unsigned int a2, LPVOID lpBuffer, int uBufferSizeLeft, int *pOutSoundSize, int a6)
@@ -539,31 +538,18 @@
 }
 
 //----- (004AA13F) --------------------------------------------------------
-void AudioPlayer::PlayMusicTrack(unsigned int uTrackID)
+void AudioPlayer::PlayMusicTrack(MusicID eTrack)
 {
-  AudioPlayer *v2; // esi@1
-  unsigned int v3; // [sp+0h] [bp-4h]@0
-
-  v2 = this;
-  if ( !(dword_6BE364_game_settings_1 & 0x10) && hAILRedbook && uMusicVolimeMultiplier )
+  if (!bNoSound && bPlayerReady && hAILRedbook && uMusicVolimeMultiplier)
   {
-    if ( bPlayerReady )
-    {
-      if ( hAILRedbook )
-        AIL_redbook_set_volume(
-          hAILRedbook,
-          (signed)(pSoundVolumeLevels[(char)uMusicVolimeMultiplier] * 64.0));
-    }
     AIL_redbook_stop(hAILRedbook);
-    AIL_redbook_track_info(hAILRedbook, v3, &v2->uCurrentMusicTrackStartMS, &v2->uCurrentMusicTrackEndMS);
-    AIL_redbook_play(hAILRedbook, v2->uCurrentMusicTrackStartMS + 1, v2->uCurrentMusicTrackEndMS);
-    v2->uCurrentMusicTrackLength = ((v2->uCurrentMusicTrackEndMS - v2->uCurrentMusicTrackStartMS) << 7) / 0x3E8;
+    AIL_redbook_set_volume(hAILRedbook, (signed)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0));
+    AIL_redbook_track_info(hAILRedbook, eTrack, &uCurrentMusicTrackStartMS, &uCurrentMusicTrackEndMS);
+    AIL_redbook_play(hAILRedbook, uCurrentMusicTrackStartMS + 1, uCurrentMusicTrackEndMS);
+    uCurrentMusicTrackLength = ((uCurrentMusicTrackEndMS - uCurrentMusicTrackStartMS) * 128) / 1000;
   }
 }
-// 4AA13F: could not find valid save-restore pair for ebx
-// 4AA13F: could not find valid save-restore pair for edi
-// 4D8324: using guessed type int __stdcall AIL_redbook_stop(int);
-// 6BE364: using guessed type int dword_6BE364_game_settings_1;
+
 
 //----- (004AA1F3) --------------------------------------------------------
 void AudioPlayer::SetMusicVolume(int vol)
@@ -1889,8 +1875,12 @@
   SMACKW32_DLL_Initialize();
   
   AIL_startup();
-  hAILRedbook = AIL_redbook_open_drive(cMM7GameCDDriveLetter/*cGameCDDriveLetter*/);
+  if (bCanLoadFromCD)
+    hAILRedbook = AIL_redbook_open_drive(cMM7GameCDDriveLetter/*cGameCDDriveLetter*/);
+  //else
+  //  hAILRedbook = AIL_redbook_open(0);
   //v4 = Audio_GetFirstHardwareDigitalDriver();
+
   hDigDriver = Audio_GetFirstHardwareDigitalDriver();
   if ( hDigDriver )
     SmackSoundUseMSS(hDigDriver);
@@ -2363,7 +2353,7 @@
 
   v0 = pMapStats->GetMapInfo(pCurrentMapName);
   if ( v0 )
-    pAudioPlayer->PlayMusicTrack(pMapStats->pInfos[v0].uRedbookTrackID);
+    pAudioPlayer->PlayMusicTrack((MusicID)pMapStats->pInfos[v0].uRedbookTrackID);
 }
 
 //----- (004AC004) --------------------------------------------------------
--- a/AudioPlayer.h	Wed Oct 10 14:21:15 2012 +0200
+++ b/AudioPlayer.h	Wed Oct 10 19:10:15 2012 +0200
@@ -93,6 +93,12 @@
   SOUND_20001 = 0x4E21,
 };
 
+
+enum MusicID: unsigned __int32
+{
+  MUSIC_Credits = 15
+};
+
 /*   20 */
 #pragma pack(push, 1)
 struct AudioPlayer
@@ -100,7 +106,7 @@
   //----- (004A9669) --------------------------------------------------------
   AudioPlayer():
     bPlayerReady(false), b3DSoundInitialized(false),
-    hStream(nullptr)
+    hAILRedbook(nullptr), hStream(nullptr)
   {
     uMixerChannels = 16;
     field_2D0_time_left = 256;
@@ -125,7 +131,7 @@
   void SetEAXPreferences();
   void SetMapEAX();
   int _4AC0A2();
-  void PlayMusicTrack(unsigned int uTrackID);
+  void PlayMusicTrack(enum MusicID eTrack);
   void __cdecl MessWithChannels();
 
 
--- a/GUIFont.cpp	Wed Oct 10 14:21:15 2012 +0200
+++ b/GUIFont.cpp	Wed Oct 10 19:10:15 2012 +0200
@@ -213,7 +213,7 @@
       do
       {
         v23 = &pString[v6];
-        if ( v7->IsCharValid(pString[v6]) )
+        if ( v7->IsCharValid(v9 = pString[v6]) )
         {
           v10 = v9;
           v11 = v9 - 9;
@@ -539,7 +539,7 @@
   v13 = v10;
   while ( Stra < (signed int)v13 )
   {
-    if ( GUIFont::IsCharValid(*v9) )
+    if ( GUIFont::IsCharValid(v11 = *v9) )
     {
       if ( v11 == 9 )
         goto LABEL_9;
--- a/GUIWindow.cpp	Wed Oct 10 14:21:15 2012 +0200
+++ b/GUIWindow.cpp	Wed Oct 10 19:10:15 2012 +0200
@@ -28,7 +28,7 @@
 
 
 int pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[1]; // idb
-struct GUIWindow *pWindow_Credits;
+struct GUIWindow *pWindow_MainMenu;
 struct GUIWindow pWindowList[20];
 
 struct GUIMessageQueue *pMessageQueue_50CBD0 = new GUIMessageQueue;
--- a/GUIWindow.h	Wed Oct 10 14:21:15 2012 +0200
+++ b/GUIWindow.h	Wed Oct 10 19:10:15 2012 +0200
@@ -12,7 +12,7 @@
   MENU_NEWGAME = 0x1,
   MENU_CREDITS = 0x2,
   MENU_SAVELOAD = 0x3,
-  MENU_4 = 0x4,
+  MENU_FINISHED = 0x4,
   MENU_5 = 0x5,
   MENU_CREATEPARTY = 0x6,
   MENU_7 = 0x7,
@@ -42,12 +42,14 @@
   WINDOW_12 = 18,
   WINDOW_13 = 19,
   WINDOW_Chest = 0x14,
+  WINDOW_MainMenu_Load = 0x18,
   WINDOW_HouseInterior = 0x19,
   WINDOW_1A = 26,
   WINDOW_1B = 27,
   WINDOW_1E = 30,
   WINDOW_1F = 31,
   WINDOW_FinalWindow = 0x46,
+  WINDOW_5A = 0x5A,
   WINDOW_KeyMappingOptions = 0x69,
   WINDOW_VideoOptions = 0x6A
 };
@@ -109,6 +111,9 @@
   UIMSG_00 = 0x0,
   UIMSG_ChangeGameState = 0x5,
   UIMSG_PlayArcomage = 0x1D,
+  UIMSG_MainMenu_ShowPartyCreationWnd = 0x36,
+  UIMSG_MainMenu_ShowLoadWindow = 0x37,
+  UIMSG_ShowCredits = 0x38,
   UIMSG_ExitToWindows = 0x39,
   UIMSG_LoadGame = 0x52,
   UIMSG_SaveGame = 0x53,
@@ -234,5 +239,5 @@
 
 
 extern int pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[]; // idb
-extern struct GUIWindow *pWindow_Credits;
+extern struct GUIWindow *pWindow_MainMenu;
 extern struct GUIWindow pWindowList[20];
\ No newline at end of file
--- a/Game.cpp	Wed Oct 10 14:21:15 2012 +0200
+++ b/Game.cpp	Wed Oct 10 19:10:15 2012 +0200
@@ -102,7 +102,7 @@
         v2 = (double)(((signed int)pMiscTimer->uTotalGameTimeElapsed >> 2) & 0x1F) * 0.032258064 * 6.0;
         //v3 = v2 + 6.7553994e15;
         //pRenderer->field_1036A8_bitmapid = LODWORD(v3);
-        pRenderer->field_1036A8_bitmapid = floorf(v2);
+        pRenderer->field_1036A8_bitmapid = floorf(v2 + 0.5f);
       }
 
       if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
@@ -258,7 +258,7 @@
     }
     DoPrepareWorld(bLoading, v3);
     pEventTimer->Resume();
-    LOBYTE(dword_6BE364_game_settings_1) = dword_6BE364_game_settings_1 | 0x80;
+    dword_6BE364_game_settings_1 |= 0x80;
     dword_6BE340 = 2;
     uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
     if (pAsyncMouse)
@@ -496,18 +496,7 @@
   uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 16;
   sub_491E3A();
 }
-// 4D82B8: using guessed type int __stdcall BinkWait(int);
-// 4D840C: using guessed type int __stdcall SmackWait(int);
-// 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;
-// 5B65A8: using guessed type int _5B65A8_npcdata_uflags_or_other;
-// 5B65AC: using guessed type int _5B65AC_npcdata_fame_or_other;
-// 5B65B0: using guessed type int _5B65B0_npcdata_rep_or_other;
-// 5B65B4: using guessed type int _5B65B4_npcdata_loword_house_or_other;
-// 5B65B8: using guessed type int _5B65B8_npcdata_hiword_house_or_other;
-// 5B65C0: using guessed type int dword_5B65C0;
-// 6BE340: using guessed type int dword_6BE340;
-// 6BE364: using guessed type int dword_6BE364_game_settings_1;
-// 463149: using guessed type int var_4C[4];
+
 
 
 
@@ -807,12 +796,12 @@
     a3a = (1.0 - this->_E28_timed_gamma_strength) * v4;
     //v5 = a3a + 6.7553994e15;
     //if ( SLODWORD(v5) >= 0 )
-    if (floorf(a3a) >= 0 )
+    if (floorf(a3a + 0.5f) >= 0 )
     {
       a3b = (1.0 - this->_E28_timed_gamma_strength) * a2a;
       //v7 = a3b + 6.7553994e15;
       //v6 = LODWORD(v7);
-      v6 = floorf(a3b);
+      v6 = floorf(a3b + 0.5f);
     }
     else
     {
@@ -823,12 +812,12 @@
       a4a = (1.0 - _E28_timed_gamma_strength) * a2a;
       //v9 = a4a + 6.7553994e15;
       //if ( SLODWORD(v9) >= 0 )
-      if (floorf(a4a) >= 0)
+      if (floorf(a4a + 0.5f) >= 0)
       {
         a4b = (1.0 - _E28_timed_gamma_strength) * a2a;
         //v10 = a4b + 6.7553994e15;
         //result = LODWORD(v10);
-        result = floorf(a4b);
+        result = floorf(a4b + 0.5f);
       }
       else
       {
@@ -891,7 +880,7 @@
       v13 = (1.0 - this->_E28_timed_gamma_strength) * v11;
       //v7 = v13 + 6.7553994e15;
       //v6 = LODWORD(v7);
-      v6 = floorf(v13);
+      v6 = floorf(v13 + 0.5f);
     }
     else
     {
@@ -906,7 +895,7 @@
         v15 = (1.0 - _E28_timed_gamma_strength) * v11;
         //v10 = v15 + 6.7553994e15;
         //result = LODWORD(v10);
-        result = floorf(v15);
+        result = floorf(v15 + 0.5f);
       }
       else
       {
--- a/Game.h	Wed Oct 10 14:21:15 2012 +0200
+++ b/Game.h	Wed Oct 10 19:10:15 2012 +0200
@@ -22,7 +22,7 @@
 enum GAME_STATE
 {
   GAME_STATE_0 = 0x0,
-  GAME_STATE_1 = 0x1,
+  GAME_FINISHED = 0x1,
   GAME_STATE_2 = 0x2,
   GAME_STATE_3 = 0x3,
   GAME_STATE_4 = 0x4,
--- a/Indoor.cpp	Wed Oct 10 14:21:15 2012 +0200
+++ b/Indoor.cpp	Wed Oct 10 19:10:15 2012 +0200
@@ -36,7 +36,7 @@
 size_t uNumLevelDecorations;
 LevelDecoration *_5C3420_pDecoration;
 
-LEVEL_TYPE uCurrentlyLoadedLevelType;
+LEVEL_TYPE uCurrentlyLoadedLevelType = LEVEL_null;
 
 stru320 stru_F8AD28; // idb
 stru337 stru_F81018;
@@ -88,9 +88,9 @@
       SLOWORD(pBLVRenderParams->vPartyPos.z),
       SLOWORD(pBLVRenderParams->uRadius),
       v5,
-      floorf(pParty->flt_TorchlightColorR),
-      floorf(pParty->flt_TorchlightColorG),
-      floorf(pParty->flt_TorchlightColorB),
+      floorf(pParty->flt_TorchlightColorR + 0.5f),
+      floorf(pParty->flt_TorchlightColorG + 0.5f),
+      floorf(pParty->flt_TorchlightColorB + 0.5f),
       v1);
   }
   PrepareWallsRenderList_BLV();
@@ -3264,8 +3264,7 @@
   pSoundList->_4A9A67(89, v5);
   return 0;
 }
-// 6807E0: using guessed type int _6807E0_num_decorations_6807B8;
-// 6BE364: using guessed type int dword_6BE364_game_settings_1;
+
 
 //----- (0049AC17) --------------------------------------------------------
 int IndoorLocation::GetSector(int sX, int sY, int sZ)
--- a/Indoor.h	Wed Oct 10 14:21:15 2012 +0200
+++ b/Indoor.h	Wed Oct 10 19:10:15 2012 +0200
@@ -8,6 +8,7 @@
 /*  319 */
 enum LEVEL_TYPE
 {
+  LEVEL_null = 0,
   LEVEL_Indoor = 0x1,
   LEVEL_Outdoor = 0x2,
 };
--- a/IndoorCameraD3D.cpp	Wed Oct 10 14:21:15 2012 +0200
+++ b/IndoorCameraD3D.cpp	Wed Oct 10 19:10:15 2012 +0200
@@ -641,10 +641,10 @@
         {
           LODWORD(a7) = *((int *)v13 - 3);
           //v25 = a7 + 6.7553994e15;
-          auto _v25 = floorf(a7);
+          auto _v25 = floorf(a7 + 0.5f);
 
           //v24 = *((float *)v13 - 4) + 6.7553994e15;
-          auto _v24 = floorf(*((float *)v13 - 4));
+          auto _v24 = floorf(*((float *)v13 - 4) + 0.5f);
 
           v14 = *(int *)v13;
           v15 = *(int *)v13;
--- a/LOD.cpp	Wed Oct 10 14:21:15 2012 +0200
+++ b/LOD.cpp	Wed Oct 10 19:10:15 2012 +0200
@@ -1630,17 +1630,16 @@
 //----- (00461EE9) --------------------------------------------------------
 void LODWriteableFile::CloseWriteFile()
 {
-  FILE **v1; // esi@1
-
-  v1 = (FILE **)this;
-  if ( this->isFileOpened )
+  if (isFileOpened)
   {
-    this->pContainerName[0] = 0;
-    this->uCurrentIndexDir = 0;
-    this->isFileOpened = 0;
+    pContainerName[0] = 0;
+    uCurrentIndexDir = 0;
     _6A0CA8_lod_unused = 0;
-    fflush(this->pFile);
-    fclose(*v1);
+    
+    isFileOpened = false;
+    fflush(pFile);
+    fclose(pFile);
+    pFile = 0;
   }
 }
 // 6A0CA8: using guessed type int 6A0CA8_lod_unused;
@@ -1860,16 +1859,19 @@
   pFile_dup = fopen(pFilename, v10);
   v3->pFile = pFile_dup;
   if ( !pFile_dup )
+  {
+    isFileOpened = false;
     return 0;
-  strcpy((char *)v3->pLODName, pFilename);
-  fread(&v3->header, 0x100u, 1u, v3->pFile);
+  }
+  strcpy(pLODName, pFilename);
+  fread(&header, 0x100u, 1u, v3->pFile);
   
   LOD::Directory dir; // [sp+Ch] [bp-20h]@5
   //LOD::Directory::LOD::Directory(&dir);
 
   fread(&dir, 0x20u, 1u, v3->pFile);
   fseek(v3->pFile, 0, 0);
-  v3->isFileOpened = 1;
+  isFileOpened = 1;
   strcpy((char *)v3->pContainerName, "chapter");
   v5 = (signed __int16)dir.uNumSubIndices;
   v6 = dir.uOfsetFromSubindicesStart;
@@ -1878,7 +1880,7 @@
   v7 = v3->pFile;
   v3->uNumSubIndices = v5;
   v3->uLODDataSize = dir.uDataSize;
-  fseek(v7, v6, 0);
+  fseek(v7, v6, SEEK_SET);
   v8 = v3->uNumSubIndices;
   if ( (signed int)v8 > 300 )
   {
@@ -1886,7 +1888,7 @@
     fclose(v3->pFile);
     return 0;
   }
-  fread(v3->pSubIndices, 0x20u, v8, v3->pFile);
+  fread(pSubIndices, 0x20u, v8, v3->pFile);
   return 1;
 }
 
@@ -2064,7 +2066,8 @@
 
 //----- (0046175B) --------------------------------------------------------
 LOD::File::File():
-  pRoot(nullptr)
+  pRoot(nullptr),
+  isFileOpened(false)
 {
   LOD::File *v1; // esi@1
 
@@ -2231,41 +2234,33 @@
 //----- (00461580) --------------------------------------------------------
 FILE *LOD::File::FindContainer(const char *pContainerName, bool bLinearSearch)
 {
-  LOD::File *this_dup; // esi@1
   unsigned int v4; // eax@4
-  signed int v5; // edi@5
-  int bLinearSearcha; // [sp+18h] [bp+Ch]@6
-
-  this_dup = this;
-  if ( !this->isFileOpened )
+  if (!isFileOpened)
     return 0;
-  if ( bLinearSearch )
+
+
+  if (bLinearSearch)
   {
-    v5 = 0;
-    if ( (signed int)this->uNumSubIndices > 0 )
-    {
-      bLinearSearcha = 0;
-      while ( _strcmpi((const char *)pContainerName, (const char *)&this_dup->pSubIndices[bLinearSearcha]) )
+    for (uint i = 0; i < uNumSubIndices; ++i)
+      if (!strcmpi(pContainerName, pSubIndices[i].pFilename))
       {
-        ++bLinearSearcha;
-        ++v5;
-        if ( v5 >= (signed int)this_dup->uNumSubIndices )
-          return 0;
+        v4 = pSubIndices[i].uOfsetFromSubindicesStart;
+        fseek(pFile, uOffsetToSubIndex + v4, SEEK_SET);
+        return pFile;
       }
-      v4 = this_dup->pSubIndices[v5].uOfsetFromSubindicesStart;
-      goto LABEL_12;
-    }
-    return 0;
+
+    return nullptr;
   }
-  CalcIndexFast(0, this->uNumSubIndices, pContainerName);
-  if ( _6A0CA4_lod_binary_search < 0 )
-    return 0;
-  v4 = this_dup->pSubIndices[_6A0CA4_lod_binary_search].uOfsetFromSubindicesStart;
-LABEL_12:
-  fseek(this_dup->pFile, this_dup->uOffsetToSubIndex + v4, 0);
-  return this_dup->pFile;
+  else
+  {
+    CalcIndexFast(0, uNumSubIndices, pContainerName);
+    if ( _6A0CA4_lod_binary_search < 0 )
+      return 0;
+    v4 = pSubIndices[_6A0CA4_lod_binary_search].uOfsetFromSubindicesStart;
+    fseek(pFile, uOffsetToSubIndex + v4, SEEK_SET);
+    return pFile;
+  }
 }
-// 6A0CA4: using guessed type int _6A0CA4_lod_binary_search;
 
 //----- (0041097D) --------------------------------------------------------
 void LODFile_IconsBitmaps::SetupPalettes(unsigned int uTargetRBits, unsigned int uTargetGBits, unsigned int uTargetBBits)
--- a/LOD.h	Wed Oct 10 14:21:15 2012 +0200
+++ b/LOD.h	Wed Oct 10 19:10:15 2012 +0200
@@ -41,7 +41,7 @@
     Directory *Reset();
 
 
-    unsigned __int8 pFilename[16];
+    char pFilename[16];
     unsigned int uOfsetFromSubindicesStart;
     unsigned int uDataSize;
     int dword_000018;
@@ -103,7 +103,7 @@
   bool _4621A7();
   int _461492(LOD::FileHeader *pHeader, LOD::Directory *pDir, const char *Source);
 
-  FILE *pFile;
+  /*FILE *pFile;
   char pLODName[256];
   unsigned int isFileOpened;
   unsigned __int8 *pIOBuffer;
@@ -116,7 +116,7 @@
   unsigned int uNumSubIndices;
   struct LOD::Directory *pSubIndices;
   unsigned int uOffsetToSubIndex;
-  FILE *pOutputFileHandle;
+  FILE *pOutputFileHandle;*/
 };
 #pragma pack(pop)
 
@@ -147,7 +147,7 @@
   void _4355F7();
 
 
-  FILE *pFile;
+  /*FILE *pFile;
   unsigned __int8 pLODName[256];
   unsigned int isFileOpened;
   unsigned __int8 *pIOBuffer;
@@ -160,7 +160,7 @@
   unsigned int uNumSubIndices;
   struct LOD::Directory *pSubIndices;
   unsigned int uOffsetToSubIndex;
-  FILE *pOutputFileHandle;
+  FILE *pOutputFileHandle;*/
   struct Texture pTextures[1000];
   unsigned int uNumLoadedFiles;
   int dword_11B80;
@@ -236,7 +236,7 @@
   void MoveSpritesToVideoMemory();
 
 
-  FILE *pFile;
+  /*FILE *pFile;
   unsigned __int8 pLODName[256];
   unsigned int isFileOpened;
   unsigned __int8 *pIOBuffer;
@@ -249,7 +249,7 @@
   unsigned int uNumSubIndices;
   struct LOD::Directory *pSubIndices;
   unsigned int uOffsetToSubIndex;
-  FILE *pOutputFileHandle;
+  FILE *pOutputFileHandle;*/
   struct LODSprite pSpriteHeaders[1500];
   unsigned int uNumLoadedSprites;
   int field_ECA0;
--- a/LightmapBuilder.cpp	Wed Oct 10 14:21:15 2012 +0200
+++ b/LightmapBuilder.cpp	Wed Oct 10 19:10:15 2012 +0200
@@ -169,9 +169,9 @@
       a6 = *((float *)v19 + 120) * 255.0;
       //v31 = a6 + 6.7553994e15;
       //v38 = __PAIR__(LODWORD(v32), LODWORD(v31));
-      v38 = __PAIR__((int)floorf(a6), (int)floorf(a6));
+      v38 = __PAIR__((int)floorf(a6 + 0.5f), (int)floorf(a6 + 0.5f));
       //v22 = LODWORD(v31) | ((LODWORD(v32) | (LODWORD(v33) << 8)) << 8);
-      v22 = (int)floorf(a6) | (((int)floorf(a6) | ((int)floorf(a6) << 8)) << 8);
+      v22 = (int)floorf(a6 + 0.5f) | (((int)floorf(a6 + 0.5f) | ((int)floorf(a6 + 0.5f) << 8)) << 8);
       if (!v22)
         v22 = 0x00FFFFFF;
       v27 = a7;
@@ -363,13 +363,13 @@
     a1.Normalize();
     //v64 = v62 + 6.7553994e15;
     //LODWORD(a5) = LODWORD(v64);
-    LODWORD(a5) = floorf(v62);
+    LODWORD(a5) = floorf(v62 + 0.5f);
     //v64 = v61 + 6.7553994e15;
     //arg0c = LODWORD(v64);
-    arg0c = floorf(v61);
+    arg0c = floorf(v61 + 0.5f);
     //v64 = v60 + 6.7553994e15;
     //arg8 = LODWORD(v64);
-    arg8 = floorf(v60);
+    arg8 = floorf(v60 + 0.5f);
     auto v64 /*HIDWORD(v64)*/ = abs(*(int *)(v25 + 8) - (signed)LODWORD(a5));
     arg0a = abs(*(int *)(v25 + 4) - arg0c);
     v31 = abs(*(int *)v25 - arg8);
@@ -847,7 +847,7 @@
     stru_F8AD28._blv_lights_gs[*pSlot] = (double)pLight->uLightColorG * 0.0039215689;
     stru_F8AD28._blv_lights_bs[*pSlot] = (double)pLight->uLightColorB * 0.0039215689;
     //pLighta = v13;
-    stru_F8AD28._blv_lights_light_dot_faces[*pSlot] = abs((int)floorf(v13));//COERCE_UNSIGNED_INT64(pLighta + 6.7553994e15));
+    stru_F8AD28._blv_lights_light_dot_faces[*pSlot] = abs((int)floorf(v13 + 0.5f));//COERCE_UNSIGNED_INT64(pLighta + 6.7553994e15));
     result = (BLVFace *)*pSlot;
     stru_F8AD28._blv_lights_smthngs[(*pSlot)++] = v7->field_B;
     LOBYTE(result) = 1;
@@ -1041,13 +1041,13 @@
   v7 = a5;
   LODWORD(a5) = *(unsigned int *)(LODWORD(a5) + 8);
   //v24 = a5 + 6.7553994e15;
-  v26 = floorf(a5);//LODWORD(v24);
+  v26 = floorf(a5 + 0.5f);//LODWORD(v24);
   LODWORD(a5) = *(unsigned int *)(LODWORD(v7) + 4);
   //v24 = a5 + 6.7553994e15;
-  auto _v24 = floorf(a5);
+  auto _v24 = floorf(a5 + 0.5f);
   LODWORD(a5) = *(unsigned int *)LODWORD(v7);
   //v23 = a5 + 6.7553994e15;
-  auto _v23 = floorf(a5);
+  auto _v23 = floorf(a5 + 0.5f);
   //*(_QWORD *)((char *)&v24 + 4) = __PAIR__(LODWORD(v24), LODWORD(v23));
   v26 = abs((signed)LODWORD(a1.z) - v26);
   //v25 = abs((signed)LODWORD(a1.y) - (signed)LODWORD(v24));
@@ -1644,11 +1644,11 @@
       a5a = ((double)a1->field_A - v15->field_2C) * v15->field_4 + v15->field_24 - 0.5;
       //v20 = a5a + 6.7553994e15;
       //a5b = (double)SLODWORD(v20);
-      a5b = (double)floorf(a5a);
+      a5b = (double)floorf(a5a + 0.5f);
       a1a = ((double)a1->field_A - *(float *)(v14 + 44)) * *(float *)(v14 + 4) + *(float *)(v14 + 36) + 0.5;
       //v21 = a1a + 6.7553994e15;
       //v22 = (double)SLODWORD(v21);
-      v22 = (double)floorf(a1a);
+      v22 = (double)floorf(a1a + 0.5f);
       result = v9->field_8;
       v23 = v9->field_C;
       v24 = -((a3a - a2a) / (v22 - a5b));
@@ -2001,7 +2001,7 @@
     a1c = (double)a1b * v4->flt_C14 * arg4->x;
     //v29 = a1c + 6.7553994e15;
     //arg4a = LODWORD(v29);
-    arg4a = floorf(a1c);
+    arg4a = floorf(a1c + 0.5f);
 
     a1d = v6 * v7->y;
     v29 = a1d + 6.7553994e15;
--- a/Might and Magic Trilogy.vcxproj.filters	Wed Oct 10 14:21:15 2012 +0200
+++ b/Might and Magic Trilogy.vcxproj.filters	Wed Oct 10 19:10:15 2012 +0200
@@ -314,5 +314,6 @@
     <ClCompile Include="mm7_5.cpp" />
     <ClCompile Include="FrameTableInc.cpp" />
     <ClCompile Include="mm7_6.cpp" />
+    <ClCompile Include="GameUIs.cpp" />
   </ItemGroup>
 </Project>
\ No newline at end of file
--- a/OutdoorCamera.h	Wed Oct 10 14:21:15 2012 +0200
+++ b/OutdoorCamera.h	Wed Oct 10 19:10:15 2012 +0200
@@ -8,6 +8,11 @@
   //----- (00462684) --------------------------------------------------------
   OutdoorCamera()
   {
+    uPickDepth = 0;
+    this->shading_dist_shade = 2048;
+    shading_dist_shademist = 4096;
+    shading_dist_mist = 8192;
+    int_fov_rad = 0;
     this->bNoSky = 0;
     this->bDoNotRenderDecorations = 0;
     this->field_5C = 0;
--- a/Party.cpp	Wed Oct 10 14:21:15 2012 +0200
+++ b/Party.cpp	Wed Oct 10 19:10:15 2012 +0200
@@ -512,7 +512,7 @@
 //----- (004917CE) --------------------------------------------------------
 int Party::Reset()
 {
-  Party *v1; // esi@1
+  //Party *v1; // esi@1
   unsigned __int64 *pTimePlayed; // edi@1
   bool v3; // edx@1
   Player **v4; // eax@1
@@ -532,27 +532,27 @@
   int v18; // edx@24
   Player *v19; // eax@24
 
-  v1 = this;
-  pTimePlayed = &this->uTimePlayed;
-  memset(&this->uTimePlayed, 0, 0x1620Cu);
-  v1->field_708 = 15;
-  pParty->sEyelevel = 160;
+  //v1 = this;
+  pTimePlayed = &uTimePlayed;
+  //memset(&this->uTimePlayed, 0, 0x1620Cu);
+  field_708 = 15;
+  sEyelevel = 160;
   LOBYTE(v3) = 1;
-  v1->uFlags2 = 0;
-  v1->uNumGold = 200;
-  v1->uNumGoldInBank = 0;
-  v1->uNumFoodRations = 7;
-  v1->uAlignment = 1;
+  uFlags2 = 0;
+  uNumGold = 200;
+  uNumGoldInBank = 0;
+  uNumFoodRations = 7;
+  uAlignment = 1;
   SetUserInterface(1, v3);
   *((int *)pTimePlayed + 1) = 0;
   *(int *)pTimePlayed = 0x21C00u;
-  LODWORD(v1->uLastRegenerationTime) = 0x21C00u;
-  HIDWORD(v1->uLastRegenerationTime) = 0;
-  v1->bTurnBasedModeOn = 0;
+  LODWORD(uLastRegenerationTime) = 0x21C00;
+  HIDWORD(uLastRegenerationTime) = 0;
+  bTurnBasedModeOn = 0;
   uActiveCharacter = 1;
-  ::pPlayers[0] = v1->pPlayers;
+  ::pPlayers[0] = pPlayers;
   v4 = &::pPlayers[1];
-  v5 = v1->pPlayers;
+  v5 = pPlayers;
   do
   {
     *v4 = v5;
@@ -564,12 +564,12 @@
   pPlayers[0].Reset(4u);
   pPlayers[0].Reset(0x18u);
   pPlayers[0].Reset(0x20u);
-  v1->pPlayers[0].uFace = 17;
-  v1->pPlayers[0].field_1924 = 17;
-  v1->pPlayers[0].uVoiceID = 17;
-  v1->pPlayers[0].SetInitialStats();
+  pPlayers[0].uFace = 17;
+  pPlayers[0].field_1924 = 17;
+  pPlayers[0].uVoiceID = 17;
+  pPlayers[0].SetInitialStats();
   v6 = 0;
-  switch ( v1->pPlayers[0].uVoiceID )
+  switch ( pPlayers[0].uVoiceID )
   {
     case 0u:
     case 1u:
@@ -602,15 +602,15 @@
     default:
       break;
   }
-  v1->pPlayers[0].uSex = v6;
-  v1->pPlayers[0].RandomizeName();
-  strcpy(v1->pPlayers[0].pName, pGlobalTXT_LocalizationStrings[509]);
-  v1->pPlayers[1].uFace = 3;
-  v1->pPlayers[1].field_1924 = 3;
-  v1->pPlayers[1].uVoiceID = 3;
-  v1->pPlayers[1].SetInitialStats();
+  pPlayers[0].uSex = v6;
+  pPlayers[0].RandomizeName();
+  strcpy(pPlayers[0].pName, pGlobalTXT_LocalizationStrings[509]);
+  pPlayers[1].uFace = 3;
+  pPlayers[1].field_1924 = 3;
+  pPlayers[1].uVoiceID = 3;
+  pPlayers[1].SetInitialStats();
   v7 = 0;
-  switch ( v1->pPlayers[1].uVoiceID )
+  switch (pPlayers[1].uVoiceID)
   {
     case 0u:
     case 1u:
@@ -645,13 +645,13 @@
   }
   pPlayers[1].uSex = v7;
   pPlayers[1].RandomizeName();
-  strcpy(v1->pPlayers[1].pName, pGlobalTXT_LocalizationStrings[506]);
+  strcpy(pPlayers[1].pName, pGlobalTXT_LocalizationStrings[506]);
   pPlayers[2].uFace = 14;
   pPlayers[2].field_1924 = 14;
   pPlayers[2].uVoiceID = 14;
   pPlayers[2].SetInitialStats();
   v8 = 0;
-  switch ( v1->pPlayers[2].uVoiceID )
+  switch (pPlayers[2].uVoiceID)
   {
     case 0u:
     case 1u:
@@ -686,13 +686,13 @@
   }
   pPlayers[2].uSex = v8;
   pPlayers[2].RandomizeName();
-  strcpy(v1->pPlayers[2].pName, pGlobalTXT_LocalizationStrings[508]);
+  strcpy(pPlayers[2].pName, pGlobalTXT_LocalizationStrings[508]);
   pPlayers[3].uFace = 10;
   pPlayers[3].field_1924 = 10;
   pPlayers[3].uVoiceID = 10;
   pPlayers[3].SetInitialStats();
   v9 = 0;
-  switch ( v1->pPlayers[3].uVoiceID )
+  switch (pPlayers[3].uVoiceID)
   {
     case 0u:
     case 1u:
@@ -725,9 +725,9 @@
     default:
       break;
   }
-  v1->pPlayers[3].uSex = v9;
+  pPlayers[3].uSex = v9;
   pPlayers[3].RandomizeName();
-  strcpy(v1->pPlayers[3].pName, pGlobalTXT_LocalizationStrings[507]);
+  strcpy(pPlayers[3].pName, pGlobalTXT_LocalizationStrings[507]);
   v10 = &::pPlayers[1];
   do
   {
@@ -751,7 +751,7 @@
     ++v10;
   }
   while ( (signed int)v10 <= (signed int)&pPlayers[4] );
-  v14 = &v1->pPartyBuffs[1];
+  v14 = &pPartyBuffs[1];
   v15 = 19;
   do
   {
@@ -761,8 +761,8 @@
   }
   while ( v15 );
   pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 100;
-  v1->uFlags = 0;
-  v16 = (char *)v1->_award_bits;
+  uFlags = 0;
+  v16 = (char *)_award_bits;
   _449B7E_toggle_bit(v16, 1, 1u);
   _449B7E_toggle_bit(v16, 2, 1u);
   _449B7E_toggle_bit(v16, 3, 1u);
--- a/Render.cpp	Wed Oct 10 14:21:15 2012 +0200
+++ b/Render.cpp	Wed Oct 10 19:10:15 2012 +0200
@@ -9846,12 +9846,12 @@
 
 
 //----- (004A6AB1) --------------------------------------------------------
-void Render::DrawTextPalette(signed int a2, signed int a3, int a4, int a5, unsigned int a6, unsigned __int16 *pPalette, int a8)
+void Render::DrawTextPalette(int x, int y, int a4, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8)
 {
   int v8; // edi@2
   unsigned int v9; // esi@2
   unsigned __int16 *v10; // eax@2
-  int v11; // edx@2
+  unsigned char *v11; // edx@2
   unsigned int v12; // ebx@3
   signed int v13; // edx@5
   int v14; // edx@6
@@ -9872,12 +9872,15 @@
   unsigned int v29; // [sp+24h] [bp+14h]@22
   unsigned int v30; // [sp+24h] [bp+14h]@31
 
+  auto a2 = x;
+  auto a3 = y;
+  auto a6 = uFontHeight;
   if ( this->uNumSceneBegins )
   {
     v8 = a5;
     v9 = a6;
-    v10 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
-    v11 = a4;
+    v10 = &pTargetSurface[x + y * uTargetSurfacePitch];
+    v11 = (unsigned char *)a4;
     v25 = a4;
     if ( this->bClip )
     {
@@ -9918,7 +9921,7 @@
           v20 = a3;
         v9 = v19 - v20;
       }
-      v11 = v25;
+      v11 = (unsigned char *)v25;
     }
     if ( a8 )
     {
@@ -9934,8 +9937,8 @@
             v27 = v8;
             do
             {
-              if ( *(char *)v11 )
-                v24 = pPalette[*(char *)v11];
+              if ( *v11 )
+                v24 = pPalette[*v11];
               else
                 v24 = v28;
               *v10 = v24;
@@ -9965,8 +9968,8 @@
             v26 = v8;
             do
             {
-              if ( *(char *)v11 )
-                *v10 = pPalette[*(char *)v11];
+              if ( *v11 )
+                *v10 = pPalette[*v11];
               ++v10;
               ++v11;
               --v26;
--- a/Render.h	Wed Oct 10 14:21:15 2012 +0200
+++ b/Render.h	Wed Oct 10 19:10:15 2012 +0200
@@ -324,7 +324,7 @@
   void _4A6776(unsigned int a2, unsigned int a3, Texture *a4);
   void DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture);
   void _4A6A68(unsigned int a2, unsigned int a3, Texture *a4, __int16 height);
-  void DrawTextPalette(signed int a2, signed int a3, int a4, int a5, unsigned int a6, unsigned __int16 *pPalette, int a8);
+  void DrawTextPalette(int x, int y, int a4, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8);
   void DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned __int16 *pFontPalette, unsigned __int16 uFaceColor, unsigned __int16 uShadowColor);
   void FillRect2(int uX, int uY, int a4, unsigned int a5, int a6, unsigned __int16 a7);
   int _4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, struct Vec2_int_ *pBitmapXY, unsigned __int16 *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7);
--- a/SaveLoad.cpp	Wed Oct 10 14:21:15 2012 +0200
+++ b/SaveLoad.cpp	Wed Oct 10 19:10:15 2012 +0200
@@ -9,40 +9,37 @@
 
 
 
+struct SavegameList *pSavegameList = new SavegameList;
 unsigned int uNumSavegameFiles;
 unsigned int pSavegameUsedSlots[45];
-struct SavegameList *pSavegameList;
-struct RGBTexture *pSavegameThumbnails;
+struct RGBTexture *pSavegameThumbnails = new RGBTexture[45];
+SavegameHeader *pSavegameHeader = new SavegameHeader[45];
 
 
 
 //----- (0045E297) --------------------------------------------------------
-void SavegameList::Initialize(unsigned int a1)
+void SavegameList::Initialize(unsigned int bHideEmptySlots)
 {
-  signed int v1; // edi@4
-  unsigned int v2; // eax@6
-  unsigned int v3; // [sp+10h] [bp-4h]@1
-
-  v3 = a1;
-  memset(&pSavegameList, 0, 0x3138u);
-  _chdir("saves");
   uNumSavegameFiles = 0;
-  if ( !v3 && _access(pGlobalTXT_LocalizationStrings[613], 0) != -1 )
-    strcpy(pSavegameList->pSavesNames[uNumSavegameFiles++], pGlobalTXT_LocalizationStrings[613]);
-  v1 = 0;
-  do
+
+  _chdir("saves");
   {
-    sprintfex(pTmpBuf, "save%03d.mm7", v1);
-    if ( _access(pTmpBuf, 0) != -1 )
+    if (!bHideEmptySlots && _access(pGlobalTXT_LocalizationStrings[613], 0) != -1 )
+      strcpy(pSavesNames[uNumSavegameFiles++], pGlobalTXT_LocalizationStrings[613]);
+
+    for (uint i = 0; i < 40; ++i)
     {
-      v2 = v1;
-      if ( !v3 )
-        v2 = uNumSavegameFiles;
-      strcpy(pSavegameList->pSavesNames[v2], pTmpBuf);
+      sprintf(pTmpBuf, "save%03d.mm7", i);
+      if (_access(pTmpBuf, 0) == -1)
+        continue;
+
+      uint idx = i;
+      if (!bHideEmptySlots)
+        idx = uNumSavegameFiles;
+      strcpy(pSavesNames[idx], pTmpBuf);
+
       ++uNumSavegameFiles;
     }
-    ++v1;
   }
-  while ( v1 < 40 );
   _chdir("..");
 }
\ No newline at end of file
--- a/SaveLoad.h	Wed Oct 10 14:21:15 2012 +0200
+++ b/SaveLoad.h	Wed Oct 10 19:10:15 2012 +0200
@@ -6,7 +6,7 @@
 #pragma pack(push, 1)
 struct SavegameList
 {
-  static void Initialize(unsigned int a1);
+  void Initialize(unsigned int a1);
 
   char field_0[20];
   char pSavesNames[40][280];
--- a/VideoPlayer.cpp	Wed Oct 10 14:21:15 2012 +0200
+++ b/VideoPlayer.cpp	Wed Oct 10 19:10:15 2012 +0200
@@ -258,7 +258,7 @@
   DrawCopyrightWindow();
   pRenderer->EndScene();
   pRenderer->Present();
-  if ( !(dword_6BE364_game_settings_1 & 0x10) && pAudioPlayer->hAILRedbook )
+  if (!bNoSound && pAudioPlayer->hAILRedbook )
   {
     pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0));
     AIL_redbook_stop(pAudioPlayer->hAILRedbook);
@@ -821,11 +821,7 @@
     Unload();
   pRenderer->EndScene();
 }
-// 4D83D0: using guessed type int __stdcall SmackBufferNewPalette(int, int, int);
-// 4D83D4: using guessed type int __stdcall SmackColorRemapWithTrans(int, int, int, int, int);
-// 4D83E4: using guessed type int __stdcall SmackDoFrame(int);
-// 4D83E8: using guessed type int __stdcall SmackNextFrame(int);
-// 4D8400: using guessed type int __stdcall SmackToBuffer(int, int, int, int, int, int, int);
+
 
 //----- (004BF141) --------------------------------------------------------
 _BINK *VideoPlayer::OpenBink(const char *pName)
--- a/Vis.cpp	Wed Oct 10 14:21:15 2012 +0200
+++ b/Vis.cpp	Wed Oct 10 19:10:15 2012 +0200
@@ -428,6 +428,8 @@
   v24 = 0;
   v26 = 0;
   a1.flt_2C = 0.0;
+  if (!pOutdoor)
+    return;
   if ( (signed int)pOutdoor->uNumBModels > 0 )
   {
     v25 = 0;
@@ -1606,7 +1608,7 @@
   this->stru1.uNumPointers = 0;
   CastPickRay(pMouseRay, fMouseX, fMouseY, fDepth);
   PickBillboards(fDepth, fMouseX, fMouseY, &v6->stru1, a5);
-  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+  if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
     PickIndoor(fDepth, pMouseRay, &v6->stru1, a6);
   else
     PickOutdoor(fDepth, pMouseRay, &v6->stru1, a6, 0);
--- a/mm7_1.cpp	Wed Oct 10 14:21:15 2012 +0200
+++ b/mm7_1.cpp	Wed Oct 10 19:10:15 2012 +0200
@@ -3977,8 +3977,8 @@
     v9 = v3;
     v8 = (double)v3 * 0.001953125 * 120.0;
     //v7 = v8 + 6.7553994e15;
-    HIDWORD(v9) = floorf(v8);//LODWORD(v7);
-    v4 = (int)floorf(v8) % 256 + 1;//LOBYTE(v7) + 1;
+    HIDWORD(v9) = floorf(v8 + 0.5f);//LODWORD(v7);
+    v4 = (int)floorf(v8 + 0.5f) % 256 + 1;//LOBYTE(v7) + 1;
     byte_4E2BC8 = v4;
     if ( (unsigned __int8)(v4) >= 0x78u )
     {
--- 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)
--- a/mm7_3.cpp	Wed Oct 10 14:21:15 2012 +0200
+++ b/mm7_3.cpp	Wed Oct 10 19:10:15 2012 +0200
@@ -20689,7 +20689,7 @@
       v5 = pIcons_LOD->LoadTexture(v3, TEXTURE_16BIT_PALETTE);
       if ( v5 == -1 )
       {
-        sprintfex(pTmpBuf, "Unable to open %s", v3);
+        sprintf(pTmpBuf, "Unable to open %s", v3);
         Abortf(pTmpBuf);
       }
       ++v4;
--- a/mm7_4.cpp	Wed Oct 10 14:21:15 2012 +0200
+++ b/mm7_4.cpp	Wed Oct 10 19:10:15 2012 +0200
@@ -2860,20 +2860,14 @@
 //----- (0048B561) --------------------------------------------------------
 int _48B561_mess_with_scaling_along_z(/*int a1, */float a2)
 {
-  float v2; // ST08_4@1
-  double v3; // ST00_8@1
-  int v4; // ST0C_4@1
-  double v5; // ST00_8@1
-  float v7; // [sp+18h] [bp+8h]@1
-
-  __debugbreak(); // check parameters carefully
-
-  v2 = a2 - 0.5;
-  v3 = v2 + 6.7553994e15;
-  v4 = LODWORD(v3);
-  v7 = (a2 - (double)SLODWORD(v3)) * 65536.0;
-  v5 = v7 + 6.7553994e15;
-  return LODWORD(v5) | (v4 << 16);
+  //v2 = a2 - 0.5;
+  //v3 = v2 + 6.7553994e15;
+  int v4 = floorf(a2 - 0.5f + 0.5f);
+  //v7 = (a2 - (double)SLODWORD(v3)) * 65536.0;
+  //v5 = v7 + 6.7553994e15;
+  //return LODWORD(v5) | (v4 << 16);
+  int v5 = floorf((a2 - v4) * 65536.0f + 0.5f);
+  return v5 | (v4 << 16);
 }
 
 
@@ -6739,7 +6733,7 @@
   unsigned int teal; // eax@19
   //Texture v12; // [sp+Ch] [bp-130h]@5
   //RGBTexture v16; // [sp+54h] [bp-E8h]@1
-  double v15; // [sp+7Ch] [bp-C0h]@9
+  //double v15; // [sp+7Ch] [bp-C0h]@9
   MSG Msg; // [sp+84h] [bp-B8h]@10
   int v17; // [sp+A0h] [bp-9Ch]@9
   int a2; // [sp+A4h] [bp-98h]@9
@@ -6769,7 +6763,7 @@
   if ( !pIcons_LOD->uNumPrevLoadedFiles )
     pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
   dword_A74C88 = 0;
-  pAudioPlayer->PlayMusicTrack(0xFu);
+  pAudioPlayer->PlayMusicTrack(MUSIC_Credits);
   v16.Load("mm6title.pcx", 0);
   v0 = (char *)pEvents_LOD->LoadRaw("credits.txt", 0);
   v1 = v0;
@@ -6803,7 +6797,8 @@
   v21.pPixels = (unsigned __int16 *)v7;
   v9 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0xFFu);
   fill_pixels_fast(v9, v21.pPixels, v8);
-  *(int *)&v21.field_20 = 0;
+  v21.field_20 = 0;
+  v21.field_22 = 0;
   a7 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x70u, 0x8Fu, 0xFEu);
   a8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xECu, 0xE6u, 0x9Cu);
   pString = (char *)operator new(2 * v3);
@@ -6832,10 +6827,10 @@
     v21.pPixels,
     (signed __int16)v21.uWidth);
   free(pString);
-  pWindow_Credits = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, (int)ptr);
-  pWindow_Credits->CreateButton(0, 0, 0, 0, 1, 0, 0x71u, 0, 0x1Bu, nullstring, 0);
+  pWindow_MainMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, (int)ptr);
+  pWindow_MainMenu->CreateButton(0, 0, 0, 0, 1, 0, 0x71u, 0, 0x1Bu, nullstring, 0);
   uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 9;
-  SetCurrentMenuID(8u);
+  SetCurrentMenuID(MENU_Credits);
   pRenderer->BeginScene();
   pRenderer->DrawTextureRGB(0, 0, &v16);
   pRenderer->Clip(a2, a3, a2 + v20, a3 + a4);
@@ -6843,8 +6838,8 @@
   pRenderer->ResetClip();
   pRenderer->EndScene();
   pString = (char *)0x447A0000;
-  v15 = 1000.0 + 6.7553994e15;
-  v17 = LODWORD(v15);
+  //v15 = 1000.0 + 6.7553994e15;
+  v17 = floorf(1000.0f + 0.5f);//(v15);
   GetTickCount();
   pRenderer->Present();
   do
@@ -6928,11 +6923,11 @@
   pAllocator->FreeChunk(ptr);
   pAllocator->FreeChunk(pFontQuick);
   pAllocator->FreeChunk(pFontCChar);
-  pWindow_Credits->Release();
+  pWindow_MainMenu->Release();
   pIcons_LOD->_4114F2();
   v16.Release();
   v21.Release();
-  return (MENU_STATE)(GetCurrentMenuID() - (int)MENU_Credits);     // return MENU_Main
+  return MENU_MAIN;     // return MENU_Main
 }
 
 
--- a/mm7_5.cpp	Wed Oct 10 14:21:15 2012 +0200
+++ b/mm7_5.cpp	Wed Oct 10 19:10:15 2012 +0200
@@ -3426,6 +3426,37 @@
     do
     {
       pMessageQueue_50CBD0->PopMessage(&v45, (int *)uClass, &v46);
+      switch (v45)
+      {
+        case UIMSG_MainMenu_ShowPartyCreationWnd:
+        {
+          GUIWindow::Create(495, 172, 0, 0, WINDOW_5A, (int)pMainMenu_BtnNew, 0);
+          SetCurrentMenuID(MENU_NEWGAME);
+        }
+        continue;
+
+        case UIMSG_MainMenu_ShowLoadWindow:
+        {
+          GUIWindow::Create(495, 227, 0, 0, WINDOW_5A, (int)pMainMenu_BtnLoad, 0);
+          SetCurrentMenuID(MENU_SAVELOAD);
+        }
+        continue;
+
+        case UIMSG_ShowCredits:
+        {
+          GUIWindow::Create(495, 282, 0, 0, WINDOW_5A, (int)pMainMenu_BtnCredits, 0);
+          SetCurrentMenuID(MENU_CREDITS);
+        }
+        continue;
+
+        case UIMSG_ExitToWindows:
+        {
+          GUIWindow::Create(495, 337, 0, 0, WINDOW_5A, (int)pMainMenu_BtnExit, 0);
+          SetCurrentMenuID(MENU_FINISHED);
+        }
+        continue;
+      }
+
       if ( (signed int)v45 > 75 )
       {
         if ( v45 > UIMSG_A3 )
@@ -3886,30 +3917,6 @@
               pMouse->SetCursorBitmap("MICON2");
               break;
             default:
-              if ( v45 == 54 )
-              {
-                GUIWindow::Create(0x1EFu, 0xACu, 0, 0, (enum WindowType)90, (int)pMainMenu_BtnNew, 0);
-                v2 = 1;
-                goto LABEL_90;
-              }
-              if ( v45 == 55 )
-              {
-                GUIWindow::Create(0x1EFu, 0xE3u, 0, 0, (enum WindowType)90, (int)pMainMenu_BtnLoad, 0);
-                v40 = 3;
-                goto LABEL_89;
-              }
-              if ( v45 == 56 )
-              {
-                GUIWindow::Create(0x1EFu, 0x11Au, 0, 0, (enum WindowType)90, (int)pMainMenu_BtnCredits, 0);
-                v40 = 2;
-                goto LABEL_89;
-              }
-              if ( v45 == UIMSG_ExitToWindows )
-              {
-                GUIWindow::Create(0x1EFu, 0x151u, 0, 0, (enum WindowType)90, (int)pMainMenu_BtnExit, 0);
-                v40 = 4;
-                goto LABEL_89;
-              }
               if ( v45 == 58 )
                 goto LABEL_114;
               break;
@@ -14910,6 +14917,15 @@
     //v0 = (GUIWindow *)&pWindowList_at_506F50_minus1_indexing[21 * pVisibleWindowsIdxs[i]];
     v0 = &pWindowList[pVisibleWindowsIdxs[i] - 1];
     v1 = v0->eWindowType;
+
+    switch (v0->eWindowType)
+    {
+      case WINDOW_MainMenu_Load:
+        GameUI_MainMenu_DrawLoad();
+        continue;
+    }
+
+
     if ( (signed int)v1 > 70 )
     {
       if ( (signed int)v1 > 95 )
@@ -15268,8 +15284,8 @@
               v9 = v8 - 3;
               if ( v9 )
               {
-                if ( v9 == 1 )
-                  sub_4606F7();
+                //if ( v9 == 1 )
+                //  sub_4606F7();
               }
               else
               {
--- a/mm7_data.cpp	Wed Oct 10 14:21:15 2012 +0200
+++ b/mm7_data.cpp	Wed Oct 10 19:10:15 2012 +0200
@@ -24,7 +24,7 @@
 
 
 #include "Math.h"
-struct stru193_math *stru_5C6E00;
+struct stru193_math *stru_5C6E00 = new stru193_math;
 
 #include "MapInfo.h"
 struct MapStats *pMapStats;
@@ -1390,10 +1390,10 @@
 char byte_4E94D0; // weak
 char byte_4E94D2; // weak
 char byte_4E94D3; // weak
-unsigned int saveload_dlg_xs[2];
-unsigned int saveload_dlg_ys[2];
-unsigned int saveload_dlg_zs[2];
-unsigned int saveload_dlg_ws[2];
+unsigned int saveload_dlg_xs[2] = {82, 0};
+unsigned int saveload_dlg_ys[2] = {60, 0};
+unsigned int saveload_dlg_zs[2] = {460, 640};
+unsigned int saveload_dlg_ws[2] = {344, 480};
 char aEWorkMsdevM_12[777]; // idb
 char a___0[777]; // idb
 char aSave03d_mm7[777]; // idb
@@ -2610,7 +2610,6 @@
 int dword_69B138; // weak
 char byte_69BD41_unused; // weak
 std::string stru_69BD44; // idb
-struct SavegameHeader *pSavegameHeader;
 unsigned int uTextureID_x_u;
 unsigned int uTextureID_LS_saveU;
 unsigned int uTextureID_LS_loadU;
@@ -2642,7 +2641,7 @@
 int texmapping_terrain_subdivpow2; // weak
 int texmapping_building_subdivsize; // weak
 int texmapping_building_subdivpow2; // weak
-int unnamed_6BE060[2];
+int unnamed_6BE060[2] = {0, 1};
 int mipmapping_building_mm1; // weak
 int mipmapping_building_mm2; // weak
 int mipmapping_building_mm3; // weak
@@ -2669,13 +2668,10 @@
 int _6BE134_odm_main_tile_group; // weak
 int dword_6BE138; // weak
 int dword_6BE13C_uCurrentlyLoadedLocationID; // weak
-float fWalkSpeedMultiplier; // weak
-float fBackwardMovementSlowdownMultiplier; // weak
-float fTurnSpeedMultiplier; // weak
-float flt_6BE150_look_up_down_dangle; // weak
-//char pMM7WindowClassName[777]; // idb
-//HINSTANCE hInstance; // idb
-//char *pCmdLine;
+float fWalkSpeedMultiplier = 1.0f; // weak
+float fBackwardMovementSlowdownMultiplier = 1.0f; // weak
+float fTurnSpeedMultiplier = 1.0f; // weak
+float flt_6BE150_look_up_down_dangle = 1.0f; // weak
 HWND hWnd; // idb
 int uWindowWidth; // idb
 int uWindowHeight; // idb
@@ -2687,10 +2683,10 @@
 char pCurrentMapName[20]; // idb
 unsigned int uLevelMapStatsID;
 int uLevel_StartingPointType; // weak
-int dword_6BE364_game_settings_1; // weak
-int dword_6BE368_debug_settings_2; // weak
-unsigned __int8 bUseLoResSprites;
-unsigned __int8 bUseRegistry;
+int dword_6BE364_game_settings_1 = 0; // weak
+int dword_6BE368_debug_settings_2 = 0; // weak
+unsigned __int8 bUseLoResSprites = false;
+unsigned __int8 bUseRegistry = true;
 unsigned __int8 bCanLoadFromCD = false;
 int bShowDamage; // idb
 unsigned int bAlwaysRun;
@@ -2703,14 +2699,17 @@
 float flt_6BE3A8_debug_recmod2;
 float flt_6BE3AC_debug_recmod1_x_1_6;
 char byte_6BE3B0[20]; // idb
-char bUnderwater; // weak
-char bNoNPCHiring; // weak
-int _702AC0_unused; // weak
-int _702AC4_unused; // weak
-char _702ACC_unused; // weak
+char bUnderwater = false; // weak
+char bNoNPCHiring = false; // weak
+int _702AC0_unused = 0; // weak
+int _702AC4_unused = 0; // weak
+char _702ACC_unused = 0; // weak
 int bDebugResouces; // weak
-unsigned int bNoVideo;
+unsigned int bNoVideo = false;
+bool bNoIntro = false;
+bool bNoLogo = false;
 bool bNoCD = false;
+bool bNoSound = false;
 int aborting_app; // weak
 int dword_720020_zvalues[100];
 int dword_7201B0_zvalues[299];
--- a/mm7_data.h	Wed Oct 10 14:21:15 2012 +0200
+++ b/mm7_data.h	Wed Oct 10 19:10:15 2012 +0200
@@ -2699,7 +2699,10 @@
 extern char _702ACC_unused; // weak
 extern int bDebugResouces; // weak
 extern unsigned int bNoVideo;
+extern bool bNoIntro;
+extern bool bNoLogo;
 extern bool bNoCD;
+extern bool bNoSound;
 extern int aborting_app; // weak
 extern int dword_720020_zvalues[100];
 extern int dword_7201B0_zvalues[299];
@@ -3254,8 +3257,8 @@
 void __fastcall LoadGame(unsigned int uSlot); // idb
 int __fastcall SaveGame(int a1, __int16 *a2);
 void __fastcall DoSavegame(unsigned int uSlot); // idb
-void __fastcall sub_4601B7(int a1);
-void __cdecl sub_4606F7();
+void GameUI_MainMenu_DoDrawLoad(int a1);
+void GameUI_MainMenu_DrawLoad();
 void __cdecl sub_4606FE();
 void __cdecl TryLoadLevelFromLOD();
 void __cdecl sub_46080D();