changeset 2157:c6d8253d4cbc

Слияние
author Ritor1
date Fri, 10 Jan 2014 17:42:57 +0600
parents eaaaa50d34e9 (current diff) 0a1438c16c2b (diff)
children 10f03a70ab6d
files Outdoor.cpp Player.cpp UI/UICharacter.cpp
diffstat 47 files changed, 1415 insertions(+), 1852 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/Actor.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -41,7 +41,7 @@
 stru319 stru_50C198; // idb
 
 
-std::array<uint, 5> dword_4DF380_hostilityRanges = {0,1024,2560,5120,10240};
+std::array<uint, 5> _4DF380_hostilityRanges = {0, 1024, 2560, 5120, 10240};
 
 
 
@@ -2467,7 +2467,7 @@
 		}
 		if ( thisActor->pMonsterInfo.uHostilityType )
 		  v10 = pMonsterStats->pInfos[thisActor->pMonsterInfo.uID].uHostilityType;
-		v11 = dword_4DF380_hostilityRanges[v10];
+		v11 = _4DF380_hostilityRanges[v10];
 		v23 = abs(thisActor->vPosition.x - actor->vPosition.x);
 		v27 = abs(thisActor->vPosition.y - actor->vPosition.y);
 		v12 = abs(thisActor->vPosition.z - actor->vPosition.z);
@@ -2499,9 +2499,9 @@
     if ( v14 != 0 )
     {
       if ( !thisActor->pMonsterInfo.uHostilityType )
-        v15 = dword_4DF380_hostilityRanges[v14];
+        v15 = _4DF380_hostilityRanges[v14];
       else
-        v15 = dword_4DF380_hostilityRanges[4];
+        v15 = _4DF380_hostilityRanges[4];
       v16 = abs(thisActor->vPosition.x - pParty->vPosition.x);
       v28 = abs(thisActor->vPosition.y - pParty->vPosition.y);
       v17 = abs(thisActor->vPosition.z - pParty->vPosition.z);
@@ -3851,7 +3851,7 @@
   {
     if ( pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].bQuestMonster & 1 )
     {
-      if ( pRenderer->pRenderD3D && pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS )
+      if ( /*pRenderer->pRenderD3D &&*/ pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS )
       {
         v33 = byte_4D864C && pGame->uFlags & 0x80000 ? 10 * pMonster->uActorRadius : pMonster->uActorRadius;
         pDecalBuilder->AddBloodsplat((float)pMonster->vPosition.x, (float)pMonster->vPosition.y, (float)pMonster->vPosition.z, 1.0, 0.0, 0.0, (float)v33, 0, 0);
--- a/Arcomage.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/Arcomage.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -53,10 +53,8 @@
 void GameResultsApply();
 
 void am_DrawText(int a1, const char *pText, POINT *pXY);
-void  am_BeginScene(unsigned __int16 *pPcxPixels, int a2, int a3); // idb
-void __fastcall Blt_Chroma(RECT  *pSrcXYZW, POINT *pTargetXY, int a3, int a4);
-void  Blt_Copy(RECT *pSrcRect, POINT *pTargetXY, int a3);
-void  am_EndScene();
+void am_BeginScene(unsigned __int16 *pPcxPixels, int a2, int a3); // idb
+void am_EndScene();
 void DrawRect(RECT *pXYZW, unsigned __int16 uColor, char bSolidFill);
 void DrawSquare( POINT *pTargetXY, unsigned __int16 uColor );
 void DrawPixel(POINT *pTargetXY, unsigned __int16 uColor);
@@ -171,6 +169,7 @@
 bool am_gameover; // 004FAA2C
 char byte_4FAA2D; // weak
 
+int am_default_starting_player = 0; // 505890
 int current_player_num; // 004FAA6C
 char need_to_discard_card; // 04FAA77
 
@@ -466,7 +465,7 @@
 
   pRenderer->BeginScene();
   pArcomageGame->pBlit_Copy_pixels = pPixels;
-  Blt_Copy(&pSrcRect, &pTargetPoint, 2);
+  pRenderer->am_Blt_Copy(&pSrcRect, &pTargetPoint, 2);
   pRenderer->EndScene();
   pArcomageGame->pBlit_Copy_pixels = 0;
 }
@@ -616,7 +615,7 @@
 }
 
 //----- (0040D7EC) --------------------------------------------------------
-void __fastcall Blt_Chroma(RECT *pSrcRect, POINT *pTargetPoint, int a3, int blend_mode)
+void Render::am_Blt_Chroma(RECT *pSrcRect, POINT *pTargetPoint, int a3, int blend_mode)
 {
 
 unsigned __int16 *pSrc; // eax@2
@@ -630,7 +629,7 @@
 int uSrcPitch; // [sp+1Ch] [bp-8h]@5
 
 
-if ( !pRenderer->uNumSceneBegins )
+if ( !uNumSceneBegins )
     return;
 if ( !pArcomageGame->pBlit_Copy_pixels )
     return;
@@ -655,8 +654,8 @@
 uSrcPitch = uSrcTotalWidth;
 
 src_surf_pos = &pSrc[pSrcRect->left + uSrcPitch * pSrcRect->top];
-v10 = 0xFFu >> (8 - (unsigned __int8)pRenderer->uTargetBBits);
-v21 = (pRenderer->uTargetGBits != 6 ? 0x31EF : 0x7BEF);
+v10 = 0xFFu >> (8 - (unsigned __int8)uTargetBBits);
+v21 = (uTargetGBits != 6 ? 0x31EF : 0x7BEF);
 
 
 if ( blend_mode == 2 )
@@ -667,7 +666,7 @@
             for (int j=0; j< src_width; ++j)
                 {
                 if ( *src_surf_pos != v10 )
-                  pRenderer->WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, *src_surf_pos);
+                  WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, *src_surf_pos);
                     //*dest_surf_pos = *src_surf_pos;
                 //++dest_surf_pos;
                 ++src_surf_pos;
@@ -684,7 +683,7 @@
         for (int j=0; j< src_width; ++j)
             {
             if ( *src_surf_pos != v10 )
-              pRenderer->WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, (v21 & (pRenderer->ReadPixel16(pTargetPoint->x + j, pTargetPoint->y + i) >> 1)) + (v21 & (*src_surf_pos >> 1)));
+              WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, (v21 & (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;
@@ -697,7 +696,7 @@
 }
 
 //----- (0040D9B1) --------------------------------------------------------
-void Blt_Copy( RECT *pSrcRect, POINT *pTargetPoint, int blend_mode )
+void Render::am_Blt_Copy( RECT *pSrcRect, POINT *pTargetPoint, int blend_mode )
     {
 
     unsigned __int16 *pSrc; // eax@2
@@ -709,7 +708,7 @@
     __int32 src_height; // [sp+18h] [bp-Ch]@3
     int uSrcPitch; // [sp+1Ch] [bp-8h]@5
 
-    if ( !pRenderer->uNumSceneBegins )
+    if ( !uNumSceneBegins )
         return;
     if ( !pArcomageGame->pBlit_Copy_pixels )
         return;
@@ -734,7 +733,7 @@
     uSrcPitch = uSrcTotalWidth;
 
     src_surf_pos = &pSrc[pSrcRect->left + uSrcPitch * pSrcRect->top];
-    v21 = (pRenderer->uTargetGBits != 6 ? 0x31EF : 0x7BEF);
+    v21 = (uTargetGBits != 6 ? 0x31EF : 0x7BEF);
 
     if ( blend_mode == 2 )
         {
@@ -743,7 +742,7 @@
             {
             for (int j=0; j< src_width; ++j)
                 { 
-                  pRenderer->WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, *src_surf_pos);
+                  WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, *src_surf_pos);
                 //*dest_surf_pos = *src_surf_pos;
                 //++dest_surf_pos;
                 ++src_surf_pos;
@@ -761,7 +760,7 @@
                 {
                  //*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)));
+                  WritePixel16(pTargetPoint->x + j, pTargetPoint->y + i, (v21 & (ReadPixel16(pTargetPoint->x + j, pTargetPoint->y + i) >> 1)) + (v21 & (*src_surf_pos >> 1)));
                 ++src_surf_pos;
                 }
             src_surf_pos+=uSrcPitch;
@@ -771,7 +770,7 @@
 }
 
 //----- (0040DB10) --------------------------------------------------------
-void  am_EndScene()
+void am_EndScene()
 {
   pRenderer->EndScene();
   pArcomageGame->pBlit_Copy_pixels = NULL;
@@ -1303,7 +1302,7 @@
   signed int i; // ecx@13
   signed int card_dispenser_counter; // eax@13
 
-  current_player_num = dword_505890;
+  current_player_num = am_default_starting_player;
   SetStartConditions();
   for(i=0; i<2; ++i )
   {
@@ -1812,7 +1811,7 @@
       pSrcXYZW.top = 0;
       pSrcXYZW.bottom = 480;
       am_BeginScene(pArcomageGame->pBackgroundPixels, -1, 1);
-      Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
+      pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
       am_EndScene();
       DrawGameUI(animation_stage);
       pRenderer->Present();
@@ -1895,11 +1894,11 @@
 
   pTargetXY.x = 8;
   pTargetXY.y = 56;
-  Blt_Copy(&pSrcRect, &pTargetXY, 2);
+  pRenderer->am_Blt_Copy(&pSrcRect, &pTargetXY, 2);
 
   pTargetXY.x = 555;
   pTargetXY.y = 56;
-  Blt_Copy(&pSrcRect, &pTargetXY, 2);
+  pRenderer->am_Blt_Copy(&pSrcRect, &pTargetXY, 2);
 
   //players name rectangle
   pSrcRect.left   = 283;
@@ -1908,11 +1907,11 @@
   pSrcRect.bottom = 190;
   pTargetXY.x = 8;
   pTargetXY.y = 13;
-  Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2);
+  pRenderer->am_Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2);
 
   pTargetXY.x = 555;
   pTargetXY.y = 13;
-  Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2);
+  pRenderer->am_Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2);
 
   //tower height rectangle
   pSrcRect.left   = 234;
@@ -1921,11 +1920,11 @@
   pSrcRect.bottom = 190;
   pTargetXY.x = 100;
   pTargetXY.y = 296;
-  Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2);
+  pRenderer->am_Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2);
 
   pTargetXY.x = 492;
   pTargetXY.y = 296;
-  Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2);
+  pRenderer->am_Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2);
 
   //wall height rectangle
   pSrcRect.left   = 192; 
@@ -1934,11 +1933,11 @@
   pSrcRect.bottom = 190;
   pTargetXY.x = 168;
   pTargetXY.y = 296;
-  Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2);
+  pRenderer->am_Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2);
 
   pTargetXY.x = 430;
   pTargetXY.y = 296;
-  Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2);
+  pRenderer->am_Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2);
 }
 
 //----- (0040AC5F) --------------------------------------------------------
@@ -2099,7 +2098,7 @@
       pSrcRect.left = v7 - 864;
       pSrcRect.top = 190;
       pSrcRect.bottom = 207;
-      Blt_Chroma(&pSrcRect, &pTargetPoint, pArcomageGame->field_54, 1);
+      pRenderer->am_Blt_Chroma(&pSrcRect, &pTargetPoint, pArcomageGame->field_54, 1);
       pTargetPoint.x += 22;
     }
   }
@@ -2132,7 +2131,7 @@
             pSrcRect.right = v7 - 357;
             pSrcRect.top = 128;
             pSrcRect.bottom = 138;
-            Blt_Copy(&pSrcRect, &pTargetPoint, 2);
+            pRenderer->am_Blt_Copy(&pSrcRect, &pTargetPoint, 2);
             pTargetPoint.x += 13;
             }
         }
@@ -2166,7 +2165,7 @@
             pSrcRect.right = v7 - 357;
             pSrcRect.top = 138;
             pSrcRect.bottom = 148;
-            Blt_Copy(&pSrcRect, &pTargetPoint, 2);
+            pRenderer->am_Blt_Copy(&pSrcRect, &pTargetPoint, 2);
             pTargetPoint.x += 13;
             }
         }
@@ -2200,7 +2199,7 @@
             pSrcRect.right = v7 - 357;
             pSrcRect.top = 148;
             pSrcRect.bottom = 158;
-            Blt_Copy(&pSrcRect, &pTargetPoint, 2);
+            pRenderer->am_Blt_Copy(&pSrcRect, &pTargetPoint, 2);
             pTargetPoint.x += 13;
             }
         }
@@ -2227,7 +2226,7 @@
 pSrcXYZW.bottom = tower_top;
 pTargetXY.x = 102;
 pTargetXY.y = 297 - tower_top;
-Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
+pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
 
 pSrcXYZW.top = 0;
 pSrcXYZW.left = 384;
@@ -2235,7 +2234,7 @@
 pSrcXYZW.bottom = 94;
 pTargetXY.y = 203 - tower_top;
 pTargetXY.x = 91;
-Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2);
+pRenderer->am_Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2);
 
 
 tower_height = am_Players[1].tower_height;
@@ -2249,7 +2248,7 @@
 
 pTargetXY.x = 494;
 pTargetXY.y = 297 - tower_top;
-Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
+pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
 //draw tower up cone
 pSrcXYZW.left   = 384;
 pSrcXYZW.right  = 452;
@@ -2258,7 +2257,7 @@
 
 pTargetXY.x = 483;
 pTargetXY.y = 203 - tower_top;
-Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2);
+pRenderer->am_Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2);
  
 }
 // 4E1884: using guessed type int dword_4E1884;
@@ -2290,7 +2289,7 @@
 pSrcXYZW.bottom = v1;
 pTargetXY.x = 177;
 pTargetXY.y = 297 - v1;
-Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2);
+pRenderer->am_Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2);
  }
 
 v3 = am_Players[1].wall_height;
@@ -2308,7 +2307,7 @@
 pSrcXYZW.bottom = v4;
 pTargetXY.x = 439;
 pTargetXY.y =  297 - v4;
-Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2);
+pRenderer->am_Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2);
         }
 }
 
@@ -2370,16 +2369,16 @@
             pSrcXYZW.right = 288;
             pSrcXYZW.top = 0;
             pSrcXYZW.bottom = 128;
-            Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
+            pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
             goto LABEL_13;
             }
         pArcomageGame->GetCardRect(v7, &pSrcXYZW);
         if ( !CanCardBePlayed(current_player_num, v2) )
             {
-            Blt_Copy(&pSrcXYZW, &pTargetXY, 0);
+            pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 0);
             goto LABEL_13;
             }
-        Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
+        pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
 
         }
 LABEL_13:
@@ -2401,7 +2400,7 @@
         if ( shown_cards[v11].uCardId != -1 )
             {
             pArcomageGame->GetCardRect(shown_cards[v11].uCardId, &pSrcXYZW);
-            Blt_Copy(&pSrcXYZW, &shown_cards[v11].field_18_point, 0);
+            pRenderer->am_Blt_Copy(&pSrcXYZW, &shown_cards[v11].field_18_point, 0);
             }
         if ( shown_cards[v11].field_4 != 0 )
             {
@@ -2411,7 +2410,7 @@
             pSrcXYZW.right  = 916;
             pSrcXYZW.top    = 200;
             pSrcXYZW.bottom = 216;
-            Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2);
+            pRenderer->am_Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2);
             }
         }
     else if ( amuint_4FAA34 <= 0 )
@@ -2436,7 +2435,7 @@
             shown_cards[v11].field_18_point.x += shown_cards[v11].field_10_xplus;
             shown_cards[v11].field_18_point.y += shown_cards[v11].field_14_y_plus;
             pArcomageGame->GetCardRect(shown_cards[v11].uCardId, &pSrcXYZW);
-            Blt_Copy(&pSrcXYZW, &shown_cards[v11].field_18_point, 0);
+            pRenderer->am_Blt_Copy(&pSrcXYZW, &shown_cards[v11].field_18_point, 0);
             }
         }
     }
@@ -2449,7 +2448,7 @@
     pSrcXYZW.bottom = 128;
     pTargetXY.x     = 120;
     pTargetXY.y     = 18;
-    Blt_Copy(&pSrcXYZW, &pTargetXY, 0);
+    pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 0);
 
 }
 
@@ -2515,7 +2514,7 @@
         pSrcXYZW.top = 0;
         pSrcXYZW.right = 288;
         pSrcXYZW.bottom = 128;
-        Blt_Copy(&pSrcXYZW, &am_uint_4FAA44_blt_xy, 2);
+        pRenderer->am_Blt_Copy(&pSrcXYZW, &am_uint_4FAA44_blt_xy, 2);
         }
     else
         {
@@ -2527,7 +2526,7 @@
     pSrcXYZW.bottom = 128;
     am_uint_4FAA44_blt_xy.x += amuint_4FAA3C_blt_xy.x;
     am_uint_4FAA44_blt_xy.y += amuint_4FAA3C_blt_xy.y;
-    Blt_Copy(&pSrcXYZW, &am_uint_4FAA44_blt_xy, 2);
+    pRenderer->am_Blt_Copy(&pSrcXYZW, &am_uint_4FAA44_blt_xy, 2);
     if ( !amuint_4FAA38 )
         {
         
@@ -2569,7 +2568,7 @@
 //LABEL_20:
             pTargetXY.x = shown_cards[v8].field_8.x;
             pTargetXY.y = shown_cards[v8].field_8.y;
-            Blt_Copy(&pSrcXYZW, &pTargetXY, 0);
+            pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 0);
             uCardID = -1;
             }
         }
@@ -2578,7 +2577,7 @@
         pArcomageGame->GetCardRect(uCardID, &pSrcXYZW);
         amuint_4FAA5C_blt_xy.x += amuint_4FAA54_blt_xy.x;
         amuint_4FAA5C_blt_xy.y += amuint_4FAA54_blt_xy.y;
-        Blt_Copy(&pSrcXYZW, &amuint_4FAA5C_blt_xy, 0);
+        pRenderer->am_Blt_Copy(&pSrcXYZW, &amuint_4FAA5C_blt_xy, 0);
         }
     }
 
@@ -2590,7 +2589,7 @@
         pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW);
         amuint_4FAA5C_blt_xy.x += amuint_4FAA54_blt_xy.x;
         amuint_4FAA5C_blt_xy.y += amuint_4FAA54_blt_xy.y;
-        Blt_Copy(&pSrcXYZW, &amuint_4FAA5C_blt_xy, 2);
+        pRenderer->am_Blt_Copy(&pSrcXYZW, &amuint_4FAA5C_blt_xy, 2);
         return;
         }
     if ( v15 == 15.0 )
@@ -2599,7 +2598,7 @@
         pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW);
         pTargetXY.x = 272;
         pTargetXY.y = 173;
-        Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
+        pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
         return;
         }
     if ( v15 == 5.0 )
@@ -2617,7 +2616,7 @@
             pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW);
             pTargetXY.x = 272;
             pTargetXY.y = 173;
-            Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
+            pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
             return;
         }
     if ( v15 >= 5.0 )
@@ -2632,7 +2631,7 @@
             pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW);
             amuint_4FAA5C_blt_xy.x += amuint_4FAA54_blt_xy.x;
             amuint_4FAA5C_blt_xy.y += amuint_4FAA54_blt_xy.y;
-            Blt_Copy(&pSrcXYZW, &amuint_4FAA5C_blt_xy, 0);
+            pRenderer->am_Blt_Copy(&pSrcXYZW, &amuint_4FAA5C_blt_xy, 0);
             return;
             }
         }
@@ -2642,7 +2641,7 @@
         pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW);
         pTargetXY.x = 272;
         pTargetXY.y = 173;
-        Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
+        pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
         return;
         }
 
@@ -2657,7 +2656,7 @@
         }
         pTargetXY.x = shown_cards[v19].field_8.x;
     pTargetXY.y = shown_cards[v19].field_8.y;
-    Blt_Copy(&pSrcXYZW, &pTargetXY, 0);
+    pRenderer->am_Blt_Copy(&pSrcXYZW, &pTargetXY, 0);
     played_card_id = -1;
     }
 }
@@ -3986,7 +3985,7 @@
   pXYZW.top = 0;
   pXYZW.bottom = 480;
   am_BeginScene(pArcomageGame->pBackgroundPixels, -1, 1);
-  Blt_Copy(&pXYZW, &pXY, 2);
+  pRenderer->am_Blt_Copy(&pXYZW, &pXY, 2);
   am_EndScene();
   pRenderer->Present();
   ArcomageGame::LoadSprites();
@@ -4087,7 +4086,7 @@
 void DrawSquare( POINT *pTargetXY, unsigned __int16 uColor )
 {
     pRenderer->BeginScene();
-    if ( pRenderer->uNumSceneBegins )
+    //if ( uNumSceneBegins )
     {
       pRenderer->WritePixel16(pTargetXY->x,     pTargetXY->y, uColor);
       pRenderer->WritePixel16(pTargetXY->x + 1, pTargetXY->y, uColor);
@@ -4110,7 +4109,7 @@
 void DrawPixel( POINT *pTargetXY, unsigned __int16 uColor )
 {
     pRenderer->BeginScene();
-    if ( pRenderer->uNumSceneBegins )
+    //if ( pRenderer->uNumSceneBegins )
         {
           pRenderer->WritePixel16(pTargetXY->x, pTargetXY->y, uColor);
         /*int xVal = pTargetXY->x;
--- a/AudioPlayer.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/AudioPlayer.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -56,6 +56,7 @@
 
 
 void ReleaseSoundData(void *_this);
+_DIG_DRIVER *Audio_GetFirstHardwareDigitalDriver();
 
 
 
@@ -1588,16 +1589,16 @@
                 v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
                 *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
                 v18 = a1.vWorldPosition.z - (double)pParty->vPosition.z;
-                if ( pRenderer->pRenderD3D )
+                //if ( pRenderer->pRenderD3D )
                 {
                   v19 = *(float *)&uNumRepeats * v56 + v58 * v55;
                   v20 = v58 * v56 - *(float *)&uNumRepeats * v55;
                 }
-                else
+                /*else
                 {
                   v19 = v58 * v55 - *(float *)&uNumRepeats * v56;
                   v20 = v58 * v56 + *(float *)&uNumRepeats * v55;
-                }
+                }*/
                 a1.vWorldViewPosition.x = v19 * v16 - v18 * v17;
                 a1.vWorldViewPosition.y = v20;
                 a1.vWorldViewPosition.z = v19 * v17 + v18 * v16;
@@ -1606,16 +1607,16 @@
               {
                 v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
                 *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
-                if ( pRenderer->pRenderD3D )
+                //if ( pRenderer->pRenderD3D )
                 {
                   a1.vWorldViewPosition.x = *(float *)&uNumRepeats * v56 + v58 * v55;
                   v21 = v58 * v56 - *(float *)&uNumRepeats * v55;
                 }
-                else
+                /*else
                 {
                   a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56;
                   v21 = v58 * v56 + *(float *)&uNumRepeats * v55;
-                }
+                }*/
                 a1.vWorldViewPosition.y = v21;
                 a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.z;
               }
@@ -1659,16 +1660,16 @@
                 v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
                 *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
                 v18 = a1.vWorldPosition.z - (double)pParty->vPosition.z;
-                if ( pRenderer->pRenderD3D )
+                //if ( pRenderer->pRenderD3D )
                 {
                   v19 = *(float *)&uNumRepeats * v56 + v58 * v55;
                   v20 = v58 * v56 - *(float *)&uNumRepeats * v55;
                 }
-                else
+                /*else
                 {
                   v19 = v58 * v55 - *(float *)&uNumRepeats * v56;
                   v20 = v58 * v56 + *(float *)&uNumRepeats * v55;
-                }
+                }*/
                 a1.vWorldViewPosition.x = v19 * v16 - v18 * v17;
                 a1.vWorldViewPosition.y = v20;
                 a1.vWorldViewPosition.z = v19 * v17 + v18 * v16;
@@ -1677,16 +1678,16 @@
               {
                 v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
                 *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
-                if ( pRenderer->pRenderD3D )
+                //if ( pRenderer->pRenderD3D )
                 {
                   a1.vWorldViewPosition.x = *(float *)&uNumRepeats * v56 + v58 * v55;
                   v21 = v58 * v56 - *(float *)&uNumRepeats * v55;
                 }
-                else
+                /*else
                 {
                   a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56;
                   v21 = v58 * v56 + *(float *)&uNumRepeats * v55;
-                }
+                }*/
                 a1.vWorldViewPosition.y = v21;
                 a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.z;
               }
@@ -1733,16 +1734,16 @@
             v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
             *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
             v18 = a1.vWorldPosition.z - (double)pParty->vPosition.z;
-            if ( pRenderer->pRenderD3D )
+            //if ( pRenderer->pRenderD3D )
             {
               v19 = *(float *)&uNumRepeats * v56 + v58 * v55;
               v20 = v58 * v56 - *(float *)&uNumRepeats * v55;
             }
-            else
+            /*else
             {
               v19 = v58 * v55 - *(float *)&uNumRepeats * v56;
               v20 = v58 * v56 + *(float *)&uNumRepeats * v55;
-            }
+            }*/
             a1.vWorldViewPosition.x = v19 * v16 - v18 * v17;
             a1.vWorldViewPosition.y = v20;
             a1.vWorldViewPosition.z = v19 * v17 + v18 * v16;
@@ -1751,16 +1752,16 @@
           {
             v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
             *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
-            if ( pRenderer->pRenderD3D )
+            //if ( pRenderer->pRenderD3D )
             {
               a1.vWorldViewPosition.x = *(float *)&uNumRepeats * v56 + v58 * v55;
               v21 = v58 * v56 - *(float *)&uNumRepeats * v55;
             }
-            else
+            /*else
             {
               a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56;
               v21 = v58 * v56 + *(float *)&uNumRepeats * v55;
-            }
+            }*/
             a1.vWorldViewPosition.y = v21;
             a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.z;
           }
@@ -1831,16 +1832,16 @@
             v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
             *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
             v18 = a1.vWorldPosition.z - (double)pParty->vPosition.z;
-            if ( pRenderer->pRenderD3D )
+            //if ( pRenderer->pRenderD3D )
             {
               v19 = *(float *)&uNumRepeats * v56 + v58 * v55;
               v20 = v58 * v56 - *(float *)&uNumRepeats * v55;
             }
-            else
+            /*else
             {
               v19 = v58 * v55 - *(float *)&uNumRepeats * v56;
               v20 = v58 * v56 + *(float *)&uNumRepeats * v55;
-            }
+            }*/
             a1.vWorldViewPosition.x = v19 * v16 - v18 * v17;
             a1.vWorldViewPosition.y = v20;
             a1.vWorldViewPosition.z = v19 * v17 + v18 * v16;
@@ -1849,16 +1850,16 @@
           {
             v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x;
             *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y;
-            if ( pRenderer->pRenderD3D )
+            //if ( pRenderer->pRenderD3D )
             {
               a1.vWorldViewPosition.x = *(float *)&uNumRepeats * v56 + v58 * v55;
               v21 = v58 * v56 - *(float *)&uNumRepeats * v55;
             }
-            else
+            /*else
             {
               a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56;
               v21 = v58 * v56 + *(float *)&uNumRepeats * v55;
-            }
+            }*/
             a1.vWorldViewPosition.y = v21;
             a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.z;
           }
--- a/CastSpellInfo.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/CastSpellInfo.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -1046,7 +1046,7 @@
 
 			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2);
 
-			pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_REGENERATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)v733 * 4.2666669), v731, amount, 0, 0);
+			pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_REGENERATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)v733 * 4.2666669), v731, amount, 0, 0);
 			LODWORD(v727) = 1;
 			break;
 		}
@@ -1237,7 +1237,7 @@
 					pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id);
 					pSpellSprite.vPosition.x = v112->vPosition.x;
 					pSpellSprite.vPosition.y = v112->vPosition.y;
-					pSpellSprite.vPosition.z = v112->vPosition.z - (unsigned int)(signed __int64)((double)(signed int)v112->uActorHeight * unk_4D8548);
+					pSpellSprite.vPosition.z = v112->vPosition.z - (unsigned int)(signed __int64)((double)v112->uActorHeight * -0.8);
 					pSpellSprite.spell_target_pid = PID(OBJECT_Actor, a2);
 					v122 = pSpellSprite.Create(0, 0, 0, 0);
 					DamageMonsterFromParty(PID(OBJECT_Item, v122), PID_ID(a2), &v701);
@@ -1418,7 +1418,7 @@
 			}
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
-			int _v726 = _46A6AC_spell_render((int)dword_50BF30.data(), 100, 4096);
+			int _v726 = pRenderer->_46A6AC_spell_render_d3d((int)dword_50BF30.data(), 100, 4096);
 			v700.z = 0;
 			v700.y = 0;
 			v700.x = 0;
@@ -1442,7 +1442,7 @@
 					v162 = dword_50BF30[a2];
 					pSpellSprite.vPosition.x = pActors[v162].vPosition.x;
 					pSpellSprite.vPosition.y = pActors[v162].vPosition.y;
-					pSpellSprite.vPosition.z = pActors[v162].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v162].uActorHeight * unk_4D8548);
+					pSpellSprite.vPosition.z = pActors[v162].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v162].uActorHeight * -0.8);
 					pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
 					v164 = pSpellSprite.Create(0, 0, 0, 0);
 					v165 = a2;
@@ -2393,8 +2393,8 @@
 				LODWORD(v733) = 300 * v2 + 180;
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
-			int _v726 = _46A6AC_spell_render((int)dword_50BF30.data(), 100, 4096);
-			pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFFFFFFu, 0xC0u);
+			int _v726 = pRenderer->_46A6AC_spell_render_d3d((int)dword_50BF30.data(), 100, 4096);
+			pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFFFFFF, 192);
 			++pSpellSprite.uType;
 			pSpellSprite.stru_24.Reset();
 			pSpellSprite.spell_id = pCastSpell->uSpellID;
@@ -2415,7 +2415,7 @@
 				{
 					pSpellSprite.vPosition.x = v369->vPosition.x;
 					pSpellSprite.vPosition.y = v369->vPosition.y;
-					pSpellSprite.vPosition.z = v369->vPosition.z - (unsigned int)(signed __int64)((double)v369->uActorHeight * unk_4D8548);
+					pSpellSprite.vPosition.z = v369->vPosition.z - (unsigned int)(signed __int64)((double)v369->uActorHeight * -0.8);
 
 					pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
 					pSpellSprite.Create(0, 0, 0, 0);
@@ -2863,8 +2863,8 @@
 				amount = 180 * v2;
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
-			int _v726 = _46A6AC_spell_render((int)dword_50BF30.data(), 100, 4096);
-			pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xA0A0Au, 0xC0u);
+			int _v726 = pRenderer->_46A6AC_spell_render_d3d((int)dword_50BF30.data(), 100, 4096);
+			pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xA0A0Au, 192);
 			++pSpellSprite.uType;
 			pSpellSprite.stru_24.Reset();
 			pSpellSprite.spell_id = pCastSpell->uSpellID;
@@ -2885,7 +2885,7 @@
 					break;
 				pSpellSprite.vPosition.x = v433->vPosition.x;
 				pSpellSprite.vPosition.y = v433->vPosition.y;
-				pSpellSprite.vPosition.z = v433->vPosition.z - (unsigned int)(signed __int64)((double)v433->uActorHeight * unk_4D8548);
+				pSpellSprite.vPosition.z = v433->vPosition.z - (unsigned int)(signed __int64)((double)v433->uActorHeight * -0.8);
 
 				pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
 				pSpellSprite.Create(0, 0, 0, 0);
@@ -3251,8 +3251,8 @@
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
 
-			pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xAFF0Au, 0xC0u);
-			v505 = _46A6AC_spell_render((int)dword_50BF30.data(), 100, 4096);
+			pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xAFF0A, 192);
+			v505 = pRenderer->_46A6AC_spell_render_d3d((int)dword_50BF30.data(), 100, 4096);
 			++pSpellSprite.uType;
 			//signed int _v733 = v505;
 			v688.x = 0;
@@ -3276,7 +3276,7 @@
 				v507 = dword_50BF30[a2];
 				pSpellSprite.vPosition.x = pActors[v507].vPosition.x;
 				pSpellSprite.vPosition.y = pActors[v507].vPosition.y;
-				pSpellSprite.vPosition.z = pActors[v507].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v507].uActorHeight * unk_4D8548);
+				pSpellSprite.vPosition.z = pActors[v507].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v507].uActorHeight * -0.8);
 				pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
 				v509 = pSpellSprite.Create(0, 0, 0, 0);
 				DamageMonsterFromParty(PID(OBJECT_Item, v509), dword_50BF30[a2], &v688);
@@ -3286,7 +3286,7 @@
 				pActor = &pActors[dword_50BF30[a2]];
 				pSpellSprite.vPosition.x = pActor->vPosition.x;
 				pSpellSprite.vPosition.y = pActor->vPosition.y;
-				pSpellSprite.vPosition.z = pActor->vPosition.z - (unsigned int)(signed __int64)((double)pActor->uActorHeight * unk_4D8548);
+				pSpellSprite.vPosition.z = pActor->vPosition.z - (unsigned int)(signed __int64)((double)pActor->uActorHeight * -0.8);
 				pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
 				pSpellSprite.Create(0, 0, 0, 0);
 				for (int i = 0; i < 22; ++i)
@@ -3372,7 +3372,7 @@
 			}
 			if ( !pPlayer->CanCastSpell(uRequiredMana) )
 				break;
-			v531 = _46A6AC_spell_render((int)dword_50BF30.data(), 100, 4096);
+			v531 = pRenderer->_46A6AC_spell_render_d3d((int)dword_50BF30.data(), 100, 4096);
 			++pSpellSprite.uType;
 			v694.x = 0;
 			v694.y = 0;
@@ -3397,7 +3397,7 @@
 					v533 = dword_50BF30[a2];
 					pSpellSprite.vPosition.x = pActors[v533].vPosition.x;
 					pSpellSprite.vPosition.y = pActors[v533].vPosition.y;
-					pSpellSprite.vPosition.z = pActors[v533].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v533].uActorHeight * unk_4D8548);
+					pSpellSprite.vPosition.z = pActors[v533].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v533].uActorHeight * -0.8);
 					pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
 					v535 = pSpellSprite.Create(0, 0, 0, 0);
 					v536 = a2;
@@ -3603,7 +3603,7 @@
 			pSpellSprite.vPosition.x = *(short *)(v721 + 142);
 			pSpellSprite.vPosition.y = *(short *)(v721 + 144);
 			v732 = *(short *)(v721 + 138);
-			pSpellSprite.vPosition.z = *(short *)(v721 + 146) - (unsigned int)(signed __int64)((double)v732 * unk_4D8548);
+			pSpellSprite.vPosition.z = *(short *)(v721 + 146) - (unsigned int)(signed __int64)((double)v732 * -0.8);
 			pSpellSprite.spell_target_pid = PID(OBJECT_Actor, (int)v577);
 			pSpellSprite.Create(0, 0, 0, 0);
 			if ( *(char *)(v581 + 52) > amount )
@@ -3909,7 +3909,7 @@
 				break;
 			pGame->GetIndoorCamera();
 			v623 = (signed __int64)pGame->pIndoorCameraD3D->GetPickDepth();
-			signed int _v733 = _46A6AC_spell_render((int)dword_50BF30.data(), 100, v623);
+			signed int _v733 = pRenderer->_46A6AC_spell_render_d3d((int)dword_50BF30.data(), 100, v623);
 			v707.x = 0;
 			v707.y = 0;
 			v707.z = 0;
@@ -3936,7 +3936,7 @@
 					pSpellSprite.vPosition.x = pActors[v625].vPosition.x;
 					pSpellSprite.vPosition.y = pActors[v625].vPosition.y;
 					//v732 = pActors[v625].uActorHeight;
-					pSpellSprite.vPosition.z = pActors[v625].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v625].uActorHeight * unk_4D8548);
+					pSpellSprite.vPosition.z = pActors[v625].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v625].uActorHeight * -0.8);
 					pSpellSprite.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]);
 					v627 = pSpellSprite.Create(0, 0, 0, 0);
 					v628 = a2;
--- a/Chest.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/Chest.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -814,7 +814,7 @@
   else
   {
     v1 = pMouse->GetCursorPos(&a2);
-    v2 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v7)->y]] & 0xFFFF;
+    v2 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v7)->y]] & 0xFFFF;
     if ( v2 )
     {
       if ( v2 )
--- a/DecalBuilder.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/DecalBuilder.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -648,79 +648,12 @@
   return result;
 }
 
-//----- (0049C095) --------------------------------------------------------
-void DecalBuilder::DrawDecal(Decal *pDecal, float z_bias)
-{
-  signed int v21; // [sp+Ch] [bp-864h]@15
-  RenderVertexD3D3 pVerticesD3D[64]; // [sp+20h] [bp-850h]@6
-
-  if (pDecal->uNumVertices < 3)
-  {
-    Log::Warning(L"Decal has < 3 vertices");
-    return;
-  }
-
-  float color_mult;
-  if ( pDecal->field_C1C & 1 )
-    color_mult = 1.0;
-  else
-    color_mult = pDecal->field_C18->_43B570_get_color_mult_by_time();
-
-  for (uint i = 0; i < pDecal->uNumVertices; ++i)
-  {
-    uint uTint = pRenderer->GetActorTintColor(pDecal->pVertices[i].vWorldViewPosition.x, pDecal->field_C14, 0, 0, nullptr);
-
-    uint uTintR = (uTint >> 16) & 0xFF,
-         uTintG = (uTint >> 8) & 0xFF,
-         uTintB = uTint & 0xFF;
-
-    uint uDecalColorMultR = (pDecal->uColorMultiplier >> 16) & 0xFF,
-         uDecalColorMultG = (pDecal->uColorMultiplier >> 8) & 0xFF,
-         uDecalColorMultB = pDecal->uColorMultiplier & 0xFF;
-
-    uint uFinalR = floorf(uTintR / 255.0 * color_mult * uDecalColorMultR + 0.0f),
-         uFinalG = floorf(uTintG / 255.0 * color_mult * uDecalColorMultG + 0.0f),
-         uFinalB = floorf(uTintB / 255.0 * color_mult * uDecalColorMultB + 0.0f);
-
-
-    float v15;
-    if (fabs(z_bias) < 1e-5)
-      v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0);
-     else
-     {
-      v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0) - z_bias;
-      if (v15 < 0.000099999997)
-        v15 = 0.000099999997;
-     }
-
-    pVerticesD3D[i].pos.z = v15;
-
-    pVerticesD3D[i].pos.x = pDecal->pVertices[i].vWorldViewProjX;
-    pVerticesD3D[i].pos.y = pDecal->pVertices[i].vWorldViewProjY;
-    pVerticesD3D[i].texcoord.x = pDecal->pVertices[i].u;
-    pVerticesD3D[i].texcoord.y = pDecal->pVertices[i].v;
-    pVerticesD3D[i].diffuse = (uFinalR << 16) | (uFinalG << 8) | uFinalB;
-    pVerticesD3D[i].specular = 0;
-    pVerticesD3D[i].rhw = 1.0 / pDecal->pVertices[i].vWorldViewPosition.x;
-  }
-
-  if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
-    v21 = D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS;
-  else
-    v21 = D3DDP_DONOTLIGHT;
-
-  ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
-            D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
-            pVerticesD3D,
-            pDecal->uNumVertices,
-            v21));
-}
 
 //----- (0049C2CD) --------------------------------------------------------
 void DecalBuilder::DrawDecals(float z_bias)
 {
   for (uint i = 0; i < std__vector_pDecals_size; ++i)
-    DrawDecal(std__vector_pDecals + i, z_bias);
+    pRenderer->DrawDecal(std__vector_pDecals + i, z_bias);
 }
 
 //----- (0049C304) --------------------------------------------------------
@@ -729,29 +662,11 @@
   if (!std__vector_pDecals_size)
     return;
 
-  if (pRenderer->bUsingSpecular)
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP));
-
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
+  pRenderer->BeginDecals();
 
-  IDirect3DTexture2* pTex = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("hwsplat04");
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTex));
- 
   DrawDecals(0.00039999999);
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
 
-  if (pRenderer->bUsingSpecular)
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
+  pRenderer->EndDecals();
 }
 
 //----- (0049C550) --------------------------------------------------------
--- a/DecalBuilder.h	Fri Jan 10 17:42:37 2014 +0600
+++ b/DecalBuilder.h	Fri Jan 10 17:42:57 2014 +0600
@@ -172,7 +172,6 @@
   bool ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID);
   char ApplyDecals_OutdoorFace(ODMFace *pFace);
   bool _49BE8A(struct Polygon *a2, Vec3_float_ *a3, float *a4, struct RenderVertexSoft *a5, unsigned int uStripType, char a7);
-  void DrawDecal(Decal *pDecal, float z_bias);
   void DrawDecals(float z_bias);
   void DrawBloodsplats();
   void DrawDecalDebugOutlines();
--- a/Game.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/Game.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -93,12 +93,12 @@
 
   if ( pVideoPlayer->AnyMovieLoaded() )
   {
-    if ( !pRenderer->pRenderD3D )
+    /*if ( !pRenderer->pRenderD3D )
     {
 		pRenderer->BeginSceneD3D();
 		pMouse->DrawCursorToTarget();
 		pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
-	}
+	}*/
   }
   else
   {
@@ -115,11 +115,11 @@
     pParty->sPrevEyelevel = pParty->sEyelevel;
     pRenderer->BeginSceneD3D();
 
-    if ( !pRenderer->pRenderD3D )
-      pMouse->DrawCursorToTarget();
+    //if ( !pRenderer->pRenderD3D )
+      //pMouse->DrawCursorToTarget();
     if ( !PauseGameDrawing() || viewparams->field_48 == 1 )
     {
-      if ( pRenderer->pRenderD3D )
+      //if ( pRenderer->pRenderD3D )
       {
         float v2 = (double)(((signed int)pMiscTimer->uTotalGameTimeElapsed >> 2) & 0x1F) * 0.032258064 * 6.0;
         //v3 = v2 + 6.7553994e15;
@@ -133,7 +133,7 @@
         pOutdoor->Draw();
       else Error("Invalid level type: %u", uCurrentlyLoadedLevelType);
 
-      if (pRenderer->pRenderD3D)
+      //if (pRenderer->pRenderD3D)
       {
         pDecalBuilder->DrawBloodsplats();
         pGame->pLightmapBuilder->DrawLightmapsType(2);
@@ -147,7 +147,7 @@
 
 
   pRenderer->BeginScene();
-  if (pRenderer->pRenderD3D)
+  //if (pRenderer->pRenderD3D)
     pMouse->DrawCursorToTarget();
   if (pOtherOverlayList->bRedraw)
     viewparams->bRedrawGameUI = true;
@@ -168,10 +168,10 @@
     GameUI_DrawMinimap(488, 16, 625, 133, viewparams->uMinimapZoom, true);//redraw = pParty->uFlags & 2);
     if (v4)
     {
-      if ( !PauseGameDrawing() && pRenderer->pRenderD3D) // clear game viewport with transparent color
+      if ( !PauseGameDrawing() /*&& pRenderer->pRenderD3D*/) // clear game viewport with transparent color
         pRenderer->FillRectFast(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pViewport->uViewportBR_X - pViewport->uViewportTL_X,
                                 pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1,
-                                pRenderer->uTargetGMask | pRenderer->uTargetBMask);
+                                0x7FF);
       viewparams->field_48 = 0;
     }
   }
@@ -318,7 +318,7 @@
     // uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0;
     pCurrentScreen = SCREEN_GAME;
 
-    if ( pRenderer->pRenderD3D )
+    //if ( pRenderer->pRenderD3D )
       pGame->pVisInstance->_4C1A02();
 
     bool game_finished = false;
@@ -554,10 +554,10 @@
            pLight->vRGBColor.x,
            pLight->vRGBColor.y,
            pLight->vRGBColor.z,
-           byte_4E94D0);
+           _4E94D0_light_type);
       }
 }
-// 4E94D0: using guessed type char byte_4E94D0;
+// 4E94D0: using guessed type char _4E94D0_light_type;
 
 //----- (0044F0FD) --------------------------------------------------------
 void Game::_44F0FD()
@@ -648,18 +648,18 @@
 
     if ( uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS)
       pStru10Instance->bDoNotDrawPortalFrustum = false;
-    if ( pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+    if ( /*pRenderer->pRenderD3D &&*/ uCurrentlyLoadedLevelType == LEVEL_Outdoor)
     {
       v5 = GetLevelFogColor();
       pRenderer->uFogColor = v5 & 0xFFFFFF;
     }
     if (uFlags & 0x0400)
       uFlags2 |= 0x01;
-    if ( !pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor && pMobileLightsStack->uNumLightsActive )
+    /*if ( !pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor && pMobileLightsStack->uNumLightsActive )
     {
       uFlags2 |= 0x01;
       field_E10 = qword_5C6DF0;
-    }
+    }*/
     v6 = qword_5C6DF0 - field_E10;
     if ( qword_5C6DF0 - field_E10 == 1 )
       uFlags2 |= v6;
@@ -703,8 +703,8 @@
 //----- (004645FA) --------------------------------------------------------
 void Game::Deinitialize()
 {
-  WriteWindowsRegistryInt("startinwindow", pRenderer->bWindowMode);
-  if (pRenderer->bWindowMode)
+  WriteWindowsRegistryInt("startinwindow", 1);//pRenderer->bWindowMode);
+  //if (pRenderer->bWindowMode)
   {
     WriteWindowsRegistryInt("window X", window->GetX());
     WriteWindowsRegistryInt("window Y", window->GetY());
@@ -1011,10 +1011,10 @@
   {
     v7 = 1.0;
   }
-  if ( pRenderer->pRenderD3D )
+  //if ( pRenderer->pRenderD3D )
     fSaturation = v7;
-  else
-    fSaturation = (1.0 - 0.5) * v7 + 0.5;
+  //else
+  //  fSaturation = (1.0 - 0.5) * v7 + 0.5;
 }
 
 //----- (0044EA17) --------------------------------------------------------
@@ -1032,8 +1032,8 @@
 //----- (0044EA5E) --------------------------------------------------------
 bool Game::PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter)
 {
-  if (pCurrentScreen != SCREEN_GAME|| !pRenderer->pRenderD3D)
-    return false;
+  /*if (pCurrentScreen != SCREEN_GAME|| !pRenderer->pRenderD3D)
+    return false;*/
 
   if (!pVisInstance)
   {
@@ -1059,7 +1059,7 @@
 //----- (0044EB12) --------------------------------------------------------
 bool Game::PickKeyboard(bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter)
 {
-  if (pCurrentScreen == SCREEN_GAME && pVisInstance && pRenderer->pRenderD3D)
+  if (pCurrentScreen == SCREEN_GAME && pVisInstance /*&& pRenderer->pRenderD3D*/)
   {
     bool r = pVisInstance->PickKeyboard(&pVisInstance->default_list, sprite_filter, face_filter);
 
@@ -1350,7 +1350,7 @@
   char a1[64]; // [sp+1F8h] [bp-404h]@467
   char Str2[128]; // [sp+238h] [bp-3C4h]@527
   Actor actor; // [sp+2B8h] [bp-344h]@4
-  unsigned short* screenshot;
+  //unsigned short* screenshot;
 
   dword_50CDC8 = 0;
   if ( !pEventTimer->bPaused )
@@ -1785,16 +1785,16 @@
             pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x12Eu, 0xD6u, 0x12u, 1, 0, UIMSG_ToggleColoredLights, 0, 0, "", 0);
             pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x144u, 0xD6u, 0x12u, 1, 0, UIMSG_ToggleTint, 0, 0, "", 0);
           }
-          if ( !pRenderer->bWindowMode )
+          /*if ( !pRenderer->bWindowMode )
           {
             //v0 = 1;
-            if ( GammaController::IsGammaSupported() )
+            if ( pRenderer->IsGammaSupported() )
             {
               pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(0x15u, 0xA1u, 0x10u, 0x10u, 1, 0, UIMSG_1A9, 4u, 0, "", pIcons_LOD->GetTexture(uTextureID_507C20), 0);
               pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0xD5u, 0xA1u, 0x10u, 0x10u, 1, 0, UIMSG_1A9, 5u, 0, "", pIcons_LOD->GetTexture(uTextureID_507C24), 0);
               pGUIWindow_CurrentMenu->CreateButton(42, 162, 170, 18, 1, 0, UIMSG_1A9, 0, 0, "", 0);
             }
-          }
+          }*/
           continue;
         case UIMSG_1A9:
 			__debugbreak();
@@ -2059,10 +2059,9 @@
               uMessageParam = 1;
               break;
             case SCREEN_HOUSE:
-              if ( !dword_50CDC8 && !dword_5C35C8 )
+              if ( !dword_50CDC8 )
               {
                 CloseWindowBackground();
-                dword_5C35C8 = 0;
                 uMessageParam = 1;
                 break;
               }
@@ -2264,14 +2263,9 @@
                         WriteWindowsRegistryInt("Tinting", pRenderer->bTinting);
                         WriteWindowsRegistryInt("Bloodsplats", (LOBYTE(pGame->uFlags2) >> 5) & 1);
                       }
-                      if ( pRenderer->bWindowMode )
-                        {
-                          stru_506E40.Release();
-                          break;
-                        }
-                      //v30 = uGammaPos;
-                      //v31 = "GammaPos";
-                      WriteWindowsRegistryInt("GammaPos", uGammaPos);
+                      /*if ( !pRenderer->bWindowMode )
+                        WriteWindowsRegistryInt("GammaPos", uGammaPos);*/
+
                       stru_506E40.Release();
                       break;
 
@@ -2349,7 +2343,6 @@
                       }
                       _506F18_num_minutes_to_sleep = 0;
                       dword_506F14 = 0;
-                      dword_507B94 = 1;
                       if ( pGUIWindow_Settings )
                       {
                         if ( pCurrentScreen == SCREEN_CHARACTERS )
@@ -2640,11 +2633,11 @@
                              pIcons_LOD->GetTexture(uTextureID_Resume1), 0);
               pGUIWindow_CurrentMenu->_41D08F_set_keyboard_control_group(6, 1, 0, 0);
               viewparams->field_48 = 1;
+
               stru_506E40.Release();
-              screenshot = MakeScreenshot(155, 117);
-              pRenderer->SavePCXImage("gamma.pcx", screenshot, 155, 117);
-              free(screenshot);
+              pRenderer->SaveScreenshot("gamma.pcx", 155, 117);
               stru_506E40.LoadPCXFile("gamma.pcx", 0);
+
               continue;
             }
             pGUIWindow_Settings->Release();
@@ -3133,7 +3126,7 @@
           else
           {
             sprintf(a1, "data\\lloyd%d%d.pcx", _506348_current_lloyd_playerid + 1, uMessageParam + 1);
-            SaveScreenshot(a1);
+            pRenderer->SaveScreenshot(a1, 92, 68);
             LoadThumbnailLloydTexture(uMessageParam, _506348_current_lloyd_playerid + 1);
             pPlayer9->pInstalledBeacons[uMessageParam].uBeaconTime = pParty->uTimePlayed + (signed __int64)((double)(qword_506350 << 7) * 0.033333335);
             pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_X = pParty->vPosition.x;
@@ -3438,16 +3431,16 @@
           continue;
         case UIMSG_CastSpell_Monster_Improvement:
         case UIMSG_CastSpell_Shoot_Monster://FireBlow, Lightning, Ice Lightning, Swarm, 
-          if ( pRenderer->pRenderD3D )
+          //if ( pRenderer->pRenderD3D )
           {
             v81 = pGame->pVisInstance->get_picked_object_zbuf_val();
           }
-          else
+          /*else
           {
             uNumSeconds = (unsigned int)pMouse->GetCursorPos(&v206);
             pPoint2 = pMouse->GetCursorPos(&v201);
             v81 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[pPoint2->y]];
-          }
+          }*/
           v83 = v81;
           v44 = (unsigned __int16)v81;
           v84 = v83 >> 16;
@@ -3912,11 +3905,11 @@
             pCurrentScreen = SCREEN_GAME;
             viewparams->bRedrawGameUI = 1;
           }
+
           stru_506E40.Release();
-          screenshot = MakeScreenshot(155, 117);
-          pRenderer->SavePCXImage("gamma.pcx", screenshot, 155, 117);
-          free(screenshot);
+          pRenderer->SaveScreenshot("gamma.pcx", 155, 117);
           stru_506E40.LoadPCXFile("gamma.pcx", 0);
+
           GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, WINDOW_PressedButton, (int)pBtn_GameSettings, 0);
 //LABEL_453:
           /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
@@ -4138,13 +4131,13 @@
           pPlayers[uActiveCharacter]->OnInventoryLeftClick();
           continue;
         case UIMSG_MouseLeftClickInGame:
-          if ( !pRenderer->pRenderD3D )
+          /*if ( !pRenderer->pRenderD3D )
           {
             if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
             OnGameViewportClick();
             continue;
-          }
+          }*/
           v115 = pMessageQueue_50CBD0->uNumMessages;
           if ( !pMessageQueue_50CBD0->uNumMessages )
           {
@@ -4193,16 +4186,16 @@
           continue;
         case UIMSG_F:
 			__debugbreak();
-          if ( pRenderer->pRenderD3D )
+          //if ( pRenderer->pRenderD3D )
           {
             LOWORD(v116) = pGame->pVisInstance->get_picked_object_zbuf_val();
           }
-          else
+          /*else
           {
             uNumSeconds = (unsigned int)pMouse->GetCursorPos(&v209);
             pPoint3 = pMouse->GetCursorPos(&v204);
             v116 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[pPoint3->y]];
-          }
+          }*/
           pButton2 = (GUIButton *)(unsigned __int16)v116;
           GUIWindow::Create(0, 0, 0, 0, WINDOW_F, (int)pButton2, 0);
           continue;
--- a/Game.h	Fri Jan 10 17:42:37 2014 +0600
+++ b/Game.h	Fri Jan 10 17:42:57 2014 +0600
@@ -2,7 +2,7 @@
 #include "VectorTypes.h"
 
 
-#define GAME_FLAGS_1_01                 0x01
+#define GAME_FLAGS_1_01_lightmap_related                 0x01
 #define GAME_FLAGS_1_DRAW_BLV_DEBUGS    0x08
 #define GAME_FLAGS_2_SATURATE_LIGHTMAPS 0x02
 #define GAME_FLAGS_2_ALTER_GRAVITY      0x08
--- a/GammaControl.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/GammaControl.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -126,24 +126,6 @@
 }
 
 
-//----- (0044F2B2) --------------------------------------------------------
-bool GammaController::IsGammaSupported()
-{
-  bool result; // eax@3
-  HRESULT v1; // eax@4
-
-  //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
-  {
-    DDCAPS halCaps; // [sp+0h] [bp-180h]@4
-    memset(&halCaps, 0, sizeof(DDCAPS));
-    halCaps.dwSize = sizeof(DDCAPS);
-
-    ErrD3D(pRenderer->pDirectDraw4->GetCaps(&halCaps, 0));
-    return (halCaps.dwCaps2 >> 17) & 1;
-  }
-  /*else
-    return false;*/
-}
 
 
 
@@ -174,7 +156,7 @@
     v4->Release();
     *v3 = 0;
   }
-  if ( IsGammaSupported() )
+  if ( pRenderer->IsGammaSupported() )
   {
     ErrD3D(a2->QueryInterface(IID_IDirectDrawGammaControl, (LPVOID *)v3));
     GetRamp();
--- a/GammaControl.h	Fri Jan 10 17:42:37 2014 +0600
+++ b/GammaControl.h	Fri Jan 10 17:42:57 2014 +0600
@@ -18,9 +18,6 @@
 
   /*protected*/void InitializeFromSurface(struct IDirectDrawSurface4 *a2);
 
-  static bool IsGammaSupported();
-
-
 
 
   void ( ***vdestructor_ptr)(GammaController *, bool);
--- a/Indoor.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/Indoor.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -119,7 +119,7 @@
     v5 = 800;
     if (pParty->TorchlightActive())
       v5 *= pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower;
-    //LOBYTE(v1) = byte_4E94D0;
+    //LOBYTE(v1) = _4E94D0_light_type;
     //v4 = pParty->flt_TorchlightColorR + 6.7553994e15;
     //v3 = pParty->flt_TorchlightColorG + 6.7553994e15;
     pMobileLightsStack->AddLight(pGame->pIndoorCameraD3D->vPartyPos.x,
@@ -130,7 +130,7 @@
                                  floorf(pParty->flt_TorchlightColorR + 0.5f),
                                  floorf(pParty->flt_TorchlightColorG + 0.5f),
                                  floorf(pParty->flt_TorchlightColorB + 0.5f),
-                                 byte_4E94D0);
+                                 _4E94D0_light_type);
   }
   PrepareBspRenderList_BLV();
   PrepareItemsRenderList_BLV();
@@ -223,7 +223,7 @@
     this->vPartyPos.y = pParty->vPosition.y;*/
     this->uPartySectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
   }
-  if ( pRenderer->pRenderD3D )
+  //if ( pRenderer->pRenderD3D )
   {
     //this->sCosineY = stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY);
     //this->sSineY = stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY);
@@ -245,10 +245,10 @@
     this->uViewportCenterX = (uViewportZ + uViewportX) / 2;
     this->uViewportCenterY = (uViewportY + uViewportW) / 2;
   }
-  else
+  /*else
   {
     __debugbreak(); // no sw
-    /*this->sCosineY = stru_5C6E00->Cos(-this->sPartyRotY);
+    this->sCosineY = stru_5C6E00->Cos(-this->sPartyRotY);
     this->sSineY = stru_5C6E00->Sin(-this->sPartyRotY);
     this->sCosineNegX = stru_5C6E00->Cos(-this->sPartyRotX);
     this->sSineNegX = stru_5C6E00->Sin(-this->sPartyRotX);
@@ -271,8 +271,8 @@
     v29 = v25;
     v26 = this->field_64;
     this->uViewportCenterX = (signed int)(v24 + v23) >> 1;
-    this->uViewportCenterY = this->uViewportW - ((unsigned __int64)(v26 * (signed __int64)v29) >> 16);*/
-  }
+    this->uViewportCenterY = this->uViewportW - ((unsigned __int64)(v26 * (signed __int64)v29) >> 16);
+  }*/
   //v27 = (unsigned int)(signed __int64)((double)this->uViewportWidth * 0.5
   //                                             / tan((double)(v2->fov_deg >> 1) * 0.01745329)
   //                                             + 0.5) << 16;
@@ -414,7 +414,7 @@
   {
     PrepareDrawLists_BLV();
     if (pBLVRenderParams->uPartySectorID)
-      IndoorLocation::ExecDraw(pRenderer->pRenderD3D != 0);
+      IndoorLocation::ExecDraw(true/*pRenderer->pRenderD3D != 0*/);
     pRenderer->DrawBillboardList_BLV();
   }
 
@@ -792,147 +792,6 @@
 }
 
 
-//----- (004AFB86) --------------------------------------------------------
-void BspRenderer::AddFaceToRenderList_sw(unsigned int node_id, unsigned int uFaceID)
-{
-  BspRenderer *v3; // ebx@1
-  BLVFace *v4; // eax@1
-  char *v5; // ecx@2
-  unsigned __int16 v6; // ax@11
-  int v7; // ecx@13
-  Vec3_short_ *v8; // esi@16
-  int v9; // edx@16
-  signed int v10; // eax@19
-  signed int v11; // edi@20
-  signed int v12; // ecx@20
-  signed int v13; // esi@20
-  int v14; // edx@21
-  int v15; // edx@25
-  unsigned __int16 v16; // ax@35
-  signed int v17; // eax@37
-  int v18; // eax@38
-  signed int v19; // [sp+Ch] [bp-14h]@19
-  char *v20; // [sp+14h] [bp-Ch]@2
-  BLVFace *v21; // [sp+18h] [bp-8h]@1
-  signed int v22; // [sp+1Ch] [bp-4h]@20
-  signed int v23; // [sp+28h] [bp+8h]@20
-
-  v3 = this;
-  v4 = &pIndoor->pFaces[uFaceID];
-  v21 = v4;
-  if (v4->Portal())
-  {
-    v5 = (char *)this + 2252 * node_id;
-    v20 = v5;
-    if ( uFaceID == *((short *)v5 + 2982) )
-      return;
-    if (!node_id
-      && pGame->pIndoorCameraD3D->vPartyPos.x >= v4->pBounding.x1 - 16
-      && pGame->pIndoorCameraD3D->vPartyPos.x <= v4->pBounding.x2 + 16
-      && pGame->pIndoorCameraD3D->vPartyPos.y >= v4->pBounding.y1 - 16
-      && pGame->pIndoorCameraD3D->vPartyPos.y <= v4->pBounding.y2 + 16
-      && pGame->pIndoorCameraD3D->vPartyPos.z >= v4->pBounding.z1 - 16
-      && pGame->pIndoorCameraD3D->vPartyPos.z <= v4->pBounding.z2 + 16 )
-    {
-      if ( abs(v4->pFacePlane_old.dist + pGame->pIndoorCameraD3D->vPartyPos.x * v4->pFacePlane_old.vNormal.x
-                                       + pGame->pIndoorCameraD3D->vPartyPos.y * v4->pFacePlane_old.vNormal.y
-                                       + pGame->pIndoorCameraD3D->vPartyPos.z * v4->pFacePlane_old.vNormal.z) <= 589824 )
-      {
-        v6 = v21->uSectorID;
-        if ( v3->nodes[0].uSectorID == v6 )
-          v6 = v21->uBackSectorID;
-        v3->nodes[v3->num_nodes].uSectorID = v6;
-        v3->nodes[v3->num_nodes].uFaceID = uFaceID;
-        v3->nodes[v3->num_nodes].uViewportX = LOWORD(pBLVRenderParams->uViewportX);
-        v3->nodes[v3->num_nodes].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ);
-        v3->nodes[v3->num_nodes].uViewportY = LOWORD(pBLVRenderParams->uViewportY);
-        v3->nodes[v3->num_nodes].uViewportW = LOWORD(pBLVRenderParams->uViewportW);
-        v3->nodes[v3->num_nodes++].PortalScreenData.GetViewportData(
-          SLOWORD(pBLVRenderParams->uViewportX),
-          pBLVRenderParams->uViewportY,
-          SLOWORD(pBLVRenderParams->uViewportZ),
-          pBLVRenderParams->uViewportW);
-        v7 = v3->num_nodes - 1;
-        goto LABEL_14;
-      }
-      v4 = v21;
-      v5 = v20;
-    }
-    v8 = &pIndoor->pVertices[*v4->pVertexIDs];
-    v9 = v4->pFacePlane_old.vNormal.x * (v8->x - pGame->pIndoorCameraD3D->vPartyPos.x)
-       + v4->pFacePlane_old.vNormal.y * (v8->y - pGame->pIndoorCameraD3D->vPartyPos.y)
-       + v4->pFacePlane_old.vNormal.z * (v8->z - pGame->pIndoorCameraD3D->vPartyPos.z);
-    if ( *((short *)v5 + 2004) != v4->uSectorID )
-      v9 = -v9;
-    if ( v9 < 0 )
-    {
-      v10 = GetPortalScreenCoord(uFaceID);
-      v19 = v10;
-      if ( v10 )
-      {
-        v11 = PortalFace._screen_space_x[0];
-        v12 = PortalFace._screen_space_y[0];
-        v23 = PortalFace._screen_space_x[0];
-        v13 = 1;
-        v22 = PortalFace._screen_space_y[0];
-        if ( v10 > 1 )
-        {
-          do
-          {
-            v14 = PortalFace._screen_space_x[v13];
-            if ( v14 < v23 )
-              v23 = PortalFace._screen_space_x[v13];
-            if ( v14 > v11 )
-              v11 = PortalFace._screen_space_x[v13];
-            v15 = PortalFace._screen_space_y[v13];
-            if ( v15 < v22 )
-              v22 = PortalFace._screen_space_y[v13];
-            if ( v15 > v12 )
-              v12 = PortalFace._screen_space_y[v13];
-            v10 = v19;
-            ++v13;
-          }
-          while ( v13 < v19 );
-        }
-        if ( v11 >= *((short *)v20 + 2005)
-          && v23 <= *((short *)v20 + 2007)
-          && v12 >= *((short *)v20 + 2006)
-          && v22 <= *((short *)v20 + 2008)
-          && PortalFrustrum(v10, &v3->nodes[v3->num_nodes].PortalScreenData, (BspRenderer_PortalViewportData *)(v20 + 4020), uFaceID) )
-        {
-          v16 = v21->uSectorID;
-          if ( *((short *)v20 + 2004) == v16 )
-            v16 = v21->uBackSectorID;
-          v3->nodes[v3->num_nodes].uSectorID = v16;
-          v3->nodes[v3->num_nodes].uFaceID = uFaceID;
-          v3->nodes[v3->num_nodes].uViewportX = LOWORD(pBLVRenderParams->uViewportX);
-          v3->nodes[v3->num_nodes].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ);
-          v3->nodes[v3->num_nodes].uViewportY = LOWORD(pBLVRenderParams->uViewportY);
-          v3->nodes[v3->num_nodes].uViewportW = LOWORD(pBLVRenderParams->uViewportW);
-          v17 = v3->num_nodes;
-          if ( v17 < 150 )
-          {
-            v18 = v17 + 1;
-            v3->num_nodes = v18;
-            v7 = v18 - 1;
-LABEL_14:
-            AddBspNodeToRenderList(v7);
-            return;
-          }
-        }
-      }
-    }
-  }
-  else
-  {
-    if (num_faces < 1000)
-    {
-      faces[num_faces].uFaceID = uFaceID;
-      faces[num_faces++].uNodeID = node_id;
-    }
-  }
-}
-
 //----- (004AE5BA) --------------------------------------------------------
 Texture *BLVFace::GetTexture()
 {
@@ -2783,10 +2642,10 @@
         HIDWORD(v27) = face->pFacePlane_old.dist >> 16;
         face->zCalc3 = -v27 / face->pFacePlane_old.vNormal.z;
       }
-      if ( face->uAttributes & FACE_TEXTURE_FLOW || pRenderer->pRenderD3D )
+      //if ( face->uAttributes & FACE_TEXTURE_FLOW || pRenderer->pRenderD3D )
         face->_get_normals(&v70, &v67);
       v28 = &pIndoor->pFaceExtras[face->uFaceExtraID];
-      if ( !pRenderer->pRenderD3D )
+      /*if ( !pRenderer->pRenderD3D )
       {
         if ( !(face->uAttributes & FACE_TEXTURE_FLOW) )
           continue;
@@ -2801,7 +2660,7 @@
         v31 = (v85 + v83 + v84) * (signed __int64)v29;
         v32 = v31 >> 16;
         goto LABEL_58;
-      }
+      }*/
       v28->sTextureDeltaU = 0;
       v28->sTextureDeltaV = 0;
       v34 = &pIndoor->pVertices[face->pVertexIDs[0]];
@@ -3557,7 +3416,7 @@
               r,
               g,
               b,
-              byte_4E94D0);
+              _4E94D0_light_type);
           }
         }
       }
@@ -4258,7 +4117,7 @@
       v41 |= 4u;
     if ( v10->uGlowRadius )
     {
-      //LOBYTE(v11) = byte_4E94D3;
+      //LOBYTE(v11) = _4E94D3_light_type;
       pMobileLightsStack->AddLight(
         a1a,
         a2,
@@ -4268,7 +4127,7 @@
         0xFFu,
         0xFFu,
         0xFFu,
-        byte_4E94D3);
+        _4E94D3_light_type);
     }
     v12 = 0;
     if ( pBspRenderer->uNumVisibleNotEmptySectors <= 0 )
@@ -4289,11 +4148,11 @@
     ++uNumBillboardsToDraw;
     ++uNumSpritesDrawnThisFrame;
     p->uAttributes |= 8u;
-    v29 = pRenderer->pRenderD3D == 0;
+    //v29 = pRenderer->pRenderD3D == 0;
     v0->uHwSpriteID = v10->pHwSpriteIDs[v32];
     v0->uPalette = v10->uPaletteIndex;
     v0->uIndoorSectorID = a5;
-    if ( v29 )
+    /*if ( v29 )
     {
       LODWORD(v20) = pBLVRenderParams->fov_rad_fixpoint << 16;
       HIDWORD(v20) = pBLVRenderParams->fov_rad_fixpoint >> 16;
@@ -4301,7 +4160,7 @@
       v0->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v10->scale * v20 / x) >> 16;
       a5a = (unsigned __int64)(v10->scale * (signed __int64)v21) >> 16;
     }
-    else
+    else*/
     {
       //v14 = &pGame->pIndoorCameraD3D;
       v0->fov_x = pGame->pIndoorCameraD3D->fov_x;
@@ -4450,7 +4309,7 @@
               v34 |= 4u;
             if ( a6 )
             {
-              LOBYTE(v11) = byte_4E94D3;
+              LOBYTE(v11) = _4E94D3_light_type;
               pMobileLightsStack->AddLight(
                 a1,
                 a2,
@@ -4460,7 +4319,7 @@
                 v1->uParticleTrailColorR,
                 v1->uParticleTrailColorG,
                 v1->uParticleTrailColorB,
-                byte_4E94D3);
+                _4E94D3_light_type);
             }
             if ( pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible_BLV(
                    a1,
@@ -4482,7 +4341,7 @@
               //v12 = pRenderer->pRenderD3D == 0;
               v3->uPalette = v24->uPaletteIndex;
               v3->uIndoorSectorID = p->uSectorID;
-              if ( pRenderer->pRenderD3D )
+              //if ( pRenderer->pRenderD3D )
               {
                 v3->fov_x = pGame->pIndoorCameraD3D->fov_x;
                 v3->fov_y = pGame->pIndoorCameraD3D->fov_y;
@@ -4492,15 +4351,15 @@
                 v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v24->scale * v18) >> 16;
                 v31 = (unsigned __int64)(v24->scale * v18) >> 16;
               }
-              else
+              /*else
               {
                 __debugbreak(); // sw rendering
-                /*LODWORD(v19) = pBLVRenderParams->field_40 << 16;
+                LODWORD(v19) = pBLVRenderParams->field_40 << 16;
                 HIDWORD(v19) = pBLVRenderParams->field_40 >> 16;
                 v20 = v19 / x;
                 v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v24->scale * v19 / x) >> 16;
-                v31 = (unsigned __int64)(v24->scale * (signed __int64)v20) >> 16;*/
-              }
+                v31 = (unsigned __int64)(v24->scale * (signed __int64)v20) >> 16;
+              }*/
               //HIWORD(v21) = HIWORD(x);
               //LOWORD(v21) = 0;
               v3->_screenspace_y_scaler_packedfloat = v31;
@@ -4519,11 +4378,11 @@
               //v3->sZValue = v21 + v23;
               v3->actual_z = HIWORD(x);
               v3->object_pid = PID(OBJECT_Item,i);
-              if (p->uAttributes & 0x20)
+              /*if (p->uAttributes & 0x20)
               {
                 if ( !pRenderer->pRenderD3D )
                   v3->sZValue = 0;
-              }
+              }*/
             }
           }
         }
@@ -4537,17 +4396,17 @@
   BLVSector *pSector; // esi@1
 
   pSector = &pIndoor->pSectors[pBspRenderer->nodes[node_id].uSectorID];
-  if ( pRenderer->pRenderD3D )
+  //if ( pRenderer->pRenderD3D )
   {
     for (uint i = 0; i < pSector->uNumNonBSPFaces; ++i)
       //Log::Warning(L"Non-BSP face: %X", v3->pFaceIDs[v2]);
       pBspRenderer->AddFaceToRenderList_d3d(node_id, pSector->pFaceIDs[i]);
   }
-  else
+  /*else
   {
     for (uint i = 0; i < pSector->uNumNonBSPFaces; ++i)
       pBspRenderer->AddFaceToRenderList_sw(node_id, pSector->pFaceIDs[i]);
-  }
+  }*/
   if ( pSector->field_0 & 0x10 )
     sub_4406BC(node_id, pSector->uFirstBSPNode);
 }
@@ -4594,16 +4453,16 @@
 
     //Log::Warning(L"Node %u: %X to %X (%hX)", uFirstNode, v7, v8, v2->pFaceIDs[v7]);
     
-    if ( pRenderer->pRenderD3D )
+    //if ( pRenderer->pRenderD3D )
     {
       while ( v7 < v8 )
         pBspRenderer->AddFaceToRenderList_d3d(node_id, pSector->pFaceIDs[v7++]);
     }
-    else
+    /*else
     {
       while ( v7 < v8 )
         pBspRenderer->AddFaceToRenderList_sw(node_id, pSector->pFaceIDs[v7++]);
-    }
+    }*/
     v9 = v5 > 0 ? pNode->uFront : pNode->uBack;
     if ( v9 == -1 )
       break;
@@ -4718,11 +4577,11 @@
 
               ++uNumBillboardsToDraw;
               ++uNumDecorationsDrawnThisFrame;
-              v16 = pRenderer->pRenderD3D == 0;
+              //v16 = pRenderer->pRenderD3D == 0;
               v15->uHwSpriteID = v12->pHwSpriteIDs[v9];
               v15->uPalette = v12->uPaletteIndex;
               v15->uIndoorSectorID = uSectorID;
-              if ( v16 )
+              /*if ( v16 )
               {
                 LODWORD(v21) = pBLVRenderParams->fov_rad_fixpoint << 16;
                 HIDWORD(v21) = pBLVRenderParams->fov_rad_fixpoint >> 16;
@@ -4732,7 +4591,7 @@
                 v15->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v12->scale * v21 / x) >> 16;
                 v37 = (unsigned __int64)(v12->scale * (signed __int64)v37) >> 16;
               }
-              else
+              else*/
               {
                 v17 = &pGame->pIndoorCameraD3D;
                 v15->fov_x = pGame->pIndoorCameraD3D->fov_x;
@@ -6523,7 +6382,7 @@
   PortalFace._screen_space_x[bottom_num_vertices] = PortalFace._screen_space_x[0];
   PortalFace._screen_space_y[bottom_num_vertices] = PortalFace._screen_space_y[0];
 //check for software(  )
-  if ( !pRenderer->pRenderD3D && bottom_num_vertices > 3 )
+  /*if ( !pRenderer->pRenderD3D && bottom_num_vertices > 3 )
   {
     PortalFace._screen_space_x[bottom_num_vertices + 1] = PortalFace._screen_space_x[1];
     PortalFace._screen_space_y[bottom_num_vertices + 1] = PortalFace._screen_space_y[1];
@@ -6569,7 +6428,7 @@
     }
     PortalFace._screen_space_x[bottom_num_vertices] = PortalFace._screen_space_x[0];
     PortalFace._screen_space_y[bottom_num_vertices] = PortalFace._screen_space_y[0];
-  }
+  }*/
   return bottom_num_vertices;
 }
 
--- a/IndoorCameraD3D.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/IndoorCameraD3D.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -233,7 +233,7 @@
     for (uint i = 0; i < uNumVertices; ++i)
     {
           float st0, st1, st2;
-          if ( pRenderer->pRenderD3D )
+          //if ( pRenderer->pRenderD3D )
           {
             /*__asm
             {
@@ -277,7 +277,7 @@
             st1 = cos_y * (a1a[i].vWorldPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) + sin_y * (a1a[i].vWorldPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y);
             st2 = (a1a[i].vWorldPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z);
           }
-          else
+          if (false)//else
           {
             /*__asm
             {
@@ -355,7 +355,7 @@
     {
       for (uint i = 0; i < uNumVertices; ++i)
       {
-          if ( pRenderer->pRenderD3D )
+          //if ( pRenderer->pRenderD3D )
           {
             /*__asm
             {
@@ -411,7 +411,7 @@
             a1a[i].vWorldViewPosition.y = sin_y * (a1a[i].vWorldPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) - cos_y * (a1a[i].vWorldPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y);
             a1a[i].vWorldViewPosition.z = (a1a[i].vWorldPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z);
           }
-          else
+          if (false)//else
           {
             __debugbreak();
             /*__asm
@@ -559,44 +559,6 @@
   return true;
 }
 
-//----- (00437C96) --------------------------------------------------------
-void IndoorCameraD3D::do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff)
-{
-  double v6; // st7@2
-  IDirect3DDevice3 *v7; // eax@2
-  HRESULT v8; // eax@2
-  std::string v9; // [sp-18h] [bp-60h]@3
-  const char *v10; // [sp-Ch] [bp-54h]@2
-  const char *v11; // [sp-8h] [bp-50h]@2
-  int v12; // [sp-4h] [bp-4Ch]@2
-  RenderVertexD3D3 v13[2]; // [sp+8h] [bp-40h]@2
-
-  if ( pRenderer->pRenderD3D )
-  {
-    v6 = 0.001 - z_stuff;
-    memcpy(v13, pLineBegin, 0x20u);
-    memcpy(&v13[1], pLineEnd, sizeof(v13[1]));
-    v13[0].pos.z = v6;
-    v13[1].pos.z = v6;
-    v12 = 0;
-    v13[0].diffuse = sDiffuseBegin;
-    v13[1].diffuse = sDiffuseEnd;
-    v7 = pRenderer->pRenderD3D->pDevice;
-    v11 = 0;
-    //v10 = (const char *)v7;
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, nullptr));
-    ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(
-           D3DPT_LINELIST,
-           452,
-           v13,
-           2,
-           16));
-  }
-  else
-  {
-    MessageBoxW(nullptr, L"draw_debug_line() not implemented for SW rendering", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Core3D.cpp:1415", 0);
-  }
-}
 
 //----- (00437AB5) --------------------------------------------------------
 void IndoorCameraD3D::do_draw_debug_line_sw(RenderVertexSoft *pLineBegin, signed int sStartDiffuse, RenderVertexSoft *pLineEnd, signed int sEndDiffuse, unsigned int uOutNumVertices, float z_stuff)
@@ -622,7 +584,7 @@
   IndoorCameraD3D *v25; // [sp+7C8h] [bp-4h]@1
 
   v25 = this;
-  if ( pRenderer->pRenderD3D )
+  //if ( pRenderer->pRenderD3D )
   {
     v7 = (char *)&pVertices[0].flt_2C;
     v8 = 20;
@@ -662,13 +624,7 @@
       v24[1].texcoord.x = 0.0;
       v24[1].texcoord.y = 0.0;
       //v19 = pRenderer->pRenderD3D->pDevice;
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, nullptr));
-      ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(
-              D3DPT_LINELIST,
-              D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
-              v24,
-              2,
-              16));
+      pRenderer->DrawLines(v24, 2);
       return;
     }
     v11 = (char *)&a1[0].flt_2C;
@@ -708,8 +664,6 @@
       goto LABEL_11;
     }
   }
-  else
-    MessageBoxW(nullptr, L"draw_debug_line() not implemented for SW rendering", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Core3D.cpp:1383", 0);
 }
 
 //----- (00437A55) --------------------------------------------------------
@@ -731,13 +685,13 @@
     do
     {
       v8 = v6 + 1;
-      do_draw_debug_line_d3d(v6, uDiffuse, v6 + 1, uDiffuse, z_stuff);
+      pRenderer->do_draw_debug_line_d3d(v6, uDiffuse, v6 + 1, uDiffuse, z_stuff);
       --v7;
       v6 = v8;
     }
     while ( v7 );
   }
-  do_draw_debug_line_d3d(&pLineVertices[v5], uDiffuse, pLineVertices, uDiffuse, z_stuff);
+  pRenderer->do_draw_debug_line_d3d(&pLineVertices[v5], uDiffuse, pLineVertices, uDiffuse, z_stuff);
 }
 
 //----- (004379EE) --------------------------------------------------------
@@ -799,25 +753,7 @@
     v[i].texcoord.y = 0;
   }
 
-
-  //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false));
-  //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, false));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA));
-  
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, nullptr));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
-                D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
-                v,
-                pFace->uNumVertices,
-                28));
-
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
-  //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE));
-  //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
+  pRenderer->DrawFansTransparent(v, pFace->uNumVertices);
 }
 
 //----- (00437906) --------------------------------------------------------
@@ -1544,7 +1480,7 @@
   float a2a; // [sp+18h] [bp+8h]@2
   float a2b; // [sp+18h] [bp+8h]@2
 
-  if ( pRenderer->pRenderD3D )
+  //if ( pRenderer->pRenderD3D )
   {
     v6 = 1.0 / (double)x;
     a2a = (double)y * fov * v6 + screenCenterX;
--- a/IndoorCameraD3D.h	Fri Jan 10 17:42:37 2014 +0600
+++ b/IndoorCameraD3D.h	Fri Jan 10 17:42:57 2014 +0600
@@ -153,7 +153,6 @@
   void debug_outline_sw(struct RenderVertexSoft *a2, unsigned int uNumVertices, unsigned int uDiffuse, float a5);
   void debug_outline_d3d(const struct RenderVertexD3D3 *pLineVertices, unsigned int uNumLines, int uDiffuse, float z_stuff);
   void do_draw_debug_line_sw(struct RenderVertexSoft *pLineBegin, signed int sStartDiffuse, struct RenderVertexSoft *pLineEnd, signed int sEndDiffuse, unsigned int uOutNumVertices, float z_stuff);
-  void do_draw_debug_line_d3d(const struct RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff);
   //void sr_437D4A_draw_some_vertices(float x, float y, float z, unsigned int a5, char a6, float a7);
   //void sr_438141_draw_list_0037C();
   //void sr_438240_draw_lits();
--- a/Indoor_stuff.h	Fri Jan 10 17:42:37 2014 +0600
+++ b/Indoor_stuff.h	Fri Jan 10 17:42:57 2014 +0600
@@ -90,7 +90,7 @@
     uNumVisibleNotEmptySectors = 0;
   }
 
-  void AddFaceToRenderList_sw(unsigned int node_id, unsigned int uFaceID);
+  //void AddFaceToRenderList_sw(unsigned int node_id, unsigned int uFaceID);
   void AddFaceToRenderList_d3d(unsigned int node_id, unsigned int uFaceID);
   void MakeVisibleSectorList();
   //void DrawFaceOutlines();
--- a/Keyboard.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/Keyboard.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -973,7 +973,7 @@
   int *v21; // [sp+18h] [bp-8h]@7
   int v22; // [sp+1Ch] [bp-4h]@4
 
-  if ( pRenderer->pRenderD3D )
+  //if ( pRenderer->pRenderD3D )
   {
     pGame->PickKeyboard(GetAsyncKeyState(VK_CONTROL) & 0x8001, &vis_sprite_filter_3, &vis_door_filter);
     int pid = pGame->pVisInstance->get_picked_object_zbuf_val();
@@ -984,7 +984,7 @@
 
   
   // software render stuff following
-
+  /*
   static int dword_720660[100]; // 720660
   static int dword_7207F0[100]; // 7207F0
 
@@ -1086,5 +1086,5 @@
     LOBYTE(v1) = DoInteractionWithTopmostZObject(dword_720660[j] & 0xFFFF, v16);
     if ( !(char)v1 )
       break;
-  }
+  }*/
 }
--- a/LOD.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/LOD.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -233,7 +233,7 @@
     int i, sprite_indx;
 
     //find if already loaded
-    if ( pRenderer->pRenderD3D )
+    //if ( pRenderer->pRenderD3D )
         {
         for (i=0; i<uNumLoadedSprites;++i)
             {
@@ -241,20 +241,20 @@
                 return i;
             } 
         }
-    else
+    /*else
         {
         for (i=0; i<uNumLoadedSprites;++i)
             {
             if (!(_stricmp(pSpriteHeaders[i].pName, pContainerName)))
                 return i;
             } 
-        }
+        }*/
 
     if (uNumLoadedSprites >= 1500 )
         return -1;
     //if not loaded - load from file   
 
-    if ( pRenderer->pRenderD3D && field_ECAC )
+    //if ( pRenderer->pRenderD3D && can_load_hardware_sprites )
         {
         if ( !pHardwareSprites )
             {
@@ -281,7 +281,7 @@
         pSpriteHeaders[uNumLoadedSprites].uWidth = temp_sprite_hdr.uWidth;
         pSpriteHeaders[uNumLoadedSprites].uHeight = temp_sprite_hdr.uHeight;
         }
-    else
+    /*else
         {
         sprite_indx = LoadSpriteFromFile( &pSpriteHeaders[uNumLoadedSprites], pContainerName);
         pSpriteHeaders[uNumLoadedSprites].word_1A = 0;
@@ -306,9 +306,9 @@
                 return -1;
             pSpriteHeaders[uNumLoadedSprites].uPaletteId = pPaletteManager->LoadPalette(pSpriteHeaders[uNumLoadedSprites].uPaletteId);
             }
-        }
+        }*/
 
-    if ( pRenderer->pRenderD3D )
+    //if ( pRenderer->pRenderD3D )
         {
         pHardwareSprites[uNumLoadedSprites].pName = (const char *)malloc(20);
         strcpy((char *)pHardwareSprites[uNumLoadedSprites].pName, pContainerName);
@@ -1284,7 +1284,7 @@
   field_ECA4 = 0;
   field_ECA0 = 0;
   pHardwareSprites = 0;
-  field_ECAC = 0;
+  //can_load_hardware_sprites = 0;
   field_ECB4 = 0;
   uNumLoadedSprites = 0;
 }
@@ -1366,7 +1366,7 @@
   v1->dword_11B80 = 0;
   v1->uNumLoadedFiles = 0;
   v1->dword_011BA4 = 0;
-  v1->dword_011BA8 = 0;
+  //v1->can_load_hardware_sprites = 0;
   v1->pHardwareSurfaces = 0;
   v1->pHardwareTextures = 0;
   v1->ptr_011BB4 = 0;
@@ -2582,7 +2582,7 @@
   v8 = pOutTex;
   fread(pOutTex, 1u, 0x30u, pFile);
   strcpy(v8->pName, pContainer);
-  if (pRenderer->pRenderD3D && v8->pBits & 2 && dword_011BA8)
+  if (/*pRenderer->pRenderD3D &&*/ v8->pBits & 2)
   {
     if (!pHardwareSurfaces || !pHardwareTextures)
     {
--- a/LOD.h	Fri Jan 10 17:42:37 2014 +0600
+++ b/LOD.h	Fri Jan 10 17:42:57 2014 +0600
@@ -215,7 +215,7 @@
   int uTexturePacksCount;
   int pFacesLock;
   int dword_011BA4;
-  int dword_011BA8;
+  //int can_load_hardware_sprites;
   struct IDirectDrawSurface **pHardwareSurfaces;
   struct IDirect3DTexture2 **pHardwareTextures;
   char *ptr_011BB4;
@@ -299,7 +299,7 @@
   int field_ECA0;
   int field_ECA4;
   int field_ECA8;
-  int field_ECAC;
+  //int can_load_hardware_sprites;
   Sprite *pHardwareSprites;
   int field_ECB4;
 };
--- a/Level/Decoration.h	Fri Jan 10 17:42:37 2014 +0600
+++ b/Level/Decoration.h	Fri Jan 10 17:42:57 2014 +0600
@@ -42,5 +42,5 @@
 
 extern std::array<LevelDecoration, 3000> pLevelDecorations;
 extern size_t uNumLevelDecorations;
-extern LevelDecoration* activeLevelDecoration;
+extern LevelDecoration* activeLevelDecoration; // 5C3420
 #pragma pack(pop)
--- a/LightmapBuilder.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/LightmapBuilder.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -587,7 +587,7 @@
 
     BLVLightMM7* pLight = &pIndoor->pLights[pSector->pLights[i]];
     if (~pLight->uAtributes & 0x08)
-      ApplyLight_BLV((StationaryLight *)pLight, pFace, &uFaceID, false, &byte_4E94D0);
+      ApplyLight_BLV((StationaryLight *)pLight, pFace, &uFaceID, false, &_4E94D0_light_type);
   }
 
   for (uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i)
@@ -595,7 +595,7 @@
     if (uNumLightsApplied >= 20)
       break;
 
-    ApplyLight_BLV(pStationaryLightsStack->pLights + i, pFace, &uNumLightsApplied, false, &byte_4E94D0);
+    ApplyLight_BLV(pStationaryLightsStack->pLights + i, pFace, &uNumLightsApplied, false, &_4E94D0_light_type);
   }
 
   stru_F8AD28.uNumLightsApplied = uNumLightsApplied;
@@ -1004,7 +1004,7 @@
     stru_F8AD28._blv_lights_types[*pSlot] = pLight->uLightType;
     //v13 = pRenderer->pRenderD3D;
     v14 = stru_F8AD28._blv_lights_types[*pSlot];
-    if ( pRenderer->pRenderD3D && v12 && v14 & 4 )
+    if ( /*pRenderer->pRenderD3D &&*/ v12 && v14 & 4 )
       v14 = _4E94D2_light_type;
     stru_F8AD28._blv_lights_types[*pSlot] = v14;
     result = 4 * *pSlot;
@@ -1155,7 +1155,7 @@
   unsigned int *v53; // esi@18
   int v54; // eax@18
   unsigned int v55; // ebx@18
-  RenderD3D *v56; // ecx@18
+  //RenderD3D *v56; // ecx@18
   char v57; // dl@18
   std::string v58; // [sp-18h] [bp-38h]@10
   const char *v59; // [sp-8h] [bp-28h]@10
@@ -1290,13 +1290,13 @@
   v55 = pRenderer->bUsingSpecular;
   stru_F8AD28._blv_lights_light_dot_faces[*v53] = v54;
   stru_F8AD28._blv_lights_types[*v53] = v8->uLightType;
-  v56 = pRenderer->pRenderD3D;
+  //v56 = pRenderer->pRenderD3D;
   v57 = stru_F8AD28._blv_lights_types[*v53];
-  if ( pRenderer->pRenderD3D && v55 && v57 & 4 )
+  if ( /*pRenderer->pRenderD3D &&*/ v55 && v57 & 4 )
     v57 = _4E94D2_light_type;
   stru_F8AD28._blv_lights_types[*v53] = v57;
   result = 4 * *v53;
-  if ( v56 && v55 )
+  if ( /*v56 &&*/ v55 )
   {
     if ( stru_F8AD28._blv_lights_types[*v53] & 4 )
     {
@@ -1376,7 +1376,7 @@
   IDirect3DDevice3 *v4; // eax@2
   HRESULT v5; // eax@2
   //char *v6; // eax@2
-  struct IDirect3DTexture2 *v7; // edi@4
+  //struct IDirect3DTexture2 *v7; // edi@4
   HRESULT v8; // eax@8
   HRESULT v9; // eax@8
   HRESULT v10; // eax@8
@@ -1410,22 +1410,12 @@
   //float v38; // [sp+84h] [bp-4h]@1
 
   if (std__vector_000004_size == 0)
-    return 1;
-
-
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP));
+    return true;
+  
+  if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related)
+    return true;
 
-  v7 = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03");
-  if ( pRenderer->bUsingSpecular )
-    pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE);
-
-  if ( !byte_4D864C || !(pGame->uFlags & GAME_FLAGS_1_01) )
-  {
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, v7));
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
+  pRenderer->BeginLightmaps();
 
       arg4.x = 1.0f;
       arg4.y = 1.0f;
@@ -1435,7 +1425,7 @@
         for (int* i = indices; *i != -1; ++i)
         {
           v28 = &std__vector_000004[*i];
-          if ( !DrawLightmap(v28, &arg4, 0.0) )
+          if ( !pRenderer->DrawLightmap(v28, &arg4, 0.0) )
             Error("Invalid lightmap detected! (%u)", *i);
         }
       }
@@ -1444,35 +1434,13 @@
         for (unsigned int i = 0; i < std__vector_000004_size; ++i)
         {
             Lightmap* _a1 = &std__vector_000004[(int)i];
-            if ( !DrawLightmap(_a1, &arg4, 0.0) )
-            {
-              MessageBoxW(nullptr, L"Invalid lightmap detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:1238", 0);
-              v35 = 5080812;
-            }
+            if ( !pRenderer->DrawLightmap(_a1, &arg4, 0.0) )
+              Error("Invalid lightmap detected! (%u)", i);
         }
       }
 
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
-  }
-
-    if ( pRenderer->bUsingSpecular )
-    {
-      //LODWORD(v30) = 1;
-      //v29 = 28;
-      //v28 = (Lightmap *)pRenderer->pRenderD3D->pDevice;
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
-      //v30 = pRenderer->uFogColor;
-      //v23 = pRenderer->pRenderD3D->pDevice;
-      //v29 = 34;
-      //v28 = (Lightmap *)v23;
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, pRenderer->uFogColor));
-      //v28 = (Lightmap *)pRenderer->pRenderD3D->pDevice;
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
-    }
-
+  pRenderer->EndLightmaps();
+  
   return true;
 }
 
@@ -1486,14 +1454,14 @@
   v.x = 1.0;
   
   for (uint i = 0; i < std__vector_183808_size; ++i)
-    if (!DrawLightmap(std__vector_183808 + i, &v, z_bias))
-      MessageBoxW(nullptr, L"Invalid lightmap detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:1288", 0);
+    if (!pRenderer->DrawLightmap(std__vector_183808 + i, &v, z_bias))
+      Error("Invalid lightmap detected! (%u)", i);
 
   return true;
 }
 
 //----- (0045DAE8) --------------------------------------------------------
-bool LightmapBuilder::DrawLightmap(Lightmap *pLightmap, Vec3_float_ *pColorMult, float z_bias)
+bool Render::DrawLightmap(Lightmap *pLightmap, Vec3_float_ *pColorMult, float z_bias)
 {
   double v10; // st7@4
   double v14; // st7@7
@@ -1568,29 +1536,9 @@
   if (!std__vector_183808_size)
     return;
 
-  if (pRenderer->bUsingSpecular)
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
- 
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
-
-  IDirect3DTexture2* pTex = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03");
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTex));
-
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
+  pRenderer->BeginLightmaps2();
 
   DoDraw_183808_Lightmaps(0.00050000002);
 
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
-
-  if (pRenderer->bUsingSpecular)
-    ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
+  pRenderer->EndLightmaps2();
 }
\ No newline at end of file
--- a/LightmapBuilder.h	Fri Jan 10 17:42:37 2014 +0600
+++ b/LightmapBuilder.h	Fri Jan 10 17:42:57 2014 +0600
@@ -36,7 +36,7 @@
   {}
 
   void Draw_183808_Lightmaps();
-  bool DrawLightmap(Lightmap *a1, Vec3_float_ *pColorMult, float z_bias);
+  //bool DrawLightmap(Lightmap *a1, Vec3_float_ *pColorMult, float z_bias);
   bool DoDraw_183808_Lightmaps(float a2);
   bool DrawLightmaps(int *indices = nullptr);
   void DrawLightmapsType(int type);
--- a/Mouse.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/Mouse.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -109,7 +109,7 @@
   //}
   v1->uMouseClickX = v2;
   v1->uMouseClickY = result;
-  if ( pRenderer->bWindowMode )
+  if ( true/*pRenderer->bWindowMode*/)
     goto LABEL_16;
   //if (pAsyncMouse)
   //  goto LABEL_24;
@@ -125,7 +125,7 @@
 LABEL_16:
     //if (pAsyncMouse)
     //  goto LABEL_24;
-    if ( pRenderer->bWindowMode && (v2 < 0 || result < 0 || v2 > 639 || result > 479) )
+    if (true/*pRenderer->bWindowMode*/ && (v2 < 0 || result < 0 || v2 > 639 || result > 479) )
       goto LABEL_23;
   }
   if ( v1->field_C )
@@ -235,7 +235,8 @@
       this->field_F4 = 0;
       return;
     }
-    if ( pRenderer->bWindowMode )
+
+    //if ( pRenderer->bWindowMode )
     {
       if ( this->uMouseClickX < 0 || this->uMouseClickY < 0 || this->uMouseClickX > 639 || this->uMouseClickY > 479 )
       {
@@ -243,7 +244,7 @@
         return;
       }
     }
-    else
+    /*else
     {
       if ( this->uMouseClickX < 0 )
         this->uMouseClickX = 0;
@@ -253,7 +254,7 @@
         this->uMouseClickX = 639;
       if ( this->uMouseClickY > 479 )
         this->uMouseClickY = 479;
-    }
+    }*/
     this->pCursorBitmapRect.x = this->uMouseClickX;
     this->pCursorBitmapRect.w = this->uMouseClickY + this->field_5C[0];
     this->pCursorBitmapRect.y = this->uMouseClickY;
@@ -563,10 +564,10 @@
     return;
   }
   y = pY;
-  if ( pRenderer->pRenderD3D )
+  //if ( pRenderer->pRenderD3D )
     v5 = pGame->pVisInstance->get_picked_object_zbuf_val();
-  else
-    v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];
+  /*else
+    v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];*/
 
   uint type = PID_TYPE((unsigned __int16)v5);
   if (type == OBJECT_Actor && uActiveCharacter && v5 < 0x2000000
--- a/OSWindow.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/OSWindow.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -321,8 +321,6 @@
 			  && pVideoPlayer->bPlayingMovie )
             pVideoPlayer->bStopBeforeSchedule = 1;
 
-          if (/*pRenderer->bUserDirect3D && */pRenderer->uAcquiredDirect3DDevice == 1)
-            SetWindowPos(api_handle, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u);
           ClipCursor(0);
           dword_6BE364_game_settings_1 |= GAME_SETTINGS_APP_INACTIVE;
           if ( pEventTimer->bPaused )
@@ -343,11 +341,6 @@
 
     case WM_SETFOCUS:
       dword_4E98BC_bApplicationActive = 0;
-      if (pRenderer)
-      {
-        if (/*pRenderer->bUserDirect3D && */pRenderer->uAcquiredDirect3DDevice == 1)
-          SetWindowPos(api_handle, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u);
-      }
       ClipCursor(0);
       return false;
 
@@ -356,28 +349,25 @@
       return false;
 
     case WM_PAINT:
-      if (pRenderer)
-      {
-        if ( !GetUpdateRect(api_handle, 0, 0) || !dword_4E98BC_bApplicationActive && !pRenderer->bWindowMode )
-          return *result = 0, true;
-      }
       if (!api_handle || !pRenderer)
         return false;
+
+      if ( !GetUpdateRect(api_handle, 0, 0))// || !dword_4E98BC_bApplicationActive && !pRenderer->bWindowMode )
+        return *result = 0, true;
+
       PAINTSTRUCT Paint;
       BeginPaint(api_handle, &Paint);
       if ( pArcomageGame->bGameInProgress )
       {
         pArcomageGame->field_F9 = 1;
       }
-      else
+      if (pRenderer->AreRenderSurfacesOk())
       {
-        if (/*!pRenderer->pRenderD3D && !pRenderer->UsingDirect3D() ||*/ !AreRenderSurfacesOk())
-        {
-          EndPaint(api_handle, &Paint);
-          return *result = 0, true;
-        }
+        pRenderer->Present();
+        //EndPaint(api_handle, &Paint);
+        //return *result = 0, true;
       }
-      pRenderer->Present();
+
       EndPaint(api_handle, &Paint);
       return *result = 0, true;
 
--- a/Outdoor.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/Outdoor.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -1022,9 +1022,9 @@
   int g_mask = 0x7E0;
   int b_mask = 0x1F;
 
-  if ( pRenderer->pRenderD3D )
+  //if ( pRenderer->pRenderD3D )
     result = 0;
-  else
+  /*else
   {
     __debugbreak();
     v5 = PaletteManager::Get_Dark_or_Red_LUT(a2, 0, 1);
@@ -1076,10 +1076,9 @@
       ++v15;
     }
     while ( v15 < 256 );
-  }
+  }*/
   return result;
 }
-// 47CB57: using guessed type char var_124[256];
 
 //----- (0047CCE2) --------------------------------------------------------
 bool OutdoorLocationTerrain::ZeroLandscape()
@@ -2970,8 +2969,8 @@
         v62 |= 4u;
       if ( v15->uGlowRadius )
       {
-        //LOBYTE(v16) = byte_4E94D3;
-        pMobileLightsStack->AddLight(x, y, z, 0, v15->uGlowRadius, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3);
+        //LOBYTE(v16) = _4E94D3_light_type;
+        pMobileLightsStack->AddLight(x, y, z, 0, v15->uGlowRadius, 0xFFu, 0xFFu, 0xFFu, _4E94D3_light_type);
       }
       v17 = (x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16;
       if (pGame->pIndoorCameraD3D->sRotationX)
--- a/Overlays.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/Overlays.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -135,10 +135,10 @@
   v4 = pIconsFrameTable->GetFrame(v5, v6);
 LABEL_14:
   v7 = &pIcons_LOD->pTextures[*((short *)v4 + 15)];
-  if ( pRenderer->pRenderD3D )
+  //if ( pRenderer->pRenderD3D )
     pRenderer->DrawTextureIndexed(0x18Au, 0x120u, v7);
-  else
-    pRenderer->DrawTextureTransparent(0x18Au, 0x120u, v7);
+  /*else
+    pRenderer->DrawTextureTransparent(0x18Au, 0x120u, v7);*/
   result = dword_50C994;
   if ( dword_50C994 < dword_50C998_turnbased_icon_1A )
   {
--- a/ParticleEngine.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/ParticleEngine.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -140,17 +140,18 @@
   else
     DrawParticles_ODM();
 
-  if (pRenderer->pRenderD3D)
+  //if (pRenderer->pRenderD3D)
   {
     if (pLines.uNumLines)
     {
-      pRenderer->pRenderD3D->pDevice->SetTexture(0, 0);
+      pRenderer->DrawLines(pLines.pLineVertices, pLines.uNumLines);
+      /*pRenderer->pRenderD3D->pDevice->SetTexture(0, 0);
       pRenderer->pRenderD3D->pDevice->DrawPrimitive(
         D3DPT_LINELIST,
         D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
         pLines.pLineVertices,
         pLines.uNumLines,
-        D3DDP_DONOTLIGHT);
+        D3DDP_DONOTLIGHT);*/
     }
   }
 }
@@ -649,10 +650,10 @@
         p->uScreenSpaceY >= pBLVRenderParams->uViewportY &&
         p->uScreenSpaceY < pBLVRenderParams->uViewportW)
     {
-      if (!pRenderer->pRenderD3D)
+      /*if (!pRenderer->pRenderD3D)
       {
         __debugbreak();
-                    /*v11 = 13 * p->_screenspace_scale >> 16;
+                    v11 = 13 * p->_screenspace_scale >> 16;
                      if ( v11 > 30 )
                        v11 = 30;
                     v12 = p->uScreenSpaceY - v11;
@@ -667,9 +668,9 @@
                      else
                      {
                        pRenderer->MakeParticleBillboardAndPush_BLV_Software(v13, v12, p->sZValue, p->uLightColor_bgr, v11);
-                     }*/
+                     }
       }
-      //else
+      else*/
 
         if (p->type & ParticleType_Diffuse)
         {
@@ -759,10 +760,10 @@
     if (particle->type == ParticleType_Invalid || !ViewProject_TrueIfStillVisible_ODM(i))
       continue;
 
-        if ( !pRenderer->pRenderD3D )
+        /*if ( !pRenderer->pRenderD3D )
         {
           __debugbreak();
-          /*v10 = 13 * particle->_screenspace_scale >> 16;
+          v10 = 13 * particle->_screenspace_scale >> 16;
           if ( v10 > 30 )
             v10 = 30;
           v11 = particle->uScreenSpaceX - (v10 >> 1);
@@ -777,9 +778,9 @@
           else
           {
             pRenderer->MakeParticleBillboardAndPush_BLV_Software(v11, v12, particle->sZValue, particle->uLightColor_bgr, v10);
-          }*/
+          }
         }
-        //else
+        else*/
 
           //v8 = *(_DWORD *)(v7 - 82);
           if (particle->type & ParticleType_Diffuse)
--- a/Party.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/Party.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -837,7 +837,7 @@
   pParty->uCurrentMonth = v5 % 0xC;
   pParty->uCurrentYear = v5 / 0xC + game_starting_year;
   pParty->RestAndHeal();
-  dword_507B94 = 1;
+
   for (int i = 0; i < 4; i++)
   {
     pParty->pPlayers[i].uTimeToRecovery = 0;
--- a/Player.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/Player.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -4646,7 +4646,7 @@
       pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);
       return;
     }
-    dword_50C9AC = 1;
+
     scroll_id = pParty->pPickedItem.uItemID - 299;
     if ( scroll_id == 30 || scroll_id == 4 || scroll_id == 91 || scroll_id == 28 ) //Enchant Item scroll, Vampiric Weapon scroll ,Recharge Item ,Fire Aura
     {
@@ -7324,7 +7324,7 @@
             }
             else
             {
-              if ( pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].bQuestMonster & 1 && pRenderer->pRenderD3D && pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS)
+              if ( pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].bQuestMonster & 1 && pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS)
               {
                 int splatRadius = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * actorPtr->uActorRadius : actorPtr->uActorRadius;
                 pDecalBuilder->AddBloodsplat(actorPtr->vPosition.x, actorPtr->vPosition.y, actorPtr->vPosition.z, 1.0, 0.0, 0.0, (float)splatRadius, 0, 0);
@@ -7516,7 +7516,7 @@
               }
               else
               {
-                if ( pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].bQuestMonster & 1 && pRenderer->pRenderD3D && pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS )
+                if ( pMonsterStats->pInfos[actorPtr->pMonsterInfo.uID].bQuestMonster & 1 && pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS )
                 {
                   int splatRadius = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * actorPtr->uActorRadius : actorPtr->uActorRadius;
                   pDecalBuilder->AddBloodsplat(actorPtr->vPosition.x, actorPtr->vPosition.y, actorPtr->vPosition.z, 1.0, 0.0, 0.0, (float)splatRadius, 0, 0);
--- a/Render.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/Render.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -28,6 +28,7 @@
 #include "MM7.h"
 #include "Lights.h"
 #include "Level/Decoration.h"
+#include "Vis.h"
 
 //#pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib")
 //#pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib")
@@ -80,7 +81,7 @@
 signed int __stdcall RenderD3D__DeviceEnumerator(GUID *lpGUID, const char *lpDevDesc, const char *lpDriverName, RenderD3D__DevInfo *pOut); // idb
 
 //----- (0049E79F) --------------------------------------------------------
-bool CheckTextureStages()
+bool Render::CheckTextureStages()
 {
   bool v0; // edi@1
   IDirectDrawSurface4 *pSurface2; // [sp+Ch] [bp-14h]@1
@@ -90,30 +91,30 @@
   IDirect3DTexture2 *pTexture1; // [sp+1Ch] [bp-4h]@1
 
   v0 = false;
-  pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface1, &pTexture1, true, false, 32u);
-  pRenderer->pRenderD3D->CreateTexture(64u, 64u, &pSurface2, &pTexture2, true, false, 32u);
-
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture1));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 2u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 1u));
-
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture2));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 7u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, 2u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, 1u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MAGFILTER, 2u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MINFILTER, 2u));
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MIPFILTER, 1u));
-
-  if ( !pRenderer->pRenderD3D->pDevice->ValidateDevice(&v4) && v4 == 1 )
+  pRenderD3D->CreateTexture(64u, 64u, &pSurface1, &pTexture1, true, false, 32u);
+  pRenderD3D->CreateTexture(64u, 64u, &pSurface2, &pTexture2, true, false, 32u);
+
+  ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture1));
+  ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP));
+  ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 2));
+  ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2));
+  ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2));
+  ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2));
+  ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 1));
+
+  ErrD3D(pRenderD3D->pDevice->SetTexture(0, pTexture2));
+  ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP));
+  ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1));
+  ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 7));
+  ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, 2));
+  ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, 1));
+  ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MAGFILTER, 2));
+  ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MINFILTER, 2));
+  ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_MIPFILTER, 1));
+
+  if ( !pRenderD3D->pDevice->ValidateDevice(&v4) && v4 == 1 )
     v0 = true;
-  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1u));
+  ErrD3D(pRenderD3D->pDevice->SetTextureStageState(1, D3DTSS_COLOROP, 1u));
   pTexture1->Release();
   pTexture2->Release();
   pSurface1->Release();
@@ -121,34 +122,6 @@
   return v0;
 }
 
-void Render::sub_4A19B0()
-{
-  char *result; // eax@1
-  signed int v1; // ecx@1
-  /*
-  result = (char *)&this->pBillboardRenderListD3D[0].uOpacity;
-  v1 = 1000;
-  do
-  {
-    *(_DWORD *)result = 0;
-    *((_DWORD *)result + 1) = -1;
-    *((_DWORD *)result + 3) = -1;
-    *((_DWORD *)result - 34) = 4;
-    result += 156;
-    --v1;
-  }
-  while ( v1 );
-  */
-  for( int i = 0; i < 1000; i++ )
-  {
-	this->pBillboardRenderListD3D[i].uOpacity = (RenderBillboardD3D::OpacityType)0;
-	this->pBillboardRenderListD3D[i].field_90 = -1;
-	this->pBillboardRenderListD3D[i].sParentBillboardID = -1;
-	this->pBillboardRenderListD3D[i].uNumVertices = 4;
-  }
-
-  return;
-}
 
 //----- (00440CB8) --------------------------------------------------------
 void Render::DrawBillboardList_BLV()
@@ -200,28 +173,9 @@
 }
 
 //----- (004A16A5) --------------------------------------------------------
-bool AreRenderSurfacesOk()
-{
-  char v0; // zf@4
-  bool result; // eax@8
-
-  if (!pRenderer)
-    return true;
-
-  {
-    if ( !pRenderer->pBackBuffer4 )
-      goto LABEL_9;
-    v0 = pRenderer->pFrontBuffer4 == 0;
-  }
-
-  if ( !v0 )
-  {
-    LOBYTE(result) = 1;
-    return result;
-  }
-LABEL_9:
-  LOBYTE(result) = 0;
-  return result;
+bool Render::AreRenderSurfacesOk()
+{
+  return pFrontBuffer4 && pBackBuffer4;
 }
 
 
@@ -614,8 +568,8 @@
               LOBYTE(v46) = v46 | 0x80;
             if ( a6 )
             {
-              //LOBYTE(v11) = byte_4E94D3;
-              pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3);
+              //LOBYTE(v11) = _4E94D3_light_type;
+              pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFFu, 0xFFu, 0xFFu, _4E94D3_light_type);
             }
             v12 = (x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16;
             if (pGame->pIndoorCameraD3D->sRotationX)
@@ -1113,7 +1067,7 @@
               v14,
               v15,
               v16,
-              byte_4E94D0);
+              _4E94D0_light_type);
           }
           v17 = (decor->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16;
           if (pGame->pIndoorCameraD3D->sRotationX)
@@ -1716,20 +1670,20 @@
   }
   else
   {
-    if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 0x10) )
+    if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_SRCALPHA) )
       v1 = 2;
-    if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 2) )
+    if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ONE) )
       v1 |= 4u;
-    if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & 1) )
+    if ( !(halCaps.dpcTriCaps.dwSrcBlendCaps & D3DPBLENDCAPS_ZERO) )
       v1 |= 8u;
-    if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 0x20) )
+    if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_INVSRCALPHA) )
       v1 |= 0x10u;
-    if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 2) )
+    if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_ONE) )
       v1 |= 0x20u;
-    if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & 4) )
+    if ( !(halCaps.dpcTriCaps.dwDestBlendCaps & D3DPBLENDCAPS_SRCCOLOR) )
       v1 |= 0x40u;
-    if ( halCaps.dpcTriCaps.dwTextureCaps & 0x20 )
-      LOBYTE(v1) = v1 | 0x80;
+    if ( halCaps.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY )
+      v1 |= 0x80;
     result = v1;
   }
   return result;
@@ -1934,7 +1888,7 @@
     if ( v7->std__vector_000004_size)
       a2 = -1;
     pGame->AlterGamma_ODM(a4, &a2);
-    if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01)
+    if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related)
     {
       v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0);
       v7->DrawLightmaps(/*v8, 0*/);
@@ -2096,17 +2050,6 @@
   //nullsub_1();
 }
 
-//----- (0049E756) --------------------------------------------------------
-bool Render::IsColorKeySupported(IDirectDraw4 *this_)
-{
-  DDCAPS refCaps; // [sp+0h] [bp-2F8h]@1
-  DDCAPS halCaps; // [sp+17Ch] [bp-17Ch]@1
-
-  halCaps.dwSize = 380;
-  refCaps.dwSize = 380;
-  this_->GetCaps(&halCaps, &refCaps);
-  return halCaps.dwSVBCaps & 0x40 && BYTE1(halCaps.dwSVBCKeyCaps) & 2;
-}
 
 //----- (0049E992) --------------------------------------------------------
 Render::Render()
@@ -2119,7 +2062,7 @@
   this->pDirectDraw4 = 0;
   this->pFrontBuffer4 = 0;
   this->pBackBuffer4 = 0;
-  this->pColorKeySurface4 = 0;
+  //this->pColorKeySurface4 = 0;
   //this->pDirectDraw2 = 0;
   //this->pFrontBuffer2 = 0;
   //this->pBackBuffer2 = 0;
@@ -2127,25 +2070,25 @@
   //RenderHWLContainer::RenderHWLContainer(&this->pD3DBitmaps);
   //RenderHWLContainer::RenderHWLContainer(&v1->pD3DSprites);
   v1->bWindowMode = 1;
-  v1->field_40054 = 0;
-  v1->field_10 = 640;
-  v1->field_14 = 480;
-  v1->field_40030 = 0;
-  v1->field_4002C = 0;
+  //v1->field_40054 = 0;
+  //v1->field_10 = 640;
+  //v1->field_14 = 480;
+  //v1->field_40030 = 0;
+  //v1->field_4002C = 0;
   v1->pActiveZBuffer = 0;
   v1->pDefaultZBuffer = 0;
   v1->raster_clip_y = 0;
   v1->raster_clip_x = 0;
   v1->raster_clip_z = 639;
   v1->raster_clip_w = 479;
-  v1->field_4003C = (int)&unk_4EED80;
-  v1->field_40040 = dword_4EED78;
+  //v1->field_4003C = 0x004EED80;
+  //v1->field_40040 = dword_4EED78;
   v1->uClipZ = 640;
-  v1->field_40044 = 2;
-  v1->field_40048 = 6;
+  //v1->field_40044 = 2;
+  //v1->field_40048 = 6;
   v1->pFrontBuffer4 = 0;
   v1->pBackBuffer4 = 0;
-  v1->pColorKeySurface4 = 0;
+  //v1->pColorKeySurface4 = 0;
   v1->pDirectDraw4 = 0;
   v1->pRenderD3D = 0;
   v1->uNumSceneBegins = 0;
@@ -2160,13 +2103,12 @@
   //v1->bColorKeySupported = 0;
   v1->bRequiredTextureStagesAvailable = 0;
   v1->bTinting = 1;
-  LOBYTE(v1->field_103668) = 0;
+  //LOBYTE(v1->field_103668) = 0;
   uNumBillboardsToDraw = 0;
   bFogEnabled = false;
 
   hd_water_tile_id = -1;
   hd_water_current_frame = 0;
-  sub_4A19B0();
 }
 
 bool Render::Initialize(OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting)
@@ -2195,13 +2137,13 @@
 //----- (0049ECC4) --------------------------------------------------------
 void Render::ClearBlack()
 {
-  if (pRenderD3D)
+  //if (pRenderD3D)
   {
     if (using_software_screen_buffer)
       pRenderD3D->ClearTarget(true, 0, false, 0.0);
   }
-  else
-    memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2));
+  //else
+    //memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2));
 }
 
 //----- (0049ED18) --------------------------------------------------------
@@ -2267,9 +2209,9 @@
     File = fopen(Filename, "wb");
     if ( File )
     {
-      pitch = this->field_10;
-      if ( this->field_10 & 1 )
-        pitch = this->field_10 + 1;
+      pitch = this->GetRenderWidth();
+      if ( pitch & 1 )
+        pitch = pitch + 1;
       if ( this->pRenderD3D )
       {
         memset(&Dst, 0, 0x7C);
@@ -2285,9 +2227,9 @@
         surface = pRenderer->pTargetSurface;
         v5 = pRenderer->uTargetSurfacePitch;
       }
-      header1.right = this->field_10 - 1;
+      header1.right = GetRenderWidth() - 1;
       header1.left = 0;
-      header1.bottom = this->field_14 - 1;
+      header1.bottom = this->GetRenderHeight() - 1;
       header1.up = 0;
       header2.pitch = pitch;
       memset(color_map, 0, sizeof(color_map));
@@ -2318,20 +2260,20 @@
       fwrite(&header2.pitch, 2, 1, pOutFile);
       fwrite(&header2.palette_info, 2, 1, pOutFile);
       fwrite(v15, 0x3Au, 1, pOutFile);
-      lineRGB = (char *)malloc(3 * this->field_10 + 6);
-      if ( this->field_14 > 0 )
+      lineRGB = (char *)malloc(3 * GetRenderWidth() + 6);
+      if ( this->GetRenderHeight() > 0 )
       {
         image_width = 3 * pitch;
         //v24 = 2 * v5;
         v8 = (unsigned short *)surface;
-        for ( int y = 0; y < this->field_14; y++ )
+        for ( int y = 0; y < this->GetRenderHeight(); y++ )
         {
           line_picture_data = v8;
-          if ( this->field_10 > 0 )
+          if ( GetRenderWidth() > 0 )
           {
             lineG = (char *)lineRGB + pitch;
             lineB = (char *)lineRGB + 2 * pitch;
-            for ( uint x = 0; x < this->field_10; x++ )
+            for ( uint x = 0; x < this->GetRenderWidth(); x++ )
             {
 			  int p = *line_picture_data; //0x2818
               int for_rad = (pRenderer->uTargetGBits + pRenderer->uTargetBBits );//16 = 8 + 8
@@ -2379,7 +2321,6 @@
     }
   }
 }
-// 4EFA80: using guessed type int dword_4EFA80;
 
 //----- (0049F1BC) --------------------------------------------------------
 void Render::SaveWinnersCertificate(const char *a1)
@@ -2435,14 +2376,16 @@
 
   if ( !this->pRenderD3D || this->using_software_screen_buffer )
   {
-    ++dword_4EFA84;
+    static int _4EFA84_num_winners_certificates = 0;
+    ++_4EFA84_num_winners_certificates;
+
     File = fopen(a1, "wb");
     if ( File )
     {
-      v25 = this->field_10;
-      pitch = this->field_10;
-      if ( this->field_10 & 1 )
-        pitch = this->field_10 + 1;
+      v25 = this->GetRenderWidth();
+      pitch = v25;
+      if ( pitch & 1 )
+        pitch = pitch + 1;
       if ( this->pRenderD3D )
       {
         memset(&Dst, 0, 0x7C);
@@ -2458,9 +2401,9 @@
         surface = pRenderer->pTargetSurface;
         v6 = pRenderer->uTargetSurfacePitch;
       }
-      v33 = this->field_10 - 1;
+      v33 = this->GetRenderWidth() - 1;
       v31 = 0;
-      v34 = (short)this->field_14 - 1;
+      v34 = (short)this->GetRenderHeight() - 1;
       v32 = 0;
       v39 = pitch;
       memset(&color_map, 0, sizeof(color_map));
@@ -2492,11 +2435,11 @@
       fwrite(&v40, 2, 1, File);
       fwrite(&v16, 0x3A, 1, File);
       lineRGB = (char *)malloc(3 * (v25 + 2));
-      if ( (signed int)this->field_14 > 0 )
+      if ( (signed int)this->GetRenderHeight() > 0 )
       {
         image_width = 3 * pitch;
         v9 = (unsigned short *)surface;
-        for ( uint j = 0; j < this->field_14; j++)
+        for ( uint j = 0; j < this->GetRenderHeight(); j++)
         {
           a1 = (const char *)v9;
           if ( v25 > 0 )
@@ -2543,7 +2486,6 @@
     }
   }
 }
-// 4EFA84: using guessed type int dword_4EFA84;
 
 //----- (0049F5A2) --------------------------------------------------------
 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size )
@@ -2688,7 +2630,7 @@
 }
 
 //----- (0049F8B5) --------------------------------------------------------
-FILE *Render::SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height)
+void Render::SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height)
 {
   FILE *result; // eax@1
   FILE *pOutFile; // edi@4
@@ -2804,29 +2746,22 @@
       v9 += width;
     }
     free(lineRGB);
-    result = (FILE *)fclose(pOutFile);
-  }
-  return result;
+    fclose(pOutFile);
+  }
 }
 
 //----- (0049FBCD) --------------------------------------------------------
 void Render::ClearTarget(unsigned int uColor)
 {
-  if (pRenderD3D)
+  //if (pRenderD3D)
   {
     if (using_software_screen_buffer)
       pRenderD3D->ClearTarget(true, uColor, false, 0.0);
   }
-  else
-    memset32(pTargetSurface, uColor, field_10 * field_14 / 2);
-}
-
-//----- (0049FC23) --------------------------------------------------------
-void Render::Release2()
-{
-  Release();
-  bWindowMode = 1;
-}
+  //else
+    //memset32(pTargetSurface, uColor, field_10 * field_14 / 2);
+}
+
 
 //----- (0049FC37) --------------------------------------------------------
 void Render::Present()
@@ -2877,7 +2812,7 @@
 }
 
 //----- (0049FD3A) --------------------------------------------------------
-void Render::_49FD3A()
+void Render::_49FD3A_fullscreen()
 {
   Render *v2; // esi@1
   IDirectDrawSurface4 *v3; // eax@6
@@ -2942,7 +2877,7 @@
       pRenderD3D->Present(0);
       pRenderD3D->ClearTarget(true, 0, false, 1.0);
     }
-    v1->pColorKeySurface4 = 0;
+    //v1->pColorKeySurface4 = 0;
     v1->pBackBuffer4 = 0;
     v1->pFrontBuffer4 = 0;
     v1->pDirectDraw4 = 0;
@@ -3064,7 +2999,7 @@
           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))
+            if (src[x + y * src_pitch] != 0xFF00FCF8)  // FFF8FCF8 =  Color32(Color16(g_mask | b_mask))
               dst[x + y * dst_pitch] = src[x + y * src_pitch];
           }
         }
@@ -3106,8 +3041,8 @@
 
   if ( !pRenderer->uNumSceneBegins )
   {
-    if ( pRenderer->using_software_screen_buffer )
-    {
+    //if ( pRenderer->using_software_screen_buffer )
+    //{
       memset(&Dst, 0, 0x7Cu);
       Dst.dwSize = 124;
       if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) )
@@ -3238,18 +3173,10 @@
           }
         }*/
       }
-    }
-  }
-}
-
-
-
-
-//----- (0049FFD7) --------------------------------------------------------
-void Render::CreateSomeTexture()
-{
-  pRenderD3D->CreateTexture(64, 64, &pSurface, &pTexture, true, false, 32);
-}
+    //}
+  }
+}
+
 
 //----- (0049FFFB) --------------------------------------------------------
 bool Render::InitializeFullscreen()
@@ -3286,7 +3213,7 @@
 
   //v2 = this;
   this->using_software_screen_buffer = 0;
-  this->pColorKeySurface4 = 0;
+  //this->pColorKeySurface4 = 0;
   this->pBackBuffer4 = 0;
   this->pFrontBuffer4 = 0;
   this->pDirectDraw4 = 0;
@@ -3314,14 +3241,12 @@
     if ( v7[v6].bIsDeviceCompatible )
     {
       v8 = pRenderD3D->CreateDevice(v6, /*0*/true, window);
-      uAcquiredDirect3DDevice = uDesiredDirect3DDevice;
     }
     else
     {
       if ( v7[1].bIsDeviceCompatible )
       {
         v8 = pRenderD3D->CreateDevice(1, /*0*/true, window);
-        uAcquiredDirect3DDevice = 1;
       }
       else
       {
@@ -3329,7 +3254,6 @@
           Error("There aren't any D3D devices to create.");
 
         v8 = pRenderD3D->CreateDevice(0, /*0*/true, window);
-        uAcquiredDirect3DDevice = 1;
       }
     }
     if ( !v8 )
@@ -3360,7 +3284,7 @@
         pRenderD3D->Release();
         delete pRenderD3D;
       }
-      pColorKeySurface4 = 0;
+      //pColorKeySurface4 = 0;
       pRenderD3D = 0;
       pBackBuffer4 = 0;
       pFrontBuffer4 = 0;
@@ -3380,7 +3304,7 @@
       pDirectDraw4 = 0;
       Error("Direct3D renderer:  The device doesn't support non-square textures.");
     }
-    LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1;
+    //LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1;
     bRequiredTextureStagesAvailable = CheckTextureStages();
     memset(&halCaps, 0, 0xFCu);
     halCaps.dwSize = 252;
@@ -3398,24 +3322,23 @@
     uMaxDeviceTextureDim = v14;
     if ( (unsigned int)v13 < 4 )
       uMinDeviceTextureDim = 4;
-    CreateSomeTexture();
     v15 = 1;
     ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, true));
     ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true));
-    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u));
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2));
     ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SPECULARENABLE, false));
     ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, false));
     ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, false));
-    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u));
-    ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2u));
-    ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2u));
-    ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3u));
-    ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2u));
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1));
+    ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, 2));
+    ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, 2));
+    ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, 3));
+    ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, 2));
     ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, 0));
-    ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2u));
-    ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2u));
+    ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, 2));
+    ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, 2));
     ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, 0));
-    ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4u));
+    ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_COLOROP, 4));
   //}
   ddpfPrimarySuface.dwSize = 32;
   GetTargetPixelFormat(&ddpfPrimarySuface);
@@ -3509,7 +3432,7 @@
   pViewport->SetFOV(flt_6BE3A0 * 65536.0f);
   using_software_screen_buffer = 0;
   Release();
-  pColorKeySurface4 = 0;
+  //pColorKeySurface4 = 0;
   pBackBuffer4 = 0;
   pFrontBuffer4 = 0;
   pDirectDraw4 = 0;
@@ -3544,7 +3467,6 @@
         uDesiredDirect3DDevice != 1 )
     {
       v7 = pRenderD3D->CreateDevice(uDesiredDirect3DDevice, true, window);
-      uAcquiredDirect3DDevice = uDesiredDirect3DDevice;
     }
     else
     {
@@ -3552,13 +3474,12 @@
         Error("There aren't any D3D devices to init.");
 
       v7 = pRenderD3D->CreateDevice(0, true, window);
-      uAcquiredDirect3DDevice = 0;
     }
     if ( !v7 )
       Error("D3Drend->Init failed.");
 
     //v8 = pRenderD3D;
-    pColorKeySurface4 = 0;
+    //pColorKeySurface4 = 0;
     pBackBuffer4 = pRenderD3D->pBackBuffer;
     pFrontBuffer4 = pRenderD3D->pFrontBuffer;
     pDirectDraw4 = pRenderD3D->pHost;
@@ -3583,14 +3504,14 @@
         pRenderD3D->Release();
         delete pRenderD3D;
       }
-      pColorKeySurface4 = 0;
+      //pColorKeySurface4 = 0;
       pRenderD3D = 0;
       pBackBuffer4 = 0;
       pFrontBuffer4 = 0;
       pDirectDraw4 = 0;
       Error("Direct3D renderer:  The device doesn't support the necessary alpha blending modes.");
     }
-    if ( (v9 & 0x80u) != 0 )
+    if (v9 & 0x80)
     {
       if (pRenderD3D)
       {
@@ -3603,7 +3524,7 @@
       pDirectDraw4 = 0;
       Error("Direct3D renderer:  The device doesn't support non-square textures.");
     }
-    LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1;
+    //LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1;
     bRequiredTextureStagesAvailable = CheckTextureStages();
     memset(&halCaps, 0, 0xFCu);
     halCaps.dwSize = 252;
@@ -3619,7 +3540,6 @@
     if ( (unsigned int)halCaps.dwMaxTextureWidth < halCaps.dwMaxTextureHeight )
       v13 = halCaps.dwMaxTextureHeight;
     uMaxDeviceTextureDim = v13;
-    CreateSomeTexture();
     ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, 1u));
     ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u));
     ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 2u));
@@ -3715,6 +3635,26 @@
       goto LABEL_45;
 }
 
+
+//----- (0044F2B2) --------------------------------------------------------
+bool Render::IsGammaSupported()
+{
+  bool result; // eax@3
+  HRESULT v1; // eax@4
+
+  //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
+  {
+    DDCAPS halCaps; // [sp+0h] [bp-180h]@4
+    memset(&halCaps, 0, sizeof(DDCAPS));
+    halCaps.dwSize = sizeof(DDCAPS);
+
+    ErrD3D(pDirectDraw4->GetCaps(&halCaps, 0));
+    return (halCaps.dwCaps2 >> 17) & 1;
+  }
+  /*else
+    return false;*/
+}
+
 //----- (004A0BEE) --------------------------------------------------------
 void Render::RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor)
 {
@@ -4194,7 +4134,7 @@
 void Render::CreateDirectDrawPrimarySurface()
 {
   Render *v1; // esi@1
-  int v2; // ebx@3
+  //int v2; // ebx@3
   IDirectDraw2 *v3; // eax@3
   HRESULT v4; // eax@3
   IDirectDrawSurface *pFrontBuffer; // eax@3
@@ -4216,8 +4156,8 @@
   //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
       //pVersion->pVersionInfo.dwMajorVersion != 4 )
   {
-    v2 = 0;
-    this->field_4004C = 1;
+    //v2 = 0;
+    //this->field_4004C = 1;
     memset(&ddsd2, 0, 0x7Cu);
     v7 = v1->pDirectDraw4;
     ddsd2.dwBackBufferCount = 1;
@@ -4258,8 +4198,8 @@
     v17.dwCaps = 4;
   ErrD3D(pFrontBuffer->GetAttachedSurface((DDSCAPS *)&v17, ppBackBuffer));//  hr = this->pFrontBuffer->GetAttachedSurface(&ddsCaps2, ppBackBuffer);
   //CheckHRESULT(&thisa, v11, (const char *)v10, v9, (unsigned int)ppBackBuffer);
-  v1->field_40030 = v2;
-  v1->field_18_locked_pitch = v2;
+  //v1->field_40030 = v2;
+  //v1->field_18_locked_pitch = v2;
 }
 
 //----- (004A14F4) --------------------------------------------------------
@@ -4355,44 +4295,6 @@
     pBackBuffer4->Restore();
 }
 
-//----- (004A1884) --------------------------------------------------------
-void Render::PresentRect(RECT *a2, RECT *a3)
-{
-  IDirectDrawSurface *pFront; // eax@3
-  HRESULT v4; // eax@5
-  IDirectDrawSurface *pBack; // [sp-1Ch] [bp-1Ch]@3
-  struct tagRECT *v6; // [sp-18h] [bp-18h]@3
-  DWORD v7; // [sp-14h] [bp-14h]@3
-  DDBLTFX *v8; // [sp-10h] [bp-10h]@3
-  const char *v9; // [sp-Ch] [bp-Ch]@3
-  int v10; // [sp-8h] [bp-8h]@3
-  unsigned int v11; // [sp-4h] [bp-4h]@3
-
-  //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
-  {
-    v11 = 0;
-    pFront = (IDirectDrawSurface *)this->pFrontBuffer4;
-    v10 = 2657;
-    v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp";
-    v8 = 0;
-    v7 = DDBLT_WAIT;
-    v6 = a3;
-    pBack = (IDirectDrawSurface *)this->pBackBuffer4;
-  }
-  /*else
-  {
-    v11 = 0;
-    pFront = (IDirectDrawSurface *)this->pFrontBuffer2;
-    v10 = 2653;
-    v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp";
-    v8 = 0;
-    v7 = DDBLT_WAIT;
-    v6 = a3;
-    pBack = (IDirectDrawSurface *)this->pBackBuffer2;
-  }*/
-  ErrD3D(pFront->Blt(a2, pBack, v6, v7, v8));
-}
-
 //----- (004A18F5) --------------------------------------------------------
 void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags)
 {
@@ -4518,7 +4420,7 @@
 {
   if (!uNumD3DSceneBegins++)
   {
-    if (pRenderD3D)
+    //if (pRenderD3D)
     {
       pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0);
       pRenderer->uNumBillboardsToDraw = 0;
@@ -4542,14 +4444,14 @@
         bUsingSpecular = 0;
       }
     }
-    else
+    /*else
     {
       LockRenderSurface((void **)&pTargetSurface, &uTargetSurfacePitch);
       if (pTargetSurface)
         field_18_locked_pitch = uTargetSurfacePitch;
       else
         --uNumD3DSceneBegins;
-    }
+    }*/
   }
 }
 
@@ -4771,7 +4673,7 @@
   /*  v9 = pGame->pLightmapBuilder;
     v65 = v9;
     v10 = v9->std__vector_000004_size;*/
-    if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01)
+    if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related)
     {
       v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0);
       pGame->pLightmapBuilder->DrawLightmaps(/*v11, 0*/);
@@ -5407,7 +5309,7 @@
     else uColor = sCorrectedColor = 0xFF109010;
   }
 
-  if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01)
+  if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related)
   {
       __debugbreak();
       ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false));
@@ -5593,9 +5495,9 @@
     //v9 = v7;
     v28 = dimming_level & 0xFF000000;
     if ( dimming_level & 0xFF000000 )
-      pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Opaque_3;
+      pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Opaque_3;
     else
-      pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Transparent;
+      pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Transparent;
     //v10 = a3;
     pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44;
     pBillboardRenderListD3D[v7].sZValue = pSoftBillboard->sZValue;
@@ -5729,7 +5631,7 @@
       //v6 = v5;
       //v7 = v5;
       v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth);
-      pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1;
+      pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1;
       pBillboardRenderListD3D[v8].field_90 = a2->field_44;
       pBillboardRenderListD3D[v8].sZValue = a2->sZValue;
       pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID;
@@ -5902,7 +5804,7 @@
     v6 = v5;
     v7 = v5;
     v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7));
-    pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1;
+    pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1;
     pBillboardRenderListD3D[v8].field_90 = a2->field_44;
     pBillboardRenderListD3D[v8].sZValue = a2->sZValue;
     pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID;
@@ -6122,9 +6024,9 @@
   pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID;
 
   if (a2->sTintColor & 0xFF000000)
-    pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_3;
+    pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_3;
   else
-    pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent;
+    pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Transparent;
 }
 
 
@@ -6253,7 +6155,7 @@
   v5 = Billboard_ProbablyAddToListAndSortByZOrder(depth);
   pBillboardRenderListD3D[v5].field_90 = 0;
   pBillboardRenderListD3D[v5].sParentBillboardID = -1;
-  pBillboardRenderListD3D[v5].uOpacity = RenderBillboardD3D::Opaque_2;
+  pBillboardRenderListD3D[v5].opacity = RenderBillboardD3D::Opaque_2;
   pBillboardRenderListD3D[v5].pTexture = 0;
   pBillboardRenderListD3D[v5].uNumVertices = a1->uNumVertices;
   pBillboardRenderListD3D[v5].z_order = depth;
@@ -6469,10 +6371,10 @@
       if ( !this->pTargetSurface )
       {
         LockRenderSurface((void **)&this->pTargetSurface, &this->uTargetSurfacePitch);
-        if ( this->pTargetSurface )
+        /*if ( this->pTargetSurface )
         {
           this->field_18_locked_pitch = this->uTargetSurfacePitch;
-        }
+        }*/
         --this->uNumSceneBegins;
       }
     }
@@ -6502,19 +6404,19 @@
       {
         this->pTargetSurface = 0;
         this->uTargetSurfacePitch = 0;
-        this->field_18_locked_pitch = 0;
+        //this->field_18_locked_pitch = 0;
         UnlockBackBuffer();
       }
     }
   }
 }
 
-//----- ( ) --------------------------------------------------------
-unsigned int Render::_4A52F1(unsigned int this_, float a3)
+//----- (004A52F1) --------------------------------------------------------
+void Render::ScreenFade(unsigned int color, float t)
 {
   unsigned int v3; // esi@1
-  double v4; // st7@2
-  double v5; // st7@6
+  //double v4; // st7@2
+  //double v5; // st7@6
   double v6; // st6@6
   unsigned int v7; // eax@6
   double v8; // st5@6
@@ -6549,36 +6451,22 @@
   unsigned int v37; // [sp+8Ch] [bp-14h]@7
   int v38; // [sp+90h] [bp-10h]@7
   double v39; // [sp+94h] [bp-Ch]@6
-  float v40; // [sp+9Ch] [bp-4h]@6
-
-  __debugbreak();
-
-  Render* ecx0 = this;
+  int v40; // [sp+9Ch] [bp-4h]@6
+
   v3 = 0;
 
-  if (!this->pRenderD3D)
-    __debugbreak(); // sw render
-
   //{
-    v4 = a3;
-    if ( a3 <= 1.0 )
-    {
-      if ( v4 < 0.0 )
-        v4 = 0.0;
-    }
-    else
-    {
-      v4 = 1.0;
-    }
-    __debugbreak(); // banker's rounding again
-    a3 = v4 * 255.0;
-    v39 = a3 + 6.7553994e15;
-    LODWORD(v40) = LODWORD(v39);
-    v5 = (double)(signed int)pViewport->uViewportTL_X;
-    v36[0].pos.x = v5;
+  if (t > 1.0f)
+    t = 1.0f;
+  else if (t < 0.0f)
+    t = 0.0f;
+
+    v40 = (char)floorf(t * 255.0f + 0.5f);
+    //v5 = (double)(signed int)pViewport->uViewportTL_X;
+    v36[0].pos.x = pViewport->uViewportTL_X;
     v6 = (double)(signed int)pViewport->uViewportTL_Y;
-    v7 = this_ | (LODWORD(v39) << 24);
-    this_ = pViewport->uViewportBR_Y + 1;
+    v7 = color | (v40 << 24);
+    //this_ = pViewport->uViewportBR_Y + 1;
     v36[0].specular = 0;
     v36[0].pos.y = v6;
     v36[0].diffuse = v7;
@@ -6592,7 +6480,7 @@
     v36[2].specular = 0;
     v36[3].specular = 0;
     v36[0].texcoord.y = 0.0;
-    v36[1].pos.x = v5;
+    v36[1].pos.x = pViewport->uViewportTL_X;
     v8 = (double)(pViewport->uViewportBR_Y + 1);
     v36[1].pos.y = v8;
     v36[1].pos.z = 0.0;
@@ -6719,7 +6607,6 @@
       while ( v32 != 1 );
     }
   }*/
-  return result;
 }
 
 //----- (004A5B81) --------------------------------------------------------
@@ -6904,7 +6791,7 @@
 }
 
 //----- (004A6E7E) --------------------------------------------------------
-void Render::_4A6E7E(unsigned int a2, unsigned int a3, Texture *a4)
+void Render::DrawTranslucent(unsigned int a2, unsigned int a3, Texture *a4)
 {
   //unsigned __int16 *v4; // eax@4
   int v5; // edx@4
@@ -8351,7 +8238,7 @@
     ModalWindow(pGlobalTXT_LocalizationStrings[62], UIMSG_0);// "Might and Magic VII requires your desktop to be in 16bit (32k or 65k) Color mode in order to operate in a window."
     return;
   }*/
-  if ( pRenderer->bWindowMode || !pRenderer->pRenderD3D || pRenderer->pRenderD3D->pAvailableDevices->bIsDeviceCompatible )
+  if ( pRenderer->bWindowMode || pRenderer->pRenderD3D->pAvailableDevices->bIsDeviceCompatible )
   {
     if ( pEventTimer->bPaused )
       dword_6BE364_game_settings_1 |= GAME_SETTINGS_0800;
@@ -8698,8 +8585,8 @@
 
   for (int i = uNumBillboardsToDraw - 1; i >= 0; --i)
   {
-    if (pBillboardRenderListD3D[i].uOpacity != RenderBillboardD3D::NoBlend)
-      SetBillboardBlendOptions(pBillboardRenderListD3D[i].uOpacity);
+    if (pBillboardRenderListD3D[i].opacity != RenderBillboardD3D::NoBlend)
+      SetBillboardBlendOptions(pBillboardRenderListD3D[i].opacity);
     
 
     pRenderD3D->pDevice->SetTexture(0, pBillboardRenderListD3D[i].pTexture);
@@ -9239,4 +9126,471 @@
       return true;
   }
   return false;
+}
+
+
+//----- (0045E03A) --------------------------------------------------------
+unsigned short *Render::MakeScreenshot(signed int width, signed int height)
+{
+  unsigned __int16 *v3; // ebx@1
+  int v4; // edx@7
+  unsigned __int8 v5; // cf@9
+  unsigned int v6; // ecx@9
+  unsigned __int16 *v7; // edi@9
+  int j; // ecx@9
+  unsigned int screen_x; // qax@18
+  HRESULT v14; // eax@21
+  int v15; // edi@29
+  signed __int64 v16; // qax@30
+  signed int v17; // edx@34
+  unsigned __int16 *v18; // edi@36
+  int k; // ecx@36
+  DDSURFACEDESC2 Dst; // [sp+4h] [bp-A0h]@6
+  unsigned __int16 *pPixels; // [sp+80h] [bp-24h]@1
+  float interval_x; // [sp+84h] [bp-20h]@1
+  unsigned __int16 *_this; // [sp+88h] [bp-1Ch]@21
+  float interval_y; // [sp+8Ch] [bp-18h]@1
+  unsigned int screen_y; // [sp+90h] [bp-14h]@17
+  int v28; // [sp+98h] [bp-Ch]@16
+  int v29; // [sp+9Ch] [bp-8h]@15
+
+  interval_x = game_viewport_width / (double)width;
+  interval_y = game_viewport_height / (double)height;
+
+  pPixels = (unsigned __int16 *)malloc(2 * height * width);
+  memset(pPixels, 0 , 2 * height * width);
+
+  v3 = pPixels;
+
+    BeginSceneD3D();
+
+    if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
+      pIndoor->Draw();
+    else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
+      pOutdoor->Draw();
+
+    DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
+    memset(&Dst, 0, 0x7C);
+    Dst.dwSize = sizeof(Dst);
+
+    if ( LockSurface_DDraw4(pBackBuffer4, &Dst, DDLOCK_WAIT) )
+    {
+      for (uint y = 0; y < height; ++y)
+      {
+        for (uint x = 0; x < width; ++x)
+        {
+          //*v3 = pRenderer->ReadPixel16((int)(x* interval_x + 8.0), (int)(y * interval_y + 8.0));//screen_data[screen_y + (int)(x* interval_x + 8.0)];
+
+          if (Dst.ddpfPixelFormat.dwRGBBitCount == 32)
+          {
+            auto p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y/* (int)(y * interval_y + 8.0)*/ * Dst.lPitch;
+            *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255);
+          }
+          else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16)
+          {
+            auto p = (unsigned __int16 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y * Dst.lPitch;
+            *v3 = *p;
+          }
+          else __debugbreak();
+          ++v3;
+        }
+      }
+      ErrD3D(pBackBuffer4->Unlock(0));
+    }
+    else
+    {
+      __debugbreak(); // unrefactored - black screenshot
+      v4 = height;
+      if ( height > 0 )
+      {
+        do
+        {
+          if ( width > 0 )
+          {
+            v5 = width & 1;
+            v6 = (unsigned int)width >> 1;
+            memset(v3, 0, 4 * ((unsigned int)width >> 1));
+            v7 = &v3[2 * v6];
+            for ( j = v5; j; --j )
+            {
+              *v7 = 0;
+              ++v7;
+            }
+            v3 += width;
+          }
+          --v4;
+        }
+        while ( v4 );
+      }
+    }
+
+    
+  /*if (!pRenderer->pRenderD3D)
+  {
+    pRenderer->BeginScene();
+    if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+    {
+      pIndoor->Draw();
+    }
+    else
+    {
+      if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
+        pOutdoor->Draw();
+    }
+    _this = pRenderer->pTargetSurface;
+    v26 = pRenderer->uTargetSurfacePitch;
+    if ( pRenderer->pTargetSurface )
+    {
+      if ( height > 0 )
+      {
+        for ( v29 = 0; v29 < height; ++v29 )
+        {
+          if ( width > 0 )
+          {
+            v15 = v26 * (unsigned __int64)(signed __int64)((double)v29 * v25 + 8.0);
+            for ( v28 = 0; v28 < width; v28++ )
+            {
+              *v3 = _this[v15 + (int)(signed __int64)((double)v28 * v23 + 8.0)];
+              ++v3;
+            }
+          }
+        }
+      }
+    }
+    else
+    {
+      if ( height > 0 )
+      {
+        for ( v17 = height; v17; --v17 )
+        {
+          if ( width > 0 )
+          {
+            memset(v3, 0, 4 * ((unsigned int)width >> 1));
+            v18 = &v3[2 * ((unsigned int)width >> 1)];
+            for ( k = width & 1; k; --k )
+            {
+              *v18 = 0;
+              ++v18;
+            }
+            v3 += width;
+          }
+        }
+      }
+    }
+    pRenderer->EndScene();
+  }*/
+  return pPixels;
+}
+//----- (0045E26C) --------------------------------------------------------
+void Render::SaveScreenshot(const char *pFilename, unsigned int width, unsigned int height)
+{
+  auto pixels = pRenderer->MakeScreenshot(width, height);
+  pRenderer->SavePCXImage(pFilename, pixels, width, height);
+  free(pixels);
+}
+
+void Render::PackScreenshot(unsigned int width, unsigned int height, void *data, unsigned int data_size, unsigned int *out_screenshot_size)
+{
+  auto pixels = pRenderer->MakeScreenshot(150, 112);
+  pRenderer->PackPCXpicture(pixels, 150, 112, data, 1000000, out_screenshot_size);
+  free(pixels);
+}
+
+
+//----- (0046A7C8) --------------------------------------------------------
+int Render::_46A6AC_spell_render_d3d(int a1, int a2, int a3)
+{
+  unsigned int v3; // eax@2
+  unsigned int v5; // eax@2
+  unsigned int v6; // eax@4
+  int v10; // ecx@11
+  unsigned int v12; // [sp+10h] [bp-14h]@1
+  int v15; // [sp+1Ch] [bp-8h]@1
+  unsigned int a1a; // [sp+20h] [bp-4h]@1
+
+  v15 = 0;
+  v12 = GetBillboardDrawListSize();
+  if ( (signed int)GetBillboardDrawListSize() > 0 )
+  {
+    for ( a1a = 0; (signed int)a1a < (signed int)v12; ++a1a )
+    {
+      v3 = GetParentBillboardID(a1a);
+      v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid;
+      if ( PID_TYPE(v5) == OBJECT_Actor)
+      {
+        if ( pBillboardRenderList[v3].sZValue <= (unsigned int)(a3 << 16) )
+        {
+          v6 = PID_ID(v5);
+          if ( pActors[v6].uAIState != Dead && pActors[v6].uAIState != Dying && pActors[v6].uAIState != Removed
+            && pActors[v6].uAIState != Disabled && pActors[v6].uAIState != Summoned )
+          {
+            if ( pGame->pVisInstance->DoesRayIntersectBillboard((double)a3, a1a) )
+            {
+              if ( v15 < a2 - 1 )
+              {
+                __debugbreak();// *(int *)(a1 + 4 * v10) = v6;   ?
+                v10 = v15++;
+                *(int *)(a1 + 4 * v10) = v6;
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+  return v15;
+}
+
+
+
+
+void Render::BeginLightmaps()
+{
+  ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP));
+
+  if (bUsingSpecular)
+    pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE);
+
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03")));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
+}
+
+void Render::EndLightmaps()
+{
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
+
+  if (bUsingSpecular)
+  {
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor));
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
+  }
+}
+
+
+void Render::BeginLightmaps2()
+{
+  if (bUsingSpecular)
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
+ 
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
+
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03")));
+
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+  ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
+}
+
+
+void Render::EndLightmaps2()
+{
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
+
+  if (bUsingSpecular)
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
+}
+
+
+
+//----- (00437C96) --------------------------------------------------------
+void Render::do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff)
+{
+  double v6; // st7@2
+  //IDirect3DDevice3 *v7; // eax@2
+  HRESULT v8; // eax@2
+  std::string v9; // [sp-18h] [bp-60h]@3
+  const char *v10; // [sp-Ch] [bp-54h]@2
+  const char *v11; // [sp-8h] [bp-50h]@2
+  int v12; // [sp-4h] [bp-4Ch]@2
+  RenderVertexD3D3 v13[2]; // [sp+8h] [bp-40h]@2
+
+  //if ( pRenderer->pRenderD3D )
+  {
+    v6 = 0.001 - z_stuff;
+    memcpy(v13, pLineBegin, 0x20u);
+    memcpy(&v13[1], pLineEnd, sizeof(v13[1]));
+    v13[0].pos.z = v6;
+    v13[1].pos.z = v6;
+    v13[0].diffuse = sDiffuseBegin;
+    v13[1].diffuse = sDiffuseEnd;
+    ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
+    ErrD3D(pRenderD3D->pDevice->DrawPrimitive(
+           D3DPT_LINELIST,
+           452,
+           v13,
+           2,
+           16));
+  }
+}
+
+
+void Render::DrawLines(const RenderVertexD3D3 *vertices, unsigned int num_vertices)
+{
+  ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
+  ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_LINELIST,
+              D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
+              (void *)vertices,
+              num_vertices,
+              D3DDP_DONOTLIGHT));
+}
+
+
+void Render::DrawFansTransparent(const RenderVertexD3D3 *vertices, unsigned int num_vertices)
+{
+  //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false));
+  //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, false));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA));
+  
+  ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr));
+  ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
+                D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
+                (void *)vertices,
+                num_vertices,
+                28));
+
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
+  //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE));
+  //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
+}
+
+
+void Render::BeginDecals()
+{
+  // code chunk from 0049C304
+  if (bUsingSpecular)
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
+  ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP));
+
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
+
+  ErrD3D(pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("hwsplat04")));
+}
+
+
+void Render::EndDecals()
+{
+  // code chunk from 0049C304
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
+
+  if (bUsingSpecular)
+    ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE));
+}
+
+
+
+//----- (0049C095) --------------------------------------------------------
+void Render::DrawDecal(Decal *pDecal, float z_bias)
+{
+  signed int v21; // [sp+Ch] [bp-864h]@15
+  RenderVertexD3D3 pVerticesD3D[64]; // [sp+20h] [bp-850h]@6
+
+  if (pDecal->uNumVertices < 3)
+  {
+    Log::Warning(L"Decal has < 3 vertices");
+    return;
+  }
+
+  float color_mult;
+  if ( pDecal->field_C1C & 1 )
+    color_mult = 1.0;
+  else
+    color_mult = pDecal->field_C18->_43B570_get_color_mult_by_time();
+
+  for (uint i = 0; i < pDecal->uNumVertices; ++i)
+  {
+    uint uTint = Render::GetActorTintColor(pDecal->pVertices[i].vWorldViewPosition.x, pDecal->field_C14, 0, 0, nullptr);
+
+    uint uTintR = (uTint >> 16) & 0xFF,
+         uTintG = (uTint >> 8) & 0xFF,
+         uTintB = uTint & 0xFF;
+
+    uint uDecalColorMultR = (pDecal->uColorMultiplier >> 16) & 0xFF,
+         uDecalColorMultG = (pDecal->uColorMultiplier >> 8) & 0xFF,
+         uDecalColorMultB = pDecal->uColorMultiplier & 0xFF;
+
+    uint uFinalR = floorf(uTintR / 255.0 * color_mult * uDecalColorMultR + 0.0f),
+         uFinalG = floorf(uTintG / 255.0 * color_mult * uDecalColorMultG + 0.0f),
+         uFinalB = floorf(uTintB / 255.0 * color_mult * uDecalColorMultB + 0.0f);
+
+
+    float v15;
+    if (fabs(z_bias) < 1e-5)
+      v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0);
+     else
+     {
+      v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0) - z_bias;
+      if (v15 < 0.000099999997)
+        v15 = 0.000099999997;
+     }
+
+    pVerticesD3D[i].pos.z = v15;
+
+    pVerticesD3D[i].pos.x = pDecal->pVertices[i].vWorldViewProjX;
+    pVerticesD3D[i].pos.y = pDecal->pVertices[i].vWorldViewProjY;
+    pVerticesD3D[i].texcoord.x = pDecal->pVertices[i].u;
+    pVerticesD3D[i].texcoord.y = pDecal->pVertices[i].v;
+    pVerticesD3D[i].diffuse = (uFinalR << 16) | (uFinalG << 8) | uFinalB;
+    pVerticesD3D[i].specular = 0;
+    pVerticesD3D[i].rhw = 1.0 / pDecal->pVertices[i].vWorldViewPosition.x;
+  }
+
+  if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
+    v21 = D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS;
+  else
+    v21 = D3DDP_DONOTLIGHT;
+
+  ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
+            D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
+            pVerticesD3D,
+            pDecal->uNumVertices,
+            v21));
+}
+
+
+void Render::DrawSpecialEffectsQuad(const RenderVertexD3D3 *vertices, IDirect3DTexture2 *texture)
+{
+  ErrD3D(pRenderD3D->pDevice->SetTexture(0, texture));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS));
+  ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
+                                     D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1,
+                                     (void *)vertices, 4, 28));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
+  ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS));
 }
\ No newline at end of file
--- a/Render.h	Fri Jan 10 17:42:37 2014 +0600
+++ b/Render.h	Fri Jan 10 17:42:57 2014 +0600
@@ -198,20 +198,27 @@
 #pragma pack(push, 1)
 struct RenderBillboardD3D
 {
-  enum OpacityType: signed __int32
+  inline RenderBillboardD3D():
+    opacity(Transparent),
+    field_90(-1),
+    sParentBillboardID(-1),
+    uNumVertices(4)
+  {}
+
+  enum OpacityType: unsigned __int32
   {
     Transparent = 0,
     Opaque_1 = 1,
     Opaque_2 = 2,
     Opaque_3 = 3,
-    NoBlend = -1
+    NoBlend = 0xFFFFFFFF
   };
 
   IDirect3DTexture2 *pTexture;
   unsigned int uNumVertices;
   RenderVertexD3D3 pQuads[4];
   float z_order;
-  OpacityType uOpacity;
+  OpacityType opacity;
   int field_90;
   int sZValue;
   signed int sParentBillboardID;
@@ -283,35 +290,21 @@
   bool Initialize(OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting);
 
 
-  bool IsColorKeySupported(IDirectDraw4 *);
-  void _stub_49EBF1();
   void ClearBlack();
   void PresentBlackScreen();
   void SavePCXScreenshot();
   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, unsigned short* picture_data, int width, int height);
   void ClearTarget(unsigned int uColor);
-  void Release2();
   void Present();
-  void _49FD3A();
+  void _49FD3A_fullscreen();
   void CreateZBuffer();
   void Release();
-  void CreateSomeTexture();
   bool InitializeFullscreen();
   bool SwitchToWindow();
   void RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor);
   void ClearZBuffer(int a2, int a3);
   void SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW);
-  void ParseTargetPixelFormat();
   bool LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags);
-  void CreateDirectDraw();
-  void SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen);
-  void SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP);
-  void CreateFrontBuffer();
-  void CreateBackBuffer();
-  void CreateDirectDrawPrimarySurface();
-  void CreateClipper(HWND a2);
   void GetTargetPixelFormat(DDPIXELFORMAT *pOut);
   void LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow);
   void UnlockBackBuffer();
@@ -319,12 +312,8 @@
   void UnlockFrontBuffer();
   void RestoreFrontBuffer();
   void RestoreBackBuffer();
-  void PresentRect(RECT *a2, RECT *a3);
   void BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags);
   void BltBackToFontFast(int a2, int a3, RECT *a4);
-  unsigned int Billboard_ProbablyAddToListAndSortByZOrder(float z);
-  unsigned int GetBillboardDrawListSize();
-  unsigned int GetParentBillboardID(unsigned int uBillboardID);
   void BeginSceneD3D();
   void DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
   unsigned int GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6);
@@ -336,16 +325,14 @@
   void DrawIndoorSky(unsigned int uNumVertices, unsigned int uFaceID);
   void MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle);
   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);
   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);
   bool MoveSpriteToDevice(Sprite *pSprite);
   void BeginScene();
   void EndScene();
-  unsigned int _4A52F1(unsigned int this_, float a3);
+  void ScreenFade(unsigned int color, float t);
   void SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW);
   void ResetTextureClipRect();
   void DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4);
@@ -364,7 +351,7 @@
   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);
   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 DrawTranslucent(unsigned int a2, unsigned int a3, struct Texture *a4);
   void DrawBuildingsD3D();
   //struct BSPModel *DrawBuildingsSW();
   //int OnOutdoorRedrawSW();
@@ -380,99 +367,101 @@
   //void ExecOutdoorDrawSW();
   void ChangeBetweenWinFullscreenModes();
   void DrawBillboardList_BLV();
-  void __cdecl sub_4A19B0();
+  bool AreRenderSurfacesOk();
+  bool IsGammaSupported();
+  void SaveScreenshot(const char *pFilename, unsigned int width, unsigned int height);
+  void PackScreenshot(unsigned int width, unsigned int height, void *out_data, unsigned int data_size, unsigned int *screenshot_size);
+  int _46A6AC_spell_render_d3d(int a1, int a2, int a3);
+
+  void BeginLightmaps();
+  void EndLightmaps();  
+  void BeginLightmaps2();
+  void EndLightmaps2();
+  bool DrawLightmap(struct Lightmap *pLightmap, struct Vec3_float_ *pColorMult, float z_bias);
+
+  void BeginDecals();
+  void EndDecals();
+  void DrawDecal(struct Decal *pDecal, float z_bias);
+  
+  void do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff);
+  void DrawLines(const RenderVertexD3D3 *vertices, unsigned int num_vertices);
+  void DrawFansTransparent(const RenderVertexD3D3 *vertices, unsigned int num_vertices);
+  void DrawSpecialEffectsQuad(const RenderVertexD3D3 *vertices, IDirect3DTexture2 *texture);
+
+  void am_Blt_Copy(RECT *pSrcRect, POINT *pTargetXY, int a3);
+  void am_Blt_Chroma(RECT *pSrcRect, POINT *pTargetPoint, int a3, int blend_mode);
 
 
-  //unsigned int bUserDirect3D;
-  //unsigned int bStartInWindow;
-  unsigned int uDesiredDirect3DDevice;
-  unsigned int uAcquiredDirect3DDevice;
-  int field_10;
-  int field_14;
-  int field_18_locked_pitch;
-  int raster_clip_x;
-  int raster_clip_y;    // clipping rect for raster ops
-  int raster_clip_z;    //    like RasterLine2D for (mini)map
-  int raster_clip_w;
-  __int16 unused_2C[65536];
-  __int16 unused_2002C[65536];
-  int field_4002C;
-  int field_40030;
-  int *pActiveZBuffer;
-  int *pDefaultZBuffer;
-  int field_4003C;
-  int field_40040;
-  int field_40044;
-  int field_40048;
-  int field_4004C;
-  //HWND hWnd;
-  OSWindow *window;
-  int field_40054;
-  unsigned int bWindowMode;
-  int field_4005C[11];
-  RenderD3D *pRenderD3D;
-  IDirectDraw4 *pDirectDraw4;
-  IDirectDrawSurface4 *pFrontBuffer4;
-  IDirectDrawSurface4 *pBackBuffer4;
-  IDirectDrawSurface4 *pColorKeySurface4;
-  //IDirectDraw2 *pDirectDraw2;
-  //IDirectDrawSurface2 *pFrontBuffer2;
-  //IDirectDrawSurface2 *pBackBuffer2;
-  //IDirectDrawSurface2 *pSomeSurface2;
-  DDPIXELFORMAT ddpfPrimarySuface;
-  unsigned int uTargetRBits;
-  unsigned int uTargetGBits;
-  unsigned int uTargetBBits;
-  unsigned int uTargetRMask;
-  unsigned int uTargetGMask;
-  unsigned int uTargetBMask;
-  unsigned int uNumSceneBegins;
-  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 uNumD3DSceneBegins;
-  int using_software_screen_buffer;
-  RenderHWLContainer pD3DBitmaps;
-  RenderHWLContainer pD3DSprites;
-  unsigned int bUseColoredLights;
-  unsigned int bRequiredTextureStagesAvailable;
-  unsigned int bTinting;
-  unsigned int uLevelOfDetail;
-  unsigned int uMaxDeviceTextureDim;
-  unsigned int uMinDeviceTextureDim;
-  int field_10365C;
-  unsigned int bUsingSpecular;
-  uint32_t uFogColor;
-  int field_103668;
-  unsigned int pHDWaterBitmapIDs[7];
-  char field_103688[32];
-  int hd_water_current_frame;
-  int hd_water_tile_id;
-  IDirectDrawSurface4 *pSurface;
-  IDirect3DTexture2 *pTexture;
-  //int field_1036B8;
-  //int _gpu_memory_used;
-  void ( *pBeforePresentFunction)();
-  int field_1036C4;
-  uint32_t bFogEnabled;
-  int field_1036CC;
-  RenderBillboardD3D pBillboardRenderListD3D[1000];
-  unsigned int uNumBillboardsToDraw;
-  int field_129834;
-  //unsigned int uCurrentlyLockedSurfacePitch;
-  //unsigned __int16 *pCurrentlyLockedSurfaceDataPtr;
-  //void             *pCurrentlyLockedSoftSurface;
+  protected: unsigned int uDesiredDirect3DDevice;
+  protected: int raster_clip_x;
+  protected: int raster_clip_y;    // clipping rect for raster ops
+  protected: int raster_clip_z;    //    like RasterLine2D for (mini)map
+  protected: int raster_clip_w;
+  public: int *pActiveZBuffer;
+  protected: int *pDefaultZBuffer;
+  protected: OSWindow *window;
+  protected: unsigned int bWindowMode;
+  protected: RenderD3D *pRenderD3D;
+  public: IDirectDraw4 *pDirectDraw4;
+  public: IDirectDrawSurface4 *pFrontBuffer4;
+  public: IDirectDrawSurface4 *pBackBuffer4;
+  protected: DDPIXELFORMAT ddpfPrimarySuface;
+  protected: unsigned int uTargetRBits;
+  protected: unsigned int uTargetGBits;
+  protected: unsigned int uTargetBBits;
+  protected: unsigned int uTargetRMask;
+  protected: unsigned int uTargetGMask;
+  protected: unsigned int uTargetBMask;
+  protected: unsigned int uNumSceneBegins;
+  protected: unsigned __int32 *pTargetSurface_unaligned;
+  public: void        *pTargetSurface;
+  public: unsigned int uTargetSurfacePitch;
+  protected: unsigned int uClipY;
+  protected: unsigned int uClipX;
+  protected: unsigned int uClipW;
+  protected: unsigned int uClipZ;
+  protected: unsigned int bClip;
+  protected: unsigned int uNumD3DSceneBegins;
+  protected: int using_software_screen_buffer;
+  protected: RenderHWLContainer pD3DBitmaps;
+  protected: RenderHWLContainer pD3DSprites;
+  public: unsigned int bUseColoredLights;
+  protected: unsigned int bRequiredTextureStagesAvailable;
+  public: unsigned int bTinting;
+  protected: unsigned int uLevelOfDetail;
+  protected: unsigned int uMaxDeviceTextureDim;
+  protected: unsigned int uMinDeviceTextureDim;
+  public: unsigned int bUsingSpecular;
+  public: uint32_t uFogColor;
+  public: unsigned int pHDWaterBitmapIDs[7];
+  public: int hd_water_current_frame;
+  public: int hd_water_tile_id;
+  public: void (*pBeforePresentFunction)();
+  public: uint32_t bFogEnabled;
+  public: RenderBillboardD3D pBillboardRenderListD3D[1000];
+  public: unsigned int uNumBillboardsToDraw;
+
 
   protected:
-  void DoRenderBillboards_D3D();
-  void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1);
-  void DrawBorderTiles(struct Polygon *poly);
+    void DoRenderBillboards_D3D();
+    void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1);
+    void DrawBorderTiles(struct Polygon *poly);
+    unsigned short *MakeScreenshot(signed int width, signed int height);
+    bool CheckTextureStages();
+    void ParseTargetPixelFormat();
+    void TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int dimming_level, RenderBillboard *pBillboard);
+    void CreateDirectDraw();
+    void SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen);
+    void SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP);
+    void CreateFrontBuffer();
+    void CreateBackBuffer();
+    void CreateDirectDrawPrimarySurface();
+    void CreateClipper(HWND a2);
+    void PackPCXpicture(unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size);
+    void SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height);
+    unsigned int Billboard_ProbablyAddToListAndSortByZOrder(float z);
+    unsigned int GetParentBillboardID(unsigned int uBillboardID);
+    unsigned int GetBillboardDrawListSize();
 
   public:
   inline void WritePixel16(int x, int y, unsigned __int16 color)
@@ -509,12 +498,16 @@
   inline void ToggleTint()          {bTinting = !bTinting;}
   inline void ToggleColoredLights() {bUseColoredLights = !bUseColoredLights;}
 
+  inline unsigned int GetRenderWidth() {return window->GetWidth();}
+  inline unsigned int GetRenderHeight() {return window->GetHeight();}
+
   inline void Sub01()
   {
     if (pRenderD3D && !bWindowMode)
-      _49FD3A();
+      _49FD3A_fullscreen();
   }
 
+  friend void Present_NoColorKey();
 
   //int windowed_mode_width;
   //int windowed_mode_height;
--- a/SaveLoad.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/SaveLoad.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -229,7 +229,7 @@
 //----- (0045F469) --------------------------------------------------------
 void SaveGame( bool IsAutoSAve, bool NotSaveWorld )
 {
-  unsigned short *pScreenshot; // edi@5
+  //unsigned short *pScreenshot; // edi@5
   int text_pos; // eax@6
   FILE *pLLoidFile; // edi@24
   char* compressed_buf; // edi@30
@@ -278,10 +278,10 @@
     pIndoor->stru1.uLastVisitDay = pParty->uTimePlayed;
   else
     pOutdoor->loc_time.uLastVisitDay = pParty->uTimePlayed;
-  pScreenshot = MakeScreenshot(150, 112);
+
+  pRenderer->PackScreenshot(150, 112, uncompressed_buff, 1000000, &pLodDirectory.uDataSize);
   strcpy(pLodDirectory.pFilename, "image.pcx");
-  pRenderer->PackPCXpicture(pScreenshot, 150, 112, uncompressed_buff, 1000000, &pLodDirectory.uDataSize);
-  free(pScreenshot);
+
   if (pCurrentScreen == SCREEN_SAVEGAME)
   {
     pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave));
@@ -556,7 +556,7 @@
   viewparams->bRedrawGameUI = 1;
   for (uint i = 0; i < 45; i++)
     pSavegameThumbnails[i].Release();
-  //while ( (signed int)v3 < (signed int)&unk_6A0758 );
+
   if ( bNotArena )
     pNew_LOD->_4621A7();
   else
@@ -665,166 +665,4 @@
   }
   free(pSave);
 }
-//----- (0045E03A) --------------------------------------------------------
-unsigned short *MakeScreenshot( signed int width, signed int height )
-{
-  unsigned __int16 *v3; // ebx@1
-  int v4; // edx@7
-  unsigned __int8 v5; // cf@9
-  unsigned int v6; // ecx@9
-  unsigned __int16 *v7; // edi@9
-  int j; // ecx@9
-  unsigned int screen_x; // qax@18
-  HRESULT v14; // eax@21
-  int v15; // edi@29
-  signed __int64 v16; // qax@30
-  signed int v17; // edx@34
-  unsigned __int16 *v18; // edi@36
-  int k; // ecx@36
-  DDSURFACEDESC2 Dst; // [sp+4h] [bp-A0h]@6
-  unsigned __int16 *pPixels; // [sp+80h] [bp-24h]@1
-  float interval_x; // [sp+84h] [bp-20h]@1
-  unsigned __int16 *_this; // [sp+88h] [bp-1Ch]@21
-  float interval_y; // [sp+8Ch] [bp-18h]@1
-  unsigned int screen_y; // [sp+90h] [bp-14h]@17
-  int v28; // [sp+98h] [bp-Ch]@16
-  int v29; // [sp+9Ch] [bp-8h]@15
 
-  interval_x = game_viewport_width / (double)width;
-  interval_y = game_viewport_height / (double)height;
-
-  pPixels = (unsigned __int16 *)malloc(2 * height * width);
-  memset(pPixels, 0 , 2 * height * width);
-
-  v3 = pPixels;
-  if (!pRenderer->pRenderD3D)
-    __debugbreak();
-
-    pRenderer->BeginSceneD3D();
-
-    if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
-      pIndoor->Draw();
-    else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
-      pOutdoor->Draw();
-
-    pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
-    memset(&Dst, 0, 0x7C);
-    Dst.dwSize = sizeof(Dst);
-
-    if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) )
-    {
-      for (uint y = 0; y < height; ++y)
-      {
-        for (uint x = 0; x < width; ++x)
-        {
-          //*v3 = pRenderer->ReadPixel16((int)(x* interval_x + 8.0), (int)(y * interval_y + 8.0));//screen_data[screen_y + (int)(x* interval_x + 8.0)];
-
-          if (Dst.ddpfPixelFormat.dwRGBBitCount == 32)
-          {
-            auto p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y/* (int)(y * interval_y + 8.0)*/ * Dst.lPitch;
-            *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255);
-          }
-          else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16)
-          {
-            auto p = (unsigned __int16 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y * Dst.lPitch;
-            *v3 = *p;
-          }
-          else __debugbreak();
-          ++v3;
-        }
-      }
-      ErrD3D(pRenderer->pBackBuffer4->Unlock(0));
-    }
-    else
-    {
-      __debugbreak(); // unrefactored
-      v4 = height;
-      if ( height > 0 )
-      {
-        do
-        {
-          if ( width > 0 )
-          {
-            v5 = width & 1;
-            v6 = (unsigned int)width >> 1;
-            memset(v3, 0, 4 * ((unsigned int)width >> 1));
-            v7 = &v3[2 * v6];
-            for ( j = v5; j; --j )
-            {
-              *v7 = 0;
-              ++v7;
-            }
-            v3 += width;
-          }
-          --v4;
-        }
-        while ( v4 );
-      }
-    }
-
-    
-  /*if (!pRenderer->pRenderD3D)
-  {
-    pRenderer->BeginScene();
-    if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-    {
-      pIndoor->Draw();
-    }
-    else
-    {
-      if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
-        pOutdoor->Draw();
-    }
-    _this = pRenderer->pTargetSurface;
-    v26 = pRenderer->uTargetSurfacePitch;
-    if ( pRenderer->pTargetSurface )
-    {
-      if ( height > 0 )
-      {
-        for ( v29 = 0; v29 < height; ++v29 )
-        {
-          if ( width > 0 )
-          {
-            v15 = v26 * (unsigned __int64)(signed __int64)((double)v29 * v25 + 8.0);
-            for ( v28 = 0; v28 < width; v28++ )
-            {
-              *v3 = _this[v15 + (int)(signed __int64)((double)v28 * v23 + 8.0)];
-              ++v3;
-            }
-          }
-        }
-      }
-    }
-    else
-    {
-      if ( height > 0 )
-      {
-        for ( v17 = height; v17; --v17 )
-        {
-          if ( width > 0 )
-          {
-            memset(v3, 0, 4 * ((unsigned int)width >> 1));
-            v18 = &v3[2 * ((unsigned int)width >> 1)];
-            for ( k = width & 1; k; --k )
-            {
-              *v18 = 0;
-              ++v18;
-            }
-            v3 += width;
-          }
-        }
-      }
-    }
-    pRenderer->EndScene();
-  }*/
-  return pPixels;
-}
-//----- (0045E26C) --------------------------------------------------------
-void  SaveScreenshot(const char *pFilename)
-{
-  unsigned short *screenshot; // esi@1
-
-  screenshot = MakeScreenshot(92, 68);
-  pRenderer->SavePCXImage(pFilename, screenshot, 92, 68);
-  free(screenshot);
-}
\ No newline at end of file
--- a/UI/Books/UIMapBook.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/UI/Books/UIMapBook.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -528,8 +528,8 @@
         v54 = ((unsigned __int64)((signed int)v93 * (signed __int64)viewparams->uMapBookMapZoom) >> 16) + screenCenter_X;
         v97 = (const void *)((unsigned __int64)(screenHeight * (signed __int64)viewparams->uMapBookMapZoom) >> 16);
         v55 = screenCenterY - (int)v97;
-        if ( v54 >= pRenderer->raster_clip_x && v54 <= pRenderer->raster_clip_z
-          && v55 >= pRenderer->raster_clip_y && v55 <= pRenderer->raster_clip_w )
+        //if ( v54 >= pRenderer->raster_clip_x && v54 <= pRenderer->raster_clip_z
+        //  && v55 >= pRenderer->raster_clip_y && v55 <= pRenderer->raster_clip_w )
         {
           if ( viewparams->uMapBookMapZoom > 512 )
           {
--- a/UI/UICharacter.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/UI/UICharacter.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -191,8 +191,8 @@
 //int paperdoll_array_51132C[165];
 unsigned int papredoll_dlaus[5];
 unsigned int papredoll_dlads[4];
-int papredoll_flying_feet[777]; // idb
-int paperdoll_boots_texture[4][6];//0x511638
+int papredoll_flying_feet[22]; // 005115E0
+int paperdoll_boots_texture[4][6];//511638
 int paperdoll_cloak_collar_texture[4][10]; // weak
 int paperdoll_cloak_texture[4][10];
 int paperdoll_helm_texture[2][16]; //511698
--- a/UI/UIOptions.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/UI/UIOptions.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -153,7 +153,7 @@
   GUIWindow msg_window; // [sp+8h] [bp-54h]@3
 
   pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(optvid_base_texture_id));//draw base texture
-  if ( !pRenderer->bWindowMode && GammaController::IsGammaSupported() )
+  //if ( !pRenderer->bWindowMode && pRenderer->IsGammaSupported() )
   {
     pRenderer->DrawTextureIndexed(17 * uGammaPos + 42, 162, pIcons_LOD->GetTexture(pTextureIDs_GammaPositions[uGammaPos]));
     pRenderer->DrawTextureRGB(274, 169, &stru_506E40);//review_window
@@ -166,13 +166,13 @@
     msg_window.DrawTitleText(pFontSmallnum, 0, 0, ui_gamemenu_video_gamma_title_color, pGlobalTXT_LocalizationStrings[226], 3); // "Gamma controls the relative ""brightness"" of the game.  May vary depending on your monitor."
   }
 
-  if (!pRenderer->pRenderD3D)//if software
+  /*if (!pRenderer->pRenderD3D)
   {
     pRenderer->DrawTextureIndexed(20, 281, pIcons_LOD->GetTexture(not_available_bloodsplats_texture_id));
     pRenderer->DrawTextureIndexed(20, 303, pIcons_LOD->GetTexture(not_available_us_colored_lights_texture_id));
     pRenderer->DrawTextureIndexed(20, 325, pIcons_LOD->GetTexture(not_available_tinting_texture_id));
   }
-  else
+  else*/
   {
     if (pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS)
       pRenderer->DrawTextureIndexed(20, 281, pIcons_LOD->GetTexture(bloodsplats_texture_id));
--- a/UI/UIPopup.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/UI/UIPopup.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -527,7 +527,7 @@
   pRenderer->RasterLine2D(v106.uViewportX - 1, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportY - 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 + 129, v106.uViewportY - 1, v106.uViewportX + 129, v106.uViewportW + 1, Color16(0xE1u, 255, 0x9Bu));//  
-  if ( pRenderer->pRenderD3D )
+  //if ( pRenderer->pRenderD3D )
   {
     v106.uScreenSpaceY = v115 + v106.uViewportY + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uBufferHeight;
     memset(&Dst, 0, 0x64u);
@@ -558,14 +558,14 @@
       dst_z = v106.uViewportZ;
     if (dst_w > v106.uViewportW)
       dst_w = v106.uViewportW;
-    pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY, pRenderer->uTargetBMask | pRenderer->uTargetGMask);
-    pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY, pRenderer->uTargetBMask | pRenderer->uTargetGMask);
+    pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY, 0x7FF);
+    pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY, 0x7FF);
     v84.left = v106.uViewportX;
     v84.top = v106.uViewportY;
     v84.right = v106.uViewportZ;
     v84.bottom = v106.uViewportW;
     ErrD3D(pRenderer->pBackBuffer4->Blt(&v84, 0, 0, 16778240u, &Dst));
-    if ( pRenderer->uTargetGBits == 5 )
+    /*if ( pRenderer->uTargetGBits == 5 )
     {
       __debugbreak(); // no monster popup for r5g5b5 will be
       memset(&pDesc, 0, 0x7Cu);
@@ -612,7 +612,7 @@
         pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].pTextureSurface->Unlock(0);
       }
     }
-    else
+    else*/
     {
       memset(&pDesc, 0, 0x7Cu);
       pDesc.dwSize = 124;
@@ -640,12 +640,12 @@
       }
     }
   }
-  else
+  /*else
   {
     pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY, 0);
     if ( v10->pHwSpriteIDs[0] >= 0 )
       pSprites_LOD->pSpriteHeaders[v10->pHwSpriteIDs[0]].DrawSprite_sw(&v106, 0);
-  }
+  }*/
 //name and profession
   if ( pActors[uActorID].sNPC_ID )
   {
@@ -1309,7 +1309,7 @@
   {
     pMouse->GetClickPos(&pX, &pY);
   }
-  if ( pRenderer->bWindowMode )
+  //if ( pRenderer->bWindowMode )
   {
     GetCursorPos(&Point);
     ScreenToClient(window->GetApiHandle(), &Point);
@@ -1428,18 +1428,18 @@
         if ( (signed int)pX <= 320 )
           popup_window.uFrameX = pX + 30;
         popup_window.uFrameY = 40;
-        if ( pRenderer->pRenderD3D )
-          LOWORD(v5) = pGame->pVisInstance->get_picked_object_zbuf_val();
-        else
-          v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];
+        //if ( pRenderer->pRenderD3D )
+          v5 = pGame->pVisInstance->get_picked_object_zbuf_val();
+        /*else
+          v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];*/
         if (PID_TYPE((unsigned __int16)v5) == OBJECT_Actor)
         {
-          if ( pRenderer->uNumSceneBegins )
+          /*if ( pRenderer->uNumSceneBegins )
           {
             popup_window.DrawMessageBox(1);
             MonsterPopup_Draw(PID_ID((unsigned __int16)v5), &popup_window);
           }
-          else
+          else*/
           {
             pRenderer->BeginScene();
             popup_window.DrawMessageBox(1);
--- a/UI/UiGame.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/UI/UiGame.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -1139,7 +1139,7 @@
 }
 // 5C35BC: using guessed type int bForceDrawFooter;
 //----- (00420EFF) --------------------------------------------------------
-void  GameUI_WritePointedObjectStatusString()
+void GameUI_WritePointedObjectStatusString()
 {
   int v1; // ebx@6
   GUIWindow *pWindow; // edi@7
@@ -1173,7 +1173,7 @@
     //() ----------------------------------
     if ( pCurrentScreen == SCREEN_GAME )
     {
-      if ( pRenderer->pRenderD3D )  // inlined mm8::4C1E01
+      //if ( pRenderer->pRenderD3D )  // inlined mm8::4C1E01
       {
         v18 = pGame->pVisInstance->get_picked_object_zbuf_val();
         if ( pX < (unsigned int)pViewport->uScreen_TL_X || pX > (unsigned int)pViewport->uScreen_BR_X
@@ -1194,8 +1194,8 @@
           return;
         }
       }
-      else
-        v18 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];
+      /*else
+        v18 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];*/
       pMouse->uPointingObjectID = (unsigned __int16)v18;
       v19 = (signed)PID_ID(v18);
       //For Items------------------------------------
@@ -1663,10 +1663,10 @@
         v7 = pIcons_LOD->GetTexture(pIconsFrameTable->GetFrame(uIconIdx_FlySpell, v0)->uTextureID);
       else
         v7 = pIcons_LOD->GetTexture(pIconsFrameTable->GetFrame(uIconIdx_FlySpell, 0)->uTextureID);
-      if ( pRenderer->pRenderD3D )
+      //if ( pRenderer->pRenderD3D )
         pRenderer->DrawTextureIndexed(8, 8, v7);
-      else
-        pRenderer->DrawTextureTransparent(8, 8, v7);
+      /*else
+        pRenderer->DrawTextureTransparent(8, 8, v7);*/
     }
     if ( pParty->WaterWalkActive() )
     {
@@ -1674,10 +1674,10 @@
         v9 = pIcons_LOD->GetTexture(pIconsFrameTable->GetFrame(uIconIdx_WaterWalk, v0)->uTextureID);
       else
         v9 = pIcons_LOD->GetTexture(pIconsFrameTable->GetFrame(uIconIdx_WaterWalk, 0)->uTextureID);
-      if ( pRenderer->pRenderD3D )
+      //if ( pRenderer->pRenderD3D )
         pRenderer->DrawTextureIndexed(396, 8, v9);
-      else
-        pRenderer->DrawTextureTransparent(396, 8, v9);
+      /*else
+        pRenderer->DrawTextureTransparent(396, 8, v9);*/
     }
   }
   for (uint i = 0; i < 4; ++i)
@@ -1719,7 +1719,7 @@
     {
       pPortrait = pTexture_PlayerFaceEradicated;
       if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime )
-        pRenderer->_4A6E7E(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i], 388, pPortrait);
+        pRenderer->DrawTranslucent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i], 388, pPortrait);
       else
         pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 1, 388, pPortrait);
       if ( pPlayer->pPlayerBuffs[PLAYER_BUFF_BLESS].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_HASTE].uExpireTime
@@ -1732,7 +1732,7 @@
     {
       pPortrait = pTexture_PlayerFaceDead;
       if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime )
-        pRenderer->_4A6E7E(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i], 388, pPortrait);
+        pRenderer->DrawTranslucent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i], 388, pPortrait);
       else
         pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 1, 388, pPortrait);
       if ( pPlayer->pPlayerBuffs[PLAYER_BUFF_BLESS].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_HASTE].uExpireTime
@@ -1759,7 +1759,7 @@
       pPlayer->field_1AA2 = pFrame->uTextureID - 1;
       pPortrait = (Texture *)pTextures_PlayerFaces[i][pPlayer->field_1AA2];//pFace = (Texture *)pTextures_PlayerFaces[i][pFrame->uTextureID];
       if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime )
-        pRenderer->_4A6E7E(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i], 388, pPortrait);
+        pRenderer->DrawTranslucent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i], 388, pPortrait);
       else
         pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 1, 388, pPortrait);
       if ( pPlayer->pPlayerBuffs[PLAYER_BUFF_BLESS].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_HASTE].uExpireTime
@@ -2042,8 +2042,8 @@
         //if (uWizardEyeSkillLevel == 1
         pPoint_X = uCenterX + ((unsigned __int64)((pSpriteObjects[i].vPosition.x - pParty->vPosition.x) * (signed __int64)uZoom) >> 16);
         pPoint_Y = uCenterY - ((signed __int64)((pSpriteObjects[i].vPosition.y - pParty->vPosition.y) * (signed __int64)uZoom) >> 16);
-        if ( pPoint_X >= pRenderer->raster_clip_x && pPoint_X <= pRenderer->raster_clip_z &&
-             pPoint_Y >= pRenderer->raster_clip_y && pPoint_Y <= pRenderer->raster_clip_w)
+        //if ( pPoint_X >= pRenderer->raster_clip_x && pPoint_X <= pRenderer->raster_clip_z &&
+        //     pPoint_Y >= pRenderer->raster_clip_y && pPoint_Y <= pRenderer->raster_clip_w)
         {
           if (pObjectList->pObjects[pSpriteObjects[i].uObjectDescID].uFlags & OBJECT_DESC_UNPICKABLE)
           {
@@ -2072,8 +2072,8 @@
       {
         pPoint_X = uCenterX + ((unsigned __int64)(( pActors[i].vPosition.x - pParty->vPosition.x) * (signed __int64)(signed int)uZoom) >> 16);
         pPoint_Y = uCenterY - ((unsigned __int64)(( pActors[i].vPosition.y - pParty->vPosition.y) * (signed __int64)(signed int)uZoom) >> 16);
-        if ( pPoint_X >= pRenderer->raster_clip_x && pPoint_X <= pRenderer->raster_clip_z
-          && pPoint_Y >= pRenderer->raster_clip_y && pPoint_Y <= pRenderer->raster_clip_w )
+        //if ( pPoint_X >= pRenderer->raster_clip_x && pPoint_X <= pRenderer->raster_clip_z
+        //  && pPoint_Y >= pRenderer->raster_clip_y && pPoint_Y <= pRenderer->raster_clip_w )
         {
           pColor = ui_game_minimap_actor_friendly_color;
           if ( BYTE3(pActors[i].uAttributes) & 1 )
@@ -2102,8 +2102,8 @@
       {
         pPoint_X = uCenterX + ((unsigned __int64)((pLevelDecorations[i].vPosition.x - pParty->vPosition.x) * (signed __int64)(signed int)uZoom) >> 16);
         pPoint_Y = uCenterY - ((unsigned __int64)((pLevelDecorations[i].vPosition.y - pParty->vPosition.y) * (signed __int64)(signed int)uZoom) >> 16);
-        if ( pPoint_X >= pRenderer->raster_clip_x && pPoint_X <= pRenderer->raster_clip_z
-          && pPoint_Y >= pRenderer->raster_clip_y && pPoint_Y <= pRenderer->raster_clip_w )
+        //if ( pPoint_X >= pRenderer->raster_clip_x && pPoint_X <= pRenderer->raster_clip_z
+        //  && pPoint_Y >= pRenderer->raster_clip_y && pPoint_Y <= pRenderer->raster_clip_w )
         {
           if ( (signed int)uZoom > 512 )
           {
--- a/VideoPlayer.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/VideoPlayer.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -353,16 +353,16 @@
     OpenGlobalMovie(pName, 0, ScreenSizeFlag);
     bPlayingMovie = 1;
 	field_44 = v4;
-    if ( pRenderer->pRenderD3D )
+    //if ( pRenderer->pRenderD3D )
     {
       pRenderer->ClearTarget(0);
     }
-    else
+   /* else
     {
       pRenderer->BeginScene();
       pRenderer->ClearTarget(0);
       pRenderer->EndScene();
-    }
+    }*/
     pCurrentScreen = SCREEN_VIDEO;
 
 	auto hwnd = pVideoPlayer->window->GetApiHandle();
--- a/Viewport.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/Viewport.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -276,10 +276,10 @@
   int clickable_distance = 512;
 
   v1 = pMouse->GetCursorPos(&a2);
-  if ( pRenderer->pRenderD3D )
+  //if ( pRenderer->pRenderD3D )
     v0 = pGame->pVisInstance->get_picked_object_zbuf_val();
-  else
-    v0 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[v1->y]];
+  //else
+  //  v0 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[v1->y]];
 
   if ( PID_TYPE(v0) == OBJECT_Item)
   {
--- a/_deleted.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/_deleted.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -14405,4 +14405,243 @@
   }
 }
 
+
+//----- (004A80DC) --------------------------------------------------------
+void stru6::_4A80DC_implosion_particle_sw(SpriteObject *a2)
+{
+  signed int v3; // ebx@1
+  Particle_sw local_0; // [sp+Ch] [bp-68h]@1
+
+  memset(&local_0, 0, 0x68u);
+  local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_1;
+  local_0.uDiffuse = 0x7E7E7E;
+  local_0.timeToLive = (rand() & 0x7F) + 128;
+  local_0.uTextureID = uTextureID_effpar1;
+  v3 = 8;
+  local_0.flt_28 = 1.0;
+  do
+  {
+    local_0.x = pRnd->GetRandom() * 40.0 + (double)a2->vPosition.x - 20.0;
+    local_0.y = pRnd->GetRandom() * 40.0 + (double)a2->vPosition.y - 20.0;
+    local_0.z = (double)a2->vPosition.z;
+    local_0.r = pRnd->GetRandom() * 800.0 - 400.0;
+    local_0.g = pRnd->GetRandom() * 800.0 - 400.0;
+    local_0.b = pRnd->GetRandom() * 350.0 + 50.0;
+    pGame->pParticleEngine->AddParticle(&local_0);
+    --v3;
+  }
+  while ( v3 );
+}
+
+
+//----- (004AFB86) --------------------------------------------------------
+void BspRenderer::AddFaceToRenderList_sw(unsigned int node_id, unsigned int uFaceID)
+{
+  BspRenderer *v3; // ebx@1
+  BLVFace *v4; // eax@1
+  char *v5; // ecx@2
+  unsigned __int16 v6; // ax@11
+  int v7; // ecx@13
+  Vec3_short_ *v8; // esi@16
+  int v9; // edx@16
+  signed int v10; // eax@19
+  signed int v11; // edi@20
+  signed int v12; // ecx@20
+  signed int v13; // esi@20
+  int v14; // edx@21
+  int v15; // edx@25
+  unsigned __int16 v16; // ax@35
+  signed int v17; // eax@37
+  int v18; // eax@38
+  signed int v19; // [sp+Ch] [bp-14h]@19
+  char *v20; // [sp+14h] [bp-Ch]@2
+  BLVFace *v21; // [sp+18h] [bp-8h]@1
+  signed int v22; // [sp+1Ch] [bp-4h]@20
+  signed int v23; // [sp+28h] [bp+8h]@20
+
+  v3 = this;
+  v4 = &pIndoor->pFaces[uFaceID];
+  v21 = v4;
+  if (v4->Portal())
+  {
+    v5 = (char *)this + 2252 * node_id;
+    v20 = v5;
+    if ( uFaceID == *((short *)v5 + 2982) )
+      return;
+    if (!node_id
+      && pGame->pIndoorCameraD3D->vPartyPos.x >= v4->pBounding.x1 - 16
+      && pGame->pIndoorCameraD3D->vPartyPos.x <= v4->pBounding.x2 + 16
+      && pGame->pIndoorCameraD3D->vPartyPos.y >= v4->pBounding.y1 - 16
+      && pGame->pIndoorCameraD3D->vPartyPos.y <= v4->pBounding.y2 + 16
+      && pGame->pIndoorCameraD3D->vPartyPos.z >= v4->pBounding.z1 - 16
+      && pGame->pIndoorCameraD3D->vPartyPos.z <= v4->pBounding.z2 + 16 )
+    {
+      if ( abs(v4->pFacePlane_old.dist + pGame->pIndoorCameraD3D->vPartyPos.x * v4->pFacePlane_old.vNormal.x
+                                       + pGame->pIndoorCameraD3D->vPartyPos.y * v4->pFacePlane_old.vNormal.y
+                                       + pGame->pIndoorCameraD3D->vPartyPos.z * v4->pFacePlane_old.vNormal.z) <= 589824 )
+      {
+        v6 = v21->uSectorID;
+        if ( v3->nodes[0].uSectorID == v6 )
+          v6 = v21->uBackSectorID;
+        v3->nodes[v3->num_nodes].uSectorID = v6;
+        v3->nodes[v3->num_nodes].uFaceID = uFaceID;
+        v3->nodes[v3->num_nodes].uViewportX = LOWORD(pBLVRenderParams->uViewportX);
+        v3->nodes[v3->num_nodes].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ);
+        v3->nodes[v3->num_nodes].uViewportY = LOWORD(pBLVRenderParams->uViewportY);
+        v3->nodes[v3->num_nodes].uViewportW = LOWORD(pBLVRenderParams->uViewportW);
+        v3->nodes[v3->num_nodes++].PortalScreenData.GetViewportData(
+          SLOWORD(pBLVRenderParams->uViewportX),
+          pBLVRenderParams->uViewportY,
+          SLOWORD(pBLVRenderParams->uViewportZ),
+          pBLVRenderParams->uViewportW);
+        v7 = v3->num_nodes - 1;
+        goto LABEL_14;
+      }
+      v4 = v21;
+      v5 = v20;
+    }
+    v8 = &pIndoor->pVertices[*v4->pVertexIDs];
+    v9 = v4->pFacePlane_old.vNormal.x * (v8->x - pGame->pIndoorCameraD3D->vPartyPos.x)
+       + v4->pFacePlane_old.vNormal.y * (v8->y - pGame->pIndoorCameraD3D->vPartyPos.y)
+       + v4->pFacePlane_old.vNormal.z * (v8->z - pGame->pIndoorCameraD3D->vPartyPos.z);
+    if ( *((short *)v5 + 2004) != v4->uSectorID )
+      v9 = -v9;
+    if ( v9 < 0 )
+    {
+      v10 = GetPortalScreenCoord(uFaceID);
+      v19 = v10;
+      if ( v10 )
+      {
+        v11 = PortalFace._screen_space_x[0];
+        v12 = PortalFace._screen_space_y[0];
+        v23 = PortalFace._screen_space_x[0];
+        v13 = 1;
+        v22 = PortalFace._screen_space_y[0];
+        if ( v10 > 1 )
+        {
+          do
+          {
+            v14 = PortalFace._screen_space_x[v13];
+            if ( v14 < v23 )
+              v23 = PortalFace._screen_space_x[v13];
+            if ( v14 > v11 )
+              v11 = PortalFace._screen_space_x[v13];
+            v15 = PortalFace._screen_space_y[v13];
+            if ( v15 < v22 )
+              v22 = PortalFace._screen_space_y[v13];
+            if ( v15 > v12 )
+              v12 = PortalFace._screen_space_y[v13];
+            v10 = v19;
+            ++v13;
+          }
+          while ( v13 < v19 );
+        }
+        if ( v11 >= *((short *)v20 + 2005)
+          && v23 <= *((short *)v20 + 2007)
+          && v12 >= *((short *)v20 + 2006)
+          && v22 <= *((short *)v20 + 2008)
+          && PortalFrustrum(v10, &v3->nodes[v3->num_nodes].PortalScreenData, (BspRenderer_PortalViewportData *)(v20 + 4020), uFaceID) )
+        {
+          v16 = v21->uSectorID;
+          if ( *((short *)v20 + 2004) == v16 )
+            v16 = v21->uBackSectorID;
+          v3->nodes[v3->num_nodes].uSectorID = v16;
+          v3->nodes[v3->num_nodes].uFaceID = uFaceID;
+          v3->nodes[v3->num_nodes].uViewportX = LOWORD(pBLVRenderParams->uViewportX);
+          v3->nodes[v3->num_nodes].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ);
+          v3->nodes[v3->num_nodes].uViewportY = LOWORD(pBLVRenderParams->uViewportY);
+          v3->nodes[v3->num_nodes].uViewportW = LOWORD(pBLVRenderParams->uViewportW);
+          v17 = v3->num_nodes;
+          if ( v17 < 150 )
+          {
+            v18 = v17 + 1;
+            v3->num_nodes = v18;
+            v7 = v18 - 1;
+LABEL_14:
+            AddBspNodeToRenderList(v7);
+            return;
+          }
+        }
+      }
+    }
+  }
+  else
+  {
+    if (num_faces < 1000)
+    {
+      faces[num_faces].uFaceID = uFaceID;
+      faces[num_faces++].uNodeID = node_id;
+    }
+  }
+}
+
+
+//----- (0046A6AC) --------------------------------------------------------
+int __fastcall _46A6AC_spell_render(int a1, int a2, int a3)
+{
+  int result; // eax@2
+  int *v5; // esi@6
+  unsigned int v6; // ebx@6
+  signed int v7; // edi@9
+  int i; // eax@14
+  int v10; // ecx@19
+  unsigned int v13; // [sp+8h] [bp-10h]@4
+  int *v15; // [sp+10h] [bp-8h]@4
+  int v16; // [sp+14h] [bp-4h]@3
+
+  if ( pRenderer->pRenderD3D )
+  {
+    result = _46A6AC_spell_render_d3d(a1, a2, a3);
+  }
+  else
+  {
+    __debugbreak(); // SW render never called
+    v16 = 0;
+    if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y )
+    {
+      v15 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y];
+      v13 = ((viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y - 1) >> 1) + 1;
+      for ( v13; v13; --v13 )
+      {
+        if ( (signed int)viewparams->uScreen_topL_X < (signed int)viewparams->uScreen_BttmR_X )
+        {
+          v5 = v15;
+          v6 = ((viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X - 1) >> 1) + 1;
+          for ( v6; v6; --v6 )
+          {
+            if ( PID_TYPE(*(char *)v5) == OBJECT_Actor)
+            {
+              if ( *v5 <= a3 << 16 )
+              {
+                v7 = PID_ID((signed int)(unsigned __int16)*v5);
+                if ( pActors[v7].uAIState != Dead && pActors[v7].uAIState != Dying && pActors[v7].uAIState != Removed
+                  && pActors[v7].uAIState != Summoned && pActors[v7].uAIState != Disabled )
+                {
+                  for ( i = 0; i < v16; ++i )
+                  {
+                    if ( *(int *)(a1 + 4 * i) == v7 )
+                      break;
+                  }
+                  if ( i == v16 )
+                  {
+                    if ( i < a2 - 1 )
+                    {
+                      v10 = v16++;
+                      *(int *)(a1 + 4 * v10) = v7;
+                    }
+                  }
+                }
+              }
+            }
+            v5 += 2;
+          }
+        }
+        v15 += 1280;
+      }
+    }
+    result = v16;
+  }
+  return result;
+}
+
 */
\ No newline at end of file
--- a/mm7_2.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/mm7_2.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -396,7 +396,7 @@
 }
 
 //----- (004BC109) --------------------------------------------------------
-void  ArenaFight()
+void ArenaFight()
 {
   int v0; // edi@1
   char *v1; // eax@7
@@ -443,9 +443,11 @@
 
   pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
   pRenderer->BeginScene();
-  if ( pRenderer->pRenderD3D )
-    pRenderer->FillRectFast(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pViewport->uViewportBR_X - pViewport->uViewportTL_X,
-      pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1, pRenderer->uTargetGMask | pRenderer->uTargetBMask);
+  //if ( pRenderer->pRenderD3D )
+    pRenderer->FillRectFast(pViewport->uViewportTL_X, pViewport->uViewportTL_Y,
+                            pViewport->uViewportBR_X - pViewport->uViewportTL_X,
+                            pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1,
+                            0x7FF);
 
   Texture* pTex = pIcons_LOD->GetTexture(uTextureID_Leather);
   pRenderer->GetLeather(8, 352 - v0, pTex, pTex->uTextureHeight - v0);
@@ -3070,7 +3072,7 @@
 //----- (004646F0) --------------------------------------------------------
 void PrepareWorld(unsigned int _0_box_loading_1_fullscreen)
 {
-  if ( pRenderer->pRenderD3D )
+  //if ( pRenderer->pRenderD3D )
     pGame->pVisInstance->_4C1A02();
   pEventTimer->Pause();
   pMiscTimer->Pause();
@@ -3088,7 +3090,7 @@
   SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
   ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows();
   pGame->Deinitialize();
-  pRenderer->Release2();
+  pRenderer->Release();
   delete window;
   //if ( !DestroyWindow(hWnd) )
   //  GetLastError();
@@ -3929,7 +3931,7 @@
   pItemsTable = new ItemsTable;
   pItemsTable->Initialize();
 
-  pBitmaps_LOD->dword_011BA8 = 1;
+  //pBitmaps_LOD->can_load_hardware_sprites = 1;
   //pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits);
   pBitmaps_LOD->SetupPalettes(5, 6, 5);
   //pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits);
@@ -3939,7 +3941,7 @@
 
   pPaletteManager->SetMistColor(128, 128, 128);
   pPaletteManager->RecalculateAll();
-  pSprites_LOD->field_ECAC = 1;
+  //pSprites_LOD->can_load_hardware_sprites = 1;
   pObjectList->InitializeSprites();
   pOverlayList->InitializeSprites();
   if (!bNoSound)
@@ -4027,7 +4029,7 @@
   static_assert(sizeof(RenderBillboard) == 0x34, "Wrong type size");
   static_assert(sizeof(Texture) == 0x48, "Wrong type size");
   static_assert(sizeof(RGBTexture) == 0x28, "Wrong type size");
-  static_assert(sizeof(LODFile_IconsBitmaps) == 0x11BB8 + 4, "Wrong type size"); // + virtual dtor ptr
+  //static_assert(sizeof(LODFile_IconsBitmaps) == 0x11BB8 + 4, "Wrong type size"); // + virtual dtor ptr
   static_assert(sizeof(AudioPlayer) == 0xC84, "Wrong type size");
   static_assert(sizeof(SoundDesc) == 0x78, "Wrong type size");
   static_assert(sizeof(stru339_spell_sound) == 0xAFD8, "Wrong type size");
@@ -4553,118 +4555,6 @@
 }
 
 
-//----- (0046A6AC) --------------------------------------------------------
-int __fastcall _46A6AC_spell_render(int a1, int a2, int a3)
-{
-  int result; // eax@2
-  int *v5; // esi@6
-  unsigned int v6; // ebx@6
-  signed int v7; // edi@9
-  int i; // eax@14
-  int v10; // ecx@19
-  unsigned int v13; // [sp+8h] [bp-10h]@4
-  int *v15; // [sp+10h] [bp-8h]@4
-  int v16; // [sp+14h] [bp-4h]@3
-
-  if ( pRenderer->pRenderD3D )
-  {
-    result = _46A6AC_spell_render_d3d(a1, a2, a3);
-  }
-  else
-  {
-    __debugbreak(); // SW render never called
-    v16 = 0;
-    if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y )
-    {
-      v15 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y];
-      v13 = ((viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y - 1) >> 1) + 1;
-      for ( v13; v13; --v13 )
-      {
-        if ( (signed int)viewparams->uScreen_topL_X < (signed int)viewparams->uScreen_BttmR_X )
-        {
-          v5 = v15;
-          v6 = ((viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X - 1) >> 1) + 1;
-          for ( v6; v6; --v6 )
-          {
-            if ( PID_TYPE(*(char *)v5) == OBJECT_Actor)
-            {
-              if ( *v5 <= a3 << 16 )
-              {
-                v7 = PID_ID((signed int)(unsigned __int16)*v5);
-                if ( pActors[v7].uAIState != Dead && pActors[v7].uAIState != Dying && pActors[v7].uAIState != Removed
-                  && pActors[v7].uAIState != Summoned && pActors[v7].uAIState != Disabled )
-                {
-                  for ( i = 0; i < v16; ++i )
-                  {
-                    if ( *(int *)(a1 + 4 * i) == v7 )
-                      break;
-                  }
-                  if ( i == v16 )
-                  {
-                    if ( i < a2 - 1 )
-                    {
-                      v10 = v16++;
-                      *(int *)(a1 + 4 * v10) = v7;
-                    }
-                  }
-                }
-              }
-            }
-            v5 += 2;
-          }
-        }
-        v15 += 1280;
-      }
-    }
-    result = v16;
-  }
-  return result;
-}
-
-//----- (0046A7C8) --------------------------------------------------------
-int __fastcall _46A6AC_spell_render_d3d(int a1, int a2, int a3)
-{
-  unsigned int v3; // eax@2
-  unsigned int v5; // eax@2
-  unsigned int v6; // eax@4
-  int v10; // ecx@11
-  unsigned int v12; // [sp+10h] [bp-14h]@1
-  int v15; // [sp+1Ch] [bp-8h]@1
-  unsigned int a1a; // [sp+20h] [bp-4h]@1
-
-  v15 = 0;
-  v12 = pRenderer->GetBillboardDrawListSize();
-  if ( (signed int)pRenderer->GetBillboardDrawListSize() > 0 )
-  {
-    for ( a1a = 0; (signed int)a1a < (signed int)v12; ++a1a )
-    {
-      v3 = pRenderer->GetParentBillboardID(a1a);
-      v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid;
-      if ( PID_TYPE(v5) == OBJECT_Actor)
-      {
-        if ( pBillboardRenderList[v3].sZValue <= (unsigned int)(a3 << 16) )
-        {
-          v6 = PID_ID(v5);
-          if ( pActors[v6].uAIState != Dead && pActors[v6].uAIState != Dying && pActors[v6].uAIState != Removed
-            && pActors[v6].uAIState != Disabled && pActors[v6].uAIState != Summoned )
-          {
-            if ( pGame->pVisInstance->DoesRayIntersectBillboard((double)a3, a1a) )
-            {
-              if ( v15 < a2 - 1 )
-              {
-                __debugbreak();// *(int *)(a1 + 4 * v10) = v6;   ?
-                v10 = v15++;
-                *(int *)(a1 + 4 * v10) = v6;
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-  return v15;
-}
-
 //----- (0046A89E) --------------------------------------------------------
 int __fastcall _46A89E_immolation_effect(int a1, int a2, int a3)
 {
--- a/mm7_3.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/mm7_3.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -2072,7 +2072,7 @@
     for(int i = 0; i < this->uNumVertices; i++)
     {
       v6 = (double)pBLVRenderParams->fov_rad_fixpoint * 0.000015258789 / this->field_B4[i*4];
-      if ( pRenderer->pRenderD3D )
+      //if ( pRenderer->pRenderD3D )
       {
         pGame->pIndoorCameraD3D->Project(round_to_int(this->field_B4[i*4]), round_to_int(this->field_B4[i*4+1]), round_to_int(this->field_B4[i*4+2]),
            &a5, &a6);
@@ -2080,12 +2080,12 @@
         this->field_B4[i*4+17] = (double)a6;
         this->field_B4[i*4+18] = round_to_int(this->field_B4[i*4]);
       }
-      else
+      /*else
       {
         this->field_B4[i*4+16] = (double)pBLVRenderParams->uViewportCenterX - v6 * this->field_B4[i*4+1];
         this->field_B4[i*4+17] = (double)pBLVRenderParams->uViewportCenterY - v6 * this->field_B4[i*4+2];
         this->field_B4[i*4+18] = this->field_B4[i*4];
-      }
+      }*/
       this->field_B4[i*4+19] = this->field_B4[i*4+3];
       if ( (double)(signed int)pViewport->uViewportTL_X <= this->field_B4[i*4+16] && (double)(signed int)pViewport->uViewportBR_X > this->field_B4[i*4+16]
         && (double)(signed int)pViewport->uViewportTL_Y <= this->field_B4[i*4+17] && (double)(signed int)pViewport->uViewportBR_Y > this->field_B4[i*4+17] )
@@ -2355,9 +2355,9 @@
   skybox_width = xn_width;
   skybox_height = xn_height;
 
-  
-  if (!pRenderer->pRenderD3D->CreateTexture(skybox_width, skybox_height, &skybox_surface, &skybox_texture,
-                                            false, false, pRenderer->uMinDeviceTextureDim))
+  __debugbreak();
+  //if (!pRenderer->pRenderD3D->CreateTexture(skybox_width, skybox_height, &skybox_surface, &skybox_texture,
+                                            //false, false, pRenderer->uMinDeviceTextureDim))
     return false;
 
   return true;
@@ -2507,11 +2507,12 @@
 
     memcpy(&v[5], &v[1], sizeof(*v));
 
+    __debugbreak();
+    /*
     pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
     pRenderer->pRenderD3D->pDevice->SetTexture(0, skybox_texture);
     pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v, 6, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT);
-    //pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v + 1, 3, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT);
-
+*/
     return true;
   }
 
@@ -3435,7 +3436,7 @@
   v10.sParentBillboardID = -1;
   v10.pTarget = pRenderer->pTargetSurface;
   v10.pTargetZ = pRenderer->pActiveZBuffer;
-  v10.uTargetPitch = pRenderer->field_10;
+  v10.uTargetPitch = pRenderer->GetRenderWidth();
   result = 0;
   v2 = a1;
   v10.uViewportX = 0;
@@ -4209,14 +4210,11 @@
 }
 
 //----- (00448B67) --------------------------------------------------------
-void OnTimer(int __unused)
+void OnTimer(int)
 {
   if (pEventTimer->bPaused)
     return;
   
-  if (__unused)
-    _5773C0_unused = 0;
-  
   long long v13 = (signed __int64)(pParty->uTimePlayed - _5773B8_event_timer) / 128;
   if (!v13)
     return;
--- a/mm7_4.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/mm7_4.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -249,7 +249,7 @@
 // 4ED498: using guessed type char byte_4ED498;
 
 //----- (00493938) --------------------------------------------------------
-void  _493938_regenerate()
+void _493938_regenerate()
 {
   int current_time; // edi@1
   int last_reg_time; // qax@1
@@ -275,7 +275,7 @@
   int v27; // eax@36
   int v28; // eax@37
   signed int v31; // ecx@53
-  char v41[400]; // [sp+4h] [bp-22Ch]@20
+  int v41[100]; // [sp+4h] [bp-22Ch]@20
   SpriteObject a1; // [sp+194h] [bp-9Ch]@15
   Vec3_int_ a3; // [sp+204h] [bp-2Ch]@15
   bool has_dragon_flag; // [sp+210h] [bp-20h]@22
@@ -372,7 +372,7 @@
       v13 = _46A89E_immolation_effect((int)v41, 100, 307);
       for ( v9 = 0; v9 < v13; ++v9 )
       {
-        v14 = (unsigned int *)&v41[4 * v9];
+        v14 = (unsigned int *)&v41[v9];
         v15 = *v14;
         v16 = *v14;
         a1.vPosition.x = pActors[v16].vPosition.x;
@@ -422,13 +422,13 @@
           {
             v25 = pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uSpecEnchantmentType;
             if ( v25 == 37 //of Regeneration("Regenerate 1hp/x while walking, etc")
-              && v25 == 44 //of Life("HP (+10), Regen hpts")
-              && v25 == 50 //of The Phoenix("Fire Res (+30), Regen hpts") && 
-              && v25 == 54 )// of The Troll("End (+15), Regen hpts")
+              || v25 == 44 //of Life("HP (+10), Regen hpts")
+              || v25 == 50 //of The Phoenix("Fire Res (+30), Regen hpts") && 
+              || v25 == 54 )// of The Troll("End (+15), Regen hpts")
                recovery_HP = true;
             if ( v25 == 38 //of Mana("Regenerate 1sp/x while walking, etc")
-              && v25 == 47 //of The Eclipse("SP (+10), Regen spts")
-              && v25 == 55 )//of The Unicorn("Luck (+15), Regen spts")
+              || v25 == 47 //of The Eclipse("SP (+10), Regen spts")
+              || v25 == 55 )//of The Unicorn("Luck (+15), Regen spts")
                recovery_SP = true;
             if ( v25 == 66 )// of Plenty("Regenerate 1 hp/x and 1 sp/x while walking, etc.")
             {
@@ -437,27 +437,29 @@
             }
           }
 
-          if ( recovery_HP && !pParty->pPlayers[v49].pConditions[Condition_Dead]
-                           && !pParty->pPlayers[v49].pConditions[Condition_Eradicated] )
+          if (recovery_HP &&
+              !pParty->pPlayers[v49].pConditions[Condition_Dead] &&
+              !pParty->pPlayers[v49].pConditions[Condition_Eradicated])
           {
-            ++pParty->pPlayers[v49].sHealth;
-            if ( pParty->pPlayers[v49].sHealth > pParty->pPlayers[v49].GetMaxHealth() )
-              pParty->pPlayers[v49].sHealth = pParty->pPlayers[v49].GetMaxHealth();
+            if ( pParty->pPlayers[v49].sHealth < pParty->pPlayers[v49].GetMaxHealth() )
+              ++pParty->pPlayers[v49].sHealth;
             if ( pParty->pPlayers[v49].pConditions[Condition_Unconcious] && pParty->pPlayers[v49].sHealth > 0 )
               pParty->pPlayers[v49].pConditions[Condition_Unconcious] = 0;
             redraw_flag = true;
           }
 
-          if ( recovery_SP )
+          if (recovery_SP &&
+              !pParty->pPlayers[v49].pConditions[Condition_Dead] &&
+              !pParty->pPlayers[v49].pConditions[Condition_Eradicated])
           {
-            ++pParty->pPlayers[v49].sMana;
-            if ( pParty->pPlayers[v49].sMana > pParty->pPlayers[v49].GetMaxMana() )
-              pParty->pPlayers[v49].sMana = pParty->pPlayers[v49].GetMaxMana();
+            if ( pParty->pPlayers[v49].sMana < pParty->pPlayers[v49].GetMaxMana() )
+              ++pParty->pPlayers[v49].sMana;
             redraw_flag = true;
           }
 
-          if ( decrease_HP && !pParty->pPlayers[v49].pConditions[Condition_Dead]
-                   && !pParty->pPlayers[v49].pConditions[Condition_Eradicated] )
+          if (decrease_HP &&
+              !pParty->pPlayers[v49].pConditions[Condition_Dead] &&
+              !pParty->pPlayers[v49].pConditions[Condition_Eradicated] )
           {
             --pParty->pPlayers[v49].sHealth;
             if ( !(pParty->pPlayers[v49].pConditions[Condition_Unconcious]) && pParty->pPlayers[v49].sHealth < 0 )
@@ -494,9 +496,8 @@
       //for warlock
       if ( has_dragon_flag && pParty->pPlayers[v49].classType == PLAYER_CLASS_WARLOCK )
       {
-        ++pParty->pPlayers[v49].sMana;
-        if ( pParty->pPlayers[v49].sMana > pParty->pPlayers[v49].GetMaxMana() )
-          pParty->pPlayers[v49].sMana = pParty->pPlayers[v49].GetMaxMana();
+        if ( pParty->pPlayers[v49].sMana < pParty->pPlayers[v49].GetMaxMana() )
+          ++pParty->pPlayers[v49].sMana;
         redraw_flag = true;
       }
 
@@ -520,9 +521,8 @@
       }
       if ( lich_jar_flag )
       {
-        ++pParty->pPlayers[v49].sMana;
-       if ( pParty->pPlayers[v49].sMana > pParty->pPlayers[v49].GetMaxMana() )
-          pParty->pPlayers[v49].sMana = pParty->pPlayers[v49].GetMaxMana();
+       if ( pParty->pPlayers[v49].sMana < pParty->pPlayers[v49].GetMaxMana() )
+          ++pParty->pPlayers[v49].sMana;
       }
 
       //for zombie
@@ -875,7 +875,7 @@
           break;
         }
       }
-      if ( !party_condition_flag || dword_5C35C0 )
+      if ( !party_condition_flag || _5C35C0_force_party_death )
         uGameState = GAME_STATE_PARTY_DIED;
     }
   }
--- a/mm7_data.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/mm7_data.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -336,16 +336,9 @@
 int pWindowList_at_506F50_minus1_indexing[1];
 int dword_4C9890[10]; // weak
 int dword_4C9920[16]; // weak
-_UNKNOWN unk_4D8548; // weak
 char byte_4D864C; // weak
 float flt_4D86CC = 1.0f; // weak
-int dword_4D86D8; // weak
-int dword_4DAFCC; // weak
-int (__stdcall *off_4DAFDC)(char); // weak
-char asc_4DB724[777]; // idb
-int dword_4DBD94; // weak
-//int dword_4DF390; // weak
-char Str2[777]; // idb
+int dword_4D86D8 = 0x40000000; // weak
 
 
 
@@ -355,97 +348,6 @@
 
 float flt_4D84E8 = 0.0f;
 
-char aIxf[4]; // idb
-_UNKNOWN unk_4E19FC; // weak
-char aD[777]; // idb
-char asc_4E1AB0[777]; // idb
-char aWb_0[777]; // idb
-char a24bitPcxOnly[777]; // idb
-char Mode[777]; // idb
-char a16bitPcx[777]; // idb
-char aUnableToLoadS[777]; // idb
-char aBitmaps[777]; // idb
-char aIcons[777]; // idb
-char aPending[777]; // idb
-char aCanTFindS[777]; // idb
-
-//std::array<char, 7> aSbwb00; // weak
-char aW[2]; // idb
-char aA[2]; // idb
-char aSD[777]; // idb
-char aSS03d03dS000S0[777]; // idb
-char aLuS[777]; // idb
-char aS_1[777]; // idb
-char aSbSc02d[777]; // idb
-char aSbSs02d[777]; // idb
-char aTabDb[777]; // idb
-char aTabDa[777]; // idb
-char aIbM6D[777]; // idb
-char aIbM6U[777]; // idb
-char aIbM5D[777]; // idb
-char aIbM5U[777]; // idb
-char aPagemask[777]; // idb
-char aBook[777]; // idb
-char aSpell_fnt[777]; // idb
-char aAutonote_fnt[777]; // idb
-char aBook2_fnt[777]; // idb
-char pFontFile[777]; // idb
-char aFontpal[777]; // idb
-char aMapbordr[777]; // idb
-char aLloydDD_pcx[777]; // idb
-char aDataLloydDD_pc[777]; // idb
-char aLb_bordr[777]; // idb
-char aTphell[777]; // idb
-char aTpheaven[777]; // idb
-char aTpisland[777]; // idb
-char aTpwarlock[777]; // idb
-char aTpelf[777]; // idb
-char aTpharmndy[777]; // idb
-char aTownport[777]; // idb
-char aSbquiknot[777]; // idb
-char aTabAn8a[777]; // idb
-char aTabAn8b[777]; // idb
-char aTabAn4a[777]; // idb
-char aTabAn4b[777]; // idb
-char aTabAn5a[777]; // idb
-char aTabAn5b[777]; // idb
-char aTabAn3a[777]; // idb
-char aTabAn3b[777]; // idb
-char aTabAn2a[777]; // idb
-char aTabAn2b[777]; // idb
-char aTabAn1a[777]; // idb
-char aTabAn1b[777]; // idb
-char aDivbar[777]; // idb
-char aSbautnot[777]; // idb
-char aTabwoff[777]; // idb
-char aTabwon[777]; // idb
-char aTabeoff[777]; // idb
-char aTabeon[777]; // idb
-char aTabsoff[777]; // idb
-char aTabson[777]; // idb
-char aTabnoff[777]; // idb
-char aTabnon[777]; // idb
-char aZootOff[777]; // idb
-char aZoomOff[777]; // idb
-char aZootOn[777]; // idb
-char aZoomOn[777]; // idb
-char aSbmap[777]; // idb
-char aMoon_ful[777]; // idb
-char aMoon_2[777]; // idb
-char aMoon_4[777]; // idb
-char aMoon_new[777]; // idb
-char aSbdateTime[777]; // idb
-char aTabAn7a[777]; // idb
-char aTabAn6a[777]; // idb
-char aTabAn7b[777]; // idb
-char aTabAn6b[777]; // idb
-char aSbplayrnot[777]; // idb
-char aPending_0[777]; // idb
-char aUnknown[8]; // weak
-char aS100110S[777]; // idb
-char aS100110D[777]; // idb
-char aS100110DS[777]; // idb
-char aS100110D02dSS[777]; // idb
 int pCurrentScreen = SCREEN_VIDEO; // 004E28F8
 unsigned int uGammaPos;
 std::array<int, 8> BtnTurnCoord = 
@@ -454,7 +356,6 @@
 }}; // weak
 std::array<__int16, 4> RightClickPortraitXmin={{0x14, 0x83, 0xF2, 0x165}};
 std::array<__int16, 4> RightClickPortraitXmax={{0x53, 0xC6, 0x138, 0x1A7}};
-void *off_4E2A12; // stat_string_control_button_count
 
 std::array<unsigned int, 4> pHealthBarPos = {{22, 137, 251, 366}};
 std::array<unsigned int, 4> pManaBarPos = {{102, 217, 331, 447}};
@@ -478,17 +379,11 @@
 const char *format_4E2DE8 = "\f%05d%s\f00000 - ";
 const char *format_4E2E00 = "%s\f%05u\xD\r180%s\n"; // idb
 const char *format_4E2E10 = "%s\f%05u\t110%d\f00000 / %d\n";
-__int16 word_4E3C66[777]; // idb
 int dword_4E455C; // weak
 std::array<int, 6> dword_4E4560;
 std::array<int, 6> dword_4E4578;
 std::array<int, 6> dword_4E4590;
 std::array<int, 6> dword_4E45A8;
-_UNKNOWN dword_4E49D4; // idb
-int dword_4E4A18[777]; // weak
-int dword_4E4A1C[777]; // weak
-int dword_4E4A40[777]; // weak
-int dword_4E4A44[777]; // weak
 std::array<float, 10> flt_4E4A80 =
 {
   0.050000001, 0.1,  0.30000001,  0.5,    0.60000002,
@@ -547,10 +442,9 @@
 
 std::array<__int16, 11> word_4E8152 = {0, 0, 0, 90, 8, 2, 70, 20, 10, 50, 30};
 
-char byte_4E94D0 = 5; // weak
-char byte_4E94D1 = 9; // weak
+char _4E94D0_light_type = 5; // weak
 char _4E94D2_light_type = 6; // weak
-char byte_4E94D3 = 10; // weak
+char _4E94D3_light_type = 10; // weak
 int dword_4E98BC_bApplicationActive; // weak
 //char *off_4EB080; // idb
 std::array<char*, 465> pTransitionStrings = {"", nullptr};  // 004EB080
@@ -777,11 +671,9 @@
  3, 0, 2, 0, 0, 1, 0, 4, 0, 2, 0, 0, 4, 4, 4, 4, 0, 0, 0, 4, 0, 4, 1, 2, 0, 3, 2, 1, 0, 0, 0, 0, 4, 0, 0, 3, 3,
  3, 0, 2, 0, 0, 1, 0, 4, 0, 2, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0, 4, 4, 1, 2, 0, 3, 2, 1, 0, 0, 0, 0, 4, 0, 0, 3, 3,
 }};
-_UNKNOWN unk_4EDF40; // weak
 std::array<unsigned int, 2> pHiredNPCsIconsOffsetsX = {489, 559};
 std::array<unsigned int, 2> pHiredNPCsIconsOffsetsY = {152, 152};
 std::array<int, 2> dword_4EE07C; // weak
-_UNKNOWN unk_4EE084; // weak
 std::array<__int16, 101> word_4EE088_sound_ids =
 {{
       0, 10000, 10010, 10020, 10030, 10040, 10050, 10060, 10070, 10080,
@@ -802,12 +694,7 @@
   47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 60
 }};
 
-int dword_4EED78; // weak
-_UNKNOWN unk_4EED80; // weak
 int ScreenshotFileNumber; // dword_4EFA80
-int dword_4EFA84; // weak
-void *off_4EFDB0; // weak
-int dword_4F031C[777]; // weak
 std::array<const char *, 19> off_4F03B8 =
 {{
   "",         "WEPNTABL", "ARMORY",   "MAGSHELF",
@@ -869,12 +756,6 @@
 					       4, 7, 10, 11,
 					       7, 11,
                  7, 11}};
-double dbl_4F2870; // weak
-int dword_4F288C; // weak
-double dbl_4F5372; // weak
-int dword_4F5428[777]; // weak
-int dword_4F542C[777]; // weak
-_UNKNOWN crtunk_4F54B8; // weak
 std::array<int, 500> ai_array_4F5E68;
 std::array<int, 500> ai_array_4F6638_actor_ids;
 std::array<int, 500> ai_near_actors_targets_pid;
@@ -883,16 +764,9 @@
 std::array<unsigned int, 500> ai_near_actors_ids;
 std::array<int, 182> dword_4F8580; // weak
 
-
-
-_UNKNOWN unk_4FAA20; // weak
 char byte_4FAA24; // weak
 //HWND dword_4FAA28; // idb
 
-
-
-
-int dword_505890; // weak
 std::array<unsigned int, 480> pSRZBufferLineOffsets;
 int areWeLoadingTexture; // weak
 std::array<char, 777> books_num_items_per_page; // weak
@@ -904,8 +778,6 @@
 __int64 qword_506350; // weak
 char byte_506360; // weak
 int dword_506364; // weak
-//Texture *dword_506404[12]; // weak
-//Texture *dword_50640C[12]; // weak
 unsigned int uExitCancelTextureId;
 int books_page_number; // weak
 int books_primary_item_per_page; // weak
@@ -961,7 +833,6 @@
 std::array<const char *, 7> aDayNames;
 std::array<const char *, 9> aSpellSchoolNames;
 std::array<const char *, 7> aAttributeNames;
-int dword_507B94; // weak
 unsigned int uActiveCharacter;
 int dword_507BF0_is_there_popup_onscreen; // weak
 int awards_scroll_bar_created; // weak
@@ -972,31 +843,11 @@
 std::array<int, 50> dword_50B570; // weak
 std::array<int, 50> dword_50B638; // weak
 stru367 PortalFace;
-/*int PortalFace.field_0; // weak
-int PortalFace.field_38[777]; // idb
-int PortalFace._view_transformed_ys[45];
-int PortalFace.field_128[777];
-int PortalFace._view_transformed_zs[45];
-int PortalFace.field_218[777];
-int PortalFace._view_transformed_xs[45];
-int PortalFace._screen_space_y[777];
-int PortalFace.field_3E4[777];
-int PortalFace.field_2F0[2]; // idb
-int PortalFace._ys[3 + 45];
-int PortalFace._ys2[48]; // idb
-int PortalFace._screen_space_x[777]; // idb
-int PortalFace.field_3D4[777]; // weak
-int PortalFace._xs[777]; // weak
-int dword_50BAE8[777]; // weak
-int PortalFace._xs2[3 + 45]; // weak
-int PortalFace._xs3[48]; // weak*/
 std::array<int, 100> dword_50BC10; // weak
 std::array<int, 100> dword_50BDA0; // weak
 std::array<int, 100> dword_50BF30; // weak
 char town_portal_caster_id; // weak
 int some_active_character; // weak
-//_UNKNOWN unk_50C190; // weak
-int dword_50C968; // weak
 std::array<unsigned int, 5> pIconIDs_Turn;
 unsigned int uIconID_TurnStop;
 unsigned int uIconID_TurnHour;
@@ -1007,7 +858,6 @@
 int uSpriteID_Spell11; // idb
 bool _50C9A0_IsEnchantingInProgress; // weak
 int _50C9A8_item_enchantment_timer = 0; // weak
-int dword_50C9AC; // weak
 int _50C9D0_AfterEnchClickEventId; // weak
 int _50C9D4_AfterEnchClickEventSecondParam; // weak
 int _50C9D8_AfterEnchClickEventTimeout; // weak
@@ -1016,7 +866,6 @@
 //int dword_50C9E8; // idb
 //int dword_50C9EC[120]; // weak
 int dword_50CDC8;
-int bProcessorIsNotIntel; // weak
 Vec3_int_ layingitem_vel_50FDFC;
 char pStartingMapName[32]; // idb
 std::array<unsigned __int8, 5> IsPlayerWearingWatersuit;
@@ -1031,7 +880,6 @@
 int dword_576E28; // weak
 int _576E2C_current_minimap_zoom; // weak
 __int64 _5773B8_event_timer; // weak
-int _5773C0_unused; // weak
 
 
 int dword_591084; // weak
@@ -1054,7 +902,6 @@
 struct Texture *pTexture_591428;
 struct Texture *pTexture_outside; // idb
 struct Texture *pTexture_Dialogue_Background;
-_UNKNOWN unk_597F10; // weak
 std::array<char, 2000> byte_5B0938;
 int EvtTargetObj; // 0x5B5920
 int _unused_5B5924_is_travel_ui_drawn = false; // 005B5924
@@ -1071,15 +918,13 @@
 signed int dword_5B65D0_dialogue_actor_npc_id; // weak
 int dword_5C3418; // weak
 int dword_5C341C; // weak
-int _5C3420_pDecoration;
 //std::array<char, 777> byte_5C3427; // weak
 std::array<char, 200> GameUI_Footer_TimedString;
 std::array<char, 200> pFooterString;
 unsigned int GameUI_Footer_TimeLeft;
 int bForceDrawFooter; // weak
-int dword_5C35C0; // weak
+int _5C35C0_force_party_death = false; // weak
 int bDialogueUI_InitializeActor_NPC_ID; // weak
-int dword_5C35C8; // weak
 char *p2DEventsTXT_Raw;
 
 int dword_5C35D4; // weak
@@ -1155,8 +1000,6 @@
 unsigned int uTextureID_save_up;
 unsigned int uTextureID_load_up;
 unsigned int uTextureID_loadsave;
-_UNKNOWN _69FBB4_ptr_iterator_end; // weak
-_UNKNOWN unk_6A0758; // weak
 int pSaveListPosition; // weak
 unsigned int uLoadGameUI_SelectedSlot;
 HWND hInsertCDWindow; // idb
--- a/mm7_data.h	Fri Jan 10 17:42:37 2014 +0600
+++ b/mm7_data.h	Fri Jan 10 17:42:57 2014 +0600
@@ -6,7 +6,7 @@
 #include <assert.h>
 #include "NZIArray.h"
 
-typedef char _UNKNOWN;
+//typedef char _UNKNOWN;
 typedef unsigned int uint;
 
 
@@ -299,120 +299,18 @@
 extern int pWindowList_at_506F50_minus1_indexing[1];
 extern int dword_4C9890[10]; // weak
 extern int dword_4C9920[16]; // weak
-extern _UNKNOWN unk_4D8548; // weak
 extern char byte_4D864C; // weak
 extern float flt_4D86CC; // weak
 extern int dword_4D86D8; // weak
-extern int dword_4DAFCC; // weak
-extern int (__stdcall *off_4DAFDC)(char); // weak
-extern char asc_4DB724[]; // idb
-extern int dword_4DBD94; // weak
-extern int dword_4DF390; // weak
-extern char Str2[]; // idb
 
 
 extern float flt_4D84E8;
 
-
-extern char aIxf[4]; // idb
-extern _UNKNOWN unk_4E19FC; // weak
-extern char aD[]; // idb
-extern char asc_4E1AB0[]; // idb
-extern char aWb_0[]; // idb
-extern char a24bitPcxOnly[]; // idb
-extern char Mode[]; // idb
-extern char a16bitPcx[]; // idb
-extern char aUnableToLoadS[]; // idb
-extern char aBitmaps[]; // idb
-extern char aIcons[]; // idb
-extern char aPending[]; // idb
-extern char aCanTFindS[]; // idb
-
-extern __int16 word_4E1D3A[]; // weak
-
-//extern std::array<char, 7> aSbwb00; // weak
-extern char aW[2]; // idb
-extern char aA[2]; // idb
-extern char aSD[]; // idb
-extern char aSS03d03dS000S0[]; // idb
-extern char aLuS[]; // idb
-extern char aS_1[]; // idb
-extern char aSbSc02d[]; // idb
-extern char aSbSs02d[]; // idb
-extern char aTabDb[]; // idb
-extern char aTabDa[]; // idb
-extern char aIbM6D[]; // idb
-extern char aIbM6U[]; // idb
-extern char aIbM5D[]; // idb
-extern char aIbM5U[]; // idb
-extern char aPagemask[]; // idb
-extern char aBook[]; // idb
-extern char aSpell_fnt[]; // idb
-extern char aAutonote_fnt[]; // idb
-extern char aBook2_fnt[]; // idb
-extern char pFontFile[]; // idb
-extern char aFontpal[]; // idb
-extern char aMapbordr[]; // idb
-extern char aLloydDD_pcx[]; // idb
-extern char aDataLloydDD_pc[]; // idb
-extern char aLb_bordr[]; // idb
-extern char aTphell[]; // idb
-extern char aTpheaven[]; // idb
-extern char aTpisland[]; // idb
-extern char aTpwarlock[]; // idb
-extern char aTpelf[]; // idb
-extern char aTpharmndy[]; // idb
-extern char aTownport[]; // idb
-extern char aSbquiknot[]; // idb
-extern char aTabAn8a[]; // idb
-extern char aTabAn8b[]; // idb
-extern char aTabAn4a[]; // idb
-extern char aTabAn4b[]; // idb
-extern char aTabAn5a[]; // idb
-extern char aTabAn5b[]; // idb
-extern char aTabAn3a[]; // idb
-extern char aTabAn3b[]; // idb
-extern char aTabAn2a[]; // idb
-extern char aTabAn2b[]; // idb
-extern char aTabAn1a[]; // idb
-extern char aTabAn1b[]; // idb
-extern char aDivbar[]; // idb
-extern char aSbautnot[]; // idb
-extern char aTabwoff[]; // idb
-extern char aTabwon[]; // idb
-extern char aTabeoff[]; // idb
-extern char aTabeon[]; // idb
-extern char aTabsoff[]; // idb
-extern char aTabson[]; // idb
-extern char aTabnoff[]; // idb
-extern char aTabnon[]; // idb
-extern char aZootOff[]; // idb
-extern char aZoomOff[]; // idb
-extern char aZootOn[]; // idb
-extern char aZoomOn[]; // idb
-extern char aSbmap[]; // idb
-extern char aMoon_ful[]; // idb
-extern char aMoon_2[]; // idb
-extern char aMoon_4[]; // idb
-extern char aMoon_new[]; // idb
-extern char aSbdateTime[]; // idb
-extern char aTabAn7a[]; // idb
-extern char aTabAn6a[]; // idb
-extern char aTabAn7b[]; // idb
-extern char aTabAn6b[]; // idb
-extern char aSbplayrnot[]; // idb
-extern char aPending_0[]; // idb
-extern char aUnknown[8]; // weak
-extern char aS100110S[]; // idb
-extern char aS100110D[]; // idb
-extern char aS100110DS[]; // idb
-extern char aS100110D02dSS[]; // idb
 extern int pCurrentScreen; // 004E28F8
 extern unsigned int uGammaPos;
 extern std::array<int, 8> BtnTurnCoord;
 extern std::array<__int16, 4> RightClickPortraitXmin;
 extern std::array<__int16, 4> RightClickPortraitXmax;
-extern void *off_4E2A12; // weak
 //extern int pArmorSkills[5];
 //extern int pWeaponSkills[9];
 //extern int pMiscSkills[12];
@@ -429,17 +327,11 @@
 extern const char *format_4E2DE8; // idb
 extern const char *format_4E2E00; // idb
 extern const char *format_4E2E10; // format text of resistance in Stats screen
-extern __int16 word_4E3C66[]; // idb
 extern int dword_4E455C; // weak
 extern std::array<int, 6> dword_4E4560;
 extern std::array<int, 6> dword_4E4578;
 extern std::array<int, 6> dword_4E4590;
 extern std::array<int, 6> dword_4E45A8;
-extern _UNKNOWN dword_4E49D4; // idb
-extern int dword_4E4A18[]; // weak
-extern int dword_4E4A1C[]; // weak
-extern int dword_4E4A40[]; // weak
-extern int dword_4E4A44[]; // weak
 extern std::array<float, 10> flt_4E4A80;
 
 extern std::array< std::array<int, 2>, 14> pPartySpellbuffsUI_XYs;
@@ -451,11 +343,9 @@
 extern std::array<const char *, 11> _4E6BDC_loc_names;
 extern std::array<__int16, 11> word_4E8152;
 extern std::array< std::array<char, 14>, 7> byte_4E8168;
-//extern stru355 stru_4E82A4;// = {0x20, 0x41, 0, 0x20, 0xFF0000, 0xFF00, 0xFF, 0xFF000000};  moved to texture.h
-//extern stru355 stru_4EFCBC;// = {0x20, 0x41, 0, 0x10, 0x7C00, 0x3E0, 0x1F, 0x8000};  moved to texture.h
-extern char byte_4E94D0; // weak
+extern char _4E94D0_light_type; // weak
 extern char _4E94D2_light_type; // weak
-extern char byte_4E94D3; // weak
+extern char _4E94D3_light_type; // weak
 extern std::array<unsigned int, 2> saveload_dlg_xs;
 extern std::array<unsigned int, 2> saveload_dlg_ys;
 extern std::array<unsigned int, 2> saveload_dlg_zs;
@@ -464,27 +354,18 @@
 extern std::array<char*, 465> pTransitionStrings; // 4EB080
 extern std::array<int, 9> dword_4EC268; // weak
 extern std::array<int, 7> dword_4EC28C; // weak
-extern int dword_4EC2A8; // weak
-extern int dword_4EC2AC; // weak
 extern std::array<const char*, 25> pPlayerPortraitsNames;
 
 extern std::array< std::array<unsigned char, 25>, 48> byte_4ECF08;
 extern std::array<std::array<unsigned char, 8>, 110> SoundSetAction; // weak
 extern std::array<__int16, 4> pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing;
 extern std::array< std::array<char, 37>, 36> byte_4ED970_skill_learn_ability_by_class_table;
-extern _UNKNOWN unk_4EDF40; // weak
 extern std::array<unsigned int, 2> pHiredNPCsIconsOffsetsX;
 extern std::array<unsigned int, 2> pHiredNPCsIconsOffsetsY;
 extern std::array<int, 2> dword_4EE07C; // weak
-extern _UNKNOWN unk_4EE084; // weak
 extern std::array<__int16, 101> word_4EE088_sound_ids; // weak
 extern std::array<short, 28> word_4EE150;
-extern int dword_4EED78; // weak
-extern _UNKNOWN unk_4EED80; // weak
 extern int ScreenshotFileNumber; // dword_4EFA80
-extern int dword_4EFA84; // weak
-extern void *off_4EFDB0; // weak
-extern int dword_4F031C[]; // weak
 extern std::array<const char *, 19> off_4F03B8; // idb
 extern __int16 word_4F0576[]; // weak
 
@@ -495,12 +376,6 @@
 extern std::array<int, 11> price_for_membership; // weak
 extern std::array<Vec2_int_, 20> pMonsterArenaPlacements;
 extern std::array<__int16, 32> word_4F0F30; // weak
-extern double dbl_4F2870; // weak
-extern int dword_4F288C; // weak
-extern double dbl_4F5372; // weak
-extern int dword_4F5428[]; // weak
-extern int dword_4F542C[]; // weak
-extern _UNKNOWN crtunk_4F54B8; // weak
 extern std::array<int, 500> ai_array_4F5E68;
 extern std::array<int, 500> ai_array_4F6638_actor_ids;
 extern std::array<int, 500> ai_near_actors_targets_pid;
@@ -511,13 +386,9 @@
 extern int dword_4FA9B0[]; // weak
 extern int dword_4FA9B4[]; // weak
 
-extern _UNKNOWN unk_4FAA20; // weak
 extern char byte_4FAA24; // weak
 //extern HWND dword_4FAA28; // idb
 
-
-
-extern int dword_505890; // weak
 extern std::array<unsigned int, 480> pSRZBufferLineOffsets;
 extern int areWeLoadingTexture; // weak
 extern std::array<char, 777> books_num_items_per_page; // weak
@@ -586,7 +457,6 @@
 extern std::array<const char *, 7> aDayNames;
 extern std::array<const char *, 9> aSpellSchoolNames;
 extern std::array<const char *, 7> aAttributeNames;
-extern int dword_507B94; // weak
 extern unsigned int uActiveCharacter;
 extern int dword_507BF0_is_there_popup_onscreen; // weak
 extern int awards_scroll_bar_created; // weak
@@ -597,31 +467,11 @@
 extern std::array<int, 50> dword_50B570; // weak
 extern std::array<int, 50> dword_50B638; // weak
 extern struct stru367 PortalFace;
-/*extern int PortalFace.field_0; // weak
-extern int PortalFace.field_38[]; // idb
-extern int PortalFace._view_transformed_ys[];
-extern int PortalFace.field_128[];
-extern int PortalFace._view_transformed_zs[];
-extern int PortalFace.field_218[];
-extern int PortalFace._view_transformed_xs[];
-extern int PortalFace._screen_space_y[];
-extern int PortalFace.field_3E4[];
-extern int PortalFace.field_2F0[]; // idb
-extern int PortalFace._ys[];
-extern int PortalFace._ys2[]; // idb
-extern int PortalFace._screen_space_x[]; // idb
-extern int PortalFace.field_3D4[]; // weak
-extern int PortalFace._xs[]; // weak
-extern int dword_50BAE8[]; // weak
-extern int PortalFace._xs2[]; // weak
-extern int PortalFace._xs3[]; // weak*/
 extern std::array<int, 100> dword_50BC10; // weak
 extern std::array<int, 100> dword_50BDA0; // weak
 extern std::array<int, 100> dword_50BF30; // weak
 extern char town_portal_caster_id; // weak
 extern int some_active_character; // weak
-extern _UNKNOWN unk_50C190; // weak
-extern int dword_50C968; // weak
 extern std::array<unsigned int, 5> pIconIDs_Turn;
 extern unsigned int uIconID_TurnStop;
 extern unsigned int uIconID_TurnHour;
@@ -632,7 +482,6 @@
 extern int uSpriteID_Spell11; // idb
 extern bool _50C9A0_IsEnchantingInProgress; // weak
 extern int _50C9A8_item_enchantment_timer; // weak
-extern int dword_50C9AC; // weak
 extern int _50C9D0_AfterEnchClickEventId; // weak
 extern int _50C9D4_AfterEnchClickEventSecondParam; // weak
 extern int _50C9D8_AfterEnchClickEventTimeout; // weak
@@ -641,7 +490,6 @@
 //extern int dword_50C9E8; // idb
 //extern int dword_50C9EC[]; // 50C9EC
 extern int dword_50CDC8;
-extern int bProcessorIsNotIntel; // weak
 extern Vec3_int_ layingitem_vel_50FDFC;
 extern char pStartingMapName[32]; // idb
 extern std::array<unsigned __int8, 5> IsPlayerWearingWatersuit;
@@ -659,8 +507,6 @@
 extern int dword_576E28; // weak
 extern int _576E2C_current_minimap_zoom; // weak
 extern __int64 _5773B8_event_timer; // weak
-extern int _5773C0_unused; // weak
-
 
 extern int dword_591084; // weak
 extern struct Actor *pDialogue_SpeakingActor;
@@ -682,7 +528,6 @@
 extern struct Texture *pTexture_591428;
 extern struct Texture *pTexture_outside; // idb
 extern struct Texture *pTexture_Dialogue_Background;
-extern _UNKNOWN unk_597F10; // weak
 extern std::array<char, 2000> byte_5B0938;
 extern int EvtTargetObj; // weak
 extern int _unused_5B5924_is_travel_ui_drawn; // 005B5924
@@ -699,15 +544,13 @@
 extern int dword_5B65D0_dialogue_actor_npc_id; // weak
 extern int dword_5C3418; // weak
 extern int dword_5C341C; // weak
-extern int _5C3420_pDecoration;
 //extern std::array<char, 777> byte_5C3427; // weak
 extern std::array<char, 200> GameUI_Footer_TimedString;
 extern std::array<char, 200> pFooterString;
 extern unsigned int GameUI_Footer_TimeLeft;
 extern int bForceDrawFooter; // weak
-extern int dword_5C35C0; // weak
+extern int _5C35C0_force_party_death; // weak
 extern int bDialogueUI_InitializeActor_NPC_ID; // weak
-extern int dword_5C35C8; // weak
 extern char *p2DEventsTXT_Raw;
 
 extern int dword_5C35D4; // weak
@@ -782,8 +625,6 @@
 extern unsigned int uTextureID_save_up;
 extern unsigned int uTextureID_load_up;
 extern unsigned int uTextureID_loadsave;
-extern _UNKNOWN _69FBB4_ptr_iterator_end; // weak
-extern _UNKNOWN unk_6A0758; // weak
 extern int pSaveListPosition; // weak
 extern unsigned int uLoadGameUI_SelectedSlot;
 extern HWND hInsertCDWindow; // idb
--- a/mm7_unsorted_subs.h	Fri Jan 10 17:42:37 2014 +0600
+++ b/mm7_unsorted_subs.h	Fri Jan 10 17:42:57 2014 +0600
@@ -119,8 +119,6 @@
 void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4);
 unsigned int SkillToMastery(unsigned int skill_value);
 unsigned int __fastcall GetSpellColor(signed int a1);
-unsigned short * MakeScreenshot(signed int width, signed int height);
-void SaveScreenshot(const char *pFilename);
 void __fastcall LoadGame(unsigned int uSlot); // idb
 void SaveGame(bool IsAutoSAve, bool NotSaveWorld);
 void __fastcall DoSavegame(unsigned int uSlot); // idb
@@ -215,14 +213,11 @@
 void DeleteCCharFont();
 bool PlayerCreationUI_Loop();
 unsigned int __fastcall GetMaxMipLevels(unsigned int uDim);
-bool CheckTextureStages();
-bool AreRenderSurfacesOk();
 struct SoundHeader *FindSound_BinSearch(unsigned int uStart, unsigned int uEnd, const char *pName);
 struct SoundData *LoadSound(const char *pSoundName, struct SoundData *pOutBuff, unsigned int uID);
 int __fastcall sub_4AAEA6_transform(struct RenderVertexSoft *a1);
 int __fastcall sub_4AB66C(int, int); // weak
 int GetSoundStrengthByDistanceFromParty(int x, int y, int z);
-struct _DIG_DRIVER *Audio_GetFirstHardwareDigitalDriver(void);
 void PlayLevelMusic();
 unsigned int __fastcall sub_4B0E07(unsigned int uFaceID); // idb
 void sub_4B1447_party_fine(int a1, int a2, int a3);
@@ -230,10 +225,7 @@
 void ShowPopupShopItem();
 void RestAndHeal(__int64 uNumMinutes); // idb
 void GetHouseGoodbyeSpeech();
-int __fastcall _46A6AC_spell_render(int a1, int a2, int a3);
-int __fastcall _46A6AC_spell_render_d3d(int a1, int a2, int a3);
 int __fastcall _46A89E_immolation_effect(int a1, int a2, int a3);
-int sub_46A99B();
 unsigned int GetGravityStrength();
 void UpdateUserInput_and_MapSpecificStuff();
 void BLV_UpdateUserInputAndOther();
--- a/stru6.cpp	Fri Jan 10 17:42:37 2014 +0600
+++ b/stru6.cpp	Fri Jan 10 17:42:57 2014 +0600
@@ -397,8 +397,9 @@
   pStru1->_47829F_sphere_particle(v10, v9, v8, v7, v6);
 }
 
+
 //----- (004A77FD) --------------------------------------------------------
-void stru6::_4A77FD_implosion_particle(SpriteObject *a1)
+void stru6::_4A77FD_implosion_particle_d3d(SpriteObject *a1)
 {
   double v4; // st7@1
   double v5; // st7@2
@@ -497,9 +498,9 @@
            (uDiffuse & 0x00FF0000) >> 16,
            (uDiffuse & 0x0000FF00) >> 8,
            uDiffuse & 0x000000FF,
-           byte_4E94D3);
+           _4E94D3_light_type);
 }
-// 4E94D3: using guessed type char byte_4E94D3;
+// 4E94D3: using guessed type char _4E94D3_light_type;
 
 //----- (004A7A66) --------------------------------------------------------
 void stru6::_4A7A66_miltiple_spell_collision_partifles___like_after_sparks_or_lightning(SpriteObject *a1, unsigned int uDiffuse, unsigned int uTextureID, float a4)
@@ -781,33 +782,6 @@
   return fixpoint_from_float(v5);
 }
 
-//----- (004A80DC) --------------------------------------------------------
-void stru6::_4A80DC_some_stuff_sw(SpriteObject *a2)
-{
-  signed int v3; // ebx@1
-  Particle_sw local_0; // [sp+Ch] [bp-68h]@1
-
-  memset(&local_0, 0, 0x68u);
-  local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_1;
-  local_0.uDiffuse = 0x7E7E7E;
-  local_0.timeToLive = (rand() & 0x7F) + 128;
-  local_0.uTextureID = uTextureID_effpar1;
-  v3 = 8;
-  local_0.flt_28 = 1.0;
-  do
-  {
-    local_0.x = pRnd->GetRandom() * 40.0 + (double)a2->vPosition.x - 20.0;
-    local_0.y = pRnd->GetRandom() * 40.0 + (double)a2->vPosition.y - 20.0;
-    local_0.z = (double)a2->vPosition.z;
-    local_0.r = pRnd->GetRandom() * 800.0 - 400.0;
-    local_0.g = pRnd->GetRandom() * 800.0 - 400.0;
-    local_0.b = pRnd->GetRandom() * 350.0 + 50.0;
-    pGame->pParticleEngine->AddParticle(&local_0);
-    --v3;
-  }
-  while ( v3 );
-}
-
 //----- (004A81CA) --------------------------------------------------------
 bool stru6::_4A81CA(SpriteObject *a2)
 {
@@ -898,7 +872,7 @@
     case 1051: // Fireball hit
     {
       AddMobileLight(a2, 0xFF3C1E, 256);
-      if (pRenderer->pRenderD3D)
+      //if (pRenderer->pRenderD3D)
       {
         result = PID_TYPE(a2->spell_caster_pid);
         if (PID_TYPE(a2->spell_caster_pid) != OBJECT_Actor &&
@@ -1074,8 +1048,8 @@
             if ( result )
               return false;
 //LABEL_63:
-            if ( !pRenderer->pRenderD3D )
-              return true;
+            //if ( !pRenderer->pRenderD3D )
+            //  return true;
             _4A78AE_sparks_spell(a2);
             AddMobileLight(a2, 0x64640F, 128);
             return false;
@@ -1098,10 +1072,10 @@
                 return false;
               if ( result <= 2081 )
               {
-                if ( pRenderer->pRenderD3D )
-                  _4A77FD_implosion_particle(a2);
-                else
-                  _4A80DC_some_stuff_sw(a2);
+                //if ( pRenderer->pRenderD3D )
+                  _4A77FD_implosion_particle_d3d(a2);
+                /*else
+                  _4A80DC_implosion_particle_sw(a2);*/
                 return false;
               }
               v9 = result == 2100;
@@ -1113,8 +1087,8 @@
             AddMobileLight(a2, 0xC8C814, 256);
             return false;
           }
-          if ( !pRenderer->pRenderD3D )
-            return true;
+          //if ( !pRenderer->pRenderD3D )
+          //  return true;
           memcpy(pContainer, "sp18h1", 7);
           pRnd->SetRange(1, 6);
           pContainer[5] = pRnd->GetInRange() + '0';
@@ -1159,8 +1133,8 @@
       }
       if ( result == 4000 )
       {
-        if ( !pRenderer->pRenderD3D )
-          return true;
+        //if ( !pRenderer->pRenderD3D )
+        //  return true;
         _4A7C07(a2);
         return false;
       }
@@ -1202,8 +1176,8 @@
             _4A75CC_single_spell_collision_particle(a2, 0xF00000, uTextureID_effpar1);
           return false;
         }
-            if ( !pRenderer->pRenderD3D )
-              return true;
+            //if ( !pRenderer->pRenderD3D )
+            //  return true;
             _4A78AE_sparks_spell(a2);
             AddMobileLight(a2, 0x64640F, 128);
             return false;
@@ -1323,8 +1297,8 @@
       return false;
     }
     AddMobileLight(a2, 0xFFFFFFu, 128);
-    if ( !pRenderer->pRenderD3D )
-      return true;
+    //if ( !pRenderer->pRenderD3D )
+    //  return true;
     AddProjectile(a2, 100, -1);
     return false;
   }
@@ -1443,7 +1417,7 @@
 void stru6::FadeScreen__like_Turn_Undead_and_mb_Armageddon(unsigned int uDiffuseColor, unsigned int uFadeTime)
 {
   this->uFadeTime = uFadeTime;
-  this->uFadeTime2 = uFadeTime;
+  this->uFadeLength = uFadeTime;
   this->uFadeColor = uDiffuseColor;
 }
 
@@ -1459,7 +1433,7 @@
 {
   double v4; // st7@4
   double v5; // st6@4
-  double v6; // st7@4
+  //double v6; // st7@4
   float v7; // ST14_4@6
   unsigned int v8; // ST14_4@8
   unsigned int v9; // eax@8
@@ -1475,7 +1449,6 @@
   const char *v19; // [sp+4h] [bp-E8h]@0
   int v20; // [sp+8h] [bp-E4h]@0
   unsigned int v21; // [sp+Ch] [bp-E0h]@0
-  RenderBillboardTransform_local0 vsr; // [sp+10h] [bp-DCh]@10
   RenderVertexD3D3 vd3d[4]; // [sp+60h] [bp-8Ch]@9
   int v24; // [sp+E0h] [bp-Ch]@10
   SpriteFrame *v70; // [sp+E4h] [bp-8h]@8
@@ -1488,16 +1461,15 @@
   }
 
   field_204 = 0;
-  v26 = uFadeTime;
-  if ( v26 > 0 )
+  if ( uFadeTime > 0 )
   {
-    v4 = (double)(signed int)v26 / (double)uFadeTime2;
+    v4 = (double)uFadeTime / (double)uFadeLength;
     v5 = 1.0 - v4 * v4;
-    v6 = v5;
+    //v6 = v5;
     if ( v5 > 0.9 )
-      v6 = 1.0 - (v5 - 0.9) * 10.0;
-    v7 = v6;
-    pRenderer->_4A52F1(uFadeColor, v7);
+      v5 = 1.0 - (v5 - 0.9) * 10.0;
+    v7 = v5;
+    pRenderer->ScreenFade(uFadeColor, v7);
     uFadeTime -= pEventTimer->uTimeElapsed;
   }
 
@@ -1511,7 +1483,7 @@
     v11 = v10->pHwSpriteIDs[0];
     v70 = v10;
     uAnimLength -= pEventTimer->uTimeElapsed;
-    if ( pRenderer->pRenderD3D )
+    //if ( pRenderer->pRenderD3D )
     {
       v12 = (double)(signed int)pViewport->uViewportTL_X;
       vd3d[0].pos.x = v12;
@@ -1550,26 +1522,10 @@
       vd3d[1].texcoord.y = 1.0;
       vd3d[2].texcoord.y = 1.0;
       vd3d[3].texcoord.y = 0.0;
-      pRenderer->pRenderD3D->pDevice->SetTexture(
-        0,
-        pSprites_LOD->pHardwareSprites[v11].pTexture);
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE);
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE);
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE);
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS);
-      pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
-        D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, vd3d, 4, 28);
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE));
-      ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE);
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE);
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE);
-      pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS);
+
+      pRenderer->DrawSpecialEffectsQuad(vd3d, pSprites_LOD->pHardwareSprites[v11].pTexture);
     }
-    else
+    /*else
     {
       vsr.pTarget = pRenderer->pTargetSurface;
       vsr.sParentBillboardID = -1;
@@ -1595,7 +1551,7 @@
       vsr.uFlags = 0;
       if ( v11 >= 0 )
         pSprites_LOD->pSpriteHeaders[v11].DrawSprite_sw(&vsr, 1);
-    }
+    }*/
   }
 }
 
--- a/stru6.h	Fri Jan 10 17:42:37 2014 +0600
+++ b/stru6.h	Fri Jan 10 17:42:57 2014 +0600
@@ -122,7 +122,7 @@
   void _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(struct SpriteObject *a2, unsigned int uDiffuse, unsigned int uTextureID);
   void _4A75CC_single_spell_collision_particle(struct SpriteObject *a1, unsigned int uDiffuse, unsigned int uTextureID);
   void _4A7688_fireball_collision_particle(struct SpriteObject *a2);
-  void _4A77FD_implosion_particle(struct SpriteObject *a1);
+  void _4A77FD_implosion_particle_d3d(struct SpriteObject *a1);
   void _4A78AE_sparks_spell(struct SpriteObject *a1);
   void _4A7948_mind_blast_after_effect(struct SpriteObject *a1);
   bool AddMobileLight(struct SpriteObject *a1, unsigned int uDiffuse, int uRadius);
@@ -132,7 +132,7 @@
   void _4A7E89_sparkles_on_actor_after_it_casts_buff(struct Actor *pActor, unsigned int uDiffuse);
   void _4A7F74(int x, int y, int z);
   int _4A806F(struct Actor *pActor);
-  void _4A80DC_some_stuff_sw(struct SpriteObject *a2);
+  //void _4A80DC_implosion_particle_sw(struct SpriteObject *a2);
   bool _4A81CA(struct SpriteObject *a2);
   void SetPlayerBuffAnim(unsigned __int16 uSpellID, unsigned __int16 uPlayerID);
   void FadeScreen__like_Turn_Undead_and_mb_Armageddon(unsigned int uDiffuseColor, unsigned int uFadeTime);
@@ -156,7 +156,7 @@
   int field_5D0;
   int uAnimLength;
   int uFadeTime;
-  int uFadeTime2;
+  int uFadeLength;
   int uFadeColor;
   unsigned int uTextureID_effpar1;
   unsigned int uTextureID_effpar2;