changeset 2572:d87bfbd3bb3b

Step towards unification of Texture and RGBTexture (class Image)
author a.parshin
date Sat, 05 Mar 2016 01:51:54 +0200
parents cf29f444ddd7
children 0c67be4ec900
files Arcomage/Arcomage.cpp Build/Visual Studio 2015/World of Might and Magic.vcxproj Build/Visual Studio 2015/World of Might and Magic.vcxproj.filters Build/Visual Studio 2015/World of Might and Magic.vcxproj.user Engine/AssetsManager.cpp Engine/AssetsManager.h Engine/Engine.cpp Engine/Graphics/IRender.h Engine/Graphics/Indoor.cpp Engine/Graphics/Indoor.h Engine/Graphics/Outdoor.cpp Engine/Graphics/Outdoor.h Engine/Graphics/Render.cpp Engine/Graphics/Render.h Engine/Graphics/RenderD3D11.cpp Engine/Graphics/RenderD3D11.h Engine/Graphics/Texture.cpp Engine/Graphics/Texture.h Engine/LOD.cpp Engine/LOD.h Engine/MMT.cpp Engine/SaveLoad.cpp Engine/SaveLoad.h Engine/mm7_7.cpp Engine/mm7_data.cpp Engine/mm7_data.h GUI/GUIProgressBar.cpp GUI/GUIProgressBar.h GUI/GUIWindow.cpp GUI/GUIWindow.h GUI/UI/Books/LloydsBook.cpp GUI/UI/Books/MapBook.cpp GUI/UI/Spellbook.cpp GUI/UI/UICharacter.cpp GUI/UI/UIGame.h GUI/UI/UIHouses.cpp GUI/UI/UIMainMenu.cpp GUI/UI/UIPartyCreation.cpp GUI/UI/UIPopup.cpp GUI/UI/UIPopup.h GUI/UI/UISaveLoad.cpp GUI/UI/UITransition.cpp GUI/UI/UiGame.cpp Game/Game.cpp Game/Game.h Game/GameMenu.cpp Game/GameOver.cpp Game/MainMenu.cpp Game/MainMenu.h Game/MainMenuLoad.cpp Media/Audio/AudioPlayer.cpp Media/Audio/AudioPlayer.h Media/MediaPlayer.cpp Media/MediaPlayer.h OSAPI.cpp
diffstat 55 files changed, 1848 insertions(+), 1193 deletions(-) [+]
line wrap: on
line diff
--- a/Arcomage/Arcomage.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/Arcomage/Arcomage.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -3528,8 +3528,6 @@
 ArcomageGame::ArcomageGame()
 {
   field_4 = 0;
-  //RGBTexture::RGBTexture(&this->pGameBackground);
-  //RGBTexture::RGBTexture(&v1->pSprites);
   bGameInProgress = 0;
   field_F9 = 0;
 }
--- a/Build/Visual Studio 2015/World of Might and Magic.vcxproj	Mon Oct 05 00:19:13 2015 +0200
+++ b/Build/Visual Studio 2015/World of Might and Magic.vcxproj	Sat Mar 05 01:51:54 2016 +0200
@@ -92,6 +92,7 @@
   <ItemGroup>
     <ClCompile Include="..\..\Arcomage\Arcomage.cpp" />
     <ClCompile Include="..\..\Arcomage\ArcomageCards.cpp" />
+    <ClCompile Include="..\..\Engine\AssetsManager.cpp" />
     <ClCompile Include="..\..\Engine\Conditions.cpp" />
     <ClCompile Include="..\..\Engine\Engine.cpp" />
     <ClCompile Include="..\..\Engine\Events.cpp" />
@@ -121,7 +122,6 @@
     <ClCompile Include="..\..\Engine\LuaVM.cpp" />
     <ClCompile Include="..\..\Engine\MapInfo.cpp" />
     <ClCompile Include="..\..\Engine\mm7text_ru.cpp" />
-    <ClCompile Include="..\..\Engine\mm7_7.cpp" />
     <ClCompile Include="..\..\Engine\mm7_data.cpp" />
     <ClCompile Include="..\..\Engine\MMT.cpp" />
     <ClCompile Include="..\..\Engine\Objects\Actor.cpp" />
@@ -262,6 +262,7 @@
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\Arcomage\Arcomage.h" />
+    <ClInclude Include="..\..\Engine\AssetsManager.h" />
     <ClInclude Include="..\..\Engine\Autonotes.h" />
     <ClInclude Include="..\..\Engine\Awards.h" />
     <ClInclude Include="..\..\Engine\Conditions.h" />
--- a/Build/Visual Studio 2015/World of Might and Magic.vcxproj.filters	Mon Oct 05 00:19:13 2015 +0200
+++ b/Build/Visual Studio 2015/World of Might and Magic.vcxproj.filters	Sat Mar 05 01:51:54 2016 +0200
@@ -456,9 +456,6 @@
     <ClCompile Include="..\..\Engine\MapInfo.cpp">
       <Filter>Engine</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\Engine\mm7_7.cpp">
-      <Filter>Engine</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\Engine\mm7_data.cpp">
       <Filter>Engine</Filter>
     </ClCompile>
@@ -618,6 +615,9 @@
     <ClCompile Include="..\..\Engine\stru6.cpp">
       <Filter>Engine</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\Engine\AssetsManager.cpp">
+      <Filter>Engine</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\lib\libavcodec\avcodec.h">
@@ -1400,6 +1400,9 @@
     <ClInclude Include="..\..\Engine\stru6.h">
       <Filter>Engine</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\Engine\AssetsManager.h">
+      <Filter>Engine</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\lib\OpenAL\lib\x86\avcodec-55.def">
--- a/Build/Visual Studio 2015/World of Might and Magic.vcxproj.user	Mon Oct 05 00:19:13 2015 +0200
+++ b/Build/Visual Studio 2015/World of Might and Magic.vcxproj.user	Sat Mar 05 01:51:54 2016 +0200
@@ -4,6 +4,6 @@
     <LocalDebuggerCommand>$(OutDir)$(TargetName)$(TargetExt)</LocalDebuggerCommand>
     <LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
     <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
-    <LocalDebuggerCommandArguments>-nomarg -window -nointro -nologo -nocd</LocalDebuggerCommandArguments>
+    <LocalDebuggerCommandArguments>-nomarg -window -nointro -nologo -nocd -novideo</LocalDebuggerCommandArguments>
   </PropertyGroup>
 </Project>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Engine/AssetsManager.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -0,0 +1,87 @@
+#include "Engine/Engine.h"
+#include "Engine/AssetsManager.h"
+#include "Engine/LOD.h"
+
+AssetsManager *assets = new AssetsManager();
+
+
+
+Texture *AssetsManager::GetTexture(const char *name)
+{
+    //wchar_t wname[1024];
+    //swprintf(wname, L"%S", name);
+
+    return pIcons_LOD->LoadTexturePtr(name);
+}
+
+
+Texture *AssetsManager::GetTexture(const wchar_t *wname)
+{
+    char name[1024];
+    sprintf(name, "%S", name);
+
+    return this->GetTexture(name);
+}
+
+
+
+Image *AssetsManager::GetImage_16BitColorKey(const wchar_t *name, unsigned __int16 colorkey)
+{
+    Image *img = new Image();
+    if (!img->ColorKey_From_LOD(name, colorkey))
+    {
+        delete img;
+        img = nullptr;
+    }
+
+    return img;
+}
+
+Image *AssetsManager::GetImage_16BitAlpha(const wchar_t *name)
+{
+    Image *img = new Image();
+    if (!img->Alpha_From_LOD(name))
+    {
+        delete img;
+        img = nullptr;
+    }
+
+    return img;
+}
+
+Image *AssetsManager::GetImage_PCXFromIconsLOD(const wchar_t *name)
+{
+    Image *img = new Image();
+    if (!img->PCX_From_IconsLOD(name))
+    {
+        delete img;
+        img = nullptr;
+    }
+
+    return img;
+}
+
+Image *AssetsManager::GetImage_PCXFromNewLOD(const wchar_t *name)
+{
+    Image *img = new Image();
+    if (!img->PCX_From_NewLOD(name))
+    {
+        delete img;
+        img = nullptr;
+    }
+
+    return img;
+}
+
+
+Image *AssetsManager::GetImage_PCXFromFile(const wchar_t *name)
+{
+    Image *img = new Image();
+    if (!img->PCX_From_File(name))
+    {
+        delete img;
+        img = nullptr;
+    }
+
+    return img;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Engine/AssetsManager.h	Sat Mar 05 01:51:54 2016 +0200
@@ -0,0 +1,23 @@
+#pragma once
+#include "Engine/LOD.h"
+
+
+class AssetsManager
+{
+    public:
+        AssetsManager() {}
+
+        Texture *GetTexture(const char *name);
+        Texture *GetTexture(const wchar_t *name);
+
+        Image *GetImage_PCXFromFile(const wchar_t *filename);
+        Image *GetImage_PCXFromIconsLOD(const wchar_t *name);
+        Image *GetImage_PCXFromNewLOD(const wchar_t *name);
+
+        Image *GetImage_16BitColorKey(const wchar_t *name, unsigned __int16 colorkey);
+        Image *GetImage_16BitAlpha(const wchar_t *name);
+
+    protected:
+};
+
+extern AssetsManager *assets;
\ No newline at end of file
--- a/Engine/Engine.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/Engine/Engine.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -999,7 +999,7 @@
     static_assert(sizeof(LevelDecoration) == 0x20, "Wrong type size");
     static_assert(sizeof(KeyboardActionMapping) == 0x20C, "Wrong type size");
     static_assert(sizeof(UIAnimation) == 0xD, "Wrong type size");
-    static_assert(sizeof(SpawnPointMM7) == 0x18, "Wrong type size");
+    //static_assert(sizeof(SpawnPointMM7) == 0x18, "Wrong type size");
     static_assert(sizeof(ODMFace) == 0x134, "Wrong type size");
     static_assert(sizeof(BSPNode) == 0x8, "Wrong type size");
     static_assert(sizeof(BSPModel) == 0xBC, "Wrong type size");
@@ -1075,7 +1075,7 @@
     static_assert(sizeof(LevelDecoration) == 32, "Wrong type size");
     static_assert(sizeof(BLVLightMM7) == 16, "Wrong type size");
     static_assert(sizeof(BSPNode) == 8, "Wrong type size");
-    static_assert(sizeof(SpawnPointMM7) == 24, "Wrong type size");
+    //static_assert(sizeof(SpawnPointMM7) == 24, "Wrong type size");
     static_assert(sizeof(DDM_DLV_Header) == 40, "Wrong type size");
     static_assert(sizeof(Actor) == 836, "Wrong type size");
     static_assert(sizeof(SpriteObject) == 112, "Wrong type size");
@@ -1372,7 +1372,7 @@
             L"Files Missing", MB_ICONEXCLAMATION);
         return false;
     }
-    pIcons_LOD->dword_011BA4 = 0;
+    pIcons_LOD->_011BA4_debug_paletted_pixels_uncompressed = false;
 
     pEvents_LOD = new LODFile_IconsBitmaps;
     if (!pEvents_LOD->Load("data\\events.lod", "icons"))
@@ -1745,6 +1745,35 @@
 bool use_music_folder = false;
 bool for_refactoring = false;
 bool all_spells = true;
+bool bNoMargareth = false;
+
+void ParseCommandLine(const wchar_t *cmd)
+{
+    //if (wcsstr(pCmdLine, L"-usedefs"))
+    //  bDebugResouces = 1;
+    if (wcsstr(cmd, L"-window"))
+        dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_RUN_IN_WIDOW;
+
+    if (wcsstr(cmd, L"-nointro"))
+        bNoIntro = true;//dword_6BE364_game_settings_1 |= 4;
+    if (wcsstr(cmd, L"-nologo"))
+        bNoLogo = true;//dword_6BE364_game_settings_1 |= 8;
+    if (wcsstr(cmd, L"-nosound"))
+        bNoSound = true; //dword_6BE364_game_settings_1 |= 0x10;
+
+    bWalkSound = ReadWindowsRegistryInt("WalkSound", 1) != 0;
+    if (wcsstr(cmd, L"-nowalksound"))
+        bWalkSound = false;//dword_6BE364_game_settings_1 |= 0x20;
+    if (wcsstr(cmd, L"-novideo"))
+    {
+        dword_6BE364_game_settings_1 |= GAME_SETTINGS_NO_HOUSE_ANIM;
+        bNoVideo = true;
+    }
+    if (wcsstr(cmd, L"-nocd"))
+        bNoCD = true;
+    if (wcsstr(cmd, L"-nomarg"))
+        bNoMargareth = true;
+}
 
 //----- (00462C94) --------------------------------------------------------
 bool MM_Main(const wchar_t *pCmdLine)
@@ -1754,36 +1783,8 @@
     lua = new LuaVM;
     lua->Initialize();
 
-    bool bNoMargareth = false;
     if (pCmdLine && *pCmdLine)
-    {
-        //if (wcsstr(pCmdLine, L"-usedefs"))
-        //  bDebugResouces = 1;
-        if (wcsstr(pCmdLine, L"-window"))
-            dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_RUN_IN_WIDOW;
-
-        if (wcsstr(pCmdLine, L"-nointro"))
-            bNoIntro = true;//dword_6BE364_game_settings_1 |= 4;
-        if (wcsstr(pCmdLine, L"-nologo"))
-            bNoLogo = true;//dword_6BE364_game_settings_1 |= 8;
-        if (wcsstr(pCmdLine, L"-nosound"))
-            bNoSound = true; //dword_6BE364_game_settings_1 |= 0x10;
-
-        bWalkSound = ReadWindowsRegistryInt("WalkSound", 1) != 0;
-        if (wcsstr(pCmdLine, L"-nowalksound"))
-            bWalkSound = false;//dword_6BE364_game_settings_1 |= 0x20;
-        if (wcsstr(pCmdLine, L"-novideo"))
-        {
-            dword_6BE364_game_settings_1 |= GAME_SETTINGS_NO_HOUSE_ANIM;
-            bNoVideo = true;
-        }
-        if (wcsstr(pCmdLine, L"-nocd"))
-            bNoCD = true;
-        if (wcsstr(pCmdLine, L"-nomarg"))
-            bNoMargareth = true;
-    }
-
-    //_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF );//Ritor1: for memory test
+        ParseCommandLine(pCmdLine);
 
     if (!MM7_Initialize(640, 480))
     {
@@ -1794,21 +1795,16 @@
 
     pEventTimer->Pause();
 
-    SetUserInterface(PartyAlignment_Neutral, false);
-
-    for (uint i = 0; i < 20; ++i)
-        pWindowList[i] = nullptr;
-    uNumVisibleWindows = -1;
-    memset(pVisibleWindowsIdxs.data(), 0, sizeof(pVisibleWindowsIdxs));
+    GUIWindow::InitializeGUI();
+
 
     ShowLogoVideo();
     //ShowIntroVideo_and_LoadingScreen();
-    WriteWindowsRegistryInt("Ran once", 1);
+
     dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000;
 
-    //Ritor1: include
-    if (use_MMT)
-        MMT_MainMenu_Loop();
+    //if (use_MMT)
+    //    MMT_MainMenu_Loop();
 
     Log::Warning(L"MM: entering main loop");
     while (1)
@@ -1840,6 +1836,9 @@
                 if (!CreateParty_Loop())
                     break;
 
+
+                pParty->pPickedItem.uItemID = 0;
+
                 strcpy(pCurrentMapName, pStartingMapName);
                 bFlashQuestBook = true;
                 pMediaPlayer->PlayFullscreenMovie(MOVIE_Emerald, true);
@@ -1914,22 +1913,6 @@
                 break;
             }
         }
-        if (!bNoSound)
-        {
-            if (use_music_folder)
-            {
-                PlayAudio(L"Music\\14.mp3");
-                alSourcef(mSourceID, AL_GAIN, pSoundVolumeLevels[uMusicVolimeMultiplier]);
-            }
-            else if (pAudioPlayer->hAILRedbook)
-            {
-                pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f);
-                AIL_redbook_stop(pAudioPlayer->hAILRedbook);
-                unsigned int startms, end_ms;
-                AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &startms, &end_ms);
-                AIL_redbook_play(pAudioPlayer->hAILRedbook, startms + 1, end_ms);
-            }
-        }
     }
     //lua_close(L);
     pEngine->Deinitialize();
--- a/Engine/Graphics/IRender.h	Mon Oct 05 00:19:13 2015 +0200
+++ b/Engine/Graphics/IRender.h	Sat Mar 05 01:51:54 2016 +0200
@@ -70,8 +70,8 @@
     virtual void CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, struct RGBTexture *pTexture) = 0;
 
     virtual void DrawTextureNew(float u, float v, struct Texture *) = 0;
-    virtual void DrawTextureNew(float u, float v, struct RGBTexture *) = 0;
-    virtual void DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, struct RGBTexture *a4) = 0;
+    virtual void DrawTextureNew(float u, float v, struct Image *) = 0;
+    virtual void DrawTextureAlphaNew(float u, float v, struct Image *) = 0;
     virtual void DrawTextureIndexed(signed int x, signed int y, struct Texture *tex) = 0;
 
     virtual void ZBuffer_Fill_2(signed int a2, signed int a3, struct Texture *pTexture, int a5) = 0;
--- a/Engine/Graphics/Indoor.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/Engine/Graphics/Indoor.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -3000,10 +3000,11 @@
   {
     for (uint i = 0; i < pIndoor->uNumSpawnPoints; ++i )
     {
-      if ( pIndoor->pSpawnPoints[i].uKind == 3 )
-        SpawnEncounter(map_info, &pIndoor->pSpawnPoints[i], 0, 0, 0);
+        auto spawn = pIndoor->pSpawnPoints + i;
+      if (spawn->IsMonsterSpawn())
+        SpawnEncounter(map_info, spawn, 0, 0, 0);
       else
-        map_info->SpawnRandomTreasure(&pIndoor->pSpawnPoints[i]);
+        map_info->SpawnRandomTreasure(spawn);
     }
     RespawnGlobalDecorations();
   }
--- a/Engine/Graphics/Indoor.h	Mon Oct 05 00:19:13 2015 +0200
+++ b/Engine/Graphics/Indoor.h	Sat Mar 05 01:51:54 2016 +0200
@@ -344,6 +344,10 @@
   unsigned __int16 uIndex;
   unsigned __int16 uAttributes;
   unsigned int uGroup;
+
+  inline bool IsMonsterSpawn() const { return uKind == 3; }
+  inline bool IsTreasureSpawn() const { return uKind != 3; }
+
 };
 #pragma pack(pop)
 
--- a/Engine/Graphics/Outdoor.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/Engine/Graphics/Outdoor.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -852,7 +852,7 @@
 }
 
 //----- (0047CB57) --------------------------------------------------------
-int OutdoorLocationTerrain::_47CB57(int a1, int a2, int a3)
+int OutdoorLocationTerrain::_47CB57(unsigned char *pixels_8bit, int a2, int num_pixels)
 {
   signed int result; // eax@2
 //  unsigned __int16 *v5; // edx@3
@@ -896,9 +896,9 @@
     v17 = v5;
     v23 = 0.0;
     a2a = 0;
-    for ( i = 0; i < a3; ++i )
+    for ( i = 0; i < num_pixels; ++i )
     {
-      v9 = *(char *)(v8 + a1);
+      v9 = *(char *)(v8 + pixels_8bit);
       if ( v9 )
       {
         v10 = v5[v9];
@@ -2202,7 +2202,7 @@
   for ( uint i = 0; i < (signed int)pBitmaps_LOD->uNumLoadedFiles; ++i )
   {
     //if ( i != -1 ? (int)&pBitmaps_LOD->pTextures[i] : 0 )
-      pBitmaps_LOD->pTextures[i].uDecompressedSize = this->pTerrain._47CB57((int)pBitmaps_LOD->pTextures[i].pLevelOfDetail0_prolly_alpha_mask,
+      pBitmaps_LOD->pTextures[i].uDecompressedSize = this->pTerrain._47CB57(pBitmaps_LOD->pTextures[i].paletted_pixels,
                                                     pBitmaps_LOD->pTextures[i].palette_id2,
                                                     pBitmaps_LOD->pTextures[i].uTextureWidth * pBitmaps_LOD->pTextures[i].uTextureHeight);
   }
@@ -4515,21 +4515,12 @@
 		//v13 = 0;
 		for (uint i = 0; i < pOutdoor->uNumSpawnPoints; ++i)
 		{
-			//v12 = 0;
-			//while ( 1 )
-			//{
 			SpawnPointMM7* spawn = pOutdoor->pSpawnPoints + i;
-			//v6 = &pOutdoor->pSpawnPoints[v12 / 0x18];
-			if (spawn->uKind == 3)
+
+			if (spawn->IsMonsterSpawn())
 				SpawnEncounter(v4, spawn, 0, 0, 0);
 			else
 				v4->SpawnRandomTreasure(spawn);
-			//++v13;
-			//v12 += 24;
-			//if ( v13 >= (signed int)pOutdoor->uNumSpawnPoints )
-			//  break;
-			//v5 = 0;
-			//}
 		}
 		RespawnGlobalDecorations();
 	}
--- a/Engine/Graphics/Outdoor.h	Mon Oct 05 00:19:13 2015 +0200
+++ b/Engine/Graphics/Outdoor.h	Sat Mar 05 01:51:54 2016 +0200
@@ -56,7 +56,7 @@
   void _47C7A9();
   void Release();
   void FillDMap(int X, int Y, int W, int Z);
-  int _47CB57(int a1, int a2, int a3);
+  int _47CB57(unsigned char *pixels_8bit, int a2, int num_pixels);
   bool ZeroLandscape();
   bool Initialize();
 
--- a/Engine/Graphics/Render.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/Engine/Graphics/Render.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -6375,75 +6375,72 @@
   __debugbreak();
 }
 
-void Render::DrawTextureNew(float u, float v, RGBTexture *a4)
-{
-  DrawTextureRGB(640 * u, 480 * v, a4);
-}
-
-//----- (004A5BE3) --------------------------------------------------------
-void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4)
-{
-  int v4; // edi@3
-  unsigned __int16 *v6; // esi@3
-  unsigned int v8; // eax@5
-  unsigned int v9; // ebx@5
-  unsigned int v11; // eax@7
-  unsigned int v12; // ebx@8
-  unsigned int v15; // eax@14
-  int v19; // [sp+10h] [bp-8h]@3
-  int v23; // [sp+28h] [bp+10h]@3
-
-  if ( this->uNumSceneBegins && a4 )
-  {
-    v4 = a4->uWidth;
-    //v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch];
-    v6 = a4->pPixels;
-    v23 = a4->uHeight;
-    v19 = v4;
-    if ( this->bClip )
-    {
-      if ( (signed int)uOutX < (signed int)this->uClipX )
-      {
-        v8 = this->uClipX - uOutX;
-        v9 = uOutX - this->uClipX;
-        v8 *= 2;
-        v4 += v9;
-        v6 = (unsigned __int16 *)((char *)v6 + v8);
-        //v5 = (unsigned __int16 *)((char *)v5 + v8);
-      }
-      if ( (signed int)uOutY < (signed int)this->uClipY )
-      {
-        v11 = this->uClipY - uOutY;
-        v6 += v19 * v11;
-        v23 += uOutY - this->uClipY;
-        //v5 += this->uTargetSurfacePitch * v11;
-      }
-      v12 = max(this->uClipX, uOutX);
-      if ( (signed int)(v4 + v12) > (signed int)this->uClipZ )
-      {
-        v4 = this->uClipZ - max(this->uClipX, uOutX);
-      }
-      v15 = max(this->uClipY, uOutY);
-      if ( (signed int)(v15 + v23) > (signed int)this->uClipW )
-      {
-        v23 = this->uClipW - max(this->uClipY, uOutY);
-      }
-    }
-
-    for (int y = 0; y < v23; y++)
-    {
-      for (int x = 0; x < v4; x++)
-      {
-        WritePixel16(uOutX + x, uOutY + y, *v6);
-        //*v5 = *v6;
-        //++v5;
-        ++v6;
-      }
-      v6 += v19 - v4;
-      //v5 += this->uTargetSurfacePitch - v4;
-    }
-  }
-}
+
+void Render::DrawTextureNew(float u, float v, Image *bmp)
+{
+    unsigned __int16 *v6; // esi@3
+    unsigned int v8; // eax@5
+    unsigned int v11; // eax@7
+    unsigned int v12; // ebx@8
+    unsigned int v15; // eax@14
+    int v19; // [sp+10h] [bp-8h]@3
+
+    if (!bmp)
+        return;
+
+    unsigned int uOutX = 640 * u;
+    unsigned int uOutY = 480 * v;
+
+    int width = bmp->GetWidth();
+    int height = bmp->GetHeight();
+    v6 = (unsigned __int16 *)bmp->GetPixels(IMAGE_FORMAT_R5G6B5);
+
+        //v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch];
+        v19 = width;
+        if (this->bClip)
+        {
+            if ((signed int)uOutX < (signed int)this->uClipX)
+            {
+                v8 = this->uClipX - uOutX;
+                unsigned int v9 = uOutX - this->uClipX;
+                v8 *= 2;
+                width += v9;
+                v6 = (unsigned __int16 *)((char *)v6 + v8);
+                //v5 = (unsigned __int16 *)((char *)v5 + v8);
+            }
+            if ((signed int)uOutY < (signed int)this->uClipY)
+            {
+                v11 = this->uClipY - uOutY;
+                v6 += v19 * v11;
+                height += uOutY - this->uClipY;
+                //v5 += this->uTargetSurfacePitch * v11;
+            }
+            v12 = max(this->uClipX, uOutX);
+            if ((signed int)(width + v12) >(signed int)this->uClipZ)
+            {
+                width = this->uClipZ - max(this->uClipX, uOutX);
+            }
+            v15 = max(this->uClipY, uOutY);
+            if ((signed int)(v15 + height) > (signed int)this->uClipW)
+            {
+                height = this->uClipW - max(this->uClipY, uOutY);
+            }
+        }
+
+        for (int y = 0; y < height; y++)
+        {
+            for (int x = 0; x < width; x++)
+            {
+                WritePixel16(uOutX + x, uOutY + y, *v6);
+                //*v5 = *v6;
+                //++v5;
+                ++v6;
+            }
+            v6 += v19 - width;
+            //v5 += this->uTargetSurfacePitch - v4;
+        }
+}
+
 
 //----- (004A5D33) --------------------------------------------------------
 void Render::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture)
@@ -6539,7 +6536,7 @@
   if ( this->uNumSceneBegins && a4 && a4->pPalette16 )
   {
     //v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
-    v20 = a4->pLevelOfDetail0_prolly_alpha_mask;
+    v20 = a4->paletted_pixels;
     v5 = a4->uTextureWidth;
     v6 = a4->uTextureHeight;
     v19 = a4->uTextureWidth;
@@ -7103,7 +7100,7 @@
   {
     v5 = pTexture->uTextureHeight;
     //v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
-    v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask;
+    v19 = pTexture->paletted_pixels;
     v20 = pTexture->uTextureWidth;
     v18 = pTexture->uTextureWidth;
     int clipped_out_x = a2;
@@ -7202,7 +7199,7 @@
 
   if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 )
   {
-    v24 = a4->pLevelOfDetail0_prolly_alpha_mask;
+    v24 = a4->paletted_pixels;
     Width = a4->uTextureWidth;
     uHeight = a4->uTextureHeight;
     int clipped_out_x = x;
@@ -7317,7 +7314,7 @@
         {
           if ( a5->pPalette16 )
           {
-            v28 = a4->pLevelOfDetail0_prolly_alpha_mask;
+            v28 = a4->paletted_pixels;
             Width = a4->uTextureWidth;
             Height = a4->uTextureHeight;
             int clipped_out_x = a2;
@@ -7368,7 +7365,7 @@
               {
                   if ( *v28 )
                   {
-                    v20 = *(&a5->pLevelOfDetail0_prolly_alpha_mask[x & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1));
+                    v20 = *(&a5->paletted_pixels[x & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1));
                     if ( v20 >= a7 )
                     {
                       if ( v20 <= a8 )
@@ -7386,39 +7383,6 @@
               }
                 v28 += a4->uTextureWidth - Width;
             }
-
-            /*if ( v24 > 0 )
-            {
-              v23 = v22 - v25;
-              do
-              {
-                for ( i = 0; i < v25; ++v28 )
-                {
-                  if ( *v28 )
-                  {
-                    v20 = *(&v9->pLevelOfDetail0_prolly_alpha_mask[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1));
-                    if ( v20 >= a7 )
-                    {
-                      if ( v20 <= a8 )
-                      {
-                        v21 = a7 + (a6 + v20) % (2 * (a8 - a7));
-                        if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 )
-                          v21 = 2 * a8 - v21 - a7;
-                        v9 = a5;
-                        *v10 = a5->pPalette16[v21];
-                      }
-                    }
-                  }
-                  ++i;
-                  ++v10;
-                }
-                ++v27;
-                v10 += this->uTargetSurfacePitch - v25;
-                v28 += v23;
-              }
-              while ( v27 < v24 );
-            }*/
-
           }
         }
       }
@@ -7426,6 +7390,88 @@
   }
 }
 
+
+
+
+void Render::DrawTextureAlphaNew(float u, float v, Image *img)
+{
+    int uHeight; // ebx@4
+    unsigned int v11; // edx@9
+    unsigned int v12; // esi@12
+    unsigned int v13; // esi@15
+    unsigned int v15; // esi@18
+    //unsigned __int8 *v19; // [sp+18h] [bp-8h]@4
+    int uWidth; // [sp+1Ch] [bp-4h]@4
+
+    if (!uNumSceneBegins || !img)
+        return;
+
+    uHeight = img->GetHeight();
+    ///v19 = pTexture->paletted_pixels;
+    uWidth = img->GetWidth();
+
+    auto pixels = (const unsigned __int32 *)img->GetPixels(IMAGE_FORMAT_A8R8G8B8);
+
+    int uX = u * 640.0f;
+    int uY = v * 480.0f;
+    int clipped_out_x = uX;
+    int clipped_out_y = uY;
+    if (this->bClip)
+    {
+        if ((signed int)uX < (signed int)this->uClipX)
+        {
+            pixels += this->uClipX - uX;
+            uWidth += uX - this->uClipX;
+            clipped_out_x = uClipX;
+        }
+
+        uHeight = img->GetHeight();
+        if ((signed int)uY < (signed int)this->uClipY)
+        {
+            pixels += img->GetWidth() * (this->uClipY - uY);
+            uHeight = uY - this->uClipY + img->GetHeight();
+            clipped_out_y = uClipY;
+        }
+        v11 = this->uClipX;
+        if ((signed int)this->uClipX < (signed int)uX)
+            v11 = uX;
+
+        if ((signed int)(v11 + uWidth) >(signed int)this->uClipZ)
+        {
+            v12 = this->uClipX;
+            if ((signed int)this->uClipX < (signed int)uX)
+                v12 = uX;
+            uWidth = this->uClipZ - v12;
+        }
+        v13 = this->uClipY;
+        if ((signed int)this->uClipY < (signed int)uY)
+            v13 = uY;
+
+        if ((signed int)(uHeight + v13) >(signed int)this->uClipW)
+        {
+            v15 = this->uClipY;
+            if ((signed int)this->uClipY < (signed int)uY)
+                v15 = uY;
+            uHeight = this->uClipW - v15;
+        }
+    }
+
+    for (int y = 0; y < uHeight; ++y)
+    {
+        for (int x = 0; x < uWidth; ++x)
+        {
+            //if (*v19)
+            if (*pixels & 0xFF000000)
+                //WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v19]);
+                WritePixel16(clipped_out_x + x, clipped_out_y + y, Color16((*pixels >> 16) & 0xFF, (*pixels >> 8) & 0xFF, *pixels & 0xFF));
+            ++pixels;
+        }
+        pixels  += img->GetWidth() - uWidth;
+    }
+}
+
+
+
 //----- (004A6274) --------------------------------------------------------
 void Render::DrawTextureIndexedAlpha(unsigned int uX, unsigned int uY, Texture *pTexture)
 {
@@ -7444,7 +7490,7 @@
       if ( pTexture->pPalette16 )
       {
         uHeight = pTexture->uTextureHeight;
-        v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask;
+        v19 = pTexture->paletted_pixels;
         uWidth = pTexture->uTextureWidth;
 
         int clipped_out_x = uX;
@@ -7553,7 +7599,7 @@
       v6 = uOutY;
       v7 = pTexture->uTextureHeight;
       pZBuffer = &this->pActiveZBuffer[uOutX + window->GetWidth() * uOutY];
-      uOutYa = pTexture->pLevelOfDetail0_prolly_alpha_mask;
+      uOutYa = pTexture->paletted_pixels;
       v8 = pTexture->uTextureWidth;
       v20 = pTexture->uTextureWidth;
       v19 = pTexture->uTextureWidth;
@@ -7718,7 +7764,7 @@
       {
         v5 = tex->uTextureHeight;
         //pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch];
-        v19 = tex->pLevelOfDetail0_prolly_alpha_mask;
+        v19 = tex->paletted_pixels;
         v20 = tex->uTextureWidth;
         v18 = tex->uTextureWidth;
 
--- a/Engine/Graphics/Render.h	Mon Oct 05 00:19:13 2015 +0200
+++ b/Engine/Graphics/Render.h	Sat Mar 05 01:51:54 2016 +0200
@@ -252,8 +252,8 @@
   virtual void CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, struct RGBTexture *pTexture);
 
   virtual void DrawTextureNew(float u, float v, struct Texture *);
-  virtual void DrawTextureNew(float u, float v, struct RGBTexture *);
-  virtual void DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, struct RGBTexture *a4);
+  virtual void DrawTextureNew(float u, float v, struct Image *);
+  virtual void DrawTextureAlphaNew(float u, float v, struct Image *);
   virtual void DrawTextureIndexed(signed int x, signed int y, struct Texture *tex);
 
   virtual void ZBuffer_Fill_2(signed int a2, signed int a3, struct Texture *pTexture, int a5);
--- a/Engine/Graphics/RenderD3D11.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/Engine/Graphics/RenderD3D11.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -152,27 +152,28 @@
   DrawTexture((float)x / window->GetWidth(), (float)y / window->GetHeight(), tex->uTextureWidth, tex->uTextureHeight, tex->d3d11_srv, ui_blend_solid);
 }
 
+
+void RenderD3D11::DrawTextureAlphaNew(float u, float v, Image *img)
+{
+    __debugbreak();
+}
+
 void RenderD3D11::DrawTextureIndexedAlpha(unsigned int uX, unsigned int uY, struct Texture *a4) 
 {
   PrepareTextureIndexed(a4);
   DrawTexture((float)uX / window->GetWidth(), (float)uY / window->GetHeight(), a4->uTextureWidth, a4->uTextureHeight, a4->d3d11_srv, ui_blend_alpha);
 }
 
-void RenderD3D11::DrawTextureRGB(unsigned int uX, unsigned int uY, RGBTexture *a4)
-{
-  PrepareTexture(a4);
-  DrawTexture((float)uX / window->GetWidth(), (float)uY / window->GetHeight(), a4->uWidth, a4->uHeight, a4->d3d11_srv, ui_blend_solid);
-}
 
 void RenderD3D11::DrawTextureNew(float u, float v, Texture *tex)
 {
   __debugbreak();
 }
 
-void RenderD3D11::DrawTextureNew(float u, float v, RGBTexture *tex)
+
+void RenderD3D11::DrawTextureNew(float u, float v, Image *tex)
 {
-  PrepareTexture(tex);
-  DrawTexture(u, v, tex->uWidth, tex->uHeight, tex->d3d11_srv, ui_blend_solid);
+    __debugbreak();
 }
 
 void RenderD3D11::DrawText(signed int uX, signed int uY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned __int16 *pFontPalette, unsigned __int16 uFaceColor, unsigned __int16 uShadowColor)
@@ -817,7 +818,7 @@
   return pShader;
 }
 
-
+/*
 void RenderD3D11::PrepareTexture(RGBTexture *p)
 {
   if (!p->d3d11_srv)
@@ -866,7 +867,7 @@
     ErrorD3D(d3dd->CreateShaderResourceView(vram_texture, nullptr, (ID3D11ShaderResourceView **)&p->d3d11_srv));
     vram_texture->Release();
   }
-}
+}*/
 
 
 
@@ -904,7 +905,7 @@
     for (unsigned int y = 0; y < desc->Height; ++y)
       for (unsigned int x = 0; x < desc->Width; ++x)
       {
-        auto index = p->pLevelOfDetail0_prolly_alpha_mask[y * p->uTextureWidth + x];
+        auto index = p->paletted_pixels[y * p->uTextureWidth + x];
         auto src = p->pPalette16[index];
         auto dst = (unsigned int *)((char *)map.pData + y * map.RowPitch) + x;
 
--- a/Engine/Graphics/RenderD3D11.h	Mon Oct 05 00:19:13 2015 +0200
+++ b/Engine/Graphics/RenderD3D11.h	Sat Mar 05 01:51:54 2016 +0200
@@ -79,8 +79,8 @@
   virtual void CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture);
   
   virtual void DrawTextureNew(float u, float v, struct Texture *);
-  virtual void DrawTextureNew(float u, float v, struct RGBTexture *);
-  virtual void DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4);
+  virtual void DrawTextureNew(float u, float v, struct Image *);
+  virtual void DrawTextureAlphaNew(float u, float v, struct Image *);
   virtual void DrawTextureIndexed(signed int x, signed int y, struct Texture *tex);
 
   virtual void ZBuffer_Fill_2(signed int a2, signed int a3, struct Texture *pTexture, int a5);
@@ -165,7 +165,6 @@
 
   protected:
     void DrawTexture(float u, float v, int texture_width, int texture_height, ID3D11ShaderResourceView *srv, ID3D11BlendState *blend);
-    void PrepareTexture(struct RGBTexture *p);
     void PrepareTextureIndexed(struct Texture *p);
     ID3D11ShaderResourceView *PrepareFontTexture(unsigned char *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned short *pFontPalette, unsigned short uFaceColor, unsigned short uShadowColor);
     ID3D11ShaderResourceView *PrepareFontTexture(unsigned char *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned short *pFontPalette);
--- a/Engine/Graphics/Texture.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/Engine/Graphics/Texture.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -71,9 +71,11 @@
 Texture *pTex_moon_2_2;
 Texture *pTex_moon_ful;
 
-
-
-RGBTexture stru_506E40; // weak
+struct Texture *minimap_loop; // 5079D8
+struct Texture *_5079B4_compass; // 5079B4
+struct Texture *_5079C8_init_y; // 5079C8
+struct Texture *_5079CC_init_r; // 5079CC
+struct Texture *_5079D0_init_g; // 5079D0
 
 
 int uTextureID_RestUI_restb4; // weak
@@ -89,15 +91,6 @@
 int uTextureID_ar_up_up; // weak
 
 
-int uTextureID_507698; // weak
-int uTextureID_50769C; // weak
-int uTextureID_5076A0; // weak
-int uTextureID_5076A4; // weak
-int uTextureID_5076A8; // weak
-int uTextureID_5076AC; // weak
-int uTextureID_5076B0; // weak
-int uTextureID_5076B4; // weak
-int uTextureID_Parchment; // weak
 unsigned int uTextureID_mhp_yel;
 unsigned int uTextureID_mhp_red;
 unsigned int uTextureID_mhp_grn;
@@ -157,17 +150,10 @@
 unsigned int uTextureID_BarBlue;
 
 
-unsigned int uTextureID_right_panel; // weak
+Texture *right_panel;
+Texture *right_panel_loop;
 
 
-RGBTexture *pTexture_StatusBar = new RGBTexture;
-RGBTexture *pTexture_LeftFrame = new RGBTexture;
-RGBTexture *pTexture_TopFrame = new RGBTexture;
-RGBTexture *pTexture_BottomFrame = new RGBTexture;
-RGBTexture *pTexture_RightFrame = new RGBTexture;
-
-
-unsigned int uTextureID_right_panel_loop;
 
 
 Texture *pTexture_Leather;
@@ -200,9 +186,6 @@
 Texture pTex_F7CE30;
 
 
-RGBTexture stru_5773C4; // idb
-
-
 
 
 
@@ -371,7 +354,7 @@
   pSource = this;
   v1 = this;
   v2 = malloc(this->uDecompressedSize);
-  zlib::MemUnzip(v2, (unsigned int *)&pSource, v1->pLevelOfDetail0_prolly_alpha_mask, v1->uTextureSize);
+  zlib::MemUnzip(v2, (unsigned int *)&pSource, v1->paletted_pixels, v1->uTextureSize);
   return v2;
 }
 
@@ -387,12 +370,12 @@
 		__debugbreak();
 	}
 	
-	  free(pLevelOfDetail0_prolly_alpha_mask);
+	  free(paletted_pixels);
       free(pPalette16);
       free(pPalette24);
     
 
-    pLevelOfDetail0_prolly_alpha_mask = nullptr;
+      paletted_pixels = nullptr;
     pLevelOfDetail1 = nullptr;
     //pLevelOfDetail2 = nullptr;
     //pLevelOfDetail3 = nullptr;
@@ -505,7 +488,7 @@
   uWidthLn2 = 0;
   palette_id1 = 0;
   palette_id2 = 0;
-  pLevelOfDetail0_prolly_alpha_mask = nullptr;
+  paletted_pixels = nullptr;
   //pLevelOfDetail3 = nullptr;
   //pLevelOfDetail2 = nullptr;
   pLevelOfDetail1 = nullptr;
@@ -1991,3 +1974,761 @@
 	return v2 | ((a2 & field_0.field_10) << field_48) | ((a2 & field_0.field_14) << field_50) | ((a2 & field_0.field_18) << field_58);
 }
 
+
+
+
+
+typedef bool (*ImageFormatConverter)(unsigned int num_pixels, const void *src, void *dst);
+
+
+unsigned __int32 R5G6B5_to_A8R8G8B8(unsigned __int16 color16, unsigned char alpha)
+{
+    unsigned __int32 c = color16;
+    unsigned int b = (c & 31) * 8;
+    unsigned int g = ((c >> 5) & 63) * 4;
+    unsigned int r = ((c >> 11) & 31) * 8;
+
+    return ((unsigned int)alpha << 24) | (r << 16) | (g << 8) | b;
+}
+
+unsigned __int16 A8R8G8B8_to_R5G6B5(unsigned __int32 c)
+{
+    unsigned __int32 b = ((c & 0xFF) / 8) & 31;
+    unsigned __int32 g = (((c >> 8) & 0xFF) / 4) & 63;
+    unsigned __int32 r = (((c >> 16) & 0xFF) / 8) & 31;
+
+    return (unsigned __int16)(
+        (r << 11) | (g << 5) | b
+    );
+}
+
+bool Image_A8R8G8B8_to_R5G6B5(unsigned int num_pixels, const void *src_pixels, void *dst_pixels)
+{
+    auto src = (unsigned __int32 *)src_pixels;
+    auto dst = (unsigned __int16 *)dst_pixels;
+
+    for (unsigned int i = 0; i < num_pixels; ++i)
+        dst[i] = A8R8G8B8_to_R5G6B5(src[i]);
+
+    return true;
+}
+
+
+
+
+
+
+struct Alpha_LOD_Loader : public ImageLoader
+{
+    inline Alpha_LOD_Loader(LODFile_IconsBitmaps *lod, const wchar_t *name)
+    {
+        wcscpy(this->name, name);
+        this->lod = lod;
+    }
+
+    virtual bool Load(unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format);
+
+    wchar_t               name[1024];
+    LODFile_IconsBitmaps *lod;
+};
+
+
+bool Alpha_LOD_Loader::Load(unsigned int *out_width, unsigned int *out_height, void **out_pixels, IMAGE_FORMAT *out_format)
+{
+    *out_width = 0;
+    *out_height = 0;
+    *out_pixels = nullptr;
+    *out_format = IMAGE_INVALID_FORMAT;
+
+    char namea[1024];
+    sprintf(namea, "%S", name);
+
+    auto tex = lod->GetTexture(lod->LoadTexture(namea, TEXTURE_16BIT_PALETTE));
+
+    if (tex->pPalette16 && tex->paletted_pixels)
+    {
+        auto palette = tex->pPalette16;
+        auto paletted_pixels = tex->paletted_pixels;
+
+        auto width = tex->uTextureWidth;
+        auto height = tex->uTextureHeight;
+        auto pixels = new unsigned __int32[width * height];
+        if (pixels)
+        {
+            for (unsigned int y = 0; y < height; ++y)
+                for (unsigned int x = 0; x < width; ++x)
+                {
+                    auto index = paletted_pixels[y * width + x];
+                    auto pixel = tex->pPalette16[index];
+                    if (index == 0)
+                        pixels[y * width + x] = 0x00000000;
+                    else
+                    {
+                        extern unsigned __int32 Color32(unsigned __int16 color16);
+                        pixels[y * width + x] = R5G6B5_to_A8R8G8B8(pixel, 255);
+                    }
+                }
+            *out_width = width;
+            *out_height = height;
+            *out_pixels = pixels;
+            *out_format = IMAGE_FORMAT_A8R8G8B8;
+        }
+    }
+
+    return *out_pixels != nullptr;
+}
+
+
+
+
+
+
+
+
+struct ColorKey_LOD_Loader : public ImageLoader
+{
+    inline ColorKey_LOD_Loader(LODFile_IconsBitmaps *lod, const wchar_t *name, unsigned __int16 colorkey)
+    {
+        wcscpy(this->name, name);
+        this->colorkey = colorkey;
+        this->lod = lod;
+    }
+
+    virtual bool Load(unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format);
+
+    wchar_t               name[1024];
+    unsigned __int16      colorkey;
+    LODFile_IconsBitmaps *lod;
+};
+
+
+
+bool ColorKey_LOD_Loader::Load(unsigned int *out_width, unsigned int *out_height, void **out_pixels, IMAGE_FORMAT *out_format)
+{
+    *out_width = 0;
+    *out_height = 0;
+    *out_pixels = nullptr;
+    *out_format = IMAGE_INVALID_FORMAT;
+
+    char namea[1024];
+    sprintf(namea, "%S", name);
+
+    auto tex = lod->GetTexture(lod->LoadTexture(namea, TEXTURE_16BIT_PALETTE));
+
+    if (tex->pPalette16 && tex->paletted_pixels)
+    {
+        auto palette = tex->pPalette16;
+        auto paletted_pixels = tex->paletted_pixels;
+
+        auto width = tex->uTextureWidth;
+        auto height = tex->uTextureHeight;
+        auto pixels = new unsigned __int32[width * height];
+        if (pixels)
+        {
+            for (unsigned int y = 0; y < height; ++y)
+                for (unsigned int x = 0; x < width; ++x)
+                {
+                    auto pixel = tex->pPalette16[paletted_pixels[y * width + x]];
+                    if (pixel == colorkey)
+                        pixels[y * width + x] = 0x00000000;
+                    else
+                    {
+                        extern unsigned __int32 Color32(unsigned __int16 color16);
+                        pixels[y * width + x] = R5G6B5_to_A8R8G8B8(pixel, 255);
+                    }
+                }
+            *out_width = width;
+            *out_height = height;
+            *out_pixels = pixels;
+            *out_format = IMAGE_FORMAT_A8R8G8B8;
+        }
+    }
+
+    return *out_pixels != nullptr;
+}
+
+
+
+
+
+
+struct PCX_Loader : public ImageLoader
+{
+    bool DecodePCX(const unsigned char *pcx_data, unsigned __int16 *pOutPixels, unsigned int *width, unsigned int *height);
+};
+
+bool PCX_Loader::DecodePCX(const unsigned char *pcx_data, unsigned __int16 *pOutPixels, unsigned int *width, unsigned int *height)
+{
+    //  signed int result; // eax@2
+    unsigned char test_byte; // edx@3
+    unsigned int read_offset; // ebx@37
+    unsigned int row_position; // edi@40
+    unsigned char value; // cl@63
+    char count; // [sp+50h] [bp-Ch]@43
+    unsigned short current_line; // [sp+54h] [bp-8h]@38
+    unsigned short *dec_position;
+    unsigned short *temp_dec_position;
+    PCXHeader1 psx_head1;
+    PCXHeader2 psx_head2;
+    //	short int width, height;
+    BYTE  color_map[48];	// Colormap for 16-color images
+
+
+    memcpy(&psx_head1, pcx_data, 16);
+    memcpy(&color_map, pcx_data + 16, 48);
+    memcpy(&psx_head2, pcx_data + 64, 6);
+
+
+    if (psx_head1.bpp != 8)
+        return 3;
+    *width = (short int)(psx_head1.right - psx_head1.left + 1);  // word @ 000014
+    *height = (short int)(psx_head1.bottom - psx_head1.up + 1);  // word @ 000016
+
+
+    unsigned int uNumPixels = *width * *height;		  // dword @ 000010
+
+    memset(pOutPixels, 0, uNumPixels * sizeof(__int16));
+    short i = 1;
+    while ((1 << i) != *width)
+    {
+        ++i;
+        if (i >= 15)
+            break;
+    }
+
+    auto field_18 = i;
+    short i_ = 1;
+    while ((1 << i_) != *height)
+    {
+        ++i_;
+        if (i_ >= 15)
+            break;
+    }
+
+    auto field_1A = i_;
+    short field_1C = 0;
+    switch (field_18)
+    {
+    case 2:   field_1C = 3;    break;
+    case 3:   field_1C = 7;    break;
+    case 4:   field_1C = 15;   break;
+    case 5:   field_1C = 31;   break;
+    case 6:   field_1C = 63;   break;
+    case 7:   field_1C = 127;  break;
+    case 8:   field_1C = 255;  break;
+    case 9:   field_1C = 511;  break;
+    case 10:  field_1C = 1023; break;
+    case 11:  field_1C = 2047; break;
+    case 12:  field_1C = 4095; break;
+    }
+
+    short field_1E = 0;
+    switch (field_1A)
+    {
+    case 2:   field_1E = 3;    break;
+    case 3:   field_1E = 7;    break;
+    case 4:   field_1E = 15;   break;
+    case 5:   field_1E = 31;   break;
+    case 6:   field_1E = 63;   break;
+    case 7:   field_1E = 127;  break;
+    case 8:   field_1E = 255;  break;
+    case 9:   field_1E = 511;  break;
+    case 10:  field_1E = 1023; break;
+    case 11:  field_1E = 2047; break;
+    case 12:  field_1E = 4095; break;
+    }
+
+    unsigned int r_mask = 0xF800;
+    unsigned int num_r_bits = 5;
+    unsigned int g_mask = 0x07E0;
+    unsigned int num_g_bits = 6;
+    unsigned int b_mask = 0x001F;
+    unsigned int num_b_bits = 5;
+    //Ïðè ñîõðàíåíèè èçîáðàæåíèÿ ïîäðÿä èäóùèå ïèêñåëè îäèíàêîâîãî öâåòà îáúåäèíÿþòñÿ è âìåñòî óêàçàíèÿ öâåòà äëÿ êàæäîãî ïèêñåëÿ
+    //óêàçûâàåòñÿ öâåò ãðóïïû ïèêñåëåé è èõ êîëè÷åñòâî.
+    read_offset = 128;
+    if (psx_head2.planes != 3)
+        return 0;
+    current_line = 0;
+    if (height > 0)
+    {
+        dec_position = pOutPixels;
+        do
+        {
+            temp_dec_position = dec_position;
+            row_position = 0;
+            //decode red line
+            if (psx_head2.pitch)
+            {
+                do
+                {
+                    test_byte = pcx_data[read_offset];
+                    ++read_offset;
+                    if ((test_byte & 0xC0) == 0xC0)//èìååòñÿ ëè îáúåäèíåíèå
+                    {
+                        value = pcx_data[read_offset];
+                        ++read_offset;
+
+                        if ((test_byte & 0x3F) > 0)
+                        {
+                            count = test_byte & 0x3F;//êîëè÷åñòâî îäèíàêîâûõ ïèêñåëåé
+                            do
+                            {
+                                ++row_position;
+                                //*temp_dec_position =0xFF000000;
+                                //*temp_dec_position|=(unsigned long)value<<16;
+                                *temp_dec_position |= r_mask & ((unsigned __int8)value << (num_g_bits + num_r_bits + num_b_bits - 8));
+                                temp_dec_position++;
+                                if (row_position == psx_head2.pitch)
+                                    break;
+                            } while (count-- != 1);
+                        }
+                    }
+                    else
+                    {
+                        ++row_position;
+                        //*temp_dec_position =0xFF000000; 
+                        //*temp_dec_position|= (unsigned long)test_byte<<16;
+
+                        *temp_dec_position |= r_mask & ((unsigned __int8)test_byte << (num_g_bits + num_r_bits + num_b_bits - 8));
+
+                        temp_dec_position++;
+                    }
+
+                } while (row_position < psx_head2.pitch);
+            }
+
+            temp_dec_position = dec_position;
+            row_position = 0;
+            //decode green line
+            while (row_position <  psx_head2.pitch)
+            {
+                test_byte = *(pcx_data + read_offset);
+                ++read_offset;
+                if ((test_byte & 0xC0) == 0xC0)
+                {
+                    value = *(pcx_data + read_offset);
+                    ++read_offset;
+                    if ((test_byte & 0x3F) > 0)
+                    {
+                        count = test_byte & 0x3F;
+                        do
+                        {
+                            //*temp_dec_position|= (unsigned int)value<<8;
+                            //temp_dec_position++;
+
+                            *temp_dec_position |= g_mask & (unsigned __int16)((unsigned __int8)value << (num_g_bits + num_b_bits - 8));
+
+                            temp_dec_position++;
+                            ++row_position;
+                            if (row_position == psx_head2.pitch)
+                                break;
+
+                        } while (count-- != 1);
+                    }
+                }
+                else
+                {
+                    //*temp_dec_position |=(unsigned int) test_byte<<8;
+                    //temp_dec_position++;
+
+                    *temp_dec_position |= g_mask & (unsigned __int16)((unsigned __int8)test_byte << (num_g_bits + num_b_bits - 8));
+                    temp_dec_position++;
+                    ++row_position;
+                }
+            }
+
+            temp_dec_position = dec_position;
+            row_position = 0;
+            //decode blue line
+            while (row_position < psx_head2.pitch)
+            {
+                test_byte = *(pcx_data + read_offset);
+                read_offset++;
+                if ((test_byte & 0xC0) == 0xC0)
+                {
+                    value = *(pcx_data + read_offset);
+                    ++read_offset;
+                    if ((test_byte & 0x3F) > 0)
+                    {
+                        count = test_byte & 0x3F;
+                        do
+                        {
+                            //*temp_dec_position|= value;
+                            //temp_dec_position++;
+
+                            *temp_dec_position |= value >> (8 - num_b_bits);
+                            temp_dec_position++;
+
+                            ++row_position;
+                            if (row_position == psx_head2.pitch)
+                                break;
+                        } while (count-- != 1);
+                    }
+                }
+                else
+                {
+                    //*temp_dec_position|= test_byte;
+                    //temp_dec_position++;
+                    *temp_dec_position |= test_byte >> (8 - num_b_bits);
+                    temp_dec_position++;
+
+                    ++row_position;
+                }
+
+            }
+            ++current_line;
+            dec_position += *width;
+        } while (current_line < *height);
+    }
+    return true;
+}
+
+
+
+
+struct PCX_File_Loader : public PCX_Loader
+{
+    inline PCX_File_Loader(LODFile_IconsBitmaps *lod, const wchar_t *filename)
+    {
+        wcscpy(this->name, filename);
+        this->lod = lod;
+    }
+
+    virtual bool Load(unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format);
+
+    wchar_t               name[1024];
+    LODFile_IconsBitmaps *lod;
+};
+
+
+
+bool PCX_File_Loader::Load(unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format)
+{
+    FILE *file; // eax@1
+    char color_map[48]; // [sp+Ch] [bp-98h]@7
+    PCXHeader1 header1; // [sp+84h] [bp-20h]@7
+    PCXHeader2 header2; // [sp+94h] [bp-10h]@7
+
+    *width = 0;
+    *height = 0;
+    *pixels = nullptr;
+    *format = IMAGE_INVALID_FORMAT;
+
+    char namea[1024];
+    sprintf(namea, "%S", name);
+
+    file = fopen(namea, "rb");
+    if (!file)
+    {
+        Log::Warning(L"Unable to load %s", name);
+        return false;
+    }
+
+    fseek(file, 0, SEEK_END);
+    int filesize = ftell(file);
+    fseek(file, 0, SEEK_SET);
+
+    auto file_image = new unsigned char[filesize];
+    fread(file_image, 1, filesize, file);
+    fclose(file);
+
+
+    memcpy(&header1, file_image, 0x10u);
+    memcpy(color_map, file_image + 16, 0x30u);
+    memcpy(&header2, file_image + 64, 6);
+    if (header1.bpp != 8)
+    {
+        delete[] file_image;
+        return false;
+    }
+
+    *width = header1.right - header1.left + 1;
+    *height = header1.bottom - header1.up + 1;
+    unsigned int num_pixels = *width * *height;
+    *pixels = new unsigned short[num_pixels + 2];
+
+    if (pixels)
+    {
+        if (!this->DecodePCX(file_image, (unsigned __int16 *)*pixels, width, height))
+        {
+            delete[] * pixels;
+            *pixels = nullptr;
+        }
+        else
+            *format = IMAGE_FORMAT_R5G6B5;
+    }
+
+    delete[] file_image;
+
+    return *pixels != nullptr;
+}
+
+
+
+
+struct PCX_LOD_Loader : public PCX_Loader
+{
+    inline PCX_LOD_Loader(LOD::File *lod, const wchar_t *name)
+    {
+        wcscpy(this->name, name);
+        this->lod = lod;
+    }
+
+    virtual bool Load(unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format);
+
+    wchar_t    name[1024];
+    LOD::File *lod;
+};
+
+
+
+bool PCX_LOD_Loader::Load(unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format)
+{
+    FILE *file; // eax@1
+    void *v6; // ebx@5
+    char color_map[48]; // [sp+Ch] [bp-98h]@7
+    Texture DstBuf; // [sp+3Ch] [bp-68h]@1
+    PCXHeader1 header1; // [sp+84h] [bp-20h]@7
+    PCXHeader2 header2; // [sp+94h] [bp-10h]@7
+    size_t Count; // [sp+A0h] [bp-4h]@4
+    unsigned char *Str1a; // [sp+ACh] [bp+8h]@5
+
+    *width = 0;
+    *height = 0;
+    *pixels = nullptr;
+    *format = IMAGE_INVALID_FORMAT;
+
+    char namea[1024];
+    sprintf(namea, "%S", name);
+
+    file = lod->FindContainer(namea, 0);
+    if (!file)
+    {
+        Log::Warning(L"Unable to load %s", name);
+        return false;
+    }
+
+    fread(&DstBuf, 1, 0x30u, file);
+    Count = DstBuf.uTextureSize;
+    if (DstBuf.uDecompressedSize)
+    {
+        Str1a = (unsigned char *)malloc(DstBuf.uDecompressedSize);
+        v6 = malloc(DstBuf.uTextureSize);
+        fread(v6, 1, Count, file);
+        zlib::MemUnzip(Str1a, &DstBuf.uDecompressedSize, v6, DstBuf.uTextureSize);
+        DstBuf.uTextureSize = DstBuf.uDecompressedSize;
+        free(v6);
+    }
+    else
+    {
+        Str1a = (unsigned char *)malloc(DstBuf.uTextureSize);
+        fread(Str1a, 1, Count, file);
+    }
+
+    memcpy(&header1, Str1a, 0x10u);
+    memcpy(color_map, Str1a + 16, 0x30u);
+    memcpy(&header2, Str1a + 64, 6);
+    if (header1.bpp != 8)
+    {
+        free(Str1a);
+        return false;
+    }
+
+    *width = header1.right - header1.left + 1;
+    *height = header1.bottom - header1.up + 1;
+    unsigned int num_pixels = *width * *height;
+    *pixels = new unsigned short[num_pixels + 2];
+
+    if (pixels)
+    {
+        if (!this->DecodePCX(Str1a, (unsigned __int16 *)*pixels, width, height))
+        {
+            delete[] *pixels;
+            *pixels = nullptr;
+        }
+        else
+            *format = IMAGE_FORMAT_R5G6B5;
+    }
+
+    free(Str1a);
+
+    return *pixels != nullptr;
+}
+
+
+
+
+
+
+bool Image::PCX_From_IconsLOD(const wchar_t *name)
+{
+    loader = new PCX_LOD_Loader(pIcons_LOD, name);
+
+    if (!lazy_initialization)
+        this->LoadImageData();
+
+    return true;
+}
+
+bool Image::PCX_From_NewLOD(const wchar_t *name)
+{
+    loader = new PCX_LOD_Loader(pNew_LOD, name);
+
+    if (!lazy_initialization)
+        this->LoadImageData();
+
+    return true;
+}
+
+bool Image::PCX_From_File(const wchar_t *filename)
+{
+    loader = new PCX_File_Loader(pIcons_LOD, filename);
+
+    if (!lazy_initialization)
+        this->LoadImageData();
+
+    return true;
+}
+
+bool Image::Alpha_From_LOD(const wchar_t *name)
+{
+    loader = new Alpha_LOD_Loader(pIcons_LOD, name);
+
+    if (!lazy_initialization)
+        this->LoadImageData();
+
+    return true;
+}
+
+
+
+bool Image::ColorKey_From_LOD(const wchar_t *name, unsigned __int16 colorkey)
+{
+    loader = new ColorKey_LOD_Loader(pIcons_LOD, name, colorkey);
+
+    if (!lazy_initialization)
+        this->LoadImageData();
+
+    return true;
+}
+
+bool Image::LoadImageData()
+{
+    if (!initialized)
+    {
+        void *pixels;
+
+        initialized = loader->Load(&width, &height, &pixels, &native_format);
+        if (initialized && native_format != IMAGE_INVALID_FORMAT)
+            this->pixels[native_format] = pixels;
+    }
+
+    return initialized;
+}
+
+
+unsigned int Image::GetWidth()
+{
+    if (!initialized)
+        LoadImageData();
+
+    if (initialized)
+        return width;
+    return 0;
+}
+
+unsigned int Image::GetHeight()
+{
+    if (!initialized)
+        LoadImageData();
+
+    if (initialized)
+        return height;
+    return 0;
+}
+
+const void *Image::GetPixels(IMAGE_FORMAT format)
+{
+    if (!initialized)
+        LoadImageData();
+
+    if (initialized)
+    {
+        if (pixels[format])
+            return pixels[format];
+
+        auto native_pixels = pixels[native_format];
+        if (native_pixels)
+        {
+            static ImageFormatConverter converters[IMAGE_NUM_FORMATS][IMAGE_NUM_FORMATS] =
+            {
+                // IMAGE_FORMAT_R5G6B5 ->
+                {
+                    nullptr, // IMAGE_FORMAT_R5G6B5
+                    nullptr, // IMAGE_FORMAT_A1R5G5B5
+                    nullptr  // IMAGE_FORMAT_A8R8G8B8
+                },
+
+                // IMAGE_FORMAT_A1R5G5B5 ->
+                {
+                    nullptr, // IMAGE_FORMAT_R5G6B5
+                    nullptr, // IMAGE_FORMAT_A1R5G5B5
+                    nullptr  // IMAGE_FORMAT_A8R8G8B8
+                },
+
+                // IMAGE_FORMAT_A8R8G8B8 ->
+                {
+                    Image_A8R8G8B8_to_R5G6B5, // IMAGE_FORMAT_R5G6B5
+                    nullptr, // IMAGE_FORMAT_A1R5G5B5
+                    nullptr  // IMAGE_FORMAT_A8R8G8B8
+                },
+            };
+
+            ImageFormatConverter cvt = converters[native_format][format];
+            if (cvt)
+            {
+                unsigned int num_pixels = width * height;
+
+                void *cvt_pixels = new unsigned char[num_pixels * IMAGE_FORMAT_BytesPerPixel(format)];
+                if (cvt(width * height, native_pixels, cvt_pixels))
+                {
+                    return pixels[format] = cvt_pixels;
+                }
+                else
+                {
+                    delete[] cvt_pixels;
+                    cvt_pixels = nullptr;
+                }
+            }
+        }
+    }
+    return nullptr;
+}
+
+
+bool Image::Release()
+{
+    if (initialized)
+    {
+        if (loader)
+        {
+            delete loader;
+            loader = nullptr;
+        }
+
+        for (unsigned int i = 0; i < IMAGE_NUM_FORMATS; ++i)
+            if (pixels[i])
+            {
+                delete[] pixels[i];
+                pixels[i] = nullptr;
+            }
+
+        native_format = IMAGE_INVALID_FORMAT;
+        width = 0;
+        height = 0;
+    }
+
+    delete this;
+    return true;
+}
\ No newline at end of file
--- a/Engine/Graphics/Texture.h	Mon Oct 05 00:19:13 2015 +0200
+++ b/Engine/Graphics/Texture.h	Sat Mar 05 01:51:54 2016 +0200
@@ -1,7 +1,83 @@
 #pragma once
+#include "Engine/Engine.h"
+
 #include <stdio.h>
 #include <array>
 
+enum IMAGE_FORMAT
+{
+    IMAGE_FORMAT_R5G6B5 = 0,
+    IMAGE_FORMAT_A1R5G5B5,
+    IMAGE_FORMAT_A8R8G8B8,
+
+    IMAGE_NUM_FORMATS,
+    IMAGE_INVALID_FORMAT = -1,
+};
+
+
+inline unsigned int IMAGE_FORMAT_BytesPerPixel(IMAGE_FORMAT format)
+{
+    switch (format)
+    {
+        case IMAGE_FORMAT_R5G6B5:   return 2;
+        case IMAGE_FORMAT_A1R5G5B5: return 2;
+        case IMAGE_FORMAT_A8R8G8B8: return 4;
+
+        default:
+            Error("Invalid format: %d", format);
+            return 0;
+    }
+}
+
+
+struct ImageLoader
+{
+    virtual bool Load(unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format) = 0;
+};
+
+
+
+struct Image
+{
+    inline Image(bool lazy_initialization = true):
+        lazy_initialization(lazy_initialization), initialized(false),
+        width(0), height(0), native_format(IMAGE_INVALID_FORMAT),
+        loader(nullptr)
+    {
+        for (unsigned int i = 0; i < IMAGE_NUM_FORMATS; ++i)
+            pixels[i] = 0;
+    }
+
+
+    bool Image_From_LOD(const wchar_t *name);
+    bool ColorKey_From_LOD(const wchar_t *name, unsigned __int16 colorkey);
+    bool Alpha_From_LOD(const wchar_t *name);
+
+    bool PCX_From_IconsLOD(const wchar_t *name);
+    bool PCX_From_NewLOD(const wchar_t *name);
+    bool PCX_From_File(const wchar_t *filename);
+
+
+    unsigned int  GetWidth();
+    unsigned int  GetHeight();
+    const void   *GetPixels(IMAGE_FORMAT format);
+
+    bool Release();
+
+
+    protected:
+        bool         lazy_initialization;
+        bool         initialized;
+        ImageLoader *loader;
+
+        unsigned int  width;
+        unsigned int  height;
+        IMAGE_FORMAT  native_format;
+        void         *pixels[IMAGE_NUM_FORMATS];
+
+        bool LoadImageData();
+};
+
 
 
 /*  194 */
@@ -53,8 +129,9 @@
   short palette_id1;
   short palette_id2;
   unsigned int uDecompressedSize;
-  int pBits;
-  unsigned __int8 *pLevelOfDetail0_prolly_alpha_mask;
+  int pBits; // 0x0002 - generate mipmaps
+             // 0x0200 - 0th palette entry is transparent, else colorkey (7FF)
+  unsigned __int8 *paletted_pixels;
   unsigned __int8 *pLevelOfDetail1;
   /*unsigned __int8 *pLevelOfDetail2;*/ struct ID3D11ShaderResourceView *d3d11_srv;   // replace ol SW stuff with new fields to keep data integrity
   /*unsigned __int8 *pLevelOfDetail3;*/ struct D3D11_TEXTURE2D_DESC     *d3d11_desc;
@@ -127,7 +204,7 @@
 
 
 
-extern std::array<struct RGBTexture, 45> pSavegameThumbnails;
+extern std::array<struct Image *, 45> pSavegameThumbnails;
 extern std::array<struct Texture *, 2> pTexture_LloydBeacons;
 extern struct Texture *pTexture_50635C;
 extern struct Texture *pTex_book_button8_off;
@@ -171,9 +248,11 @@
 extern struct Texture *pTex_moon_2_2;
 extern struct Texture *pTex_moon_ful;
 
-
-
-extern RGBTexture stru_506E40; // weak
+extern struct Texture *minimap_loop; // 5079D8
+extern struct Texture *_5079B4_compass; // 5079B4
+extern struct Texture *_5079C8_init_y; // 5079C8
+extern struct Texture *_5079CC_init_r; // 5079CC
+extern struct Texture *_5079D0_init_g; // 5079D0
 
 
 extern int uTextureID_RestUI_restb4; // weak
@@ -189,15 +268,6 @@
 extern int uTextureID_ar_up_up; // weak
 
 
-extern int uTextureID_507698; // weak
-extern int uTextureID_50769C; // weak
-extern int uTextureID_5076A0; // weak
-extern int uTextureID_5076A4; // weak
-extern int uTextureID_5076A8; // weak
-extern int uTextureID_5076AC; // weak
-extern int uTextureID_5076B0; // weak
-extern int uTextureID_5076B4; // weak
-extern int uTextureID_Parchment; // weak
 extern unsigned int uTextureID_mhp_yel;
 extern unsigned int uTextureID_mhp_red;
 extern unsigned int uTextureID_mhp_grn;
@@ -257,17 +327,8 @@
 extern unsigned int uTextureID_BarBlue;
 
 
-extern unsigned int uTextureID_right_panel; // weak
-
-
-extern struct RGBTexture *pTexture_StatusBar;
-extern struct RGBTexture *pTexture_LeftFrame;
-extern struct RGBTexture *pTexture_TopFrame;
-extern struct RGBTexture *pTexture_BottomFrame;
-extern struct RGBTexture *pTexture_RightFrame;
-
-
-extern unsigned int uTextureID_right_panel_loop; // weak
+extern Texture *right_panel;
+extern Texture *right_panel_loop;
 
 
 extern struct Texture *pTexture_Leather;
@@ -318,9 +379,6 @@
 
 extern struct Texture pTex_F7CE30;
 
-
-extern struct RGBTexture stru_5773C4; // idb
-
 extern struct stru355 stru_4E82A4;// = {0x20, 0x41, 0, 0x20, 0xFF0000, 0xFF00, 0xFF, 0xFF000000};  moved to texture.h
 extern struct stru355 stru_4EFCBC;// = {0x20, 0x41, 0, 0x10, 0x7C00, 0x3E0, 0x1F, 0x8000};  moved to texture.h
 
--- a/Engine/LOD.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/Engine/LOD.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -42,6 +42,15 @@
 int _6A0CA8_lod_unused; // weak
 
 
+inline int LODFile_IconsBitmaps::LoadDummyTexture()
+{
+    for (unsigned int i = 0; i < uNumLoadedFiles; ++i)
+        if (!strcmp(pTextures[i].pName, "pending"))
+            return i;
+    return LoadTextureFromLOD(&pTextures[uNumLoadedFiles], "pending", TEXTURE_16BIT_PALETTE);
+}
+
+
 // inlined
 //----- (mm6c::00408860) --------------------------------------------------
 void LODFile_IconsBitmaps::_inlined_sub2()
@@ -1144,7 +1153,7 @@
   this->dword_11B84 = 0;
   this->dword_11B80 = 0;
   this->uNumLoadedFiles = 0;
-  this->dword_011BA4 = 0;
+  this->_011BA4_debug_paletted_pixels_uncompressed = false;
   //this->can_load_hardware_sprites = 0;
   this->pHardwareSurfaces = 0;
   this->pHardwareTextures = 0;
@@ -1809,20 +1818,20 @@
 
   fread(pDst, 1, 0x30u, File);
   strcpy(pDst->pName, pContainer);
-  pDst->pLevelOfDetail0_prolly_alpha_mask = 0;
+  pDst->paletted_pixels = 0;
   if ( pDst->uDecompressedSize )
   {
-    pDst->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)malloc(pDst->uDecompressedSize);
+    pDst->paletted_pixels = (unsigned __int8 *)malloc(pDst->uDecompressedSize);
     v9 = malloc(pDst->uTextureSize);
     fread((void *)v9, 1, (size_t)pDst->uTextureSize, File);
-    zlib::MemUnzip(pDst->pLevelOfDetail0_prolly_alpha_mask, &pDst->uDecompressedSize, v9, pDst->uTextureSize);
+    zlib::MemUnzip(pDst->paletted_pixels, &pDst->uDecompressedSize, v9, pDst->uTextureSize);
     pDst->uTextureSize = pDst->uDecompressedSize;
     free(v9);
   }
   else
   {
-    pDst->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)malloc(0);
-    fread(pDst->pLevelOfDetail0_prolly_alpha_mask, 1, (size_t)pDst->uTextureSize, File);
+    pDst->paletted_pixels = (unsigned __int8 *)malloc(0);
+    fread(pDst->paletted_pixels, 1, (size_t)pDst->uTextureSize, File);
   }
   pDst->pPalette16 = 0;
   pDst->pPalette24 = 0;
@@ -1849,7 +1858,7 @@
 
   if ( pDst->pBits & 2 )
   {
-    v15 = (int)&pDst->pLevelOfDetail0_prolly_alpha_mask[pDst->uSizeOfMaxLevelOfDetail];
+    v15 = (int)&pDst->paletted_pixels[pDst->uSizeOfMaxLevelOfDetail];
     pDst->pLevelOfDetail1 = (unsigned __int8 *)v15;
     v16 = (pDst->uSizeOfMaxLevelOfDetail >> 2) + v15;
     //pDst->pLevelOfDetail2 = (unsigned __int8 *)v16;
@@ -2061,7 +2070,7 @@
 
   File = FindContainer(pContainer, 0);
   v6 = pDst;
-  if ( File && pDst->pLevelOfDetail0_prolly_alpha_mask
+  if ( File && pDst->paletted_pixels
     && mode == 2
     && pDst->pPalette16 && !pDst->pPalette24
     && (v7 = pDst->uTextureSize,
@@ -2070,9 +2079,9 @@
         v8 = pDst->uTextureSize,
         (signed int)v8 <= (signed int)v7) )
   {
-    if ( !pDst->uDecompressedSize || this->dword_011BA4 )
+    if ( !pDst->uDecompressedSize || this->_011BA4_debug_paletted_pixels_uncompressed)
     {
-      fread(pDst->pLevelOfDetail0_prolly_alpha_mask, 1, pDst->uTextureSize, File);
+      fread(pDst->paletted_pixels, 1, pDst->uTextureSize, File);
     }
     else
     {
@@ -2082,7 +2091,7 @@
       zlib::MemUnzip(Sourcea, &v6->uDecompressedSize, DstBufa, v6->uTextureSize);
       v6->uTextureSize = pDst->uDecompressedSize;
       free(DstBufa);
-      memcpy(v6->pLevelOfDetail0_prolly_alpha_mask, Sourcea, pDst->uDecompressedSize);
+      memcpy(v6->paletted_pixels, Sourcea, pDst->uDecompressedSize);
       free(Sourcea);
     }
     for( uint i = 0; i < 256; ++i )
@@ -2159,10 +2168,10 @@
     }
     return result;
   }
-  if ( !v8->uDecompressedSize || dword_011BA4 )
+  if ( !v8->uDecompressedSize || _011BA4_debug_paletted_pixels_uncompressed)
   {
-    v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)malloc(v8->uTextureSize);
-    fread(v8->pLevelOfDetail0_prolly_alpha_mask, 1, (size_t)v8->uTextureSize, pFile);
+    v8->paletted_pixels = (unsigned __int8 *)malloc(v8->uTextureSize);
+    fread(v8->paletted_pixels, 1, (size_t)v8->uTextureSize, pFile);
   }
   else
   {
@@ -2179,8 +2188,8 @@
                           + ((signed int)v8->uSizeOfMaxLevelOfDetail >> 6));
       v22 = (size_t)pOutTex;
       v23 = &pContainer[v8->uTextureWidth * v8->uTextureHeight];
-      v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)malloc((unsigned int)pOutTex);
-      memcpy(v8->pLevelOfDetail0_prolly_alpha_mask, v23, v22);
+      v8->paletted_pixels = (unsigned __int8 *)malloc((unsigned int)pOutTex);
+      memcpy(v8->paletted_pixels, v23, v22);
       v8->uTextureWidth = (signed __int16)v8->uTextureWidth / 2;
       v8->uTextureHeight = (signed __int16)v8->uTextureHeight / 2;
       --v8->uWidthLn2;
@@ -2192,8 +2201,8 @@
     }
     else
     {
-      v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)malloc(v8->uDecompressedSize);
-      memcpy(v8->pLevelOfDetail0_prolly_alpha_mask, pContainer, v8->uDecompressedSize);
+      v8->paletted_pixels = (unsigned __int8 *)malloc(v8->uDecompressedSize);
+      memcpy(v8->paletted_pixels, pContainer, v8->uDecompressedSize);
     }
     free((void *)pContainer);
   }
@@ -2230,7 +2239,7 @@
 
   if ( v8->pBits & 2 )
   {
-    v8->pLevelOfDetail1 = &v8->pLevelOfDetail0_prolly_alpha_mask[v8->uSizeOfMaxLevelOfDetail];
+    v8->pLevelOfDetail1 = &v8->paletted_pixels[v8->uSizeOfMaxLevelOfDetail];
     //v8->pLevelOfDetail2 = &v8->pLevelOfDetail1[v8->uSizeOfMaxLevelOfDetail >> 2];
     //v8->pLevelOfDetail3 = &v8->pLevelOfDetail2[v8->uSizeOfMaxLevelOfDetail >> 4];
   }
--- a/Engine/LOD.h	Mon Oct 05 00:19:13 2015 +0200
+++ b/Engine/LOD.h	Sat Mar 05 01:51:54 2016 +0200
@@ -168,13 +168,7 @@
   void _inlined_sub1();
   void _inlined_sub2();
 
-  inline int LoadDummyTexture()
-  {
-    for (unsigned int i = 0; i < uNumLoadedFiles; ++i)
-      if (!strcmp(pTextures[i].pName, "pending"))
-        return i;
-    return LoadTextureFromLOD(&pTextures[uNumLoadedFiles], "pending", TEXTURE_16BIT_PALETTE);
-  }
+  int LoadDummyTexture();
 
   Texture *GetTexture(int idx);
 
@@ -204,7 +198,7 @@
   int uNumPrevLoadedFiles;
   int uTexturePacksCount;
   int pFacesLock;
-  int dword_011BA4;
+  int _011BA4_debug_paletted_pixels_uncompressed;
   //int can_load_hardware_sprites;
   struct IDirectDrawSurface **pHardwareSurfaces;
   struct IDirect3DTexture2 **pHardwareTextures;
--- a/Engine/MMT.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/Engine/MMT.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -121,7 +121,7 @@
   tex->uTextureSize = png_get_rowbytes(png_ptr, info_ptr);
   tex->uDecompressedSize = png_get_rowbytes(png_ptr, info_ptr);
   tex->pPalette16 = (unsigned __int16 *) malloc(sizeof(unsigned __int16) * width * height);
-  tex->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *) malloc(sizeof(unsigned __int8) * width * height);
+  tex->paletted_pixels = (unsigned __int8 *) malloc(sizeof(unsigned __int8) * width * height);
 
   for (y=0; y<height; y++)
   {
@@ -137,7 +137,7 @@
 	  //ptr[3] = 255 - ptr[3]; // alpha mask gradient
       ptr[3] = 255 - tmp;
       tex->pPalette16[i] = Color16(ptr[0], ptr[1], ptr[2]);
-      tex->pLevelOfDetail0_prolly_alpha_mask[i] = ptr[3];
+      tex->paletted_pixels[i] = ptr[3];
       i++;
     }
   }
@@ -150,7 +150,7 @@
 
 void MMT_MainMenu_Loop()
 {
-  GUIButton *pButton; // eax@27
+  /*GUIButton *pButton; // eax@27
   unsigned int pControlParam; // ecx@35
   unsigned int pX;
   unsigned int pY; // [sp-18h] [bp-54h]@39
@@ -279,14 +279,13 @@
   pRenderer->Present();
 
   //remove resource
-  main_menu_background.Release();
   if ( pGUIWindow2 )
   {
     pGUIWindow2->Release();
     pGUIWindow2 = 0;
   }
   pWindow_MMT_MainMenu->Release();
-  pIcons_LOD->RemoveTexturesPackFromTextureList();
+  pIcons_LOD->RemoveTexturesPackFromTextureList();*/
 }
 
 void MMT_MenuMessageProc()
--- a/Engine/SaveLoad.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/Engine/SaveLoad.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -34,7 +34,8 @@
 struct SavegameList *pSavegameList = new SavegameList;
 unsigned int uNumSavegameFiles;
 std::array<unsigned int, 45> pSavegameUsedSlots;
-std::array<struct RGBTexture, 45> pSavegameThumbnails;
+//std::array<struct RGBTexture, 45> pSavegameThumbnails;
+std::array<Image *, 45> pSavegameThumbnails;
 std::array<SavegameHeader, 45> pSavegameHeader;
 
 
@@ -231,7 +232,10 @@
   dword_6BE364_game_settings_1 |= GAME_SETTINGS_2000 | GAME_SETTINGS_0001;
 
   for (uint i = 0; i < uNumSavegameFiles; ++i)
-    pSavegameThumbnails[i].Release();
+  {
+      pSavegameThumbnails[i]->Release();
+      pSavegameThumbnails[i] = nullptr;
+  }
 
   pIcons_LOD->RemoveTexturesPackFromTextureList();
   if ( use_music_folder )
@@ -586,7 +590,10 @@
   //v3 = pSavegameThumbnails;
   viewparams->bRedrawGameUI = true;
   for (uint i = 0; i < 45; i++)
-    pSavegameThumbnails[i].Release();
+  {
+      pSavegameThumbnails[i]->Release();
+      pSavegameThumbnails[i] = nullptr;
+  }
 
   if ( _stricmp(pCurrentMapName, "d05.blv") )
     pNew_LOD->_4621A7();
--- a/Engine/SaveLoad.h	Mon Oct 05 00:19:13 2015 +0200
+++ b/Engine/SaveLoad.h	Sat Mar 05 01:51:54 2016 +0200
@@ -52,5 +52,5 @@
 
 extern unsigned int uNumSavegameFiles;
 extern std::array<unsigned int, 45> pSavegameUsedSlots;
-extern struct SavegameList  *pSavegameList;
+extern struct SavegameList *pSavegameList;
 extern std::array<SavegameHeader, 45>  pSavegameHeader;
\ No newline at end of file
--- a/Engine/mm7_7.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,492 +0,0 @@
-#define _CRTDBG_MAP_ALLOC
-#include <stdlib.h>
-#include <crtdbg.h>
-
-#define _CRT_SECURE_NO_WARNINGS
-
-/*
-GUIProgressBar *__cdecl crt_construct_576E30()
-{
-  RGBTexture::RGBTexture(&pGameLoadingUI_ProgressBar.pLoadingBg);
-  RGBTexture::RGBTexture(&pGameLoadingUI_ProgressBar.field_40);
-  RGBTexture::RGBTexture(&pGameLoadingUI_ProgressBar.field_68);
-  RGBTexture::RGBTexture(&pGameLoadingUI_ProgressBar.field_90);
-  RGBTexture::RGBTexture(&pGameLoadingUI_ProgressBar.field_B8);
-  Texture::Texture(&pGameLoadingUI_ProgressBar.field_E0);
-  Texture::Texture(&pGameLoadingUI_ProgressBar.pBardata);
-  Texture::Texture(&pGameLoadingUI_ProgressBar.pLoadingProgress);
-  pGameLoadingUI_ProgressBar.uProgressCurrent = 0;
-  pGameLoadingUI_ProgressBar.uProgressMax = 0;
-  pGameLoadingUI_ProgressBar.field_9 = 0;
-  pGameLoadingUI_ProgressBar.field_8 = 0;
-  pGameLoadingUI_ProgressBar.uHeight = 0;
-  pGameLoadingUI_ProgressBar.uWidth = 0;
-  pGameLoadingUI_ProgressBar.uY = 0;
-  pGameLoadingUI_ProgressBar.uX = 0;
-  pGameLoadingUI_ProgressBar.field_17 = 0;
-  pGameLoadingUI_ProgressBar.field_16 = 0;
-  pGameLoadingUI_ProgressBar.field_15 = 0;
-  pGameLoadingUI_ProgressBar.field_14 = 0;
-  pGameLoadingUI_ProgressBar.field_13 = 0;
-  pGameLoadingUI_ProgressBar.field_12 = 0;
-  pGameLoadingUI_ProgressBar.field_11 = 0;
-  pGameLoadingUI_ProgressBar.field_10 = 0;
-  return &pGameLoadingUI_ProgressBar;
-}
-*/
-
-/*void constructors()
-{
-	//no call to these anywhere
-	uGameUIFontMain_initialize();
-	uGameUIFontShadow_initialize();
-}*/
-
-/*
-
-X = called already in our code
-byte = constructor byte setter
-
-.data:004DF004                 dd offset sub_4C9A95
-IOStream
-
-.data:004DF008                 dd offset sub_4C9B06
-IOStream
-
-.data:004DF00C                 dd offset sub_401022
-achieved by zero initializing dword_4F8580, dword_4F8580[0] = 1; is unused anyway
-
-.data:004DF010                 dd offset sub_408B98
-.data:004DF014                 dd offset sub_409BCC
-.data:004DF018                 dd offset crt_sub_40D6EB
-byte
-
-.data:004DF01C                 dd offset crt_construct_40D707_ptr_pArcomageGame
-X
-
-.data:004DF020                 dd offset crt_sub_40E4A6
-.data:004DF024                 dd offset crt_deconstruct_40E503
-.data:004DF028                 dd offset crt_sub_40F760
-.data:004DF02C                 dd offset crt_sub_40F7EA
-.data:004DF030                 dd offset crt_sub_40F9A9
-.data:004DF034                 dd offset crt_sub_410AD9
-byte
-
-.data:004DF038                 dd offset SetMoonPhaseNames
-X
-
-.data:004DF03C                 dd offset crt_sub_413FD0
-byte
-
-.data:004DF040                 dd offset j_SetMonthNames
-.data:004DF044                 dd offset j_SetDayNames
-.data:004DF048                 dd offset j_SetSpellSchoolNames
-.data:004DF04C                 dd offset j_SetAttributeNames
-X InitializeGameText
-
-.data:004DF050                 dd offset uGameUIFontMain_initialize
-.data:004DF054                 dd offset uGameUIFontShadow_initialize
-X called in SetUserInterface(Neutral)
-
-.data:004DF058                 dd offset crt_construct_507ABC
-.data:004DF05C                 dd offset crt_construct_507A94
-.data:004DF060                 dd offset crt_construct_507A6C
-.data:004DF064                 dd offset crt_construct_507A44
-.data:004DF068                 dd offset crt_construct_507A1C
-.data:004DF06C                 dd offset crt_construct_506F20
-.data:004DF070                 dd offset crt_construct_414D90_ptr_506E40
-X (RGBTexture constructor)
-
-.data:004DF074                 dd offset crt_sub_423903
-byte
-
-.data:004DF078                 dd offset IndoorCamera__IndoorCamera
-X
-
-.data:004DF07C                 dd offset crt_sub_423ACD
-byte
-
-.data:004DF080                 dd offset j_reset_some_strus_flt_2Cs
-deleted
-
-.data:004DF084                 dd offset j_sub_423B4A
-byte
-
-.data:004DF088                 dd offset crt_sub_4262DD
-byte
-
-.data:004DF08C                 dd offset crt_construct_pEventTimer
-.data:004DF090                 dd offset crt_construct_pMiscTimer
-X
-
-.data:004DF094                 dd offset crt_sub_42640D
-.data:004DF098                 dd offset crt_sub_4268C7
-.data:004DF09C                 dd offset crt_sub_42692B
-byte
-
-.data:004DF0A0                 dd offset sub_426947
-X initialized
-
-.data:004DF0A4                 dd offset crt_construct_50C0C8
-X CastSpellInfo
-
-.data:004DF0A8                 dd offset crt_sub_42FBB7
-byte
-
-.data:004DF0AC                 dd offset crt_construct_50CDB4
-seems unused CastSpellInfo variable
-
-.data:004DF0B0                 dd offset sub_4361D3
-.data:004DF0B4                 dd offset sub_4382A0
-.data:004DF0B8                 dd offset sub_43850A
-.data:004DF0BC                 dd offset crt_438AEF
-.data:004DF0C0                 dd offset crt_438B7F
-.data:004DF0C4                 dd offset ctr_deconstruct_43B4E0
-byte
-
-.data:004DF0C8                 dd offset crt_43B4FC
-deleted, constructor for stru_51076C
-
-.data:004DF0CC                 dd offset crt_deconstruct_43B51C
-.data:004DF0D0                 dd offset crt_deconstruct_43B5F0
-.data:004DF0D4                 dd offset crt_deconstruct_43B64C
-byte
-
-.data:004DF0D8                 dd offset _crt_construct_stru165
-X BloodsplatContainer
-
-.data:004DF0DC                 dd offset crt_deconstruct_43B751
-.data:004DF0E0                 dd offset crt_deconstruct_43B9E3
-.data:004DF0E4                 dd offset crt_deconstruct_43BC8B
-.data:004DF0E8                 dd offset crt_deconstruct_43F22A
-byte
-
-.data:004DF0EC                 dd offset crt_construct_51B778
-X BspRenderer
-
-.data:004DF0F0                 dd offset crt_construct_519AB8
-X LightsStack_MobileLight
-
-.data:004DF0F4                 dd offset crt_construct_5187F0
-X LightsStack_StationaryLight
-
-
-.data:004DF0F8                 dd offset crt_deconstruct_440B28
-.data:004DF0FC                 dd offset crt_deconstruct_440F5C
-byte
-
-.data:004DF100                 dd offset crt_construct_576E30
-added but have to RECHECK
-
-.data:004DF104                 dd offset crt_deconstruct_4437E5
-byte
-
-.data:004DF108                 dd offset sub_446219
-X InitializeGameText
-
-.data:004DF10C                 dd offset crt_construct_5773C4
-unused RGBTexture
-
-.data:004DF110                 dd offset sub_44C346
-.data:004DF114                 dd offset crt_deconstruct_44C42C
-.data:004DF118                 dd offset crt_deconstruct_44D49E
-byte
-
-.data:004DF11C                 dd offset _inline_SpriteFrameTable__SpriteFrameTable_global
-.data:004DF120                 dd offset _inline_TextureFrameTable__TextureFrameTable_global
-X
-
-.data:004DF124                 dd offset sub_44E49B
-.data:004DF128                 dd offset sub_44F1F9
-.data:004DF12C                 dd offset sub_44F560
-.data:004DF130                 dd offset sub_450DC2
-.data:004DF134                 dd offset crt_deconstruct_45232B
-byte
-
-.data:004DF138                 dd offset crt_construct_stru193_math@5C6E00
-X
-
-.data:004DF13C                 dd offset crt_452B74
-byte
-
-.data:004DF140                 dd offset j_SetSomeItemsNames
-added
-
-.data:004DF144                 dd offset crt_deconstruct_458364
-byte
-
-.data:004DF148                 dd offset _intline_DecorationList__DecorationList_global
-X
-
-.data:004DF14C                 dd offset j_crt_construct_6836D0
-X LevelDecorations
-
-.data:004DF150                 dd offset _inline_ObjectList__ObjectList_global
-X
-
-.data:004DF154                 dd offset j_crt_construct_665230
-X SpriteObjects
-
-.data:004DF158                 dd offset j_crt_construct_5FF158
-X Actors
-
-.data:004DF15C                 dd offset _inline_MonsterList__MonsterList_global
-X
-
-.data:004DF160                 dd offset _inline_ChestList__ChestList_global
-X
-
-.data:004DF164                 dd offset j_crt_construct_5E5150
-X Chests
-
-.data:004DF168                 dd offset _inline_OverlayList__OverlayList_global
-X
-
-.data:004DF16C                 dd offset crt_construct_5E4D58
-X OverlayList
-
-.data:004DF170                 dd offset sub_459C05
-byte
-
-.data:004DF174                 dd offset sub_459C21
-X KeyboardActionMapping
-
-.data:004DF178                 dd offset crt_deconstruct_45AFBD
-.data:004DF17C                 dd offset crt_deconstruct_45B0EE
-.data:004DF180                 dd offset sub_45BA89
-byte
-
-.data:004DF184                 dd offset crt_call_global_ctor_45BAA5
-stru_69BD44 = "effpar03" , need RECHECK
-
-.data:004DF188                 dd offset crt_deconstruct_45DEF7
-.data:004DF18C                 dd offset crt_deconstruct_45DF53
-.data:004DF190                 dd offset crt_deconstruct_45DF6F
-.data:004DF194                 dd offset crt_deconstruct_45DF8B
-byte
-
-.data:004DF198                 dd offset crt_construct_ptr_6A0A60
-X LODFile
-
-.data:004DF19C                 dd offset crt_construct_ptr_6A0820
-X LODFile
-
-.data:004DF1A0                 dd offset j_crt_construct_ptr_6A0118
-X RGBTexture
-
-.data:004DF1A4                 dd offset sub_461415
-.data:004DF1A8                 dd offset crt_deconstruct_4621BE
-.data:004DF1AC                 dd offset crt_deconstruct_46220E
-byte
-
-.data:004DF1B0                 dd offset crt_construct_ptr_702B28
-X Allocator
-
-.data:004DF1B4                 dd offset sub_46224A
-X unused
-
-.data:004DF1B8                 dd offset crt_construct_ptr_06F0E80
-X LODFile_IconsBitmaps
-
-.data:004DF1BC                 dd offset sub_4623CF
-X LODFile_Sprites
-
-.data:004DF1C0                 dd offset crt_call_ctors__pIcons_LOD
-.data:004DF1C4                 dd offset crt_call_ctors__pEvents_LOD
-.data:004DF1C8                 dd offset _inline_IndoorLocation__IndoorLocation_global
-X
-
-.data:004DF1CC                 dd offset crt_init_globals_462620
-X initialized
-
-.data:004DF1D0                 dd offset crt_construct_ptr_6BE158
-unused stru289
-
-.data:004DF1D4                 dd offset j_crt_init_globals_462659
-X initialized
-
-.data:004DF1D8                 dd offset crt_construct_ptr_06BE070
-X ODMRenderParams
-
-.data:004DF1DC                 dd offset crt_init_globals_46269B
-unused SW variable
-
-.data:004DF1E0                 dd offset crt_construct_ptr_6BE048
-X TileTable
-
-.data:004DF1E4                 dd offset crt_construct_ptr_6A0DF0
-X OutdoorLocation
-
-.data:004DF1E8                 dd offset sub_466CA6
-.data:004DF1EC                 dd offset crt_deconstruct_467D29
-.data:004DF1F0                 dd offset sub_467E32
-.data:004DF1F4                 dd offset crt_deconstruct_46AC2C
-byte
-
-.data:004DF1F8                 dd offset crt_construct_46AC48_ptr_720990
-X std__string_720990 = "micon1" , need RECHECK
-
-.data:004DF1FC                 dd offset crt_deconstruct_46BD83
-byte
-
-.data:004DF200                 dd offset crt_init_globals_46BD9F
-added
-
-.data:004DF204                 dd offset nullsub_26
-X
-
-.data:004DF208                 dd offset sub_476102
-byte
-
-.data:004DF20C                 dd offset sub_47611E
-X Texture
-
-.data:004DF210                 dd offset sub_476128
-dword_7241C8 = 1 RECHECK
-
-.data:004DF214                 dd offset sub_476133
-X InitializeGameText
-
-.data:004DF218                 dd offset sub_477595
-.data:004DF21C                 dd offset sub_47836D
-.data:004DF220                 dd offset crt_sub_4783D9
-byte
-
-.data:004DF224                 dd offset j__sub_4783FA_construct_global_73D150
-
-
-.data:004DF228                 dd offset sub_47A368
-.data:004DF22C                 dd offset sub_47C778
-.data:004DF230                 dd offset sub_47CDBE
-byte
-
-.data:004DF234                 dd offset sub_47CDDA
-
-
-.data:004DF238                 dd offset sub_47F483
-byte
-
-.data:004DF23C                 dd offset sub_47F49F
-
-
-.data:004DF240                 dd offset sub_47F4B9
-
-
-.data:004DF244                 dd offset sub_482A74
-.data:004DF248                 dd offset sub_485F37
-.data:004DF24C                 dd offset sub_486A0C
-.data:004DF250                 dd offset crt_deconstruct_487DF7
-.data:004DF254                 dd offset sub_488E07
-.data:004DF258                 dd offset sub_489572
-.data:004DF25C                 dd offset crt_deconstruct_489B44
-.data:004DF260                 dd offset crt_deconstruct_489BBA
-byte
-
-.data:004DF264                 dd offset crt_construct_489BD6_ptr_080D198
-X PaletteManager
-
-.data:004DF268                 dd offset sub_48AAA9
-.data:004DF26C                 dd offset sub_48C20E
-byte
-
-.data:004DF270                 dd offset sub_48C22A
-.data:004DF274                 dd offset loc_48C234
-.data:004DF278                 dd offset loc_48C243
-.data:004DF27C                 dd offset loc_48C252
-.data:004DF280                 dd offset loc_48C3C0
-.data:004DF284                 dd offset loc_48C474
-Party constructor
-
-.data:004DF288                 dd offset sub_49801C
-.data:004DF28C                 dd offset sub_498077
-.data:004DF290                 dd offset sub_498A25
-.data:004DF294                 dd offset sub_49AFE5
-.data:004DF298                 dd offset crt_deconstruct_49B36B
-byte
-
-.data:004DF29C                 dd offset crt_construct_stru187@AE5BA8
-X DecalBuilder
-
-.data:004DF2A0                 dd offset crt_construct_ptr_AE5B94
-std__string_AE5B94 = "hwsplat04", need RECHECK
-
-.data:004DF2A4                 dd offset sub_49C594
-.data:004DF2A8                 dd offset sub_49D6C8
-.data:004DF2AC                 dd offset sub_49D6E4
-.data:004DF2B0                 dd offset sub_49E71A
-byte
-
-.data:004DF2B4                 dd offset sub_49E736
-X Render
-
-.data:004DF2B8                 dd offset sub_4A198F
-byte
-
-.data:004DF2BC                 dd offset sub_4A19AB
-added
-
-.data:004DF2C0                 dd offset sub_4A51AF
-.data:004DF2C4                 dd offset sub_4A7047
-.data:004DF2C8                 dd offset sub_4A94EB
-.data:004DF2CC                 dd offset sub_4A963E
-byte
-
-.data:004DF2D0                 dd offset sub_4A965A
-X pSoundList
-
-.data:004DF2D4                 dd offset AudioPlayer__AudioPlayer
-X
-
-.data:004DF2D8                 dd offset sub_4AC1AD
-.data:004DF2DC                 dd offset sub_4AC662
-.data:004DF2E0                 dd offset sub_4ACC1C
-.data:004DF2E4                 dd offset sub_4AD369
-.data:004DF2E8                 dd offset crt_deconstruct_4AD44B
-byte
-
-.data:004DF2EC                 dd offset crt_construct_4AD467_ptr_F79D68
-X OSVersion
-
-.data:004DF2F0                 dd offset crt_deconstruct_4AD4DE
-byte
-
-.data:004DF2F4                 dd offset crt_construct_ptr_F7CE30
-X Texture
-
-.data:004DF2F8                 dd offset sub_4B142B
-.data:004DF2FC                 dd offset crt_sub_4BE344
-byte
-
-.data:004DF300                 dd offset j_Random__ctor
-X
-
-.data:004DF304                 dd offset crt_sub_4BE6B5
-.data:004DF308                 dd offset crt_sub_4BE6D4
-byte
-
-.data:004DF30C                 dd offset crt_j_VideoPlayer__ctor
-RECHECK
-
-.data:004DF310                 dd offset sub_4C021E
-byte
-
-.data:004DF314                 dd offset sub_4C023A
-added
-
-.data:004DF318                 dd offset sub_4C035A
-.data:004DF31C                 dd offset sub_4C03A3
-byte
-
-.data:004DF320                 dd offset sub_4C03BF
-.data:004DF324                 dd offset sub_4C03F1
-.data:004DF328                 dd offset sub_4C0423
-.data:004DF32C                 dd offset sub_4C044B
-.data:004DF330                 dd offset sub_4C047D
-X vis filters
-
-.data:004DF334                 dd offset sub_4C2A6E
-.data:004DF338                 dd offset sub_4C2A8A
-.data:004DF33C                 dd offset sub_4C2F7C
-byte
-
-*/
\ No newline at end of file
--- a/Engine/mm7_data.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/Engine/mm7_data.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -782,11 +782,6 @@
 int uTextureID_PlayerBuff_Preservation; // weak
 int uTextureID_PlayerBuff_Bless; // weak
 int uTextureID_Btn_QuickReference; // weak
-int uTextureID_Compas; // dword_5079B4
-int dword_5079C8; // weak
-int dword_5079CC; // weak
-int dword_5079D0; // weak
-int uTextureID_Minimap_Loop; // dword_5079D8
 struct GUIButton *pBtn_ZoomOut; // idb
 struct GUIButton *pBtn_ZoomIn; // idb
 unsigned int uGameUIFontShadow;
--- a/Engine/mm7_data.h	Mon Oct 05 00:19:13 2015 +0200
+++ b/Engine/mm7_data.h	Sat Mar 05 01:51:54 2016 +0200
@@ -445,11 +445,6 @@
 extern int uTextureID_PlayerBuff_Preservation; // weak
 extern int uTextureID_PlayerBuff_Bless; // weak
 extern int uTextureID_Btn_QuickReference; // weak
-extern int uTextureID_Compas; // dword_5079B4
-extern int dword_5079C8; // weak
-extern int dword_5079CC; // weak
-extern int dword_5079D0; // weak
-extern int uTextureID_Minimap_Loop; // dword_5079D8
 extern struct GUIButton *pBtn_ZoomOut; // idb
 extern struct GUIButton *pBtn_ZoomIn; // idb
 extern unsigned int uGameUIFontShadow;
--- a/GUI/GUIProgressBar.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/GUI/GUIProgressBar.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -4,6 +4,7 @@
 
 #define _CRT_SECURE_NO_WARNINGS
 #include "Engine/Engine.h"
+#include "Engine/AssetsManager.h"
 
 #include "GUIProgressBar.h"
 #include "Engine/LOD.h"
@@ -45,7 +46,7 @@
   }
 
   //v2 = this;
-  if (pLoadingBg.pPixels)
+  if (loading_bg)
     return false;
 
   uType = type;
@@ -72,7 +73,12 @@
       while ( field_10[v7] == 1 );
     }
     sprintf(Str1, "loading%d.pcx", v7);
-    pLoadingBg.Load(Str1, 2);
+
+    wchar_t image_name[1024];
+    swprintf(image_name, L"loading%d.pcx", v7);
+
+    loading_bg = assets->GetImage_PCXFromIconsLOD(image_name);
+    //pLoadingBg.Load(Str1, 2);
     uProgressCurrent = 0;
     uX = 122;
     uY = 151;
@@ -120,7 +126,12 @@
 {
   int v3; // edi@7
 
-  pLoadingBg.Release();
+  if (loading_bg)
+  {
+      loading_bg->Release();
+      loading_bg = nullptr;
+  }
+
   if ( this->uType == 1 )
   {
     if ( this->uProgressCurrent != this->uProgressMax )
@@ -128,19 +139,19 @@
       this->uProgressCurrent = this->uProgressMax - 1;
       Progress();
     }
-    v3 = (int)&this->pLoadingProgress.pLevelOfDetail0_prolly_alpha_mask;
-    free(this->pLoadingProgress.pLevelOfDetail0_prolly_alpha_mask);
+    v3 = (int)&this->pLoadingProgress.paletted_pixels;
+    free(this->pLoadingProgress.paletted_pixels);
     free(this->pLoadingProgress.pPalette16);
     this->pLoadingProgress.pPalette16 = 0;
   }
   else
   {
-    if ( !this->pBardata.pLevelOfDetail0_prolly_alpha_mask )
+    if ( !this->pBardata.paletted_pixels)
       return;
-    free(this->pBardata.pLevelOfDetail0_prolly_alpha_mask);
+    free(this->pBardata.paletted_pixels);
     v3 = (int)&this->pBardata.pPalette16;
     free(this->pBardata.pPalette16);
-    this->pBardata.pLevelOfDetail0_prolly_alpha_mask = 0;
+    this->pBardata.paletted_pixels = 0;
   }
   *(int *)v3 = 0;
 }
@@ -151,7 +162,7 @@
   pRenderer->BeginScene();
   if (uType != TYPE_Fullscreen)
   {
-    if (pBardata.pLevelOfDetail0_prolly_alpha_mask)
+    if (pBardata.paletted_pixels)
     {
       pRenderer->Sub01();
 
@@ -169,17 +180,20 @@
     return;
   }
 
-  if (!pLoadingBg.pPixels)
+  //if (!pLoadingBg.pPixels)
+  if (!loading_bg)
   {
-    pRenderer->EndScene();
-    return;
+      pRenderer->EndScene();
   }
+  else
+  {
 
-  pRenderer->DrawTextureRGB(0, 0, &pLoadingBg);
-  //pRenderer->SetRasterClipRect(0, 0, 639, 479);
-  pRenderer->SetUIClipRect(172, 459, 15 * (signed int)(signed __int64)((double)(300 * uProgressCurrent) / (double)uProgressMax) / 15 + 172, 471);
-  pRenderer->DrawTextureIndexedAlpha(172, 459, &pLoadingProgress);
-  pRenderer->ResetUIClipRect();
-  pRenderer->EndScene();
-  pRenderer->Present();
+      pRenderer->DrawTextureNew(0, 0, loading_bg);
+      //pRenderer->SetRasterClipRect(0, 0, 639, 479);
+      pRenderer->SetUIClipRect(172, 459, 15 * (signed int)(signed __int64)((double)(300 * uProgressCurrent) / (double)uProgressMax) / 15 + 172, 471);
+      pRenderer->DrawTextureIndexedAlpha(172, 459, &pLoadingProgress);
+      pRenderer->ResetUIClipRect();
+      pRenderer->EndScene();
+      pRenderer->Present();
+  }
 }
\ No newline at end of file
--- a/GUI/GUIProgressBar.h	Mon Oct 05 00:19:13 2015 +0200
+++ b/GUI/GUIProgressBar.h	Sat Mar 05 01:51:54 2016 +0200
@@ -36,14 +36,21 @@
   //char field_15;
   //char field_16;
   //char field_17;
-  RGBTexture pLoadingBg;
-  RGBTexture field_40;
-  RGBTexture field_68;
-  RGBTexture field_90;
-  RGBTexture field_B8;
+  //RGBTexture pLoadingBg; // 18
+  //RGBTexture field_40;
+  //RGBTexture field_68;
+  //RGBTexture field_90;
+  //RGBTexture field_B8;
   struct Texture field_E0;
   struct Texture pBardata;
   struct Texture pLoadingProgress;
+
+
+  inline GUIProgressBar():
+      loading_bg(nullptr)
+  {}
+
+  struct Image *loading_bg;
 };
 #pragma pack(pop)
 
--- a/GUI/GUIWindow.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/GUI/GUIWindow.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -25,8 +25,11 @@
 #include "Engine/Graphics/Outdoor.h"
 #include "Engine/Tables/IconFrameTable.h"
 #include "Engine/Objects/Actor.h"
+#include "Engine/AssetsManager.h"
 
 #include "GUI\UI\UIArena.h"
+#include "GUI/UI/UIPopup.h"
+#include "GUI/UI/UIGame.h"
 #include "Engine/Events.h"
 #include "Engine/Graphics/Level\Decoration.h"
 
@@ -494,56 +497,55 @@
 
 
 //----- (00415551) --------------------------------------------------------
-void GUIWindow::DrawMessageBox(int arg0)
+void GUIWindow::DrawMessageBox(bool inside_game_viewport)
 {
-  unsigned int v2; // edi@1
-  signed int v4; // esi@2
-  unsigned int v5; // eax@2
   unsigned int v16; // esi@19
   GUIWindow current_window; // [sp+Ch] [bp-60h]@18
   POINT cursor; // [sp+60h] [bp-Ch]@8
   unsigned int v22; // [sp+74h] [bp+8h]@2
 
-  v2 = 0;
-  if ( arg0 )
+  int x = 0;
+  int y = 0;
+  int z, w;
+  if (inside_game_viewport)
   {
-    v4 = pViewport->uViewportTL_X;
-    v5 = pViewport->uViewportBR_X;
-    v2 = pViewport->uViewportTL_Y;
-    v22 = pViewport->uViewportBR_Y;
+    x = pViewport->uViewportTL_X;
+    z = pViewport->uViewportBR_X;
+    y = pViewport->uViewportTL_Y;
+    w = pViewport->uViewportBR_Y;
   }
   else
   {
-    v4 = 0;
-    v5 = window->GetWidth();
-    v22 = window->GetHeight();
+    z = window->GetWidth();
+    w = window->GetHeight();
   }
+
   pMouse->GetCursorPos(&cursor);
-  if ( (signed int)this->uFrameX >= v4 )
+  if ( (signed int)this->uFrameX >= x )
   {
-    if ( (signed int)(this->uFrameWidth + this->uFrameX) > (signed int)v5 )
+    if ( (signed int)(this->uFrameWidth + this->uFrameX) > z )
     {
-      this->uFrameX = v5 - this->uFrameWidth;
+      this->uFrameX = z - this->uFrameWidth;
       this->uFrameY = cursor.y + 30;
     }
   }
   else
   {
-    this->uFrameX = v4;
+    this->uFrameX = x;
     this->uFrameY = cursor.y + 30;
   }
 
-  if ( (signed int)this->uFrameY >= (signed int)v2 )
+  if ( (signed int)this->uFrameY >= y )
   {
-    if ( (signed int)(this->uFrameY + this->uFrameHeight) > (signed int)v22 )
+    if ( (signed int)(this->uFrameY + this->uFrameHeight) > w)
       this->uFrameY = cursor.y - this->uFrameHeight - 30;
   }
   else
     this->uFrameY = cursor.y + 30;
-  if ( (signed int)this->uFrameY < (signed int)v2 )
-    this->uFrameY = v2;
-  if ( (signed int)this->uFrameX < v4 )
-    this->uFrameX = v4;
+  if ( (signed int)this->uFrameY < y )
+    this->uFrameY = y;
+  if ( (signed int)this->uFrameX < x )
+    this->uFrameX = x;
   this->uFrameZ = this->uFrameWidth + this->uFrameX - 1;
   this->uFrameW = this->uFrameHeight + this->uFrameY - 1;
   memcpy(&current_window, this, sizeof(current_window));
@@ -567,19 +569,32 @@
 }
 
 //----- (00411B59) --------------------------------------------------------
-void __fastcall LoadThumbnailLloydTexture(unsigned int uSlot, unsigned int uPlayer)
+void LoadThumbnailLloydTexture(unsigned int uSlot, unsigned int uPlayer)
 {
   //unsigned int v2; // esi@1
   //unsigned int v3; // edi@1
   FILE *v4; // ebx@1
   FILE *v5; // eax@2
-  char pContainerName[64]; // [sp+Ch] [bp-44h]@1
+  //char pContainerName[64]; // [sp+Ch] [bp-44h]@1
   //unsigned int v7; // [sp+4Ch] [bp-4h]@1
 
-  //v2 = uSlot;
-  //v7 = uPlayer;
-  //v3 = uSlot + 1;
-  sprintf(pContainerName, "data\\lloyd%d%d.pcx", uPlayer, uSlot + 1);
+  if (pSavegameThumbnails[uSlot])
+  {
+      pSavegameThumbnails[uSlot]->Release();
+      pSavegameThumbnails[uSlot] = nullptr;
+  }
+
+
+  wchar_t filename[1024];
+  swprintf(filename, L"data\\lloyd%d%d.pcx", uPlayer, uSlot + 1);
+  pSavegameThumbnails[uSlot] = assets->GetImage_PCXFromFile(filename);
+
+  if (!pSavegameThumbnails[uSlot])
+  {
+      swprintf(filename, L"lloyd%d%d.pcx", uPlayer, uSlot + 1);
+      pSavegameThumbnails[uSlot] = assets->GetImage_PCXFromNewLOD(filename);
+  }
+  /*sprintf(pContainerName, "data\\lloyd%d%d.pcx", uPlayer, uSlot + 1);
   v4 = fopen(pContainerName, "rb");
   if ( v4 )
   {
@@ -594,7 +609,7 @@
       pSavegameThumbnails[uSlot].LoadFromFILE(v5, 0, 0);
     else
       *((int *)&pSavegameThumbnails.data()->pPixels + 10 * uSlot) = 0;
-  }
+  }*/
 }
 
 
@@ -624,7 +639,7 @@
   pWhiteColor = Color16(0xFFu, 0xFFu, 0xFFu);
   pColor2 = Color16(0x15u, 0x99u, 0xE9u);
   pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background);
-  pRenderer->DrawTextureIndexedAlpha(0x1D4u, 0, &pIcons_LOD->pTextures[uTextureID_right_panel_loop]);
+  pRenderer->DrawTextureIndexedAlpha(0x1D4u, 0, right_panel_loop);
   if ( pDialogueNPCCount != uNumDialogueNPCPortraits || !uHouse_ExitPic )
   {
     pDialogWindow.uFrameWidth = 130;
@@ -891,7 +906,7 @@
     Stra = strtok(0, "\n");
   }
 }
-// 5C6DB4: using guessed type int ui_current_text_color;
+
 
 //----- (0044CE08) --------------------------------------------------------
 void GUIWindow::DrawText(GUIFont *font, signed int uX, int uY, unsigned short uFontColor, const char *Str, bool present_time_transparency, int max_text_height, signed int uFontShadowColor )
@@ -1197,6 +1212,19 @@
   return pButton;
 }
 
+
+void GUIWindow::InitializeGUI()
+{
+    SetUserInterface(PartyAlignment_Neutral, false);
+
+    for (uint i = 0; i < 20; ++i)
+        pWindowList[i] = nullptr;
+    uNumVisibleWindows = -1;
+    memset(pVisibleWindowsIdxs.data(), 0, sizeof(pVisibleWindowsIdxs));
+
+    MainMenuUI_LoadFontsAndSomeStuff();
+}
+
 //----- (00459C2B) --------------------------------------------------------
 void GUIWindow::DrawFlashingInputCursor( signed int uX, int uY, struct GUIFont *a2 )
 {
@@ -1537,7 +1565,7 @@
     pWindow = pWindowList[pVisibleWindowsIdxs[i] - 1];
 
     pWindow->Update();
-    switch (pWindow->eWindowType)
+    /*switch (pWindow->eWindowType)
     {
       case WINDOW_50:
       {
@@ -1614,7 +1642,7 @@
       default:
           __debugbreak();
         continue;
-    }
+    }*/
   }
   if ( GetCurrentMenuID() == -1 )
     GameUI_DrawFoodAndGold();
@@ -1622,34 +1650,6 @@
     UI_OnMouseRightClick(0);
 }
 
-//----- (00415485) --------------------------------------------------------
-void DrawMM7CopyrightWindow()
-{
-  GUIWindow Dst; // [sp+8h] [bp-54h]@1
-
-  memset(&Dst, 0, sizeof(Dst));
-  Dst.uFrameWidth = 624;
-  Dst.uFrameHeight = 256;
-  Dst.uFrameX = 8;
-  Dst.uFrameY = 30;                             // c 1999 The 3DO Company.
-  Dst.uFrameHeight = pFontSmallnum->CalcTextHeight(pGlobalTXT_LocalizationStrings[157], &Dst, 24, 0)
-                   + 2 * LOBYTE(pFontSmallnum->uFontHeight)
-                   + 24;
-  Dst.uFrameY = 470 - Dst.uFrameHeight;
-  Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
-  Dst.uFrameW = 469;
-  //Dst.Hint = "abcagfdsgsg ljsrengvlkjesnfkjwnef";
-  Dst.DrawMessageBox(0);
-
-  Dst.uFrameWidth -= 24;
-  Dst.uFrameX += 12;
-  Dst.uFrameY += 12;
-  Dst.uFrameHeight -= 12;
-  Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
-  Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1;
-  Dst.DrawTitleText(pFontSmallnum, 0, 0xCu, ui_mainmenu_copyright_color, pGlobalTXT_LocalizationStrings[157], 3);
-}
-
 
 //----- (00467FB6) --------------------------------------------------------
 void CreateScrollWindow()
@@ -1713,21 +1713,27 @@
   extern void set_default_ui_skin();
   set_default_ui_skin();
 
+
+  if (!parchment)
+      parchment = assets->GetImage_16BitColorKey(L"parchment", 0x7FF);
+
   if (align == PartyAlignment_Evil)
   {
     if ( bReplace )
     {
-      pTexture_RightFrame->Reload("ib-r-C.pcx");
-      pTexture_BottomFrame->Reload("ib-b-C.pcx");
-      pTexture_TopFrame->Reload("ib-t-C.pcx");
-      pTexture_LeftFrame->Reload("ib-l-C.pcx");
-      pTexture_StatusBar->Reload("IB-Foot-c.pcx");
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_right_panel], "ib-mb-C", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Minimap_Loop], "ib-autmask-c", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Compas], "IB-COMP-C", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079D0], "IB-InitG-c", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079C8], "IB-InitY-c", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079CC], "IB-InitR-c", 2);
+        game_ui_rightframe = assets->GetImage_PCXFromIconsLOD(L"ib-r-C.pcx");
+        game_ui_bottomframe = assets->GetImage_PCXFromIconsLOD(L"ib-b-C.pcx");
+        game_ui_topframe = assets->GetImage_PCXFromIconsLOD(L"ib-t-C.pcx");
+        game_ui_leftframe = assets->GetImage_PCXFromIconsLOD(L"ib-l-C.pcx");
+        game_ui_statusbar = assets->GetImage_PCXFromIconsLOD(L"IB-Foot-c.pcx");
+
+      right_panel = assets->GetTexture("ib-mb-C");
+      minimap_loop = assets->GetTexture("ib-autmask-c");
+      _5079B4_compass = assets->GetTexture("IB-COMP-C");
+      _5079D0_init_g = assets->GetTexture("IB-InitG-c");
+      _5079C8_init_y = assets->GetTexture("IB-InitY-c");
+      _5079CC_init_r = assets->GetTexture("IB-InitR-c");
+
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Btn_NPCLeft], "IB-NPCLD-C", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Btn_NPCRight], "IB-NPCRD-C", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Btn_ZoomIn], "ib-autout-C", 2);
@@ -1751,30 +1757,31 @@
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uExitCancelTextureId], "ib-bcu-c", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50795C], "evtnpc-c", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_CharacterUI_InventoryBackground], "fr_inven-c", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Parchment], "parchment", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076B4], "cornr_ll-c", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076B0], "cornr_lr-c", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076AC], "cornr_ul-c", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076A8], "cornr_ur-c", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076A4], "edge_btm-c", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076A0], "edge_lf-c", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50769C], "edge_rt-c", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507698], "edge_top-c", 2);
+      messagebox_corner_y = assets->GetImage_16BitAlpha(L"cornr_ll-c");
+      messagebox_corner_w = assets->GetImage_16BitAlpha(L"cornr_lr-c");
+      messagebox_corner_x = assets->GetImage_16BitAlpha(L"cornr_ul-c");
+      messagebox_corner_z = assets->GetImage_16BitAlpha(L"cornr_ur-c"); 
+      messagebox_border_bottom = assets->GetImage_16BitAlpha(L"edge_btm-c");
+      messagebox_border_left = assets->GetImage_16BitAlpha(L"edge_lf-c");
+      messagebox_border_right = assets->GetImage_16BitAlpha(L"edge_rt-c");
+      messagebox_border_top = assets->GetImage_16BitAlpha(L"edge_top-c");
       pIcons_LOD->ReloadTexture(pTexture_591428, "endcap-c", 2);
     }
     else
     {
-      pTexture_RightFrame->Load("ib-r-C.pcx", 0);
-      pTexture_BottomFrame->Load("ib-b-c.pcx", 0);
-      pTexture_TopFrame->Load("ib-t-C.pcx", 0);
-      pTexture_LeftFrame->Load("ib-l-C.pcx", 0);
-      pTexture_StatusBar->Load("IB-Foot-c.pcx", 0);
-      uTextureID_right_panel = pIcons_LOD->LoadTexture("ib-mb-C", TEXTURE_16BIT_PALETTE);
-      uTextureID_Minimap_Loop = pIcons_LOD->LoadTexture("ib-autmask-c", TEXTURE_16BIT_PALETTE);
-      uTextureID_Compas = pIcons_LOD->LoadTexture("IB-COMP-C", TEXTURE_16BIT_PALETTE);
-      dword_5079D0 = pIcons_LOD->LoadTexture("IB-InitG-c", TEXTURE_16BIT_PALETTE);
-      dword_5079C8 = pIcons_LOD->LoadTexture("IB-InitY-c", TEXTURE_16BIT_PALETTE);
-      dword_5079CC = pIcons_LOD->LoadTexture("IB-InitR-c", TEXTURE_16BIT_PALETTE);
+        game_ui_rightframe = assets->GetImage_PCXFromIconsLOD(L"ib-r-C.pcx");
+        game_ui_bottomframe = assets->GetImage_PCXFromIconsLOD(L"ib-b-c.pcx");
+        game_ui_topframe = assets->GetImage_PCXFromIconsLOD(L"ib-t-C.pcx");
+        game_ui_leftframe = assets->GetImage_PCXFromIconsLOD(L"ib-l-C.pcx");
+      game_ui_statusbar = assets->GetImage_PCXFromIconsLOD(L"IB-Foot-c.pcx");
+
+      right_panel = assets->GetTexture("ib-mb-C");
+      minimap_loop = assets->GetTexture("ib-autmask-c");
+      _5079B4_compass = assets->GetTexture("IB-COMP-C");
+      _5079D0_init_g = assets->GetTexture("IB-InitG-c");
+      _5079C8_init_y = assets->GetTexture("IB-InitY-c");
+      _5079CC_init_r = assets->GetTexture("IB-InitR-c");
+
       uTextureID_Btn_NPCLeft = pIcons_LOD->LoadTexture("IB-NPCLD-C", TEXTURE_16BIT_PALETTE);
       uTextureID_Btn_NPCRight = pIcons_LOD->LoadTexture("IB-NPCRD-C", TEXTURE_16BIT_PALETTE);
       uTextureID_Btn_ZoomIn = pIcons_LOD->LoadTexture("ib-autout-C", TEXTURE_16BIT_PALETTE);
@@ -1803,17 +1810,19 @@
   {
     if ( bReplace )
     {
-      pTexture_RightFrame->Reload("ib-r-a.pcx");
-      pTexture_BottomFrame->Reload("ib-b-a.pcx");
-      pTexture_TopFrame->Reload("ib-t-a.pcx");
-      pTexture_LeftFrame->Reload("ib-l-a.pcx");
-      pTexture_StatusBar->Reload("IB-Foot-a.pcx");
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_right_panel], "ib-mb-a", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Minimap_Loop], "ib-autmask-a", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Compas], "IB-COMP-a", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079D0], "IB-InitG-a", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079C8], "IB-InitY-a", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079CC], "IB-InitR-a", 2);
+        game_ui_rightframe = assets->GetImage_PCXFromIconsLOD(L"ib-r-a.pcx");
+        game_ui_bottomframe = assets->GetImage_PCXFromIconsLOD(L"ib-b-a.pcx");
+        game_ui_topframe = assets->GetImage_PCXFromIconsLOD(L"ib-t-a.pcx");
+        game_ui_leftframe = assets->GetImage_PCXFromIconsLOD(L"ib-l-a.pcx");
+      game_ui_statusbar = assets->GetImage_PCXFromIconsLOD(L"IB-Foot-a.pcx");
+
+      right_panel = assets->GetTexture("ib-mb-a");
+      minimap_loop = assets->GetTexture("ib-autmask-a");
+      _5079B4_compass = assets->GetTexture("IB-COMP-a");
+      _5079D0_init_g = assets->GetTexture("IB-InitG-a");
+      _5079C8_init_y = assets->GetTexture("IB-InitY-a");
+      _5079CC_init_r = assets->GetTexture("IB-InitR-a");
+
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Btn_NPCLeft], "IB-NPCLD-a", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Btn_NPCRight], "IB-NPCRD-a", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Btn_ZoomIn], "ib-autout-a", 2);
@@ -1834,30 +1843,31 @@
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uExitCancelTextureId], "ib-bcu-a", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50795C], "evtnpc", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_CharacterUI_InventoryBackground], "fr_inven", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Parchment], "parchment", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076B4], "cornr_ll", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076B0], "cornr_lr", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076AC], "cornr_ul", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076A8], "cornr_ur", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076A4], "edge_btm", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076A0], "edge_lf", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50769C], "edge_rt", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507698], "edge_top", 2);
+      messagebox_corner_y = assets->GetImage_16BitAlpha(L"cornr_ll");
+      messagebox_corner_w = assets->GetImage_16BitAlpha(L"cornr_lr");
+      messagebox_corner_x = assets->GetImage_16BitAlpha(L"cornr_ul");
+      messagebox_corner_z = assets->GetImage_16BitAlpha(L"cornr_ur");
+      messagebox_border_bottom = assets->GetImage_16BitAlpha(L"edge_btm");
+      messagebox_border_left = assets->GetImage_16BitAlpha(L"edge_lf");
+      messagebox_border_right = assets->GetImage_16BitAlpha(L"edge_rt");
+      messagebox_border_top = assets->GetImage_16BitAlpha(L"edge_top");
       pIcons_LOD->ReloadTexture(pTexture_591428, "endcap", 2);
     }
     else
     {
-      pTexture_RightFrame->Load("ib-r-A.pcx", 0);
-      pTexture_BottomFrame->Load("ib-b-A.pcx", 0);
-      pTexture_TopFrame->Load("ib-t-A.pcx", 0);
-      pTexture_LeftFrame->Load("ib-l-A.pcx", 0);
-      pTexture_StatusBar->Load("IB-Foot-a.pcx", 0);
-      uTextureID_right_panel = pIcons_LOD->LoadTexture("ib-mb-A", TEXTURE_16BIT_PALETTE);
-      uTextureID_Minimap_Loop = pIcons_LOD->LoadTexture("ib-autmask-a", TEXTURE_16BIT_PALETTE);
-      uTextureID_Compas = pIcons_LOD->LoadTexture("IB-COMP-A", TEXTURE_16BIT_PALETTE);
-      dword_5079D0 = pIcons_LOD->LoadTexture("IB-InitG-a", TEXTURE_16BIT_PALETTE);
-      dword_5079C8 = pIcons_LOD->LoadTexture("IB-InitY-a", TEXTURE_16BIT_PALETTE);
-      dword_5079CC = pIcons_LOD->LoadTexture("IB-InitR-a", TEXTURE_16BIT_PALETTE);
+        game_ui_rightframe = assets->GetImage_PCXFromIconsLOD(L"ib-r-A.pcx");
+        game_ui_bottomframe = assets->GetImage_PCXFromIconsLOD(L"ib-b-A.pcx");
+        game_ui_topframe = assets->GetImage_PCXFromIconsLOD(L"ib-t-A.pcx");
+        game_ui_leftframe = assets->GetImage_PCXFromIconsLOD(L"ib-l-A.pcx");
+      game_ui_statusbar = assets->GetImage_PCXFromIconsLOD(L"IB-Foot-a.pcx");
+
+      right_panel = assets->GetTexture("ib-mb-A");
+      minimap_loop = assets->GetTexture("ib-autmask-a");
+      _5079B4_compass = assets->GetTexture("IB-COMP-A");
+      _5079D0_init_g = assets->GetTexture("IB-InitG-a");
+      _5079C8_init_y = assets->GetTexture("IB-InitY-a");
+      _5079CC_init_r = assets->GetTexture("IB-InitR-a");
+
       uTextureID_Btn_NPCLeft = pIcons_LOD->LoadTexture("IB-NPCLD-A", TEXTURE_16BIT_PALETTE);
       uTextureID_Btn_NPCRight = pIcons_LOD->LoadTexture("IB-NPCRD-A", TEXTURE_16BIT_PALETTE);
       uTextureID_GameUI_CharSelectionFrame = pIcons_LOD->LoadTexture("IB-selec-A", TEXTURE_16BIT_PALETTE);
@@ -1878,15 +1888,14 @@
       pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnim_WizardEye->uIconID);
       pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchA");
       pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID);
-      uTextureID_Parchment = pIcons_LOD->LoadTexture("parchment", TEXTURE_16BIT_PALETTE);
-      uTextureID_5076B4 = pIcons_LOD->LoadTexture("cornr_ll", TEXTURE_16BIT_PALETTE);
-      uTextureID_5076B0 = pIcons_LOD->LoadTexture("cornr_lr", TEXTURE_16BIT_PALETTE);
-      uTextureID_5076AC = pIcons_LOD->LoadTexture("cornr_ul", TEXTURE_16BIT_PALETTE);
-      uTextureID_5076A8 = pIcons_LOD->LoadTexture("cornr_ur", TEXTURE_16BIT_PALETTE);
-      uTextureID_5076A4 = pIcons_LOD->LoadTexture("edge_btm", TEXTURE_16BIT_PALETTE);
-      uTextureID_5076A0 = pIcons_LOD->LoadTexture("edge_lf", TEXTURE_16BIT_PALETTE);
-      uTextureID_50769C = pIcons_LOD->LoadTexture("edge_rt", TEXTURE_16BIT_PALETTE);
-      uTextureID_507698 = pIcons_LOD->LoadTexture("edge_top", TEXTURE_16BIT_PALETTE);
+      messagebox_corner_y = assets->GetImage_16BitAlpha(L"cornr_ll");
+      messagebox_corner_w = assets->GetImage_16BitAlpha(L"cornr_lr");
+      messagebox_corner_x = assets->GetImage_16BitAlpha(L"cornr_ul");
+      messagebox_corner_z = assets->GetImage_16BitAlpha(L"cornr_ur");
+      messagebox_border_bottom = assets->GetImage_16BitAlpha(L"edge_btm");
+      messagebox_border_left = assets->GetImage_16BitAlpha(L"edge_lf");
+      messagebox_border_right = assets->GetImage_16BitAlpha(L"edge_rt");
+      messagebox_border_top = assets->GetImage_16BitAlpha(L"edge_top");
       pTexture_591428 = pIcons_LOD->LoadTexturePtr("endcap", TEXTURE_16BIT_PALETTE);
     }
     uGameUIFontMain = Color16(0xAu, 0, 0);
@@ -1896,17 +1905,19 @@
   {
     if ( bReplace )
     {
-      pTexture_RightFrame->Reload("ib-r-B.pcx");
-      pTexture_BottomFrame->Reload("ib-b-B.pcx");
-      pTexture_TopFrame->Reload("ib-t-B.pcx");
-      pTexture_LeftFrame->Reload("ib-l-B.pcx");
-      pTexture_StatusBar->Reload("IB-Foot-b.pcx");
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_right_panel], "ib-mb-B", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Minimap_Loop], "ib-autmask-b", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Compas], "IB-COMP-B", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079D0], "IB-InitG-b", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079C8], "IB-InitY-b", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079CC], "IB-InitR-b", 2);
+        game_ui_rightframe = assets->GetImage_PCXFromIconsLOD(L"ib-r-B.pcx");
+        game_ui_bottomframe = assets->GetImage_PCXFromIconsLOD(L"ib-b-B.pcx");
+        game_ui_topframe = assets->GetImage_PCXFromIconsLOD(L"ib-t-B.pcx");
+        game_ui_leftframe = assets->GetImage_PCXFromIconsLOD(L"ib-l-B.pcx");
+      game_ui_statusbar = assets->GetImage_PCXFromIconsLOD(L"IB-Foot-b.pcx");
+
+      right_panel = assets->GetTexture("ib-mb-B");
+      minimap_loop = assets->GetTexture("ib-autmask-b");
+      _5079B4_compass = assets->GetTexture("IB-COMP-B");
+      _5079D0_init_g = assets->GetTexture("IB-InitG-b");
+      _5079C8_init_y = assets->GetTexture("IB-InitY-b");
+      _5079CC_init_r = assets->GetTexture("IB-InitR-b");
+
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Btn_NPCLeft], "IB-NPCLD-B", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Btn_NPCRight], "IB-NPCRD-B", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Btn_ZoomIn], "ib-autout-B", 2);
@@ -1927,15 +1938,14 @@
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uExitCancelTextureId], "ib-bcu-b", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50795C], "evtnpc-b", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_CharacterUI_InventoryBackground], "fr_inven-b", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Parchment], "parchment", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076B4], "cornr_ll-b", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076B0], "cornr_lr-b", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076AC], "cornr_ul-b", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076A8], "cornr_ur-b", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076A4], "edge_btm-b", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076A0], "edge_lf-b", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50769C], "edge_rt-b", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507698], "edge_top-b", 2);
+      messagebox_corner_y = assets->GetImage_16BitAlpha(L"cornr_ll-b");
+      messagebox_corner_w = assets->GetImage_16BitAlpha(L"cornr_lr-b");
+      messagebox_corner_x = assets->GetImage_16BitAlpha(L"cornr_ul-b");
+      messagebox_corner_z = assets->GetImage_16BitAlpha(L"cornr_ur-b");
+      messagebox_border_bottom = assets->GetImage_16BitAlpha(L"edge_btm-b");
+      messagebox_border_left = assets->GetImage_16BitAlpha(L"edge_lf-b");
+      messagebox_border_right = assets->GetImage_16BitAlpha(L"edge_rt-b");
+      messagebox_border_top = assets->GetImage_16BitAlpha(L"edge_top-b");
       pIcons_LOD->ReloadTexture(pTexture_591428, "endcap-b", 2);
     }
     uGameUIFontMain = Color16(0, 0, 0xC8u);
@@ -2072,10 +2082,10 @@
 	//  int v6; // ecx@6
 	//  int v9; // [sp+18h] [bp-4h]@1
 
-	if (pIcons_LOD->dword_011BA4 && a2->uDecompressedSize)
+	if (pIcons_LOD->_011BA4_debug_paletted_pixels_uncompressed && a2->uDecompressedSize)
 		v4 = a2->UnzipPalette();
 	else
-		v4 = a2->pLevelOfDetail0_prolly_alpha_mask;
+		v4 = a2->paletted_pixels;
 	//v5 = pZBuffer;
 	for (uint i = 0; i < a2->uTextureHeight; i++)
 	{
@@ -2086,7 +2096,7 @@
 		}
 		pZBuffer += window->GetWidth() - a2->uTextureWidth;
 	}
-	if (pIcons_LOD->dword_011BA4)
+	if (pIcons_LOD->_011BA4_debug_paletted_pixels_uncompressed)
 	{
 		if (a2->uDecompressedSize)
 			free(v4);
@@ -2114,10 +2124,10 @@
 	//  int v11; // [sp+18h] [bp-8h]@1
 	//void *v12; // [sp+1Ch] [bp-4h]@5
 
-	if (pIcons_LOD->dword_011BA4 && pTex->uDecompressedSize)
+	if (pIcons_LOD->_011BA4_debug_paletted_pixels_uncompressed && pTex->uDecompressedSize)
 		v3 = pTex->UnzipPalette();
 	else
-		v3 = pTex->pLevelOfDetail0_prolly_alpha_mask;
+		v3 = pTex->paletted_pixels;
 	//v12 = v3;
 	//v4 = v3;
 	//v5 = pZBuffer;
@@ -2134,7 +2144,7 @@
 		}
 		pZBuffer += window->GetWidth() - pTex->uTextureWidth;
 	}
-	if (pIcons_LOD->dword_011BA4)
+	if (pIcons_LOD->_011BA4_debug_paletted_pixels_uncompressed)
 	{
 		if (pTex->uDecompressedSize)
 			free(v3);
@@ -2730,7 +2740,7 @@
 //----- (004B46A5) --------------------------------------------------------
 void __fastcall DrawTextAtStatusBar(const char *Str, int a5)
 {
-	pRenderer->DrawTextureRGB(0, 352, pTexture_StatusBar);
+	pRenderer->DrawTextureNew(0, 352/480.0f, game_ui_statusbar);
 	pPrimaryWindow->DrawText(pFontLucida, pFontLucida->AlignText_Center(450, Str) + 11, 357, a5, Str, 0, 0, 0);
 }
 
--- a/GUI/GUIWindow.h	Mon Oct 05 00:19:13 2015 +0200
+++ b/GUI/GUIWindow.h	Sat Mar 05 01:51:54 2016 +0200
@@ -289,8 +289,8 @@
   WINDOW_Scroll          = 0x1E,
   WINDOW_CastSpell_InInventory = 31,
   WINDOW_ModalWindow    = 70,
-  WINDOW_50             = 80,
-  WINDOW_59             = 89,
+  WINDOW_50             = 80, // Debug
+  WINDOW_59             = 89, // Debug: Item Generation Window
   WINDOW_PressedButton2 = 90,
   WINDOW_CharactersPressedButton = 91,
   WINDOW_PressedButton       = 92,
@@ -342,7 +342,7 @@
   void DrawTitleText(GUIFont *a2, signed int uHorizontalMargin, unsigned int uVerticalMargin, unsigned __int16 uDefaultColor, const char *pInString, unsigned int uLineSpacing);
   void DrawShops_next_generation_time_string(__int64 next_generation_time);
   void HouseDialogManager();
-  void DrawMessageBox(int arg0);
+  void DrawMessageBox(bool inside_game_viewport);
   GUIButton *GetControl(unsigned int uID);
   void _41D08F_set_keyboard_control_group(int num_buttons, int a3, int a4, int a5);
   void _41D73D_draw_buff_tooltip();
@@ -350,6 +350,8 @@
   virtual void Update() {}
   virtual void Release();
 
+  static void InitializeGUI();
+
   unsigned int uFrameX;
   unsigned int uFrameY;
   unsigned int uFrameWidth;
@@ -671,7 +673,7 @@
 
 void UI_OnMouseRightClick(Vec2_int_ *_this);
 
-void __fastcall DrawPopupWindow(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight); // idb
+void DrawPopupWindow(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight); // idb
 void DrawMM7CopyrightWindow();
 //void LoadFonts_and_DrawCopyrightWindow();
 void GUI_UpdateWindows();
@@ -680,7 +682,7 @@
 void CreateAwardsScrollBar();
 void ReleaseAwardsScrollBar();
 void Inventory_ItemPopupAndAlchemy();
-void __fastcall LoadThumbnailLloydTexture(unsigned int uSlot, unsigned int uPlayer);
+void LoadThumbnailLloydTexture(unsigned int uSlot, unsigned int uPlayer);
 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
--- a/GUI/UI/Books/LloydsBook.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/GUI/UI/Books/LloydsBook.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -132,7 +132,7 @@
             if (pPlayer->pInstalledBeacons[BeaconID].SaveFileID != 0)
             {
                 pRenderer->DrawTextureIndexedAlpha(pLloydsBeacons_SomeXs[BeaconID], pLloydsBeacons_SomeYs[BeaconID], pTexture_CurrentBook);
-                pRenderer->DrawTextureRGB(pLloydsBeaconsPreviewXs[BeaconID], pLloydsBeaconsPreviewYs[BeaconID], &pSavegameThumbnails[BeaconID]);
+                pRenderer->DrawTextureNew(pLloydsBeaconsPreviewXs[BeaconID]/640.0f, pLloydsBeaconsPreviewYs[BeaconID]/480.0f, pSavegameThumbnails[BeaconID]);
                 Str = pMapStats->pInfos[pMapStats->sub_410D99_get_map_index(pPlayer->pInstalledBeacons[BeaconID].SaveFileID)].pName;
                 pTextHeight = pSpellFont->CalcTextHeight(Str, &pWindow, 0, 0);
                 pWindow.uFrameY += -6 - pTextHeight;
--- a/GUI/UI/Books/MapBook.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/GUI/UI/Books/MapBook.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -242,7 +242,7 @@
         screenWidth = br_x - tl_x + 1;
         screenHeight = br_y - tl_y + 1;
         //render16_data = &pRenderer->pTargetSurface[tl_x + tl_y * pRenderer->uTargetSurfacePitch];
-        texture8_data = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0_prolly_alpha_mask;
+        texture8_data = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].paletted_pixels;
         pPalette_16 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
         scale_increment = (1 << (pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2 + 16)) / viewparams->uMapBookMapZoom;
 
--- a/GUI/UI/Spellbook.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/GUI/UI/Spellbook.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -168,7 +168,7 @@
                         pTexture = SBPageCSpellsTextureList[i];
                     else
                         pTexture = SBPageSSpellsTextureList[i];
-                    if (pTexture->pLevelOfDetail0_prolly_alpha_mask)
+                    if (pTexture->paletted_pixels)
                     {
                         pX_coord = pViewport->uViewportTL_X + pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][i]].Xpos;
                         pY_coord = pViewport->uViewportTL_Y + pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][i]].Ypos;
@@ -188,7 +188,7 @@
     v10 = pRenderer->pActiveZBuffer[a2.x + pSRZBufferLineOffsets[a2.y]] & 0xFFFF;
     if (v10)
     {
-        if (SBPageCSpellsTextureList[v10]->pLevelOfDetail0_prolly_alpha_mask)
+        if (SBPageCSpellsTextureList[v10]->paletted_pixels)
         {
             pX_coord = pViewport->uViewportTL_X + pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][v10]].Xpos;
             pY_coord = pViewport->uViewportTL_Y + pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][v10]].Ypos;
--- a/GUI/UI/UICharacter.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/GUI/UI/UICharacter.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -1608,7 +1608,7 @@
   }
   if ( !bRingsShownInCharScreen )//ðèñîâàíèå ëóïû
     pRenderer->DrawTextureIndexedAlpha(603, 299, pIcons_LOD->GetTexture(uTextureID_MAGNIF_B));
-  pRenderer->DrawTextureIndexedAlpha(468, 0, pIcons_LOD->GetTexture(uTextureID_right_panel_loop));//îáðàìëåíèå
+  pRenderer->DrawTextureIndexedAlpha(468, 0, right_panel_loop);//îáðàìëåíèå
 }
 
 //----- (0041A2D1) --------------------------------------------------------
@@ -1723,7 +1723,7 @@
 {
   CharacterUI_DrawPaperdoll(player);
   pRenderer->DrawTextureIndexedAlpha(0x1D9u, 0, pIcons_LOD->GetTexture(uTextureID_BACKHAND));
-  pRenderer->DrawTextureIndexedAlpha(0x1D4u, 0, pIcons_LOD->GetTexture(uTextureID_right_panel_loop));
+  pRenderer->DrawTextureIndexedAlpha(0x1D4u, 0, right_panel_loop);
   pRenderer->DrawTextureIndexed(pCharacterScreen_DetalizBtn->uX, pCharacterScreen_DetalizBtn->uY,
                                 pIcons_LOD->GetTexture(uTextureID_detaliz_close_button));
   for (uint i = 0; i < 6; ++i)
@@ -1755,7 +1755,7 @@
   uTextureID_MAGNIF_B = pIcons_LOD->LoadTexture("MAGNIF-B", TEXTURE_16BIT_PALETTE);
   //if ( !pParty->uAlignment || pParty->uAlignment == 1 || pParty->uAlignment == 2 )
   uTextureID_BACKDOLL = pIcons_LOD->LoadTexture("BACKDOLL", TEXTURE_16BIT_PALETTE);
-  uTextureID_right_panel_loop = uTextureID_right_panel;
+  right_panel_loop = right_panel;
   uTextureID_BACKHAND = pIcons_LOD->LoadTexture("BACKHAND", TEXTURE_16BIT_PALETTE);
   uTextureID_detaliz_close_button = uExitCancelTextureId;
   for ( uint i = 0; i < 4; ++i )
--- a/GUI/UI/UIGame.h	Mon Oct 05 00:19:13 2015 +0200
+++ b/GUI/UI/UIGame.h	Sat Mar 05 01:51:54 2016 +0200
@@ -44,4 +44,13 @@
     virtual ~GUIWindow_GameVideoOptions() {}
 
     virtual void Update();
-};
\ No newline at end of file
+};
+
+
+
+
+extern class Image *game_ui_statusbar;
+extern class Image *game_ui_rightframe;
+extern class Image *game_ui_topframe;
+extern class Image *game_ui_leftframe;
+extern class Image *game_ui_bottomframe;
\ No newline at end of file
--- a/GUI/UI/UIHouses.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/GUI/UI/UIHouses.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -887,10 +887,10 @@
 		v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
 		pDialogueNPCCount = 0;
 		pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v17];
-		uTextureID_right_panel_loop = uTextureID_right_panel;
+        right_panel_loop = right_panel;
 		PrepareHouse(uHouseID);
 		v18 = 1;
-		uTextureID_right_panel_loop = uTextureID_right_panel;
+        right_panel_loop = right_panel;
 		if ( uNumDialogueNPCPortraits == 1 )
 			pDialogueNPCCount = 1;
 		pMediaPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u);
--- a/GUI/UI/UIMainMenu.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/GUI/UI/UIMainMenu.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -4,6 +4,7 @@
 #include <crtdbg.h>
 
 #include "Engine/Engine.h"
+#include "Engine/AssetsManager.h"
 #include "Engine/LOD.h"
 #include "Engine/MMT.h"
 #include "Engine/texts.h"
@@ -325,7 +326,6 @@
   char *pString; // [sp+12Ch] [bp-10h]@9
   GUIFont *pFontQuick; // [sp+134h] [bp-8h]@1
   GUIFont *pFontCChar; // [sp+138h] [bp-4h]@1
-  RGBTexture mm6title_texture; // [sp+54h] [bp-E8h]@1
   RGBTexture cred_texture; // [sp+100h] [bp-3Ch]@1
   Texture pTemporaryTexture; // [sp+Ch] [bp-130h]@5
 
@@ -344,7 +344,9 @@
 	PlayAudio(L"Music\\15.mp3");
   else
     pAudioPlayer->PlayMusicTrack(MUSIC_Credits);
-  mm6title_texture.Load("mm6title.pcx", 0);
+
+  Image *mm6title = assets->GetImage_PCXFromIconsLOD(L"mm6title.pcx");
+
   cred_texturet = (char *)pEvents_LOD->LoadRaw("credits.txt", 0);
   pFile = pEvents_LOD->FindContainer("credits.txt", 0);
   if ( !pFile )
@@ -402,7 +404,7 @@
     else
     {
       pRenderer->BeginScene();
-      pRenderer->DrawTextureRGB(0, 0, &mm6title_texture);
+      pRenderer->DrawTextureNew(0, 0, mm6title);
       pRenderer->SetUIClipRect(credit_window.uFrameX, credit_window.uFrameY, credit_window.uFrameX + credit_window.uFrameWidth,
            credit_window.uFrameY + credit_window.uFrameHeight);
       pRenderer->CreditsTextureScroll(credit_window.uFrameX, credit_window.uFrameY, 0, move_Y, &cred_texture);
@@ -425,7 +427,13 @@
   free(pFontCChar);
   pWindow_MainMenu->Release();
   pIcons_LOD->RemoveTexturesPackFromTextureList();
-  mm6title_texture.Release();
+
+  if (mm6title)
+  {
+      mm6title->Release();
+      mm6title = nullptr;
+  }
+    
   cred_texture.Release();
   return MENU_MAIN;     // return MENU_Main
 }
--- a/GUI/UI/UIPartyCreation.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/GUI/UI/UIPartyCreation.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -4,6 +4,7 @@
 #include <crtdbg.h>
 
 #include "Engine/Engine.h"
+#include "Engine/AssetsManager.h"
 #include "Engine/Party.h"
 #include "Engine/LOD.h"
 #include "Engine/Timer.h"
@@ -109,7 +110,7 @@
 
   //move sky
   pRenderer->BeginScene();
-  pRenderer->DrawTextureNew(0, 0, &main_menu_background);
+  pRenderer->DrawTextureNew(0, 0, main_menu_background);
   uPlayerCreationUI_SkySliderPos = (GetTickCount() % 12800) / 20;
   pRenderer->DrawTextureIndexed(uPlayerCreationUI_SkySliderPos, 2, pTexture_MAKESKY);
   pRenderer->DrawTextureIndexed(uPlayerCreationUI_SkySliderPos - window->GetWidth(), 2, pTexture_MAKESKY);
@@ -565,8 +566,13 @@
   bool party_not_creation_flag; // [sp+74h] [bp-Ch]@1
 
   party_not_creation_flag = false;
-  main_menu_background.Release();
-  main_menu_background.Load("makeme.pcx", 0);
+
+  if (main_menu_background)
+  {
+      main_menu_background->Release();
+      main_menu_background = nullptr;
+  }
+  main_menu_background = assets->GetImage_PCXFromIconsLOD(L"makeme.pcx");
 
   pGUIWindow_CurrentMenu->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
   SetCurrentMenuID(MENU_CREATEPARTY);
@@ -607,7 +613,6 @@
       }
     }
   }
-  main_menu_background.Release();
 
   pGUIWindow_CurrentMenu->Release();
   pGUIWindow_CurrentMenu = nullptr;
@@ -731,6 +736,12 @@
     }
   }
 
+  if (main_menu_background)
+  {
+      main_menu_background->Release();
+      main_menu_background = nullptr;
+  }
+
   pAudioPlayer->StopChannels(-1, -1);
   return party_not_creation_flag;
 }
\ No newline at end of file
--- a/GUI/UI/UIPopup.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/GUI/UI/UIPopup.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -31,6 +31,16 @@
 static char static_sub_417BB5_out_string[1200]; // static to a file, not sub actually
 
 
+struct Image *parchment = nullptr;
+struct Image *messagebox_corner_x = nullptr; // 5076AC
+struct Image *messagebox_corner_y = nullptr; // 5076B4
+struct Image *messagebox_corner_z = nullptr; // 5076A8
+struct Image *messagebox_corner_w = nullptr; // 5076B0
+struct Image *messagebox_border_top = nullptr; // 507698
+struct Image *messagebox_border_bottom = nullptr; // 5076A4
+struct Image *messagebox_border_left = nullptr; // 50769C
+struct Image *messagebox_border_right = nullptr; // 5076A0
+
 //----- (004179BC) --------------------------------------------------------
 void CharacterUI_DrawTooltip(const char *Title, const char *content)
 {
@@ -59,55 +69,117 @@
 }
 
 //----- (004151D9) --------------------------------------------------------
-void __fastcall DrawPopupWindow(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight)
+void DrawPopupWindow(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight)
 {
   unsigned int uNumTiles; // [sp+2Ch] [bp-Ch]@6
-  unsigned int coord_x; // [sp+2Ch] [bp-Ch]@3
-  unsigned int coord_y; // [sp+34h] [bp-4h]@5
+  int coord_x; // [sp+2Ch] [bp-Ch]@3
+  int coord_y; // [sp+34h] [bp-4h]@5
 
-  auto parchment = pIcons_LOD->GetTexture(uTextureID_Parchment);
+  if (!parchment)
+      return;
 
-  if ( parchment->uTextureWidth && parchment->uTextureHeight)
-  {
+
     pRenderer->SetUIClipRect(uX, uY, uX + uWidth, uY + uHeight);
 
-    uNumTiles = uWidth / parchment->uTextureWidth;
-    if ( uWidth % parchment->uTextureWidth )
+    unsigned int parchment_width = parchment->GetWidth();
+    unsigned int parchment_height = parchment->GetHeight();
+
+    uNumTiles = uWidth / parchment_width;
+    if ( uWidth % parchment_width)
       ++uNumTiles;
     coord_y = uY;
-    for ( uint j = 0; j <= uHeight / parchment->uTextureHeight; j++ )
+    for ( uint j = 0; j <= uHeight / parchment_height; j++ )
     {
-      coord_x = uX - parchment->uTextureWidth;
+      coord_x = uX - parchment_width;
       for ( uint i = uNumTiles + 1; i; --i )
       {
-        coord_x += parchment->uTextureWidth;
-        pRenderer->DrawTextureIndexed(coord_x, coord_y, parchment);
+        coord_x += parchment_width;
+        pRenderer->DrawTextureNew(coord_x / 640.0f, coord_y / 480.0f, parchment);
       }
-      coord_y += parchment->uTextureHeight;
+      coord_y += parchment_height;
     }
-    pRenderer->DrawTextureIndexedAlpha(uX,               uY,                pIcons_LOD->GetTexture(uTextureID_5076AC));
-    pRenderer->DrawTextureIndexedAlpha(uX,               uY + uHeight - 32, pIcons_LOD->GetTexture(uTextureID_5076B4));
-    pRenderer->DrawTextureIndexedAlpha(uX + uWidth - 32, uY,                pIcons_LOD->GetTexture(uTextureID_5076A8));
-    pRenderer->DrawTextureIndexedAlpha(uX + uWidth - 32, uY + uHeight - 32, pIcons_LOD->GetTexture(uTextureID_5076B0));
-    if ( uWidth > 64 )
+
+
+    pRenderer->DrawTextureAlphaNew(
+        uX / 640.0f,
+        uY / 480.0f,
+        messagebox_corner_x
+    );
+    pRenderer->DrawTextureAlphaNew(
+        uX / 640.0f,
+        (uY + uHeight - messagebox_corner_y->GetHeight()) / 480.0f,
+        messagebox_corner_y
+    );
+    pRenderer->DrawTextureAlphaNew(
+        (uX + uWidth - messagebox_corner_z->GetWidth()) / 640.0f,
+        uY / 480.0f,
+        messagebox_corner_z
+    );
+    pRenderer->DrawTextureAlphaNew(
+        (uX + uWidth - messagebox_corner_z->GetWidth()) / 640.0f,
+        (uY + uHeight - messagebox_corner_y->GetHeight()) / 480.0f,
+        messagebox_corner_w
+    );
+
+
+    if (uWidth > messagebox_corner_x->GetWidth() + messagebox_corner_z->GetWidth())
     {
-      pRenderer->SetUIClipRect(uX + 32, uY, uX + uWidth - 32, uY + uHeight);
-      pRenderer->DrawTextureIndexedAlpha(uX + 32, uY,                pIcons_LOD->GetTexture(uTextureID_507698));
-      pRenderer->DrawTextureIndexedAlpha(uX + 32, uY + uHeight - 10, pIcons_LOD->GetTexture(uTextureID_5076A4));
-      if ( uWidth > 512 )
+      pRenderer->SetUIClipRect(
+          uX + messagebox_corner_x->GetWidth(),
+          uY,
+          uX + uWidth - messagebox_corner_z->GetWidth(),
+          uY + uHeight
+      );
+
+      // horizontal borders
+      for (
+          unsigned int x = uX + messagebox_corner_x->GetWidth();
+          x < uX + uWidth - messagebox_corner_x->GetWidth();
+          x += messagebox_border_top->GetWidth()
+      )
       {
-        pRenderer->DrawTextureIndexedAlpha(uX + 544, uY,                pIcons_LOD->GetTexture(uTextureID_507698));
-        pRenderer->DrawTextureIndexedAlpha(uX + 544, uY + uHeight - 10, pIcons_LOD->GetTexture(uTextureID_5076A4));
+          pRenderer->DrawTextureAlphaNew(
+              x / 640.0f,
+              uY / 480.0f,
+              messagebox_border_top
+          );
+          pRenderer->DrawTextureAlphaNew(
+              x / 640.0f,
+              (uY + uHeight - messagebox_border_bottom->GetHeight()) / 480.0f,
+              messagebox_border_bottom
+          );
       }
     }
-    if ( uHeight > 64 )
+
+    // vertical borders
+    if ( uHeight > messagebox_corner_x->GetHeight() + messagebox_corner_y->GetHeight())
     {
-      pRenderer->SetUIClipRect(uX, uY + 32, uX + uWidth, uY + uHeight - 32);
-      pRenderer->DrawTextureIndexedAlpha(uX,               uY + 32, pIcons_LOD->GetTexture(uTextureID_5076A0));
-      pRenderer->DrawTextureIndexedAlpha(uX + uWidth - 10, uY + 32, pIcons_LOD->GetTexture(uTextureID_50769C));
+      pRenderer->SetUIClipRect(
+          uX,
+          uY + messagebox_corner_x->GetHeight(),
+          uX + uWidth,
+          uY + uHeight - messagebox_corner_y->GetHeight()
+      );
+
+      for (
+          unsigned int y = uY + messagebox_corner_x->GetHeight();
+          y < uY + uHeight - messagebox_corner_y->GetHeight();
+          y += messagebox_border_top->GetHeight()
+      )
+      {
+          pRenderer->DrawTextureAlphaNew(
+              uX / 640.0f,
+              y / 480.0f,
+              messagebox_border_left
+          );
+          pRenderer->DrawTextureAlphaNew(
+              (uX + uWidth - messagebox_border_right->GetWidth() - 1) / 640.0f,
+              y / 480.0f,
+              messagebox_border_right
+          );
+      }
     }
     pRenderer->ResetUIClipRect();
-  }
 }
 
 //----- (0041D895) --------------------------------------------------------
--- a/GUI/UI/UIPopup.h	Mon Oct 05 00:19:13 2015 +0200
+++ b/GUI/UI/UIPopup.h	Sat Mar 05 01:51:54 2016 +0200
@@ -2,3 +2,14 @@
 
 unsigned int __fastcall GetSpellColor(signed int a1);
 __int64 GetExperienceRequiredForLevel(int a1);
+
+
+extern struct Image *parchment;
+extern struct Image *messagebox_corner_x; // 5076AC
+extern struct Image *messagebox_corner_y; // 5076B4
+extern struct Image *messagebox_corner_z; // 5076A8
+extern struct Image *messagebox_corner_w; // 5076B0
+extern struct Image *messagebox_border_top; // 507698
+extern struct Image *messagebox_border_bottom; // 5076A4
+extern struct Image *messagebox_border_left; // 50769C
+extern struct Image *messagebox_border_right; // 5076A0
\ No newline at end of file
--- a/GUI/UI/UISaveLoad.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/GUI/UI/UISaveLoad.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -76,7 +76,7 @@
             fread(&pSavegameHeader[i], 100, 1, pLODFile.FindContainer("header.bin", 1));
             if (pLODFile.FindContainer("image.pcx", 1))
             {
-                pSavegameThumbnails[i].LoadFromFILE(pLODFile.FindContainer("image.pcx", 1), 0, 1);
+                //pSavegameThumbnails[i].LoadFromFILE(pLODFile.FindContainer("image.pcx", 1), 0, 1);
                 pLODFile.CloseWriteFile();
                 pSavegameUsedSlots[i] = 1;
             }
@@ -137,7 +137,7 @@
     pIcons_LOD->_inlined_sub2();
 
     memset(pSavegameUsedSlots.data(), 0, sizeof(pSavegameUsedSlots));
-    memset(pSavegameThumbnails.data(), 0, 45 * sizeof(RGBTexture));
+    memset(pSavegameThumbnails.data(), 0, 45 * sizeof(Image *));
     uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE);
     uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE);
     uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE);
@@ -160,7 +160,7 @@
         pRenderer->DrawTextureIndexed(351, 302, pIcons_LOD->GetTexture(uTextureID_x_u));
     }
     else
-        pRenderer->DrawTextureNew(0, 0, &main_menu_background);
+        pRenderer->DrawTextureNew(0, 0, main_menu_background);
 
 
     /*pGUIWindow_CurrentMenu = new GUIWindow_Load(
@@ -210,7 +210,7 @@
         }
         else
         {
-            pSavegameThumbnails[i].LoadFromFILE(pLODFile.FindContainer("image.pcx", true), 0, true);
+            //pSavegameThumbnails[i].LoadFromFILE(pLODFile.FindContainer("image.pcx", true), 0, true);
             pLODFile.CloseWriteFile();
             pSavegameUsedSlots[i] = 1;
         }
@@ -299,8 +299,8 @@
     save_load_window.uFrameZ = save_load_window.uFrameX + 219;
     save_load_window.uFrameHeight = pFontSmallnum->uFontHeight;
     save_load_window.uFrameW = pFontSmallnum->uFontHeight + save_load_window.uFrameY - 1;
-    if ( pSavegameThumbnails[uLoadGameUI_SelectedSlot].pPixels )
-      pRenderer->DrawTextureRGB(pGUIWindow_CurrentMenu->uFrameX + 276, pGUIWindow_CurrentMenu->uFrameY + 171, &pSavegameThumbnails[uLoadGameUI_SelectedSlot]);
+    if ( pSavegameThumbnails[uLoadGameUI_SelectedSlot] )
+      pRenderer->DrawTextureNew((pGUIWindow_CurrentMenu->uFrameX + 276)/640.0f, (pGUIWindow_CurrentMenu->uFrameY + 171)/480.0f, pSavegameThumbnails[uLoadGameUI_SelectedSlot]);
 //Draw map name
     save_load_window.DrawTitleText(pFontSmallnum, 0, 0, 0, pMapStats->pInfos[pMapStats->GetMapInfo(pSavegameHeader[uLoadGameUI_SelectedSlot].pLocationName)].pName, 3);
 //Draw date
--- a/GUI/UI/UITransition.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/GUI/UI/UITransition.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -216,7 +216,7 @@
   memcpy(&travel_window, pPrimaryWindow, sizeof(travel_window));
   pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pDestinationMapName, 20);
   pRenderer->DrawTextureIndexed(477, 0, pTexture_Dialogue_Background);
-  pRenderer->DrawTextureIndexedAlpha(468, 0, &pIcons_LOD->pTextures[uTextureID_right_panel_loop]);
+  pRenderer->DrawTextureIndexedAlpha(468, 0, right_panel_loop);
   pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pTexture_outside);
   pRenderer->DrawTextureIndexed(556, 451, pIcons_LOD->GetTexture(uTextureID_x_x_u));
   pRenderer->DrawTextureIndexed(476, 451, pIcons_LOD->GetTexture(uTextureID_x_ok_u));
@@ -259,8 +259,8 @@
   pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background);
   pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, pIcons_LOD->GetTexture(uTextureID_50795C));
   pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pTexture_outside);
-  uTextureID_right_panel_loop = uTextureID_right_panel;
-  pRenderer->DrawTextureIndexedAlpha(468, 0, pIcons_LOD->GetTexture(uTextureID_right_panel));
+  right_panel_loop = right_panel;
+  pRenderer->DrawTextureIndexedAlpha(468, 0, right_panel);
   pRenderer->DrawTextureIndexed(556, 451, pIcons_LOD->GetTexture(uTextureID_x_x_u));
   pRenderer->DrawTextureIndexed(476, 451, pIcons_LOD->GetTexture(uTextureID_x_ok_u));
   map_id = pMapStats->GetMapInfo(pCurrentMapName);
--- a/GUI/UI/UiGame.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/GUI/UI/UiGame.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -30,6 +30,8 @@
 #include "Engine/Objects/Chest.h"
 #include "Engine/Graphics/Overlays.h"
 
+#include "Game/Game.h"
+
 #include "IO/Mouse.h"
 #include "IO/Keyboard.h"
 
@@ -44,6 +46,13 @@
 int uTextureID_GameUI_CharSelectionFrame; // 50C98C
 
 
+Image *game_ui_statusbar = nullptr;
+Image *game_ui_rightframe = nullptr;
+Image *game_ui_topframe = nullptr;
+Image *game_ui_leftframe = nullptr;
+Image *game_ui_bottomframe = nullptr;
+
+
 GUIWindow_GameMenu::GUIWindow_GameMenu() :
     GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), 0, nullptr)
 {
@@ -340,7 +349,7 @@
     //if ( !pRenderer->bWindowMode && pRenderer->IsGammaSupported() )
     {
         pRenderer->DrawTextureIndexed(17 * uGammaPos + 42, 162, pIcons_LOD->GetTexture(pTextureIDs_GammaPositions[uGammaPos]));
-        pRenderer->DrawTextureRGB(274, 169, &stru_506E40);//review_window
+        pRenderer->DrawTextureNew(274/640.0f, 169/480.0f, gamma_preview_image);
         msg_window.uFrameX = 22;
         msg_window.uFrameY = 190;
         msg_window.uFrameWidth = 211;
@@ -765,7 +774,7 @@
   v9 = 0;
   pDialogueNPCPortraits[0] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
   dword_591084 = areWeLoadingTexture;
-  uTextureID_right_panel_loop = uTextureID_right_panel;
+  right_panel_loop = right_panel;
   if ( !pNPCInfo->Hired() && pNPCInfo->Location2D >= 0 )
   {
     if ( (signed int)pParty->GetPartyFame() <= pNPCInfo->fame
@@ -863,7 +872,7 @@
   window.uFrameWidth -= 10;
   window.uFrameZ -= 10;
   pRenderer->DrawTextureIndexed(477, 0, pTexture_Dialogue_Background);
-  pRenderer->DrawTextureIndexedAlpha(468, 0, (Texture *)(uTextureID_right_panel_loop != -1 ? &pIcons_LOD->pTextures[uTextureID_right_panel_loop] : 0));
+  pRenderer->DrawTextureIndexedAlpha(468, 0, right_panel_loop);
   pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, (Texture *)(uTextureID_50795C != -1 ? &pIcons_LOD->pTextures[uTextureID_50795C] : 0));
   pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pDialogueNPCPortraits[0]);
 
@@ -1142,7 +1151,7 @@
   pRenderer->GetLeather(8, 352 - pTextHeight, pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - pTextHeight);
   pRenderer->DrawTextureIndexed(8, 347 - pTextHeight, pTexture_591428);
   pGUIWindow2->DrawText(pFont, 12, 354 - pTextHeight, 0, FitTextInAWindow(byte_5B0938.data(), pFont, &BranchlessDlg_window, 12, 0), 0, 0, 0);
-  pRenderer->DrawTextureRGB(0, 0x160u, pTexture_StatusBar);
+  pRenderer->DrawTextureNew(0, 352/480.0f, game_ui_statusbar);
   if ( pGUIWindow2->receives_keyboard_input_2 != WINDOW_INPUT_IN_PROGRESS)
   {
     if ( pGUIWindow2->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED)
@@ -1340,9 +1349,9 @@
   {
     GameUI_RightPanel_BookFlashTimer = pParty->uTimePlayed;
     
-    static bool byte_50697C = false; // 50697C
-    byte_50697C = !byte_50697C;
-    if ( byte_50697C && current_screen_type != SCREEN_REST )
+    static bool _50697C_book_flasher = false; // 50697C
+    _50697C_book_flasher = !_50697C_book_flasher;
+    if (_50697C_book_flasher && current_screen_type != SCREEN_REST )
     {
       if (bFlashQuestBook)     pRenderer->DrawTextureIndexedAlpha(493, 355, pIcons_LOD->GetTexture(uTextureID_ib_td1_A));
       if (bFlashAutonotesBook) pRenderer->DrawTextureIndexedAlpha(527, 353, pIcons_LOD->GetTexture(uTextureID_ib_td2_A));
@@ -1350,7 +1359,7 @@
     }
     else
     {
-      pRenderer->DrawTextureRGB(468, 0, pTexture_RightFrame);
+      pRenderer->DrawTextureNew(468/640.0f, 0, game_ui_rightframe);
       GameUI_DrawHiredNPCs();
     }
   }
@@ -1425,18 +1434,21 @@
 //----- (0041B3B6) --------------------------------------------------------
 void GameUI_DrawRightPanel()
 {
-  pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportBR_X, 0, pIcons_LOD->GetTexture(uTextureID_right_panel));
+  pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportBR_X, 0, right_panel);
 }
 
 //----- (0041B3E2) --------------------------------------------------------
 void GameUI_DrawRightPanelFrames()
 {
-  pRenderer->DrawTextureRGB(0,   0,   pTexture_TopFrame);
-  pRenderer->DrawTextureRGB(0,   8,   pTexture_LeftFrame);
-  pRenderer->DrawTextureRGB(468, 0,   pTexture_RightFrame);
-  pRenderer->DrawTextureRGB(0,   352, pTexture_BottomFrame);
+  pRenderer->DrawTextureNew(0,   0, game_ui_topframe);
+  pRenderer->DrawTextureNew(0,   8/480.0f, game_ui_leftframe);
+  pRenderer->DrawTextureNew(468/640.0f, 0, game_ui_rightframe);
+  pRenderer->DrawTextureNew(0,   352 / 480.0f, game_ui_bottomframe);
   GameUI_DrawFoodAndGold();
   GameUI_DrawRightPanelItems();
+
+  //pRenderer->EndScene();
+  //pRenderer->Present();
 }
 
 //----- (0041C047) --------------------------------------------------------
@@ -1445,7 +1457,7 @@
   char *v1; // edx@2
   int v5; // eax@5
 
-  pRenderer->DrawTextureRGB(0, 352, pTexture_StatusBar);
+  pRenderer->DrawTextureNew(0, 352/480.0f, game_ui_statusbar);
   if (GameUI_Footer_TimeLeft)
     v1 = GameUI_Footer_TimedString.data();
   else
@@ -1491,7 +1503,7 @@
 
   if ( pFooterString[0] || GameUI_Footer_TimeLeft || bForceDrawFooter )
   {
-    pRenderer->DrawTextureRGB(0, 352, pTexture_StatusBar);
+    pRenderer->DrawTextureNew(0, 352/480.0f, game_ui_statusbar);
     if ( GameUI_Footer_TimeLeft )
     {
       v1 = GameUI_Footer_TimedString.data();
@@ -1952,7 +1964,6 @@
 {
   unsigned int face_expression_ID; // eax@17
   PlayerFrame *pFrame; // eax@21
-  int pTextureID; // eax@57
   Texture *pPortrait; // [sp-4h] [bp-1Ch]@27
 
   if ( _A750D8_player_speech_timer )
@@ -2035,15 +2046,20 @@
           {
             if (PID_TYPE(pTurnEngine->pQueue[i].uPackedID) != OBJECT_Player)
               break;
-            pTextureID = dword_5079D0;
+
+            auto tex = _5079D0_init_g;
             if ( pParty->uFlags & 0x10 )
-              pTextureID = dword_5079CC;
+                tex = _5079CC_init_r;
             else
             {
               if ( pParty->uFlags & 0x20 )
-                pTextureID = dword_5079C8;
+                  tex = _5079C8_init_y;
             }
-            pRenderer->DrawTextureIndexedAlpha(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[PID_ID(pTurnEngine->pQueue[i].uPackedID)] - 4, 385, pIcons_LOD->GetTexture(pTextureID));
+            pRenderer->DrawTextureIndexedAlpha(
+                pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[PID_ID(pTurnEngine->pQueue[i].uPackedID)] - 4,
+                385,
+                tex
+            );
           }
         }
       }
@@ -2055,15 +2071,15 @@
     {
       if (pParty->pPlayers[i].CanAct() && !pParty->pPlayers[i].uTimeToRecovery)
       {
-        pTextureID = dword_5079D0;
+        auto tex = _5079D0_init_g;
         if ( pParty->uFlags & 0x10 )
-          pTextureID = dword_5079CC;
+            tex = _5079CC_init_r;
         else
         {
           if ( pParty->uFlags & 0x20 )
-            pTextureID = dword_5079C8;
+              tex = _5079C8_init_y;
         }
-        pRenderer->DrawTextureIndexedAlpha(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] - 4, 385, pIcons_LOD->GetTexture(pTextureID));
+        pRenderer->DrawTextureIndexedAlpha(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] - 4, 385, tex);
       }
     }
   }
@@ -2116,7 +2132,7 @@
 
   if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
   {
-    uchar* pMapLod0 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0_prolly_alpha_mask;
+    uchar* pMapLod0 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].paletted_pixels;
     ushort* pPal = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
     v73 = (1 << (pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2 + 16)) / (signed int)uZoom;
     v20 = (double)(pParty->vPosition.x + 32768) / (double)(1 << (16 - pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2));
@@ -2382,9 +2398,9 @@
       }
     }
   }
-  pRenderer->DrawTextureIndexedAlpha(468, 0, pIcons_LOD->GetTexture(uTextureID_Minimap_Loop));//draw minimap_loop
+  pRenderer->DrawTextureIndexedAlpha(468, 0, minimap_loop);
   pRenderer->SetUIClipRect(541, 0, 567, 480);
-  pRenderer->DrawTextureIndexed(floorf(((double)pParty->sRotationY * 0.1171875) + 0.5f) + 285, 136, pIcons_LOD->GetTexture(uTextureID_Compas));//draw compas
+  pRenderer->DrawTextureIndexed(floorf(((double)pParty->sRotationY * 0.1171875) + 0.5f) + 285, 136, _5079B4_compass);
   pRenderer->ResetUIClipRect();
 }
 
--- a/Game/Game.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/Game/Game.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -1,4 +1,5 @@
 #include "Engine/Engine.h"
+#include "Engine/AssetsManager.h"
 #include "Engine/Party.h"
 #include "Engine/LOD.h"
 #include "Engine/Events.h"
@@ -56,6 +57,11 @@
 #include "Game/GameMenu.h"
 
 
+
+Image *gamma_preview_image = nullptr; // 506E40
+
+
+
 void DoThatMessageThing()
 {
     if (pMessageQueue_50CBD0->uNumMessages)
@@ -1445,27 +1451,34 @@
                 uNumSeconds = (unsigned int)&pPlayer->pInstalledBeacons[uMessageParam];
                 if (bRecallingBeacon)
                 {
-                    if (!*((int *)&pSavegameThumbnails[10 * uMessageParam].pPixels))
-                        continue;
-                    v173 = pMapStats->pInfos[pMapStats->sub_410D99_get_map_index(pPlayer->pInstalledBeacons[uMessageParam].SaveFileID)].pName;
-                    sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[474], v173);// "Recall to %s"
-                    GameUI_SetFooterString(pTmpBuf.data());
+                    
+                    __debugbreak();/*indexing error*/ //if (*((int *)&pSavegameThumbnails[10 * uMessageParam].pPixels))
+                    {
+                        v173 = pMapStats->pInfos[pMapStats->sub_410D99_get_map_index(pPlayer->pInstalledBeacons[uMessageParam].SaveFileID)].pName;
+                        sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[474], v173);// "Recall to %s"
+                        GameUI_SetFooterString(pTmpBuf.data());
+                    }
                     continue;
                 }
                 pMapNum = pMapStats->GetMapInfo(pCurrentMapName);
                 pMapName = "Not in Map Stats";
                 if (pMapNum)
                     pMapName = pMapStats->pInfos[pMapNum].pName;
-                if (!*((int *)&pSavegameThumbnails[10 * uMessageParam].pPixels) || !pMapNum)
+
+                __debugbreak();/*indexing error*/ //if (!*((int *)&pSavegameThumbnails[10 * uMessageParam].pPixels) || !pMapNum)
+                if (!pMapNum)
                 {
                     sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[476], pMapName);// "Set to %s"
                     GameUI_SetFooterString(pTmpBuf.data());
-                    continue;
                 }
-                v174 = pMapStats->pInfos[pMapStats->sub_410D99_get_map_index(*(short *)(uNumSeconds + 26))].pName;
-                sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[475], (unsigned int)pMapName, v174);// "Set %s over %s"
-                GameUI_SetFooterString(pTmpBuf.data());
+                else
+                {
+                    v174 = pMapStats->pInfos[pMapStats->sub_410D99_get_map_index(*(short *)(uNumSeconds + 26))].pName;
+                    sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[475], (unsigned int)pMapName, v174);// "Set %s over %s"
+                    GameUI_SetFooterString(pTmpBuf.data());
+                }
                 continue;
+
             case UIMSG_CloseAfterInstallBeacon:
                 dword_50CDC8 = 1;
                 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
@@ -1675,7 +1688,7 @@
                 }
                 if (!(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v68))
                 {
-                    pRenderer->DrawTextureRGB(0, 0x160u, pTexture_StatusBar);
+                    pRenderer->DrawTextureNew(0, 352/480.0f, game_ui_statusbar);
                     continue;
                 }
                 //LABEL_506:
@@ -2254,9 +2267,13 @@
                     viewparams->bRedrawGameUI = 1;
                 }
 
-                stru_506E40.Release();
+                if (gamma_preview_image)
+                {
+                    gamma_preview_image->Release();
+                    gamma_preview_image = nullptr;
+                }
                 pRenderer->SaveScreenshot("gamma.pcx", 155, 117);
-                stru_506E40.LoadPCXFile("gamma.pcx", 0);
+                gamma_preview_image = assets->GetImage_PCXFromFile(L"gamma.pcx");
 
                 new OnButtonClick(0x25Au, 0x1C2u, 0, 0, (int)pBtn_GameSettings, 0);
                 //LABEL_453:
--- a/Game/Game.h	Mon Oct 05 00:19:13 2015 +0200
+++ b/Game/Game.h	Sat Mar 05 01:51:54 2016 +0200
@@ -1,3 +1,6 @@
 #pragma once
 
-void Game_Loop();
\ No newline at end of file
+void Game_Loop();
+
+
+extern struct Image *gamma_preview_image; // 506E40
\ No newline at end of file
--- a/Game/GameMenu.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/Game/GameMenu.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -1,4 +1,6 @@
 #include "Engine/Engine.h"
+#include "Engine/AssetsManager.h"
+#include "Game/Game.h"
 #include "Engine/Timer.h"
 #include "Engine/LOD.h"
 #include "Engine/Party.h"
@@ -592,9 +594,13 @@
 
     viewparams->field_48 = 1;
 
-    stru_506E40.Release();
+    if (gamma_preview_image)
+    {
+        gamma_preview_image->Release();
+        gamma_preview_image = nullptr;
+    }
     pRenderer->SaveScreenshot("gamma.pcx", 155, 117);
-    stru_506E40.LoadPCXFile("gamma.pcx", 0);
+    gamma_preview_image = assets->GetImage_PCXFromFile(L"gamma.pcx");
 
     while (uGameState == GAME_STATE_PLAYING
         && (
@@ -633,5 +639,9 @@
     pGUIWindow_CurrentMenu->Release();
     pGUIWindow_CurrentMenu = nullptr;
 
-    stru_506E40.Release();
+    if (gamma_preview_image)
+    {
+        gamma_preview_image->Release();
+        gamma_preview_image = nullptr;
+    }
 }
\ No newline at end of file
--- a/Game/GameOver.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/Game/GameOver.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -1,4 +1,5 @@
 #include "Engine/Engine.h"
+#include "Engine/AssetsManager.h"
 #include "Engine/Timer.h"
 #include "Engine/texts.h"
 #include "Engine/Party.h"
@@ -39,7 +40,7 @@
     unsigned __int64 v23; // [sp+C8h] [bp-8h]@5
     MSG msg;
 
-    RGBTexture _this; // [sp+Ch] [bp-C4h]@1
+    //RGBTexture _this; // [sp+Ch] [bp-C4h]@1
     //RGBTexture::RGBTexture(&this);
 
     dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_4000;
@@ -52,12 +53,17 @@
     pRenderer->Present();
     //pMediaPlayer->pResetflag = 0;
     _449B57_test_bit(pParty->_quest_bits, 99);
-    _this.Load("winbg.pcx", 2);
-    pRenderer->BeginScene();
-    pRenderer->DrawTextureRGB(0, 0, &_this);
-    pRenderer->EndScene();
-    free(_this.pPixels);
-    _this.pPixels = 0;
+
+
+    Image *background = assets->GetImage_PCXFromIconsLOD(L"winbg.pcx");
+    {
+        pRenderer->BeginScene();
+        pRenderer->DrawTextureNew(0, 0, background);
+        pRenderer->EndScene();
+    }
+    background->Release();
+    background = nullptr;
+
     window_SpeakInHouse = new GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), 0, 0);
     pWindow.uFrameX = 75;
     pWindow.uFrameY = 60;
--- a/Game/MainMenu.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/Game/MainMenu.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -1,8 +1,10 @@
 #include "Engine/Engine.h"
+#include "Engine/AssetsManager.h"
 #include "Engine/Timer.h"
 #include "Engine/Party.h"
 #include "Engine/LOD.h"
 #include "Engine/SaveLoad.h"
+#include "Engine/texts.h"
 #include "Engine/Graphics/IRender.h"
 #include "Engine/Graphics/Viewport.h"
 
@@ -13,6 +15,7 @@
 #include "GUI/UI/UIPartyCreation.h"
 #include "GUI/UI/UISaveLoad.h"
 #include "GUI/GUIButton.h"
+#include "GUI/GUIFont.h"
 
 #include "Media/Audio/AudioPlayer.h"
 #include "Media/Audio/AIL.h"
@@ -21,7 +24,8 @@
 #include "Game/MainMenuLoad.h"
 
 
-RGBTexture main_menu_background;
+Image *main_menu_bg = nullptr;
+Image *main_menu_background = nullptr;
 
 
 
@@ -367,28 +371,20 @@
     MSG msg;
 
 
+    pAudioPlayer->StopChannels(-1, -1);
+    if (!bNoSound && pAudioPlayer)
+        pAudioPlayer->PlayMusicTrack(MUSIC_MainMenu);
 
     if (first_initialization)
     {
         first_initialization = false;
 
-        RGBTexture tex; // [sp+Ch] [bp-30h]@1
-        tex.Load("mm6title.pcx", 2);
+        if (!main_menu_bg)
+            main_menu_bg = assets->GetImage_PCXFromIconsLOD(L"mm6title.pcx");
 
         pRenderer->ResetUIClipRect();
         pRenderer->BeginScene();
         {
-            pRenderer->DrawTextureNew(0, 0, &tex);
-        }
-        pRenderer->EndScene();
-        pRenderer->Present();
-
-        tex.Release();
-
-        MainMenuUI_LoadFontsAndSomeStuff();
-
-        pRenderer->BeginScene();
-        {
             DrawMM7CopyrightWindow();
         }
         pRenderer->EndScene();
@@ -398,17 +394,6 @@
         Sleep(1500);   // let the copyright window stay for a while
 #endif
 
-        if (!bNoSound && pAudioPlayer->hAILRedbook)
-        {
-            unsigned int uTrackStartMS; // [sp+34h] [bp-8h]@8
-            unsigned int uTrackEndMS; // [sp+38h] [bp-4h]@8
-
-            pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0));
-            AIL_redbook_stop(pAudioPlayer->hAILRedbook);
-            AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &uTrackStartMS, &uTrackEndMS);
-            AIL_redbook_play(pAudioPlayer->hAILRedbook, uTrackStartMS + 1, uTrackEndMS);
-        }
-
         SecondaryInitialization();
         FinalInitialization();
     }
@@ -417,38 +402,18 @@
     current_screen_type = SCREEN_GAME;
 
     pGUIWindow2 = 0;
-    pAudioPlayer->StopChannels(-1, -1);
-    pMouse->RemoveHoldingItem();
-
-    pIcons_LOD->_inlined_sub2();
 
     pWindow_MainMenu = new GUIWindow_MainMenu();
 
-    main_menu_background.Release();
-    main_menu_background.Load("title.pcx", 0);
     SetCurrentMenuID(MENU_MAIN);
     SetForegroundWindow(window->GetApiHandle());
     SendMessageW(window->GetApiHandle(), WM_ACTIVATEAPP, 1, 0);
 
-    //while (GetCurrentMenuID() == MENU_MAIN || GetCurrentMenuID() == MENU_SAVELOAD)
     while (GetCurrentMenuID() == MENU_MAIN)
     {
         POINT pt;
         pMouse->GetCursorPos(&pt);
         pWindow = pWindow_MainMenu;
-        /*if (GetCurrentMenuID() == MENU_SAVELOAD)
-        {
-            if (current_screen_type != SCREEN_LOADGAME)
-            {
-                main_menu_background.Release();
-                main_menu_background.Load("lsave640.pcx", 0);
-                pGUIWindow2 = new GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), 0, 0);
-
-                //LoadUI_Load(0);
-                pGUIWindow_CurrentMenu = new GUIWindow_Load(false);
-            }
-            pWindow = pGUIWindow_CurrentMenu;
-        }*/
 
         while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE))
         {
@@ -464,9 +429,12 @@
             continue;
         }
 
+        if (!main_menu_background)
+            main_menu_background = assets->GetImage_PCXFromIconsLOD(L"title.pcx");
+
         pRenderer->BeginScene();
         {
-            pRenderer->DrawTextureNew(0, 0, &main_menu_background);
+            pRenderer->DrawTextureNew(0, 0, main_menu_background);
 
             MainMenu_EventLoop();
             GUI_UpdateWindows();
@@ -483,14 +451,41 @@
     pRenderer->EndScene();
     pRenderer->Present();
 
-    main_menu_background.Release();
-    /*if (pGUIWindow2)
-    {
-        pGUIWindow2->Release();
-        pGUIWindow2 = 0;
-    }*/
+    main_menu_background->Release();
+    main_menu_background = nullptr;
+
     pWindow_MainMenu->Release();
     pWindow_MainMenu = nullptr;
+}
 
-    pIcons_LOD->RemoveTexturesPackFromTextureList();
-}
\ No newline at end of file
+
+
+//----- (00415485) --------------------------------------------------------
+void DrawMM7CopyrightWindow()
+{
+    pRenderer->DrawTextureNew(0, 0, main_menu_bg);
+
+    GUIWindow Dst; // [sp+8h] [bp-54h]@1
+
+    memset(&Dst, 0, sizeof(Dst));
+    Dst.uFrameWidth = 624;
+    Dst.uFrameHeight = 256;
+    Dst.uFrameX = 8;
+    Dst.uFrameY = 30;                             // c 1999 The 3DO Company.
+    Dst.uFrameHeight = pFontSmallnum->CalcTextHeight(pGlobalTXT_LocalizationStrings[157], &Dst, 24, 0)
+        + 2 * LOBYTE(pFontSmallnum->uFontHeight)
+        + 24;
+    Dst.uFrameY = 470 - Dst.uFrameHeight;
+    Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
+    Dst.uFrameW = 469;
+    //Dst.Hint = "abcagfdsgsg ljsrengvlkjesnfkjwnef";
+    Dst.DrawMessageBox(0);
+
+    Dst.uFrameWidth -= 24;
+    Dst.uFrameX += 12;
+    Dst.uFrameY += 12;
+    Dst.uFrameHeight -= 12;
+    Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
+    Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1;
+    Dst.DrawTitleText(pFontSmallnum, 0, 12, ui_mainmenu_copyright_color, pGlobalTXT_LocalizationStrings[157], 3);
+}
--- a/Game/MainMenu.h	Mon Oct 05 00:19:13 2015 +0200
+++ b/Game/MainMenu.h	Sat Mar 05 01:51:54 2016 +0200
@@ -4,4 +4,4 @@
 void MainMenu_EventLoop();
 
 
-extern struct RGBTexture main_menu_background;
\ No newline at end of file
+extern struct Image *main_menu_background;
\ No newline at end of file
--- a/Game/MainMenuLoad.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/Game/MainMenuLoad.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -1,4 +1,5 @@
 #include "Engine/Engine.h"
+#include "Engine/AssetsManager.h"
 #include "Engine/SaveLoad.h"
 #include "Engine/LOD.h"
 #include "Engine/Timer.h"
@@ -95,8 +96,14 @@
                 {
                     pIcons_LOD->RemoveTexturesPackFromTextureList();
                     //crt_deconstruct_ptr_6A0118();
-                    main_menu_background.Release();
-                    main_menu_background.Load("title.pcx", 0);
+
+                    if (main_menu_background)
+                    {
+                        main_menu_background->Release();
+                        main_menu_background = nullptr;
+                    }
+                    main_menu_background = assets->GetImage_PCXFromIconsLOD(L"title.pcx");
+
                     SetCurrentMenuID(MENU_MAIN);
                     current_screen_type = SCREEN_GAME;
                     pEventTimer->Resume();
@@ -113,8 +120,12 @@
 {
     current_screen_type = SCREEN_LOADGAME;
 
-    main_menu_background.Release();
-    main_menu_background.Load("lsave640.pcx", 0);
+    if (main_menu_background)
+    {
+        main_menu_background->Release();
+        main_menu_background = nullptr;
+    }
+    main_menu_background = assets->GetImage_PCXFromIconsLOD(L"lsave640.pcx");
 
         //LoadUI_Load(0);
     pGUIWindow_CurrentMenu = new GUIWindow_Load(false);
@@ -137,7 +148,7 @@
         }
 
         pRenderer->BeginScene();
-        pRenderer->DrawTextureNew(0, 0, &main_menu_background);
+        pRenderer->DrawTextureNew(0, 0, main_menu_background);
 
         MainMenuLoad_EventLoop();
         GUI_UpdateWindows();
--- a/Media/Audio/AudioPlayer.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/Media/Audio/AudioPlayer.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -433,14 +433,15 @@
 //----- (004AA13F) --------------------------------------------------------
 void AudioPlayer::PlayMusicTrack(MusicID eTrack)
 {
-  char string[256];
   if (!bNoSound && bPlayerReady && uMusicVolimeMultiplier)
   {
     if ( use_music_folder )
     {
       alSourceStop(mSourceID);
 
+      char string[256];
       sprintf(string, "Music\\%d.mp3", eTrack);
+
       if (!FileExists(string))
       {
         Log::Warning(L"Music\\%d.mp3 not found", eTrack);
@@ -449,13 +450,13 @@
       LPWSTR wStr = new WCHAR[255];
       char2wchar_t(string, wStr);
       PlayAudio(wStr);
-      delete []wStr;
-      alSourcef (mSourceID, AL_GAIN, pSoundVolumeLevels[uMusicVolimeMultiplier]);
+      delete [] wStr;
+      alSourcef(mSourceID, AL_GAIN, pSoundVolumeLevels[uMusicVolimeMultiplier]);
     }
     else if ( hAILRedbook )
     {
       AIL_redbook_stop(hAILRedbook);
-      AIL_redbook_set_volume(hAILRedbook, (signed)pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f);
+      AIL_redbook_set_volume(hAILRedbook, 64.0f * pSoundVolumeLevels[uMusicVolimeMultiplier]);
       AIL_redbook_track_info(hAILRedbook, eTrack, &uCurrentMusicTrackStartMS, &uCurrentMusicTrackEndMS);
       AIL_redbook_play(hAILRedbook, uCurrentMusicTrackStartMS + 1, uCurrentMusicTrackEndMS);
       uCurrentMusicTrackLength = ((uCurrentMusicTrackEndMS - uCurrentMusicTrackStartMS) * 128) / 1000;
--- a/Media/Audio/AudioPlayer.h	Mon Oct 05 00:19:13 2015 +0200
+++ b/Media/Audio/AudioPlayer.h	Sat Mar 05 01:51:54 2016 +0200
@@ -175,7 +175,8 @@
 
 enum MusicID: unsigned __int32
 {
-  MUSIC_Credits = 15
+    MUSIC_MainMenu = 14,
+    MUSIC_Credits = 15
 };
 
 /*   20 */
--- a/Media/MediaPlayer.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/Media/MediaPlayer.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -6,6 +6,7 @@
 #include <deque>
 
 #include "Engine/Engine.h"
+#include "Engine/AssetsManager.h"
 
 #include "IO/Mouse.h"
 #include "GUI/GUIWindow.h"
@@ -1020,6 +1021,14 @@
 {
   window = target_window;
 
+  hVidFile = INVALID_HANDLE_VALUE;
+
+  uNumMightVideoHeaders = 0;
+  pMightVideoHeaders = nullptr;
+
+  uNumMagicVideoHeaders = 0;
+  pMagicVideoHeaders = nullptr;
+
   if (bNoVideo)
     return;
 
@@ -1318,7 +1327,7 @@
       this->uMovieType = 2;
     }
   }
-  if (!hVidFile)
+  if (hVidFile == INVALID_HANDLE_VALUE)
   {
     pMediaPlayer->Unload();
     MessageBoxA(0, "MediaPlayer error", "MediaPlayer Error", 0);
@@ -1340,7 +1349,7 @@
 //----- (004BF794) --------------------------------------------------------
 void MPlayer::ShowMM7IntroVideo_and_LoadingScreen()
 {
-  RGBTexture tex; // [sp+Ch] [bp-30h]@1
+  //RGBTexture tex; // [sp+Ch] [bp-30h]@1
   unsigned int uTrackStartMS; // [sp+34h] [bp-8h]@8
   unsigned int uTrackEndMS; // [sp+38h] [bp-4h]@8
 
@@ -1354,11 +1363,10 @@
       PlayFullscreenMovie(MOVIE_Intro, true);
   }
 
-  tex.Load("mm6title.pcx", 2);
+  Image *tex = assets->GetImage_PCXFromIconsLOD(L"mm6title.pcx");
+
   pRenderer->BeginScene();
-  pRenderer->DrawTextureRGB(0, 0, &tex);
-  free(tex.pPixels);
-  tex.pPixels = 0;
+  pRenderer->DrawTextureNew(0, 0, tex);
 
   //LoadFonts_and_DrawCopyrightWindow();
   DrawMM7CopyrightWindow();
@@ -1366,25 +1374,16 @@
   pRenderer->EndScene();
   pRenderer->Present();
 
+  tex->Release();
+  tex = nullptr;
+
   #ifndef _DEBUG
     Sleep(1500);   // let the copyright window stay for a while
   #endif
 
-  if (!bNoSound )
-  {
-	if ( use_music_folder )
-	{
-      PlayAudio(L"Music\\14.mp3");
-      alSourcef (mSourceID, AL_GAIN, pSoundVolumeLevels[uMusicVolimeMultiplier]);
-	}
-	else if ( pAudioPlayer->hAILRedbook )
-    {
-      pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0));
-      AIL_redbook_stop(pAudioPlayer->hAILRedbook);
-      AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &uTrackStartMS, &uTrackEndMS);
-      AIL_redbook_play(pAudioPlayer->hAILRedbook, uTrackStartMS + 1, uTrackEndMS);
-    }
-  }
+    if (!bNoSound)
+        pAudioPlayer->PlayMusicTrack(MUSIC_MainMenu);
+
   bGameoverLoop = false;
 }
 
@@ -1403,8 +1402,11 @@
   }
   pEventTimer->Resume();
 
-  pMovie_Track->Release();
-  delete pMovie_Track;
+  if (pMovie_Track)
+  {
+      pMovie_Track->Release();
+      delete pMovie_Track;
+  }
   pMovie_Track = nullptr;
 }
 
@@ -1524,7 +1526,7 @@
 
     bStopBeforeSchedule = false;
 //    pResetflag = 0;
-    pVideoFrame.Release();
+//    pVideoFrame.Release();
 }
 
 void PlayAudio(const wchar_t * pFilename)
--- a/Media/MediaPlayer.h	Mon Oct 05 00:19:13 2015 +0200
+++ b/Media/MediaPlayer.h	Sat Mar 05 01:51:54 2016 +0200
@@ -90,7 +90,7 @@
       virtual ~MPlayer();
 
 	  //for video/////////////////////////////////////////////////
-      RGBTexture pVideoFrame;
+      //RGBTexture pVideoFrame;
       int field_44;//final video
       unsigned int bFirstFrame;
       unsigned int bLoopPlaying;
--- a/OSAPI.cpp	Mon Oct 05 00:19:13 2015 +0200
+++ b/OSAPI.cpp	Sat Mar 05 01:51:54 2016 +0200
@@ -17,6 +17,12 @@
 //----- (00462C94) --------------------------------------------------------
 int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hprevinstance, wchar_t *lpCmdLine, int nShowCmd)
 {
+    #ifndef NDEBUG
+    {
+        //_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF);
+    }
+    #endif
+
   Log::Initialize();
   
   //if (HWND hMM7Window = FindWindowW(L"MM7", 0))