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