comparison Arcomage.cpp @ 1184:a90dc4aee8f4

arcomage refactoring continued
author Gloval
date Thu, 06 Jun 2013 08:33:43 +0400
parents fa30ea497e94
children 24454b5c9268
comparison
equal deleted inserted replaced
1183:fa30ea497e94 1184:a90dc4aee8f4
100 {125, 350, 10, 20, 3, 1, 2, 15, 5, 10, 2}, 100 {125, 350, 10, 20, 3, 1, 2, 15, 5, 10, 2},
101 {125, 350, 10, 20, 3, 1, 2, 15, 5, 10, 1}, 101 {125, 350, 10, 20, 3, 1, 2, 15, 5, 10, 1},
102 {100, 300, 50, 50, 5, 3, 5, 20, 10, 20, 0} 102 {100, 300, 50, 50, 5, 3, 5, 20, 10, 20, 0}
103 }; 103 };
104 104
105 105 #define SIG_trpg 0x67707274
106 106 #define SIG_xxxx 0x78787878
107 107
108 ArcomageGame *pArcomageGame = new ArcomageGame; 108 ArcomageGame *pArcomageGame = new ArcomageGame;
109 ArcomageCard pCards[87]; 109 ArcomageCard pCards[87];
110 ArcomagePlayer am_Players[2]; 110 ArcomagePlayer am_Players[2];
111 111
112 Acromage_st1 struct_st1[10]; 112 Acromage_st1 struct_st1[10];
113 113
114 stru272 array_4FAC10[10]; 114 stru272 array_4FABD0[10];
115 115
116 116
117 117
118 /* 267 */ 118 /* 267 */
119 #pragma pack(push, 1) 119 #pragma pack(push, 1)
166 166
167 auto a1 = this; 167 auto a1 = this;
168 return a1->x >= pXYZW->x && a1->x <= pXYZW->z && (v2 = a1->y, v2 >= pXYZW->y) && v2 <= pXYZW->w; 168 return a1->x >= pXYZW->x && a1->x <= pXYZW->z && (v2 = a1->y, v2 >= pXYZW->y) && v2 <= pXYZW->w;
169 } 169 }
170 170
171 171 //----- (0040DFD1) --------------------------------------------------------
172 void stru272_stru0::_40DFD1(stru272_stru0 *a1)
173 {
174 stru272_stru0 *v2; // eax@1
175 v2 = (stru272_stru0 *)malloc(0x5Cu);
176 a1 = v2;
177 v2->signature = SIG_trpg;
178 v2->field_8 = 0;
179 v2->field_30 = 0.0;
180 v2->field_58 = 0;
181 v2->field_59 = 0;
182 }
183
184 //----- (0040DFFE) --------------------------------------------------------
185 int stru272_stru0::_40DFFE()
186 {
187
188 if ( this->signature == SIG_trpg )
189 {
190 this->signature = SIG_xxxx;
191 free(this);
192 return 0;
193 }
194 else
195 return 2;
196
197 }
198
199 //----- (0040E01A) --------------------------------------------------------
200 int stru272_stru0::_40E01A(int a2)
201 {
202 signed int result; // eax@2
203
204 auto a1 = this;
205 if ( a1->signature == SIG_trpg )
206 {
207 a1->field_4 = *(int *)(a2 + 32);
208 a1->field_C = *(int *)a2 << 16;
209 a1->field_10 = *(int *)(a2 + 4) << 16;
210 a1->field_14 = *(int *)(a2 + 8) << 16;
211 a1->field_18 = *(int *)(a2 + 12) << 16;
212 a1->field_1C = *(int *)(a2 + 16);
213 a1->field_20 = *(int *)(a2 + 20);
214 a1->field_24 = *(int *)(a2 + 24);
215 a1->field_28 = *(float *)(a2 + 28) * 65536.0;
216 LODWORD(a1->field_2C) = *(int *)(a2 + 36);
217 a1->field_34 = (signed __int64)(*(float *)(a2 + 40) * 65536.0);
218 a1->field_38 = (signed __int64)(*(float *)(a2 + 44) * 65536.0);
219 a1->field_3C = *(int *)(a2 + 48);
220 a1->field_40 = *(int *)(a2 + 52);
221 // a1->field_54 = *(int *)(a2 + 56);
222 a1->field_59 = 1;
223 result = 0;
224 }
225 else
226 {
227 result = 2;
228 }
229 return result;
230 }
231
232 //----- (0040E0F5) --------------------------------------------------------
233 int stru272_stru0::_40E0F5(char a2, char a3)
234 {
235 signed int result; // eax@2
236 int v4; // edx@7
237 int v5; // eax@7
238
239 auto a1 = this;
240 if ( a1->signature == SIG_trpg)
241 {
242 if ( a2 )
243 {
244 a1->field_8 = 0;
245 a1->field_30 = 0.0;
246 }
247 if ( a1->field_59 && a3 )
248 {
249 v4 = a1->field_4;
250 // v5 = a1->field_54;
251 do
252 {
253 *(int *)v5 = 0;
254 v5 += 28;
255 --v4;
256 }
257 while ( v4 );
258 a1->field_58 = 0;
259 }
260 result = 0;
261 }
262 else
263 {
264 result = 2;
265 }
266 return result;
267 }
268
269 //----- (0040E133) --------------------------------------------------------
270 int stru272_stru0::_40E133()
271 {
272 stru272_stru0 *v1; // edi@1
273 int v3; // ST18_4@3
274 double v4; // st7@3
275 double v5; // st6@4
276 char v6; // bl@8
277 int v7; // esi@8
278 int v8; // ecx@10
279 signed int v9; // eax@10
280 int v10; // ecx@10
281 signed int v11; // eax@10
282 signed int v12; // edx@12
283 signed int v13; // edx@12
284 int v14; // [sp+8h] [bp-10h]@8
285 int v15; // [sp+Ch] [bp-Ch]@8
286 float v16; // [sp+14h] [bp-4h]@3
287
288 v1 = this;
289 if ( this->signature != SIG_trpg )
290 return 2;
291 v3 = this->field_8;
292 v16 = this->field_30;
293 v4 = (double)v3;
294 if ( v3 > 0 )
295 {
296 v5 = v16 + this->field_2C;
297 v16 = v5;
298 if ( v5 > v4 )
299 v16 = v4;
300 }
301 if ( v16 >= 1.0 || this->field_58 )
302 {
303 v6 = 0;
304 // v7 = this->field_54;
305 v14 = (signed __int64)this->field_28;
306 v15 = this->field_4;
307 while ( *(int *)v7 <= 0 )
308 {
309 if ( v16 >= 1.0 )
310 {
311 *(int *)v7 = v1->field_3C + rand() % (v1->field_40 - v1->field_3C + 1);
312 *(int *)(v7 + 20) = (rand() % 17 - 8) << 16;
313 *(int *)(v7 + 24) = (rand() % 17 - 8) << 16;
314 v12 = v1->field_C + rand() % (v1->field_14 - 1 - v1->field_C + 1);
315 *(int *)(v7 + 12) = v12;
316 *(int *)(v7 + 4) = v12 >> 16;
317 v16 = v16 - 1.0;
318 v13 = v1->field_10 + rand() % (v1->field_18 - 1 - v1->field_10 + 1);
319 *(int *)(v7 + 16) = v13;
320 *(int *)(v7 + 8) = v13 >> 16;
321 --v1->field_8;
322 goto LABEL_13;
323 }
324 LABEL_14:
325 v7 += 28;
326 --v15;
327 if ( !v15 )
328 {
329 v1->field_58 = v6;
330 v1->field_30 = v16;
331 return 0;
332 }
333 }
334 v8 = *(int *)(v7 + 20);
335 --*(int *)v7;
336 v9 = v8 + *(int *)(v7 + 12);
337 v10 = v14 + *(int *)(v7 + 24);
338 *(int *)(v7 + 12) = v9;
339 *(int *)(v7 + 4) = v9 >> 16;
340 v11 = v10 + *(int *)(v7 + 16);
341 *(int *)(v7 + 24) = v10;
342 *(int *)(v7 + 16) = v11;
343 *(int *)(v7 + 8) = v11 >> 16;
344 LABEL_13:
345 v6 = 1;
346 goto LABEL_14;
347 }
348 return 0;
349 }
350
351 //----- (0040E2A7) --------------------------------------------------------
352 int stru272_stru0::_40E2A7()
353 {
354 int result; // eax@2
355
356 if ( this->signature == SIG_trpg )
357 {
358 if ( this->field_8 <= 0 )
359 result = this->field_58 != 0 ? 2 : 0;
360 else
361 result = 1;
362 }
363 else
364 {
365 result = 3;
366 }
367 return result;
368 }
172 369
173 370
174 //----- (0040DFAF) -------------------------------------------------------- 371 //----- (0040DFAF) --------------------------------------------------------
175 void ArcomageGame::OnMouseClick(char right_left, bool bDown) 372 void ArcomageGame::OnMouseClick(char right_left, bool bDown)
176 { 373 {
1368 { 1565 {
1369 dword_4FAA70 = -1; 1566 dword_4FAA70 = -1;
1370 } 1567 }
1371 pVideoPlayer->BinkUpdatePalette(dword_4FAA28); 1568 pVideoPlayer->BinkUpdatePalette(dword_4FAA28);
1372 1569
1373 /*v3 = array_4FAC10; 1570 for(int i=0; i<10; ++i)
1374 do 1571 {
1375 { 1572 array_4FABD0[i].field_40->_40E0F5(1,1);
1376 v3->ptr_0->_40E0F5(1, 1); 1573 array_4FABD0[i].field_40->_40DFFE();
1377 v3->ptr_0->_40DFFE(); 1574 }
1378 ++v3;
1379 }
1380 while ( (signed int)v3 < (signed int)&unk_5052C8 );*/
1381 1575
1382 pArcomageGame->pGameBackground.Release(); 1576 pArcomageGame->pGameBackground.Release();
1383 pArcomageGame->pSprites.Release(); 1577 pArcomageGame->pSprites.Release();
1384 pArcomageGame->bGameInProgress = 0; 1578 pArcomageGame->bGameInProgress = 0;
1385 viewparams->bRedrawGameUI = 1; 1579 viewparams->bRedrawGameUI = 1;
1565 } 1759 }
1566 while ( *v7 == 1 ); 1760 while ( *v7 == 1 );
1567 *v7 = 1; 1761 *v7 = 1;
1568 dword_505314[v4] = dword_505554[v6]; 1762 dword_505314[v4] = dword_505554[v6];
1569 result = byte_5054E8[v6]; 1763 result = byte_5054E8[v6];
1570 array_4FAC10[9].field_4[v4++ + 4232] = result;//затирает pArcomageGame 1764 //array_4FABD0[9].field_4[v4++ + 4232] = result;//затирает pArcomageGame
1571 } 1765 }
1572 while ( v4 < 108 ); 1766 while ( v4 < 108 );
1573 dword_4FABC8 = 0; 1767 dword_4FABC8 = 0;
1574 amuint_4FABC4 = -1; 1768 amuint_4FABC4 = -1;
1575 pArcomageGame->field_F6 = 1; 1769 pArcomageGame->field_F6 = 1;
1614 if ( v2 >= 108 ) 1808 if ( v2 >= 108 )
1615 { 1809 {
1616 am_40A198(); 1810 am_40A198();
1617 v2 = dword_4FABC8; 1811 v2 = dword_4FABC8;
1618 } 1812 }
1619 if ( !array_4FAC10[9].field_4[v2 + 4232] ) 1813 /*if ( !array_4FABD0[9].field_4[v2 + 4232] )
1620 { 1814 {
1621 v3 = dword_505314[v2]; 1815 v3 = dword_505314[v2];
1622 v5 = 1; 1816 v5 = 1;
1623 } 1817 }*/
1624 ++v2; 1818 ++v2;
1625 dword_4FABC8 = v2; 1819 dword_4FABC8 = v2;
1626 } 1820 }
1627 while ( !v5 ); 1821 while ( !v5 );
1628 ArcomageGame::PlaySound(0x15u); 1822 ArcomageGame::PlaySound(0x15u);
2052 am_chroma_blt(); 2246 am_chroma_blt();
2053 am_DrawUI(); 2247 am_DrawUI();
2054 am_EndScene(); 2248 am_EndScene();
2055 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1); 2249 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1);
2056 am_40B76F(v1); 2250 am_40B76F(v1);
2057 v2 = (stru272_stru0 **)array_4FAC10; 2251 v2 = (stru272_stru0 **)array_4FABD0;
2058 do 2252 do
2059 { 2253 {
2060 if ( *((unsigned char *)v2 - 64) ) 2254 if ( *((unsigned char *)v2 - 64) )
2061 (*v2)->_40E133(); 2255 (*v2)->_40E133();
2062 v2 += 1067; 2256 v2 += 1067;
2130 } 2324 }
2131 while ( v3 < 150 ); 2325 while ( v3 < 150 );
2132 } 2326 }
2133 v0 += 4268; 2327 v0 += 4268;
2134 } 2328 }
2135 while ( v0 < (signed int)&array_4FAC10[9].field_4[4201] ); 2329 while ( v0 < 1);//(signed int)&array_4FABD0[9].field_4[4201] );
2136 } 2330 }
2137 2331
2138 //----- (0040AB0A) -------------------------------------------------------- 2332 //----- (0040AB0A) --------------------------------------------------------
2139 void __cdecl am_chroma_blts() 2333 void __cdecl am_chroma_blts()
2140 { 2334 {
5340 5534
5341 v11 = 0; 5535 v11 = 0;
5342 v2 = a2; 5536 v2 = a2;
5343 v3 = a1; 5537 v3 = a1;
5344 v4 = byte_4FABD0; 5538 v4 = byte_4FABD0;
5345 v12 = (stru272_stru0 **)array_4FAC10; 5539 v12 = (stru272_stru0 **)array_4FABD0;
5346 while ( *v4 ) 5540 while ( *v4 )
5347 { 5541 {
5348 result = (*v12)->_40E2A7(); 5542 result = (*v12)->_40E2A7();
5349 if ( !result ) 5543 if ( !result )
5350 { 5544 {
5372 } 5566 }
5373 *(unsigned int *)((char *)&unk_4FABD4 + v6) = v3->x - 20; 5567 *(unsigned int *)((char *)&unk_4FABD4 + v6) = v3->x - 20;
5374 dword_4FABDC[v6 / 4] = v3->x + 20; 5568 dword_4FABDC[v6 / 4] = v3->x + 20;
5375 dword_4FABD8[v6 / 4] = v3->y - 20; 5569 dword_4FABD8[v6 / 4] = v3->y - 20;
5376 dword_4FABE0[v6 / 4] = v3->y + 20; 5570 dword_4FABE0[v6 / 4] = v3->y + 20;
5377 v7 = array_4FAC10[v6 / 0x10AC].ptr_0; 5571 // v7 = array_4FABD0[v6 / 0x10AC]
5378 dword_4FABE4[v6 / 4] = -60; 5572 dword_4FABE4[v6 / 4] = -60;
5379 dword_4FABE8[v6 / 4] = 60; 5573 dword_4FABE8[v6 / 4] = 60;
5380 dword_4FABEC[v6 / 4] = 180; 5574 dword_4FABEC[v6 / 4] = 180;
5381 dword_4FABF0[v6 / 4] = 0x3F000000u; 5575 dword_4FABF0[v6 / 4] = 0x3F000000u;
5382 dword_4FABF4[v6 / 4] = 150; 5576 dword_4FABF4[v6 / 4] = 150;
5383 dword_4FABF8[v6 / 4] = 0x42480000u; 5577 dword_4FABF8[v6 / 4] = 0x42480000u;
5384 dword_4FABFC[v6 / 4] = 0x40400000u; 5578 dword_4FABFC[v6 / 4] = 0x40400000u;
5385 dword_4FAC00[v6 / 4] = 0x41000000u; 5579 dword_4FAC00[v6 / 4] = 0x41000000u;
5386 dword_4FAC04[v6 / 4] = 5; 5580 dword_4FAC04[v6 / 4] = 5;
5387 dword_4FAC08[v6 / 4] = 15; 5581 dword_4FAC08[v6 / 4] = 15;
5388 dword_4FAC0C[v6 / 4] = (int)array_4FAC10[v6 / 0x10AC].field_4; 5582 dword_4FAC0C[v6 / 4] = (int)array_4FABD0[v6 / 0x10AC].field_4;
5389 v7->_40E01A((int)((char *)&unk_4FABD4 + v6)); 5583 v7->_40E01A((int)((char *)&unk_4FABD4 + v6));
5390 if ( 10 * v2 > 150 ) 5584 if ( 10 * v2 > 150 )
5391 v2 = 15; 5585 v2 = 15;
5392 v8 = array_4FAC10[v6 / 0x10AC].ptr_0; 5586 // v8 = array_4FABD0[v6 / 0x10AC].ptr_0;
5393 if ( v8->field_0 != 0x67707274 ) 5587 if ( v8->signature != SIG_trpg )
5394 return 2; 5588 return 2;
5395 if ( !v8->field_59 ) 5589 if ( !v8->field_59 )
5396 return 3; 5590 return 3;
5397 v8->field_8 = 10 * v2; 5591 v8->field_8 = 10 * v2;
5398 v9 = v8->field_4; 5592 v9 = v8->field_4;
5400 v8->field_58 = 0; 5594 v8->field_58 = 0;
5401 v8->field_44 = 0; 5595 v8->field_44 = 0;
5402 v8->field_4C = 0; 5596 v8->field_4C = 0;
5403 v8->field_48 = 0; 5597 v8->field_48 = 0;
5404 v8->field_50 = 0; 5598 v8->field_50 = 0;
5405 v10 = v8->field_54; 5599 /*v10 = v8->field_54;
5406 do 5600 do
5407 { 5601 {
5408 *(unsigned int *)v10 = 0; 5602 *(unsigned int *)v10 = 0;
5409 v10 += 28; 5603 v10 += 28;
5410 --v9; 5604 --v9;
5411 } 5605 }*/
5412 while ( v9 ); 5606 while ( v9 );
5413 return 0; 5607 return 0;
5414 } 5608 }
5415 // 40D2B4: using guessed type int __fastcall am_40D2B4(uint, uint); 5609 // 40D2B4: using guessed type int __fastcall am_40D2B4(uint, uint);
5416 // 4FABD8: using guessed type int dword_4FABD8[]; 5610 // 4FABD8: using guessed type int dword_4FABD8[];
5737 5931
5738 v4 = 120; 5932 v4 = 120;
5739 for (int i=0; i<12; ++i) 5933 for (int i=0; i<12; ++i)
5740 am_sounds[i] = pSoundList->LoadSound(v4++, 0); 5934 am_sounds[i] = pSoundList->LoadSound(v4++, 0);
5741 5935
5742 //v5 = array_4FAC10; 5936
5743 //do 5937 for (int i=0; i<10; ++i)
5744 //{ 5938 array_4FABD0[i].field_40->_40DFD1(array_4FABD0[i].field_40);
5745 // v5->_40DFD1(); 5939
5746 // ++v5;
5747 //}
5748 //while ( (signed int)v5 < 10 );//(signed int)&unk_5052C8 );
5749
5750 dword_4FABBC = -1; 5940 dword_4FABBC = -1;
5751 amuint_4FAA4C = -1; 5941 amuint_4FAA4C = -1;
5752 byte_4FAA74 = 0; 5942 byte_4FAA74 = 0;
5753 pArcomageGame->field_F4 = 0; 5943 pArcomageGame->field_F4 = 0;
5754 byte_4FAA2C = 0; 5944 byte_4FAA2C = 0;