changeset 2539:407263babde8

Removed GammaControl
author a.parshin
date Sat, 09 May 2015 12:19:09 +0200
parents c9182a87095e
children abc6a9d079b9
files Build/Visual Studio 2013/World of Might and Magic.vcxproj Build/Visual Studio 2013/World of Might and Magic.vcxproj.filters Engine/Game.cpp Engine/Game.h Engine/Graphics/GammaControl.cpp Engine/Graphics/GammaControl.h Engine/Graphics/Render.cpp Engine/mm7_data.cpp Engine/mm7_data.h _deleted.cpp
diffstat 10 files changed, 274 insertions(+), 289 deletions(-) [+]
line wrap: on
line diff
--- a/Build/Visual Studio 2013/World of Might and Magic.vcxproj	Sat May 09 11:29:44 2015 +0200
+++ b/Build/Visual Studio 2013/World of Might and Magic.vcxproj	Sat May 09 12:19:09 2015 +0200
@@ -98,7 +98,6 @@
     <ClCompile Include="..\..\Engine\Graphics\BSPModel.cpp" />
     <ClCompile Include="..\..\Engine\Graphics\DecalBuilder.cpp" />
     <ClCompile Include="..\..\Engine\Graphics\DecorationList.cpp" />
-    <ClCompile Include="..\..\Engine\Graphics\GammaControl.cpp" />
     <ClCompile Include="..\..\Engine\Graphics\Indoor.cpp" />
     <ClCompile Include="..\..\Engine\Graphics\IndoorCameraD3D.cpp" />
     <ClCompile Include="..\..\Engine\Graphics\Level\Decoration.cpp" />
@@ -260,7 +259,6 @@
     <ClInclude Include="..\..\Engine\Graphics\BSPModel.h" />
     <ClInclude Include="..\..\Engine\Graphics\DecalBuilder.h" />
     <ClInclude Include="..\..\Engine\Graphics\DecorationList.h" />
-    <ClInclude Include="..\..\Engine\Graphics\GammaControl.h" />
     <ClInclude Include="..\..\Engine\Graphics\Indoor.h" />
     <ClInclude Include="..\..\Engine\Graphics\IndoorCameraD3D.h" />
     <ClInclude Include="..\..\Engine\Graphics\IRender.h" />
--- a/Build/Visual Studio 2013/World of Might and Magic.vcxproj.filters	Sat May 09 11:29:44 2015 +0200
+++ b/Build/Visual Studio 2013/World of Might and Magic.vcxproj.filters	Sat May 09 12:19:09 2015 +0200
@@ -321,9 +321,6 @@
     <ClCompile Include="..\..\Engine\Graphics\IndoorCameraD3D.cpp">
       <Filter>Engine\Graphics</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\Engine\Graphics\GammaControl.cpp">
-      <Filter>Engine\Graphics</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\Engine\Graphics\LightmapBuilder.cpp">
       <Filter>Engine\Graphics</Filter>
     </ClCompile>
@@ -1023,9 +1020,6 @@
     <ClInclude Include="..\..\Engine\Graphics\IndoorCameraD3D.h">
       <Filter>Engine\Graphics</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\Engine\Graphics\GammaControl.h">
-      <Filter>Engine\Graphics</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\Engine\Graphics\IRender.h">
       <Filter>Engine\Graphics</Filter>
     </ClInclude>
--- a/Engine/Game.cpp	Sat May 09 11:29:44 2015 +0200
+++ b/Engine/Game.cpp	Sat May 09 12:19:09 2015 +0200
@@ -671,7 +671,6 @@
       uFlags2 |= 1;
       uNumStationaryLights_in_pStationaryLightsStack = pStationaryLightsStack->uNumLightsActive;
     }
-    _44E904();
     return true;
 }
 
@@ -873,11 +872,8 @@
   field_E0C = 0;
   field_E10 = 0;
   uNumStationaryLights_in_pStationaryLightsStack = 0;
-  bGammaControlInitialized = false;
   uFlags = 0;
   uFlags2 = 0;
-  uSomeGammaStartTime = 0;
-  uSomeGammaDeltaTime = 0;
 
   //pThreadWardInstance = new ThreadWard;
   pThreadWardInstance = nullptr;
@@ -896,7 +892,7 @@
   //pCShow = new CShow;
   pCShow = nullptr;
   pKeyboardInstance = new Keyboard;
-  pGammaController = new GammaController;
+  //pGammaController = new GammaController;
 
   uFlags |= 0x0800;
   uFlags2 |= 0x24;
@@ -907,7 +903,7 @@
 //----- (0044E7F3) --------------------------------------------------------
 Game::~Game()
 {
-  delete pGammaController;
+  //delete pGammaController;
   delete pKeyboardInstance;
 /*delete pCShow;
   delete pStru12Instance;
@@ -923,83 +919,6 @@
 //delete pThreadWardInstance;
 }
 
-//----- (0044E904) --------------------------------------------------------
-void Game::_44E904()
-{
-  //Game *v1; // esi@1
-  unsigned __int64 v2; // qax@1
-  unsigned int v3; // ecx@1
-  int v4; // edi@1
-  unsigned __int8 v5; // cf@7
-  double v6; // st7@13
-  double v7; // st7@15
-  signed __int64 v8; // [sp+Ch] [bp-8h]@1
-
-  //v1 = this;
-  v2 = pEventTimer->Time();
-  v4 = (v2 - uSomeGammaStartTime) >> 32;
-  v3 = v2 - LODWORD(uSomeGammaStartTime);
-  v8 = v2 - uSomeGammaStartTime;
-  if ( v4 < 0
-    || SHIDWORD(v2) < ((unsigned int)v2 < LODWORD(uSomeGammaStartTime)) + HIDWORD(uSomeGammaStartTime) | v4 == 0
-    && v3 <= 0x80 )
-  {
-    if ( v4 < 0 )
-	{
-		v3 = 0;
-		v4 = 0;
-		uSomeGammaStartTime = v2;
-		v8 = __PAIR__(v4, v3);
-	}
-  }
-  else
-  {
-    if ( uSomeGammaDeltaTime )
-    {
-      LODWORD(uSomeGammaDeltaTime) = 0;
-      HIDWORD(uSomeGammaDeltaTime) = 0;
-    }
-    else
-    {
-      LODWORD(uSomeGammaDeltaTime) = v3;
-      HIDWORD(uSomeGammaDeltaTime) = v4;
-    }
-    v5 = __CFADD__(v3, -128);
-    v3 -= 128;
-    v4 = v5 + v4 - 1;
-    uSomeGammaStartTime = v2;
-    v8 = __PAIR__(v4, v3);
-  }
-  if ( uSomeGammaDeltaTime )
-    v6 = (double)(signed __int64)(uSomeGammaDeltaTime - __PAIR__(v4, v3));
-  else
-    v6 = (double)v8;
-  v7 = v6 * 0.0078125;
-  if ( v7 < 0.0 || v7 <= 1.0 )
-  {
-    if ( v7 < 0.0 )
-      v7 = 0.0;
-  }
-  else
-    v7 = 1.0;
-  //if ( pRenderer->pRenderD3D )
-    fSaturation = v7;
-  //else
-  //  fSaturation = (1.0 - 0.5) * v7 + 0.5;
-}
-
-//----- (0044EA17) --------------------------------------------------------
-bool Game::InitializeGammaController()
-{
-  //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
-      //pVersion->pVersionInfo.dwMajorVersion != 4 )
-    pGammaController->InitializeFromSurface(pRenderer->pFrontBuffer4);
-
-  bGammaControlInitialized = true;
-  uSomeGammaStartTime = pEventTimer->Time();
-  return true;
-}
-
 //----- (0044EA5E) --------------------------------------------------------
 bool Game::PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter)
 {
@@ -1675,7 +1594,7 @@
               continue;
             }
             v19 = (double)(signed int)uGammaPos * 0.1 + 0.6;
-            pGame->pGammaController->Initialize(v19);
+            //pGame->pGammaController->Initialize(v19);
             GUIWindow::Create(21, 161, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderLeft, (char *)1);
             pAudioPlayer->PlaySound(SOUND_ClickMovingSelector, 0, 0, -1, 0, 0, 0, 0);
             continue;
@@ -1686,7 +1605,7 @@
             if ( (signed int)uGammaPos <= 9 )
             {
               v21 = (double)(signed int)uGammaPos * 0.1 + 0.6;
-              pGame->pGammaController->Initialize(v21);
+              //pGame->pGammaController->Initialize(v21);
               GUIWindow::Create(213, 161, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderRight, (char *)1);
               pAudioPlayer->PlaySound(SOUND_ClickMovingSelector, 0, 0, -1, 0, 0, 0, 0);
               continue;
@@ -1697,7 +1616,7 @@
           {
             uGammaPos = (pMouse->GetCursorPos(&a2)->x - 42) / 17;
             v22 = (double)(signed int)uGammaPos * 0.1 + 0.6;
-            pGame->pGammaController->Initialize(v22);
+            //pGame->pGammaController->Initialize(v22);
           }
           pAudioPlayer->PlaySound(SOUND_ClickMovingSelector, 0, 0, -1, 0, 0, 0, 0);
           continue;
@@ -2139,8 +2058,6 @@
                         WriteWindowsRegistryInt("Tinting", pRenderer->bTinting);
                         WriteWindowsRegistryInt("Bloodsplats", (LOBYTE(pGame->uFlags2) >> 5) & 1);
                       }
-                      /*if ( !pRenderer->bWindowMode )
-                        WriteWindowsRegistryInt("GammaPos", uGammaPos);*/
 
                       stru_506E40.Release();
                       break;
@@ -5263,7 +5180,7 @@
 	bShowDamage = ReadWindowsRegistryInt("ShowDamage", 1) != 0;
 
 	uGammaPos = min(4, ReadWindowsRegistryInt("GammaPos", 4));
-	pGame->pGammaController->Initialize(uGammaPos * 0.1 + 0.6);
+	//pGame->pGammaController->Initialize(uGammaPos * 0.1 + 0.6);
 
 	if (ReadWindowsRegistryInt("Bloodsplats", 1))
 		pGame->uFlags2 |= GAME_FLAGS_2_DRAW_BLOODSPLATS;
@@ -5284,7 +5201,7 @@
 	{
 	case 0: // undefined turn option
 		__debugbreak(); // really shouldn't use this mode
-		uTurnSpeed = (unsigned int)uCPUSpeed < 199 ? 128 : 64; // adjust turn speed to estimated fps
+        uTurnSpeed = 64; //(unsigned int)uCPUSpeed < 199/*MHz*/ ? 128 : 64; // adjust turn speed to estimated fps
 		break;
 
 	case 1:             // 16x
@@ -5394,7 +5311,6 @@
 	dword_576E28 = 9;
 }
 
-bool new_sky = false;            //new sky(need texture)
 int max_flight_height = 4000;    //maximum altitude
 bool use_MMT = false;
 bool use_music_folder = true;
@@ -5405,9 +5321,6 @@
 {
 	IntegrityTest();
 
-	char test[1024];
-	sprintfex(test, "^Pi[%s]: знахар^R[ь;ка;]", "Золтан");
-
 	lua = new LuaVM;
 	lua->Initialize();
 
@@ -5436,20 +5349,10 @@
 		}
 		if (wcsstr(pCmdLine, L"-nocd"))
 			bNoCD = true;
-		if (wcsstr(pCmdLine, L"-new_sky"))
-			new_sky = true;
 		if (wcsstr(pCmdLine, L"-nomarg"))
 			bNoMargareth = true;
 	}
 
-	/*v8 = _4AC1C9_get_cpu_speed(0, (Vec4_int_ *)a2);
-	Rect.left = *(int *)v8;
-	Rect.top = *(int *)(v8 + 4);
-	Rect.right = *(int *)(v8 + 8);
-	Rect.bottom = *(int *)(v8 + 12);
-	uCPUSpeed = Rect.bottom;*/
-	uCPUSpeed = 2048; // about 2GHz
-
 	//_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF );//Ritor1: for memory test
 
 	if (!MM7_Initialize(640, 480))
@@ -5467,7 +5370,6 @@
 	//ShowIntroVideo_and_LoadingScreen();
 	WriteWindowsRegistryInt("Ran once", 1);
 	dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000;
-	pGame->InitializeGammaController();
 	SecondaryInitialization();
 	//pRenderer->SetRasterClipRect(0, 0, window->GetWidth() - 1, window->GetHeight() - 1);
 	FinalInitialization();
--- a/Engine/Game.h	Sat May 09 11:29:44 2015 +0200
+++ b/Engine/Game.h	Sat May 09 12:19:09 2015 +0200
@@ -95,8 +95,8 @@
 
 
 public:
-  void _44E904();
-  bool InitializeGammaController();
+  //void _44E904_gamma_saturation_adjust();
+  //bool InitializeGammaController();
   bool PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, struct Vis_SelectionFilter *sprite_filter, struct Vis_SelectionFilter *face_filter);
   bool PickKeyboard(bool bOutline, struct Vis_SelectionFilter *sprite_filter, struct Vis_SelectionFilter *face_filter);
   void OutlineSelection();
@@ -151,12 +151,12 @@
   int field_E0C;
   __int64 field_E10;
   int uNumStationaryLights_in_pStationaryLightsStack;
-  unsigned int bGammaControlInitialized;
+  unsigned int __depricated1;//unsigned int bGammaControlInitialized;
   unsigned int uFlags;
   unsigned int uFlags2;
   float fSaturation;
-  unsigned __int64 uSomeGammaStartTime;
-  __int64 uSomeGammaDeltaTime;
+  unsigned __int64 __depricated2;//unsigned __int64 uSomeGammaStartTime;
+  unsigned __int64 __depricated3;//__int64 uSomeGammaDeltaTime;
   void/*ThreadWard*/ *pThreadWardInstance;
   ParticleEngine *pParticleEngine;
   Mouse *pMouseInstance;
@@ -170,7 +170,7 @@
   void/*stru12*/ *pStru12Instance;
   void/*CShow*/ *pCShow;
   Keyboard *pKeyboardInstance;
-  GammaController *pGammaController;
+  void *__depricated_4;//GammaController *pGammaController;
   int field_E74;
 };
 #pragma pack(pop)
--- a/Engine/Graphics/GammaControl.cpp	Sat May 09 11:29:44 2015 +0200
+++ b/Engine/Graphics/GammaControl.cpp	Sat May 09 12:19:09 2015 +0200
@@ -1,138 +0,0 @@
-#define _CRTDBG_MAP_ALLOC
-#include <stdlib.h>
-#include <crtdbg.h>
-
-#define _CRT_SECURE_NO_WARNINGS
-#include <string>
-
-#include "GammaControl.h"
-#include "Render.h"
-
-#include "../mm7_data.h"
-
-
-
-//----- (0044F324) --------------------------------------------------------
-void GammaController::GetRamp()
-{
-  if (pGammaControl)
-    ErrD3D(pGammaControl->GetGammaRamp(0, &pDefaultRamp));
-}
-
-//----- (0044F377) --------------------------------------------------------
-double GammaController::_44F377(DDGAMMARAMP *a1)
-{
-  double v2; // st7@1
-  unsigned __int16 *v3; // ecx@1
-  double v4; // st6@2
-  signed int v6; // [sp+0h] [bp-8h]@1
-  signed int v7; // [sp+4h] [bp-4h]@1
-
-  v2 = 0.0;
-  v6 = 256;
-  v3 = a1->green;
-  for ( v7 = 0; v7 < 256; ++v7 )
-  {
-    v4 = ((double)*(v3 - 256) + (double)v3[256] + (double)*v3) * 0.000015259022 * 0.33333334;
-    if ( v4 == 0.0 )
-      --v6;
-    else
-      v2 = v2 + (double)v7 * 0.0039215689 / v4;
-    ++v3;
-  }
-  if ( v6 )
-    return v2 / (double)v6;
-  else
-    return 1.0;
-}
-
-//----- (0044F408) --------------------------------------------------------
-void GammaController::SetGammaRamp(DDGAMMARAMP *pRamp)
-{
-  if (pGammaControl)
-    ErrD3D(pGammaControl->SetGammaRamp(0, pRamp));
-}
-
-//----- (0044F45B) --------------------------------------------------------
-int GammaController::InitGammaRamp(DDGAMMARAMP *pRamp)
-{
-  unsigned __int16 *v2; // esi@1
-  double v3; // st7@2
-  signed __int64 v4; // qax@3
-  signed int v6; // [sp+Ch] [bp-4h]@1
-
-  v2 = pRamp->green;
-  for ( v6 = 0; v6 < 256; ++v6 )
-  {
-    v3 = (double)v6 * 0.0039215689 * this->fGamma;
-    if ( v3 >= 1.0 || (v4 = (signed __int64)(v3 * 65535.0), (signed int)v4 > 65535) )
-      LODWORD(v4) = 65535;
-    else if ( (signed int)v4 < 0 )
-      LODWORD(v4) = 0;
-	else
-	{
-    if ( (signed int)v4 > 65535 )
-      LODWORD(v4) = 65535;
-	}
-    v2[256] = v4;
-    *v2 = v4;
-    *(v2 - 256) = v4;
-    ++v2;
-  }
-  return v4;
-}
-
-//----- (0044F4D9) --------------------------------------------------------
-void GammaController::Initialize(float gamma)
-{
-  double v3; // st7@3
-  double v4; // st6@4
-
-  //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
-      //pVersion->pVersionInfo.dwMajorVersion != 4)
-  {
-    InitializeFromSurface(pRenderer->pFrontBuffer4);
-    v3 = 2.8;
-    if ( gamma <= 2.8f )
-      v4 = gamma;
-    else
-      v4 = 2.8;
-    if ( v4 >= 0.1f )
-    {
-      if ( gamma <= 2.8f )
-        v3 = gamma;
-    }
-    else
-      v3 = 0.1;
-    this->fGamma = v3;
-    InitGammaRamp(&this->field_60C);
-    SetGammaRamp(&this->field_60C);
-  }
-}
-
-//----- (0044F215) --------------------------------------------------------
-GammaController::GammaController()
-{
-  static float flt_4D8670_default_gamma = 1.0f;
-
-  pGammaControl = nullptr;
-  fGamma = flt_4D8670_default_gamma;
-}
-
-//----- (0044F24B) --------------------------------------------------------
-void GammaController::InitializeFromSurface(IDirectDrawSurface4 *a2)
-{
-  this->pSurface = a2;
-  if ( this->pGammaControl )
-  {
-    this->pGammaControl->Release();
-    this->pGammaControl = 0;
-  }
-  if ( pRenderer->IsGammaSupported() )
-  {
-    ErrD3D(a2->QueryInterface(IID_IDirectDrawGammaControl, (LPVOID *)&this->pGammaControl));
-    GetRamp();
-    memcpy(&this->field_60C, &this->pDefaultRamp, 0x600u);
-    fGamma = _44F377(&this->field_60C);
-  }
-}
\ No newline at end of file
--- a/Engine/Graphics/GammaControl.h	Sat May 09 11:29:44 2015 +0200
+++ b/Engine/Graphics/GammaControl.h	Sat May 09 12:19:09 2015 +0200
@@ -1,29 +1,1 @@
-#pragma once
-#include "lib\legacy_dx\d3d.h"
 
-#pragma pack(push, 1)
-class GammaController
-{
-public:
-  GammaController();
-  inline ~GammaController() {} //----- (0044F22E)
-  
-  void Initialize/*_44F4D9*/(float gamma);
-
-  void GetRamp();
-  double _44F377(DDGAMMARAMP *a1);
-  void SetGammaRamp(DDGAMMARAMP *pRamp);
-  int InitGammaRamp(DDGAMMARAMP *pRamp);
-
-  /*protected*/void InitializeFromSurface(struct IDirectDrawSurface4 *a2);
-
-
-
-  void ( ***vdestructor_ptr)(GammaController *, bool);
-  IDirectDrawSurface4 *pSurface;
-  IDirectDrawGammaControl *pGammaControl;
-  DDGAMMARAMP pDefaultRamp;
-  DDGAMMARAMP field_60C;
-  float fGamma;//field_C0C;
-};
-#pragma pack(pop)
--- a/Engine/Graphics/Render.cpp	Sat May 09 11:29:44 2015 +0200
+++ b/Engine/Graphics/Render.cpp	Sat May 09 12:19:09 2015 +0200
@@ -7851,8 +7851,6 @@
       //SetWindowLongA(hWnd, -16, 0x10000000u);
       window->SetFullscreenMode();
       pRenderer->InitializeFullscreen();
-      v0 = (double)(signed int)uGammaPos * 0.1 + 0.6;
-      pGame->pGammaController->Initialize(v0);
     }
     else
     {
--- a/Engine/mm7_data.cpp	Sat May 09 11:29:44 2015 +0200
+++ b/Engine/mm7_data.cpp	Sat May 09 12:19:09 2015 +0200
@@ -967,7 +967,6 @@
 int pSaveListPosition; // weak
 unsigned int uLoadGameUI_SelectedSlot;
 HWND hInsertCDWindow; // idb
-int uCPUSpeed; // weak
 char cMM7GameCDDriveLetter; // idb
 MENU_STATE sCurrentMenuID;
 unsigned int uGameState;
--- a/Engine/mm7_data.h	Sat May 09 11:29:44 2015 +0200
+++ b/Engine/mm7_data.h	Sat May 09 12:19:09 2015 +0200
@@ -630,7 +630,6 @@
 extern int pSaveListPosition; // weak
 extern unsigned int uLoadGameUI_SelectedSlot;
 extern HWND hInsertCDWindow; // idb
-extern int uCPUSpeed; // weak
 extern char cMM7GameCDDriveLetter; // idb
 extern enum MENU_STATE sCurrentMenuID;
 extern unsigned int uGameState;
--- a/_deleted.cpp	Sat May 09 11:29:44 2015 +0200
+++ b/_deleted.cpp	Sat May 09 12:19:09 2015 +0200
@@ -14663,4 +14663,265 @@
   bStopBeforeSchedule = 0;
   PlayFullscreenMovie(MOVIE_Death, true);
 }
+
+
+
+
+
+
+
+
+
+
+
+
+#pragma once
+#include "lib\legacy_dx\d3d.h"
+
+#pragma pack(push, 1)
+class GammaController
+{
+public:
+GammaController();
+inline ~GammaController() {} //----- (0044F22E)
+
+void Initialize(float gamma); // 44F4D9
+
+void GetRamp();
+double _44F377(DDGAMMARAMP *a1);
+void SetGammaRamp(DDGAMMARAMP *pRamp);
+int InitGammaRamp(DDGAMMARAMP *pRamp);
+
+void InitializeFromSurface(struct IDirectDrawSurface4 *a2);
+
+
+
+void(***vdestructor_ptr)(GammaController *, bool);
+IDirectDrawSurface4 *pSurface;
+IDirectDrawGammaControl *pGammaControl;
+DDGAMMARAMP pDefaultRamp;
+DDGAMMARAMP field_60C;
+float fGamma;//field_C0C;
+};
+#pragma pack(pop)
+
+
+
+#define _CRTDBG_MAP_ALLOC
+#include <stdlib.h>
+#include <crtdbg.h>
+
+#define _CRT_SECURE_NO_WARNINGS
+#include <string>
+
+#include "GammaControl.h"
+#include "Render.h"
+
+#include "../mm7_data.h"
+
+
+
+//----- (0044F324) --------------------------------------------------------
+void GammaController::GetRamp()
+{
+if (pGammaControl)
+ErrD3D(pGammaControl->GetGammaRamp(0, &pDefaultRamp));
+}
+
+//----- (0044F377) --------------------------------------------------------
+double GammaController::_44F377(DDGAMMARAMP *a1)
+{
+double v2; // st7@1
+unsigned __int16 *v3; // ecx@1
+double v4; // st6@2
+signed int v6; // [sp+0h] [bp-8h]@1
+signed int v7; // [sp+4h] [bp-4h]@1
+
+v2 = 0.0;
+v6 = 256;
+v3 = a1->green;
+for ( v7 = 0; v7 < 256; ++v7 )
+{
+v4 = ((double)*(v3 - 256) + (double)v3[256] + (double)*v3) * 0.000015259022 * 0.33333334;
+if ( v4 == 0.0 )
+--v6;
+else
+v2 = v2 + (double)v7 * 0.0039215689 / v4;
+++v3;
+}
+if ( v6 )
+return v2 / (double)v6;
+else
+return 1.0;
+}
+
+//----- (0044F408) --------------------------------------------------------
+void GammaController::SetGammaRamp(DDGAMMARAMP *pRamp)
+{
+if (pGammaControl)
+ErrD3D(pGammaControl->SetGammaRamp(0, pRamp));
+}
+
+//----- (0044F45B) --------------------------------------------------------
+int GammaController::InitGammaRamp(DDGAMMARAMP *pRamp)
+{
+unsigned __int16 *v2; // esi@1
+double v3; // st7@2
+signed __int64 v4; // qax@3
+signed int v6; // [sp+Ch] [bp-4h]@1
+
+v2 = pRamp->green;
+for ( v6 = 0; v6 < 256; ++v6 )
+{
+v3 = (double)v6 * 0.0039215689 * this->fGamma;
+if ( v3 >= 1.0 || (v4 = (signed __int64)(v3 * 65535.0), (signed int)v4 > 65535) )
+LODWORD(v4) = 65535;
+else if ( (signed int)v4 < 0 )
+LODWORD(v4) = 0;
+else
+{
+if ( (signed int)v4 > 65535 )
+LODWORD(v4) = 65535;
+}
+v2[256] = v4;
+*v2 = v4;
+*(v2 - 256) = v4;
+++v2;
+}
+return v4;
+}
+
+//----- (0044F4D9) --------------------------------------------------------
+void GammaController::Initialize(float gamma)
+{
+double v3; // st7@3
+double v4; // st6@4
+
+//if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
+//pVersion->pVersionInfo.dwMajorVersion != 4)
+{
+InitializeFromSurface(pRenderer->pFrontBuffer4);
+v3 = 2.8;
+if ( gamma <= 2.8f )
+v4 = gamma;
+else
+v4 = 2.8;
+if ( v4 >= 0.1f )
+{
+if ( gamma <= 2.8f )
+v3 = gamma;
+}
+else
+v3 = 0.1;
+this->fGamma = v3;
+InitGammaRamp(&this->field_60C);
+SetGammaRamp(&this->field_60C);
+}
+}
+
+//----- (0044F215) --------------------------------------------------------
+GammaController::GammaController()
+{
+static float flt_4D8670_default_gamma = 1.0f;
+
+pGammaControl = nullptr;
+fGamma = flt_4D8670_default_gamma;
+}
+
+//----- (0044F24B) --------------------------------------------------------
+void GammaController::InitializeFromSurface(IDirectDrawSurface4 *a2)
+{
+this->pSurface = a2;
+if ( this->pGammaControl )
+{
+this->pGammaControl->Release();
+this->pGammaControl = 0;
+}
+if ( pRenderer->IsGammaSupported() )
+{
+ErrD3D(a2->QueryInterface(IID_IDirectDrawGammaControl, (LPVOID *)&this->pGammaControl));
+GetRamp();
+memcpy(&this->field_60C, &this->pDefaultRamp, 0x600u);
+fGamma = _44F377(&this->field_60C);
+}
+}
+
+
+
+
+
+//----- (0044E904) --------------------------------------------------------
+void Game::_44E904_gamma_saturation_adjust()
+{
+//Game *v1; // esi@1
+unsigned __int64 v2; // qax@1
+unsigned int v3; // ecx@1
+int v4; // edi@1
+unsigned __int8 v5; // cf@7
+double v6; // st7@13
+double v7; // st7@15
+signed __int64 v8; // [sp+Ch] [bp-8h]@1
+
+//v1 = this;
+v2 = pEventTimer->Time();
+v4 = (v2 - uSomeGammaStartTime) >> 32;
+v3 = v2 - LODWORD(uSomeGammaStartTime);
+v8 = v2 - uSomeGammaStartTime;
+if ( v4 < 0
+|| SHIDWORD(v2) < ((unsigned int)v2 < LODWORD(uSomeGammaStartTime)) + HIDWORD(uSomeGammaStartTime) | v4 == 0
+&& v3 <= 0x80 )
+{
+if ( v4 < 0 )
+{
+v3 = 0;
+v4 = 0;
+uSomeGammaStartTime = v2;
+v8 = __PAIR__(v4, v3);
+}
+}
+else
+{
+if ( uSomeGammaDeltaTime )
+{
+uSomeGammaDeltaTime = 0;
+}
+else
+{
+LODWORD(uSomeGammaDeltaTime) = v3;
+HIDWORD(uSomeGammaDeltaTime) = v4;
+}
+v5 = __CFADD__(v3, -128);
+v3 -= 128;
+v4 = v5 + v4 - 1;
+uSomeGammaStartTime = v2;
+v8 = __PAIR__(v4, v3);
+}
+if ( uSomeGammaDeltaTime )
+v6 = (double)(signed __int64)(uSomeGammaDeltaTime - __PAIR__(v4, v3));
+else
+v6 = (double)v8;
+v7 = v6 * 0.0078125;
+if ( v7 < 0.0 || v7 <= 1.0 )
+{
+if ( v7 < 0.0 )
+v7 = 0.0;
+}
+else
+v7 = 1.0;
+//if ( pRenderer->pRenderD3D )
+fSaturation = v7;
+//else
+//  fSaturation = (1.0 - 0.5) * v7 + 0.5;
+}
+
+//----- (0044EA17) --------------------------------------------------------
+bool Game::InitializeGammaController()
+{
+//if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
+//pVersion->pVersionInfo.dwMajorVersion != 4 )
+pGammaController->InitializeFromSurface(pRenderer->pFrontBuffer4);
+
+uSomeGammaStartTime = pEventTimer->Time();
+return true;
+}
 */
\ No newline at end of file