comparison GammaControl.cpp @ 2268:fd788d2e9585

EventProcessor cleaned and ODM_NearClip fix
author Ritor1
date Sun, 09 Mar 2014 22:39:59 +0600
parents aff7a7b072b7
children f4af3b203f65
comparison
equal deleted inserted replaced
2267:6532bbac1a9e 2268:fd788d2e9585
21 double GammaController::_44F377(DDGAMMARAMP *a1) 21 double GammaController::_44F377(DDGAMMARAMP *a1)
22 { 22 {
23 double v2; // st7@1 23 double v2; // st7@1
24 unsigned __int16 *v3; // ecx@1 24 unsigned __int16 *v3; // ecx@1
25 double v4; // st6@2 25 double v4; // st6@2
26 double result; // st7@7
27 signed int v6; // [sp+0h] [bp-8h]@1 26 signed int v6; // [sp+0h] [bp-8h]@1
28 signed int v7; // [sp+4h] [bp-4h]@1 27 signed int v7; // [sp+4h] [bp-4h]@1
29 28
30 v7 = 0;
31 v2 = 0.0; 29 v2 = 0.0;
32 v6 = 256; 30 v6 = 256;
33 v3 = a1->green; 31 v3 = a1->green;
34 do 32 for ( v7 = 0; v7 < 256; ++v7 )
35 { 33 {
36 v4 = ((double)*(v3 - 256) + (double)v3[256] + (double)*v3) * 0.000015259022 * 0.33333334; 34 v4 = ((double)*(v3 - 256) + (double)v3[256] + (double)*v3) * 0.000015259022 * 0.33333334;
37 if ( v4 == 0.0 ) 35 if ( v4 == 0.0 )
38 --v6; 36 --v6;
39 else 37 else
40 v2 = v2 + (double)v7 * 0.0039215689 / v4; 38 v2 = v2 + (double)v7 * 0.0039215689 / v4;
41 ++v7;
42 ++v3; 39 ++v3;
43 } 40 }
44 while ( v7 < 256 );
45 if ( v6 ) 41 if ( v6 )
46 result = v2 / (double)v6; 42 return v2 / (double)v6;
47 else 43 else
48 result = 1.0; 44 return 1.0;
49 return result;
50 } 45 }
51 46
52 //----- (0044F408) -------------------------------------------------------- 47 //----- (0044F408) --------------------------------------------------------
53 void GammaController::SetGammaRamp(DDGAMMARAMP *pRamp) 48 void GammaController::SetGammaRamp(DDGAMMARAMP *pRamp)
54 { 49 {
64 unsigned __int16 *v2; // esi@1 59 unsigned __int16 *v2; // esi@1
65 double v3; // st7@2 60 double v3; // st7@2
66 signed __int64 v4; // qax@3 61 signed __int64 v4; // qax@3
67 signed int v6; // [sp+Ch] [bp-4h]@1 62 signed int v6; // [sp+Ch] [bp-4h]@1
68 63
69 v6 = 0;
70 v2 = pRamp->green; 64 v2 = pRamp->green;
71 do 65 for ( v6 = 0; v6 < 256; ++v6 )
72 { 66 {
73 v3 = (double)v6 * 0.0039215689 * this->fGamma; 67 v3 = (double)v6 * 0.0039215689 * this->fGamma;
74 if ( v3 >= 1.0 || (v4 = (signed __int64)(v3 * 65535.0), (signed int)v4 > 65535) ) 68 if ( v3 >= 1.0 || (v4 = (signed __int64)(v3 * 65535.0), (signed int)v4 > 65535) )
75 { 69 LODWORD(v4) = 65535;
76 LODWORD(v4) = 65535;
77 }
78 else if ( (signed int)v4 < 0 ) 70 else if ( (signed int)v4 < 0 )
79 {
80 LODWORD(v4) = 0; 71 LODWORD(v4) = 0;
81 }
82 else 72 else
83 { 73 {
84 if ( (signed int)v4 > 65535 ) 74 if ( (signed int)v4 > 65535 )
85 LODWORD(v4) = 65535; 75 LODWORD(v4) = 65535;
86 } 76 }
87 ++v6;
88 v2[256] = v4; 77 v2[256] = v4;
89 *v2 = v4; 78 *v2 = v4;
90 *(v2 - 256) = v4; 79 *(v2 - 256) = v4;
91 ++v2; 80 ++v2;
92 } 81 }
93 while ( v6 < 256 );
94 return v4; 82 return v4;
95 } 83 }
96 84
97 //----- (0044F4D9) -------------------------------------------------------- 85 //----- (0044F4D9) --------------------------------------------------------
98 void GammaController::Initialize(float gamma) 86 void GammaController::Initialize(float gamma)
99 { 87 {
100 GammaController *v2; // esi@1
101 double v3; // st7@3 88 double v3; // st7@3
102 double v4; // st6@4 89 double v4; // st6@4
103 90
104 v2 = this;
105 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || 91 //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
106 //pVersion->pVersionInfo.dwMajorVersion != 4) 92 //pVersion->pVersionInfo.dwMajorVersion != 4)
107 { 93 {
108 InitializeFromSurface(pRenderer->pFrontBuffer4); 94 InitializeFromSurface(pRenderer->pFrontBuffer4);
109 v3 = 2.8; 95 v3 = 2.8;
115 { 101 {
116 if ( gamma <= 2.8f ) 102 if ( gamma <= 2.8f )
117 v3 = gamma; 103 v3 = gamma;
118 } 104 }
119 else 105 else
120 {
121 v3 = 0.1; 106 v3 = 0.1;
122 } 107 this->fGamma = v3;
123 v2->fGamma = v3; 108 InitGammaRamp(&this->field_60C);
124 InitGammaRamp(&v2->field_60C); 109 SetGammaRamp(&this->field_60C);
125 SetGammaRamp(&v2->field_60C);
126 } 110 }
127 } 111 }
128
129
130
131
132 112
133 //----- (0044F215) -------------------------------------------------------- 113 //----- (0044F215) --------------------------------------------------------
134 GammaController::GammaController() 114 GammaController::GammaController()
135 { 115 {
136 static float flt_4D8670_default_gamma = 1.0f; 116 static float flt_4D8670_default_gamma = 1.0f;
137 117
138 pGammaControl = nullptr; 118 pGammaControl = nullptr;
139 fGamma = flt_4D8670_default_gamma; 119 fGamma = flt_4D8670_default_gamma;
140 } 120 }
141 121
142
143
144 //----- (0044F24B) -------------------------------------------------------- 122 //----- (0044F24B) --------------------------------------------------------
145 void GammaController::InitializeFromSurface(IDirectDrawSurface4 *a2) 123 void GammaController::InitializeFromSurface(IDirectDrawSurface4 *a2)
146 { 124 {
147 GammaController *v2; // esi@1
148 IDirectDrawGammaControl **v3; // edi@1
149 IDirectDrawGammaControl *v4; // eax@1
150
151 v2 = this;
152 v3 = &this->pGammaControl;
153 this->pSurface = a2; 125 this->pSurface = a2;
154 v4 = this->pGammaControl; 126 if ( this->pGammaControl )
155 if ( v4 )
156 { 127 {
157 v4->Release(); 128 this->pGammaControl->Release();
158 *v3 = 0; 129 this->pGammaControl = 0;
159 } 130 }
160 if ( pRenderer->IsGammaSupported() ) 131 if ( pRenderer->IsGammaSupported() )
161 { 132 {
162 ErrD3D(a2->QueryInterface(IID_IDirectDrawGammaControl, (LPVOID *)v3)); 133 ErrD3D(a2->QueryInterface(IID_IDirectDrawGammaControl, (LPVOID *)&this->pGammaControl));
163 GetRamp(); 134 GetRamp();
164 memcpy(&v2->field_60C, &v2->pDefaultRamp, 0x600u); 135 memcpy(&this->field_60C, &this->pDefaultRamp, 0x600u);
165 fGamma = _44F377(&v2->field_60C); 136 fGamma = _44F377(&this->field_60C);
166 } 137 }
167 } 138 }