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