Mercurial > mm7
annotate Engine/Graphics/Texture.cpp @ 2573:0c67be4ec900
DrawTextureIndexed renamed to DrawTextureTransparentColorKey
Changing more class Texture to class Image.
author | a.parshin |
---|---|
date | Sat, 05 Mar 2016 16:25:53 +0200 |
parents | d87bfbd3bb3b |
children | dd36326a9994 |
rev | line source |
---|---|
2496 | 1 #define _CRTDBG_MAP_ALLOC |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
5 #define _CRT_SECURE_NO_WARNINGS | |
6 #include <stdlib.h> | |
7 | |
2541 | 8 #include "Engine/Engine.h" |
9 | |
2496 | 10 #include "Texture.h" |
2499 | 11 #include "../Tables/FrameTableInc.h" |
12 #include "../LOD.h" | |
2496 | 13 #include "PaletteManager.h" |
2499 | 14 #include "../ZlibWrapper.h" |
2496 | 15 |
16 | |
2499 | 17 #include "../OurMath.h" |
2496 | 18 |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 struct TextureFrameTable *pTextureFrameTable; | |
27 | |
28 | |
29 | |
30 | |
31 | |
32 std::array<Texture *, 2> pTexture_LloydBeacons; | |
33 Texture *pTexture_50635C; | |
34 Texture *pTex_book_button8_off; | |
35 Texture *pTex_book_button8_on; | |
36 Texture *pTex_book_button7_off; | |
37 Texture *pTex_book_button7_on; | |
38 Texture *pTex_book_button6_off; | |
39 Texture *pTex_book_button6_on; | |
40 Texture *pTex_book_button5_off; | |
41 Texture *pTex_book_button5_on; | |
42 Texture *pTex_book_button4_off; | |
43 Texture *pTex_book_button4_on; | |
44 Texture *pTex_book_button3_off; | |
45 Texture *pTex_book_button3_on; | |
46 Texture *pTex_book_button2_off; | |
47 Texture *pTex_book_button1_off; | |
48 Texture *pTex_book_button2_on; | |
49 Texture *pTex_book_button1_on; | |
50 std::array<Texture *, 6> pTexture_TownPortalIcons; // [0]Harmonale, [1]Pierpont, [2]Nighon, [3]Evenmorn Island, [4]Celestia, [5]The Pit | |
51 std::array<Texture *, 12> SBPageCSpellsTextureList; | |
52 std::array<Texture *, 12> SBPageSSpellsTextureList; | |
53 Texture *pSBQuickSpellBtnTextr; | |
54 Texture *pSpellBookClickCloseBtnTextr; | |
55 Texture *pSBClickQuickSpellBtnTextr; | |
56 Texture *pSpellBookCloseBtnTextr; | |
57 std::array<std::array<Texture *, 2>, 9> pTextures_tabs; | |
58 Texture *pTexture_mapbordr; // idb | |
59 Texture *pTexture_pagemask; // idb | |
60 std::array<Texture *, 9> pSpellBookPagesTextr; | |
61 Texture *pSpellBookPagesTextr_9; | |
62 Texture *pSpellBookPagesTextr_10; | |
63 Texture *pSpellBookPagesTextr_11; | |
64 Texture *pSpellBookPagesTextr_12; | |
65 Texture *pSpellBookPagesTextr_13; | |
66 Texture *pTexture_AutonotesBook; | |
67 Texture *pTexture_CurrentBook; | |
68 Texture *pTex_moon_new; | |
69 Texture *pTex_moon_4; | |
70 Texture *pTex_moon_2; | |
71 Texture *pTex_moon_2_2; | |
72 Texture *pTex_moon_ful; | |
73 | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
74 struct Texture *minimap_loop; // 5079D8 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
75 struct Texture *_5079B4_compass; // 5079B4 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
76 struct Texture *_5079C8_init_y; // 5079C8 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
77 struct Texture *_5079CC_init_r; // 5079CC |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
78 struct Texture *_5079D0_init_g; // 5079D0 |
2496 | 79 |
80 | |
81 int uTextureID_RestUI_restb4; // weak | |
82 int uTextureID_RestUI_restexit; // weak | |
83 int uTextureID_RestUI_restb3; // weak | |
84 int uTextureID_RestUI_restb1; // weak | |
85 int uTextureID_RestUI_restb2; // weak | |
86 int uTextureID_RestUI_restmain; // weak | |
87 unsigned int uTextureID_Leather; | |
88 int uTextureID_ar_dn_dn; // weak | |
89 int uTextureID_ar_dn_up; // weak | |
90 int uTextureID_ar_up_dn; // weak | |
91 int uTextureID_ar_up_up; // weak | |
92 | |
93 | |
94 unsigned int uTextureID_mhp_yel; | |
95 unsigned int uTextureID_mhp_red; | |
96 unsigned int uTextureID_mhp_grn; | |
97 unsigned int uTextureID_mhp_capr; | |
98 unsigned int uTextureID_mhp_capl; | |
99 unsigned int uTextureID_mhp_bd; | |
100 unsigned int uTextureID_BUTTDESC2; | |
101 unsigned int uTextureID_x_x_u; | |
102 unsigned int uTextureID_BUTTMAKE2; | |
103 unsigned int uTextureID_BUTTMAKE; | |
104 unsigned int uTextureID_BUTTYES2; | |
105 unsigned int uTextureID_x_ok_u; | |
106 std::array<Texture *, 22> pPlayerPortraits; | |
107 std::array<Texture *, 9> pTexture_IC_KNIGHT; | |
108 Texture *pTexture_MAKESKY; | |
109 Texture *pTexture_MAKETOP; | |
110 std::array<Texture *, 20> pTextures_arrowr; | |
111 std::array<Texture *, 20> pTextures_arrowl; | |
112 Texture *pTexture_presleft; | |
113 Texture *pTexture_pressrigh; | |
114 Texture *pTexture_buttminu; | |
115 Texture *pTexture_buttplus; | |
116 unsigned int uTextureID_Quit1; // weak | |
117 unsigned int uTextureID_Resume1; // weak | |
118 unsigned int uTextureID_Controls1; // weak | |
119 unsigned int uTextureID_Save1; // weak | |
120 unsigned int uTextureID_Load1; // weak | |
121 unsigned int uTextureID_New1; // weak | |
122 unsigned int uTextureID_Options; // weak | |
123 | |
124 | |
125 unsigned int uTextureID_ib_td5_A; | |
126 unsigned int uTextureID_ib_td4_A; | |
127 unsigned int uTextureID_ib_td3_A; | |
128 unsigned int uTextureID_ib_td2_A; | |
129 unsigned int uTextureID_ib_td1_A; | |
130 int uTextureID_50795C; // weak | |
131 | |
132 | |
133 unsigned int uTextureID_Btn_GameSettings; | |
134 | |
135 | |
136 unsigned int uTextureID_Btn_Rest; | |
137 unsigned int uTextureID_Btn_CastSpell; | |
138 unsigned int uTextureID_Btn_ZoomIn; | |
139 unsigned int uTextureID_Btn_ZoomOut; | |
140 unsigned int uTextureID_FONTPAL; | |
141 unsigned int uTextureID_Btn_NPCRight; | |
142 unsigned int uTextureID_Btn_NPCLeft; | |
143 std::array<unsigned int, 8> pTextureIDs_pMapDirs; | |
144 | |
145 | |
146 unsigned int uTextureID_BarRed; | |
147 unsigned int uTextureID_BarYellow; | |
148 unsigned int uTextureID_BarGreen; | |
149 unsigned int uTextureID_BarBlue; | |
150 | |
151 | |
152 | |
153 | |
154 Texture *pTexture_Leather; | |
155 Texture *pTexture_RestUI_CurrentSkyFrame; // idb | |
156 Texture *pTexture_RestUI_CurrentHourglassFrame; // idb | |
157 | |
158 | |
159 std::array<unsigned int, 5> uTextureID_Optkb; | |
160 | |
161 unsigned int optvid_base_texture_id; | |
162 unsigned int bloodsplats_texture_id; | |
163 unsigned int us_colored_lights_texture_id; | |
164 unsigned int tinting_texture_id; | |
165 unsigned int uTextureID_507C20; // weak | |
166 unsigned int uTextureID_507C24; // weak | |
167 std::array<unsigned int, 10> pTextureIDs_GammaPositions; | |
168 unsigned int not_available_bloodsplats_texture_id; | |
169 unsigned int not_available_us_colored_lights_texture_id; | |
170 unsigned int not_available_tinting_texture_id; | |
171 | |
172 | |
173 stru355 stru_4E82A4 = {0x20, 0x41, 0, 0x20, 0xFF0000, 0xFF00, 0xFF, 0xFF000000}; | |
174 stru355 stru_4EFCBC = {0x20, 0x41, 0, 0x10, 0x7C00, 0x3E0, 0x1F, 0x8000}; | |
175 | |
176 Texture pTex_F7CE30; | |
177 | |
178 | |
179 | |
180 | |
181 | |
182 | |
183 | |
184 | |
185 | |
186 | |
187 | |
188 /* 245 */ | |
189 #pragma pack(push, 1) | |
190 struct PCXHeader1 | |
191 { | |
192 char magic; | |
193 char version; | |
194 char encoding; | |
195 char bpp; | |
196 __int16 left; | |
197 __int16 up; | |
198 __int16 right; | |
199 __int16 bottom; | |
200 __int16 hres; | |
201 __int16 vres; | |
202 }; | |
203 #pragma pack(pop) | |
204 | |
205 /* 246 */ | |
206 #pragma pack(push, 1) | |
207 struct PCXHeader2 | |
208 { | |
209 char reserved; | |
210 char planes; | |
211 __int16 pitch; | |
212 __int16 palette_info; | |
213 }; | |
214 #pragma pack(pop) | |
215 | |
216 | |
217 | |
218 | |
219 | |
220 | |
221 | |
222 | |
223 | |
224 //----- (0044E054) -------------------------------------------------------- | |
225 void TextureFrameTable::ToFile() | |
226 { | |
227 TextureFrameTable *v1; // esi@1 | |
228 FILE *v2; // eax@1 | |
229 FILE *v3; // edi@1 | |
230 | |
231 v1 = this; | |
232 v2 = fopen("data\\dtft.bin", "wb"); | |
233 v3 = v2; | |
234 if ( !v2 ) | |
235 Error("Unable to save dtft.bin!"); | |
236 fwrite(v1, 4u, 1u, v2); | |
237 fwrite(v1->pTextures, 0x14u, v1->sNumTextures, v3); | |
238 fclose(v3); | |
239 } | |
240 | |
241 //----- (0044E0A0) -------------------------------------------------------- | |
242 void TextureFrameTable::FromFile(void *data_mm6, void *data_mm7, void *data_mm8) | |
243 { | |
244 uint num_mm6_frames = data_mm6 ? *(int *)data_mm6 : 0, | |
245 num_mm7_frames = data_mm7 ? *(int *)data_mm7 : 0, | |
246 num_mm8_frames = data_mm8 ? *(int *)data_mm8 : 0; | |
247 | |
248 sNumTextures = num_mm6_frames + num_mm7_frames + num_mm8_frames; | |
249 Assert(sNumTextures); | |
250 Assert(!num_mm8_frames); | |
251 | |
252 pTextures = (TextureFrame *)malloc(sNumTextures * sizeof(TextureFrame)); | |
253 | |
254 memcpy(pTextures, (char *)data_mm7 + 4, num_mm7_frames * sizeof(TextureFrame)); | |
255 memcpy(pTextures + num_mm7_frames, (char *)data_mm6 + 4, num_mm6_frames * sizeof(TextureFrame)); | |
256 memcpy(pTextures + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 4, num_mm8_frames * sizeof(TextureFrame)); | |
257 } | |
258 | |
259 //----- (0044E0ED) -------------------------------------------------------- | |
260 void TextureFrameTable::LoadAnimationSequenceAndPalettes( signed int uIconID ) | |
261 { | |
262 //TextureFrameTable *v3; // ebx@1 | |
263 unsigned int i; // edi@3 | |
264 | |
265 //v3 = this; | |
266 if ( (uIconID <= this->sNumTextures) && uIconID >= 0 ) | |
267 { | |
268 for ( i = uIconID; ; ++i ) | |
269 { | |
270 this->pTextures[i].uTextureID = pBitmaps_LOD->LoadTexture(this->pTextures[i].pTextureName, TEXTURE_DEFAULT); | |
271 | |
272 if (this->pTextures[i].uTextureID != -1) | |
273 pBitmaps_LOD->pTextures[this->pTextures[i].uTextureID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[this->pTextures[i].uTextureID].palette_id1); | |
274 //result = (unsigned int)v3->pTextures; | |
275 //if ( !(*(char *)(result + i * 20 + 18) & 1) ) | |
276 if( this->pTextures[i].uFlags & 1) | |
277 break; | |
278 } | |
279 } | |
280 return; | |
281 } | |
282 | |
283 //----- (0044E163) -------------------------------------------------------- | |
284 signed int TextureFrameTable::FindTextureByName(const char *Str2) | |
285 { | |
286 if ( (signed int)this->sNumTextures <= 0 ) | |
287 return -1; | |
288 for ( int i = 0; (signed int)i < (signed int)this->sNumTextures; ++i ) | |
289 { | |
290 if ( !_stricmp(this->pTextures[i].pTextureName, Str2) ) | |
291 return i; | |
292 } | |
293 return -1; | |
294 } | |
295 | |
296 //----- (0044E19A) -------------------------------------------------------- | |
297 int TextureFrameTable::GetFrameTexture(int uFrameID, signed int a3) | |
298 { | |
299 int v3; // esi@1 | |
300 TextureFrame *v4; // edi@1 | |
301 TextureFrame *v5; // ecx@1 | |
302 __int16 v6; // dx@2 | |
303 int v7; // edx@3 | |
304 char *i; // eax@3 | |
305 int v9; // ecx@5 | |
306 unsigned int result; // eax@6 | |
307 | |
308 v3 = uFrameID; | |
309 v4 = this->pTextures; | |
310 v5 = &v4[uFrameID]; | |
311 if ( v5->uFlags & 1 && (v6 = v5->uAnimLength) != 0 ) | |
312 { | |
313 v7 = (a3 >> 3) % v6; | |
314 for ( i = (char *)&v5->uAnimTime; ; i += 20 ) | |
315 { | |
316 v9 = *(short *)i; | |
317 if ( v7 <= v9 ) | |
318 break; | |
319 v7 -= v9; | |
320 ++v3; | |
321 } | |
322 result = v4[v3].uTextureID; | |
323 } | |
324 else | |
325 { | |
326 result = v5->uTextureID; | |
327 } | |
328 return result; | |
329 } | |
330 | |
331 | |
332 | |
333 | |
334 | |
335 | |
336 //----- (0040F806) -------------------------------------------------------- | |
337 void *Texture::UnzipPalette() | |
338 { | |
339 Texture *v1; // esi@1 | |
340 | |
341 void *v2; // edi@1 | |
342 Texture *pSource; // [sp+0h] [bp-4h]@1 | |
343 | |
344 pSource = this; | |
345 v1 = this; | |
346 v2 = malloc(this->uDecompressedSize); | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
347 zlib::MemUnzip(v2, (unsigned int *)&pSource, v1->paletted_pixels, v1->uTextureSize); |
2496 | 348 return v2; |
349 } | |
350 | |
351 //----- (0040F77C) -------------------------------------------------------- | |
352 void Texture::Release() | |
353 { | |
354 if (this) | |
355 { | |
356 pName[0] = 0; | |
357 | |
358 if (pBits & 0x0400) | |
359 { | |
360 __debugbreak(); | |
361 } | |
362 | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
363 free(paletted_pixels); |
2496 | 364 free(pPalette16); |
365 free(pPalette24); | |
366 | |
367 | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
368 paletted_pixels = nullptr; |
2496 | 369 pLevelOfDetail1 = nullptr; |
2524 | 370 //pLevelOfDetail2 = nullptr; |
371 //pLevelOfDetail3 = nullptr; | |
372 | |
373 if (d3d11_srv) | |
374 { | |
375 if (d3d11_desc) | |
376 { | |
377 delete d3d11_desc; | |
378 d3d11_desc = nullptr; | |
379 } | |
380 | |
381 extern void d3d11_release(struct ID3D11ShaderResourceView *); | |
382 d3d11_release(d3d11_srv); | |
383 d3d11_srv = nullptr; | |
384 } | |
2496 | 385 |
386 pPalette16 = nullptr; | |
387 pPalette24 = nullptr; | |
388 | |
389 uSizeOfMaxLevelOfDetail = 0; | |
390 uTextureSize = 0; | |
391 uTextureHeight = 0; | |
392 uTextureWidth = 0; | |
393 uHeightLn2 = 0; | |
394 uWidthLn2 = 0; | |
395 palette_id1 = 0; | |
396 palette_id2 = 0; | |
397 pBits &= 0xFFFF0000; | |
398 } | |
399 } | |
400 | |
401 //----- (0040F5F5) -------------------------------------------------------- | |
402 int RGBTexture::Reload(const char *pContainer) | |
403 { | |
404 //RGBTexture *v2; // esi@1 | |
405 FILE *v3; // eax@3 | |
406 FILE *v4; // edi@3 | |
407 void *v5; // ebx@7 | |
408 signed int result; // eax@11 | |
409 unsigned int v7; // ecx@12 | |
410 unsigned __int16 *v8; // ST20_4@14 | |
411 int v9; // eax@14 | |
412 char color_map[48]; // [sp+8h] [bp-98h]@9 | |
413 Texture DstBuf; // [sp+38h] [bp-68h]@1 | |
414 PCXHeader1 header1; // [sp+80h] [bp-20h]@9 | |
415 PCXHeader2 header2; // [sp+90h] [bp-10h]@9 | |
416 FILE *File; // [sp+98h] [bp-8h]@3 | |
417 size_t Count; // [sp+9Ch] [bp-4h]@6 | |
418 void *uSourceLena; // [sp+A8h] [bp+8h]@7 | |
419 | |
420 // v2 = this; | |
421 if ( !this->pPixels ) | |
422 return 2; | |
423 v3 = pIcons_LOD->FindContainer(pContainer, 0); | |
424 v4 = v3; | |
425 File = v3; | |
426 if ( !v3 ) | |
427 Error("Unable to load %s", pContainer); | |
428 | |
429 fread(&DstBuf, 1, 0x30, v3); | |
430 Count = DstBuf.uTextureSize; | |
431 if ( DstBuf.uDecompressedSize ) | |
432 { | |
433 v5 = malloc(DstBuf.uDecompressedSize); | |
434 uSourceLena = malloc(DstBuf.uTextureSize); | |
435 fread(uSourceLena, 1, Count, File); | |
436 zlib::MemUnzip(v5, &DstBuf.uDecompressedSize, uSourceLena, DstBuf.uTextureSize); | |
437 DstBuf.uTextureSize = DstBuf.uDecompressedSize; | |
438 free(uSourceLena); | |
439 } | |
440 else | |
441 { | |
442 v5 = malloc(DstBuf.uTextureSize); | |
443 fread(v5, 1, Count, v4); | |
444 } | |
445 memcpy(&header1, v5, 0x10u); | |
446 memcpy(color_map, (char *)v5 + 16, 0x30); | |
447 memcpy(&header2, (char *)v5 + 64, 6); | |
448 if ( header1.bpp != 8 ) | |
449 return 3; | |
450 v7 = (signed __int16)(header1.right - header1.left + 1); | |
451 if ( (signed int)(v7 * (signed __int16)(header1.bottom - header1.up + 1)) <= (signed int)this->uNumPixels ) | |
452 { | |
453 this->uWidth = header1.right - header1.left + 1; | |
454 v8 = this->pPixels; | |
455 v9 = v7 * this->uHeight; | |
456 this->uNumPixels = v9; | |
457 this->uHeight = v9; | |
458 this->DecodePCX((char *)v5, v8, v7); | |
459 free(v5); | |
460 result = 0; | |
461 } | |
462 else | |
463 { | |
464 result = -1; | |
465 } | |
466 return result; | |
467 } | |
468 | |
469 //----- (0040F5BE) -------------------------------------------------------- | |
470 Texture::Texture() | |
471 { | |
472 pName[0] = 0; | |
473 uSizeOfMaxLevelOfDetail = 0; | |
474 uTextureSize = 0; | |
475 uTextureHeight = 0; | |
476 uTextureWidth = 0; | |
477 uHeightLn2 = 0; | |
478 uWidthLn2 = 0; | |
479 palette_id1 = 0; | |
480 palette_id2 = 0; | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
481 paletted_pixels = nullptr; |
2524 | 482 //pLevelOfDetail3 = nullptr; |
483 //pLevelOfDetail2 = nullptr; | |
2496 | 484 pLevelOfDetail1 = nullptr; |
485 pPalette16 = nullptr; | |
486 pPalette24 = nullptr; | |
2524 | 487 |
488 d3d11_srv = nullptr; | |
489 d3d11_desc = nullptr; | |
2496 | 490 } |
491 | |
492 //----- (0040F414) -------------------------------------------------------- | |
493 int RGBTexture::Load(const char *pContainer, int mode) | |
494 { | |
495 FILE *file; // eax@1 | |
496 void *v6; // ebx@5 | |
497 char color_map[48]; // [sp+Ch] [bp-98h]@7 | |
498 Texture DstBuf; // [sp+3Ch] [bp-68h]@1 | |
499 PCXHeader1 header1; // [sp+84h] [bp-20h]@7 | |
500 PCXHeader2 header2; // [sp+94h] [bp-10h]@7 | |
501 size_t Count; // [sp+A0h] [bp-4h]@4 | |
502 char *Str1a; // [sp+ACh] [bp+8h]@5 | |
503 | |
504 file = pIcons_LOD->FindContainer(pContainer, 0); | |
505 if ( !file ) | |
506 Error("Unable to load %s", pContainer); | |
507 | |
508 fread(&DstBuf, 1, 0x30u, file); | |
509 Count = DstBuf.uTextureSize; | |
510 if ( DstBuf.uDecompressedSize ) | |
511 { | |
512 Str1a = (char *)malloc(DstBuf.uDecompressedSize); | |
513 v6 = malloc(DstBuf.uTextureSize); | |
514 fread(v6, 1, Count, file); | |
515 zlib::MemUnzip(Str1a, &DstBuf.uDecompressedSize, v6, DstBuf.uTextureSize); | |
516 DstBuf.uTextureSize = DstBuf.uDecompressedSize; | |
517 free(v6); | |
518 } | |
519 else | |
520 { | |
521 Str1a = (char *)malloc(DstBuf.uTextureSize); | |
522 fread(Str1a, 1, Count, file); | |
523 } | |
524 memcpy(&header1, Str1a, 0x10u); | |
525 memcpy(color_map, Str1a + 16, 0x30u); | |
526 memcpy(&header2, Str1a + 64, 6); | |
527 if ( header1.bpp != 8 ) | |
528 return 3; | |
529 this->uWidth = header1.right - header1.left + 1; | |
530 this->uHeight = header1.bottom - header1.up + 1; | |
531 this->uNumPixels = (signed __int16)this->uWidth * (signed __int16)this->uHeight; | |
532 this->pPixels = (unsigned __int16 *)malloc(2 * this->uNumPixels + 4); | |
533 if ( this->pPixels ) | |
534 { | |
535 if ( mode ) | |
536 { | |
537 if ( mode != 2 ) | |
538 { | |
539 if ( !this->pPixels ) | |
540 return 2; | |
541 this->DecodePCX(Str1a, this->pPixels, this->uWidth); | |
542 free(Str1a); | |
543 return 0; | |
544 } | |
545 this->_allocation_flags |= 1; | |
546 this->pPixels = (unsigned __int16 *)malloc(2 * this->uNumPixels + 4); | |
547 if ( !this->pPixels ) | |
548 return 2; | |
549 this->DecodePCX(Str1a, this->pPixels, this->uWidth); | |
550 free(Str1a); | |
551 return 0; | |
552 } | |
553 free(this->pPixels); | |
554 } | |
555 if ( !mode ) | |
556 { | |
557 this->pPixels = (unsigned __int16 *)malloc(2 * this->uNumPixels + 4); | |
558 if ( !this->pPixels ) | |
559 return 2; | |
560 this->DecodePCX(Str1a, this->pPixels, this->uWidth); | |
561 free(Str1a); | |
562 return 0; | |
563 } | |
564 if ( mode != 2 ) | |
565 { | |
566 if ( !this->pPixels ) | |
567 return 2; | |
568 this->DecodePCX(Str1a, this->pPixels, this->uWidth); | |
569 free(Str1a); | |
570 return 0; | |
571 } | |
572 this->_allocation_flags |= 1; | |
573 this->pPixels = (unsigned __int16 *)malloc(2 * this->uNumPixels + 4); | |
574 if ( !this->pPixels ) | |
575 return 2; | |
576 this->DecodePCX(Str1a, this->pPixels, this->uWidth); | |
577 free(Str1a); | |
578 return 0; | |
579 } | |
580 | |
581 //----- (0040F037) -------------------------------------------------------- | |
582 signed int RGBTexture::DecodePCX(char *pPcx, unsigned __int16 *pOutPixels, unsigned int uNumPixels) | |
583 { | |
584 // signed int result; // eax@2 | |
585 unsigned char test_byte; // edx@3 | |
586 unsigned int read_offset; // ebx@37 | |
587 unsigned int row_position; // edi@40 | |
588 unsigned char value; // cl@63 | |
589 char count; // [sp+50h] [bp-Ch]@43 | |
590 unsigned short current_line; // [sp+54h] [bp-8h]@38 | |
591 unsigned short *dec_position; | |
592 unsigned short *temp_dec_position; | |
593 PCXHeader1 psx_head1; | |
594 PCXHeader2 psx_head2; | |
595 // short int width, height; | |
596 BYTE color_map[48]; // Colormap for 16-color images | |
597 | |
598 | |
599 memcpy(&psx_head1, pPcx , 16); | |
600 memcpy(&color_map, pPcx + 16, 48); | |
601 memcpy(&psx_head2, pPcx + 64, 6); | |
602 | |
603 | |
604 if (psx_head1.bpp!=8) | |
605 return 3; | |
606 uWidth=(short int )(psx_head1.right-psx_head1.left+1); // word @ 000014 | |
607 uHeight=(short int )(psx_head1.bottom-psx_head1.up+1); // word @ 000016 | |
608 | |
609 | |
610 uNumPixels=uWidth*uHeight; // dword @ 000010 | |
611 | |
612 memset(pOutPixels, 0, uNumPixels * sizeof(__int16)); | |
613 short i=1; | |
614 while ( (1<<i) !=uWidth) | |
615 { | |
616 ++i; | |
617 if (i >= 15) | |
618 break; | |
619 } | |
620 field_18=i; | |
621 short i_=1; | |
622 while ( (1<<i_) !=uHeight) | |
623 { | |
624 ++i_; | |
625 if (i_ >= 15) | |
626 break; | |
627 } | |
628 field_1A=i_; | |
629 switch (field_18) | |
630 { | |
631 case 2: field_1C = 3; break; | |
632 case 3: field_1C = 7; break; | |
633 case 4: field_1C = 15; break; | |
634 case 5: field_1C = 31; break; | |
635 case 6: field_1C = 63; break; | |
636 case 7: field_1C = 127; break; | |
637 case 8: field_1C = 255; break; | |
638 case 9: field_1C = 511; break; | |
639 case 10: field_1C = 1023; break; | |
640 case 11: field_1C = 2047; break; | |
641 case 12: field_1C = 4095; break; | |
642 } | |
643 | |
644 switch (field_1A) | |
645 { | |
646 case 2: field_1E = 3; break; | |
647 case 3: field_1E = 7; break; | |
648 case 4: field_1E = 15; break; | |
649 case 5: field_1E = 31; break; | |
650 case 6: field_1E = 63; break; | |
651 case 7: field_1E = 127; break; | |
652 case 8: field_1E = 255; break; | |
653 case 9: field_1E = 511; break; | |
654 case 10: field_1E = 1023; break; | |
655 case 11: field_1E = 2047; break; | |
656 case 12: field_1E = 4095; break; | |
657 } | |
658 | |
659 unsigned int r_mask = 0xF800; | |
660 unsigned int num_r_bits = 5; | |
661 unsigned int g_mask = 0x07E0; | |
662 unsigned int num_g_bits = 6; | |
663 unsigned int b_mask = 0x001F; | |
664 unsigned int num_b_bits = 5; | |
665 //Ïðè ñîõðàíåíèè èçîáðàæåíèÿ ïîäðÿä èäóùèå ïèêñåëè îäèíàêîâîãî öâåòà îáúåäèíÿþòñÿ è âìåñòî óêàçàíèÿ öâåòà äëÿ êàæäîãî ïèêñåëÿ | |
666 //óêàçûâàåòñÿ öâåò ãðóïïû ïèêñåëåé è èõ êîëè÷åñòâî. | |
667 read_offset = 128; | |
668 if (psx_head2.planes != 3) | |
669 return 0; | |
670 current_line = 0; | |
671 if ( uHeight > 0 ) | |
672 { | |
673 dec_position = pOutPixels; | |
674 do | |
675 { | |
676 temp_dec_position = dec_position; | |
677 row_position = 0; | |
678 //decode red line | |
679 if (psx_head2.pitch) | |
680 { | |
681 do | |
682 { | |
683 test_byte = pPcx[read_offset]; | |
684 ++read_offset; | |
685 if ((test_byte & 0xC0) == 0xC0)//èìååòñÿ ëè îáúåäèíåíèå | |
686 { | |
687 value = pPcx[read_offset]; | |
688 ++read_offset; | |
689 | |
690 if ((test_byte & 0x3F) > 0) | |
691 { | |
692 count = test_byte & 0x3F;//êîëè÷åñòâî îäèíàêîâûõ ïèêñåëåé | |
693 do | |
694 { | |
695 ++row_position; | |
696 //*temp_dec_position =0xFF000000; | |
697 //*temp_dec_position|=(unsigned long)value<<16; | |
698 *temp_dec_position |= r_mask & ((unsigned __int8)value << (num_g_bits + num_r_bits + num_b_bits - 8)); | |
699 temp_dec_position++; | |
700 if (row_position == psx_head2.pitch) | |
701 break; | |
702 } | |
703 while (count-- != 1); | |
704 } | |
705 } | |
706 else | |
707 { | |
708 ++row_position; | |
709 //*temp_dec_position =0xFF000000; | |
710 //*temp_dec_position|= (unsigned long)test_byte<<16; | |
711 | |
712 *temp_dec_position |= r_mask & ((unsigned __int8)test_byte << (num_g_bits + num_r_bits + num_b_bits - 8)); | |
713 | |
714 temp_dec_position++; | |
715 } | |
716 | |
717 } | |
718 while (row_position < psx_head2.pitch); | |
719 } | |
720 | |
721 temp_dec_position = dec_position; | |
722 row_position=0; | |
723 //decode green line | |
724 while (row_position < psx_head2.pitch) | |
725 { | |
726 test_byte = *(pPcx + read_offset); | |
727 ++read_offset; | |
728 if ((test_byte & 0xC0) == 0xC0) | |
729 { | |
730 value = *(pPcx + read_offset); | |
731 ++read_offset; | |
732 if ((test_byte & 0x3F) > 0) | |
733 { | |
734 count = test_byte & 0x3F; | |
735 do | |
736 { | |
737 //*temp_dec_position|= (unsigned int)value<<8; | |
738 //temp_dec_position++; | |
739 | |
740 *temp_dec_position|= g_mask & (unsigned __int16)((unsigned __int8)value << (num_g_bits + num_b_bits - 8)); | |
741 | |
742 temp_dec_position++; | |
743 ++row_position; | |
744 if (row_position == psx_head2.pitch) | |
745 break; | |
746 | |
747 } | |
748 while (count-- != 1); | |
749 } | |
750 } | |
751 else | |
752 { | |
753 //*temp_dec_position |=(unsigned int) test_byte<<8; | |
754 //temp_dec_position++; | |
755 | |
756 *temp_dec_position|= g_mask & (unsigned __int16)((unsigned __int8)test_byte << (num_g_bits + num_b_bits - 8)); | |
757 temp_dec_position++; | |
758 ++row_position; | |
759 } | |
760 } | |
761 | |
762 temp_dec_position = dec_position; | |
763 row_position=0; | |
764 //decode blue line | |
765 while (row_position < psx_head2.pitch) | |
766 { | |
767 test_byte = *(pPcx + read_offset); | |
768 read_offset++; | |
769 if ((test_byte & 0xC0) == 0xC0) | |
770 { | |
771 value = *(pPcx + read_offset); | |
772 ++read_offset; | |
773 if ((test_byte & 0x3F) > 0) | |
774 { | |
775 count = test_byte & 0x3F; | |
776 do | |
777 { | |
778 //*temp_dec_position|= value; | |
779 //temp_dec_position++; | |
780 | |
781 *temp_dec_position |= value >> (8 - num_b_bits); | |
782 temp_dec_position++; | |
783 | |
784 ++row_position; | |
785 if (row_position == psx_head2.pitch) | |
786 break; | |
787 } | |
788 while (count-- != 1); | |
789 } | |
790 } | |
791 else | |
792 { | |
793 //*temp_dec_position|= test_byte; | |
794 //temp_dec_position++; | |
795 *temp_dec_position |= test_byte >> (8 - num_b_bits); | |
796 temp_dec_position++; | |
797 | |
798 ++row_position; | |
799 } | |
800 | |
801 } | |
802 ++current_line; | |
803 dec_position += uWidth; | |
804 } | |
805 while (current_line < uHeight); | |
806 } | |
807 return 0; | |
808 /* | |
809 RGBTexture *v4; // esi@1 | |
810 signed int result; // eax@2 | |
811 unsigned __int16 v6; // ax@3 | |
812 unsigned __int16 *v7; // ecx@3 | |
813 unsigned int v8; // edx@3 | |
814 signed int v9; // ecx@3 | |
815 signed int v10; // ecx@8 | |
816 signed int v11; // ebx@37 | |
817 unsigned __int16 *v12; // eax@40 | |
818 int v13; // edi@40 | |
819 int v14; // ebx@41 | |
820 char v15; // bl@42 | |
821 unsigned __int16 *v16; // eax@50 | |
822 int v17; // ebx@51 | |
823 char v18; // bl@52 | |
824 unsigned __int16 *v19; // eax@61 | |
825 unsigned __int8 v20; // dl@62 | |
826 unsigned __int8 v21; // dl@63 | |
827 unsigned __int8 v22; // cl@63 | |
828 char color_map[48]; // [sp+8h] [bp-54h]@1 | |
829 PCXHeader1 header1; // [sp+38h] [bp-24h]@1 | |
830 PCXHeader2 header2; // [sp+48h] [bp-14h]@1 | |
831 unsigned int v26; // [sp+50h] [bp-Ch]@43 | |
832 int v27; // [sp+54h] [bp-8h]@38 | |
833 unsigned __int16 *v28; // [sp+58h] [bp-4h]@3 | |
834 int pOutPixelsa; // [sp+68h] [bp+Ch]@41 | |
835 int pOutPixelsb; // [sp+68h] [bp+Ch]@51 | |
836 | |
837 v4 = this; | |
838 memcpy(&header1, pPcx, 0x10u); | |
839 memcpy(color_map, pPcx + 16, 0x30u); | |
840 memcpy(&header2, pPcx + 64, 6u); | |
841 if ( header1.bpp == 8 ) | |
842 { | |
843 v6 = header1.right - header1.left + 1; | |
844 LOWORD(v7) = header1.bottom - header1.up + 1; | |
845 v4->uWidth = v6; | |
846 v4->uHeight = (unsigned __int16)v7; | |
847 v7 = (unsigned __int16 *)(signed __int16)v7; | |
848 v28 = v7; | |
849 v4->uNumPixels = (signed __int16)v7 * (signed __int16)v6; | |
850 HIWORD(v8) = 0; | |
851 v9 = 1; | |
852 while ( 1 << v9 != (signed __int16)v6 ) | |
853 { | |
854 ++v9; | |
855 if ( v9 >= 15 ) | |
856 goto LABEL_8; | |
857 } | |
858 v4->field_18 = v9; | |
859 LABEL_8: | |
860 v10 = 1; | |
861 while ( (unsigned __int16 *)(1 << v10) != v28 ) | |
862 { | |
863 ++v10; | |
864 if ( v10 >= 15 ) | |
865 goto LABEL_13; | |
866 } | |
867 v4->field_1A = v10; | |
868 LABEL_13: | |
869 switch ( v4->field_18 ) | |
870 { | |
871 case 2: | |
872 v4->field_1C = 3; | |
873 break; | |
874 case 3: | |
875 v4->field_1C = 7; | |
876 break; | |
877 case 4: | |
878 v4->field_1C = 15; | |
879 break; | |
880 case 5: | |
881 v4->field_1C = 31; | |
882 break; | |
883 case 6: | |
884 v4->field_1C = 63; | |
885 break; | |
886 case 7: | |
887 v4->field_1C = 127; | |
888 break; | |
889 case 8: | |
890 v4->field_1C = 255; | |
891 break; | |
892 case 9: | |
893 v4->field_1C = 511; | |
894 break; | |
895 case 10: | |
896 v4->field_1C = 1023; | |
897 break; | |
898 case 11: | |
899 v4->field_1C = 2047; | |
900 break; | |
901 case 12: | |
902 v4->field_1C = 4095; | |
903 break; | |
904 default: | |
905 break; | |
906 } | |
907 switch ( v4->field_1A ) | |
908 { | |
909 case 2: | |
910 v4->field_1E = 3; | |
911 break; | |
912 case 3: | |
913 v4->field_1E = 7; | |
914 break; | |
915 case 4: | |
916 v4->field_1E = 15; | |
917 break; | |
918 case 5: | |
919 v4->field_1E = 31; | |
920 break; | |
921 case 6: | |
922 v4->field_1E = 63; | |
923 break; | |
924 case 7: | |
925 v4->field_1E = 127; | |
926 break; | |
927 case 8: | |
928 v4->field_1E = 255; | |
929 break; | |
930 case 9: | |
931 v4->field_1E = 511; | |
932 break; | |
933 case 10: | |
934 v4->field_1E = 1023; | |
935 break; | |
936 case 11: | |
937 v4->field_1E = 2047; | |
938 break; | |
939 case 12: | |
940 v4->field_1E = 4095; | |
941 break; | |
942 default: | |
943 break; | |
944 } | |
945 v11 = 128; | |
946 if ( header2.planes == 3 ) | |
947 { | |
948 v27 = 0; | |
949 if ( (signed int)v28 > 0 ) | |
950 { | |
951 v28 = pOutPixels; | |
952 do | |
953 { | |
954 v12 = v28; | |
955 v13 = 0; | |
956 if ( header2.pitch ) | |
957 { | |
958 do | |
959 { | |
960 LOBYTE(v8) = pPcx[v11]; | |
961 v14 = v11 + 1; | |
962 pOutPixelsa = v14; | |
963 if ( (v8 & 0xC0) == -64 ) | |
964 { | |
965 pOutPixelsa = v14 + 1; | |
966 v15 = pPcx[v14]; | |
967 if ( (signed int)(v8 & 0x3F) > 0 ) | |
968 { | |
969 v26 = v8 & 0x3F; | |
970 do | |
971 { | |
972 ++v13; | |
973 *v12 = LOWORD(pRenderer->uTargetRMask) & ((unsigned __int8)v15 << (LOBYTE(pRenderer->uTargetGBits) | |
974 + LOBYTE(pRenderer->uTargetRBits) | |
975 + LOBYTE(pRenderer->uTargetBBits) | |
976 - 8)); | |
977 ++v12; | |
978 if ( v13 == (unsigned __int16)header2.pitch ) | |
979 v12 = &v12[uNumPixels - (unsigned __int16)header2.pitch - 1]; | |
980 --v26; | |
981 } | |
982 while ( v26 ); | |
983 } | |
984 } | |
985 else | |
986 { | |
987 LOWORD(v8) = (unsigned __int8)v8; | |
988 v8 = pRenderer->uTargetRMask & (v8 << (LOBYTE(pRenderer->uTargetGBits) | |
989 + LOBYTE(pRenderer->uTargetRBits) | |
990 + LOBYTE(pRenderer->uTargetBBits) | |
991 - 8)); | |
992 ++v13; | |
993 *v12 = v8; | |
994 ++v12; | |
995 } | |
996 v11 = pOutPixelsa; | |
997 } | |
998 while ( v13 < (unsigned __int16)header2.pitch ); | |
999 } | |
1000 v16 = v28; | |
1001 while ( v13 < 2 * (unsigned __int16)header2.pitch ) | |
1002 { | |
1003 LOBYTE(v8) = pPcx[v11]; | |
1004 v17 = v11 + 1; | |
1005 pOutPixelsb = v17; | |
1006 if ( (v8 & 0xC0) == -64 ) | |
1007 { | |
1008 pOutPixelsb = v17 + 1; | |
1009 v18 = pPcx[v17]; | |
1010 if ( (signed int)(v8 & 0x3F) > 0 ) | |
1011 { | |
1012 v26 = v8 & 0x3F; | |
1013 do | |
1014 { | |
1015 *v16 |= pRenderer->uTargetGMask & (unsigned __int16)((unsigned __int8)v18 << (LOBYTE(pRenderer->uTargetGBits) | |
1016 + LOBYTE(pRenderer->uTargetBBits) | |
1017 - 8)); | |
1018 ++v13; | |
1019 ++v16; | |
1020 if ( v13 == (unsigned __int16)header2.pitch ) | |
1021 v16 = &v16[uNumPixels - (unsigned __int16)header2.pitch - 1]; | |
1022 --v26; | |
1023 } | |
1024 while ( v26 ); | |
1025 } | |
1026 } | |
1027 else | |
1028 { | |
1029 LOWORD(v8) = (unsigned __int8)v8; | |
1030 v8 = pRenderer->uTargetGMask & (v8 << (LOBYTE(pRenderer->uTargetGBits) + LOBYTE(pRenderer->uTargetBBits) - 8)); | |
1031 *v16 |= v8; | |
1032 ++v13; | |
1033 ++v16; | |
1034 } | |
1035 v11 = pOutPixelsb; | |
1036 } | |
1037 v19 = v28; | |
1038 while ( v13 < 3 * (unsigned __int16)header2.pitch ) | |
1039 { | |
1040 v20 = pPcx[v11++]; | |
1041 if ( (v20 & 0xC0) == -64 ) | |
1042 { | |
1043 v21 = v20 & 0x3F; | |
1044 v22 = pPcx[v11++]; | |
1045 if ( (signed int)v21 > 0 ) | |
1046 { | |
1047 v26 = v21; | |
1048 do | |
1049 { | |
1050 *v19 |= v22 >> (8 - LOBYTE(pRenderer->uTargetBBits)); | |
1051 ++v13; | |
1052 ++v19; | |
1053 if ( v13 == (unsigned __int16)header2.pitch ) | |
1054 { | |
1055 v8 = uNumPixels - (unsigned __int16)header2.pitch; | |
1056 v19 = &v19[uNumPixels - (unsigned __int16)header2.pitch - 1]; | |
1057 } | |
1058 --v26; | |
1059 } | |
1060 while ( v26 ); | |
1061 } | |
1062 } | |
1063 else | |
1064 { | |
1065 *v19 |= v20 >> (8 - LOBYTE(pRenderer->uTargetBBits)); | |
1066 ++v13; | |
1067 ++v19; | |
1068 } | |
1069 } | |
1070 ++v27; | |
1071 v28 += uNumPixels; | |
1072 } | |
1073 while ( v27 < v4->uHeight ); | |
1074 } | |
1075 } | |
1076 result = 0; | |
1077 } | |
1078 else | |
1079 { | |
1080 result = 3; | |
1081 } | |
1082 return result; | |
1083 */ | |
1084 } | |
1085 | |
1086 //----- (0040EAD8) -------------------------------------------------------- | |
1087 unsigned int RGBTexture::LoadFromFILE(FILE *pFile, unsigned int mode, unsigned int bCloseFile) | |
1088 { | |
1089 // signed int result; // eax@2 | |
1090 // unsigned char test_byte; // edx@3 | |
1091 //unsigned int read_offset; // ebx@37 | |
1092 // unsigned int row_position; // edi@40 | |
1093 // unsigned char value; // cl@63 | |
1094 // char count; // [sp+50h] [bp-Ch]@43 | |
1095 // unsigned short current_line; // [sp+54h] [bp-8h]@38 | |
1096 // unsigned short *dec_position; | |
1097 // unsigned short *temp_dec_position; | |
1098 PCXHeader1 psx_head1; | |
1099 PCXHeader2 psx_head2; | |
1100 // short int width, height; | |
1101 BYTE color_map[48]; // Colormap for 16-color images | |
1102 | |
1103 unsigned int num_r_bits = 5; | |
1104 unsigned int num_g_bits = 6; | |
1105 unsigned int num_b_bits = 5; | |
1106 | |
1107 unsigned int r_mask = 0xF800; | |
1108 unsigned int g_mask = 0x07E0; | |
1109 unsigned int b_mask = 0x001F; | |
1110 | |
1111 if (!pFile) | |
1112 return 1; | |
1113 | |
1114 | |
1115 fread(&psx_head1, 1, 16, pFile); | |
1116 fread(&color_map, 1, 48, pFile); | |
1117 fread(&psx_head2, 1, 6, pFile); | |
1118 | |
1119 if (psx_head1.bpp!=8) | |
1120 return 3; | |
1121 uWidth=(short int )(psx_head1.right-psx_head1.left+1); // word @ 000014 | |
1122 uHeight=(short int )(psx_head1.bottom-psx_head1.up+1); // word @ 000016 | |
1123 | |
1124 | |
1125 uNumPixels=uWidth*uHeight; // dword @ 000010 | |
1126 | |
1127 | |
1128 if ( mode == 0 ) | |
1129 { | |
1130 free(pPixels); | |
1131 pPixels = (unsigned __int16 *)malloc(2 * uNumPixels + 4); | |
1132 } | |
1133 else | |
1134 { | |
1135 if ( mode != 1 && mode == 2 ) | |
1136 { | |
1137 pPixels = (unsigned __int16 *)malloc((uNumPixels + 2) * sizeof(unsigned __int16)); | |
1138 _allocation_flags |= 1; | |
1139 } | |
1140 } | |
1141 | |
1142 ushort* pOutPixels = pPixels; | |
1143 | |
1144 memset(pOutPixels, 0, uNumPixels * sizeof(__int16)); | |
1145 | |
1146 short i=1; | |
1147 while ( (1<<i) !=uWidth) | |
1148 { | |
1149 ++i; | |
1150 if (i >= 15) | |
1151 break; | |
1152 } | |
1153 field_18=i; | |
1154 short i_=1; | |
1155 while ( (1<<i_) !=uHeight) | |
1156 { | |
1157 ++i_; | |
1158 if (i_ >= 15) | |
1159 break; | |
1160 } | |
1161 field_1A=i_; | |
1162 switch (field_18) | |
1163 { | |
1164 case 2: field_1C = 3; break; | |
1165 case 3: field_1C = 7; break; | |
1166 case 4: field_1C = 15; break; | |
1167 case 5: field_1C = 31; break; | |
1168 case 6: field_1C = 63; break; | |
1169 case 7: field_1C = 127; break; | |
1170 case 8: field_1C = 255; break; | |
1171 case 9: field_1C = 511; break; | |
1172 case 10: field_1C = 1023; break; | |
1173 case 11: field_1C = 2047; break; | |
1174 case 12: field_1C = 4095; break; | |
1175 } | |
1176 | |
1177 switch (field_1A) | |
1178 { | |
1179 case 2: field_1E = 3; break; | |
1180 case 3: field_1E = 7; break; | |
1181 case 4: field_1E = 15; break; | |
1182 case 5: field_1E = 31; break; | |
1183 case 6: field_1E = 63; break; | |
1184 case 7: field_1E = 127; break; | |
1185 case 8: field_1E = 255; break; | |
1186 case 9: field_1E = 511; break; | |
1187 case 10: field_1E = 1023; break; | |
1188 case 11: field_1E = 2047; break; | |
1189 case 12: field_1E = 4095; break; | |
1190 } | |
1191 | |
1192 fseek(pFile, 128 - 70, SEEK_CUR); | |
1193 | |
1194 | |
1195 for (uint y = 0; y < uHeight; ++y) | |
1196 { | |
1197 unsigned __int16 *pDst = pPixels + y * uWidth; | |
1198 | |
1199 uint x = 0; | |
1200 do | |
1201 { | |
1202 uint ctrl = 0; | |
1203 fread(&ctrl, 1, 1, pFile); | |
1204 if ((ctrl & 0xC0) == 0xC0) | |
1205 { | |
1206 uint uNumPixels = ctrl & 0x3F; | |
1207 uint clr = 0; | |
1208 fread(&clr, 1, 1, pFile); | |
1209 for (uint i = 0; i < uNumPixels; ++i) | |
1210 pDst[x++] = r_mask & (clr << (num_g_bits + num_r_bits + num_b_bits - 8)); | |
1211 } | |
1212 else | |
1213 { | |
1214 pDst[x++] = r_mask & (ctrl << (num_g_bits + num_r_bits + num_b_bits - 8)); | |
1215 } | |
1216 } while (x < psx_head2.pitch); | |
1217 | |
1218 x = 0; | |
1219 do | |
1220 { | |
1221 uint ctrl = 0; | |
1222 fread(&ctrl, 1, 1, pFile); | |
1223 if ((ctrl & 0xC0) == 0xC0) | |
1224 { | |
1225 uint uNumPixels = ctrl & 0x3F; | |
1226 uint clr = 0; | |
1227 fread(&clr, 1, 1, pFile); | |
1228 for (uint i = 0; i < uNumPixels; ++i) | |
1229 pDst[x++] |= g_mask & (clr << (num_g_bits + num_b_bits - 8)); | |
1230 } | |
1231 else | |
1232 { | |
1233 pDst[x++] |= g_mask & (ctrl << (num_g_bits + num_b_bits - 8)); | |
1234 } | |
1235 } while (x < psx_head2.pitch); | |
1236 | |
1237 x = 0; | |
1238 do | |
1239 { | |
1240 uint ctrl = 0; | |
1241 fread(&ctrl, 1, 1, pFile); | |
1242 if ((ctrl & 0xC0) == 0xC0) | |
1243 { | |
1244 uint uNumPixels = ctrl & 0x3F; | |
1245 uint clr = 0; | |
1246 fread(&clr, 1, 1, pFile); | |
1247 for (uint i = 0; i < uNumPixels; ++i) | |
1248 pDst[x++] |= b_mask & (clr >> (8 - num_b_bits)); | |
1249 } | |
1250 else | |
1251 { | |
1252 pDst[x++] |= b_mask & (ctrl >> (8 - num_b_bits)); | |
1253 } | |
1254 } while (x < psx_head2.pitch); | |
1255 } | |
1256 | |
1257 if (bCloseFile) | |
1258 fclose(pFile); | |
1259 return 0; | |
1260 } | |
1261 | |
1262 //----- (0040E51F) -------------------------------------------------------- | |
1263 void RGBTexture::Release() | |
1264 { | |
1265 this->pName[0] = 0; | |
1266 //if ( !(this->_allocation_flags & 1) ) | |
1267 //free(this->pPixels); | |
1268 //else | |
2518 | 1269 //free(this->pPixels); |
1270 if (this->pPixels) | |
2496 | 1271 free(this->pPixels); |
1272 this->_allocation_flags = 0; | |
1273 this->pPixels = 0; | |
1274 this->uNumPixels = 0; | |
1275 this->uHeight = 0; | |
1276 this->uWidth = 0; | |
1277 this->field_1A = 0; | |
1278 this->field_18 = 0; | |
2518 | 1279 |
1280 if (d3d11_srv) | |
2524 | 1281 { |
1282 if (d3d11_desc) | |
1283 { | |
1284 delete d3d11_desc; | |
1285 d3d11_desc = nullptr; | |
1286 } | |
1287 | |
1288 extern void d3d11_release(struct ID3D11ShaderResourceView *); | |
1289 d3d11_release(d3d11_srv); | |
1290 d3d11_srv = nullptr; | |
1291 } | |
2496 | 1292 } |
1293 | |
1294 //----- (0040E55E) -------------------------------------------------------- | |
1295 int RGBTexture::LoadPCXFile(const char *Filename, unsigned int a3) | |
1296 { | |
1297 signed int result; // eax@2 | |
1298 char *v6; // eax@3 | |
1299 int v7; // edx@3 | |
1300 char v8; // cl@4 | |
1301 signed int v14; // ecx@19 | |
1302 signed int v15; // ecx@24 | |
1303 // int v16; // eax@57 | |
1304 // unsigned __int16 *v17; // ecx@57 | |
1305 // unsigned __int16 *v18; // edi@57 | |
1306 // signed int x; // eax@59 | |
1307 // unsigned __int16 *v20; // edi@64 | |
1308 // signed int v21; // eax@66 | |
1309 // unsigned __int16 *v22; // edi@71 | |
1310 // signed int v23; // eax@73 | |
1311 // int v24; // eax@78 | |
1312 char v25[48]; // [sp+Ch] [bp-54h]@3 | |
1313 PCXHeader1 pcx_header1; | |
1314 PCXHeader2 pcx_header2; | |
1315 int y; // [sp+54h] [bp-Ch]@3 | |
1316 FILE *File; // [sp+5Ch] [bp-4h]@1 | |
1317 | |
1318 unsigned int num_r_bits = 5; | |
1319 unsigned int num_g_bits = 6; | |
1320 unsigned int num_b_bits = 5; | |
1321 | |
1322 unsigned int r_mask = 0xF800; | |
1323 unsigned int g_mask = 0x07E0; | |
1324 unsigned int b_mask = 0x001F; | |
1325 | |
1326 | |
1327 File = fopen(Filename, "rb"); | |
1328 if ( !File ) | |
1329 return 1; | |
1330 | |
1331 fread(&pcx_header1, sizeof(pcx_header1), 1, File); | |
1332 fread(&v25,48,1,File); | |
1333 fread(&pcx_header2, 4, 1, File); | |
1334 | |
1335 v6 = (char *)Filename; | |
1336 v7 = (char *)this - Filename; | |
1337 uint i = 0; | |
1338 for ( i; i < 15; ++i ) | |
1339 { | |
1340 v8 = *v6; | |
1341 if ( !*v6 ) | |
1342 break; | |
1343 if ( v8 == 46 ) | |
1344 break; | |
1345 (v6++)[v7] = v8; | |
1346 } | |
1347 this->pName[i] = 0; | |
1348 if ( pcx_header1.bpp != 8 ) | |
1349 return 3; | |
1350 this->uWidth = pcx_header1.right - pcx_header1.left + 1; | |
1351 this->uHeight = pcx_header1.bottom - pcx_header1.up + 1; | |
1352 this->uNumPixels = (signed __int16)this->uWidth * (signed __int16)this->uHeight; | |
1353 if ( !a3 ) | |
1354 { | |
1355 free(this->pPixels); | |
1356 this->pPixels = (unsigned __int16 *)malloc(2 * this->uNumPixels + 4); | |
1357 } | |
1358 if ( a3 == 2 ) | |
1359 { | |
1360 this->_allocation_flags |= 1; | |
1361 this->pPixels = (unsigned __int16 *)malloc((uNumPixels + 2) * sizeof(unsigned __int16)); | |
1362 } | |
1363 if ( this->pPixels ) | |
1364 { | |
1365 for ( v14 = 1; v14 < 15; ++v14 ) | |
1366 { | |
1367 if ( 1 << v14 == this->uWidth ) | |
1368 this->field_18 = v14; | |
1369 } | |
1370 for ( v15 = 1; v15 < 15; ++v15 ) | |
1371 { | |
1372 if ( 1 << v15 == this->uHeight ) | |
1373 this->field_1A = v15; | |
1374 } | |
1375 switch ( this->field_18 ) | |
1376 { | |
1377 case 2: this->field_1C = 3; break; | |
1378 case 3: this->field_1C = 7; break; | |
1379 case 4: this->field_1C = 15; break; | |
1380 case 5: this->field_1C = 31; break; | |
1381 case 6: this->field_1C = 63; break; | |
1382 case 7: this->field_1C = 127; break; | |
1383 case 8: this->field_1C = 255; break; | |
1384 case 9: this->field_1C = 511; break; | |
1385 case 10: this->field_1C = 1023; break; | |
1386 case 11: this->field_1C = 2047; break; | |
1387 case 12: this->field_1C = 4095; break; | |
1388 default: break; | |
1389 } | |
1390 switch ( this->field_1A ) | |
1391 { | |
1392 case 2: this->field_1E = 3; break; | |
1393 case 3: this->field_1E = 7; break; | |
1394 case 4: this->field_1E = 15; break; | |
1395 case 5: this->field_1E = 31; break; | |
1396 case 6: this->field_1E = 63; break; | |
1397 case 7: this->field_1E = 127; break; | |
1398 case 8: this->field_1E = 255; break; | |
1399 case 9: this->field_1E = 511; break; | |
1400 case 10: this->field_1E = 1023; break; | |
1401 case 11: this->field_1E = 2047; break; | |
1402 case 12: this->field_1E = 4095; break; | |
1403 default: break; | |
1404 } | |
1405 fseek(File, 128, 0); | |
1406 ftell(File); | |
1407 if ( pcx_header2.planes == 1 ) | |
1408 Error("24bit PCX Only!"); | |
1409 | |
1410 if ( pcx_header2.planes == 3 ) | |
1411 { | |
1412 for ( y = 0; y < this->uHeight; ++y ) | |
1413 { | |
1414 unsigned __int16 *pDst = pPixels + y * uWidth; | |
1415 uint x = 0; | |
1416 do | |
1417 { | |
1418 uint ctrl = 0; | |
1419 fread(&ctrl, 1, 1, File); | |
1420 if ( (ctrl & 0xC0) == 0xC0 ) | |
1421 { | |
1422 uint uNumPixels = ctrl & 0x3F; | |
1423 uint clr = 0; | |
1424 ctrl &= 0x3F; | |
1425 fread(&clr, 1, 1, File); | |
1426 for ( uint i = 0; i < uNumPixels; ++i ) | |
1427 pDst[x++] = r_mask & (clr << (num_r_bits + num_g_bits + num_b_bits - 8)); | |
1428 } | |
1429 else | |
1430 pDst[x++] = r_mask & (ctrl << (num_g_bits + num_r_bits + num_b_bits - 8)); | |
1431 } | |
1432 while ( x < pcx_header2.pitch ); | |
1433 | |
1434 x = 0; | |
1435 do | |
1436 { | |
1437 uint ctrl = 0; | |
1438 fread(&ctrl, 1, 1, File); | |
1439 if ( (ctrl & 0xC0) == 0xC0 ) | |
1440 { | |
1441 uint uNumPixels = ctrl & 0x3F; | |
1442 uint clr = 0; | |
1443 ctrl &= 0x3F; | |
1444 fread(&clr, 1, 1, File); | |
1445 for ( uint i = 0; i < uNumPixels; ++i ) | |
1446 pDst[x++] |= g_mask & (clr << (num_g_bits + num_b_bits - 8)); | |
1447 } | |
1448 else | |
1449 pDst[x++] |= g_mask & (ctrl << (num_g_bits + num_b_bits - 8)); | |
1450 } | |
1451 while (x < pcx_header2.pitch); | |
1452 | |
1453 x = 0; | |
1454 do | |
1455 { | |
1456 uint ctrl = 0; | |
1457 fread(&ctrl, 1, 1, File); | |
1458 if ( (ctrl & 0xC0) == 0xC0 ) | |
1459 { | |
1460 uint uNumPixels = ctrl & 0x3F; | |
1461 uint clr = 0; | |
1462 fread(&clr, 1, 1, File); | |
1463 for ( uint i = 0; i < uNumPixels; ++i ) | |
1464 pDst[x++] |= b_mask & (clr >> (8 - num_b_bits)); | |
1465 } | |
1466 else | |
1467 pDst[x++] |= b_mask & (ctrl >> (8 - num_b_bits)); | |
1468 } | |
1469 while (x < pcx_header2.pitch); | |
1470 } | |
1471 } | |
1472 fclose(File); | |
1473 result = 0; | |
1474 } | |
1475 else | |
1476 { | |
1477 result = 2; | |
1478 } | |
1479 return result; | |
1480 } | |
1481 | |
1482 //----- (0040D73D) -------------------------------------------------------- | |
1483 RGBTexture::RGBTexture() | |
1484 { | |
1485 pName[0] = 0; | |
1486 pPixels = 0; | |
1487 uNumPixels = 0; | |
1488 uHeight = 0; | |
1489 uWidth = 0; | |
1490 field_1A = 0; | |
1491 field_18 = 0; | |
1492 _allocation_flags = 0; | |
2518 | 1493 |
1494 d3d11_srv = nullptr; | |
1495 d3d11_desc = nullptr; | |
2496 | 1496 } |
1497 //----- (0044E1EC) -------------------------------------------------------- | |
1498 int TextureFrameTable::FromFileTxt(const char *Args) | |
1499 { | |
1500 TextureFrameTable *v2; // ebx@1 | |
1501 FILE *v3; // eax@1 | |
1502 int v4; // esi@3 | |
1503 const void *v5; // ST0C_4@10 | |
1504 void *v6; // eax@10 | |
1505 FILE *v7; // ST0C_4@12 | |
1506 char *i; // eax@12 | |
1507 signed int v9; // esi@15 | |
1508 int v10; // eax@17 | |
1509 int v11; // edx@22 | |
1510 int v12; // ecx@23 | |
1511 int v13; // eax@24 | |
1512 signed int j; // eax@27 | |
1513 TextureFrame *v15; // edx@28 | |
1514 int v16; // esi@28 | |
1515 int k; // ecx@29 | |
1516 char Buf; // [sp+Ch] [bp-2F8h]@3 | |
1517 FrameTableTxtLine v20; // [sp+200h] [bp-104h]@4 | |
1518 int v21; // [sp+27Ch] [bp-88h]@4 | |
1519 char *Str1; // [sp+280h] [bp-84h]@5 | |
1520 char *Str; // [sp+284h] [bp-80h]@15 | |
1521 int v24; // [sp+2F8h] [bp-Ch]@3 | |
1522 int v25; // [sp+2FCh] [bp-8h]@3 | |
1523 FILE *File; // [sp+300h] [bp-4h]@1 | |
1524 int Argsa; // [sp+30Ch] [bp+8h]@28 | |
1525 | |
1526 v2 = this; | |
1527 v3 = fopen(Args, "r"); | |
1528 File = v3; | |
1529 if ( !v3 ) | |
1530 Error("CTextureFrameTable::load - Unable to open file: %s.", Args); | |
1531 | |
1532 v4 = 0; | |
1533 v24 = 0; | |
1534 v25 = 1; | |
1535 if ( fgets(&Buf, 490, v3) ) | |
1536 { | |
1537 do | |
1538 { | |
1539 *strchr(&Buf, 10) = 0; | |
1540 memcpy(&v21, txt_file_frametable_parser(&Buf, &v20), 0x7Cu); | |
1541 __debugbreak(); // warning C4700: uninitialized local variable 'Str1' used | |
1542 if ( v21 && *Str1 != 47 ) | |
1543 { | |
1544 if ( v21 < 2 ) | |
1545 Error("CTextureFrameTable::load, too few arguments, %s line %i.", Args, v25); | |
1546 ++v24; | |
1547 } | |
1548 ++v25; | |
1549 } | |
1550 while ( fgets(&Buf, 490, File) ); | |
1551 v4 = v24; | |
1552 } | |
1553 v5 = v2->pTextures; | |
1554 v2->sNumTextures = v4; | |
1555 v6 = malloc(20 * v4); | |
1556 v2->pTextures = (TextureFrame *)v6; | |
1557 if ( !v6 ) | |
1558 Error("CTextureFrameTable::load - Out of Memory!"); | |
1559 v7 = File; | |
1560 v2->sNumTextures = 0; | |
1561 fseek(v7, 0, 0); | |
1562 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) | |
1563 { | |
1564 *strchr(&Buf, 10) = 0; | |
1565 memcpy(&v21, txt_file_frametable_parser(&Buf, &v20), 0x7Cu); | |
1566 if ( v21 && *Str1 != 47 ) | |
1567 { | |
1568 strcpy(v2->pTextures[v2->sNumTextures].pTextureName, Str1); | |
1569 __debugbreak(); // warning C4700: uninitialized local variable 'Str' used | |
1570 v2->pTextures[v2->sNumTextures].uAnimTime = atoi(Str); | |
1571 v9 = 2; | |
1572 for ( v2->pTextures[v2->sNumTextures].uFlags = 0; v9 < v21; ++v9 ) | |
1573 { | |
1574 if ( !_stricmp((&Str1)[4 * v9], "New") ) | |
1575 { | |
1576 //v10 = (int)&v2->pTextures[v2->sNumTextures].uFlags; | |
1577 v2->pTextures[v2->sNumTextures].uFlags |= 2; | |
1578 } | |
1579 } | |
1580 ++v2->sNumTextures; | |
1581 } | |
1582 } | |
1583 fclose(File); | |
1584 v11 = 0; | |
1585 if ( (signed int)(v2->sNumTextures - 1) > 0 ) | |
1586 { | |
1587 v12 = 0; | |
1588 do | |
1589 { | |
1590 v13 = (int)&v2->pTextures[v12]; | |
1591 if ( !(*(char *)(v13 + 38) & 2) ) | |
1592 *(char *)(v13 + 18) |= 1u; | |
1593 ++v11; | |
1594 ++v12; | |
1595 } | |
1596 while ( v11 < (signed int)(v2->sNumTextures - 1) ); | |
1597 } | |
1598 for ( j = 0; j < (signed int)v2->sNumTextures; *(short *)(Argsa + 16) = v16 ) | |
1599 { | |
1600 v15 = v2->pTextures; | |
1601 Argsa = (int)&v15[j]; | |
1602 v16 = *(short *)(Argsa + 14); | |
1603 if ( *(char *)(Argsa + 18) & 1 ) | |
1604 { | |
1605 ++j; | |
1606 for ( k = (int)&v15[j]; *(char *)(k + 18) & 1; k += 20 ) | |
1607 { | |
1608 v16 += *(short *)(k + 14); | |
1609 ++j; | |
1610 } | |
1611 LOWORD(v16) = v15[j].uAnimTime + v16; | |
1612 } | |
1613 ++j; | |
1614 } | |
1615 return 1; | |
1616 } | |
1617 | |
1618 //----- (00451007) -------------------------------------------------------- | |
1619 int stru350::sub_451007_scale_image_bicubic(unsigned short *pSrc, int srcWidth, int srcHeight, int srcPitch, //changing this to some library function might be a good idea | |
1620 unsigned short *pDst, int dstWidth, int dstHeight, int dstPitch, | |
1621 int a10, int a11) | |
1622 { | |
1623 int result; // eax@1 | |
1624 float v17; // ST3C_4@12 | |
1625 float v18; // ST38_4@12 | |
1626 unsigned int v19; // esi@12 | |
1627 int v21; // eax@18 | |
1628 unsigned int v22; // ecx@25 | |
1629 unsigned int v23; // eax@29 | |
1630 unsigned int heightRatioPlusOne; // [sp+Ch] [bp-7Ch]@12 | |
1631 unsigned int widthRatio; // [sp+Ch] [bp-7Ch]@218 | |
1632 unsigned int heightRatio; // [sp+14h] [bp-74h]@12 | |
1633 unsigned int widthRatioPlusOne; // [sp+14h] [bp-74h]@218 | |
1634 // int v160; // [sp+3Ch] [bp-4Ch]@13 | |
1635 unsigned __int16 *v175; // [sp+4Ch] [bp-3Ch]@13 | |
1636 unsigned __int16 *v193; // [sp+5Ch] [bp-2Ch]@7 | |
1637 //signed int v231; // [sp+78h] [bp-10h]@7 | |
1638 __int64 v240; // [sp+7Ch] [bp-Ch]@12 | |
1639 unsigned int v251; // [sp+80h] [bp-8h]@218 | |
1640 unsigned int v252; // [sp+84h] [bp-4h]@218 | |
1641 float a6s; // [sp+A0h] [bp+18h]@218 | |
1642 float a6t; // [sp+A0h] [bp+18h]@218 | |
1643 unsigned int a6b; // [sp+A0h] [bp+18h]@218 | |
1644 int field_0_bits; | |
1645 int field_20_bits; | |
1646 | |
1647 int field0value = this->field_0.field_C; | |
1648 switch (field0value) | |
1649 { | |
1650 case 8: field_0_bits = 1; | |
1651 break; | |
1652 case 16: field_0_bits = 2; | |
1653 break; | |
1654 case 32: field_0_bits = 4; | |
1655 break; | |
1656 default: | |
1657 return field0value; | |
1658 } | |
1659 int field20value = this->field_20.field_C; | |
1660 switch (field20value) | |
1661 { | |
1662 case 8: field_20_bits = 1; | |
1663 break; | |
1664 case 16: field_20_bits = 2; | |
1665 break; | |
1666 case 32: field_20_bits = 4; | |
1667 break; | |
1668 default: | |
1669 return field20value; | |
1670 } | |
1671 | |
1672 result = (int)pDst; | |
1673 v193 = pDst; | |
1674 if (dstHeight <= 0) | |
1675 return result; | |
1676 | |
1677 //do | |
1678 for (int height = 0; height < dstHeight; height++) | |
1679 { | |
1680 for (int width = 0; width < dstWidth; width++) | |
1681 { | |
1682 a6s = (double)width / (double)dstWidth * (double)srcWidth; | |
1683 widthRatio = bankersRounding(a6s); | |
1684 a6t = (double)(width + 1) / (double)dstWidth * (double)srcWidth; | |
1685 widthRatioPlusOne = bankersRounding(a6t); | |
1686 | |
1687 v17 = (double)height / (double)dstHeight * (double)srcHeight; | |
1688 heightRatio = bankersRounding(v17); | |
1689 v18 = (double)(height + 1) / (double)dstHeight * (double)srcHeight; | |
1690 heightRatioPlusOne = bankersRounding(v18); | |
1691 | |
1692 v251 = 0; | |
1693 v19 = (heightRatioPlusOne - heightRatio) * (widthRatioPlusOne - widthRatio); | |
1694 v252 = 0; | |
1695 a6b = 0; | |
1696 v240 = 0i64; | |
1697 | |
1698 v175 = (unsigned short*)((char *)pSrc + field_0_bits * (widthRatio + srcPitch * heightRatio)); | |
1699 for (int heightDiff = 0; heightDiff < heightRatioPlusOne - heightRatio; heightDiff++) | |
1700 { | |
1701 //int ratioDiff = widthRatioPlusOne - widthRatio; | |
1702 for (int ratioDiff = 0; ratioDiff < widthRatioPlusOne - widthRatio; ratioDiff++) | |
1703 { | |
1704 if (field0value == 32) | |
1705 v21 = _450FB1(((int*)v175)[ratioDiff]); | |
1706 else if (field0value == 16) | |
1707 v21 = _450FB1(((_WORD*)v175)[ratioDiff]); | |
1708 else if (field0value == 8) | |
1709 v21 = _450FB1(((unsigned __int8*)v175)[ratioDiff]); | |
1710 v240 += ((unsigned int)v21 >> 24); | |
1711 a6b += BYTE2(v21); | |
1712 v252 += BYTE1(v21); | |
1713 v251 += (unsigned __int8)v21; | |
1714 } | |
1715 if (field0value == 32) | |
1716 v175 += 2 * srcPitch; | |
1717 else if (field0value == 16) | |
1718 v175 += srcPitch; | |
1719 else if (field0value == 8) | |
1720 v175 = (unsigned short*)((char *)v175 + 2 * srcPitch); | |
1721 } | |
1722 | |
1723 v22 = (unsigned int)v240 / ((heightRatioPlusOne - heightRatio) * (widthRatioPlusOne - widthRatio)); | |
1724 if (v19) | |
1725 { | |
1726 a6b /= v19; | |
1727 v252 /= v19; | |
1728 v251 /= v19; | |
1729 } | |
1730 if (v22 != 255) | |
1731 v22 &= 0x7FFFFFFFu; | |
1732 v23 = _450F55(v251 | ((v252 | ((a6b | (v22 << 8)) << 8)) << 8)); | |
1733 *(_DWORD *)v193 = v23; //Invalid memory access | |
1734 v193 = (unsigned __int16 *)((char *)v193 + field_20_bits); | |
1735 } | |
1736 v193 = (unsigned __int16 *)((char *)v193 + field_20_bits * (dstPitch - dstWidth)); | |
1737 //++v231; | |
1738 result = height; | |
1739 } | |
1740 //while(v231 < dstHeight); | |
1741 return result; | |
1742 } | |
1743 | |
1744 | |
1745 //----- (00450DDE) -------------------------------------------------------- | |
1746 stru350 *stru350::_450DDE() | |
1747 { | |
1748 _450DF1(&stru_4E82A4, &stru_4E82A4); | |
1749 return this; | |
1750 } | |
1751 | |
1752 //----- (00450DF1) -------------------------------------------------------- | |
1753 bool stru350::_450DF1(const stru355 *p1, const stru355 *p2) | |
1754 { | |
1755 //stru350 *v3; // esi@1 | |
1756 //void *result; // eax@1 | |
1757 unsigned int v5; // ecx@2 | |
1758 int v6; // edi@2 | |
1759 int v7; // edx@2 | |
1760 unsigned int v8; // ecx@8 | |
1761 int v9; // edi@8 | |
1762 int v10; // edx@8 | |
1763 int v11; // ecx@12 | |
1764 int v12; // edi@12 | |
1765 unsigned int v13; // ecx@12 | |
1766 int v14; // edx@12 | |
1767 int v15; // ecx@16 | |
1768 unsigned int v16; // edx@16 | |
1769 int v17; // ecx@16 | |
1770 int v18; // edi@16 | |
1771 char v19; // zf@20 | |
1772 unsigned int v20; // ecx@21 | |
1773 int v21; // edi@21 | |
1774 int v22; // edx@21 | |
1775 unsigned int v23; // ecx@27 | |
1776 int v24; // edi@27 | |
1777 int v25; // edx@27 | |
1778 int v26; // ecx@31 | |
1779 int v27; // edi@31 | |
1780 unsigned int v28; // ecx@31 | |
1781 int v29; // edx@31 | |
1782 int v30; // ebx@35 | |
1783 int v31; // ecx@35 | |
1784 int v32; // edi@35 | |
1785 int v33; // edx@35 | |
1786 unsigned int i; // ecx@35 | |
1787 int v35; // ecx@39 | |
1788 unsigned int v36; // edx@39 | |
1789 int v37; // ecx@39 | |
1790 int v38; // ebx@39 | |
1791 | |
1792 //v3 = this; | |
1793 memcpy(&field_0, p1, sizeof(stru355)); | |
1794 memcpy(&field_20, p2, sizeof(stru355)); | |
1795 //result = memcpy(&v3->field_20, p2, 0x20u); | |
1796 //LOBYTE(result) = 1; | |
1797 if (field_0.field_4 & 1) | |
1798 { | |
1799 v5 = field_0.field_1C; | |
1800 v6 = 0; | |
1801 v7 = 0; | |
1802 while (!(v5 & 1)) | |
1803 { | |
1804 ++v6; | |
1805 v5 >>= 1; | |
1806 } | |
1807 do | |
1808 { | |
1809 v5 >>= 1; | |
1810 ++v7; | |
1811 } while (v5 & 1); | |
1812 field_40 = 32 - v7 - v6; | |
1813 } | |
1814 else | |
1815 { | |
1816 field_40 = 0; | |
1817 } | |
1818 v8 = field_0.field_10; | |
1819 v9 = 0; | |
1820 v10 = 0; | |
1821 while (!(v8 & 1)) | |
1822 { | |
1823 ++v9; | |
1824 v8 >>= 1; | |
1825 } | |
1826 do | |
1827 { | |
1828 v8 >>= 1; | |
1829 ++v10; | |
1830 } while (v8 & 1); | |
1831 v11 = 24 - v10 - v9; | |
1832 v12 = 0; | |
1833 field_48 = v11; | |
1834 v13 = field_0.field_14; | |
1835 v14 = 0; | |
1836 while (!(v13 & 1)) | |
1837 { | |
1838 ++v12; | |
1839 v13 >>= 1; | |
1840 } | |
1841 do | |
1842 { | |
1843 v13 >>= 1; | |
1844 ++v14; | |
1845 } while (v13 & 1); | |
1846 v15 = 16 - v14; | |
1847 v16 = field_0.field_18; | |
1848 field_50 = v15 - v12; | |
1849 v17 = 0; | |
1850 v18 = 0; | |
1851 while (!(v16 & 1)) | |
1852 { | |
1853 ++v17; | |
1854 v16 >>= 1; | |
1855 } | |
1856 do | |
1857 { | |
1858 v16 >>= 1; | |
1859 ++v18; | |
1860 } while (v16 & 1); | |
1861 v19 = (field_20.field_4 & 1) == 0; | |
1862 field_58 = v17 - v18 + 8; | |
1863 if (v19) | |
1864 { | |
1865 field_44 = 0; | |
1866 } | |
1867 else | |
1868 { | |
1869 v20 = field_20.field_1C; | |
1870 v21 = 0; | |
1871 v22 = 0; | |
1872 while (!(v20 & 1)) | |
1873 { | |
1874 ++v21; | |
1875 v20 >>= 1; | |
1876 } | |
1877 do | |
1878 { | |
1879 v20 >>= 1; | |
1880 ++v22; | |
1881 } while (v20 & 1); | |
1882 field_44 = 32 - v22 - v21; | |
1883 } | |
1884 v23 = field_20.field_10; | |
1885 v24 = 0; | |
1886 v25 = 0; | |
1887 while (!(v23 & 1)) | |
1888 { | |
1889 ++v24; | |
1890 v23 >>= 1; | |
1891 } | |
1892 do | |
1893 { | |
1894 v23 >>= 1; | |
1895 ++v25; | |
1896 } while (v23 & 1); | |
1897 v26 = 24 - v25 - v24; | |
1898 v27 = 0; | |
1899 field_4C = v26; | |
1900 v28 = field_20.field_14; | |
1901 v29 = 0; | |
1902 while (!(v28 & 1)) | |
1903 { | |
1904 ++v27; | |
1905 v28 >>= 1; | |
1906 } | |
1907 do | |
1908 { | |
1909 v28 >>= 1; | |
1910 ++v29; | |
1911 } while (v28 & 1); | |
1912 v30 = 0; | |
1913 v31 = 16 - v29 - v27; | |
1914 v32 = field_20.field_18; | |
1915 field_54 = v31; | |
1916 v33 = 0; | |
1917 for (i = v32; !(i & 1); i >>= 1) | |
1918 ++v30; | |
1919 do | |
1920 { | |
1921 i >>= 1; | |
1922 ++v33; | |
1923 } while (i & 1); | |
1924 v35 = 32 - v33; | |
1925 v36 = v32; | |
1926 field_5C = v35 - v30; | |
1927 v37 = 0; | |
1928 v38 = 0; | |
1929 while (!(v36 & 1)) | |
1930 { | |
1931 ++v37; | |
1932 v36 >>= 1; | |
1933 } | |
1934 do | |
1935 { | |
1936 v36 >>= 1; | |
1937 ++v38; | |
1938 } while (v36 & 1); | |
1939 field_5C = v37 - v38 + 8; | |
1940 return true; | |
1941 } | |
1942 | |
1943 //----- (00450F55) -------------------------------------------------------- | |
1944 unsigned int stru350::_450F55(int a2) | |
1945 { | |
1946 int v2 = a2 & stru_4E82A4.field_1C; | |
1947 if (field_20.field_4 & 1) | |
1948 v2 = (unsigned int)v2 >> this->field_44; | |
1949 return v2 & field_20.field_1C | | |
1950 field_20.field_10 & ((a2 & (unsigned int)stru_4E82A4.field_10) >> field_4C) | | |
1951 field_20.field_14 & ((a2 & (unsigned int)stru_4E82A4.field_14) >> field_54) | | |
1952 field_20.field_18 & ((a2 & (unsigned int)stru_4E82A4.field_18) >> field_5C); | |
1953 } | |
1954 | |
1955 //----- (00450FB1) -------------------------------------------------------- | |
1956 int stru350::_450FB1(int a2) | |
1957 { | |
1958 int v2 = 0; | |
1959 int v4 = field_0.field_4 & 1; | |
1960 if (v4) | |
1961 v2 = a2 & field_0.field_1C; | |
1962 if (v4) | |
1963 v2 <<= field_40; | |
1964 return v2 | ((a2 & field_0.field_10) << field_48) | ((a2 & field_0.field_14) << field_50) | ((a2 & field_0.field_18) << field_58); | |
1965 } | |
1966 | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1967 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1968 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1969 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1970 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1971 typedef bool (*ImageFormatConverter)(unsigned int num_pixels, const void *src, void *dst); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1972 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1973 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1974 unsigned __int32 R5G6B5_to_A8R8G8B8(unsigned __int16 color16, unsigned char alpha) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1975 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1976 unsigned __int32 c = color16; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1977 unsigned int b = (c & 31) * 8; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1978 unsigned int g = ((c >> 5) & 63) * 4; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1979 unsigned int r = ((c >> 11) & 31) * 8; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1980 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1981 return ((unsigned int)alpha << 24) | (r << 16) | (g << 8) | b; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1982 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1983 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1984 unsigned __int16 A8R8G8B8_to_R5G6B5(unsigned __int32 c) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1985 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1986 unsigned __int32 b = ((c & 0xFF) / 8) & 31; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1987 unsigned __int32 g = (((c >> 8) & 0xFF) / 4) & 63; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1988 unsigned __int32 r = (((c >> 16) & 0xFF) / 8) & 31; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1989 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1990 return (unsigned __int16)( |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1991 (r << 11) | (g << 5) | b |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1992 ); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1993 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1994 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1995 bool Image_A8R8G8B8_to_R5G6B5(unsigned int num_pixels, const void *src_pixels, void *dst_pixels) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1996 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1997 auto src = (unsigned __int32 *)src_pixels; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1998 auto dst = (unsigned __int16 *)dst_pixels; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
1999 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2000 for (unsigned int i = 0; i < num_pixels; ++i) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2001 dst[i] = A8R8G8B8_to_R5G6B5(src[i]); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2002 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2003 return true; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2004 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2005 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2006 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2007 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2008 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2009 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2010 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2011 struct Alpha_LOD_Loader : public ImageLoader |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2012 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2013 inline Alpha_LOD_Loader(LODFile_IconsBitmaps *lod, const wchar_t *name) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2014 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2015 wcscpy(this->name, name); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2016 this->lod = lod; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2017 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2018 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2019 virtual bool Load(unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2020 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2021 wchar_t name[1024]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2022 LODFile_IconsBitmaps *lod; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2023 }; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2024 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2025 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2026 bool Alpha_LOD_Loader::Load(unsigned int *out_width, unsigned int *out_height, void **out_pixels, IMAGE_FORMAT *out_format) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2027 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2028 *out_width = 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2029 *out_height = 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2030 *out_pixels = nullptr; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2031 *out_format = IMAGE_INVALID_FORMAT; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2032 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2033 char namea[1024]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2034 sprintf(namea, "%S", name); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2035 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2036 auto tex = lod->GetTexture(lod->LoadTexture(namea, TEXTURE_16BIT_PALETTE)); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2037 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2038 if (tex->pPalette16 && tex->paletted_pixels) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2039 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2040 auto palette = tex->pPalette16; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2041 auto paletted_pixels = tex->paletted_pixels; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2042 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2043 auto width = tex->uTextureWidth; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2044 auto height = tex->uTextureHeight; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2045 auto pixels = new unsigned __int32[width * height]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2046 if (pixels) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2047 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2048 for (unsigned int y = 0; y < height; ++y) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2049 for (unsigned int x = 0; x < width; ++x) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2050 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2051 auto index = paletted_pixels[y * width + x]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2052 auto pixel = tex->pPalette16[index]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2053 if (index == 0) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2054 pixels[y * width + x] = 0x00000000; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2055 else |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2056 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2057 extern unsigned __int32 Color32(unsigned __int16 color16); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2058 pixels[y * width + x] = R5G6B5_to_A8R8G8B8(pixel, 255); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2059 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2060 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2061 *out_width = width; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2062 *out_height = height; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2063 *out_pixels = pixels; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2064 *out_format = IMAGE_FORMAT_A8R8G8B8; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2065 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2066 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2067 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2068 return *out_pixels != nullptr; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2069 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2070 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2071 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2072 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2073 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2074 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2075 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2076 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2077 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2078 struct ColorKey_LOD_Loader : public ImageLoader |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2079 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2080 inline ColorKey_LOD_Loader(LODFile_IconsBitmaps *lod, const wchar_t *name, unsigned __int16 colorkey) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2081 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2082 wcscpy(this->name, name); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2083 this->colorkey = colorkey; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2084 this->lod = lod; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2085 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2086 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2087 virtual bool Load(unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2088 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2089 wchar_t name[1024]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2090 unsigned __int16 colorkey; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2091 LODFile_IconsBitmaps *lod; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2092 }; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2093 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2094 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2095 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2096 bool ColorKey_LOD_Loader::Load(unsigned int *out_width, unsigned int *out_height, void **out_pixels, IMAGE_FORMAT *out_format) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2097 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2098 *out_width = 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2099 *out_height = 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2100 *out_pixels = nullptr; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2101 *out_format = IMAGE_INVALID_FORMAT; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2102 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2103 char namea[1024]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2104 sprintf(namea, "%S", name); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2105 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2106 auto tex = lod->GetTexture(lod->LoadTexture(namea, TEXTURE_16BIT_PALETTE)); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2107 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2108 if (tex->pPalette16 && tex->paletted_pixels) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2109 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2110 auto palette = tex->pPalette16; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2111 auto paletted_pixels = tex->paletted_pixels; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2112 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2113 auto width = tex->uTextureWidth; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2114 auto height = tex->uTextureHeight; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2115 auto pixels = new unsigned __int32[width * height]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2116 if (pixels) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2117 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2118 for (unsigned int y = 0; y < height; ++y) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2119 for (unsigned int x = 0; x < width; ++x) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2120 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2121 auto pixel = tex->pPalette16[paletted_pixels[y * width + x]]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2122 if (pixel == colorkey) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2123 pixels[y * width + x] = 0x00000000; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2124 else |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2125 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2126 extern unsigned __int32 Color32(unsigned __int16 color16); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2127 pixels[y * width + x] = R5G6B5_to_A8R8G8B8(pixel, 255); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2128 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2129 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2130 *out_width = width; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2131 *out_height = height; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2132 *out_pixels = pixels; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2133 *out_format = IMAGE_FORMAT_A8R8G8B8; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2134 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2135 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2136 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2137 return *out_pixels != nullptr; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2138 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2139 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2140 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2141 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2142 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2143 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2144 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2145 struct PCX_Loader : public ImageLoader |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2146 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2147 bool DecodePCX(const unsigned char *pcx_data, unsigned __int16 *pOutPixels, unsigned int *width, unsigned int *height); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2148 }; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2149 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2150 bool PCX_Loader::DecodePCX(const unsigned char *pcx_data, unsigned __int16 *pOutPixels, unsigned int *width, unsigned int *height) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2151 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2152 // signed int result; // eax@2 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2153 unsigned char test_byte; // edx@3 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2154 unsigned int read_offset; // ebx@37 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2155 unsigned int row_position; // edi@40 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2156 unsigned char value; // cl@63 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2157 char count; // [sp+50h] [bp-Ch]@43 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2158 unsigned short current_line; // [sp+54h] [bp-8h]@38 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2159 unsigned short *dec_position; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2160 unsigned short *temp_dec_position; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2161 PCXHeader1 psx_head1; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2162 PCXHeader2 psx_head2; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2163 // short int width, height; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2164 BYTE color_map[48]; // Colormap for 16-color images |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2165 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2166 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2167 memcpy(&psx_head1, pcx_data, 16); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2168 memcpy(&color_map, pcx_data + 16, 48); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2169 memcpy(&psx_head2, pcx_data + 64, 6); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2170 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2171 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2172 if (psx_head1.bpp != 8) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2173 return 3; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2174 *width = (short int)(psx_head1.right - psx_head1.left + 1); // word @ 000014 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2175 *height = (short int)(psx_head1.bottom - psx_head1.up + 1); // word @ 000016 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2176 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2177 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2178 unsigned int uNumPixels = *width * *height; // dword @ 000010 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2179 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2180 memset(pOutPixels, 0, uNumPixels * sizeof(__int16)); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2181 short i = 1; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2182 while ((1 << i) != *width) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2183 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2184 ++i; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2185 if (i >= 15) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2186 break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2187 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2188 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2189 auto field_18 = i; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2190 short i_ = 1; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2191 while ((1 << i_) != *height) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2192 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2193 ++i_; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2194 if (i_ >= 15) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2195 break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2196 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2197 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2198 auto field_1A = i_; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2199 short field_1C = 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2200 switch (field_18) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2201 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2202 case 2: field_1C = 3; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2203 case 3: field_1C = 7; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2204 case 4: field_1C = 15; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2205 case 5: field_1C = 31; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2206 case 6: field_1C = 63; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2207 case 7: field_1C = 127; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2208 case 8: field_1C = 255; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2209 case 9: field_1C = 511; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2210 case 10: field_1C = 1023; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2211 case 11: field_1C = 2047; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2212 case 12: field_1C = 4095; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2213 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2214 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2215 short field_1E = 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2216 switch (field_1A) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2217 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2218 case 2: field_1E = 3; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2219 case 3: field_1E = 7; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2220 case 4: field_1E = 15; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2221 case 5: field_1E = 31; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2222 case 6: field_1E = 63; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2223 case 7: field_1E = 127; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2224 case 8: field_1E = 255; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2225 case 9: field_1E = 511; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2226 case 10: field_1E = 1023; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2227 case 11: field_1E = 2047; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2228 case 12: field_1E = 4095; break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2229 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2230 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2231 unsigned int r_mask = 0xF800; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2232 unsigned int num_r_bits = 5; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2233 unsigned int g_mask = 0x07E0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2234 unsigned int num_g_bits = 6; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2235 unsigned int b_mask = 0x001F; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2236 unsigned int num_b_bits = 5; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2237 //Ïðè ñîõðàíåíèè èçîáðàæåíèÿ ïîäðÿä èäóùèå ïèêñåëè îäèíàêîâîãî öâåòà îáúåäèíÿþòñÿ è âìåñòî óêàçàíèÿ öâåòà äëÿ êàæäîãî ïèêñåëÿ |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2238 //óêàçûâàåòñÿ öâåò ãðóïïû ïèêñåëåé è èõ êîëè÷åñòâî. |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2239 read_offset = 128; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2240 if (psx_head2.planes != 3) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2241 return 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2242 current_line = 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2243 if (height > 0) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2244 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2245 dec_position = pOutPixels; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2246 do |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2247 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2248 temp_dec_position = dec_position; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2249 row_position = 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2250 //decode red line |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2251 if (psx_head2.pitch) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2252 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2253 do |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2254 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2255 test_byte = pcx_data[read_offset]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2256 ++read_offset; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2257 if ((test_byte & 0xC0) == 0xC0)//èìååòñÿ ëè îáúåäèíåíèå |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2258 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2259 value = pcx_data[read_offset]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2260 ++read_offset; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2261 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2262 if ((test_byte & 0x3F) > 0) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2263 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2264 count = test_byte & 0x3F;//êîëè÷åñòâî îäèíàêîâûõ ïèêñåëåé |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2265 do |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2266 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2267 ++row_position; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2268 //*temp_dec_position =0xFF000000; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2269 //*temp_dec_position|=(unsigned long)value<<16; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2270 *temp_dec_position |= r_mask & ((unsigned __int8)value << (num_g_bits + num_r_bits + num_b_bits - 8)); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2271 temp_dec_position++; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2272 if (row_position == psx_head2.pitch) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2273 break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2274 } while (count-- != 1); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2275 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2276 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2277 else |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2278 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2279 ++row_position; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2280 //*temp_dec_position =0xFF000000; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2281 //*temp_dec_position|= (unsigned long)test_byte<<16; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2282 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2283 *temp_dec_position |= r_mask & ((unsigned __int8)test_byte << (num_g_bits + num_r_bits + num_b_bits - 8)); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2284 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2285 temp_dec_position++; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2286 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2287 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2288 } while (row_position < psx_head2.pitch); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2289 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2290 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2291 temp_dec_position = dec_position; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2292 row_position = 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2293 //decode green line |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2294 while (row_position < psx_head2.pitch) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2295 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2296 test_byte = *(pcx_data + read_offset); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2297 ++read_offset; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2298 if ((test_byte & 0xC0) == 0xC0) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2299 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2300 value = *(pcx_data + read_offset); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2301 ++read_offset; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2302 if ((test_byte & 0x3F) > 0) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2303 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2304 count = test_byte & 0x3F; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2305 do |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2306 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2307 //*temp_dec_position|= (unsigned int)value<<8; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2308 //temp_dec_position++; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2309 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2310 *temp_dec_position |= g_mask & (unsigned __int16)((unsigned __int8)value << (num_g_bits + num_b_bits - 8)); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2311 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2312 temp_dec_position++; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2313 ++row_position; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2314 if (row_position == psx_head2.pitch) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2315 break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2316 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2317 } while (count-- != 1); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2318 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2319 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2320 else |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2321 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2322 //*temp_dec_position |=(unsigned int) test_byte<<8; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2323 //temp_dec_position++; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2324 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2325 *temp_dec_position |= g_mask & (unsigned __int16)((unsigned __int8)test_byte << (num_g_bits + num_b_bits - 8)); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2326 temp_dec_position++; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2327 ++row_position; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2328 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2329 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2330 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2331 temp_dec_position = dec_position; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2332 row_position = 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2333 //decode blue line |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2334 while (row_position < psx_head2.pitch) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2335 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2336 test_byte = *(pcx_data + read_offset); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2337 read_offset++; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2338 if ((test_byte & 0xC0) == 0xC0) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2339 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2340 value = *(pcx_data + read_offset); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2341 ++read_offset; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2342 if ((test_byte & 0x3F) > 0) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2343 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2344 count = test_byte & 0x3F; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2345 do |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2346 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2347 //*temp_dec_position|= value; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2348 //temp_dec_position++; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2349 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2350 *temp_dec_position |= value >> (8 - num_b_bits); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2351 temp_dec_position++; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2352 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2353 ++row_position; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2354 if (row_position == psx_head2.pitch) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2355 break; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2356 } while (count-- != 1); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2357 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2358 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2359 else |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2360 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2361 //*temp_dec_position|= test_byte; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2362 //temp_dec_position++; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2363 *temp_dec_position |= test_byte >> (8 - num_b_bits); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2364 temp_dec_position++; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2365 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2366 ++row_position; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2367 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2368 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2369 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2370 ++current_line; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2371 dec_position += *width; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2372 } while (current_line < *height); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2373 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2374 return true; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2375 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2376 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2377 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2378 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2379 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2380 struct PCX_File_Loader : public PCX_Loader |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2381 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2382 inline PCX_File_Loader(LODFile_IconsBitmaps *lod, const wchar_t *filename) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2383 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2384 wcscpy(this->name, filename); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2385 this->lod = lod; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2386 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2387 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2388 virtual bool Load(unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2389 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2390 wchar_t name[1024]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2391 LODFile_IconsBitmaps *lod; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2392 }; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2393 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2394 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2395 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2396 bool PCX_File_Loader::Load(unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2397 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2398 FILE *file; // eax@1 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2399 char color_map[48]; // [sp+Ch] [bp-98h]@7 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2400 PCXHeader1 header1; // [sp+84h] [bp-20h]@7 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2401 PCXHeader2 header2; // [sp+94h] [bp-10h]@7 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2402 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2403 *width = 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2404 *height = 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2405 *pixels = nullptr; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2406 *format = IMAGE_INVALID_FORMAT; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2407 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2408 char namea[1024]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2409 sprintf(namea, "%S", name); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2410 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2411 file = fopen(namea, "rb"); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2412 if (!file) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2413 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2414 Log::Warning(L"Unable to load %s", name); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2415 return false; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2416 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2417 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2418 fseek(file, 0, SEEK_END); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2419 int filesize = ftell(file); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2420 fseek(file, 0, SEEK_SET); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2421 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2422 auto file_image = new unsigned char[filesize]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2423 fread(file_image, 1, filesize, file); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2424 fclose(file); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2425 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2426 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2427 memcpy(&header1, file_image, 0x10u); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2428 memcpy(color_map, file_image + 16, 0x30u); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2429 memcpy(&header2, file_image + 64, 6); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2430 if (header1.bpp != 8) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2431 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2432 delete[] file_image; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2433 return false; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2434 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2435 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2436 *width = header1.right - header1.left + 1; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2437 *height = header1.bottom - header1.up + 1; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2438 unsigned int num_pixels = *width * *height; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2439 *pixels = new unsigned short[num_pixels + 2]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2440 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2441 if (pixels) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2442 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2443 if (!this->DecodePCX(file_image, (unsigned __int16 *)*pixels, width, height)) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2444 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2445 delete[] * pixels; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2446 *pixels = nullptr; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2447 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2448 else |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2449 *format = IMAGE_FORMAT_R5G6B5; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2450 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2451 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2452 delete[] file_image; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2453 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2454 return *pixels != nullptr; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2455 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2456 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2457 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2458 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2459 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2460 struct PCX_LOD_Loader : public PCX_Loader |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2461 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2462 inline PCX_LOD_Loader(LOD::File *lod, const wchar_t *name) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2463 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2464 wcscpy(this->name, name); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2465 this->lod = lod; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2466 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2467 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2468 virtual bool Load(unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2469 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2470 wchar_t name[1024]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2471 LOD::File *lod; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2472 }; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2473 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2474 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2475 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2476 bool PCX_LOD_Loader::Load(unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2477 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2478 FILE *file; // eax@1 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2479 void *v6; // ebx@5 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2480 char color_map[48]; // [sp+Ch] [bp-98h]@7 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2481 Texture DstBuf; // [sp+3Ch] [bp-68h]@1 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2482 PCXHeader1 header1; // [sp+84h] [bp-20h]@7 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2483 PCXHeader2 header2; // [sp+94h] [bp-10h]@7 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2484 size_t Count; // [sp+A0h] [bp-4h]@4 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2485 unsigned char *Str1a; // [sp+ACh] [bp+8h]@5 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2486 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2487 *width = 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2488 *height = 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2489 *pixels = nullptr; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2490 *format = IMAGE_INVALID_FORMAT; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2491 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2492 char namea[1024]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2493 sprintf(namea, "%S", name); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2494 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2495 file = lod->FindContainer(namea, 0); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2496 if (!file) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2497 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2498 Log::Warning(L"Unable to load %s", name); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2499 return false; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2500 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2501 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2502 fread(&DstBuf, 1, 0x30u, file); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2503 Count = DstBuf.uTextureSize; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2504 if (DstBuf.uDecompressedSize) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2505 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2506 Str1a = (unsigned char *)malloc(DstBuf.uDecompressedSize); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2507 v6 = malloc(DstBuf.uTextureSize); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2508 fread(v6, 1, Count, file); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2509 zlib::MemUnzip(Str1a, &DstBuf.uDecompressedSize, v6, DstBuf.uTextureSize); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2510 DstBuf.uTextureSize = DstBuf.uDecompressedSize; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2511 free(v6); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2512 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2513 else |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2514 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2515 Str1a = (unsigned char *)malloc(DstBuf.uTextureSize); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2516 fread(Str1a, 1, Count, file); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2517 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2518 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2519 memcpy(&header1, Str1a, 0x10u); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2520 memcpy(color_map, Str1a + 16, 0x30u); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2521 memcpy(&header2, Str1a + 64, 6); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2522 if (header1.bpp != 8) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2523 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2524 free(Str1a); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2525 return false; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2526 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2527 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2528 *width = header1.right - header1.left + 1; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2529 *height = header1.bottom - header1.up + 1; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2530 unsigned int num_pixels = *width * *height; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2531 *pixels = new unsigned short[num_pixels + 2]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2532 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2533 if (pixels) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2534 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2535 if (!this->DecodePCX(Str1a, (unsigned __int16 *)*pixels, width, height)) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2536 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2537 delete[] *pixels; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2538 *pixels = nullptr; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2539 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2540 else |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2541 *format = IMAGE_FORMAT_R5G6B5; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2542 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2543 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2544 free(Str1a); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2545 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2546 return *pixels != nullptr; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2547 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2548 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2549 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2550 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2551 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2552 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2553 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2554 bool Image::PCX_From_IconsLOD(const wchar_t *name) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2555 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2556 loader = new PCX_LOD_Loader(pIcons_LOD, name); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2557 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2558 if (!lazy_initialization) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2559 this->LoadImageData(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2560 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2561 return true; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2562 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2563 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2564 bool Image::PCX_From_NewLOD(const wchar_t *name) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2565 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2566 loader = new PCX_LOD_Loader(pNew_LOD, name); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2567 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2568 if (!lazy_initialization) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2569 this->LoadImageData(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2570 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2571 return true; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2572 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2573 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2574 bool Image::PCX_From_File(const wchar_t *filename) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2575 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2576 loader = new PCX_File_Loader(pIcons_LOD, filename); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2577 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2578 if (!lazy_initialization) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2579 this->LoadImageData(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2580 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2581 return true; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2582 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2583 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2584 bool Image::Alpha_From_LOD(const wchar_t *name) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2585 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2586 loader = new Alpha_LOD_Loader(pIcons_LOD, name); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2587 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2588 if (!lazy_initialization) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2589 this->LoadImageData(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2590 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2591 return true; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2592 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2593 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2594 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2595 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2596 bool Image::ColorKey_From_LOD(const wchar_t *name, unsigned __int16 colorkey) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2597 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2598 loader = new ColorKey_LOD_Loader(pIcons_LOD, name, colorkey); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2599 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2600 if (!lazy_initialization) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2601 this->LoadImageData(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2602 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2603 return true; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2604 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2605 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2606 bool Image::LoadImageData() |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2607 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2608 if (!initialized) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2609 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2610 void *pixels; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2611 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2612 initialized = loader->Load(&width, &height, &pixels, &native_format); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2613 if (initialized && native_format != IMAGE_INVALID_FORMAT) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2614 this->pixels[native_format] = pixels; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2615 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2616 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2617 return initialized; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2618 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2619 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2620 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2621 unsigned int Image::GetWidth() |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2622 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2623 if (!initialized) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2624 LoadImageData(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2625 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2626 if (initialized) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2627 return width; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2628 return 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2629 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2630 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2631 unsigned int Image::GetHeight() |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2632 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2633 if (!initialized) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2634 LoadImageData(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2635 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2636 if (initialized) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2637 return height; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2638 return 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2639 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2640 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2641 const void *Image::GetPixels(IMAGE_FORMAT format) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2642 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2643 if (!initialized) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2644 LoadImageData(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2645 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2646 if (initialized) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2647 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2648 if (pixels[format]) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2649 return pixels[format]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2650 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2651 auto native_pixels = pixels[native_format]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2652 if (native_pixels) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2653 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2654 static ImageFormatConverter converters[IMAGE_NUM_FORMATS][IMAGE_NUM_FORMATS] = |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2655 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2656 // IMAGE_FORMAT_R5G6B5 -> |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2657 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2658 nullptr, // IMAGE_FORMAT_R5G6B5 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2659 nullptr, // IMAGE_FORMAT_A1R5G5B5 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2660 nullptr // IMAGE_FORMAT_A8R8G8B8 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2661 }, |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2662 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2663 // IMAGE_FORMAT_A1R5G5B5 -> |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2664 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2665 nullptr, // IMAGE_FORMAT_R5G6B5 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2666 nullptr, // IMAGE_FORMAT_A1R5G5B5 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2667 nullptr // IMAGE_FORMAT_A8R8G8B8 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2668 }, |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2669 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2670 // IMAGE_FORMAT_A8R8G8B8 -> |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2671 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2672 Image_A8R8G8B8_to_R5G6B5, // IMAGE_FORMAT_R5G6B5 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2673 nullptr, // IMAGE_FORMAT_A1R5G5B5 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2674 nullptr // IMAGE_FORMAT_A8R8G8B8 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2675 }, |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2676 }; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2677 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2678 ImageFormatConverter cvt = converters[native_format][format]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2679 if (cvt) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2680 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2681 unsigned int num_pixels = width * height; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2682 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2683 void *cvt_pixels = new unsigned char[num_pixels * IMAGE_FORMAT_BytesPerPixel(format)]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2684 if (cvt(width * height, native_pixels, cvt_pixels)) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2685 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2686 return pixels[format] = cvt_pixels; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2687 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2688 else |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2689 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2690 delete[] cvt_pixels; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2691 cvt_pixels = nullptr; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2692 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2693 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2694 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2695 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2696 return nullptr; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2697 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2698 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2699 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2700 bool Image::Release() |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2701 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2702 if (initialized) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2703 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2704 if (loader) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2705 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2706 delete loader; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2707 loader = nullptr; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2708 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2709 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2710 for (unsigned int i = 0; i < IMAGE_NUM_FORMATS; ++i) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2711 if (pixels[i]) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2712 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2713 delete[] pixels[i]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2714 pixels[i] = nullptr; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2715 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2716 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2717 native_format = IMAGE_INVALID_FORMAT; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2718 width = 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2719 height = 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2720 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2721 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2722 delete this; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2723 return true; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2724 } |