changeset 2069:259df09dfb50

32bits almost there
author Nomad
date Tue, 03 Dec 2013 20:18:17 +0200
parents b2a434d65344
children 4231fdf46dde
files Arcomage.cpp GUIFont.cpp GUIWindow.cpp Game.cpp Indoor.cpp Indoor.h Indoor_stuff.h LOD.cpp Mouse.cpp OSWindow.cpp ParticleEngine.cpp Party.h Render.cpp Render.h SaveLoad.cpp Texture.cpp UI/Books/UIMapBook.cpp UI/UICharacter.cpp UI/UIGuilds.cpp UI/UIHouses.cpp UI/UIMainMenu.cpp UI/UIOptions.cpp UI/UIPartyCreation.cpp UI/UIPopup.cpp UI/UIRest.cpp UI/UISaveLoad.cpp UI/UIShops.cpp UI/UiGame.cpp VideoPlayer.cpp Viewport.cpp Weather.cpp _deleted.cpp mm7_2.cpp mm7_4.cpp mm7_5.cpp mm7_data.cpp mm7_data.h
diffstat 37 files changed, 1579 insertions(+), 1227 deletions(-) [+]
line wrap: on
line diff
--- a/Arcomage.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/Arcomage.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -70,7 +70,7 @@
 //----- (0040DEDB) --------------------------------------------------------
 unsigned int R8G8B8_to_TargetFormat(int uColor)
 {
-  return TargetColor(LOBYTE(uColor), BYTE1(uColor), BYTE2(uColor));
+  return Color16(LOBYTE(uColor), BYTE1(uColor), BYTE2(uColor));
 }
 
 /*  388 */
@@ -624,7 +624,7 @@
 {
 
 unsigned __int16 *pSrc; // eax@2
-unsigned __int16 *dest_surf_pos; // edi@3
+//unsigned __int16 *dest_surf_pos; // edi@3
 int uSrcTotalWidth; // ecx@4
 unsigned int v10; // esi@9
 int v21; // [sp+Ch] [bp-18h]@8
@@ -639,7 +639,7 @@
 if ( !pArcomageGame->pBlit_Copy_pixels )
     return;
 
-dest_surf_pos = &pRenderer->pTargetSurface[pTargetPoint->x + pTargetPoint->y * pRenderer->uTargetSurfacePitch];
+//dest_surf_pos = &pRenderer->pTargetSurface[pTargetPoint->x + pTargetPoint->y * pRenderer->uTargetSurfacePitch];
 src_width = pSrcRect->right - pSrcRect->left;
 src_height = pSrcRect->bottom - pSrcRect->top;
 
@@ -671,12 +671,13 @@
             for (int j=0; j< src_width; ++j)
                 {
                 if ( *src_surf_pos != v10 )
-                    *dest_surf_pos = *src_surf_pos;
-                ++dest_surf_pos;
+                  pRenderer->WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, *src_surf_pos);
+                    //*dest_surf_pos = *src_surf_pos;
+                //++dest_surf_pos;
                 ++src_surf_pos;
                 }
             src_surf_pos+=uSrcPitch;
-            dest_surf_pos += pRenderer->uTargetSurfacePitch - src_width;
+            //dest_surf_pos += pRenderer->uTargetSurfacePitch - src_width;
             }
     }
 else 
@@ -687,12 +688,13 @@
         for (int j=0; j< src_width; ++j)
             {
             if ( *src_surf_pos != v10 )
-                *dest_surf_pos = (v21 & (*dest_surf_pos >> 1)) + (v21 & (*src_surf_pos >> 1));
-            ++dest_surf_pos;
+              pRenderer->WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, (v21 & (pRenderer->ReadPixel16(pTargetPoint->x + j, pTargetPoint->y + i) >> 1)) + (v21 & (*src_surf_pos >> 1)));
+                //*dest_surf_pos = (v21 & (*dest_surf_pos >> 1)) + (v21 & (*src_surf_pos >> 1));
+            //++dest_surf_pos;
             ++src_surf_pos;
             }
         src_surf_pos+=uSrcPitch;
-        dest_surf_pos += pRenderer->uTargetSurfacePitch - src_width;
+        //dest_surf_pos += pRenderer->uTargetSurfacePitch - src_width;
         }
     }
 
@@ -703,7 +705,7 @@
     {
 
     unsigned __int16 *pSrc; // eax@2
-    unsigned __int16 *dest_surf_pos; // edi@3
+    //unsigned __int16 *dest_surf_pos; // edi@3
     int uSrcTotalWidth; // ecx@4
     int v21; // [sp+Ch] [bp-18h]@8
     unsigned __int16 *src_surf_pos; // [sp+10h] [bp-14h]@9
@@ -716,7 +718,7 @@
     if ( !pArcomageGame->pBlit_Copy_pixels )
         return;
 
-    dest_surf_pos = &pRenderer->pTargetSurface[pTargetPoint->x + pTargetPoint->y * pRenderer->uTargetSurfacePitch];
+    //dest_surf_pos = &pRenderer->pTargetSurface[pTargetPoint->x + pTargetPoint->y * pRenderer->uTargetSurfacePitch];
     src_width = pSrcRect->right - pSrcRect->left;
     src_height = pSrcRect->bottom - pSrcRect->top;
 
@@ -744,13 +746,14 @@
         for (int i=0; i< src_height; ++i)
             {
             for (int j=0; j< src_width; ++j)
-                {    
-                *dest_surf_pos = *src_surf_pos;
-                ++dest_surf_pos;
+                { 
+                  pRenderer->WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, *src_surf_pos);
+                //*dest_surf_pos = *src_surf_pos;
+                //++dest_surf_pos;
                 ++src_surf_pos;
                 }
             src_surf_pos+=uSrcPitch;
-            dest_surf_pos += pRenderer->uTargetSurfacePitch - src_width;
+            //dest_surf_pos += pRenderer->uTargetSurfacePitch - src_width;
             }
         }
     else 
@@ -760,12 +763,13 @@
             {
             for (int j=0; j< src_width; ++j)
                 {
-                 *dest_surf_pos = (v21 & (*dest_surf_pos >> 1)) + (v21 & (*src_surf_pos >> 1));
-                ++dest_surf_pos;
+                 //*dest_surf_pos = (v21 & (*dest_surf_pos >> 1)) + (v21 & (*src_surf_pos >> 1));
+                //++dest_surf_pos;
+                  pRenderer->WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, (v21 & (pRenderer->ReadPixel16(pTargetPoint->x + j, pTargetPoint->y + i) >> 1)) + (v21 & (*src_surf_pos >> 1)));
                 ++src_surf_pos;
                 }
             src_surf_pos+=uSrcPitch;
-            dest_surf_pos += pRenderer->uTargetSurfacePitch - src_width;
+            //dest_surf_pos += pRenderer->uTargetSurfacePitch - src_width;
             }
         }
 }
@@ -4085,11 +4089,15 @@
     }
 
 void DrawSquare( POINT *pTargetXY, unsigned __int16 uColor )
-    {
+{
     pRenderer->BeginScene();
     if ( pRenderer->uNumSceneBegins )
-        {
-        int xVal = pTargetXY->x;
+    {
+      pRenderer->WritePixel16(pTargetXY->x,     pTargetXY->y, uColor);
+      pRenderer->WritePixel16(pTargetXY->x + 1, pTargetXY->y, uColor);
+      pRenderer->WritePixel16(pTargetXY->x,     pTargetXY->y + 1, uColor);
+      pRenderer->WritePixel16(pTargetXY->x + 1, pTargetXY->y + 1, uColor);
+        /*int xVal = pTargetXY->x;
         int yVal = pTargetXY->y;
         if ( xVal >= 0 && xVal <= 639 && yVal >= 0 && yVal <= 479)
             {
@@ -4097,26 +4105,27 @@
             pRenderer->pTargetSurface[xVal+1 + pRenderer->uTargetSurfacePitch * yVal] = uColor;
             pRenderer->pTargetSurface[xVal + pRenderer->uTargetSurfacePitch * (yVal+1)] = uColor;
             pRenderer->pTargetSurface[xVal+1 + pRenderer->uTargetSurfacePitch * (yVal+1)] = uColor;
-            }
+            }*/
         pRenderer->EndScene();
         }
-    }
+}
 
 //----- (0040DBD3) --------------------------------------------------------
 void DrawPixel( POINT *pTargetXY, unsigned __int16 uColor )
-    {
+{
     pRenderer->BeginScene();
     if ( pRenderer->uNumSceneBegins )
         {
-        int xVal = pTargetXY->x;
+          pRenderer->WritePixel16(pTargetXY->x, pTargetXY->y, uColor);
+        /*int xVal = pTargetXY->x;
         int yVal = pTargetXY->y;
         if ( xVal >= 0 && xVal <= 639 && yVal >= 0 && yVal <= 479)
             {
             pRenderer->pTargetSurface[xVal + pRenderer->uTargetSurfacePitch * yVal] = uColor;
-            }
+            }*/
         pRenderer->EndScene();
         }
-    }
+}
 
 
 //----- (0040DDB1) --------------------------------------------------------
--- a/GUIFont.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/GUIFont.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -646,11 +646,11 @@
 //----- (00414162) --------------------------------------------------------
 void uGameUIFontMain_initialize()
 {
-  uGameUIFontMain = TargetColor(0xAu, 0, 0);
+  uGameUIFontMain = Color16(0xAu, 0, 0);
 }
 
 //----- (00414174) --------------------------------------------------------
 void uGameUIFontShadow_initialize()
 {
-  uGameUIFontShadow = TargetColor(0xE6u, 214u, 193u);
+  uGameUIFontShadow = Color16(0xE6u, 214u, 193u);
 }
\ No newline at end of file
--- a/GUIWindow.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/GUIWindow.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -229,7 +229,7 @@
     {
       remaing_time = pParty->pPartyBuffs[i].uExpireTime- pParty->uTimePlayed;//!!!
       Y_pos = string_count * pFontComic->uFontHeight + 40; 
-      text_color = TargetColor(spell_tooltip_colors[i].R, spell_tooltip_colors[i].G, spell_tooltip_colors[i].B);
+      text_color = Color16(spell_tooltip_colors[i].R, spell_tooltip_colors[i].G, spell_tooltip_colors[i].B);
       DrawText(pFontComic, 52, Y_pos, text_color, aSpellNames[i], 0, 0, 0);
       DrawBuff_remaining_time_string(Y_pos, this, remaing_time, pFontComic); 
       ++string_count;
@@ -871,8 +871,8 @@
   memcpy(&pWindow, this, sizeof(pWindow));
   pWindow.uFrameWidth -= 18;
   pWindow.uFrameZ -= 18;
-  pWhiteColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
-  pColor2 = TargetColor(0x15u, 0x99u, 0xE9u);
+  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]);
   if ( pDialogueNPCCount != uNumDialogueNPCPortraits || !uHouse_ExitPic )
@@ -1117,7 +1117,7 @@
     sprintfex(pTmpBuf2.data(), "%d %s ", (int)seconds, text);
     strcat(pTmpBuf.data(), pTmpBuf2.data());
   }
-  this->DrawTitleText(pFontArrus, 0, (212 - pFontArrus->CalcTextHeight(pTmpBuf.data(), this, 0, 0)) / 2 + 101, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
+  this->DrawTitleText(pFontArrus, 0, (212 - pFontArrus->CalcTextHeight(pTmpBuf.data(), this, 0, 0)) / 2 + 101, Color16(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
 }
 
 
@@ -1965,7 +1965,7 @@
       }
       case WINDOW_50:
       {
-        v27 = TargetColor(255, 255, 255);
+        v27 = Color16(255, 255, 255);
         if ( ptr_507BD0->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS)
         {
           ptr_507BD0->DrawMessageBox(0);
@@ -2332,7 +2332,7 @@
   a1.uFrameZ = a1.uFrameWidth + a1.uFrameX - 1;
   a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1;
   v1 = pItemsTable->pItems[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C + 700].pName;
-  v2 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
+  v2 = Color16(0xFFu, 0xFFu, 0x9Bu);
   sprintf(pTmpBuf.data(), format_4E2D80, v2, v1);
   a1.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf.data(), 3u);
   a1.DrawText(
@@ -2458,8 +2458,8 @@
       pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchC");
       pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID);
     }
-    uGameUIFontMain = TargetColor(0xC8u, 0, 0);
-    uGameUIFontShadow = TargetColor(10, 0, 0);
+    uGameUIFontMain = Color16(0xC8u, 0, 0);
+    uGameUIFontShadow = Color16(10, 0, 0);
   }
   else if (align == PartyAlignment_Neutral)
   {
@@ -2551,8 +2551,8 @@
       uTextureID_507698 = pIcons_LOD->LoadTexture("edge_top", TEXTURE_16BIT_PALETTE);
       pTexture_591428 = pIcons_LOD->LoadTexturePtr("endcap", TEXTURE_16BIT_PALETTE);
     }
-    uGameUIFontMain = TargetColor(0xAu, 0, 0);
-    uGameUIFontShadow = TargetColor(230, 214, 193);
+    uGameUIFontMain = Color16(0xAu, 0, 0);
+    uGameUIFontShadow = Color16(230, 214, 193);
   }
   else if (align == PartyAlignment_Good)
   {
@@ -2600,8 +2600,8 @@
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507698], "edge_top-b", 2);
       pIcons_LOD->ReloadTexture(pTexture_591428, "endcap-b", 2);
     }
-    uGameUIFontMain = TargetColor(0, 0, 0xC8u);
-    uGameUIFontShadow = TargetColor(255, 255, 255);
+    uGameUIFontMain = Color16(0, 0, 0xC8u);
+    uGameUIFontShadow = Color16(255, 255, 255);
   }
   else Error("Invalid alignment type: %u", align);
 }
--- a/Game.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/Game.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -227,17 +227,17 @@
     if (render_framerate)
     {
       sprintf(pTmpBuf.data(), "FPS: % .4f", framerate);
-      pPrimaryWindow->DrawText(pFontArrus, 494, 0, TargetColor(0, 0, 0), pTmpBuf.data(), 0, 0, 0);
+      pPrimaryWindow->DrawText(pFontArrus, 494, 0, Color16(0, 0, 0), pTmpBuf.data(), 0, 0, 0);
     }
 
     if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
     {
       int sector_id = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
       sprintf(pTmpBuf.data(), "Party Sector ID:        %u/%u\n", sector_id, pIndoor->uNumSectors);
-      pPrimaryWindow->DrawText(pFontArrus, 16, 16, TargetColor(255, 255, 255), pTmpBuf.data(), 0, 0, -1);
+      pPrimaryWindow->DrawText(pFontArrus, 16, 16, Color16(255, 255, 255), pTmpBuf.data(), 0, 0, -1);
     }
     sprintf(pTmpBuf.data(), "Party Position:         % d % d % d", pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
-    pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16, TargetColor(255, 255, 255), pTmpBuf.data(), 0, 0, -1);
+    pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16, Color16(255, 255, 255), pTmpBuf.data(), 0, 0, -1);
   
     if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
     {
@@ -252,7 +252,7 @@
       int floor_level = ODM_GetFloorLevel(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z, 0, &on_water, &_a6, false);
       sprintf(pTmpBuf.data(), "ODM_GetFloorLevel: %d   on_water: %s    a6 = %d\n", floor_level, on_water ? "true" : "false", _a6);
     }
-    pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16 + 16, TargetColor(255, 255, 255), pTmpBuf.data(), 0, 0, -1);
+    pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16 + 16, Color16(255, 255, 255), pTmpBuf.data(), 0, 0, -1);
   }
 
   GUI_UpdateWindows();
--- a/Indoor.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/Indoor.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -937,54 +937,6 @@
   }
 }
 
-//----- (004B0967) --------------------------------------------------------
-void BspRenderer::DrawFaceOutlines()
-{
-  signed int i; // edi@1
-  int v1; // esi@2
-  unsigned int v2; // ecx@4
-  int v3; // eax@4
-  int v4; // eax@6
-  unsigned __int16 *v5; // edx@6
-  int v6; // ecx@7
-  int v7; // esi@8
-
-  for ( i = 0; i < (signed int)pBspRenderer->num_faces; ++i )
-  {
-    v1 = pBspRenderer->faces[i].uFaceID;
-    if ( v1 >= 0 )
-    {
-      if ( v1 < (signed int)pIndoor->uNumFaces )
-      {
-        v2 = pBspRenderer->faces[i].uFaceID;
-        pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].PortalScreenData;
-        v3 = GetPortalScreenCoord(v2);
-        if ( v3 )
-        {
-          if ( PortalFrustrum(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1) )
-          {
-            v4 = stru_F8A590._viewport_space_y;
-            v5 = pBLVRenderParams->pRenderTarget;
-            if ( stru_F8A590._viewport_space_y <= stru_F8A590._viewport_space_w )
-            {
-              v6 = 640 * stru_F8A590._viewport_space_y;
-              do
-              {
-                v5[v6 + stru_F8A590.viewport_left_side[v4]] = -1;
-                v7 = v6 + stru_F8A590.viewport_right_side[v4];
-                v6 += 640;
-                v5[v7] = -1;
-                ++v4;
-              }
-              while ( v4 <= stru_F8A590._viewport_space_w );
-            }
-          }
-        }
-      }
-    }
-  }
-}
-
 
 //----- (004AE5BA) --------------------------------------------------------
 Texture *BLVFace::GetTexture()
--- a/Indoor.h	Mon Dec 02 15:13:49 2013 +0200
+++ b/Indoor.h	Tue Dec 03 20:18:17 2013 +0200
@@ -235,7 +235,7 @@
 #define FACE_TEXTURE_FRAME      0x00004000 // Texture ID is a frameset from TextureFrameTable, otherwise BitmapID
 #define FACE_OUTLINED           0x00010000 // outline face edges
 #define FACE_TEXTURE_FLOW       0x00040000 // The texture moves slowly. For horizontal facets only.
-#define FACE_INDOOR_SKY       0x00400000
+#define FACE_INDOOR_SKY         0x00400000
 #define FACE_CLICKABLE          0x02000000 // Event can be triggered by clicking on the facet.
 #define FACE_PRESSURE_PLATE     0x04000000 // Event can be triggered by stepping on the facet.
 #define FACE_ETHEREAL           0x20000000 // Untouchable. You can pass through it.
@@ -495,7 +495,7 @@
   float _unused_fSineNegX;   // the same
   int fov_rad_fixpoint;
   int fov_rad_inv_fixpoint;//float
-  unsigned __int16 *pRenderTarget;
+  void *pRenderTarget;
   unsigned int uTargetWidth;
   unsigned int uTargetHeight;
   unsigned int uViewportX;
--- a/Indoor_stuff.h	Mon Dec 02 15:13:49 2013 +0200
+++ b/Indoor_stuff.h	Tue Dec 03 20:18:17 2013 +0200
@@ -93,7 +93,7 @@
   void AddFaceToRenderList_sw(unsigned int node_id, unsigned int uFaceID);
   void AddFaceToRenderList_d3d(unsigned int node_id, unsigned int uFaceID);
   void MakeVisibleSectorList();
-  void DrawFaceOutlines();
+  //void DrawFaceOutlines();
 
   unsigned int num_faces;
   //__int16 pFaceIDs[2000];
--- a/LOD.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/LOD.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -484,7 +484,7 @@
   LODSprite_stru0 *v44; // ecx@66
   int v45; // edx@69
   int v46; // edx@77
-  unsigned __int16 *pTarget; // [sp+Ch] [bp-50h]@2
+  //unsigned __int16 *pTarget; // [sp+Ch] [bp-50h]@2
   signed int v48; // [sp+10h] [bp-4Ch]@2
   signed int v49; // [sp+14h] [bp-48h]@2
   int v50; // [sp+14h] [bp-48h]@19
@@ -545,7 +545,9 @@
   v70 = (this->uHeight << 16) - v8;
   v49 = v7;
   v69 = v3->uTargetPitch;
-  pTarget = v3->pTarget;
+
+  __debugbreak(); // target surface  will most likely be 32bit, but this sub awaits 16bits
+  auto pTarget = (unsigned __int16 *)v3->pTarget;
   v57 = v3->sZValue;
   v61 = v3->pPalette;
   v9 = (v6 * this->uWidth + 32768) >> 16;
@@ -839,7 +841,9 @@
   result = (int)a2;
   v14 = this;
   v4 = a2->uTargetPitch;
-  v16 = a2->pTarget;
+
+  __debugbreak(); // sub expects 16bit target surface, we may have 32bit
+  v16 = (unsigned short *)a2->pTarget;
   v15 = a2->pPalette;
   v5 = this->uHeight - 1;
   for ( i = v4 * a2->uScreenSpaceY - (this->uWidth >> 1) + a2->uScreenSpaceX + 1; v5 >= 0; --v5 )
--- a/Mouse.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/Mouse.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -332,7 +332,8 @@
   ushort* pSrc = pCursorBitmap3_sysmembits_16bit;
   for (uint y = field_44; y < field_4C; ++y)
     for (uint x = field_40; x < field_48; ++x)
-      pRenderer->pTargetSurface[y * pRenderer->uTargetSurfacePitch + x] = *pSrc++;
+      //pRenderer->pTargetSurface[y * pRenderer->uTargetSurfacePitch + x] = *pSrc++;
+        pRenderer->WritePixel16(x, y, *pSrc++);
 }
 
 //----- (00469EA4) --------------------------------------------------------
@@ -349,13 +350,13 @@
   int v9; // ebx@26
   unsigned int v10; // eax@26
   int v11; // edx@27
-  unsigned __int16 *v12; // edx@29
-  unsigned __int16 *v13; // ebx@29
+  //unsigned __int16 *v12; // edx@29
+  //unsigned __int16 *v13; // ebx@29
   unsigned int a2; // [sp+Ch] [bp-1Ch]@5
   unsigned int v15; // [sp+10h] [bp-18h]@5
-  unsigned int v16; // [sp+14h] [bp-14h]@25
-  unsigned __int16 *v17; // [sp+18h] [bp-10h]@25
-  int v18; // [sp+1Ch] [bp-Ch]@27
+  //unsigned int v16; // [sp+14h] [bp-14h]@25
+  //unsigned __int16 *v17; // [sp+18h] [bp-10h]@25
+  //int v18; // [sp+1Ch] [bp-Ch]@27
   int v19; // [sp+20h] [bp-8h]@15
   unsigned __int16 *v20; // [sp+20h] [bp-8h]@28
   int pTextureWidth; // [sp+24h] [bp-4h]@12
@@ -412,9 +413,21 @@
       }
       v8 = this->field_44;
       v22 = this->pCursorBitmap3_sysmembits_16bit;
-      v17 = pRenderer->pTargetSurface;
-      v16 = pRenderer->uTargetSurfacePitch;
-      if ( v8 < this->field_4C )
+      //v17 = pRenderer->pTargetSurface;
+      //v16 = pRenderer->uTargetSurfacePitch;
+      
+        v10 = pRenderer->uTargetSurfacePitch * v8;
+          v11 = this->field_40;
+      for (int y = this->field_44; y < this->field_4C; ++y)
+      {
+            //v20 = &v17[v10 + v11];
+        for (int x = this->field_40; x < this->field_48; ++x)
+        {
+              //++v18;
+              *v22++ = pRenderer->ReadPixel16(x, y);
+        }
+      }
+      /*if ( v8 < this->field_4C )
       {
         v9 = this->field_48;
         v10 = pRenderer->uTargetSurfacePitch * v8;
@@ -427,13 +440,10 @@
             v20 = &v17[v10 + v11];
             do
             {
-              v12 = v20;
-              v13 = v22;
+              //v12 = v20;
               ++v18;
-              ++v20;
-              ++v22;
-              *v13 = *v12;
-              v9 = this->field_48;
+              //++v20;
+              *v22++ = *v20++;
             }
             while ( v18 < v9 );
           }
@@ -442,7 +452,9 @@
         }
         while ( v8 < this->field_4C );
         v6 = v15;
-      }
+      }*/
+
+      v6 = v15;
       if (pParty->pPickedItem.IsBroken())
         pRenderer->DrawTransparentRedShade(a2, v6, pTexture);
       else if (!pParty->pPickedItem.IsIdentified())
--- a/OSWindow.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/OSWindow.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -272,15 +272,15 @@
         if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE)
         {
           dword_4E98BC_bApplicationActive = 1;
-          if ( pRenderer->bWindowMode )
+          /*if ( pRenderer->bWindowMode )
           {
             HDC hDC = GetDC(api_handle);
             int bitsPerPixel = GetDeviceCaps(hDC, BITSPIXEL);
             int planes = GetDeviceCaps(hDC, PLANES);
             ReleaseDC(api_handle, hDC);
             if (bitsPerPixel != 16 || planes != 1)
-              Error(pGlobalTXT_LocalizationStrings[62]);
-          }
+              Error(L"%S", pGlobalTXT_LocalizationStrings[62]);
+          }*/
           dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_APP_INACTIVE;
 
           if ( pArcomageGame->bGameInProgress )
@@ -402,7 +402,9 @@
     return false;
 
   api_handle = CreateWindowExW(0, wcxw.lpszClassName, title, 0,
-                               0, 0, window_width, window_height, nullptr,
+                               ReadWindowsRegistryInt("window X", (GetSystemMetrics(SM_CXSCREEN) - window_width) / 2),
+                               ReadWindowsRegistryInt("window Y", (GetSystemMetrics(SM_CYSCREEN) - window_height) / 2),
+                               window_width, window_height, nullptr,
                                nullptr, wcxw.hInstance, this);
   if (!api_handle)
   {
@@ -499,6 +501,9 @@
 
 void OSWindow::SetWindowedMode(int new_window_width, int new_window_height)
 {
+  RECT rcWindowPos;
+  GetWindowRect(api_handle, &rcWindowPos);
+
   SetWindowLongW(api_handle, GWL_EXSTYLE, 0);
   SetWindowLongW(api_handle, GWL_STYLE,   WS_VISIBLE | WS_OVERLAPPEDWINDOW);
   SetWindowPos(api_handle, HWND_TOP, 0, 0, -1, -1, 0);
@@ -518,13 +523,16 @@
     if (!GetMenu(api_handle))
       window_total_height += GetSystemMetrics(SM_CYMENU);
   #endif
-  MoveWindow(api_handle, ReadWindowsRegistryInt("window X", (GetSystemMetrics(SM_CXSCREEN) - window_total_width) / 2),
-                         ReadWindowsRegistryInt("window Y", (GetSystemMetrics(SM_CYSCREEN) - window_total_height) / 2),
+  MoveWindow(api_handle, rcWindowPos.left,
+                         rcWindowPos.top,
                          window_total_width,
                          window_total_height, 0);
   #ifdef _DEBUG
     static HMENU debug_menu = CreateDebugMenuPanel();
     SetMenu(api_handle, debug_menu);
+    
+    GetWindowRect(api_handle, &rcWindow);
+    GetClientRect(api_handle, &rcClient);
   #endif
 }
 
--- a/ParticleEngine.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/ParticleEngine.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -649,8 +649,28 @@
         p->uScreenSpaceY >= pBLVRenderParams->uViewportY &&
         p->uScreenSpaceY < pBLVRenderParams->uViewportW)
     {
-      if (pRenderer->pRenderD3D)
+      if (!pRenderer->pRenderD3D)
       {
+        __debugbreak();
+                    /*v11 = 13 * p->_screenspace_scale >> 16;
+                     if ( v11 > 30 )
+                       v11 = 30;
+                    v12 = p->uScreenSpaceY - v11;
+                    v13 = p->uScreenSpaceX - (v11 >> 1);
+                     if ( v13 + v11 < (signed int)pViewport->uViewportTL_X
+                       || v13 >= (signed int)pViewport->uViewportBR_X
+                       || v12 + v11 < (signed int)pViewport->uViewportTL_Y
+                       || v12 >= (signed int)pViewport->uViewportBR_Y )
+                     {
+                      ;
+                     }
+                     else
+                     {
+                       pRenderer->MakeParticleBillboardAndPush_BLV_Software(v13, v12, p->sZValue, p->uLightColor_bgr, v11);
+                     }*/
+      }
+      //else
+
         if (p->type & ParticleType_Diffuse)
         {
           //v14 = &pParticles[i];
@@ -703,26 +723,6 @@
           v15.sZValue = p->sZValue;
           pRenderer->MakeParticleBillboardAndPush_BLV(&v15, pSprites_LOD->pHardwareSprites[p->uTextureID].pTexture, p->uLightColor_bgr, p->angle);
         }
-      }
-      else
-      {
-                    v11 = 13 * p->_screenspace_scale >> 16;
-                     if ( v11 > 30 )
-                       v11 = 30;
-                    v12 = p->uScreenSpaceY - v11;
-                    v13 = p->uScreenSpaceX - (v11 >> 1);
-                     if ( v13 + v11 < (signed int)pViewport->uViewportTL_X
-                       || v13 >= (signed int)pViewport->uViewportBR_X
-                       || v12 + v11 < (signed int)pViewport->uViewportTL_Y
-                       || v12 >= (signed int)pViewport->uViewportBR_Y )
-                     {
-                      ;
-                     }
-                     else
-                     {
-                       pRenderer->MakeParticleBillboardAndPush_BLV_Software(v13, v12, p->sZValue, p->uLightColor_bgr, v11);
-                     }
-      }
     }
   }
 }
@@ -759,8 +759,28 @@
     if (particle->type == ParticleType_Invalid || !ViewProject_TrueIfStillVisible_ODM(i))
       continue;
 
-        if ( pRenderer->pRenderD3D )
+        if ( !pRenderer->pRenderD3D )
         {
+          __debugbreak();
+          /*v10 = 13 * particle->_screenspace_scale >> 16;
+          if ( v10 > 30 )
+            v10 = 30;
+          v11 = particle->uScreenSpaceX - (v10 >> 1);
+          v12 = particle->uScreenSpaceY - v10;
+          if ( v11 + v10 < pViewport->uViewportTL_X
+            || v11 >= pViewport->uViewportBR_X
+            || particle->uScreenSpaceY < pViewport->uViewportTL_Y
+            || v12 >= (signed int)pViewport->uViewportBR_Y )
+          {
+            ;
+          }
+          else
+          {
+            pRenderer->MakeParticleBillboardAndPush_BLV_Software(v11, v12, particle->sZValue, particle->uLightColor_bgr, v10);
+          }*/
+        }
+        //else
+
           //v8 = *(_DWORD *)(v7 - 82);
           if (particle->type & ParticleType_Diffuse)
           {
@@ -813,26 +833,6 @@
             pBillboard.uScreenSpaceY = particle->uScreenSpaceY;
             pBillboard.sZValue = particle->sZValue;
             pRenderer->MakeParticleBillboardAndPush_ODM(&pBillboard, pSprites_LOD->pHardwareSprites[particle->uTextureID].pTexture, particle->uLightColor_bgr, particle->angle);
-          }
-        }
-        else
-        {
-          v10 = 13 * particle->_screenspace_scale >> 16;
-          if ( v10 > 30 )
-            v10 = 30;
-          v11 = particle->uScreenSpaceX - (v10 >> 1);
-          v12 = particle->uScreenSpaceY - v10;
-          if ( v11 + v10 < pViewport->uViewportTL_X
-            || v11 >= pViewport->uViewportBR_X
-            || particle->uScreenSpaceY < pViewport->uViewportTL_Y
-            || v12 >= (signed int)pViewport->uViewportBR_Y )
-          {
-            ;
-          }
-          else
-          {
-            pRenderer->MakeParticleBillboardAndPush_BLV_Software(v11, v12, particle->sZValue, particle->uLightColor_bgr, v10);
-          }
-        }      
+          }   
   }
 }
\ No newline at end of file
--- a/Party.h	Mon Dec 02 15:13:49 2013 +0200
+++ b/Party.h	Tue Dec 03 20:18:17 2013 +0200
@@ -50,6 +50,7 @@
 /*  355 */
 enum PARTY_FLAGS_1: __int32
 {
+  PARTY_FLAGS_1_0002 = 0x0002,
   PARTY_FLAGS_1_WATER_DAMAGE = 0x0004,
   PARTY_FLAGS_1_FALLING = 0x0008,
   PARTY_FLAGS_1_ALERT_RED = 0x0010,
--- a/Render.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/Render.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -87,7 +87,7 @@
 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut); // idb
 
 //----- (0049E79F) --------------------------------------------------------
-bool  CheckTextureStages()
+bool CheckTextureStages()
 {
   bool v0; // edi@1
   IDirectDrawSurface4 *pSurface2; // [sp+Ch] [bp-14h]@1
@@ -1206,7 +1206,7 @@
 {
   HRESULT v2; // esi@2
 
-  if ( Src->dwFlags & 0x400 | 0x2000 )
+  if ( Src->dwFlags & (0x400 | 0x2000))
   {
     v2 = 0;
     if ( Src->dwRGBBitCount == 16 && !Src->dwRBitMask )
@@ -1375,7 +1375,7 @@
 }
 
 //----- (0049DE14) --------------------------------------------------------
-bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, HWND hWnd)
+bool RenderD3D::CreateDevice(unsigned int uDeviceID, int bWindowed, OSWindow *window)
 {
   //IDirectDraw4 *v8; // eax@12
   //IDirectDraw4 *v9; // eax@16
@@ -1391,6 +1391,10 @@
   IDirectDrawClipper *v30; // [sp+C4h] [bp-14h]@18
   LPDIRECTDRAW lpDD; // [sp+C8h] [bp-10h]@1
 
+  auto hWnd = window->GetApiHandle();
+  int game_width = window->GetWidth();
+  int game_height = window->GetHeight();
+
   this->bWindowed = bWindowed;
   this->hWindow = hWnd;
 
@@ -1432,7 +1436,7 @@
     {
       ddsd2.dwSize = sizeof(DDSURFACEDESC2);
       pHost->GetDisplayMode(&ddsd2);
-      if ( ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 )
+      if ( FORCE_16_BITS && ddsd2.ddpfPixelFormat.dwRGBBitCount != 16 )
       {
         v24 = "Init - Desktop isn't in 16 bit mode.\n";
         goto LABEL_14;
@@ -1440,8 +1444,8 @@
 
       ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
       ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
-      ddsd2.dwWidth = 640;
-      ddsd2.dwHeight = 480;
+      ddsd2.dwWidth = game_width;
+      ddsd2.dwHeight = game_height;
       if (pHost->CreateSurface(&ddsd2, &pBackBuffer, 0) )
       {
         v24 = "Init - Failed to create back buffer.\n";
@@ -1469,8 +1473,8 @@
 
       ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
       ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
-      ddsd2.dwWidth = 640;
-      ddsd2.dwHeight = 480;
+      ddsd2.dwWidth = game_width;
+      ddsd2.dwHeight = game_height;
 
       if ( pDirect3D->EnumZBufferFormats(*pAvailableDevices[uDeviceID].pGUID,
              (HRESULT (__stdcall *)(DDPIXELFORMAT *, void *))D3DZBufferFormatEnumerator,
@@ -1610,8 +1614,8 @@
 LABEL_54:
   d3dvp2.dwSize = sizeof(D3DVIEWPORT2);
   //v17 = *hWnda;
-  d3dvp2.dwWidth = 640;
-  d3dvp2.dwHeight = 480;
+  d3dvp2.dwWidth = game_width;
+  d3dvp2.dwHeight = game_height;
   d3dvp2.dvClipX = -1.0;
   //v18 = v17->lpVtbl;
   //v32 = &v4->pViewport;
@@ -2106,14 +2110,14 @@
   v1->pRenderD3D = 0;
   v1->uNumSceneBegins = 0;
   v1->uNumD3DSceneBegins = 0;
-  v1->field_40110 = 0;
+  v1->using_software_screen_buffer = 0;
   v1->pTargetSurface = 0;
   v1->uTargetSurfacePitch = 0;
   v1->uClipY = 0;
   v1->uClipX = 0;
   v1->uClipW = 480;
   v1->bClip = 1;
-  v1->bColorKeySupported = 0;
+  //v1->bColorKeySupported = 0;
   v1->bRequiredTextureStagesAvailable = 0;
   v1->bTinting = 1;
   LOBYTE(v1->field_103668) = 0;
@@ -2127,12 +2131,12 @@
   sub_4A19B0();
 }
 
-bool Render::Initialize(bool bWindowed, OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting)
+bool Render::Initialize(OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting)
 {
   //bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0);
 
   this->window = window;
-  bStartInWindow = bWindowed;
+  //bStartInWindow = true;
   //windowed_mode_width = windowed_width;
   //windowed_mode_height = windowed_height;
 
@@ -2149,62 +2153,13 @@
   return r1 && r2;
 }
 
-//----- (0049EBF1) --------------------------------------------------------
-void Render::_49EBF1()
-{
-  signed int uNumRedBits; // edx@1
-  signed int uNuGreenBits; // edi@1
-  signed int uNumBlueBits; // esi@1
-  unsigned int v4; // edx@4
-  unsigned int v5; // edi@4
-  int v6; // ebx@4
-  int v7; // edx@4
-  signed int v8; // [sp+8h] [bp-24h]@1
-  signed int v9; // [sp+Ch] [bp-20h]@1
-  signed int v10; // [sp+20h] [bp-Ch]@1
-  signed int i; // [sp+24h] [bp-8h]@2
-  signed int v12; // [sp+28h] [bp-4h]@3
-
-  v10 = 0;
-  uNumRedBits = 1 << this->uTargetRBits;
-  uNuGreenBits = 1 << this->uTargetGBits;
-  uNumBlueBits = 1 << this->uTargetBBits;
-  v9 = 1 << this->uTargetRBits;
-  v8 = 1 << this->uTargetGBits;
-  if ( uNumRedBits > 0 )
-  {
-    do
-    {
-      for ( i = 0; i < uNuGreenBits; ++i )
-      {
-        v12 = 0;
-        if ( uNumBlueBits > 0 )
-        {
-          do
-          {
-            v4 = this->uTargetBBits;
-            v5 = v4 + this->uTargetGBits;
-            v6 = (v12 >> 1) + (v10 >> 1 << v5) + (i >> 1 << this->uTargetBBits);
-            v7 = (v10 << v5) + v12++ + (i << v4);
-            this->field_2C[v7] = v6;
-          }
-          while ( v12 < uNumBlueBits );
-          uNumRedBits = v9;
-          uNuGreenBits = v8;
-        }
-      }
-      ++v10;
-    }
-    while ( v10 < uNumRedBits );
-  }
-}
 
 //----- (0049ECC4) --------------------------------------------------------
 void Render::ClearBlack()
 {
   if (pRenderD3D)
   {
-    if (field_40110)
+    if (using_software_screen_buffer)
       pRenderD3D->ClearTarget(true, 0, false, 0.0);
   }
   else
@@ -2275,7 +2230,7 @@
 
   v1 = this;
   v2 = 0;
-  if ( !this->pRenderD3D || this->field_40110 )
+  if ( !this->pRenderD3D || this->using_software_screen_buffer )
   {
     sprintf(Filename, "screen%0.2i.pcx", dword_4EFA80++ % 100);
     File = fopen(Filename, "wb");
@@ -2420,7 +2375,7 @@
 // 4EFA80: using guessed type int dword_4EFA80;
 
 //----- (0049F1BC) --------------------------------------------------------
-void Render::_49F1BC(const char *a1)
+void Render::SaveWinnersCertificate(const char *a1)
 {
   Render *v2; // esi@1
   __int16 v3; // di@1
@@ -2470,7 +2425,7 @@
 
   v2 = this;
   v3 = 0;
-  if ( !this->pRenderD3D || this->field_40110 )
+  if ( !this->pRenderD3D || this->using_software_screen_buffer )
   {
     ++dword_4EFA84;
     File = fopen(a1, "wb");
@@ -2498,7 +2453,7 @@
       else
       {
         pRenderer->BeginScene();
-        v42 = pRenderer->pTargetSurface;
+        //v42 = pRenderer->pTargetSurface;
         v6 = pRenderer->uTargetSurfacePitch;
       }
       i = (char *)v6;
@@ -2909,7 +2864,7 @@
 {
   if (pRenderD3D)
   {
-    if (field_40110)
+    if (using_software_screen_buffer)
       pRenderD3D->ClearTarget(true, uColor, false, 0.0);
   }
   else
@@ -2932,12 +2887,12 @@
   struct tagPOINT Point; // [sp+28h] [bp-8h]@11
 
   v1 = this;
-  if ( !pRenderer->pRenderD3D || this->field_40110 )
+  if ( !pRenderer->pRenderD3D || this->using_software_screen_buffer )
   {
     this->pBeforePresentFunction();
     if ( v1->pRenderD3D )
     {
-      if ( v1->field_40110 )
+      if ( v1->using_software_screen_buffer )
       {
         pRenderD3D->Present(false);
       }
@@ -3031,7 +2986,7 @@
   v1 = this;
   if (pRenderD3D)
   {
-    if ( v1->field_40110 )
+    if ( v1->using_software_screen_buffer )
     {
       pRenderD3D->ClearTarget(true, 0, false, 1.0);
       pRenderD3D->Present(0);
@@ -3043,9 +2998,9 @@
     v1->pDirectDraw4 = 0;
     if (v1->pTargetSurface)
     {
-      free(v1->ptr_400E8);
+      delete [] v1->pTargetSurface_unaligned;
       v1->pTargetSurface = 0;
-      v1->ptr_400E8 = 0;
+      v1->pTargetSurface_unaligned = 0;
     }
     if (pRenderD3D)
     {
@@ -3155,11 +3110,11 @@
   int v13; // ecx@25
   int v14; // eax@27
   signed int v15; // ebx@31
-  bool v16; // eax@35
-  char v17; // zf@35
+  //bool v16; // eax@35
+  //char v17; // zf@35
   IDirectDraw4 *v18; // eax@38
   HRESULT v19; // eax@38
-  int *v20; // eax@39
+  //int *v20; // eax@39
   int *v22; // eax@42
   int v23; // ecx@42
   D3DDEVICEDESC refCaps; // [sp+Ch] [bp-300h]@25
@@ -3169,13 +3124,15 @@
   void *v28; // [sp+2FCh] [bp-10h]@2
   int v29; // [sp+308h] [bp-4h]@2
 
+  __debugbreak(); // Nomad
+
   //v2 = this;
-  this->field_40110 = 0;
+  this->using_software_screen_buffer = 0;
   this->pColorKeySurface4 = 0;
   this->pBackBuffer4 = 0;
   this->pFrontBuffer4 = 0;
   this->pDirectDraw4 = 0;
-  this->bColorKeySupported = 0;
+  //this->bColorKeySupported = 0;
   Release();
   //v3 = hWnd;
   this->window = window;
@@ -3198,14 +3155,14 @@
     v7 = pRenderD3D->pAvailableDevices;
     if ( v7[v6].bIsDeviceCompatible )
     {
-      v8 = pRenderD3D->CreateDevice(v6, 0, window->GetApiHandle());
+      v8 = pRenderD3D->CreateDevice(v6, /*0*/true, window);
       uAcquiredDirect3DDevice = uDesiredDirect3DDevice;
     }
     else
     {
       if ( v7[1].bIsDeviceCompatible )
       {
-        v8 = pRenderD3D->CreateDevice(1u, 0, window->GetApiHandle());
+        v8 = pRenderD3D->CreateDevice(1, /*0*/true, window);
         uAcquiredDirect3DDevice = 1;
       }
       else
@@ -3213,7 +3170,7 @@
         if ( !v7->bIsDeviceCompatible )
           Error("There aren't any D3D devices to create.");
 
-        v8 = pRenderD3D->CreateDevice(0, 0, window->GetApiHandle());
+        v8 = pRenderD3D->CreateDevice(0, /*0*/true, window);
         uAcquiredDirect3DDevice = 1;
       }
     }
@@ -3302,13 +3259,18 @@
     ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0));
     ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u));
   //}
-  ddpfPrimareSuface.dwSize = 32;
-  GetTargetPixelFormat(&ddpfPrimareSuface);
+  ddpfPrimarySuface.dwSize = 32;
+  GetTargetPixelFormat(&ddpfPrimarySuface);
   ParseTargetPixelFormat();
-  _49EBF1();
-  if ( pRenderD3D )
-  {
-    v16 = IsColorKeySupported(pDirectDraw4);
+
+  if (!pRenderD3D)
+  {
+    __debugbreak();
+    pBeforePresentFunction = 0;//nullsub_1;
+  }
+  //else
+  //{
+    /*v16 = IsColorKeySupported(pDirectDraw4);
     v17 = uAcquiredDirect3DDevice == v15;
     bColorKeySupported = v16;
     if ( !v17 )
@@ -3327,35 +3289,30 @@
       ErrD3D(v18->CreateSurface(&ddsd2, &pColorKeySurface4, 0));
       pBeforePresentFunction = Present_ColorKey;
     }
-    else
+    else*/
     {
       pTargetSurface = 0;
-      ptr_400E8 = 0;
-      v20 = (int *)malloc(0x96020u);
-      ptr_400E8 = v20;
-      if ( !v20
+      pTargetSurface_unaligned = 0;
+      pTargetSurface_unaligned = (unsigned int *)malloc(640 * 480 * 2 + 32);
+      if ( !pTargetSurface_unaligned
         || (memset(&pDesc, 0, 0x7Cu),
             pDesc.dwSize = 124,
             !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, v15)) )
         return 0;
       pBackBuffer4->Unlock(0);
-      v22 = ptr_400E8 + 4;
+      v22 = (int *)pTargetSurface_unaligned + 4;
       v23 = (unsigned int)pDesc.lpSurface & 7;
       LOBYTE(v22) = (unsigned __int8)v22 & 0xF8;
       uTargetSurfacePitch = 640;
       pBeforePresentFunction = Present_NoColorKey;
       v15 = 1;
-      pTargetSurface = (unsigned __int16 *)((char *)v22 + 2 * v23);
-    }
-    field_40110 = v15;
-  }
-  else
-  {
-    pBeforePresentFunction = 0;//nullsub_1;
-  }
+      pTargetSurface = (unsigned __int32 *)((char *)v22 + 2 * v23);
+    }
+    using_software_screen_buffer = v15;
+  //}
   bWindowMode = 0;
   pParty->uFlags |= 2u;
-  LODWORD(flt_6BE3A0) = 0x3F0CCCCDu;  __debugbreak(); // replace with actual float
+  flt_6BE3A0 = 0.55000001f;
   pViewport->_4C02F8(36044);
   return v15 != 0;
 }
@@ -3375,11 +3332,11 @@
   HRESULT v11; // eax@24
   int v12; // eax@24
   int v13; // eax@26
-  bool v14; // eax@32
-  char v15; // zf@32
+  //bool v14; // eax@32
+  //char v15; // zf@32
   IDirectDraw4 *v16; // eax@35
   HRESULT v17; // eax@35
-  int *v18; // eax@36
+  //int *v18; // eax@36
   int *v19; // edx@38
   int v20; // eax@38
   unsigned int v21; // ecx@38
@@ -3391,17 +3348,17 @@
   //RenderD3D *thisa; // [sp+2FCh] [bp-10h]@2
   int v29; // [sp+308h] [bp-4h]@2
 
-  pParty->uFlags |= 2u;
+  pParty->uFlags |= PARTY_FLAGS_1_0002;
   //v2 = this;
   flt_6BE3A0 = 0.55000001f;
   pViewport->_4C02F8(36044);
-  field_40110 = 0;
+  using_software_screen_buffer = 0;
   Release();
   pColorKeySurface4 = 0;
   pBackBuffer4 = 0;
   pFrontBuffer4 = 0;
   pDirectDraw4 = 0;
-  bColorKeySupported = 0;
+  //bColorKeySupported = 0;
   CreateZBuffer();
   /*if (!bUserDirect3D)
   {
@@ -3431,7 +3388,7 @@
     if (pRenderD3D->pAvailableDevices[uDesiredDirect3DDevice].bIsDeviceCompatible &&
         uDesiredDirect3DDevice != 1 )
     {
-      v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, 1, window->GetApiHandle());
+      v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, true, window);
       uAcquiredDirect3DDevice = uDesiredDirect3DDevice;
     }
     else
@@ -3439,7 +3396,7 @@
       if ( !pRenderD3D->pAvailableDevices[0].bIsDeviceCompatible )
         Error("There aren't any D3D devices to init.");
 
-      v7 = pRenderD3D->CreateDevice(0, 1, window->GetApiHandle());
+      v7 = pRenderD3D->CreateDevice(0, true, window);
       uAcquiredDirect3DDevice = 0;
     }
     if ( !v7 )
@@ -3500,7 +3457,7 @@
     refCaps.dwSize = 252;
     ErrD3D(pRenderD3D->pDevice->GetCaps(&halCaps, &refCaps));
     v12 = halCaps.dwMinTextureWidth;
-    if ( (unsigned int)halCaps.dwMinTextureWidth >= halCaps.dwMinTextureHeight )
+    if ( (unsigned int)halCaps.dwMinTextureWidth > halCaps.dwMinTextureHeight )
       v12 = halCaps.dwMinTextureHeight;
     uMinDeviceTextureDim = v12;
     v13 = halCaps.dwMaxTextureWidth;
@@ -3525,23 +3482,25 @@
     ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u));
   //}
 
-  ddpfPrimareSuface.dwSize = 32;
-  GetTargetPixelFormat(&ddpfPrimareSuface);
+  ddpfPrimarySuface.dwSize = 32;
+  GetTargetPixelFormat(&ddpfPrimarySuface);
   ParseTargetPixelFormat();
-  _49EBF1();
+
   if ( !pRenderD3D )
   {
-    pBeforePresentFunction = 0;//nullsub_1;
-    goto LABEL_47;
-  }
-  v14 = IsColorKeySupported(pDirectDraw4);
+    __debugbreak();
+    //pBeforePresentFunction = 0;//nullsub_1;
+    //goto LABEL_47;
+  }
+  /*v14 = IsColorKeySupported(pDirectDraw4);
   v15 = uAcquiredDirect3DDevice == 1;
   bColorKeySupported = v14;
   if ( !v15 )
-    bColorKeySupported = 0;
-  if ( bColorKeySupported )
-  {
-    memset(&ddsd2, 0, 0x7Cu);
+    bColorKeySupported = 0;*/
+  //if ( bColorKeySupported )
+  if (false)
+  {
+    /*memset(&ddsd2, 0, 0x7Cu);
     ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue = uTargetGMask | uTargetBMask;
     ddsd2.ddckCKSrcBlt.dwColorSpaceHighValue = ddsd2.ddckCKSrcBlt.dwColorSpaceLowValue;
     v16 = pDirectDraw4;
@@ -3551,27 +3510,36 @@
     ddsd2.dwWidth = 640;
     ddsd2.dwHeight = 480;
     ErrD3D(v16->CreateSurface(&ddsd2, &pColorKeySurface4, 0));
-    pBeforePresentFunction = Present_ColorKey;
+    pBeforePresentFunction = Present_ColorKey;*/
 LABEL_45:
-    field_40110 = 1;
-LABEL_47:
+    using_software_screen_buffer = 1;
+//LABEL_47:
     bWindowMode = 1;
     //hWnd = hWnd;
     return 0;
   }
   pTargetSurface = 0;
-  ptr_400E8 = 0;
-  v18 = (int *)new char[0x96020];
-  memset(v18, -1, 0x96020);
-  ptr_400E8 = v18;
-  if ( v18 )
-  {
-    memset(&pDesc, 0, 0x7Cu);
-    pDesc.dwSize = 124;
-    if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT) )
-    {
+  pTargetSurface_unaligned = 0;
+
+  uint num_pixels = window->GetWidth() * window->GetHeight();
+  pTargetSurface_unaligned = new unsigned int[num_pixels];
+
+  if (!pTargetSurface_unaligned)
+    return false;
+
+  memset(&pDesc, 0, 0x7Cu);
+  pDesc.dwSize = 124;
+  if (!pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT))
+  {
+    delete [] pTargetSurface_unaligned;
+    return false;
+  }
+
+  memset32(pTargetSurface_unaligned, -1, num_pixels);
+
+
       pRenderer->pBackBuffer4->Unlock(0);
-      v19 = ptr_400E8;
+      /*v19 = pTargetSurface_unaligned;
       v20 = (unsigned int)pDesc.lpSurface & 7;
       v21 = (unsigned int)ptr_400E8 & 7;
       if ( v21 == v20 )
@@ -3585,13 +3553,11 @@
         else
           v22 = (int)((char *)v19 + 2 * (v20 - v21) + 16);
         pTargetSurface = (unsigned __int16 *)v22;
-      }
-      uTargetSurfacePitch = 640;
+      }*/
+      pTargetSurface = pTargetSurface_unaligned;
+      uTargetSurfacePitch = window->GetWidth();
       pBeforePresentFunction = Present_NoColorKey;
       goto LABEL_45;
-    }
-  }
-  return 0;
 }
 
 //----- (004A0BEE) --------------------------------------------------------
@@ -3688,7 +3654,9 @@
         v24 = -1;
       }
       v25 = 0;
-      v26 = v35->pTargetSurface;
+
+      __debugbreak(); //target sruface will most likely be 32bits/pixel, but this sub awaits 16 bits
+      v26 = (unsigned __int16 *)v35->pTargetSurface;
       if ( v26 )
       {
         if ( (signed int)uXa <= v23 )
@@ -3852,11 +3820,11 @@
   signed int v5; // ecx@5
   unsigned int uBlueMask; // edx@9
   signed int v7; // ecx@9
-  unsigned int v8; // ecx@13
+  //unsigned int v8; // ecx@13
 
   v1 = this;
   v2 = 0;
-  uRedMask = v1->ddpfPrimareSuface.dwRBitMask;
+  uRedMask = v1->ddpfPrimarySuface.dwRBitMask;
   v1->uTargetBBits = 0;
   v1->uTargetGBits = 0;
   v1->uTargetRBits = 0;
@@ -3866,8 +3834,8 @@
       ++v1->uTargetRBits;
     ++v2;
   }
-  while ( v2 < 16 );
-  uGreenMask = v1->ddpfPrimareSuface.dwGBitMask;
+  while ( v2 < 32 );
+  uGreenMask = v1->ddpfPrimarySuface.dwGBitMask;
   v5 = 0;
   do
   {
@@ -3875,8 +3843,8 @@
       ++v1->uTargetGBits;
     ++v5;
   }
-  while ( v5 < 16 );
-  uBlueMask = v1->ddpfPrimareSuface.dwBBitMask;
+  while ( v5 < 32 );
+  uBlueMask = v1->ddpfPrimarySuface.dwBBitMask;
   v7 = 0;
   do
   {
@@ -3884,10 +3852,9 @@
       ++v1->uTargetBBits;
     ++v7;
   }
-  while ( v7 < 16 );
-  v8 = v1->ddpfPrimareSuface.dwRBitMask;
+  while ( v7 < 32 );
   v1->uTargetGMask = uGreenMask;
-  v1->uTargetRMask = v8;
+  v1->uTargetRMask = v1->ddpfPrimarySuface.dwRBitMask;
   v1->uTargetBMask = uBlueMask;
 }
 
@@ -6155,62 +6122,6 @@
     pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent;
 }
 
-//----- (004A48E4) --------------------------------------------------------
-int Render::MakeParticleBillboardAndPush_BLV_Software(int screenSpaceX, int screenSpaceY, int z, int lightColor, int a6)
-{
-  int v6; // ecx@1
-  int v7; // ebx@1
-  int v8; // ecx@1
-  int v9; // edx@1
-  int v10; // edi@1
-  unsigned int x; // esi@1
-  int result; // eax@8
-  int v13; // [sp+Ch] [bp-10h]@1
-  int v14; // [sp+10h] [bp-Ch]@1
-  int v15; // [sp+14h] [bp-8h]@1
-  int v16; // [sp+18h] [bp-4h]@1
-  int v17; // [sp+24h] [bp+8h]@1
-  unsigned int v18; // [sp+28h] [bp+Ch]@1
-  int v19; // [sp+34h] [bp+18h]@1
-
-  v6 = screenSpaceX;
-  v7 = (a6 >> 1) + screenSpaceY;
-  v17 = 0;
-  v15 = 0;
-  v8 = (a6 >> 1) + v6;
-  v14 = (a6 >> 1) * (a6 >> 1);
-  v9 = 2 * (a6 >> 1);
-  v10 = (a6 >> 1) * ((a6 >> 1) - 1);
-  x = v8 - (a6 >> 1);
-  v16 = (a6 >> 1) + screenSpaceY - v8;
-  v19 = a6 >> 1;
-  v13 = v9;
-  v18 = v8;
-  do
-  {
-    sr_4A46E6_draw_particle_segment(x, v16 + v18, z, 2 * v19, lightColor);
-    if ( v15 )
-      sr_4A46E6_draw_particle_segment(x, v17 + v7, z, 2 * v19, lightColor);
-    v14 -= v15;
-    if ( v14 <= v10 )
-    {
-      if ( v19 != v17 )
-      {
-        sr_4A46E6_draw_particle_segment(v18, v16 + x, z, 2 * v17, lightColor);
-        sr_4A46E6_draw_particle_segment(v18, v19 + v7, z, 2 * v17, lightColor);
-      }
-      --v19;
-      v13 -= 2;
-      ++x;
-      v10 -= v13;
-    }
-    result = v17++;
-    v15 += 2;
-    --v18;
-  }
-  while ( result < v19 );
-  return result;
-}
 
 //----- (004A49D0) --------------------------------------------------------
 void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9)
@@ -6536,7 +6447,7 @@
   {
     if ( this->pRenderD3D )
     {
-      if ( this->bColorKeySupported )
+      /*if ( this->bColorKeySupported )
       {
         memset(&Dst, 0, 0x7Cu);
         Dst.dwSize = 124;
@@ -6547,7 +6458,7 @@
           this->field_18_locked_pitch = Dst.lPitch >> 1;
         }
         --this->uNumSceneBegins;
-      }
+      }*/
     }
     else
     {
@@ -6575,13 +6486,13 @@
     {
       if ( this->pRenderD3D )
       {
-        if ( this->bColorKeySupported )
+        /*if ( this->bColorKeySupported )
         {
           this->pTargetSurface = 0;
           this->uTargetSurfacePitch = 0;
           this->field_18_locked_pitch = 0;
           ErrD3D(this->pColorKeySurface4->Unlock(0));
-        }
+        }*/
       }
       else
       {
@@ -6827,11 +6738,33 @@
   this->uClipZ = 640;
 }
 
+unsigned __int32 Color32(unsigned __int16 color16)
+{
+  unsigned __int32 c = color16;
+  unsigned int b = (c & 31) * 8;
+  unsigned int g = ((c >> 5) & 63) * 4;
+  unsigned int r = ((c >> 11) & 31) * 8;
+
+  return 0xFF000000 | (r << 16) | (g << 8) | b;
+}
+
+//----- (0040DEF3) --------------------------------------------------------
+unsigned __int16 Color16(unsigned __int32 r, unsigned __int32 g, unsigned __int32 b)
+{
+  //return ((unsigned int)b >> (8 - LOBYTE(pRenderer->uTargetBBits))) | pRenderer->uTargetGMask & (g << (LOBYTE(pRenderer->uTargetGBits) + 
+  //                         LOBYTE(pRenderer->uTargetBBits) - 8)) | pRenderer->uTargetRMask & (r << (LOBYTE(pRenderer->uTargetGBits) + 
+  //                         LOBYTE(pRenderer->uTargetRBits) + LOBYTE(pRenderer->uTargetBBits) - 8));
+  return (b >> (8 - 5)) |
+         0x7E0 & (g << (6 + 5 - 8)) |
+         0xF800 & (r << (6 + 5 + 5 - 8));
+}
+
+
 //----- (004A5BE3) --------------------------------------------------------
 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4)
 {
   int v4; // edi@3
-  unsigned __int16 *v5; // edx@3
+  //unsigned __int16 *v5; // edx@3
   unsigned __int16 *v6; // esi@3
   unsigned int v8; // eax@5
   unsigned int v9; // ebx@5
@@ -6845,7 +6778,7 @@
   if ( this->uNumSceneBegins && a4 )
   {
     v4 = a4->uWidth;
-    v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch];
+    //v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch];
     v6 = a4->pPixels;
     v23 = a4->uHeight;
     v19 = v4;
@@ -6858,14 +6791,14 @@
         v8 *= 2;
         v4 += v9;
         v6 = (unsigned __int16 *)((char *)v6 + v8);
-        v5 = (unsigned __int16 *)((char *)v5 + v8);
+        //v5 = (unsigned __int16 *)((char *)v5 + v8);
       }
       if ( (signed int)uOutY < (signed int)this->uClipY )
       {
         v11 = this->uClipY - uOutY;
         v6 += v19 * v11;
         v23 += uOutY - this->uClipY;
-        v5 += this->uTargetSurfacePitch * v11;
+        //v5 += this->uTargetSurfacePitch * v11;
       }
       v12 = max(this->uClipX, uOutX);
       if ( (signed int)(v4 + v12) > (signed int)this->uClipZ )
@@ -6879,16 +6812,17 @@
       }
     }
 
-    for (int outerCounter = 0; outerCounter < v23; outerCounter++)
-    {
-      for (int counter = 0; counter < v4; counter++)
-      {
-        *v5 = *v6;
-        ++v5;
+    for (int y = 0; y < v23; y++)
+    {
+      for (int x = 0; x < v4; x++)
+      {
+        WritePixel16(uOutX + x, uOutY + y, *v6);
+        //*v5 = *v6;
+        //++v5;
         ++v6;
       }
       v6 += v19 - v4;
-      v5 += this->uTargetSurfacePitch - v4;
+      //v5 += this->uTargetSurfacePitch - v4;
     }
   }
 }
@@ -6896,15 +6830,19 @@
 //----- (004A5D33) --------------------------------------------------------
 void Render::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture)
 {
-  unsigned __int16 *v7; // ebx@3
+  //unsigned __int16 *v7; // ebx@3
   int full_width; // ecx@3
   int full_height; // edi@3
-  int v23; // edi@23
+  //int v23; // edi@23
   unsigned __int16 *pTexturea; // [sp+28h] [bp+18h]@3
 
   if ( this->uNumSceneBegins && pTexture )
   {
-    v7 = &this->pTargetSurface[pX + pY * this->uTargetSurfacePitch];
+    /*auto v7 = this->pTargetSurface;
+    if (FORCE_16_BITS)
+      v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 2);
+    else
+      v7 = (unsigned __int32 *)((char *)v7 + (pX + pY * this->uTargetSurfacePitch) * 4);*/
     full_width = pTexture->uWidth - move_X;
     full_height = pTexture->uHeight - move_Y;
     pTexturea = &pTexture->pPixels[move_X + move_Y * pTexture->uWidth];
@@ -6914,13 +6852,13 @@
       {
         pTexturea = (unsigned __int16 *)((char *)pTexturea + (2 * (this->uClipX - pX)));
         full_width += pX - this->uClipX;
-        v7 = (unsigned __int16 *)((char *)v7 + (2 * (this->uClipX - pX)));
+        //v7 = (unsigned __int32 *)((char *)v7 + ((FORCE_16_BITS ? 2 : 4) * (this->uClipX - pX)));
       }
       if ( pY < this->uClipY )//если кадр выходит за верхнюю границу
       {
         pTexturea += pTexture->uWidth * (this->uClipY - pY);
         full_height += pY - this->uClipY;
-        v7 += this->uTargetSurfacePitch * (this->uClipY - pY);
+        //v7 = (unsigned __int32 *)((char *)v7 + (FORCE_16_BITS ? 2 : 4) * this->uTargetSurfacePitch * (this->uClipY - pY));
       }
       if ( this->uClipX < pX )//если правая граница окна меньше х координаты кадра
         this->uClipX = pX;
@@ -6939,36 +6877,32 @@
         full_height = this->uClipW - this->uClipY;
       }
     }
-    if ( full_height > 0 )
-    {
-      do
-      {
-        if ( full_width > 0 )
-        {
-          v23 = full_width;
-          do
-          {
-            if ( *pTexturea != TargetColor(0, 0xFFu, 0xFFu) )
-              *v7 = *pTexturea;
+
+    for (int y = 0; y < full_height; ++y)
+    {
+      for (int x = 0; x < full_width; ++x)
+      {
+            if ( *pTexturea != Color16(0, 0xFFu, 0xFFu) )
+            {
+              WritePixel16(pX + x, pY + y, *pTexturea);
+              /*if (FORCE_16_BITS)
+                *(unsigned __int16 *)v7 = *pTexturea;
+              else
+                *(unsigned __int32 *)v7 = r5g6b5_2_r8g8b8(*pTexturea);*/
+            }
             ++pTexturea;
-            ++v7;
-            --v23;
-          }
-          while ( v23 );
+            //++v7;
         }
-        v7 += this->uTargetSurfacePitch - full_width;
+        //v7 += this->uTargetSurfacePitch - full_width;
         pTexturea = (unsigned __int16 *)((char *)pTexturea + 2 * (pTexture->uWidth - full_width));
-        --full_height;
-      }
-      while ( full_height );
-    }
+      }
   }
 }
 
 //----- (004A6E7E) --------------------------------------------------------
 void Render::_4A6E7E(unsigned int a2, unsigned int a3, Texture *a4)
 {
-  unsigned __int16 *v4; // eax@4
+  //unsigned __int16 *v4; // eax@4
   int v5; // edx@4
   unsigned int v6; // edi@4
   unsigned int v7; // edx@5
@@ -6992,12 +6926,14 @@
 
   if ( this->uNumSceneBegins && a4 && a4->pPalette16 )
   {
-    v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
+    //v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
     v20 = a4->pLevelOfDetail0_prolly_alpha_mask;
     v5 = a4->uTextureWidth;
     v6 = a4->uTextureHeight;
     v19 = a4->uTextureWidth;
     v18 = a4->uTextureWidth;
+    int clipped_out_x = a2;
+    int clipped_out_y = a3;
     if ( this->bClip )
     {
       v7 = this->uClipX;
@@ -7006,7 +6942,8 @@
         v8 = v7 - a2;
         v20 += v8;
         v19 += a2 - this->uClipX;
-        v4 += v8;
+        //v4 += v8;
+        clipped_out_x = uClipX;
       }
       v9 = this->uClipY;
       if ( (signed int)a3 < (signed int)v9 )
@@ -7014,7 +6951,8 @@
         v10 = v9 - a3;
         v20 += v18 * v10;
         v6 = a3 - this->uClipY + a4->uTextureHeight;
-        v4 += this->uTargetSurfacePitch * v10;
+        //v4 += this->uTargetSurfacePitch * v10;
+        clipped_out_y = uClipY;
       }
       v11 = this->uClipX;
       v5 = v19;
@@ -7040,7 +6978,19 @@
         v6 = v15 - v16;
       }
     }
-    if ( pRenderer->uTargetGBits == 5 )
+
+    for (int y = 0; y < v6; ++y)
+    {
+      for (int x = 0; x < v5; ++x)
+      {
+        if ( *v20 )
+          WritePixel16(clipped_out_x + x, clipped_out_y + y, ((unsigned int)a4->pPalette16[*v20] >> 1) & 0x7BEF);
+        ++v20;
+      }
+          v20 += v18 - v5;
+    }
+
+    /*if ( pRenderer->uTargetGBits == 5 )
     {
       if ( (signed int)v6 > 0 )
       {
@@ -7093,12 +7043,12 @@
         }
         while ( !v17 );
       }
-    }
+    }*/
   }
 }
 
 //----- (004A6DF5) --------------------------------------------------------
-int Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, unsigned __int16 *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7)
+void Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7)
 {
   int result; // eax@0
   int v8; // ecx@3
@@ -7108,19 +7058,19 @@
   unsigned __int16 *pBitmapa; // [sp+14h] [bp+8h]@3
   unsigned __int16 *pTargeta; // [sp+20h] [bp+14h]@3
 
-  if ( pBitmap )
-  {
-    if ( pTarget )
-    {
+  if ( !pBitmap || !pTarget)
+    return;
+
       pBitmapa = &pBitmap[pBitmapXY->x + uBitmapPitch * pBitmapXY->y];
-      pTargeta = &pTarget[a7->x + uTargetPitch * a7->y];
+
+      __debugbreak(); // sub expects 16bit target surface, we may have 32bit
+      pTargeta = (unsigned short *)pTarget + a7->x + uTargetPitch * a7->y;
       v8 = a7->z - a7->x;
-      result = a7->w - a7->y;
-      if ( result > 0 )
+      v11 = a7->w - a7->y;
+      if ( v11 > 0 )
       {
         v9 = pBitmapa;
         v10 = pTargeta;
-        v11 = a7->w - a7->y;
         do
         {
           if ( v8 > 0 )
@@ -7141,9 +7091,6 @@
         }
         while ( v11 );
       }
-    }
-  }
-  return result;
 }
 
 //----- (004A6D87) --------------------------------------------------------
@@ -7155,11 +7102,14 @@
   unsigned __int32 twoColors = (uColor16 << 16) | uColor16;
   for (uint y = 0; y < uHeight; ++y)
   {
-    ushort* pDst = &pTargetSurface[uX + (y + uY) * uTargetSurfacePitch];
-
-    memset32(pDst, twoColors, uWidth / 2);
-    if (uWidth & 1)
-      pDst[uWidth - 1] = uColor16;
+    void *pDst = (char *)pTargetSurface + (FORCE_16_BITS ? 2 : 4) * (uX + (y + uY) * uTargetSurfacePitch);
+
+    memset32(pDst,
+             FORCE_16_BITS ? twoColors : Color32(uColor16),  // two colors per int (16bit) or 1 (32bit)
+             uWidth / (FORCE_16_BITS ? 2 : 1));                      // two pixels per int (16bit) or 1 (32bit)
+
+    if (FORCE_16_BITS && uWidth & 1) // we may miss one pixel for 16bit
+      ((unsigned __int16 *)pTargetSurface)[uX + uWidth - 1 + (y + uY) * uTargetSurfacePitch] = uColor16;
     }
 }
 
@@ -7168,7 +7118,7 @@
 {
   unsigned int v9; // edi@2
   unsigned int v10; // esi@2
-  unsigned __int16 *v11; // eax@2
+  //unsigned __int16 *v11; // eax@2
   unsigned int v12; // ebx@3
   signed int v13; // edx@5
   int v14; // edx@6
@@ -7178,25 +7128,29 @@
   signed int v18; // ebx@13
   unsigned int v19; // edx@15
   signed int v20; // esi@16
-  unsigned int v21; // esi@22
+  //unsigned int v21; // esi@22
   unsigned __int16 v22; // dx@24
-  char v23; // zf@28
+  //char v23; // zf@28
   unsigned __int8 *v24; // [sp+Ch] [bp-4h]@2
-  unsigned int uOutXa; // [sp+18h] [bp+8h]@20
-
-  if ( this->uNumSceneBegins )
-  {
+  //unsigned int uOutXa; // [sp+18h] [bp+8h]@20
+
+  if (!this->uNumSceneBegins)
+    return;
+
     v9 = uCharWidth;
     v10 = uCharHeight;
-    v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch];
+    //v11 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch];
     v24 = pFontPixels;
+
+    int clipped_out_x = uOutX, clipped_out_y = uOutY;
     if ( this->bClip )
     {
       v12 = this->uClipX;
       if ( uOutX < (signed int)v12 )
       {
         v24 = &pFontPixels[v12 - uOutX];
-        v11 += v12 - uOutX;
+        //v11 += v12 - uOutX;
+        clipped_out_x = uClipX;
         v9 = uCharWidth + uOutX - v12;
       }
       v13 = this->uClipY;
@@ -7205,7 +7159,8 @@
         v14 = v13 - uOutY;
         v24 += uCharWidth * v14;
         v10 = uCharHeight + uOutY - this->uClipY;
-        v11 += this->uTargetSurfacePitch * v14;
+        //v11 += this->uTargetSurfacePitch * v14;
+        clipped_out_y = uClipY;
       }
       v15 = this->uClipX;
       if ( v15 < uOutX )
@@ -7230,36 +7185,23 @@
         v10 = v19 - v20;
       }
     }
-    if ( (signed int)v10 > 0 )
-    {
-      uOutXa = v10;
-      do
-      {
-        if ( (signed int)v9 > 0 )
+
+    for (int y = 0; y < v10; ++y)
+    {
+      for (int x = 0; x < v9; ++x)
+      {
+        if (*v24)
         {
-          v21 = v9;
-          do
-          {
-            if ( *v24 )
-            {
-              v22 = uShadowColor;
-              if ( *v24 != 1 )
-                v22 = uFaceColor;
-              *v11 = v22;
-            }
-            ++v11;
-            ++v24;
-            --v21;
-          }
-          while ( v21 );
+          v22 = uShadowColor;
+          if ( *v24 != 1 )
+            v22 = uFaceColor;
+          WritePixel16(clipped_out_x + x, clipped_out_y + y, v22);
         }
+      }
         v24 += uCharWidth - v9;
-        v23 = uOutXa-- == 1;
-        v11 += this->uTargetSurfacePitch - v9;
-      }
-      while ( !v23 );
-    }
-  }
+        //v23 = uOutXa-- == 1;
+        //v11 += this->uTargetSurfacePitch - v9;
+    }
 }
 
 //----- (004A6A68) --------------------------------------------------------
@@ -7278,7 +7220,7 @@
     {
   int v8; // edi@2
   unsigned int v9; // esi@2
-  unsigned __int16 *v10; // eax@2
+  //unsigned __int16 *v10; // eax@2
   unsigned char *v11; // edx@2
   unsigned int v12; // ebx@3
   signed int v13; // edx@5
@@ -7303,21 +7245,25 @@
   int a2 = x;
   int a3 = y;
   uint a6 = uFontHeight;
-  if ( this->uNumSceneBegins )
-  {
+  if (!this->uNumSceneBegins)
+    return;
+
     v8 = a5;
     v9 = a6;
-    v10 = &pTargetSurface[x + y * uTargetSurfacePitch];
+    //v10 = &pTargetSurface[x + y * uTargetSurfacePitch];
     v11 = (unsigned char *)font_pixels;
     v25 = (int)font_pixels;
+    int clipped_out_x = x;
+    int clipped_out_y = y;
     if ( this->bClip )
     {
       v12 = this->uClipX;
       if ( a2 < (signed int)v12 )
       {
         v25 = v12 - a2 + (int)font_pixels;
-        v10 += v12 - a2;
+        //v10 += v12 - a2;
         v8 = a5 + a2 - v12;
+        clipped_out_x = uClipX;
       }
       v13 = this->uClipY;
       if ( a3 < v13 )
@@ -7325,7 +7271,8 @@
         v14 = v13 - a3;
         v25 += a5 * v14;
         v9 = a6 + a3 - this->uClipY;
-        v10 += this->uTargetSurfacePitch * v14;
+        //v10 += this->uTargetSurfacePitch * v14;
+        clipped_out_y = uClipY;
       }
       v15 = this->uClipX;
       if ( v15 < a2 )
@@ -7351,10 +7298,27 @@
       }
       v11 = (unsigned char *)v25;
     }
+
     if ( a8 )
     {
-      v28 = pRenderer->uTargetGMask | pRenderer->uTargetBMask;
-      if ( (signed int)v9 > 0 )
+      v28 = 0x7FF; // 16bit pRenderer->uTargetGMask | pRenderer->uTargetBMask;
+      for (int dy = 0; dy < v9; ++dy)
+      {
+        for (int dx = 0; dx < v8; ++dx)
+        {
+              if ( *v11 )
+                v24 = pPalette[*v11];
+              else
+                v24 = v28;
+              WritePixel16(clipped_out_x + dx, clipped_out_y + dy, v24);
+              //*v10 = v24;
+              //++v10;
+              //++v11;
+              //--v27;
+        }
+          v11 += a5 - v8;
+      }
+      /*if ( (signed int)v9 > 0 )
       {
         v23 = a5;
         v30 = v9;
@@ -7381,11 +7345,24 @@
           v10 += this->uTargetSurfacePitch - v8;
         }
         while ( !v22 );
-      }
+      }*/
     }
     else
     {
-      if ( (signed int)v9 > 0 )
+      for (int dy = 0; dy < v9; ++dy)
+      {
+        for (int dx = 0; dx < v8; ++dx)
+        {
+              WritePixel16(clipped_out_x + dx, clipped_out_y + dy, pPalette[*v11]);
+              //*v10 = v24;
+              //++v10;
+              //++v11;
+              //--v27;
+        }
+          v11 += a5 - v8;
+      }
+
+      /*if ( (signed int)v9 > 0 )
       {
         v21 = a5;
         v29 = v9;
@@ -7409,124 +7386,22 @@
           v10 += this->uTargetSurfacePitch - v8;
         }
         while ( !v22 );
-      }
-    }
-  }
+      }*/
+    }
 }
 
 //----- (004A68EF) --------------------------------------------------------
 void Render::DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture)
 {
-  Texture *v4; // edi@2
-  unsigned int v5; // ebx@4
-  unsigned __int16 *v6; // eax@4
-  signed int v7; // edx@5
-  int v8; // edx@6
-  signed int v9; // edx@7
-  int v10; // edx@8
-  signed int v11; // edx@9
-  signed int v12; // esi@12
-  signed int v13; // esi@15
-  unsigned int v14; // edx@17
-  signed int v15; // esi@18
-  unsigned __int8 *v16; // ebx@22
-  char v17; // zf@28
-  int v18; // [sp+10h] [bp-10h]@4
-  unsigned __int8 *v19; // [sp+18h] [bp-8h]@4
-  int v20; // [sp+1Ch] [bp-4h]@4
-  int v21; // [sp+28h] [bp+8h]@24
-  unsigned int v22; // [sp+2Ch] [bp+Ch]@22
-  unsigned int pTexturea; // [sp+30h] [bp+10h]@11
-
-  if ( this->uNumSceneBegins )
-  {
-    v4 = pTexture;
-    if ( pTexture )
-    {
-      if ( pTexture->pPalette16 )
-      {
-        v5 = pTexture->uTextureHeight;
-        v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
-        v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask;
-        v20 = pTexture->uTextureWidth;
-        v18 = pTexture->uTextureWidth;
-        if ( this->bClip )
-        {
-          v7 = this->uClipX;
-          if ( a2 < v7 )
-          {
-            v8 = v7 - a2;
-            v19 += v8;
-            v20 += a2 - this->uClipX;
-            v6 += v8;
-          }
-          v9 = this->uClipY;
-          v5 = pTexture->uTextureHeight;
-          if ( a3 < v9 )
-          {
-            v10 = v9 - a3;
-            v19 += v18 * v10;
-            v5 = a3 - this->uClipY + pTexture->uTextureHeight;
-            v4 = pTexture;
-            v6 += this->uTargetSurfacePitch * v10;
-          }
-          v11 = this->uClipX;
-          if ( v11 < a2 )
-            v11 = a2;
-          pTexturea = this->uClipZ;
-          if ( v11 + v20 > (signed int)pTexturea )
-          {
-            v12 = this->uClipX;
-            if ( v12 < a2 )
-              v12 = a2;
-            v20 = pTexturea - v12;
-          }
-          v13 = this->uClipY;
-          if ( v13 < a3 )
-            v13 = a3;
-          v14 = this->uClipW;
-          if ( (signed int)(v5 + v13) > (signed int)v14 )
-          {
-            v15 = this->uClipY;
-            if ( v15 < a3 )
-              v15 = a3;
-            v5 = v14 - v15;
-          }
-        }
-        if ( (signed int)v5 > 0 )
-        {
-          v22 = v5;
-          v16 = v19;
-          do
-          {
-            if ( v20 > 0 )
-            {
-              v21 = v20;
-              do
-              {
-                if ( *v16 )
-                  *v6 = this->uTargetGMask & v4->pPalette16[*v16];
-                ++v6;
-                ++v16;
-                --v21;
-              }
-              while ( v21 );
-            }
-            v16 += v18 - v20;
-            v17 = v22-- == 1;
-            v6 += this->uTargetSurfacePitch - v20;
-          }
-          while ( !v17 );
-        }
-      }
-    }
-  }
-}
+  DrawMasked(a2, a3, pTexture, 0x07E0);
+}
+
 
 //----- (004A6776) --------------------------------------------------------
 void Render::DrawTransparentRedShade(unsigned int a2, unsigned int a3, Texture *a4)
 {
-  Texture *v4; // edi@2
+  DrawMasked(a2, a3, a4, 0xF800);
+  /*Texture *v4; // edi@2
   unsigned int v5; // ebx@4
   unsigned __int16 *v6; // eax@4
   unsigned int v7; // edx@5
@@ -7629,13 +7504,138 @@
         }
       }
     }
-  }
-}
+  }*/
+}
+
+//----- (004A68EF) --------------------------------------------------------
+void Render::DrawMasked(signed int a2, signed int a3, Texture *pTexture, unsigned __int16 mask)
+{
+  Texture *v4; // edi@2
+  unsigned int v5; // ebx@4
+  //unsigned __int16 *v6; // eax@4
+  signed int v7; // edx@5
+  int v8; // edx@6
+  signed int v9; // edx@7
+  int v10; // edx@8
+  signed int v11; // edx@9
+  signed int v12; // esi@12
+  signed int v13; // esi@15
+  unsigned int v14; // edx@17
+  signed int v15; // esi@18
+  unsigned __int8 *v16; // ebx@22
+  char v17; // zf@28
+  int v18; // [sp+10h] [bp-10h]@4
+  unsigned __int8 *v19; // [sp+18h] [bp-8h]@4
+  int v20; // [sp+1Ch] [bp-4h]@4
+  int v21; // [sp+28h] [bp+8h]@24
+  unsigned int v22; // [sp+2Ch] [bp+Ch]@22
+  unsigned int pTexturea; // [sp+30h] [bp+10h]@11
+
+  if (!uNumSceneBegins || !pTexture)
+    return;
+
+    v4 = pTexture;
+
+      if ( pTexture->pPalette16 )
+      {
+        v5 = pTexture->uTextureHeight;
+        //v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
+        v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask;
+        v20 = pTexture->uTextureWidth;
+        v18 = pTexture->uTextureWidth;
+        int clipped_out_x = a2;
+        int clipped_out_y = a3;
+        if ( this->bClip )
+        {
+          v7 = this->uClipX;
+          if ( a2 < v7 )
+          {
+            v8 = v7 - a2;
+            v19 += v8;
+            v20 += a2 - this->uClipX;
+            //v6 += v8;
+            clipped_out_x = uClipX;
+          }
+          v9 = this->uClipY;
+          v5 = pTexture->uTextureHeight;
+          if ( a3 < v9 )
+          {
+            v10 = v9 - a3;
+            v19 += v18 * v10;
+            v5 = a3 - this->uClipY + pTexture->uTextureHeight;
+            v4 = pTexture;
+            //v6 += this->uTargetSurfacePitch * v10;
+            clipped_out_y = uClipY;
+          }
+          v11 = this->uClipX;
+          if ( v11 < a2 )
+            v11 = a2;
+          pTexturea = this->uClipZ;
+          if ( v11 + v20 > (signed int)pTexturea )
+          {
+            v12 = this->uClipX;
+            if ( v12 < a2 )
+              v12 = a2;
+            v20 = pTexturea - v12;
+          }
+          v13 = this->uClipY;
+          if ( v13 < a3 )
+            v13 = a3;
+          v14 = this->uClipW;
+          if ( (signed int)(v5 + v13) > (signed int)v14 )
+          {
+            v15 = this->uClipY;
+            if ( v15 < a3 )
+              v15 = a3;
+            v5 = v14 - v15;
+          }
+        }
+        
+          v16 = v19;
+        for (int y = 0; y < v5; ++y)
+        {
+          for (int x = 0; x < v20; ++x)
+          {
+                if ( *v16 )
+                  WritePixel16(clipped_out_x + x, clipped_out_y + y, v4->pPalette16[*v16] & mask);
+                ++v16;
+          }
+            v16 += v18 - v20;
+        }
+
+        /*if ( (signed int)v5 > 0 )
+        {
+          v22 = v5;
+          v16 = v19;
+          do
+          {
+            if ( v20 > 0 )
+            {
+              v21 = v20;
+              do
+              {
+                if ( *v16 )
+                  *v6 = this->uTargetGMask & v4->pPalette16[*v16];
+                ++v6;
+                ++v16;
+                --v21;
+              }
+              while ( v21 );
+            }
+            v16 += v18 - v20;
+            v17 = v22-- == 1;
+            v6 += this->uTargetSurfacePitch - v20;
+          }
+          while ( !v17 );
+        }*/
+      }
+}
+
 
 //----- (004A65CC) --------------------------------------------------------
 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8)
 {
-  unsigned __int16 *v8; // esi@6
+  //unsigned __int16 *v8; // esi@6
   unsigned int v9; // edi@6
   unsigned int v10; // eax@7
   unsigned int v11; // eax@8
@@ -7658,11 +7658,13 @@
 
   if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 )
   {
-    v8 = &this->pTargetSurface[x + y * this->uTargetSurfacePitch];
+    //v8 = &this->pTargetSurface[x + y * this->uTargetSurfacePitch];
     v24 = a4->pLevelOfDetail0_prolly_alpha_mask;
     v27 = a4->uTextureWidth;
     v9 = a4->uTextureHeight;
     v22 = a4->uTextureWidth;
+    int clipped_out_x = x;
+    int clipped_out_y = y;
     if ( this->bClip )
     {
       v10 = this->uClipX;
@@ -7671,7 +7673,8 @@
         v11 = v10 - x;
         v24 += v11;
         v27 += x - this->uClipX;
-        v8 += v11;
+        //v8 += v11;
+        clipped_out_x = uClipX;
       }
       v12 = this->uClipY;
       if ( (signed int)y < (signed int)v12 )
@@ -7679,7 +7682,8 @@
         v13 = v12 - y;
         v24 += v22 * v13;
         v9 = y - this->uClipY + a4->uTextureHeight;
-        v8 += this->uTargetSurfacePitch * v13;
+        //v8 += this->uTargetSurfacePitch * v13;
+        clipped_out_y = uClipY;
       }
       v14 = this->uClipX;
       if ( (signed int)v14 < (signed int)x )
@@ -7704,7 +7708,25 @@
         v9 = v18 - v19;
       }
     }
-    if ( (signed int)v9 > 0 )
+
+    for (int dy = 0; dy < v9; ++dy)
+    {
+      for (int dx = 0; dx < v27; ++dx)
+      {
+            v20 = *v24;
+            if ( v20 >= a7 && v20 <= a8 )
+            {
+              v21 = a7 + (a6 + v20) % (2 * (a8 - a7));
+              if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 )
+                v21 = 2 * a8 - v21 - a7;
+              //*v8 = a4->pPalette16[v21];
+              WritePixel16(clipped_out_x + dx, clipped_out_y + dy, a4->pPalette16[v21]);
+            }
+            ++v24;
+      }
+        v24 += v22 - v27;
+    }
+    /*if ( (signed int)v9 > 0 )
     {
       ya = v9;
       v23 = v22 - v27;
@@ -7734,7 +7756,7 @@
         --ya;
       }
       while ( ya );
-    }
+    }*/
   }
 }
 
@@ -7742,8 +7764,8 @@
 void Render::DrawAura(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8)
 {
   Texture *v8; // eax@2
-  Texture *v9; // ebx@4
-  unsigned __int16 *v10; // esi@6
+  //Texture *v9; // ebx@4
+  //unsigned __int16 *v10; // esi@6
   unsigned int v11; // edi@7
   unsigned int v12; // eax@9
   unsigned int v13; // eax@10
@@ -7770,16 +7792,18 @@
     {
       if ( a4->pPalette16 )
       {
-        v9 = a5;
         if ( a5 )
         {
           if ( a5->pPalette16 )
           {
-            v10 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
+            //v10 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
             v28 = a4->pLevelOfDetail0_prolly_alpha_mask;
             v25 = v8->uTextureWidth;
             v24 = v8->uTextureHeight;
             v22 = v8->uTextureWidth;
+
+            int clipped_out_x = a2;
+            int clipped_out_y = a3;
             if ( this->bClip )
             {
               v11 = this->uClipX;
@@ -7787,17 +7811,17 @@
               {
                 v28 += v11 - a2;
                 v25 += a2 - v11;
-                v9 = a5;
-                v10 += v11 - a2;
+                //v10 += v11 - a2;
+                clipped_out_x = uClipX;
               }
               v12 = this->uClipY;
               if ( (signed int)a3 < (signed int)v12 )
               {
                 v13 = v12 - a3;
-                v9 = a5;
                 v28 += v22 * v13;
                 v24 += a3 - this->uClipY;
-                v10 += this->uTargetSurfacePitch * v13;
+                //v10 += this->uTargetSurfacePitch * v13;
+                clipped_out_y = uClipY;
               }
               v14 = this->uClipX;
               if ( (signed int)v14 < (signed int)a2 )
@@ -7822,8 +7846,34 @@
                 v24 = v18 - v19;
               }
             }
+
             v27 = 0;
-            if ( v24 > 0 )
+            for (int y = 0; y < v24; ++y)
+            {
+              for (int x = 0; x < v25; ++x)
+              {
+                  if ( *v28 )
+                  {
+                    v20 = *(&a5->pLevelOfDetail0_prolly_alpha_mask[i & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1));
+                    if ( v20 >= a7 )
+                    {
+                      if ( v20 <= a8 )
+                      {
+                        v21 = a7 + (a6 + v20) % (2 * (a8 - a7));
+                        if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 )
+                          v21 = 2 * a8 - v21 - a7;
+                        //v9 = a5;
+                        //*v10 = a5->pPalette16[v21];
+                        WritePixel16(clipped_out_x + x, clipped_out_y + y, a5->pPalette16[v21]);
+                      }
+                    }
+                  }
+                  v28++;
+              }
+                v28 += v22 - v25;
+            }
+
+            /*if ( v24 > 0 )
             {
               v23 = v22 - v25;
               do
@@ -7853,7 +7903,10 @@
                 v28 += v23;
               }
               while ( v27 < v24 );
-            }
+            }*/
+
+
+
           }
         }
       }
@@ -7866,7 +7919,7 @@
 {
   Texture *pCurrentTexture; // edi@2
   int uHeight; // ebx@4
-  unsigned __int16 *v6; // eax@4
+  //unsigned __int16 *v6; // eax@4
   unsigned int v7; // edx@5
   unsigned int v8; // edx@6
   unsigned int v9; // edx@7
@@ -7893,10 +7946,13 @@
       if ( pTexture->pPalette16 )
       {
         uHeight = pTexture->uTextureHeight;
-        v6 = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch];
+        //v6 = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch];
         v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask;
         uWidth = pTexture->uTextureWidth;
         v18 = pTexture->uTextureWidth;
+
+        int clipped_out_x = uX;
+        int clipped_out_y = uY;
         if ( this->bClip )
         {
           v7 = this->uClipX;
@@ -7905,7 +7961,8 @@
             v8 = v7 - uX;
             v19 += v8;
             uWidth += uX - this->uClipX;
-            v6 += v8;
+            //v6 += v8;
+            clipped_out_x = uClipX;
           }
           v9 = this->uClipY;
           uHeight = pTexture->uTextureHeight;
@@ -7915,7 +7972,8 @@
             v19 += v18 * v10;
             uHeight = uY - this->uClipY + pTexture->uTextureHeight;
             pCurrentTexture = pTexture;
-            v6 += this->uTargetSurfacePitch * v10;
+            //v6 += this->uTargetSurfacePitch * v10;
+            clipped_out_y = uClipY;
           }
           v11 = this->uClipX;
           if ( (signed int)v11 < (signed int)uX )
@@ -7940,7 +7998,19 @@
             uHeight = v14 - v15;
           }
         }
-        if ( (signed int)uHeight > 0 )
+        
+          v16 = v19;
+        for (int y = 0; y < uHeight; ++y)
+        {
+          for (int x = 0; x < uWidth; ++x)
+          {
+                if ( *v16 )
+                  WritePixel16(clipped_out_x + x, clipped_out_y + y, pCurrentTexture->pPalette16[*v16]);
+                ++v16;
+          }
+            v16 += v18 - uWidth;
+        }
+        /*if ( (signed int)uHeight > 0 )
         {
           uYa = uHeight;
           v16 = v19;
@@ -7963,7 +8033,7 @@
             v6 += this->uTargetSurfacePitch - uWidth;
           }
           while ( !uFlag );
-        }
+        }*/
       }
     }
   }
@@ -8159,8 +8229,8 @@
 void Render::DrawTextureIndexed(unsigned int uX, unsigned int uY, Texture *a4)
 {
   Texture *v4; // edi@2
-  unsigned int v5; // ebx@4
-  unsigned __int16 *pTarget; // eax@4
+  int v5; // ebx@4
+  //unsigned __int16 *pTarget; // eax@4
   unsigned int v7; // edx@5
   unsigned int v8; // edx@6
   unsigned int v9; // edx@7
@@ -8168,7 +8238,7 @@
   unsigned int v11; // edx@9
   unsigned int v12; // esi@12
   unsigned int v13; // esi@15
-  unsigned int v14; // edx@17
+  //unsigned int v14; // edx@17
   unsigned int v15; // esi@18
   unsigned __int8 *v16; // edx@22
   char v17; // zf@26
@@ -8187,10 +8257,13 @@
       if ( a4->pPalette16 )
       {
         v5 = a4->uTextureHeight;
-        pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch];
+        //pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch];
         v19 = a4->pLevelOfDetail0_prolly_alpha_mask;
         v20 = a4->uTextureWidth;
         v18 = a4->uTextureWidth;
+
+        int clipped_out_x = uX;
+        int clipped_out_y = uY;
         if ( this->bClip )
         {
           v7 = this->uClipX;
@@ -8199,7 +8272,8 @@
             v8 = v7 - uX;
             v19 += v8;
             v20 += uX - this->uClipX;
-            pTarget += v8;
+            //pTarget += v8;
+            clipped_out_x = uClipX;
           }
           v9 = this->uClipY;
           v5 = a4->uTextureHeight;
@@ -8209,7 +8283,8 @@
             v19 += v18 * v10;
             v5 = uY - this->uClipY + a4->uTextureHeight;
             v4 = a4;
-            pTarget += this->uTargetSurfacePitch * v10;
+            //pTarget += this->uTargetSurfacePitch * v10;
+            clipped_out_y = uClipY;
           }
           v11 = this->uClipX;
           if ( (signed int)v11 < (signed int)uX )
@@ -8225,16 +8300,27 @@
           v13 = this->uClipY;
           if ( (signed int)v13 < (signed int)uY )
             v13 = uY;
-          v14 = this->uClipW;
-          if ( (signed int)(v5 + v13) > (signed int)v14 )
+
+          if ( (signed int)(v5 + v13) > (signed int)uClipW )
           {
             v15 = this->uClipY;
             if ( (signed int)v15 < (signed int)uY )
               v15 = uY;
-            v5 = v14 - v15;
+            v5 = uClipW - v15;
           }
         }
-        if ( (signed int)v5 > 0 )
+        
+          v16 = v19;
+        for (int y = 0; y < v5; ++y)
+        {
+          for (int x = 0; x < v20; ++x)
+          {
+                WritePixel16(clipped_out_x + x, clipped_out_y + y, v4->pPalette16[*v16]);
+                ++v16;
+          }
+            v16 += v18 - v20;
+        }
+        /*if ( (signed int)v5 > 0 )
         {
           uYa = v5;
           v16 = v19;
@@ -8257,7 +8343,7 @@
             pTarget += this->uTargetSurfacePitch - v20;
           }
           while ( !v17 );
-        }
+        }*/
       }
     }
   }
--- a/Render.h	Mon Dec 02 15:13:49 2013 +0200
+++ b/Render.h	Tue Dec 03 20:18:17 2013 +0200
@@ -15,6 +15,9 @@
 struct ODMFace;
 
 
+unsigned __int16 Color16(unsigned __int32 r, unsigned __int32 g, unsigned __int32 b);
+unsigned __int32 Color32(unsigned __int16 color16);
+
 /*  119 */
 #pragma pack(push, 1)
 struct RenderVertexSoft
@@ -228,7 +231,7 @@
   
   void GetAvailableDevices(RenderD3D__DevInfo **pOutDevices);
   void Release();
-  bool CreateDevice(unsigned int uDeviceID, int bWindowed, HWND hWnd);
+  bool CreateDevice(unsigned int uDeviceID, int bWindowed, struct OSWindow *window);
   unsigned int GetDeviceCaps();
   void ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear);
   void Present(bool bForceBlit);
@@ -269,15 +272,15 @@
 
   static Render *Create() {return new Render;}
 
-  bool Initialize(bool bWindowed, OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting);
+  bool Initialize(OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting);
 
 
   bool IsColorKeySupported(IDirectDraw4 *);
-  void _49EBF1();
+  void _stub_49EBF1();
   void ClearBlack();
   void PresentBlackScreen();
   void SavePCXScreenshot();
-  void _49F1BC(const char *a1);
+  void SaveWinnersCertificate(const char *a1);
   void PackPCXpicture(unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size);
   FILE *SavePCXImage(const char *Filename, char *a3, int a4, int a5);
   void ClearTarget(unsigned int uColor);
@@ -328,7 +331,7 @@
   void MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle);
   void TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int dimming_level, RenderBillboard *pBillboard);
   void DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level);
-  int MakeParticleBillboardAndPush_BLV_Software(int screenSpaceX, int screenSpaceY, int z, int lightColor, int a6);
+  //int MakeParticleBillboardAndPush_BLV_Software(int screenSpaceX, int screenSpaceY, int z, int lightColor, int a6);
   void DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9);
   void _4A4CC9_AddSomeBillboard(struct stru6_stru1_indoor_sw_billboard *a1, int diffuse);
   bool LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture);
@@ -348,11 +351,12 @@
   void _4A65CC(unsigned int x, unsigned int y, struct Texture *a4, struct Texture *a5, int a6, int a7, int a8);
   void DrawTransparentRedShade(unsigned int a2, unsigned int a3, struct Texture *a4);
   void DrawTransparentGreenShade(signed int a2, signed int a3, struct Texture *pTexture);
+  void DrawMasked(signed int a2, signed int a3, struct Texture *pTexture, unsigned __int16 mask);
   void GetLeather(unsigned int a2, unsigned int a3, struct Texture *a4, __int16 height);
   void DrawTextPalette(int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8);
   void DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned __int16 *pFontPalette, unsigned __int16 uFaceColor, unsigned __int16 uShadowColor);
   void FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16);
-  int _4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, struct Vec2_int_ *pBitmapXY, unsigned __int16 *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7);
+  void _4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, struct Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7);
   void _4A6E7E(unsigned int a2, unsigned int a3, struct Texture *a4);
   void DrawBuildingsD3D();
   //struct BSPModel *DrawBuildingsSW();
@@ -372,7 +376,7 @@
   void __cdecl sub_4A19B0();
 
   //unsigned int bUserDirect3D;
-  unsigned int bStartInWindow;
+  //unsigned int bStartInWindow;
   unsigned int uDesiredDirect3DDevice;
   unsigned int uAcquiredDirect3DDevice;
   int field_10;
@@ -382,8 +386,8 @@
   int raster_clip_y;    // clipping rect for raster ops
   int raster_clip_z;    //    like RasterLine2D for (mini)map
   int raster_clip_w;
-  __int16 field_2C[65536];
-  __int16 field_2002C[65536];
+  __int16 unused_2C[65536];
+  __int16 unused_2002C[65536];
   int field_4002C;
   int field_40030;
   int *pActiveZBuffer;
@@ -407,7 +411,7 @@
   IDirectDrawSurface2 *pFrontBuffer2;
   IDirectDrawSurface2 *pBackBuffer2;
   IDirectDrawSurface2 *pSomeSurface2;
-  DDPIXELFORMAT ddpfPrimareSuface;
+  DDPIXELFORMAT ddpfPrimarySuface;
   unsigned int uTargetRBits;
   unsigned int uTargetGBits;
   unsigned int uTargetBBits;
@@ -415,17 +419,17 @@
   unsigned int uTargetGMask;
   unsigned int uTargetBMask;
   unsigned int uNumSceneBegins;
-  int *ptr_400E8;
-  unsigned __int16 *pTargetSurface;
+  unsigned __int32 *pTargetSurface_unaligned;
+  void             *pTargetSurface;
   unsigned int uTargetSurfacePitch;
   unsigned int uClipY;
   unsigned int uClipX;
   unsigned int uClipW;
   unsigned int uClipZ;
   unsigned int bClip;
-  unsigned int bColorKeySupported;
+  //unsigned int bColorKeySupported;
   unsigned int uNumD3DSceneBegins;
-  int field_40110;
+  int using_software_screen_buffer;
   RenderHWLContainer pD3DBitmaps;
   RenderHWLContainer pD3DSprites;
   unsigned int bUseColoredLights;
@@ -453,9 +457,39 @@
   RenderBillboardD3D pBillboardRenderListD3D[1000];
   unsigned int uNumBillboardsToDraw;
   int field_129834;
-  unsigned int uCurrentlyLockedSurfacePitch;
-  unsigned __int16 *pCurrentlyLockedSurfaceDataPtr;
-  unsigned __int16 *pCurrentlyLockedSoftSurface;
+  //unsigned int uCurrentlyLockedSurfacePitch;
+  //unsigned __int16 *pCurrentlyLockedSurfaceDataPtr;
+  //void             *pCurrentlyLockedSoftSurface;
+
+  inline void WritePixel16(int x, int y, unsigned __int16 color)
+  {
+    if (ddpfPrimarySuface.dwRGBBitCount == 32)
+    {
+      auto p = (unsigned __int32 *)pTargetSurface + x + y * uTargetSurfacePitch;
+      *p = Color32(color);
+    }
+    else if (ddpfPrimarySuface.dwRGBBitCount == 16)
+    {
+      auto p = (unsigned __int16 *)pTargetSurface + x + y * uTargetSurfacePitch;
+      *p = color;
+    }
+    else __debugbreak();
+  }
+
+  inline unsigned __int16 ReadPixel16(int x, int y)
+  {
+    if (ddpfPrimarySuface.dwRGBBitCount == 32)
+    {
+      auto p = (unsigned __int32 *)pTargetSurface + x + y * uTargetSurfacePitch;
+      return Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255);
+    }
+    else if (ddpfPrimarySuface.dwRGBBitCount == 16)
+    {
+      auto p = (unsigned __int16 *)pTargetSurface + x + y * uTargetSurfacePitch;
+      return *p;
+    }
+    else __debugbreak();
+  }
 
 
   //int windowed_mode_width;
@@ -473,7 +507,7 @@
 #pragma pack(push, 1)
 struct RenderBillboardTransform_local0
 {
-  unsigned __int16 *pTarget;
+  void *pTarget;
   int *pTargetZ;
   int uScreenSpaceX;
   int uScreenSpaceY;
--- a/SaveLoad.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/SaveLoad.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -669,7 +669,7 @@
   free(pSave);
 }
 //----- (0045E03A) --------------------------------------------------------
-unsigned short * MakeScreenshot( signed int width, signed int height )
+unsigned short *MakeScreenshot( signed int width, signed int height )
 {
   //signed int v2; // edi@1
   unsigned __int16 *v3; // ebx@1
@@ -710,8 +710,9 @@
   memset(pPixels, 0 , 2 * height * width);
 
   v3 = pPixels;
-  if ( pRenderer->pRenderD3D )
-  {
+  if (!pRenderer->pRenderD3D)
+    __debugbreak();
+
     pRenderer->BeginSceneD3D();
 
     if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
@@ -774,8 +775,9 @@
         while ( v4 );
       }
     }
-  }
-  else
+
+    
+  /*if (!pRenderer->pRenderD3D)
   {
     pRenderer->BeginScene();
     if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
@@ -828,7 +830,7 @@
       }
     }
     pRenderer->EndScene();
-  }
+  }*/
   return pPixels;
 }
 //----- (0045E26C) --------------------------------------------------------
--- a/Texture.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/Texture.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -684,6 +684,12 @@
   case 12:  field_1E = 4095; break;
 	  }
 
+  unsigned int r_mask = 0xF800;
+  unsigned int num_r_bits = 5;
+  unsigned int g_mask = 0x07E0;
+  unsigned int num_g_bits = 6;
+  unsigned int b_mask = 0x001F;
+  unsigned int num_b_bits = 5;
  
  read_offset = 128;
  if (psx_head2.planes != 3)
@@ -717,10 +723,7 @@
          ++row_position;
           //*temp_dec_position =0xFF000000;
 		  //*temp_dec_position|=(unsigned long)value<<16;
-         *temp_dec_position |= LOWORD(pRenderer->uTargetRMask) & ((unsigned __int8)value << (LOBYTE(pRenderer->uTargetGBits)
-                                                                                    + LOBYTE(pRenderer->uTargetRBits)
-                                                                                    + LOBYTE(pRenderer->uTargetBBits)
-                                                                                    - 8));
+         *temp_dec_position |= r_mask & ((unsigned __int8)value << (num_g_bits + num_r_bits + num_b_bits - 8));
 
 		   temp_dec_position++;
        if (row_position == psx_head2.pitch)
@@ -735,10 +738,7 @@
 	   //*temp_dec_position =0xFF000000; 
 	  //*temp_dec_position|= (unsigned long)test_byte<<16;
        
-       *temp_dec_position |= LOWORD(pRenderer->uTargetRMask) & ((unsigned __int8)test_byte << (LOBYTE(pRenderer->uTargetGBits)
-                                                                                    + LOBYTE(pRenderer->uTargetRBits)
-                                                                                    + LOBYTE(pRenderer->uTargetBBits)
-                                                                                    - 8));
+       *temp_dec_position |= r_mask & ((unsigned __int8)test_byte << (num_g_bits + num_r_bits + num_b_bits - 8));
 
        temp_dec_position++;
       }
@@ -766,9 +766,7 @@
         //*temp_dec_position|= (unsigned int)value<<8;
 		//temp_dec_position++;
          
-         *temp_dec_position|= pRenderer->uTargetGMask & (unsigned __int16)((unsigned __int8)value << (LOBYTE(pRenderer->uTargetGBits)
-                                                                                             + LOBYTE(pRenderer->uTargetBBits)
-                                                                                             - 8));
+         *temp_dec_position|= g_mask & (unsigned __int16)((unsigned __int8)value << (num_g_bits + num_b_bits - 8));
          
        temp_dec_position++;
         ++row_position;
@@ -784,9 +782,7 @@
       //*temp_dec_position |=(unsigned int) test_byte<<8;
 	  //temp_dec_position++;
        
-         *temp_dec_position|= pRenderer->uTargetGMask & (unsigned __int16)((unsigned __int8)test_byte << (LOBYTE(pRenderer->uTargetGBits)
-                                                                                             + LOBYTE(pRenderer->uTargetBBits)
-                                                                                             - 8));
+         *temp_dec_position|= g_mask & (unsigned __int16)((unsigned __int8)test_byte << (num_g_bits + num_b_bits - 8));
        temp_dec_position++;
       ++row_position;
      }
@@ -811,7 +807,7 @@
         //*temp_dec_position|= value;
 		 //temp_dec_position++;
 
-         *temp_dec_position |= value >> (8 - LOBYTE(pRenderer->uTargetBBits));
+         *temp_dec_position |= value >> (8 - num_b_bits);
        temp_dec_position++;
 
         ++row_position;
@@ -825,7 +821,7 @@
      {
       //*temp_dec_position|= test_byte;
 	   //temp_dec_position++;
-         *temp_dec_position |= test_byte >> (8 - LOBYTE(pRenderer->uTargetBBits));
+         *temp_dec_position |= test_byte >> (8 - num_b_bits);
        temp_dec_position++;
 
       ++row_position;
--- a/UI/Books/UIMapBook.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/UI/Books/UIMapBook.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -311,12 +311,12 @@
   unsigned __int16 v69; // cx@99
   signed int v73; // [sp-4h] [bp-48068h]@59
   unsigned __int16 v74; // [sp-4h] [bp-48068h]@79
-  unsigned short map_texture_16[147456]; // [sp+Ch] [bp-48058h]@23
+  //unsigned short map_texture_16[320 * 460 + 256]; // [sp+Ch] [bp-48058h]@23
   int v76; // [sp+4800Ch] [bp-58h]@23
-  unsigned __int16 *v77; // [sp+48010h] [bp-54h]@27
+  //unsigned __int16 *v77; // [sp+48010h] [bp-54h]@27
   unsigned __int16 *pPalette_16; // [sp+48014h] [bp-50h]@23
   int map_tile_X; // [sp+48020h] [bp-44h]@23
-  unsigned __int16* render16_data;
+  //unsigned __int16* render16_data;
   unsigned char* texture8_data;
   unsigned char* curr_line;
   int scale_increment;
@@ -339,7 +339,7 @@
   int map_tile_Y; // [sp+4805Ch] [bp-8h]@10
   const void *v97; // [sp+48060h] [bp-4h]@16
   unsigned short *a4a; // [sp+4806Ch] [bp+8h]@85
-  int a5a; // [sp+48070h] [bp+Ch]@86
+  //int a5a; // [sp+48070h] [bp+Ch]@86
 
   screenCenter_X = (signed int)(tl_x + br_x) / 2;
   screenCenterY = (signed int)(tl_y + br_y) / 2;
@@ -366,7 +366,7 @@
   {
     screenWidth = br_x - tl_x + 1;
     screenHeight = br_y - tl_y + 1;
-    render16_data = &pRenderer->pTargetSurface[tl_x + tl_y * pRenderer->uTargetSurfacePitch];
+    //render16_data = &pRenderer->pTargetSurface[tl_x + tl_y * pRenderer->uTargetSurfacePitch];
     texture8_data = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0_prolly_alpha_mask;
     pPalette_16 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
     scale_increment = (1 << (pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2 + 16)) / viewparams->uMapBookMapZoom;
@@ -390,24 +390,26 @@
         for( uint j = 0; j < screenWidth; ++j )
         {
           scaled_posX=stepX_r>>16;
-          map_texture_16[i*screenWidth+j]=pPalette_16[*(curr_line+scaled_posX)];
+          //map_texture_16[i*screenWidth+j]=pPalette_16[*(curr_line+scaled_posX)];
+          pRenderer->WritePixel16(tl_x + j, tl_y + i, pPalette_16[*(curr_line+scaled_posX)]);
           stepX_r+=scale_increment;      
         }
         stepY_r+=scale_increment;
         scaled_posY=stepY_r>>16;
       }
     }
-    //move visible square to render
+
+    /*//move visible square to render
     for( uint i = 0; i < screenHeight; ++i )
     {
       if ( screenWidth > 0 )
         memcpy((void*)&render16_data[pRenderer->uTargetSurfacePitch * i],(void*)&map_texture_16[i*screenWidth], screenWidth*2);
-    }
+    }*/
   }
   else
   {
-    black = TargetColor(0, 0, 0);
-    teal = TargetColor(0, 0xFFu, 0xFFu);
+    black = Color16(0, 0, 0);
+    teal = Color16(0, 0xFFu, 0xFFu);
     uNumBlueFacesInBLVMinimap = 0;
     if ( pIndoor->pMapOutlines->uNumOutlines )
     {
@@ -535,14 +537,14 @@
         {
           if ( viewparams->uMapBookMapZoom > 512 )
           {
-            pRenderer->RasterLine2D(v54 - 1, v55 - 1, v54 - 1, v55 + 1, TargetColor(0xFFu, 0xFFu, 0xFFu));
-            pRenderer->RasterLine2D(v54,     v55 - 1, v54,     v55 + 1, TargetColor(0xFFu, 0xFFu, 0xFFu));
-            pRenderer->RasterLine2D(v54 + 1, v55 - 1, v54 + 1, v55 + 1, TargetColor(0xFFu, 0xFFu, 0xFFu));
+            pRenderer->RasterLine2D(v54 - 1, v55 - 1, v54 - 1, v55 + 1, Color16(0xFFu, 0xFFu, 0xFFu));
+            pRenderer->RasterLine2D(v54,     v55 - 1, v54,     v55 + 1, Color16(0xFFu, 0xFFu, 0xFFu));
+            pRenderer->RasterLine2D(v54 + 1, v55 - 1, v54 + 1, v55 + 1, Color16(0xFFu, 0xFFu, 0xFFu));
           }
           else
             pRenderer->RasterLine2D(v54, screenCenterY - (int)v97,
                    ((unsigned __int64)((signed int)v93 * (signed __int64)viewparams->uMapBookMapZoom) >> 16) + screenCenter_X,
-                   screenCenterY - (int)v97, TargetColor(0xFFu, 0xFFu, 0xFFu));
+                   screenCenterY - (int)v97, Color16(0xFFu, 0xFFu, 0xFFu));
         }
       }
     }
@@ -551,7 +553,7 @@
   {
     screenCenterY = br_x - tl_x + 1;
     v95 = br_y - tl_y + 1;
-    v77 = &pRenderer->pTargetSurface[tl_x + tl_y * pRenderer->uTargetSurfacePitch];
+    //v77 = &pRenderer->pTargetSurface[tl_x + tl_y * pRenderer->uTargetSurfacePitch];
     black = (1 << (pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2 + 16)) / viewparams->uMapBookMapZoom;
     v57 = (double)(1 << (16 - pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2));
     v60 = (int)((signed __int64)((double)(viewparams->sViewCenterX - (22528 / (viewparams->uMapBookMapZoom / 384)) + 32768) / v57)) << 16;
@@ -560,7 +562,37 @@
     v97 = (const void *)((int)((signed __int64)((double)(viewparams->sViewCenterX - (22528 / (viewparams->uMapBookMapZoom / 384)) + 32768) / v57)) << 16);
     v62 = (int)((signed __int64)((double)(32768 - (22528 / (viewparams->uMapBookMapZoom / 384)) - pCenterY) / v57)) << 16;
     v63 = (signed __int16)((signed __int64)((double)(32768 - (22528 / (viewparams->uMapBookMapZoom / 384)) - pCenterY) / v57));
-    a4a = map_texture_16;
+
+
+    for (int y = 0; y < (signed int)v95; ++y)
+    {
+        map_tile_Y = (v63 - 80) / 4;
+        v64 = teal;
+        for (int x = 0; x < screenCenterY; ++x)
+        {
+          map_tile_X = (v64 - 80) / 4;
+          if ( !pOutdoor->_47F04C(map_tile_X, map_tile_Y) )
+          {
+            if ( pOutdoor->_47F097(map_tile_X, map_tile_Y) )
+            {
+              if ( !((x + screenCenter_X) % 2) )
+                //*a4a = Color16(12, 12, 12);
+                  pRenderer->WritePixel16(tl_x + x, tl_y + y, Color16(12, 12, 12));
+            }
+            else
+              //*a4a = 0;
+                  pRenderer->WritePixel16(tl_x + x, tl_y + y, Color16(0, 0, 0));
+          }
+          v97 = (char *)v97 + black;
+          v64 = (signed int)v97 >> 16;
+        }
+
+      v62 += black;
+      v97 = (const void *)v60;
+      v63 = v62 >> 16;
+      teal = (unsigned int)pPalette_16;
+    }
+    /*a4a = map_texture_16;
     for ( screenCenter_X = 0; screenCenter_X < (signed int)v95; ++screenCenter_X )
     {
       if ( screenCenterY > 0 )
@@ -575,7 +607,7 @@
             if ( pOutdoor->_47F097(map_tile_X, map_tile_Y) )
             {
               if ( !((a5a + screenCenter_X) % 2) )
-                *a4a = TargetColor(0xCu, 0xCu, 0xCu);
+                *a4a = Color16(0xCu, 0xCu, 0xCu);
             }
             else
               *a4a = 0;
@@ -591,6 +623,7 @@
       v63 = v62 >> 16;
       teal = (unsigned int)pPalette_16;
     }
+
     v66 = map_texture_16;
     if ( (signed int)v95 > 0 )
     {
@@ -611,7 +644,7 @@
         }
         v67 = (unsigned __int16 *)((char *)v67 + result);
       }
-    }
+    }*/
   }
 }
 
--- a/UI/UICharacter.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/UI/UICharacter.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -89,101 +89,101 @@
 
 void set_default_ui_skin()
 {
-  ui_mainmenu_copyright_color = TargetColor(255, 255, 255);
+  ui_mainmenu_copyright_color = Color16(255, 255, 255);
 
-  ui_character_tooltip_header_default_color = TargetColor(255, 255, 155);
-  ui_character_default_text_color = TargetColor(255, 255, 255);
-  ui_character_header_text_color = TargetColor(255, 255, 155);
-  ui_character_bonus_text_color = TargetColor(0, 255, 0);
-  ui_character_bonus_text_color_neg = TargetColor(255, 0, 0);
+  ui_character_tooltip_header_default_color = Color16(255, 255, 155);
+  ui_character_default_text_color = Color16(255, 255, 255);
+  ui_character_header_text_color = Color16(255, 255, 155);
+  ui_character_bonus_text_color = Color16(0, 255, 0);
+  ui_character_bonus_text_color_neg = Color16(255, 0, 0);
 
-  ui_character_skill_upgradeable_color = TargetColor(0, 175, 255);
-  ui_character_skill_default_color = TargetColor(255, 0, 0);
-  ui_character_skill_highlight_color = TargetColor(255, 0, 0);  
+  ui_character_skill_upgradeable_color = Color16(0, 175, 255);
+  ui_character_skill_default_color = Color16(255, 0, 0);
+  ui_character_skill_highlight_color = Color16(255, 0, 0);  
   
-  ui_character_stat_default_color = TargetColor(255, 255, 255);
-  ui_character_stat_buffed_color = TargetColor(0,   255,   0);
-  ui_character_stat_debuffed_color = TargetColor(255,  35,   0);
+  ui_character_stat_default_color = Color16(255, 255, 255);
+  ui_character_stat_buffed_color = Color16(0,   255,   0);
+  ui_character_stat_debuffed_color = Color16(255,  35,   0);
   
-  ui_character_skillinfo_can_learn = TargetColor(255, 255, 255);
-  ui_character_skillinfo_can_learn_gm = TargetColor(255, 255, 0);
-  ui_character_skillinfo_cant_learn = TargetColor(255, 0, 0);
+  ui_character_skillinfo_can_learn = Color16(255, 255, 255);
+  ui_character_skillinfo_can_learn_gm = Color16(255, 255, 0);
+  ui_character_skillinfo_cant_learn = Color16(255, 0, 0);
   
-  ui_character_condition_normal_color = TargetColor(255, 255, 255);
-  ui_character_condition_light_color = TargetColor(0, 255, 0);
-  ui_character_condition_moderate_color = TargetColor(225, 205, 35);
-  ui_character_condition_severe_color = TargetColor(255, 35, 0);
+  ui_character_condition_normal_color = Color16(255, 255, 255);
+  ui_character_condition_light_color = Color16(0, 255, 0);
+  ui_character_condition_moderate_color = Color16(225, 205, 35);
+  ui_character_condition_severe_color = Color16(255, 35, 0);
 
-  ui_character_award_color[0] = TargetColor(248, 108, 160);
-  ui_character_award_color[1] = TargetColor(112, 220, 248);
-  ui_character_award_color[2] = TargetColor(192, 192, 240);
-  ui_character_award_color[3] = TargetColor( 64, 244,  96);
-  ui_character_award_color[4] = TargetColor(232, 244,  96);
-  ui_character_award_color[5] = TargetColor(240, 252, 192);
+  ui_character_award_color[0] = Color16(248, 108, 160);
+  ui_character_award_color[1] = Color16(112, 220, 248);
+  ui_character_award_color[2] = Color16(192, 192, 240);
+  ui_character_award_color[3] = Color16( 64, 244,  96);
+  ui_character_award_color[4] = Color16(232, 244,  96);
+  ui_character_award_color[5] = Color16(240, 252, 192);
   
-  ui_game_minimap_outline_color = TargetColor(0, 0, 255);
-  ui_game_minimap_actor_friendly_color = TargetColor(0, 255, 0);
-  ui_game_minimap_actor_hostile_color = TargetColor(255, 0, 0);
-  ui_game_minimap_actor_corpse_color = TargetColor(255, 255, 0);
-  ui_game_minimap_decoration_color_1 = TargetColor(255, 255, 255);
-  ui_game_minimap_projectile_color = TargetColor(255, 0, 0);
-  ui_game_minimap_treasure_color = TargetColor(0, 0, 255);
+  ui_game_minimap_outline_color = Color16(0, 0, 255);
+  ui_game_minimap_actor_friendly_color = Color16(0, 255, 0);
+  ui_game_minimap_actor_hostile_color = Color16(255, 0, 0);
+  ui_game_minimap_actor_corpse_color = Color16(255, 255, 0);
+  ui_game_minimap_decoration_color_1 = Color16(255, 255, 255);
+  ui_game_minimap_projectile_color = Color16(255, 0, 0);
+  ui_game_minimap_treasure_color = Color16(0, 0, 255);
 
-  ui_game_character_record_playerbuff_colors[0] = TargetColor(150, 212, 255);
-  ui_game_character_record_playerbuff_colors[1] = TargetColor(225, 225, 225);
-  ui_game_character_record_playerbuff_colors[2] = TargetColor(255, 128, 0);
-  ui_game_character_record_playerbuff_colors[3] = TargetColor(128, 128, 128);
-  ui_game_character_record_playerbuff_colors[4] = TargetColor(225, 225, 225);
-  ui_game_character_record_playerbuff_colors[5] = TargetColor(255, 85, 0);
-  ui_game_character_record_playerbuff_colors[6] = TargetColor(255, 128, 0);
-  ui_game_character_record_playerbuff_colors[7] = TargetColor(255, 85, 0);
-  ui_game_character_record_playerbuff_colors[8] = TargetColor(225, 225, 225);
-  ui_game_character_record_playerbuff_colors[9] = TargetColor(235, 15, 255);
-  ui_game_character_record_playerbuff_colors[10] = TargetColor(192, 192, 240);
-  ui_game_character_record_playerbuff_colors[11] = TargetColor(225, 225, 225);
-  ui_game_character_record_playerbuff_colors[12] = TargetColor(255, 128, 0);
-  ui_game_character_record_playerbuff_colors[13] = TargetColor(150, 212, 255);
-  ui_game_character_record_playerbuff_colors[14] = TargetColor(128, 128, 128);
-  ui_game_character_record_playerbuff_colors[15] = TargetColor(255, 255, 155);
-  ui_game_character_record_playerbuff_colors[16] = TargetColor(255, 255, 155);
-  ui_game_character_record_playerbuff_colors[17] = TargetColor(255, 255, 155);
-  ui_game_character_record_playerbuff_colors[18] = TargetColor(255, 255, 155);
-  ui_game_character_record_playerbuff_colors[19] = TargetColor(255, 255, 155);
-  ui_game_character_record_playerbuff_colors[20] = TargetColor(255, 255, 155);
-  ui_game_character_record_playerbuff_colors[21] = TargetColor(255, 255, 155);
-  ui_game_character_record_playerbuff_colors[22] = TargetColor(0, 128, 255);
-  ui_game_character_record_playerbuff_colors[23] = TargetColor(0, 128, 255);
+  ui_game_character_record_playerbuff_colors[0] = Color16(150, 212, 255);
+  ui_game_character_record_playerbuff_colors[1] = Color16(225, 225, 225);
+  ui_game_character_record_playerbuff_colors[2] = Color16(255, 128, 0);
+  ui_game_character_record_playerbuff_colors[3] = Color16(128, 128, 128);
+  ui_game_character_record_playerbuff_colors[4] = Color16(225, 225, 225);
+  ui_game_character_record_playerbuff_colors[5] = Color16(255, 85, 0);
+  ui_game_character_record_playerbuff_colors[6] = Color16(255, 128, 0);
+  ui_game_character_record_playerbuff_colors[7] = Color16(255, 85, 0);
+  ui_game_character_record_playerbuff_colors[8] = Color16(225, 225, 225);
+  ui_game_character_record_playerbuff_colors[9] = Color16(235, 15, 255);
+  ui_game_character_record_playerbuff_colors[10] = Color16(192, 192, 240);
+  ui_game_character_record_playerbuff_colors[11] = Color16(225, 225, 225);
+  ui_game_character_record_playerbuff_colors[12] = Color16(255, 128, 0);
+  ui_game_character_record_playerbuff_colors[13] = Color16(150, 212, 255);
+  ui_game_character_record_playerbuff_colors[14] = Color16(128, 128, 128);
+  ui_game_character_record_playerbuff_colors[15] = Color16(255, 255, 155);
+  ui_game_character_record_playerbuff_colors[16] = Color16(255, 255, 155);
+  ui_game_character_record_playerbuff_colors[17] = Color16(255, 255, 155);
+  ui_game_character_record_playerbuff_colors[18] = Color16(255, 255, 155);
+  ui_game_character_record_playerbuff_colors[19] = Color16(255, 255, 155);
+  ui_game_character_record_playerbuff_colors[20] = Color16(255, 255, 155);
+  ui_game_character_record_playerbuff_colors[21] = Color16(255, 255, 155);
+  ui_game_character_record_playerbuff_colors[22] = Color16(0, 128, 255);
+  ui_game_character_record_playerbuff_colors[23] = Color16(0, 128, 255);
 
-  ui_gamemenu_video_gamma_title_color = TargetColor(255, 255, 155);
-  ui_gamemenu_keys_action_name_color = TargetColor(255, 255, 255);
-  ui_gamemenu_keys_key_selection_blink_color_1 = TargetColor(50, 0, 0);
-  ui_gamemenu_keys_key_selection_blink_color_2 = TargetColor(225, 205, 35);
-  ui_gamemenu_keys_key_default_color = TargetColor(255, 255, 255);
+  ui_gamemenu_video_gamma_title_color = Color16(255, 255, 155);
+  ui_gamemenu_keys_action_name_color = Color16(255, 255, 255);
+  ui_gamemenu_keys_key_selection_blink_color_1 = Color16(50, 0, 0);
+  ui_gamemenu_keys_key_selection_blink_color_2 = Color16(225, 205, 35);
+  ui_gamemenu_keys_key_default_color = Color16(255, 255, 255);
 
-  ui_book_quests_title_color = TargetColor(255, 255, 255);
-  ui_book_quests_text_color = TargetColor(255, 255, 255);
-  ui_book_autonotes_title_color = TargetColor(255, 255, 255);
-  ui_book_autonotes_text_color = TargetColor(255, 255, 255);
-  ui_book_map_title_color = TargetColor(255, 255, 255);
-  ui_book_map_coordinates_color = TargetColor(255, 255, 255);
+  ui_book_quests_title_color = Color16(255, 255, 255);
+  ui_book_quests_text_color = Color16(255, 255, 255);
+  ui_book_autonotes_title_color = Color16(255, 255, 255);
+  ui_book_autonotes_text_color = Color16(255, 255, 255);
+  ui_book_map_title_color = Color16(255, 255, 255);
+  ui_book_map_coordinates_color = Color16(255, 255, 255);
 
-  ui_book_calendar_title_color = TargetColor(255, 255, 255);
-  ui_book_calendar_time_color = TargetColor(75, 75, 75);
-  ui_book_calendar_day_color = TargetColor(75, 75, 75);
-  ui_book_calendar_month_color = TargetColor(75, 75, 75);
-  ui_book_calendar_year_color = TargetColor(75, 75, 75);
-  ui_book_calendar_moon_color = TargetColor(75, 75, 75);
-  ui_book_calendar_location_color = TargetColor(75, 75, 75);
+  ui_book_calendar_title_color = Color16(255, 255, 255);
+  ui_book_calendar_time_color = Color16(75, 75, 75);
+  ui_book_calendar_day_color = Color16(75, 75, 75);
+  ui_book_calendar_month_color = Color16(75, 75, 75);
+  ui_book_calendar_year_color = Color16(75, 75, 75);
+  ui_book_calendar_moon_color = Color16(75, 75, 75);
+  ui_book_calendar_location_color = Color16(75, 75, 75);
 
-  ui_book_journal_title_color = TargetColor(255, 255, 255);
-  ui_book_journal_text_color = TargetColor(255, 255, 255);
-  ui_book_journal_text_shadow = TargetColor(0, 0, 0);
+  ui_book_journal_title_color = Color16(255, 255, 255);
+  ui_book_journal_text_color = Color16(255, 255, 255);
+  ui_book_journal_text_shadow = Color16(0, 0, 0);
 
-  ui_game_dialogue_npc_name_color = TargetColor(21, 153, 233);
-  ui_game_dialogue_option_highlight_color = TargetColor(225, 205, 35);
-  ui_game_dialogue_option_normal_color = TargetColor(255, 255, 255);
+  ui_game_dialogue_npc_name_color = Color16(21, 153, 233);
+  ui_game_dialogue_option_highlight_color = Color16(225, 205, 35);
+  ui_game_dialogue_option_normal_color = Color16(255, 255, 255);
 
-  ui_house_player_cant_interact_color = TargetColor(255, 255, 155);
+  ui_house_player_cant_interact_color = Color16(255, 255, 155);
 }
 
 std::array<unsigned int, 16> papredoll_dbrds;
--- a/UI/UIGuilds.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/UI/UIGuilds.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -52,7 +52,7 @@
             guild_mambership_flags[(unsigned int)window_SpeakInHouse->ptr_1C - 139]) )
     { //you must me member
       pTextHeight = pFontArrus->CalcTextHeight(pNPCTopics[121].pText, &working_window, 0, 0);
-      working_window.DrawTitleText(pFontArrus, 0, (212 - pTextHeight) / 2 + 101, TargetColor(0xFFu, 0xFFu, 0x9Bu), pNPCTopics[121].pText, 3);
+      working_window.DrawTitleText(pFontArrus, 0, (212 - pTextHeight) / 2 + 101, Color16(0xFFu, 0xFFu, 0x9Bu), pNPCTopics[121].pText, 3);
       pDialogueWindow->pNumPresenceButton = 0;
       return;
     }
@@ -64,7 +64,7 @@
       strcat(pTmpBuf.data(), "\n \n");
       strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further."
       pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &working_window, 0, 0);
-      working_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
+      working_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, Color16(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
       return;
     }
     v61 = 0;
@@ -95,7 +95,7 @@
       strcat(pTmpBuf.data(), "\n \n");
       strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further."
       pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &working_window, 0, 0);
-      working_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
+      working_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, Color16(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
       return;
     }
     if ( pSkillFlag )
@@ -118,9 +118,9 @@
         pButton->uHeight = pTextHeight;
         v26 = pButton->uY + pTextHeight - 1;
         pButton->uW = v26;
-        pTextColor = TargetColor(0xFFu, 0xFFu, 0x9Bu);
+        pTextColor = Color16(0xFFu, 0xFFu, 0x9Bu);
         if ( pDialogueWindow->pCurrentPosActiveItem != i )
-          pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
+          pTextColor = Color16(0xFFu, 0xFFu, 0xFFu);
         working_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pGlobalTXT_LocalizationStrings[400], 3);//"Buy Spells"
       }
       else
@@ -133,9 +133,9 @@
           pButton->uHeight = pTextHeight;
           v26 = pButton->uY + pTextHeight - 1;
           pButton->uW = v26;
-          pTextColor = TargetColor(0xFFu, 0xFFu, 0x9Bu);
+          pTextColor = Color16(0xFFu, 0xFFu, 0x9Bu);
           if ( pDialogueWindow->pCurrentPosActiveItem != i )
-            pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
+            pTextColor = Color16(0xFFu, 0xFFu, 0xFFu);
           working_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pSkillNames[pButton->msg_param - 36], 3);
         }
         else
@@ -198,7 +198,7 @@
         v17 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction( (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)window_SpeakInHouse->ptr_1C, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C,  2);
         v18 = BuildDialogueString(pMerchantsBuyPhrases[v17], uActiveCharacter - 1, v15, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
         pTextHeight = pFontArrus->CalcTextHeight(v18, &working_window, 0, 0);
-        working_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138,  TargetColor(0xFFu, 0xFFu, 0xFFu), v18, 3);
+        working_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138,  Color16(0xFFu, 0xFFu, 0xFFu), v18, 3);
         return;
       }
     }
--- a/UI/UIHouses.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/UI/UIHouses.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -1459,9 +1459,9 @@
         {
   //get color for current string(определение цвета текущей строки)----------
           if ( pDialogueWindow->pCurrentPosActiveItem == pCurrentButton )
-            sprintf(pTopicArray[index], "\f%05d", TargetColor(255, 255, 155));
+            sprintf(pTopicArray[index], "\f%05d", Color16(255, 255, 155));
           else
-            sprintf(pTopicArray[index], "\f%05d", TargetColor(255, 255, 255));
+            sprintf(pTopicArray[index], "\f%05d", Color16(255, 255, 255));
   //hired NPC premium(премия наёмного НПС)----------------------------------
           travel_time = transport_schedule[schedule_id].uTravelTime;
           if ( (unsigned int)window_SpeakInHouse->ptr_1C >= HOUSE_BOATS_EMERALD_ISLE )
@@ -1517,7 +1517,7 @@
       else
       {
         travel_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[561], &travel_window, 0, 0)) / 2 + 138,//"Извините, приходите в другой день"
-                          TargetColor(255, 255, 255), pGlobalTXT_LocalizationStrings[561], 3);
+                          Color16(255, 255, 255), pGlobalTXT_LocalizationStrings[561], 3);
         pAudioPlayer->StopChannels(-1, -1);
       }
     }
@@ -1647,7 +1647,7 @@
   townHall_window.uFrameWidth = 148;
   townHall_window.uFrameZ = 334;
   sprintf(pTmpBuf.data(), "%s: %d", pGlobalTXT_LocalizationStrings[605], pParty->uFine);//Текущий штраф
-  townHall_window.DrawTitleText(pFontArrus, 0, 260, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
+  townHall_window.DrawTitleText(pFontArrus, 0, 260, Color16(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
   switch(dialog_menu_id)
   {
     case HOUSE_DIALOGUE_MAIN:
@@ -1678,9 +1678,9 @@
           pButton->uHeight = pTextHeight;
           v17 = pButton->uY + pTextHeight - 1;
           pButton->uW = v17;
-          pTextColor = TargetColor(0xFFu, 0xFFu, 0x9Bu);
+          pTextColor = Color16(0xFFu, 0xFFu, 0x9Bu);
           if ( pDialogueWindow->pCurrentPosActiveItem != v31 )
-            pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
+            pTextColor = Color16(0xFFu, 0xFFu, 0xFFu);
           townHall_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pShopOptions[j], 3);
           ++v31;
           ++j;
@@ -1690,8 +1690,8 @@
     }
     case HOUSE_DIALOGUE_TOWNHALL_MESSAGE:
     {
-      sprintf(pTmpBuf.data(), "\f%05d%s\f%05d", TargetColor(0xFFu, 0xFFu, 0x9Bu),
-      pMonsterStats->pInfos[bountyHunting_monster_id_for_hunting].pName, TargetColor(0xFFu, 0xFFu, 0xFFu));
+      sprintf(pTmpBuf.data(), "\f%05d%s\f%05d", Color16(0xFFu, 0xFFu, 0x9Bu),
+      pMonsterStats->pInfos[bountyHunting_monster_id_for_hunting].pName, Color16(0xFFu, 0xFFu, 0xFFu));
       sprintf(pTmpBuf2.data(), bountyHunting_text, pTmpBuf.data(), 100 * pMonsterStats->pInfos[bountyHunting_monster_id_for_hunting].uLevel);
       current_npc_text = pTmpBuf2.data();
       memcpy(&window, pDialogueWindow, sizeof(window));
@@ -1714,8 +1714,8 @@
       if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS)
       {
         sprintfex(pTmpBuf.data(), "%s\n%s", pGlobalTXT_LocalizationStrings[606], pGlobalTXT_LocalizationStrings[112]); // "Pay"   "How Much?"
-        townHall_window.DrawTitleText(pFontArrus, 0, 146, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
-        townHall_window.DrawTitleText(pFontArrus, 0, 186, TargetColor(0xFFu, 0xFFu, 0xFFu), (const char *)pKeyActionMap->pPressedKeysBuffer, 3);
+        townHall_window.DrawTitleText(pFontArrus, 0, 146, Color16(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
+        townHall_window.DrawTitleText(pFontArrus, 0, 186, Color16(0xFFu, 0xFFu, 0xFFu), (const char *)pKeyActionMap->pPressedKeysBuffer, 3);
         townHall_window.DrawFlashingInputCursor(pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer) / 2 + 80, 185, pFontArrus);
         return;
       }
@@ -1768,18 +1768,18 @@
   bank_window.uFrameWidth = 148;
   bank_window.uFrameZ = 334;
   sprintf(pTmpBuf.data(), "%s: %d", pGlobalTXT_LocalizationStrings[25], pParty->uNumGoldInBank);//Баланс
-  bank_window.DrawTitleText(pFontArrus, 0, 220, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
+  bank_window.DrawTitleText(pFontArrus, 0, 220, Color16(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
   switch(dialog_menu_id)
   {
     case HOUSE_DIALOGUE_MAIN:
     {
-      pColorText = TargetColor(0xFFu, 0xFFu, 0x9Bu);
+      pColorText = Color16(0xFFu, 0xFFu, 0x9Bu);
       if ( pDialogueWindow->pCurrentPosActiveItem != 2 )
-        pColorText = TargetColor(0xFFu, 0xFFu, 0xFFu);
+        pColorText = Color16(0xFFu, 0xFFu, 0xFFu);
       bank_window.DrawTitleText(pFontArrus, 0, 146, pColorText, pGlobalTXT_LocalizationStrings[60], 3);
-      pColorText = TargetColor(0xFFu, 0xFFu, 0x9Bu);
+      pColorText = Color16(0xFFu, 0xFFu, 0x9Bu);
       if ( pDialogueWindow->pCurrentPosActiveItem != 3 )
-        pColorText = TargetColor(0xFFu, 0xFFu, 0xFFu);
+        pColorText = Color16(0xFFu, 0xFFu, 0xFFu);
       bank_window.DrawTitleText(pFontArrus, 0, 176, pColorText, pGlobalTXT_LocalizationStrings[244], 3);
       break;
     }
@@ -1788,8 +1788,8 @@
       if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS)
       {
         sprintf(pTmpBuf.data(), "%s\n%s", pGlobalTXT_LocalizationStrings[60], pGlobalTXT_LocalizationStrings[112]);//"Положить" "Сколько?"
-        bank_window.DrawTitleText(pFontArrus, 0, 146, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
-        bank_window.DrawTitleText(pFontArrus, 0, 186, TargetColor(0xFFu, 0xFFu, 0xFFu), (const char *)pKeyActionMap->pPressedKeysBuffer, 3);
+        bank_window.DrawTitleText(pFontArrus, 0, 146, Color16(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
+        bank_window.DrawTitleText(pFontArrus, 0, 186, Color16(0xFFu, 0xFFu, 0xFFu), (const char *)pKeyActionMap->pPressedKeysBuffer, 3);
         bank_window.DrawFlashingInputCursor(pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer) / 2 + 80, 185, pFontArrus);
         return;
       }
@@ -1830,8 +1830,8 @@
       if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS)
       {
         sprintfex(pTmpBuf.data(), "%s\n%s", pGlobalTXT_LocalizationStrings[244], pGlobalTXT_LocalizationStrings[112]);//"Снять" "Сколько?"
-        bank_window.DrawTitleText(pFontArrus, 0, 146, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
-        bank_window.DrawTitleText(pFontArrus, 0, 186, TargetColor(0xFFu, 0xFFu, 0xFFu), (const char *)pKeyActionMap->pPressedKeysBuffer, 3);
+        bank_window.DrawTitleText(pFontArrus, 0, 146, Color16(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
+        bank_window.DrawTitleText(pFontArrus, 0, 186, Color16(0xFFu, 0xFFu, 0xFFu), (const char *)pKeyActionMap->pPressedKeysBuffer, 3);
         bank_window.DrawFlashingInputCursor(pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer) / 2 + 80, 185, pFontArrus);
         return;
       }
@@ -1930,27 +1930,27 @@
       if ( !HouseUI_CheckIfPlayerCanInteract() )
           return;
 
-      sprintf(pTopic1, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 2 ? TargetColor(0xFFu, 0xFFu, 0x9Bu) : TargetColor(0xFFu, 0xFFu, 0xFFu));
+      sprintf(pTopic1, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 2 ? Color16(0xFFu, 0xFFu, 0x9Bu) : Color16(0xFFu, 0xFFu, 0xFFu));
       sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[178], pPriceRoom); // Rent room for %d gold
       strcat(pTopic1, pTmpBuf2.data());
       pTopic1Height = pFontArrus->CalcTextHeight(pTopic1, &dialog_window, 0, 0);
       strcat(pTopic1, "\n \n");
 
-      sprintf(pTopic2, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 3 ? TargetColor(0xFFu, 0xFFu, 0x9Bu) : TargetColor(0xFFu, 0xFFu, 0xFFu));
+      sprintf(pTopic2, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 3 ? Color16(0xFFu, 0xFFu, 0x9Bu) : Color16(0xFFu, 0xFFu, 0xFFu));
       sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[86], // Buy food for %d days for %d gold
         (unsigned int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier, pPriceFood);
       strcat(pTopic2, pTmpBuf2.data());
       pTopic2Height = pFontArrus->CalcTextHeight(pTopic2, &dialog_window, 0, 0);
       strcat(pTopic2, "\n \n");
 
-      sprintf(pTopic3, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 4 ? TargetColor(0xFFu, 0xFFu, 0x9Bu) : TargetColor(0xFFu, 0xFFu, 0xFFu));
+      sprintf(pTopic3, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 4 ? Color16(0xFFu, 0xFFu, 0x9Bu) : Color16(0xFFu, 0xFFu, 0xFFu));
       strcat(pTopic3, pGlobalTXT_LocalizationStrings[160]); // Learn Skills
       pTopic3Height = pFontArrus->CalcTextHeight(pTopic3, &dialog_window, 0, 0);
       strcat(pTopic3, "\n \n");
       pTopic4[0] = 0;
       if ( (signed int)window_SpeakInHouse->par1C >= 108 && (signed int)window_SpeakInHouse->par1C <= 120 )
       {
-        sprintf(pTopic4, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 5 ? TargetColor(0xFFu, 0xFFu, 0x9Bu) : TargetColor(0xFFu, 0xFFu, 0xFFu));
+        sprintf(pTopic4, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 5 ? Color16(0xFFu, 0xFFu, 0x9Bu) : Color16(0xFFu, 0xFFu, 0xFFu));
         strcat(pTopic4, pGlobalTXT_LocalizationStrings[611]); // Play Arcomage
         pTopic4Height = pFontArrus->CalcTextHeight(pTopic4, &dialog_window, 0, 0);
       }
@@ -2037,7 +2037,7 @@
       }
       strcpy(pTmpBuf.data(), pText);
       dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138,
-                                  TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
+                                  Color16(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
       break;
     }
     case HOUSE_DIALOGUE_TAVERN_REST:
@@ -2113,9 +2113,9 @@
             pButton->uHeight = pTextHeight;
             v54 = pTextHeight + pButton->uY - 1;
             pButton->uW = v54;
-            pColorText = TargetColor(0xFFu, 0xFFu, 0x9Bu);
+            pColorText = Color16(0xFFu, 0xFFu, 0x9Bu);
             if ( pDialogueWindow->pCurrentPosActiveItem != i )
-              pColorText = TargetColor(0xFFu, 0xFFu, 0xFFu);
+              pColorText = Color16(0xFFu, 0xFFu, 0xFFu);
             dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[pButton->msg_param - 36], 3);
           }
         }
@@ -2126,7 +2126,7 @@
       strcat(pTmpBuf.data(), "\n \n");
       strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);//Больше ничего не могу предложить.
       pTextHeight = (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138;
-      dialog_window.DrawTitleText(pFontArrus, 0, pTextHeight, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
+      dialog_window.DrawTitleText(pFontArrus, 0, pTextHeight, Color16(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
       return;
     }
 
@@ -2181,9 +2181,9 @@
           pButton->uHeight = pTextHeight;
           v54 = pButton->uY + pTextHeight - 1;
           pButton->uW = v54;
-          pColorText = TargetColor(0xFFu, 0xFFu, 0x9Bu);
+          pColorText = Color16(0xFFu, 0xFFu, 0x9Bu);
           if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
-            pColorText = TargetColor(0xFFu, 0xFFu, 0xFFu);
+            pColorText = Color16(0xFFu, 0xFFu, 0xFFu);
           dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
           ++pNumString;
         }
@@ -2259,9 +2259,9 @@
         pButton->uHeight = pTextHeight;
         pButton->uW = pButton->uY + pTextHeight - 1;
         all_text_height = pButton->uW;
-        pTextColor = TargetColor(0xFFu, 0xFFu, 0x9Bu);
+        pTextColor = Color16(0xFFu, 0xFFu, 0x9Bu);
         if ( pDialogueWindow->pCurrentPosActiveItem != index + 2 )
-          pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
+          pTextColor = Color16(0xFFu, 0xFFu, 0xFFu);
         tample_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pShopOptions[1 * i], 3);
         i++;
         index++;
@@ -2441,9 +2441,9 @@
               pButton->uHeight = pTextHeight;
               pButton->uW = pButton->uY + pTextHeight - 1;
               all_text_height = pButton->uW;
-              pTextColor = TargetColor(0xFFu, 0xFFu, 0x9Bu);
+              pTextColor = Color16(0xFFu, 0xFFu, 0x9Bu);
               if ( pDialogueWindow->pCurrentPosActiveItem != pCurrentItem )
-                pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
+                pTextColor = Color16(0xFFu, 0xFFu, 0xFFu);
               tample_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pSkillNames[pButton->msg_param - 36], 3);
             }
             pCurrentItem++;
@@ -2456,7 +2456,7 @@
         strcat(pTmpBuf.data(), "\n \n");
         strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);//"Больше ничего не могу предложить."
         pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &tample_window, 0, 0);
-        tample_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
+        tample_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, Color16(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
       }
     }
   }
@@ -2550,9 +2550,9 @@
             pButton->uHeight = pTextHeight;
             pButton->uW = pTextHeight + pButton->uY - 1;
             v49 = pButton->uW;
-            pTextColor = TargetColor(0xE1u, 0xCDu, 0x23u);
+            pTextColor = Color16(0xE1u, 0xCDu, 0x23u);
             if ( pDialogueWindow->pCurrentPosActiveItem != i )
-              pTextColor = TargetColor(255, 255, 255);
+              pTextColor = Color16(255, 255, 255);
             training_dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pShopOptions[index], 3);
             ++index;
           }
@@ -2565,7 +2565,7 @@
       if ( !HouseUI_CheckIfPlayerCanInteract() )
       {
         v33 = pFontArrus->CalcTextHeight(pNPCTopics[122].pText, &training_dialog_window, 0, 0);
-        training_dialog_window.DrawTitleText(pFontArrus, 0, (212 - v33) / 2 + 101, TargetColor(0xE1u, 0xCDu, 0x23u), pNPCTopics[122].pText, 3);
+        training_dialog_window.DrawTitleText(pFontArrus, 0, (212 - v33) / 2 + 101, Color16(0xE1u, 0xCDu, 0x23u), pNPCTopics[122].pText, 3);
         pDialogueWindow->pNumPresenceButton = 0;
         return;
       }
@@ -2622,7 +2622,7 @@
                                                 // ""Sorry, but we are unable to train you.""
         v36 = (212 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &training_dialog_window, 0, 0)) / 2 + 101;
       }
-      training_dialog_window.DrawTitleText(pFontArrus, 0, v36, TargetColor(0xE1u, 0xCDu, 0x23u), pTmpBuf.data(), 3);
+      training_dialog_window.DrawTitleText(pFontArrus, 0, v36, Color16(0xE1u, 0xCDu, 0x23u), pTmpBuf.data(), 3);
       PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)3);
       pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
       return;
@@ -2674,9 +2674,9 @@
             pButton->uHeight = pTextHeight;
             pButton->uW = pButton->uY + pTextHeight - 1;
             v19 = pButton->uY + pTextHeight - 1;
-            pTextColor = TargetColor(0xE1u, 0xCDu, 0x23u);
+            pTextColor = Color16(0xE1u, 0xCDu, 0x23u);
             if ( pDialogueWindow->pCurrentPosActiveItem != i )
-              pTextColor = TargetColor(255, 255, 255);
+              pTextColor = Color16(255, 255, 255);
             training_dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pSkillNames[pButton->msg_param - 36], 3);
           }
         }
@@ -2688,7 +2688,7 @@
         strcat(pTmpBuf.data(), "\n \n");
         strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further."
         pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &training_dialog_window, 0, 0);
-        training_dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, TargetColor(0xE1u, 0xCDu, 0x23u), pTmpBuf.data(), 3);
+        training_dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, Color16(0xE1u, 0xCDu, 0x23u), pTmpBuf.data(), 3);
       }
     }
   }
@@ -2731,7 +2731,7 @@
     if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)pPlayers[uActiveCharacter]->_achieved_awards_bits, word_4F0754[2 * (unsigned int)window_SpeakInHouse->ptr_1C]) )
     {
       pTextHeight = pFontArrus->CalcTextHeight(pNPCTopics[171].pText, &dialog_window, 0, 0);//
-      dialog_window.DrawTitleText(pFontArrus, 0, (212 - pTextHeight) / 2 + 101, TargetColor(0xFFu, 0xFFu, 0x9Bu), pNPCTopics[171].pText, 3);
+      dialog_window.DrawTitleText(pFontArrus, 0, (212 - pTextHeight) / 2 + 101, Color16(0xFFu, 0xFFu, 0x9Bu), pNPCTopics[171].pText, 3);
       pDialogueWindow->pNumPresenceButton = 0;
       return;
     }
@@ -2755,7 +2755,7 @@
       strcat(pTmpBuf.data(), "\n \n");
       strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);//Больше ничего не могу предложить.
       pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0);
-      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
+      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, Color16(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
       return; 
     }
     sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pPrice);//Стоимость навыка: %lu
@@ -2779,9 +2779,9 @@
             pButton->uHeight = pTextHeight;
             pButton->uW = pButton->uY + pTextHeight - 1;
             index = pButton->uY + pTextHeight - 1;
-            pTextColor = TargetColor(0xFFu, 0xFFu, 0x9Bu);
+            pTextColor = Color16(0xFFu, 0xFFu, 0x9Bu);
             if ( pDialogueWindow->pCurrentPosActiveItem != i )
-              pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
+              pTextColor = Color16(0xFFu, 0xFFu, 0xFFu);
             dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pSkillNames[pButton->msg_param - 36], 3);
           }
         }
@@ -2883,7 +2883,7 @@
     sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[429], pNPC->pName, aNPCProfessionNames[pNPC->uProfession]);//^Pi[%s] %s
   else
     strcpy(pTmpBuf.data(), pNPC->pName);
-  house_window.DrawTitleText(pFontCreate, 483, 113, TargetColor(0x15u, 0x99u, 0xE9u), pTmpBuf.data(), 3);
+  house_window.DrawTitleText(pFontCreate, 483, 113, Color16(0x15u, 0x99u, 0xE9u), pTmpBuf.data(), 3);
   if ( !dword_591080 )
   {
     if ( !uDialogueType )
@@ -2935,7 +2935,7 @@
           strcpy(pButton->pButtonName, v15);
           continue;
         }
-        sprintf(pTmpBuf.data(), format_4E2D80, TargetColor(0xE1u, 0xCDu, 0x23u), pItemsTable->pItems[contract_approved].pUnidentifiedName);
+        sprintf(pTmpBuf.data(), format_4E2D80, Color16(0xE1u, 0xCDu, 0x23u), pItemsTable->pItems[contract_approved].pUnidentifiedName);
         sprintf(pTmpBuf2.data(), current_npc_text, pTmpBuf.data());
         current_npc_text = pTmpBuf2.data();
         strcpy(pButton->pButtonName, v15);
@@ -2991,7 +2991,7 @@
       case 83:
         v29 = pMonsterStats->pInfos[bountyHunting_monster_id_for_hunting].pName;
         v31 = *(int *)v29;
-        sprintfex(pTmpBuf.data(), "\f%05d%s\f%05d", TargetColor(0xFFu, 0xFFu, 0x9Bu), v31, TargetColor(0xFFu, 0xFFu, 0xFFu));
+        sprintfex(pTmpBuf.data(), "\f%05d%s\f%05d", Color16(0xFFu, 0xFFu, 0x9Bu), v31, Color16(0xFFu, 0xFFu, 0xFFu));
         sprintfex(pTmpBuf2.data(), bountyHunting_text, pTmpBuf.data(), 100 * (unsigned __int8)v29[8]);
         current_npc_text = pTmpBuf2.data();
         strcpy(pButton->pButtonName, "");
@@ -3036,9 +3036,9 @@
       pButton->uHeight = pTextHeight;
       v40 = pButton->uY + pTextHeight - 1;
       pButton->uW = v40;
-      pTextColor = TargetColor(0xE1u, 0xCDu, 0x23u);
+      pTextColor = Color16(0xE1u, 0xCDu, 0x23u);
       if ( pDialogueWindow->pCurrentPosActiveItem != i )
-        pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
+        pTextColor = Color16(0xFFu, 0xFFu, 0xFFu);
       right_panel_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pButton->pButtonName, 3);
     }
   }
@@ -3069,5 +3069,5 @@
   jail_dialogue_window.uFrameWidth = 148;
   jail_dialogue_window.uFrameZ = 334;
   jail_dialogue_window.DrawTitleText(pFontArrus, 0, (310 - pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[672], &jail_dialogue_window, 0, 0)) / 2 + 18,
-     TargetColor(0xFFu, 0xFFu, 0x9Bu), pGlobalTXT_LocalizationStrings[672], 3);//"За многочисленные преступления и злодеяния вы были приговорены к одному году заключения."
+     Color16(0xFFu, 0xFFu, 0x9Bu), pGlobalTXT_LocalizationStrings[672], 3);//"За многочисленные преступления и злодеяния вы были приговорены к одному году заключения."
 }
\ No newline at end of file
--- a/UI/UIMainMenu.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/UI/UIMainMenu.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -20,8 +20,10 @@
 //----- (0041B578) --------------------------------------------------------
 void MainMenuUI_LoadFontsAndSomeStuff()
 {
-  pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits);
-  pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits);
+  //pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits);
+  pIcons_LOD->SetupPalettes(5, 6, 5);
+  //pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits);
+  pPaletteManager->SetColorChannelInfo(5, 6, 5);
   pPaletteManager->RecalculateAll();
 
   for (uint i = 0; i < 480; ++i)
@@ -244,7 +246,7 @@
   cred_texture.uHeight = pFontQuick->GetStringHeight2(pFontCChar, cred_texturet, &credit_window, 0, 1) + 2 * credit_window.uFrameHeight;
   cred_texture.uNumPixels = cred_texture.uWidth * cred_texture.uHeight;
   cred_texture.pPixels = (unsigned __int16 *)malloc(2 * cred_texture.uNumPixels);
-  fill_pixels_fast(TargetColor(0, 0xFFu, 0xFFu), cred_texture.pPixels, cred_texture.uNumPixels);
+  fill_pixels_fast(Color16(0, 0xFFu, 0xFFu), cred_texture.pPixels, cred_texture.uNumPixels);
   cred_texture._allocation_flags = 0;
 
   //дать шрифт и цвета тексту
@@ -252,7 +254,7 @@
   strncpy(pString, cred_texturet, pSize);
   pString[pSize] = 0;
   pFontQuick->_44D2FD_prolly_draw_credits_entry(pFontCChar, 0, credit_window.uFrameHeight, cred_texture.uWidth,
-    cred_texture.uHeight, TargetColor(0x70u, 0x8Fu, 0xFEu), TargetColor(0xECu, 0xE6u, 0x9Cu), pString, cred_texture.pPixels, cred_texture.uWidth);
+    cred_texture.uHeight, Color16(0x70u, 0x8Fu, 0xFEu), Color16(0xECu, 0xE6u, 0x9Cu), pString, cred_texture.pPixels, cred_texture.uWidth);
   free(pString);
 
   pWindow_MainMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, cred_texturet);
--- a/UI/UIOptions.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/UI/UIOptions.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -42,7 +42,7 @@
     else
       intensity = + 70 - 70 * time / 800;
 
-    return TargetColor(185 + intensity, 40 + intensity / 4, 40 + intensity / 4);
+    return Color16(185 + intensity, 40 + intensity / 4, 40 + intensity / 4);
   }
 
   return ui_gamemenu_keys_key_default_color;
--- a/UI/UIPartyCreation.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/UI/UIPartyCreation.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -193,7 +193,7 @@
     pGUIWindow_CurrentMenu->DrawTextInRect(pFontCreate, pIntervalX + 72, pIntervalY + 12, 0, pTmpBuf.data(), 130, 0);//Race Name
 
     pTextCenter = pFontCreate->AlignText_Center(150, pText);
-    pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + uX - 24, 291, TargetColor(0xD1, 0xBB, 0x61), pText, 0, 0, 0); // Skills
+    pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + uX - 24, 291, Color16(0xD1, 0xBB, 0x61), pText, 0, 0, 0); // Skills
 
     uStatLevel = pParty->pPlayers[i].GetActualMight();
     sprintf(pTmpBuf.data(), "%s\r%03d%d", pGlobalTXT_LocalizationStrings[144], pX_Numbers, uStatLevel);// "Might"
@@ -234,27 +234,27 @@
     pSkillsType = pParty->pPlayers[i].GetSkillIdxByOrder(0);
     pTextCenter = pFontCreate->AlignText_Center(150, pSkillNames[pSkillsType]);
     sprintf(pTmpBuf.data(), "\t%03u%s", pTextCenter, pSkillNames[pSkillsType]);
-    pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX - 24, 311, TargetColor(0xFF, 0xFF, 0xFF), pTmpBuf.data(), 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX - 24, 311, Color16(0xFF, 0xFF, 0xFF), pTmpBuf.data(), 0, 0, 0);
 
     pSkillsType = pParty->pPlayers[i].GetSkillIdxByOrder(1);
     pTextCenter = pFontCreate->AlignText_Center(150, pSkillNames[pSkillsType]);
     sprintf(pTmpBuf.data(), "\t%03u%s", pTextCenter, pSkillNames[pSkillsType]);
-    pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX - 24, pIntervalY + 311, TargetColor(0xFF, 0xFF, 0xFF), pTmpBuf.data(), 0, 0, 0);
+    pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX - 24, pIntervalY + 311, Color16(0xFF, 0xFF, 0xFF), pTmpBuf.data(), 0, 0, 0);
 
     pSkillsType = pParty->pPlayers[i].GetSkillIdxByOrder(2);
     pTextCenter = pFontCreate->AlignText_Center(150, pSkillNames[pSkillsType]);
     sprintf(pTmpBuf.data(), "\t%03u%s", pTextCenter, pSkillNames[pSkillsType]);
-    pColorText = TargetColor(0, 0xFF, 0);
+    pColorText = Color16(0, 0xFF, 0);
     if ( (signed int)pSkillsType >= 37 )
-      pColorText = TargetColor(0, 0xF7, 0xF7);
+      pColorText = Color16(0, 0xF7, 0xF7);
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX - 24, 2 * pIntervalY + 311, pColorText, pTmpBuf.data(), 0, 0, 0);
 
     pSkillsType = pParty->pPlayers[i].GetSkillIdxByOrder(3);
     pTextCenter = pFontCreate->AlignText_Center(150, pSkillNames[pSkillsType]);
     sprintf(pTmpBuf.data(), "\t%03u%s", pTextCenter, pSkillNames[pSkillsType]);
-    pColorText = TargetColor(0, 0xFF, 0);
+    pColorText = Color16(0, 0xFF, 0);
     if ( (signed int)pSkillsType >= 37 )
-      pColorText = TargetColor(0, 0xF7, 0xF7);
+      pColorText = Color16(0, 0xF7, 0xF7);
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX - 24, 3 * pIntervalY + 311, pColorText, pTmpBuf.data(), 0, 0, 0);
 
     pIntervalX += 159;
@@ -268,64 +268,64 @@
 
   uClassType = pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].classType;
   pTextCenter = pFontCreate->AlignText_Center(193, pText);
-  pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 324, 395, TargetColor(0xD1, 0xBB, 0x61), pText, 0, 0, 0);//Classes
+  pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 324, 395, Color16(0xD1, 0xBB, 0x61), pText, 0, 0, 0);//Classes
 
-  pColorText = TargetColor(0, 0xF7, 0xF7);
+  pColorText = Color16(0, 0xF7, 0xF7);
   if ( uClassType )
-    pColorText = TargetColor(0xFF, 0xFF, 0xFF);
+    pColorText = Color16(0xFF, 0xFF, 0xFF);
   pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[0]);
   pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 323, 417, pColorText, pClassNames[0], 0, 0, 0);
 
-  pColorText = TargetColor(0, 0xF7, 0xF7);
+  pColorText = Color16(0, 0xF7, 0xF7);
   if ( uClassType != PLAYER_CLASS_PALADIN )
-    pColorText = TargetColor(0xFF, 0xFF, 0xFF);
+    pColorText = Color16(0xFF, 0xFF, 0xFF);
   pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[12]);
   pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 323, pIntervalY + 417, pColorText, pClassNames[12], 0, 0, 0);
 
-  pColorText = TargetColor(0, 0xF7, 0xF7);
+  pColorText = Color16(0, 0xF7, 0xF7);
   if ( uClassType != PLAYER_CLASS_DRUID )
-    pColorText = TargetColor(0xFF, 0xFF, 0xFF);
+    pColorText = Color16(0xFF, 0xFF, 0xFF);
   pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[20]);
   pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 323, 2 * pIntervalY + 417, pColorText, pClassNames[20], 0, 0, 0);
 
-  pColorText = TargetColor(0, 0xF7, 0xF7);
+  pColorText = Color16(0, 0xF7, 0xF7);
   if ( uClassType != PLAYER_CLASS_CLERIC )
-    pColorText = TargetColor(0xFF, 0xFF, 0xFF);
+    pColorText = Color16(0xFF, 0xFF, 0xFF);
   pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[24]);
   pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 388, 417, pColorText, pClassNames[24], 0, 0, 0);
 
-  pColorText = TargetColor(0, 0xF7, 0xF7);
+  pColorText = Color16(0, 0xF7, 0xF7);
   if ( uClassType != PLAYER_CLASS_DRUID)
-    pColorText = TargetColor(0xFF, 0xFF, 0xFF);
+    pColorText = Color16(0xFF, 0xFF, 0xFF);
   pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[28]);
   pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 388, pIntervalY + 417, pColorText, pClassNames[28], 0, 0, 0);
 
-  pColorText = TargetColor(0, 0xF7, 0xF7);
+  pColorText = Color16(0, 0xF7, 0xF7);
   if ( uClassType != PLAYER_CLASS_SORCERER )
-    pColorText = TargetColor(0xFF, 0xFF, 0xFF);
+    pColorText = Color16(0xFF, 0xFF, 0xFF);
   pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[32]);
   pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 388, 2 * pIntervalY + 417, pColorText, pClassNames[32], 0, 0, 0);
 
-  pColorText = TargetColor(0, 0xF7, 0xF7);
+  pColorText = Color16(0, 0xF7, 0xF7);
   if ( uClassType != PLAYER_CLASS_ARCHER )
-    pColorText = TargetColor(0xFF, 0xFF, 0xFF);
+    pColorText = Color16(0xFF, 0xFF, 0xFF);
   pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[16]);
   pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 453, 417, pColorText, pClassNames[16], 0, 0, 0);
 
-  pColorText = TargetColor(0, 0xF7, 0xF7);
+  pColorText = Color16(0, 0xF7, 0xF7);
   if ( uClassType != PLAYER_CLASS_MONK )
-    pColorText = TargetColor(0xFF, 0xFF, 0xFF);
+    pColorText = Color16(0xFF, 0xFF, 0xFF);
   pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[8]);
   pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 453, pIntervalY + 417, pColorText, pClassNames[8], 0, 0, 0);
 
-  pColorText = TargetColor(0, 0xF7, 0xF7);
+  pColorText = Color16(0, 0xF7, 0xF7);
   if ( uClassType != PLAYER_CLASS_THEIF )
-    pColorText = TargetColor(0xFF, 0xFF, 0xFF);
+    pColorText = Color16(0xFF, 0xFF, 0xFF);
   pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[4]);
   pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 453, 2 * pIntervalY + 417, pColorText, pClassNames[4], 0, 0, 0);
 
   pTextCenter = pFontCreate->AlignText_Center(236, pGlobalTXT_LocalizationStrings[20]); // "Available Skills"
-  pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 37, 395, TargetColor(0xD1, 0xBB, 0x61), pGlobalTXT_LocalizationStrings[20], 0, 0, 0);
+  pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 37, 395, Color16(0xD1, 0xBB, 0x61), pGlobalTXT_LocalizationStrings[20], 0, 0, 0);
   for (uint i = 0; i < 9; ++i)
   {
     pSkillId = pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(i + 4);
@@ -351,19 +351,19 @@
     pCorrective = -10;//-5
     if ( (signed int)pLenText < 8 )//if ( (signed int)v124 > 2 )
       pCorrective = 0;
-    pColorText = TargetColor(0, 0xF7, 0xF7);
+    pColorText = Color16(0, 0xF7, 0xF7);
     if ( !pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].pActiveSkills[pSkillId] )
-      pColorText = TargetColor(0xFF, 0xFF, 0xFF);
+      pColorText = Color16(0xFF, 0xFF, 0xFF);
     pTextCenter = pFontCreate->AlignText_Center(100, pText);
     pGUIWindow_CurrentMenu->DrawText(pFontCreate, 100 * (i / 3) + pTextCenter + pCorrective + 17, pIntervalY * (i % 3) + 417, pColorText, pText, 0, 0, 0);
   }
 
   pTextCenter = pFontCreate->AlignText_Center(0x5C, pGlobalTXT_LocalizationStrings[30]);// "Bonus"
-  pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 533, 394, TargetColor(0xD1, 0xBB, 0x61), pGlobalTXT_LocalizationStrings[30], 0, 0, 0);
+  pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 533, 394, Color16(0xD1, 0xBB, 0x61), pGlobalTXT_LocalizationStrings[30], 0, 0, 0);
   pBonusNum = PlayerCreation_GetUnspentAttributePointCount();
   sprintf(pTmpBuf.data(), "%d", pBonusNum);
   pTextCenter = pFontCreate->AlignText_Center(84, pTmpBuf.data());
-  pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 530, 410, TargetColor(0xFF, 0xFF, 0xFF), pTmpBuf.data(), 0, 0, 0);
+  pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 530, 410, Color16(0xFF, 0xFF, 0xFF), pTmpBuf.data(), 0, 0, 0);
   if ( GameUI_Footer_TimeLeft > GetTickCount() )
   {
     message_window.Hint = pGlobalTXT_LocalizationStrings[412];// "Create Party cannot be completed unless you have assigned all characters 2 extra skills and have spent all of your bonus points."
--- a/UI/UIPopup.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/UI/UIPopup.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -203,9 +203,9 @@
       pText = (char *)inspect_item->GetIdentifiedName();
     else
       pText = pItemsTable->pItems[inspect_item->uItemID].pUnidentifiedName;
-    iteminfo_window.DrawTitleText(pFontArrus, 0, 0xCu, TargetColor(0xFFu, 0xFFu, 0x9Bu), pText, 3);
+    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,
-                   TargetColor(0xFFu, 0x19u, 0x19u), pGlobalTXT_LocalizationStrings[32], 3); //"Broken Item"
+                   Color16(0xFFu, 0x19u, 0x19u), pGlobalTXT_LocalizationStrings[32], 3); //"Broken Item"
     pRenderer->ResetTextureClipRect();
     if ( !areWeLoadingTexture )
     {
@@ -224,9 +224,9 @@
     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));
-    iteminfo_window.DrawTitleText(pFontArrus, 0, 0xCu, TargetColor(0xFFu, 0xFFu, 0x9Bu), pItemsTable->pItems[inspect_item->uItemID].pUnidentifiedName, 3);
+    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,
-                        TargetColor(0xFFu, 0x19u, 0x19u), pGlobalTXT_LocalizationStrings[232], 3);//"Not Identified"
+                        Color16(0xFFu, 0x19u, 0x19u), pGlobalTXT_LocalizationStrings[232], 3);//"Not Identified"
     pRenderer->ResetTextureClipRect();
     if ( !areWeLoadingTexture )
     {
@@ -355,7 +355,7 @@
     iteminfo_window.DrawText(pFontSmallnum, 100, v34, 0, v28, 0, 0, 0);
   iteminfo_window.uFrameX += 12;
   iteminfo_window.uFrameWidth -= 24;
-  iteminfo_window.DrawTitleText(pFontArrus, 0, 0xCu, TargetColor(0xFFu, 0xFFu, 0x9Bu), inspect_item->GetIdentifiedName(), 3);
+  iteminfo_window.DrawTitleText(pFontArrus, 0, 0xCu, Color16(0xFFu, 0xFFu, 0x9Bu), inspect_item->GetIdentifiedName(), 3);
   iteminfo_window.uFrameWidth += 24;
   iteminfo_window.uFrameX -= 12;
   if ( v77 )
@@ -524,10 +524,10 @@
   v106.sZValue = 0;
   v106.uFlags = 0;
   pRenderer->SetRasterClipRect(0, 0, 0x27Fu, 0x1DFu);
-  pRenderer->RasterLine2D(v106.uViewportX - 1, v106.uViewportY - 1, v106.uViewportX + 129, v106.uViewportY - 1, TargetColor(0xE1u, 255, 0x9Bu));
-  pRenderer->RasterLine2D( v106.uViewportX + 129,  v106.uViewportY - 1,  v106.uViewportX + 129,    v106.uViewportW + 1, TargetColor(0xE1u, 255, 0x9Bu));
-  pRenderer->RasterLine2D(v106.uViewportX + 129, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportW + 1, TargetColor(0xE1u, 255, 0x9Bu));
-  pRenderer->RasterLine2D(v106.uViewportX - 1, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportY - 1, TargetColor(0xE1u, 255, 0x9Bu));
+  pRenderer->RasterLine2D(v106.uViewportX - 1, v106.uViewportY - 1, v106.uViewportX + 129, v106.uViewportY - 1, Color16(0xE1u, 255, 0x9Bu));
+  pRenderer->RasterLine2D( v106.uViewportX + 129,  v106.uViewportY - 1,  v106.uViewportX + 129,    v106.uViewportW + 1, Color16(0xE1u, 255, 0x9Bu));
+  pRenderer->RasterLine2D(v106.uViewportX + 129, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportW + 1, Color16(0xE1u, 255, 0x9Bu));
+  pRenderer->RasterLine2D(v106.uViewportX - 1, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportY - 1, Color16(0xE1u, 255, 0x9Bu));
   if ( pRenderer->pRenderD3D )
   {
     v106.uScreenSpaceY = v115 + v106.uViewportY + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uBufferHeight;
@@ -568,7 +568,7 @@
     ErrD3D(pRenderer->pBackBuffer4->Blt(&v84, 0, 0, 16778240u, &Dst));
     if ( pRenderer->uTargetGBits == 5 )
     {
-      __debugbreak(); // no monster popup for r5g5b5 yet
+      __debugbreak(); // no monster popup for r5g5b5 will be
       memset(&pDesc, 0, 0x7Cu);
       pDesc.dwSize = 124;
       if ( pRenderer->LockSurface_DDraw4(pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].pTextureSurface, &pDesc, DDLOCK_WAIT))
@@ -578,7 +578,7 @@
         if (dst_y < dst_w)
         {
           v21 = dst_x;
-          v22 = &pRenderer->pTargetSurface[dst_y * pRenderer->uTargetSurfacePitch + dst_x];
+          //v22 = &pRenderer->pTargetSurface[dst_y * pRenderer->uTargetSurfacePitch + dst_x];
           ushort* _v22_2 = v22;
           v23 = i - dst_y;
           v115 = i - dst_y;
@@ -623,7 +623,7 @@
         uint num_top_scanlines_above_frame_y = i - dst_y;
         for (uint y = dst_y; y < dst_w; ++y)
         {
-          ushort* dst = &pRenderer->pTargetSurface[y * pRenderer->uTargetSurfacePitch + dst_x];
+          //ushort* dst = &pRenderer->pTargetSurface[y * pRenderer->uTargetSurfacePitch + dst_x];
 
           uint src_y = num_top_scanlines_above_frame_y + y;
           for (uint x = dst_x; x < dst_z; ++x)
@@ -633,7 +633,8 @@
             uint idx = pDesc.dwHeight * src_y / pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaHeight * (pDesc.lPitch / sizeof(short)) +
                        pDesc.dwWidth  * src_x / pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaWidth;
             uint b = src[idx] & 0x1F;
-            *dst++ = b | 2 * (src[idx] & 0xFFE0);
+            //*dst++ = b | 2 * (src[idx] & 0xFFE0);
+            pRenderer->WritePixel16(y, x, b | 2 * (src[idx] & 0xFFE0));
           }
         }
         pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].pTextureSurface->Unlock(0);
@@ -661,7 +662,7 @@
     else
       strncpy(pTmpBuf.data(), pMonsterStats->pInfos[pActors[uActorID].pMonsterInfo.uID].pName, 2000);
   }
-  window->DrawTitleText(pFontComic, 0, 0xCu, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
+  window->DrawTitleText(pFontComic, 0, 0xCu, Color16(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
   //health bar
   Actor::DrawHealthBar(&pActors[uActorID], window);
 
@@ -733,9 +734,9 @@
     for_effects = 1;
   }
 
-  window->DrawText(pFontSmallnum, 12, 196, TargetColor(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[631], 0, 0, 0);//Effects
+  window->DrawText(pFontSmallnum, 12, 196, Color16(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[631], 0, 0, 0);//Effects
   if ( !for_effects )
-    window->DrawText(pFontSmallnum, 28, LOBYTE(pFontSmallnum->uFontHeight) + 193, TargetColor(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[630], 0, 0, 0);//?
+    window->DrawText(pFontSmallnum, 28, LOBYTE(pFontSmallnum->uFontHeight) + 193, Color16(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[630], 0, 0, 0);//?
   else
   {
     pText = "";
@@ -839,24 +840,24 @@
       }
     }
     if ( pText == "" )
-      window->DrawText(pFontSmallnum, 28, pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[153], 0, 0, 0);//Нет
+      window->DrawText(pFontSmallnum, 28, pTextHeight, Color16(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[153], 0, 0, 0);//Нет
   }
 
   if ( normal_level )
   {
     sprintf(pTmpBuf.data(), "%s\f%05u\t100%d\n", pGlobalTXT_LocalizationStrings[108], 0, pActors[uActorID].pMonsterInfo.uHP);
-    window->DrawText(pFontSmallnum, 150, (int)v106.uViewportY, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+    window->DrawText(pFontSmallnum, 150, (int)v106.uViewportY, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
     pTextHeight = v106.uViewportY + LOBYTE(pFontSmallnum->uFontHeight) - 3;
     sprintf(pTmpBuf.data(), "%s\f%05u\t100%d\n", pGlobalTXT_LocalizationStrings[12], 0, pActors[uActorID].pMonsterInfo.uAC);//Armor Class
   }
   else
   {
     sprintf(pTmpBuf.data(), "%s\f%05u\t100%s\n", pGlobalTXT_LocalizationStrings[108], 0, pGlobalTXT_LocalizationStrings[630]);//?
-    window->DrawText(pFontSmallnum, 150, (int)v106.uViewportY, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+    window->DrawText(pFontSmallnum, 150, (int)v106.uViewportY, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
     pTextHeight = v106.uViewportY + LOBYTE(pFontSmallnum->uFontHeight) - 3;
     sprintf(pTmpBuf.data(), "%s\f%05u\t100%s\n", pGlobalTXT_LocalizationStrings[12], 0, (unsigned int)pGlobalTXT_LocalizationStrings[630]);//?
   }
-  window->DrawText(pFontSmallnum, 150, pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+  window->DrawText(pFontSmallnum, 150, pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
   pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 6 + LOBYTE(pFontSmallnum->uFontHeight);
 
   content[0] = pGlobalTXT_LocalizationStrings[87];
@@ -874,7 +875,7 @@
   if ( expert_level )
   {
     sprintf(pTmpBuf.data(), "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[18], 0, content[pActors[uActorID].pMonsterInfo.uAttack1Type]);//Attack
-    window->DrawText(pFontSmallnum, 150, (int)pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+    window->DrawText(pFontSmallnum, 150, (int)pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
     pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
     if ( pActors[uActorID].pMonsterInfo.uAttack1DamageBonus )
       sprintf(pTmpBuf.data(), "%s\f%05u\t080%dd%d+%d\n", pGlobalTXT_LocalizationStrings[53],
@@ -886,17 +887,17 @@
   else
   {
     sprintf(pTmpBuf.data(), "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[18], 0, pGlobalTXT_LocalizationStrings[630]);
-    window->DrawText(pFontSmallnum, 150, (int)pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+    window->DrawText(pFontSmallnum, 150, (int)pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
     pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
     sprintf(pTmpBuf.data(), "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[53], 0, pGlobalTXT_LocalizationStrings[630]);
   }
-  window->DrawText(pFontSmallnum, 150, pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+  window->DrawText(pFontSmallnum, 150, pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
   pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 6 + LOBYTE(pFontSmallnum->uFontHeight);
 
   if ( !master_level )
   {
     sprintf(pTmpBuf.data(), "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[628], 0, pGlobalTXT_LocalizationStrings[630]);//"Spell" "?"
-    window->DrawText(pFontSmallnum, 150, (int)pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+    window->DrawText(pFontSmallnum, 150, (int)pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
     pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
   }
   else
@@ -907,24 +908,24 @@
     if ( pActors[uActorID].pMonsterInfo.uSpell1ID )
     {
       sprintf(pTmpBuf.data(), "%s\f%05u\t070%s\n", pText, 0, pSpellStats->pInfos[pActors[uActorID].pMonsterInfo.uSpell1ID].pShortName);//"%s\f%05u\t060%s\n"
-      window->DrawText(pFontSmallnum, 150, (int)pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+      window->DrawText(pFontSmallnum, 150, (int)pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
       pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
     }
     if ( pActors[uActorID].pMonsterInfo.uSpell2ID )
     {
       sprintf(pTmpBuf.data(), "\f%05u\t070%s\n", 0, pSpellStats->pInfos[pActors[uActorID].pMonsterInfo.uSpell2ID].pShortName);//"%s\f%05u\t060%s\n"
-      window->DrawText(pFontSmallnum, 150, (int)pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+      window->DrawText(pFontSmallnum, 150, (int)pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
       pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
     }
     if ( !pActors[uActorID].pMonsterInfo.uSpell1ID && !pActors[uActorID].pMonsterInfo.uSpell2ID )
     {
       sprintf(pTmpBuf.data(), "%s\f%05u\t070%s\n", pGlobalTXT_LocalizationStrings[628], 0, pGlobalTXT_LocalizationStrings[153]);//"%s\f%05u\t060%s\n"
-      window->DrawText(pFontSmallnum, 150, (int)pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+      window->DrawText(pFontSmallnum, 150, (int)pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
       pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
     }
   }
   pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
-  window->DrawText(pFontSmallnum, 150, pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[626], 0, 0, 0);//Immune
+  window->DrawText(pFontSmallnum, 150, pTextHeight, Color16(0xE1u, 255, 0x9Bu), pGlobalTXT_LocalizationStrings[626], 0, 0, 0);//Immune
   pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
 
   string_name[0] = pGlobalTXT_LocalizationStrings[87];//Fire
@@ -965,7 +966,7 @@
           pText = pGlobalTXT_LocalizationStrings[153];//None
       }
       sprintf(pTmpBuf.data(), "%s\f%05u\t070%s\n", string_name[i], 0, pText);
-      window->DrawText(pFontSmallnum, 170, pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+      window->DrawText(pFontSmallnum, 170, pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
       pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
     }
   }
@@ -974,7 +975,7 @@
     for ( uint i = 0; i < 10; ++i )
     {
       sprintf(pTmpBuf.data(), "%s\f%05u\t070%s\n", string_name[i], 0, pGlobalTXT_LocalizationStrings[630]); // "?"
-      window->DrawText(pFontSmallnum, 170, pTextHeight, TargetColor(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
+      window->DrawText(pFontSmallnum, 170, pTextHeight, Color16(0xE1u, 255, 0x9Bu), pTmpBuf.data(), 0, 0, 0);
       pTextHeight = pTextHeight + LOBYTE(pFontSmallnum->uFontHeight) - 3;
     }
   }
@@ -1027,7 +1028,7 @@
   }
   else
   {
-    sprintf(Source, "\f%05d", TargetColor(0xFFu, 0xFFu, 0xFFu));
+    sprintf(Source, "\f%05d", Color16(0xFFu, 0xFFu, 0xFFu));
     strcat(a2, Source);
     strcat(a2, "%s: +%d");
     sprintf(static_sub_417BB5_out_string, a2, pSkillDesc[uPlayerSkillType],
@@ -1274,7 +1275,7 @@
   spell_info_window.uFrameHeight -= 12;
   spell_info_window.uFrameZ = spell_info_window.uFrameX + spell_info_window.uFrameWidth - 1;
   spell_info_window.uFrameW = spell_info_window.uFrameHeight + spell_info_window.uFrameY - 1;
-  spell_info_window.DrawTitleText(pFontArrus, 0x78u, 0xCu, TargetColor(0xFFu, 0xFFu, 0x9Bu), spell->pName, 3);
+  spell_info_window.DrawTitleText(pFontArrus, 0x78u, 0xCu, Color16(0xFFu, 0xFFu, 0x9Bu), spell->pName, 3);
   spell_info_window.DrawText(pFontSmallnum, 120, 44, 0, pTmpBuf2.data(), 0, 0, 0);
   spell_info_window.uFrameWidth = 108;
   spell_info_window.uFrameZ = spell_info_window.uFrameX + 107;
@@ -1574,7 +1575,7 @@
         popup_window.uFrameHeight -= 12;
         popup_window.uFrameZ = popup_window.uFrameX + popup_window.uFrameWidth - 1;
         popup_window.uFrameW = popup_window.uFrameY + popup_window.uFrameHeight - 1;
-        sprintf(pTmpBuf.data(), "\f%05d%s\f00000\n", TargetColor(0xFF, 0xFF, 0x9B), pStr);
+        sprintf(pTmpBuf.data(), "\f%05d%s\f00000\n", Color16(0xFF, 0xFF, 0x9B), pStr);
         popup_window.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf.data(), 3);
         popup_window.DrawText(pFontSmallnum, 1, pFontLucida->uFontHeight, 0, pHint, 0, 0, 0);
       }
--- a/UI/UIRest.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/UI/UIRest.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -128,16 +128,16 @@
     tmp_button.uWidth = 171;
     tmp_button.uHeight = 37;
     tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent;
-    tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, TargetColor(10, 0, 0), TargetColor(230, 214, 193));//Отдых и лечение 8 часов
+    tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Отдых и лечение 8 часов
     tmp_button.pParent = 0;
 
     sprintf(pTmpBuf.data(), "\r408%d", uRestUI_FoodRequiredToRest);
-    pGUIWindow_CurrentMenu->DrawText(pFontCreate, 0, 164, TargetColor(10, 0, 0), pTmpBuf.data(), 0, 0, TargetColor(230, 214, 193));
+    pGUIWindow_CurrentMenu->DrawText(pFontCreate, 0, 164, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193));
 
-    pButton_RestUI_WaitUntilDawn->DrawLabel(pGlobalTXT_LocalizationStrings[237], pFontCreate, TargetColor(10, 0, 0), TargetColor(230, 214, 193));//Ждать до рассвета
-    pButton_RestUI_Wait1Hour->DrawLabel(pGlobalTXT_LocalizationStrings[239], pFontCreate, TargetColor(10, 0, 0), TargetColor(230, 214, 193));//Ждать 1 час
-    pButton_RestUI_Wait5Minutes->DrawLabel(pGlobalTXT_LocalizationStrings[238], pFontCreate, TargetColor(10, 0, 0), TargetColor(230, 214, 193));//Ждать 5 минут
-    pButton_RestUI_Exit->DrawLabel(pGlobalTXT_LocalizationStrings[81], pFontCreate, TargetColor(10, 0, 0), TargetColor(230, 214, 193));//Закончить отдыхать
+    pButton_RestUI_WaitUntilDawn->DrawLabel(pGlobalTXT_LocalizationStrings[237], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Ждать до рассвета
+    pButton_RestUI_Wait1Hour->DrawLabel(pGlobalTXT_LocalizationStrings[239], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Ждать 1 час
+    pButton_RestUI_Wait5Minutes->DrawLabel(pGlobalTXT_LocalizationStrings[238], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Ждать 5 минут
+    pButton_RestUI_Exit->DrawLabel(pGlobalTXT_LocalizationStrings[81], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Закончить отдыхать
     memset(&tmp_button, 0, sizeof(GUIButton));
     tmp_button.uX = 45;
     tmp_button.uY = 199;
@@ -149,16 +149,16 @@
     tmp_button.uHeight = 30;
 
     tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent;
-    tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[236], pFontCreate, TargetColor(10, 0, 0), TargetColor(230, 214, 193));//Ждать без лечения
+    tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[236], pFontCreate, Color16(10, 0, 0), Color16(230, 214, 193));//Ждать без лечения
     tmp_button.pParent = 0;
     sprintf(pTmpBuf.data(), "%d:%02d %s", am_pm_hours, pParty->uCurrentMinute, aAMPMNames[(pParty->uCurrentHour >= 12 && pParty->uCurrentHour < 24)? 1:0]);
-    pGUIWindow_CurrentMenu->DrawText(pFontCreate, 368, 168, TargetColor(10, 0, 0), pTmpBuf.data(), 0, 0, TargetColor(230, 214, 193));
+    pGUIWindow_CurrentMenu->DrawText(pFontCreate, 368, 168, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193));
     sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[56], pParty->uDaysPlayed + 1);//День
-    pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 190, TargetColor(10, 0, 0), pTmpBuf.data(), 0, 0, TargetColor(230, 214, 193));
+    pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 190, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193));
     sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[146], pParty->uCurrentMonth + 1);//Месяц
-    pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 222, TargetColor(10, 0, 0), pTmpBuf.data(), 0, 0, TargetColor(230, 214, 193));
+    pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 222, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193));
     sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear);//Год
-    pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 254, TargetColor(10, 0, 0), pTmpBuf.data(), 0, 0, TargetColor(230, 214, 193));
+    pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 254, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193));
     if ( dword_506F14 )
       Sleep6Hours();
   }
--- a/UI/UISaveLoad.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/UI/UISaveLoad.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -125,9 +125,9 @@
       if ( slot_Y >= 346 )
         break;
       if ( pGUIWindow_CurrentMenu->receives_keyboard_input_2 != WINDOW_INPUT_IN_PROGRESS || i != uLoadGameUI_SelectedSlot )
-        pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, 27, slot_Y, i == uLoadGameUI_SelectedSlot ? TargetColor(0xFF, 0xFF, 0x64) : 0, pSavegameHeader[i].pName, 185, 0);
+        pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, 27, slot_Y, i == uLoadGameUI_SelectedSlot ? Color16(0xFF, 0xFF, 0x64) : 0, pSavegameHeader[i].pName, 185, 0);
       else
-        pGUIWindow_CurrentMenu->DrawFlashingInputCursor(pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, 27, slot_Y, i == uLoadGameUI_SelectedSlot ? TargetColor(0xFF, 0xFF, 0x64) : 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 175, 1) + 27,
+        pGUIWindow_CurrentMenu->DrawFlashingInputCursor(pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, 27, slot_Y, i == uLoadGameUI_SelectedSlot ? Color16(0xFF, 0xFF, 0x64) : 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 175, 1) + 27,
            slot_Y, pFontSmallnum);
       slot_Y += 21;
     }
--- a/UI/UIShops.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/UI/UIShops.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -61,9 +61,9 @@
           pButton->uHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0);
           v19 = pButton->uY + pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0) - 1;
           pButton->uW = v19;
-          pColorText = TargetColor(0xE1u, 0xCDu, 0x23u);
+          pColorText = Color16(0xE1u, 0xCDu, 0x23u);
           if ( pDialogueWindow->pCurrentPosActiveItem != i )
-            pColorText = TargetColor(0xFFu, 0xFFu, 0xFFu);
+            pColorText = Color16(0xFFu, 0xFFu, 0xFFu);
           dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
           ++pNumString;
         }
@@ -106,12 +106,12 @@
             {
               pText = BuildDialogueString(pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 2)],
                                        uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
-              dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+              dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3);
             }
             else
             {
               pText = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
-              dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+              dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3);
             }
           }
         }
@@ -157,12 +157,12 @@
             {
               pText = BuildDialogueString(pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 2)],
                                        uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
-              dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+              dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3);
             }
             else
             {
               pText = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
-              dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+              dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3);
             }
           }
         }
@@ -189,7 +189,7 @@
       item = &pPlayers[uActiveCharacter]->pInventoryItemList[pItemID - 1];
       phrases_id = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 3);
       pText = BuildDialogueString(pMerchantsSellPhrases[phrases_id], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 3, 0);
-      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3);
       break;
     }
     case HOUSE_DIALOGUE_SHOP_IDENTIFY:
@@ -211,12 +211,12 @@
       {
         phrases_id = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 4);
         pText = BuildDialogueString(pMerchantsIdentifyPhrases[phrases_id], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
-        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3);
       }
       else
       {
         pText = BuildDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
-        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3);
       }
       break;
     }
@@ -238,7 +238,7 @@
       item = &pPlayers[uActiveCharacter]->pInventoryItemList[pItemID - 1];
       phrases_id = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 5);
       pText = BuildDialogueString(pMerchantsRepairPhrases[phrases_id], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 5, 0);
-      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3);
       return;
     }
     break;
@@ -263,9 +263,9 @@
         pButton->uHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0);
         v19 = pButton->uY + pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0) - 1;
         pButton->uW = v19;
-        pColorText = TargetColor(0xE1u, 0xCDu, 0x23u);
+        pColorText = Color16(0xE1u, 0xCDu, 0x23u);
         if ( pDialogueWindow->pCurrentPosActiveItem != i )
-          pColorText = TargetColor(0xFFu, 0xFFu, 0xFFu);
+          pColorText = Color16(0xFFu, 0xFFu, 0xFFu);
         dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
         ++pNumString;
         }
@@ -316,9 +316,9 @@
             pButton->uHeight = pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &dialog_window, 0, 0);
             v19 = pButton->uY + pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &dialog_window, 0, 0) - 1;
             pButton->uW = v19;
-            pColorText = TargetColor(0xE1u, 0xCDu, 0x23u);
+            pColorText = Color16(0xE1u, 0xCDu, 0x23u);
             if ( pDialogueWindow->pCurrentPosActiveItem != i )
-              pColorText = TargetColor(0xFFu, 0xFFu, 0xFFu);
+              pColorText = Color16(0xFFu, 0xFFu, 0xFFu);
             dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[pButton->msg_param - 36], 3);
           }
         }
@@ -327,7 +327,7 @@
       sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]);
       strcat(pTmpBuf.data(), "\n \n");
       strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);//Больше ничего не могу предложить.
-      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xE1u, 0xCDu, 0x23u), pTmpBuf.data(), 3);
+      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138, Color16(0xE1u, 0xCDu, 0x23u), pTmpBuf.data(), 3);
       return;
     }
     default:
@@ -387,9 +387,9 @@
         pButton->uHeight = pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0);
         v23 = pButton->uY + pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0) - 1;
         pButton->uW = v23;
-        pTextColor = TargetColor(0xE1u, 0xCDu, 0x23u);
+        pTextColor = Color16(0xE1u, 0xCDu, 0x23u);
         if ( pDialogueWindow->pCurrentPosActiveItem != i )
-          pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
+          pTextColor = Color16(0xFFu, 0xFFu, 0xFFu);
         dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pShopOptions[pNumString], 3);
         ++pNumString;
       }
@@ -441,12 +441,12 @@
         {
           pText = BuildDialogueString(pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 2)],
                                  uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
-          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3);
         }
         else
         {
           pText = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); //"Steal %24"
-          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3);
         }
         return;
       }
@@ -504,12 +504,12 @@
         {
           pText = BuildDialogueString(pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 2)],
                  uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
-          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3);
         }
         else
         {
           pText = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);//"Steal %24"
-          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3);
         }
         return;
       }
@@ -539,9 +539,9 @@
         pButton->uHeight = pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0);
         v23 = pButton->uY + pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0) - 1;
         pButton->uW = v23;
-        pTextColor = TargetColor(0xE1u, 0xCDu, 0x23u);
+        pTextColor = Color16(0xE1u, 0xCDu, 0x23u);
         if ( pDialogueWindow->pCurrentPosActiveItem != i )
-          pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
+          pTextColor = Color16(0xFFu, 0xFFu, 0xFFu);
         dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pShopOptions[pNumString], 3);
         ++pNumString;
       }
@@ -565,7 +565,7 @@
       selected_item = &pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v153) - 1];
       pText = BuildDialogueString(pMerchantsSellPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 3)],
               uActiveCharacter - 1, selected_item, (char *) window_SpeakInHouse->par1C, 3, 0);
-      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3);
       return;
     }
     break;
@@ -588,7 +588,7 @@
             else
               pText = BuildDialogueString(pMerchantsIdentifyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BuildingType_ArmorShop,
                     (int)window_SpeakInHouse->ptr_1C, 4)], uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
-            dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+            dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3);
             return;
           }
         }
@@ -613,7 +613,7 @@
       phrases_id = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v153) - 1],
              BuildingType_ArmorShop, window_SpeakInHouse->par1C, 5);
       pText = BuildDialogueString(pMerchantsRepairPhrases[phrases_id], uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 5, 0);
-      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3);
       return;
     }
     break;
@@ -663,9 +663,9 @@
             pButton->uHeight = pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &dialog_window, 0, 0);
             v23 = pButton->uY + pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &dialog_window, 0, 0) - 1;
             pButton->uW = v23;
-            pTextColor = TargetColor(0xE1u, 0xCDu, 0x23u);
+            pTextColor = Color16(0xE1u, 0xCDu, 0x23u);
             if ( pDialogueWindow->pCurrentPosActiveItem != i )
-              pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
+              pTextColor = Color16(0xFFu, 0xFFu, 0xFFu);
             dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pSkillNames[pButton->msg_param - 36], 3);
           }
         }
@@ -674,7 +674,7 @@
       sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); //"Seek knowledge elsewhere %s the %s"
       strcat(pTmpBuf.data(), "\n \n");
       strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further."
-      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xE1u, 0xCDu, 0x23u), pTmpBuf.data(), 3);
+      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138, Color16(0xE1u, 0xCDu, 0x23u), pTmpBuf.data(), 3);
       return;
     }
     break;
@@ -733,9 +733,9 @@
           pButton->uHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0);
           v105 = pButton->uY + pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0) - 1;
           pButton->uW = v105;
-          pColorText = TargetColor(0xE1u, 0xCDu, 0x23u);
+          pColorText = Color16(0xE1u, 0xCDu, 0x23u);
           if ( pDialogueWindow->pCurrentPosActiveItem != i )
-            pColorText = TargetColor(0xFFu, 0xFFu, 0xFFu);
+            pColorText = Color16(0xFFu, 0xFFu, 0xFFu);
           dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
           ++pNumString;
         }
@@ -821,7 +821,7 @@
           }
           else
             pText = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
-          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3);
           return ;
         }
       }
@@ -909,7 +909,7 @@
           }
           else
             pText = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
-          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3);
           return;
         }
       }
@@ -933,7 +933,7 @@
              BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 3);
       pText = BuildDialogueString(pMerchantsSellPhrases[v71], uActiveCharacter - 1, &pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&index) - 1],
              (char *)window_SpeakInHouse->ptr_1C, 3, 0);
-      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3);
       return; 
     }
 
@@ -958,7 +958,7 @@
       }
       else
         pText = BuildDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
-      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, Color16(0xFFu, 0xFFu, 0xFFu), pText, 3);
       return;
     }
 
@@ -982,9 +982,9 @@
         pButton->uHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0);
         v105 = pButton->uY + pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0) - 1;
         pButton->uW = v105;
-        pColorText = TargetColor(0xE1u, 0xCDu, 0x23u);
+        pColorText = Color16(0xE1u, 0xCDu, 0x23u);
         if ( pDialogueWindow->pCurrentPosActiveItem != i )
-          pColorText = TargetColor(0xFFu, 0xFFu, 0xFFu);
+          pColorText = Color16(0xFFu, 0xFFu, 0xFFu);
         dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
         ++pNumString;
       }
@@ -1017,7 +1017,7 @@
         sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]);
         strcat(pTmpBuf.data(), "\n \n");
         strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);
-        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xE1u, 0xCDu, 0x23u), pTmpBuf.data(), 3);
+        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138, Color16(0xE1u, 0xCDu, 0x23u), pTmpBuf.data(), 3);
         return;
       }
       if ( item_num )
@@ -1045,9 +1045,9 @@
             pButton->uHeight = pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &dialog_window, 0, 0);
             v105 = pButton->uY + pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &dialog_window, 0, 0) - 1;
             pButton->uW = v105;
-            pColorText = TargetColor(0xE1u, 0xCDu, 0x23u);
+            pColorText = Color16(0xE1u, 0xCDu, 0x23u);
             if ( pDialogueWindow->pCurrentPosActiveItem != i )
-              pColorText = TargetColor(0xFFu, 0xFFu, 0xFFu);
+              pColorText = Color16(0xFFu, 0xFFu, 0xFFu);
             dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[pButton->msg_param - 36], 3);
           }
         }
@@ -1108,9 +1108,9 @@
       control_button->uHeight = pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0);
       v23 = control_button->uY + control_button->uHeight - 1;
       control_button->uW = v23;
-      text_color = TargetColor(225, 205, 35);
+      text_color = Color16(225, 205, 35);
       if ( pDialogueWindow->pCurrentPosActiveItem != i )
-        text_color = TargetColor(255, 255, 255);
+        text_color = Color16(255, 255, 255);
       dialog_window.DrawTitleText(pFontArrus, 0, control_button->uY, text_color, pShopOptions[pNumString], 3);
       ++pNumString;
     }
@@ -1196,7 +1196,7 @@
           v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2);
           v30 = BuildDialogueString(pMerchantsBuyPhrases[v75], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
         }
-        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138, TargetColor(255, 255, 255), v30, 3);
+        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138, Color16(255, 255, 255), v30, 3);
         return;
       }
     }
@@ -1284,7 +1284,7 @@
           v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2);
           v30 = BuildDialogueString(pMerchantsBuyPhrases[v75], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
         }
-        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138, TargetColor(255, 255, 255), v30, 3);
+        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138, Color16(255, 255, 255), v30, 3);
         return;
       }
     }
@@ -1312,9 +1312,9 @@
       control_button->uHeight = pFontArrus->CalcTextHeight(pShopOptions[pSrtingNum], &dialog_window, 0, 0);
       v23 = control_button->uHeight + control_button->uY - 1;
       control_button->uW = v23;
-      text_color = TargetColor(225, 205, 35);
+      text_color = Color16(225, 205, 35);
       if ( pDialogueWindow->pCurrentPosActiveItem != i )
-        text_color = TargetColor(255, 255, 255);
+        text_color = Color16(255, 255, 255);
       dialog_window.DrawTitleText(pFontArrus, 0, control_button->uY, text_color, pShopOptions[pSrtingNum], 3);
       ++pSrtingNum;
     }
@@ -1337,7 +1337,7 @@
     item = &pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117) - 1];
     v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 3);
     v30 = BuildDialogueString(pMerchantsSellPhrases[v75], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 3, 0);
-    dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138, TargetColor(255, 255, 255), v30, 3);
+    dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138, Color16(255, 255, 255), v30, 3);
     return;
   }
 
@@ -1358,12 +1358,12 @@
           if ( item->uAttributes & 1 )
           {
             dialog_window.DrawTitleText(pFontArrus, 0, (212 - pFontArrus->CalcTextHeight(BuildDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0), &dialog_window, 0, 0)) / 2 + 101,
-               TargetColor(255, 255, 255), BuildDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0), 3); 
+               Color16(255, 255, 255), BuildDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0), 3); 
             return;
           }
           v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 4);
           v30 = BuildDialogueString(pMerchantsIdentifyPhrases[v75], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
-          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138, TargetColor(255, 255, 255), v30, 3);
+          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138, Color16(255, 255, 255), v30, 3);
           return;
         }
       }
@@ -1389,7 +1389,7 @@
     v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117) - 1],
              BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 5);
     v30 = BuildDialogueString(pMerchantsRepairPhrases[v75], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 5, 0);
-    dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138, TargetColor(255, 255, 255), v30, 3);
+    dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138, Color16(255, 255, 255), v30, 3);
     return;
   }
 
@@ -1419,7 +1419,7 @@
                                             // "Seek knowledge elsewhere %s the %s"
         strcat(pTmpBuf.data(), "\n \n");
         strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further."
-        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138, TargetColor(225, 205, 35), pTmpBuf.data(), 3);
+        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138, Color16(225, 205, 35), pTmpBuf.data(), 3);
         return;
       }
       sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pPrice);// "Skill Cost: %lu"
@@ -1445,9 +1445,9 @@
           control_button->uHeight = pFontArrus->CalcTextHeight(pSkillNames[control_button->msg_param - 36], &dialog_window, 0, 0);
           v23 = control_button->uY + control_button->uHeight - 1;
           control_button->uW = v23;
-          text_color = TargetColor(225, 205, 35);
+          text_color = Color16(225, 205, 35);
           if ( pDialogueWindow->pCurrentPosActiveItem != i )
-            text_color = TargetColor(255, 255, 255);
+            text_color = Color16(255, 255, 255);
           dialog_window.DrawTitleText(pFontArrus, 0, control_button->uY, text_color, pSkillNames[control_button->msg_param - 36], 3);
         }
       }
--- a/UI/UiGame.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/UI/UiGame.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -230,7 +230,7 @@
           v11 = pTmpBuf.data();
           strcpy(pTmpBuf.data(), pNPC->pName);
         }
-        popup_window.DrawTitleText(pFontArrus, 0, 12, TargetColor(0xFFu, 0xFFu, 0x9Bu), v11, 3);
+        popup_window.DrawTitleText(pFontArrus, 0, 12, Color16(0xFFu, 0xFFu, 0x9Bu), v11, 3);
         popup_window.uFrameWidth -= 24;
         popup_window.uFrameZ = popup_window.uFrameX + popup_window.uFrameWidth - 1;
         popup_window.DrawText(pFontArrus, 100, 36, 0, BuildDialogueString((char *)lpsz, uActiveCharacter - 1, 0, 0, 0, 0), 0, 0, 0);
@@ -1822,7 +1822,7 @@
   int v15; // eax@23
   double v20; // st7@30
   signed int v27; // eax@37
-  unsigned __int16 *v28; // ecx@37
+  //unsigned __int16 *v28; // ecx@37
   signed int v29; // edi@40
   int pPoint_X; // edi@72
   int pPoint_Y; // ebx@72
@@ -1888,12 +1888,15 @@
       break;
       default: assert(false);
     }
+
+    static unsigned __int16 pOdmMinimap[117][137];
     assert(sizeof(pOdmMinimap) == 137 * 117 * sizeof(short));
 
     v70 = floorf(v20 * 65536.0 + 0.5f);//LODWORD(v24);
     uBluea = floorf(uWb * 65536.0 + 0.5f);//LODWORD(v25);
     v27 = uBluea >> 16;
-    v28 = &pRenderer->pTargetSurface[uX + uY * lPitch];
+    //v28 = &pRenderer->pTargetSurface[uX + uY * lPitch];
+
     if (pMapLod0 && bRedrawOdmMinimap)
     {
       assert(uWidth == 137 && uHeight == 117);
@@ -1908,6 +1911,18 @@
         for (int x = 0; x < uWidth; ++x)
         {
           //*pMinimap++ = pPal[pMapLod0Line[v29]];
+          pRenderer->WritePixel16(uX + x, uY + y, pPal[pMapLod0Line[v29]]);
+          v29 = (v70 + x * v73) >> 16;
+        }
+      }
+
+      /*v29 = v70 >> 16;
+      for (int y = 0; y < uHeight; ++y)
+      {
+        uchar* pMapLod0Line = &pMapLod0[v27 * mapWidth];
+        for (int x = 0; x < uWidth; ++x)
+        {
+          //*pMinimap++ = pPal[pMapLod0Line[v29]];
           pOdmMinimap[y][x] = pPal[pMapLod0Line[v29]];
           v29 = (v70 + x * v73) >> 16;
         }
@@ -1915,17 +1930,17 @@
         v28 += 137 - uWidth;
         uBluea += v73;
         v27 = uBluea >> 16;
-      }
+      }*/
     }
 
-    for (int y = 0; y < 117; ++y)
+    /*for (int y = 0; y < 117; ++y)
     {
       for (int x = 0; x < 137; ++x)
       {
         *v28++ = pOdmMinimap[y][x];
       }
       v28 += lPitch - 137;
-    }
+    }*/
     uNumBlueFacesInBLVMinimap = 0;
   }
   else// uCurrentlyLoadedLevelType == LEVEL_Indoor
@@ -2214,7 +2229,7 @@
   }
   else//Green
     R = 0, G = 255, B = 0;
-  return TargetColor(R, G, B);
+  return Color16(R, G, B);
 }
 
 //----- (00417939) --------------------------------------------------------
--- a/VideoPlayer.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/VideoPlayer.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -843,22 +843,33 @@
 //----- (004BF08B) --------------------------------------------------------
 void VideoPlayer::SmackUpdatePalette()
 {
-  VideoPlayer *v2; // esi@1
+  //VideoPlayer *v2; // esi@1
   unsigned __int16 *v3; // ebx@1
   unsigned int v4; // edi@1
   unsigned int v5; // eax@1
-  _SMACK *v6; // eax@1
+  //_SMACK *v6; // eax@1
 
-  v2 = this;
   pRenderer->BeginScene();
-  v3 = pRenderer->pTargetSurface;
-  v4 = pRenderer->uTargetSurfacePitch;
+
+  auto pixels = new unsigned short[640 * 480];
+  v3 = pixels;//pRenderer->pTargetSurface;
+  v4 = 640;//pRenderer->uTargetSurfacePitch;
   v5 = SmackCheckSurfaceFromat();
-  SmackToBuffer(v2->pSmackerMovie, 8, 8, 2 * v4, pRenderer->field_14, v3, v5);
-  v6 = v2->pSmackerMovie;
-  if ( v6->NewPalette )
+
+  SmackToBuffer(pSmackerMovie, 8, 8, 2 * v4, pRenderer->field_14, v3, v5);
+
+  
+  for (unsigned int y = 8; y < 8 + pRenderer->field_14; ++y)
+    for (unsigned int x = 8; x < 8 + pSmackerMovie->Width; ++x)
+    {
+      pRenderer->WritePixel16(x, y, pixels[x + y * 640]);
+    }
+  delete [] pixels;
+
+  //v6 = pSmackerMovie;
+  if ( pSmackerMovie->NewPalette )
   {
-    SmackBufferNewPalette((long)pSmackerBuffer, (long)v6->Palette, LOWORD(v6->PalType));
+    SmackBufferNewPalette((long)pSmackerBuffer, (long)pSmackerMovie->Palette, LOWORD(pSmackerMovie->PalType));
     SmackColorRemapWithTrans(
       (long)pSmackerMovie,
       (long)pSmackerBuffer->Palette,
@@ -866,9 +877,9 @@
       (long)pSmackerBuffer->PalType,
       1000);
   }
-  SmackDoFrame(v2->pSmackerMovie);
-  if ( v2->pSmackerMovie->FrameNum != v2->pSmackerMovie->Frames - 1 || v2->bLoopPlaying )
-    SmackNextFrame(v2->pSmackerMovie);
+  SmackDoFrame(pSmackerMovie);
+  if ( pSmackerMovie->FrameNum != pSmackerMovie->Frames - 1 || bLoopPlaying )
+    SmackNextFrame(pSmackerMovie);
   else
     Unload();
   pRenderer->EndScene();
--- a/Viewport.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/Viewport.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -54,9 +54,9 @@
     this->uScreenWidth = br_x - tl_x + 1;
     this->uScreenHeight = br_y - tl_y + 1;
     this->uScreenCenterX = (signed int)(br_x + tl_x) /2;
-    if ( pRenderer->pRenderD3D == 0 )
-        this->uScreenCenterY = this->uScreen_BR_Y - fixpoint_mul(field_30, uScreenHeight);
-    else
+    //if ( pRenderer->pRenderD3D == 0 )
+    //    this->uScreenCenterY = this->uScreen_BR_Y - fixpoint_mul(field_30, uScreenHeight);
+    //else
         this->uScreenCenterY = (br_y + tl_y)/2;
     SetViewport(this->uScreen_TL_X, this->uScreen_TL_Y, this->uScreen_BR_X, this->uScreen_BR_Y);
     }
@@ -195,7 +195,7 @@
 void ViewingParams::InitGrayPalette()
     {
     for  (unsigned short i=0; i<256; ++i)
-        pPalette[i]=TargetColor(i, i, i);
+        pPalette[i]=Color16(i, i, i);
     }
 
 //----- (00443365) --------------------------------------------------------
--- a/Weather.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/Weather.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -52,7 +52,9 @@
   v25 = viewparams->uScreen_BttmR_X;
   v28 = viewparams->uScreen_topL_Y;
   v31 = 0;
-  v1 = pRenderer->pTargetSurface;
+  if (!FORCE_16_BITS)
+    __debugbreak(); // function expects 16bit target buffer, will fail otherwise
+  v1 = (unsigned __int16 *)pRenderer->pTargetSurface;
   v29 = viewparams->uScreen_topL_X;
   v23 = viewparams->uScreen_BttmR_Y;
   v24 = viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X;
--- a/_deleted.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/_deleted.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -13196,6 +13196,269 @@
   return bUserDirect3D == 0;
 }
 
+
+//----- (004A46E6) --------------------------------------------------------
+int __fastcall sr_4A46E6_draw_particle_segment(unsigned int x, signed int y, signed int _z, int a4, unsigned int lightColor)
+{
+  int v5; // eax@1
+  int z; // eax@1
+  unsigned int v7; // eax@9
+  unsigned int v8; // ecx@9
+  int v9; // eax@9
+  unsigned int v10; // eax@10
+  int *v11; // esi@10
+  int *v12; // edi@10
+  int v13; // ecx@10
+  int v14; // edx@10
+  unsigned int v15; // eax@22
+  int *v16; // esi@22
+  int *v17; // edi@22
+  int v18; // ecx@22
+  int v19; // edx@22
+  unsigned __int16 *pTarget; // [sp+Ch] [bp-8h]@9
+  int *pTargetZ; // [sp+10h] [bp-4h]@9
+  unsigned int v22; // [sp+1Ch] [bp+8h]@9
+  signed int v23; // [sp+20h] [bp+Ch]@1
+
+  v5 = a4;
+  v23 = _z >> 16;
+  z = x + v5;
+  if ( z >= (signed int)pViewport->uViewportTL_X
+    && (signed int)x <= (signed int)pViewport->uViewportBR_X
+    && y >= (signed int)pViewport->uViewportTL_Y
+    && y <= (signed int)pViewport->uViewportBR_Y )
+  {
+    if ( (signed int)x < (signed int)pViewport->uViewportTL_X )
+      x = pViewport->uViewportTL_X;
+    if ( z > (signed int)pViewport->uViewportBR_X )
+      z = pViewport->uViewportBR_X;
+    pTarget = &pRenderer->pTargetSurface[x + y * pRenderer->uTargetSurfacePitch];
+    v22 = z - x;
+    pTargetZ = &pRenderer->pActiveZBuffer[x + 640 * y];
+    v7 = lightColor >> 3;
+    v8 = lightColor & 0xF0;
+    v9 = v7 & 0x1E0000;
+    if ( pRenderer->uTargetGBits == 5 )
+    {
+      v10 = (v8 | (((unsigned __int16)(lightColor & 0xF000) | (unsigned int)v9) >> 3)) >> 4;
+      v11 = (int *)pTarget;
+      v12 = pTargetZ;
+      v13 = v22;
+      v14 = (v10 << 16) | v10;
+      z = (unsigned __int8)pTarget & 2;
+      if ( (unsigned __int8)pTarget & 2 )
+      {
+        z = (unsigned int)*pTargetZ >> 16;
+        if ( z > v23 )
+        {
+          z = v14 + ((*pTarget & 0x7BDEu) >> 1);
+          *pTarget = z;
+        }
+        v13 = v22 - 1;
+        v11 = (int *)(pTarget + 1);
+        v12 = pTargetZ + 1;
+      }
+      while ( v13 != 1 )
+      {
+        if ( v13 < 1 )
+          return z;
+        z = (unsigned int)*v12 >> 16;
+        if ( z <= v23 )
+        {
+          v13 -= 2;
+          ++v11;
+          v12 += 2;
+        }
+        else
+        {
+          v12 += 2;
+          z = v14 + ((*v11 & 0x7BDE7BDEu) >> 1);
+          v13 -= 2;
+          *v11 = z;
+          ++v11;
+        }
+      }
+      z = (unsigned int)*v12 >> 16;
+      if ( z > v23 )
+      {
+        z = v14 + ((*(short *)v11 & 0x7BDEu) >> 1);
+        *(short *)v11 = z;
+      }
+    }
+    else
+    {
+      v15 = (v8 | (((unsigned __int16)(lightColor & 0xF800) | (unsigned int)v9) >> 2)) >> 4;
+      v16 = (int *)pTarget;
+      v17 = pTargetZ;
+      v18 = v22;
+      v19 = (v15 << 16) | v15;
+      z = (unsigned __int8)pTarget & 2;
+      if ( (unsigned __int8)pTarget & 2 )
+      {
+        z = (unsigned int)*pTargetZ >> 16;
+        if ( z > v23 )
+        {
+          z = v19 + ((*pTarget & 0xF7DEu) >> 1);
+          *pTarget = z;
+        }
+        v18 = v22 - 1;
+        v16 = (int *)(pTarget + 1);
+        v17 = pTargetZ + 1;
+      }
+      while ( v18 != 1 )
+      {
+        if ( v18 < 1 )
+          return z;
+        z = (unsigned int)*v17 >> 16;
+        if ( z <= v23 )
+        {
+          v18 -= 2;
+          ++v16;
+          v17 += 2;
+        }
+        else
+        {
+          v17 += 2;
+          z = v19 + ((*v16 & 0xF7DEF7DEu) >> 1);
+          v18 -= 2;
+          *v16 = z;
+          ++v16;
+        }
+      }
+      z = (unsigned int)*v17 >> 16;
+      if ( z > v23 )
+      {
+        z = v19 + ((*(short *)v16 & 0xF7DEu) >> 1);
+        *(short *)v16 = z;
+      }
+    }
+  }
+  return z;
+}
+
+
+//----- (004A57E9) --------------------------------------------------------
+void Present_ColorKey()
+{
+  HRESULT v0; // eax@3
+  HRESULT v1; // eax@3
+  HRESULT v2; // eax@3
+  HRESULT v3; // eax@3
+  HRESULT v4; // eax@3
+  RECT a2; // [sp+4h] [bp-14h]@3
+  //CheckHRESULT_stru0 this; // [sp+14h] [bp-4h]@3
+
+  if ( !pRenderer->uNumSceneBegins )
+  {
+    if ( pRenderer->using_software_screen_buffer )
+    {
+      a2.bottom = pViewport->uViewportTL_Y;
+      a2.left = 0;
+      a2.top = 0;
+      a2.right = 640;
+      ErrD3D(pRenderer->pBackBuffer4->BltFast(0, 0, pRenderer->pColorKeySurface4, &a2, 16u));
+      a2.right = 640;
+      a2.left = 0;
+      a2.top = pViewport->uViewportBR_Y + 1;
+      a2.bottom = 480;
+      ErrD3D(pRenderer->pBackBuffer4->BltFast(
+             0,
+             pViewport->uViewportBR_Y + 1,
+             pRenderer->pColorKeySurface4,
+             &a2,
+             16u));
+      a2.right = pViewport->uViewportTL_X;
+      a2.bottom = pViewport->uViewportBR_Y + 1;
+      a2.left = 0;
+      a2.top = pViewport->uViewportTL_Y;
+      ErrD3D(pRenderer->pBackBuffer4->BltFast(
+             0,
+             pViewport->uViewportTL_Y,
+             pRenderer->pColorKeySurface4,
+             &a2,
+             16u));
+      a2.left = pViewport->uViewportBR_X;
+      a2.top = pViewport->uViewportTL_Y;
+      a2.right = 640;
+      a2.bottom = pViewport->uViewportBR_Y + 1;
+      ErrD3D(pRenderer->pBackBuffer4->BltFast(
+             pViewport->uViewportBR_X,
+             pViewport->uViewportTL_Y,
+             pRenderer->pColorKeySurface4,
+             &a2,
+             16u));
+      a2.right = pViewport->uViewportBR_X;
+      a2.bottom = pViewport->uViewportBR_Y + 1;
+      a2.left = pViewport->uViewportTL_X;
+      a2.top = pViewport->uViewportTL_Y;
+      ErrD3D(pRenderer->pBackBuffer4->BltFast(
+             pViewport->uViewportTL_X,
+             pViewport->uViewportTL_Y,
+             pRenderer->pColorKeySurface4,
+             &a2,
+             17u));
+    }
+  }
+}
+
+
+//----- (004A48E4) --------------------------------------------------------
+int Render::MakeParticleBillboardAndPush_BLV_Software(int screenSpaceX, int screenSpaceY, int z, int lightColor, int a6)
+{
+  int v6; // ecx@1
+  int v7; // ebx@1
+  int v8; // ecx@1
+  int v9; // edx@1
+  int v10; // edi@1
+  unsigned int x; // esi@1
+  int result; // eax@8
+  int v13; // [sp+Ch] [bp-10h]@1
+  int v14; // [sp+10h] [bp-Ch]@1
+  int v15; // [sp+14h] [bp-8h]@1
+  int v16; // [sp+18h] [bp-4h]@1
+  int v17; // [sp+24h] [bp+8h]@1
+  unsigned int v18; // [sp+28h] [bp+Ch]@1
+  int v19; // [sp+34h] [bp+18h]@1
+
+  v6 = screenSpaceX;
+  v7 = (a6 >> 1) + screenSpaceY;
+  v17 = 0;
+  v15 = 0;
+  v8 = (a6 >> 1) + v6;
+  v14 = (a6 >> 1) * (a6 >> 1);
+  v9 = 2 * (a6 >> 1);
+  v10 = (a6 >> 1) * ((a6 >> 1) - 1);
+  x = v8 - (a6 >> 1);
+  v16 = (a6 >> 1) + screenSpaceY - v8;
+  v19 = a6 >> 1;
+  v13 = v9;
+  v18 = v8;
+  do
+  {
+    sr_4A46E6_draw_particle_segment(x, v16 + v18, z, 2 * v19, lightColor);
+    if ( v15 )
+      sr_4A46E6_draw_particle_segment(x, v17 + v7, z, 2 * v19, lightColor);
+    v14 -= v15;
+    if ( v14 <= v10 )
+    {
+      if ( v19 != v17 )
+      {
+        sr_4A46E6_draw_particle_segment(v18, v16 + x, z, 2 * v17, lightColor);
+        sr_4A46E6_draw_particle_segment(v18, v19 + v7, z, 2 * v17, lightColor);
+      }
+      --v19;
+      v13 -= 2;
+      ++x;
+      v10 -= v13;
+    }
+    result = v17++;
+    v15 += 2;
+    --v18;
+  }
+  while ( result < v19 );
+  return result;
+}
+
 //----- (004637EB) --------------------------------------------------------
 int __stdcall aWinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
@@ -14045,4 +14308,104 @@
   return v19;
 }
 
+
+//----- (0049EBF1) --------------------------------------------------------
+void Render::_stub_49EBF1()
+{
+  signed int uNumRedBits; // edx@1
+  signed int uNuGreenBits; // edi@1
+  signed int uNumBlueBits; // esi@1
+  unsigned int v4; // edx@4
+  unsigned int v5; // edi@4
+  int v6; // ebx@4
+  int v7; // edx@4
+  signed int v8; // [sp+8h] [bp-24h]@1
+  signed int v9; // [sp+Ch] [bp-20h]@1
+  signed int v10; // [sp+20h] [bp-Ch]@1
+  signed int i; // [sp+24h] [bp-8h]@2
+  signed int v12; // [sp+28h] [bp-4h]@3
+
+  v10 = 0;
+  uNumRedBits = 1 << this->uTargetRBits;
+  uNuGreenBits = 1 << this->uTargetGBits;
+  uNumBlueBits = 1 << this->uTargetBBits;
+  v9 = 1 << this->uTargetRBits;
+  v8 = 1 << this->uTargetGBits;
+  if ( uNumRedBits > 0 )
+  {
+    do
+    {
+      for ( i = 0; i < uNuGreenBits; ++i )
+      {
+        v12 = 0;
+        if ( uNumBlueBits > 0 )
+        {
+          do
+          {
+            v4 = this->uTargetBBits;
+            v5 = v4 + this->uTargetGBits;
+            v6 = (v12 >> 1) + (v10 >> 1 << v5) + (i >> 1 << this->uTargetBBits);
+            v7 = (v10 << v5) + v12++ + (i << v4);
+            this->unused_2C[v7] = v6;
+          }
+          while ( v12 < uNumBlueBits );
+          uNumRedBits = v9;
+          uNuGreenBits = v8;
+        }
+      }
+      ++v10;
+    }
+    while ( v10 < uNumRedBits );
+  }
+}
+
+
+//----- (004B0967) --------------------------------------------------------
+void BspRenderer::DrawFaceOutlines()
+{
+  signed int i; // edi@1
+  int v1; // esi@2
+  unsigned int v2; // ecx@4
+  int v3; // eax@4
+  int v4; // eax@6
+  unsigned __int16 *v5; // edx@6
+  int v6; // ecx@7
+  int v7; // esi@8
+
+  for ( i = 0; i < (signed int)pBspRenderer->num_faces; ++i )
+  {
+    v1 = pBspRenderer->faces[i].uFaceID;
+    if ( v1 >= 0 )
+    {
+      if ( v1 < (signed int)pIndoor->uNumFaces )
+      {
+        v2 = pBspRenderer->faces[i].uFaceID;
+        pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].PortalScreenData;
+        v3 = GetPortalScreenCoord(v2);
+        if ( v3 )
+        {
+          if ( PortalFrustrum(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1) )
+          {
+            v4 = stru_F8A590._viewport_space_y;
+            v5 = pBLVRenderParams->pRenderTarget;
+            if ( stru_F8A590._viewport_space_y <= stru_F8A590._viewport_space_w )
+            {
+              v6 = 640 * stru_F8A590._viewport_space_y;
+              do
+              {
+                v5[v6 + stru_F8A590.viewport_left_side[v4]] = -1;
+                v7 = v6 + stru_F8A590.viewport_right_side[v4];
+                v6 += 640;
+                v5[v7] = -1;
+                ++v4;
+              }
+              while ( v4 <= stru_F8A590._viewport_space_w );
+            }
+          }
+        }
+      }
+    }
+  }
+}
+
 */
\ No newline at end of file
--- a/mm7_2.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/mm7_2.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -815,7 +815,7 @@
   pRenderer->Present();
   if ( pRenderer->pRenderD3D )
     pRenderer->pBeforePresentFunction();
-  pRenderer->_49F1BC("MM7_Win.Pcx");
+  pRenderer->SaveWinnersCertificate("MM7_Win.Pcx");
   free(pFont);
   window_SpeakInHouse->Release();
   window_SpeakInHouse = 0;
@@ -2790,25 +2790,25 @@
 unsigned int __fastcall GetSpellColor(signed int a1)
 {
   if ( a1 == 0 )
-    return TargetColor(0, 0, 0);
+    return Color16(0, 0, 0);
   if ( a1 < 12 )
-    return TargetColor(255, 85, 0);
+    return Color16(255, 85, 0);
   if ( a1 < 23 )
-    return TargetColor(150, 212, 255);
+    return Color16(150, 212, 255);
   if ( a1 < 34 )
-    return TargetColor(0, 128, 255);
+    return Color16(0, 128, 255);
   if ( a1 < 45 )
-    return TargetColor(128, 128, 128);
+    return Color16(128, 128, 128);
   if ( a1 < 56 )
-    return TargetColor(225, 225, 225);
+    return Color16(225, 225, 225);
   if ( a1 < 67 )
-    return TargetColor(235, 15, 255);
+    return Color16(235, 15, 255);
   if ( a1 < 78 )
-    return TargetColor(255, 128, 0);
+    return Color16(255, 128, 0);
   if ( a1 < 89 )
-    return TargetColor(255, 255, 155);
+    return Color16(255, 255, 155);
   if ( a1 < 100 )
-    return TargetColor(192, 192, 240);
+    return Color16(192, 192, 240);
 }
 
 //----- (004610AA) --------------------------------------------------------
@@ -3710,13 +3710,13 @@
   }
   else
   {
-    bool bWindowMode = ReadWindowsRegistryInt("startinwindow", false);
+    //bool bWindowMode = ReadWindowsRegistryInt("startinwindow", false);
     //uint uDefaultDevice = ReadWindowsRegistryInt("D3D Device", 1);
     bool bColoredLights = ReadWindowsRegistryInt("Colored Lights", false);
     uint uLevelOfDetail = ReadWindowsRegistryInt("Detail Level", 1);
     uint bTinting = ReadWindowsRegistryInt("Tinting", 1) != 0;
 
-    if (!pRenderer->Initialize(bWindowMode, window, bColoredLights, uLevelOfDetail, bTinting))
+    if (!pRenderer->Initialize(window, bColoredLights, uLevelOfDetail, bTinting))
     {
       Log::Warning(L"Render failed to initialize");
       return false;
@@ -3987,18 +3987,16 @@
 
 
   
-  if (dword_6BE364_game_settings_1 & 2 || !(dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_RUN_IN_WIDOW))// 
-                                                //   color depth != 16
-                                                // or
-                                                //   not in window
+  if (dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_RUN_IN_WIDOW)
   {
-    window->SetFullscreenMode();
-    pRenderer->InitializeFullscreen();
+    //window->SetWindowedMode(game_width, game_height);
+    pRenderer->SwitchToWindow();
   }
   else
   {
-    //window->SetWindowedMode(game_width, game_height);
-    pRenderer->SwitchToWindow();
+    __debugbreak(); // Nomad
+    window->SetFullscreenMode();
+    pRenderer->InitializeFullscreen();
   }
   sub_4C023F();
   uSoundVolumeMultiplier = ReadWindowsRegistryInt("soundflag", 9);
@@ -4077,9 +4075,12 @@
   pItemsTable->Initialize();
 
   pBitmaps_LOD->dword_011BA8 = 1;
-  pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits);
-  pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits);
-  pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits);
+  //pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits);
+  pBitmaps_LOD->SetupPalettes(5, 6, 5);
+  //pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits);
+  pIcons_LOD->SetupPalettes(5, 6, 5);
+  //pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits);
+  pPaletteManager->SetColorChannelInfo(5, 6, 5);
 
   pPaletteManager->SetMistColor(128, 128, 128);
   pPaletteManager->RecalculateAll();
--- a/mm7_4.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/mm7_4.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -1707,7 +1707,7 @@
           i += 2;
           break;
         case 24://название товара в продаже
-          sprintfex(a1, format_4E2D80, TargetColor(255, 255, 155), a3->GetDisplayName());
+          sprintfex(a1, format_4E2D80, Color16(255, 255, 155), a3->GetDisplayName());
           strcat(pTmpBuf2.data(), a1);
           dst = strlen(pTmpBuf2.data());
           i += 2;
@@ -2031,207 +2031,34 @@
   return LOBYTE(v13) | ((LOBYTE(v11) | (((v6 << 8) | v9) << 8)) << 8);*/
 }
 
-//----- (004A46E6) --------------------------------------------------------
-int __fastcall sr_4A46E6_draw_particle_segment(unsigned int x, signed int y, signed int _z, int a4, unsigned int lightColor)
+void Present32(unsigned __int32 *src, unsigned int src_pitch,
+               unsigned __int32 *dst, unsigned int dst_pitch)
 {
-  int v5; // eax@1
-  int z; // eax@1
-  unsigned int v7; // eax@9
-  unsigned int v8; // ecx@9
-  int v9; // eax@9
-  unsigned int v10; // eax@10
-  int *v11; // esi@10
-  int *v12; // edi@10
-  int v13; // ecx@10
-  int v14; // edx@10
-  unsigned int v15; // eax@22
-  int *v16; // esi@22
-  int *v17; // edi@22
-  int v18; // ecx@22
-  int v19; // edx@22
-  unsigned __int16 *pTarget; // [sp+Ch] [bp-8h]@9
-  int *pTargetZ; // [sp+10h] [bp-4h]@9
-  unsigned int v22; // [sp+1Ch] [bp+8h]@9
-  signed int v23; // [sp+20h] [bp+Ch]@1
+        for (uint y = 0; y < 8; ++y)
+          memcpy(dst + y * dst_pitch,
+                 src + y * src_pitch, src_pitch * sizeof(__int32));
 
-  v5 = a4;
-  v23 = _z >> 16;
-  z = x + v5;
-  if ( z >= (signed int)pViewport->uViewportTL_X
-    && (signed int)x <= (signed int)pViewport->uViewportBR_X
-    && y >= (signed int)pViewport->uViewportTL_Y
-    && y <= (signed int)pViewport->uViewportBR_Y )
-  {
-    if ( (signed int)x < (signed int)pViewport->uViewportTL_X )
-      x = pViewport->uViewportTL_X;
-    if ( z > (signed int)pViewport->uViewportBR_X )
-      z = pViewport->uViewportBR_X;
-    pTarget = &pRenderer->pTargetSurface[x + y * pRenderer->uTargetSurfacePitch];
-    v22 = z - x;
-    pTargetZ = &pRenderer->pActiveZBuffer[x + 640 * y];
-    v7 = lightColor >> 3;
-    v8 = lightColor & 0xF0;
-    v9 = v7 & 0x1E0000;
-    if ( pRenderer->uTargetGBits == 5 )
-    {
-      v10 = (v8 | (((unsigned __int16)(lightColor & 0xF000) | (unsigned int)v9) >> 3)) >> 4;
-      v11 = (int *)pTarget;
-      v12 = pTargetZ;
-      v13 = v22;
-      v14 = (v10 << 16) | v10;
-      z = (unsigned __int8)pTarget & 2;
-      if ( (unsigned __int8)pTarget & 2 )
-      {
-        z = (unsigned int)*pTargetZ >> 16;
-        if ( z > v23 )
-        {
-          z = v14 + ((*pTarget & 0x7BDEu) >> 1);
-          *pTarget = z;
-        }
-        v13 = v22 - 1;
-        v11 = (int *)(pTarget + 1);
-        v12 = pTargetZ + 1;
-      }
-      while ( v13 != 1 )
-      {
-        if ( v13 < 1 )
-          return z;
-        z = (unsigned int)*v12 >> 16;
-        if ( z <= v23 )
-        {
-          v13 -= 2;
-          ++v11;
-          v12 += 2;
-        }
-        else
-        {
-          v12 += 2;
-          z = v14 + ((*v11 & 0x7BDE7BDEu) >> 1);
-          v13 -= 2;
-          *v11 = z;
-          ++v11;
-        }
-      }
-      z = (unsigned int)*v12 >> 16;
-      if ( z > v23 )
-      {
-        z = v14 + ((*(short *)v11 & 0x7BDEu) >> 1);
-        *(short *)v11 = z;
-      }
-    }
-    else
-    {
-      v15 = (v8 | (((unsigned __int16)(lightColor & 0xF800) | (unsigned int)v9) >> 2)) >> 4;
-      v16 = (int *)pTarget;
-      v17 = pTargetZ;
-      v18 = v22;
-      v19 = (v15 << 16) | v15;
-      z = (unsigned __int8)pTarget & 2;
-      if ( (unsigned __int8)pTarget & 2 )
-      {
-        z = (unsigned int)*pTargetZ >> 16;
-        if ( z > v23 )
+        for (uint y = 8; y < 352; ++y)
         {
-          z = v19 + ((*pTarget & 0xF7DEu) >> 1);
-          *pTarget = z;
-        }
-        v18 = v22 - 1;
-        v16 = (int *)(pTarget + 1);
-        v17 = pTargetZ + 1;
-      }
-      while ( v18 != 1 )
-      {
-        if ( v18 < 1 )
-          return z;
-        z = (unsigned int)*v17 >> 16;
-        if ( z <= v23 )
-        {
-          v18 -= 2;
-          ++v16;
-          v17 += 2;
+          memcpy(dst + y * dst_pitch,
+                 src + y * src_pitch, 8 * sizeof(__int32));
+          memcpy(dst + 8 + game_viewport_width + y * dst_pitch,
+                 src + 8 + game_viewport_width + y * src_pitch, 174/*172*/ * sizeof(__int32));
         }
-        else
-        {
-          v17 += 2;
-          z = v19 + ((*v16 & 0xF7DEF7DEu) >> 1);
-          v18 -= 2;
-          *v16 = z;
-          ++v16;
-        }
-      }
-      z = (unsigned int)*v17 >> 16;
-      if ( z > v23 )
-      {
-        z = v19 + ((*(short *)v16 & 0xF7DEu) >> 1);
-        *(short *)v16 = z;
-      }
-    }
-  }
-  return z;
-}
 
-//----- (004A57E9) --------------------------------------------------------
-void  Present_ColorKey()
-{
-  HRESULT v0; // eax@3
-  HRESULT v1; // eax@3
-  HRESULT v2; // eax@3
-  HRESULT v3; // eax@3
-  HRESULT v4; // eax@3
-  RECT a2; // [sp+4h] [bp-14h]@3
-  //CheckHRESULT_stru0 this; // [sp+14h] [bp-4h]@3
+        for (uint y = 352; y < 480; ++y)
+          memcpy(dst + y * dst_pitch,
+                 src + y * src_pitch, src_pitch * sizeof(__int32));
 
-  if ( !pRenderer->uNumSceneBegins )
-  {
-    if ( pRenderer->field_40110 )
-    {
-      a2.bottom = pViewport->uViewportTL_Y;
-      a2.left = 0;
-      a2.top = 0;
-      a2.right = 640;
-      ErrD3D(pRenderer->pBackBuffer4->BltFast(0, 0, pRenderer->pColorKeySurface4, &a2, 16u));
-      a2.right = 640;
-      a2.left = 0;
-      a2.top = pViewport->uViewportBR_Y + 1;
-      a2.bottom = 480;
-      ErrD3D(pRenderer->pBackBuffer4->BltFast(
-             0,
-             pViewport->uViewportBR_Y + 1,
-             pRenderer->pColorKeySurface4,
-             &a2,
-             16u));
-      a2.right = pViewport->uViewportTL_X;
-      a2.bottom = pViewport->uViewportBR_Y + 1;
-      a2.left = 0;
-      a2.top = pViewport->uViewportTL_Y;
-      ErrD3D(pRenderer->pBackBuffer4->BltFast(
-             0,
-             pViewport->uViewportTL_Y,
-             pRenderer->pColorKeySurface4,
-             &a2,
-             16u));
-      a2.left = pViewport->uViewportBR_X;
-      a2.top = pViewport->uViewportTL_Y;
-      a2.right = 640;
-      a2.bottom = pViewport->uViewportBR_Y + 1;
-      ErrD3D(pRenderer->pBackBuffer4->BltFast(
-             pViewport->uViewportBR_X,
-             pViewport->uViewportTL_Y,
-             pRenderer->pColorKeySurface4,
-             &a2,
-             16u));
-      a2.right = pViewport->uViewportBR_X;
-      a2.bottom = pViewport->uViewportBR_Y + 1;
-      a2.left = pViewport->uViewportTL_X;
-      a2.top = pViewport->uViewportTL_Y;
-      ErrD3D(pRenderer->pBackBuffer4->BltFast(
-             pViewport->uViewportTL_X,
-             pViewport->uViewportTL_Y,
-             pRenderer->pColorKeySurface4,
-             &a2,
-             17u));
-    }
-  }
+        for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y)
+        {
+          for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x)
+          {
+            //if (src[x + y * src_pitch] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask))
+            if (src[x + y * src_pitch] != 0xFFF8FCF8)  // FFF8FCF8 =  Color32(Color16(g_mask | b_mask))
+              dst[x + y * dst_pitch] = src[x + y * src_pitch];
+          }
+        }
 }
 
 //----- (004A597D) --------------------------------------------------------
@@ -2256,7 +2083,7 @@
   int v17; // eax@16
   HRESULT v18; // eax@22
   DDSURFACEDESC2 Dst; // [sp+Ch] [bp-98h]@3
-  int v20; // [sp+88h] [bp-1Ch]@10
+  //int v20; // [sp+88h] [bp-1Ch]@10
   int v21; // [sp+8Ch] [bp-18h]@10
   __int32 v22; // [sp+90h] [bp-14h]@10
   //unsigned __int32 v23; // [sp+94h] [bp-10h]@10
@@ -2266,19 +2093,19 @@
 
   if ( !pRenderer->uNumSceneBegins )
   {
-    if ( pRenderer->field_40110 )
+    if ( pRenderer->using_software_screen_buffer )
     {
       memset(&Dst, 0, 0x7Cu);
       Dst.dwSize = 124;
       if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) )
       {
         //v26 = Dst.lpSurface;
-        pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface;
+        //pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface;
         v24 = pRenderer->uTargetGMask | pRenderer->uTargetBMask |
               ((pRenderer->uTargetGMask | pRenderer->uTargetBMask) << 16);
-        pRenderer->pCurrentlyLockedSoftSurface = pRenderer->pTargetSurface;
-        pRenderer->uCurrentlyLockedSurfacePitch = Dst.lPitch;
-        v1 = pRenderer->pTargetSurface;
+        //pRenderer->pCurrentlyLockedSoftSurface = pRenderer->pTargetSurface;
+        //pRenderer->uCurrentlyLockedSurfacePitch = Dst.lPitch;
+        //v1 = pRenderer->pTargetSurface;
         v2 = Dst.lpSurface;
 
 
@@ -2288,8 +2115,12 @@
           for (uint x = 0; x < 640; ++x)
             pDst[x] = pRenderer->uTargetRMask | pRenderer->uTargetBMask;
         }*/
-        
-        ushort* pSrc = pRenderer->pTargetSurface;
+
+        if (!FORCE_16_BITS)
+          Present32((unsigned __int32 *)pRenderer->pTargetSurface, pRenderer->uTargetSurfacePitch, (unsigned __int32 *)Dst.lpSurface, Dst.lPitch / 4);
+        else
+        {        
+        ushort* pSrc = (unsigned short *)pRenderer->pTargetSurface;
         short* pDst = (__int16 *)Dst.lpSurface;
 
         for (uint y = 0; y < 8; ++y)
@@ -2323,7 +2154,7 @@
         //v26 = (LPVOID)(pViewport->uViewportW - pViewport->uViewportY + 1);
         v10 = (int)pSrc_x1y1;
         v11 = (int)pDst_x1y1;
-        int uHalfWidth = v20 = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2;
+        int uHalfWidth = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2;
         v13 = v24;
 
         for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y)
@@ -2336,6 +2167,7 @@
               pDst[y * Dst.lPitch / 2 + x] = pSrc[y * 640 + x];
           }
         }
+        }
 
               ErrD3D(pRenderer->pBackBuffer4->Unlock(0));
 
@@ -2541,7 +2373,7 @@
   v7 = pSpellStats->pInfos[v1].pName;
   a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1;
   a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1;
-  v8 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
+  v8 = Color16(0xFFu, 0xFFu, 0x9Bu);
   a1.DrawTitleText(pFontArrus, 0x78u, 0xCu, v8, v7, 3u);
   a1.DrawText(pFontSmallnum, 120, 44, 0, pTmpBuf2.data(), 0, 0, 0);
   a1.uFrameZ = a1.uFrameX + 107;
--- a/mm7_5.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/mm7_5.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -1144,14 +1144,6 @@
   return result;
 }
 
-//----- (0040DEF3) --------------------------------------------------------
-unsigned short TargetColor( unsigned __int16 r, unsigned __int16 g, unsigned __int16 b )
-{
-  return ((unsigned int)b >> (8 - LOBYTE(pRenderer->uTargetBBits))) | pRenderer->uTargetGMask & (g << (LOBYTE(pRenderer->uTargetGBits) + 
-                           LOBYTE(pRenderer->uTargetBBits) - 8)) | pRenderer->uTargetRMask & (r << (LOBYTE(pRenderer->uTargetGBits) + 
-                           LOBYTE(pRenderer->uTargetRBits) + LOBYTE(pRenderer->uTargetBBits) - 8));
-}
-
 
 
 //----- (0040F82D) --------------------------------------------------------
--- a/mm7_data.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/mm7_data.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -1005,7 +1005,6 @@
 std::array<char, 54> party_has_equipment;
 std::array<char, 17> byte_5111F6;
 
-std::array<std::array<unsigned __int16, 137>, 117> pOdmMinimap;
 unsigned int uNumBlueFacesInBLVMinimap;
 std::array<unsigned __int16, 50> pBlueFacesInBLVMinimapIDs;
 std::array<int, 14> pTextureIDs_PartyBuffIcons;
@@ -1190,6 +1189,7 @@
 float fTurnSpeedMultiplier = 1.0f; // weak
 float flt_6BE150_look_up_down_dangle = 1.0f; // weak
 //HWND hWnd; // idb
+bool FORCE_16_BITS = false;
 class OSWindow *window = nullptr;
 char pCurrentMapName[32]; // idb
 unsigned int uLevelMapStatsID;
--- a/mm7_data.h	Mon Dec 02 15:13:49 2013 +0200
+++ b/mm7_data.h	Tue Dec 03 20:18:17 2013 +0200
@@ -652,7 +652,6 @@
 
 extern int bRingsShownInCharScreen; // weak
 
-extern std::array<std::array<unsigned __int16, 137>, 117> pOdmMinimap;
 extern unsigned int uNumBlueFacesInBLVMinimap;
 extern std::array<unsigned __int16, 50> pBlueFacesInBLVMinimapIDs;
 extern std::array<int, 14> pTextureIDs_PartyBuffIcons;
@@ -843,7 +842,7 @@
 extern char pCurrentMapName[32]; // idb
 extern unsigned int uLevelMapStatsID;
 
-
+extern bool FORCE_16_BITS; // related to GAME_SETTINGS_INVALID_RESOLUTION
 #define GAME_SETTINGS_0001                            0x0001
 #define GAME_SETTINGS_INVALID_RESOLUTION              0x0002
 #define GAME_SETTINGS_NO_INTRO                        0x0004
@@ -1074,7 +1073,6 @@
 unsigned int SearchActorByGroup(unsigned int *pTotalActors, unsigned int uGroup);
 unsigned int SearchActorByID(unsigned int *pTotalActors, unsigned int a2);
 void PrepareArcomage();
-unsigned short TargetColor(unsigned __int16 r, unsigned __int16 g, unsigned __int16 b); // idb
 void DoBlt_Copy(unsigned __int16 *pPixels); // idb
 void __fastcall ZBuffer_Fill(int *pZBuffer, int uTextureId, int iZValue);
 void __fastcall ZBuffer_DoFill(int *pZBuffer, struct Texture *pTex, int uZValue);
@@ -1266,8 +1264,6 @@
 bool AreRenderSurfacesOk();
 unsigned int BlendColors(unsigned int c1, unsigned int c2); // weak
 void DoRenderBillboards_D3D();
-int __fastcall sr_4A46E6_draw_particle_segment(unsigned int x, signed int y, signed int z, int a4, unsigned int lightColor);
-void Present_ColorKey();
 void Present_NoColorKey();
 unsigned int ModulateColor(unsigned int diffuse, float multiplier); // idb
 struct SoundHeader *FindSound_BinSearch(unsigned int uStart, unsigned int uEnd, const char *pName);