changeset 2152:d44b7775fc06

Removed DirectDraw2 compatibility. 3D Sound enabled (change 3DSoundProvider registry entry to activate it). Moved all forward declarations to mm7_unsorted_subs.h (many cpp files do not need them anyweay).
author Nomad
date Thu, 09 Jan 2014 01:37:34 +0200
parents 92511cd8fcdb
children d28d3c006077
files AudioPlayer.cpp AudioPlayer.h Build/Visual Studio 2012/World of Might and Magic.vcxproj Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters DecalBuilder.cpp GUIWindow.h Game.cpp GammaControl.cpp Indoor.cpp IndoorCameraD3D.cpp Keyboard.cpp Keyboard.h LOD.cpp OSAPI.cpp OSInfo.h OSWindow.cpp Outdoor.cpp PaletteManager.cpp Party.h Render.cpp Render.h Sprites.cpp Texture.cpp UI/UIHouses.cpp UI/UIMainMenu.cpp UI/UISaveLoad.cpp VectorTypes.cpp VideoPlayer.cpp Vis.cpp _deleted.cpp mm7_2.cpp mm7_4.cpp mm7_5.cpp mm7_data.cpp mm7_data.h mm7_unsorted_subs.h stru6.cpp
diffstat 37 files changed, 801 insertions(+), 1109 deletions(-) [+]
line wrap: on
line diff
--- a/AudioPlayer.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/AudioPlayer.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -15,7 +15,6 @@
 #include "Game.h"
 #include "DecorationList.h"
 #include "Timer.h"
-#include "OSInfo.h"
 #include "OurMath.h"
 #include "MapInfo.h"
 #include "GUIWindow.h"
@@ -30,8 +29,6 @@
 
 PCMWAVEFORMAT pcmWaveFormat;
 
-int Aureal3D_SplashScreen;
-int Aureal3D_SplashAudio;
 int uFindSound_BinSearch_ResultID; // weak
 int uLastLoadedSoundID; // weak
 int sLastTrackLengthMS;
@@ -2246,7 +2243,6 @@
   //AudioPlayer *v2; // esi@1
   int v3; // ebx@1
   //_DIG_DRIVER *v4; // eax@1
-  char v5; // dl@5
   _PROVIDER *v6; // eax@9
   //HWND v7; // ST00_4@9
   //MixerChannel *pChannel; // edi@14
@@ -2282,14 +2278,13 @@
   hDigDriver = Audio_GetFirstHardwareDigitalDriver();
   if ( hDigDriver )
     SmackSoundUseMSS(hDigDriver);
-  if ( ReadWindowsRegistryInt("Disable3DSound", 0) != 1 && pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT )
+  if ( ReadWindowsRegistryInt("Disable3DSound", 0) != 1 && true)//pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT )
   {
     v14 = 0;
     bEAXSupported = 0;
     b3DSoundInitialized = 0;
     ReadWindowsRegistryString("3DSoundProvider", p3DSoundProvider, 128u, "NONE");
-    __debugbreak(); // audioplayer.cpp(1926): warning C4700: uninitialized local variable 'v5' used
-    CheckA3DSupport(v5);
+    CheckA3DSupport(true);
     HPROVIDER prov;
     while ( AIL_enumerate_3D_providers(&v14, &prov, &Str1) )
     {
@@ -2417,36 +2412,27 @@
 }
 
 //----- (004ABC9B) --------------------------------------------------------
-LSTATUS AudioPlayer::CheckA3DSupport(char a2)
+void AudioPlayer::CheckA3DSupport(bool query)
 {
-  LSTATUS result; // eax@1
   DWORD cbData; // [sp+8h] [bp-Ch]@1
-  int Data; // [sp+Ch] [bp-8h]@1
   HKEY hKey; // [sp+10h] [bp-4h]@1
-  char v6; // [sp+1Ch] [bp+8h]@0
-  v6=0; //to fix
   hKey = 0;
   cbData = 4;
-  Data = 0;
-  result = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Aureal\\A3D", 0, 0x2001Fu, &hKey);
-  if ( !result )
+  if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Aureal\\A3D", 0, 0x2001Fu, &hKey))
   {
-    if ( v6 )
+    int Aureal3D_SplashAudio = 0;
+    if (query)
       RegQueryValueExA(hKey, "SplashAudio", 0, 0, (LPBYTE)&Aureal3D_SplashAudio, &cbData);
-    else
-      Data = Aureal3D_SplashAudio;
-    RegSetValueExA(hKey, "SplashAudio", 0, 4u, (const BYTE *)&Data, 4u);
-    Data = 0;
-    if ( v6 )
+    RegSetValueExA(hKey, "SplashAudio", 0, 4, (const BYTE *)&Aureal3D_SplashAudio, 4);
+
+    int Aureal3D_SplashScreen = 0;
+    if (query)
       RegQueryValueExA(hKey, "SplashScreen", 0, 0, (LPBYTE)&Aureal3D_SplashScreen, &cbData);
-    else
-      Data = Aureal3D_SplashScreen;
-    RegSetValueExA(hKey, "SplashScreen", 0, 4u, (const BYTE *)&Data, 4u);
-    result = RegCloseKey(hKey);
+    RegSetValueExA(hKey, "SplashScreen", 0, 4, (const BYTE *)&Aureal3D_SplashScreen, 4);
+    RegCloseKey(hKey);
   }
-  return result;
 }
-// 4ABC9B: inconsistent function type and number of purged bytes
+
 
 //----- (004ABD5B) --------------------------------------------------------
 void AudioPlayer::Release() //Освободить
@@ -2472,7 +2458,7 @@
     }
     if ( ReadWindowsRegistryInt("Disable3DSound", 0) != 1 )
     {
-      pAudioPlayer->CheckA3DSupport(0);// pAudioPlayer->CheckA3DSupport(v4);
+      CheckA3DSupport(false);
       if ( pAudioPlayer->uNum3DSamples > 0 )
       {
         p3DSample = pAudioPlayer->p3DSamples;
--- a/AudioPlayer.h	Wed Jan 08 22:29:11 2014 +0200
+++ b/AudioPlayer.h	Thu Jan 09 01:37:34 2014 +0200
@@ -170,7 +170,7 @@
   void StopChannels(int uStartChannel, int uEndChannel);
   void LoadAudioSnd();
   void Initialize();
-  LSTATUS CheckA3DSupport(char a2);
+  void CheckA3DSupport(bool query);
   void Release();
   void FreeChannel(MixerChannel *pChannel);
   void _4ABF23(AudioPlayer_3DSample *a2);
--- a/Build/Visual Studio 2012/World of Might and Magic.vcxproj	Wed Jan 08 22:29:11 2014 +0200
+++ b/Build/Visual Studio 2012/World of Might and Magic.vcxproj	Thu Jan 09 01:37:34 2014 +0200
@@ -402,6 +402,7 @@
     <ClInclude Include="..\..\MapInfo.h" />
     <ClInclude Include="..\..\MM7.h" />
     <ClInclude Include="..\..\mm7_data.h" />
+    <ClInclude Include="..\..\mm7_unsorted_subs.h" />
     <ClInclude Include="..\..\Monsters.h" />
     <ClInclude Include="..\..\Mouse.h" />
     <ClInclude Include="..\..\NewUI\Core\UIControl.h" />
--- a/Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters	Wed Jan 08 22:29:11 2014 +0200
+++ b/Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters	Thu Jan 09 01:37:34 2014 +0200
@@ -834,6 +834,7 @@
     <ClInclude Include="..\..\UI\UIHouses.h">
       <Filter>UI</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\mm7_unsorted_subs.h" />
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\Player.swig" />
--- a/DecalBuilder.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/DecalBuilder.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -6,6 +6,7 @@
 #include "Log.h"
 
 #include "mm7_data.h"
+#include "mm7_unsorted_subs.h"
 
 #include "stru9.h"
 
--- a/GUIWindow.h	Wed Jan 08 22:29:11 2014 +0200
+++ b/GUIWindow.h	Thu Jan 09 01:37:34 2014 +0200
@@ -509,7 +509,7 @@
 void GameUI_CharacterQuickRecord_Draw(GUIWindow *window, Player *player);
 void GameUI_DrawNPCPopup(void *_this);
 
-void GameUI_InitializeDialogue(Actor *actor, int bPlayerSaysHello);
+void GameUI_InitializeDialogue(struct Actor *actor, int bPlayerSaysHello);
 void GameUI_DrawBranchlessDialogue();
 void GameUI_DrawDialogue();
 
--- a/Game.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/Game.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -24,7 +24,6 @@
 #include "Overlays.h"
 #include "AudioPlayer.h"
 #include "LOD.h"
-#include "OSInfo.h"
 #include "GUIWindow.h"
 #include "TurnEngine.h"
 #include "VideoPlayer.h"
@@ -920,11 +919,6 @@
   uFlags2 |= 0x24;
 
   _44F0FD();
-
-  bWinNT4_0 = false;
-  if (pVersion->pVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT &&
-      pVersion->pVersionInfo.dwMajorVersion == 4)
-    bWinNT4_0 = true;
 }
 
 //----- (0044E7F3) --------------------------------------------------------
@@ -1030,8 +1024,8 @@
 //----- (0044EA17) --------------------------------------------------------
 bool Game::InitializeGammaController()
 {
-  if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
-      pVersion->pVersionInfo.dwMajorVersion != 4 )
+  //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
+      //pVersion->pVersionInfo.dwMajorVersion != 4 )
     pGammaController->InitializeFromSurface(pRenderer->pFrontBuffer4);
 
   bGammaControlInitialized = true;
--- a/GammaControl.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/GammaControl.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -2,7 +2,6 @@
 
 #include "GammaControl.h"
 #include "Render.h"
-#include "OSInfo.h"
 
 #include "mm7_data.h"
 
@@ -102,8 +101,8 @@
   double v4; // st6@4
 
   v2 = this;
-  if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
-      pVersion->pVersionInfo.dwMajorVersion != 4)
+  //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
+      //pVersion->pVersionInfo.dwMajorVersion != 4)
   {
     InitializeFromSurface(pRenderer->pFrontBuffer4);
     v3 = 2.8;
@@ -133,7 +132,7 @@
   bool result; // eax@3
   HRESULT v1; // eax@4
 
-  if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
+  //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
   {
     DDCAPS halCaps; // [sp+0h] [bp-180h]@4
     memset(&halCaps, 0, sizeof(DDCAPS));
@@ -142,8 +141,8 @@
     ErrD3D(pRenderer->pDirectDraw4->GetCaps(&halCaps, 0));
     return (halCaps.dwCaps2 >> 17) & 1;
   }
-  else
-    return false;
+  /*else
+    return false;*/
 }
 
 
--- a/Indoor.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/Indoor.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -3407,10 +3407,7 @@
     v3 = v37;
   }
   dword_6BE13C_uCurrentlyLoadedLocationID = v39;
-  free(ptr_6A0D08);
-  ptr_6A0D08 = 0;
-  _6A0D0C_txt_lod_loading = 0;
-  TryLoadLevelFromLOD();
+
   pStationaryLightsStack->uNumLightsActive = 0;
   v4 = pIndoor->Load(pCurrentMapName,
          (unsigned int)(signed __int64)((double)pParty->uTimePlayed * 0.234375) / 60 / 60 / 24 + 1,
--- a/IndoorCameraD3D.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/IndoorCameraD3D.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -197,6 +197,17 @@
 {
   RenderVertexSoft v; // [sp+8h] [bp-30h]@1
 
+  //----- (0043648F) --------------------------------------------------------
+  auto Vec3_short__to_RenderVertexSoft = [](RenderVertexSoft *_this, Vec3_short_ *a2) -> void
+  {
+    _this->flt_2C = 0.0;
+
+    _this->vWorldPosition.x = a2->x;
+    _this->vWorldPosition.y = a2->y;
+    _this->vWorldPosition.z = a2->z;
+  };
+
+
   Vec3_short__to_RenderVertexSoft(&v, &pIndoor->pVertices[*pFace->pVertexIDs]);
   return is_face_faced_to_camera(pFace, &v);
 }
--- a/Keyboard.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/Keyboard.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -6,9 +6,9 @@
 #include "Keyboard.h"
 #include "GUIWindow.h"
 #include "Game.h"
-#include "OSInfo.h"
 
 #include "mm7_data.h"
+#include "mm7_unsorted_subs.h"
 #include "Vis.h"
 #include "MM7.h"
 #include "Actor.h"
@@ -929,15 +929,6 @@
   return static_sub_45AE2C_string_69ADE0;
 }
 
-//----- (0045AFD9) --------------------------------------------------------
-Keyboard::Keyboard()
-{
-  bUsingAsynKeyboard = false;
-
-  if (pVersion->pVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT &&
-      pVersion->pVersionInfo.dwMajorVersion == 4)
-    bUsingAsynKeyboard = false;
-}
 
 //----- (0045B019) --------------------------------------------------------
 void Keyboard::EnterCriticalSection()
--- a/Keyboard.h	Wed Jan 08 22:29:11 2014 +0200
+++ b/Keyboard.h	Thu Jan 09 01:37:34 2014 +0200
@@ -80,7 +80,9 @@
 class Keyboard
 {
 public:
-  Keyboard();
+  inline Keyboard():
+    bUsingAsynKeyboard(false)
+  {}
   bool WasKeyPressed(int vKey);
   bool IsKeyBeingHeld(int vKey);
   bool IsShiftHeld();
--- a/LOD.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/LOD.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -8,6 +8,7 @@
 #include "Viewport.h"
 
 #include "mm7_data.h"
+#include "mm7_unsorted_subs.h"
 
 #include "Sprites.h"
 
@@ -2911,44 +2912,3 @@
   }
   return false;
 }
-//----- (00460706) --------------------------------------------------------
-void TryLoadLevelFromLOD()
-{
-  FILE *v0; // eax@1
-  FILE *v1; // esi@1
-  __int32 v2; // edi@2
-  char Ext[256]; // [sp+4h] [bp-40Ch]@1
-  char Dir[256]; // [sp+104h] [bp-30Ch]@1
-  char Filename[256]; // [sp+204h] [bp-20Ch]@1
-  char a1[260]; // [sp+304h] [bp-10Ch]@1
-  char Drive[4]; // [sp+408h] [bp-8h]@1
-  int DstBuf; // [sp+40Ch] [bp-4h]@2
-
-  strcpy(a1, pCurrentMapName);
-  _splitpath(a1, Drive, Dir, Filename, Ext);
-  sprintf(a1, "levels\\%s%s", Filename, ".lod");
-  v0 = fopen(a1, "rb");
-  v1 = v0;
-  if ( v0 )
-  {
-    fseek(v0, 0, 2);
-    v2 = ftell(v1);
-    rewind(v1);
-    ptr_6A0D08 = malloc(v2);
-    fread(ptr_6A0D08, v2, 1u, v1);
-    fseek(v1, v2 - 6, 0);
-    DstBuf = 0;
-    fread(&DstBuf, 4u, 1u, v1);
-    fread(&_6A0D10_txt_lod_loading__unused, 2u, 1u, v1);
-    _6A0D0C_txt_lod_loading = (int)((char *)ptr_6A0D08 + DstBuf);
-    fclose(v1);
-  }
-}
-
-//----- (0046080D) --------------------------------------------------------
-void  sub_46080D()
-{
-  free(ptr_6A0D08);
-  ptr_6A0D08 = 0;
-  _6A0D0C_txt_lod_loading = 0;
-}
--- a/OSAPI.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/OSAPI.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -3,7 +3,8 @@
 #include "Log.h"
 
 
-OSVersion *pVersion = nullptr;
+bool           OSInfo::initialized = false;
+OSVERSIONINFOA OSInfo::info;
 
 
 
@@ -21,24 +22,17 @@
     SetForegroundWindow(GetLastActivePopup(hMM7Window));
     return 0;
   }
+
   HWND hPrevWindow = GetActiveWindow();
-
-  pVersion = new OSVersion;
   {
-
     Log::Warning(L"OS init: ok");
-
     extern bool MM_Main(const wchar_t *pCmdLine);
     MM_Main(lpCmdLine);
   }
-  delete pVersion;
-  pVersion = nullptr;
-
   if (hPrevWindow)
     SetActiveWindow(hPrevWindow);
 
-  //__debugbreak();
-  return 0;
+  return GetLastError();
 }
 
 
--- a/OSInfo.h	Wed Jan 08 22:29:11 2014 +0200
+++ b/OSInfo.h	Thu Jan 09 01:37:34 2014 +0200
@@ -1,31 +1,34 @@
 #pragma once
 #include "OSAPI.h"
 
-/*  293 */
-#pragma pack(push, 1)
-struct OSVersion
+class OSInfo
 {
-  //----- (004AD48F) --------------------------------------------------------
-  OSVersion()
-  {
-    bInitialized = false;
-    pVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
-    if (GetVersionExA(&pVersionInfo))
-      bInitialized = true;
-  }
+  public:
+    inline static bool CanUseDirectDraw4()
+    {
+      if (Ready())
+        return info.dwPlatformId != VER_PLATFORM_WIN32_NT || info.dwMajorVersion >= 4;
+      return false;
+    }
 
-  //----- (004AD4BA) --------------------------------------------------------
-  virtual ~OSVersion()
-  {
-    bInitialized = false;
-  }
+    inline static bool CanUseDirectDraw2()
+    {
+      return true;
+    }
 
 
-  //void ( ***vdestructor_ptr)(OSVersion *, bool);
-  OSVERSIONINFOA pVersionInfo;
-  int bInitialized;
-};
-#pragma pack(pop)
+  private:
+    static bool           initialized;
+    static OSVERSIONINFOA info;
 
-
-extern struct OSVersion *pVersion; // idb
\ No newline at end of file
+    static bool Ready()
+    {
+      if (!initialized)
+      {
+        info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
+        if (GetVersionExA(&info))
+          initialized = true;
+      }
+      return initialized;
+    }
+};
\ No newline at end of file
--- a/OSWindow.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/OSWindow.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -304,7 +304,7 @@
             if ( pVideoPlayer->pMovie)//pVideoPlayer->pSmackerMovie )
             {
               pRenderer->RestoreFrontBuffer();
-              pRenderer->_4A184C();
+              pRenderer->RestoreBackBuffer();
               //pVideoPlayer->_4BF5B2();
             }
           }
--- a/Outdoor.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/Outdoor.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -295,8 +295,7 @@
     pSprites_LOD->DeleteSomeOtherSprites();
     pSpriteFrameTable->ResetSomeSpriteFlags();
     pIcons_LOD->ReleaseAll2();
-    sub_46080D();
-    TryLoadLevelFromLOD();
+
     if ( !Load(pFilename, (ODMFace *)File, uRespawnInterval, thisa) )
     {
       MessageBoxA(0, "Error!", "Couldn't Load Map!", 0);
--- a/PaletteManager.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/PaletteManager.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -17,6 +17,24 @@
 
 
 
+//----- (00452AE2) --------------------------------------------------------
+int __fastcall MakeColorMaskFromBitDepth(int a1)
+{
+  signed __int64 v1; // qax@1
+
+  v1 = 4294967296i64;
+  if ( a1 > 0 )
+  {
+    do
+    {
+      LODWORD(v1) = HIDWORD(v1) + v1;
+      HIDWORD(v1) *= 2;
+      --a1;
+    }
+    while ( a1 );
+  }
+  return v1;
+}
 
 //----- (0048A643) --------------------------------------------------------
 bool __fastcall HSV2RGB(float *a1, float *a2, float *a3, float a4, float a5, float a6)
--- a/Party.h	Wed Jan 08 22:29:11 2014 +0200
+++ b/Party.h	Thu Jan 09 01:37:34 2014 +0200
@@ -2,6 +2,7 @@
 #include "Player.h"
 #include "NPC.h"
 #include "mm7_data.h"
+#include "mm7_unsorted_subs.h"
 #include <array>
 
 
--- a/Render.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/Render.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -24,7 +24,6 @@
 #include "ObjectList.h"
 #include "SpriteObject.h"
 #include "DecorationList.h"
-#include "OSInfo.h"
 #include "Actor.h"
 #include "Log.h"
 #include "TileFrameTable.h"
@@ -214,18 +213,13 @@
 
   if (!pRenderer)
     return true;
-  if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
+
   {
     if ( !pRenderer->pBackBuffer4 )
       goto LABEL_9;
     v0 = pRenderer->pFrontBuffer4 == 0;
   }
-  else
-  {
-    if ( !pRenderer->pBackBuffer2 )
-      goto LABEL_9;
-    v0 = pRenderer->pFrontBuffer2 == 0;
-  }
+
   if ( !v0 )
   {
     LOBYTE(result) = 1;
@@ -236,6 +230,50 @@
   return result;
 }
 
+
+//----- (004A19D8) --------------------------------------------------------
+unsigned int BlendColors(unsigned int a1, unsigned int a2)
+{
+  /*signed __int64 v2; // ST10_8@1
+  double v3; // st7@1
+  float v4; // ST24_4@1
+  double v5; // ST10_8@1
+  int v6; // ST1C_4@1
+  float v7; // ST24_4@1
+  double v8; // ST10_8@1
+  unsigned __int8 v9; // ST20_1@1
+  float v10; // ST24_4@1
+  double v11; // ST10_8@1
+  float v12; // ST24_4@1
+  double v13; // ST08_8@1*/
+
+  uint alpha = (uint)floorf(0.5f + (a1 >> 24) / 255.0f *
+                                   (a2 >> 24) / 255.0f * 255.0f),
+       red = (uint)floorf(0.5f + ((a1 >> 16) & 0xFF) / 255.0f *
+                                 ((a2 >> 16) & 0xFF) / 255.0f * 255.0f),
+       green = (uint)floorf(0.5f + ((a1 >> 8) & 0xFF) / 255.0f *
+                                   ((a2 >> 8) & 0xFF) / 255.0f * 255.0f),
+       blue = (uint)floorf(0.5f + ((a1 >> 0) & 0xFF) / 255.0f *
+                                   ((a2 >> 0) & 0xFF) / 255.0f * 255.0f);
+  return (alpha << 24) | (red << 16) | (green << 8) | blue;
+  /*v2 = a1 >> 24;
+  v3 = (double)v2 / 255.0f;
+  HIDWORD(v2) = 0;
+  LODWORD(v2) = a2 >> 24;
+  v4 = v3 * (double)v2 / 255.0f * 255.0;
+  v5 = v4 + 6.7553994e15;
+  v6 = LODWORD(v5);
+  v7 = (double)((a1 >> 16) & 0xFFi64) / 255.0f * (double)((a2 >> 16) & 0xFF) * 0.0039215689 * 255.0;
+  v8 = v7 + 6.7553994e15;
+  v9 = LOBYTE(v8);
+  v10 = (double)((unsigned __int16)a1 >> 8) / 255.0f * (double)((unsigned __int16)a2 >> 8) / 255.0f * 255.0;
+  v11 = v10 + 6.7553994e15;
+  v12 = (double)(a1 & 0xFFi64) / 255.0f * (double)(unsigned __int8)a2 / 255.0f * 255.0;
+  v13 = v12 + 6.7553994e15;
+  return LOBYTE(v13) | ((LOBYTE(v11) | (((v6 << 8) | v9) << 8)) << 8);*/
+}
+
+
 void Render::RenderTerrainD3D() // New function
 {
   int v6; // ecx@8
@@ -2077,10 +2115,10 @@
   this->pFrontBuffer4 = 0;
   this->pBackBuffer4 = 0;
   this->pColorKeySurface4 = 0;
-  this->pDirectDraw2 = 0;
-  this->pFrontBuffer2 = 0;
-  this->pBackBuffer2 = 0;
-  this->pSomeSurface2 = 0;
+  //this->pDirectDraw2 = 0;
+  //this->pFrontBuffer2 = 0;
+  //this->pBackBuffer2 = 0;
+  //this->pSomeSurface2 = 0;
   //RenderHWLContainer::RenderHWLContainer(&this->pD3DBitmaps);
   //RenderHWLContainer::RenderHWLContainer(&v1->pD3DSprites);
   v1->bWindowMode = 1;
@@ -2172,15 +2210,11 @@
 
   memset(&v3, 0, sizeof(DDBLTFX));
   GetWindowRect(window->GetApiHandle(), &x);
-  if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
-      pVersion->pVersionInfo.dwMajorVersion >= 5)
+
   {
     v2 = (IDirectDrawSurface *)this->pBackBuffer4;
   }
-  else
-  {
-    v2 = (IDirectDrawSurface *)this->pBackBuffer2;
-  }
+
   v3.dwFillColor = 0;
   v3.dwSize = 100;
   v2->Blt(&x, 0, 0, DDBLT_COLORFILL, &v3);
@@ -3000,6 +3034,214 @@
   }*/
 }
 
+
+
+
+void Present32(unsigned __int32 *src, unsigned int src_pitch,
+               unsigned __int32 *dst, unsigned int dst_pitch)
+{
+        for (uint y = 0; y < 8; ++y)
+          memcpy(dst + y * dst_pitch,
+                 src + y * src_pitch, src_pitch * sizeof(__int32));
+
+        for (uint y = 8; y < 352; ++y)
+        {
+          memcpy(dst + y * dst_pitch,
+                 src + y * src_pitch, 8 * sizeof(__int32));
+          memcpy(dst + 8 + game_viewport_width + y * dst_pitch,
+                 src + 8 + game_viewport_width + y * src_pitch, 174/*172*/ * sizeof(__int32));
+        }
+
+        for (uint y = 352; y < 480; ++y)
+          memcpy(dst + y * dst_pitch,
+                 src + y * src_pitch, src_pitch * sizeof(__int32));
+
+        for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y)
+        {
+          for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x)
+          {
+            //if (src[x + y * src_pitch] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask))
+            if (src[x + y * src_pitch] != 0xFFF8FCF8)  // FFF8FCF8 =  Color32(Color16(g_mask | b_mask))
+              dst[x + y * dst_pitch] = src[x + y * src_pitch];
+          }
+        }
+}
+
+//----- (004A597D) --------------------------------------------------------
+void Present_NoColorKey()
+{
+  //unsigned __int16 *v0; // eax@4
+  unsigned __int16 *v1; // esi@4
+  void *v2; // edi@4
+  //signed int v4; // ebx@4
+  //signed int v5; // ebx@6
+  //void *v6; // edi@7
+  //const void *v7; // esi@7
+  signed int v8; // ebx@8
+  int v9; // eax@10
+  unsigned int v10; // esi@10
+  unsigned __int32 v11; // edi@10
+  //int v12; // ecx@10
+  unsigned int v13; // ebx@10
+  int v14; // eax@11
+  int v15; // eax@13
+  int v16; // eax@14
+  int v17; // eax@16
+  HRESULT v18; // eax@22
+  DDSURFACEDESC2 Dst; // [sp+Ch] [bp-98h]@3
+  //int v20; // [sp+88h] [bp-1Ch]@10
+  int v21; // [sp+8Ch] [bp-18h]@10
+  __int32 v22; // [sp+90h] [bp-14h]@10
+  //unsigned __int32 v23; // [sp+94h] [bp-10h]@10
+  unsigned int v24; // [sp+98h] [bp-Ch]@4
+  //unsigned int _this; // [sp+9Ch] [bp-8h]@10
+  //LPVOID v26; // [sp+A0h] [bp-4h]@4
+
+  int r_mask = 0xF800;
+  int g_mask = 0x7E0;
+  int b_mask = 0x1F;
+
+  if ( !pRenderer->uNumSceneBegins )
+  {
+    if ( pRenderer->using_software_screen_buffer )
+    {
+      memset(&Dst, 0, 0x7Cu);
+      Dst.dwSize = 124;
+      if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) )
+      {
+        //v26 = Dst.lpSurface;
+        //pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface;
+        v24 = g_mask | b_mask | ((g_mask | b_mask) << 16);
+        //pRenderer->pCurrentlyLockedSoftSurface = pRenderer->pTargetSurface;
+        //pRenderer->uCurrentlyLockedSurfacePitch = Dst.lPitch;
+        //v1 = pRenderer->pTargetSurface;
+        v2 = Dst.lpSurface;
+
+
+        /*for (uint y = 0; y < 480; ++y)
+        {
+          auto pDst = (unsigned short *)((char *)Dst.lpSurface + y * Dst.lPitch);
+          for (uint x = 0; x < 640; ++x)
+            pDst[x] = pRenderer->uTargetRMask | pRenderer->uTargetBMask;
+        }*/
+
+        if (!FORCE_16_BITS)
+          Present32((unsigned __int32 *)pRenderer->pTargetSurface, pRenderer->uTargetSurfacePitch, (unsigned __int32 *)Dst.lpSurface, Dst.lPitch / 4);
+        else
+        {        
+        ushort* pSrc = (unsigned short *)pRenderer->pTargetSurface;
+        short* pDst = (__int16 *)Dst.lpSurface;
+
+        for (uint y = 0; y < 8; ++y)
+          memcpy(pDst + y * Dst.lPitch / 2,
+
+		  pSrc + y * 640, 640 * sizeof(__int16));
+
+        for (uint y = 8; y < 352; ++y)
+        {
+          memcpy(pDst + y * Dst.lPitch / 2,
+                 pSrc + y * 640, 8 * sizeof(__int16));
+          memcpy(pDst + 8 + game_viewport_width/*462*/ + y * Dst.lPitch / 2,
+                 pSrc + 8 + game_viewport_width/*462*/ + y * 640, 174/*172*/ * sizeof(__int16));
+        }
+
+        for (uint y = 352; y < 480; ++y)
+          memcpy(pDst + y * Dst.lPitch / 2,
+                 pSrc + y * 640, 640 * sizeof(__int16));
+
+
+        ushort* pSrc_x1y1 = pSrc + 640 * pViewport->uViewportTL_Y + pViewport->uViewportTL_X;
+        //_this = (unsigned int)&pSrc[2 * (((signed int)pViewport->uViewportX >> 1) + 320 * pViewport->uViewportY)];
+        short* pDst_x1y1 = pDst + Dst.lPitch * pViewport->uViewportTL_Y + pViewport->uViewportTL_X;
+        //v23 = (unsigned __int32)((char *)v26 + 4 * (((signed int)pViewport->uViewportX >> 1) + (Dst.lPitch >> 2) * pViewport->uViewportY));
+        v9 = ((signed int)pViewport->uViewportTL_X >> 1) - ((signed int)pViewport->uViewportBR_X >> 1);
+        //v20 = ((signed int)pViewport->uViewportZ >> 1) - ((signed int)pViewport->uViewportX >> 1);
+        v22 = 4 * ((Dst.lPitch / 4) + v9);
+        v21 = 4 * v9 + 1280;
+
+        //auto uNumLines = pViewport->uViewportW - pViewport->uViewportY + 1;
+        //v26 = (LPVOID)(pViewport->uViewportW - pViewport->uViewportY + 1);
+        v10 = (int)pSrc_x1y1;
+        v11 = (int)pDst_x1y1;
+        int uHalfWidth = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2;
+        v13 = v24;
+
+        for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y)
+        {
+          //memcpy(pDst + pViewport->uViewportX + y * Dst.lPitch / 2,
+          //       pSrc + pViewport->uViewportX + y * 640, (pViewport->uViewportZ - pViewport->uViewportX) * sizeof(__int16));
+          for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x)
+          {
+            if (pSrc[y * 640 + x] != (g_mask | b_mask))
+              pDst[y * Dst.lPitch / 2 + x] = pSrc[y * 640 + x];
+          }
+        }
+        }
+
+              ErrD3D(pRenderer->pBackBuffer4->Unlock(0));
+
+       /* while ( 1 )
+        {
+          while ( 1 )
+          {
+            v14 = *(int *)v10;
+            v10 += 4;
+            if ( v14 == v13 )
+              break;
+            if ( (short)v14 == (short)v13 )
+            {
+              *(int *)v11 = *(int *)v11 & 0xFFFF | v14 & 0xFFFF0000;
+              v11 += 4;
+              --uHalfWidth;
+              if ( !uHalfWidth )
+                goto LABEL_21;
+            }
+            else
+            {
+              v15 = __ROL__(v14, 16);
+              if ( (short)v15 == (short)v13 )
+              {
+                v17 = __ROR__(v15, 16);
+                *(int *)v11 = *(int *)v11 & 0xFFFF0000 | (unsigned __int16)v17;
+                v11 += 4;
+                --uHalfWidth;
+                if ( !uHalfWidth )
+                  goto LABEL_21;
+              }
+              else
+              {
+                v16 = __ROR__(v15, 16);
+                *(int *)v11 = v16;
+                v11 += 4;
+                --uHalfWidth;
+                if ( !uHalfWidth )
+                  goto LABEL_21;
+              }
+            }
+          }
+          v11 += 4;
+          --uHalfWidth;
+          if ( !uHalfWidth )
+          {
+LABEL_21:
+            v10 += v21;
+            v11 += v22;
+            uHalfWidth = v20;
+            if ( !--uNumLines )
+            {
+              ErrD3D(pRenderer->pBackBuffer4->Unlock(0));
+              return;
+            }
+          }
+        }*/
+      }
+    }
+  }
+}
+
+
+
+
 //----- (0049FFD7) --------------------------------------------------------
 void Render::CreateSomeTexture()
 {
@@ -3816,67 +4058,6 @@
   return result;
 }
 
-//----- (004A1032) --------------------------------------------------------
-bool Render::LockSurface_DDraw2(IDirectDrawSurface2 *pSurface, DDSURFACEDESC *pDesc, unsigned int uLockFlags)
-{
-  IDirectDrawSurface2 *v4; // esi@1
-  HRESULT v5; // eax@1
-  HRESULT v6; // eax@2
-  int v7; // [sp-8h] [bp-10h]@8
-  unsigned int v8; // [sp-4h] [bp-Ch]@8
-
-  v4 = pSurface;
-  v5 = pSurface->Lock(
-         0,
-         pDesc,
-         uLockFlags,
-         0);
-  BYTE3(pSurface) = 1;
-  if ( v5 == DDERR_SURFACELOST )
-  {
-    v6 = v4->Restore();
-    if ( !v6 )
-      goto LABEL_5;
-    if ( v6 == DDERR_IMPLICITLYCREATED )
-    {
-      pRenderer->pFrontBuffer2->Restore();
-      v4->Restore();
-LABEL_5:
-      v5 = v4->Lock(0, pDesc, 1u, 0) != 0;
-      if ( v5 == DDERR_INVALIDRECT || v5 == DDERR_SURFACEBUSY )
-        goto LABEL_14;
-      if ( !v5 )
-        return true;
-      ErrD3D(v5);
-      //v8 = 0;
-      //v7 = 2247;
-      goto LABEL_13;
-    }
-    else
-    {
-      pDesc->dwSize = 0;
-      return false;
-    }
-  }
-  else
-  {
-    if ( !v5 )
-      return true;
-    if ( v5 != DDERR_INVALIDRECT && v5 != DDERR_SURFACEBUSY )
-    {
-      //v8 = 0;
-      //v7 = 2269;
-      ErrD3D(v5);
-      pDesc->dwSize = 0;
-      return false;
-LABEL_13:
-      //CheckHRESULT((CheckHRESULT_stru0 *)&pSurface, v5, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp", v7, v8);
-      goto LABEL_14;
-    }
-  }
-LABEL_14:
-  return true;
-}
 
 //----- (004A10E4) --------------------------------------------------------
 void Render::CreateDirectDraw()
@@ -3891,14 +4072,9 @@
   v1 = this;
   ErrD3D(DirectDrawCreate(0, &lpDD, 0));
 
-  pDirectDraw2 = nullptr;
   pDirectDraw4 = nullptr;
 
-  if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
-      pVersion->pVersionInfo.dwMajorVersion != 4 )
-    ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4));
-  else
-    ErrD3D(lpDD->QueryInterface(IID_IDirectDraw2, (void **)&pDirectDraw2));
+  ErrD3D(lpDD->QueryInterface(IID_IDirectDraw4, (void **)&pDirectDraw4));
 
   lpDD->Release();
   lpDD = nullptr;
@@ -3916,21 +4092,13 @@
   flags = bFullscreen ? DDSCL_NORMAL | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN :
                         DDSCL_NORMAL;
 
-  if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
-      pVersion->pVersionInfo.dwMajorVersion != 4 )
-    ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED));
-  else
-    ErrD3D(pDirectDraw2->SetCooperativeLevel(hWnd, flags));
+  ErrD3D(pDirectDraw4->SetCooperativeLevel(hWnd, flags | DDSCL_MULTITHREADED));
 }
 
 //----- (004A11C6) --------------------------------------------------------
 void Render::SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP)
 {
-  if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
-      pVersion->pVersionInfo.dwMajorVersion != 4 )
-    ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0));
-  else
-    ErrD3D(pDirectDraw2->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0));
+  ErrD3D(pDirectDraw4->SetDisplayMode(uWidth, uHeight, uBPP, 0, 0));
 }
 
 //----- (004A121C) --------------------------------------------------------
@@ -3946,8 +4114,8 @@
   DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3
 
   v1 = this;
-  if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
-      pVersion->pVersionInfo.dwMajorVersion != 4 )
+  //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
+      //pVersion->pVersionInfo.dwMajorVersion != 4 )
   {
     memset(&a2, 0, 0x7Cu);
     pDD = (IDirectDraw *)v1->pDirectDraw4;
@@ -3959,7 +4127,7 @@
     pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer4;
     v4 = (struct _DDSURFACEDESC *)&a2;
   }
-  else
+  /*else
   {
     memset(&a2.lPitch, 0, 0x6Cu);               // DDSURFACEDESC here
     pDD = (IDirectDraw *)v1->pDirectDraw2;
@@ -3970,7 +4138,7 @@
     v6 = 2346;
     pOutSurf = (IDirectDrawSurface **)&v1->pFrontBuffer2;
     v4 = (struct _DDSURFACEDESC *)&a2.lPitch;
-  }
+  }*/
   ErrD3D(pDD->CreateSurface(v4, pOutSurf, 0));
 }
 
@@ -3987,8 +4155,8 @@
   DDSURFACEDESC2 a2; // [sp+4h] [bp-80h]@3
 
   v1 = this;
-  if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
-      pVersion->pVersionInfo.dwMajorVersion != 4 )
+  //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
+    //  pVersion->pVersionInfo.dwMajorVersion != 4 )
   {
     memset(&a2, 0, 0x7Cu);
     v2 = (IDirectDraw *)v1->pDirectDraw4;
@@ -4002,7 +4170,7 @@
     ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4;
     v4 = (struct _DDSURFACEDESC *)&a2;
   }
-  else
+  /*else
   {
     memset(&a2.lPitch, 0, 0x6Cu);
     v2 = (IDirectDraw *)v1->pDirectDraw2;
@@ -4015,7 +4183,7 @@
     v6 = 2374;
     ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2;
     v4 = (struct _DDSURFACEDESC *)&a2.lPitch;   // //DDSURFACEDESC here fo ddraw2
-  }
+  }*/
   ErrD3D(v2->CreateSurface(v4, ppBackBuffer, 0));
 }
 
@@ -4042,8 +4210,8 @@
   int a4; // [sp+98h] [bp-8h]@3
 
   v1 = this;
-  if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
-      pVersion->pVersionInfo.dwMajorVersion != 4 )
+  //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
+      //pVersion->pVersionInfo.dwMajorVersion != 4 )
   {
     v2 = 0;
     this->field_4004C = 1;
@@ -4060,7 +4228,7 @@
     pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer4;
     ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer4;
   }
-  else
+  /*else
   {
     v2 = 0;
     this->field_4004C = 1;
@@ -4079,7 +4247,7 @@
 
     pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2;
     ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2;
-  }
+  }*/
   __debugbreak(); // warning C4700: uninitialized local variable 'v6' used
   v9 = (int)v6;
   v10 = pFrontBuffer;                           // BUG
@@ -4094,31 +4262,15 @@
 //----- (004A14F4) --------------------------------------------------------
 void Render::CreateClipper(HWND a2)
 {
-  if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
-      pVersion->pVersionInfo.dwMajorVersion != 4 )
-  {
-    ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0));
-    ErrD3D(pDDrawClipper->SetHWnd(0, a2));
-    ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper));
-  }
-  else
-  {
-    ErrD3D(pDirectDraw2->CreateClipper(0, &pDDrawClipper, 0));
-    ErrD3D(pDDrawClipper->SetHWnd(0, a2));
-  }
+  ErrD3D(pDirectDraw4->CreateClipper(0, &pDDrawClipper, 0));
+  ErrD3D(pDDrawClipper->SetHWnd(0, a2));
+  ErrD3D(pFrontBuffer4->SetClipper(pDDrawClipper));
 }
 
 //----- (004A15D8) --------------------------------------------------------
 void Render::GetTargetPixelFormat(DDPIXELFORMAT *pOut)
 {
-  IDirectDrawSurface *v2; // eax@3
-
-  if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
-      pVersion->pVersionInfo.dwMajorVersion != 4 )
-    v2 = (IDirectDrawSurface *)this->pFrontBuffer4;
-  else
-    v2 = (IDirectDrawSurface *)this->pFrontBuffer2;
-  v2->GetPixelFormat(pOut);
+  pFrontBuffer4->GetPixelFormat(pOut);
 }
 
 //----- (004A1605) --------------------------------------------------------
@@ -4126,8 +4278,8 @@
 {
   signed int v4; // eax@3
 
-  if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
-      pVersion->pVersionInfo.dwMajorVersion != 4 )
+  //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
+      //pVersion->pVersionInfo.dwMajorVersion != 4 )
   {
   DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3
     memset(&pDesc, 0, 0x7Cu);
@@ -4136,7 +4288,7 @@
     *pOutSurfacePtr = pDesc.lpSurface;
     v4 = pDesc.lPitch;
   }
-  else
+  /*else
   {
   DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3
     memset(&pDesc.lPitch, 0, 0x6Cu);
@@ -4144,18 +4296,14 @@
     LockSurface_DDraw2(this->pBackBuffer2, &pDesc, 1);
     *pOutSurfacePtr = (void *)pDesc.lpSurface;
     v4 = pDesc.dwReserved;
-  }
+  }*/
   *pOutPixelsPerRow = v4 >> 1;
 }
 
 //----- (004A16E1) --------------------------------------------------------
 void Render::UnlockBackBuffer()
 {
-  if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
-      pVersion->pVersionInfo.dwMajorVersion != 4 )
-    ErrD3D(pBackBuffer4->Unlock(0));
-  else
-    ErrD3D(pBackBuffer2->Unlock(0));
+  ErrD3D(pBackBuffer4->Unlock(0));
 }
 
 //----- (004A172E) --------------------------------------------------------
@@ -4163,7 +4311,7 @@
 {
   signed int v4; // eax@3
 
-  if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
+  //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
   {
   DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3
     memset(&pDesc, 0, 0x7Cu);
@@ -4172,7 +4320,7 @@
     *pOutSurface = pDesc.lpSurface;
     v4 = pDesc.lPitch;
   }
-  else
+  /*else
   {
   DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3
     memset(&pDesc.lPitch, 0, 0x6Cu);
@@ -4180,59 +4328,28 @@
     LockSurface_DDraw2(this->pFrontBuffer2, &pDesc, 1);
     *pOutSurface = (void *)pDesc.lpSurface;
     v4 = pDesc.dwReserved;
-  }
+  }*/
   *pOutPixelsPerRow = v4 >> 1;
 }
 
 //----- (004A17C7) --------------------------------------------------------
 void Render::UnlockFrontBuffer()
 {
-  IDirectDrawSurface *pFront; // eax@3
-  HRESULT v2; // eax@5
-  signed int v3; // [sp-8h] [bp-Ch]@3
-  int v4; // [sp-4h] [bp-8h]@3
-
-  Render* a5 = this;
-  if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
-  {
-    pFront = (IDirectDrawSurface *)a5->pFrontBuffer4;
-    v4 = 0;
-    v3 = 2615;
-  }
-  else
-  {
-    pFront = (IDirectDrawSurface *)a5->pFrontBuffer2;
-    v4 = 0;
-    v3 = 2611;
-  }
-  ErrD3D(pFront->Unlock(0));
+  ErrD3D(pFrontBuffer4->Unlock(0));
 }
 
 //----- (004A1814) --------------------------------------------------------
 void Render::RestoreFrontBuffer()
 {
-  IDirectDrawSurface **v1; // esi@2
-
-  if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT
-    || (v1 = (IDirectDrawSurface **)&this->pFrontBuffer2, pVersion->pVersionInfo.dwMajorVersion >= 5u) )
-    v1 = (IDirectDrawSurface **)&this->pFrontBuffer4;
-  if ( (*v1)->IsLost() == DDERR_SURFACELOST )
-    (*v1)->Restore();
+  if (pFrontBuffer4->IsLost() == DDERR_SURFACELOST )
+    pFrontBuffer4->Restore();
 }
 
 //----- (004A184C) --------------------------------------------------------
-HRESULT Render::_4A184C()
-{
-  IDirectDrawSurface **pBack; // esi@2
-  HRESULT result; // eax@4
-
-  if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT
-    || (pBack = (IDirectDrawSurface **)&this->pBackBuffer2, pVersion->pVersionInfo.dwMajorVersion != 4) )
-    pBack = (IDirectDrawSurface **)&this->pBackBuffer4;
-  result = (*pBack)->IsLost();
-  if ( result == DDERR_SURFACELOST )
-    result = (*pBack)->Restore();
-  return result;
+void Render::RestoreBackBuffer()
+{
+  if ( pBackBuffer4->IsLost() == DDERR_SURFACELOST )
+    pBackBuffer4->Restore();
 }
 
 //----- (004A1884) --------------------------------------------------------
@@ -4248,7 +4365,7 @@
   int v10; // [sp-8h] [bp-8h]@3
   unsigned int v11; // [sp-4h] [bp-4h]@3
 
-  if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
+  //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
   {
     v11 = 0;
     pFront = (IDirectDrawSurface *)this->pFrontBuffer4;
@@ -4259,7 +4376,7 @@
     v6 = a3;
     pBack = (IDirectDrawSurface *)this->pBackBuffer4;
   }
-  else
+  /*else
   {
     v11 = 0;
     pFront = (IDirectDrawSurface *)this->pFrontBuffer2;
@@ -4269,22 +4386,14 @@
     v7 = DDBLT_WAIT;
     v6 = a3;
     pBack = (IDirectDrawSurface *)this->pBackBuffer2;
-  }
+  }*/
   ErrD3D(pFront->Blt(a2, pBack, v6, v7, v8));
 }
 
 //----- (004A18F5) --------------------------------------------------------
 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags)
 {
-  IDirectDrawSurface *pFront; // eax@3
-  HRESULT v6; // eax@5
-  int v7; // [sp-8h] [bp-8h]@3
-  unsigned int v8; // [sp-4h] [bp-4h]@3
-
-  if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u )
-    ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr));
-  else
-    ErrD3D(pFrontBuffer2->Blt(pDstRect, (IDirectDrawSurface2 *)pSrcSurface, pSrcRect, uBltFlags, nullptr));
+  ErrD3D(pFrontBuffer4->Blt(pDstRect, (IDirectDrawSurface4 *)pSrcSurface, pSrcRect, uBltFlags, nullptr));
 }
 
 //----- (004A194A) --------------------------------------------------------
@@ -4293,16 +4402,16 @@
   IDirectDrawSurface *pFront; // eax@3
   IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3
 
-  if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
+  //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
   {
     pFront = (IDirectDrawSurface *)this->pFrontBuffer4;
     pBack = (IDirectDrawSurface *)this->pBackBuffer4;
   }
-  else
+  /*else
   {
     pFront = (IDirectDrawSurface *)this->pFrontBuffer2;
     pBack = (IDirectDrawSurface *)this->pBackBuffer2;
-  }
+  }*/
   pFront->BltFast(0, 0, pBack, a4, DDBLTFAST_WAIT);
 }
 
--- a/Render.h	Wed Jan 08 22:29:11 2014 +0200
+++ b/Render.h	Thu Jan 09 01:37:34 2014 +0200
@@ -8,6 +8,14 @@
 
 #include "VectorTypes.h"
 
+
+#define ErrD3D(hr) \
+  do \
+  {  \
+    extern void ErrHR(HRESULT, const char *, const char *, const char *, int); \
+    ErrHR(hr, "Direct3D", __FUNCTION__, __FILE__, __LINE__); \
+  } while(0)
+
 struct Polygon;
 struct Texture;
 struct RGBTexture;
@@ -297,7 +305,6 @@
   void SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW);
   void ParseTargetPixelFormat();
   bool LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags);
-  bool LockSurface_DDraw2(IDirectDrawSurface2 *pSurface, DDSURFACEDESC *pDesc, unsigned int uLockFlags);
   void CreateDirectDraw();
   void SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen);
   void SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP);
@@ -311,7 +318,7 @@
   void LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow);
   void UnlockFrontBuffer();
   void RestoreFrontBuffer();
-  HRESULT _4A184C();
+  void RestoreBackBuffer();
   void PresentRect(RECT *a2, RECT *a3);
   void BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags);
   void BltBackToFontFast(int a2, int a3, RECT *a4);
@@ -407,10 +414,10 @@
   IDirectDrawSurface4 *pFrontBuffer4;
   IDirectDrawSurface4 *pBackBuffer4;
   IDirectDrawSurface4 *pColorKeySurface4;
-  IDirectDraw2 *pDirectDraw2;
-  IDirectDrawSurface2 *pFrontBuffer2;
-  IDirectDrawSurface2 *pBackBuffer2;
-  IDirectDrawSurface2 *pSomeSurface2;
+  //IDirectDraw2 *pDirectDraw2;
+  //IDirectDrawSurface2 *pFrontBuffer2;
+  //IDirectDrawSurface2 *pBackBuffer2;
+  //IDirectDrawSurface2 *pSomeSurface2;
   DDPIXELFORMAT ddpfPrimarySuface;
   unsigned int uTargetRBits;
   unsigned int uTargetGBits;
--- a/Sprites.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/Sprites.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -11,6 +11,7 @@
 #include "FrameTableInc.h"
 
 #include "mm7_data.h"
+#include "mm7_unsorted_subs.h"
 #include "Outdoor.h"
 #include "DecorationList.h"
 #include "MM7.h"
--- a/Texture.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/Texture.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -11,6 +11,7 @@
 #include "Render.h"
 
 #include "mm7_data.h"
+#include "mm7_unsorted_subs.h"
 
 
 
--- a/UI/UIHouses.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/UI/UIHouses.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -800,7 +800,6 @@
 	uCloseTime = p2DEvents[uHouseID - 1].uCloseTime;
 	current_npc_text = 0;
 	dword_F8B1E4 = 0;
-	dword_F8B1F4 = 0;
 	memset(byte_F8B1F0.data(), 0, 4);
 	memset(player_levels.data(), 0, 16);
 	pRenderer->ClearZBuffer(0, 479);
--- a/UI/UIMainMenu.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/UI/UIMainMenu.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -15,6 +15,7 @@
 #include "..\texts.h"
 
 #include "..\mm7_data.h"
+#include "..\mm7_unsorted_subs.h"
 
 
 //----- (0041B578) --------------------------------------------------------
@@ -193,6 +194,36 @@
   LoadPartyBuffIcons();
 }
 
+
+
+
+//----- (00452AF3) --------------------------------------------------------
+void __fastcall fill_pixels_fast(unsigned int a1, unsigned __int16 *pPixels, unsigned int uNumPixels)
+{
+  void *v3; // edi@1
+  unsigned int v4; // eax@1
+  unsigned __int16 *v5; // edi@3
+  unsigned int i; // ecx@3
+
+  __debugbreak(); // Nomad: sub operates on 16 bit pixels, we have 32 bits.
+
+  v3 = pPixels;
+  v4 = a1 | (a1 << 16);
+  if ( (unsigned __int8)pPixels & 2 )           // first 2 pixels
+  {
+    *pPixels = v4;
+    v3 = pPixels + 1;
+    --uNumPixels;
+  }
+  memset32(v3, v4, uNumPixels >> 1);            // 4 pixels at once
+  v5 = (unsigned __int16 *)((char *)v3 + 4 * (uNumPixels >> 1));
+  for ( i = uNumPixels & 1; i; --i )            // leftover pixels
+  {
+    *v5 = v4;
+    ++v5;
+  }
+}
+
 //----- (004979D2) --------------------------------------------------------
 MENU_STATE MainMenuUI_Credits_Loop()
 {
--- a/UI/UISaveLoad.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/UI/UISaveLoad.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -16,6 +16,7 @@
 #include "..\texts.h"
 
 #include "..\mm7_data.h"
+#include "..\mm7_unsorted_subs.h"
 
 
 //----- (004601B7) --------------------------------------------------------
--- a/VectorTypes.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/VectorTypes.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -54,6 +54,7 @@
 template <class T>
 void Vec3<T>::Normalize(T *x, T *y, T *z)
 {
+  extern int integer_sqrt(int val);
   *x *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1);
   *y *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1);
   *z *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1);
--- a/VideoPlayer.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/VideoPlayer.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -9,7 +9,6 @@
 #include "CShow.h"
 #include "Mouse.h"
 
-#include "OSInfo.h"
 #include "VideoPlayer.h"
 #include "AudioPlayer.h"
 #include "Game.h"
@@ -84,8 +83,8 @@
   IDirectDrawSurface2 *a2; // [sp+10Ch] [bp-8h]@3
 
   v13 = uWidth;
-  if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
-      pVersion->pVersionInfo.dwMajorVersion >= 5u )
+  //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
+      //pVersion->pVersionInfo.dwMajorVersion >= 5u )
   {
     v4 = 0;
     v15 = 0;
@@ -126,7 +125,7 @@
     v5->field_38 = 0;
     v7 = (IDirectDrawSurface *)v15;
   }
-  else
+  /*else
   {
     v4 = 0;
     a2 = 0;
@@ -168,7 +167,7 @@
     v5->uBinkDDSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)a2);
     v5->field_38 = 0;
     v7 = (IDirectDrawSurface *)a2;
-  }
+  }*/
   v5->pTargetDDrawSurface = v7;
   v5->hWnd = window->GetApiHandle();
   v9 = a4;
@@ -210,7 +209,7 @@
   IDirectDrawSurface4 *v6; // edi@11
 
   //v1 = _this;
-  if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u )
+  //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u )
   {
     DDSURFACEDESC2 v8; // [sp+Ch] [bp-7Ch]@4
     if ( _this->pTargetDDrawSurface )
@@ -237,7 +236,7 @@
       return 1;
     }
   }
-  else
+  /*else
   {
     DDSURFACEDESC v8; // [sp+Ch] [bp-7Ch]@4
     if ( _this->pTargetDDrawSurface )
@@ -263,7 +262,7 @@
       _this->uDDrawSurfacePitch = v8.dwReserved;
       return 1;
     }
-  }
+  }*/
   return 1;
 }
 
@@ -573,11 +572,7 @@
   bFirstFrame = false;
   bUsingSmackerMMX = SmackUseMMX(1);
   BinkSetSoundSystem(BinkOpenMiles, pAudioPlayer->hDigDriver);
-  if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5)
-    uBinkDirectDrawSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)pRenderer->pBackBuffer4);
-  else
-    uBinkDirectDrawSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)pRenderer->pBackBuffer2);
-
+  uBinkDirectDrawSurfaceType = BinkDDSurfaceType((IDirectDrawSurface *)pRenderer->pBackBuffer4);
 }
 
 
@@ -1272,7 +1267,6 @@
   //RGBTexture::RGBTexture(&pVideoPlayer->pVideoFrame);
   bStopBeforeSchedule = false;
   pResetflag = 0;
-  byte_F8BC0C = 0;
   pPlayer = new MultimediaPlayer();
   pPlayer->Initialize();
   pMovie = nullptr;
--- a/Vis.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/Vis.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -10,6 +10,7 @@
 #include "ErrorHandling.h"
 
 #include "mm7_data.h"
+#include "mm7_unsorted_subs.h"
 #include "MM7.h"
 #include "Level/Decoration.h"
 
--- a/_deleted.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/_deleted.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -13925,7 +13925,7 @@
             if ( pVideoPlayer->pSmackerMovie )
             {
               pRenderer->RestoreFrontBuffer();
-              pRenderer->_4A184C();
+              pRenderer->RestoreBackBuffer();
               pVideoPlayer->_4BF5B2();
             }
           }
--- a/mm7_2.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/mm7_2.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -9,6 +9,7 @@
 
 #include "Texture.h"
 #include "mm7_data.h"
+#include "mm7_unsorted_subs.h"
 #include "VideoPlayer.h"
 #include "Sprites.h"
 #include "BSPModel.h"
@@ -2279,49 +2280,7 @@
     return result;
 }
 
-//----- (00452AE2) --------------------------------------------------------
-int __fastcall MakeColorMaskFromBitDepth(int a1)
-{
-  signed __int64 v1; // qax@1
-
-  v1 = 4294967296i64;
-  if ( a1 > 0 )
-  {
-    do
-    {
-      LODWORD(v1) = HIDWORD(v1) + v1;
-      HIDWORD(v1) *= 2;
-      --a1;
-    }
-    while ( a1 );
-  }
-  return v1;
-}
-
-//----- (00452AF3) --------------------------------------------------------
-void __fastcall fill_pixels_fast(unsigned int a1, unsigned __int16 *pPixels, unsigned int uNumPixels)
-{
-  void *v3; // edi@1
-  unsigned int v4; // eax@1
-  unsigned __int16 *v5; // edi@3
-  unsigned int i; // ecx@3
-
-  v3 = pPixels;
-  v4 = a1 | (a1 << 16);
-  if ( (unsigned __int8)pPixels & 2 )           // first 2 pixels
-  {
-    *pPixels = v4;
-    v3 = pPixels + 1;
-    --uNumPixels;
-  }
-  memset32(v3, v4, uNumPixels >> 1);            // 4 pixels at once
-  v5 = (unsigned __int16 *)((char *)v3 + 4 * (uNumPixels >> 1));
-  for ( i = uNumPixels & 1; i; --i )            // leftover pixels
-  {
-    *v5 = v4;
-    ++v5;
-  }
-}
+
 
 //----- (00452B2E) --------------------------------------------------------
 int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides)
@@ -3101,7 +3060,7 @@
     pRenderer->field_1036B8 = 0;
     pRenderer->_gpu_memory_used = 0;
   }
-  sub_46080D();
+
   if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
     pIndoor->Release();
   else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
@@ -4467,18 +4426,6 @@
   }
 
   pODMRenderParams = new ODMRenderParams;
-  outdoor_day_top_r      = GetPrivateProfileIntW(L"outdoor", L"RGBDayTop.r", 81, pIniFilename);
-  outdoor_day_top_g      = GetPrivateProfileIntW(L"outdoor", L"RGBDayTop.g", 121, pIniFilename);
-  outdoor_day_top_b      = GetPrivateProfileIntW(L"outdoor", L"RGBDayTop.b", 236, pIniFilename);
-  outdoor_day_bottom_r   = GetPrivateProfileIntW(L"outdoor", L"RGBDayBottom.r", 153, pIniFilename);
-  outdoor_day_bottom_g   = GetPrivateProfileIntW(L"outdoor", L"RGBDayBottom.g", 193, pIniFilename);
-  outdoor_day_bottom_b   = GetPrivateProfileIntW(L"outdoor", L"RGBDayBottom.b", 237, pIniFilename);
-  outdoor_night_top_r    = GetPrivateProfileIntW(L"outdoor", L"RGBNightTop.r", 0, pIniFilename);
-  outdoor_night_top_g    = GetPrivateProfileIntW(L"outdoor", L"RGBNightTop.g", 0, pIniFilename);
-  outdoor_night_top_b    = GetPrivateProfileIntW(L"outdoor", L"RGBNightTop.b", 0, pIniFilename);
-  outdoor_night_bottom_r = GetPrivateProfileIntW(L"outdoor", L"RGBNightBottom.r", 11, pIniFilename);
-  outdoor_night_bottom_g = GetPrivateProfileIntW(L"outdoor", L"RGBNightBottom.g", 41, pIniFilename);
-  outdoor_night_bottom_b = GetPrivateProfileIntW(L"outdoor", L"RGBNightBottom.b", 129, pIniFilename);
   pODMRenderParams->outdoor_no_mist = GetPrivateProfileIntW(L"debug", L"noMist", 0, pIniFilename);
   pODMRenderParams->bNoSky          = GetPrivateProfileIntW(L"outdoor", L"nosky", 0, pIniFilename);
   pODMRenderParams->bDoNotRenderDecorations = GetPrivateProfileIntW(L"render", L"nodecorations", 0, pIniFilename);
@@ -4488,12 +4435,6 @@
   outdoor_grid_band_3 = GetPrivateProfileIntW(L"outdoor", L"gridband3", 25, pIniFilename);
   pODMRenderParams->terrain_gamma  = GetPrivateProfileIntW(L"outdoor", L"ter_gamma", 0, pIniFilename);
   pODMRenderParams->building_gamme = GetPrivateProfileIntW(L"outdoor", L"bld_gamma", 0, pIniFilename);
-  mipmapping_terrain_mm1  = GetPrivateProfileIntW(L"mipmapping", L"ter_mm1", 2048, pIniFilename);
-  mipmapping_terrain_mm2  = GetPrivateProfileIntW(L"mipmapping", L"ter_mm2", 4096, pIniFilename);
-  mipmapping_terrain_mm3  = GetPrivateProfileIntW(L"mipmapping", L"ter_mm3", 8192, pIniFilename);
-  mipmapping_building_mm1 = GetPrivateProfileIntW(L"mipmapping", L"bld_mm1", 1024, pIniFilename);
-  mipmapping_building_mm2 = GetPrivateProfileIntW(L"mipmapping", L"bld_mm2", 2048, pIniFilename);
-  mipmapping_building_mm3 = GetPrivateProfileIntW(L"mipmapping", L"bld_mm3", 4096, pIniFilename);
   pODMRenderParams->shading_dist_shade     = GetPrivateProfileIntW(L"shading", L"dist_shade", 2048, pIniFilename);
   pODMRenderParams->shading_dist_shademist = GetPrivateProfileIntW(L"shading", L"dist_shademist", 4096, pIniFilename);
 
@@ -4543,11 +4484,6 @@
     while ( v4 < strlen(pDefaultGroundTexture) );
   }
 
-  texmapping_terrain_subdivsize  = GetPrivateProfileIntW(L"texmapping", L"terrain_subdivsize", 16, pIniFilename);
-  texmapping_terrain_subdivpow2  = GetPrivateProfileIntW(L"texmapping", L"terrain_subdivpow2", 4, pIniFilename);
-  texmapping_building_subdivsize = GetPrivateProfileIntW(L"texmapping", L"building_subdivsize", 32, pIniFilename);
-  texmapping_building_subdivpow2 = GetPrivateProfileIntW(L"texmapping", L"building_subdivpow2", 5, pIniFilename);
-
   MM7Initialization();
 }
 
@@ -4565,15 +4501,9 @@
       pODMRenderParams->bNoSky = false;
       LOBYTE(viewparams->field_20) = 0;
     }*/
-    mipmapping_terrain_mm1 = 1024;
-    mipmapping_terrain_mm2 = 2048;
-    mipmapping_building_mm1 = 1024;
-    mipmapping_building_mm2 = 2048;
     pODMRenderParams->shading_dist_shade = 2048;
     pODMRenderParams->terrain_gamma = 0;
     pODMRenderParams->building_gamme = 0;
-    mipmapping_terrain_mm3 = 4096;
-    mipmapping_building_mm3 = 4096;
     pODMRenderParams->shading_dist_shademist = 4096;
     pODMRenderParams->outdoor_no_wavy_water = 0;
     //_47F4D3_initialize_terrain_bezier_stuff(outdoor_grid_band_1, outdoor_grid_band_2, outdoor_grid_band_3);
--- a/mm7_4.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/mm7_4.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -2,8 +2,9 @@
 #define _CRT_SECURE_NO_WARNINGS
 #endif
 
+#include "mm7_data.h"
+#include "mm7_unsorted_subs.h"
 #include "Texture.h"
-#include "mm7_data.h"
 #include "VideoPlayer.h"
 #include "Sprites.h"
 #include "BSPModel.h"
@@ -1724,272 +1725,6 @@
   return v3 == 0 ? v2 : 0;
 }
 
-//----- (004A19D8) --------------------------------------------------------
-unsigned int BlendColors(unsigned int a1, unsigned int a2)
-{
-  /*signed __int64 v2; // ST10_8@1
-  double v3; // st7@1
-  float v4; // ST24_4@1
-  double v5; // ST10_8@1
-  int v6; // ST1C_4@1
-  float v7; // ST24_4@1
-  double v8; // ST10_8@1
-  unsigned __int8 v9; // ST20_1@1
-  float v10; // ST24_4@1
-  double v11; // ST10_8@1
-  float v12; // ST24_4@1
-  double v13; // ST08_8@1*/
-
-  uint alpha = (uint)floorf(0.5f + (a1 >> 24) / 255.0f *
-                                   (a2 >> 24) / 255.0f * 255.0f),
-       red = (uint)floorf(0.5f + ((a1 >> 16) & 0xFF) / 255.0f *
-                                 ((a2 >> 16) & 0xFF) / 255.0f * 255.0f),
-       green = (uint)floorf(0.5f + ((a1 >> 8) & 0xFF) / 255.0f *
-                                   ((a2 >> 8) & 0xFF) / 255.0f * 255.0f),
-       blue = (uint)floorf(0.5f + ((a1 >> 0) & 0xFF) / 255.0f *
-                                   ((a2 >> 0) & 0xFF) / 255.0f * 255.0f);
-  return (alpha << 24) | (red << 16) | (green << 8) | blue;
-  /*v2 = a1 >> 24;
-  v3 = (double)v2 / 255.0f;
-  HIDWORD(v2) = 0;
-  LODWORD(v2) = a2 >> 24;
-  v4 = v3 * (double)v2 / 255.0f * 255.0;
-  v5 = v4 + 6.7553994e15;
-  v6 = LODWORD(v5);
-  v7 = (double)((a1 >> 16) & 0xFFi64) / 255.0f * (double)((a2 >> 16) & 0xFF) * 0.0039215689 * 255.0;
-  v8 = v7 + 6.7553994e15;
-  v9 = LOBYTE(v8);
-  v10 = (double)((unsigned __int16)a1 >> 8) / 255.0f * (double)((unsigned __int16)a2 >> 8) / 255.0f * 255.0;
-  v11 = v10 + 6.7553994e15;
-  v12 = (double)(a1 & 0xFFi64) / 255.0f * (double)(unsigned __int8)a2 / 255.0f * 255.0;
-  v13 = v12 + 6.7553994e15;
-  return LOBYTE(v13) | ((LOBYTE(v11) | (((v6 << 8) | v9) << 8)) << 8);*/
-}
-
-void Present32(unsigned __int32 *src, unsigned int src_pitch,
-               unsigned __int32 *dst, unsigned int dst_pitch)
-{
-        for (uint y = 0; y < 8; ++y)
-          memcpy(dst + y * dst_pitch,
-                 src + y * src_pitch, src_pitch * sizeof(__int32));
-
-        for (uint y = 8; y < 352; ++y)
-        {
-          memcpy(dst + y * dst_pitch,
-                 src + y * src_pitch, 8 * sizeof(__int32));
-          memcpy(dst + 8 + game_viewport_width + y * dst_pitch,
-                 src + 8 + game_viewport_width + y * src_pitch, 174/*172*/ * sizeof(__int32));
-        }
-
-        for (uint y = 352; y < 480; ++y)
-          memcpy(dst + y * dst_pitch,
-                 src + y * src_pitch, src_pitch * sizeof(__int32));
-
-        for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y)
-        {
-          for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x)
-          {
-            //if (src[x + y * src_pitch] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask))
-            if (src[x + y * src_pitch] != 0xFFF8FCF8)  // FFF8FCF8 =  Color32(Color16(g_mask | b_mask))
-              dst[x + y * dst_pitch] = src[x + y * src_pitch];
-          }
-        }
-}
-
-//----- (004A597D) --------------------------------------------------------
-void Present_NoColorKey()
-{
-  //unsigned __int16 *v0; // eax@4
-  unsigned __int16 *v1; // esi@4
-  void *v2; // edi@4
-  //signed int v4; // ebx@4
-  //signed int v5; // ebx@6
-  //void *v6; // edi@7
-  //const void *v7; // esi@7
-  signed int v8; // ebx@8
-  int v9; // eax@10
-  unsigned int v10; // esi@10
-  unsigned __int32 v11; // edi@10
-  //int v12; // ecx@10
-  unsigned int v13; // ebx@10
-  int v14; // eax@11
-  int v15; // eax@13
-  int v16; // eax@14
-  int v17; // eax@16
-  HRESULT v18; // eax@22
-  DDSURFACEDESC2 Dst; // [sp+Ch] [bp-98h]@3
-  //int v20; // [sp+88h] [bp-1Ch]@10
-  int v21; // [sp+8Ch] [bp-18h]@10
-  __int32 v22; // [sp+90h] [bp-14h]@10
-  //unsigned __int32 v23; // [sp+94h] [bp-10h]@10
-  unsigned int v24; // [sp+98h] [bp-Ch]@4
-  //unsigned int _this; // [sp+9Ch] [bp-8h]@10
-  //LPVOID v26; // [sp+A0h] [bp-4h]@4
-
-  int r_mask = 0xF800;
-  int g_mask = 0x7E0;
-  int b_mask = 0x1F;
-
-  if ( !pRenderer->uNumSceneBegins )
-  {
-    if ( pRenderer->using_software_screen_buffer )
-    {
-      memset(&Dst, 0, 0x7Cu);
-      Dst.dwSize = 124;
-      if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) )
-      {
-        //v26 = Dst.lpSurface;
-        //pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface;
-        v24 = g_mask | b_mask | ((g_mask | b_mask) << 16);
-        //pRenderer->pCurrentlyLockedSoftSurface = pRenderer->pTargetSurface;
-        //pRenderer->uCurrentlyLockedSurfacePitch = Dst.lPitch;
-        //v1 = pRenderer->pTargetSurface;
-        v2 = Dst.lpSurface;
-
-
-        /*for (uint y = 0; y < 480; ++y)
-        {
-          auto pDst = (unsigned short *)((char *)Dst.lpSurface + y * Dst.lPitch);
-          for (uint x = 0; x < 640; ++x)
-            pDst[x] = pRenderer->uTargetRMask | pRenderer->uTargetBMask;
-        }*/
-
-        if (!FORCE_16_BITS)
-          Present32((unsigned __int32 *)pRenderer->pTargetSurface, pRenderer->uTargetSurfacePitch, (unsigned __int32 *)Dst.lpSurface, Dst.lPitch / 4);
-        else
-        {        
-        ushort* pSrc = (unsigned short *)pRenderer->pTargetSurface;
-        short* pDst = (__int16 *)Dst.lpSurface;
-
-        for (uint y = 0; y < 8; ++y)
-          memcpy(pDst + y * Dst.lPitch / 2,
-
-		  pSrc + y * 640, 640 * sizeof(__int16));
-
-        for (uint y = 8; y < 352; ++y)
-        {
-          memcpy(pDst + y * Dst.lPitch / 2,
-                 pSrc + y * 640, 8 * sizeof(__int16));
-          memcpy(pDst + 8 + game_viewport_width/*462*/ + y * Dst.lPitch / 2,
-                 pSrc + 8 + game_viewport_width/*462*/ + y * 640, 174/*172*/ * sizeof(__int16));
-        }
-
-        for (uint y = 352; y < 480; ++y)
-          memcpy(pDst + y * Dst.lPitch / 2,
-                 pSrc + y * 640, 640 * sizeof(__int16));
-
-
-        ushort* pSrc_x1y1 = pSrc + 640 * pViewport->uViewportTL_Y + pViewport->uViewportTL_X;
-        //_this = (unsigned int)&pSrc[2 * (((signed int)pViewport->uViewportX >> 1) + 320 * pViewport->uViewportY)];
-        short* pDst_x1y1 = pDst + Dst.lPitch * pViewport->uViewportTL_Y + pViewport->uViewportTL_X;
-        //v23 = (unsigned __int32)((char *)v26 + 4 * (((signed int)pViewport->uViewportX >> 1) + (Dst.lPitch >> 2) * pViewport->uViewportY));
-        v9 = ((signed int)pViewport->uViewportTL_X >> 1) - ((signed int)pViewport->uViewportBR_X >> 1);
-        //v20 = ((signed int)pViewport->uViewportZ >> 1) - ((signed int)pViewport->uViewportX >> 1);
-        v22 = 4 * ((Dst.lPitch / 4) + v9);
-        v21 = 4 * v9 + 1280;
-
-        //auto uNumLines = pViewport->uViewportW - pViewport->uViewportY + 1;
-        //v26 = (LPVOID)(pViewport->uViewportW - pViewport->uViewportY + 1);
-        v10 = (int)pSrc_x1y1;
-        v11 = (int)pDst_x1y1;
-        int uHalfWidth = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2;
-        v13 = v24;
-
-        for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y)
-        {
-          //memcpy(pDst + pViewport->uViewportX + y * Dst.lPitch / 2,
-          //       pSrc + pViewport->uViewportX + y * 640, (pViewport->uViewportZ - pViewport->uViewportX) * sizeof(__int16));
-          for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x)
-          {
-            if (pSrc[y * 640 + x] != (g_mask | b_mask))
-              pDst[y * Dst.lPitch / 2 + x] = pSrc[y * 640 + x];
-          }
-        }
-        }
-
-              ErrD3D(pRenderer->pBackBuffer4->Unlock(0));
-
-       /* while ( 1 )
-        {
-          while ( 1 )
-          {
-            v14 = *(int *)v10;
-            v10 += 4;
-            if ( v14 == v13 )
-              break;
-            if ( (short)v14 == (short)v13 )
-            {
-              *(int *)v11 = *(int *)v11 & 0xFFFF | v14 & 0xFFFF0000;
-              v11 += 4;
-              --uHalfWidth;
-              if ( !uHalfWidth )
-                goto LABEL_21;
-            }
-            else
-            {
-              v15 = __ROL__(v14, 16);
-              if ( (short)v15 == (short)v13 )
-              {
-                v17 = __ROR__(v15, 16);
-                *(int *)v11 = *(int *)v11 & 0xFFFF0000 | (unsigned __int16)v17;
-                v11 += 4;
-                --uHalfWidth;
-                if ( !uHalfWidth )
-                  goto LABEL_21;
-              }
-              else
-              {
-                v16 = __ROR__(v15, 16);
-                *(int *)v11 = v16;
-                v11 += 4;
-                --uHalfWidth;
-                if ( !uHalfWidth )
-                  goto LABEL_21;
-              }
-            }
-          }
-          v11 += 4;
-          --uHalfWidth;
-          if ( !uHalfWidth )
-          {
-LABEL_21:
-            v10 += v21;
-            v11 += v22;
-            uHalfWidth = v20;
-            if ( !--uNumLines )
-            {
-              ErrD3D(pRenderer->pBackBuffer4->Unlock(0));
-              return;
-            }
-          }
-        }*/
-      }
-    }
-  }
-}
-
-//----- (004A7063) --------------------------------------------------------
-unsigned int ModulateColor(unsigned int diffuse, float multiplier)
-{
-  float alpha = multiplier * ((diffuse >> 24) & 0xFF);
-  int   a = (int)floorf(alpha + 0.5f);
-  a = max(0, min(255, a));
-
-  float red = multiplier * ((diffuse >> 16) & 0xFF);
-  int   r = (int)floorf(red + 0.5f);
-  r = max(0, min(255, r));
-  
-  float green = multiplier * ((diffuse >> 8) & 0xFF);
-  int   g = (int)floorf(green + 0.5f);
-  g = max(0, min(255, g));
-  
-  float blue = multiplier * ((diffuse >> 0) & 0xFF);
-  int   b = (int)floorf(blue + 0.5f);
-  b = max(0, min(255, b));
-
-  return (a << 24) | (r << 16) | (g << 8) | b;
-}
-
 //----- (004B1447) --------------------------------------------------------
 void sub_4B1447_party_fine(int a1, int a2, int a3)
 {
--- a/mm7_5.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/mm7_5.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -34,16 +34,6 @@
   viewparams->bRedrawGameUI = 1;
 }
 
-//----- (0043648F) --------------------------------------------------------
-void Vec3_short__to_RenderVertexSoft(RenderVertexSoft *_this, Vec3_short_ *a2)
-{
-  _this->flt_2C = 0.0;
-
-  _this->vWorldPosition.x = a2->x;
-  _this->vWorldPosition.y = a2->y;
-  _this->vWorldPosition.z = a2->z;
-}
-
 //----- (004369DB) --------------------------------------------------------
 void Vec3_float_::Normalize()
 {
--- a/mm7_data.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/mm7_data.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -549,7 +549,6 @@
 	"isecdoor"
 };
 
-int bWinNT4_0; // weak
 std::array<__int16, 11> word_4E8152 = {0, 0, 0, 90, 8, 2, 70, 20, 10, 50, 30};
 
 char byte_4E94D0 = 5; // weak
@@ -1167,9 +1166,6 @@
 HWND hInsertCDWindow; // idb
 int uCPUSpeed; // weak
 char cMM7GameCDDriveLetter; // idb
-void *ptr_6A0D08;
-int _6A0D0C_txt_lod_loading; // weak
-int _6A0D10_txt_lod_loading__unused; // weak
 MENU_STATE sCurrentMenuID;
 unsigned int uGameState;
 int uDefaultTravelTime_ByFoot; // weak
@@ -1177,31 +1173,9 @@
 int day_fogrange_1; // weak
 int day_fogrange_2; // weak
 struct TileTable *pTileTable; // idb
-int texmapping_terrain_subdivsize; // weak
-int texmapping_terrain_subdivpow2; // weak
-int texmapping_building_subdivsize; // weak
-int texmapping_building_subdivpow2; // weak
-int mipmapping_building_mm1; // weak
-int mipmapping_building_mm2; // weak
-int mipmapping_building_mm3; // weak
-int mipmapping_terrain_mm1; // weak
-int mipmapping_terrain_mm2; // weak
-int mipmapping_terrain_mm3; // weak
 int outdoor_grid_band_1; // idb
 int outdoor_grid_band_2; // idb
 int outdoor_grid_band_3; // idb
-char outdoor_day_top_r; // weak
-char outdoor_day_top_g; // weak
-char outdoor_day_top_b; // weak
-char outdoor_day_bottom_r; // weak
-char outdoor_day_bottom_g; // weak
-char outdoor_day_bottom_b; // weak
-char outdoor_night_top_r; // weak
-char outdoor_night_top_g; // weak
-char outdoor_night_top_b; // weak
-char outdoor_night_bottom_r; // weak
-char outdoor_night_bottom_g; // weak
-char outdoor_night_bottom_b; // weak
 std::array<char, 777> pDefaultSkyTexture; // idb
 std::array<char, 16> byte_6BE124_cfg_textures_DefaultGroundTexture; // idb
 int _6BE134_odm_main_tile_group; // weak
@@ -1306,7 +1280,6 @@
 int dword_F8B1B0; // weak
 int gold_transaction_amount; // F8B1B4
 std::array<char *, 4> pShopOptions;
-_UNKNOWN unk_F8B1C8; // weak
 int dword_F8B1D8; // weak
 int dword_F8B1DC; // weak
 int dword_F8B1E0; // weak
@@ -1315,13 +1288,7 @@
 char dialogue_show_profession_details = false; // F8B1EC
 std::array<char, 777> byte_F8B1EF; // weak
 std::array<char, 4> byte_F8B1F0;
-int dword_F8B1F4; // weak
 
-
-//_UNKNOWN unk_F8BA50; // weak
-char byte_F8BC0C; // weak
 int bGameoverLoop = 0; // weak
 std::array<__int16, 104> intersect_face_vertex_coords_list_a; // word_F8BC48
-std::array<__int16, 104> intersect_face_vertex_coords_list_b; // word_F8BD18
-int dword_F93F20; // weak
-int dword_F93F70; // weak
+std::array<__int16, 104> intersect_face_vertex_coords_list_b; // word_F8BD18
\ No newline at end of file
--- a/mm7_data.h	Wed Jan 08 22:29:11 2014 +0200
+++ b/mm7_data.h	Thu Jan 09 01:37:34 2014 +0200
@@ -449,7 +449,6 @@
 extern std::array< std::array<int, 6>, 6> pNPCPortraits_y; // 004E5EE0
 extern std::array<const char *, 11> pHouse_ExitPictures;
 extern std::array<const char *, 11> _4E6BDC_loc_names;
-extern int bWinNT4_0; // weak
 extern std::array<__int16, 11> word_4E8152;
 extern std::array< std::array<char, 14>, 7> byte_4E8168;
 //extern stru355 stru_4E82A4;// = {0x20, 0x41, 0, 0x20, 0xFF0000, 0xFF00, 0xFF, 0xFF000000};  moved to texture.h
@@ -790,9 +789,6 @@
 extern HWND hInsertCDWindow; // idb
 extern int uCPUSpeed; // weak
 extern char cMM7GameCDDriveLetter; // idb
-extern void *ptr_6A0D08;
-extern int _6A0D0C_txt_lod_loading; // weak
-extern int _6A0D10_txt_lod_loading__unused; // weak
 extern enum MENU_STATE sCurrentMenuID;
 extern unsigned int uGameState;
 extern int uDefaultTravelTime_ByFoot; // weak
@@ -800,31 +796,9 @@
 extern int day_fogrange_1; // weak
 extern int day_fogrange_2; // weak
 extern struct TileTable *pTileTable; // idb
-extern int texmapping_terrain_subdivsize; // weak
-extern int texmapping_terrain_subdivpow2; // weak
-extern int texmapping_building_subdivsize; // weak
-extern int texmapping_building_subdivpow2; // weak
-extern int mipmapping_building_mm1; // weak
-extern int mipmapping_building_mm2; // weak
-extern int mipmapping_building_mm3; // weak
-extern int mipmapping_terrain_mm1; // weak
-extern int mipmapping_terrain_mm2; // weak
-extern int mipmapping_terrain_mm3; // weak
 extern int outdoor_grid_band_1; // idb
 extern int outdoor_grid_band_2; // idb
 extern int outdoor_grid_band_3; // idb
-extern char outdoor_day_top_r; // weak
-extern char outdoor_day_top_g; // weak
-extern char outdoor_day_top_b; // weak
-extern char outdoor_day_bottom_r; // weak
-extern char outdoor_day_bottom_g; // weak
-extern char outdoor_day_bottom_b; // weak
-extern char outdoor_night_top_r; // weak
-extern char outdoor_night_top_g; // weak
-extern char outdoor_night_top_b; // weak
-extern char outdoor_night_bottom_r; // weak
-extern char outdoor_night_bottom_g; // weak
-extern char outdoor_night_bottom_b; // weak
 extern std::array<char, 777> pDefaultSkyTexture; // idb
 extern std::array<char, 16> byte_6BE124_cfg_textures_DefaultGroundTexture; // idb
 extern int _6BE134_odm_main_tile_group; // weak
@@ -954,7 +928,6 @@
 extern int dword_F8B1B0; // weak
 extern int gold_transaction_amount; // F8B1B4
 extern std::array<char *, 4> pShopOptions;
-extern _UNKNOWN unk_F8B1C8; // weak
 extern int dword_F8B1D8; // weak
 extern int dword_F8B1DC; // weak
 extern int dword_F8B1E0; // weak
@@ -963,356 +936,8 @@
 extern char dialogue_show_profession_details; // weak
 extern std::array<char, 777> byte_F8B1EF; // weak
 extern std::array<char, 4> byte_F8B1F0;
-extern int dword_F8B1F4; // weak
 
-
-
-
-//extern _UNKNOWN unk_F8BA50; // weak
-extern char byte_F8BC0C; // weak
 extern int bGameoverLoop; // weak
 extern std::array<__int16, 104> intersect_face_vertex_coords_list_a; // word_F8BC48
 extern std::array<__int16, 104> intersect_face_vertex_coords_list_b; // word_F8BD18
-//extern _UNKNOWN unk_F8EA04; // weak
-//extern _UNKNOWN unk_F8F8F8; // weak
-extern int dword_F93F20; // weak
-extern int dword_F93F70; // weak
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-//-------------------------------------------------------------------------
-// Function declarations
-void constructors();
-
-void init_event_triggers();
-void check_event_triggers();
-
-
-
-
-void ShowIntroVideo_and_LoadingScreen();
-unsigned int GameOverMenu(void *ecx0);
-int __fastcall SpawnRandomTreasure(struct MapInfo *a1, struct SpawnPointMM7 *a2);
-void DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, struct Vec3_int_ *pVelocity);
-
-void MakeActorAIList_ODM();
-int MakeActorAIList_BLV();
-void UpdateActorAI();
-bool __fastcall sub_4070EF_prolly_detect_player(unsigned int uObjID, unsigned int uObj2ID);
-bool __fastcall sub_4075DB(int a1, int a2, int a3, struct BLVFace *face);
-bool __fastcall sub_4077F1(int a1, int a2, int a3, struct ODMFace *face, struct BSPVertexBuffer *a5);
-bool __fastcall sub_407A1C(int x, int z, int y, struct Vec3_int_ v); // idb
-void InitializeActors();
-void InitializeSpriteObjects();
-int __fastcall sub_4088E9(int a1, int a2, int a3, int a4, int a5, int a6);
-unsigned int SearchAliveActors(unsigned int *pTotalActors);
-unsigned int SearchActorByMonsterID(unsigned int *pTotalActors, int uMonsterID);
-unsigned int SearchActorByGroup(unsigned int *pTotalActors, unsigned int uGroup);
-unsigned int SearchActorByID(unsigned int *pTotalActors, unsigned int a2);
-void PrepareArcomage();
-void DoBlt_Copy(unsigned __int16 *pPixels); // idb
-void __fastcall ZBuffer_Fill(int *pZBuffer, int uTextureId, int iZValue);
-void __fastcall ZBuffer_DoFill(int *pZBuffer, struct Texture *pTex, int uZValue);
-void __fastcall ZBuffer_DoFill2(int *pZBuffer, struct Texture *a2, int a3); // idb
-void SetMoonPhaseNames();
-int __fastcall sub_410D99_get_map_index(int a1);
-void __fastcall LoadThumbnailLloydTexture(unsigned int uSlot, unsigned int uPlayer);
-void SetAttributeNames();
-void uGameUIFontMain_initialize();
-void uGameUIFontShadow_initialize();
-void Inventory_ItemPopupAndAlchemy();
-void UI_OnMouseRightClick(struct Vec2_int_ *_this);
-void UI_OnMouseLeftClick(int *pXY); // idb
-unsigned int UI_GetHealthManaAndOtherQualitiesStringColor(signed int current_pos, signed int base_pos);
-unsigned int __fastcall GetSizeInInventorySlots(unsigned int uNumPixels);
-struct GUIButton *__fastcall GUI_HandleHotkey(unsigned __int8 uHotkey); // idb
-int __fastcall GUI_ReplaceHotkey(unsigned __int8 uOldHotkey, unsigned __int8 uNewHotkey, char bFirstCall);
-void DrawBuff_remaining_time_string(int uY, struct GUIWindow *window, __int64 remaining_time, struct GUIFont *Font);
-bool UI_OnKeyDown(unsigned int vkKey);
-void GameUI_DrawItemInfo(struct ItemGen* inspect_item); // idb
-void MonsterPopup_Draw(unsigned int uActorID, struct GUIWindow *window);
-void LoadActualSkyFrame();
-void Sleep6Hours();
-void ChestUI_WritePointedObjectStatusString();
-void OnChestLeftClick();
-void GameUI_WritePointedObjectStatusString();
-void __fastcall GameUI_OnPlayerPortraitLeftClick(unsigned int uPlayerID); // idb
-void OnGameViewportClick();
-bool PauseGameDrawing();
-void SetUserInterface(enum PartyAlignment alignment, bool bReplace);
-void reset_some_strus_flt_2Cs();
-int __fastcall GetPortalScreenCoord(unsigned int uFaceID);
-bool PortalFrustrum(int pNumVertices, struct BspRenderer_PortalViewportData *a2, struct BspRenderer_PortalViewportData *near_portal, int uFaceID);
-int ODM_NearClip(unsigned int uVertexID); // idb
-int ODM_FarClip(unsigned int uNumVertices);
-bool sub_427769_isSpellQuickCastableOnShiftClick(unsigned int uSpellID);
-void _42777D_CastSpell_UseWand_ShootArrow(int a1, unsigned int uPlayerID, unsigned int a4, __int16 a5, int a6);
-void _42ECB5_PlayerAttacksActor();
-void  InitializeTurnBasedAnimations(void *);
-bool __fastcall sub_42F7EB_DropItemAt(unsigned int uSpriteID, int x, int y, int z, int a4, int count, int a7, unsigned __int16 attributes, ItemGen *a9);
-void __fastcall sub_42F960_create_object(int x, int y, int z); // idb
-void CompactLayingItemsList();
-void _42FA66_do_explosive_impact(int a1, int a2, int a3, int a4, __int16 a5, signed int a6);
-bool _42FB5C_check_spell(signed int spell_id);
-void sub_42FBDD();
-void CloseWindowBackground();
-void ProcessInputActions();
-void GameUI_MsgProc();
-void back_to_game();
-void GUI_MainMenuMessageProc();
-double get_shading_dist_mist();
-void Vec3_short__to_RenderVertexSoft(struct RenderVertexSoft *_this, struct Vec3_short_ *a2);
-void area_of_effect__damage_evaluate();
-void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int a2, struct Vec3_int_ *pPos, signed int a4);
-void __fastcall sub_43A97E(unsigned int uLayingItemID, signed int a2); // idb
-double __fastcall sub_43AE12(signed int a1);
-int __fastcall _43AFE3_calc_spell_damage(int a1, int a2, signed int a3, int a4);
-void ItemDamageFromActor(unsigned int uObjID, unsigned int uActorID, struct Vec3_int_ *pVelocity);
-void ActorDamageFromMonster(signed int attacker_id, unsigned int actor_id, struct Vec3_int_ *pVelocity, signed int a4);
-void CharacterUI_LoadPaperdollTextures();
-int __fastcall GetItemTextureFilename(char *pOut, signed int item_id, int index, int shoulder);
-bool IsDwarfPresentInParty(bool b);
-bool  ShouldLoadTexturesForRaceAndGender(unsigned int _this);
-void WetsuitOn(unsigned int uPlayerID); // idb
-void WetsuitOff(unsigned int uPlayerID);
-void __fastcall PrepareDrawLists_BLV();
-void FindBillboardsLightLevels_BLV();
-int __fastcall _43F55F_get_billboard_light_level(struct RenderBillboard *a1, int uBaseLightLevel);
-int __fastcall _43F5C8_get_point_light_level_with_respect_to_lights(unsigned int uBaseLightLevel, int uSectorID, float x, float y, float z);
-void PrepareBspRenderList_BLV();
-void PrepareDecorationsRenderList_BLV(unsigned int uDecorationID, unsigned int uSectorID);
-void PrepareActorRenderList_BLV();
-void PrepareItemsRenderList_BLV();
-void AddBspNodeToRenderList(unsigned int node_id);
-void __fastcall sub_4406BC(unsigned int node_id, unsigned int uFirstNode); // idb
-bool sub_44100D();
-__int16 __fastcall sub_441A4E(int a1);
-void DrawBook_Map_sub(unsigned int tl_x, unsigned int tl_y, unsigned int br_x, int br_y, int _48074); // idb
-void Initialize2DA();
-void LoadLevel_InitializeLevelStr();
-void OnMapLeave();
-void OnMapLoad();
-void Level_LoadEvtAndStr(const char *pLevelName);
-const char *GetMapBookHintText();//sub_444564
-char *GetEventHintString(unsigned int uEventID); // idb
-int GetTravelTime();
-void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4);
-unsigned int SkillToMastery(unsigned int skill_value);
-unsigned int __fastcall GetSpellColor(signed int a1);
-unsigned short * MakeScreenshot(signed int width, signed int height);
-void SaveScreenshot(const char *pFilename);
-void __fastcall LoadGame(unsigned int uSlot); // idb
-void SaveGame(bool IsAutoSAve, bool NotSaveWorld);
-void __fastcall DoSavegame(unsigned int uSlot); // idb
-void TryLoadLevelFromLOD();
-void sub_46080D();
-bool Initialize_GamesLOD_NewLOD();
-void SaveNewGame();
-void PrepareToLoadBLV(unsigned int bLoading);
-void __fastcall PrepareToLoadODM(unsigned int bLoading, struct ODMRenderParams *a2);
-void _461103_load_level_sub();
-void MainMenu_Loop();
-char sub_4637E0_is_there_popup_onscreen();
-void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows();
-void PrepareWorld(unsigned int _0_box_loading_1_fullscreen);
-void Game_DeinitializeAndTerminate(int exitCode); // idb
-void FinalInitialization();
-char Is_out15odm_underwater();
-void SetUnderwaterFog();
-void DoPrepareWorld(unsigned int bLoading, int _1_fullscreen_loading_2_box);
-int __fastcall ReadWindowsRegistryInt(const char *pKey, int uDefValue); // idb
-void __fastcall WriteWindowsRegistryString(const char *pKey, const char *pString);
-void __fastcall ReadWindowsRegistryString(const char *pKeyName, char *pOutString, int uBufLen, const char *pDefaultValue);
-void __fastcall WriteWindowsRegistryInt(const char *pKey, int val);
-bool __fastcall CheckMM7CD(char c);
-void SecondaryInitialization();
-void CreateAsyncMouse();
-void CreateAsyncKeyboard();
-void MM6_Initialize(const wchar_t *pIniFilename);
-void MM7Initialization();
-void SetCurrentMenuID(enum MENU_STATE); // idb
-enum MENU_STATE GetCurrentMenuID();
-void CreateMsgScrollWindow(signed int mscroll_id);
-void free_book_subwindow();
-void CreateScrollWindow();
-void OnPaperdollLeftClick();
-void OnPressSpace();
-char __fastcall DoInteractionWithTopmostZObject(int a1, int a2);
-void OracleDialogue();
-void __fastcall ClickNPCTopic(signed int uMessageParam);
-char * _4B254D_SkillMasteryTeacher(int _this);
-const char *ContractSelectText(int pEventCode);
-void SimpleHouseDialog();
-void CreateButtonInColumn(int a1, unsigned int a2);
-void FillAviableSkillsToTeach(int _this);
-void sub_4B3E1E();
-void DrawJoinGuildWindow(int pEventCode);
-void __fastcall _4B3FE5_training_dialogue(int a4);
-void NPCHireableDialogPrepare();
-void _4B4224_UpdateNPCTopics(int _this);
-void __fastcall DrawTextAtStatusBar(const char *Str, int a5);
-__int64 GetExperienceRequiredForLevel(int a1);
-void CheckBountyRespawnAndAward();
-void Arena_SelectionFightLevel();
-void ArenaFight();
-void SpellBookGenerator();
-void UI_CreateEndConversationButton();
-void __fastcall OnSelectShopDialogueOption(signed int uMessageParam);
-int HouseDialogPressCloseBtn();
-bool MerchandiseTest(ItemGen *item, int _2da_idx);
-void UIShop_Buy_Identify_Repair();
-bool __fastcall IsBModelVisible(unsigned int uModelID, int *unused);
-void ODM_LoadAndInitialize(const char *pLevelFilename, struct ODMRenderParams *thisa);
-unsigned int GetLevelFogColor();
-int __fastcall sub_47C3D7_get_fog_related_stuff(int a1, int a2, float a3);
-int __fastcall GetActorTintColor(int max_dim, int min_dim, float distance, int a4, struct RenderBillboard *a5);
-unsigned int WorldPosToGridCellX(int); // weak
-unsigned int WorldPosToGridCellZ(int); // weak
-int GridCellToWorldPosX(int); // weak
-int GridCellToWorldPosZ(int); // weak
-void sub_481ED9_MessWithODMRenderParams();
-bool IsTerrainSlopeTooHigh(int pos_x, int pos_y);
-int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *a3, int a4);
-void sub_487DA9();
-double GetFogDensityByTime(struct OutdoorLocation *_this);
-bool __fastcall HSV2RGB(float *a1, float *a2, float *a3, float a4, float a5, float a6);
-void __fastcall RGB2HSV(float *a1, float *a2, float a3, float a4, float a5, float *a6);
-signed int ReplaceHSV(unsigned int uColor, float a2, float gamma, float a4);
-bool PlayerCreation_Choose4Skills();
-int PlayerCreation_GetUnspentAttributePointCount();
-void LoadPlayerPortraintsAndVoices();
-void ReloadPlayerPortraits(int player_id, int face_id);
-void sub_491E3A();
-int CycleCharacter(bool backwards);
-void __fastcall Rest(unsigned int uHoursToSleep);
-void _493938_regenerate();
-void init_summoned_item(struct stru351_summoned_item *_this, __int64 duration);
-void _494035_timed_effects__water_walking_damage__etc();
-unsigned int __fastcall _494820_training_time(unsigned int a1);
-char *__fastcall sub_495366(unsigned __int8 a1, unsigned __int8 a2);
-const char *GetReputationString(signed int a1);
-char *BuildDialogueString(const char *lpsz, unsigned __int8 uPlayerID, struct ItemGen *a3, char *a4, int a5, __int64 *a6);
-void PlayerCreationUI_Draw();
-void PlayerCreationUI_Initialize();
-void DeleteCCharFont();
-bool PlayerCreationUI_Loop();
-unsigned int __fastcall GetMaxMipLevels(unsigned int uDim);
-bool CheckTextureStages();
-bool AreRenderSurfacesOk();
-unsigned int BlendColors(unsigned int c1, unsigned int c2); // weak
-void DoRenderBillboards_D3D();
-void Present_NoColorKey();
-unsigned int ModulateColor(unsigned int diffuse, float multiplier); // idb
-struct SoundHeader *FindSound_BinSearch(unsigned int uStart, unsigned int uEnd, const char *pName);
-struct SoundData *LoadSound(const char *pSoundName, struct SoundData *pOutBuff, unsigned int uID);
-int __fastcall sub_4AAEA6_transform(struct RenderVertexSoft *a1);
-int __fastcall sub_4AB66C(int, int); // weak
-int GetSoundStrengthByDistanceFromParty(int x, int y, int z);
-struct _DIG_DRIVER *Audio_GetFirstHardwareDigitalDriver(void);
-void PlayLevelMusic();
-unsigned int __fastcall sub_4B0E07(unsigned int uFaceID); // idb
-void sub_4B1447_party_fine(int a1, int a2, int a3);
-void sub_4B1523(int *_this);
-void ShowPopupShopItem();
-void RestAndHeal(__int64 uNumMinutes); // idb
-void GetHouseGoodbyeSpeech();
-int __fastcall _46A6AC_spell_render(int a1, int a2, int a3);
-int __fastcall _46A6AC_spell_render_d3d(int a1, int a2, int a3);
-int __fastcall _46A89E_immolation_effect(int a1, int a2, int a3);
-int sub_46A99B();
-unsigned int GetGravityStrength();
-void UpdateUserInput_and_MapSpecificStuff();
-void BLV_UpdateUserInputAndOther();
-void ODM_UpdateUserInputAndOther();
-bool __fastcall _46BFFA_check_object_intercept(unsigned int uLayingItemID, signed int a2);
-int BLV_GetFloorLevel(int x, int y, int z, unsigned int uSectorID, unsigned int *pFaceID);
-int ODM_GetFloorLevel(int X, signed int Y, int Z, int, int *pOnWater, int *bmodel_pid, int bWaterWalk);
-int GetCeilingHeight(int Party_X, signed int Party_Y, int Party_ZHeight, int pFaceID);
-void ODM_GetTerrainNormalAt(int pos_x, int pos_z, Vec3_int_ *out);
-unsigned int __fastcall sub_46DEF2(signed int a2, unsigned int uLayingItemID);
-void _46E0B2_collide_against_decorations();
-void __fastcall _46E26D_collide_against_sprites(signed int a1, signed int a2);
-int _46E44E_collide_against_faces_and_portals(unsigned int b1); // idb
-int __fastcall _46E889_collide_against_bmodels(unsigned int ecx0);
-int collide_against_floor(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID); // idb
-void __fastcall _46ED8A_collide_against_sprite_objects(unsigned int _this);
-int _46EF01_collision_chech_player(int a1); // idb
-int _46F04E_collide_against_portals();
-void BLV_UpdateDoors();
-void UpdateActors_BLV();
-void UpdateActors_ODM();
-void UpdateObjects();
-int collide_against_floor_approximate(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID); // idb
-void BLV_ProcessPartyActions();
-void ODM_ProcessPartyActions();
-bool sub_47531C(int a1, int *a2, int pos_x, int pos_y, int pos_z, int dir_x, int dir_y, int dir_z, struct BLVFace *face, int a10);
-bool sub_4754BF(int a1, int *a2, int X, int Y, int Z, int dir_x, int dir_y, int dir_z, struct BLVFace *face, int a10, int a11);
-int sub_475665(struct BLVFace *face, int a2, __int16 a3);
-bool __fastcall sub_4759C9(struct BLVFace *face, int a2, int a3, __int16 a4);
-bool __fastcall sub_475D85(Vec3_int_ *a1, Vec3_int_ *a2, int *a3, struct BLVFace *a4);
-bool __fastcall sub_475F30(int *a1, struct BLVFace *a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9);
-void sub_4452BB();
-const char *GetProfessionActionText(int a1);
-struct NPCData *__fastcall GetNPCData(signed int npcid);
-struct NPCData * GetNewNPCData(signed int npcid, int* npc_indx);
-int __fastcall GetGreetType(signed int SpeakingNPC_ID);
-void  DialogueEnding();
-void PrepareHouse(enum HOUSE_ID house); // idb
-bool EnterHouse(enum HOUSE_ID uHouseID);
-bool sub_4465DF_check_season(int a1);
-int __fastcall IsActorAlive(unsigned int uType, unsigned int uParam, unsigned int uNumAlive); // idb
-int NPC_EventProcessor(int npc_event_id, int entry_line = 0);
-void __fastcall sub_448518_npc_set_item(int npc, unsigned int item, int a3);
-void __fastcall sub_44861E_set_texture(unsigned int uFaceCog, const char *pFilename);
-void __fastcall SetDecorationSprite(uint16_t uCog, bool bHide, const char *pFileName); // idb
-void __fastcall sub_44892E_set_faces_bit(int sCogNumber, int bit, int on);
-void __fastcall ToggleActorGroupFlag(unsigned int uGroupID, unsigned int uFlag, unsigned int bToggle);
-void  GameUI_StatusBar_UpdateTimedString(unsigned int bForceHide); // idb
-void OnTimer(int);
-void __fastcall sub_448CF4_spawn_monsters(__int16 typeindex, __int16 level, int count, int x, int y, int z, int group, unsigned int uUniqueName);
-void __fastcall EventCastSpell(int uSpellID, int uSkillLevel, int uSkill, int fromx, int fromy, int fromz, int tox, int toy, int toz);//sub_448DF8
-void Door_switch_animation(unsigned int uDoorID, int a2); // idb: sub_449A49
-bool _449B57_test_bit(unsigned __int8 *a1, __int16 a2);
-void _449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle); // idb
-void ShowStatusBarString(const char *pString, unsigned int uNumSeconds);
-void ShowNothingHereStatus();
-int const_2();
-bool TeleportToNWCDungeon();
-void SpawnEncounter(struct MapInfo *pMapInfo, struct SpawnPointMM7 *spawn, int a3, int a4, int a5);
-int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3);
-int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6);
-int __fastcall _45063B_spawn_some_monster(struct MapInfo *a1, int a2);
-void RespawnGlobalDecorations();
-bool __fastcall SpawnActor(unsigned int uMonsterID);
-int GetAlertStatus();
-int integer_sqrt(int val);
-int __fastcall MakeColorMaskFromBitDepth(int a1);
-void __fastcall fill_pixels_fast(unsigned int a1, unsigned __int16 *pPixels, unsigned int uNumPixels);
-int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides); // idb
-inline int round_to_int(float x) { return (int)floor(x + 0.5f); }
-inline void __fastcall memset32(void *ptr, unsigned __int32 value, int count)
-{
-  unsigned __int32* p = (unsigned __int32 *)ptr;
-  for ( int i=0; i < count; i++ )
-    *p++ = value;
-}
-#define ErrD3D(hr) do {extern void ErrHR(HRESULT, const char *, const char *, const char *, int); ErrHR(hr, "Direct3D", __FUNCTION__, __FILE__, __LINE__);} while(0)
-
-
-namespace zlib
-{
-  int MemZip(void *dest, unsigned int *destLen, void *source, unsigned int sourceLen);
-  int MemUnzip(void *dest, unsigned int *destLen, const void *source, unsigned int sourceLen);
-};
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mm7_unsorted_subs.h	Thu Jan 09 01:37:34 2014 +0200
@@ -0,0 +1,319 @@
+#pragma once
+
+
+
+//-------------------------------------------------------------------------
+// Function declarations
+void constructors();
+
+void init_event_triggers();
+void check_event_triggers();
+
+
+
+
+void ShowIntroVideo_and_LoadingScreen();
+unsigned int GameOverMenu(void *ecx0);
+int __fastcall SpawnRandomTreasure(struct MapInfo *a1, struct SpawnPointMM7 *a2);
+void DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, struct Vec3_int_ *pVelocity);
+
+void MakeActorAIList_ODM();
+int MakeActorAIList_BLV();
+void UpdateActorAI();
+bool __fastcall sub_4070EF_prolly_detect_player(unsigned int uObjID, unsigned int uObj2ID);
+bool __fastcall sub_4075DB(int a1, int a2, int a3, struct BLVFace *face);
+bool __fastcall sub_4077F1(int a1, int a2, int a3, struct ODMFace *face, struct BSPVertexBuffer *a5);
+bool __fastcall sub_407A1C(int x, int z, int y, struct Vec3_int_ v); // idb
+void InitializeActors();
+void InitializeSpriteObjects();
+int __fastcall sub_4088E9(int a1, int a2, int a3, int a4, int a5, int a6);
+unsigned int SearchAliveActors(unsigned int *pTotalActors);
+unsigned int SearchActorByMonsterID(unsigned int *pTotalActors, int uMonsterID);
+unsigned int SearchActorByGroup(unsigned int *pTotalActors, unsigned int uGroup);
+unsigned int SearchActorByID(unsigned int *pTotalActors, unsigned int a2);
+void PrepareArcomage();
+void DoBlt_Copy(unsigned __int16 *pPixels); // idb
+void __fastcall ZBuffer_Fill(int *pZBuffer, int uTextureId, int iZValue);
+void __fastcall ZBuffer_DoFill(int *pZBuffer, struct Texture *pTex, int uZValue);
+void __fastcall ZBuffer_DoFill2(int *pZBuffer, struct Texture *a2, int a3); // idb
+void SetMoonPhaseNames();
+int __fastcall sub_410D99_get_map_index(int a1);
+void __fastcall LoadThumbnailLloydTexture(unsigned int uSlot, unsigned int uPlayer);
+void SetAttributeNames();
+void uGameUIFontMain_initialize();
+void uGameUIFontShadow_initialize();
+void Inventory_ItemPopupAndAlchemy();
+void UI_OnMouseRightClick(struct Vec2_int_ *_this);
+void UI_OnMouseLeftClick(int *pXY); // idb
+unsigned int UI_GetHealthManaAndOtherQualitiesStringColor(signed int current_pos, signed int base_pos);
+unsigned int __fastcall GetSizeInInventorySlots(unsigned int uNumPixels);
+struct GUIButton *__fastcall GUI_HandleHotkey(unsigned __int8 uHotkey); // idb
+int __fastcall GUI_ReplaceHotkey(unsigned __int8 uOldHotkey, unsigned __int8 uNewHotkey, char bFirstCall);
+void DrawBuff_remaining_time_string(int uY, struct GUIWindow *window, __int64 remaining_time, struct GUIFont *Font);
+bool UI_OnKeyDown(unsigned int vkKey);
+void GameUI_DrawItemInfo(struct ItemGen* inspect_item); // idb
+void MonsterPopup_Draw(unsigned int uActorID, struct GUIWindow *window);
+void LoadActualSkyFrame();
+void Sleep6Hours();
+void ChestUI_WritePointedObjectStatusString();
+void OnChestLeftClick();
+void GameUI_WritePointedObjectStatusString();
+void __fastcall GameUI_OnPlayerPortraitLeftClick(unsigned int uPlayerID); // idb
+void OnGameViewportClick();
+bool PauseGameDrawing();
+void SetUserInterface(enum PartyAlignment alignment, bool bReplace);
+void reset_some_strus_flt_2Cs();
+int __fastcall GetPortalScreenCoord(unsigned int uFaceID);
+bool PortalFrustrum(int pNumVertices, struct BspRenderer_PortalViewportData *a2, struct BspRenderer_PortalViewportData *near_portal, int uFaceID);
+int ODM_NearClip(unsigned int uVertexID); // idb
+int ODM_FarClip(unsigned int uNumVertices);
+bool sub_427769_isSpellQuickCastableOnShiftClick(unsigned int uSpellID);
+void _42777D_CastSpell_UseWand_ShootArrow(int a1, unsigned int uPlayerID, unsigned int a4, __int16 a5, int a6);
+void _42ECB5_PlayerAttacksActor();
+void  InitializeTurnBasedAnimations(void *);
+bool __fastcall sub_42F7EB_DropItemAt(unsigned int uSpriteID, int x, int y, int z, int a4, int count, int a7, unsigned __int16 attributes, ItemGen *a9);
+void __fastcall sub_42F960_create_object(int x, int y, int z); // idb
+void CompactLayingItemsList();
+void _42FA66_do_explosive_impact(int a1, int a2, int a3, int a4, __int16 a5, signed int a6);
+bool _42FB5C_check_spell(signed int spell_id);
+void sub_42FBDD();
+void CloseWindowBackground();
+void ProcessInputActions();
+void GameUI_MsgProc();
+void back_to_game();
+void GUI_MainMenuMessageProc();
+double get_shading_dist_mist();
+void area_of_effect__damage_evaluate();
+void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int a2, struct Vec3_int_ *pPos, signed int a4);
+void __fastcall sub_43A97E(unsigned int uLayingItemID, signed int a2); // idb
+double __fastcall sub_43AE12(signed int a1);
+int __fastcall _43AFE3_calc_spell_damage(int a1, int a2, signed int a3, int a4);
+void ItemDamageFromActor(unsigned int uObjID, unsigned int uActorID, struct Vec3_int_ *pVelocity);
+void ActorDamageFromMonster(signed int attacker_id, unsigned int actor_id, struct Vec3_int_ *pVelocity, signed int a4);
+void CharacterUI_LoadPaperdollTextures();
+int __fastcall GetItemTextureFilename(char *pOut, signed int item_id, int index, int shoulder);
+bool IsDwarfPresentInParty(bool b);
+bool  ShouldLoadTexturesForRaceAndGender(unsigned int _this);
+void WetsuitOn(unsigned int uPlayerID); // idb
+void WetsuitOff(unsigned int uPlayerID);
+void __fastcall PrepareDrawLists_BLV();
+void FindBillboardsLightLevels_BLV();
+int __fastcall _43F55F_get_billboard_light_level(struct RenderBillboard *a1, int uBaseLightLevel);
+int __fastcall _43F5C8_get_point_light_level_with_respect_to_lights(unsigned int uBaseLightLevel, int uSectorID, float x, float y, float z);
+void PrepareBspRenderList_BLV();
+void PrepareDecorationsRenderList_BLV(unsigned int uDecorationID, unsigned int uSectorID);
+void PrepareActorRenderList_BLV();
+void PrepareItemsRenderList_BLV();
+void AddBspNodeToRenderList(unsigned int node_id);
+void __fastcall sub_4406BC(unsigned int node_id, unsigned int uFirstNode); // idb
+bool sub_44100D();
+__int16 __fastcall sub_441A4E(int a1);
+void DrawBook_Map_sub(unsigned int tl_x, unsigned int tl_y, unsigned int br_x, int br_y, int _48074); // idb
+void Initialize2DA();
+void LoadLevel_InitializeLevelStr();
+void OnMapLeave();
+void OnMapLoad();
+void Level_LoadEvtAndStr(const char *pLevelName);
+const char *GetMapBookHintText();//sub_444564
+char *GetEventHintString(unsigned int uEventID); // idb
+int GetTravelTime();
+void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4);
+unsigned int SkillToMastery(unsigned int skill_value);
+unsigned int __fastcall GetSpellColor(signed int a1);
+unsigned short * MakeScreenshot(signed int width, signed int height);
+void SaveScreenshot(const char *pFilename);
+void __fastcall LoadGame(unsigned int uSlot); // idb
+void SaveGame(bool IsAutoSAve, bool NotSaveWorld);
+void __fastcall DoSavegame(unsigned int uSlot); // idb
+bool Initialize_GamesLOD_NewLOD();
+void SaveNewGame();
+void PrepareToLoadBLV(unsigned int bLoading);
+void __fastcall PrepareToLoadODM(unsigned int bLoading, struct ODMRenderParams *a2);
+void _461103_load_level_sub();
+void MainMenu_Loop();
+char sub_4637E0_is_there_popup_onscreen();
+void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows();
+void PrepareWorld(unsigned int _0_box_loading_1_fullscreen);
+void Game_DeinitializeAndTerminate(int exitCode); // idb
+void FinalInitialization();
+char Is_out15odm_underwater();
+void SetUnderwaterFog();
+void DoPrepareWorld(unsigned int bLoading, int _1_fullscreen_loading_2_box);
+int __fastcall ReadWindowsRegistryInt(const char *pKey, int uDefValue); // idb
+void __fastcall WriteWindowsRegistryString(const char *pKey, const char *pString);
+void __fastcall ReadWindowsRegistryString(const char *pKeyName, char *pOutString, int uBufLen, const char *pDefaultValue);
+void __fastcall WriteWindowsRegistryInt(const char *pKey, int val);
+bool __fastcall CheckMM7CD(char c);
+void SecondaryInitialization();
+void CreateAsyncMouse();
+void CreateAsyncKeyboard();
+void MM6_Initialize(const wchar_t *pIniFilename);
+void MM7Initialization();
+void SetCurrentMenuID(enum MENU_STATE); // idb
+enum MENU_STATE GetCurrentMenuID();
+void CreateMsgScrollWindow(signed int mscroll_id);
+void free_book_subwindow();
+void CreateScrollWindow();
+void OnPaperdollLeftClick();
+void OnPressSpace();
+char __fastcall DoInteractionWithTopmostZObject(int a1, int a2);
+void OracleDialogue();
+void __fastcall ClickNPCTopic(signed int uMessageParam);
+char * _4B254D_SkillMasteryTeacher(int _this);
+const char *ContractSelectText(int pEventCode);
+void SimpleHouseDialog();
+void CreateButtonInColumn(int a1, unsigned int a2);
+void FillAviableSkillsToTeach(int _this);
+void sub_4B3E1E();
+void DrawJoinGuildWindow(int pEventCode);
+void __fastcall _4B3FE5_training_dialogue(int a4);
+void NPCHireableDialogPrepare();
+void _4B4224_UpdateNPCTopics(int _this);
+void __fastcall DrawTextAtStatusBar(const char *Str, int a5);
+__int64 GetExperienceRequiredForLevel(int a1);
+void CheckBountyRespawnAndAward();
+void Arena_SelectionFightLevel();
+void ArenaFight();
+void SpellBookGenerator();
+void UI_CreateEndConversationButton();
+void __fastcall OnSelectShopDialogueOption(signed int uMessageParam);
+int HouseDialogPressCloseBtn();
+bool MerchandiseTest(ItemGen *item, int _2da_idx);
+void UIShop_Buy_Identify_Repair();
+bool __fastcall IsBModelVisible(unsigned int uModelID, int *unused);
+void ODM_LoadAndInitialize(const char *pLevelFilename, struct ODMRenderParams *thisa);
+unsigned int GetLevelFogColor();
+int __fastcall sub_47C3D7_get_fog_related_stuff(int a1, int a2, float a3);
+int __fastcall GetActorTintColor(int max_dim, int min_dim, float distance, int a4, struct RenderBillboard *a5);
+unsigned int WorldPosToGridCellX(int); // weak
+unsigned int WorldPosToGridCellZ(int); // weak
+int GridCellToWorldPosX(int); // weak
+int GridCellToWorldPosZ(int); // weak
+void sub_481ED9_MessWithODMRenderParams();
+bool IsTerrainSlopeTooHigh(int pos_x, int pos_y);
+int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *a3, int a4);
+void sub_487DA9();
+double GetFogDensityByTime(struct OutdoorLocation *_this);
+bool __fastcall HSV2RGB(float *a1, float *a2, float *a3, float a4, float a5, float a6);
+void __fastcall RGB2HSV(float *a1, float *a2, float a3, float a4, float a5, float *a6);
+signed int ReplaceHSV(unsigned int uColor, float a2, float gamma, float a4);
+bool PlayerCreation_Choose4Skills();
+int PlayerCreation_GetUnspentAttributePointCount();
+void LoadPlayerPortraintsAndVoices();
+void ReloadPlayerPortraits(int player_id, int face_id);
+void sub_491E3A();
+int CycleCharacter(bool backwards);
+void __fastcall Rest(unsigned int uHoursToSleep);
+void _493938_regenerate();
+void init_summoned_item(struct stru351_summoned_item *_this, __int64 duration);
+void _494035_timed_effects__water_walking_damage__etc();
+unsigned int __fastcall _494820_training_time(unsigned int a1);
+char *__fastcall sub_495366(unsigned __int8 a1, unsigned __int8 a2);
+const char *GetReputationString(signed int a1);
+char *BuildDialogueString(const char *lpsz, unsigned __int8 uPlayerID, struct ItemGen *a3, char *a4, int a5, __int64 *a6);
+void PlayerCreationUI_Draw();
+void PlayerCreationUI_Initialize();
+void DeleteCCharFont();
+bool PlayerCreationUI_Loop();
+unsigned int __fastcall GetMaxMipLevels(unsigned int uDim);
+bool CheckTextureStages();
+bool AreRenderSurfacesOk();
+void DoRenderBillboards_D3D();
+struct SoundHeader *FindSound_BinSearch(unsigned int uStart, unsigned int uEnd, const char *pName);
+struct SoundData *LoadSound(const char *pSoundName, struct SoundData *pOutBuff, unsigned int uID);
+int __fastcall sub_4AAEA6_transform(struct RenderVertexSoft *a1);
+int __fastcall sub_4AB66C(int, int); // weak
+int GetSoundStrengthByDistanceFromParty(int x, int y, int z);
+struct _DIG_DRIVER *Audio_GetFirstHardwareDigitalDriver(void);
+void PlayLevelMusic();
+unsigned int __fastcall sub_4B0E07(unsigned int uFaceID); // idb
+void sub_4B1447_party_fine(int a1, int a2, int a3);
+void sub_4B1523(int *_this);
+void ShowPopupShopItem();
+void RestAndHeal(__int64 uNumMinutes); // idb
+void GetHouseGoodbyeSpeech();
+int __fastcall _46A6AC_spell_render(int a1, int a2, int a3);
+int __fastcall _46A6AC_spell_render_d3d(int a1, int a2, int a3);
+int __fastcall _46A89E_immolation_effect(int a1, int a2, int a3);
+int sub_46A99B();
+unsigned int GetGravityStrength();
+void UpdateUserInput_and_MapSpecificStuff();
+void BLV_UpdateUserInputAndOther();
+void ODM_UpdateUserInputAndOther();
+bool __fastcall _46BFFA_check_object_intercept(unsigned int uLayingItemID, signed int a2);
+int BLV_GetFloorLevel(int x, int y, int z, unsigned int uSectorID, unsigned int *pFaceID);
+int ODM_GetFloorLevel(int X, signed int Y, int Z, int, int *pOnWater, int *bmodel_pid, int bWaterWalk);
+int GetCeilingHeight(int Party_X, signed int Party_Y, int Party_ZHeight, int pFaceID);
+void ODM_GetTerrainNormalAt(int pos_x, int pos_z, Vec3_int_ *out);
+unsigned int __fastcall sub_46DEF2(signed int a2, unsigned int uLayingItemID);
+void _46E0B2_collide_against_decorations();
+void __fastcall _46E26D_collide_against_sprites(signed int a1, signed int a2);
+int _46E44E_collide_against_faces_and_portals(unsigned int b1); // idb
+int __fastcall _46E889_collide_against_bmodels(unsigned int ecx0);
+int collide_against_floor(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID); // idb
+void __fastcall _46ED8A_collide_against_sprite_objects(unsigned int _this);
+int _46EF01_collision_chech_player(int a1); // idb
+int _46F04E_collide_against_portals();
+void BLV_UpdateDoors();
+void UpdateActors_BLV();
+void UpdateActors_ODM();
+void UpdateObjects();
+int collide_against_floor_approximate(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID); // idb
+void BLV_ProcessPartyActions();
+void ODM_ProcessPartyActions();
+bool sub_47531C(int a1, int *a2, int pos_x, int pos_y, int pos_z, int dir_x, int dir_y, int dir_z, struct BLVFace *face, int a10);
+bool sub_4754BF(int a1, int *a2, int X, int Y, int Z, int dir_x, int dir_y, int dir_z, struct BLVFace *face, int a10, int a11);
+int sub_475665(struct BLVFace *face, int a2, __int16 a3);
+bool __fastcall sub_4759C9(struct BLVFace *face, int a2, int a3, __int16 a4);
+bool __fastcall sub_475D85(Vec3_int_ *a1, Vec3_int_ *a2, int *a3, struct BLVFace *a4);
+bool __fastcall sub_475F30(int *a1, struct BLVFace *a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9);
+void sub_4452BB();
+const char *GetProfessionActionText(int a1);
+struct NPCData *__fastcall GetNPCData(signed int npcid);
+struct NPCData * GetNewNPCData(signed int npcid, int* npc_indx);
+int __fastcall GetGreetType(signed int SpeakingNPC_ID);
+void  DialogueEnding();
+void PrepareHouse(enum HOUSE_ID house); // idb
+bool EnterHouse(enum HOUSE_ID uHouseID);
+bool sub_4465DF_check_season(int a1);
+int __fastcall IsActorAlive(unsigned int uType, unsigned int uParam, unsigned int uNumAlive); // idb
+int NPC_EventProcessor(int npc_event_id, int entry_line = 0);
+void __fastcall sub_448518_npc_set_item(int npc, unsigned int item, int a3);
+void __fastcall sub_44861E_set_texture(unsigned int uFaceCog, const char *pFilename);
+void __fastcall SetDecorationSprite(uint16_t uCog, bool bHide, const char *pFileName); // idb
+void __fastcall sub_44892E_set_faces_bit(int sCogNumber, int bit, int on);
+void __fastcall ToggleActorGroupFlag(unsigned int uGroupID, unsigned int uFlag, unsigned int bToggle);
+void  GameUI_StatusBar_UpdateTimedString(unsigned int bForceHide); // idb
+void OnTimer(int);
+void __fastcall sub_448CF4_spawn_monsters(__int16 typeindex, __int16 level, int count, int x, int y, int z, int group, unsigned int uUniqueName);
+void __fastcall EventCastSpell(int uSpellID, int uSkillLevel, int uSkill, int fromx, int fromy, int fromz, int tox, int toy, int toz);//sub_448DF8
+void Door_switch_animation(unsigned int uDoorID, int a2); // idb: sub_449A49
+bool _449B57_test_bit(unsigned __int8 *a1, __int16 a2);
+void _449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle); // idb
+void ShowStatusBarString(const char *pString, unsigned int uNumSeconds);
+void ShowNothingHereStatus();
+int const_2();
+bool TeleportToNWCDungeon();
+void SpawnEncounter(struct MapInfo *pMapInfo, struct SpawnPointMM7 *spawn, int a3, int a4, int a5);
+int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3);
+int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6);
+int __fastcall _45063B_spawn_some_monster(struct MapInfo *a1, int a2);
+void RespawnGlobalDecorations();
+bool __fastcall SpawnActor(unsigned int uMonsterID);
+int GetAlertStatus();
+int integer_sqrt(int val);
+int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides); // idb
+inline int round_to_int(float x) { return (int)floor(x + 0.5f); }
+inline void __fastcall memset32(void *ptr, unsigned __int32 value, int count)
+{
+  unsigned __int32* p = (unsigned __int32 *)ptr;
+  for ( int i=0; i < count; i++ )
+    *p++ = value;
+}
+
+
+namespace zlib
+{
+  int MemZip(void *dest, unsigned int *destLen, void *source, unsigned int sourceLen);
+  int MemUnzip(void *dest, unsigned int *destLen, const void *source, unsigned int sourceLen);
+};
\ No newline at end of file
--- a/stru6.cpp	Wed Jan 08 22:29:11 2014 +0200
+++ b/stru6.cpp	Thu Jan 09 01:37:34 2014 +0200
@@ -28,6 +28,29 @@
 
 
 
+//----- (004A7063) --------------------------------------------------------
+unsigned int ModulateColor(unsigned int diffuse, float multiplier)
+{
+  float alpha = multiplier * ((diffuse >> 24) & 0xFF);
+  int   a = (int)floorf(alpha + 0.5f);
+  a = max(0, min(255, a));
+
+  float red = multiplier * ((diffuse >> 16) & 0xFF);
+  int   r = (int)floorf(red + 0.5f);
+  r = max(0, min(255, r));
+  
+  float green = multiplier * ((diffuse >> 8) & 0xFF);
+  int   g = (int)floorf(green + 0.5f);
+  g = max(0, min(255, g));
+  
+  float blue = multiplier * ((diffuse >> 0) & 0xFF);
+  int   b = (int)floorf(blue + 0.5f);
+  b = max(0, min(255, b));
+
+  return (a << 24) | (r << 16) | (g << 8) | b;
+}
+
+
 //----- (0042620A) --------------------------------------------------------
 bool sr_42620A(RenderVertexSoft *p)
 {