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