annotate Texture.cpp @ 2486:1e70f8470638

simplified SpriteObject::Create
author Grumpy7
date Sun, 07 Sep 2014 01:36:04 +0200
parents b054ea5daf45
children 7b076fe64f23
rev   line source
2415
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2378
diff changeset
1 #define _CRTDBG_MAP_ALLOC
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2378
diff changeset
2 #include <stdlib.h>
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2378
diff changeset
3 #include <crtdbg.h>
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2378
diff changeset
4
2253
aff7a7b072b7 adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents: 2153
diff changeset
5 #define _CRT_SECURE_NO_WARNINGS
0
Ritor1
parents:
diff changeset
6 #include <stdlib.h>
Ritor1
parents:
diff changeset
7
Ritor1
parents:
diff changeset
8 #include "Texture.h"
Ritor1
parents:
diff changeset
9 #include "FrameTableInc.h"
Ritor1
parents:
diff changeset
10 #include "LOD.h"
Ritor1
parents:
diff changeset
11 #include "PaletteManager.h"
2336
d6887ee81068 header file include cleanup
Grumpy7
parents: 2335
diff changeset
12 #include "ErrorHandling.h"
2352
8a49cf25fb88 Moving zlib wrappers to separate headers
Grumpy7
parents: 2336
diff changeset
13 #include "ZlibWrapper.h"
0
Ritor1
parents:
diff changeset
14
Ritor1
parents:
diff changeset
15 #include "mm7_data.h"
Ritor1
parents:
diff changeset
16
2463
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
17 #include "OurMath.h"
0
Ritor1
parents:
diff changeset
18
Ritor1
parents:
diff changeset
19
Ritor1
parents:
diff changeset
20
Ritor1
parents:
diff changeset
21
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 struct TextureFrameTable *pTextureFrameTable;
Ritor1
parents:
diff changeset
27
Ritor1
parents:
diff changeset
28
Ritor1
parents:
diff changeset
29
Ritor1
parents:
diff changeset
30
Ritor1
parents:
diff changeset
31
1207
96a81634669e arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents: 1205
diff changeset
32 std::array<Texture *, 2> pTexture_LloydBeacons;
0
Ritor1
parents:
diff changeset
33 Texture *pTexture_50635C;
1453
dfc9484ed94c GetDayPart and Journal_Draw
Ritor1
parents: 1409
diff changeset
34 Texture *pTex_book_button8_off;
dfc9484ed94c GetDayPart and Journal_Draw
Ritor1
parents: 1409
diff changeset
35 Texture *pTex_book_button8_on;
dfc9484ed94c GetDayPart and Journal_Draw
Ritor1
parents: 1409
diff changeset
36 Texture *pTex_book_button7_off;
dfc9484ed94c GetDayPart and Journal_Draw
Ritor1
parents: 1409
diff changeset
37 Texture *pTex_book_button7_on;
dfc9484ed94c GetDayPart and Journal_Draw
Ritor1
parents: 1409
diff changeset
38 Texture *pTex_book_button6_off;
dfc9484ed94c GetDayPart and Journal_Draw
Ritor1
parents: 1409
diff changeset
39 Texture *pTex_book_button6_on;
dfc9484ed94c GetDayPart and Journal_Draw
Ritor1
parents: 1409
diff changeset
40 Texture *pTex_book_button5_off;
dfc9484ed94c GetDayPart and Journal_Draw
Ritor1
parents: 1409
diff changeset
41 Texture *pTex_book_button5_on;
dfc9484ed94c GetDayPart and Journal_Draw
Ritor1
parents: 1409
diff changeset
42 Texture *pTex_book_button4_off;
dfc9484ed94c GetDayPart and Journal_Draw
Ritor1
parents: 1409
diff changeset
43 Texture *pTex_book_button4_on;
dfc9484ed94c GetDayPart and Journal_Draw
Ritor1
parents: 1409
diff changeset
44 Texture *pTex_book_button3_off;
dfc9484ed94c GetDayPart and Journal_Draw
Ritor1
parents: 1409
diff changeset
45 Texture *pTex_book_button3_on;
dfc9484ed94c GetDayPart and Journal_Draw
Ritor1
parents: 1409
diff changeset
46 Texture *pTex_book_button2_off;
dfc9484ed94c GetDayPart and Journal_Draw
Ritor1
parents: 1409
diff changeset
47 Texture *pTex_book_button1_off;
dfc9484ed94c GetDayPart and Journal_Draw
Ritor1
parents: 1409
diff changeset
48 Texture *pTex_book_button2_on;
dfc9484ed94c GetDayPart and Journal_Draw
Ritor1
parents: 1409
diff changeset
49 Texture *pTex_book_button1_on;
1207
96a81634669e arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents: 1205
diff changeset
50 std::array<Texture *, 6> pTexture_TownPortalIcons; // [0]Harmonale, [1]Pierpont, [2]Nighon, [3]Evenmorn Island, [4]Celestia, [5]The Pit
1402
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1306
diff changeset
51 std::array<Texture *, 12> SBPageCSpellsTextureList;
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1306
diff changeset
52 std::array<Texture *, 12> SBPageSSpellsTextureList;
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1306
diff changeset
53 Texture *pSBQuickSpellBtnTextr;
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1306
diff changeset
54 Texture *pSpellBookClickCloseBtnTextr;
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1306
diff changeset
55 Texture *pSBClickQuickSpellBtnTextr;
a519a6a412d0 CloseSpellBook and close SpellBookPage
Ritor1
parents: 1306
diff changeset
56 Texture *pSpellBookCloseBtnTextr;
1207
96a81634669e arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents: 1205
diff changeset
57 std::array<std::array<Texture *, 2>, 9> pTextures_tabs;
0
Ritor1
parents:
diff changeset
58 Texture *pTexture_mapbordr; // idb
Ritor1
parents:
diff changeset
59 Texture *pTexture_pagemask; // idb
1207
96a81634669e arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents: 1205
diff changeset
60 std::array<Texture *, 9> pSpellBookPagesTextr;
688
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;
1207
96a81634669e arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents: 1205
diff changeset
114 std::array<Texture *, 22> pPlayerPortraits;
96a81634669e arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents: 1205
diff changeset
115 std::array<Texture *, 9> pTexture_IC_KNIGHT;
0
Ritor1
parents:
diff changeset
116 Texture *pTexture_MAKESKY;
Ritor1
parents:
diff changeset
117 Texture *pTexture_MAKETOP;
1207
96a81634669e arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents: 1205
diff changeset
118 std::array<Texture *, 20> pTextures_arrowr;
96a81634669e arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents: 1205
diff changeset
119 std::array<Texture *, 20> pTextures_arrowl;
0
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;
1667
c586fa9e4cbb MainMenuUI_Credits_Loop() cleaning(continue)
Ritor1
parents: 1632
diff changeset
134 unsigned int uTextureID_ib_td4_A;
c586fa9e4cbb MainMenuUI_Credits_Loop() cleaning(continue)
Ritor1
parents: 1632
diff changeset
135 unsigned int uTextureID_ib_td3_A;
c586fa9e4cbb MainMenuUI_Credits_Loop() cleaning(continue)
Ritor1
parents: 1632
diff changeset
136 unsigned int uTextureID_ib_td2_A;
0
Ritor1
parents:
diff changeset
137 unsigned int uTextureID_ib_td1_A;
984
d982fffb8b96 CharacterUI_InventoryTab_Draw cleaned.
Nomad
parents: 973
diff changeset
138 int uTextureID_CharacterUI_InventoryBackground; // weak
0
Ritor1
parents:
diff changeset
139 int uTextureID_50795C; // weak
Ritor1
parents:
diff changeset
140
Ritor1
parents:
diff changeset
141
319
5a66be213cff Actor::Die
Nomad
parents: 135
diff changeset
142 unsigned int uTextureID_Btn_GameSettings;
0
Ritor1
parents:
diff changeset
143
Ritor1
parents:
diff changeset
144
319
5a66be213cff Actor::Die
Nomad
parents: 135
diff changeset
145 unsigned int uTextureID_Btn_Rest;
5a66be213cff Actor::Die
Nomad
parents: 135
diff changeset
146 unsigned int uTextureID_Btn_CastSpell;
5a66be213cff Actor::Die
Nomad
parents: 135
diff changeset
147 unsigned int uTextureID_Btn_ZoomIn;
5a66be213cff Actor::Die
Nomad
parents: 135
diff changeset
148 unsigned int uTextureID_Btn_ZoomOut;
0
Ritor1
parents:
diff changeset
149 unsigned int uTextureID_FONTPAL;
319
5a66be213cff Actor::Die
Nomad
parents: 135
diff changeset
150 unsigned int uTextureID_Btn_NPCRight;
5a66be213cff Actor::Die
Nomad
parents: 135
diff changeset
151 unsigned int uTextureID_Btn_NPCLeft;
1207
96a81634669e arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents: 1205
diff changeset
152 std::array<unsigned int, 8> pTextureIDs_pMapDirs;
0
Ritor1
parents:
diff changeset
153
Ritor1
parents:
diff changeset
154
Ritor1
parents:
diff changeset
155 unsigned int uTextureID_BarRed;
Ritor1
parents:
diff changeset
156 unsigned int uTextureID_BarYellow;
Ritor1
parents:
diff changeset
157 unsigned int uTextureID_BarGreen;
Ritor1
parents:
diff changeset
158 unsigned int uTextureID_BarBlue;
Ritor1
parents:
diff changeset
159
Ritor1
parents:
diff changeset
160
Ritor1
parents:
diff changeset
161 unsigned int uTextureID_right_panel; // weak
Ritor1
parents:
diff changeset
162
Ritor1
parents:
diff changeset
163
Ritor1
parents:
diff changeset
164 RGBTexture *pTexture_StatusBar = new RGBTexture;
Ritor1
parents:
diff changeset
165 RGBTexture *pTexture_LeftFrame = new RGBTexture;
Ritor1
parents:
diff changeset
166 RGBTexture *pTexture_TopFrame = new RGBTexture;
Ritor1
parents:
diff changeset
167 RGBTexture *pTexture_BottomFrame = new RGBTexture;
Ritor1
parents:
diff changeset
168 RGBTexture *pTexture_RightFrame = new RGBTexture;
Ritor1
parents:
diff changeset
169
Ritor1
parents:
diff changeset
170
910
Ritor1
parents: 712
diff changeset
171 unsigned int uTextureID_right_panel_loop;
0
Ritor1
parents:
diff changeset
172
Ritor1
parents:
diff changeset
173
Ritor1
parents:
diff changeset
174 Texture *pTexture_Leather;
Ritor1
parents:
diff changeset
175 Texture *pTexture_RestUI_CurrentSkyFrame; // idb
Ritor1
parents:
diff changeset
176 Texture *pTexture_RestUI_CurrentHourglassFrame; // idb
Ritor1
parents:
diff changeset
177
Ritor1
parents:
diff changeset
178
1207
96a81634669e arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents: 1205
diff changeset
179 std::array<unsigned int, 5> uTextureID_Optkb;
0
Ritor1
parents:
diff changeset
180
1676
483cc7f0d86c GameMenuUI_DrawKeyBindings() and GameMenuUI_DrawVideoOptions() cleared
Ritor1
parents: 1667
diff changeset
181 unsigned int optvid_base_texture_id;
1677
a699ecd7aeb3 PlayerCreationUI_Draw()
Ritor1
parents: 1676
diff changeset
182 unsigned int bloodsplats_texture_id;
a699ecd7aeb3 PlayerCreationUI_Draw()
Ritor1
parents: 1676
diff changeset
183 unsigned int us_colored_lights_texture_id;
a699ecd7aeb3 PlayerCreationUI_Draw()
Ritor1
parents: 1676
diff changeset
184 unsigned int tinting_texture_id;
0
Ritor1
parents:
diff changeset
185 unsigned int uTextureID_507C20; // weak
Ritor1
parents:
diff changeset
186 unsigned int uTextureID_507C24; // weak
1207
96a81634669e arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents: 1205
diff changeset
187 std::array<unsigned int, 10> pTextureIDs_GammaPositions;
1677
a699ecd7aeb3 PlayerCreationUI_Draw()
Ritor1
parents: 1676
diff changeset
188 unsigned int not_available_bloodsplats_texture_id;
a699ecd7aeb3 PlayerCreationUI_Draw()
Ritor1
parents: 1676
diff changeset
189 unsigned int not_available_us_colored_lights_texture_id;
a699ecd7aeb3 PlayerCreationUI_Draw()
Ritor1
parents: 1676
diff changeset
190 unsigned int not_available_tinting_texture_id;
0
Ritor1
parents:
diff changeset
191
Ritor1
parents:
diff changeset
192
910
Ritor1
parents: 712
diff changeset
193 unsigned int uTextureID_detaliz_close_button; // weak
0
Ritor1
parents:
diff changeset
194 unsigned int uTextureID_MAGNIF_B; // weak
Ritor1
parents:
diff changeset
195 unsigned int uTextureID_BACKDOLL; // weak
Ritor1
parents:
diff changeset
196 unsigned int uTextureID_BACKHAND; // weak
Ritor1
parents:
diff changeset
197
1262
0aeac0b9ca30 included header cleanup
Grumpy7
parents: 1207
diff changeset
198 stru355 stru_4E82A4 = {0x20, 0x41, 0, 0x20, 0xFF0000, 0xFF00, 0xFF, 0xFF000000};
0aeac0b9ca30 included header cleanup
Grumpy7
parents: 1207
diff changeset
199 stru355 stru_4EFCBC = {0x20, 0x41, 0, 0x10, 0x7C00, 0x3E0, 0x1F, 0x8000};
0
Ritor1
parents:
diff changeset
200
Ritor1
parents:
diff changeset
201 Texture pTex_F7CE30;
Ritor1
parents:
diff changeset
202
Ritor1
parents:
diff changeset
203
Ritor1
parents:
diff changeset
204 RGBTexture stru_5773C4; // idb
Ritor1
parents:
diff changeset
205
Ritor1
parents:
diff changeset
206
Ritor1
parents:
diff changeset
207
Ritor1
parents:
diff changeset
208
Ritor1
parents:
diff changeset
209
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 /* 245 */
Ritor1
parents:
diff changeset
217 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
218 struct PCXHeader1
Ritor1
parents:
diff changeset
219 {
Ritor1
parents:
diff changeset
220 char magic;
Ritor1
parents:
diff changeset
221 char version;
Ritor1
parents:
diff changeset
222 char encoding;
Ritor1
parents:
diff changeset
223 char bpp;
Ritor1
parents:
diff changeset
224 __int16 left;
Ritor1
parents:
diff changeset
225 __int16 up;
Ritor1
parents:
diff changeset
226 __int16 right;
Ritor1
parents:
diff changeset
227 __int16 bottom;
Ritor1
parents:
diff changeset
228 __int16 hres;
Ritor1
parents:
diff changeset
229 __int16 vres;
Ritor1
parents:
diff changeset
230 };
Ritor1
parents:
diff changeset
231 #pragma pack(pop)
Ritor1
parents:
diff changeset
232
Ritor1
parents:
diff changeset
233 /* 246 */
Ritor1
parents:
diff changeset
234 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
235 struct PCXHeader2
Ritor1
parents:
diff changeset
236 {
Ritor1
parents:
diff changeset
237 char reserved;
Ritor1
parents:
diff changeset
238 char planes;
Ritor1
parents:
diff changeset
239 __int16 pitch;
Ritor1
parents:
diff changeset
240 __int16 palette_info;
Ritor1
parents:
diff changeset
241 };
Ritor1
parents:
diff changeset
242 #pragma pack(pop)
Ritor1
parents:
diff changeset
243
Ritor1
parents:
diff changeset
244
Ritor1
parents:
diff changeset
245
Ritor1
parents:
diff changeset
246
Ritor1
parents:
diff changeset
247
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 //----- (0044E054) --------------------------------------------------------
Ritor1
parents:
diff changeset
253 void TextureFrameTable::ToFile()
Ritor1
parents:
diff changeset
254 {
Ritor1
parents:
diff changeset
255 TextureFrameTable *v1; // esi@1
Ritor1
parents:
diff changeset
256 FILE *v2; // eax@1
Ritor1
parents:
diff changeset
257 FILE *v3; // edi@1
Ritor1
parents:
diff changeset
258
Ritor1
parents:
diff changeset
259 v1 = this;
Ritor1
parents:
diff changeset
260 v2 = fopen("data\\dtft.bin", "wb");
Ritor1
parents:
diff changeset
261 v3 = v2;
Ritor1
parents:
diff changeset
262 if ( !v2 )
1545
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1477
diff changeset
263 Error("Unable to save dtft.bin!");
0
Ritor1
parents:
diff changeset
264 fwrite(v1, 4u, 1u, v2);
711
a5e587c8e30e some cleaning
Gloval
parents: 688
diff changeset
265 fwrite(v1->pTextures, 0x14u, v1->sNumTextures, v3);
0
Ritor1
parents:
diff changeset
266 fclose(v3);
Ritor1
parents:
diff changeset
267 }
Ritor1
parents:
diff changeset
268
Ritor1
parents:
diff changeset
269 //----- (0044E0A0) --------------------------------------------------------
1477
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1453
diff changeset
270 void TextureFrameTable::FromFile(void *data_mm6, void *data_mm7, void *data_mm8)
0
Ritor1
parents:
diff changeset
271 {
1477
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1453
diff changeset
272 uint num_mm6_frames = data_mm6 ? *(int *)data_mm6 : 0,
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1453
diff changeset
273 num_mm7_frames = data_mm7 ? *(int *)data_mm7 : 0,
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1453
diff changeset
274 num_mm8_frames = data_mm8 ? *(int *)data_mm8 : 0;
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1453
diff changeset
275
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1453
diff changeset
276 sNumTextures = num_mm6_frames + num_mm7_frames + num_mm8_frames;
1545
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1477
diff changeset
277 Assert(sNumTextures);
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1477
diff changeset
278 Assert(!num_mm8_frames);
1477
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1453
diff changeset
279
1583
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1545
diff changeset
280 pTextures = (TextureFrame *)malloc(sNumTextures * sizeof(TextureFrame));
1477
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1453
diff changeset
281
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1453
diff changeset
282 memcpy(pTextures, (char *)data_mm7 + 4, num_mm7_frames * sizeof(TextureFrame));
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1453
diff changeset
283 memcpy(pTextures + num_mm7_frames, (char *)data_mm6 + 4, num_mm6_frames * sizeof(TextureFrame));
7ef4b64f6329 * LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents: 1453
diff changeset
284 memcpy(pTextures + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 4, num_mm8_frames * sizeof(TextureFrame));
0
Ritor1
parents:
diff changeset
285 }
Ritor1
parents:
diff changeset
286
Ritor1
parents:
diff changeset
287 //----- (0044E0ED) --------------------------------------------------------
711
a5e587c8e30e some cleaning
Gloval
parents: 688
diff changeset
288 void TextureFrameTable::LoadAnimationSequenceAndPalettes( signed int uIconID )
2378
48dbf99c0f7f spawn_light_elemental cleaned
Ritor1
parents: 2369
diff changeset
289 {
48dbf99c0f7f spawn_light_elemental cleaned
Ritor1
parents: 2369
diff changeset
290 //TextureFrameTable *v3; // ebx@1
0
Ritor1
parents:
diff changeset
291 unsigned int i; // edi@3
Ritor1
parents:
diff changeset
292
2378
48dbf99c0f7f spawn_light_elemental cleaned
Ritor1
parents: 2369
diff changeset
293 //v3 = this;
711
a5e587c8e30e some cleaning
Gloval
parents: 688
diff changeset
294 if ( (uIconID <= this->sNumTextures) && uIconID >= 0 )
0
Ritor1
parents:
diff changeset
295 {
Ritor1
parents:
diff changeset
296 for ( i = uIconID; ; ++i )
Ritor1
parents:
diff changeset
297 {
2378
48dbf99c0f7f spawn_light_elemental cleaned
Ritor1
parents: 2369
diff changeset
298 this->pTextures[i].uTextureID = pBitmaps_LOD->LoadTexture(this->pTextures[i].pTextureName, TEXTURE_DEFAULT);
973
ec7568e13b24 Minor code cleaning.
Nomad
parents: 948
diff changeset
299
2378
48dbf99c0f7f spawn_light_elemental cleaned
Ritor1
parents: 2369
diff changeset
300 if (this->pTextures[i].uTextureID != -1)
48dbf99c0f7f spawn_light_elemental cleaned
Ritor1
parents: 2369
diff changeset
301 pBitmaps_LOD->pTextures[this->pTextures[i].uTextureID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[this->pTextures[i].uTextureID].palette_id1);
711
a5e587c8e30e some cleaning
Gloval
parents: 688
diff changeset
302 //result = (unsigned int)v3->pTextures;
a5e587c8e30e some cleaning
Gloval
parents: 688
diff changeset
303 //if ( !(*(char *)(result + i * 20 + 18) & 1) )
2378
48dbf99c0f7f spawn_light_elemental cleaned
Ritor1
parents: 2369
diff changeset
304 if( this->pTextures[i].uFlags & 1)
0
Ritor1
parents:
diff changeset
305 break;
Ritor1
parents:
diff changeset
306 }
Ritor1
parents:
diff changeset
307 }
711
a5e587c8e30e some cleaning
Gloval
parents: 688
diff changeset
308 return;
0
Ritor1
parents:
diff changeset
309 }
Ritor1
parents:
diff changeset
310
Ritor1
parents:
diff changeset
311 //----- (0044E163) --------------------------------------------------------
Ritor1
parents:
diff changeset
312 unsigned int TextureFrameTable::FindTextureByName(const char *Str2)
Ritor1
parents:
diff changeset
313 {
Ritor1
parents:
diff changeset
314 TextureFrameTable *v2; // esi@1
Ritor1
parents:
diff changeset
315 int v3; // ebx@1
Ritor1
parents:
diff changeset
316 unsigned int uID; // edi@1
Ritor1
parents:
diff changeset
317 unsigned int result; // eax@4
Ritor1
parents:
diff changeset
318
Ritor1
parents:
diff changeset
319 v2 = this;
Ritor1
parents:
diff changeset
320 v3 = 0;
Ritor1
parents:
diff changeset
321 uID = 0;
711
a5e587c8e30e some cleaning
Gloval
parents: 688
diff changeset
322 if ( (signed int)this->sNumTextures <= 0 )
0
Ritor1
parents:
diff changeset
323 {
Ritor1
parents:
diff changeset
324 LABEL_4:
Ritor1
parents:
diff changeset
325 result = -1;
Ritor1
parents:
diff changeset
326 }
Ritor1
parents:
diff changeset
327 else
Ritor1
parents:
diff changeset
328 {
1104
5d5c78088274 strcmpi to stricmp conversion
Grumpy7
parents: 1093
diff changeset
329 while ( _stricmp(v2->pTextures[v3].pTextureName, Str2) )
0
Ritor1
parents:
diff changeset
330 {
Ritor1
parents:
diff changeset
331 ++uID;
Ritor1
parents:
diff changeset
332 ++v3;
711
a5e587c8e30e some cleaning
Gloval
parents: 688
diff changeset
333 if ( (signed int)uID >= (signed int)v2->sNumTextures )
0
Ritor1
parents:
diff changeset
334 goto LABEL_4;
Ritor1
parents:
diff changeset
335 }
Ritor1
parents:
diff changeset
336 result = uID;
Ritor1
parents:
diff changeset
337 }
Ritor1
parents:
diff changeset
338 return result;
Ritor1
parents:
diff changeset
339 }
Ritor1
parents:
diff changeset
340
Ritor1
parents:
diff changeset
341 //----- (0044E19A) --------------------------------------------------------
1632
69ab7593e7af Out of bounds (id 65536) texture fixed.
Nomad
parents: 1583
diff changeset
342 int TextureFrameTable::GetFrameTexture(int uFrameID, signed int a3)
0
Ritor1
parents:
diff changeset
343 {
Ritor1
parents:
diff changeset
344 int v3; // esi@1
Ritor1
parents:
diff changeset
345 TextureFrame *v4; // edi@1
Ritor1
parents:
diff changeset
346 TextureFrame *v5; // ecx@1
Ritor1
parents:
diff changeset
347 __int16 v6; // dx@2
Ritor1
parents:
diff changeset
348 int v7; // edx@3
Ritor1
parents:
diff changeset
349 char *i; // eax@3
Ritor1
parents:
diff changeset
350 int v9; // ecx@5
Ritor1
parents:
diff changeset
351 unsigned int result; // eax@6
Ritor1
parents:
diff changeset
352
Ritor1
parents:
diff changeset
353 v3 = uFrameID;
Ritor1
parents:
diff changeset
354 v4 = this->pTextures;
Ritor1
parents:
diff changeset
355 v5 = &v4[uFrameID];
Ritor1
parents:
diff changeset
356 if ( v5->uFlags & 1 && (v6 = v5->uAnimLength) != 0 )
Ritor1
parents:
diff changeset
357 {
Ritor1
parents:
diff changeset
358 v7 = (a3 >> 3) % v6;
Ritor1
parents:
diff changeset
359 for ( i = (char *)&v5->uAnimTime; ; i += 20 )
Ritor1
parents:
diff changeset
360 {
Ritor1
parents:
diff changeset
361 v9 = *(short *)i;
Ritor1
parents:
diff changeset
362 if ( v7 <= v9 )
Ritor1
parents:
diff changeset
363 break;
Ritor1
parents:
diff changeset
364 v7 -= v9;
Ritor1
parents:
diff changeset
365 ++v3;
Ritor1
parents:
diff changeset
366 }
Ritor1
parents:
diff changeset
367 result = v4[v3].uTextureID;
Ritor1
parents:
diff changeset
368 }
Ritor1
parents:
diff changeset
369 else
Ritor1
parents:
diff changeset
370 {
Ritor1
parents:
diff changeset
371 result = v5->uTextureID;
Ritor1
parents:
diff changeset
372 }
Ritor1
parents:
diff changeset
373 return result;
Ritor1
parents:
diff changeset
374 }
Ritor1
parents:
diff changeset
375
Ritor1
parents:
diff changeset
376
Ritor1
parents:
diff changeset
377
Ritor1
parents:
diff changeset
378
Ritor1
parents:
diff changeset
379
Ritor1
parents:
diff changeset
380
Ritor1
parents:
diff changeset
381 //----- (0040F806) --------------------------------------------------------
Ritor1
parents:
diff changeset
382 void *Texture::UnzipPalette()
Ritor1
parents:
diff changeset
383 {
Ritor1
parents:
diff changeset
384 Texture *v1; // esi@1
1093
c59ac5ea63f5 * stru154::GetFacePlane mistake fixed
zipi
parents: 984
diff changeset
385
0
Ritor1
parents:
diff changeset
386 void *v2; // edi@1
Ritor1
parents:
diff changeset
387 Texture *pSource; // [sp+0h] [bp-4h]@1
Ritor1
parents:
diff changeset
388
Ritor1
parents:
diff changeset
389 pSource = this;
Ritor1
parents:
diff changeset
390 v1 = this;
Ritor1
parents:
diff changeset
391 v2 = malloc(this->uDecompressedSize);
710
735dab8d3c9a Town portal screen + misc gui const replacements
Nomad
parents: 688
diff changeset
392 zlib::MemUnzip(v2, (unsigned int *)&pSource, v1->pLevelOfDetail0_prolly_alpha_mask, v1->uTextureSize);
0
Ritor1
parents:
diff changeset
393 return v2;
Ritor1
parents:
diff changeset
394 }
Ritor1
parents:
diff changeset
395
Ritor1
parents:
diff changeset
396 //----- (0040F77C) --------------------------------------------------------
Ritor1
parents:
diff changeset
397 void Texture::Release()
Ritor1
parents:
diff changeset
398 {
Ritor1
parents:
diff changeset
399 if (this)
Ritor1
parents:
diff changeset
400 {
Ritor1
parents:
diff changeset
401 pName[0] = 0;
Ritor1
parents:
diff changeset
402
Ritor1
parents:
diff changeset
403 if (pBits & 0x0400)
Ritor1
parents:
diff changeset
404 {
1093
c59ac5ea63f5 * stru154::GetFacePlane mistake fixed
zipi
parents: 984
diff changeset
405 __debugbreak();
c59ac5ea63f5 * stru154::GetFacePlane mistake fixed
zipi
parents: 984
diff changeset
406 }
c59ac5ea63f5 * stru154::GetFacePlane mistake fixed
zipi
parents: 984
diff changeset
407
1583
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1545
diff changeset
408 free(pLevelOfDetail0_prolly_alpha_mask);
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1545
diff changeset
409 free(pPalette16);
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1545
diff changeset
410 free(pPalette24);
1093
c59ac5ea63f5 * stru154::GetFacePlane mistake fixed
zipi
parents: 984
diff changeset
411
0
Ritor1
parents:
diff changeset
412
710
735dab8d3c9a Town portal screen + misc gui const replacements
Nomad
parents: 688
diff changeset
413 pLevelOfDetail0_prolly_alpha_mask = nullptr;
0
Ritor1
parents:
diff changeset
414 pLevelOfDetail1 = nullptr;
Ritor1
parents:
diff changeset
415 pLevelOfDetail2 = nullptr;
Ritor1
parents:
diff changeset
416 pLevelOfDetail3 = nullptr;
Ritor1
parents:
diff changeset
417
Ritor1
parents:
diff changeset
418 pPalette16 = nullptr;
Ritor1
parents:
diff changeset
419 pPalette24 = nullptr;
Ritor1
parents:
diff changeset
420
Ritor1
parents:
diff changeset
421 uSizeOfMaxLevelOfDetail = 0;
Ritor1
parents:
diff changeset
422 uTextureSize = 0;
Ritor1
parents:
diff changeset
423 uTextureHeight = 0;
Ritor1
parents:
diff changeset
424 uTextureWidth = 0;
Ritor1
parents:
diff changeset
425 uHeightLn2 = 0;
Ritor1
parents:
diff changeset
426 uWidthLn2 = 0;
Ritor1
parents:
diff changeset
427 palette_id1 = 0;
Ritor1
parents:
diff changeset
428 palette_id2 = 0;
Ritor1
parents:
diff changeset
429 pBits &= 0xFFFF0000;
Ritor1
parents:
diff changeset
430 }
Ritor1
parents:
diff changeset
431 }
Ritor1
parents:
diff changeset
432
Ritor1
parents:
diff changeset
433 //----- (0040F5F5) --------------------------------------------------------
Ritor1
parents:
diff changeset
434 int RGBTexture::Reload(const char *pContainer)
Ritor1
parents:
diff changeset
435 {
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
436 //RGBTexture *v2; // esi@1
0
Ritor1
parents:
diff changeset
437 FILE *v3; // eax@3
Ritor1
parents:
diff changeset
438 FILE *v4; // edi@3
Ritor1
parents:
diff changeset
439 void *v5; // ebx@7
Ritor1
parents:
diff changeset
440 signed int result; // eax@11
Ritor1
parents:
diff changeset
441 unsigned int v7; // ecx@12
Ritor1
parents:
diff changeset
442 unsigned __int16 *v8; // ST20_4@14
Ritor1
parents:
diff changeset
443 int v9; // eax@14
Ritor1
parents:
diff changeset
444 char color_map[48]; // [sp+8h] [bp-98h]@9
Ritor1
parents:
diff changeset
445 Texture DstBuf; // [sp+38h] [bp-68h]@1
Ritor1
parents:
diff changeset
446 PCXHeader1 header1; // [sp+80h] [bp-20h]@9
Ritor1
parents:
diff changeset
447 PCXHeader2 header2; // [sp+90h] [bp-10h]@9
Ritor1
parents:
diff changeset
448 FILE *File; // [sp+98h] [bp-8h]@3
Ritor1
parents:
diff changeset
449 size_t Count; // [sp+9Ch] [bp-4h]@6
Ritor1
parents:
diff changeset
450 void *uSourceLena; // [sp+A8h] [bp+8h]@7
Ritor1
parents:
diff changeset
451
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
452 // v2 = this;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
453 if ( !this->pPixels )
0
Ritor1
parents:
diff changeset
454 return 2;
Ritor1
parents:
diff changeset
455 v3 = pIcons_LOD->FindContainer(pContainer, 0);
Ritor1
parents:
diff changeset
456 v4 = v3;
Ritor1
parents:
diff changeset
457 File = v3;
Ritor1
parents:
diff changeset
458 if ( !v3 )
1545
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1477
diff changeset
459 Error("Unable to load %s", pContainer);
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1477
diff changeset
460
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
461 fread(&DstBuf, 1, 0x30, v3);
0
Ritor1
parents:
diff changeset
462 Count = DstBuf.uTextureSize;
Ritor1
parents:
diff changeset
463 if ( DstBuf.uDecompressedSize )
Ritor1
parents:
diff changeset
464 {
Ritor1
parents:
diff changeset
465 v5 = malloc(DstBuf.uDecompressedSize);
1583
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1545
diff changeset
466 uSourceLena = malloc(DstBuf.uTextureSize);
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
467 fread(uSourceLena, 1, Count, File);
0
Ritor1
parents:
diff changeset
468 zlib::MemUnzip(v5, &DstBuf.uDecompressedSize, uSourceLena, DstBuf.uTextureSize);
Ritor1
parents:
diff changeset
469 DstBuf.uTextureSize = DstBuf.uDecompressedSize;
1583
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1545
diff changeset
470 free(uSourceLena);
0
Ritor1
parents:
diff changeset
471 }
Ritor1
parents:
diff changeset
472 else
Ritor1
parents:
diff changeset
473 {
Ritor1
parents:
diff changeset
474 v5 = malloc(DstBuf.uTextureSize);
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
475 fread(v5, 1, Count, v4);
0
Ritor1
parents:
diff changeset
476 }
Ritor1
parents:
diff changeset
477 memcpy(&header1, v5, 0x10u);
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
478 memcpy(color_map, (char *)v5 + 16, 0x30);
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
479 memcpy(&header2, (char *)v5 + 64, 6);
0
Ritor1
parents:
diff changeset
480 if ( header1.bpp != 8 )
Ritor1
parents:
diff changeset
481 return 3;
Ritor1
parents:
diff changeset
482 v7 = (signed __int16)(header1.right - header1.left + 1);
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
483 if ( (signed int)(v7 * (signed __int16)(header1.bottom - header1.up + 1)) <= (signed int)this->uNumPixels )
0
Ritor1
parents:
diff changeset
484 {
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
485 this->uWidth = header1.right - header1.left + 1;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
486 v8 = this->pPixels;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
487 v9 = v7 * this->uHeight;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
488 this->uNumPixels = v9;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
489 this->uHeight = v9;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
490 this->DecodePCX((char *)v5, v8, v7);
0
Ritor1
parents:
diff changeset
491 free(v5);
Ritor1
parents:
diff changeset
492 result = 0;
Ritor1
parents:
diff changeset
493 }
Ritor1
parents:
diff changeset
494 else
Ritor1
parents:
diff changeset
495 {
Ritor1
parents:
diff changeset
496 result = -1;
Ritor1
parents:
diff changeset
497 }
Ritor1
parents:
diff changeset
498 return result;
Ritor1
parents:
diff changeset
499 }
Ritor1
parents:
diff changeset
500
Ritor1
parents:
diff changeset
501 //----- (0040F5BE) --------------------------------------------------------
Ritor1
parents:
diff changeset
502 Texture::Texture()
Ritor1
parents:
diff changeset
503 {
Ritor1
parents:
diff changeset
504 pName[0] = 0;
Ritor1
parents:
diff changeset
505 uSizeOfMaxLevelOfDetail = 0;
Ritor1
parents:
diff changeset
506 uTextureSize = 0;
Ritor1
parents:
diff changeset
507 uTextureHeight = 0;
Ritor1
parents:
diff changeset
508 uTextureWidth = 0;
Ritor1
parents:
diff changeset
509 uHeightLn2 = 0;
Ritor1
parents:
diff changeset
510 uWidthLn2 = 0;
Ritor1
parents:
diff changeset
511 palette_id1 = 0;
Ritor1
parents:
diff changeset
512 palette_id2 = 0;
2369
bddcaf5d5db2 removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents: 2353
diff changeset
513 pLevelOfDetail0_prolly_alpha_mask = nullptr;
bddcaf5d5db2 removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents: 2353
diff changeset
514 pLevelOfDetail3 = nullptr;
bddcaf5d5db2 removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents: 2353
diff changeset
515 pLevelOfDetail2 = nullptr;
bddcaf5d5db2 removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents: 2353
diff changeset
516 pLevelOfDetail1 = nullptr;
bddcaf5d5db2 removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents: 2353
diff changeset
517 pPalette16 = nullptr;
bddcaf5d5db2 removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents: 2353
diff changeset
518 pPalette24 = nullptr;
0
Ritor1
parents:
diff changeset
519 }
Ritor1
parents:
diff changeset
520
Ritor1
parents:
diff changeset
521 //----- (0040F414) --------------------------------------------------------
Ritor1
parents:
diff changeset
522 int RGBTexture::Load(const char *pContainer, int mode)
Ritor1
parents:
diff changeset
523 {
2278
0cd17b0d36c2 MMT_MainMenu
Ritor1
parents: 2253
diff changeset
524 FILE *file; // eax@1
0
Ritor1
parents:
diff changeset
525 void *v6; // ebx@5
Ritor1
parents:
diff changeset
526 char color_map[48]; // [sp+Ch] [bp-98h]@7
Ritor1
parents:
diff changeset
527 Texture DstBuf; // [sp+3Ch] [bp-68h]@1
Ritor1
parents:
diff changeset
528 PCXHeader1 header1; // [sp+84h] [bp-20h]@7
Ritor1
parents:
diff changeset
529 PCXHeader2 header2; // [sp+94h] [bp-10h]@7
Ritor1
parents:
diff changeset
530 size_t Count; // [sp+A0h] [bp-4h]@4
Ritor1
parents:
diff changeset
531 char *Str1a; // [sp+ACh] [bp+8h]@5
Ritor1
parents:
diff changeset
532
2278
0cd17b0d36c2 MMT_MainMenu
Ritor1
parents: 2253
diff changeset
533 file = pIcons_LOD->FindContainer(pContainer, 0);
0cd17b0d36c2 MMT_MainMenu
Ritor1
parents: 2253
diff changeset
534 if ( !file )
2279
a01d3cf9ff83 mm7 game sound
Ritor1
parents: 2278
diff changeset
535 Error("Unable to load %s", pContainer);
1545
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1477
diff changeset
536
2278
0cd17b0d36c2 MMT_MainMenu
Ritor1
parents: 2253
diff changeset
537 fread(&DstBuf, 1, 0x30u, file);
0
Ritor1
parents:
diff changeset
538 Count = DstBuf.uTextureSize;
Ritor1
parents:
diff changeset
539 if ( DstBuf.uDecompressedSize )
Ritor1
parents:
diff changeset
540 {
Ritor1
parents:
diff changeset
541 Str1a = (char *)malloc(DstBuf.uDecompressedSize);
1583
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1545
diff changeset
542 v6 = malloc(DstBuf.uTextureSize);
2278
0cd17b0d36c2 MMT_MainMenu
Ritor1
parents: 2253
diff changeset
543 fread(v6, 1, Count, file);
0
Ritor1
parents:
diff changeset
544 zlib::MemUnzip(Str1a, &DstBuf.uDecompressedSize, v6, DstBuf.uTextureSize);
Ritor1
parents:
diff changeset
545 DstBuf.uTextureSize = DstBuf.uDecompressedSize;
1583
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1545
diff changeset
546 free(v6);
0
Ritor1
parents:
diff changeset
547 }
Ritor1
parents:
diff changeset
548 else
Ritor1
parents:
diff changeset
549 {
Ritor1
parents:
diff changeset
550 Str1a = (char *)malloc(DstBuf.uTextureSize);
2278
0cd17b0d36c2 MMT_MainMenu
Ritor1
parents: 2253
diff changeset
551 fread(Str1a, 1, Count, file);
0
Ritor1
parents:
diff changeset
552 }
Ritor1
parents:
diff changeset
553 memcpy(&header1, Str1a, 0x10u);
Ritor1
parents:
diff changeset
554 memcpy(color_map, Str1a + 16, 0x30u);
1835
Ritor1
parents: 1677
diff changeset
555 memcpy(&header2, Str1a + 64, 6);
0
Ritor1
parents:
diff changeset
556 if ( header1.bpp != 8 )
Ritor1
parents:
diff changeset
557 return 3;
1835
Ritor1
parents: 1677
diff changeset
558 this->uWidth = header1.right - header1.left + 1;
Ritor1
parents: 1677
diff changeset
559 this->uHeight = header1.bottom - header1.up + 1;
Ritor1
parents: 1677
diff changeset
560 this->uNumPixels = (signed __int16)this->uWidth * (signed __int16)this->uHeight;
1846
Ritor1
parents: 1835
diff changeset
561 this->pPixels = (unsigned __int16 *)malloc(2 * this->uNumPixels + 4);
1835
Ritor1
parents: 1677
diff changeset
562 if ( this->pPixels )
0
Ritor1
parents:
diff changeset
563 {
Ritor1
parents:
diff changeset
564 if ( mode )
2369
bddcaf5d5db2 removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents: 2353
diff changeset
565 {
1835
Ritor1
parents: 1677
diff changeset
566 if ( mode != 2 )
Ritor1
parents: 1677
diff changeset
567 {
Ritor1
parents: 1677
diff changeset
568 if ( !this->pPixels )
Ritor1
parents: 1677
diff changeset
569 return 2;
Ritor1
parents: 1677
diff changeset
570 this->DecodePCX(Str1a, this->pPixels, this->uWidth);
Ritor1
parents: 1677
diff changeset
571 free(Str1a);
Ritor1
parents: 1677
diff changeset
572 return 0;
Ritor1
parents: 1677
diff changeset
573 }
Ritor1
parents: 1677
diff changeset
574 this->_allocation_flags |= 1;
Ritor1
parents: 1677
diff changeset
575 this->pPixels = (unsigned __int16 *)malloc(2 * this->uNumPixels + 4);
Ritor1
parents: 1677
diff changeset
576 if ( !this->pPixels )
Ritor1
parents: 1677
diff changeset
577 return 2;
Ritor1
parents: 1677
diff changeset
578 this->DecodePCX(Str1a, this->pPixels, this->uWidth);
Ritor1
parents: 1677
diff changeset
579 free(Str1a);
Ritor1
parents: 1677
diff changeset
580 return 0;
2369
bddcaf5d5db2 removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents: 2353
diff changeset
581 }
1835
Ritor1
parents: 1677
diff changeset
582 free(this->pPixels);
0
Ritor1
parents:
diff changeset
583 }
Ritor1
parents:
diff changeset
584 if ( !mode )
Ritor1
parents:
diff changeset
585 {
1835
Ritor1
parents: 1677
diff changeset
586 this->pPixels = (unsigned __int16 *)malloc(2 * this->uNumPixels + 4);
Ritor1
parents: 1677
diff changeset
587 if ( !this->pPixels )
Ritor1
parents: 1677
diff changeset
588 return 2;
Ritor1
parents: 1677
diff changeset
589 this->DecodePCX(Str1a, this->pPixels, this->uWidth);
Ritor1
parents: 1677
diff changeset
590 free(Str1a);
Ritor1
parents: 1677
diff changeset
591 return 0;
0
Ritor1
parents:
diff changeset
592 }
Ritor1
parents:
diff changeset
593 if ( mode != 2 )
1835
Ritor1
parents: 1677
diff changeset
594 {
Ritor1
parents: 1677
diff changeset
595 if ( !this->pPixels )
Ritor1
parents: 1677
diff changeset
596 return 2;
Ritor1
parents: 1677
diff changeset
597 this->DecodePCX(Str1a, this->pPixels, this->uWidth);
Ritor1
parents: 1677
diff changeset
598 free(Str1a);
Ritor1
parents: 1677
diff changeset
599 return 0;
Ritor1
parents: 1677
diff changeset
600 }
Ritor1
parents: 1677
diff changeset
601 this->_allocation_flags |= 1;
Ritor1
parents: 1677
diff changeset
602 this->pPixels = (unsigned __int16 *)malloc(2 * this->uNumPixels + 4);
Ritor1
parents: 1677
diff changeset
603 if ( !this->pPixels )
0
Ritor1
parents:
diff changeset
604 return 2;
1835
Ritor1
parents: 1677
diff changeset
605 this->DecodePCX(Str1a, this->pPixels, this->uWidth);
0
Ritor1
parents:
diff changeset
606 free(Str1a);
Ritor1
parents:
diff changeset
607 return 0;
Ritor1
parents:
diff changeset
608 }
Ritor1
parents:
diff changeset
609
Ritor1
parents:
diff changeset
610 //----- (0040F037) --------------------------------------------------------
Ritor1
parents:
diff changeset
611 signed int RGBTexture::DecodePCX(char *pPcx, unsigned __int16 *pOutPixels, unsigned int uNumPixels)
Ritor1
parents:
diff changeset
612 {
2334
ddb803517a48 unused local variables I commented
Ritor1
parents: 2279
diff changeset
613 // signed int result; // eax@2
0
Ritor1
parents:
diff changeset
614 unsigned char test_byte; // edx@3
Ritor1
parents:
diff changeset
615 unsigned int read_offset; // ebx@37
Ritor1
parents:
diff changeset
616 unsigned int row_position; // edi@40
Ritor1
parents:
diff changeset
617 unsigned char value; // cl@63
Ritor1
parents:
diff changeset
618 char count; // [sp+50h] [bp-Ch]@43
Ritor1
parents:
diff changeset
619 unsigned short current_line; // [sp+54h] [bp-8h]@38
Ritor1
parents:
diff changeset
620 unsigned short *dec_position;
Ritor1
parents:
diff changeset
621 unsigned short *temp_dec_position;
Ritor1
parents:
diff changeset
622 PCXHeader1 psx_head1;
Ritor1
parents:
diff changeset
623 PCXHeader2 psx_head2;
2334
ddb803517a48 unused local variables I commented
Ritor1
parents: 2279
diff changeset
624 // short int width, height;
0
Ritor1
parents:
diff changeset
625 BYTE color_map[48]; // Colormap for 16-color images
Ritor1
parents:
diff changeset
626
Ritor1
parents:
diff changeset
627
Ritor1
parents:
diff changeset
628 memcpy(&psx_head1, pPcx , 16);
Ritor1
parents:
diff changeset
629 memcpy(&color_map, pPcx + 16, 48);
Ritor1
parents:
diff changeset
630 memcpy(&psx_head2, pPcx + 64, 6);
Ritor1
parents:
diff changeset
631
Ritor1
parents:
diff changeset
632
Ritor1
parents:
diff changeset
633 if (psx_head1.bpp!=8)
Ritor1
parents:
diff changeset
634 return 3;
Ritor1
parents:
diff changeset
635 uWidth=(short int )(psx_head1.right-psx_head1.left+1); // word @ 000014
Ritor1
parents:
diff changeset
636 uHeight=(short int )(psx_head1.bottom-psx_head1.up+1); // word @ 000016
Ritor1
parents:
diff changeset
637
Ritor1
parents:
diff changeset
638
Ritor1
parents:
diff changeset
639 uNumPixels=uWidth*uHeight; // dword @ 000010
Ritor1
parents:
diff changeset
640
Ritor1
parents:
diff changeset
641 memset(pOutPixels, 0, uNumPixels * sizeof(__int16));
Ritor1
parents:
diff changeset
642 short i=1;
Ritor1
parents:
diff changeset
643 while ( (1<<i) !=uWidth)
Ritor1
parents:
diff changeset
644 {
Ritor1
parents:
diff changeset
645 ++i;
Ritor1
parents:
diff changeset
646 if (i >= 15)
Ritor1
parents:
diff changeset
647 break;
Ritor1
parents:
diff changeset
648 }
Ritor1
parents:
diff changeset
649 field_18=i;
Ritor1
parents:
diff changeset
650 short i_=1;
Ritor1
parents:
diff changeset
651 while ( (1<<i_) !=uHeight)
Ritor1
parents:
diff changeset
652 {
Ritor1
parents:
diff changeset
653 ++i_;
Ritor1
parents:
diff changeset
654 if (i_ >= 15)
Ritor1
parents:
diff changeset
655 break;
Ritor1
parents:
diff changeset
656 }
Ritor1
parents:
diff changeset
657 field_1A=i_;
Ritor1
parents:
diff changeset
658 switch (field_18)
Ritor1
parents:
diff changeset
659 {
Ritor1
parents:
diff changeset
660 case 2: field_1C = 3; break;
Ritor1
parents:
diff changeset
661 case 3: field_1C = 7; break;
Ritor1
parents:
diff changeset
662 case 4: field_1C = 15; break;
Ritor1
parents:
diff changeset
663 case 5: field_1C = 31; break;
Ritor1
parents:
diff changeset
664 case 6: field_1C = 63; break;
Ritor1
parents:
diff changeset
665 case 7: field_1C = 127; break;
Ritor1
parents:
diff changeset
666 case 8: field_1C = 255; break;
Ritor1
parents:
diff changeset
667 case 9: field_1C = 511; break;
Ritor1
parents:
diff changeset
668 case 10: field_1C = 1023; break;
Ritor1
parents:
diff changeset
669 case 11: field_1C = 2047; break;
Ritor1
parents:
diff changeset
670 case 12: field_1C = 4095; break;
Ritor1
parents:
diff changeset
671 }
Ritor1
parents:
diff changeset
672
Ritor1
parents:
diff changeset
673 switch (field_1A)
Ritor1
parents:
diff changeset
674 {
Ritor1
parents:
diff changeset
675 case 2: field_1E = 3; break;
Ritor1
parents:
diff changeset
676 case 3: field_1E = 7; break;
Ritor1
parents:
diff changeset
677 case 4: field_1E = 15; break;
Ritor1
parents:
diff changeset
678 case 5: field_1E = 31; break;
Ritor1
parents:
diff changeset
679 case 6: field_1E = 63; break;
Ritor1
parents:
diff changeset
680 case 7: field_1E = 127; break;
Ritor1
parents:
diff changeset
681 case 8: field_1E = 255; break;
Ritor1
parents:
diff changeset
682 case 9: field_1E = 511; break;
Ritor1
parents:
diff changeset
683 case 10: field_1E = 1023; break;
Ritor1
parents:
diff changeset
684 case 11: field_1E = 2047; break;
Ritor1
parents:
diff changeset
685 case 12: field_1E = 4095; break;
Ritor1
parents:
diff changeset
686 }
Ritor1
parents:
diff changeset
687
2069
259df09dfb50 32bits almost there
Nomad
parents: 1980
diff changeset
688 unsigned int r_mask = 0xF800;
259df09dfb50 32bits almost there
Nomad
parents: 1980
diff changeset
689 unsigned int num_r_bits = 5;
259df09dfb50 32bits almost there
Nomad
parents: 1980
diff changeset
690 unsigned int g_mask = 0x07E0;
259df09dfb50 32bits almost there
Nomad
parents: 1980
diff changeset
691 unsigned int num_g_bits = 6;
259df09dfb50 32bits almost there
Nomad
parents: 1980
diff changeset
692 unsigned int b_mask = 0x001F;
259df09dfb50 32bits almost there
Nomad
parents: 1980
diff changeset
693 unsigned int num_b_bits = 5;
2127
400f3db2e4e5 Screenshot continue
Ritor1
parents: 2069
diff changeset
694 //Ïðè ñîõðàíåíèè èçîáðàæåíèÿ ïîäðÿä èäóùèå ïèêñåëè îäèíàêîâîãî öâåòà îáúåäèíÿþòñÿ è âìåñòî óêàçàíèÿ öâåòà äëÿ êàæäîãî ïèêñåëÿ
400f3db2e4e5 Screenshot continue
Ritor1
parents: 2069
diff changeset
695 //óêàçûâàåòñÿ öâåò ãðóïïû ïèêñåëåé è èõ êîëè÷åñòâî.
0
Ritor1
parents:
diff changeset
696 read_offset = 128;
Ritor1
parents:
diff changeset
697 if (psx_head2.planes != 3)
Ritor1
parents:
diff changeset
698 return 0;
Ritor1
parents:
diff changeset
699 current_line = 0;
Ritor1
parents:
diff changeset
700 if ( uHeight > 0 )
Ritor1
parents:
diff changeset
701 {
Ritor1
parents:
diff changeset
702 dec_position = pOutPixels;
Ritor1
parents:
diff changeset
703 do
Ritor1
parents:
diff changeset
704 {
Ritor1
parents:
diff changeset
705 temp_dec_position = dec_position;
Ritor1
parents:
diff changeset
706 row_position = 0;
Ritor1
parents:
diff changeset
707 //decode red line
Ritor1
parents:
diff changeset
708 if (psx_head2.pitch)
Ritor1
parents:
diff changeset
709 {
Ritor1
parents:
diff changeset
710 do
Ritor1
parents:
diff changeset
711 {
Ritor1
parents:
diff changeset
712 test_byte = pPcx[read_offset];
Ritor1
parents:
diff changeset
713 ++read_offset;
2127
400f3db2e4e5 Screenshot continue
Ritor1
parents: 2069
diff changeset
714 if ((test_byte & 0xC0) == 0xC0)//èìååòñÿ ëè îáúåäèíåíèå
0
Ritor1
parents:
diff changeset
715 {
Ritor1
parents:
diff changeset
716 value = pPcx[read_offset];
Ritor1
parents:
diff changeset
717 ++read_offset;
Ritor1
parents:
diff changeset
718
Ritor1
parents:
diff changeset
719 if ((test_byte & 0x3F) > 0)
Ritor1
parents:
diff changeset
720 {
2127
400f3db2e4e5 Screenshot continue
Ritor1
parents: 2069
diff changeset
721 count = test_byte & 0x3F;//êîëè÷åñòâî îäèíàêîâûõ ïèêñåëåé
0
Ritor1
parents:
diff changeset
722 do
Ritor1
parents:
diff changeset
723 {
Ritor1
parents:
diff changeset
724 ++row_position;
Ritor1
parents:
diff changeset
725 //*temp_dec_position =0xFF000000;
2127
400f3db2e4e5 Screenshot continue
Ritor1
parents: 2069
diff changeset
726 //*temp_dec_position|=(unsigned long)value<<16;
2069
259df09dfb50 32bits almost there
Nomad
parents: 1980
diff changeset
727 *temp_dec_position |= r_mask & ((unsigned __int8)value << (num_g_bits + num_r_bits + num_b_bits - 8));
2127
400f3db2e4e5 Screenshot continue
Ritor1
parents: 2069
diff changeset
728 temp_dec_position++;
400f3db2e4e5 Screenshot continue
Ritor1
parents: 2069
diff changeset
729 if (row_position == psx_head2.pitch)
400f3db2e4e5 Screenshot continue
Ritor1
parents: 2069
diff changeset
730 break;
0
Ritor1
parents:
diff changeset
731 }
Ritor1
parents:
diff changeset
732 while (count-- != 1);
Ritor1
parents:
diff changeset
733 }
Ritor1
parents:
diff changeset
734 }
Ritor1
parents:
diff changeset
735 else
Ritor1
parents:
diff changeset
736 {
Ritor1
parents:
diff changeset
737 ++row_position;
Ritor1
parents:
diff changeset
738 //*temp_dec_position =0xFF000000;
Ritor1
parents:
diff changeset
739 //*temp_dec_position|= (unsigned long)test_byte<<16;
Ritor1
parents:
diff changeset
740
2069
259df09dfb50 32bits almost there
Nomad
parents: 1980
diff changeset
741 *temp_dec_position |= r_mask & ((unsigned __int8)test_byte << (num_g_bits + num_r_bits + num_b_bits - 8));
0
Ritor1
parents:
diff changeset
742
Ritor1
parents:
diff changeset
743 temp_dec_position++;
Ritor1
parents:
diff changeset
744 }
Ritor1
parents:
diff changeset
745
Ritor1
parents:
diff changeset
746 }
Ritor1
parents:
diff changeset
747 while (row_position < psx_head2.pitch);
Ritor1
parents:
diff changeset
748 }
Ritor1
parents:
diff changeset
749
Ritor1
parents:
diff changeset
750 temp_dec_position = dec_position;
Ritor1
parents:
diff changeset
751 row_position=0;
Ritor1
parents:
diff changeset
752 //decode green line
Ritor1
parents:
diff changeset
753 while (row_position < psx_head2.pitch)
Ritor1
parents:
diff changeset
754 {
Ritor1
parents:
diff changeset
755 test_byte = *(pPcx + read_offset);
Ritor1
parents:
diff changeset
756 ++read_offset;
Ritor1
parents:
diff changeset
757 if ((test_byte & 0xC0) == 0xC0)
Ritor1
parents:
diff changeset
758 {
Ritor1
parents:
diff changeset
759 value = *(pPcx + read_offset);
Ritor1
parents:
diff changeset
760 ++read_offset;
Ritor1
parents:
diff changeset
761 if ((test_byte & 0x3F) > 0)
Ritor1
parents:
diff changeset
762 {
Ritor1
parents:
diff changeset
763 count = test_byte & 0x3F;
Ritor1
parents:
diff changeset
764 do
Ritor1
parents:
diff changeset
765 {
Ritor1
parents:
diff changeset
766 //*temp_dec_position|= (unsigned int)value<<8;
Ritor1
parents:
diff changeset
767 //temp_dec_position++;
Ritor1
parents:
diff changeset
768
2069
259df09dfb50 32bits almost there
Nomad
parents: 1980
diff changeset
769 *temp_dec_position|= g_mask & (unsigned __int16)((unsigned __int8)value << (num_g_bits + num_b_bits - 8));
0
Ritor1
parents:
diff changeset
770
Ritor1
parents:
diff changeset
771 temp_dec_position++;
Ritor1
parents:
diff changeset
772 ++row_position;
Ritor1
parents:
diff changeset
773 if (row_position == psx_head2.pitch)
Ritor1
parents:
diff changeset
774 break;
Ritor1
parents:
diff changeset
775
Ritor1
parents:
diff changeset
776 }
Ritor1
parents:
diff changeset
777 while (count-- != 1);
Ritor1
parents:
diff changeset
778 }
Ritor1
parents:
diff changeset
779 }
Ritor1
parents:
diff changeset
780 else
Ritor1
parents:
diff changeset
781 {
Ritor1
parents:
diff changeset
782 //*temp_dec_position |=(unsigned int) test_byte<<8;
Ritor1
parents:
diff changeset
783 //temp_dec_position++;
Ritor1
parents:
diff changeset
784
2069
259df09dfb50 32bits almost there
Nomad
parents: 1980
diff changeset
785 *temp_dec_position|= g_mask & (unsigned __int16)((unsigned __int8)test_byte << (num_g_bits + num_b_bits - 8));
0
Ritor1
parents:
diff changeset
786 temp_dec_position++;
Ritor1
parents:
diff changeset
787 ++row_position;
Ritor1
parents:
diff changeset
788 }
Ritor1
parents:
diff changeset
789 }
Ritor1
parents:
diff changeset
790
Ritor1
parents:
diff changeset
791 temp_dec_position = dec_position;
Ritor1
parents:
diff changeset
792 row_position=0;
Ritor1
parents:
diff changeset
793 //decode blue line
Ritor1
parents:
diff changeset
794 while (row_position < psx_head2.pitch)
Ritor1
parents:
diff changeset
795 {
Ritor1
parents:
diff changeset
796 test_byte = *(pPcx + read_offset);
Ritor1
parents:
diff changeset
797 read_offset++;
Ritor1
parents:
diff changeset
798 if ((test_byte & 0xC0) == 0xC0)
Ritor1
parents:
diff changeset
799 {
Ritor1
parents:
diff changeset
800 value = *(pPcx + read_offset);
Ritor1
parents:
diff changeset
801 ++read_offset;
Ritor1
parents:
diff changeset
802 if ((test_byte & 0x3F) > 0)
Ritor1
parents:
diff changeset
803 {
Ritor1
parents:
diff changeset
804 count = test_byte & 0x3F;
Ritor1
parents:
diff changeset
805 do
Ritor1
parents:
diff changeset
806 {
Ritor1
parents:
diff changeset
807 //*temp_dec_position|= value;
Ritor1
parents:
diff changeset
808 //temp_dec_position++;
Ritor1
parents:
diff changeset
809
2069
259df09dfb50 32bits almost there
Nomad
parents: 1980
diff changeset
810 *temp_dec_position |= value >> (8 - num_b_bits);
0
Ritor1
parents:
diff changeset
811 temp_dec_position++;
Ritor1
parents:
diff changeset
812
Ritor1
parents:
diff changeset
813 ++row_position;
Ritor1
parents:
diff changeset
814 if (row_position == psx_head2.pitch)
Ritor1
parents:
diff changeset
815 break;
Ritor1
parents:
diff changeset
816 }
Ritor1
parents:
diff changeset
817 while (count-- != 1);
Ritor1
parents:
diff changeset
818 }
Ritor1
parents:
diff changeset
819 }
Ritor1
parents:
diff changeset
820 else
Ritor1
parents:
diff changeset
821 {
Ritor1
parents:
diff changeset
822 //*temp_dec_position|= test_byte;
Ritor1
parents:
diff changeset
823 //temp_dec_position++;
2069
259df09dfb50 32bits almost there
Nomad
parents: 1980
diff changeset
824 *temp_dec_position |= test_byte >> (8 - num_b_bits);
0
Ritor1
parents:
diff changeset
825 temp_dec_position++;
Ritor1
parents:
diff changeset
826
Ritor1
parents:
diff changeset
827 ++row_position;
Ritor1
parents:
diff changeset
828 }
Ritor1
parents:
diff changeset
829
Ritor1
parents:
diff changeset
830 }
Ritor1
parents:
diff changeset
831 ++current_line;
Ritor1
parents:
diff changeset
832 dec_position += uWidth;
Ritor1
parents:
diff changeset
833 }
Ritor1
parents:
diff changeset
834 while (current_line < uHeight);
Ritor1
parents:
diff changeset
835 }
Ritor1
parents:
diff changeset
836 return 0;
Ritor1
parents:
diff changeset
837 /*
Ritor1
parents:
diff changeset
838 RGBTexture *v4; // esi@1
Ritor1
parents:
diff changeset
839 signed int result; // eax@2
Ritor1
parents:
diff changeset
840 unsigned __int16 v6; // ax@3
Ritor1
parents:
diff changeset
841 unsigned __int16 *v7; // ecx@3
Ritor1
parents:
diff changeset
842 unsigned int v8; // edx@3
Ritor1
parents:
diff changeset
843 signed int v9; // ecx@3
Ritor1
parents:
diff changeset
844 signed int v10; // ecx@8
Ritor1
parents:
diff changeset
845 signed int v11; // ebx@37
Ritor1
parents:
diff changeset
846 unsigned __int16 *v12; // eax@40
Ritor1
parents:
diff changeset
847 int v13; // edi@40
Ritor1
parents:
diff changeset
848 int v14; // ebx@41
Ritor1
parents:
diff changeset
849 char v15; // bl@42
Ritor1
parents:
diff changeset
850 unsigned __int16 *v16; // eax@50
Ritor1
parents:
diff changeset
851 int v17; // ebx@51
Ritor1
parents:
diff changeset
852 char v18; // bl@52
Ritor1
parents:
diff changeset
853 unsigned __int16 *v19; // eax@61
Ritor1
parents:
diff changeset
854 unsigned __int8 v20; // dl@62
Ritor1
parents:
diff changeset
855 unsigned __int8 v21; // dl@63
Ritor1
parents:
diff changeset
856 unsigned __int8 v22; // cl@63
Ritor1
parents:
diff changeset
857 char color_map[48]; // [sp+8h] [bp-54h]@1
Ritor1
parents:
diff changeset
858 PCXHeader1 header1; // [sp+38h] [bp-24h]@1
Ritor1
parents:
diff changeset
859 PCXHeader2 header2; // [sp+48h] [bp-14h]@1
Ritor1
parents:
diff changeset
860 unsigned int v26; // [sp+50h] [bp-Ch]@43
Ritor1
parents:
diff changeset
861 int v27; // [sp+54h] [bp-8h]@38
Ritor1
parents:
diff changeset
862 unsigned __int16 *v28; // [sp+58h] [bp-4h]@3
Ritor1
parents:
diff changeset
863 int pOutPixelsa; // [sp+68h] [bp+Ch]@41
Ritor1
parents:
diff changeset
864 int pOutPixelsb; // [sp+68h] [bp+Ch]@51
Ritor1
parents:
diff changeset
865
Ritor1
parents:
diff changeset
866 v4 = this;
Ritor1
parents:
diff changeset
867 memcpy(&header1, pPcx, 0x10u);
Ritor1
parents:
diff changeset
868 memcpy(color_map, pPcx + 16, 0x30u);
Ritor1
parents:
diff changeset
869 memcpy(&header2, pPcx + 64, 6u);
Ritor1
parents:
diff changeset
870 if ( header1.bpp == 8 )
Ritor1
parents:
diff changeset
871 {
Ritor1
parents:
diff changeset
872 v6 = header1.right - header1.left + 1;
Ritor1
parents:
diff changeset
873 LOWORD(v7) = header1.bottom - header1.up + 1;
Ritor1
parents:
diff changeset
874 v4->uWidth = v6;
Ritor1
parents:
diff changeset
875 v4->uHeight = (unsigned __int16)v7;
Ritor1
parents:
diff changeset
876 v7 = (unsigned __int16 *)(signed __int16)v7;
Ritor1
parents:
diff changeset
877 v28 = v7;
Ritor1
parents:
diff changeset
878 v4->uNumPixels = (signed __int16)v7 * (signed __int16)v6;
Ritor1
parents:
diff changeset
879 HIWORD(v8) = 0;
Ritor1
parents:
diff changeset
880 v9 = 1;
Ritor1
parents:
diff changeset
881 while ( 1 << v9 != (signed __int16)v6 )
Ritor1
parents:
diff changeset
882 {
Ritor1
parents:
diff changeset
883 ++v9;
Ritor1
parents:
diff changeset
884 if ( v9 >= 15 )
Ritor1
parents:
diff changeset
885 goto LABEL_8;
Ritor1
parents:
diff changeset
886 }
Ritor1
parents:
diff changeset
887 v4->field_18 = v9;
Ritor1
parents:
diff changeset
888 LABEL_8:
Ritor1
parents:
diff changeset
889 v10 = 1;
Ritor1
parents:
diff changeset
890 while ( (unsigned __int16 *)(1 << v10) != v28 )
Ritor1
parents:
diff changeset
891 {
Ritor1
parents:
diff changeset
892 ++v10;
Ritor1
parents:
diff changeset
893 if ( v10 >= 15 )
Ritor1
parents:
diff changeset
894 goto LABEL_13;
Ritor1
parents:
diff changeset
895 }
Ritor1
parents:
diff changeset
896 v4->field_1A = v10;
Ritor1
parents:
diff changeset
897 LABEL_13:
Ritor1
parents:
diff changeset
898 switch ( v4->field_18 )
Ritor1
parents:
diff changeset
899 {
Ritor1
parents:
diff changeset
900 case 2:
Ritor1
parents:
diff changeset
901 v4->field_1C = 3;
Ritor1
parents:
diff changeset
902 break;
Ritor1
parents:
diff changeset
903 case 3:
Ritor1
parents:
diff changeset
904 v4->field_1C = 7;
Ritor1
parents:
diff changeset
905 break;
Ritor1
parents:
diff changeset
906 case 4:
Ritor1
parents:
diff changeset
907 v4->field_1C = 15;
Ritor1
parents:
diff changeset
908 break;
Ritor1
parents:
diff changeset
909 case 5:
Ritor1
parents:
diff changeset
910 v4->field_1C = 31;
Ritor1
parents:
diff changeset
911 break;
Ritor1
parents:
diff changeset
912 case 6:
Ritor1
parents:
diff changeset
913 v4->field_1C = 63;
Ritor1
parents:
diff changeset
914 break;
Ritor1
parents:
diff changeset
915 case 7:
Ritor1
parents:
diff changeset
916 v4->field_1C = 127;
Ritor1
parents:
diff changeset
917 break;
Ritor1
parents:
diff changeset
918 case 8:
Ritor1
parents:
diff changeset
919 v4->field_1C = 255;
Ritor1
parents:
diff changeset
920 break;
Ritor1
parents:
diff changeset
921 case 9:
Ritor1
parents:
diff changeset
922 v4->field_1C = 511;
Ritor1
parents:
diff changeset
923 break;
Ritor1
parents:
diff changeset
924 case 10:
Ritor1
parents:
diff changeset
925 v4->field_1C = 1023;
Ritor1
parents:
diff changeset
926 break;
Ritor1
parents:
diff changeset
927 case 11:
Ritor1
parents:
diff changeset
928 v4->field_1C = 2047;
Ritor1
parents:
diff changeset
929 break;
Ritor1
parents:
diff changeset
930 case 12:
Ritor1
parents:
diff changeset
931 v4->field_1C = 4095;
Ritor1
parents:
diff changeset
932 break;
Ritor1
parents:
diff changeset
933 default:
Ritor1
parents:
diff changeset
934 break;
Ritor1
parents:
diff changeset
935 }
Ritor1
parents:
diff changeset
936 switch ( v4->field_1A )
Ritor1
parents:
diff changeset
937 {
Ritor1
parents:
diff changeset
938 case 2:
Ritor1
parents:
diff changeset
939 v4->field_1E = 3;
Ritor1
parents:
diff changeset
940 break;
Ritor1
parents:
diff changeset
941 case 3:
Ritor1
parents:
diff changeset
942 v4->field_1E = 7;
Ritor1
parents:
diff changeset
943 break;
Ritor1
parents:
diff changeset
944 case 4:
Ritor1
parents:
diff changeset
945 v4->field_1E = 15;
Ritor1
parents:
diff changeset
946 break;
Ritor1
parents:
diff changeset
947 case 5:
Ritor1
parents:
diff changeset
948 v4->field_1E = 31;
Ritor1
parents:
diff changeset
949 break;
Ritor1
parents:
diff changeset
950 case 6:
Ritor1
parents:
diff changeset
951 v4->field_1E = 63;
Ritor1
parents:
diff changeset
952 break;
Ritor1
parents:
diff changeset
953 case 7:
Ritor1
parents:
diff changeset
954 v4->field_1E = 127;
Ritor1
parents:
diff changeset
955 break;
Ritor1
parents:
diff changeset
956 case 8:
Ritor1
parents:
diff changeset
957 v4->field_1E = 255;
Ritor1
parents:
diff changeset
958 break;
Ritor1
parents:
diff changeset
959 case 9:
Ritor1
parents:
diff changeset
960 v4->field_1E = 511;
Ritor1
parents:
diff changeset
961 break;
Ritor1
parents:
diff changeset
962 case 10:
Ritor1
parents:
diff changeset
963 v4->field_1E = 1023;
Ritor1
parents:
diff changeset
964 break;
Ritor1
parents:
diff changeset
965 case 11:
Ritor1
parents:
diff changeset
966 v4->field_1E = 2047;
Ritor1
parents:
diff changeset
967 break;
Ritor1
parents:
diff changeset
968 case 12:
Ritor1
parents:
diff changeset
969 v4->field_1E = 4095;
Ritor1
parents:
diff changeset
970 break;
Ritor1
parents:
diff changeset
971 default:
Ritor1
parents:
diff changeset
972 break;
Ritor1
parents:
diff changeset
973 }
Ritor1
parents:
diff changeset
974 v11 = 128;
Ritor1
parents:
diff changeset
975 if ( header2.planes == 3 )
Ritor1
parents:
diff changeset
976 {
Ritor1
parents:
diff changeset
977 v27 = 0;
Ritor1
parents:
diff changeset
978 if ( (signed int)v28 > 0 )
Ritor1
parents:
diff changeset
979 {
Ritor1
parents:
diff changeset
980 v28 = pOutPixels;
Ritor1
parents:
diff changeset
981 do
Ritor1
parents:
diff changeset
982 {
Ritor1
parents:
diff changeset
983 v12 = v28;
Ritor1
parents:
diff changeset
984 v13 = 0;
Ritor1
parents:
diff changeset
985 if ( header2.pitch )
Ritor1
parents:
diff changeset
986 {
Ritor1
parents:
diff changeset
987 do
Ritor1
parents:
diff changeset
988 {
Ritor1
parents:
diff changeset
989 LOBYTE(v8) = pPcx[v11];
Ritor1
parents:
diff changeset
990 v14 = v11 + 1;
Ritor1
parents:
diff changeset
991 pOutPixelsa = v14;
Ritor1
parents:
diff changeset
992 if ( (v8 & 0xC0) == -64 )
Ritor1
parents:
diff changeset
993 {
Ritor1
parents:
diff changeset
994 pOutPixelsa = v14 + 1;
Ritor1
parents:
diff changeset
995 v15 = pPcx[v14];
Ritor1
parents:
diff changeset
996 if ( (signed int)(v8 & 0x3F) > 0 )
Ritor1
parents:
diff changeset
997 {
Ritor1
parents:
diff changeset
998 v26 = v8 & 0x3F;
Ritor1
parents:
diff changeset
999 do
Ritor1
parents:
diff changeset
1000 {
Ritor1
parents:
diff changeset
1001 ++v13;
Ritor1
parents:
diff changeset
1002 *v12 = LOWORD(pRenderer->uTargetRMask) & ((unsigned __int8)v15 << (LOBYTE(pRenderer->uTargetGBits)
Ritor1
parents:
diff changeset
1003 + LOBYTE(pRenderer->uTargetRBits)
Ritor1
parents:
diff changeset
1004 + LOBYTE(pRenderer->uTargetBBits)
Ritor1
parents:
diff changeset
1005 - 8));
Ritor1
parents:
diff changeset
1006 ++v12;
Ritor1
parents:
diff changeset
1007 if ( v13 == (unsigned __int16)header2.pitch )
Ritor1
parents:
diff changeset
1008 v12 = &v12[uNumPixels - (unsigned __int16)header2.pitch - 1];
Ritor1
parents:
diff changeset
1009 --v26;
Ritor1
parents:
diff changeset
1010 }
Ritor1
parents:
diff changeset
1011 while ( v26 );
Ritor1
parents:
diff changeset
1012 }
Ritor1
parents:
diff changeset
1013 }
Ritor1
parents:
diff changeset
1014 else
Ritor1
parents:
diff changeset
1015 {
Ritor1
parents:
diff changeset
1016 LOWORD(v8) = (unsigned __int8)v8;
Ritor1
parents:
diff changeset
1017 v8 = pRenderer->uTargetRMask & (v8 << (LOBYTE(pRenderer->uTargetGBits)
Ritor1
parents:
diff changeset
1018 + LOBYTE(pRenderer->uTargetRBits)
Ritor1
parents:
diff changeset
1019 + LOBYTE(pRenderer->uTargetBBits)
Ritor1
parents:
diff changeset
1020 - 8));
Ritor1
parents:
diff changeset
1021 ++v13;
Ritor1
parents:
diff changeset
1022 *v12 = v8;
Ritor1
parents:
diff changeset
1023 ++v12;
Ritor1
parents:
diff changeset
1024 }
Ritor1
parents:
diff changeset
1025 v11 = pOutPixelsa;
Ritor1
parents:
diff changeset
1026 }
Ritor1
parents:
diff changeset
1027 while ( v13 < (unsigned __int16)header2.pitch );
Ritor1
parents:
diff changeset
1028 }
Ritor1
parents:
diff changeset
1029 v16 = v28;
Ritor1
parents:
diff changeset
1030 while ( v13 < 2 * (unsigned __int16)header2.pitch )
Ritor1
parents:
diff changeset
1031 {
Ritor1
parents:
diff changeset
1032 LOBYTE(v8) = pPcx[v11];
Ritor1
parents:
diff changeset
1033 v17 = v11 + 1;
Ritor1
parents:
diff changeset
1034 pOutPixelsb = v17;
Ritor1
parents:
diff changeset
1035 if ( (v8 & 0xC0) == -64 )
Ritor1
parents:
diff changeset
1036 {
Ritor1
parents:
diff changeset
1037 pOutPixelsb = v17 + 1;
Ritor1
parents:
diff changeset
1038 v18 = pPcx[v17];
Ritor1
parents:
diff changeset
1039 if ( (signed int)(v8 & 0x3F) > 0 )
Ritor1
parents:
diff changeset
1040 {
Ritor1
parents:
diff changeset
1041 v26 = v8 & 0x3F;
Ritor1
parents:
diff changeset
1042 do
Ritor1
parents:
diff changeset
1043 {
Ritor1
parents:
diff changeset
1044 *v16 |= pRenderer->uTargetGMask & (unsigned __int16)((unsigned __int8)v18 << (LOBYTE(pRenderer->uTargetGBits)
Ritor1
parents:
diff changeset
1045 + LOBYTE(pRenderer->uTargetBBits)
Ritor1
parents:
diff changeset
1046 - 8));
Ritor1
parents:
diff changeset
1047 ++v13;
Ritor1
parents:
diff changeset
1048 ++v16;
Ritor1
parents:
diff changeset
1049 if ( v13 == (unsigned __int16)header2.pitch )
Ritor1
parents:
diff changeset
1050 v16 = &v16[uNumPixels - (unsigned __int16)header2.pitch - 1];
Ritor1
parents:
diff changeset
1051 --v26;
Ritor1
parents:
diff changeset
1052 }
Ritor1
parents:
diff changeset
1053 while ( v26 );
Ritor1
parents:
diff changeset
1054 }
Ritor1
parents:
diff changeset
1055 }
Ritor1
parents:
diff changeset
1056 else
Ritor1
parents:
diff changeset
1057 {
Ritor1
parents:
diff changeset
1058 LOWORD(v8) = (unsigned __int8)v8;
Ritor1
parents:
diff changeset
1059 v8 = pRenderer->uTargetGMask & (v8 << (LOBYTE(pRenderer->uTargetGBits) + LOBYTE(pRenderer->uTargetBBits) - 8));
Ritor1
parents:
diff changeset
1060 *v16 |= v8;
Ritor1
parents:
diff changeset
1061 ++v13;
Ritor1
parents:
diff changeset
1062 ++v16;
Ritor1
parents:
diff changeset
1063 }
Ritor1
parents:
diff changeset
1064 v11 = pOutPixelsb;
Ritor1
parents:
diff changeset
1065 }
Ritor1
parents:
diff changeset
1066 v19 = v28;
Ritor1
parents:
diff changeset
1067 while ( v13 < 3 * (unsigned __int16)header2.pitch )
Ritor1
parents:
diff changeset
1068 {
Ritor1
parents:
diff changeset
1069 v20 = pPcx[v11++];
Ritor1
parents:
diff changeset
1070 if ( (v20 & 0xC0) == -64 )
Ritor1
parents:
diff changeset
1071 {
Ritor1
parents:
diff changeset
1072 v21 = v20 & 0x3F;
Ritor1
parents:
diff changeset
1073 v22 = pPcx[v11++];
Ritor1
parents:
diff changeset
1074 if ( (signed int)v21 > 0 )
Ritor1
parents:
diff changeset
1075 {
Ritor1
parents:
diff changeset
1076 v26 = v21;
Ritor1
parents:
diff changeset
1077 do
Ritor1
parents:
diff changeset
1078 {
Ritor1
parents:
diff changeset
1079 *v19 |= v22 >> (8 - LOBYTE(pRenderer->uTargetBBits));
Ritor1
parents:
diff changeset
1080 ++v13;
Ritor1
parents:
diff changeset
1081 ++v19;
Ritor1
parents:
diff changeset
1082 if ( v13 == (unsigned __int16)header2.pitch )
Ritor1
parents:
diff changeset
1083 {
Ritor1
parents:
diff changeset
1084 v8 = uNumPixels - (unsigned __int16)header2.pitch;
Ritor1
parents:
diff changeset
1085 v19 = &v19[uNumPixels - (unsigned __int16)header2.pitch - 1];
Ritor1
parents:
diff changeset
1086 }
Ritor1
parents:
diff changeset
1087 --v26;
Ritor1
parents:
diff changeset
1088 }
Ritor1
parents:
diff changeset
1089 while ( v26 );
Ritor1
parents:
diff changeset
1090 }
Ritor1
parents:
diff changeset
1091 }
Ritor1
parents:
diff changeset
1092 else
Ritor1
parents:
diff changeset
1093 {
Ritor1
parents:
diff changeset
1094 *v19 |= v20 >> (8 - LOBYTE(pRenderer->uTargetBBits));
Ritor1
parents:
diff changeset
1095 ++v13;
Ritor1
parents:
diff changeset
1096 ++v19;
Ritor1
parents:
diff changeset
1097 }
Ritor1
parents:
diff changeset
1098 }
Ritor1
parents:
diff changeset
1099 ++v27;
Ritor1
parents:
diff changeset
1100 v28 += uNumPixels;
Ritor1
parents:
diff changeset
1101 }
Ritor1
parents:
diff changeset
1102 while ( v27 < v4->uHeight );
Ritor1
parents:
diff changeset
1103 }
Ritor1
parents:
diff changeset
1104 }
Ritor1
parents:
diff changeset
1105 result = 0;
Ritor1
parents:
diff changeset
1106 }
Ritor1
parents:
diff changeset
1107 else
Ritor1
parents:
diff changeset
1108 {
Ritor1
parents:
diff changeset
1109 result = 3;
Ritor1
parents:
diff changeset
1110 }
Ritor1
parents:
diff changeset
1111 return result;
Ritor1
parents:
diff changeset
1112 */
Ritor1
parents:
diff changeset
1113 }
Ritor1
parents:
diff changeset
1114
Ritor1
parents:
diff changeset
1115 //----- (0040EAD8) --------------------------------------------------------
Ritor1
parents:
diff changeset
1116 unsigned int RGBTexture::LoadFromFILE(FILE *pFile, unsigned int mode, unsigned int bCloseFile)
Ritor1
parents:
diff changeset
1117 {
2334
ddb803517a48 unused local variables I commented
Ritor1
parents: 2279
diff changeset
1118 // signed int result; // eax@2
ddb803517a48 unused local variables I commented
Ritor1
parents: 2279
diff changeset
1119 // unsigned char test_byte; // edx@3
0
Ritor1
parents:
diff changeset
1120 //unsigned int read_offset; // ebx@37
2334
ddb803517a48 unused local variables I commented
Ritor1
parents: 2279
diff changeset
1121 // unsigned int row_position; // edi@40
ddb803517a48 unused local variables I commented
Ritor1
parents: 2279
diff changeset
1122 // unsigned char value; // cl@63
ddb803517a48 unused local variables I commented
Ritor1
parents: 2279
diff changeset
1123 // char count; // [sp+50h] [bp-Ch]@43
ddb803517a48 unused local variables I commented
Ritor1
parents: 2279
diff changeset
1124 // unsigned short current_line; // [sp+54h] [bp-8h]@38
ddb803517a48 unused local variables I commented
Ritor1
parents: 2279
diff changeset
1125 // unsigned short *dec_position;
ddb803517a48 unused local variables I commented
Ritor1
parents: 2279
diff changeset
1126 // unsigned short *temp_dec_position;
0
Ritor1
parents:
diff changeset
1127 PCXHeader1 psx_head1;
Ritor1
parents:
diff changeset
1128 PCXHeader2 psx_head2;
2334
ddb803517a48 unused local variables I commented
Ritor1
parents: 2279
diff changeset
1129 // short int width, height;
0
Ritor1
parents:
diff changeset
1130 BYTE color_map[48]; // Colormap for 16-color images
Ritor1
parents:
diff changeset
1131
2131
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1132 unsigned int num_r_bits = 5;
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1133 unsigned int num_g_bits = 6;
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1134 unsigned int num_b_bits = 5;
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1135
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1136 unsigned int r_mask = 0xF800;
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1137 unsigned int g_mask = 0x07E0;
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1138 unsigned int b_mask = 0x001F;
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1139
0
Ritor1
parents:
diff changeset
1140 if (!pFile)
Ritor1
parents:
diff changeset
1141 return 1;
Ritor1
parents:
diff changeset
1142
Ritor1
parents:
diff changeset
1143
Ritor1
parents:
diff changeset
1144 fread(&psx_head1, 1, 16, pFile);
Ritor1
parents:
diff changeset
1145 fread(&color_map, 1, 48, pFile);
Ritor1
parents:
diff changeset
1146 fread(&psx_head2, 1, 6, pFile);
Ritor1
parents:
diff changeset
1147
Ritor1
parents:
diff changeset
1148 if (psx_head1.bpp!=8)
Ritor1
parents:
diff changeset
1149 return 3;
Ritor1
parents:
diff changeset
1150 uWidth=(short int )(psx_head1.right-psx_head1.left+1); // word @ 000014
Ritor1
parents:
diff changeset
1151 uHeight=(short int )(psx_head1.bottom-psx_head1.up+1); // word @ 000016
Ritor1
parents:
diff changeset
1152
Ritor1
parents:
diff changeset
1153
Ritor1
parents:
diff changeset
1154 uNumPixels=uWidth*uHeight; // dword @ 000010
Ritor1
parents:
diff changeset
1155
Ritor1
parents:
diff changeset
1156
Ritor1
parents:
diff changeset
1157 if ( mode == 0 )
Ritor1
parents:
diff changeset
1158 {
2369
bddcaf5d5db2 removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents: 2353
diff changeset
1159 free(pPixels);
1583
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1545
diff changeset
1160 pPixels = (unsigned __int16 *)malloc(2 * uNumPixels + 4);
0
Ritor1
parents:
diff changeset
1161 }
Ritor1
parents:
diff changeset
1162 else
Ritor1
parents:
diff changeset
1163 {
Ritor1
parents:
diff changeset
1164 if ( mode != 1 && mode == 2 )
Ritor1
parents:
diff changeset
1165 {
Ritor1
parents:
diff changeset
1166 pPixels = (unsigned __int16 *)malloc((uNumPixels + 2) * sizeof(unsigned __int16));
1583
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1545
diff changeset
1167 _allocation_flags |= 1;
0
Ritor1
parents:
diff changeset
1168 }
Ritor1
parents:
diff changeset
1169 }
Ritor1
parents:
diff changeset
1170
1980
c1c74df0a33e changing most of auto types to their actual types
Grumpy7
parents: 1846
diff changeset
1171 ushort* pOutPixels = pPixels;
0
Ritor1
parents:
diff changeset
1172
Ritor1
parents:
diff changeset
1173 memset(pOutPixels, 0, uNumPixels * sizeof(__int16));
Ritor1
parents:
diff changeset
1174
Ritor1
parents:
diff changeset
1175 short i=1;
Ritor1
parents:
diff changeset
1176 while ( (1<<i) !=uWidth)
Ritor1
parents:
diff changeset
1177 {
Ritor1
parents:
diff changeset
1178 ++i;
Ritor1
parents:
diff changeset
1179 if (i >= 15)
Ritor1
parents:
diff changeset
1180 break;
Ritor1
parents:
diff changeset
1181 }
Ritor1
parents:
diff changeset
1182 field_18=i;
Ritor1
parents:
diff changeset
1183 short i_=1;
Ritor1
parents:
diff changeset
1184 while ( (1<<i_) !=uHeight)
Ritor1
parents:
diff changeset
1185 {
Ritor1
parents:
diff changeset
1186 ++i_;
Ritor1
parents:
diff changeset
1187 if (i_ >= 15)
Ritor1
parents:
diff changeset
1188 break;
Ritor1
parents:
diff changeset
1189 }
Ritor1
parents:
diff changeset
1190 field_1A=i_;
Ritor1
parents:
diff changeset
1191 switch (field_18)
Ritor1
parents:
diff changeset
1192 {
Ritor1
parents:
diff changeset
1193 case 2: field_1C = 3; break;
Ritor1
parents:
diff changeset
1194 case 3: field_1C = 7; break;
Ritor1
parents:
diff changeset
1195 case 4: field_1C = 15; break;
Ritor1
parents:
diff changeset
1196 case 5: field_1C = 31; break;
Ritor1
parents:
diff changeset
1197 case 6: field_1C = 63; break;
Ritor1
parents:
diff changeset
1198 case 7: field_1C = 127; break;
Ritor1
parents:
diff changeset
1199 case 8: field_1C = 255; break;
Ritor1
parents:
diff changeset
1200 case 9: field_1C = 511; break;
Ritor1
parents:
diff changeset
1201 case 10: field_1C = 1023; break;
Ritor1
parents:
diff changeset
1202 case 11: field_1C = 2047; break;
Ritor1
parents:
diff changeset
1203 case 12: field_1C = 4095; break;
Ritor1
parents:
diff changeset
1204 }
Ritor1
parents:
diff changeset
1205
Ritor1
parents:
diff changeset
1206 switch (field_1A)
Ritor1
parents:
diff changeset
1207 {
Ritor1
parents:
diff changeset
1208 case 2: field_1E = 3; break;
Ritor1
parents:
diff changeset
1209 case 3: field_1E = 7; break;
Ritor1
parents:
diff changeset
1210 case 4: field_1E = 15; break;
Ritor1
parents:
diff changeset
1211 case 5: field_1E = 31; break;
Ritor1
parents:
diff changeset
1212 case 6: field_1E = 63; break;
Ritor1
parents:
diff changeset
1213 case 7: field_1E = 127; break;
Ritor1
parents:
diff changeset
1214 case 8: field_1E = 255; break;
Ritor1
parents:
diff changeset
1215 case 9: field_1E = 511; break;
Ritor1
parents:
diff changeset
1216 case 10: field_1E = 1023; break;
Ritor1
parents:
diff changeset
1217 case 11: field_1E = 2047; break;
Ritor1
parents:
diff changeset
1218 case 12: field_1E = 4095; break;
Ritor1
parents:
diff changeset
1219 }
Ritor1
parents:
diff changeset
1220
Ritor1
parents:
diff changeset
1221 fseek(pFile, 128 - 70, SEEK_CUR);
Ritor1
parents:
diff changeset
1222
Ritor1
parents:
diff changeset
1223
Ritor1
parents:
diff changeset
1224 for (uint y = 0; y < uHeight; ++y)
Ritor1
parents:
diff changeset
1225 {
Ritor1
parents:
diff changeset
1226 unsigned __int16 *pDst = pPixels + y * uWidth;
Ritor1
parents:
diff changeset
1227
Ritor1
parents:
diff changeset
1228 uint x = 0;
Ritor1
parents:
diff changeset
1229 do
Ritor1
parents:
diff changeset
1230 {
Ritor1
parents:
diff changeset
1231 uint ctrl = 0;
Ritor1
parents:
diff changeset
1232 fread(&ctrl, 1, 1, pFile);
Ritor1
parents:
diff changeset
1233 if ((ctrl & 0xC0) == 0xC0)
Ritor1
parents:
diff changeset
1234 {
Ritor1
parents:
diff changeset
1235 uint uNumPixels = ctrl & 0x3F;
Ritor1
parents:
diff changeset
1236 uint clr = 0;
Ritor1
parents:
diff changeset
1237 fread(&clr, 1, 1, pFile);
Ritor1
parents:
diff changeset
1238 for (uint i = 0; i < uNumPixels; ++i)
2131
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1239 pDst[x++] = r_mask & (clr << (num_g_bits + num_r_bits + num_b_bits - 8));
0
Ritor1
parents:
diff changeset
1240 }
Ritor1
parents:
diff changeset
1241 else
Ritor1
parents:
diff changeset
1242 {
2131
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1243 pDst[x++] = r_mask & (ctrl << (num_g_bits + num_r_bits + num_b_bits - 8));
0
Ritor1
parents:
diff changeset
1244 }
Ritor1
parents:
diff changeset
1245 } while (x < psx_head2.pitch);
Ritor1
parents:
diff changeset
1246
Ritor1
parents:
diff changeset
1247 x = 0;
Ritor1
parents:
diff changeset
1248 do
Ritor1
parents:
diff changeset
1249 {
Ritor1
parents:
diff changeset
1250 uint ctrl = 0;
Ritor1
parents:
diff changeset
1251 fread(&ctrl, 1, 1, pFile);
Ritor1
parents:
diff changeset
1252 if ((ctrl & 0xC0) == 0xC0)
Ritor1
parents:
diff changeset
1253 {
Ritor1
parents:
diff changeset
1254 uint uNumPixels = ctrl & 0x3F;
Ritor1
parents:
diff changeset
1255 uint clr = 0;
Ritor1
parents:
diff changeset
1256 fread(&clr, 1, 1, pFile);
Ritor1
parents:
diff changeset
1257 for (uint i = 0; i < uNumPixels; ++i)
2131
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1258 pDst[x++] |= g_mask & (clr << (num_g_bits + num_b_bits - 8));
0
Ritor1
parents:
diff changeset
1259 }
Ritor1
parents:
diff changeset
1260 else
Ritor1
parents:
diff changeset
1261 {
2131
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1262 pDst[x++] |= g_mask & (ctrl << (num_g_bits + num_b_bits - 8));
0
Ritor1
parents:
diff changeset
1263 }
Ritor1
parents:
diff changeset
1264 } while (x < psx_head2.pitch);
Ritor1
parents:
diff changeset
1265
Ritor1
parents:
diff changeset
1266 x = 0;
Ritor1
parents:
diff changeset
1267 do
Ritor1
parents:
diff changeset
1268 {
Ritor1
parents:
diff changeset
1269 uint ctrl = 0;
Ritor1
parents:
diff changeset
1270 fread(&ctrl, 1, 1, pFile);
Ritor1
parents:
diff changeset
1271 if ((ctrl & 0xC0) == 0xC0)
Ritor1
parents:
diff changeset
1272 {
Ritor1
parents:
diff changeset
1273 uint uNumPixels = ctrl & 0x3F;
Ritor1
parents:
diff changeset
1274 uint clr = 0;
Ritor1
parents:
diff changeset
1275 fread(&clr, 1, 1, pFile);
Ritor1
parents:
diff changeset
1276 for (uint i = 0; i < uNumPixels; ++i)
2131
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1277 pDst[x++] |= b_mask & (clr >> (8 - num_b_bits));
0
Ritor1
parents:
diff changeset
1278 }
Ritor1
parents:
diff changeset
1279 else
Ritor1
parents:
diff changeset
1280 {
2131
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1281 pDst[x++] |= b_mask & (ctrl >> (8 - num_b_bits));
0
Ritor1
parents:
diff changeset
1282 }
Ritor1
parents:
diff changeset
1283 } while (x < psx_head2.pitch);
Ritor1
parents:
diff changeset
1284 }
Ritor1
parents:
diff changeset
1285
Ritor1
parents:
diff changeset
1286 if (bCloseFile)
Ritor1
parents:
diff changeset
1287 fclose(pFile);
Ritor1
parents:
diff changeset
1288 return 0;
Ritor1
parents:
diff changeset
1289 }
Ritor1
parents:
diff changeset
1290
Ritor1
parents:
diff changeset
1291 //----- (0040E51F) --------------------------------------------------------
Ritor1
parents:
diff changeset
1292 void RGBTexture::Release()
Ritor1
parents:
diff changeset
1293 {
Ritor1
parents:
diff changeset
1294 this->pName[0] = 0;
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1295 //if ( !(this->_allocation_flags & 1) )
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1296 //free(this->pPixels);
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1297 //else
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1298 free(this->pPixels);
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1299 this->_allocation_flags = 0;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1300 this->pPixels = 0;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1301 this->uNumPixels = 0;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1302 this->uHeight = 0;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1303 this->uWidth = 0;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1304 this->field_1A = 0;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1305 this->field_18 = 0;
0
Ritor1
parents:
diff changeset
1306 }
Ritor1
parents:
diff changeset
1307
Ritor1
parents:
diff changeset
1308 //----- (0040E55E) --------------------------------------------------------
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1309 int RGBTexture::LoadPCXFile(const char *Filename, unsigned int a3)
0
Ritor1
parents:
diff changeset
1310 {
Ritor1
parents:
diff changeset
1311 signed int result; // eax@2
Ritor1
parents:
diff changeset
1312 char *v6; // eax@3
Ritor1
parents:
diff changeset
1313 int v7; // edx@3
Ritor1
parents:
diff changeset
1314 char v8; // cl@4
Ritor1
parents:
diff changeset
1315 signed int v14; // ecx@19
Ritor1
parents:
diff changeset
1316 signed int v15; // ecx@24
2334
ddb803517a48 unused local variables I commented
Ritor1
parents: 2279
diff changeset
1317 // int v16; // eax@57
ddb803517a48 unused local variables I commented
Ritor1
parents: 2279
diff changeset
1318 // unsigned __int16 *v17; // ecx@57
ddb803517a48 unused local variables I commented
Ritor1
parents: 2279
diff changeset
1319 // unsigned __int16 *v18; // edi@57
ddb803517a48 unused local variables I commented
Ritor1
parents: 2279
diff changeset
1320 // signed int x; // eax@59
ddb803517a48 unused local variables I commented
Ritor1
parents: 2279
diff changeset
1321 // unsigned __int16 *v20; // edi@64
ddb803517a48 unused local variables I commented
Ritor1
parents: 2279
diff changeset
1322 // signed int v21; // eax@66
ddb803517a48 unused local variables I commented
Ritor1
parents: 2279
diff changeset
1323 // unsigned __int16 *v22; // edi@71
ddb803517a48 unused local variables I commented
Ritor1
parents: 2279
diff changeset
1324 // signed int v23; // eax@73
ddb803517a48 unused local variables I commented
Ritor1
parents: 2279
diff changeset
1325 // int v24; // eax@78
71
2b90f29892ae ESC menu fixed
zipi
parents: 0
diff changeset
1326 char v25[48]; // [sp+Ch] [bp-54h]@3
2b90f29892ae ESC menu fixed
zipi
parents: 0
diff changeset
1327 PCXHeader1 pcx_header1;
2b90f29892ae ESC menu fixed
zipi
parents: 0
diff changeset
1328 PCXHeader2 pcx_header2;
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1329 int y; // [sp+54h] [bp-Ch]@3
0
Ritor1
parents:
diff changeset
1330 FILE *File; // [sp+5Ch] [bp-4h]@1
Ritor1
parents:
diff changeset
1331
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1332 unsigned int num_r_bits = 5;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1333 unsigned int num_g_bits = 6;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1334 unsigned int num_b_bits = 5;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1335
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1336 unsigned int r_mask = 0xF800;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1337 unsigned int g_mask = 0x07E0;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1338 unsigned int b_mask = 0x001F;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1339
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1340
0
Ritor1
parents:
diff changeset
1341 File = fopen(Filename, "rb");
Ritor1
parents:
diff changeset
1342 if ( !File )
Ritor1
parents:
diff changeset
1343 return 1;
71
2b90f29892ae ESC menu fixed
zipi
parents: 0
diff changeset
1344
2b90f29892ae ESC menu fixed
zipi
parents: 0
diff changeset
1345 fread(&pcx_header1, sizeof(pcx_header1), 1, File);
2b90f29892ae ESC menu fixed
zipi
parents: 0
diff changeset
1346 fread(&v25,48,1,File);
2b90f29892ae ESC menu fixed
zipi
parents: 0
diff changeset
1347 fread(&pcx_header2, 4, 1, File);
2b90f29892ae ESC menu fixed
zipi
parents: 0
diff changeset
1348
0
Ritor1
parents:
diff changeset
1349 v6 = (char *)Filename;
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1350 v7 = (char *)this - Filename;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1351 uint i = 0;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1352 for ( i; i < 15; ++i )
0
Ritor1
parents:
diff changeset
1353 {
Ritor1
parents:
diff changeset
1354 v8 = *v6;
Ritor1
parents:
diff changeset
1355 if ( !*v6 )
Ritor1
parents:
diff changeset
1356 break;
Ritor1
parents:
diff changeset
1357 if ( v8 == 46 )
Ritor1
parents:
diff changeset
1358 break;
Ritor1
parents:
diff changeset
1359 (v6++)[v7] = v8;
Ritor1
parents:
diff changeset
1360 }
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1361 this->pName[i] = 0;
71
2b90f29892ae ESC menu fixed
zipi
parents: 0
diff changeset
1362 if ( pcx_header1.bpp != 8 )
0
Ritor1
parents:
diff changeset
1363 return 3;
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1364 this->uWidth = pcx_header1.right - pcx_header1.left + 1;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1365 this->uHeight = pcx_header1.bottom - pcx_header1.up + 1;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1366 this->uNumPixels = (signed __int16)this->uWidth * (signed __int16)this->uHeight;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1367 if ( !a3 )
0
Ritor1
parents:
diff changeset
1368 {
2369
bddcaf5d5db2 removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents: 2353
diff changeset
1369 free(this->pPixels);
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1370 this->pPixels = (unsigned __int16 *)malloc(2 * this->uNumPixels + 4);
0
Ritor1
parents:
diff changeset
1371 }
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1372 if ( a3 == 2 )
0
Ritor1
parents:
diff changeset
1373 {
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1374 this->_allocation_flags |= 1;
2131
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1375 this->pPixels = (unsigned __int16 *)malloc((uNumPixels + 2) * sizeof(unsigned __int16));
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1376 }
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1377 if ( this->pPixels )
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1378 {
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1379 for ( v14 = 1; v14 < 15; ++v14 )
0
Ritor1
parents:
diff changeset
1380 {
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1381 if ( 1 << v14 == this->uWidth )
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1382 this->field_18 = v14;
0
Ritor1
parents:
diff changeset
1383 }
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1384 for ( v15 = 1; v15 < 15; ++v15 )
0
Ritor1
parents:
diff changeset
1385 {
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1386 if ( 1 << v15 == this->uHeight )
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1387 this->field_1A = v15;
0
Ritor1
parents:
diff changeset
1388 }
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1389 switch ( this->field_18 )
0
Ritor1
parents:
diff changeset
1390 {
2129
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1391 case 2: this->field_1C = 3; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1392 case 3: this->field_1C = 7; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1393 case 4: this->field_1C = 15; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1394 case 5: this->field_1C = 31; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1395 case 6: this->field_1C = 63; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1396 case 7: this->field_1C = 127; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1397 case 8: this->field_1C = 255; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1398 case 9: this->field_1C = 511; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1399 case 10: this->field_1C = 1023; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1400 case 11: this->field_1C = 2047; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1401 case 12: this->field_1C = 4095; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1402 default: break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1403 }
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1404 switch ( this->field_1A )
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1405 {
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1406 case 2: this->field_1E = 3; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1407 case 3: this->field_1E = 7; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1408 case 4: this->field_1E = 15; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1409 case 5: this->field_1E = 31; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1410 case 6: this->field_1E = 63; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1411 case 7: this->field_1E = 127; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1412 case 8: this->field_1E = 255; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1413 case 9: this->field_1E = 511; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1414 case 10: this->field_1E = 1023; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1415 case 11: this->field_1E = 2047; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1416 case 12: this->field_1E = 4095; break;
23dbcaa651cc LoadPCXFile
Ritor1
parents: 2127
diff changeset
1417 default: break;
0
Ritor1
parents:
diff changeset
1418 }
Ritor1
parents:
diff changeset
1419 fseek(File, 128, 0);
Ritor1
parents:
diff changeset
1420 ftell(File);
2131
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1421 if ( pcx_header2.planes == 1 )
1545
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1477
diff changeset
1422 Error("24bit PCX Only!");
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1477
diff changeset
1423
71
2b90f29892ae ESC menu fixed
zipi
parents: 0
diff changeset
1424 if ( pcx_header2.planes == 3 )
0
Ritor1
parents:
diff changeset
1425 {
2131
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1426 for ( y = 0; y < this->uHeight; ++y )
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1427 {
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1428 unsigned __int16 *pDst = pPixels + y * uWidth;
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1429 uint x = 0;
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1430 do
0
Ritor1
parents:
diff changeset
1431 {
2131
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1432 uint ctrl = 0;
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1433 fread(&ctrl, 1, 1, File);
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1434 if ( (ctrl & 0xC0) == 0xC0 )
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1435 {
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1436 uint uNumPixels = ctrl & 0x3F;
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1437 uint clr = 0;
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1438 ctrl &= 0x3F;
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1439 fread(&clr, 1, 1, File);
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1440 for ( uint i = 0; i < uNumPixels; ++i )
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1441 pDst[x++] = r_mask & (clr << (num_r_bits + num_g_bits + num_b_bits - 8));
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1442 }
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1443 else
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1444 pDst[x++] = r_mask & (ctrl << (num_g_bits + num_r_bits + num_b_bits - 8));
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1445 }
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1446 while ( x < pcx_header2.pitch );
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1447
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1448 x = 0;
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1449 do
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1450 {
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1451 uint ctrl = 0;
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1452 fread(&ctrl, 1, 1, File);
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1453 if ( (ctrl & 0xC0) == 0xC0 )
0
Ritor1
parents:
diff changeset
1454 {
2131
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1455 uint uNumPixels = ctrl & 0x3F;
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1456 uint clr = 0;
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1457 ctrl &= 0x3F;
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1458 fread(&clr, 1, 1, File);
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1459 for ( uint i = 0; i < uNumPixels; ++i )
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1460 pDst[x++] |= g_mask & (clr << (num_g_bits + num_b_bits - 8));
0
Ritor1
parents:
diff changeset
1461 }
2131
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1462 else
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1463 pDst[x++] |= g_mask & (ctrl << (num_g_bits + num_b_bits - 8));
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1464 }
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1465 while (x < pcx_header2.pitch);
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1466
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1467 x = 0;
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1468 do
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1469 {
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1470 uint ctrl = 0;
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1471 fread(&ctrl, 1, 1, File);
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1472 if ( (ctrl & 0xC0) == 0xC0 )
0
Ritor1
parents:
diff changeset
1473 {
2131
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1474 uint uNumPixels = ctrl & 0x3F;
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1475 uint clr = 0;
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1476 fread(&clr, 1, 1, File);
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1477 for ( uint i = 0; i < uNumPixels; ++i )
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1478 pDst[x++] |= b_mask & (clr >> (8 - num_b_bits));
0
Ritor1
parents:
diff changeset
1479 }
2131
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1480 else
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1481 pDst[x++] |= b_mask & (ctrl >> (8 - num_b_bits));
0
Ritor1
parents:
diff changeset
1482 }
2131
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1483 while (x < pcx_header2.pitch);
651b24553ae9 savegame screenshot fix
Ritor1
parents: 2129
diff changeset
1484 }
0
Ritor1
parents:
diff changeset
1485 }
Ritor1
parents:
diff changeset
1486 fclose(File);
Ritor1
parents:
diff changeset
1487 result = 0;
Ritor1
parents:
diff changeset
1488 }
Ritor1
parents:
diff changeset
1489 else
Ritor1
parents:
diff changeset
1490 {
Ritor1
parents:
diff changeset
1491 result = 2;
Ritor1
parents:
diff changeset
1492 }
Ritor1
parents:
diff changeset
1493 return result;
Ritor1
parents:
diff changeset
1494 }
Ritor1
parents:
diff changeset
1495
Ritor1
parents:
diff changeset
1496 //----- (0040D73D) --------------------------------------------------------
Ritor1
parents:
diff changeset
1497 RGBTexture::RGBTexture()
Ritor1
parents:
diff changeset
1498 {
Ritor1
parents:
diff changeset
1499 pName[0] = 0;
Ritor1
parents:
diff changeset
1500 pPixels = 0;
Ritor1
parents:
diff changeset
1501 uNumPixels = 0;
Ritor1
parents:
diff changeset
1502 uHeight = 0;
Ritor1
parents:
diff changeset
1503 uWidth = 0;
Ritor1
parents:
diff changeset
1504 field_1A = 0;
Ritor1
parents:
diff changeset
1505 field_18 = 0;
1583
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1545
diff changeset
1506 _allocation_flags = 0;
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1507 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1508 //----- (0044E1EC) --------------------------------------------------------
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1509 int TextureFrameTable::FromFileTxt(const char *Args)
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1510 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1511 TextureFrameTable *v2; // ebx@1
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1512 FILE *v3; // eax@1
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1513 int v4; // esi@3
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1514 const void *v5; // ST0C_4@10
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1515 void *v6; // eax@10
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1516 FILE *v7; // ST0C_4@12
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1517 char *i; // eax@12
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1518 signed int v9; // esi@15
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1519 int v10; // eax@17
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1520 int v11; // edx@22
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1521 int v12; // ecx@23
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1522 int v13; // eax@24
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1523 signed int j; // eax@27
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1524 TextureFrame *v15; // edx@28
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1525 int v16; // esi@28
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1526 int k; // ecx@29
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1527 char Buf; // [sp+Ch] [bp-2F8h]@3
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1528 FrameTableTxtLine v20; // [sp+200h] [bp-104h]@4
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1529 int v21; // [sp+27Ch] [bp-88h]@4
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1530 char *Str1; // [sp+280h] [bp-84h]@5
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1531 char *Str; // [sp+284h] [bp-80h]@15
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1532 int v24; // [sp+2F8h] [bp-Ch]@3
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1533 int v25; // [sp+2FCh] [bp-8h]@3
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1534 FILE *File; // [sp+300h] [bp-4h]@1
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1535 int Argsa; // [sp+30Ch] [bp+8h]@28
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1536
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1537 v2 = this;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1538 v3 = fopen(Args, "r");
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1539 File = v3;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1540 if ( !v3 )
1545
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1477
diff changeset
1541 Error("CTextureFrameTable::load - Unable to open file: %s.", Args);
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1477
diff changeset
1542
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1543 v4 = 0;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1544 v24 = 0;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1545 v25 = 1;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1546 if ( fgets(&Buf, 490, v3) )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1547 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1548 do
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1549 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1550 *strchr(&Buf, 10) = 0;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1551 memcpy(&v21, txt_file_frametable_parser(&Buf, &v20), 0x7Cu);
1409
c9e3b93ec570 Highlighted locations with "using uninitialized variable" warning.
Nomad
parents: 1402
diff changeset
1552 __debugbreak(); // warning C4700: uninitialized local variable 'Str1' used
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1553 if ( v21 && *Str1 != 47 )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1554 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1555 if ( v21 < 2 )
1545
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1477
diff changeset
1556 Error("CTextureFrameTable::load, too few arguments, %s line %i.", Args, v25);
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1557 ++v24;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1558 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1559 ++v25;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1560 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1561 while ( fgets(&Buf, 490, File) );
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1562 v4 = v24;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1563 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1564 v5 = v2->pTextures;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1565 v2->sNumTextures = v4;
1583
75fafd8ced59 Allocator (CMemory) bye-bye
Nomad
parents: 1545
diff changeset
1566 v6 = malloc(20 * v4);
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1567 v2->pTextures = (TextureFrame *)v6;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1568 if ( !v6 )
1545
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1477
diff changeset
1569 Error("CTextureFrameTable::load - Out of Memory!");
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1570 v7 = File;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1571 v2->sNumTextures = 0;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1572 fseek(v7, 0, 0);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1573 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1574 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1575 *strchr(&Buf, 10) = 0;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1576 memcpy(&v21, txt_file_frametable_parser(&Buf, &v20), 0x7Cu);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1577 if ( v21 && *Str1 != 47 )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1578 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1579 strcpy(v2->pTextures[v2->sNumTextures].pTextureName, Str1);
1409
c9e3b93ec570 Highlighted locations with "using uninitialized variable" warning.
Nomad
parents: 1402
diff changeset
1580 __debugbreak(); // warning C4700: uninitialized local variable 'Str' used
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1581 v2->pTextures[v2->sNumTextures].uAnimTime = atoi(Str);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1582 v9 = 2;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1583 for ( v2->pTextures[v2->sNumTextures].uFlags = 0; v9 < v21; ++v9 )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1584 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1585 if ( !_stricmp((&Str1)[4 * v9], "New") )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1586 {
2335
6e3ca612f132 int -> uint
Ritor1
parents: 2334
diff changeset
1587 //v10 = (int)&v2->pTextures[v2->sNumTextures].uFlags;
6e3ca612f132 int -> uint
Ritor1
parents: 2334
diff changeset
1588 v2->pTextures[v2->sNumTextures].uFlags |= 2;
1297
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1589 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1590 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1591 ++v2->sNumTextures;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1592 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1593 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1594 fclose(File);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1595 v11 = 0;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1596 if ( (signed int)(v2->sNumTextures - 1) > 0 )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1597 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1598 v12 = 0;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1599 do
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1600 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1601 v13 = (int)&v2->pTextures[v12];
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1602 if ( !(*(char *)(v13 + 38) & 2) )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1603 *(char *)(v13 + 18) |= 1u;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1604 ++v11;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1605 ++v12;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1606 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1607 while ( v11 < (signed int)(v2->sNumTextures - 1) );
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1608 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1609 for ( j = 0; j < (signed int)v2->sNumTextures; *(short *)(Argsa + 16) = v16 )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1610 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1611 v15 = v2->pTextures;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1612 Argsa = (int)&v15[j];
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1613 v16 = *(short *)(Argsa + 14);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1614 if ( *(char *)(Argsa + 18) & 1 )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1615 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1616 ++j;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1617 for ( k = (int)&v15[j]; *(char *)(k + 18) & 1; k += 20 )
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1618 {
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1619 v16 += *(short *)(k + 14);
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1620 ++j;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1621 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1622 LOWORD(v16) = v15[j].uAnimTime + v16;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1623 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1624 ++j;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1625 }
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1626 return 1;
5450af4f57ef moving files mm7_x ending
Ritor1
parents: 1262
diff changeset
1627 }
2463
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1628
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1629 //----- (00451007) --------------------------------------------------------
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1630 int stru350::sub_451007_scale_image_bicubic(unsigned short *pSrc, int srcWidth, int srcHeight, int srcPitch, //changing this to some library function might be a good idea
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1631 unsigned short *pDst, int dstWidth, int dstHeight, int dstPitch,
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1632 int a10, int a11)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1633 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1634 int result; // eax@1
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1635 float v17; // ST3C_4@12
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1636 float v18; // ST38_4@12
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1637 unsigned int v19; // esi@12
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1638 int v21; // eax@18
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1639 unsigned int v22; // ecx@25
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1640 unsigned int v23; // eax@29
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1641 unsigned int heightRatioPlusOne; // [sp+Ch] [bp-7Ch]@12
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1642 unsigned int widthRatio; // [sp+Ch] [bp-7Ch]@218
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1643 unsigned int heightRatio; // [sp+14h] [bp-74h]@12
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1644 unsigned int widthRatioPlusOne; // [sp+14h] [bp-74h]@218
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1645 // int v160; // [sp+3Ch] [bp-4Ch]@13
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1646 unsigned __int16 *v175; // [sp+4Ch] [bp-3Ch]@13
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1647 unsigned __int16 *v193; // [sp+5Ch] [bp-2Ch]@7
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1648 //signed int v231; // [sp+78h] [bp-10h]@7
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1649 __int64 v240; // [sp+7Ch] [bp-Ch]@12
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1650 unsigned int v251; // [sp+80h] [bp-8h]@218
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1651 unsigned int v252; // [sp+84h] [bp-4h]@218
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1652 float a6s; // [sp+A0h] [bp+18h]@218
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1653 float a6t; // [sp+A0h] [bp+18h]@218
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1654 unsigned int a6b; // [sp+A0h] [bp+18h]@218
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1655 int field_0_bits;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1656 int field_20_bits;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1657
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1658 int field0value = this->field_0.field_C;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1659 switch (field0value)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1660 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1661 case 8: field_0_bits = 1;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1662 break;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1663 case 16: field_0_bits = 2;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1664 break;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1665 case 32: field_0_bits = 4;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1666 break;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1667 default:
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1668 return field0value;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1669 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1670 int field20value = this->field_20.field_C;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1671 switch (field20value)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1672 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1673 case 8: field_20_bits = 1;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1674 break;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1675 case 16: field_20_bits = 2;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1676 break;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1677 case 32: field_20_bits = 4;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1678 break;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1679 default:
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1680 return field20value;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1681 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1682
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1683 result = (int)pDst;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1684 v193 = pDst;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1685 if (dstHeight <= 0)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1686 return result;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1687
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1688 //do
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1689 for (int height = 0; height < dstHeight; height++)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1690 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1691 for (int width = 0; width < dstWidth; width++)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1692 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1693 a6s = (double)width / (double)dstWidth * (double)srcWidth;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1694 widthRatio = bankersRounding(a6s);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1695 a6t = (double)(width + 1) / (double)dstWidth * (double)srcWidth;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1696 widthRatioPlusOne = bankersRounding(a6t);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1697
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1698 v17 = (double)height / (double)dstHeight * (double)srcHeight;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1699 heightRatio = bankersRounding(v17);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1700 v18 = (double)(height + 1) / (double)dstHeight * (double)srcHeight;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1701 heightRatioPlusOne = bankersRounding(v18);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1702
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1703 v251 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1704 v19 = (heightRatioPlusOne - heightRatio) * (widthRatioPlusOne - widthRatio);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1705 v252 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1706 a6b = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1707 v240 = 0i64;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1708
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1709 v175 = (unsigned short*)((char *)pSrc + field_0_bits * (widthRatio + srcPitch * heightRatio));
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1710 for (int heightDiff = 0; heightDiff < heightRatioPlusOne - heightRatio; heightDiff++)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1711 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1712 //int ratioDiff = widthRatioPlusOne - widthRatio;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1713 for (int ratioDiff = 0; ratioDiff < widthRatioPlusOne - widthRatio; ratioDiff++)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1714 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1715 if (field0value == 32)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1716 v21 = _450FB1(((int*)v175)[ratioDiff]);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1717 else if (field0value == 16)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1718 v21 = _450FB1(((_WORD*)v175)[ratioDiff]);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1719 else if (field0value == 8)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1720 v21 = _450FB1(((unsigned __int8*)v175)[ratioDiff]);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1721 v240 += ((unsigned int)v21 >> 24);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1722 a6b += BYTE2(v21);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1723 v252 += BYTE1(v21);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1724 v251 += (unsigned __int8)v21;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1725 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1726 if (field0value == 32)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1727 v175 += 2 * srcPitch;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1728 else if (field0value == 16)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1729 v175 += srcPitch;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1730 else if (field0value == 8)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1731 v175 = (unsigned short*)((char *)v175 + 2 * srcPitch);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1732 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1733
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1734 v22 = (unsigned int)v240 / ((heightRatioPlusOne - heightRatio) * (widthRatioPlusOne - widthRatio));
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1735 if (v19)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1736 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1737 a6b /= v19;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1738 v252 /= v19;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1739 v251 /= v19;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1740 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1741 if (v22 != 255)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1742 v22 &= 0x7FFFFFFFu;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1743 v23 = _450F55(v251 | ((v252 | ((a6b | (v22 << 8)) << 8)) << 8));
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1744 *(_DWORD *)v193 = v23; //Invalid memory access
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1745 v193 = (unsigned __int16 *)((char *)v193 + field_20_bits);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1746 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1747 v193 = (unsigned __int16 *)((char *)v193 + field_20_bits * (dstPitch - dstWidth));
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1748 //++v231;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1749 result = height;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1750 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1751 //while(v231 < dstHeight);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1752 return result;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1753 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1754
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1755
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1756 //----- (00450DDE) --------------------------------------------------------
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1757 stru350 *stru350::_450DDE()
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1758 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1759 _450DF1(&stru_4E82A4, &stru_4E82A4);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1760 return this;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1761 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1762
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1763 //----- (00450DF1) --------------------------------------------------------
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1764 bool stru350::_450DF1(const stru355 *p1, const stru355 *p2)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1765 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1766 //stru350 *v3; // esi@1
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1767 //void *result; // eax@1
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1768 unsigned int v5; // ecx@2
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1769 int v6; // edi@2
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1770 int v7; // edx@2
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1771 unsigned int v8; // ecx@8
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1772 int v9; // edi@8
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1773 int v10; // edx@8
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1774 int v11; // ecx@12
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1775 int v12; // edi@12
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1776 unsigned int v13; // ecx@12
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1777 int v14; // edx@12
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1778 int v15; // ecx@16
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1779 unsigned int v16; // edx@16
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1780 int v17; // ecx@16
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1781 int v18; // edi@16
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1782 char v19; // zf@20
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1783 unsigned int v20; // ecx@21
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1784 int v21; // edi@21
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1785 int v22; // edx@21
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1786 unsigned int v23; // ecx@27
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1787 int v24; // edi@27
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1788 int v25; // edx@27
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1789 int v26; // ecx@31
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1790 int v27; // edi@31
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1791 unsigned int v28; // ecx@31
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1792 int v29; // edx@31
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1793 int v30; // ebx@35
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1794 int v31; // ecx@35
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1795 int v32; // edi@35
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1796 int v33; // edx@35
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1797 unsigned int i; // ecx@35
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1798 int v35; // ecx@39
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1799 unsigned int v36; // edx@39
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1800 int v37; // ecx@39
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1801 int v38; // ebx@39
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1802
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1803 //v3 = this;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1804 memcpy(&field_0, p1, sizeof(stru355));
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1805 memcpy(&field_20, p2, sizeof(stru355));
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1806 //result = memcpy(&v3->field_20, p2, 0x20u);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1807 //LOBYTE(result) = 1;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1808 if (field_0.field_4 & 1)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1809 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1810 v5 = field_0.field_1C;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1811 v6 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1812 v7 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1813 while (!(v5 & 1))
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1814 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1815 ++v6;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1816 v5 >>= 1;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1817 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1818 do
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1819 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1820 v5 >>= 1;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1821 ++v7;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1822 } while (v5 & 1);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1823 field_40 = 32 - v7 - v6;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1824 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1825 else
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1826 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1827 field_40 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1828 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1829 v8 = field_0.field_10;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1830 v9 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1831 v10 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1832 while (!(v8 & 1))
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1833 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1834 ++v9;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1835 v8 >>= 1;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1836 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1837 do
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1838 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1839 v8 >>= 1;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1840 ++v10;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1841 } while (v8 & 1);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1842 v11 = 24 - v10 - v9;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1843 v12 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1844 field_48 = v11;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1845 v13 = field_0.field_14;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1846 v14 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1847 while (!(v13 & 1))
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1848 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1849 ++v12;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1850 v13 >>= 1;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1851 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1852 do
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1853 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1854 v13 >>= 1;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1855 ++v14;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1856 } while (v13 & 1);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1857 v15 = 16 - v14;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1858 v16 = field_0.field_18;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1859 field_50 = v15 - v12;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1860 v17 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1861 v18 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1862 while (!(v16 & 1))
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1863 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1864 ++v17;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1865 v16 >>= 1;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1866 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1867 do
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1868 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1869 v16 >>= 1;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1870 ++v18;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1871 } while (v16 & 1);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1872 v19 = (field_20.field_4 & 1) == 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1873 field_58 = v17 - v18 + 8;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1874 if (v19)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1875 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1876 field_44 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1877 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1878 else
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1879 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1880 v20 = field_20.field_1C;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1881 v21 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1882 v22 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1883 while (!(v20 & 1))
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1884 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1885 ++v21;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1886 v20 >>= 1;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1887 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1888 do
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1889 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1890 v20 >>= 1;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1891 ++v22;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1892 } while (v20 & 1);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1893 field_44 = 32 - v22 - v21;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1894 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1895 v23 = field_20.field_10;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1896 v24 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1897 v25 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1898 while (!(v23 & 1))
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1899 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1900 ++v24;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1901 v23 >>= 1;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1902 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1903 do
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1904 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1905 v23 >>= 1;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1906 ++v25;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1907 } while (v23 & 1);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1908 v26 = 24 - v25 - v24;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1909 v27 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1910 field_4C = v26;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1911 v28 = field_20.field_14;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1912 v29 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1913 while (!(v28 & 1))
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1914 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1915 ++v27;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1916 v28 >>= 1;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1917 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1918 do
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1919 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1920 v28 >>= 1;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1921 ++v29;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1922 } while (v28 & 1);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1923 v30 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1924 v31 = 16 - v29 - v27;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1925 v32 = field_20.field_18;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1926 field_54 = v31;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1927 v33 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1928 for (i = v32; !(i & 1); i >>= 1)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1929 ++v30;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1930 do
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1931 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1932 i >>= 1;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1933 ++v33;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1934 } while (i & 1);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1935 v35 = 32 - v33;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1936 v36 = v32;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1937 field_5C = v35 - v30;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1938 v37 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1939 v38 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1940 while (!(v36 & 1))
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1941 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1942 ++v37;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1943 v36 >>= 1;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1944 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1945 do
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1946 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1947 v36 >>= 1;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1948 ++v38;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1949 } while (v36 & 1);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1950 field_5C = v37 - v38 + 8;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1951 return true;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1952 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1953
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1954 //----- (00450F55) --------------------------------------------------------
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1955 unsigned int stru350::_450F55(int a2)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1956 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1957 int v2 = a2 & stru_4E82A4.field_1C;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1958 if (field_20.field_4 & 1)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1959 v2 = (unsigned int)v2 >> this->field_44;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1960 return v2 & field_20.field_1C |
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1961 field_20.field_10 & ((a2 & (unsigned int)stru_4E82A4.field_10) >> field_4C) |
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1962 field_20.field_14 & ((a2 & (unsigned int)stru_4E82A4.field_14) >> field_54) |
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1963 field_20.field_18 & ((a2 & (unsigned int)stru_4E82A4.field_18) >> field_5C);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1964 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1965
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1966 //----- (00450FB1) --------------------------------------------------------
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1967 int stru350::_450FB1(int a2)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1968 {
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1969 int v2 = 0;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1970 int v4 = field_0.field_4 & 1;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1971 if (v4)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1972 v2 = a2 & field_0.field_1C;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1973 if (v4)
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1974 v2 <<= field_40;
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1975 return v2 | ((a2 & field_0.field_10) << field_48) | ((a2 & field_0.field_14) << field_50) | ((a2 & field_0.field_18) << field_58);
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1976 }
0f17a30149ec cleaning project part 1
zipi
parents: 2415
diff changeset
1977