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