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