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));
|
32
|
644 short i=1;
|
|
645 while ( (1<<i) !=uWidth)
|
|
646 {
|
|
647 ++i;
|
|
648 if (i >= 15)
|
|
649 break;
|
|
650 }
|
|
651 field_18=i;
|
|
652 short i_=1;
|
|
653 while ( (1<<i_) !=uHeight)
|
|
654 {
|
|
655 ++i_;
|
|
656 if (i_ >= 15)
|
|
657 break;
|
|
658 }
|
|
659 field_1A=i_;
|
0
|
660 switch (field_18)
|
|
661 {
|
|
662 case 2: field_1C = 3; break;
|
|
663 case 3: field_1C = 7; break;
|
|
664 case 4: field_1C = 15; break;
|
|
665 case 5: field_1C = 31; break;
|
|
666 case 6: field_1C = 63; break;
|
|
667 case 7: field_1C = 127; break;
|
|
668 case 8: field_1C = 255; break;
|
|
669 case 9: field_1C = 511; break;
|
|
670 case 10: field_1C = 1023; break;
|
|
671 case 11: field_1C = 2047; break;
|
|
672 case 12: field_1C = 4095; break;
|
|
673 }
|
|
674
|
|
675 switch (field_1A)
|
|
676 {
|
|
677 case 2: field_1E = 3; break;
|
|
678 case 3: field_1E = 7; break;
|
|
679 case 4: field_1E = 15; break;
|
|
680 case 5: field_1E = 31; break;
|
|
681 case 6: field_1E = 63; break;
|
|
682 case 7: field_1E = 127; break;
|
|
683 case 8: field_1E = 255; break;
|
|
684 case 9: field_1E = 511; break;
|
|
685 case 10: field_1E = 1023; break;
|
|
686 case 11: field_1E = 2047; break;
|
|
687 case 12: field_1E = 4095; break;
|
|
688 }
|
|
689
|
|
690
|
|
691 read_offset = 128;
|
|
692 if (psx_head2.planes != 3)
|
32
|
693 return 0;
|
0
|
694 current_line = 0;
|
32
|
695 if ( uHeight > 0 )
|
0
|
696 {
|
|
697 dec_position = pOutPixels;
|
|
698 do
|
|
699 {
|
|
700 temp_dec_position = dec_position;
|
|
701 row_position = 0;
|
|
702 //decode red line
|
|
703 if (psx_head2.pitch)
|
|
704 {
|
|
705 do
|
|
706 {
|
32
|
707 test_byte = pPcx[read_offset];
|
0
|
708 ++read_offset;
|
|
709 if ((test_byte & 0xC0) == 0xC0)
|
|
710 {
|
32
|
711 value = pPcx[read_offset];
|
0
|
712 ++read_offset;
|
|
713
|
|
714 if ((test_byte & 0x3F) > 0)
|
|
715 {
|
|
716 count = test_byte & 0x3F;
|
|
717 do
|
|
718 {
|
|
719
|
|
720 ++row_position;
|
|
721 //*temp_dec_position =0xFF000000;
|
|
722 //*temp_dec_position|=(unsigned long)value<<16;
|
|
723 *temp_dec_position |= LOWORD(pRenderer->uTargetRMask) & ((unsigned __int8)value << (LOBYTE(pRenderer->uTargetGBits)
|
|
724 + LOBYTE(pRenderer->uTargetRBits)
|
|
725 + LOBYTE(pRenderer->uTargetBBits)
|
|
726 - 8));
|
|
727
|
|
728 temp_dec_position++;
|
|
729 if (row_position == psx_head2.pitch)
|
|
730 break;
|
|
731 }
|
|
732 while (count-- != 1);
|
|
733 }
|
|
734 }
|
|
735 else
|
|
736 {
|
|
737 ++row_position;
|
|
738 //*temp_dec_position =0xFF000000;
|
|
739 //*temp_dec_position|= (unsigned long)test_byte<<16;
|
|
740
|
|
741 *temp_dec_position |= LOWORD(pRenderer->uTargetRMask) & ((unsigned __int8)test_byte << (LOBYTE(pRenderer->uTargetGBits)
|
|
742 + LOBYTE(pRenderer->uTargetRBits)
|
|
743 + LOBYTE(pRenderer->uTargetBBits)
|
|
744 - 8));
|
|
745
|
|
746 temp_dec_position++;
|
|
747 }
|
|
748
|
|
749 }
|
|
750 while (row_position < psx_head2.pitch);
|
|
751 }
|
|
752
|
|
753 temp_dec_position = dec_position;
|
|
754 row_position=0;
|
|
755 //decode green line
|
|
756 while (row_position < psx_head2.pitch)
|
|
757 {
|
|
758 test_byte = *(pPcx + read_offset);
|
|
759 ++read_offset;
|
|
760 if ((test_byte & 0xC0) == 0xC0)
|
|
761 {
|
|
762 value = *(pPcx + read_offset);
|
|
763 ++read_offset;
|
|
764 if ((test_byte & 0x3F) > 0)
|
|
765 {
|
|
766 count = test_byte & 0x3F;
|
|
767 do
|
|
768 {
|
|
769 //*temp_dec_position|= (unsigned int)value<<8;
|
|
770 //temp_dec_position++;
|
|
771
|
|
772 *temp_dec_position|= pRenderer->uTargetGMask & (unsigned __int16)((unsigned __int8)value << (LOBYTE(pRenderer->uTargetGBits)
|
|
773 + LOBYTE(pRenderer->uTargetBBits)
|
|
774 - 8));
|
|
775
|
|
776 temp_dec_position++;
|
|
777 ++row_position;
|
|
778 if (row_position == psx_head2.pitch)
|
|
779 break;
|
|
780
|
|
781 }
|
|
782 while (count-- != 1);
|
|
783 }
|
|
784 }
|
|
785 else
|
|
786 {
|
|
787 //*temp_dec_position |=(unsigned int) test_byte<<8;
|
|
788 //temp_dec_position++;
|
|
789
|
|
790 *temp_dec_position|= pRenderer->uTargetGMask & (unsigned __int16)((unsigned __int8)test_byte << (LOBYTE(pRenderer->uTargetGBits)
|
|
791 + LOBYTE(pRenderer->uTargetBBits)
|
|
792 - 8));
|
|
793 temp_dec_position++;
|
|
794 ++row_position;
|
|
795 }
|
|
796 }
|
|
797
|
|
798 temp_dec_position = dec_position;
|
|
799 row_position=0;
|
|
800 //decode blue line
|
|
801 while (row_position < psx_head2.pitch)
|
|
802 {
|
|
803 test_byte = *(pPcx + read_offset);
|
|
804 read_offset++;
|
|
805 if ((test_byte & 0xC0) == 0xC0)
|
|
806 {
|
|
807 value = *(pPcx + read_offset);
|
|
808 ++read_offset;
|
|
809 if ((test_byte & 0x3F) > 0)
|
|
810 {
|
|
811 count = test_byte & 0x3F;
|
|
812 do
|
|
813 {
|
|
814 //*temp_dec_position|= value;
|
|
815 //temp_dec_position++;
|
|
816
|
|
817 *temp_dec_position |= value >> (8 - LOBYTE(pRenderer->uTargetBBits));
|
|
818 temp_dec_position++;
|
|
819
|
|
820 ++row_position;
|
|
821 if (row_position == psx_head2.pitch)
|
|
822 break;
|
|
823 }
|
|
824 while (count-- != 1);
|
|
825 }
|
|
826 }
|
|
827 else
|
|
828 {
|
|
829 //*temp_dec_position|= test_byte;
|
|
830 //temp_dec_position++;
|
|
831 *temp_dec_position |= test_byte >> (8 - LOBYTE(pRenderer->uTargetBBits));
|
|
832 temp_dec_position++;
|
|
833
|
|
834 ++row_position;
|
|
835 }
|
|
836
|
|
837 }
|
|
838 ++current_line;
|
|
839 dec_position += uWidth;
|
|
840 }
|
|
841 while (current_line < uHeight);
|
|
842 }
|
|
843 return 0;
|
|
844 /*
|
|
845 RGBTexture *v4; // esi@1
|
|
846 signed int result; // eax@2
|
|
847 unsigned __int16 v6; // ax@3
|
|
848 unsigned __int16 *v7; // ecx@3
|
|
849 unsigned int v8; // edx@3
|
|
850 signed int v9; // ecx@3
|
|
851 signed int v10; // ecx@8
|
|
852 signed int v11; // ebx@37
|
|
853 unsigned __int16 *v12; // eax@40
|
|
854 int v13; // edi@40
|
|
855 int v14; // ebx@41
|
|
856 char v15; // bl@42
|
|
857 unsigned __int16 *v16; // eax@50
|
|
858 int v17; // ebx@51
|
|
859 char v18; // bl@52
|
|
860 unsigned __int16 *v19; // eax@61
|
|
861 unsigned __int8 v20; // dl@62
|
|
862 unsigned __int8 v21; // dl@63
|
|
863 unsigned __int8 v22; // cl@63
|
|
864 char color_map[48]; // [sp+8h] [bp-54h]@1
|
|
865 PCXHeader1 header1; // [sp+38h] [bp-24h]@1
|
|
866 PCXHeader2 header2; // [sp+48h] [bp-14h]@1
|
|
867 unsigned int v26; // [sp+50h] [bp-Ch]@43
|
|
868 int v27; // [sp+54h] [bp-8h]@38
|
|
869 unsigned __int16 *v28; // [sp+58h] [bp-4h]@3
|
|
870 int pOutPixelsa; // [sp+68h] [bp+Ch]@41
|
|
871 int pOutPixelsb; // [sp+68h] [bp+Ch]@51
|
|
872
|
|
873 v4 = this;
|
|
874 memcpy(&header1, pPcx, 0x10u);
|
|
875 memcpy(color_map, pPcx + 16, 0x30u);
|
|
876 memcpy(&header2, pPcx + 64, 6u);
|
|
877 if ( header1.bpp == 8 )
|
|
878 {
|
|
879 v6 = header1.right - header1.left + 1;
|
|
880 LOWORD(v7) = header1.bottom - header1.up + 1;
|
|
881 v4->uWidth = v6;
|
|
882 v4->uHeight = (unsigned __int16)v7;
|
|
883 v7 = (unsigned __int16 *)(signed __int16)v7;
|
|
884 v28 = v7;
|
|
885 v4->uNumPixels = (signed __int16)v7 * (signed __int16)v6;
|
|
886 HIWORD(v8) = 0;
|
|
887 v9 = 1;
|
|
888 while ( 1 << v9 != (signed __int16)v6 )
|
|
889 {
|
|
890 ++v9;
|
|
891 if ( v9 >= 15 )
|
|
892 goto LABEL_8;
|
|
893 }
|
|
894 v4->field_18 = v9;
|
|
895 LABEL_8:
|
|
896 v10 = 1;
|
|
897 while ( (unsigned __int16 *)(1 << v10) != v28 )
|
|
898 {
|
|
899 ++v10;
|
|
900 if ( v10 >= 15 )
|
|
901 goto LABEL_13;
|
|
902 }
|
|
903 v4->field_1A = v10;
|
|
904 LABEL_13:
|
|
905 switch ( v4->field_18 )
|
|
906 {
|
|
907 case 2:
|
|
908 v4->field_1C = 3;
|
|
909 break;
|
|
910 case 3:
|
|
911 v4->field_1C = 7;
|
|
912 break;
|
|
913 case 4:
|
|
914 v4->field_1C = 15;
|
|
915 break;
|
|
916 case 5:
|
|
917 v4->field_1C = 31;
|
|
918 break;
|
|
919 case 6:
|
|
920 v4->field_1C = 63;
|
|
921 break;
|
|
922 case 7:
|
|
923 v4->field_1C = 127;
|
|
924 break;
|
|
925 case 8:
|
|
926 v4->field_1C = 255;
|
|
927 break;
|
|
928 case 9:
|
|
929 v4->field_1C = 511;
|
|
930 break;
|
|
931 case 10:
|
|
932 v4->field_1C = 1023;
|
|
933 break;
|
|
934 case 11:
|
|
935 v4->field_1C = 2047;
|
|
936 break;
|
|
937 case 12:
|
|
938 v4->field_1C = 4095;
|
|
939 break;
|
|
940 default:
|
|
941 break;
|
|
942 }
|
|
943 switch ( v4->field_1A )
|
|
944 {
|
|
945 case 2:
|
|
946 v4->field_1E = 3;
|
|
947 break;
|
|
948 case 3:
|
|
949 v4->field_1E = 7;
|
|
950 break;
|
|
951 case 4:
|
|
952 v4->field_1E = 15;
|
|
953 break;
|
|
954 case 5:
|
|
955 v4->field_1E = 31;
|
|
956 break;
|
|
957 case 6:
|
|
958 v4->field_1E = 63;
|
|
959 break;
|
|
960 case 7:
|
|
961 v4->field_1E = 127;
|
|
962 break;
|
|
963 case 8:
|
|
964 v4->field_1E = 255;
|
|
965 break;
|
|
966 case 9:
|
|
967 v4->field_1E = 511;
|
|
968 break;
|
|
969 case 10:
|
|
970 v4->field_1E = 1023;
|
|
971 break;
|
|
972 case 11:
|
|
973 v4->field_1E = 2047;
|
|
974 break;
|
|
975 case 12:
|
|
976 v4->field_1E = 4095;
|
|
977 break;
|
|
978 default:
|
|
979 break;
|
|
980 }
|
|
981 v11 = 128;
|
|
982 if ( header2.planes == 3 )
|
|
983 {
|
|
984 v27 = 0;
|
|
985 if ( (signed int)v28 > 0 )
|
|
986 {
|
|
987 v28 = pOutPixels;
|
|
988 do
|
|
989 {
|
|
990 v12 = v28;
|
|
991 v13 = 0;
|
|
992 if ( header2.pitch )
|
|
993 {
|
|
994 do
|
|
995 {
|
|
996 LOBYTE(v8) = pPcx[v11];
|
|
997 v14 = v11 + 1;
|
|
998 pOutPixelsa = v14;
|
|
999 if ( (v8 & 0xC0) == -64 )
|
|
1000 {
|
|
1001 pOutPixelsa = v14 + 1;
|
|
1002 v15 = pPcx[v14];
|
|
1003 if ( (signed int)(v8 & 0x3F) > 0 )
|
|
1004 {
|
|
1005 v26 = v8 & 0x3F;
|
|
1006 do
|
|
1007 {
|
|
1008 ++v13;
|
|
1009 *v12 = LOWORD(pRenderer->uTargetRMask) & ((unsigned __int8)v15 << (LOBYTE(pRenderer->uTargetGBits)
|
|
1010 + LOBYTE(pRenderer->uTargetRBits)
|
|
1011 + LOBYTE(pRenderer->uTargetBBits)
|
|
1012 - 8));
|
|
1013 ++v12;
|
|
1014 if ( v13 == (unsigned __int16)header2.pitch )
|
|
1015 v12 = &v12[uNumPixels - (unsigned __int16)header2.pitch - 1];
|
|
1016 --v26;
|
|
1017 }
|
|
1018 while ( v26 );
|
|
1019 }
|
|
1020 }
|
|
1021 else
|
|
1022 {
|
|
1023 LOWORD(v8) = (unsigned __int8)v8;
|
|
1024 v8 = pRenderer->uTargetRMask & (v8 << (LOBYTE(pRenderer->uTargetGBits)
|
|
1025 + LOBYTE(pRenderer->uTargetRBits)
|
|
1026 + LOBYTE(pRenderer->uTargetBBits)
|
|
1027 - 8));
|
|
1028 ++v13;
|
|
1029 *v12 = v8;
|
|
1030 ++v12;
|
|
1031 }
|
|
1032 v11 = pOutPixelsa;
|
|
1033 }
|
|
1034 while ( v13 < (unsigned __int16)header2.pitch );
|
|
1035 }
|
|
1036 v16 = v28;
|
|
1037 while ( v13 < 2 * (unsigned __int16)header2.pitch )
|
|
1038 {
|
|
1039 LOBYTE(v8) = pPcx[v11];
|
|
1040 v17 = v11 + 1;
|
|
1041 pOutPixelsb = v17;
|
|
1042 if ( (v8 & 0xC0) == -64 )
|
|
1043 {
|
|
1044 pOutPixelsb = v17 + 1;
|
|
1045 v18 = pPcx[v17];
|
|
1046 if ( (signed int)(v8 & 0x3F) > 0 )
|
|
1047 {
|
|
1048 v26 = v8 & 0x3F;
|
|
1049 do
|
|
1050 {
|
|
1051 *v16 |= pRenderer->uTargetGMask & (unsigned __int16)((unsigned __int8)v18 << (LOBYTE(pRenderer->uTargetGBits)
|
|
1052 + LOBYTE(pRenderer->uTargetBBits)
|
|
1053 - 8));
|
|
1054 ++v13;
|
|
1055 ++v16;
|
|
1056 if ( v13 == (unsigned __int16)header2.pitch )
|
|
1057 v16 = &v16[uNumPixels - (unsigned __int16)header2.pitch - 1];
|
|
1058 --v26;
|
|
1059 }
|
|
1060 while ( v26 );
|
|
1061 }
|
|
1062 }
|
|
1063 else
|
|
1064 {
|
|
1065 LOWORD(v8) = (unsigned __int8)v8;
|
|
1066 v8 = pRenderer->uTargetGMask & (v8 << (LOBYTE(pRenderer->uTargetGBits) + LOBYTE(pRenderer->uTargetBBits) - 8));
|
|
1067 *v16 |= v8;
|
|
1068 ++v13;
|
|
1069 ++v16;
|
|
1070 }
|
|
1071 v11 = pOutPixelsb;
|
|
1072 }
|
|
1073 v19 = v28;
|
|
1074 while ( v13 < 3 * (unsigned __int16)header2.pitch )
|
|
1075 {
|
|
1076 v20 = pPcx[v11++];
|
|
1077 if ( (v20 & 0xC0) == -64 )
|
|
1078 {
|
|
1079 v21 = v20 & 0x3F;
|
|
1080 v22 = pPcx[v11++];
|
|
1081 if ( (signed int)v21 > 0 )
|
|
1082 {
|
|
1083 v26 = v21;
|
|
1084 do
|
|
1085 {
|
|
1086 *v19 |= v22 >> (8 - LOBYTE(pRenderer->uTargetBBits));
|
|
1087 ++v13;
|
|
1088 ++v19;
|
|
1089 if ( v13 == (unsigned __int16)header2.pitch )
|
|
1090 {
|
|
1091 v8 = uNumPixels - (unsigned __int16)header2.pitch;
|
|
1092 v19 = &v19[uNumPixels - (unsigned __int16)header2.pitch - 1];
|
|
1093 }
|
|
1094 --v26;
|
|
1095 }
|
|
1096 while ( v26 );
|
|
1097 }
|
|
1098 }
|
|
1099 else
|
|
1100 {
|
|
1101 *v19 |= v20 >> (8 - LOBYTE(pRenderer->uTargetBBits));
|
|
1102 ++v13;
|
|
1103 ++v19;
|
|
1104 }
|
|
1105 }
|
|
1106 ++v27;
|
|
1107 v28 += uNumPixels;
|
|
1108 }
|
|
1109 while ( v27 < v4->uHeight );
|
|
1110 }
|
|
1111 }
|
|
1112 result = 0;
|
|
1113 }
|
|
1114 else
|
|
1115 {
|
|
1116 result = 3;
|
|
1117 }
|
|
1118 return result;
|
|
1119 */
|
|
1120 }
|
|
1121
|
|
1122 //----- (0040EAD8) --------------------------------------------------------
|
|
1123 unsigned int RGBTexture::LoadFromFILE(FILE *pFile, unsigned int mode, unsigned int bCloseFile)
|
|
1124 {
|
|
1125 RGBTexture *v4; // esi@1
|
|
1126 unsigned int result; // eax@2
|
|
1127 unsigned int v6; // ebx@3
|
|
1128 unsigned __int16 v7; // cx@5
|
|
1129 unsigned __int16 v8; // ax@5
|
|
1130 unsigned int v9; // eax@5
|
|
1131 char v10; // zf@5
|
|
1132 signed int v11; // ecx@14
|
|
1133 int v12; // ebx@19
|
|
1134 signed int v13; // ecx@19
|
|
1135 int v14; // ebx@52
|
|
1136 unsigned __int16 *v15; // edi@52
|
|
1137 __int16 v16; // ax@54
|
|
1138 unsigned __int16 *v17; // edi@59
|
|
1139 __int16 v18; // ax@61
|
|
1140 unsigned __int16 *v19; // edi@66
|
|
1141 unsigned __int16 v20; // ax@68
|
|
1142 int v21; // eax@73
|
|
1143 char DstBuf[60]; // [sp+Ch] [bp-90h]@3
|
|
1144 char pColorMap[48]; // [sp+48h] [bp-54h]@3
|
|
1145 PCXHeader1 pcxh1; // [sp+78h] [bp-24h]@3
|
|
1146 PCXHeader2 pcxh2; // [sp+88h] [bp-14h]@3
|
|
1147 int v26; // [sp+90h] [bp-Ch]@51
|
|
1148 int v27; // [sp+94h] [bp-8h]@54
|
|
1149 unsigned __int8 v28; // [sp+9Bh] [bp-1h]@54
|
|
1150
|
|
1151 v4 = this;
|
|
1152 if ( pFile )
|
|
1153 {
|
|
1154 fread(&pcxh1, 1u, 1u, pFile);
|
|
1155 fread(&pcxh1.version, 1u, 1u, pFile);
|
|
1156 fread(&pcxh1.encoding, 1u, 1u, pFile);
|
|
1157 fread(&pcxh1.bpp, 1u, 1u, pFile);
|
|
1158 v6 = 2;
|
|
1159 fread(&pcxh1.left, 2u, 1u, pFile);
|
|
1160 fread(&pcxh1.up, 2u, 1u, pFile);
|
|
1161 fread(&pcxh1.right, 2u, 1u, pFile);
|
|
1162 fread(&pcxh1.bottom, 2u, 1u, pFile);
|
|
1163 fread(&pcxh1.hres, 2u, 1u, pFile);
|
|
1164 fread(&pcxh1.vres, 2u, 1u, pFile);
|
|
1165 fread(pColorMap, 0x30u, 1u, pFile);
|
|
1166 fread(&pcxh2, 1u, 1u, pFile);
|
|
1167 fread(&pcxh2.planes, 1u, 1u, pFile);
|
|
1168 fread(&pcxh2.pitch, 2u, 1u, pFile);
|
|
1169 fread(&pcxh2.palette_info, 2u, 1u, pFile);
|
|
1170 fread(DstBuf, 58u, 1u, pFile);
|
|
1171 if ( pcxh1.bpp == 8 )
|
|
1172 {
|
|
1173 v7 = pcxh1.right - pcxh1.left + 1;
|
|
1174 v8 = pcxh1.bottom - pcxh1.up;
|
|
1175 v4->uWidth = v7;
|
|
1176 ++v8;
|
|
1177 v4->uHeight = v8;
|
|
1178 v9 = (signed __int16)v7 * (signed __int16)v8;
|
|
1179 v10 = mode == 0;
|
|
1180 v4->uNumPixels = v9;
|
|
1181 if ( v10 )
|
|
1182 {
|
|
1183 if ( v4->pPixels )
|
|
1184 {
|
|
1185 pAllocator->FreeChunk(v4->pPixels);
|
|
1186 v4->pPixels = 0;
|
|
1187 }
|
|
1188 v4->pPixels = (unsigned __int16 *)pAllocator->AllocNamedChunk(
|
|
1189 v4->pPixels,
|
|
1190 2 * v4->uNumPixels + 4,
|
|
1191 v4->pName);
|
|
1192 v6 = 2;
|
|
1193 }
|
|
1194 else
|
|
1195 {
|
|
1196 if ( mode != 1 && mode == 2 )
|
|
1197 {
|
|
1198 operator new(2 * v9 + 4);
|
|
1199 v4->pPixels = 0;
|
|
1200 *(unsigned int *)&v4->field_20 |= 1u;
|
|
1201 }
|
|
1202 }
|
|
1203 if ( v4->pPixels )
|
|
1204 {
|
|
1205 v11 = 1;
|
|
1206 while ( 1 << v11 != v4->uWidth )
|
|
1207 {
|
|
1208 ++v11;
|
|
1209 if ( v11 >= 15 )
|
|
1210 goto LABEL_19;
|
|
1211 }
|
|
1212 v4->field_18 = v11;
|
|
1213 LABEL_19:
|
|
1214 v12 = v4->uHeight;
|
|
1215 v13 = 1;
|
|
1216 while ( 1 << v13 != v12 )
|
|
1217 {
|
|
1218 ++v13;
|
|
1219 if ( v13 >= 15 )
|
|
1220 goto LABEL_24;
|
|
1221 }
|
|
1222 v4->field_1A = v13;
|
|
1223 LABEL_24:
|
|
1224 switch ( v4->field_18 )
|
|
1225 {
|
|
1226 case 2:
|
|
1227 v4->field_1C = 3;
|
|
1228 break;
|
|
1229 case 3:
|
|
1230 v4->field_1C = 7;
|
|
1231 break;
|
|
1232 case 4:
|
|
1233 v4->field_1C = 15;
|
|
1234 break;
|
|
1235 case 5:
|
|
1236 v4->field_1C = 31;
|
|
1237 break;
|
|
1238 case 6:
|
|
1239 v4->field_1C = 63;
|
|
1240 break;
|
|
1241 case 7:
|
|
1242 v4->field_1C = 127;
|
|
1243 break;
|
|
1244 case 8:
|
|
1245 v4->field_1C = 255;
|
|
1246 break;
|
|
1247 case 9:
|
|
1248 v4->field_1C = 511;
|
|
1249 break;
|
|
1250 case 10:
|
|
1251 v4->field_1C = 1023;
|
|
1252 break;
|
|
1253 case 11:
|
|
1254 v4->field_1C = 2047;
|
|
1255 break;
|
|
1256 case 12:
|
|
1257 v4->field_1C = 4095;
|
|
1258 break;
|
|
1259 default:
|
|
1260 break;
|
|
1261 }
|
|
1262 switch ( v4->field_1A )
|
|
1263 {
|
|
1264 case 2:
|
|
1265 v4->field_1E = 3;
|
|
1266 break;
|
|
1267 case 3:
|
|
1268 v4->field_1E = 7;
|
|
1269 break;
|
|
1270 case 4:
|
|
1271 v4->field_1E = 15;
|
|
1272 break;
|
|
1273 case 5:
|
|
1274 v4->field_1E = 31;
|
|
1275 break;
|
|
1276 case 6:
|
|
1277 v4->field_1E = 63;
|
|
1278 break;
|
|
1279 case 7:
|
|
1280 v4->field_1E = 127;
|
|
1281 break;
|
|
1282 case 8:
|
|
1283 v4->field_1E = 255;
|
|
1284 break;
|
|
1285 case 9:
|
|
1286 v4->field_1E = 511;
|
|
1287 break;
|
|
1288 case 10:
|
|
1289 v4->field_1E = 1023;
|
|
1290 break;
|
|
1291 case 11:
|
|
1292 v4->field_1E = 2047;
|
|
1293 break;
|
|
1294 case 12:
|
|
1295 v4->field_1E = 4095;
|
|
1296 break;
|
|
1297 default:
|
|
1298 break;
|
|
1299 }
|
|
1300 if ( pcxh2.planes == 1 )
|
|
1301 Abortf("24bit PCX Only!");
|
|
1302 if ( pcxh2.planes == 3 )
|
|
1303 {
|
|
1304 v26 = 0;
|
|
1305 if ( v12 > 0 )
|
|
1306 {
|
|
1307 do
|
|
1308 {
|
|
1309 v14 = 0;
|
|
1310 v15 = &v4->pPixels[v26 * v4->uWidth];
|
|
1311 if ( pcxh2.pitch )
|
|
1312 {
|
|
1313 do
|
|
1314 {
|
|
1315 fread((char *)&mode + 3, 1u, 1u, pFile);
|
|
1316 if ( (BYTE3(mode) & 0xC0) == -64 )
|
|
1317 {
|
|
1318 BYTE3(mode) &= 0x3Fu;
|
|
1319 fread(&v28, 1u, 1u, pFile);
|
|
1320 v27 = 0;
|
|
1321 v16 = v28;
|
|
1322 if ( BYTE3(mode) )
|
|
1323 {
|
|
1324 do
|
|
1325 {
|
|
1326 ++v14;
|
26
|
1327 *v15 = LOWORD(pRenderer->uTargetRMask) & (v16 << (pRenderer->uTargetGBits
|
|
1328 + pRenderer->uTargetRBits
|
|
1329 + pRenderer->uTargetBBits
|
0
|
1330 - 8));
|
|
1331 ++v15;
|
|
1332 ++v27;
|
|
1333 }
|
|
1334 while ( v27 < BYTE3(mode) );
|
|
1335 }
|
|
1336 }
|
|
1337 else
|
|
1338 {
|
|
1339 ++v14;
|
26
|
1340 *v15 = LOWORD(pRenderer->uTargetRMask) & (BYTE3(mode) << (pRenderer->uTargetGBits
|
|
1341 + pRenderer->uTargetRBits
|
|
1342 + pRenderer->uTargetBBits
|
0
|
1343 - 8));
|
|
1344 ++v15;
|
|
1345 }
|
|
1346 }
|
|
1347 while ( v14 < (unsigned __int16)pcxh2.pitch );
|
|
1348 }
|
|
1349 v17 = &v4->pPixels[v26 * v4->uWidth];
|
|
1350 while ( v14 < 2 * (unsigned __int16)pcxh2.pitch )
|
|
1351 {
|
|
1352 fread((char *)&mode + 3, 1u, 1u, pFile);
|
|
1353 if ( (BYTE3(mode) & 0xC0) == -64 )
|
|
1354 {
|
|
1355 BYTE3(mode) &= 0x3Fu;
|
|
1356 fread(&v28, 1u, 1u, pFile);
|
|
1357 v27 = 0;
|
|
1358 v18 = v28;
|
|
1359 if ( BYTE3(mode) )
|
|
1360 {
|
|
1361 do
|
|
1362 {
|
26
|
1363 *v17 |= pRenderer->uTargetGMask & (unsigned __int16)(v18 << (pRenderer->uTargetGBits
|
|
1364 + pRenderer->uTargetBBits
|
0
|
1365 - 8));
|
|
1366 ++v14;
|
|
1367 ++v17;
|
|
1368 ++v27;
|
|
1369 }
|
|
1370 while ( v27 < BYTE3(mode) );
|
|
1371 }
|
|
1372 }
|
|
1373 else
|
|
1374 {
|
26
|
1375 *v17 |= pRenderer->uTargetGMask & (unsigned __int16)(BYTE3(mode) << (pRenderer->uTargetGBits
|
|
1376 + pRenderer->uTargetBBits
|
0
|
1377 - 8));
|
|
1378 ++v14;
|
|
1379 ++v17;
|
|
1380 }
|
|
1381 }
|
|
1382 v19 = &v4->pPixels[v26 * v4->uWidth];
|
|
1383 while ( v14 < 3 * (unsigned __int16)pcxh2.pitch )
|
|
1384 {
|
|
1385 fread((char *)&mode + 3, 1u, 1u, pFile);
|
|
1386 if ( (BYTE3(mode) & 0xC0) == -64 )
|
|
1387 {
|
|
1388 BYTE3(mode) &= 0x3Fu;
|
|
1389 fread(&v28, 1u, 1u, pFile);
|
|
1390 v27 = 0;
|
|
1391 v20 = v28;
|
|
1392 if ( BYTE3(mode) )
|
|
1393 {
|
|
1394 do
|
|
1395 {
|
26
|
1396 *v19 |= v20 >> (8 - pRenderer->uTargetBBits);
|
0
|
1397 ++v14;
|
|
1398 ++v19;
|
|
1399 ++v27;
|
|
1400 }
|
|
1401 while ( v27 < BYTE3(mode) );
|
|
1402 }
|
|
1403 }
|
|
1404 else
|
|
1405 {
|
26
|
1406 *v19 |= BYTE3(mode) >> (8 - pRenderer->uTargetBBits);
|
0
|
1407 ++v14;
|
|
1408 ++v19;
|
|
1409 }
|
|
1410 }
|
|
1411 v21 = v4->uHeight;
|
|
1412 ++v26;
|
|
1413 }
|
|
1414 while ( v26 < v21 );
|
|
1415 }
|
|
1416 }
|
|
1417 if ( bCloseFile )
|
|
1418 fclose(pFile);
|
|
1419 result = 0;
|
|
1420 }
|
|
1421 else
|
|
1422 {
|
|
1423 result = v6;
|
|
1424 }
|
|
1425 }
|
|
1426 else
|
|
1427 {
|
|
1428 result = 3;
|
|
1429 }
|
|
1430 }
|
|
1431 else
|
|
1432 {
|
|
1433 result = 1;
|
|
1434 }
|
|
1435 return result;
|
|
1436 }
|
|
1437
|
|
1438 //----- (0040E51F) --------------------------------------------------------
|
|
1439 void RGBTexture::Release()
|
|
1440 {
|
|
1441 RGBTexture *v1; // esi@1
|
|
1442 char v2; // zf@1
|
|
1443 void *v3; // [sp-4h] [bp-Ch]@1
|
|
1444
|
|
1445 v1 = this;
|
|
1446 v2 = (this->field_20 & 1) == 0;
|
|
1447 v3 = this->pPixels;
|
|
1448 this->pName[0] = 0;
|
|
1449 if ( v2 )
|
|
1450 pAllocator->FreeChunk(v3);
|
|
1451 else
|
|
1452 free(v3);
|
|
1453 *(unsigned int *)&v1->field_20 = 0;
|
|
1454 v1->pPixels = 0;
|
|
1455 v1->uNumPixels = 0;
|
|
1456 v1->uHeight = 0;
|
|
1457 v1->uWidth = 0;
|
|
1458 v1->field_1A = 0;
|
|
1459 v1->field_18 = 0;
|
|
1460 }
|
|
1461
|
|
1462 //----- (0040E55E) --------------------------------------------------------
|
|
1463 int RGBTexture::_40E55E(const char *Filename, unsigned int a3)
|
|
1464 {
|
|
1465 RGBTexture *v3; // esi@1
|
|
1466 signed int result; // eax@2
|
|
1467 FILE *v5; // edi@3
|
|
1468 char *v6; // eax@3
|
|
1469 int v7; // edx@3
|
|
1470 char v8; // cl@4
|
|
1471 unsigned __int16 v9; // cx@9
|
|
1472 unsigned __int16 v10; // ax@9
|
|
1473 int v11; // eax@9
|
|
1474 char v12; // zf@9
|
|
1475 void *v13; // eax@12
|
|
1476 signed int v14; // ecx@19
|
|
1477 signed int v15; // ecx@24
|
|
1478 int v16; // eax@57
|
|
1479 unsigned __int16 *v17; // ecx@57
|
|
1480 unsigned __int16 *v18; // edi@57
|
|
1481 signed int v19; // eax@59
|
|
1482 unsigned __int16 *v20; // edi@64
|
|
1483 signed int v21; // eax@66
|
|
1484 unsigned __int16 *v22; // edi@71
|
|
1485 signed int v23; // eax@73
|
|
1486 int v24; // eax@78
|
|
1487 char v25; // [sp+Ch] [bp-54h]@3
|
|
1488 char DstBuf; // [sp+3Ch] [bp-24h]@3
|
|
1489 char v27; // [sp+3Dh] [bp-23h]@3
|
|
1490 char v28; // [sp+3Eh] [bp-22h]@3
|
|
1491 char v29; // [sp+3Fh] [bp-21h]@3
|
|
1492 int v30; // [sp+40h] [bp-20h]@3
|
|
1493 int v31; // [sp+44h] [bp-1Ch]@3
|
|
1494 char v32; // [sp+48h] [bp-18h]@3
|
|
1495 char v33; // [sp+4Ah] [bp-16h]@3
|
|
1496 char v34; // [sp+4Ch] [bp-14h]@3
|
|
1497 char v35; // [sp+4Dh] [bp-13h]@3
|
|
1498 unsigned __int16 v36; // [sp+4Eh] [bp-12h]@3
|
|
1499 int v37; // [sp+54h] [bp-Ch]@3
|
|
1500 int v38; // [sp+58h] [bp-8h]@57
|
|
1501 FILE *File; // [sp+5Ch] [bp-4h]@1
|
|
1502
|
|
1503 v3 = this;
|
|
1504 File = fopen(Filename, "rb");
|
|
1505 if ( !File )
|
|
1506 return 1;
|
|
1507 v5 = File;
|
|
1508 fread(&DstBuf, 1u, 1u, File);
|
|
1509 fread(&v27, 1u, 1u, v5);
|
|
1510 fread(&v28, 1u, 1u, v5);
|
|
1511 fread(&v29, 1u, 1u, v5);
|
|
1512 fread(&v30, 2u, 1u, v5);
|
|
1513 fread((char *)&v30 + 2, 2u, 1u, File);
|
|
1514 fread(&v31, 2u, 1u, File);
|
|
1515 fread((char *)&v31 + 2, 2u, 1u, File);
|
|
1516 fread(&v32, 2u, 1u, File);
|
|
1517 fread(&v33, 2u, 1u, File);
|
|
1518 fread(&v25, 0x30u, 1u, File);
|
|
1519 fread(&v34, 1u, 1u, File);
|
|
1520 fread(&v35, 1u, 1u, File);
|
|
1521 fread(&v36, 2u, 1u, File);
|
|
1522 v6 = (char *)Filename;
|
|
1523 v37 = 0;
|
|
1524 v7 = (char *)v3 - Filename;
|
|
1525 do
|
|
1526 {
|
|
1527 v8 = *v6;
|
|
1528 if ( !*v6 )
|
|
1529 break;
|
|
1530 if ( v8 == 46 )
|
|
1531 break;
|
|
1532 ++v37;
|
|
1533 (v6++)[v7] = v8;
|
|
1534 }
|
|
1535 while ( v37 < 15 );
|
|
1536 v3->pName[v37] = 0;
|
|
1537 if ( v29 != 8 )
|
|
1538 return 3;
|
|
1539 v9 = v31 - (short)v30 + 1;
|
|
1540 v10 = HIWORD(v31) - HIWORD(v30);
|
|
1541 v3->uWidth = v9;
|
|
1542 ++v10;
|
|
1543 v3->uHeight = v10;
|
|
1544 v11 = (signed __int16)v9 * (signed __int16)v10;
|
|
1545 v12 = a3 == 0;
|
|
1546 v3->uNumPixels = v11;
|
|
1547 if ( v12 )
|
|
1548 {
|
|
1549 if ( v3->pPixels )
|
|
1550 pAllocator->FreeChunk(v3->pPixels);
|
|
1551 v13 = pAllocator->AllocNamedChunk(v3->pPixels, 2 * v3->uNumPixels + 4, v3->pName);
|
|
1552 goto LABEL_16;
|
|
1553 }
|
|
1554 if ( a3 != 1 && a3 == 2 )
|
|
1555 {
|
|
1556 v13 = operator new(4 * v11 + 8);
|
|
1557 *(unsigned int *)&v3->field_20 |= 1u;
|
|
1558 LABEL_16:
|
|
1559 v3->pPixels = (unsigned __int16 *)v13;
|
|
1560 }
|
|
1561 if ( v3->pPixels )
|
|
1562 {
|
|
1563 v14 = 1;
|
|
1564 while ( 1 << v14 != v3->uWidth )
|
|
1565 {
|
|
1566 ++v14;
|
|
1567 if ( v14 >= 15 )
|
|
1568 goto LABEL_24;
|
|
1569 }
|
|
1570 v3->field_18 = v14;
|
|
1571 LABEL_24:
|
|
1572 v15 = 1;
|
|
1573 while ( 1 << v15 != v3->uHeight )
|
|
1574 {
|
|
1575 ++v15;
|
|
1576 if ( v15 >= 15 )
|
|
1577 goto LABEL_29;
|
|
1578 }
|
|
1579 v3->field_1A = v15;
|
|
1580 LABEL_29:
|
|
1581 switch ( v3->field_18 )
|
|
1582 {
|
|
1583 case 2:
|
|
1584 v3->field_1C = 3;
|
|
1585 break;
|
|
1586 case 3:
|
|
1587 v3->field_1C = 7;
|
|
1588 break;
|
|
1589 case 4:
|
|
1590 v3->field_1C = 15;
|
|
1591 break;
|
|
1592 case 5:
|
|
1593 v3->field_1C = 31;
|
|
1594 break;
|
|
1595 case 6:
|
|
1596 v3->field_1C = 63;
|
|
1597 break;
|
|
1598 case 7:
|
|
1599 v3->field_1C = 127;
|
|
1600 break;
|
|
1601 case 8:
|
|
1602 v3->field_1C = 255;
|
|
1603 break;
|
|
1604 case 9:
|
|
1605 v3->field_1C = 511;
|
|
1606 break;
|
|
1607 case 10:
|
|
1608 v3->field_1C = 1023;
|
|
1609 break;
|
|
1610 case 11:
|
|
1611 v3->field_1C = 2047;
|
|
1612 break;
|
|
1613 case 12:
|
|
1614 v3->field_1C = 4095;
|
|
1615 break;
|
|
1616 default:
|
|
1617 break;
|
|
1618 }
|
|
1619 switch ( v3->field_1A )
|
|
1620 {
|
|
1621 case 2:
|
|
1622 v3->field_1E = 3;
|
|
1623 break;
|
|
1624 case 3:
|
|
1625 v3->field_1E = 7;
|
|
1626 break;
|
|
1627 case 4:
|
|
1628 v3->field_1E = 15;
|
|
1629 break;
|
|
1630 case 5:
|
|
1631 v3->field_1E = 31;
|
|
1632 break;
|
|
1633 case 6:
|
|
1634 v3->field_1E = 63;
|
|
1635 break;
|
|
1636 case 7:
|
|
1637 v3->field_1E = 127;
|
|
1638 break;
|
|
1639 case 8:
|
|
1640 v3->field_1E = 255;
|
|
1641 break;
|
|
1642 case 9:
|
|
1643 v3->field_1E = 511;
|
|
1644 break;
|
|
1645 case 10:
|
|
1646 v3->field_1E = 1023;
|
|
1647 break;
|
|
1648 case 11:
|
|
1649 v3->field_1E = 2047;
|
|
1650 break;
|
|
1651 case 12:
|
|
1652 v3->field_1E = 4095;
|
|
1653 break;
|
|
1654 default:
|
|
1655 break;
|
|
1656 }
|
|
1657 fseek(File, 128, 0);
|
|
1658 ftell(File);
|
|
1659 if ( v35 == 1 )
|
|
1660 Abortf("24bit PCX Only!");
|
|
1661 if ( v35 == 3 )
|
|
1662 {
|
|
1663 v37 = 0;
|
|
1664 if ( v3->uHeight > 0 )
|
|
1665 {
|
|
1666 do
|
|
1667 {
|
|
1668 v16 = v37 * v3->uWidth;
|
|
1669 v17 = v3->pPixels;
|
|
1670 v38 = 0;
|
|
1671 v18 = &v17[v16];
|
|
1672 if ( v36 )
|
|
1673 {
|
|
1674 do
|
|
1675 {
|
|
1676 fread((char *)&Filename + 3, 1u, 1u, File);
|
|
1677 if ( (BYTE3(Filename) & 0xC0) == -64 )
|
|
1678 {
|
|
1679 BYTE3(Filename) &= 0x3Fu;
|
|
1680 fread((char *)&a3 + 3, 1u, 1u, File);
|
|
1681 v19 = 0;
|
|
1682 if ( BYTE3(Filename) )
|
|
1683 {
|
|
1684 do
|
|
1685 {
|
|
1686 ++v38;
|
|
1687 *v18 = LOWORD(pRenderer->uTargetRMask) & (BYTE3(a3) << (LOBYTE(pRenderer->uTargetGBits)
|
|
1688 + LOBYTE(pRenderer->uTargetRBits)
|
|
1689 + LOBYTE(pRenderer->uTargetBBits)
|
|
1690 - 8));
|
|
1691 ++v18;
|
|
1692 ++v19;
|
|
1693 }
|
|
1694 while ( v19 < BYTE3(Filename) );
|
|
1695 }
|
|
1696 }
|
|
1697 else
|
|
1698 {
|
|
1699 ++v38;
|
|
1700 *v18 = LOWORD(pRenderer->uTargetRMask) & (BYTE3(Filename) << (LOBYTE(pRenderer->uTargetGBits)
|
|
1701 + LOBYTE(pRenderer->uTargetRBits)
|
|
1702 + LOBYTE(pRenderer->uTargetBBits)
|
|
1703 - 8));
|
|
1704 ++v18;
|
|
1705 }
|
|
1706 }
|
|
1707 while ( v38 < v36 );
|
|
1708 }
|
|
1709 v20 = &v3->pPixels[v37 * v3->uWidth];
|
|
1710 while ( v38 < 2 * v36 )
|
|
1711 {
|
|
1712 fread((char *)&Filename + 3, 1u, 1u, File);
|
|
1713 if ( (BYTE3(Filename) & 0xC0) == -64 )
|
|
1714 {
|
|
1715 BYTE3(Filename) &= 0x3Fu;
|
|
1716 fread((char *)&a3 + 3, 1u, 1u, File);
|
|
1717 v21 = 0;
|
|
1718 if ( BYTE3(Filename) )
|
|
1719 {
|
|
1720 do
|
|
1721 {
|
|
1722 *v20 |= pRenderer->uTargetGMask & (unsigned __int16)(BYTE3(a3) << (LOBYTE(pRenderer->uTargetGBits)
|
|
1723 + LOBYTE(pRenderer->uTargetBBits)
|
|
1724 - 8));
|
|
1725 ++v38;
|
|
1726 ++v20;
|
|
1727 ++v21;
|
|
1728 }
|
|
1729 while ( v21 < BYTE3(Filename) );
|
|
1730 }
|
|
1731 }
|
|
1732 else
|
|
1733 {
|
|
1734 *v20 |= pRenderer->uTargetGMask & (unsigned __int16)(BYTE3(Filename) << (LOBYTE(pRenderer->uTargetGBits)
|
|
1735 + LOBYTE(pRenderer->uTargetBBits)
|
|
1736 - 8));
|
|
1737 ++v38;
|
|
1738 ++v20;
|
|
1739 }
|
|
1740 }
|
|
1741 v22 = &v3->pPixels[v37 * v3->uWidth];
|
|
1742 while ( v38 < 3 * v36 )
|
|
1743 {
|
|
1744 fread((char *)&Filename + 3, 1u, 1u, File);
|
|
1745 if ( (BYTE3(Filename) & 0xC0) == -64 )
|
|
1746 {
|
|
1747 BYTE3(Filename) &= 0x3Fu;
|
|
1748 fread((char *)&a3 + 3, 1u, 1u, File);
|
|
1749 v23 = 0;
|
|
1750 if ( BYTE3(Filename) )
|
|
1751 {
|
|
1752 do
|
|
1753 {
|
|
1754 *v22 |= BYTE3(a3) >> (8 - LOBYTE(pRenderer->uTargetBBits));
|
|
1755 ++v38;
|
|
1756 ++v22;
|
|
1757 ++v23;
|
|
1758 }
|
|
1759 while ( v23 < BYTE3(Filename) );
|
|
1760 }
|
|
1761 }
|
|
1762 else
|
|
1763 {
|
|
1764 *v22 |= BYTE3(Filename) >> (8 - LOBYTE(pRenderer->uTargetBBits));
|
|
1765 ++v38;
|
|
1766 ++v22;
|
|
1767 }
|
|
1768 }
|
|
1769 v24 = v3->uHeight;
|
|
1770 ++v37;
|
|
1771 }
|
|
1772 while ( v37 < v24 );
|
|
1773 }
|
|
1774 }
|
|
1775 fclose(File);
|
|
1776 result = 0;
|
|
1777 }
|
|
1778 else
|
|
1779 {
|
|
1780 result = 2;
|
|
1781 }
|
|
1782 return result;
|
|
1783 }
|
|
1784
|
|
1785
|
|
1786 //----- (0040D73D) --------------------------------------------------------
|
|
1787 RGBTexture::RGBTexture()
|
|
1788 {
|
26
|
1789 pName[0] = 0;
|
|
1790 pPixels = 0;
|
|
1791 uNumPixels = 0;
|
|
1792 uHeight = 0;
|
|
1793 uWidth = 0;
|
|
1794 field_1A = 0;
|
|
1795 field_18 = 0;
|
|
1796 field_20 = 0;
|
|
1797 field_22 = 0;
|
0
|
1798 } |