changeset 2524:c7264ab7132f

Main menu rendered using d3d11
author a.parshin
date Fri, 10 Oct 2014 17:42:05 +0300
parents c532d5242055
children 4cc81f981afb
files Build/Visual Studio 2012/World of Might and Magic.vcxproj Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters Engine/ErrorHandling.h Engine/Game.cpp Engine/Graphics/IRender.h Engine/Graphics/Overlays.cpp Engine/Graphics/Render.cpp Engine/Graphics/Render.h Engine/Graphics/RenderD3D11.cpp Engine/Graphics/RenderD3D11.h Engine/Graphics/Shaders/UI.hlsl Engine/Graphics/Shaders/UI.shader Engine/Graphics/Sprites.h Engine/Graphics/Texture.cpp Engine/Graphics/Texture.h Engine/LOD.cpp Engine/MMT.cpp Engine/Objects/Actor.cpp Engine/Objects/Chest.cpp GUI/GUIProgressBar.cpp GUI/GUIWindow.cpp GUI/UI/Books/UIMapBook.cpp GUI/UI/Books/UINotesBooks.cpp GUI/UI/Books/UISpellBook.cpp GUI/UI/UICharacter.cpp GUI/UI/UIGuilds.cpp GUI/UI/UIMainMenu.cpp GUI/UI/UIPartyCreation.cpp GUI/UI/UIPopup.cpp GUI/UI/UIShops.cpp GUI/UI/UITransition.cpp GUI/UI/UiGame.cpp IO/Mouse.cpp Media/MediaPlayer.cpp stru6.cpp
diffstat 35 files changed, 815 insertions(+), 375 deletions(-) [+]
line wrap: on
line diff
--- a/Build/Visual Studio 2012/World of Might and Magic.vcxproj	Thu Oct 09 23:33:36 2014 +0300
+++ b/Build/Visual Studio 2012/World of Might and Magic.vcxproj	Fri Oct 10 17:42:05 2014 +0300
@@ -502,6 +502,7 @@
     <ClInclude Include="..\..\stru6.h" />
   </ItemGroup>
   <ItemGroup>
+    <None Include="..\..\Engine\Graphics\Shaders\UI.hlsl" />
     <None Include="..\..\Engine\Objects\Player.swig" />
     <None Include="..\..\GUI\NewUI\Core\UIControlModule.swig" />
     <None Include="..\..\lib\legacy_dx\d3dvec.inl" />
--- a/Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters	Thu Oct 09 23:33:36 2014 +0300
+++ b/Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters	Fri Oct 10 17:42:05 2014 +0300
@@ -106,6 +106,9 @@
     <Filter Include="lib\legacy_dx\lib">
       <UniqueIdentifier>{20adc48e-74d5-48a4-a357-a8b133eef51f}</UniqueIdentifier>
     </Filter>
+    <Filter Include="Engine\Graphics\Shaders">
+      <UniqueIdentifier>{740b8731-e3ff-44cb-b6c8-85a64c7cbfc0}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\lib\zlib\adler32.c">
@@ -1356,6 +1359,9 @@
     <None Include="..\..\GUI\NewUI\Core\UIControlModule.swig">
       <Filter>GUI\NewUI\Core</Filter>
     </None>
+    <None Include="..\..\Engine\Graphics\Shaders\UI.hlsl">
+      <Filter>Engine\Graphics\Shaders</Filter>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <Library Include="..\..\lib\OpenAL\lib\OpenAL\OpenAL32.lib">
--- a/Engine/ErrorHandling.h	Thu Oct 09 23:33:36 2014 +0300
+++ b/Engine/ErrorHandling.h	Fri Oct 10 17:42:05 2014 +0300
@@ -1,8 +1,8 @@
 #define _CRT_NON_CONFORMING_SWPRINTFS
 #pragma once
 
-#define Error(format, ...)             Error_impl_(__FILE__, __FUNCTION__, __LINE__, format, __VA_ARGS__)
-#define Assert(condition, ...) Assert_impl_(__FILE__, __FUNCTION__, __LINE__, condition, #condition,  __VA_ARGS__)
+#define Error(format, ...)      do {Error_impl_(__FILE__, __FUNCTION__, __LINE__, format, __VA_ARGS__); __debugbreak(); exit(0); } while (0)
+#define Assert(condition, ...)  Assert_impl_(__FILE__, __FUNCTION__, __LINE__, condition, #condition,  __VA_ARGS__)
 
 
 
@@ -27,11 +27,6 @@
     MsgBox(msg, L"Error");
   }
   va_end(va);
-
-  #ifndef NODEBUG
-    __debugbreak();
-  #endif
-  exit(0);
 }
 
 
--- a/Engine/Game.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/Engine/Game.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -4483,7 +4483,7 @@
 void  sub_42FBDD()
 {
   pAudioPlayer->PlaySound(SOUND_StartMainChoice02, 0, 0, -1, 0, 0, 0, 0);
-  pRenderer->DrawTextureTransparent(pBtn_YES->uX, pBtn_YES->uY, pBtn_YES->pTextures[0]);
+  pRenderer->DrawTextureIndexedAlpha(pBtn_YES->uX, pBtn_YES->uY, pBtn_YES->pTextures[0]);
   pRenderer->Present();
 }
 
@@ -4491,7 +4491,7 @@
 void  CloseWindowBackground()
 {
   pAudioPlayer->PlaySound(SOUND_StartMainChoice02, -2, 0, -1, 0, 0, 0, 0);
-  pRenderer->DrawTextureTransparent(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pBtn_ExitCancel->pTextures[0]);
+  pRenderer->DrawTextureIndexedAlpha(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pBtn_ExitCancel->pTextures[0]);
   pRenderer->Present();
 }
 
@@ -5466,7 +5466,7 @@
 	dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000;
 	pGame->InitializeGammaController();
 	SecondaryInitialization();
-	pRenderer->SetRasterClipRect(0, 0, window->GetWidth() - 1, window->GetHeight() - 1);
+	//pRenderer->SetRasterClipRect(0, 0, window->GetWidth() - 1, window->GetHeight() - 1);
 	FinalInitialization();
 
 	//Ritor1: include
@@ -5837,7 +5837,7 @@
 		}
 
 		pRenderer->BeginScene();
-		pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX);
+		pRenderer->DrawTextureNew(0, 0, &pTexture_PCX);
 
 		GUI_MainMenuMessageProc();
 		GUI_UpdateWindows();
--- a/Engine/Graphics/IRender.h	Thu Oct 09 23:33:36 2014 +0300
+++ b/Engine/Graphics/IRender.h	Fri Oct 10 17:42:05 2014 +0300
@@ -64,8 +64,8 @@
     virtual void EndScene() = 0;
     virtual void ScreenFade(unsigned int color, float t) = 0;
 
-    virtual void SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) = 0;
-    virtual void ResetTextureClipRect() = 0;
+    virtual void SetUIClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) = 0;
+    virtual void ResetUIClipRect() = 0;
     virtual void CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture) = 0;
 
     virtual void DrawTextureNew(float u, float v, struct Texture *) = 0;
@@ -75,7 +75,7 @@
 
     virtual void ZBuffer_Fill_2(signed int a2, signed int a3, struct Texture *pTexture, int a5) = 0;
     virtual void DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, struct Texture *pTexture, int zVal) = 0;
-    virtual void DrawTextureTransparent(unsigned int uX, unsigned int uY, struct Texture *pTexture) = 0;
+    virtual void DrawTextureIndexedAlpha(unsigned int uX, unsigned int uY, struct Texture *pTexture) = 0;
     virtual void DrawAura(unsigned int a2, unsigned int a3, struct Texture *a4, struct Texture *a5, int a6, int a7, int a8) = 0;
     virtual void _4A65CC(unsigned int x, unsigned int y, struct Texture *a4, struct Texture *a5, int a6, int a7, int a8) = 0;
 
--- a/Engine/Graphics/Overlays.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/Engine/Graphics/Overlays.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -106,7 +106,7 @@
   //if ( pRenderer->pRenderD3D )
     pRenderer->DrawTextureIndexed(394, 288, &pIcons_LOD->pTextures[frame->uTextureID]);
   /*else
-    pRenderer->DrawTextureTransparent(0x18Au, 0x120u, v7);*/
+    pRenderer->DrawTextureIndexedAlpha(0x18Au, 0x120u, v7);*/
   if ( dword_50C994 < dword_50C998_turnbased_icon_1A )
   {
     dword_50C994 += pEventTimer->uTimeElapsed;
--- a/Engine/Graphics/Render.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/Engine/Graphics/Render.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -6003,8 +6003,9 @@
   stru350 Dst; // [sp+Ch] [bp-F8h]@12
 
   HWLTexture* pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps);
-  if ( pHWLTexture )
-  {
+  if (!pHWLTexture)
+    return false;
+
     bMipMaps = !strncmp(pName, "HDWTR", 5);
     if ( !pRenderD3D->CreateTexture(pHWLTexture->uWidth, pHWLTexture->uHeight, pOutSurface, pOutTexture, true,
             bMipMaps, uMinDeviceTextureDim) )
@@ -6083,8 +6084,7 @@
     delete [] pHWLTexture->pPixels;
     delete pHWLTexture;
     return true;
-  }
-  return false;
+
 }
 
 //----- (004A5048) --------------------------------------------------------
@@ -6368,7 +6368,7 @@
 }
 
 //----- (004A5B81) --------------------------------------------------------
-void Render::SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW)
+void Render::SetUIClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW)
 {
   this->bClip = 1;
   this->uClipX = uX;
@@ -6378,7 +6378,7 @@
 }
 
 //----- (004A5BB6) --------------------------------------------------------
-void Render::ResetTextureClipRect()
+void Render::ResetUIClipRect()
 {
   this->bClip = 1;
   this->uClipX = 0;
@@ -7475,7 +7475,7 @@
 }
 
 //----- (004A6274) --------------------------------------------------------
-void Render::DrawTextureTransparent(unsigned int uX, unsigned int uY, Texture *pTexture)
+void Render::DrawTextureIndexedAlpha(unsigned int uX, unsigned int uY, Texture *pTexture)
 {
   int uHeight; // ebx@4
   unsigned int v11; // edx@9
--- a/Engine/Graphics/Render.h	Thu Oct 09 23:33:36 2014 +0300
+++ b/Engine/Graphics/Render.h	Fri Oct 10 17:42:05 2014 +0300
@@ -248,8 +248,8 @@
   virtual void EndScene();
   virtual void ScreenFade(unsigned int color, float t);
 
-  virtual void SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW);
-  virtual void ResetTextureClipRect();
+  virtual void SetUIClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW);
+  virtual void ResetUIClipRect();
   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 *);
@@ -259,7 +259,7 @@
 
   virtual void ZBuffer_Fill_2(signed int a2, signed int a3, struct Texture *pTexture, int a5);
   virtual void DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, struct Texture *pTexture, int zVal);
-  virtual void DrawTextureTransparent(unsigned int uX, unsigned int uY, struct Texture *pTexture);
+  virtual void DrawTextureIndexedAlpha(unsigned int uX, unsigned int uY, struct Texture *pTexture);
   virtual void DrawAura(unsigned int a2, unsigned int a3, struct Texture *a4, struct Texture *a5, int a6, int a7, int a8);
   virtual void _4A65CC(unsigned int x, unsigned int y, struct Texture *a4, struct Texture *a5, int a6, int a7, int a8);
 
--- a/Engine/Graphics/RenderD3D11.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/Engine/Graphics/RenderD3D11.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -6,6 +6,7 @@
 #include "../mm7_data.h"
 #include "Texture.h"
 #include "../Log.h"
+#include "Sprites.h"
 
 #define ErrorD3D(x)\
 {\
@@ -28,7 +29,6 @@
 
 void RenderD3D11::ClearBlack() {__debugbreak();}
 void RenderD3D11::SaveWinnersCertificate(const char *a1) {__debugbreak();}
-void RenderD3D11::Present() {__debugbreak();}
 void RenderD3D11::_49FD3A_fullscreen() {__debugbreak();}
 bool RenderD3D11::InitializeFullscreen() {__debugbreak(); return 0;}
 void RenderD3D11::CreateZBuffer() {__debugbreak();}
@@ -59,16 +59,10 @@
 void RenderD3D11::TransformBillboardsAndSetPalettesODM() {__debugbreak();}
 void RenderD3D11::DrawBillboardList_BLV() {__debugbreak();}
 void RenderD3D11::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) {__debugbreak();}
-bool RenderD3D11::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture) {__debugbreak(); return 0;}
-bool RenderD3D11::MoveSpriteToDevice(Sprite *pSprite) {__debugbreak(); return 0;}
 void RenderD3D11::ScreenFade(unsigned int color, float t) {__debugbreak();}
-void RenderD3D11::SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) {__debugbreak();}
-void RenderD3D11::ResetTextureClipRect() {__debugbreak();}
 void RenderD3D11::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture) {__debugbreak();}
-void RenderD3D11::DrawTextureIndexed(unsigned int uX, unsigned int uY, struct Texture *a4) {__debugbreak();}
 void RenderD3D11::ZBuffer_Fill_2(signed int a2, signed int a3, struct Texture *pTexture, int a5) {__debugbreak();}
 void RenderD3D11::DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, struct Texture *pTexture, int zVal) {__debugbreak();}
-void RenderD3D11::DrawTextureTransparent(unsigned int uX, unsigned int uY, struct Texture *pTexture) {__debugbreak();}
 void RenderD3D11::DrawAura(unsigned int a2, unsigned int a3, struct Texture *a4, struct Texture *a5, int a6, int a7, int a8) {__debugbreak();}
 void RenderD3D11::_4A65CC(unsigned int x, unsigned int y, struct Texture *a4, struct Texture *a5, int a6, int a7, int a8) {__debugbreak();}
 void RenderD3D11::DrawTransparentRedShade(unsigned int a2, unsigned int a3, struct Texture *a4) {__debugbreak();}
@@ -77,7 +71,6 @@
 void RenderD3D11::DrawMasked(signed int a2, signed int a3, struct Texture *pTexture, unsigned __int16 mask) {__debugbreak();}
 void RenderD3D11::GetLeather(unsigned int a2, unsigned int a3, struct Texture *a4, __int16 height) {__debugbreak();}
 void RenderD3D11::DrawTextPalette(int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8) {__debugbreak();}
-void RenderD3D11::DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned __int16 *pFontPalette, unsigned __int16 uFaceColor, unsigned __int16 uShadowColor) {__debugbreak();}
 void RenderD3D11::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16) {__debugbreak();}
 void RenderD3D11::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, struct Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) {__debugbreak();}
 void RenderD3D11::DrawTranslucent(unsigned int a2, unsigned int a3, struct Texture *a4) {__debugbreak();}
@@ -90,7 +83,7 @@
 void RenderD3D11::DrawSpriteObjects_ODM() {__debugbreak();}
 void RenderD3D11::RenderTerrainD3D() {__debugbreak();}
 void RenderD3D11::ChangeBetweenWinFullscreenModes() {__debugbreak();}
-bool RenderD3D11::AreRenderSurfacesOk() {__debugbreak(); return 0;}
+bool RenderD3D11::AreRenderSurfacesOk() {return true;}
 void RenderD3D11::SaveScreenshot(const char *pFilename, unsigned int width, unsigned int height) {__debugbreak();}
 void RenderD3D11::PackScreenshot(unsigned int width, unsigned int height, void *out_data, unsigned int data_size, unsigned int *screenshot_size) {__debugbreak();}
 void RenderD3D11::SavePCXScreenshot() {__debugbreak();}
@@ -115,6 +108,22 @@
 
 
 
+void RenderD3D11::SetUIClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW)
+{
+  ui_clip_rect.left = uX;
+  ui_clip_rect.top = uY;
+  ui_clip_rect.right = uZ;
+  ui_clip_rect.bottom = uW;
+}
+
+void RenderD3D11::ResetUIClipRect()
+{
+  ui_clip_rect.left = 0;
+  ui_clip_rect.top = 0;
+  ui_clip_rect.right = window->GetWidth();
+  ui_clip_rect.bottom = window->GetHeight();
+}
+
 void RenderD3D11::PresentBlackScreen()
 {
   ClearTarget(0xFF000000);
@@ -137,6 +146,19 @@
 }
 
 
+
+void RenderD3D11::DrawTextureIndexed(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_solid);
+}
+
+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 uOutX, unsigned int uOutY, RGBTexture *a4)
 {
   __debugbreak();
@@ -149,60 +171,32 @@
 
 void RenderD3D11::DrawTextureNew(float u, float v, RGBTexture *tex)
 {
-  if (!tex->d3d11_srv)
-  {
-    auto desc = tex->d3d11_desc = new D3D11_TEXTURE2D_DESC;
-    desc->Width = tex->uWidth;
-    desc->Height = tex->uHeight;
-    desc->ArraySize = 1;
-    desc->MipLevels = 1;
-    desc->Format = DXGI_FORMAT_R8G8B8A8_UNORM;
-    desc->SampleDesc.Count = 1;
-    desc->SampleDesc.Quality = 0;
-    desc->Usage = D3D11_USAGE_DEFAULT;
-    desc->BindFlags = D3D11_BIND_SHADER_RESOURCE;
-    desc->CPUAccessFlags = 0;
-    desc->MiscFlags = 0;
-    
-    ID3D11Texture2D *vram_texture = nullptr;
-    ErrD3D(d3dd->CreateTexture2D(desc, nullptr, &vram_texture));
+  PrepareTexture(tex);
+  DrawTexture(u, v, tex->uWidth, tex->uHeight, tex->d3d11_srv, ui_blend_solid);
+}
 
-    D3D11_TEXTURE2D_DESC ram_desc;
-    memcpy(&ram_desc, desc, sizeof(ram_desc));
-    ram_desc.Usage = D3D11_USAGE_STAGING;
-    ram_desc.BindFlags = 0;
-    ram_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
-    
-    ID3D11Texture2D *ram_texture = nullptr;
-    ErrD3D(d3dd->CreateTexture2D(&ram_desc, nullptr, &ram_texture));
+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)
+{
+  auto srv = PrepareFontTexture(pFontPixels, uCharWidth, uCharHeight, pFontPalette, uFaceColor, uShadowColor);
+  {
+    DrawTexture((float)uX / window->GetWidth(), (float)uY / window->GetHeight(), uCharWidth, uCharHeight, srv, ui_blend_alpha);
+  }
+  srv->Release();
+}
 
-    D3D11_MAPPED_SUBRESOURCE map;
-    ErrD3D(d3dc->Map(ram_texture, 0, D3D11_MAP_WRITE, 0, &map));
-    for (unsigned int y = 0; y < desc->Height; ++y)
-      for (unsigned int x = 0; x < desc->Width; ++x)
-      {
-        auto src = tex->pPixels + y * tex->uWidth + x;
-        auto dst = (unsigned int *)((char *)map.pData + y * map.RowPitch) + x;
 
-        extern unsigned __int32 Color32_SwapRedBlue(unsigned __int16 color16);
-        *dst = 0xFF000000 | Color32_SwapRedBlue(*src);
-      }
-
-    d3dc->Unmap(ram_texture, 0);
-    d3dc->CopyResource(vram_texture, ram_texture);
-    ram_texture->Release();
-    
-    ErrD3D(d3dd->CreateShaderResourceView(vram_texture, nullptr, (ID3D11ShaderResourceView **)&tex->d3d11_srv));
-    vram_texture->Release();
-  }
-
+void RenderD3D11::DrawTexture(float u, float v, int texture_width, int texture_height, ID3D11ShaderResourceView *srv, ID3D11BlendState *blend)
+{
+  bool clipping = false;
+  if (ui_clip_rect.left != 0 || ui_clip_rect.top != 0
+      || ui_clip_rect.right != window->GetWidth()  || ui_clip_rect.bottom != window->GetHeight())
+      clipping = true;
 
   float blendFactor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
   d3dc->OMSetRenderTargets(1, &primary_srv, depth_srv);
-  d3dc->OMSetBlendState(ui_blend, blendFactor, 0xFFFFFFFF);
+  d3dc->OMSetBlendState(blend, blendFactor, 0xFFFFFFFF);
   d3dc->OMSetDepthStencilState(ui_depthstencil, 1);
 
-
   {
     struct cb_fast
     {
@@ -219,8 +213,8 @@
       {
         data.pos_x = u;
         data.pos_y = v;
-        data.size_x = (float)tex->uWidth / window->GetWidth();
-        data.size_y = (float)tex->uHeight / window->GetHeight();
+        data.size_x = (float)texture_width / window->GetWidth();
+        data.size_y = (float)texture_height / window->GetHeight();
       }
       memcpy(map.pData, &data, sizeof(data));
     }
@@ -232,7 +226,14 @@
 
   d3dc->PSSetShader(ui_ps, nullptr, 0);
   d3dc->PSSetConstantBuffers(0, 1, &ui_cb_fast);
-  d3dc->PSSetShaderResources(0, 1, &tex->d3d11_srv);
+  d3dc->PSSetShaderResources(0, 1, &srv);
+
+  if (clipping)
+  {
+    d3dc->RSSetState(ui_rasterizer);
+    d3dc->RSSetScissorRects(1, &ui_clip_rect);
+  }
+  //d3dc->RSSetViewports(1, &ui_viewport);
 
   uint uOffset = 0;
   uint uStride = 4 * sizeof(float);
@@ -242,6 +243,17 @@
 
   d3dc->Draw(6, 0);
 
+  if (clipping)
+  {
+    d3dc->RSSetState(default_rasterizer);
+    //d3dc->RSSetScissorRects(0, nullptr);
+  }
+}
+
+
+
+void RenderD3D11::Present()
+{
   pSwapChain->Present(0, 0);
 }
 
@@ -313,7 +325,10 @@
 
   auto d3d_lib = LoadLibraryW(L"d3d11.dll");
   if (!d3d_lib)
-    return Error("d3d11.dll is missing"), false;
+  {
+    Error("d3d11.dll is missing");
+    return false;
+  }
 
 
   DXGI_SWAP_CHAIN_DESC swapChainDesc;
@@ -416,6 +431,24 @@
   ErrorD3D(d3dd->CreateRasterizerState(&default_rasterizer_desc, &default_rasterizer));
   d3dc->RSSetState(default_rasterizer);
 
+
+
+  D3D11_RASTERIZER_DESC ui_rasterizer_desc;
+  memset(&ui_rasterizer_desc, 0, sizeof(ui_rasterizer_desc));
+  ui_rasterizer_desc.FillMode = D3D11_FILL_SOLID;
+  ui_rasterizer_desc.CullMode = D3D11_CULL_NONE;
+  //ui_rasterizer_desc.FrontCounterClockwise = false;
+  //ui_rasterizer_desc.DepthBias = 0;
+  //ui_rasterizer_desc.DepthBiasClamp = 0.0f;
+  //ui_rasterizer_desc.SlopeScaledDepthBias = 0.0f;
+  //ui_rasterizer_desc.DepthClipEnable = true;
+  ui_rasterizer_desc.ScissorEnable = true;
+  //ui_rasterizer_desc.MultisampleEnable = false;
+  //ui_rasterizer_desc.AntialiasedLineEnable = false;
+
+  ErrorD3D(d3dd->CreateRasterizerState(&ui_rasterizer_desc, &ui_rasterizer));
+
+
   default_depthstencil = nullptr;
   default_blend = nullptr;
 
@@ -423,21 +456,23 @@
 
   D3D11_VIEWPORT viewport;
   memset(&viewport, 0, sizeof(viewport));
-  viewport.TopLeftX = game_viewport_x;
-  viewport.TopLeftY = game_viewport_y;
+  viewport.TopLeftX = 0;
+  viewport.TopLeftY = 0;
   viewport.Width    = window->GetWidth();
   viewport.Height   = window->GetHeight();
   viewport.MinDepth = 0;
   viewport.MaxDepth = 1;
   d3dc->RSSetViewports(1, &viewport);
 
+  ResetUIClipRect();
+
 
   D3D11_INPUT_ELEMENT_DESC layout_desc[] =
   {
     { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0,  0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
     //{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT,       0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0 },  
   };
-  CompileShader(d3dd, L"data/shaders/UI.shader", layout_desc, 1/*2*/, &ui_vs, &ui_ps, &ui_layout);
+  CompileShader(d3dd, L"data/shaders/UI.hlsl", layout_desc, 1/*2*/, &ui_vs, &ui_ps, &ui_layout);
 
       {
         uint uVertexSize = 4 * sizeof(float);
@@ -508,18 +543,123 @@
   ErrorD3D(d3dd->CreateDepthStencilState(&ui_depthstencil_desc, &ui_depthstencil));
 
 
-  D3D11_BLEND_DESC ui_blend_desc;
-  memset(&ui_blend_desc, 0, sizeof(ui_blend_desc));
-  ui_blend_desc.RenderTarget[0].BlendEnable = false;
-  ui_blend_desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
-  ErrD3D(d3dd->CreateBlendState(&ui_blend_desc, &ui_blend));
+  D3D11_BLEND_DESC ui_blend_solid_desc;
+  memset(&ui_blend_solid_desc, 0, sizeof(ui_blend_solid_desc));
+  ui_blend_solid_desc.RenderTarget[0].BlendEnable = false;
+  ui_blend_solid_desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
+  ErrorD3D(d3dd->CreateBlendState(&ui_blend_solid_desc, &ui_blend_solid));
 
-  return true;
+  D3D11_BLEND_DESC ui_blend_alpha_desc;
+  memset(&ui_blend_alpha_desc, 0, sizeof(ui_blend_alpha_desc));
+  ui_blend_alpha_desc.RenderTarget[0].BlendEnable = true;
+  ui_blend_alpha_desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
+  ui_blend_alpha_desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
+  ui_blend_alpha_desc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
+  ui_blend_alpha_desc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
+  ui_blend_alpha_desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
+  ui_blend_alpha_desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
+  ui_blend_alpha_desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE;
+  ErrorD3D(d3dd->CreateBlendState(&ui_blend_alpha_desc, &ui_blend_alpha));
+
+
+  return pD3DBitmaps.Load(L"data\\d3dbitmap.hwl") && pD3DSprites.Load(L"data\\d3dsprite.hwl");
 }
 
 
 
 
+bool RenderD3D11::MoveSpriteToDevice(Sprite *pSprite)
+{
+  HWLTexture *sprite_texture; // eax@1
+  unsigned __int16 *v9; // edx@5
+  LPVOID v10; // eax@5
+  DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4
+
+  sprite_texture = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID);
+  if ( sprite_texture )
+  {
+    pSprite->uAreaX = sprite_texture->uAreaX;
+    pSprite->uAreaY = sprite_texture->uAreaY;
+    pSprite->uBufferWidth = sprite_texture->uBufferWidth;
+    pSprite->uBufferHeight = sprite_texture->uBufferHeight;
+    pSprite->uAreaWidth = sprite_texture->uAreaWidth;
+    pSprite->uAreaHeight = sprite_texture->uAreaHeigth;
+
+    {
+      D3D11_TEXTURE2D_DESC desc;
+      desc.Width = sprite_texture->uWidth;
+      desc.Height = sprite_texture->uHeight;
+      desc.ArraySize = 1;
+      desc.MipLevels = 1;
+      desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+      desc.SampleDesc.Count = 1;
+      desc.SampleDesc.Quality = 0;
+      desc.Usage = D3D11_USAGE_DEFAULT;
+      desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
+      desc.CPUAccessFlags = 0;
+      desc.MiscFlags = 0;
+    
+      ID3D11Texture2D *vram_texture = nullptr;
+      ErrorD3D(d3dd->CreateTexture2D(&desc, nullptr, &vram_texture));
+
+      D3D11_TEXTURE2D_DESC ram_desc;
+      memcpy(&ram_desc, &desc, sizeof(ram_desc));
+      ram_desc.Usage = D3D11_USAGE_STAGING;
+      ram_desc.BindFlags = 0;
+      ram_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
+
+      ID3D11Texture2D *ram_texture = nullptr;
+      ErrorD3D(d3dd->CreateTexture2D(&ram_desc, nullptr, &ram_texture));
+
+      D3D11_MAPPED_SUBRESOURCE map;
+      ErrorD3D(d3dc->Map(ram_texture, 0, D3D11_MAP_WRITE, 0, &map));
+      for (unsigned int y = 0; y < desc.Height; ++y)
+        for (unsigned int x = 0; x < desc.Width; ++x)
+        {
+          auto src = sprite_texture->pPixels + y * desc.Width + x;
+          auto dst = (unsigned int *)((char *)map.pData + y * map.RowPitch) + x;
+
+          extern unsigned __int32 Color32_SwapRedBlue(unsigned __int16 color16);
+          *dst = 0xFF000000 | Color32_SwapRedBlue(*src);
+        }
+
+
+      d3dc->Unmap(ram_texture, 0);
+      d3dc->CopyResource(vram_texture, ram_texture);
+      ram_texture->Release();
+    
+      ID3D11ShaderResourceView *srv = nullptr;
+      ErrorD3D(d3dd->CreateShaderResourceView(vram_texture, nullptr, &srv));
+      vram_texture->Release();
+
+      pSprite->d3d11_srv = srv;
+    }
+    /*if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim))
+      Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0);
+    memset(&Dst, 0, sizeof(DDSURFACEDESC2));
+    Dst.dwSize = 124;
+    if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) )
+    {
+      v9 = sprite_texture->pPixels;
+      v10 = Dst.lpSurface;
+      for (uint i=0; i<sprite_texture->uHeight; ++i)
+      {
+        for (uint j=0; j<sprite_texture->uWidth/2; ++j)
+        {
+          *(int *)v10 = *(int *)v9;
+          v9 += 2;
+          v10 = (char *)v10 + 4;
+        }
+        v10 = (char *)v10 + Dst.lPitch-sprite_texture->uWidth*2;
+      }
+      ErrD3D(pSprite->pTextureSurface->Unlock(NULL));
+    }*/
+    delete [] sprite_texture->pPixels;
+    delete sprite_texture;
+	return true;
+  }
+  return false;
+}
 
 
 ID3DBlob *DoD3DCompiling(const wchar_t *shader_name, const char *pShaderSource, uint uShaderSourceLen, const char *pEntry, const char *pVersionString, uint uCompileOptions);
@@ -551,9 +691,9 @@
 
   DoCompile(pShaderSourceFile, pShaderSource, uShaderSourceLen, &vs, &vs_size, &ps, &ps_size);
 
-  ErrD3D(d3dd->CreateVertexShader(vs, vs_size, nullptr, vertex_out));
-  ErrD3D(d3dd->CreatePixelShader(ps, ps_size, nullptr, pixel_out));
-  ErrD3D(d3dd->CreateInputLayout(input_desc, input_desc_size, vs, vs_size, layout_out));
+  ErrorD3D(d3dd->CreateVertexShader(vs, vs_size, nullptr, vertex_out));
+  ErrorD3D(d3dd->CreatePixelShader(ps, ps_size, nullptr, pixel_out));
+  ErrorD3D(d3dd->CreateInputLayout(input_desc, input_desc_size, vs, vs_size, layout_out));
 
   delete [] vs;
   delete [] ps;
@@ -667,4 +807,255 @@
   }
 
   return pShader;
+}
+
+
+void RenderD3D11::PrepareTexture(RGBTexture *p)
+{
+  if (!p->d3d11_srv)
+  {
+    auto desc = p->d3d11_desc = new D3D11_TEXTURE2D_DESC;
+    desc->Width = p->uWidth;
+    desc->Height = p->uHeight;
+    desc->ArraySize = 1;
+    desc->MipLevels = 1;
+    desc->Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+    desc->SampleDesc.Count = 1;
+    desc->SampleDesc.Quality = 0;
+    desc->Usage = D3D11_USAGE_DEFAULT;
+    desc->BindFlags = D3D11_BIND_SHADER_RESOURCE;
+    desc->CPUAccessFlags = 0;
+    desc->MiscFlags = 0;
+    
+    ID3D11Texture2D *vram_texture = nullptr;
+    ErrorD3D(d3dd->CreateTexture2D(desc, nullptr, &vram_texture));
+
+    D3D11_TEXTURE2D_DESC ram_desc;
+    memcpy(&ram_desc, desc, sizeof(ram_desc));
+    ram_desc.Usage = D3D11_USAGE_STAGING;
+    ram_desc.BindFlags = 0;
+    ram_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
+    
+    ID3D11Texture2D *ram_texture = nullptr;
+    ErrorD3D(d3dd->CreateTexture2D(&ram_desc, nullptr, &ram_texture));
+
+    D3D11_MAPPED_SUBRESOURCE map;
+    ErrorD3D(d3dc->Map(ram_texture, 0, D3D11_MAP_WRITE, 0, &map));
+    for (unsigned int y = 0; y < desc->Height; ++y)
+      for (unsigned int x = 0; x < desc->Width; ++x)
+      {
+        auto src = p->pPixels + y * p->uWidth + x;
+        auto dst = (unsigned int *)((char *)map.pData + y * map.RowPitch) + x;
+
+        extern unsigned __int32 Color32_SwapRedBlue(unsigned __int16 color16);
+        *dst = 0xFF000000 | Color32_SwapRedBlue(*src);
+      }
+
+    d3dc->Unmap(ram_texture, 0);
+    d3dc->CopyResource(vram_texture, ram_texture);
+    ram_texture->Release();
+    
+    ErrorD3D(d3dd->CreateShaderResourceView(vram_texture, nullptr, (ID3D11ShaderResourceView **)&p->d3d11_srv));
+    vram_texture->Release();
+  }
+}
+
+
+
+void RenderD3D11::PrepareTextureIndexed(Texture *p)
+{
+  if (!p->d3d11_srv)
+  {
+    auto desc = p->d3d11_desc = new D3D11_TEXTURE2D_DESC;
+    desc->Width = p->uTextureWidth;
+    desc->Height = p->uTextureHeight;
+    desc->ArraySize = 1;
+    desc->MipLevels = 1;
+    desc->Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+    desc->SampleDesc.Count = 1;
+    desc->SampleDesc.Quality = 0;
+    desc->Usage = D3D11_USAGE_DEFAULT;
+    desc->BindFlags = D3D11_BIND_SHADER_RESOURCE;
+    desc->CPUAccessFlags = 0;
+    desc->MiscFlags = 0;
+    
+    ID3D11Texture2D *vram_texture = nullptr;
+    ErrorD3D(d3dd->CreateTexture2D(desc, nullptr, &vram_texture));
+
+    D3D11_TEXTURE2D_DESC ram_desc;
+    memcpy(&ram_desc, desc, sizeof(ram_desc));
+    ram_desc.Usage = D3D11_USAGE_STAGING;
+    ram_desc.BindFlags = 0;
+    ram_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
+    
+    ID3D11Texture2D *ram_texture = nullptr;
+    ErrorD3D(d3dd->CreateTexture2D(&ram_desc, nullptr, &ram_texture));
+
+    D3D11_MAPPED_SUBRESOURCE map;
+    ErrorD3D(d3dc->Map(ram_texture, 0, D3D11_MAP_WRITE, 0, &map));
+    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 src = p->pPalette16[index];
+        auto dst = (unsigned int *)((char *)map.pData + y * map.RowPitch) + x;
+
+        if (index)
+        {
+          extern unsigned __int32 Color32_SwapRedBlue(unsigned __int16 color16);
+          *dst = 0xFF000000 | Color32_SwapRedBlue(src);
+        }
+        else
+          *dst = 0x00000000;
+      }
+
+    d3dc->Unmap(ram_texture, 0);
+    d3dc->CopyResource(vram_texture, ram_texture);
+    ram_texture->Release();
+    
+    ErrorD3D(d3dd->CreateShaderResourceView(vram_texture, nullptr, (ID3D11ShaderResourceView **)&p->d3d11_srv));
+    vram_texture->Release();
+  }
+}
+
+
+ID3D11ShaderResourceView *RenderD3D11::PrepareFontTexture(unsigned char *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned short *pFontPalette, unsigned short uFaceColor, unsigned short uShadowColor)
+{
+  D3D11_TEXTURE2D_DESC desc;
+  desc.Width = uCharWidth;
+  desc.Height = uCharHeight;
+  desc.ArraySize = 1;
+  desc.MipLevels = 1;
+  desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+  desc.SampleDesc.Count = 1;
+  desc.SampleDesc.Quality = 0;
+  desc.Usage = D3D11_USAGE_DEFAULT;
+  desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
+  desc.CPUAccessFlags = 0;
+  desc.MiscFlags = 0;
+    
+  ID3D11Texture2D *vram_texture = nullptr;
+  ErrorD3D(d3dd->CreateTexture2D(&desc, nullptr, &vram_texture));
+
+  D3D11_TEXTURE2D_DESC ram_desc;
+  memcpy(&ram_desc, &desc, sizeof(ram_desc));
+  ram_desc.Usage = D3D11_USAGE_STAGING;
+  ram_desc.BindFlags = 0;
+  ram_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
+    
+  ID3D11Texture2D *ram_texture = nullptr;
+  ErrorD3D(d3dd->CreateTexture2D(&ram_desc, nullptr, &ram_texture));
+
+  D3D11_MAPPED_SUBRESOURCE map;
+  ErrorD3D(d3dc->Map(ram_texture, 0, D3D11_MAP_WRITE, 0, &map));
+  for (unsigned int y = 0; y < desc.Height; ++y)
+    for (unsigned int x = 0; x < desc.Width; ++x)
+    {
+      auto index = pFontPixels[y * desc.Width + x];
+      auto src = pFontPalette[index];
+      auto dst = (unsigned int *)((char *)map.pData + y * map.RowPitch) + x;
+
+      if (index)
+      {
+        extern unsigned __int32 Color32_SwapRedBlue(unsigned __int16 color16);
+        *dst = 0xFF000000 | Color32_SwapRedBlue(index == 1 ? uShadowColor : uFaceColor);
+      }
+      else
+        *dst = 0x00000000;
+    }
+
+  d3dc->Unmap(ram_texture, 0);
+  d3dc->CopyResource(vram_texture, ram_texture);
+  ram_texture->Release();
+    
+  ID3D11ShaderResourceView *srv = nullptr;
+  ErrorD3D(d3dd->CreateShaderResourceView(vram_texture, nullptr, &srv));
+  vram_texture->Release();
+
+  return srv;
+}
+
+void d3d11_release(ID3D11ShaderResourceView *srv)
+{
+  srv->Release();
+}
+
+
+//----- (004A4DE1) --------------------------------------------------------
+bool RenderD3D11::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture)
+{
+  unsigned __int16 *v13; // ecx@19
+  unsigned __int16 *v14; // eax@19
+  DWORD v15; // edx@20
+
+  HWLTexture* pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps);
+  if (!pHWLTexture)
+    return false;
+
+  int num_min_levels = 1;
+  {
+    int dim = min(pHWLTexture->uWidth, pHWLTexture->uHeight);
+    while (dim > 1)
+    {
+      dim /= 2;
+      num_min_levels++;
+    }
+  }
+
+  
+    {
+      D3D11_TEXTURE2D_DESC desc;
+      desc.Width = pHWLTexture->uWidth;
+      desc.Height = pHWLTexture->uHeight;
+      desc.ArraySize = 1;
+      desc.MipLevels = num_min_levels;
+      desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+      desc.SampleDesc.Count = 1;
+      desc.SampleDesc.Quality = 0;
+      desc.Usage = D3D11_USAGE_DEFAULT;
+      desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET/* for mipmap generation */;
+      desc.CPUAccessFlags = 0;
+      desc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS;
+    
+      ID3D11Texture2D *vram_texture = nullptr;
+      ErrorD3D(d3dd->CreateTexture2D(&desc, nullptr, &vram_texture));
+
+      D3D11_TEXTURE2D_DESC ram_desc;
+      memcpy(&ram_desc, &desc, sizeof(ram_desc));
+      ram_desc.Usage = D3D11_USAGE_STAGING;
+      ram_desc.BindFlags = 0;
+      ram_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
+      ram_desc.MiscFlags = 0;
+
+      ID3D11Texture2D *ram_texture = nullptr;
+      ErrorD3D(d3dd->CreateTexture2D(&ram_desc, nullptr, &ram_texture));
+
+      D3D11_MAPPED_SUBRESOURCE map;
+      ErrorD3D(d3dc->Map(ram_texture, 0, D3D11_MAP_WRITE, 0, &map));
+      for (unsigned int y = 0; y < desc.Height; ++y)
+        for (unsigned int x = 0; x < desc.Width; ++x)
+        {
+          auto src = pHWLTexture->pPixels + y * desc.Width + x;
+          auto dst = (unsigned int *)((char *)map.pData + y * map.RowPitch) + x;
+
+          extern unsigned __int32 Color32_SwapRedBlue(unsigned __int16 color16);
+          *dst = 0xFF000000 | Color32_SwapRedBlue(*src);
+        }
+
+      d3dc->Unmap(ram_texture, 0);
+      d3dc->CopyResource(vram_texture, ram_texture);
+      ram_texture->Release();
+    
+      ID3D11ShaderResourceView *srv = nullptr;
+      ErrorD3D(d3dd->CreateShaderResourceView(vram_texture, nullptr, &srv));
+      vram_texture->Release();
+      
+      d3dc->GenerateMips(srv);
+      *pOutTexture = (IDirect3DTexture2 *)srv;
+      *pOutSurface = nullptr;
+    }
+
+    delete [] pHWLTexture->pPixels;
+    delete pHWLTexture;
+    return true;
 }
\ No newline at end of file
--- a/Engine/Graphics/RenderD3D11.h	Thu Oct 09 23:33:36 2014 +0300
+++ b/Engine/Graphics/RenderD3D11.h	Fri Oct 10 17:42:05 2014 +0300
@@ -74,8 +74,8 @@
   virtual void EndScene();
   virtual void ScreenFade(unsigned int color, float t);
 
-  virtual void SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW);
-  virtual void ResetTextureClipRect();
+  virtual void SetUIClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW);
+  virtual void ResetUIClipRect();
   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 *);
@@ -85,7 +85,7 @@
 
   virtual void ZBuffer_Fill_2(signed int a2, signed int a3, struct Texture *pTexture, int a5);
   virtual void DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, struct Texture *pTexture, int zVal);
-  virtual void DrawTextureTransparent(unsigned int uX, unsigned int uY, struct Texture *pTexture);
+  virtual void DrawTextureIndexedAlpha(unsigned int uX, unsigned int uY, struct Texture *pTexture);
   virtual void DrawAura(unsigned int a2, unsigned int a3, struct Texture *a4, struct Texture *a5, int a6, int a7, int a8);
   virtual void _4A65CC(unsigned int x, unsigned int y, struct Texture *a4, struct Texture *a5, int a6, int a7, int a8);
 
@@ -165,6 +165,11 @@
 
 
   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);
+
     OSWindow *window;
 
     IDXGISwapChain          *pSwapChain;
@@ -182,5 +187,12 @@
     ID3D11InputLayout       *ui_layout;
     ID3D11Buffer            *ui_vb;
     ID3D11DepthStencilState *ui_depthstencil;
-    ID3D11BlendState        *ui_blend;
+    ID3D11BlendState        *ui_blend_solid;
+    ID3D11BlendState        *ui_blend_alpha;
+    ID3D11RasterizerState   *ui_rasterizer;
+    D3D11_RECT               ui_clip_rect;
+
+    
+    RenderHWLContainer pD3DBitmaps;
+    RenderHWLContainer pD3DSprites;
 };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Engine/Graphics/Shaders/UI.hlsl	Fri Oct 10 17:42:05 2014 +0300
@@ -0,0 +1,45 @@
+cbuffer fast: register(b0)
+{
+    float2 position : packoffset(c0.x);
+    float2 size     : packoffset(c0.z);
+};
+
+cbuffer slow: register(b1)
+{
+};
+
+
+struct VInput
+{
+    float4 pos: POSITION0;
+};
+
+struct VOutput
+{
+    float4 pos: SV_Position0;
+    float2 uv:  TEXCOORD0;
+};
+
+
+VOutput vs(VInput vin)
+{
+    VOutput vout;
+
+    float2 normalized_pos = vin.pos.xy * position.xy + vin.pos.zw * size.xy;
+    vout.pos.xy = float2(2, -2) * normalized_pos + float2(-1, 1);
+    vout.pos.zw = float2(0, 1);
+    vout.uv = vin.pos.zw;
+
+    return vout;
+}
+
+
+
+
+SamplerState      basic_sampler: register(s0);
+Texture2D<float4> image: register(t0);
+
+float4 main(VOutput pin): SV_Target0
+{
+    return image.Sample(basic_sampler, pin.uv);
+}
\ No newline at end of file
--- a/Engine/Graphics/Shaders/UI.shader	Thu Oct 09 23:33:36 2014 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-cbuffer fast: register(b0)
-{
-    float2 position : packoffset(c0.x);
-    float2 size     : packoffset(c0.z);
-};
-
-cbuffer slow: register(b1)
-{
-};
-
-
-struct VInput
-{
-    float4 pos: POSITION0;
-};
-
-struct VOutput
-{
-    float4 pos: SV_Position0;
-    float2 uv:  TEXCOORD0;
-};
-
-
-VOutput vs(VInput vin)
-{
-    VOutput vout;
-
-    float2 normalized_pos = vin.pos.xy * position.xy + vin.pos.zw * size.xy;
-    vout.pos.xy = float2(2, -2) * normalized_pos + float2(-1, 1);
-    vout.pos.zw = float2(0, 1);
-    vout.uv = vin.pos.zw;
-
-    return vout;
-}
-
-
-
-
-SamplerState      basic_sampler: register(s0);
-Texture2D<float4> image: register(t0);
-
-float4 main(VOutput pin): SV_Target0
-{
-    return image.Sample(basic_sampler, pin.uv);
-}
\ No newline at end of file
--- a/Engine/Graphics/Sprites.h	Thu Oct 09 23:33:36 2014 +0300
+++ b/Engine/Graphics/Sprites.h	Fri Oct 10 17:42:05 2014 +0300
@@ -5,7 +5,13 @@
 #pragma pack(push, 1)
 class Sprite  //28h
 {
-public:
+  public:
+    inline Sprite()
+    {
+      d3d11_srv = nullptr;
+    }
+    ~Sprite();
+
     void Release();
 
     const char *pName;  //0
@@ -18,6 +24,8 @@
     int uBufferHeight;  //1ch
     int uAreaWidth;  //20h
     int uAreaHeight; //24h
+
+    struct ID3D11ShaderResourceView *d3d11_srv;
 };
 #pragma pack(pop)
 
--- a/Engine/Graphics/Texture.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/Engine/Graphics/Texture.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -395,8 +395,21 @@
 
     pLevelOfDetail0_prolly_alpha_mask = nullptr;
     pLevelOfDetail1 = nullptr;
-    pLevelOfDetail2 = nullptr;
-    pLevelOfDetail3 = nullptr;
+    //pLevelOfDetail2 = nullptr;
+    //pLevelOfDetail3 = nullptr;
+
+    if (d3d11_srv)
+    {
+      if (d3d11_desc)
+      {
+        delete d3d11_desc;
+        d3d11_desc = nullptr;
+      }
+
+      extern void d3d11_release(struct ID3D11ShaderResourceView *);
+      d3d11_release(d3d11_srv);
+      d3d11_srv = nullptr;
+    }
 
     pPalette16 = nullptr;
     pPalette24 = nullptr;
@@ -494,11 +507,14 @@
   palette_id1 = 0;
   palette_id2 = 0;
   pLevelOfDetail0_prolly_alpha_mask = nullptr;
-  pLevelOfDetail3 = nullptr;
-  pLevelOfDetail2 = nullptr;
+  //pLevelOfDetail3 = nullptr;
+  //pLevelOfDetail2 = nullptr;
   pLevelOfDetail1 = nullptr;
   pPalette16 = nullptr;
   pPalette24 = nullptr;
+
+  d3d11_srv = nullptr;
+  d3d11_desc = nullptr;
 }
 
 //----- (0040F414) --------------------------------------------------------
@@ -1290,8 +1306,17 @@
   this->field_18 = 0;
 
   if (d3d11_srv)
-    __debugbreak(); // should properly release this stuff
-  d3d11_srv = nullptr;
+  {
+    if (d3d11_desc)
+    {
+      delete d3d11_desc;
+      d3d11_desc = nullptr;
+    }
+
+    extern void d3d11_release(struct ID3D11ShaderResourceView *);
+    d3d11_release(d3d11_srv);
+    d3d11_srv = nullptr;
+  }
 }
 
 //----- (0040E55E) --------------------------------------------------------
--- a/Engine/Graphics/Texture.h	Thu Oct 09 23:33:36 2014 +0300
+++ b/Engine/Graphics/Texture.h	Fri Oct 10 17:42:05 2014 +0300
@@ -56,8 +56,8 @@
   int pBits;
   unsigned __int8 *pLevelOfDetail0_prolly_alpha_mask;
   unsigned __int8 *pLevelOfDetail1;
-  unsigned __int8 *pLevelOfDetail2;
-  unsigned __int8 *pLevelOfDetail3;
+  /*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;
   unsigned __int16 *pPalette16;
   unsigned __int8 *pPalette24;
 };
--- a/Engine/LOD.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/Engine/LOD.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -1851,16 +1851,16 @@
     v15 = (int)&pDst->pLevelOfDetail0_prolly_alpha_mask[pDst->uSizeOfMaxLevelOfDetail];
     pDst->pLevelOfDetail1 = (unsigned __int8 *)v15;
     v16 = (pDst->uSizeOfMaxLevelOfDetail >> 2) + v15;
-    pDst->pLevelOfDetail2 = (unsigned __int8 *)v16;
+    //pDst->pLevelOfDetail2 = (unsigned __int8 *)v16;
     v17 = v16 + (pDst->uSizeOfMaxLevelOfDetail >> 4);
   }
   else
   {
     v17 = 0;
-    pDst->pLevelOfDetail2 = 0;
-    pDst->pLevelOfDetail1 = 0;
+    //pDst->pLevelOfDetail2 = 0;
+    //pDst->pLevelOfDetail1 = 0;
   }
-  pDst->pLevelOfDetail3 = (unsigned __int8 *)v17;
+  //pDst->pLevelOfDetail3 = (unsigned __int8 *)v17;
   v21 = 1;
   while ( 1 << v21 != pDst->uTextureWidth )
   {
@@ -2230,14 +2230,14 @@
   if ( v8->pBits & 2 )
   {
     v8->pLevelOfDetail1 = &v8->pLevelOfDetail0_prolly_alpha_mask[v8->uSizeOfMaxLevelOfDetail];
-    v8->pLevelOfDetail2 = &v8->pLevelOfDetail1[v8->uSizeOfMaxLevelOfDetail >> 2];
-    v8->pLevelOfDetail3 = &v8->pLevelOfDetail2[v8->uSizeOfMaxLevelOfDetail >> 4];
+    //v8->pLevelOfDetail2 = &v8->pLevelOfDetail1[v8->uSizeOfMaxLevelOfDetail >> 2];
+    //v8->pLevelOfDetail3 = &v8->pLevelOfDetail2[v8->uSizeOfMaxLevelOfDetail >> 4];
   }
   else
   {
     v8->pLevelOfDetail1 = 0;
-    v8->pLevelOfDetail2 = 0;
-    v8->pLevelOfDetail3 = 0;
+    //v8->pLevelOfDetail2 = 0;
+    //v8->pLevelOfDetail3 = 0;
   }
   for ( v41 = 1; v41 < 15; ++v41 )
   {
--- a/Engine/MMT.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/Engine/MMT.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -60,14 +60,20 @@
     tex.LoadPCXFile("data/New_Icons/MMTTITLE.pcx", 0);
   else
     tex.Load("mm6title.pcx", 2);
-
+  
+  pRenderer->ResetUIClipRect();
   pRenderer->BeginScene();
-  pRenderer->DrawTextureNew(0, 0, &tex);
-
+  {
+    pRenderer->DrawTextureNew(0, 0, &tex);
+  }
+  pRenderer->EndScene();
+  pRenderer->Present();
+  
   tex.Release();
 
   MainMenuUI_LoadFontsAndSomeStuff();
-
+  
+  pRenderer->BeginScene();
   if (use_MMT)
     DrawMMTCopyrightWindow();
   else
@@ -76,9 +82,10 @@
   pRenderer->EndScene();
   pRenderer->Present();
 
-  #ifndef _DEBUG
+  #ifdef NDEBUG
     Sleep(1500);   // let the copyright window stay for a while
   #endif
+
   if (!use_MMT)
   {
     if (!bNoSound && pAudioPlayer->hAILRedbook )
@@ -106,15 +113,6 @@
   bGameoverLoop = 0;
 }
 
-void abort_(const char * s, ...)
-{
-  va_list args;
-  va_start(args, s);
-  vfprintf(stderr, s, args);
-  fprintf(stderr, "\n");
-  va_end(args);
-  abort();
-}
 
 Texture *LoadPNG(const char *name)
 {
@@ -134,21 +132,21 @@
   /* open file and test for it being a png */
   FILE *fp = fopen(name, "rb");
   if (!fp)
-    abort_("[read_png_file] File %s could not be opened for reading", name);
+    Error("[read_png_file] File %s could not be opened for reading", name);
   fread(header, 1, 8, fp);
   if (png_sig_cmp((png_bytep)header, 0, 8))
-    abort_("[read_png_file] File %s is not recognized as a PNG file", name);
+    Error("[read_png_file] File %s is not recognized as a PNG file", name);
   /* initialize stuff */
   png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
 
   if (!png_ptr)
-    abort_("[read_png_file] png_create_read_struct failed");
+    Error("[read_png_file] png_create_read_struct failed");
   info_ptr = png_create_info_struct(png_ptr);
   if (!info_ptr)
-    abort_("[read_png_file] png_create_info_struct failed");
+    Error("[read_png_file] png_create_info_struct failed");
 
   if (setjmp(png_jmpbuf(png_ptr)))
-    abort_("[read_png_file] Error during init_io");
+    Error("[read_png_file] Error during init_io");
 
   png_init_io(png_ptr, fp);
   png_set_sig_bytes(png_ptr, 8);
@@ -165,7 +163,7 @@
 
   /* read file */
   if (setjmp(png_jmpbuf(png_ptr)))
-    abort_("[read_png_file] Error during read_image");
+    Error("[read_png_file] Error during read_image");
   row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * height);
   for (y=0; y<height; y++)
     row_pointers[y] = (png_byte*) malloc(png_get_rowbytes(png_ptr,info_ptr));
--- a/Engine/Objects/Actor.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/Engine/Objects/Actor.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -105,12 +105,12 @@
 
   uX = window->uFrameX + (signed int)(window->uFrameWidth - bar_length) / 2;
 
-  pRenderer->SetTextureClipRect(uX, window->uFrameY + 32, uX + bar_length, window->uFrameY + 52);
+  pRenderer->SetUIClipRect(uX, window->uFrameY + 32, uX + bar_length, window->uFrameY + 52);
   pRenderer->DrawTextureIndexed(uX, window->uFrameY + 32, pIcons_LOD->GetTexture(uTextureID_mhp_bd));
-  pRenderer->SetTextureClipRect(uX, window->uFrameY + 32, uX + v10, window->uFrameY + 52);
+  pRenderer->SetUIClipRect(uX, window->uFrameY + 32, uX + v10, window->uFrameY + 52);
   pRenderer->DrawTextureIndexed(uX, window->uFrameY + 34, pIcons_LOD->GetTexture(v9));
 
-  pRenderer->ResetTextureClipRect();
+  pRenderer->ResetUIClipRect();
   pRenderer->DrawTextureIndexed(uX - 5, window->uFrameY + 32, pIcons_LOD->GetTexture(uTextureID_mhp_capl));
   pRenderer->DrawTextureIndexed(uX + bar_length, window->uFrameY + 32, pIcons_LOD->GetTexture(uTextureID_mhp_capr));
 }
--- a/Engine/Objects/Chest.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/Engine/Objects/Chest.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -272,7 +272,7 @@
             itemPixelPosX = chest_offs_x + 32 * (item_counter % chestWidthCells) + ((signed int)(v13 - itemPixelWidth)/2);
             itemPixelPosY = chest_offs_y + 32 * (item_counter / chestHeghtCells) +
                 ((signed int)(((itemPixelHeght - 14) & 0xFFFFFFE0) + 32- item_texture->uTextureHeight ) /2);
-            pRenderer->DrawTextureTransparent(  itemPixelPosX,   itemPixelPosY,  item_texture);
+            pRenderer->DrawTextureIndexedAlpha(  itemPixelPosX,   itemPixelPosY,  item_texture);
             ZBuffer_DoFill2(&v16[itemPixelPosX + pSRZBufferLineOffsets[itemPixelPosY]], item_texture, item_counter + 1);
             }
         }
--- a/GUI/GUIProgressBar.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/GUI/GUIProgressBar.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -157,7 +157,7 @@
       pRenderer->Sub01();
 
       pRenderer->DrawTextureIndexed(80, 122, &pBardata);//прогрессбар для данжей
-      pRenderer->DrawTextureTransparent(100, 146, &pIcons_LOD->pTextures[pIconsFrameTable->GetFrame(uIconID_TurnHour, 0)->uTextureID]);
+      pRenderer->DrawTextureIndexedAlpha(100, 146, &pIcons_LOD->pTextures[pIconsFrameTable->GetFrame(uIconID_TurnHour, 0)->uTextureID]);
       //pRenderer->FillRectFast(174, 164, floorf(((double)(113 * uProgressCurrent) / (double)uProgressMax) + 0.5f),//COERCE_UNSIGNED_INT64(v4 + 6.7553994e15),
         //16, pRenderer->uTargetRMask);
       pRenderer->FillRectFast(174, 164, floorf(((double)(113 * uProgressCurrent) / (double)uProgressMax) + 0.5f),//COERCE_UNSIGNED_INT64(v4 + 6.7553994e15),
@@ -178,9 +178,9 @@
 
   pRenderer->DrawTextureRGB(0, 0, &pLoadingBg);
   pRenderer->SetRasterClipRect(0, 0, 639, 479);
-  pRenderer->SetTextureClipRect(172, 459, 15 * (signed int)(signed __int64)((double)(300 * uProgressCurrent) / (double)uProgressMax) / 15 + 172, 471);
-  pRenderer->DrawTextureTransparent(172, 459, &pLoadingProgress);
-  pRenderer->ResetTextureClipRect();
+  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/GUIWindow.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/GUI/GUIWindow.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -801,7 +801,7 @@
   pWhiteColor = Color16(0xFFu, 0xFFu, 0xFFu);
   pColor2 = Color16(0x15u, 0x99u, 0xE9u);
   pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background);
-  pRenderer->DrawTextureTransparent(0x1D4u, 0, &pIcons_LOD->pTextures[uTextureID_right_panel_loop]);
+  pRenderer->DrawTextureIndexedAlpha(0x1D4u, 0, &pIcons_LOD->pTextures[uTextureID_right_panel_loop]);
   if ( pDialogueNPCCount != uNumDialogueNPCPortraits || !uHouse_ExitPic )
   {
     pDialogWindow.uFrameWidth = 130;
@@ -1848,7 +1848,7 @@
         draw_leather();
         CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
         CharacterUI_DrawPaperdoll(pPlayers[uActiveCharacter]);
-        pRenderer->DrawTextureTransparent(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pIcons_LOD->GetTexture(uTextureID_x_x_u));
+        pRenderer->DrawTextureIndexedAlpha(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pIcons_LOD->GetTexture(uTextureID_x_x_u));
         continue;
       }
       case WINDOW_ModalWindow:
@@ -1970,7 +1970,7 @@
         if ( pWindow->Hint != (char *)1 )
           pAudioPlayer->PlaySound(SOUND_StartMainChoice02, 0, 0, -1, 0, 0, 0, 0);
         pButton = (GUIButton *)pWindow->ptr_1C;
-        pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[0]);
+        pRenderer->DrawTextureIndexedAlpha(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[0]);
         viewparams->bRedrawGameUI = 1;
         if ( pWindow->Hint )
         {
@@ -1985,7 +1985,7 @@
         if ( pWindow->Hint != (char *)1 )
           pAudioPlayer->PlaySound(SOUND_StartMainChoice02, 0, 0, -1, 0, 0, 0, 0);
         pButton = (GUIButton *)pWindow->ptr_1C;
-        pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[1]);
+        pRenderer->DrawTextureIndexedAlpha(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[1]);
         viewparams->bRedrawGameUI = 1;
         pWindow->Release();
         continue;
@@ -2012,7 +2012,7 @@
         if ( pWindow->Hint != (char *)1 )
           pAudioPlayer->PlaySound(SOUND_StartMainChoice02, 0, 0, -1, 0, 0, 0, 0);
         pButton = (GUIButton *)pWindow->ptr_1C;
-        pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[0]);
+        pRenderer->DrawTextureIndexedAlpha(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[0]);
         viewparams->bRedrawGameUI = 1;
         if ( pWindow->Hint && pWindow->Hint != (char *)1 )
           pButton->DrawLabel(pWindow->Hint, pFontCreate, 0, 0);
--- a/GUI/UI/Books/UIMapBook.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/GUI/UI/Books/UIMapBook.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -40,8 +40,8 @@
   POINT a2; // [sp+68h] [bp-8h]@17
 
   pRenderer->ClearZBuffer(0, 479);
-  pRenderer->DrawTextureTransparent(8, 8, pTexture_CurrentBook);
-  pRenderer->DrawTextureTransparent(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId));
+  pRenderer->DrawTextureIndexedAlpha(8, 8, pTexture_CurrentBook);
+  pRenderer->DrawTextureIndexedAlpha(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId));
 
   TownPortalWindow.uFrameX = game_viewport_x;
   TownPortalWindow.uFrameY = game_viewport_y;
@@ -107,15 +107,15 @@
   pWindow.DrawTitleText(pBook2Font, 0, 22, 0, pTmpBuf.data(), 3);
   if ( bRecallingBeacon )
   {
-    pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_book_button1_on);
+    pRenderer->DrawTextureIndexedAlpha(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_book_button1_on);
     v19 = pTex_book_button1_off;
   }
   else
   {
-    pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_book_button1_off);
+    pRenderer->DrawTextureIndexedAlpha(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_book_button1_off);
     v19 = pTex_book_button1_on;
   }
-  pRenderer->DrawTextureTransparent(pBtn_Book_2->uX, pBtn_Book_2->uY, v19);
+  pRenderer->DrawTextureIndexedAlpha(pBtn_Book_2->uX, pBtn_Book_2->uY, v19);
   uNumMaxBeacons = 1;
   if ( HIBYTE(pPlayer->pActiveSkills[PLAYER_SKILL_WATER]) & 1 || (pPlayer->pActiveSkills[PLAYER_SKILL_WATER] & 0x80u) != 0 )
   {
@@ -139,7 +139,7 @@
       //if ( pSavegameThumbnails[BeaconID].pPixels != 0 )
       if ( pPlayer->pInstalledBeacons[BeaconID].SaveFileID != 0 )
       {
-        pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[BeaconID], pLloydsBeacons_SomeYs[BeaconID], pTexture_CurrentBook);
+        pRenderer->DrawTextureIndexedAlpha(pLloydsBeacons_SomeXs[BeaconID], pLloydsBeacons_SomeYs[BeaconID], pTexture_CurrentBook);
         pRenderer->DrawTextureRGB(pLloydsBeaconsPreviewXs[BeaconID], pLloydsBeaconsPreviewYs[BeaconID], &pSavegameThumbnails[BeaconID]);
         Str = pMapStats->pInfos[pMapStats->sub_410D99_get_map_index(pPlayer->pInstalledBeacons[BeaconID].SaveFileID)].pName;
         pTextHeight = pSpellFont->CalcTextHeight(Str, &pWindow, 0, 0);
@@ -176,7 +176,7 @@
       }
       if ( !bRecallingBeacon )
       {
-        pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[BeaconID], pLloydsBeacons_SomeYs[BeaconID], pTexture_CurrentBook);
+        pRenderer->DrawTextureIndexedAlpha(pLloydsBeacons_SomeXs[BeaconID], pLloydsBeacons_SomeYs[BeaconID], pTexture_CurrentBook);
         pTextHeight = pSpellFont->CalcTextHeight(pGlobalTXT_LocalizationStrings[19], &pWindow, 0, 0);
         pWindow.DrawTitleText(pSpellFont, 0, (signed int)pWindow.uFrameHeight / 2 - pTextHeight / 2, 1, pGlobalTXT_LocalizationStrings[19], 3);//Доступно
       }
@@ -196,34 +196,34 @@
 
   pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_12);
   if ( BtnUp_flag || viewparams->uMapBookMapZoom / 128 >= 12 )//Button 1
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 2, pTex_book_button1_off);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 2, pTex_book_button1_off);
   else
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, pTex_book_button1_on);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, pTex_book_button1_on);
 
   if ( BtnDown_flag || viewparams->uMapBookMapZoom / 128 <= 3 )//Button 2
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 38, pTex_book_button2_off);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 38, pTex_book_button2_off);
   else
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, pTex_book_button2_on);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, pTex_book_button2_on);
 
   if ( Book_PageBtn3_flag )//Button 3
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 113, pTex_book_button3_off);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 113, pTex_book_button3_off);
   else
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, pTex_book_button3_on);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, pTex_book_button3_on);
 
   if ( Book_PageBtn4_flag )//Button 4
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 150, pTex_book_button4_off);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 150, pTex_book_button4_off);
   else
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 399, pViewport->uViewportTL_Y + 150, pTex_book_button4_on);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 399, pViewport->uViewportTL_Y + 150, pTex_book_button4_on);
 
   if ( Book_PageBtn5_flag )//Button 5
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 188, pTex_book_button5_off);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 188, pTex_book_button5_off);
   else
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, pTex_book_button5_on);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, pTex_book_button5_on);
 
   if ( Book_PageBtn6_flag )//Button 6
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 226, pTex_book_button6_off);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 226, pTex_book_button6_off);
   else
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, pTex_book_button6_on);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, pTex_book_button6_on);
 
   if ( BtnDown_flag )
     viewparams->CenterOnParty2();
@@ -247,7 +247,7 @@
   Book_PageBtn4_flag = 0;
   Book_PageBtn3_flag = 0;
   DrawBook_Map_sub(97, 49, 361, 313, 0);
-  pRenderer->DrawTextureTransparent(75, 22, pTexture_mapbordr);
+  pRenderer->DrawTextureIndexedAlpha(75, 22, pTexture_mapbordr);
   map_window.uFrameWidth = game_viewport_width;
   map_window.uFrameHeight = game_viewport_height;
   map_window.uFrameX = game_viewport_x;
--- a/GUI/UI/Books/UINotesBooks.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/GUI/UI/Books/UINotesBooks.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -105,14 +105,14 @@
 
   pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pTexture_CurrentBook);
   if ( BtnUp_flag || !books_primary_item_per_page )//Bookmark Up(Закладка вверх)
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 2, pTex_book_button1_off);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 2, pTex_book_button1_off);
   else
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, pTex_book_button1_on);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, pTex_book_button1_on);
 
   if ( BtnDown_flag || books_primary_item_per_page + num_achieved_awards >= full_num_items_in_book )//Bookmark Down(Закладка вниз)
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 38, pTex_book_button2_off);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 38, pTex_book_button2_off);
   else
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, pTex_book_button2_on);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, pTex_book_button2_on);
 
   //for title
   questbook_window.uFrameWidth = game_viewport_width;
@@ -157,7 +157,7 @@
     pTextHeight = pAutonoteFont->CalcTextHeight(pQuestTable[achieved_awards[i]], &questbook_window, 1, 0);
     if ( (signed int)(questbook_window.uFrameY + pTextHeight) > (signed int)questbook_window.uFrameHeight )
       break;
-    pRenderer->DrawTextureTransparent(100, (questbook_window.uFrameY + pTextHeight) + 12, pSpellBookPagesTextr_10);
+    pRenderer->DrawTextureIndexedAlpha(100, (questbook_window.uFrameY + pTextHeight) + 12, pSpellBookPagesTextr_10);
     questbook_window.uFrameY = (questbook_window.uFrameY + pTextHeight) + 24;
   }
 }
@@ -172,133 +172,133 @@
   change_flag = false;
   pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pTexture_AutonotesBook);
   if ( BtnUp_flag || !books_primary_item_per_page )
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 2, pTex_book_button1_off);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 2, pTex_book_button1_off);
   else
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, pTex_book_button1_on);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, pTex_book_button1_on);
 
   if ( BtnDown_flag || books_primary_item_per_page + num_achieved_awards >= full_num_items_in_book )
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 38, pTex_book_button2_off);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 38, pTex_book_button2_off);
   else
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, pTex_book_button2_on);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, pTex_book_button2_on);
 
   if ( Book_PageBtn3_flag )//Potions_page_flag
   {
     if (_506568_autonote_type == AUTONOTE_POTION_RECEPIE)//press again(повторное нажатие)
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, pTex_book_button3_on);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, pTex_book_button3_on);
     else//press(нажатие)
     {
       change_flag = true;
       pAudioPlayer->PlaySound(SOUND_StartMainChoice02, 0, 0, -1, 0, 0, 0, 0);
       _506568_autonote_type = AUTONOTE_POTION_RECEPIE;
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, pTex_book_button3_on);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, pTex_book_button3_on);
     }
   }
   else 
   {
     if (_506568_autonote_type == AUTONOTE_POTION_RECEPIE)// default(по умолчанию при запуске окна)
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, pTex_book_button3_on);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, pTex_book_button3_on);
     else//Potions_page not active(вкладка снадобья не активна)
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 113, pTex_book_button3_off);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 113, pTex_book_button3_off);
   }
 
   if ( Book_PageBtn4_flag )//Fontains_page_flag
   {
     if ( _506568_autonote_type == AUTONOTE_STAT_HINT )
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 399, pViewport->uViewportTL_Y + 150, pTex_book_button4_on);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 399, pViewport->uViewportTL_Y + 150, pTex_book_button4_on);
     else
     {
       change_flag = true;
       pAudioPlayer->PlaySound(SOUND_StartMainChoice02, 0, 0, -1, 0, 0, 0, 0);
       _506568_autonote_type = AUTONOTE_STAT_HINT;
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 399, pViewport->uViewportTL_Y + 150, pTex_book_button4_on);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 399, pViewport->uViewportTL_Y + 150, pTex_book_button4_on);
     }
   }
   else
   {
     if ( _506568_autonote_type == AUTONOTE_STAT_HINT )
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 399, pViewport->uViewportTL_Y + 150, pTex_book_button4_on);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 399, pViewport->uViewportTL_Y + 150, pTex_book_button4_on);
     else
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 150, pTex_book_button4_off);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 150, pTex_book_button4_off);
   }
 
   if ( Book_PageBtn5_flag )//Autonotes_Obelisks_page_flag
   {
     if ( _506568_autonote_type == AUTONOTE_OBELISK)
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, pTex_book_button5_on);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, pTex_book_button5_on);
     else
     {
       change_flag = true;
       pAudioPlayer->PlaySound(SOUND_StartMainChoice02, 0, 0, -1, 0, 0, 0, 0);
       _506568_autonote_type = AUTONOTE_OBELISK;
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, pTex_book_button5_on);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, pTex_book_button5_on);
     }
   }
   else
   {
     if ( _506568_autonote_type == AUTONOTE_OBELISK)
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, pTex_book_button5_on);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, pTex_book_button5_on);
     else
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 188, pTex_book_button5_off);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 188, pTex_book_button5_off);
   }
 
   if ( Book_PageBtn6_flag )//Autonotes_Seer_page_flag
   {
     if ( _506568_autonote_type == AUTONOTE_SEER)
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, pTex_book_button6_on);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, pTex_book_button6_on);
     else
     {
       change_flag = true;
       pAudioPlayer->PlaySound(SOUND_StartMainChoice02, 0, 0, -1, 0, 0, 0, 0);
       _506568_autonote_type = AUTONOTE_SEER;
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, pTex_book_button6_on);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, pTex_book_button6_on);
     }
   }
   else
   {
     if ( _506568_autonote_type == AUTONOTE_SEER)
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, pTex_book_button6_on);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, pTex_book_button6_on);
     else
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 226, pTex_book_button6_off);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 226, pTex_book_button6_off);
   }
 
   if ( Autonotes_Misc_page_flag )
   {
     if ( _506568_autonote_type == AUTONOTE_MISC)
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 264, pTex_book_button7_on);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 264, pTex_book_button7_on);
     else
     {
       change_flag = true;
       pAudioPlayer->PlaySound(SOUND_StartMainChoice02, 0, 0, -1, 0, 0, 0, 0);
       _506568_autonote_type = AUTONOTE_MISC;
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 264, pTex_book_button7_on);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 264, pTex_book_button7_on);
     }
   }
   else
   {
     if ( _506568_autonote_type == AUTONOTE_MISC)
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 264, pTex_book_button7_on);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 264, pTex_book_button7_on);
     else
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 263, pTex_book_button7_off);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 263, pTex_book_button7_off);
   }
 
   if ( Autonotes_Instructors_page_flag )
   {
     if ( _506568_autonote_type == AUTONOTE_TEACHER)
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 302, pTex_book_button8_on);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 302, pTex_book_button8_on);
     else
     {
       change_flag = true;
       pAudioPlayer->PlaySound(SOUND_StartMainChoice02, 0, 0, -1, 0, 0, 0, 0);
       _506568_autonote_type = AUTONOTE_TEACHER;
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 302, pTex_book_button8_on);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 302, pTex_book_button8_on);
     }
   }
   else
   {
     if ( _506568_autonote_type == AUTONOTE_TEACHER)
-      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 302, pTex_book_button8_on);
+      pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 302, pTex_book_button8_on);
     else
-     pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 302, pTex_book_button8_off);
+     pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 302, pTex_book_button8_off);
   }
 
   //for title
@@ -372,7 +372,7 @@
     pTextHeight = pAutonoteFont->CalcTextHeight(pAutonoteTxt[achieved_awards[i]].pText, &autonotes_window, 1, 0);
     if ( (signed int)(autonotes_window.uFrameY + pTextHeight) > (signed int)autonotes_window.uFrameHeight )
       break;
-    pRenderer->DrawTextureTransparent(100, (autonotes_window.uFrameY + pTextHeight) + 12, pSpellBookPagesTextr_10);
+    pRenderer->DrawTextureIndexedAlpha(100, (autonotes_window.uFrameY + pTextHeight) + 12, pSpellBookPagesTextr_10);
     autonotes_window.uFrameY = (autonotes_window.uFrameY + pTextHeight) + 24;
   }
 }
@@ -386,14 +386,14 @@
 
   pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_11);
   if ( BtnUp_flag || !books_primary_item_per_page )
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 2, pTex_book_button1_off);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 2, pTex_book_button1_off);
   else
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, pTex_book_button1_on);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, pTex_book_button1_on);
 
   if ( BtnDown_flag || books_primary_item_per_page + num_achieved_awards >= full_num_items_in_book )
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 38, pTex_book_button2_off);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 38, pTex_book_button2_off);
   else
-    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, pTex_book_button2_on);
+    pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, pTex_book_button2_on);
 
   if ( !Journal_limitation_factor[books_primary_item_per_page] )//for title
   {
--- a/GUI/UI/Books/UISpellBook.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/GUI/UI/Books/UISpellBook.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -105,7 +105,7 @@
             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;
             if ( pTexture->pBits & 0x200 )
-              pRenderer->DrawTextureTransparent(pX_coord, pY_coord, pTexture);
+              pRenderer->DrawTextureIndexedAlpha(pX_coord, pY_coord, pTexture);
             else
               pRenderer->DrawTextureIndexed(pX_coord, pY_coord, pTexture);
             pRenderer->DrawMaskToZBuffer(pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][i]].Xpos,
@@ -125,7 +125,7 @@
       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;
       if ( SBPageCSpellsTextureList[v10]->pBits & 0x200 )
-        pRenderer->DrawTextureTransparent(pX_coord, pY_coord, SBPageCSpellsTextureList[v10]);
+        pRenderer->DrawTextureIndexedAlpha(pX_coord, pY_coord, SBPageCSpellsTextureList[v10]);
       else
         pRenderer->DrawTextureIndexed(pX_coord, pY_coord, SBPageCSpellsTextureList[v10]);
     }
@@ -148,7 +148,7 @@
         pX_coord = texture_tab_coord0[i][0];
         pY_coord = texture_tab_coord0[i][1];
       }
-      pRenderer->DrawTextureTransparent(pX_coord, pY_coord, pPageTexture);
+      pRenderer->DrawTextureIndexedAlpha(pX_coord, pY_coord, pPageTexture);
     }
   }
 }
\ No newline at end of file
--- a/GUI/UI/UICharacter.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/GUI/UI/UICharacter.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -769,11 +769,11 @@
       break;
     }
 
-  pRenderer->ResetTextureClipRect();
+  pRenderer->ResetUIClipRect();
   pRenderer->DrawTextureIndexed(467, 0, pIcons_LOD->GetTexture(uTextureID_BACKDOLL));//Подложка
   if ( IsPlayerWearingWatersuit[uPlayerID] )//акваланг
   {
-    pRenderer->DrawTextureTransparent(pPaperdoll_BodyX, pPaperdoll_BodyY, pIcons_LOD->GetTexture(papredoll_dbods[uPlayerID - 1]));
+    pRenderer->DrawTextureIndexedAlpha(pPaperdoll_BodyX, pPaperdoll_BodyY, pIcons_LOD->GetTexture(papredoll_dbods[uPlayerID - 1]));
     if ( !bRingsShownInCharScreen )
       pRenderer->DrawMaskToZBuffer(pPaperdoll_BodyX, pPaperdoll_BodyY, pIcons_LOD->GetTexture(papredoll_dbods[uPlayerID - 1]), player->pEquipment.uArmor);
     //Рука не занята или ...
@@ -781,7 +781,7 @@
          || ( player->GetMainHandItem()->GetItemEquipType() != EQUIP_TWO_HANDED)
          && (player->GetMainHandItem()->GetItemEquipType() != PLAYER_SKILL_SPEAR
          || player->GetItem(&PlayerEquipment::uShield)) )
-      pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_LeftHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_LeftHand[pBodyComplection][1],
+      pRenderer->DrawTextureIndexedAlpha(pPaperdoll_BodyX + pPaperdoll_LeftHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_LeftHand[pBodyComplection][1],
                                         pIcons_LOD->GetTexture(papredoll_dlads[uPlayerID - 1]));
     //-----------------------------------------------------(Hand/Рука)---------------------------------------------------------------
     if ( player->GetItem(&PlayerEquipment::uMainHand) )
@@ -817,7 +817,7 @@
 	  else if ( item->uAttributes & ITEM_BROKEN )
         pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(v166, TEXTURE_16BIT_PALETTE)));
       else if ( item->uAttributes & ITEM_IDENTIFIED )
-        pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(v166, TEXTURE_16BIT_PALETTE)));
+        pRenderer->DrawTextureIndexedAlpha(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(v166, TEXTURE_16BIT_PALETTE)));
       else
         pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(v166, TEXTURE_16BIT_PALETTE)));
 
@@ -859,7 +859,7 @@
       else if ( !(item->uAttributes & ITEM_IDENTIFIED) )//не опознанный лук зелёный
         pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(item->GetIconName(), TEXTURE_16BIT_PALETTE)));
       else // опознанный лук
-        pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(item->GetIconName(), TEXTURE_16BIT_PALETTE)));
+        pRenderer->DrawTextureIndexedAlpha(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(item->GetIconName(), TEXTURE_16BIT_PALETTE)));
 
       if ( !bRingsShownInCharScreen )
         pRenderer->DrawMaskToZBuffer(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(item->GetIconName(), TEXTURE_16BIT_PALETTE)),
@@ -918,7 +918,7 @@
 	    else if ( item->uAttributes & ITEM_BROKEN )
           pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_cloak_texture[pBodyComplection][index]));
         else
-          pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_cloak_texture[pBodyComplection][index]));
+          pRenderer->DrawTextureIndexedAlpha(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_cloak_texture[pBodyComplection][index]));
 
         if ( !bRingsShownInCharScreen )
           pRenderer->DrawMaskToZBuffer(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_cloak_texture[pBodyComplection][index]),
@@ -926,7 +926,7 @@
       }
     }
     //-------------------------------(Paperdoll/Кукла)-------------------------------------------
-    pRenderer->DrawTextureTransparent(pPaperdoll_BodyX, pPaperdoll_BodyY, pIcons_LOD->GetTexture(papredoll_dbods[uPlayerID - 1]));
+    pRenderer->DrawTextureIndexedAlpha(pPaperdoll_BodyX, pPaperdoll_BodyY, pIcons_LOD->GetTexture(papredoll_dbods[uPlayerID - 1]));
     //-------------------------------(Armor/Броня)-----------------------------------------------
     if ( player->GetItem(&PlayerEquipment::uArmor) )
     {
@@ -979,7 +979,7 @@
         else if ( !(item->uAttributes & ITEM_IDENTIFIED) )
           pRenderer->DrawTransparentGreenShade(item_X, item_Y, &pIcons_LOD->pTextures[paperdoll_armor_texture[pBodyComplection][index][0]]);
         else
-          pRenderer->DrawTextureTransparent(item_X, item_Y, &pIcons_LOD->pTextures[paperdoll_armor_texture[pBodyComplection][index][0]]);
+          pRenderer->DrawTextureIndexedAlpha(item_X, item_Y, &pIcons_LOD->pTextures[paperdoll_armor_texture[pBodyComplection][index][0]]);
 
         if ( !bRingsShownInCharScreen )
           pRenderer->DrawMaskToZBuffer(item_X, item_Y, &pIcons_LOD->pTextures[paperdoll_armor_texture[pBodyComplection][index][0]],
@@ -1033,7 +1033,7 @@
 		else if ( item->uAttributes & ITEM_BROKEN )
           pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(v59));
         else if ( item->uAttributes & ITEM_IDENTIFIED )
-          pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(v59));
+          pRenderer->DrawTextureIndexedAlpha(item_X, item_Y, pIcons_LOD->GetTexture(v59));
         else
           pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(v59));
 
@@ -1046,7 +1046,7 @@
         || ( player->GetMainHandItem()->GetItemEquipType() != EQUIP_TWO_HANDED)
         && (player->GetMainHandItem()->GetPlayerSkillType() != PLAYER_SKILL_SPEAR
         || player->GetItem(&PlayerEquipment::uShield)) )
-      pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_LeftHand[pBodyComplection][0],
+      pRenderer->DrawTextureIndexedAlpha(pPaperdoll_BodyX + pPaperdoll_LeftHand[pBodyComplection][0],
                             pPaperdoll_BodyY + pPaperdoll_LeftHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_dlads[uPlayerID - 1]));
     //--------------------------------------------(Belt/Пояс)-------------------------------------------------------
     if ( player->GetItem(&PlayerEquipment::uBelt))
@@ -1096,7 +1096,7 @@
 		else if ( item->uAttributes & ITEM_BROKEN )
           pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(v75));
         else if ( item->uAttributes & ITEM_IDENTIFIED )
-          pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(v75));
+          pRenderer->DrawTextureIndexedAlpha(item_X, item_Y, pIcons_LOD->GetTexture(v75));
         else
           pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(v75));
 
@@ -1172,7 +1172,7 @@
 		    else if ( item->uAttributes & ITEM_BROKEN )
               pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(v94));
             else if ( item->uAttributes & ITEM_IDENTIFIED )
-              pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(v94));
+              pRenderer->DrawTextureIndexedAlpha(item_X, item_Y, pIcons_LOD->GetTexture(v94));
             else
               pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(v94));
 
@@ -1209,7 +1209,7 @@
 			else if ( item->uAttributes & ITEM_BROKEN )
               pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_armor_texture[pBodyComplection][index][1]));
             else if ( item->uAttributes & ITEM_IDENTIFIED )
-              pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_armor_texture[pBodyComplection][index][1]));
+              pRenderer->DrawTextureIndexedAlpha(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_armor_texture[pBodyComplection][index][1]));
             else
               pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_armor_texture[pBodyComplection][index][1]));
 
@@ -1272,7 +1272,7 @@
 		    else if ( item->uAttributes & ITEM_BROKEN )
               pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_cloak_collar_texture[pBodyComplection][index]));
             else
-              pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_cloak_collar_texture[pBodyComplection][index]));
+              pRenderer->DrawTextureIndexedAlpha(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_cloak_collar_texture[pBodyComplection][index]));
 
             if ( !bRingsShownInCharScreen )
               pRenderer->DrawMaskToZBuffer(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_cloak_collar_texture[pBodyComplection][index]),
@@ -1284,7 +1284,7 @@
       if ( player->uCurrentFace == 12 || player->uCurrentFace == 13 )
       {
         if ( papredoll_dbrds[player->uCurrentFace] != pIcons_LOD->FindTextureByName("Pending") )
-          pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_Beards[2 * player->uCurrentFace - 24],
+          pRenderer->DrawTextureIndexedAlpha(pPaperdoll_BodyX + pPaperdoll_Beards[2 * player->uCurrentFace - 24],
                      pPaperdoll_BodyY + pPaperdoll_Beards[2 * player->uCurrentFace - 23],
                      pIcons_LOD->GetTexture(papredoll_dbrds[player->uCurrentFace]));
       }
@@ -1344,7 +1344,7 @@
         else if ( item->uAttributes & ITEM_BROKEN )
           pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(v127));
         else if ( item->uAttributes & ITEM_IDENTIFIED )
-          pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(v127));
+          pRenderer->DrawTextureIndexedAlpha(item_X, item_Y, pIcons_LOD->GetTexture(v127));
         else
           pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(v127));
 
@@ -1386,7 +1386,7 @@
 	  else if ( item->uAttributes & ITEM_BROKEN )
         pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(v181, TEXTURE_16BIT_PALETTE)));
       else if ( item->uAttributes & ITEM_IDENTIFIED )
-        pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(v181, TEXTURE_16BIT_PALETTE)));
+        pRenderer->DrawTextureIndexedAlpha(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(v181, TEXTURE_16BIT_PALETTE)));
       else
         pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(v181, TEXTURE_16BIT_PALETTE)));
 
@@ -1455,24 +1455,24 @@
       else if ( !(item->uAttributes & ITEM_IDENTIFIED) )
         pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(v153));
       else
-        pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(v153));
+        pRenderer->DrawTextureIndexedAlpha(item_X, item_Y, pIcons_LOD->GetTexture(v153));
 
       if ( two_handed_left_fist )//two-handed - left fist/двуручие - левая кисть
-        pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdollLeftEmptyHand[pBodyComplection][0],
+        pRenderer->DrawTextureIndexedAlpha(pPaperdoll_BodyX + pPaperdollLeftEmptyHand[pBodyComplection][0],
                  pPaperdoll_BodyY + pPaperdollLeftEmptyHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_dlhs[uPlayerID - 1]));
       if ( !bRingsShownInCharScreen )
         pRenderer->DrawMaskToZBuffer(item_X, item_Y, pIcons_LOD->GetTexture(v153), player->pEquipment.uShield);
     }
   }
   //--------------------------------------------------------(RightHand/Правая кисть)--------------------------------------------------
-  pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_RightHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_RightHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_drhs[uPlayerID - 1]));
+  pRenderer->DrawTextureIndexedAlpha(pPaperdoll_BodyX + pPaperdoll_RightHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_RightHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_drhs[uPlayerID - 1]));
   //---------------------------------------------(two-handed - hand/Двуручие - рука)--------------------------------------------------
   if ( player->GetItem(&PlayerEquipment::uMainHand) )
   {
     if ( player->GetMainHandItem()->GetItemEquipType() == EQUIP_TWO_HANDED
          || player->GetMainHandItem()->GetPlayerSkillType() == PLAYER_SKILL_SPEAR
          && !player->GetItem(&PlayerEquipment::uShield) )
-      pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[pBodyComplection][0],
+      pRenderer->DrawTextureIndexedAlpha(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[pBodyComplection][0],
                  pPaperdoll_BodyY + pPaperdoll_SecondLeftHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_dlaus[uPlayerID - 1]));
   }
   //--------------------------------------------------------(two-handed - fist/двуручие - кисть)----------------------------------------------------
@@ -1482,13 +1482,13 @@
     if ( item->GetItemEquipType() == EQUIP_TWO_HANDED
         || item->GetPlayerSkillType() == PLAYER_SKILL_SPEAR
         && !player->GetItem(&PlayerEquipment::uShield) )
-      pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[pBodyComplection][0], 
+      pRenderer->DrawTextureIndexedAlpha(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[pBodyComplection][0], 
                                         pPaperdoll_BodyY + pPaperdoll_SecondLeftHand[pBodyComplection][1], 
                                         pIcons_LOD->GetTexture(papredoll_dlhus[uPlayerID - 1]));
   }
   if ( !bRingsShownInCharScreen )//рисование лупы
-    pRenderer->DrawTextureTransparent(603, 299, pIcons_LOD->GetTexture(uTextureID_MAGNIF_B));
-  pRenderer->DrawTextureTransparent(468, 0, pIcons_LOD->GetTexture(uTextureID_right_panel_loop));//обрамление
+    pRenderer->DrawTextureIndexedAlpha(603, 299, pIcons_LOD->GetTexture(uTextureID_MAGNIF_B));
+  pRenderer->DrawTextureIndexedAlpha(468, 0, pIcons_LOD->GetTexture(uTextureID_right_panel_loop));//обрамление
 }
 
 //----- (0041A2D1) --------------------------------------------------------
@@ -1551,7 +1551,7 @@
         if (player->pInventoryItemList[player->pInventoryMatrix[i] - 1].IsBroken())
           pRenderer->DrawTransparentRedShade(uCellX, uCellY, pTexture);
         else
-          pRenderer->DrawTextureTransparent(uCellX, uCellY, pTexture);
+          pRenderer->DrawTextureIndexedAlpha(uCellX, uCellY, pTexture);
       }
       else
         pRenderer->DrawTransparentGreenShade(uCellX, uCellY, pTexture);
@@ -1592,7 +1592,7 @@
     else if (!item->IsIdentified())
       pRenderer->DrawTransparentGreenShade(x, y, item_texture);
     else
-      pRenderer->DrawTextureTransparent(x, y, item_texture);
+      pRenderer->DrawTextureIndexedAlpha(x, y, item_texture);
 
     pRenderer->ZBuffer_Fill_2(x, y, item_texture, id);
   }
@@ -1602,8 +1602,8 @@
 void CharacterUI_DrawPaperdollWithRingOverlay(Player *player)
 {
   CharacterUI_DrawPaperdoll(player);
-  pRenderer->DrawTextureTransparent(0x1D9u, 0, pIcons_LOD->GetTexture(uTextureID_BACKHAND));
-  pRenderer->DrawTextureTransparent(0x1D4u, 0, pIcons_LOD->GetTexture(uTextureID_right_panel_loop));
+  pRenderer->DrawTextureIndexedAlpha(0x1D9u, 0, pIcons_LOD->GetTexture(uTextureID_BACKHAND));
+  pRenderer->DrawTextureIndexedAlpha(0x1D4u, 0, pIcons_LOD->GetTexture(uTextureID_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)
--- a/GUI/UI/UIGuilds.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/GUI/UI/UIGuilds.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -162,7 +162,7 @@
     {
       if ( pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v6].uItemID )
       {
-        pRenderer->DrawTextureTransparent(pX, 90, ItemsInShopTexture[v6]);
+        pRenderer->DrawTextureIndexedAlpha(pX, 90, ItemsInShopTexture[v6]);
         ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 230528), ItemsInShopTexture[v6], v6 + 1);
       }
       v62 += 280;
@@ -174,7 +174,7 @@
     {
       if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v7].uItemID)
       {
-        pRenderer->DrawTextureTransparent(pX, 250, ItemsInShopTexture[v7]);
+        pRenderer->DrawTextureIndexedAlpha(pX, 250, ItemsInShopTexture[v7]);
         ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 638448), ItemsInShopTexture[v7], v7 + 1);
       }
       v62 += 280;
--- a/GUI/UI/UIMainMenu.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/GUI/UI/UIMainMenu.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -33,8 +33,6 @@
   for (uint i = 0; i < window->GetHeight(); ++i)
     pSRZBufferLineOffsets[i] = window->GetWidth() * i;
 
-  pRenderer->ResetTextureClipRect();
-
   uTextureID_FONTPAL = pIcons_LOD->LoadTexture("FONTPAL", TEXTURE_16BIT_PALETTE);
 
   pFontArrus = LoadFont("arrus.fnt", "FONTPAL", nullptr);
@@ -321,10 +319,10 @@
     {
       pRenderer->BeginScene();
       pRenderer->DrawTextureRGB(0, 0, &mm6title_texture);
-      pRenderer->SetTextureClipRect(credit_window.uFrameX, credit_window.uFrameY, credit_window.uFrameX + credit_window.uFrameWidth,
+      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);
-      pRenderer->ResetTextureClipRect();
+      pRenderer->ResetUIClipRect();
       pRenderer->EndScene();
       ++move_Y;
       if ( move_Y >= cred_texture.uHeight )
--- a/GUI/UI/UIPartyCreation.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/GUI/UI/UIPartyCreation.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -110,7 +110,7 @@
   uPlayerCreationUI_SkySliderPos = (GetTickCount() % 12800) / 20;
   pRenderer->DrawTextureIndexed(uPlayerCreationUI_SkySliderPos, 2, pTexture_MAKESKY);
   pRenderer->DrawTextureIndexed(uPlayerCreationUI_SkySliderPos - window->GetWidth(), 2, pTexture_MAKESKY);
-  pRenderer->DrawTextureTransparent(0, 0, pTexture_MAKETOP);
+  pRenderer->DrawTextureIndexedAlpha(0, 0, pTexture_MAKETOP);
 
   uPlayerCreationUI_SelectedCharacter = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) / 7;
   switch (uPlayerCreationUI_SelectedCharacter)
@@ -125,18 +125,18 @@
 
   pTextCenter = pFontCChar->AlignText_Center(window->GetWidth(), pGlobalTXT_LocalizationStrings[51]);
   pGUIWindow_CurrentMenu->DrawText(pFontCChar, pTextCenter + 1, 0, 0, pGlobalTXT_LocalizationStrings[51], 0, 0, 0);//С О З Д А Т Ь  О Т Р Я Д
-  pRenderer->DrawTextureTransparent(17, 35, pPlayerPortraits[pParty->pPlayers[0].uCurrentFace]);
-  pRenderer->DrawTextureTransparent(176, 35, pPlayerPortraits[pParty->pPlayers[1].uCurrentFace]);
-  pRenderer->DrawTextureTransparent(335, 35, pPlayerPortraits[pParty->pPlayers[2].uCurrentFace]);
-  pRenderer->DrawTextureTransparent(494, 35, pPlayerPortraits[pParty->pPlayers[3].uCurrentFace]);
+  pRenderer->DrawTextureIndexedAlpha(17, 35, pPlayerPortraits[pParty->pPlayers[0].uCurrentFace]);
+  pRenderer->DrawTextureIndexedAlpha(176, 35, pPlayerPortraits[pParty->pPlayers[1].uCurrentFace]);
+  pRenderer->DrawTextureIndexedAlpha(335, 35, pPlayerPortraits[pParty->pPlayers[2].uCurrentFace]);
+  pRenderer->DrawTextureIndexedAlpha(494, 35, pPlayerPortraits[pParty->pPlayers[3].uCurrentFace]);
   pFrame = pIconsFrameTable->GetFrame(uIconID_CharacterFrame, pEventTimer->uStartTime);
 
 
-  pRenderer->DrawTextureTransparent(pX, 29, &pIcons_LOD->pTextures[pFrame->uTextureID]);
+  pRenderer->DrawTextureIndexedAlpha(pX, 29, &pIcons_LOD->pTextures[pFrame->uTextureID]);
   uPosActiveItem = pGUIWindow_CurrentMenu->GetControl(pGUIWindow_CurrentMenu->pCurrentPosActiveItem);
   uPlayerCreationUI_ArrowAnim = 19 - (GetTickCount() % 500) / 25;
-  pRenderer->DrawTextureTransparent(uPosActiveItem->uZ - 4, uPosActiveItem->uY, pTextures_arrowl[uPlayerCreationUI_ArrowAnim]);
-  pRenderer->DrawTextureTransparent(uPosActiveItem->uX - 12, uPosActiveItem->uY, pTextures_arrowr[uPlayerCreationUI_ArrowAnim]);
+  pRenderer->DrawTextureIndexedAlpha(uPosActiveItem->uZ - 4, uPosActiveItem->uY, pTextures_arrowl[uPlayerCreationUI_ArrowAnim]);
+  pRenderer->DrawTextureIndexedAlpha(uPosActiveItem->uX - 12, uPosActiveItem->uY, pTextures_arrowr[uPlayerCreationUI_ArrowAnim]);
 
   memset(pText, 0, 200);
   strcpy(pText, pGlobalTXT_LocalizationStrings[205]);// "Skills"
@@ -151,7 +151,7 @@
   for (int i = 0; i < 4; ++i)
   {
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, pIntervalX + 73, 100, 0, pClassNames[pParty->pPlayers[i].classType], 0, 0, 0);
-    pRenderer->DrawTextureTransparent(pIntervalX + 77, 50, pTexture_IC_KNIGHT[pParty->pPlayers[i].classType / 4]);
+    pRenderer->DrawTextureIndexedAlpha(pIntervalX + 77, 50, pTexture_IC_KNIGHT[pParty->pPlayers[i].classType / 4]);
 
     if ( pGUIWindow_CurrentMenu->receives_keyboard_input_2 != WINDOW_INPUT_NONE && pGUIWindow_CurrentMenu->ptr_1C == (void *)i )
     {
--- a/GUI/UI/UIPopup.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/GUI/UI/UIPopup.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -67,45 +67,48 @@
   unsigned int coord_x; // [sp+2Ch] [bp-Ch]@3
   unsigned int coord_y; // [sp+34h] [bp-4h]@5
 
-  pRenderer->SetTextureClipRect(uX, uY, uX + uWidth, uY + uHeight);
-  if ( pIcons_LOD->GetTexture(uTextureID_Parchment)->uTextureWidth && pIcons_LOD->GetTexture(uTextureID_Parchment)->uTextureHeight)
+  auto parchment = pIcons_LOD->GetTexture(uTextureID_Parchment);
+
+  if ( parchment->uTextureWidth && parchment->uTextureHeight)
   {
-    uNumTiles = uWidth / pIcons_LOD->GetTexture(uTextureID_Parchment)->uTextureWidth;
-    if ( uWidth % pIcons_LOD->GetTexture(uTextureID_Parchment)->uTextureWidth )
+    pRenderer->SetUIClipRect(uX, uY, uX + uWidth, uY + uHeight);
+
+    uNumTiles = uWidth / parchment->uTextureWidth;
+    if ( uWidth % parchment->uTextureWidth )
       ++uNumTiles;
     coord_y = uY;
-    for ( uint j = 0; j <= uHeight / pIcons_LOD->GetTexture(uTextureID_Parchment)->uTextureHeight; j++ )
+    for ( uint j = 0; j <= uHeight / parchment->uTextureHeight; j++ )
     {
-      coord_x = uX - pIcons_LOD->GetTexture(uTextureID_Parchment)->uTextureWidth;
+      coord_x = uX - parchment->uTextureWidth;
       for ( uint i = uNumTiles + 1; i; --i )
       {
-        coord_x += pIcons_LOD->GetTexture(uTextureID_Parchment)->uTextureWidth;
-        pRenderer->DrawTextureIndexed(coord_x, coord_y, pIcons_LOD->GetTexture(uTextureID_Parchment));
+        coord_x += parchment->uTextureWidth;
+        pRenderer->DrawTextureIndexed(coord_x, coord_y, parchment);
       }
-      coord_y += pIcons_LOD->GetTexture(uTextureID_Parchment)->uTextureHeight;
+      coord_y += parchment->uTextureHeight;
     }
-    pRenderer->DrawTextureTransparent(uX,               uY,                pIcons_LOD->GetTexture(uTextureID_5076AC));
-    pRenderer->DrawTextureTransparent(uX,               uY + uHeight - 32, pIcons_LOD->GetTexture(uTextureID_5076B4));
-    pRenderer->DrawTextureTransparent(uX + uWidth - 32, uY,                pIcons_LOD->GetTexture(uTextureID_5076A8));
-    pRenderer->DrawTextureTransparent(uX + uWidth - 32, uY + uHeight - 32, pIcons_LOD->GetTexture(uTextureID_5076B0));
+    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->SetTextureClipRect(uX + 32, uY, uX + uWidth - 32, uY + uHeight);
-      pRenderer->DrawTextureTransparent(uX + 32, uY,                pIcons_LOD->GetTexture(uTextureID_507698));
-      pRenderer->DrawTextureTransparent(uX + 32, uY + uHeight - 10, pIcons_LOD->GetTexture(uTextureID_5076A4));
+      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->DrawTextureTransparent(uX + 544, uY,                pIcons_LOD->GetTexture(uTextureID_507698));
-        pRenderer->DrawTextureTransparent(uX + 544, uY + uHeight - 10, pIcons_LOD->GetTexture(uTextureID_5076A4));
+        pRenderer->DrawTextureIndexedAlpha(uX + 544, uY,                pIcons_LOD->GetTexture(uTextureID_507698));
+        pRenderer->DrawTextureIndexedAlpha(uX + 544, uY + uHeight - 10, pIcons_LOD->GetTexture(uTextureID_5076A4));
       }
     }
     if ( uHeight > 64 )
     {
-      pRenderer->SetTextureClipRect(uX, uY + 32, uX + uWidth, uY + uHeight - 32);
-      pRenderer->DrawTextureTransparent(uX,               uY + 32, pIcons_LOD->GetTexture(uTextureID_5076A0));
-      pRenderer->DrawTextureTransparent(uX + uWidth - 10, uY + 32, pIcons_LOD->GetTexture(uTextureID_50769C));
+      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->ResetTextureClipRect();
+    pRenderer->ResetUIClipRect();
   }
 }
 
@@ -199,7 +202,7 @@
   if (inspect_item->IsBroken())
   {
     iteminfo_window.DrawMessageBox(0);
-    pRenderer->SetTextureClipRect(iteminfo_window.uFrameX + 12, iteminfo_window.uFrameY + 12,
+    pRenderer->SetUIClipRect(iteminfo_window.uFrameX + 12, iteminfo_window.uFrameY + 12,
     iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 12, 
     iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 12);
     iteminfo_window.uFrameWidth -= 24;
@@ -214,7 +217,7 @@
     iteminfo_window.DrawTitleText(pFontArrus, 0, 0xCu, Color16(0xFFu, 0xFFu, 0x9Bu), pText, 3);
     iteminfo_window.DrawTitleText(pFontArrus, 0x64u, ((signed int)iteminfo_window.uFrameHeight >> 1) - pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[32], &iteminfo_window, 0, 0) / 2,
                    Color16(0xFFu, 0x19u, 0x19u), pGlobalTXT_LocalizationStrings[32], 3); //"Broken Item"
-    pRenderer->ResetTextureClipRect();
+    pRenderer->ResetUIClipRect();
     if ( !areWeLoadingTexture )
     {
       pIcons_LOD->LoadTexturePtr(inspect_item->GetIconName(), TEXTURE_16BIT_PALETTE)->Release();
@@ -225,17 +228,17 @@
   if (!inspect_item->IsIdentified())
   {
     iteminfo_window.DrawMessageBox(0);
-    pRenderer->SetTextureClipRect(iteminfo_window.uFrameX + 12,  iteminfo_window.uFrameY + 12,
+    pRenderer->SetUIClipRect(iteminfo_window.uFrameX + 12,  iteminfo_window.uFrameY + 12,
           iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 12,  iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 12);
     iteminfo_window.uFrameWidth -= 24;
     iteminfo_window.uFrameHeight -= 12;
     iteminfo_window.uFrameZ = iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 1;
     iteminfo_window.uFrameW = iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 1;
-    pRenderer->DrawTextureTransparent(iteminfo_window.uFrameX + v78, v81 + iteminfo_window.uFrameY + 30, pIcons_LOD->LoadTexturePtr(inspect_item->GetIconName(), TEXTURE_16BIT_PALETTE));
+    pRenderer->DrawTextureIndexedAlpha(iteminfo_window.uFrameX + v78, v81 + iteminfo_window.uFrameY + 30, pIcons_LOD->LoadTexturePtr(inspect_item->GetIconName(), TEXTURE_16BIT_PALETTE));
     iteminfo_window.DrawTitleText(pFontArrus, 0, 0xCu, Color16(0xFFu, 0xFFu, 0x9Bu), pItemsTable->pItems[inspect_item->uItemID].pUnidentifiedName, 3);
     iteminfo_window.DrawTitleText(pFontArrus, 0x64u, ((signed int)iteminfo_window.uFrameHeight >> 1) - pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[232], &iteminfo_window, 0, 0) / 2,
                         Color16(0xFFu, 0x19u, 0x19u), pGlobalTXT_LocalizationStrings[232], 3);//"Not Identified"
-    pRenderer->ResetTextureClipRect();
+    pRenderer->ResetUIClipRect();
     if ( !areWeLoadingTexture )
     {
       pIcons_LOD->LoadTexturePtr(inspect_item->GetIconName(), TEXTURE_16BIT_PALETTE)->Release();
@@ -337,13 +340,13 @@
   iteminfo_window.uFrameW = iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 1;
   iteminfo_window.uFrameZ = iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 1;
   iteminfo_window.DrawMessageBox(0);
-  pRenderer->SetTextureClipRect(iteminfo_window.uFrameX + 12, iteminfo_window.uFrameY + 12,
+  pRenderer->SetUIClipRect(iteminfo_window.uFrameX + 12, iteminfo_window.uFrameY + 12,
          iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 12, iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 12);
   iteminfo_window.uFrameWidth -= 12;
   iteminfo_window.uFrameHeight -= 12;
   iteminfo_window.uFrameZ = iteminfo_window.uFrameX + iteminfo_window.uFrameWidth - 1;
   iteminfo_window.uFrameW = iteminfo_window.uFrameY + iteminfo_window.uFrameHeight - 1;
-  pRenderer->DrawTextureTransparent(iteminfo_window.uFrameX + v78,
+  pRenderer->DrawTextureIndexedAlpha(iteminfo_window.uFrameX + v78,
       iteminfo_window.uFrameY + (signed int)(iteminfo_window.uFrameHeight - pIcons_LOD->LoadTexturePtr(inspect_item->GetIconName(), TEXTURE_16BIT_PALETTE)->uTextureHeight) / 2,
       pIcons_LOD->LoadTexturePtr(inspect_item->GetIconName(), TEXTURE_16BIT_PALETTE));
 
@@ -370,7 +373,7 @@
   {
     sprintf(pTmpBuf.data(), "%s: %lu", pGlobalTXT_LocalizationStrings[465], v77);//"Value"
     iteminfo_window.DrawText(pFontComic, 100, iteminfo_window.uFrameHeight - LOBYTE(pFontComic->uFontHeight), 0, pTmpBuf.data(), 0, 0, 0);
-    pRenderer->ResetTextureClipRect();
+    pRenderer->ResetUIClipRect();
   }
   else
   {
@@ -407,7 +410,7 @@
     {
       if ( !(inspect_item->uAttributes & ITEM_HARDENED) )
       {
-        pRenderer->ResetTextureClipRect();
+        pRenderer->ResetUIClipRect();
         if ( !areWeLoadingTexture )
         {
           pIcons_LOD->LoadTexturePtr(inspect_item->GetIconName(), TEXTURE_16BIT_PALETTE)->Release();
@@ -420,7 +423,7 @@
     LOWORD(inspect_item->uAttributes) = r_mask;
     iteminfo_window.DrawText(pFontComic, pFontComic->GetLineWidth(pTmpBuf.data()) + 132,
           iteminfo_window.uFrameHeight - LOBYTE(pFontComic->uFontHeight), inspect_item->uAttributes, pText, 0, 0, 0);
-    pRenderer->ResetTextureClipRect();
+    pRenderer->ResetUIClipRect();
   }
   if ( !areWeLoadingTexture )
   {
--- a/GUI/UI/UIShops.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/GUI/UI/UIShops.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -88,7 +88,7 @@
       {
         if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID)
         {
-          pRenderer->DrawTextureTransparent((60 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_X, weapons_Ypos[i] + 30, ItemsInShopTexture[i]);
+          pRenderer->DrawTextureIndexedAlpha((60 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_X, weapons_Ypos[i] + 30, ItemsInShopTexture[i]);
           ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[(60 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_X + window->GetWidth() * (weapons_Ypos[i] + 30)], ItemsInShopTexture[i], i + 1);
         }
         item_X += 70;
@@ -139,7 +139,7 @@
       {
         if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID)
         {
-          pRenderer->DrawTextureTransparent((60 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_X, weapons_Ypos[i] + 30, ItemsInShopTexture[i]);
+          pRenderer->DrawTextureIndexedAlpha((60 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_X, weapons_Ypos[i] + 30, ItemsInShopTexture[i]);
           ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[(60 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_X + window->GetWidth() * (weapons_Ypos[i] + 30)], ItemsInShopTexture[i], i + 1);
         }
         item_X += 70;
@@ -416,12 +416,12 @@
         {
           if ( i >= 4 )  //low row
           {
-            pRenderer->DrawTextureTransparent((90 - (ItemsInShopTexture[i]->uTextureWidth / 2)) + item_x - 420, 126, ItemsInShopTexture[i]);
+            pRenderer->DrawTextureIndexedAlpha((90 - (ItemsInShopTexture[i]->uTextureWidth / 2)) + item_x - 420, 126, ItemsInShopTexture[i]);
             v59 = (90 - (ItemsInShopTexture[i]->uTextureWidth / 2)) + item_x + 80220;
           }
           else
           {
-            pRenderer->DrawTextureTransparent(( 86 - (ItemsInShopTexture[i]->uTextureWidth / 2)) + item_x, 98 -  ItemsInShopTexture[i]->uTextureHeight, ItemsInShopTexture[i]);
+            pRenderer->DrawTextureIndexedAlpha(( 86 - (ItemsInShopTexture[i]->uTextureWidth / 2)) + item_x, 98 -  ItemsInShopTexture[i]->uTextureHeight, ItemsInShopTexture[i]);
             v59 = item_x + (86 - (ItemsInShopTexture[i]->uTextureWidth / 2)) + window->GetWidth() * (98 -  ItemsInShopTexture[i]->uTextureHeight);
           }
           ZBuffer_DoFill(&pRenderer->pActiveZBuffer[v59], ItemsInShopTexture[i], i + 1);
@@ -475,12 +475,12 @@
         {
           if ( i >= 4 )
           {
-            pRenderer->DrawTextureTransparent(item_x + (90 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) - 420, 126, ItemsInShopTexture[i]);
+            pRenderer->DrawTextureIndexedAlpha(item_x + (90 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) - 420, 126, ItemsInShopTexture[i]);
             v59 = item_x + (90 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + 80220;
           }
           else
           {
-            pRenderer->DrawTextureTransparent(86 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2) + item_x, 98 - ItemsInShopTexture[i]->uTextureHeight, ItemsInShopTexture[i]);
+            pRenderer->DrawTextureIndexedAlpha(86 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2) + item_x, 98 - ItemsInShopTexture[i]->uTextureHeight, ItemsInShopTexture[i]);
             v59 = (86 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_x + window->GetWidth() * (98 - ItemsInShopTexture[i]->uTextureHeight);
           }
           ZBuffer_DoFill(&pRenderer->pActiveZBuffer[v59], ItemsInShopTexture[i], i + 1);
@@ -774,7 +774,7 @@
           }
           else if ( (signed int)product_width_1row < 18 )
             product_width_1row = 18;
-          pRenderer->DrawTextureTransparent(product_width_1row, product_height_1row, ItemsInShopTexture[i]);
+          pRenderer->DrawTextureIndexedAlpha(product_width_1row, product_height_1row, ItemsInShopTexture[i]);
           ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_1row + window->GetWidth() * product_height_1row], ItemsInShopTexture[i], i + 1);
         }
       }
@@ -799,7 +799,7 @@
             if ( (signed int)product_width_2row < 18 )
               product_width_2row = 18;
           }
-          pRenderer->DrawTextureTransparent(product_width_2row, product_height_2row, ItemsInShopTexture[i + 6]);
+          pRenderer->DrawTextureIndexedAlpha(product_width_2row, product_height_2row, ItemsInShopTexture[i + 6]);
           ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_2row + window->GetWidth() * product_height_2row], ItemsInShopTexture[i + 6], i + 7);
         }
       }
@@ -862,7 +862,7 @@
             if ( (signed int)product_width_1row < 18 )
               product_width_1row = 18;
           }
-          pRenderer->DrawTextureTransparent(product_width_1row, product_height_1row, ItemsInShopTexture[i]);
+          pRenderer->DrawTextureIndexedAlpha(product_width_1row, product_height_1row, ItemsInShopTexture[i]);
           ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_1row + window->GetWidth() * product_height_1row], ItemsInShopTexture[i], i + 1);
         }
       }
@@ -887,7 +887,7 @@
             if ( (signed int)product_width_2row < 18 )
               product_width_2row = 18;
           }
-          pRenderer->DrawTextureTransparent(product_width_2row, product_height_2row, ItemsInShopTexture[i + 6]);
+          pRenderer->DrawTextureIndexedAlpha(product_width_2row, product_height_2row, ItemsInShopTexture[i + 6]);
           ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_2row + window->GetWidth() * product_height_2row], ItemsInShopTexture[i + 6], i + 7);
         }
       }
@@ -1151,7 +1151,7 @@
           if ( (signed int)product_width_1row < 18 )
             product_width_1row = 18;
         }
-        pRenderer->DrawTextureTransparent(product_width_1row, product_height_1row, ItemsInShopTexture[i]);
+        pRenderer->DrawTextureIndexedAlpha(product_width_1row, product_height_1row, ItemsInShopTexture[i]);
         ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_1row + window->GetWidth() * product_height_1row], ItemsInShopTexture[i], i + 1);
       }
     }
@@ -1174,7 +1174,7 @@
           if ( (signed int)product_width_2row < 18 )
             product_width_2row = 18;
         }
-        pRenderer->DrawTextureTransparent(product_width_2row, product_height_2row, ItemsInShopTexture[i + 6]);
+        pRenderer->DrawTextureIndexedAlpha(product_width_2row, product_height_2row, ItemsInShopTexture[i + 6]);
         ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_2row + window->GetWidth() * product_height_2row], ItemsInShopTexture[i + 6], i + 7);
       }
     }
@@ -1237,7 +1237,7 @@
           if ( (signed int)product_width_1row < 18 )
             product_width_1row = 18;
         }
-        pRenderer->DrawTextureTransparent(product_width_1row, product_height_1row, ItemsInShopTexture[i]);
+        pRenderer->DrawTextureIndexedAlpha(product_width_1row, product_height_1row, ItemsInShopTexture[i]);
         ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_1row + window->GetWidth() * product_height_1row], ItemsInShopTexture[i], i + 1);
       }
     }
@@ -1262,7 +1262,7 @@
           if ( (signed int)product_width_2row < 18 )
             product_width_2row = 18;
         }
-        pRenderer->DrawTextureTransparent(product_width_2row, product_height_2row, ItemsInShopTexture[i + 6]);
+        pRenderer->DrawTextureIndexedAlpha(product_width_2row, product_height_2row, ItemsInShopTexture[i + 6]);
         ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[product_width_2row + window->GetWidth() * product_height_2row], ItemsInShopTexture[i + 6], i + 7);
       }
     }
--- a/GUI/UI/UITransition.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/GUI/UI/UITransition.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -137,7 +137,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->DrawTextureTransparent(468, 0, &pIcons_LOD->pTextures[uTextureID_right_panel_loop]);
+  pRenderer->DrawTextureIndexedAlpha(468, 0, &pIcons_LOD->pTextures[uTextureID_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));
@@ -177,7 +177,7 @@
   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->DrawTextureTransparent(468, 0, pIcons_LOD->GetTexture(uTextureID_right_panel));
+  pRenderer->DrawTextureIndexedAlpha(468, 0, pIcons_LOD->GetTexture(uTextureID_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	Thu Oct 09 23:33:36 2014 +0300
+++ b/GUI/UI/UiGame.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -382,7 +382,7 @@
   window.uFrameWidth -= 10;
   window.uFrameZ -= 10;
   pRenderer->DrawTextureIndexed(477, 0, pTexture_Dialogue_Background);
-  pRenderer->DrawTextureTransparent(468, 0, (Texture *)(uTextureID_right_panel_loop != -1 ? &pIcons_LOD->pTextures[uTextureID_right_panel_loop] : 0));
+  pRenderer->DrawTextureIndexedAlpha(468, 0, (Texture *)(uTextureID_right_panel_loop != -1 ? &pIcons_LOD->pTextures[uTextureID_right_panel_loop] : 0));
   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]);
 
@@ -799,7 +799,7 @@
       v13 = pTextures_PlayerFaces[(unsigned int)window->ptr_1C][v15->uTextureID - 1];
   }
 
-  pRenderer->DrawTextureTransparent(window->uFrameX + 24, window->uFrameY + 24, v13);
+  pRenderer->DrawTextureIndexedAlpha(window->uFrameX + 24, window->uFrameY + 24, v13);
 
   sprintfex(pTmpBuf.data(), "\f%05d", ui_character_header_text_color);
   sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[429], player->pName, pClassNames[player->classType]); // "%s the %s"
@@ -976,9 +976,9 @@
     byte_50697C = !byte_50697C;
     if ( byte_50697C && pCurrentScreen != SCREEN_REST )
     {
-      if (bFlashQuestBook)     pRenderer->DrawTextureTransparent(493, 355, pIcons_LOD->GetTexture(uTextureID_ib_td1_A));
-      if (bFlashAutonotesBook) pRenderer->DrawTextureTransparent(527, 353, pIcons_LOD->GetTexture(uTextureID_ib_td2_A));
-      if (bFlashHistoryBook)   pRenderer->DrawTextureTransparent(600, 361, pIcons_LOD->GetTexture(uTextureID_ib_td5_A));
+      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));
+      if (bFlashHistoryBook)   pRenderer->DrawTextureIndexedAlpha(600, 361, pIcons_LOD->GetTexture(uTextureID_ib_td5_A));
     }
     else
     {
@@ -1032,10 +1032,10 @@
         pTextureHealth = pIcons_LOD->GetTexture(uTextureID_BarRed);
       if( v3 > 0.0 )
       {
-        pRenderer->SetTextureClipRect(v17 + pHealthBarPos[i], (signed __int64)((1.0 - v3) * pTextureHealth->uTextureHeight) + 402,
+        pRenderer->SetUIClipRect(v17 + pHealthBarPos[i], (signed __int64)((1.0 - v3) * pTextureHealth->uTextureHeight) + 402,
                                           v17 + pHealthBarPos[i] + pTextureHealth->uTextureWidth, pTextureHealth->uTextureHeight + 402);
         pRenderer->DrawTextureIndexed(v17 + pHealthBarPos[i], 402, pTextureHealth);
-        pRenderer->ResetTextureClipRect();
+        pRenderer->ResetUIClipRect();
       }
     }
     if (pParty->pPlayers[i].sMana > 0)
@@ -1046,10 +1046,10 @@
       int v17 = 0;
       if (i == 2)
         v17 = 1;
-      pRenderer->SetTextureClipRect(v17 + pManaBarPos[i], (signed __int64)((1.0 - v7) * pTextureMana->uTextureHeight) + 402,
+      pRenderer->SetUIClipRect(v17 + pManaBarPos[i], (signed __int64)((1.0 - v7) * pTextureMana->uTextureHeight) + 402,
                                     v17 + pManaBarPos[i] + pTextureMana->uTextureWidth, pTextureMana->uTextureHeight + 402);
       pRenderer->DrawTextureIndexed(v17 + pManaBarPos[i], 402, pTextureMana);
-      pRenderer->ResetTextureClipRect();
+      pRenderer->ResetUIClipRect();
     }
   }
 }
@@ -1057,7 +1057,7 @@
 //----- (0041B3B6) --------------------------------------------------------
 void GameUI_DrawRightPanel()
 {
-  pRenderer->DrawTextureTransparent(pViewport->uViewportBR_X, 0, pIcons_LOD->GetTexture(uTextureID_right_panel));
+  pRenderer->DrawTextureIndexedAlpha(pViewport->uViewportBR_X, 0, pIcons_LOD->GetTexture(uTextureID_right_panel));
 }
 
 //----- (0041B3E2) --------------------------------------------------------
@@ -1514,7 +1514,7 @@
 void GameUI_DrawCharacterSelectionFrame()
 {
   if ( uActiveCharacter )
-    pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[uActiveCharacter - 1] - 9, 380,
+    pRenderer->DrawTextureIndexedAlpha(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[uActiveCharacter - 1] - 9, 380,
                                       pIcons_LOD->GetTexture(uTextureID_GameUI_CharSelectionFrame));
 }
 
@@ -1552,7 +1552,7 @@
       //if ( pRenderer->pRenderD3D )
         pRenderer->DrawTextureIndexed(8, 8, spell_texture);
       /*else
-        pRenderer->DrawTextureTransparent(8, 8, v7);*/
+        pRenderer->DrawTextureIndexedAlpha(8, 8, v7);*/
     }
     if ( pParty->WaterWalkActive() )
     {
@@ -1563,7 +1563,7 @@
       //if ( pRenderer->pRenderD3D )
         pRenderer->DrawTextureIndexed(396, 8, spell_texture);
       /*else
-        pRenderer->DrawTextureTransparent(396, 8, v9);*/
+        pRenderer->DrawTextureIndexedAlpha(396, 8, v9);*/
     }
   }
   for (uint i = 0; i < 4; ++i)
@@ -1607,7 +1607,7 @@
       if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime )
         pRenderer->DrawTranslucent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i], 388, pPortrait);
       else
-        pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 1, 388, pPortrait);
+        pRenderer->DrawTextureIndexedAlpha(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 1, 388, pPortrait);
       if ( pPlayer->pPlayerBuffs[PLAYER_BUFF_BLESS].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_HASTE].uExpireTime
          | pPlayer->pPlayerBuffs[PLAYER_BUFF_HEROISM].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_SHIELD].uExpireTime
          | pPlayer->pPlayerBuffs[PLAYER_BUFF_STONESKIN].uExpireTime )
@@ -1620,7 +1620,7 @@
       if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime )
         pRenderer->DrawTranslucent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i], 388, pPortrait);
       else
-        pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 1, 388, pPortrait);
+        pRenderer->DrawTextureIndexedAlpha(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 1, 388, pPortrait);
       if ( pPlayer->pPlayerBuffs[PLAYER_BUFF_BLESS].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_HASTE].uExpireTime
          | pPlayer->pPlayerBuffs[PLAYER_BUFF_HEROISM].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_SHIELD].uExpireTime
          | pPlayer->pPlayerBuffs[PLAYER_BUFF_STONESKIN].uExpireTime )
@@ -1647,7 +1647,7 @@
       if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime )
         pRenderer->DrawTranslucent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i], 388, pPortrait);
       else
-        pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 1, 388, pPortrait);
+        pRenderer->DrawTextureIndexedAlpha(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 1, 388, pPortrait);
       if ( pPlayer->pPlayerBuffs[PLAYER_BUFF_BLESS].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_HASTE].uExpireTime
          | pPlayer->pPlayerBuffs[PLAYER_BUFF_HEROISM].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_SHIELD].uExpireTime
          | pPlayer->pPlayerBuffs[PLAYER_BUFF_STONESKIN].uExpireTime )
@@ -1675,7 +1675,7 @@
               if ( pParty->uFlags & 0x20 )
                 pTextureID = dword_5079C8;
             }
-            pRenderer->DrawTextureTransparent(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, pIcons_LOD->GetTexture(pTextureID));
           }
         }
       }
@@ -1695,7 +1695,7 @@
           if ( pParty->uFlags & 0x20 )
             pTextureID = dword_5079C8;
         }
-        pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] - 4, 385, pIcons_LOD->GetTexture(pTextureID));
+        pRenderer->DrawTextureIndexedAlpha(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] - 4, 385, pIcons_LOD->GetTexture(pTextureID));
       }
     }
   }
@@ -1925,7 +1925,7 @@
     arrow_idx = 0;
   if ( (signed int)rotate < 128 || (signed int)rotate > 1920 )
     arrow_idx = 7;
-  pRenderer->DrawTextureTransparent(uCenterX - 3, uCenterY - 3, pIcons_LOD->GetTexture(pTextureIDs_pMapDirs[arrow_idx]));//стрелка
+  pRenderer->DrawTextureIndexedAlpha(uCenterX - 3, uCenterY - 3, pIcons_LOD->GetTexture(pTextureIDs_pMapDirs[arrow_idx]));//стрелка
 
   //draw objects on the minimap
   if ( bWizardEyeActive )
@@ -2014,10 +2014,10 @@
       }
     }
   }
-  pRenderer->DrawTextureTransparent(468, 0, pIcons_LOD->GetTexture(uTextureID_Minimap_Loop));//draw minimap_loop
-  pRenderer->SetTextureClipRect(541, 0, 567, 480);
+  pRenderer->DrawTextureIndexedAlpha(468, 0, pIcons_LOD->GetTexture(uTextureID_Minimap_Loop));//draw 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->ResetTextureClipRect();
+  pRenderer->ResetUIClipRect();
 }
 
 //----- (00441498) --------------------------------------------------------
@@ -2038,12 +2038,12 @@
     if (pParty->TorchlightActive())
     {
       IconFrame* icon = pIconsFrameTable->GetFrame((signed __int16)pUIAnum_Torchlight->uIconID, pEventTimer->Time());
-      pRenderer->DrawTextureTransparent(pUIAnum_Torchlight->x, pUIAnum_Torchlight->y, pIcons_LOD->GetTexture(icon->uTextureID));
+      pRenderer->DrawTextureIndexedAlpha(pUIAnum_Torchlight->x, pUIAnum_Torchlight->y, pIcons_LOD->GetTexture(icon->uTextureID));
     }
     if (pParty->WizardEyeActive())
     {
       IconFrame* icon = pIconsFrameTable->GetFrame((signed __int16)pUIAnim_WizardEye->uIconID, pEventTimer->Time());
-      pRenderer->DrawTextureTransparent(pUIAnim_WizardEye->x, pUIAnim_WizardEye->y, pIcons_LOD->GetTexture(icon->uTextureID));
+      pRenderer->DrawTextureIndexedAlpha(pUIAnim_WizardEye->x, pUIAnim_WizardEye->y, pIcons_LOD->GetTexture(icon->uTextureID));
     }
   }
 }
@@ -2105,7 +2105,7 @@
                 break;
             }
           }
-          pRenderer->DrawTextureTransparent(pHiredNPCsIconsOffsetsX[pNPC_limit_ID], pHiredNPCsIconsOffsetsY[pNPC_limit_ID],
+          pRenderer->DrawTextureIndexedAlpha(pHiredNPCsIconsOffsetsX[pNPC_limit_ID], pHiredNPCsIconsOffsetsY[pNPC_limit_ID],
                         &pIcons_LOD->pTextures[pIconsFrameTable->GetFrame(v13, uFrameID)->uTextureID]);
         }
       }
--- a/IO/Mouse.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/IO/Mouse.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -410,7 +410,7 @@
       else if (!pParty->pPickedItem.IsIdentified())
         pRenderer->DrawTransparentGreenShade(pMouse->uMouseClickX, pMouse->uMouseClickY, pTexture);
       else
-        pRenderer->DrawTextureTransparent(pMouse->uMouseClickX, pMouse->uMouseClickY, pTexture);
+        pRenderer->DrawTextureIndexedAlpha(pMouse->uMouseClickX, pMouse->uMouseClickY, pTexture);
     }
   }
   else
--- a/Media/MediaPlayer.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/Media/MediaPlayer.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -274,7 +274,10 @@
 static bool av_open_video_stream(AVFormatContext *format_ctx, AVVideoStream *out_stream)
 {
   if (!av_open_stream(format_ctx, AVMEDIA_TYPE_VIDEO, out_stream))
-    return Error("Video stream not found"), false;
+  {
+    Error("Video stream not found");
+    false;
+  }
 
   out_stream->frames_per_second = (double)out_stream->dec_ctx->time_base.den / (double)out_stream->dec_ctx->time_base.num;
   return true;
--- a/stru6.cpp	Thu Oct 09 23:33:36 2014 +0300
+++ b/stru6.cpp	Fri Oct 10 17:42:05 2014 +0300
@@ -1533,7 +1533,7 @@
     }
 
     IconFrame* icon = pIconsFrameTable->GetFrame(buff->uSpellIconID, buff->uSpellAnimTimeElapsed);
-    pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i], 385, pIcons_LOD->GetTexture(icon->uTextureID));
+    pRenderer->DrawTextureIndexedAlpha(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i], 385, pIcons_LOD->GetTexture(icon->uTextureID));
 
     pOtherOverlayList->bRedraw = true;
   }