Mercurial > mm7
annotate Sprites.cpp @ 1652:42055a4bd550
Слияние
author | Ritor1 |
---|---|
date | Wed, 18 Sep 2013 09:21:38 +0600 |
parents | 75fafd8ced59 |
children | 35c1e4ff6ba7 |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
4 |
0 | 5 #include <string.h> |
1017 | 6 #include <algorithm> |
0 | 7 |
8 #include "Sprites.h" | |
9 #include "PaletteManager.h" | |
10 #include "LOD.h" | |
11 #include "FrameTableInc.h" | |
12 | |
13 #include "mm7_data.h" | |
1295 | 14 #include "Outdoor.h" |
15 #include "DecorationList.h" | |
16 #include "MM7.h" | |
17 #include "Actor.h" | |
0 | 18 |
19 | |
20 | |
21 | |
22 struct SpriteFrameTable *pSpriteFrameTable; | |
23 | |
24 | |
25 | |
26 | |
27 //----- (0044D4D8) -------------------------------------------------------- | |
28 void SpriteFrameTable::ReleaseSFrames() | |
29 { | |
30 SpriteFrameTable *v1; // esi@1 | |
31 | |
32 v1 = this; | |
33 if ( this->pSpriteSFrames ) | |
34 { | |
1583 | 35 free(this->pSpriteSFrames); |
0 | 36 v1->pSpriteSFrames = 0; |
37 } | |
38 v1->uNumSpriteFrames = 0; | |
39 } | |
40 | |
41 //----- (0044D4F6) -------------------------------------------------------- | |
42 void SpriteFrameTable::ResetSomeSpriteFlags() | |
43 { | |
44 int v1; // esi@1 | |
45 signed int i; // edx@1 | |
46 char *v3; // eax@2 | |
47 | |
48 v1 = 0; | |
49 for ( i = 0; i < (signed int)this->uNumSpriteFrames; ++i ) | |
50 { | |
51 v3 = (char *)&this->pSpriteSFrames[v1].uFlags; | |
52 ++v1; | |
53 *v3 &= 0x7Fu; | |
54 } | |
55 } | |
56 | |
57 //----- (0044D513) -------------------------------------------------------- | |
670 | 58 void SpriteFrameTable::InitializeSprite( signed int uSpriteID ) |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
670
diff
changeset
|
59 { |
670 | 60 //SpriteFrameTable *v2; // esi@1 |
61 unsigned int v3; // ebx@3 | |
62 //char *v4; // edx@3 | |
63 //int v5; // eax@3 | |
64 SpriteFrame *v6; // ecx@5 | |
65 int v7; // eax@5 | |
66 __int16 v8; // ax@6 | |
67 //signed int v9; // edx@6 | |
68 //int v10; // ecx@6 | |
69 signed int v11; // edi@10 | |
70 __int16 v12; // ax@16 | |
71 int v13; // ecx@16 | |
72 size_t v14; // eax@19 | |
73 signed int v15; // edi@19 | |
74 __int16 v16; // ax@27 | |
75 int v17; // ecx@27 | |
76 signed int v18; // edi@29 | |
77 SpriteFrame *v19; // eax@30 | |
78 __int16 v20; // ax@45 | |
79 int v21; // ecx@45 | |
0 | 80 |
670 | 81 char Str[32]; // [sp+Ch] [bp-3Ch]@19 |
82 char sprite_name[20]; // [sp+2Ch] [bp-1Ch]@15 | |
83 char Source[4]; // [sp+40h] [bp-8h]@19 | |
0 | 84 |
85 | |
670 | 86 //v2 = this; |
87 if ( uSpriteID <= this->uNumSpriteFrames ) | |
0 | 88 { |
670 | 89 if ( uSpriteID >= 0 ) |
0 | 90 { |
670 | 91 v3 = uSpriteID; |
92 | |
93 auto uFlags = pSpriteSFrames[v3].uFlags; | |
94 if (!(uFlags & 0x0080)) //not loaded | |
95 { | |
96 pSpriteSFrames[v3].uFlags |= 0x80; //set loaded | |
97 while ( 1 ) | |
98 { | |
99 pSpriteSFrames[v3].uPaletteIndex = pPaletteManager->LoadPalette(pSpriteSFrames[v3].uPaletteID); | |
100 if ( uFlags & 0x10 ) //single frame per frame sequence | |
101 { | |
102 v8 = pSprites_LOD->LoadSprite(pSpriteSFrames[v3].pTextureName, pSpriteSFrames[v3].uPaletteID); | |
103 for (uint i = 0; i < 8; ++i) | |
104 { | |
105 | |
106 pSpriteSFrames[v3].pHwSpriteIDs[i] = v8; | |
107 } | |
108 | |
109 } | |
110 else if ( uFlags & 0x10000 ) | |
111 { | |
112 for (uint i = 0; i < 8; ++i) | |
113 { | |
114 switch ( i ) | |
115 { | |
116 case 3: | |
117 case 4: | |
118 case 5: | |
119 sprintf(sprite_name, "%s4", pSpriteSFrames[v3].pTextureName); | |
120 break; | |
121 case 2: | |
122 case 6: | |
123 sprintf(sprite_name, "%s2", pSpriteSFrames[v3].pTextureName); | |
124 break; | |
125 case 0: | |
126 case 1: | |
127 case 7: | |
128 sprintf(sprite_name, "%s0", pSpriteSFrames[v3].pTextureName); | |
129 break; | |
130 } | |
131 v12 = pSprites_LOD->LoadSprite(sprite_name, pSpriteSFrames[v3].uPaletteID); | |
132 | |
133 pSpriteSFrames[v3].pHwSpriteIDs[i]=v12; | |
134 } | |
135 | |
136 } | |
137 else if ( uFlags & 0x40 ) //part of monster fidgeting seq | |
138 { | |
139 strcpy(Source, "stA"); | |
140 strcpy(Str, pSpriteSFrames[v3].pTextureName); | |
141 v14 = strlen(Str); | |
142 strcpy(&Str[v14-3], Source); | |
143 for (uint i = 0; i < 8; ++i) | |
144 { | |
145 switch ( i ) | |
146 { | |
147 case 0: | |
148 sprintf(sprite_name, "%s0", pSpriteSFrames[v3].pTextureName); | |
149 break; | |
150 case 4: | |
151 sprintf(sprite_name, "%s4",&Str ); | |
152 break; | |
153 case 3: | |
154 case 5: | |
155 sprintf(sprite_name, "%s3",&Str ); | |
156 break; | |
157 case 2: | |
158 case 6: | |
159 sprintf(sprite_name, "%s2", pSpriteSFrames[v3].pTextureName); | |
160 break; | |
161 case 1: | |
162 case 7: | |
163 sprintf(sprite_name, "%s1", pSpriteSFrames[v3].pTextureName); | |
164 break; | |
165 } | |
166 v12 = pSprites_LOD->LoadSprite(sprite_name, pSpriteSFrames[v3].uPaletteID); | |
167 pSpriteSFrames[v3].pHwSpriteIDs[i]=v12; | |
168 } | |
169 } | |
170 | |
171 else | |
172 { | |
173 for (uint i = 0; i < 8; ++i) | |
174 | |
175 { | |
176 | |
177 if (((0x0100 << i) & pSpriteSFrames[v3].uFlags) ) //mirrors | |
178 { | |
179 switch ( i ) | |
180 { | |
181 case 1: | |
182 sprintf(sprite_name, "%s7", pSpriteSFrames[v3].pTextureName); | |
183 break; | |
184 case 2: | |
185 sprintf(sprite_name, "%s6", pSpriteSFrames[v3].pTextureName); | |
186 break; | |
187 case 3: | |
188 sprintf(sprite_name, "%s5", pSpriteSFrames[v3].pTextureName); | |
189 break; | |
190 case 4: | |
191 sprintf(sprite_name, "%s4", pSpriteSFrames[v3].pTextureName); | |
192 break; | |
193 | |
194 case 5: | |
195 sprintf(sprite_name, "%s3", pSpriteSFrames[v3].pTextureName); | |
196 break; | |
197 | |
198 case 6: | |
199 sprintf(sprite_name, "%s2", pSpriteSFrames[v3].pTextureName); | |
200 break; | |
201 case 7: | |
202 sprintf(sprite_name, "%s1", pSpriteSFrames[v3].pTextureName); | |
203 break; | |
204 } | |
205 } | |
206 else | |
207 { | |
208 sprintf(sprite_name, "%s%i", pSpriteSFrames[v3].pTextureName, i); | |
209 | |
210 } | |
211 v12 = pSprites_LOD->LoadSprite(sprite_name, pSpriteSFrames[v3].uPaletteID); | |
212 pSpriteSFrames[v3].pHwSpriteIDs[i]=v12; | |
213 | |
214 } | |
215 } | |
216 | |
217 if ( !(pSpriteSFrames[v3].uFlags & 1) ) | |
218 return; | |
219 ++v3; | |
220 } | |
221 } | |
222 } | |
0 | 223 } |
224 } | |
225 | |
226 //----- (0044D813) -------------------------------------------------------- | |
670 | 227 signed int SpriteFrameTable::FastFindSprite( char *pSpriteName ) |
1017 | 228 { |
670 | 229 signed int result; // eax@2 |
0 | 230 |
1017 | 231 int searchResult = BinarySearch(pSpriteName); |
232 if ( searchResult < 0 ) | |
0 | 233 result = 0; |
234 else | |
1017 | 235 result = this->pSpriteEFrames[searchResult]; |
0 | 236 return result; |
237 } | |
238 | |
239 //----- (0044D83A) -------------------------------------------------------- | |
1017 | 240 int SpriteFrameTable::BinarySearch( const char *pSpriteName ) |
0 | 241 { |
1017 | 242 int startPos = 0; |
243 int endPos = uNumEFrames; | |
244 while ( 1 ) | |
0 | 245 { |
1017 | 246 int searchRange = endPos - startPos; |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
247 int middleFrameIndex = startPos + (endPos - startPos) / 2; |
1017 | 248 int comparisonResult = _stricmp(pSpriteName, this->pSpritePFrames[middleFrameIndex]->pIconName); |
249 if ( !comparisonResult ) | |
0 | 250 { |
1017 | 251 return middleFrameIndex; |
252 } | |
253 if ( startPos == endPos ) | |
254 { | |
255 return -1; | |
0 | 256 } |
1017 | 257 if ( comparisonResult >= 0 ) |
258 { | |
259 startPos += max(((endPos - startPos) / 2), 1); | |
260 } | |
261 else{ | |
262 endPos = max(((endPos - startPos) / 2), 1) + startPos; | |
263 } | |
0 | 264 } |
265 } | |
266 | |
267 //----- (0044D8D0) -------------------------------------------------------- | |
639 | 268 SpriteFrame *SpriteFrameTable::GetFrame(unsigned int uSpriteID, unsigned int uTime) |
0 | 269 { |
639 | 270 //SpriteFrame *v3; // edi@1 |
0 | 271 SpriteFrame *v4; // ecx@1 |
639 | 272 //__int16 v5; // dx@2 |
273 //int v6; // edx@3 | |
274 //unsigned int v7; // eax@3 | |
275 //char *i; // ecx@3 | |
276 //int v9; // esi@5 | |
277 //SpriteFrame *result; // eax@6 | |
0 | 278 |
639 | 279 v4 = &pSpriteSFrames[uSpriteID]; |
280 if (~v4->uFlags & 1 || !v4->uAnimLength) | |
281 return pSpriteSFrames + uSpriteID; | |
282 | |
283 for (uint t = (uTime / 8) % v4->uAnimLength; t > v4->uAnimTime; ++v4) | |
284 t -= v4->uAnimTime; | |
285 return v4; | |
286 | |
287 /*for (v4; v4->uAnimTime <= t; ++v4) | |
288 | |
289 v6 = (uTime / 8) % v4->uAnimLength; | |
290 //v7 = uSpriteID; | |
0 | 291 for ( i = (char *)&v4->uAnimTime; ; i += 60 ) |
292 { | |
293 v9 = *(short *)i; | |
294 if ( v6 <= v9 ) | |
295 break; | |
296 v6 -= v9; | |
297 ++v7; | |
298 } | |
639 | 299 return &pSpriteSFrames[v7];*/ |
300 | |
0 | 301 } |
302 | |
303 //----- (0044D91F) -------------------------------------------------------- | |
304 SpriteFrame *SpriteFrameTable::GetFrameBy_x(unsigned int uSpriteID, signed int a3) | |
305 { | |
306 SpriteFrame *v3; // edi@1 | |
307 SpriteFrame *v4; // esi@1 | |
308 __int16 v5; // ax@2 | |
309 int v6; // ecx@3 | |
310 int v7; // edx@3 | |
311 unsigned int v8; // eax@3 | |
312 int v9; // ecx@3 | |
313 char *i; // edx@3 | |
314 int v11; // esi@5 | |
315 SpriteFrame *result; // eax@6 | |
316 | |
317 v3 = this->pSpriteSFrames; | |
318 v4 = &v3[uSpriteID]; | |
319 if ( v4->uFlags & 1 && (v5 = v4->uAnimLength) != 0 ) | |
320 { | |
321 v6 = v5; | |
322 v7 = a3 % v5; | |
323 v8 = uSpriteID; | |
324 v9 = v6 - v7; | |
325 for ( i = (char *)&v4->uAnimTime; ; i += 60 ) | |
326 { | |
327 v11 = *(short *)i; | |
328 if ( v9 <= v11 ) | |
329 break; | |
330 v9 -= v11; | |
331 ++v8; | |
332 } | |
333 result = &v3[v8]; | |
334 } | |
335 else | |
336 { | |
337 result = &v3[uSpriteID]; | |
338 } | |
339 return result; | |
340 } | |
341 | |
342 //----- (0044D96D) -------------------------------------------------------- | |
343 void SpriteFrameTable::ToFile() | |
344 { | |
345 SpriteFrameTable *v1; // esi@1 | |
346 FILE *v2; // eax@1 | |
347 FILE *v3; // edi@1 | |
348 | |
349 v1 = this; | |
350 v2 = fopen("data\\dsft.bin", "wb"); | |
351 v3 = v2; | |
352 if ( !v2 ) | |
1545 | 353 Error("Unable to save dsft.bin!"); |
0 | 354 fwrite(v1, 4u, 1u, v2); |
355 fwrite(&v1->uNumEFrames, 4u, 1u, v3); | |
356 fwrite(v1->pSpriteSFrames, 0x3Cu, v1->uNumSpriteFrames, v3); | |
357 fwrite(v1->pSpriteEFrames, 2u, v1->uNumEFrames, v3); | |
358 fclose(v3); | |
359 } | |
360 | |
361 //----- (0044D9D7) -------------------------------------------------------- | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
362 void SpriteFrameTable::FromFile(void *data_mm6, void *data_mm7, void *data_mm8) |
0 | 363 { |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
364 uint num_mm6_frames = 0; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
365 uint num_mm6_eframes = 0; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
366 if (data_mm6) |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
367 { |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
368 num_mm6_frames = *(int *)data_mm6; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
369 num_mm6_eframes = *((int *)data_mm6 + 1); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
370 } |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
371 |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
372 uint num_mm7_frames = 0; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
373 uint num_mm7_eframes = 0; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
374 if (data_mm7) |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
375 { |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
376 num_mm7_frames = *(int *)data_mm7; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
377 num_mm7_eframes = *((int *)data_mm7 + 1); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
378 } |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
379 |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
380 uint num_mm8_frames = 0; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
381 uint num_mm8_eframes = 0; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
382 if (data_mm8) |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
383 { |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
384 num_mm8_frames = *(int *)data_mm8; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
385 num_mm8_eframes = *((int *)data_mm8 + 1); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
386 } |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
387 |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
388 uNumSpriteFrames = num_mm6_frames + num_mm7_frames + num_mm8_frames; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
389 uNumEFrames = num_mm6_eframes + num_mm7_eframes + num_mm8_eframes; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
390 |
1583 | 391 pSpriteSFrames = (SpriteFrame *)malloc(uNumSpriteFrames * sizeof(SpriteFrame)); |
392 pSpriteEFrames = (__int16 *)malloc(uNumSpriteFrames * sizeof(short)); | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
393 |
1583 | 394 pSpritePFrames = (SpriteFrame **)malloc(4 * uNumSpriteFrames); |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
395 |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
396 auto mm7_frames_size = num_mm7_frames * sizeof(SpriteFrame); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
397 memcpy(pSpriteSFrames, (char *)data_mm7 + 8, mm7_frames_size); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
398 memcpy(pSpriteEFrames, (char *)data_mm7 + 8 + mm7_frames_size, 2 * num_mm7_eframes); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
399 |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
400 auto mm6_frames_size = num_mm6_frames * sizeof(SpriteFrame_mm6); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
401 for (uint i = 0; i < num_mm6_frames; ++i) |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
402 { |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
403 memcpy(pSpriteSFrames + num_mm7_frames + i, (char *)data_mm6 + 8 + i * sizeof(SpriteFrame_mm6), sizeof(SpriteFrame_mm6)); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
404 pSpriteSFrames[num_mm7_frames + i].uAnimLength = 0; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
405 } |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
406 memcpy(pSpriteEFrames + num_mm7_frames, (char *)data_mm6 + 8 + mm6_frames_size, 2 * num_mm6_eframes); |
1541 | 407 |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
408 auto mm8_frames_size = num_mm8_frames * sizeof(SpriteFrame); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
409 memcpy(pSpriteSFrames + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 8, mm8_frames_size); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
410 memcpy(pSpriteEFrames + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 8 + mm8_frames_size, 2 * num_mm8_eframes); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
411 |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
412 for (uint i = 0; i < num_mm7_frames; ++i) |
0 | 413 pSpritePFrames[i] = &pSpriteSFrames[pSpriteEFrames[i]]; |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
414 |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
415 for (uint i = num_mm7_frames; i < num_mm6_frames + num_mm7_frames; ++i) |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
416 pSpritePFrames[i] = &pSpriteSFrames[pSpriteEFrames[i] + num_mm7_frames]; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
417 |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
418 for (uint i = num_mm6_frames + num_mm7_frames; i < num_mm6_frames + num_mm7_frames + num_mm8_frames; ++i) |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
419 pSpritePFrames[i] = &pSpriteSFrames[pSpriteEFrames[i] + num_mm6_frames + num_mm7_frames]; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
420 |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
421 //for (uint i = 0; i < uNumSpriteFrames; ++i) |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1295
diff
changeset
|
422 // pSpritePFrames[i] = &pSpriteSFrames[pSpriteEFrames[i]]; |
0 | 423 } |
424 | |
425 //----- (0044DA92) -------------------------------------------------------- | |
426 bool SpriteFrameTable::FromFileTxt(const char *Args) | |
427 { | |
428 SpriteFrameTable *v2; // ebx@1 | |
429 FILE *v3; // eax@1 | |
430 unsigned int v4; // esi@3 | |
431 signed int result; // eax@10 | |
432 FILE *v6; // ST18_4@11 | |
433 char *i; // eax@11 | |
434 const char *v8; // ST20_4@14 | |
435 __int16 v9; // ax@14 | |
436 const char *v10; // ST0C_4@14 | |
437 double v11; // st7@14 | |
438 int v12; // eax@14 | |
439 const char *v13; // ST04_4@14 | |
440 __int16 v14; // ax@14 | |
441 const char *v15; // ST00_4@14 | |
442 int v16; // eax@14 | |
443 int v17; // eax@17 | |
444 int v18; // eax@23 | |
445 int v19; // eax@24 | |
446 int v20; // eax@25 | |
447 int v21; // eax@28 | |
448 int v22; // eax@29 | |
449 int j; // edi@30 | |
450 const char *v24; // esi@31 | |
451 int v25; // eax@32 | |
452 int v26; // edx@53 | |
453 int v27; // ecx@54 | |
454 int v28; // eax@55 | |
455 signed int k; // edx@58 | |
456 SpriteFrame *v30; // ecx@59 | |
457 int v31; // esi@59 | |
458 int l; // eax@60 | |
459 signed int v33; // eax@65 | |
460 int v34; // edi@66 | |
461 int v35; // esi@66 | |
462 SpriteFrame **v36; // eax@69 | |
463 int v37; // ecx@69 | |
464 SpriteFrame *v38; // edx@69 | |
465 __int16 *v39; // eax@69 | |
466 int v40; // ecx@69 | |
467 char Buf[500]; // [sp+Ch] [bp-2F0h]@3 | |
468 FrameTableTxtLine v42; // [sp+200h] [bp-FCh]@4 | |
469 FrameTableTxtLine v43; // [sp+27Ch] [bp-80h]@4 | |
470 FILE *File; // [sp+2F8h] [bp-4h]@1 | |
471 unsigned int Argsa; // [sp+304h] [bp+8h]@3 | |
472 int Argsb; // [sp+304h] [bp+8h]@59 | |
473 FILE *Argsc; // [sp+304h] [bp+8h]@67 | |
474 | |
475 v2 = this; | |
476 ReleaseSFrames(); | |
477 v3 = fopen(Args, "r"); | |
478 File = v3; | |
479 if ( !v3 ) | |
1545 | 480 Error("CSpriteFrameTable::load - Unable to open file: %s.", Args); |
481 | |
0 | 482 v4 = 0; |
483 Argsa = 0; | |
484 if ( fgets(Buf, 490, v3) ) | |
485 { | |
486 do | |
487 { | |
488 *strchr(Buf, '\n') = 0; | |
489 memcpy(&v43, frame_table_txt_parser(Buf, &v42), sizeof(v43)); | |
701 | 490 if ( v43.uPropCount && *v43.pProperties[0] != '/' ) |
0 | 491 ++Argsa; |
492 } | |
493 while ( fgets(Buf, 490, File) ); | |
494 v4 = Argsa; | |
495 } | |
496 v2->uNumSpriteFrames = v4; | |
1583 | 497 v2->pSpriteSFrames = (SpriteFrame *)malloc(60 * v4); |
498 v2->pSpriteEFrames = (__int16 *)malloc(2 * v2->uNumSpriteFrames); | |
499 v2->pSpritePFrames = (SpriteFrame **)malloc(4 * v2->uNumSpriteFrames); | |
0 | 500 if ( v2->pSpriteSFrames ) |
501 { | |
502 v6 = File; | |
503 v2->uNumSpriteFrames = 0; | |
504 fseek(v6, 0, 0); | |
505 for ( i = fgets(Buf, 490, File); i; i = fgets(Buf, 490, File) ) | |
506 { | |
507 *strchr(Buf, 10) = 0; | |
508 memcpy(&v43, frame_table_txt_parser(Buf, &v42), sizeof(v43)); | |
701 | 509 if ( v43.uPropCount && *v43.pProperties[0] != '/' ) |
0 | 510 { |
511 v8 = v43.pProperties[0]; | |
512 v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags = 0; | |
513 v2->pSpriteSFrames[v2->uNumSpriteFrames].uPaletteIndex = 0; | |
514 strcpy(v2->pSpriteSFrames[v2->uNumSpriteFrames].pIconName, v8); | |
515 strcpy(v2->pSpriteSFrames[v2->uNumSpriteFrames].pTextureName, v43.pProperties[1]); | |
516 v9 = atoi(v43.pProperties[3]); | |
517 v10 = v43.pProperties[4]; | |
518 v2->pSpriteSFrames[v2->uNumSpriteFrames].uPaletteID = v9; | |
519 v11 = atof(v10) * 65536.0; | |
520 v12 = abs((signed __int64)v11); | |
521 v13 = v43.pProperties[5]; | |
522 v2->pSpriteSFrames[v2->uNumSpriteFrames].scale = v12; | |
523 v14 = atoi(v13); | |
524 v15 = v43.pProperties[6]; | |
525 v2->pSpriteSFrames[v2->uNumSpriteFrames].uGlowRadius = v14; | |
526 v2->pSpriteSFrames[v2->uNumSpriteFrames].uAnimTime = atoi(v15); | |
527 v16 = (int)&v2->pSpriteSFrames[v2->uNumSpriteFrames]; | |
528 if ( *(short *)(v16 + 48) ) | |
529 *(int *)(v16 + 44) |= 2u; | |
1104 | 530 if ( !_stricmp(v43.pProperties[2], "new") ) |
0 | 531 { |
532 v17 = (int)&v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags; | |
533 *(int *)v17 |= 4u; | |
534 v2->pSpritePFrames[v2->uNumEFrames] = &v2->pSpriteSFrames[v2->uNumSpriteFrames]; | |
535 v2->pSpriteEFrames[v2->uNumEFrames++] = LOWORD(v2->uNumSpriteFrames); | |
536 } | |
1104 | 537 if ( !_stricmp(v43.pProperties[10], "1") ) |
0 | 538 BYTE2(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 4u; |
1104 | 539 if ( !_stricmp(v43.pProperties[11], "1") ) |
0 | 540 BYTE2(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 2u; |
1104 | 541 if ( !_stricmp(v43.pProperties[12], "1") ) |
0 | 542 { |
543 v18 = (int)&v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags; | |
544 *(int *)v18 |= 0x20u; | |
545 } | |
546 v19 = atoi(v43.pProperties[7]) - 1; | |
547 if ( v19 ) | |
548 { | |
549 v20 = v19 - 2; | |
550 if ( v20 ) | |
551 { | |
552 if ( v20 == 2 ) | |
553 BYTE1(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 0xE0u; | |
554 } | |
555 else | |
556 { | |
557 v21 = (int)&v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags; | |
558 *(int *)v21 |= 0x1E000u; | |
559 } | |
560 } | |
561 else | |
562 { | |
563 v22 = (int)&v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags; | |
564 *(int *)v22 |= 0x10u; | |
565 } | |
701 | 566 for ( j = 13; j < v43.uPropCount; ++j ) |
0 | 567 { |
568 v24 = v43.pProperties[j]; | |
1104 | 569 if ( _stricmp(v43.pProperties[j], "Luminous") ) |
0 | 570 { |
1104 | 571 if ( _stricmp(v24, "Mirror0") ) |
0 | 572 { |
1104 | 573 if ( _stricmp(v24, "Mirror1") ) |
0 | 574 { |
1104 | 575 if ( _stricmp(v24, "Mirror2") ) |
0 | 576 { |
1104 | 577 if ( _stricmp(v24, "Mirror3") ) |
0 | 578 { |
1104 | 579 if ( _stricmp(v24, "Mirror4") ) |
0 | 580 { |
1104 | 581 if ( _stricmp(v24, "Mirror5") ) |
0 | 582 { |
1104 | 583 if ( _stricmp(v24, "Mirror6") ) |
0 | 584 { |
1104 | 585 if ( !_stricmp(v24, "Mirror7") ) |
0 | 586 BYTE1(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 0x80u; |
587 } | |
588 else | |
589 { | |
590 BYTE1(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 0x40u; | |
591 } | |
592 } | |
593 else | |
594 { | |
595 BYTE1(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 0x20u; | |
596 } | |
597 } | |
598 else | |
599 { | |
600 BYTE1(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 0x10u; | |
601 } | |
602 } | |
603 else | |
604 { | |
605 BYTE1(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 8u; | |
606 } | |
607 } | |
608 else | |
609 { | |
610 BYTE1(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 4u; | |
611 } | |
612 } | |
613 else | |
614 { | |
615 BYTE1(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 2u; | |
616 } | |
617 } | |
618 else | |
619 { | |
620 BYTE1(v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags) |= 1u; | |
621 } | |
622 } | |
623 else | |
624 { | |
625 v25 = (int)&v2->pSpriteSFrames[v2->uNumSpriteFrames].uFlags; | |
626 *(int *)v25 |= 2u; | |
627 } | |
628 } | |
629 ++v2->uNumSpriteFrames; | |
630 } | |
631 } | |
632 fclose(File); | |
633 v26 = 0; | |
634 if ( (signed int)(v2->uNumSpriteFrames - 1) > 0 ) | |
635 { | |
636 v27 = 0; | |
637 do | |
638 { | |
639 v28 = (int)&v2->pSpriteSFrames[v27]; | |
640 if ( !(*(char *)(v28 + 104) & 4) ) | |
641 *(int *)(v28 + 44) |= 1u; | |
642 ++v26; | |
643 ++v27; | |
644 } | |
645 while ( v26 < (signed int)(v2->uNumSpriteFrames - 1) ); | |
646 } | |
647 for ( k = 0; k < (signed int)v2->uNumSpriteFrames; *(short *)(Argsb + 56) = v31 ) | |
648 { | |
649 v30 = v2->pSpriteSFrames; | |
650 Argsb = (int)&v30[k]; | |
651 v31 = *(short *)(Argsb + 54); | |
652 if ( *(char *)(Argsb + 44) & 1 ) | |
653 { | |
654 ++k; | |
655 for ( l = (int)&v30[k]; *(char *)(l + 44) & 1; l += 60 ) | |
656 { | |
657 v31 += *(short *)(l + 54); | |
658 ++k; | |
659 } | |
660 LOWORD(v31) = v30[k].uAnimTime + v31; | |
661 } | |
662 ++k; | |
663 } | |
664 v33 = v2->uNumEFrames; | |
665 if ( v33 > 0 ) | |
666 { | |
667 v34 = 0; | |
668 v35 = 0; | |
669 File = (FILE *)1; | |
670 do | |
671 { | |
672 Argsc = File; | |
673 if ( (signed int)File < v33 ) | |
674 { | |
675 do | |
676 { | |
1104 | 677 if ( _stricmp(v2->pSpritePFrames[(int)Argsc]->pIconName, v2->pSpritePFrames[v35]->pIconName) < 0 ) |
0 | 678 { |
679 v36 = v2->pSpritePFrames; | |
680 v37 = (int)&v36[(int)Argsc]; | |
681 v38 = *(SpriteFrame **)v37; | |
682 *(int *)v37 = (int)v36[v35]; | |
683 v2->pSpritePFrames[v35] = v38; | |
684 v39 = v2->pSpriteEFrames; | |
685 v40 = (int)&v39[(int)Argsc]; | |
686 LOWORD(v38) = *(short *)v40; | |
687 *(short *)v40 = v39[v34]; | |
688 v2->pSpriteEFrames[v34] = (signed __int16)v38; | |
689 } | |
690 Argsc = (FILE *)((char *)Argsc + 1); | |
691 } | |
692 while ( (signed int)Argsc < v2->uNumEFrames ); | |
693 } | |
694 File = (FILE *)((char *)File + 1); | |
695 v33 = v2->uNumEFrames; | |
696 ++v35; | |
697 ++v34; | |
698 } | |
699 while ( (signed int)((char *)File - 1) < v33 ); | |
700 } | |
701 result = 1; | |
702 } | |
703 else | |
704 { | |
705 MessageBoxW(nullptr, L"CSpriteFrameTable::load - Out of Memory!", nullptr, 0); | |
706 fclose(File); | |
707 result = 0; | |
708 } | |
709 return result; | |
1295 | 710 } |
711 //----- (0046E26D) -------------------------------------------------------- | |
712 void __fastcall _46E26D_collide_against_sprites(signed int a1, signed int a2) | |
713 { | |
714 int v2; // edx@5 | |
715 unsigned __int16 *v3; // eax@5 | |
716 unsigned __int16 v4; // ax@6 | |
717 LevelDecoration *v5; // edi@7 | |
718 DecorationDesc *v6; // esi@8 | |
719 int v7; // edx@9 | |
720 int v8; // eax@9 | |
721 int v9; // ecx@11 | |
722 int v10; // ebx@13 | |
723 int v11; // esi@13 | |
724 int v12; // ebp@15 | |
725 int v13; // ebx@15 | |
726 int v14; // esi@16 | |
727 int v15; // edi@17 | |
728 int v16; // eax@17 | |
729 int v17; // esi@19 | |
730 char v18; // zf@23 | |
731 int v19; // [sp+0h] [bp-10h]@15 | |
732 unsigned __int16 *v20; // [sp+4h] [bp-Ch]@5 | |
733 int v21; // [sp+8h] [bp-8h]@15 | |
734 int v22; // [sp+Ch] [bp-4h]@13 | |
735 | |
736 if ( a1 >= 0 ) | |
737 { | |
738 if ( a1 <= 127 ) | |
739 { | |
740 if ( a2 >= 0 ) | |
741 { | |
742 if ( a2 <= 127 ) | |
743 { | |
744 v2 = a1 + (a2 << 7); | |
745 v3 = &pOutdoor->pFaceIDLIST[pOutdoor->pOMAP[v2]]; | |
746 v20 = &pOutdoor->pFaceIDLIST[pOutdoor->pOMAP[v2]]; | |
747 if ( v3 ) | |
748 { | |
749 do | |
750 { | |
751 v4 = *v3; | |
752 if ( PID_TYPE(v4) == OBJECT_Decoration) | |
753 { | |
754 v5 = &pLevelDecorations[(signed __int16)v4 >> 3]; | |
1489 | 755 if (!(v5->uFlags & LEVEL_DECORATION_INVISIBLE)) |
1295 | 756 { |
757 v6 = &pDecorationList->pDecorations[v5->uDecorationDescID]; | |
758 if (!v6->CanMoveThrough()) | |
759 { | |
760 v7 = v6->uRadius; | |
761 v8 = v5->vPosition.x; | |
762 if ( stru_721530.sMaxX <= v8 + v7 ) | |
763 { | |
764 if ( stru_721530.sMinX >= v8 - v7 ) | |
765 { | |
766 v9 = v5->vPosition.y; | |
767 if ( stru_721530.sMaxY <= v9 + v7 ) | |
768 { | |
769 if ( stru_721530.sMinY >= v9 - v7 ) | |
770 { | |
771 v10 = v6->uDecorationHeight; | |
772 v11 = v5->vPosition.z; | |
773 v22 = v10; | |
774 if ( stru_721530.sMaxZ <= v11 + v10 ) | |
775 { | |
776 if ( stru_721530.sMinZ >= v11 ) | |
777 { | |
778 v12 = v8 - stru_721530.normal.x; | |
779 v19 = v9 - stru_721530.normal.y; | |
780 v13 = stru_721530.prolly_normal_d + v7; | |
1546 | 781 v21 = ((v8 - stru_721530.normal.x) * stru_721530.direction.y |
782 - (v9 - stru_721530.normal.y) * stru_721530.direction.x) >> 16; | |
1295 | 783 if ( abs(v21) <= stru_721530.prolly_normal_d + v7 ) |
784 { | |
1546 | 785 v14 = (v12 * stru_721530.direction.x + v19 * stru_721530.direction.y) >> 16; |
1295 | 786 if ( v14 > 0 ) |
787 { | |
788 v15 = v5->vPosition.z; | |
789 v16 = stru_721530.normal.z | |
1546 | 790 + ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v14) >> 16); |
1295 | 791 if ( v16 >= v15 ) |
792 { | |
793 if ( v16 <= v22 + v15 ) | |
794 { | |
795 v17 = v14 - integer_sqrt(v13 * v13 - v21 * v21); | |
796 if ( v17 < 0 ) | |
797 v17 = 0; | |
798 if ( v17 < stru_721530.field_7C ) | |
799 { | |
800 stru_721530.field_7C = v17; | |
801 stru_721530.uFaceID = (signed __int16)*v20; | |
802 } | |
803 } | |
804 } | |
805 } | |
806 } | |
807 } | |
808 } | |
809 } | |
810 } | |
811 } | |
812 } | |
813 } | |
814 } | |
815 } | |
816 v3 = v20 + 1; | |
817 v18 = *v20 == 0; | |
818 ++v20; | |
819 } | |
820 while ( !v18 ); | |
821 } | |
822 } | |
823 } | |
824 } | |
825 } | |
826 } |