annotate PaletteManager.cpp @ 22:e7ee737cd473

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