Mercurial > mm7
annotate PaletteManager.cpp @ 2360:63ad4e3606f4
MovieRelease();
author | Ritor1 |
---|---|
date | Wed, 16 Apr 2014 17:36:47 +0600 |
parents | 5d263539bbec |
children | f4af3b203f65 |
rev | line source |
---|---|
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2153
diff
changeset
|
1 #define _CRT_SECURE_NO_WARNINGS |
2336 | 2 #include "ErrorHandling.h" |
0 | 3 #include "PaletteManager.h" |
4 #include "Texture.h" | |
5 #include "Game.h" | |
6 #include "LOD.h" | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
7 #include "Log.h" |
2343 | 8 #include "OurMath.h" |
0 | 9 |
10 #include "mm7_data.h" | |
11 | |
12 | |
13 | |
14 | |
15 PaletteManager *pPaletteManager = new PaletteManager; | |
16 | |
17 | |
18 | |
2152 | 19 //----- (00452AE2) -------------------------------------------------------- |
20 int __fastcall MakeColorMaskFromBitDepth(int a1) | |
21 { | |
22 signed __int64 v1; // qax@1 | |
23 | |
24 v1 = 4294967296i64; | |
25 if ( a1 > 0 ) | |
26 { | |
27 do | |
28 { | |
29 LODWORD(v1) = HIDWORD(v1) + v1; | |
30 HIDWORD(v1) *= 2; | |
31 --a1; | |
32 } | |
33 while ( a1 ); | |
34 } | |
35 return v1; | |
36 } | |
0 | 37 |
38 //----- (0048A643) -------------------------------------------------------- | |
39 bool __fastcall HSV2RGB(float *a1, float *a2, float *a3, float a4, float a5, float a6) | |
40 { | |
41 float *v6; // ebx@1 | |
42 float *v7; // edi@1 | |
43 float *v8; // esi@1 | |
44 double v9; // st7@5 | |
45 signed __int64 v10; // qax@5 | |
46 double v11; // st7@5 | |
47 double v12; // st5@5 | |
48 int v13; // eax@6 | |
49 int v14; // eax@7 | |
50 int v15; // eax@8 | |
51 int v16; // eax@9 | |
52 float v17; // eax@11 | |
53 float a3a; // [sp+1Ch] [bp+8h]@14 | |
54 float a4b; // [sp+20h] [bp+Ch]@5 | |
55 float a4c; // [sp+20h] [bp+Ch]@5 | |
56 float a4a; // [sp+20h] [bp+Ch]@5 | |
57 | |
58 v6 = a3; | |
59 v7 = a2; | |
60 v8 = a1; | |
61 if ( a5 == 0.0 ) | |
62 { | |
63 *a3 = a6; | |
64 *a2 = a6; | |
65 *a1 = a6; | |
66 goto LABEL_20; | |
67 } | |
68 if ( a4 == 360.0 ) | |
69 a4 = 0.0; | |
70 v9 = a4 * 0.01666666666666667; | |
71 a4b = v9; | |
72 floor(v9); | |
73 v10 = (signed __int64)v9; | |
74 a4c = a4b - (double)(signed int)(signed __int64)v9; | |
75 v11 = (1.0 - a5) * a6; | |
76 v12 = (1.0 - a4c * a5) * a6; | |
77 a4a = (1.0 - (1.0 - a4c) * a5) * a6; | |
78 if ( (int)v10 ) | |
79 { | |
80 v13 = v10 - 1; | |
81 if ( v13 ) | |
82 { | |
83 v14 = v13 - 1; | |
84 if ( v14 ) | |
85 { | |
86 v15 = v14 - 1; | |
87 if ( v15 ) | |
88 { | |
89 v16 = v15 - 1; | |
90 if ( v16 ) | |
91 { | |
92 if ( v16 != 1 ) | |
93 goto LABEL_20; | |
94 *v8 = a6; | |
95 v17 = v12; | |
96 *v7 = v11; | |
97 goto LABEL_12; | |
98 } | |
99 *(int *)v8 = LODWORD(a4a); | |
100 *v7 = v11; | |
101 } | |
102 else | |
103 { | |
104 *v8 = v11; | |
105 a3a = v12; | |
106 *(int *)v7 = LODWORD(a3a); | |
107 } | |
108 v17 = a6; | |
109 } | |
110 else | |
111 { | |
112 *v8 = v11; | |
113 *(int *)v7 = LODWORD(a6); | |
114 v17 = a4a; | |
115 } | |
116 LABEL_12: | |
117 *(int *)v6 = LODWORD(v17); | |
118 goto LABEL_20; | |
119 } | |
120 *v8 = v12; | |
121 *v7 = a6; | |
122 } | |
123 else | |
124 { | |
125 *v8 = a6; | |
126 *(int *)v7 = LODWORD(a4a); | |
127 } | |
128 *a3 = v11; | |
129 LABEL_20: | |
130 if ( *v8 > 1.0 ) | |
131 *v8 = 1.0; | |
132 if ( *v7 > 1.0 ) | |
133 *v7 = 1.0; | |
134 if ( *v6 > 1.0 ) | |
135 *v6 = 1.0; | |
136 if ( *v8 < 0.0 ) | |
137 *v8 = 0.0; | |
138 if ( *v7 < 0.0 ) | |
139 *v7 = 0.0; | |
140 if ( *v6 < 0.0 ) | |
141 *v6 = 0.0; | |
142 return 1; | |
143 } | |
144 | |
145 //----- (0048A7AA) -------------------------------------------------------- | |
146 void __fastcall RGB2HSV(float *a1, float *a2, float a3, float a4, float a5, float *a6) | |
147 { | |
148 double v6; // st7@2 | |
149 double v7; // st6@7 | |
150 double v8; // st5@12 | |
151 double v9; // st7@15 | |
152 double v10; // st7@17 | |
2334 | 153 // double v11; // st7@21 |
154 // __int16 v12; // fps@21 | |
155 // unsigned __int8 v13; // c0@21 | |
156 // unsigned __int8 v14; // c2@21 | |
0 | 157 float a6a; // [sp+14h] [bp+14h]@16 |
158 | |
159 if ( a3 <= (double)a4 ) | |
160 v6 = a4; | |
161 else | |
162 v6 = a3; | |
163 if ( v6 < a5 ) | |
164 v6 = a5; | |
165 if ( a3 <= (double)a4 ) | |
166 v7 = a3; | |
167 else | |
168 v7 = a4; | |
169 if ( v7 > a5 ) | |
170 v7 = a5; | |
171 *a6 = v6; | |
172 if ( v6 == 0.0 ) | |
173 v8 = 0.0; | |
174 else | |
175 v8 = (v6 - v7) / v6; | |
176 *a2 = v8; | |
177 if ( v8 == 0.0 ) | |
178 { | |
179 v9 = 0.0; | |
2334 | 180 //LABEL_23: |
0 | 181 *a1 = v9; |
182 return; | |
183 } | |
184 a6a = v6 - v7; | |
185 if ( a3 == v6 ) | |
186 { | |
187 v10 = (a4 - a5) / a6a; | |
188 } | |
189 else | |
190 { | |
191 if ( a4 == v6 ) | |
192 v10 = (a5 - a3) / a6a + 2.0; | |
193 else | |
194 v10 = (a3 - a4) / a6a + 4.0; | |
195 } | |
196 //*a1 = v10; | |
197 //v11 = *a1 * 60.0; | |
198 //UNDEF(v12); | |
199 *a1 = v10 * 60.0; | |
200 if (*a1 < 0) | |
201 { | |
202 *a1 += 360.0; | |
203 } | |
204 } | |
205 | |
206 | |
207 | |
208 //----- (0048A8A3) -------------------------------------------------------- | |
209 int PaletteManager::LockAll() | |
210 { | |
211 int *v1; // edx@1 | |
212 signed int v2; // eax@1 | |
213 | |
214 v1 = &this->pPaletteIDs[1]; | |
215 v2 = 1; | |
216 do | |
217 { | |
218 if ( *v1 ) | |
219 this->_num_locked = v2 + 1; | |
220 ++v2; | |
221 ++v1; | |
222 } | |
223 while ( v2 < 50 ); | |
224 return this->_num_locked; | |
225 } | |
226 | |
227 //----- (0048A8CC) -------------------------------------------------------- | |
228 int PaletteManager::LockTestAll() | |
229 { | |
230 char *v1; // edx@1 | |
231 signed int v2; // eax@1 | |
232 | |
233 v1 = (char *)&this->pPaletteIDs[1]; | |
234 v2 = 1; | |
235 do | |
236 { | |
237 if ( *(int *)v1 ) | |
238 this->_pal_lock_test = v2 + 1; | |
239 ++v2; | |
240 v1 += 4; | |
241 } | |
242 while ( v2 < 50 ); | |
243 return this->_pal_lock_test; | |
244 } | |
245 | |
246 | |
247 //----- (0048A8F5) -------------------------------------------------------- | |
248 void PaletteManager::SetColorChannelInfo(int uNumRBits, int uNumGBits, int uNumBBits) | |
249 { | |
250 PaletteManager *v4; // esi@1 | |
251 int v5; // edi@1 | |
252 int v6; // eax@1 | |
253 int v7; // ebx@1 | |
254 | |
255 v4 = this; | |
256 this->uNumTargetRBits = uNumRBits; | |
257 this->uNumTargetGBits = uNumGBits; | |
258 v5 = this->uNumTargetGBits; | |
259 this->uNumTargetBBits = uNumBBits; | |
260 v6 = MakeColorMaskFromBitDepth(uNumRBits); | |
261 v7 = v4->uNumTargetBBits; | |
262 v4->uTargetRMask = v6 << (v5 + v4->uNumTargetBBits); | |
263 v4->uTargetGMask = MakeColorMaskFromBitDepth(v5) << v7; | |
264 v4->uTargetBMask = MakeColorMaskFromBitDepth(v7); | |
265 } | |
266 | |
267 | |
268 //----- (00489BE0) -------------------------------------------------------- | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
269 void PaletteManager::CalcPalettes_LUT(int a2) |
0 | 270 { |
271 PaletteManager *v2; // esi@1 | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
272 //char *v3; // edi@1 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
273 //signed int v4; // ebx@4 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
274 //float v5; // ST08_4@5 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
275 //float v6; // ST04_4@5 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
276 //float v7; // ST00_4@5 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
277 //int v8; // eax@7 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
278 //float *v9; // edx@8 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
279 //float *v10; // ST0C_4@8 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
280 //float *v11; // ecx@8 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
281 //int v12; // ebx@8 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
282 //int v13; // eax@8 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
283 //float v14; // ebx@8 |
2334 | 284 // float v15; // ST08_4@8 |
285 // float v16; // ST04_4@8 | |
286 // float v17; // ST00_4@8 | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
287 //unsigned __int8 v18; // sf@8 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
288 //unsigned __int8 v19; // of@8 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
289 //int v20; // eax@10 |
0 | 290 double v21; // st5@11 |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
291 //float v22; // ST0C_4@13 |
0 | 292 unsigned int v23; // eax@13 |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
293 //__int16 v24; // bx@16 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
294 //int v25; // eax@16 |
0 | 295 double v26; // st7@20 |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
296 //float v27; // ST0C_4@22 |
0 | 297 unsigned int v28; // eax@22 |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
298 //__int16 v29; // bx@25 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
299 //__int16 *v30; // eax@25 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
300 //int v31; // eax@27 |
0 | 301 double v32; // st5@28 |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
302 //float v33; // ST0C_4@30 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
303 //float v34; // ST08_4@30 |
0 | 304 unsigned int v35; // ebx@30 |
305 signed __int64 v36; // qax@33 | |
306 signed int v37; // edx@33 | |
307 char v38; // cl@33 | |
308 unsigned int v39; // ebx@33 | |
309 signed int v40; // edi@33 | |
310 unsigned int v41; // ecx@33 | |
311 unsigned int v42; // ecx@35 | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
312 //int v43; // eax@39 |
0 | 313 signed int v44; // edx@39 |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
314 //unsigned __int8 v45; // al@40 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
315 //double v46; // st6@43 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
316 //signed int v47; // eax@43 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
317 //int v48; // eax@45 |
0 | 318 double v49; // st6@47 |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
319 //float v50; // ST08_4@49 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
320 //unsigned int v51; // ebx@49 |
0 | 321 int v52; // edi@55 |
322 int v53; // ebx@55 | |
323 signed __int64 v54; // qax@55 | |
324 double v55; // st7@56 | |
325 unsigned int v56; // ecx@57 | |
326 unsigned int v57; // ecx@59 | |
327 //int v58; // edx@61 | |
328 unsigned int v59; // ecx@61 | |
329 unsigned int v60; // eax@63 | |
330 char v61; // cl@63 | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
331 //int result; // eax@63 |
0 | 332 float v63[256]; // [sp+1Ch] [bp-C38h]@5 |
333 float v64[256]; // [sp+41Ch] [bp-838h]@5 | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
334 float a6[256]; // [sp+81Ch] [bp-438h]@5 |
2334 | 335 // int v66; // [sp+C1Ch] [bp-38h]@43 |
0 | 336 float v67; // [sp+C20h] [bp-34h]@43 |
337 float v68; // [sp+C24h] [bp-30h]@43 | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
338 //PaletteManager *v69; // [sp+C28h] [bp-2Ch]@9 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
339 //float v70; // [sp+C2Ch] [bp-28h]@43 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
340 //double v71; // [sp+C30h] [bp-24h]@10 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
341 //int v72; // [sp+C38h] [bp-1Ch]@9 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
342 //int v73; // [sp+C3Ch] [bp-18h]@9 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
343 //int i; // [sp+C40h] [bp-14h]@7 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
344 //float v75; // [sp+C44h] [bp-10h]@5 |
0 | 345 float a2a; // [sp+C48h] [bp-Ch]@13 |
346 float a1; // [sp+C4Ch] [bp-8h]@13 | |
347 float a3; // [sp+C50h] [bp-4h]@13 | |
348 signed int v79; // [sp+C5Ch] [bp+8h]@33 | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
349 //signed int v80; // [sp+C5Ch] [bp+8h]@43 |
0 | 350 int v81; // [sp+C5Ch] [bp+8h]@57 |
351 | |
352 v2 = this; | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
353 //v3 = (char *)pBaseColors[a2]; |
0 | 354 if (pPalette_tintColor[0] || pPalette_tintColor[1] || pPalette_tintColor[2]) |
355 { | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
356 //v8 = 0; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
357 //i = 0; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
358 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
359 for (uint i = 0; i < 256; ++i) |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
360 RGB2HSV(&v64[i], &v63[i], (pBaseColors[a2][i][0] + pPalette_tintColor[0]) / (255.0f + 255.0f), |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
361 (pBaseColors[a2][i][1] + pPalette_tintColor[1]) / (255.0f + 255.0f), |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
362 (pBaseColors[a2][i][2] + pPalette_tintColor[2]) / (255.0f + 255.0f), &a6[i]); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
363 //do |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
364 //{ |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
365 //v9 = (float *)((char *)v63 + v8); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
366 //v10 = (float *)((char *)a6 + v8); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
367 //v11 = (float *)((char *)v64 + v8); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
368 //v12 = pPalette_tintColor[1]; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
369 //LODWORD(v75) = pPalette_tintColor[2] + (unsigned __int8)v3[2]; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
370 //v13 = pPalette_tintColor[1] + (unsigned __int8)v3[1]; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
371 //LODWORD(v14) = (unsigned __int8)*v3; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
372 //v15 = (double)((unsigned __int8)v3[2] + pPalette_tintColor[2]) / (2.0f * 255.0f); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
373 //LODWORD(v75) = v13; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
374 //LODWORD(v75) = (unsigned __int8)*v3 + pPalette_tintColor[0]; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
375 //v16 = (double)((unsigned __int8)v3[1] + pPalette_tintColor[1]) / 510.0f; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
376 //v17 = (double)((unsigned __int8)*v3 + pPalette_tintColor[0]) / 510.0f; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
377 //RGB2HSV(&v64[i], &v63[i], v17, v16, v15, &a6[i]); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
378 //v3 += 3; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
379 //v8 = i + 4; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
380 //v19 = __OFSUB__(i + 4, 1024); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
381 //v18 = i - 1020 < 0; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
382 //i += 4; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
383 //} |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
384 //while ( i < ); |
0 | 385 } |
386 else | |
387 { | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
388 for (uint i = 0; i < 256; ++i) |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
389 RGB2HSV(&v64[i], &v63[i], pBaseColors[a2][i][0] / 255.0f, |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
390 pBaseColors[a2][i][1] / 255.0f, |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
391 pBaseColors[a2][i][2] / 255.0f, &a6[i]); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
392 /*v4 = 0; |
0 | 393 do |
394 { | |
395 LODWORD(v75) = (unsigned __int8)v3[2]; | |
396 v5 = (double)SLODWORD(v75) * 0.00392156862745098; | |
397 LODWORD(v75) = (unsigned __int8)v3[1]; | |
398 v6 = (double)SLODWORD(v75) * 0.00392156862745098; | |
399 LODWORD(v75) = (unsigned __int8)*v3; | |
400 v7 = (double)SLODWORD(v75) * 0.00392156862745098; | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
401 RGB2HSV(&v64[v4], &v63[v4], v7, v6, v5, &a6[v4]); |
0 | 402 ++v4; |
403 v3 += 3; | |
404 } | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
405 while ( v4 < 256 );*/ |
0 | 406 } |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
407 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
408 //v69 = (PaletteManager *)((char *)v2 + 16384 * a2); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
409 //v72 = 0; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
410 //v73 = (int)pPalette1[a2]; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
411 for (uint i = 0; i < 32; ++i) |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
412 //do |
0 | 413 { |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
414 //v20 = 0; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
415 //i = 0; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
416 //v71 = 1.0 - (double)v72 / 31.0f; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
417 //do |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
418 for (uint j = 0; j < 256; ++j) |
0 | 419 { |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
420 v21 = a6[j] * (1.0f - i / 32.0f); |
0 | 421 if ( v21 < 0.0 ) |
422 v21 = 0.0; | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
423 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
424 //v22 = v21; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
425 HSV2RGB(&a1, &a2a, &a3, v64[j], v63[j], v21); |
0 | 426 v23 = v2->uNumTargetGBits; |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
427 if ( v23 == 6 ) // r5g6b5 |
0 | 428 { |
429 a1 = a1 * 31.0; | |
430 a2a = a2a * 62.0; | |
431 a3 = a3 * 31.0; | |
432 } | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
433 else if (v23 == 5) // r5g5b5 |
0 | 434 { |
435 a1 = a1 * 31.0; | |
436 a2a = a2a * 31.0; | |
437 a3 = a3 * 31.0; | |
438 } | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
439 else if (v23 == 0) |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
440 Log::Warning(L"Calling palette manager with num_target_bits == 0"); |
1545 | 441 else Error("(%u)", v23); |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
442 //v24 = (unsigned __int32)a3 | ((unsigned __int32)a2a << v2->uNumTargetBBits) | ((unsigned __int32)a1 << (v2->uNumTargetBBits + v2->uNumTargetGBits)); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
443 //v25 = v73; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
444 //v73 += 2; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
445 //*(short *)v25 = v24; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
446 pPalette1[a2][i][j] = (unsigned __int32)a3 | |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
447 ((unsigned __int32)a2a << v2->uNumTargetBBits) | |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
448 ((unsigned __int32)a1 << (v2->uNumTargetBBits + v2->uNumTargetGBits)); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
449 //v20 = i + 4; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
450 //v19 = __OFSUB__(i + 4, 1024); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
451 //v18 = i - 1020 < 0; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
452 //i += 4; |
0 | 453 } |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
454 //while ( v18 ^ v19 ); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
455 //++v72; |
0 | 456 } |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
457 //while ( v72 < 32 ); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
458 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
459 //v72 = 0; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
460 //v73 = (int)v69->field_199600_palettes; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
461 //do |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
462 for (uint i = 0; i < 32; ++i) |
0 | 463 { |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
464 //i = 0; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
465 //v71 = 1.0 - (double)v72 / 31.0f; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
466 //do |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
467 for (uint j = 0; j < 256; ++j) |
0 | 468 { |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
469 v26 = a6[j] * (1.0 - i / 31.0f); |
0 | 470 if ( v26 < 0.0 ) |
471 v26 = 0.0; | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
472 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
473 //v27 = v26; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
474 HSV2RGB(&a1, &a2a, &a3, 1.0, 1.0, v26); |
0 | 475 v28 = v2->uNumTargetGBits; |
476 if ( v28 == 6 ) | |
477 { | |
478 a1 = a1 * 31.0; | |
479 a2a = a2a * 62.0; | |
480 a3 = a3 * 31.0; | |
481 } | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
482 else if (v28 == 5) |
0 | 483 { |
484 a1 = a1 * 31.0; | |
485 a2a = a2a * 31.0; | |
486 a3 = a3 * 31.0; | |
487 } | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
488 else if (v23 == 0) |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
489 Log::Warning(L"Calling palette manager with num_target_bits == 0"); |
1545 | 490 else Error("(%u)", v23); |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
491 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
492 //v29 = (unsigned __int64)(signed __int64)a3 | ((unsigned __int16)(signed __int64)a2a << v2->uNumTargetBBits) | (unsigned __int16)((unsigned __int16)(signed __int64)a1 << (v2->uNumTargetBBits + v28)); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
493 //v30 = (__int16 *)v73; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
494 //++i; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
495 //v73 += 2; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
496 //v19 = __OFSUB__(i, 256); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
497 //v18 = i - 256 < 0; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
498 //*v30 = v29; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
499 field_199600_palettes[a2][i][j] = (unsigned __int64)(signed __int64)a3 | ((unsigned __int16)(signed __int64)a2a << v2->uNumTargetBBits) | (unsigned __int16)((unsigned __int16)(signed __int64)a1 << (v2->uNumTargetBBits + v28)); |
0 | 500 } |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
501 //while ( v18 ^ v19 ); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
502 //++v72; |
0 | 503 } |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
504 //while ( v72 < 32 ); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
505 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
506 //v73 = (int)((char *)v2 + 512 * (a2 + 4875)); // field_261600[a2] |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
507 //v31 = 0; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
508 //i = 0; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
509 for (uint i = 0; i < 256; ++i) |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
510 //do |
0 | 511 { |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
512 //v32 = (*(float *)((char *)a6 + v31) - 0.8) * 0.8387096774193549 + 0.8; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
513 v32 = (a6[i] - 0.8f) * 0.8387096774193549 + 0.8; |
0 | 514 if ( v32 < 0.0 ) |
515 v32 = 0.0; | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
516 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
517 //v33 = v32; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
518 //v34 = v63[i] * 0.7034339229968783; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
519 HSV2RGB(&a1, &a2a, &a3, v64[i], v63[i] * 0.7034339229968783, v32); |
0 | 520 v35 = v2->uNumTargetGBits; |
521 if ( v35 == 6 ) | |
522 { | |
523 a1 = a1 * 31.0; | |
524 a2a = a2a * 62.0; | |
525 a3 = a3 * 31.0; | |
526 } | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
527 else if (v35 == 5) |
0 | 528 { |
529 a1 = a1 * 31.0; | |
530 a2a = a2a * 31.0; | |
531 a3 = a3 * 31.0; | |
532 } | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
533 else if (v23 == 0) |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
534 Log::Warning(L"Calling palette manager with num_target_bits == 0"); |
1545 | 535 else Error("(%u)", v23); |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
536 |
0 | 537 v36 = (signed __int64)((a1 + a2a + a3) * 0.3333333333333333 * 8.0); |
538 v37 = (signed int)v36 >> (8 - v2->uNumTargetRBits); | |
539 v38 = 8 - v35; | |
540 v39 = v2->uNumTargetBBits; | |
541 v40 = (signed int)v36 >> v38; | |
542 v41 = v2->uNumTargetRBits; | |
543 v79 = (signed int)v36 >> (8 - v39); | |
544 if ( v37 > (1 << v41) - 1 ) | |
545 v37 = (1 << v41) - 1; | |
546 v42 = v2->uNumTargetGBits; | |
547 if ( v40 > (1 << v42) - 1 ) | |
548 v40 = (1 << v42) - 1; | |
549 if ( v79 > (1 << v39) - 1 ) | |
550 v79 = (1 << v39) - 1; | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
551 //v43 = v73; |
0 | 552 v44 = v37 << (v39 + v2->uNumTargetGBits); |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
553 //v73 += 2; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
554 //*(short *)v43 = v79 | ((short)v40 << v39) | (unsigned __int16)v44; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
555 field_261600[a2][i] = v79 | ((unsigned short)v40 << v39) | (unsigned __int16)v44; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
556 //v31 = i + 4; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
557 //v19 = __OFSUB__(i + 4, 1024); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
558 //v18 = i - 1020 < 0; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
559 //i += 4; |
0 | 560 } |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
561 //while ( v18 ^ v19 ); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
562 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
563 //v45 = pPalette_mistColor[0]; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
564 float mist_a, mist_b, mist_c; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
565 if (pPalette_mistColor[0] || pPalette_mistColor[1] || pPalette_mistColor[2]) |
0 | 566 { |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
567 //v46 = (double)v45; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
568 //v80 = pPalette_mistColor[1]; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
569 //v47 = pPalette_mistColor[2]; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
570 //v70 = v46 * 0.00392156862745098; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
571 //*((float *)&v71 + 1) = (double)v80 * 0.00392156862745098; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
572 //v75 = (double)v47 * 0.00392156862745098; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
573 mist_a = pPalette_mistColor[0] / 255.0f; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
574 mist_b = pPalette_mistColor[1] / 255.0f; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
575 mist_c = pPalette_mistColor[2] / 255.0f; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
576 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
577 float unused; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
578 RGB2HSV(&v68, &v67, mist_a, mist_b, mist_c, &unused); |
0 | 579 } |
580 | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
581 //v72 = 0; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
582 //v73 = (int)v69->field_D1600; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
583 //do |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
584 for (uint i = 0; i < 32; ++i) |
0 | 585 { |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
586 //v48 = 0; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
587 //for ( i = 0; ; v48 = i ) |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
588 for (uint j = 0; j < 256; ++j) |
0 | 589 { |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
590 v49 = v63[j]; |
0 | 591 if ( v49 < 0.0 ) |
592 v49 = 0.0; | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
593 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
594 //v50 = v49; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
595 HSV2RGB(&a1, &a2a, &a3, v64[j], v49, a6[j]); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
596 //v51 = v2->uNumTargetGBits; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
597 if ( v2->uNumTargetGBits == 6 ) |
0 | 598 { |
599 a1 = a1 * 31.0; | |
600 a2a = a2a * 62.0; | |
601 a3 = a3 * 31.0; | |
602 } | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
603 else if (v2->uNumTargetGBits == 5) |
0 | 604 { |
605 a1 = a1 * 31.0; | |
606 a2a = a2a * 31.0; | |
607 a3 = a3 * 31.0; | |
608 } | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
609 else if (v23 == 0) |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
610 Log::Warning(L"Calling palette manager with num_target_bits == 0"); |
1545 | 611 else Error("(%u)", v23); |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
612 |
0 | 613 if (pPalette_mistColor[0] || pPalette_mistColor[1] || pPalette_mistColor[2]) |
614 { | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
615 v55 = (double)i / 31.0f; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
616 v52 = (signed __int64)((double)(1 << v2->uNumTargetRBits) * mist_a * v55 + a1 * (1.0 - v55)); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
617 v53 = (signed __int64)((double)(1 << v2->uNumTargetGBits) * mist_b * v55 + a2a * (1.0 - v55)); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
618 v54 = (signed __int64)((double)(1 << v2->uNumTargetBBits) * mist_c * v55 + a3 * (1.0 - v55)); |
0 | 619 } |
620 else | |
621 { | |
622 v52 = (signed __int64)a1; | |
623 v53 = (signed __int64)a2a; | |
624 v54 = (signed __int64)a3; | |
625 } | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
626 |
0 | 627 v56 = v2->uNumTargetRBits; |
628 v81 = v54; | |
629 if ( v52 > (1 << v56) - 1 ) | |
630 v52 = (1 << v56) - 1; | |
631 v57 = v2->uNumTargetGBits; | |
632 if ( v53 > (1 << v57) - 1 ) | |
633 v53 = (1 << v57) - 1; | |
634 HIDWORD(v54) = v2->uNumTargetBBits; | |
635 v59 = v2->uNumTargetBBits; | |
636 if ( (signed int)v54 > (1 << v59) - 1 ) | |
637 v81 = (1 << v59) - 1; | |
638 v60 = v2->uNumTargetGBits; | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
639 //i += 4; |
0 | 640 v61 = uNumTargetBBits + v60; |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
641 //result = v73; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
642 //v73 += 2; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
643 //v19 = __OFSUB__(i, 1024); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
644 //v18 = i - 1024 < 0; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
645 //*(short *)result = v81 | ((short)v53 << uNumTargetBBits) | (v52 << v61); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
646 field_D1600[a2][i][j] = v81 | ((short)v53 << uNumTargetBBits) | (v52 << v61); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
647 //if ( !(v18 ^ v19) ) |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
648 // break; |
0 | 649 } |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
650 //++v72; |
0 | 651 } |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
652 //while ( v72 < 32 ); |
0 | 653 } |
654 | |
655 | |
656 //----- (0048A300) -------------------------------------------------------- | |
657 PaletteManager::PaletteManager(): | |
670 | 658 uNumTargetRBits(0), uNumTargetGBits(0),uNumTargetBBits(0),_num_locked(0) |
0 | 659 { |
660 for (uint i = 0; i < 256; ++i) | |
661 { | |
662 pBaseColors[0][i][0] = i; | |
663 pBaseColors[0][i][1] = i; | |
664 pBaseColors[0][i][2] = i; | |
665 } | |
666 | |
667 CalcPalettes_LUT(0); | |
668 memset(pPaletteIDs, 0, sizeof(pPaletteIDs)); | |
669 } | |
670 | |
671 //----- (0048A336) -------------------------------------------------------- | |
672 // make grayscale palette at 0, clear all palettes ids that aren't locked | |
673 int PaletteManager::ResetNonLocked() | |
674 { | |
675 PaletteManager *v1; // esi@1 | |
676 signed int v2; // ecx@1 | |
677 int v3; // eax@1 | |
678 signed int result; // eax@3 | |
679 void *v5; // edi@4 | |
680 int v6; // ecx@4 | |
681 | |
682 v1 = this; | |
683 v2 = 0; | |
684 v3 = (int)&v1->pBaseColors[0][0][1]; | |
685 do | |
686 { | |
687 *(char *)(v3 + 1) = v2; | |
688 *(char *)v3 = v2; | |
689 *(char *)(v3 - 1) = v2++; | |
690 v3 += 3; | |
691 } | |
692 while ( v2 < 256 ); | |
693 CalcPalettes_LUT(0); | |
694 result = v1->_num_locked; | |
695 if ( result < 50 ) | |
696 { | |
697 v5 = &v1->pPaletteIDs[result]; | |
698 v6 = 50 - result; | |
699 result = 0; | |
700 memset(v5, 0, 4 * v6); | |
701 } | |
702 return result; | |
703 } | |
704 | |
705 //----- (0048A379) -------------------------------------------------------- | |
706 // make grayscale palette at 0, clear all palettes ids that aren't in "lock_test" | |
707 int PaletteManager::ResetNonTestLocked() | |
708 { | |
709 PaletteManager *v1; // esi@1 | |
710 signed int v2; // ecx@1 | |
711 int v3; // eax@1 | |
712 signed int result; // eax@3 | |
713 void *v5; // edi@4 | |
714 int v6; // ecx@4 | |
715 | |
716 v1 = this; | |
717 v2 = 0; | |
718 v3 = (int)&v1->pBaseColors[0][0][1]; | |
719 do | |
720 { | |
721 *(char *)(v3 + 1) = v2; | |
722 *(char *)v3 = v2; | |
723 *(char *)(v3 - 1) = v2++; | |
724 v3 += 3; | |
725 } | |
726 while ( v2 < 256 ); | |
727 CalcPalettes_LUT(0); | |
728 result = v1->_pal_lock_test; | |
729 if ( result < 50 ) | |
730 { | |
731 v5 = &v1->pPaletteIDs[result]; | |
732 v6 = 50 - result; | |
733 result = 0; | |
734 memset(v5, 0, 4 * v6); | |
735 } | |
736 return result; | |
737 } | |
738 | |
739 //----- (0048A3BC) -------------------------------------------------------- | |
740 int PaletteManager::LoadPalette(unsigned int uPaletteID) | |
741 { | |
742 unsigned int *v2; // ecx@1 | |
743 signed int result; // eax@1 | |
744 signed int v4; // esi@6 | |
745 double v5; // st7@7 | |
746 double v6; // st7@12 | |
747 double v7; // st6@17 | |
748 signed __int64 v8; // qax@17 | |
749 double v9; // st6@17 | |
750 char v10[768]; // [sp+18h] [bp-388h]@6 | |
751 //char v11; // [sp+19h] [bp-387h]@17 | |
752 //char v12[766]; // [sp+1Ah] [bp-386h]@17 | |
753 char Source[32]; // [sp+360h] [bp-40h]@4 | |
2335 | 754 //PaletteManager *v15; // [sp+380h] [bp-20h]@1 |
0 | 755 float v16; // [sp+384h] [bp-1Ch]@7 |
756 int v17; // [sp+388h] [bp-18h]@6 | |
757 float v18; // [sp+38Ch] [bp-14h]@7 | |
758 float a2a; // [sp+390h] [bp-10h]@7 | |
759 float a1; // [sp+394h] [bp-Ch]@7 | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
760 float a6; // [sp+398h] [bp-8h]@7 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
761 float a3; // [sp+39Ch] [bp-4h]@7 |
0 | 762 |
2335 | 763 //v15 = this; |
0 | 764 v2 = (unsigned int *)&this->pPaletteIDs[1]; |
765 result = 1; | |
766 while ( *v2 != uPaletteID ) | |
767 { | |
768 ++result; | |
769 ++v2; | |
770 if ( result >= 50 ) | |
771 { | |
772 sprintf(Source, "pal%03i", uPaletteID); | |
773 | |
774 Texture tex; // [sp+318h] [bp-88h]@4 | |
775 //Texture::Texture(&tex); | |
776 | |
777 if ( pBitmaps_LOD->LoadTextureFromLOD(&tex, Source, TEXTURE_24BIT_PALETTE) == 1 ) | |
778 { | |
779 v4 = 0; | |
780 v17 = 1 - (int)&v10; | |
781 do | |
782 { | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
783 //LODWORD(a1) = tex.pPalette24[v4]; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
784 a1 = (double)tex.pPalette24[v4] / 255.0f; |
0 | 785 LODWORD(a2a) = (unsigned __int8)*(&v10 + v4 + v17 + (unsigned int)tex.pPalette24); |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
786 a2a = (double)tex.pPalette24[v4 + 1] / 255.0f; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
787 //a3 = tex.pPalette24[v4 + 2]; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
788 a3 = (double)tex.pPalette24[v4 + 2] / 255.0f; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
789 RGB2HSV(&v16, &v18, a1, a2a, a3, &a6); |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
790 v5 = a6 * 1.1; |
0 | 791 if ( v5 >= 0.0 && v5 >= 1.0 ) |
792 v5 = 1.0; | |
793 else | |
794 { | |
795 if ( v5 < 0.0 ) | |
796 v5 = 0.0; | |
797 } | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
798 a6 = v5; |
0 | 799 v6 = v18 * 0.64999998; |
800 if ( v6 >= 0.0 && v6 >= 1.0 ) | |
801 v6 = 1.0; | |
802 else | |
803 { | |
804 if ( v6 < 0.0 ) | |
805 v6 = 0.0; | |
806 } | |
807 v18 = v6; | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
808 HSV2RGB(&a1, &a2a, &a3, v16, v18, a6); |
0 | 809 v7 = a2a * 255.0; |
810 v10[v4] = (signed __int64)(a1 * 255.0); | |
811 v8 = (signed __int64)v7; | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
812 v9 = a3 * 255.0; |
0 | 813 v10[v4 + 1] = v8; |
814 v10[v4 + 2] = (signed __int64)v9; | |
815 v4 += 3; | |
816 } | |
817 while ( v4 < 768 ); | |
818 tex.Release(); | |
2335 | 819 result = this->MakeBasePaletteLut(uPaletteID, v10); |
0 | 820 } |
821 else | |
822 result = 0; | |
823 return result; | |
824 } | |
825 } | |
826 return result; | |
827 } | |
828 // 48A3BC: using guessed type char var_386[766]; | |
829 | |
830 //----- (0048A5A4) -------------------------------------------------------- | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
831 int PaletteManager::MakeBasePaletteLut(int idx, char *entries) |
0 | 832 { |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
833 //PaletteManager *v3; // edi@1 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
834 //signed int result; // eax@1 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
835 //int *v5; // ecx@1 |
0 | 836 int v6; // eax@4 |
837 int v7; // esi@4 | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
838 //int v8; // eax@9 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
839 //signed int v9; // ecx@9 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
840 //int v10; // edx@9 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
841 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
842 //v3 = this; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
843 //result = 0; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
844 //v5 = this->pPaletteIDs; |
0 | 845 |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
846 for (uint i = 0; i < 50; ++i) |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
847 if (pPaletteIDs[i] == idx) |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
848 return i; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
849 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
850 v6 = (int)&pPaletteIDs[1]; |
0 | 851 v7 = 1; |
852 while ( *(int *)v6 ) | |
853 { | |
854 ++v7; | |
855 v6 += 4; | |
856 if ( v7 >= 50 ) | |
857 return 0; | |
858 } | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
859 /*v8 = (int)pBaseColors[v7];//(int)((char *)v3 + 768 * v7); |
0 | 860 v9 = 768; |
861 v10 = (int)(entries - v8); | |
862 do | |
863 { | |
864 *(char *)v8 = *(char *)(v10 + v8); | |
865 ++v8; | |
866 --v9; | |
867 } | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
868 while ( v9 );*/ |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
869 unsigned __int8 *dst = (unsigned __int8 *)pBaseColors[v7]; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
870 for (uint i = 0; i < 768; ++i) |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
871 dst[i] = entries[i]; |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
872 |
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
873 pPaletteIDs[v7] = idx; |
0 | 874 CalcPalettes_LUT(v7); |
875 return v7; | |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
876 |
0 | 877 } |
878 | |
762 | 879 // inlined |
880 //----- (mm6c::0045C610) --------------------------------------------------- | |
881 void PaletteManager::SetMistColor(unsigned char r, unsigned char g, unsigned char b) | |
882 { | |
883 pPalette_mistColor[0] = r; | |
884 pPalette_mistColor[1] = g; | |
885 pPalette_mistColor[2] = b; | |
886 } | |
887 | |
0 | 888 //----- (0048A614) -------------------------------------------------------- |
889 void PaletteManager::RecalculateAll() | |
890 { | |
891 CalcPalettes_LUT(0); | |
892 | |
893 for (uint i = 1; i < 50; ++i) | |
894 if (pPaletteIDs[i]) | |
895 CalcPalettes_LUT(i); | |
896 } | |
897 | |
898 | |
899 //----- (0047BE67) -------------------------------------------------------- | |
900 unsigned __int16 *PaletteManager::Get(int a1) | |
901 { | |
902 return (unsigned __int16 *)pPaletteManager->field_199600_palettes[a1]; | |
903 } | |
904 | |
905 //----- (0047BE72) -------------------------------------------------------- | |
906 unsigned __int16 *PaletteManager::Get_Mist_or_Red_LUT(int a1, int a2, char a3) | |
907 { | |
908 int v3; // eax@4 | |
909 | |
910 if ( a3 & 2 || byte_4D864C && BYTE2(pGame->uFlags) & 4 ) | |
911 v3 = 32 * a1 + a2 + 3275; | |
912 else | |
913 v3 = 32 * a1 + a2 + 1675; | |
914 return (unsigned __int16 *)((char *)&pPaletteManager + 512 * v3); | |
915 } | |
916 // 4D864C: using guessed type char byte_4D864C; | |
917 | |
918 | |
919 //----- (0041F50D) -------------------------------------------------------- | |
920 unsigned __int16 *PaletteManager::Get_Dark_or_Red_LUT(int a1, int a2, char a3) | |
921 { | |
922 int v3; // eax@4 | |
923 | |
924 if ( a3 & 2 || byte_4D864C && BYTE2(pGame->uFlags) & 4 ) | |
925 v3 = 32 * a1 + a2 + 3275; | |
926 else | |
927 v3 = 32 * a1 + a2 + 75; | |
928 return (unsigned __int16 *)((char *)&pPaletteManager + 512 * v3); | |
929 } | |
930 // 4D864C: using guessed type char byte_4D864C; | |
931 | |
932 | |
933 //----- (0047C30E) -------------------------------------------------------- | |
934 unsigned __int16 *PaletteManager::_47C30E_get_palette(int a1, char a2) | |
935 { | |
936 char *result; // eax@4 | |
937 | |
938 if ( a2 & 2 || byte_4D864C && BYTE2(pGame->uFlags) & 4 ) | |
939 result = (char *)pPaletteManager->field_199600_palettes[a1]; | |
940 else | |
941 result = (char *)pPaletteManager->field_D1600[a1]; | |
942 return (unsigned __int16 *)result; | |
943 } | |
944 | |
945 | |
946 //----- (0047C33F) -------------------------------------------------------- | |
947 unsigned __int16 *PaletteManager::_47C33F_get_palette(int a1, char a2) | |
948 { | |
949 unsigned __int16 *result; // eax@4 | |
950 | |
951 if ( a2 & 2 || byte_4D864C && BYTE2(pGame->uFlags) & 4 ) | |
952 result = (unsigned __int16 *)pPaletteManager->field_199600_palettes[a1]; | |
953 else | |
954 result = (unsigned __int16 *)pPaletteManager->pPalette1[a1]; | |
955 return result; | |
956 } | |
2343 | 957 // 4D864C: using guessed type char byte_4D864C; |
958 | |
959 | |
960 //----- (0048A959) -------------------------------------------------------- | |
961 signed int ReplaceHSV(unsigned int uColor, float h_replace, float s_replace, float v_replace) | |
962 { | |
963 float r = ((uColor & 0x00FF0000) >> 16) / 255.0f, | |
964 g = ((uColor & 0x0000FF00) >> 8) / 255.0f, | |
965 b = (uColor & 0x000000FF) / 255.0f; | |
966 | |
967 float h, s, v; | |
968 RGB2HSV(&h, &s, r, g, b, &v); | |
969 | |
970 if ( h_replace != -1.0 ) | |
971 h = h_replace; | |
972 if ( s_replace != -1.0 ) | |
973 s = s_replace; | |
974 if ( v_replace != -1.0 ) | |
975 v = v_replace; | |
976 HSV2RGB(&r, &g, &b, h, s, v); | |
977 | |
978 return (((uint)round_to_int(r * 255.0f) & 0xFF) << 16) | | |
979 (((uint)round_to_int(g * 255.0f) & 0xFF) << 8) | | |
980 (((uint)round_to_int(b * 255.0f) & 0xFF)); | |
981 } |