annotate Texture.cpp @ 844:d593ca75c366

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