Mercurial > mm7
annotate Texture.cpp @ 1583:75fafd8ced59
Allocator (CMemory) bye-bye
author | Nomad |
---|---|
date | Tue, 10 Sep 2013 21:07:07 +0200 |
parents | c4ab816fcc5e |
children | 69ab7593e7af |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1119
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1119
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1119
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1119
diff
changeset
|
4 |
0 | 5 #include <stdlib.h> |
6 | |
7 #include "Texture.h" | |
8 #include "FrameTableInc.h" | |
9 #include "LOD.h" | |
10 #include "PaletteManager.h" | |
11 #include "Render.h" | |
12 | |
13 #include "mm7_data.h" | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 struct TextureFrameTable *pTextureFrameTable; | |
25 | |
26 | |
27 | |
28 | |
29 | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1205
diff
changeset
|
30 std::array<Texture *, 2> pTexture_LloydBeacons; |
0 | 31 Texture *pTexture_50635C; |
1453 | 32 Texture *pTex_book_button8_off; |
33 Texture *pTex_book_button8_on; | |
34 Texture *pTex_book_button7_off; | |
35 Texture *pTex_book_button7_on; | |
36 Texture *pTex_book_button6_off; | |
37 Texture *pTex_book_button6_on; | |
38 Texture *pTex_book_button5_off; | |
39 Texture *pTex_book_button5_on; | |
40 Texture *pTex_book_button4_off; | |
41 Texture *pTex_book_button4_on; | |
42 Texture *pTex_book_button3_off; | |
43 Texture *pTex_book_button3_on; | |
44 Texture *pTex_book_button2_off; | |
45 Texture *pTex_book_button1_off; | |
46 Texture *pTex_book_button2_on; | |
47 Texture *pTex_book_button1_on; | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1205
diff
changeset
|
48 std::array<Texture *, 6> pTexture_TownPortalIcons; // [0]Harmonale, [1]Pierpont, [2]Nighon, [3]Evenmorn Island, [4]Celestia, [5]The Pit |
1402 | 49 std::array<Texture *, 12> SBPageCSpellsTextureList; |
50 std::array<Texture *, 12> SBPageSSpellsTextureList; | |
51 Texture *pSBQuickSpellBtnTextr; | |
52 Texture *pSpellBookClickCloseBtnTextr; | |
53 Texture *pSBClickQuickSpellBtnTextr; | |
54 Texture *pSpellBookCloseBtnTextr; | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1205
diff
changeset
|
55 std::array<std::array<Texture *, 2>, 9> pTextures_tabs; |
0 | 56 Texture *pTexture_mapbordr; // idb |
57 Texture *pTexture_pagemask; // idb | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1205
diff
changeset
|
58 std::array<Texture *, 9> pSpellBookPagesTextr; |
688 | 59 Texture *pSpellBookPagesTextr_9; |
60 Texture *pSpellBookPagesTextr_10; | |
61 Texture *pSpellBookPagesTextr_11; | |
62 Texture *pSpellBookPagesTextr_12; | |
63 Texture *pSpellBookPagesTextr_13; | |
0 | 64 Texture *pTexture_AutonotesBook; |
65 Texture *pTexture_CurrentBook; | |
66 Texture *pTex_moon_new; | |
67 Texture *pTex_moon_4; | |
68 Texture *pTex_moon_2; | |
69 Texture *pTex_moon_2_2; | |
70 Texture *pTex_moon_ful; | |
71 | |
72 | |
73 | |
74 RGBTexture stru_506E40; // weak | |
75 RGBTexture pTexture_PCX; | |
76 | |
77 | |
78 int uTextureID_RestUI_restb4; // weak | |
79 int uTextureID_RestUI_restexit; // weak | |
80 int uTextureID_RestUI_restb3; // weak | |
81 int uTextureID_RestUI_restb1; // weak | |
82 int uTextureID_RestUI_restb2; // weak | |
83 int uTextureID_RestUI_restmain; // weak | |
84 unsigned int uTextureID_Leather; | |
85 int uTextureID_ar_dn_dn; // weak | |
86 int uTextureID_ar_dn_up; // weak | |
87 int uTextureID_ar_up_dn; // weak | |
88 int uTextureID_ar_up_up; // weak | |
89 | |
90 | |
91 int uTextureID_507698; // weak | |
92 int uTextureID_50769C; // weak | |
93 int uTextureID_5076A0; // weak | |
94 int uTextureID_5076A4; // weak | |
95 int uTextureID_5076A8; // weak | |
96 int uTextureID_5076AC; // weak | |
97 int uTextureID_5076B0; // weak | |
98 int uTextureID_5076B4; // weak | |
99 int uTextureID_Parchment; // weak | |
100 unsigned int uTextureID_mhp_yel; | |
101 unsigned int uTextureID_mhp_red; | |
102 unsigned int uTextureID_mhp_grn; | |
103 unsigned int uTextureID_mhp_capr; | |
104 unsigned int uTextureID_mhp_capl; | |
105 unsigned int uTextureID_mhp_bd; | |
106 unsigned int uTextureID_BUTTDESC2; | |
107 unsigned int uTextureID_x_x_u; | |
108 unsigned int uTextureID_BUTTMAKE2; | |
109 unsigned int uTextureID_BUTTMAKE; | |
110 unsigned int uTextureID_BUTTYES2; | |
111 unsigned int uTextureID_x_ok_u; | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1205
diff
changeset
|
112 std::array<Texture *, 22> pPlayerPortraits; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1205
diff
changeset
|
113 std::array<Texture *, 9> pTexture_IC_KNIGHT; |
0 | 114 Texture *pTexture_MAKESKY; |
115 Texture *pTexture_MAKETOP; | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1205
diff
changeset
|
116 std::array<Texture *, 20> pTextures_arrowr; |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1205
diff
changeset
|
117 std::array<Texture *, 20> pTextures_arrowl; |
0 | 118 Texture *pTexture_presleft; |
119 Texture *pTexture_pressrigh; | |
120 Texture *pTexture_buttminu; | |
121 Texture *pTexture_buttplus; | |
362 | 122 unsigned int uTextureID_Quit1; // weak |
123 unsigned int uTextureID_Resume1; // weak | |
124 unsigned int uTextureID_Controls1; // weak | |
125 unsigned int uTextureID_Save1; // weak | |
126 unsigned int uTextureID_Load1; // weak | |
127 unsigned int uTextureID_New1; // weak | |
128 unsigned int uTextureID_Options; // weak | |
0 | 129 |
130 | |
131 unsigned int uTextureID_ib_td5_A; | |
132 unsigned int uTextureID_ib_td2_A; // weak | |
133 unsigned int uTextureID_ib_td1_A; | |
984 | 134 int uTextureID_CharacterUI_InventoryBackground; // weak |
0 | 135 int uTextureID_50795C; // weak |
136 | |
137 | |
319 | 138 unsigned int uTextureID_Btn_GameSettings; |
0 | 139 |
140 | |
319 | 141 unsigned int uTextureID_Btn_Rest; |
142 unsigned int uTextureID_Btn_CastSpell; | |
143 unsigned int uTextureID_Btn_ZoomIn; | |
144 unsigned int uTextureID_Btn_ZoomOut; | |
0 | 145 unsigned int uTextureID_FONTPAL; |
319 | 146 unsigned int uTextureID_Btn_NPCRight; |
147 unsigned int uTextureID_Btn_NPCLeft; | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1205
diff
changeset
|
148 std::array<unsigned int, 8> pTextureIDs_pMapDirs; |
0 | 149 |
150 | |
151 unsigned int uTextureID_BarRed; | |
152 unsigned int uTextureID_BarYellow; | |
153 unsigned int uTextureID_BarGreen; | |
154 unsigned int uTextureID_BarBlue; | |
155 | |
156 | |
157 unsigned int uTextureID_right_panel; // weak | |
158 | |
159 | |
160 RGBTexture *pTexture_StatusBar = new RGBTexture; | |
161 RGBTexture *pTexture_LeftFrame = new RGBTexture; | |
162 RGBTexture *pTexture_TopFrame = new RGBTexture; | |
163 RGBTexture *pTexture_BottomFrame = new RGBTexture; | |
164 RGBTexture *pTexture_RightFrame = new RGBTexture; | |
165 | |
166 | |
910 | 167 unsigned int uTextureID_right_panel_loop; |
0 | 168 |
169 | |
170 Texture *pTexture_Leather; | |
171 Texture *pTexture_RestUI_CurrentSkyFrame; // idb | |
172 Texture *pTexture_RestUI_CurrentHourglassFrame; // idb | |
173 | |
174 | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1205
diff
changeset
|
175 std::array<unsigned int, 5> uTextureID_Optkb; |
0 | 176 |
177 unsigned int uTextureID_507C10; // weak | |
178 unsigned int uTextureID_507C14; // weak | |
179 unsigned int uTextureID_507C18; // weak | |
180 unsigned int uTextureID_507C1C; // weak | |
181 unsigned int uTextureID_507C20; // weak | |
182 unsigned int uTextureID_507C24; // weak | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1205
diff
changeset
|
183 std::array<unsigned int, 10> pTextureIDs_GammaPositions; |
0 | 184 unsigned int uTextureID_507C50; // weak |
185 unsigned int uTextureID_507C54; // weak | |
186 unsigned int uTextureID_507C58; // weak | |
187 | |
188 | |
910 | 189 unsigned int uTextureID_detaliz_close_button; // weak |
0 | 190 unsigned int uTextureID_MAGNIF_B; // weak |
191 unsigned int uTextureID_BACKDOLL; // weak | |
192 unsigned int uTextureID_BACKHAND; // weak | |
193 | |
1262 | 194 stru355 stru_4E82A4 = {0x20, 0x41, 0, 0x20, 0xFF0000, 0xFF00, 0xFF, 0xFF000000}; |
195 stru355 stru_4EFCBC = {0x20, 0x41, 0, 0x10, 0x7C00, 0x3E0, 0x1F, 0x8000}; | |
0 | 196 |
197 Texture pTex_F7CE30; | |
198 | |
199 | |
200 RGBTexture stru_5773C4; // idb | |
201 | |
202 | |
203 | |
204 | |
205 | |
206 | |
207 | |
208 | |
209 | |
210 | |
211 | |
212 /* 245 */ | |
213 #pragma pack(push, 1) | |
214 struct PCXHeader1 | |
215 { | |
216 char magic; | |
217 char version; | |
218 char encoding; | |
219 char bpp; | |
220 __int16 left; | |
221 __int16 up; | |
222 __int16 right; | |
223 __int16 bottom; | |
224 __int16 hres; | |
225 __int16 vres; | |
226 }; | |
227 #pragma pack(pop) | |
228 | |
229 /* 246 */ | |
230 #pragma pack(push, 1) | |
231 struct PCXHeader2 | |
232 { | |
233 char reserved; | |
234 char planes; | |
235 __int16 pitch; | |
236 __int16 palette_info; | |
237 }; | |
238 #pragma pack(pop) | |
239 | |
240 | |
241 | |
242 | |
243 | |
244 | |
245 | |
246 | |
247 | |
248 //----- (0044E054) -------------------------------------------------------- | |
249 void TextureFrameTable::ToFile() | |
250 { | |
251 TextureFrameTable *v1; // esi@1 | |
252 FILE *v2; // eax@1 | |
253 FILE *v3; // edi@1 | |
254 | |
255 v1 = this; | |
256 v2 = fopen("data\\dtft.bin", "wb"); | |
257 v3 = v2; | |
258 if ( !v2 ) | |
1545 | 259 Error("Unable to save dtft.bin!"); |
0 | 260 fwrite(v1, 4u, 1u, v2); |
711 | 261 fwrite(v1->pTextures, 0x14u, v1->sNumTextures, v3); |
0 | 262 fclose(v3); |
263 } | |
264 | |
265 //----- (0044E0A0) -------------------------------------------------------- | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1453
diff
changeset
|
266 void TextureFrameTable::FromFile(void *data_mm6, void *data_mm7, void *data_mm8) |
0 | 267 { |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1453
diff
changeset
|
268 uint num_mm6_frames = data_mm6 ? *(int *)data_mm6 : 0, |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1453
diff
changeset
|
269 num_mm7_frames = data_mm7 ? *(int *)data_mm7 : 0, |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1453
diff
changeset
|
270 num_mm8_frames = data_mm8 ? *(int *)data_mm8 : 0; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1453
diff
changeset
|
271 |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1453
diff
changeset
|
272 sNumTextures = num_mm6_frames + num_mm7_frames + num_mm8_frames; |
1545 | 273 Assert(sNumTextures); |
274 Assert(!num_mm8_frames); | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1453
diff
changeset
|
275 |
1583 | 276 pTextures = (TextureFrame *)malloc(sNumTextures * sizeof(TextureFrame)); |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1453
diff
changeset
|
277 |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1453
diff
changeset
|
278 memcpy(pTextures, (char *)data_mm7 + 4, num_mm7_frames * sizeof(TextureFrame)); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1453
diff
changeset
|
279 memcpy(pTextures + num_mm7_frames, (char *)data_mm6 + 4, num_mm6_frames * sizeof(TextureFrame)); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1453
diff
changeset
|
280 memcpy(pTextures + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 4, num_mm8_frames * sizeof(TextureFrame)); |
0 | 281 } |
282 | |
283 //----- (0044E0ED) -------------------------------------------------------- | |
711 | 284 void TextureFrameTable::LoadAnimationSequenceAndPalettes( signed int uIconID ) |
285 { | |
0 | 286 TextureFrameTable *v3; // ebx@1 |
287 unsigned int i; // edi@3 | |
288 | |
289 v3 = this; | |
711 | 290 if ( (uIconID <= this->sNumTextures) && uIconID >= 0 ) |
0 | 291 { |
292 for ( i = uIconID; ; ++i ) | |
293 { | |
294 v3->pTextures[i].uTextureID = pBitmaps_LOD->LoadTexture(v3->pTextures[i].pTextureName, TEXTURE_DEFAULT); | |
973 | 295 |
1108
a1fd8045ffb1
probably erroneous semicolons removed, mace and staff stun chance work as they should
Grumpy7
parents:
1104
diff
changeset
|
296 if (v3->pTextures[i].uTextureID != -1) |
973 | 297 pBitmaps_LOD->pTextures[v3->pTextures[i].uTextureID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v3->pTextures[i].uTextureID].palette_id1); |
711 | 298 //result = (unsigned int)v3->pTextures; |
299 //if ( !(*(char *)(result + i * 20 + 18) & 1) ) | |
973 | 300 if( v3->pTextures[i].uFlags & 1) |
0 | 301 break; |
302 } | |
303 } | |
711 | 304 return; |
0 | 305 } |
306 | |
307 //----- (0044E163) -------------------------------------------------------- | |
308 unsigned int TextureFrameTable::FindTextureByName(const char *Str2) | |
309 { | |
310 TextureFrameTable *v2; // esi@1 | |
311 int v3; // ebx@1 | |
312 unsigned int uID; // edi@1 | |
313 unsigned int result; // eax@4 | |
314 | |
315 v2 = this; | |
316 v3 = 0; | |
317 uID = 0; | |
711 | 318 if ( (signed int)this->sNumTextures <= 0 ) |
0 | 319 { |
320 LABEL_4: | |
321 result = -1; | |
322 } | |
323 else | |
324 { | |
1104 | 325 while ( _stricmp(v2->pTextures[v3].pTextureName, Str2) ) |
0 | 326 { |
327 ++uID; | |
328 ++v3; | |
711 | 329 if ( (signed int)uID >= (signed int)v2->sNumTextures ) |
0 | 330 goto LABEL_4; |
331 } | |
332 result = uID; | |
333 } | |
334 return result; | |
335 } | |
336 | |
337 //----- (0044E19A) -------------------------------------------------------- | |
338 unsigned int TextureFrameTable::GetFrameTexture(int uFrameID, signed int a3) | |
339 { | |
340 int v3; // esi@1 | |
341 TextureFrame *v4; // edi@1 | |
342 TextureFrame *v5; // ecx@1 | |
343 __int16 v6; // dx@2 | |
344 int v7; // edx@3 | |
345 char *i; // eax@3 | |
346 int v9; // ecx@5 | |
347 unsigned int result; // eax@6 | |
348 | |
349 v3 = uFrameID; | |
350 v4 = this->pTextures; | |
351 v5 = &v4[uFrameID]; | |
352 if ( v5->uFlags & 1 && (v6 = v5->uAnimLength) != 0 ) | |
353 { | |
354 v7 = (a3 >> 3) % v6; | |
355 for ( i = (char *)&v5->uAnimTime; ; i += 20 ) | |
356 { | |
357 v9 = *(short *)i; | |
358 if ( v7 <= v9 ) | |
359 break; | |
360 v7 -= v9; | |
361 ++v3; | |
362 } | |
363 result = v4[v3].uTextureID; | |
364 } | |
365 else | |
366 { | |
367 result = v5->uTextureID; | |
368 } | |
369 return result; | |
370 } | |
371 | |
372 | |
373 | |
374 | |
375 | |
376 | |
377 //----- (0040F806) -------------------------------------------------------- | |
378 void *Texture::UnzipPalette() | |
379 { | |
380 Texture *v1; // esi@1 | |
1093 | 381 |
0 | 382 void *v2; // edi@1 |
383 Texture *pSource; // [sp+0h] [bp-4h]@1 | |
384 | |
385 pSource = this; | |
386 v1 = this; | |
387 v2 = malloc(this->uDecompressedSize); | |
710 | 388 zlib::MemUnzip(v2, (unsigned int *)&pSource, v1->pLevelOfDetail0_prolly_alpha_mask, v1->uTextureSize); |
0 | 389 return v2; |
390 } | |
391 | |
392 //----- (0040F77C) -------------------------------------------------------- | |
393 void Texture::Release() | |
394 { | |
395 if (this) | |
396 { | |
397 pName[0] = 0; | |
398 | |
399 if (pBits & 0x0400) | |
400 { | |
1093 | 401 __debugbreak(); |
402 } | |
403 | |
1583 | 404 free(pLevelOfDetail0_prolly_alpha_mask); |
405 free(pPalette16); | |
406 free(pPalette24); | |
1093 | 407 |
0 | 408 |
710 | 409 pLevelOfDetail0_prolly_alpha_mask = nullptr; |
0 | 410 pLevelOfDetail1 = nullptr; |
411 pLevelOfDetail2 = nullptr; | |
412 pLevelOfDetail3 = nullptr; | |
413 | |
414 pPalette16 = nullptr; | |
415 pPalette24 = nullptr; | |
416 | |
417 uSizeOfMaxLevelOfDetail = 0; | |
418 uTextureSize = 0; | |
419 uTextureHeight = 0; | |
420 uTextureWidth = 0; | |
421 uHeightLn2 = 0; | |
422 uWidthLn2 = 0; | |
423 palette_id1 = 0; | |
424 palette_id2 = 0; | |
425 pBits &= 0xFFFF0000; | |
426 } | |
427 } | |
428 | |
429 //----- (0040F5F5) -------------------------------------------------------- | |
430 int RGBTexture::Reload(const char *pContainer) | |
431 { | |
432 RGBTexture *v2; // esi@1 | |
433 FILE *v3; // eax@3 | |
434 FILE *v4; // edi@3 | |
435 void *v5; // ebx@7 | |
436 signed int result; // eax@11 | |
437 unsigned int v7; // ecx@12 | |
438 unsigned __int16 *v8; // ST20_4@14 | |
439 int v9; // eax@14 | |
440 char color_map[48]; // [sp+8h] [bp-98h]@9 | |
441 Texture DstBuf; // [sp+38h] [bp-68h]@1 | |
442 PCXHeader1 header1; // [sp+80h] [bp-20h]@9 | |
443 PCXHeader2 header2; // [sp+90h] [bp-10h]@9 | |
444 FILE *File; // [sp+98h] [bp-8h]@3 | |
445 size_t Count; // [sp+9Ch] [bp-4h]@6 | |
446 void *uSourceLena; // [sp+A8h] [bp+8h]@7 | |
447 | |
448 v2 = this; | |
449 if ( !v2->pPixels ) | |
450 return 2; | |
451 v3 = pIcons_LOD->FindContainer(pContainer, 0); | |
452 v4 = v3; | |
453 File = v3; | |
454 if ( !v3 ) | |
1545 | 455 Error("Unable to load %s", pContainer); |
456 | |
0 | 457 fread(&DstBuf, 1u, 0x30u, v3); |
458 Count = DstBuf.uTextureSize; | |
459 if ( DstBuf.uDecompressedSize ) | |
460 { | |
461 v5 = malloc(DstBuf.uDecompressedSize); | |
1583 | 462 uSourceLena = malloc(DstBuf.uTextureSize); |
0 | 463 fread(uSourceLena, 1u, Count, File); |
464 zlib::MemUnzip(v5, &DstBuf.uDecompressedSize, uSourceLena, DstBuf.uTextureSize); | |
465 DstBuf.uTextureSize = DstBuf.uDecompressedSize; | |
1583 | 466 free(uSourceLena); |
0 | 467 } |
468 else | |
469 { | |
470 v5 = malloc(DstBuf.uTextureSize); | |
471 fread(v5, 1u, Count, v4); | |
472 } | |
473 memcpy(&header1, v5, 0x10u); | |
474 memcpy(color_map, (char *)v5 + 16, 0x30u); | |
475 memcpy(&header2, (char *)v5 + 64, 6u); | |
476 if ( header1.bpp != 8 ) | |
477 return 3; | |
478 v7 = (signed __int16)(header1.right - header1.left + 1); | |
479 if ( (signed int)(v7 * (signed __int16)(header1.bottom - header1.up + 1)) <= (signed int)v2->uNumPixels ) | |
480 { | |
481 v2->uWidth = header1.right - header1.left + 1; | |
482 v8 = v2->pPixels; | |
483 v9 = v7 * v2->uHeight; | |
484 v2->uNumPixels = v9; | |
485 v2->uHeight = v9; | |
486 v2->DecodePCX((char *)v5, v8, v7); | |
487 free(v5); | |
488 result = 0; | |
489 } | |
490 else | |
491 { | |
492 result = -1; | |
493 } | |
494 return result; | |
495 } | |
496 | |
497 //----- (0040F5BE) -------------------------------------------------------- | |
498 Texture::Texture() | |
499 { | |
500 pName[0] = 0; | |
501 uSizeOfMaxLevelOfDetail = 0; | |
502 uTextureSize = 0; | |
503 uTextureHeight = 0; | |
504 uTextureWidth = 0; | |
505 uHeightLn2 = 0; | |
506 uWidthLn2 = 0; | |
507 palette_id1 = 0; | |
508 palette_id2 = 0; | |
710 | 509 pLevelOfDetail0_prolly_alpha_mask = 0; |
0 | 510 pLevelOfDetail3 = 0; |
511 pLevelOfDetail2 = 0; | |
512 pLevelOfDetail1 = 0; | |
513 pPalette16 = 0; | |
514 pPalette24 = 0; | |
515 } | |
516 | |
517 //----- (0040F414) -------------------------------------------------------- | |
518 int RGBTexture::Load(const char *pContainer, int mode) | |
519 { | |
520 RGBTexture *v3; // esi@1 | |
521 FILE *v4; // eax@1 | |
522 FILE *v5; // ebx@1 | |
523 void *v6; // ebx@5 | |
524 unsigned __int16 v7; // ax@9 | |
525 unsigned __int16 v8; // cx@9 | |
526 int v9; // ecx@9 | |
527 void *v10; // eax@9 | |
528 void *v11; // eax@13 | |
529 unsigned __int16 *v12; // eax@17 | |
530 char color_map[48]; // [sp+Ch] [bp-98h]@7 | |
531 Texture DstBuf; // [sp+3Ch] [bp-68h]@1 | |
532 PCXHeader1 header1; // [sp+84h] [bp-20h]@7 | |
533 PCXHeader2 header2; // [sp+94h] [bp-10h]@7 | |
534 FILE *File; // [sp+9Ch] [bp-8h]@1 | |
535 size_t Count; // [sp+A0h] [bp-4h]@4 | |
536 char *Str1a; // [sp+ACh] [bp+8h]@5 | |
537 | |
538 v3 = this; | |
539 v4 = pIcons_LOD->FindContainer(pContainer, 0); | |
540 v5 = v4; | |
541 File = v4; | |
542 if ( !v4 ) | |
1545 | 543 Error("Unable to load %s", pContainer); |
544 | |
0 | 545 fread(&DstBuf, 1u, 0x30u, v4); |
546 Count = DstBuf.uTextureSize; | |
547 if ( DstBuf.uDecompressedSize ) | |
548 { | |
549 Str1a = (char *)malloc(DstBuf.uDecompressedSize); | |
1583 | 550 v6 = malloc(DstBuf.uTextureSize); |
0 | 551 fread(v6, 1u, Count, File); |
552 zlib::MemUnzip(Str1a, &DstBuf.uDecompressedSize, v6, DstBuf.uTextureSize); | |
553 DstBuf.uTextureSize = DstBuf.uDecompressedSize; | |
1583 | 554 free(v6); |
0 | 555 } |
556 else | |
557 { | |
558 Str1a = (char *)malloc(DstBuf.uTextureSize); | |
559 fread(Str1a, 1u, Count, v5); | |
560 } | |
561 memcpy(&header1, Str1a, 0x10u); | |
562 memcpy(color_map, Str1a + 16, 0x30u); | |
563 memcpy(&header2, Str1a + 64, 6u); | |
564 if ( header1.bpp != 8 ) | |
565 return 3; | |
566 v7 = header1.right - header1.left + 1; | |
567 v8 = header1.bottom - header1.up + 1; | |
568 v3->uWidth = v7; | |
569 v3->uHeight = v8; | |
570 v9 = (signed __int16)v7 * (signed __int16)v8; | |
571 v10 = v3->pPixels; | |
572 v3->uNumPixels = v9; | |
573 if ( v10 ) | |
574 { | |
575 if ( mode ) | |
576 goto LABEL_14; | |
1583 | 577 free(v10); |
0 | 578 } |
579 if ( !mode ) | |
580 { | |
1583 | 581 v11 = malloc(2 * v3->uNumPixels + 4); |
0 | 582 goto LABEL_16; |
583 } | |
584 LABEL_14: | |
585 if ( mode != 2 ) | |
586 goto LABEL_17; | |
587 v11 = malloc(2 * v3->uNumPixels + 4); | |
1583 | 588 v3->_allocation_flags |= 1u; |
0 | 589 LABEL_16: |
590 v3->pPixels = (unsigned __int16 *)v11; | |
591 LABEL_17: | |
592 v12 = v3->pPixels; | |
593 if ( !v12 ) | |
594 return 2; | |
595 v3->DecodePCX(Str1a, v12, v3->uWidth); | |
596 free(Str1a); | |
597 return 0; | |
598 } | |
599 | |
600 | |
601 //----- (0040F037) -------------------------------------------------------- | |
602 signed int RGBTexture::DecodePCX(char *pPcx, unsigned __int16 *pOutPixels, unsigned int uNumPixels) | |
603 { | |
604 signed int result; // eax@2 | |
605 unsigned char test_byte; // edx@3 | |
606 unsigned int read_offset; // ebx@37 | |
607 unsigned int row_position; // edi@40 | |
608 unsigned char value; // cl@63 | |
609 char count; // [sp+50h] [bp-Ch]@43 | |
610 unsigned short current_line; // [sp+54h] [bp-8h]@38 | |
611 unsigned short *dec_position; | |
612 unsigned short *temp_dec_position; | |
613 PCXHeader1 psx_head1; | |
614 PCXHeader2 psx_head2; | |
615 short int width, height; | |
616 BYTE color_map[48]; // Colormap for 16-color images | |
617 | |
618 | |
619 memcpy(&psx_head1, pPcx , 16); | |
620 memcpy(&color_map, pPcx + 16, 48); | |
621 memcpy(&psx_head2, pPcx + 64, 6); | |
622 | |
623 | |
624 if (psx_head1.bpp!=8) | |
625 return 3; | |
626 uWidth=(short int )(psx_head1.right-psx_head1.left+1); // word @ 000014 | |
627 uHeight=(short int )(psx_head1.bottom-psx_head1.up+1); // word @ 000016 | |
628 | |
629 | |
630 uNumPixels=uWidth*uHeight; // dword @ 000010 | |
631 | |
632 memset(pOutPixels, 0, uNumPixels * sizeof(__int16)); | |
633 short i=1; | |
634 while ( (1<<i) !=uWidth) | |
635 { | |
636 ++i; | |
637 if (i >= 15) | |
638 break; | |
639 } | |
640 field_18=i; | |
641 short i_=1; | |
642 while ( (1<<i_) !=uHeight) | |
643 { | |
644 ++i_; | |
645 if (i_ >= 15) | |
646 break; | |
647 } | |
648 field_1A=i_; | |
649 switch (field_18) | |
650 { | |
651 case 2: field_1C = 3; break; | |
652 case 3: field_1C = 7; break; | |
653 case 4: field_1C = 15; break; | |
654 case 5: field_1C = 31; break; | |
655 case 6: field_1C = 63; break; | |
656 case 7: field_1C = 127; break; | |
657 case 8: field_1C = 255; break; | |
658 case 9: field_1C = 511; break; | |
659 case 10: field_1C = 1023; break; | |
660 case 11: field_1C = 2047; break; | |
661 case 12: field_1C = 4095; break; | |
662 } | |
663 | |
664 switch (field_1A) | |
665 { | |
666 case 2: field_1E = 3; break; | |
667 case 3: field_1E = 7; break; | |
668 case 4: field_1E = 15; break; | |
669 case 5: field_1E = 31; break; | |
670 case 6: field_1E = 63; break; | |
671 case 7: field_1E = 127; break; | |
672 case 8: field_1E = 255; break; | |
673 case 9: field_1E = 511; break; | |
674 case 10: field_1E = 1023; break; | |
675 case 11: field_1E = 2047; break; | |
676 case 12: field_1E = 4095; break; | |
677 } | |
678 | |
679 | |
680 read_offset = 128; | |
681 if (psx_head2.planes != 3) | |
682 return 0; | |
683 current_line = 0; | |
684 if ( uHeight > 0 ) | |
685 { | |
686 dec_position = pOutPixels; | |
687 do | |
688 { | |
689 temp_dec_position = dec_position; | |
690 row_position = 0; | |
691 //decode red line | |
692 if (psx_head2.pitch) | |
693 { | |
694 do | |
695 { | |
696 test_byte = pPcx[read_offset]; | |
697 ++read_offset; | |
698 if ((test_byte & 0xC0) == 0xC0) | |
699 { | |
700 value = pPcx[read_offset]; | |
701 ++read_offset; | |
702 | |
703 if ((test_byte & 0x3F) > 0) | |
704 { | |
705 count = test_byte & 0x3F; | |
706 do | |
707 { | |
708 | |
709 ++row_position; | |
710 //*temp_dec_position =0xFF000000; | |
711 //*temp_dec_position|=(unsigned long)value<<16; | |
712 *temp_dec_position |= LOWORD(pRenderer->uTargetRMask) & ((unsigned __int8)value << (LOBYTE(pRenderer->uTargetGBits) | |
713 + LOBYTE(pRenderer->uTargetRBits) | |
714 + LOBYTE(pRenderer->uTargetBBits) | |
715 - 8)); | |
716 | |
717 temp_dec_position++; | |
718 if (row_position == psx_head2.pitch) | |
719 break; | |
720 } | |
721 while (count-- != 1); | |
722 } | |
723 } | |
724 else | |
725 { | |
726 ++row_position; | |
727 //*temp_dec_position =0xFF000000; | |
728 //*temp_dec_position|= (unsigned long)test_byte<<16; | |
729 | |
730 *temp_dec_position |= LOWORD(pRenderer->uTargetRMask) & ((unsigned __int8)test_byte << (LOBYTE(pRenderer->uTargetGBits) | |
731 + LOBYTE(pRenderer->uTargetRBits) | |
732 + LOBYTE(pRenderer->uTargetBBits) | |
733 - 8)); | |
734 | |
735 temp_dec_position++; | |
736 } | |
737 | |
738 } | |
739 while (row_position < psx_head2.pitch); | |
740 } | |
741 | |
742 temp_dec_position = dec_position; | |
743 row_position=0; | |
744 //decode green line | |
745 while (row_position < psx_head2.pitch) | |
746 { | |
747 test_byte = *(pPcx + read_offset); | |
748 ++read_offset; | |
749 if ((test_byte & 0xC0) == 0xC0) | |
750 { | |
751 value = *(pPcx + read_offset); | |
752 ++read_offset; | |
753 if ((test_byte & 0x3F) > 0) | |
754 { | |
755 count = test_byte & 0x3F; | |
756 do | |
757 { | |
758 //*temp_dec_position|= (unsigned int)value<<8; | |
759 //temp_dec_position++; | |
760 | |
761 *temp_dec_position|= pRenderer->uTargetGMask & (unsigned __int16)((unsigned __int8)value << (LOBYTE(pRenderer->uTargetGBits) | |
762 + LOBYTE(pRenderer->uTargetBBits) | |
763 - 8)); | |
764 | |
765 temp_dec_position++; | |
766 ++row_position; | |
767 if (row_position == psx_head2.pitch) | |
768 break; | |
769 | |
770 } | |
771 while (count-- != 1); | |
772 } | |
773 } | |
774 else | |
775 { | |
776 //*temp_dec_position |=(unsigned int) test_byte<<8; | |
777 //temp_dec_position++; | |
778 | |
779 *temp_dec_position|= pRenderer->uTargetGMask & (unsigned __int16)((unsigned __int8)test_byte << (LOBYTE(pRenderer->uTargetGBits) | |
780 + LOBYTE(pRenderer->uTargetBBits) | |
781 - 8)); | |
782 temp_dec_position++; | |
783 ++row_position; | |
784 } | |
785 } | |
786 | |
787 temp_dec_position = dec_position; | |
788 row_position=0; | |
789 //decode blue line | |
790 while (row_position < psx_head2.pitch) | |
791 { | |
792 test_byte = *(pPcx + read_offset); | |
793 read_offset++; | |
794 if ((test_byte & 0xC0) == 0xC0) | |
795 { | |
796 value = *(pPcx + read_offset); | |
797 ++read_offset; | |
798 if ((test_byte & 0x3F) > 0) | |
799 { | |
800 count = test_byte & 0x3F; | |
801 do | |
802 { | |
803 //*temp_dec_position|= value; | |
804 //temp_dec_position++; | |
805 | |
806 *temp_dec_position |= value >> (8 - LOBYTE(pRenderer->uTargetBBits)); | |
807 temp_dec_position++; | |
808 | |
809 ++row_position; | |
810 if (row_position == psx_head2.pitch) | |
811 break; | |
812 } | |
813 while (count-- != 1); | |
814 } | |
815 } | |
816 else | |
817 { | |
818 //*temp_dec_position|= test_byte; | |
819 //temp_dec_position++; | |
820 *temp_dec_position |= test_byte >> (8 - LOBYTE(pRenderer->uTargetBBits)); | |
821 temp_dec_position++; | |
822 | |
823 ++row_position; | |
824 } | |
825 | |
826 } | |
827 ++current_line; | |
828 dec_position += uWidth; | |
829 } | |
830 while (current_line < uHeight); | |
831 } | |
832 return 0; | |
833 /* | |
834 RGBTexture *v4; // esi@1 | |
835 signed int result; // eax@2 | |
836 unsigned __int16 v6; // ax@3 | |
837 unsigned __int16 *v7; // ecx@3 | |
838 unsigned int v8; // edx@3 | |
839 signed int v9; // ecx@3 | |
840 signed int v10; // ecx@8 | |
841 signed int v11; // ebx@37 | |
842 unsigned __int16 *v12; // eax@40 | |
843 int v13; // edi@40 | |
844 int v14; // ebx@41 | |
845 char v15; // bl@42 | |
846 unsigned __int16 *v16; // eax@50 | |
847 int v17; // ebx@51 | |
848 char v18; // bl@52 | |
849 unsigned __int16 *v19; // eax@61 | |
850 unsigned __int8 v20; // dl@62 | |
851 unsigned __int8 v21; // dl@63 | |
852 unsigned __int8 v22; // cl@63 | |
853 char color_map[48]; // [sp+8h] [bp-54h]@1 | |
854 PCXHeader1 header1; // [sp+38h] [bp-24h]@1 | |
855 PCXHeader2 header2; // [sp+48h] [bp-14h]@1 | |
856 unsigned int v26; // [sp+50h] [bp-Ch]@43 | |
857 int v27; // [sp+54h] [bp-8h]@38 | |
858 unsigned __int16 *v28; // [sp+58h] [bp-4h]@3 | |
859 int pOutPixelsa; // [sp+68h] [bp+Ch]@41 | |
860 int pOutPixelsb; // [sp+68h] [bp+Ch]@51 | |
861 | |
862 v4 = this; | |
863 memcpy(&header1, pPcx, 0x10u); | |
864 memcpy(color_map, pPcx + 16, 0x30u); | |
865 memcpy(&header2, pPcx + 64, 6u); | |
866 if ( header1.bpp == 8 ) | |
867 { | |
868 v6 = header1.right - header1.left + 1; | |
869 LOWORD(v7) = header1.bottom - header1.up + 1; | |
870 v4->uWidth = v6; | |
871 v4->uHeight = (unsigned __int16)v7; | |
872 v7 = (unsigned __int16 *)(signed __int16)v7; | |
873 v28 = v7; | |
874 v4->uNumPixels = (signed __int16)v7 * (signed __int16)v6; | |
875 HIWORD(v8) = 0; | |
876 v9 = 1; | |
877 while ( 1 << v9 != (signed __int16)v6 ) | |
878 { | |
879 ++v9; | |
880 if ( v9 >= 15 ) | |
881 goto LABEL_8; | |
882 } | |
883 v4->field_18 = v9; | |
884 LABEL_8: | |
885 v10 = 1; | |
886 while ( (unsigned __int16 *)(1 << v10) != v28 ) | |
887 { | |
888 ++v10; | |
889 if ( v10 >= 15 ) | |
890 goto LABEL_13; | |
891 } | |
892 v4->field_1A = v10; | |
893 LABEL_13: | |
894 switch ( v4->field_18 ) | |
895 { | |
896 case 2: | |
897 v4->field_1C = 3; | |
898 break; | |
899 case 3: | |
900 v4->field_1C = 7; | |
901 break; | |
902 case 4: | |
903 v4->field_1C = 15; | |
904 break; | |
905 case 5: | |
906 v4->field_1C = 31; | |
907 break; | |
908 case 6: | |
909 v4->field_1C = 63; | |
910 break; | |
911 case 7: | |
912 v4->field_1C = 127; | |
913 break; | |
914 case 8: | |
915 v4->field_1C = 255; | |
916 break; | |
917 case 9: | |
918 v4->field_1C = 511; | |
919 break; | |
920 case 10: | |
921 v4->field_1C = 1023; | |
922 break; | |
923 case 11: | |
924 v4->field_1C = 2047; | |
925 break; | |
926 case 12: | |
927 v4->field_1C = 4095; | |
928 break; | |
929 default: | |
930 break; | |
931 } | |
932 switch ( v4->field_1A ) | |
933 { | |
934 case 2: | |
935 v4->field_1E = 3; | |
936 break; | |
937 case 3: | |
938 v4->field_1E = 7; | |
939 break; | |
940 case 4: | |
941 v4->field_1E = 15; | |
942 break; | |
943 case 5: | |
944 v4->field_1E = 31; | |
945 break; | |
946 case 6: | |
947 v4->field_1E = 63; | |
948 break; | |
949 case 7: | |
950 v4->field_1E = 127; | |
951 break; | |
952 case 8: | |
953 v4->field_1E = 255; | |
954 break; | |
955 case 9: | |
956 v4->field_1E = 511; | |
957 break; | |
958 case 10: | |
959 v4->field_1E = 1023; | |
960 break; | |
961 case 11: | |
962 v4->field_1E = 2047; | |
963 break; | |
964 case 12: | |
965 v4->field_1E = 4095; | |
966 break; | |
967 default: | |
968 break; | |
969 } | |
970 v11 = 128; | |
971 if ( header2.planes == 3 ) | |
972 { | |
973 v27 = 0; | |
974 if ( (signed int)v28 > 0 ) | |
975 { | |
976 v28 = pOutPixels; | |
977 do | |
978 { | |
979 v12 = v28; | |
980 v13 = 0; | |
981 if ( header2.pitch ) | |
982 { | |
983 do | |
984 { | |
985 LOBYTE(v8) = pPcx[v11]; | |
986 v14 = v11 + 1; | |
987 pOutPixelsa = v14; | |
988 if ( (v8 & 0xC0) == -64 ) | |
989 { | |
990 pOutPixelsa = v14 + 1; | |
991 v15 = pPcx[v14]; | |
992 if ( (signed int)(v8 & 0x3F) > 0 ) | |
993 { | |
994 v26 = v8 & 0x3F; | |
995 do | |
996 { | |
997 ++v13; | |
998 *v12 = LOWORD(pRenderer->uTargetRMask) & ((unsigned __int8)v15 << (LOBYTE(pRenderer->uTargetGBits) | |
999 + LOBYTE(pRenderer->uTargetRBits) | |
1000 + LOBYTE(pRenderer->uTargetBBits) | |
1001 - 8)); | |
1002 ++v12; | |
1003 if ( v13 == (unsigned __int16)header2.pitch ) | |
1004 v12 = &v12[uNumPixels - (unsigned __int16)header2.pitch - 1]; | |
1005 --v26; | |
1006 } | |
1007 while ( v26 ); | |
1008 } | |
1009 } | |
1010 else | |
1011 { | |
1012 LOWORD(v8) = (unsigned __int8)v8; | |
1013 v8 = pRenderer->uTargetRMask & (v8 << (LOBYTE(pRenderer->uTargetGBits) | |
1014 + LOBYTE(pRenderer->uTargetRBits) | |
1015 + LOBYTE(pRenderer->uTargetBBits) | |
1016 - 8)); | |
1017 ++v13; | |
1018 *v12 = v8; | |
1019 ++v12; | |
1020 } | |
1021 v11 = pOutPixelsa; | |
1022 } | |
1023 while ( v13 < (unsigned __int16)header2.pitch ); | |
1024 } | |
1025 v16 = v28; | |
1026 while ( v13 < 2 * (unsigned __int16)header2.pitch ) | |
1027 { | |
1028 LOBYTE(v8) = pPcx[v11]; | |
1029 v17 = v11 + 1; | |
1030 pOutPixelsb = v17; | |
1031 if ( (v8 & 0xC0) == -64 ) | |
1032 { | |
1033 pOutPixelsb = v17 + 1; | |
1034 v18 = pPcx[v17]; | |
1035 if ( (signed int)(v8 & 0x3F) > 0 ) | |
1036 { | |
1037 v26 = v8 & 0x3F; | |
1038 do | |
1039 { | |
1040 *v16 |= pRenderer->uTargetGMask & (unsigned __int16)((unsigned __int8)v18 << (LOBYTE(pRenderer->uTargetGBits) | |
1041 + LOBYTE(pRenderer->uTargetBBits) | |
1042 - 8)); | |
1043 ++v13; | |
1044 ++v16; | |
1045 if ( v13 == (unsigned __int16)header2.pitch ) | |
1046 v16 = &v16[uNumPixels - (unsigned __int16)header2.pitch - 1]; | |
1047 --v26; | |
1048 } | |
1049 while ( v26 ); | |
1050 } | |
1051 } | |
1052 else | |
1053 { | |
1054 LOWORD(v8) = (unsigned __int8)v8; | |
1055 v8 = pRenderer->uTargetGMask & (v8 << (LOBYTE(pRenderer->uTargetGBits) + LOBYTE(pRenderer->uTargetBBits) - 8)); | |
1056 *v16 |= v8; | |
1057 ++v13; | |
1058 ++v16; | |
1059 } | |
1060 v11 = pOutPixelsb; | |
1061 } | |
1062 v19 = v28; | |
1063 while ( v13 < 3 * (unsigned __int16)header2.pitch ) | |
1064 { | |
1065 v20 = pPcx[v11++]; | |
1066 if ( (v20 & 0xC0) == -64 ) | |
1067 { | |
1068 v21 = v20 & 0x3F; | |
1069 v22 = pPcx[v11++]; | |
1070 if ( (signed int)v21 > 0 ) | |
1071 { | |
1072 v26 = v21; | |
1073 do | |
1074 { | |
1075 *v19 |= v22 >> (8 - LOBYTE(pRenderer->uTargetBBits)); | |
1076 ++v13; | |
1077 ++v19; | |
1078 if ( v13 == (unsigned __int16)header2.pitch ) | |
1079 { | |
1080 v8 = uNumPixels - (unsigned __int16)header2.pitch; | |
1081 v19 = &v19[uNumPixels - (unsigned __int16)header2.pitch - 1]; | |
1082 } | |
1083 --v26; | |
1084 } | |
1085 while ( v26 ); | |
1086 } | |
1087 } | |
1088 else | |
1089 { | |
1090 *v19 |= v20 >> (8 - LOBYTE(pRenderer->uTargetBBits)); | |
1091 ++v13; | |
1092 ++v19; | |
1093 } | |
1094 } | |
1095 ++v27; | |
1096 v28 += uNumPixels; | |
1097 } | |
1098 while ( v27 < v4->uHeight ); | |
1099 } | |
1100 } | |
1101 result = 0; | |
1102 } | |
1103 else | |
1104 { | |
1105 result = 3; | |
1106 } | |
1107 return result; | |
1108 */ | |
1109 } | |
1110 | |
1111 //----- (0040EAD8) -------------------------------------------------------- | |
1112 unsigned int RGBTexture::LoadFromFILE(FILE *pFile, unsigned int mode, unsigned int bCloseFile) | |
1113 { | |
1114 signed int result; // eax@2 | |
1115 unsigned char test_byte; // edx@3 | |
1116 //unsigned int read_offset; // ebx@37 | |
1117 unsigned int row_position; // edi@40 | |
1118 unsigned char value; // cl@63 | |
1119 char count; // [sp+50h] [bp-Ch]@43 | |
1120 unsigned short current_line; // [sp+54h] [bp-8h]@38 | |
1121 unsigned short *dec_position; | |
1122 unsigned short *temp_dec_position; | |
1123 PCXHeader1 psx_head1; | |
1124 PCXHeader2 psx_head2; | |
1125 short int width, height; | |
1126 BYTE color_map[48]; // Colormap for 16-color images | |
1127 | |
1128 if (!pFile) | |
1129 return 1; | |
1130 | |
1131 | |
1132 fread(&psx_head1, 1, 16, pFile); | |
1133 fread(&color_map, 1, 48, pFile); | |
1134 fread(&psx_head2, 1, 6, pFile); | |
1135 | |
1136 if (psx_head1.bpp!=8) | |
1137 return 3; | |
1138 uWidth=(short int )(psx_head1.right-psx_head1.left+1); // word @ 000014 | |
1139 uHeight=(short int )(psx_head1.bottom-psx_head1.up+1); // word @ 000016 | |
1140 | |
1141 | |
1142 uNumPixels=uWidth*uHeight; // dword @ 000010 | |
1143 | |
1144 | |
1145 if ( mode == 0 ) | |
1146 { | |
1147 if ( pPixels ) | |
1148 { | |
1583 | 1149 free(pPixels); |
0 | 1150 pPixels = 0; |
1151 } | |
1583 | 1152 pPixels = (unsigned __int16 *)malloc(2 * uNumPixels + 4); |
0 | 1153 } |
1154 else | |
1155 { | |
1156 if ( mode != 1 && mode == 2 ) | |
1157 { | |
1158 pPixels = (unsigned __int16 *)malloc((uNumPixels + 2) * sizeof(unsigned __int16)); | |
1583 | 1159 _allocation_flags |= 1; |
0 | 1160 } |
1161 } | |
1162 | |
1163 | |
1164 | |
1165 | |
1166 auto pOutPixels = pPixels; | |
1167 | |
1168 memset(pOutPixels, 0, uNumPixels * sizeof(__int16)); | |
1169 | |
1170 short i=1; | |
1171 while ( (1<<i) !=uWidth) | |
1172 { | |
1173 ++i; | |
1174 if (i >= 15) | |
1175 break; | |
1176 } | |
1177 field_18=i; | |
1178 short i_=1; | |
1179 while ( (1<<i_) !=uHeight) | |
1180 { | |
1181 ++i_; | |
1182 if (i_ >= 15) | |
1183 break; | |
1184 } | |
1185 field_1A=i_; | |
1186 switch (field_18) | |
1187 { | |
1188 case 2: field_1C = 3; break; | |
1189 case 3: field_1C = 7; break; | |
1190 case 4: field_1C = 15; break; | |
1191 case 5: field_1C = 31; break; | |
1192 case 6: field_1C = 63; break; | |
1193 case 7: field_1C = 127; break; | |
1194 case 8: field_1C = 255; break; | |
1195 case 9: field_1C = 511; break; | |
1196 case 10: field_1C = 1023; break; | |
1197 case 11: field_1C = 2047; break; | |
1198 case 12: field_1C = 4095; break; | |
1199 } | |
1200 | |
1201 switch (field_1A) | |
1202 { | |
1203 case 2: field_1E = 3; break; | |
1204 case 3: field_1E = 7; break; | |
1205 case 4: field_1E = 15; break; | |
1206 case 5: field_1E = 31; break; | |
1207 case 6: field_1E = 63; break; | |
1208 case 7: field_1E = 127; break; | |
1209 case 8: field_1E = 255; break; | |
1210 case 9: field_1E = 511; break; | |
1211 case 10: field_1E = 1023; break; | |
1212 case 11: field_1E = 2047; break; | |
1213 case 12: field_1E = 4095; break; | |
1214 } | |
1215 | |
1216 | |
1217 fseek(pFile, 128 - 70, SEEK_CUR); | |
1218 | |
1219 | |
1220 for (uint y = 0; y < uHeight; ++y) | |
1221 { | |
1222 unsigned __int16 *pDst = pPixels + y * uWidth; | |
1223 | |
1224 uint x = 0; | |
1225 do | |
1226 { | |
1227 uint ctrl = 0; | |
1228 fread(&ctrl, 1, 1, pFile); | |
1229 if ((ctrl & 0xC0) == 0xC0) | |
1230 { | |
1231 uint uNumPixels = ctrl & 0x3F; | |
1232 uint clr = 0; | |
1233 fread(&clr, 1, 1, pFile); | |
1234 for (uint i = 0; i < uNumPixels; ++i) | |
1235 pDst[x++] = pRenderer->uTargetRMask & (clr << (pRenderer->uTargetGBits + | |
1236 pRenderer->uTargetRBits + | |
1237 pRenderer->uTargetBBits - 8)); | |
1238 } | |
1239 else | |
1240 { | |
1241 pDst[x++] = pRenderer->uTargetRMask & (ctrl << (pRenderer->uTargetGBits + | |
1242 pRenderer->uTargetRBits + | |
1243 pRenderer->uTargetBBits - 8)); | |
1244 } | |
1245 } while (x < psx_head2.pitch); | |
1246 | |
1247 | |
1248 | |
1249 | |
1250 | |
1251 x = 0; | |
1252 do | |
1253 { | |
1254 uint ctrl = 0; | |
1255 fread(&ctrl, 1, 1, pFile); | |
1256 if ((ctrl & 0xC0) == 0xC0) | |
1257 { | |
1258 uint uNumPixels = ctrl & 0x3F; | |
1259 uint clr = 0; | |
1260 fread(&clr, 1, 1, pFile); | |
1261 for (uint i = 0; i < uNumPixels; ++i) | |
1262 pDst[x++] |= pRenderer->uTargetGMask & (clr << (pRenderer->uTargetGBits + | |
1263 pRenderer->uTargetBBits - 8)); | |
1264 } | |
1265 else | |
1266 { | |
1267 pDst[x++] |= pRenderer->uTargetGMask & (ctrl << (pRenderer->uTargetGBits + | |
1268 pRenderer->uTargetBBits - 8)); | |
1269 } | |
1270 } while (x < psx_head2.pitch); | |
1271 | |
1272 | |
1273 | |
1274 | |
1275 | |
1276 x = 0; | |
1277 do | |
1278 { | |
1279 uint ctrl = 0; | |
1280 fread(&ctrl, 1, 1, pFile); | |
1281 if ((ctrl & 0xC0) == 0xC0) | |
1282 { | |
1283 uint uNumPixels = ctrl & 0x3F; | |
1284 uint clr = 0; | |
1285 fread(&clr, 1, 1, pFile); | |
1286 for (uint i = 0; i < uNumPixels; ++i) | |
1287 pDst[x++] |= pRenderer->uTargetBMask & (clr >> (8 - pRenderer->uTargetBBits)); | |
1288 } | |
1289 else | |
1290 { | |
1291 pDst[x++] |= pRenderer->uTargetBMask & (ctrl >> (8 - pRenderer->uTargetRBits)); | |
1292 } | |
1293 } while (x < psx_head2.pitch); | |
1294 } | |
1295 | |
1296 if (bCloseFile) | |
1297 fclose(pFile); | |
1298 return 0; | |
1299 } | |
1300 | |
1301 //----- (0040E51F) -------------------------------------------------------- | |
1302 void RGBTexture::Release() | |
1303 { | |
1304 RGBTexture *v1; // esi@1 | |
1305 char v2; // zf@1 | |
1306 void *v3; // [sp-4h] [bp-Ch]@1 | |
1307 | |
1308 v1 = this; | |
1583 | 1309 v2 = (this->_allocation_flags & 1) == 0; |
0 | 1310 v3 = this->pPixels; |
1311 this->pName[0] = 0; | |
1312 if ( v2 ) | |
1583 | 1313 free(v3); |
0 | 1314 else |
1315 free(v3); | |
1583 | 1316 v1->_allocation_flags = 0; |
0 | 1317 v1->pPixels = 0; |
1318 v1->uNumPixels = 0; | |
1319 v1->uHeight = 0; | |
1320 v1->uWidth = 0; | |
1321 v1->field_1A = 0; | |
1322 v1->field_18 = 0; | |
1323 } | |
1324 | |
1325 //----- (0040E55E) -------------------------------------------------------- | |
1326 int RGBTexture::_40E55E(const char *Filename, unsigned int a3) | |
1327 { | |
1328 RGBTexture *v3; // esi@1 | |
1329 signed int result; // eax@2 | |
1330 char *v6; // eax@3 | |
1331 int v7; // edx@3 | |
1332 char v8; // cl@4 | |
1333 unsigned __int16 v9; // cx@9 | |
1334 unsigned __int16 v10; // ax@9 | |
1335 int v11; // eax@9 | |
1336 char v12; // zf@9 | |
1337 void *v13; // eax@12 | |
1338 signed int v14; // ecx@19 | |
1339 signed int v15; // ecx@24 | |
1340 int v16; // eax@57 | |
1341 unsigned __int16 *v17; // ecx@57 | |
1342 unsigned __int16 *v18; // edi@57 | |
1343 signed int v19; // eax@59 | |
1344 unsigned __int16 *v20; // edi@64 | |
1345 signed int v21; // eax@66 | |
1346 unsigned __int16 *v22; // edi@71 | |
1347 signed int v23; // eax@73 | |
1348 int v24; // eax@78 | |
71 | 1349 char v25[48]; // [sp+Ch] [bp-54h]@3 |
1350 PCXHeader1 pcx_header1; | |
1351 PCXHeader2 pcx_header2; | |
0 | 1352 int v37; // [sp+54h] [bp-Ch]@3 |
1353 int v38; // [sp+58h] [bp-8h]@57 | |
1354 FILE *File; // [sp+5Ch] [bp-4h]@1 | |
1355 | |
1356 v3 = this; | |
1357 File = fopen(Filename, "rb"); | |
1358 if ( !File ) | |
1359 return 1; | |
71 | 1360 |
1361 fread(&pcx_header1, sizeof(pcx_header1), 1, File); | |
1362 fread(&v25,48,1,File); | |
1363 fread(&pcx_header2, 4, 1, File); | |
1364 | |
0 | 1365 v6 = (char *)Filename; |
1366 v37 = 0; | |
1367 v7 = (char *)v3 - Filename; | |
1368 do | |
1369 { | |
1370 v8 = *v6; | |
1371 if ( !*v6 ) | |
1372 break; | |
1373 if ( v8 == 46 ) | |
1374 break; | |
1375 ++v37; | |
1376 (v6++)[v7] = v8; | |
1377 } | |
1378 while ( v37 < 15 ); | |
1379 v3->pName[v37] = 0; | |
71 | 1380 if ( pcx_header1.bpp != 8 ) |
0 | 1381 return 3; |
71 | 1382 v9 = pcx_header1.right - pcx_header1.left + 1; |
1383 v10 = pcx_header1.bottom - pcx_header1.up; | |
0 | 1384 v3->uWidth = v9; |
1385 ++v10; | |
1386 v3->uHeight = v10; | |
1387 v11 = (signed __int16)v9 * (signed __int16)v10; | |
1388 v12 = a3 == 0; | |
1389 v3->uNumPixels = v11; | |
1390 if ( v12 ) | |
1391 { | |
1392 if ( v3->pPixels ) | |
1583 | 1393 free(v3->pPixels); |
1394 v13 = malloc(2 * v3->uNumPixels + 4); | |
0 | 1395 goto LABEL_16; |
1396 } | |
1397 if ( a3 != 1 && a3 == 2 ) | |
1398 { | |
1583 | 1399 v13 = malloc(4 * v11 + 8); |
1400 v3->_allocation_flags |= 1u; | |
0 | 1401 LABEL_16: |
1402 v3->pPixels = (unsigned __int16 *)v13; | |
1403 } | |
1404 if ( v3->pPixels ) | |
1405 { | |
1406 v14 = 1; | |
1407 while ( 1 << v14 != v3->uWidth ) | |
1408 { | |
1409 ++v14; | |
1410 if ( v14 >= 15 ) | |
1411 goto LABEL_24; | |
1412 } | |
1413 v3->field_18 = v14; | |
1414 LABEL_24: | |
1415 v15 = 1; | |
1416 while ( 1 << v15 != v3->uHeight ) | |
1417 { | |
1418 ++v15; | |
1419 if ( v15 >= 15 ) | |
1420 goto LABEL_29; | |
1421 } | |
1422 v3->field_1A = v15; | |
1423 LABEL_29: | |
1424 switch ( v3->field_18 ) | |
1425 { | |
1426 case 2: | |
1427 v3->field_1C = 3; | |
1428 break; | |
1429 case 3: | |
1430 v3->field_1C = 7; | |
1431 break; | |
1432 case 4: | |
1433 v3->field_1C = 15; | |
1434 break; | |
1435 case 5: | |
1436 v3->field_1C = 31; | |
1437 break; | |
1438 case 6: | |
1439 v3->field_1C = 63; | |
1440 break; | |
1441 case 7: | |
1442 v3->field_1C = 127; | |
1443 break; | |
1444 case 8: | |
1445 v3->field_1C = 255; | |
1446 break; | |
1447 case 9: | |
1448 v3->field_1C = 511; | |
1449 break; | |
1450 case 10: | |
1451 v3->field_1C = 1023; | |
1452 break; | |
1453 case 11: | |
1454 v3->field_1C = 2047; | |
1455 break; | |
1456 case 12: | |
1457 v3->field_1C = 4095; | |
1458 break; | |
1459 default: | |
1460 break; | |
1461 } | |
1462 switch ( v3->field_1A ) | |
1463 { | |
1464 case 2: | |
1465 v3->field_1E = 3; | |
1466 break; | |
1467 case 3: | |
1468 v3->field_1E = 7; | |
1469 break; | |
1470 case 4: | |
1471 v3->field_1E = 15; | |
1472 break; | |
1473 case 5: | |
1474 v3->field_1E = 31; | |
1475 break; | |
1476 case 6: | |
1477 v3->field_1E = 63; | |
1478 break; | |
1479 case 7: | |
1480 v3->field_1E = 127; | |
1481 break; | |
1482 case 8: | |
1483 v3->field_1E = 255; | |
1484 break; | |
1485 case 9: | |
1486 v3->field_1E = 511; | |
1487 break; | |
1488 case 10: | |
1489 v3->field_1E = 1023; | |
1490 break; | |
1491 case 11: | |
1492 v3->field_1E = 2047; | |
1493 break; | |
1494 case 12: | |
1495 v3->field_1E = 4095; | |
1496 break; | |
1497 default: | |
1498 break; | |
1499 } | |
1500 fseek(File, 128, 0); | |
1501 ftell(File); | |
71 | 1502 if ( pcx_header2.planes == 1 ) |
1545 | 1503 Error("24bit PCX Only!"); |
1504 | |
71 | 1505 if ( pcx_header2.planes == 3 ) |
0 | 1506 { |
1507 v37 = 0; | |
1508 if ( v3->uHeight > 0 ) | |
1509 { | |
1510 do | |
1511 { | |
1512 v16 = v37 * v3->uWidth; | |
1513 v17 = v3->pPixels; | |
1514 v38 = 0; | |
1515 v18 = &v17[v16]; | |
71 | 1516 if ( pcx_header2.pitch ) |
0 | 1517 { |
1518 do | |
1519 { | |
1520 fread((char *)&Filename + 3, 1u, 1u, File); | |
1521 if ( (BYTE3(Filename) & 0xC0) == -64 ) | |
1522 { | |
1523 BYTE3(Filename) &= 0x3Fu; | |
1524 fread((char *)&a3 + 3, 1u, 1u, File); | |
1525 v19 = 0; | |
1526 if ( BYTE3(Filename) ) | |
1527 { | |
1528 do | |
1529 { | |
1530 ++v38; | |
1531 *v18 = LOWORD(pRenderer->uTargetRMask) & (BYTE3(a3) << (LOBYTE(pRenderer->uTargetGBits) | |
1532 + LOBYTE(pRenderer->uTargetRBits) | |
1533 + LOBYTE(pRenderer->uTargetBBits) | |
1534 - 8)); | |
1535 ++v18; | |
1536 ++v19; | |
1537 } | |
1538 while ( v19 < BYTE3(Filename) ); | |
1539 } | |
1540 } | |
1541 else | |
1542 { | |
1543 ++v38; | |
1544 *v18 = LOWORD(pRenderer->uTargetRMask) & (BYTE3(Filename) << (LOBYTE(pRenderer->uTargetGBits) | |
1545 + LOBYTE(pRenderer->uTargetRBits) | |
1546 + LOBYTE(pRenderer->uTargetBBits) | |
1547 - 8)); | |
1548 ++v18; | |
1549 } | |
1550 } | |
71 | 1551 while ( v38 < (unsigned __int16)pcx_header2.pitch); |
0 | 1552 } |
1553 v20 = &v3->pPixels[v37 * v3->uWidth]; | |
71 | 1554 while ( v38 < 2 * (unsigned __int16)pcx_header2.pitch ) |
0 | 1555 { |
1556 fread((char *)&Filename + 3, 1u, 1u, File); | |
1557 if ( (BYTE3(Filename) & 0xC0) == -64 ) | |
1558 { | |
1559 BYTE3(Filename) &= 0x3Fu; | |
1560 fread((char *)&a3 + 3, 1u, 1u, File); | |
1561 v21 = 0; | |
1562 if ( BYTE3(Filename) ) | |
1563 { | |
1564 do | |
1565 { | |
1566 *v20 |= pRenderer->uTargetGMask & (unsigned __int16)(BYTE3(a3) << (LOBYTE(pRenderer->uTargetGBits) | |
1567 + LOBYTE(pRenderer->uTargetBBits) | |
1568 - 8)); | |
1569 ++v38; | |
1570 ++v20; | |
1571 ++v21; | |
1572 } | |
1573 while ( v21 < BYTE3(Filename) ); | |
1574 } | |
1575 } | |
1576 else | |
1577 { | |
1578 *v20 |= pRenderer->uTargetGMask & (unsigned __int16)(BYTE3(Filename) << (LOBYTE(pRenderer->uTargetGBits) | |
1579 + LOBYTE(pRenderer->uTargetBBits) | |
1580 - 8)); | |
1581 ++v38; | |
1582 ++v20; | |
1583 } | |
1584 } | |
1585 v22 = &v3->pPixels[v37 * v3->uWidth]; | |
71 | 1586 while ( v38 < 3 * (unsigned __int16)pcx_header2.pitch ) |
0 | 1587 { |
1588 fread((char *)&Filename + 3, 1u, 1u, File); | |
1589 if ( (BYTE3(Filename) & 0xC0) == -64 ) | |
1590 { | |
1591 BYTE3(Filename) &= 0x3Fu; | |
1592 fread((char *)&a3 + 3, 1u, 1u, File); | |
1593 v23 = 0; | |
1594 if ( BYTE3(Filename) ) | |
1595 { | |
1596 do | |
1597 { | |
1598 *v22 |= BYTE3(a3) >> (8 - LOBYTE(pRenderer->uTargetBBits)); | |
1599 ++v38; | |
1600 ++v22; | |
1601 ++v23; | |
1602 } | |
1603 while ( v23 < BYTE3(Filename) ); | |
1604 } | |
1605 } | |
1606 else | |
1607 { | |
1608 *v22 |= BYTE3(Filename) >> (8 - LOBYTE(pRenderer->uTargetBBits)); | |
1609 ++v38; | |
1610 ++v22; | |
1611 } | |
1612 } | |
1613 v24 = v3->uHeight; | |
1614 ++v37; | |
1615 } | |
1616 while ( v37 < v24 ); | |
1617 } | |
1618 } | |
1619 fclose(File); | |
1620 result = 0; | |
1621 } | |
1622 else | |
1623 { | |
1624 result = 2; | |
1625 } | |
1626 return result; | |
1627 } | |
1628 | |
1629 | |
1630 //----- (0040D73D) -------------------------------------------------------- | |
1631 RGBTexture::RGBTexture() | |
1632 { | |
1633 pName[0] = 0; | |
1634 pPixels = 0; | |
1635 uNumPixels = 0; | |
1636 uHeight = 0; | |
1637 uWidth = 0; | |
1638 field_1A = 0; | |
1639 field_18 = 0; | |
1583 | 1640 _allocation_flags = 0; |
1297 | 1641 } |
1642 //----- (0044E1EC) -------------------------------------------------------- | |
1643 int TextureFrameTable::FromFileTxt(const char *Args) | |
1644 { | |
1645 TextureFrameTable *v2; // ebx@1 | |
1646 FILE *v3; // eax@1 | |
1647 int v4; // esi@3 | |
1648 const void *v5; // ST0C_4@10 | |
1649 void *v6; // eax@10 | |
1650 FILE *v7; // ST0C_4@12 | |
1651 char *i; // eax@12 | |
1652 signed int v9; // esi@15 | |
1653 int v10; // eax@17 | |
1654 int v11; // edx@22 | |
1655 int v12; // ecx@23 | |
1656 int v13; // eax@24 | |
1657 signed int j; // eax@27 | |
1658 TextureFrame *v15; // edx@28 | |
1659 int v16; // esi@28 | |
1660 int k; // ecx@29 | |
1661 char Buf; // [sp+Ch] [bp-2F8h]@3 | |
1662 FrameTableTxtLine v20; // [sp+200h] [bp-104h]@4 | |
1663 int v21; // [sp+27Ch] [bp-88h]@4 | |
1664 char *Str1; // [sp+280h] [bp-84h]@5 | |
1665 char *Str; // [sp+284h] [bp-80h]@15 | |
1666 int v24; // [sp+2F8h] [bp-Ch]@3 | |
1667 int v25; // [sp+2FCh] [bp-8h]@3 | |
1668 FILE *File; // [sp+300h] [bp-4h]@1 | |
1669 int Argsa; // [sp+30Ch] [bp+8h]@28 | |
1670 | |
1671 v2 = this; | |
1672 v3 = fopen(Args, "r"); | |
1673 File = v3; | |
1674 if ( !v3 ) | |
1545 | 1675 Error("CTextureFrameTable::load - Unable to open file: %s.", Args); |
1676 | |
1297 | 1677 v4 = 0; |
1678 v24 = 0; | |
1679 v25 = 1; | |
1680 if ( fgets(&Buf, 490, v3) ) | |
1681 { | |
1682 do | |
1683 { | |
1684 *strchr(&Buf, 10) = 0; | |
1685 memcpy(&v21, txt_file_frametable_parser(&Buf, &v20), 0x7Cu); | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1402
diff
changeset
|
1686 __debugbreak(); // warning C4700: uninitialized local variable 'Str1' used |
1297 | 1687 if ( v21 && *Str1 != 47 ) |
1688 { | |
1689 if ( v21 < 2 ) | |
1545 | 1690 Error("CTextureFrameTable::load, too few arguments, %s line %i.", Args, v25); |
1297 | 1691 ++v24; |
1692 } | |
1693 ++v25; | |
1694 } | |
1695 while ( fgets(&Buf, 490, File) ); | |
1696 v4 = v24; | |
1697 } | |
1698 v5 = v2->pTextures; | |
1699 v2->sNumTextures = v4; | |
1583 | 1700 v6 = malloc(20 * v4); |
1297 | 1701 v2->pTextures = (TextureFrame *)v6; |
1702 if ( !v6 ) | |
1545 | 1703 Error("CTextureFrameTable::load - Out of Memory!"); |
1297 | 1704 v7 = File; |
1705 v2->sNumTextures = 0; | |
1706 fseek(v7, 0, 0); | |
1707 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) | |
1708 { | |
1709 *strchr(&Buf, 10) = 0; | |
1710 memcpy(&v21, txt_file_frametable_parser(&Buf, &v20), 0x7Cu); | |
1711 if ( v21 && *Str1 != 47 ) | |
1712 { | |
1713 strcpy(v2->pTextures[v2->sNumTextures].pTextureName, Str1); | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1402
diff
changeset
|
1714 __debugbreak(); // warning C4700: uninitialized local variable 'Str' used |
1297 | 1715 v2->pTextures[v2->sNumTextures].uAnimTime = atoi(Str); |
1716 v9 = 2; | |
1717 for ( v2->pTextures[v2->sNumTextures].uFlags = 0; v9 < v21; ++v9 ) | |
1718 { | |
1719 if ( !_stricmp((&Str1)[4 * v9], "New") ) | |
1720 { | |
1721 v10 = (int)&v2->pTextures[v2->sNumTextures].uFlags; | |
1722 *(char *)v10 |= 2u; | |
1723 } | |
1724 } | |
1725 ++v2->sNumTextures; | |
1726 } | |
1727 } | |
1728 fclose(File); | |
1729 v11 = 0; | |
1730 if ( (signed int)(v2->sNumTextures - 1) > 0 ) | |
1731 { | |
1732 v12 = 0; | |
1733 do | |
1734 { | |
1735 v13 = (int)&v2->pTextures[v12]; | |
1736 if ( !(*(char *)(v13 + 38) & 2) ) | |
1737 *(char *)(v13 + 18) |= 1u; | |
1738 ++v11; | |
1739 ++v12; | |
1740 } | |
1741 while ( v11 < (signed int)(v2->sNumTextures - 1) ); | |
1742 } | |
1743 for ( j = 0; j < (signed int)v2->sNumTextures; *(short *)(Argsa + 16) = v16 ) | |
1744 { | |
1745 v15 = v2->pTextures; | |
1746 Argsa = (int)&v15[j]; | |
1747 v16 = *(short *)(Argsa + 14); | |
1748 if ( *(char *)(Argsa + 18) & 1 ) | |
1749 { | |
1750 ++j; | |
1751 for ( k = (int)&v15[j]; *(char *)(k + 18) & 1; k += 20 ) | |
1752 { | |
1753 v16 += *(short *)(k + 14); | |
1754 ++j; | |
1755 } | |
1756 LOWORD(v16) = v15[j].uAnimTime + v16; | |
1757 } | |
1758 ++j; | |
1759 } | |
1760 return 1; | |
1761 } |