annotate PaletteManager.cpp @ 2469:8516bb27d7f0

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