comparison Arcomage.cpp @ 0:9c0607679772

init
author Ritor1
date Sat, 12 Jan 2013 09:45:18 +0600
parents
children 038a4d09406f
comparison
equal deleted inserted replaced
-1:000000000000 0:9c0607679772
1 #include <string>
2
3 #include "Arcomage.h"
4 #include "VideoPlayer.h"
5 #include "AudioPlayer.h"
6 #include "Mouse.h"
7 #include "Game.h"
8 #include "Viewport.h"
9 #include "Time.h"
10 #include "GUIFont.h"
11 #include "Party.h"
12 #include "GUIWindow.h"
13 #include "Events2D.h"
14 #include "stru272.h"
15 #include "VectorTypes.h"
16
17 #include "mm7_data.h"
18
19
20
21
22
23 ArcomageGame *pArcomageGame = new ArcomageGame;
24 ArcomageCard pCards[87];
25 ArcomageGame_stru0 stru_505708[2];
26
27
28
29
30
31 /* 267 */
32 #pragma pack(push, 1)
33 struct stru273
34 {
35 bool _40DD2F();
36 bool Inside(Vec4_int_ *pXYZW);
37
38 int x;
39 int y;
40 char field_8;
41 char field_9;
42 char field_A;
43 char field_B;
44 };
45 #pragma pack(pop)
46
47
48
49
50
51
52
53
54 //----- (0040DD2F) --------------------------------------------------------
55 bool stru273::_40DD2F()
56 {
57 bool result; // eax@1
58
59 this->x = pArcomageGame->mouse_x;
60 result = pArcomageGame->mouse_y;
61 this->y = pArcomageGame->mouse_y;
62 this->field_8 = pArcomageGame->mouse_left;
63 this->field_9 = pArcomageGame->mouse_left == pArcomageGame->field_F7;
64 this->field_8 = pArcomageGame->mouse_left;
65 this->field_B = pArcomageGame->mouse_right == pArcomageGame->field_F8;
66 pArcomageGame->field_F7 = pArcomageGame->mouse_left;
67 pArcomageGame->field_F8 = pArcomageGame->mouse_right;
68 LOBYTE(result) = 1;
69 return result;
70 }
71
72 //----- (0040DD93) --------------------------------------------------------
73 bool stru273::Inside(Vec4_int_ *pXYZW)
74 {
75 int v2; // eax@3
76
77 auto a1 = this;
78 return a1->x >= pXYZW->x && a1->x <= pXYZW->z && (v2 = a1->y, v2 >= pXYZW->y) && v2 <= pXYZW->w;
79 }
80
81
82
83
84 //----- (0040DFAF) --------------------------------------------------------
85 void ArcomageGame::OnMouseClick(char right_left, bool bDown)
86 {
87 if ( right_left )
88 pArcomageGame->mouse_right = bDown;
89 else
90 pArcomageGame->mouse_left = bDown;
91 }
92
93 //----- (0040DFC1) --------------------------------------------------------
94 void ArcomageGame::OnMouseMove(POINT *pXY)
95 {
96 pArcomageGame->mouse_x = pXY->x;
97 pArcomageGame->mouse_y = pXY->y;
98 }
99
100
101 //----- (0040DF47) --------------------------------------------------------
102 void DoBlt_Copy(unsigned __int16 *pPixels)
103 {
104 unsigned __int16 *v1; // ebx@1
105 ArcomageRect rect; // [sp+Ch] [bp-18h]@1
106 int pTargetXY[2]; // [sp+1Ch] [bp-8h]@1
107
108 v1 = pPixels;
109 pRenderer->Present();
110 pTargetXY[0] = 0;
111 pTargetXY[1] = 0;
112 rect.x = 0;
113 rect.z = 640;
114 rect.y = 0;
115 rect.w = 480;
116 pRenderer->BeginScene();
117 pArcomageGame->pBlit_Copy_pixels = v1;
118 Blt_Copy(&rect, pTargetXY, 2);
119 pRenderer->EndScene();
120 pArcomageGame->pBlit_Copy_pixels = 0;
121 }
122
123 //----- (0040DDC9) --------------------------------------------------------
124 void __thiscall ArcomageGame::PlaySound(unsigned int a1)
125 {
126 SoundID v1; // eax@10
127 signed int v2; // [sp-4h] [bp-4h]@2
128
129 switch ( a1 )
130 {
131 case 0x28u:
132 case 0x2Bu:
133 case 0x2Eu:
134 v2 = SOUND_Arcomage_LoseResources;
135 goto LABEL_10;
136 case 0x27u:
137 case 0x29u:
138 case 0x2Au:
139 case 0x2Cu:
140 case 0x2Du:
141 case 0x2Fu:
142 v2 = SOUND_Arcomage_AddResources;
143 goto LABEL_10;
144 case 0u:
145 case 0xCu:
146 case 0xEu:
147 case 0xFu:
148 case 0x10u:
149 case 0x30u:
150 case 0x32u:
151 case 0x35u:
152 v2 = SOUND_Arcomage_TowerWallDamage;
153 goto LABEL_10;
154 case 0x15u:
155 case 0x16u:
156 case 0x17u:
157 v2 = SOUND_Arcomage_DrawCard;
158 goto LABEL_10;
159 case 0x38u:
160 v2 = 124;
161 goto LABEL_10;
162 case 0x1Fu:
163 case 0x22u:
164 case 0x25u:
165 v2 = SOUND_Arcomage_ProductionDamage;
166 goto LABEL_10;
167 case 1u:
168 case 0x1Eu:
169 case 0x20u:
170 case 0x21u:
171 case 0x23u:
172 case 0x24u:
173 case 0x26u:
174 v2 = SOUND_Arcomage_ProductionUpgrade;
175 goto LABEL_10;
176 case 0x14u:
177 v2 = SOUND_Arcomage_127;
178 LABEL_10:
179 v1 = (SoundID)v2;
180 goto LABEL_16;
181 case 3u:
182 v1 = SOUND_Arcomage_128;
183 goto LABEL_16;
184 case 0x34u:
185 case 0x36u:
186 v1 = SOUND_Arcomage_TowerUpgrade;
187 goto LABEL_16;
188 case 0xAu:
189 case 0xBu:
190 case 0xDu:
191 v1 = (SoundID)130;
192 goto LABEL_16;
193 case 0x37u:
194 v1 = (SoundID)131;
195 goto LABEL_16;
196 case 0x31u:
197 case 0x33u:
198 v1 = SOUND_Arcomage_WallUpgrade;
199 LABEL_16:
200 pAudioPlayer->PlaySound(v1, 0, 0, -1, 0, 0, 0, 0);
201 break;
202 default:
203 return;
204 }
205 }
206
207 //----- (0040DC2D) --------------------------------------------------------
208 bool ArcomageGame::MsgLoop(int a1, ArcomageGame_stru1 *a2)
209 {
210 void *v2; // ebp@1
211 BOOL v3; // eax@1
212 int v4; // edx@6
213 int v5; // edx@6
214 int v6; // eax@6
215 int v7; // edx@7
216
217 v2 = a2;
218 pArcomageGame->field_0 = 0;
219 pArcomageGame->stru1.field_0 = 0;
220 v3 = PeekMessageA(&pArcomageGame->msg, 0, 0, 0, PM_REMOVE);
221 if ( pArcomageGame->msg.message == WM_QUIT )
222 Game_DeinitializeAndTerminate(0);
223 if ( v3 > 0 )
224 {
225 TranslateMessage(&pArcomageGame->msg);
226 DispatchMessageA(&pArcomageGame->msg);
227 }
228 if (pAsyncMouse)
229 {
230 EnterCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse);
231 v4 = *((unsigned int *)pAsyncMouse + 7);
232 pArcomageGame->mouse_x = *((unsigned int *)pAsyncMouse + 6);
233 pArcomageGame->mouse_y = v4;
234 v5 = *((unsigned int *)pAsyncMouse + 27);
235 v6 = *(unsigned int *)v5;
236 if ( *(unsigned int *)v5 != v5 )
237 {
238 do
239 {
240 v7 = *(unsigned int *)(v6 + 20);
241 if ( v7 & 1 )
242 {
243 pArcomageGame->stru1.field_0 = 7;
244 }
245 else
246 {
247 if ( v7 & 2 )
248 pArcomageGame->stru1.field_0 = 8;
249 }
250 v6 = *(unsigned int *)v6;
251 }
252 while ( v6 != *((unsigned int *)pAsyncMouse + 27) );
253 }
254 pAsyncMouse->_46B944();
255 if ( !*((unsigned char *)pAsyncMouse + 90) )
256 pArcomageGame->field_F6 = 1;
257 LeaveCriticalSection(&pGame->pThreadWardInstance->csAsyncMouse);
258 }
259 memcpy(v2, &pArcomageGame->stru1, 0xCu);
260 return pArcomageGame->stru1.field_0 != 0;
261 }
262
263
264 //----- (0040D7D5) --------------------------------------------------------
265 void am_BeginScene(unsigned __int16 *pPcxPixels, int a2, int a3)
266 {
267 unsigned __int16 *v3; // esi@1
268
269 v3 = pPcxPixels;
270 pRenderer->BeginScene();
271 pArcomageGame->pBlit_Copy_pixels = v3;
272 }
273
274 //----- (0040D7EC) --------------------------------------------------------
275 void __fastcall Blt_Chroma(ArcomageRect *pSrcXYZW, int *pTargetXY, int a3, int a4)
276 {
277 ArcomageRect *pSrcXYZW_; // esi@1
278 int x; // ecx@1
279 int y; // edx@1
280 unsigned __int16 *pSrc; // eax@2
281 unsigned __int16 *v8; // edi@3
282 int uSrcTotalWidth; // ecx@4
283 unsigned int v10; // esi@9
284 int v11; // ebx@11
285 unsigned __int16 *v12; // edx@11
286 char v13; // zf@17
287 unsigned __int16 *v14; // ebx@20
288 int v15; // eax@20
289 unsigned __int16 *v16; // ecx@20
290 unsigned int v17; // eax@23
291 std::string v18; // [sp-18h] [bp-3Ch]@8
292 const char *v19; // [sp-8h] [bp-2Ch]@8
293 int v20; // [sp-4h] [bp-28h]@8
294 std::string *v21; // [sp+Ch] [bp-18h]@8
295 unsigned __int16 *v22; // [sp+10h] [bp-14h]@9
296 int v23; // [sp+14h] [bp-10h]@3
297 int v24; // [sp+18h] [bp-Ch]@3
298 int uSrcPitch; // [sp+1Ch] [bp-8h]@5
299 int a3a; // [sp+23h] [bp-1h]@8
300 int v27; // [sp+30h] [bp+Ch]@13
301
302 pSrcXYZW_ = pSrcXYZW;
303 x = *pTargetXY;
304 y = pTargetXY[1];
305 if ( !pRenderer->uNumSceneBegins || (pSrc = pArcomageGame->pBlit_Copy_pixels) == 0 )
306 return;
307 v8 = &pRenderer->pTargetSurface[x + y * pRenderer->uTargetSurfacePitch];
308 v23 = pSrcXYZW_->z - pSrcXYZW_->x;
309 v24 = pSrcXYZW_->w - pSrcXYZW_->y;
310 if ( pArcomageGame->pBlit_Copy_pixels == pArcomageGame->pBackgroundPixels )
311 {
312 uSrcTotalWidth = (signed __int16)pArcomageGame->pGameBackground.uWidth;
313 LABEL_5:
314 uSrcPitch = uSrcTotalWidth;
315 goto LABEL_9;
316 }
317 if ( pArcomageGame->pBlit_Copy_pixels == pArcomageGame->pSpritesPixels )
318 {
319 uSrcTotalWidth = (signed __int16)pArcomageGame->pSprites.uWidth;
320 goto LABEL_5;
321 }
322 MessageBoxW(nullptr, L"Problem in Blit_Chroma", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\am_nw.cpp:157", 0);
323 pSrc = pArcomageGame->pBlit_Copy_pixels;
324 LABEL_9:
325 v22 = &pSrc[pSrcXYZW_->x + uSrcPitch * pSrcXYZW_->y];
326 v10 = 0xFFu >> (8 - LOBYTE(pRenderer->uTargetBBits));
327 v21 = (std::string *)((((pRenderer->uTargetGBits != 6) - 1) & 0x4A00) + 12783);
328 if ( a4 == 2 )
329 {
330 if ( v24 > 0 )
331 {
332 v11 = v23;
333 v12 = v22;
334 uSrcPitch = 2 * (uSrcPitch - v23);
335 do
336 {
337 if ( v11 > 0 )
338 {
339 v27 = v11;
340 do
341 {
342 if ( *v12 != v10 )
343 *v8 = *v12;
344 ++v8;
345 ++v12;
346 --v27;
347 }
348 while ( v27 );
349 }
350 v12 = (unsigned __int16 *)((char *)v12 + uSrcPitch);
351 v13 = v24-- == 1;
352 v8 += pRenderer->uTargetSurfacePitch - v11;
353 }
354 while ( !v13 );
355 }
356 }
357 else
358 {
359 if ( v24 > 0 )
360 {
361 v14 = (unsigned __int16 *)v23;
362 v15 = uSrcPitch - v23;
363 v23 = v24;
364 v16 = v22;
365 uSrcPitch = 2 * v15;
366 do
367 {
368 if ( (signed int)v14 > 0 )
369 {
370 v22 = v14;
371 do
372 {
373 v17 = *v16;
374 if ( v17 != v10 )
375 {
376 v24 = *v8;
377 *v8 = ((unsigned __int16)v21 & ((unsigned int)v24 >> 1)) + ((unsigned __int16)v21 & (v17 >> 1));
378 }
379 ++v8;
380 ++v16;
381 v22 = (unsigned __int16 *)((char *)v22 - 1);
382 }
383 while ( v22 );
384 }
385 v16 = (unsigned __int16 *)((char *)v16 + uSrcPitch);
386 v13 = v23-- == 1;
387 v8 += pRenderer->uTargetSurfacePitch - (uint)v14;
388 }
389 while ( !v13 );
390 }
391 }
392 }
393
394 //----- (0040D9B1) --------------------------------------------------------
395 void __fastcall Blt_Copy(ArcomageRect *pSrcXYZW, int *pTargetXY, int a3)
396 {
397 ArcomageRect *pSrcXYZW_; // esi@1
398 int x; // ecx@1
399 int y; // edx@1
400 unsigned __int16 *v6; // eax@2
401 unsigned __int16 *v7; // edi@3
402 int uSrcRegionWidth; // ebx@3
403 int uSrcTotalWidth; // ecx@4
404 unsigned __int16 *pSrc; // esi@8
405 int v11; // edx@9
406 int v12; // eax@12
407 int v13; // ecx@19
408 char v14; // zf@21
409 std::string v15; // [sp-18h] [bp-38h]@7
410 const char *v16; // [sp-8h] [bp-28h]@7
411 int v17; // [sp-4h] [bp-24h]@7
412 unsigned int v18; // [sp+Ch] [bp-14h]@7
413 int v19; // [sp+10h] [bp-10h]@8
414 int v20; // [sp+14h] [bp-Ch]@17
415 int uSrcRegionHeight; // [sp+18h] [bp-8h]@3
416 int a3a; // [sp+1Fh] [bp-1h]@7
417
418 pSrcXYZW_ = pSrcXYZW;
419 x = *pTargetXY;
420 y = pTargetXY[1];
421 if ( pRenderer->uNumSceneBegins )
422 {
423 v6 = pArcomageGame->pBlit_Copy_pixels;
424 if ( pArcomageGame->pBlit_Copy_pixels )
425 {
426 v7 = &pRenderer->pTargetSurface[x + y * pRenderer->uTargetSurfacePitch];
427 uSrcRegionWidth = pSrcXYZW_->z - pSrcXYZW_->x;
428 uSrcRegionHeight = pSrcXYZW_->w - pSrcXYZW_->y;
429 if ( pArcomageGame->pBlit_Copy_pixels == pArcomageGame->pBackgroundPixels )
430 {
431 uSrcTotalWidth = (signed __int16)pArcomageGame->pGameBackground.uWidth;
432 }
433 else
434 {
435 if ( pArcomageGame->pBlit_Copy_pixels == pArcomageGame->pSpritesPixels )
436 {
437 uSrcTotalWidth = (signed __int16)pArcomageGame->pSprites.uWidth;
438 }
439 else
440 {
441 MessageBoxW(nullptr, L"Problem in Blit_Copy", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\am_nw.cpp:246", 0);
442 uSrcTotalWidth = a3;
443 v6 = pArcomageGame->pBlit_Copy_pixels;
444 }
445 }
446 pSrc = &v6[pSrcXYZW_->x + uSrcTotalWidth * pSrcXYZW_->y];
447 v19 = (((pRenderer->uTargetGBits != 6) - 1) & 0x4A00) + 0x31EF;
448 if ( a3 == 2 )
449 {
450 v11 = uSrcRegionHeight;
451 if ( uSrcRegionHeight > 0 )
452 {
453 uSrcRegionHeight = 2 * (uSrcTotalWidth - uSrcRegionWidth);
454 do
455 {
456 if ( uSrcRegionWidth > 0 )
457 {
458 v12 = uSrcRegionWidth;
459 do
460 {
461 *v7 = *pSrc;
462 ++v7;
463 ++pSrc;
464 --v12;
465 }
466 while ( v12 );
467 }
468 pSrc = (unsigned __int16 *)((char *)pSrc + uSrcRegionHeight);
469 --v11;
470 v7 += pRenderer->uTargetSurfacePitch - uSrcRegionWidth;
471 }
472 while ( v11 );
473 }
474 }
475 else
476 {
477 if ( uSrcRegionHeight > 0 )
478 {
479 v20 = uSrcRegionHeight;
480 uSrcRegionHeight = 2 * (uSrcTotalWidth - uSrcRegionWidth);
481 do
482 {
483 if ( uSrcRegionWidth > 0 )
484 {
485 v13 = uSrcRegionWidth;
486 do
487 {
488 v18 = *v7;
489 *v7 = (v19 & (v18 >> 1)) + (v19 & ((unsigned int)*pSrc >> 1));
490 ++v7;
491 ++pSrc;
492 --v13;
493 }
494 while ( v13 );
495 }
496 pSrc = (unsigned __int16 *)((char *)pSrc + uSrcRegionHeight);
497 v14 = v20-- == 1;
498 v7 += pRenderer->uTargetSurfacePitch - uSrcRegionWidth;
499 }
500 while ( !v14 );
501 }
502 }
503 }
504 }
505 }
506
507 //----- (0040DB10) --------------------------------------------------------
508 void __cdecl am_EndScene()
509 {
510 pRenderer->EndScene();
511 pArcomageGame->pBlit_Copy_pixels = 0;
512 }
513
514 //----- (0040D7B7) --------------------------------------------------------
515 bool ArcomageGame::LoadSprites()
516 {
517 bool result; // eax@1
518
519 pArcomageGame->pSprites.Load("sprites.pcx", 2);
520 result = (bool)pArcomageGame->pSprites.pPixels;
521 pArcomageGame->pSpritesPixels = pArcomageGame->pSprites.pPixels;
522 LOBYTE(result) = 1;
523 return result;
524 }
525
526 //----- (0040D799) --------------------------------------------------------
527 bool ArcomageGame::LoadBackground()
528 {
529 bool result; // eax@1
530
531 pArcomageGame->pGameBackground.Load("layout.pcx", 2);
532 result = (bool)pArcomageGame->pGameBackground.pPixels;
533 pArcomageGame->pBackgroundPixels = pArcomageGame->pGameBackground.pPixels;
534 LOBYTE(result) = 1;
535 return result;
536 }
537
538 //----- (00408BB4) --------------------------------------------------------
539 bool __fastcall am_408BB4(int a1)
540 {
541 char result; // al@3
542 signed int v3; // ebx@8
543 int v4; // esi@8
544 int v5; // eax@9
545 int v6; // edi@9
546 int v7; // eax@11
547 signed int v8; // eax@11
548 int v9; // ebx@5
549 int v10; // eax@5
550 int v11; // ecx@18
551 char v12; // bl@20
552 int v13; // eax@20
553 ArcomageCard *v14; // ecx@20
554 char v15; // dl@20
555 char v16; // dl@24
556 int v17; // edx@25
557 int v18; // edx@27
558 char v19; // dl@31
559 int v20; // edx@32
560 char v21; // dl@35
561 char v22; // dl@39
562 int v23; // edx@40
563 char v24; // dl@45
564 int v25; // edx@46
565 char v26; // dl@52
566 int v27; // edx@53
567 char v28; // dl@58
568 int v29; // edx@59
569 char v30; // dl@64
570 int v31; // edx@65
571 char v32; // dl@70
572 int v33; // edx@71
573 char v34; // dl@76
574 int v35; // edx@77
575 char v36; // dl@82
576 int v37; // edx@83
577 char v38; // dl@86
578 char v39; // dl@90
579 int v40; // edi@93
580 char v41; // dl@93
581 int v42; // esi@93
582 char v43; // bl@94
583 int v44; // esi@95
584 char v45; // dl@99
585 char v46; // dl@103
586 char v47; // dl@107
587 char v48; // dl@111
588 char v49; // dl@115
589 ArcomageGame_stru0 *v50; // ebx@116
590 ArcomageGame_stru0 *v51; // edx@116
591 int v52; // esi@124
592 int v53; // edx@124
593 int v54; // edx@127
594 int v55; // esi@130
595 int v56; // edi@138
596 int l; // esi@138
597 int v58; // eax@140
598 int v59; // ecx@142
599 int v60; // edx@142
600 int v61; // ebx@142
601 int v62; // eax@145
602 int v63; // esi@146
603 int v64; // ebx@4
604 int v65; // eax@4
605 int v66; // ecx@168
606 char v67; // bl@170
607 int v68; // eax@170
608 ArcomageCard *v69; // ecx@170
609 char v70; // dl@170
610 char v71; // dl@174
611 int v72; // edx@175
612 int v73; // edx@177
613 char v74; // dl@181
614 char v75; // dl@184
615 char v76; // dl@188
616 int v77; // edx@189
617 char v78; // dl@194
618 char v79; // dl@200
619 int v80; // edx@201
620 char v81; // dl@206
621 int v82; // edx@207
622 char v83; // dl@212
623 int v84; // edx@213
624 char v85; // dl@218
625 int v86; // edx@219
626 char v87; // dl@224
627 int v88; // edx@225
628 char v89; // dl@230
629 int v90; // edx@231
630 char v91; // dl@234
631 int v92; // edx@235
632 char v93; // dl@238
633 int v94; // edx@239
634 int v95; // esi@241
635 char v96; // dl@241
636 int v97; // esi@241
637 char v98; // bl@242
638 int v99; // edi@243
639 int v100; // edx@245
640 int v101; // edi@246
641 char v102; // dl@247
642 int v103; // edx@248
643 char v104; // dl@251
644 int v105; // edx@252
645 char v106; // dl@255
646 int v107; // edx@256
647 char v108; // dl@259
648 int v109; // edx@260
649 char v110; // dl@263
650 ArcomageGame_stru0 *v111; // ebx@264
651 ArcomageGame_stru0 *v112; // edx@264
652 int v113; // esi@272
653 int v114; // edx@272
654 int v115; // edx@275
655 int v116; // esi@278
656 int v117; // edi@286
657 int j; // esi@286
658 int v119; // eax@288
659 int v120; // ecx@290
660 int v121; // edx@290
661 int v122; // ebx@290
662 int v123; // eax@293
663 int v124; // esi@294
664 int v125; // [sp-28h] [bp-28h]@130
665 int v126; // [sp-28h] [bp-28h]@278
666 int k; // [sp-24h] [bp-24h]@18
667 int i; // [sp-24h] [bp-24h]@168
668 int v129; // [sp-20h] [bp-20h]@5
669 int v130; // [sp-20h] [bp-20h]@4
670 int v131; // [sp-1Ch] [bp-1Ch]@17
671 int v132; // [sp-1Ch] [bp-1Ch]@140
672 int v133; // [sp-1Ch] [bp-1Ch]@167
673 int v134; // [sp-1Ch] [bp-1Ch]@288
674 int v135; // [sp-18h] [bp-18h]@5
675 int v136; // [sp-18h] [bp-18h]@4
676 signed int v137; // [sp-14h] [bp-14h]@0
677 int v138; // [sp-14h] [bp-14h]@93
678 int v139; // [sp-14h] [bp-14h]@130
679 int v140; // [sp-14h] [bp-14h]@241
680 int v141; // [sp-14h] [bp-14h]@278
681 ArcomageGame_stru0 *v142; // [sp-10h] [bp-10h]@5
682 ArcomageGame_stru0 *v143; // [sp-10h] [bp-10h]@4
683 ArcomageGame_stru0 *v144; // [sp-Ch] [bp-Ch]@5
684 ArcomageGame_stru0 *v145; // [sp-Ch] [bp-Ch]@4
685 char v146; // [sp-8h] [bp-8h]@35
686 char v147; // [sp-8h] [bp-8h]@184
687 char v148; // [sp-5h] [bp-5h]@20
688 char v149; // [sp-5h] [bp-5h]@170
689
690 byte_4FAA00 = 1;
691 if ( dword_4DF3A4 )
692 {
693 if ( dword_4DF3A4 != 1 )
694 {
695 result = dword_4DF3A4 - 2;
696 if ( dword_4DF3A4 != 2 )
697 return result;
698 v64 = a1;
699 v145 = &stru_505708[a1];
700 v130 = a1;
701 v143 = &stru_505708[(a1 + 1) % 2];
702 v136 = am_40BB49(a1);
703 v65 = 0;
704 do
705 {
706 if ( v65 >= v136 )
707 {
708 dword_4FA9B0[2 * v65] = -1;
709 dword_4FA9B4[2 * v65] = -9999;
710 }
711 else
712 {
713 dword_4FA9B0[2 * v65] = v65;
714 dword_4FA9B4[2 * v65] = 0;
715 }
716 ++v65;
717 }
718 while ( v65 < 10 );
719 v133 = 0;
720 if ( v136 > 0 )
721 {
722 v66 = 47 * v64;
723 for ( i = 47 * v64; ; v66 = i )
724 {
725 v67 = 99;
726 v68 = 2 * v133;
727 v69 = &pCards[stru_505708[0].arr_44[v66 + dword_4FA9B0[2 * v133]]];
728 v70 = v69->field_38[2];
729 v149 = v69->field_38[2];
730 if ( v145->field_24 >= 10 )
731 {
732 if ( v70 == 99
733 || v69->field_48[4] == 99
734 || v69->field_48[15] == 99
735 || (v74 = BYTE1(v69->field_68), v74 == 99) )
736 v73 = 5 * (v143->field_24 - v145->field_24);
737 else
738 v73 = 5 * (v149 + v69->field_48[4] + v69->field_48[15] + v74);
739 }
740 else
741 {
742 if ( v70 == 99
743 || v69->field_48[4] == 99
744 || v69->field_48[15] == 99
745 || (v71 = BYTE1(v69->field_68), v71 == 99) )
746 v72 = 5 * (v143->field_24 - v145->field_24);
747 else
748 v72 = 5 * (v149 + v69->field_48[4] + v69->field_48[15] + v71);
749 v73 = 4 * v72;
750 }
751 dword_4FA9B4[v68] += v73;
752 v75 = v69->field_38[1];
753 v147 = v69->field_38[1];
754 if ( v145->field_28 >= 10 )
755 {
756 if ( v75 == 99
757 || v69->field_48[3] == 99
758 || v69->field_48[14] == 99
759 || (v78 = LOBYTE(v69->field_68), v78 == 99) )
760 v77 = v143->field_28 - v145->field_28;
761 else
762 v77 = v147 + v69->field_48[3] + v69->field_48[14] + v78;
763 }
764 else
765 {
766 if ( v75 == 99
767 || v69->field_48[3] == 99
768 || v69->field_48[14] == 99
769 || (v76 = LOBYTE(v69->field_68), v76 == 99) )
770 v77 = 5 * (v143->field_28 - v145->field_28);
771 else
772 v77 = 5 * (v147 + v69->field_48[3] + v69->field_48[14] + v76);
773 }
774 dword_4FA9B4[v68] += v77;
775 dword_4FA9B4[v68] += 7 * (v69->field_38[0] + v69->field_48[2] + v69->field_48[13] + v69->field_58[15]);
776 if ( BYTE2(v69->field_30) == 99
777 || v69->field_38[12] == 99
778 || v69->field_48[7] == 99
779 || (v79 = v69->field_58[9], v79 == 99) )
780 v80 = 5 * (v143->field_2C - v145->field_2C);
781 else
782 v80 = 5 * (BYTE2(v69->field_30) + v69->field_38[12] + v69->field_48[7] + v79);
783 dword_4FA9B4[v68] += 8 * v80;
784 if ( BYTE3(v69->field_30) == 99
785 || v69->field_38[13] == 99
786 || v69->field_48[8] == 99
787 || (v81 = v69->field_58[10], v81 == 99) )
788 v82 = 5 * (v143->field_30 - v145->field_30);
789 else
790 v82 = 5 * (BYTE3(v69->field_30) + v69->field_38[13] + v69->field_48[8] + v81);
791 dword_4FA9B4[v68] += 8 * v82;
792 if ( LOBYTE(v69->field_34) == 99
793 || v69->field_38[14] == 99
794 || v69->field_48[9] == 99
795 || (v83 = v69->field_58[11], v83 == 99) )
796 v84 = 5 * (v143->field_34 - v145->field_34);
797 else
798 v84 = 5 * (LOBYTE(v69->field_34) + v69->field_38[14] + v69->field_48[9] + v83);
799 dword_4FA9B4[v68] += 8 * v84;
800 if ( BYTE1(v69->field_34) == 99
801 || v69->field_38[15] == 99
802 || v69->field_48[10] == 99
803 || (v85 = v69->field_58[12], v85 == 99) )
804 v86 = v143->field_38 - v145->field_38;
805 else
806 v86 = BYTE1(v69->field_34) + v69->field_38[15] + v69->field_48[10] + v85;
807 dword_4FA9B4[v68] += 2 * v86;
808 if ( BYTE2(v69->field_34) == 99
809 || v69->field_48[0] == 99
810 || v69->field_48[11] == 99
811 || (v87 = v69->field_58[13], v87 == 99) )
812 v88 = v143->field_3C - v145->field_3C;
813 else
814 v88 = BYTE2(v69->field_34) + v69->field_48[0] + v69->field_48[11] + v87;
815 dword_4FA9B4[v68] += 2 * v88;
816 if ( BYTE3(v69->field_34) == 99
817 || v69->field_48[1] == 99
818 || v69->field_48[12] == 99
819 || (v89 = v69->field_58[14], v89 == 99) )
820 v90 = v143->field_40 - v145->field_40;
821 else
822 v90 = BYTE3(v69->field_34) + v69->field_48[1] + v69->field_48[12] + v89;
823 dword_4FA9B4[v68] += 2 * v90;
824 if ( v69->field_38[11] == 99 || (v91 = v69->field_58[8], v91 == 99) )
825 v92 = 10 * (v145->field_24 - v143->field_24);
826 else
827 v92 = -10 * (v69->field_38[11] + v91);
828 dword_4FA9B4[v68] += v92;
829 if ( v69->field_38[10] == 99 || (v93 = v69->field_58[7], v93 == 99) )
830 v94 = 3 * (v145->field_28 - v143->field_28);
831 else
832 v94 = -3 * (v69->field_38[10] + v93);
833 dword_4FA9B4[v68] += v94;
834 v95 = v69->field_38[9];
835 v140 = v95;
836 v96 = v69->field_38[3];
837 dword_4FA9B4[v68] += -7 * (v69->field_58[6] + v95);
838 v97 = dword_4FA9B4[v68];
839 if ( v96 == 99 )
840 goto LABEL_245;
841 v98 = v69->field_58[0];
842 if ( v98 == 99 )
843 break;
844 v99 = v96 + v98;
845 v67 = 99;
846 dword_4FA9B4[v68] = v97 - 5 * v99;
847 LABEL_246:
848 v101 = v140;
849 if ( v69->field_38[4] == v67 || (v102 = v69->field_58[1], v102 == v67) )
850 v103 = 5 * (v145->field_30 - v143->field_30);
851 else
852 v103 = -5 * (v69->field_38[4] + v102);
853 dword_4FA9B4[v68] += v103;
854 if ( v69->field_38[5] == v67 || (v104 = v69->field_58[2], v104 == v67) )
855 v105 = 5 * (v145->field_34 - v143->field_34);
856 else
857 v105 = -5 * (v69->field_38[5] + v104);
858 dword_4FA9B4[v68] += v105;
859 if ( v69->field_38[6] == v67 || (v106 = v69->field_58[3], v106 == v67) )
860 v107 = v145->field_38 - v143->field_38;
861 else
862 v107 = -(v69->field_38[6] + v106);
863 dword_4FA9B4[v68] += 2 * v107;
864 if ( v69->field_38[7] == v67 || (v108 = v69->field_58[4], v108 == v67) )
865 v109 = v145->field_3C - v143->field_3C;
866 else
867 v109 = -(v69->field_38[7] + v108);
868 dword_4FA9B4[v68] += 2 * v109;
869 if ( v69->field_38[8] == v67 || (v110 = v69->field_58[5], v110 == v67) )
870 {
871 v112 = v145;
872 v111 = v143;
873 dword_4FA9B4[v68] += 2 * (v145->field_40 - v143->field_40);
874 }
875 else
876 {
877 v111 = v143;
878 dword_4FA9B4[v68] += -2 * (v69->field_38[8] + v110);
879 v112 = v145;
880 }
881 if ( LOBYTE(v69->field_30) || v69->field_48[5] )
882 dword_4FA9B4[v68] *= 10;
883 if ( LOBYTE(v69->field_24) == 1 )
884 {
885 v113 = LOBYTE(v69->field_28);
886 v114 = v112->field_38;
887 }
888 else
889 {
890 if ( LOBYTE(v69->field_24) == 2 )
891 {
892 v113 = BYTE1(v69->field_28);
893 v114 = v112->field_3C;
894 }
895 else
896 {
897 if ( LOBYTE(v69->field_24) != 3 )
898 goto LABEL_278;
899 v113 = BYTE2(v69->field_28);
900 v114 = v112->field_40;
901 }
902 }
903 v115 = v114 - v113;
904 if ( v115 > 3 )
905 v115 = 3;
906 dword_4FA9B4[v68] += 5 * v115;
907 LABEL_278:
908 v116 = v69->field_58[8];
909 v141 = v111->field_24;
910 v126 = v69->field_38[11];
911 if ( v141 <= v116 + v126 )
912 dword_4FA9B4[v68] += 9999;
913 v137 = v111->field_28 + v141;
914 if ( v137 <= v116 + v126 + v69->field_58[6] + v69->field_58[7] + v101 + v69->field_38[10] )
915 dword_4FA9B4[v68] += 9999;
916 if ( v69->field_48[15] + (signed int)BYTE1(v69->field_68) + v145->field_24 + v69->field_48[4] + v149 >= dword_4E1884 )
917 dword_4FA9B4[v68] += 9999;
918 ++v133;
919 if ( v133 >= v136 )
920 {
921 v64 = v130;
922 goto LABEL_286;
923 }
924 }
925 v67 = 99;
926 LABEL_245:
927 v100 = v145->field_2C - v143->field_2C;
928 dword_4FA9B4[v68] = v97 + 4 * v100 + v100;
929 goto LABEL_246;
930 }
931 LABEL_286:
932 v117 = v136 - 1;
933 for ( j = v136 - 1; j >= 0; --j )
934 {
935 v137 = 0;
936 if ( j > 0 )
937 {
938 v119 = (int)dword_4FA9B0;
939 v134 = j;
940 v137 = j;
941 do
942 {
943 if ( *(unsigned int *)(v119 + 4) < *(unsigned int *)(v119 + 12) )
944 {
945 v120 = *(unsigned int *)v119;
946 v121 = *(unsigned int *)(v119 + 4);
947 *(unsigned int *)v119 = *(unsigned int *)(v119 + 8);
948 v122 = *(unsigned int *)(v119 + 12);
949 *(unsigned int *)(v119 + 8) = v120;
950 *(unsigned int *)(v119 + 4) = v122;
951 v64 = v130;
952 *(unsigned int *)(v119 + 12) = v121;
953 }
954 v119 += 8;
955 --v134;
956 }
957 while ( v134 );
958 }
959 }
960 v123 = v136 - 1;
961 if ( am_byte_4FAA77 )
962 {
963 if ( v117 >= 0 )
964 {
965 while ( !BYTE3(pCards[stru_505708[0].arr_44[47 * v64 + dword_4FA9B0[2 * v123]]].field_28) )
966 {
967 --v123;
968 if ( v123 < 0 )
969 return am_40BCFB(v64, v137);
970 }
971 v137 = dword_4FA9B0[2 * v123];
972 }
973 }
974 else
975 {
976 v124 = 0;
977 if ( v117 >= 0 )
978 {
979 while ( !BYTE3(pCards[stru_505708[0].arr_44[47 * v64 + dword_4FA9B0[2 * v123]]].field_28) )
980 {
981 --v123;
982 if ( v123 < 0 )
983 goto LABEL_299;
984 }
985 v137 = dword_4FA9B0[2 * v123];
986 }
987 LABEL_299:
988 if ( v136 > 0 )
989 {
990 while ( !am_40BF15(v64, dword_4FA9B0[2 * v124]) || dword_4FA9B4[2 * v124] < 0 )
991 {
992 ++v124;
993 if ( v124 >= v136 )
994 return am_40BCFB(v64, v137);
995 }
996 return am_40BE0E(v64, dword_4FA9B0[2 * v124]);
997 }
998 }
999 return am_40BCFB(v64, v137);
1000 }
1001 v9 = a1;
1002 v144 = &stru_505708[a1];
1003 v129 = a1;
1004 v142 = &stru_505708[(a1 + 1) % 2];
1005 v135 = am_40BB49(a1);
1006 v10 = 0;
1007 do
1008 {
1009 if ( v10 >= v135 )
1010 {
1011 dword_4FA9B0[2 * v10] = -1;
1012 dword_4FA9B4[2 * v10] = -9999;
1013 }
1014 else
1015 {
1016 dword_4FA9B0[2 * v10] = v10;
1017 dword_4FA9B4[2 * v10] = 0;
1018 }
1019 ++v10;
1020 }
1021 while ( v10 < 10 );
1022 v131 = 0;
1023 if ( v135 > 0 )
1024 {
1025 v11 = 47 * v9;
1026 for ( k = 47 * v9; ; v11 = k )
1027 {
1028 v12 = 99;
1029 v13 = 2 * v131;
1030 v14 = &pCards[stru_505708[0].arr_44[v11 + dword_4FA9B0[2 * v131]]];
1031 v15 = v14->field_38[2];
1032 v148 = v14->field_38[2];
1033 if ( v144->field_24 >= 10 )
1034 {
1035 if ( v15 == 99 || v14->field_48[4] == 99 || v14->field_48[15] == 99 || (v19 = BYTE1(v14->field_68), v19 == 99) )
1036 v20 = 5 * (v142->field_24 - v144->field_24);
1037 else
1038 v20 = 5 * (v148 + v14->field_48[4] + v14->field_48[15] + v19);
1039 v18 = 2 * v20;
1040 }
1041 else
1042 {
1043 if ( v15 == 99 || v14->field_48[4] == 99 || v14->field_48[15] == 99 || (v16 = BYTE1(v14->field_68), v16 == 99) )
1044 v17 = 5 * (v142->field_24 - v144->field_24);
1045 else
1046 v17 = 5 * (v148 + v14->field_48[4] + v14->field_48[15] + v16);
1047 v18 = 4 * v17;
1048 }
1049 dword_4FA9B4[v13] += v18;
1050 v21 = v14->field_38[1];
1051 v146 = v14->field_38[1];
1052 if ( v144->field_28 >= 10 )
1053 {
1054 if ( v21 == 99
1055 || v14->field_48[3] == 99
1056 || v14->field_48[14] == 99
1057 || (v24 = LOBYTE(v14->field_68), v24 == 99) )
1058 v25 = v142->field_28 - v144->field_28;
1059 else
1060 v25 = v146 + v14->field_48[3] + v14->field_48[14] + v24;
1061 v23 = 2 * v25;
1062 }
1063 else
1064 {
1065 if ( v21 == 99
1066 || v14->field_48[3] == 99
1067 || v14->field_48[14] == 99
1068 || (v22 = LOBYTE(v14->field_68), v22 == 99) )
1069 v23 = 5 * (v142->field_28 - v144->field_28);
1070 else
1071 v23 = 5 * (v146 + v14->field_48[3] + v14->field_48[14] + v22);
1072 }
1073 dword_4FA9B4[v13] += v23;
1074 dword_4FA9B4[v13] += 7 * (v14->field_38[0] + v14->field_48[2] + v14->field_48[13] + v14->field_58[15]);
1075 if ( BYTE2(v14->field_30) == 99
1076 || v14->field_38[12] == 99
1077 || v14->field_48[7] == 99
1078 || (v26 = v14->field_58[9], v26 == 99) )
1079 v27 = 5 * (v142->field_2C - v144->field_2C);
1080 else
1081 v27 = 5 * (BYTE2(v14->field_30) + v14->field_38[12] + v14->field_48[7] + v26);
1082 dword_4FA9B4[v13] += 8 * v27;
1083 if ( BYTE3(v14->field_30) == 99
1084 || v14->field_38[13] == 99
1085 || v14->field_48[8] == 99
1086 || (v28 = v14->field_58[10], v28 == 99) )
1087 v29 = 5 * (v142->field_30 - v144->field_30);
1088 else
1089 v29 = 5 * (BYTE3(v14->field_30) + v14->field_38[13] + v14->field_48[8] + v28);
1090 dword_4FA9B4[v13] += 8 * v29;
1091 if ( LOBYTE(v14->field_34) == 99
1092 || v14->field_38[14] == 99
1093 || v14->field_48[9] == 99
1094 || (v30 = v14->field_58[11], v30 == 99) )
1095 v31 = 5 * (v142->field_34 - v144->field_34);
1096 else
1097 v31 = 5 * (LOBYTE(v14->field_34) + v14->field_38[14] + v14->field_48[9] + v30);
1098 dword_4FA9B4[v13] += 8 * v31;
1099 if ( BYTE1(v14->field_34) == 99
1100 || v14->field_38[15] == 99
1101 || v14->field_48[10] == 99
1102 || (v32 = v14->field_58[12], v32 == 99) )
1103 v33 = v142->field_38 - v144->field_38;
1104 else
1105 v33 = BYTE1(v14->field_34) + v14->field_38[15] + v14->field_48[10] + v32;
1106 dword_4FA9B4[v13] += 2 * v33;
1107 if ( BYTE2(v14->field_34) == 99
1108 || v14->field_48[0] == 99
1109 || v14->field_48[11] == 99
1110 || (v34 = v14->field_58[13], v34 == 99) )
1111 v35 = v142->field_3C - v144->field_3C;
1112 else
1113 v35 = BYTE2(v14->field_34) + v14->field_48[0] + v14->field_48[11] + v34;
1114 dword_4FA9B4[v13] += 2 * v35;
1115 if ( BYTE3(v14->field_34) == 99
1116 || v14->field_48[1] == 99
1117 || v14->field_48[12] == 99
1118 || (v36 = v14->field_58[14], v36 == 99) )
1119 v37 = v142->field_40 - v144->field_40;
1120 else
1121 v37 = BYTE3(v14->field_34) + v14->field_48[1] + v14->field_48[12] + v36;
1122 dword_4FA9B4[v13] += 2 * v37;
1123 if ( v14->field_38[11] == 99 || (v38 = v14->field_58[8], v38 == 99) )
1124 dword_4FA9B4[v13] += v144->field_24 - v142->field_24;
1125 else
1126 dword_4FA9B4[v13] -= v14->field_38[11] + v38;
1127 if ( v14->field_38[10] == 99 || (v39 = v14->field_58[7], v39 == 99) )
1128 dword_4FA9B4[v13] += v144->field_28 - v142->field_28;
1129 else
1130 dword_4FA9B4[v13] -= v14->field_38[10] + v39;
1131 v40 = v14->field_38[9];
1132 v138 = v14->field_38[9];
1133 dword_4FA9B4[v13] -= v40 + v14->field_58[6];
1134 v41 = v14->field_38[3];
1135 v42 = dword_4FA9B4[v13];
1136 if ( v41 == 99 )
1137 goto LABEL_97;
1138 v43 = v14->field_58[0];
1139 if ( v43 == 99 )
1140 break;
1141 v44 = v42 - v43;
1142 v12 = 99;
1143 dword_4FA9B4[v13] = v44 - v41;
1144 LABEL_98:
1145 if ( v14->field_38[4] == v12 || (v45 = v14->field_58[1], v45 == v12) )
1146 dword_4FA9B4[v13] += v144->field_30 - v142->field_30;
1147 else
1148 dword_4FA9B4[v13] -= v14->field_38[4] + v45;
1149 if ( v14->field_38[5] == v12 || (v46 = v14->field_58[2], v46 == v12) )
1150 dword_4FA9B4[v13] += v144->field_34 - v142->field_34;
1151 else
1152 dword_4FA9B4[v13] -= v14->field_38[5] + v46;
1153 if ( v14->field_38[6] == v12 || (v47 = v14->field_58[3], v47 == v12) )
1154 dword_4FA9B4[v13] += v144->field_38 - v142->field_38;
1155 else
1156 dword_4FA9B4[v13] -= v14->field_38[6] + v47;
1157 if ( v14->field_38[7] == v12 || (v48 = v14->field_58[4], v48 == v12) )
1158 dword_4FA9B4[v13] += v144->field_3C - v142->field_3C;
1159 else
1160 dword_4FA9B4[v13] -= v14->field_38[7] + v48;
1161 if ( v14->field_38[8] == v12 || (v49 = v14->field_58[5], v49 == v12) )
1162 {
1163 v51 = v144;
1164 v50 = v142;
1165 dword_4FA9B4[v13] += v144->field_40 - v142->field_40;
1166 }
1167 else
1168 {
1169 v50 = v142;
1170 dword_4FA9B4[v13] -= v14->field_38[8] + v49;
1171 v51 = v144;
1172 }
1173 if ( LOBYTE(v14->field_30) || v14->field_48[5] )
1174 dword_4FA9B4[v13] *= 10;
1175 if ( LOBYTE(v14->field_24) == 1 )
1176 {
1177 v52 = LOBYTE(v14->field_28);
1178 v53 = v51->field_38;
1179 }
1180 else
1181 {
1182 if ( LOBYTE(v14->field_24) == 2 )
1183 {
1184 v52 = BYTE1(v14->field_28);
1185 v53 = v51->field_3C;
1186 }
1187 else
1188 {
1189 if ( LOBYTE(v14->field_24) != 3 )
1190 goto LABEL_130;
1191 v52 = BYTE2(v14->field_28);
1192 v53 = v51->field_40;
1193 }
1194 }
1195 v54 = v53 - v52;
1196 if ( v54 > 3 )
1197 v54 = 3;
1198 dword_4FA9B4[v13] += 5 * v54;
1199 LABEL_130:
1200 v55 = v14->field_58[8];
1201 v139 = v50->field_24;
1202 v125 = v14->field_38[11];
1203 if ( v139 <= v55 + v125 )
1204 dword_4FA9B4[v13] += 9999;
1205 v137 = v50->field_28 + v139;
1206 if ( v137 <= v55 + v125 + v14->field_58[6] + v14->field_58[7] + v40 + v14->field_38[10] )
1207 dword_4FA9B4[v13] += 9999;
1208 if ( v14->field_48[15] + (signed int)BYTE1(v14->field_68) + v144->field_24 + v14->field_48[4] + v148 >= dword_4E1884 )
1209 dword_4FA9B4[v13] += 9999;
1210 ++v131;
1211 if ( v131 >= v135 )
1212 {
1213 v9 = v129;
1214 goto LABEL_138;
1215 }
1216 }
1217 v12 = 99;
1218 LABEL_97:
1219 v40 = v138;
1220 dword_4FA9B4[v13] = v42 + v144->field_2C - v142->field_2C;
1221 goto LABEL_98;
1222 }
1223 LABEL_138:
1224 v56 = v135 - 1;
1225 for ( l = v135 - 1; l >= 0; --l )
1226 {
1227 v137 = 0;
1228 if ( l > 0 )
1229 {
1230 v58 = (int)dword_4FA9B0;
1231 v132 = l;
1232 v137 = l;
1233 do
1234 {
1235 if ( *(unsigned int *)(v58 + 4) < *(unsigned int *)(v58 + 12) )
1236 {
1237 v59 = *(unsigned int *)v58;
1238 v60 = *(unsigned int *)(v58 + 4);
1239 *(unsigned int *)v58 = *(unsigned int *)(v58 + 8);
1240 v61 = *(unsigned int *)(v58 + 12);
1241 *(unsigned int *)(v58 + 8) = v59;
1242 *(unsigned int *)(v58 + 4) = v61;
1243 v9 = v129;
1244 *(unsigned int *)(v58 + 12) = v60;
1245 }
1246 v58 += 8;
1247 --v132;
1248 }
1249 while ( v132 );
1250 }
1251 }
1252 v62 = v135 - 1;
1253 if ( am_byte_4FAA77 )
1254 {
1255 if ( v56 >= 0 )
1256 {
1257 while ( !BYTE3(pCards[stru_505708[0].arr_44[47 * v9 + dword_4FA9B0[2 * v62]]].field_28) )
1258 {
1259 --v62;
1260 if ( v62 < 0 )
1261 return am_40BCFB(v9, v137);
1262 }
1263 v137 = dword_4FA9B0[2 * v62];
1264 }
1265 }
1266 else
1267 {
1268 v63 = 0;
1269 if ( v56 >= 0 )
1270 {
1271 while ( !BYTE3(pCards[stru_505708[0].arr_44[47 * v9 + dword_4FA9B0[2 * v62]]].field_28) )
1272 {
1273 --v62;
1274 if ( v62 < 0 )
1275 goto LABEL_151;
1276 }
1277 v137 = dword_4FA9B0[2 * v62];
1278 }
1279 LABEL_151:
1280 if ( v135 > 0 )
1281 {
1282 while ( !am_40BF15(v9, dword_4FA9B0[2 * v63]) || dword_4FA9B4[2 * v63] < 0 )
1283 {
1284 ++v63;
1285 if ( v63 >= v135 )
1286 return am_40BCFB(v9, v137);
1287 }
1288 return am_40BE0E(v9, dword_4FA9B0[2 * v63]);
1289 }
1290 }
1291 return am_40BCFB(v9, v137);
1292 }
1293 v3 = 0;
1294 v4 = a1;
1295 if ( am_byte_4FAA77 )
1296 {
1297 LABEL_11:
1298 v7 = am_40BB49(v4);
1299 v8 = rand_interval(0, v7 - 1);
1300 result = am_40BCFB(v4, v8);
1301 }
1302 else
1303 {
1304 while ( 1 )
1305 {
1306 v5 = am_40BB49(v4);
1307 v6 = rand_interval(0, v5 - 1);
1308 if ( am_40BF15(v4, v6) )
1309 break;
1310 ++v3;
1311 if ( v3 >= 10 )
1312 goto LABEL_11;
1313 }
1314 result = am_40BE0E(v4, v6);
1315 }
1316 return result;
1317 }
1318 // 408BB4: could not find valid save-restore pair for ebp
1319 // 4DF3A4: using guessed type int dword_4DF3A4;
1320 // 4E1884: using guessed type int dword_4E1884;
1321 // 4FA9B0: using guessed type int dword_4FA9B0[];
1322 // 4FA9B4: using guessed type int dword_4FA9B4[];
1323 // 4FAA00: using guessed type char byte_4FAA00;
1324 // 4FAA77: using guessed type char am_byte_4FAA77;
1325
1326
1327
1328 //----- (00409E6A) --------------------------------------------------------
1329 void ArcomageGame::Loop()
1330 {
1331 int v0; // edx@2
1332 int v1; // ecx@14
1333 signed int v2; // eax@15
1334 stru272 *v3; // esi@17
1335 __int16 *v4; // esi@23
1336
1337 while ( !pArcomageGame->field_F5 )
1338 {
1339 pArcomageGame->field_F6 = 1;
1340 byte_4FAA24 = 1;
1341 am_40A346(amuint_4FAA6C);
1342 LABEL_8:
1343 while ( byte_4FAA24 )
1344 {
1345 amuint_4FABC0 = -1;
1346 am_40A283(amuint_4FAA6C, v0);
1347 while ( 1 )
1348 {
1349 byte_4FAA24 = am_40A560(amuint_4FAA6C);
1350 if ( am_40BB49(amuint_4FAA6C) <= dword_4E1874 )
1351 break;
1352 am_byte_4FAA77 = 1;
1353 if ( pArcomageGame->field_F4 )
1354 goto LABEL_8;
1355 }
1356 am_byte_4FAA77 = 0;
1357 }
1358 pArcomageGame->field_F5 = am_40A514();
1359 if ( !pArcomageGame->field_F5 )
1360 am_40A383();
1361 if ( pArcomageGame->field_F4 )
1362 pArcomageGame->field_F5 = 1;
1363 }
1364 am_40D444();
1365 if ( byte_4FAA2C )
1366 {
1367 v2 = retzero_sub_40DFA7((int)dword_4FAA28);
1368 v1 = 1000;
1369 dword_4FAA70 = v2 / 1000;
1370 }
1371 else
1372 {
1373 dword_4FAA70 = -1;
1374 }
1375 pVideoPlayer->BinkUpdatePalette(dword_4FAA28);
1376 v3 = array_4FAC10;
1377 do
1378 {
1379 v3->ptr_0->_40E0F5(1, 1);
1380 v3->ptr_0->_40DFFE();
1381 ++v3;
1382 }
1383 while ( (signed int)v3 < (signed int)&unk_5052C8 );
1384 if (pAsyncMouse)
1385 {
1386 pAsyncMouse->_409E3D(*((unsigned char *)pAsyncMouse + 103));
1387 pAsyncMouse->_46B944();
1388 }
1389 pArcomageGame->pGameBackground.Release();
1390 pArcomageGame->pSprites.Release();
1391 pArcomageGame->bGameInProgress = 0;
1392 viewparams->bRedrawGameUI = 1;
1393 if ( pVideoPlayer->AnyMovieLoaded() )
1394 pVideoPlayer->_4BF5B2();
1395 v4 = am_sounds;
1396 do
1397 {
1398 pSoundList->_4A9DCD((unsigned __int16)*v4, 1);
1399 ++v4;
1400 }
1401 while ( (signed int)v4 <= (signed int)&unk_4FAA20 );
1402 }
1403 // 40DFA7: using guessed type uint __stdcall retzero_sub_40DFA7(uint);
1404 // 4E1874: using guessed type int dword_4E1874;
1405 // 4FAA24: using guessed type char byte_4FAA24;
1406 // 4FAA2C: using guessed type char byte_4FAA2C;
1407 // 4FAA70: using guessed type int dword_4FAA70;
1408 // 4FAA77: using guessed type char am_byte_4FAA77;
1409
1410 //----- (00409FE9) --------------------------------------------------------
1411 char __cdecl am_409FE9()
1412 {
1413 signed int v0; // edi@1
1414 signed int v1; // esi@4
1415 int *v2; // ecx@7
1416 int *v3; // eax@7
1417 signed int v4; // edx@7
1418 int v5; // edx@13
1419 signed int v6; // ecx@13
1420 signed int v7; // eax@13
1421
1422 amuint_4FAA6C = dword_505890;
1423 sub_409BE8();
1424 v0 = 0;
1425 do
1426 {
1427 if ( v0 )
1428 {
1429 v1 = v0;
1430 inv_strcpy(pArcomageGame->pPlayer2Name, stru_505708[v0].pPlayerName);
1431 if ( byte_4E185C )
1432 LOBYTE(stru_505708[v1].field_20) = 0;
1433 else
1434 LOBYTE(stru_505708[v1].field_20) = 1;
1435 }
1436 else
1437 {
1438 inv_strcpy(pArcomageGame->pPlayer1Name, (char *)stru_505708);
1439 LOBYTE(stru_505708[0].field_20) = 1;
1440 }
1441 stru_505708[v0].field_24 = amuint_4E1860;
1442 stru_505708[v0].field_28 = amuint_4E1864;
1443 stru_505708[v0].field_2C = amuint_4E1868;
1444 stru_505708[v0].field_30 = amuint_4E186C;
1445 stru_505708[v0].field_34 = amuint_4E1870;
1446 stru_505708[v0].field_38 = amuint_505884;
1447 stru_505708[v0].field_3C = amuint_505888;
1448 stru_505708[v0].field_40 = amuint_50588C;
1449 v2 = &stru_505708[v0].arr_6C[0][1];
1450 v3 = stru_505708[v0].arr_44;
1451 v4 = 10;
1452 do
1453 {
1454 *v3 = -1;
1455 if ( am_byte_4E185D )
1456 {
1457 *(v2 - 1) = -1;
1458 *v2 = -1;
1459 }
1460 else
1461 {
1462 *(v2 - 1) = 0;
1463 *v2 = 0;
1464 }
1465 ++v3;
1466 v2 += 2;
1467 --v4;
1468 }
1469 while ( v4 );
1470 ++v0;
1471 }
1472 while ( v0 < 2 );
1473 inv_strcpy(pDeckMaster, byte_5054C8);
1474 v5 = 0;
1475 v6 = (signed int)dword_505554;
1476 v7 = -2;
1477 do
1478 {
1479 byte_5054E8[v7 + 2] = 0;
1480 *(unsigned int *)v6 = v5;
1481 switch ( v7 )
1482 {
1483 default:
1484 ++v5;
1485 break;
1486 case 0:
1487 case 2:
1488 case 6:
1489 case 9:
1490 case 13:
1491 case 18:
1492 case 23:
1493 case 33:
1494 case 36:
1495 case 38:
1496 case 44:
1497 case 46:
1498 case 52:
1499 case 57:
1500 case 69:
1501 case 71:
1502 case 75:
1503 case 79:
1504 case 81:
1505 case 84:
1506 case 89:
1507 break;
1508 }
1509 v6 += 4;
1510 ++v7;
1511 }
1512 while ( v6 < (signed int)&unk_505704 );
1513 return am_40A198();
1514 }
1515 // 4E185C: using guessed type char byte_4E185C;
1516 // 4E185D: using guessed type char am_byte_4E185D;
1517 // 4E1860: using guessed type int amuint_4E1860;
1518 // 4E1864: using guessed type int amuint_4E1864;
1519 // 4E1868: using guessed type int amuint_4E1868;
1520 // 4E186C: using guessed type int amuint_4E186C;
1521 // 4E1870: using guessed type int amuint_4E1870;
1522 // 505554: using guessed type int dword_505554[];
1523 // 505884: using guessed type int amuint_505884;
1524 // 505888: using guessed type int amuint_505888;
1525 // 50588C: using guessed type int amuint_50588C;
1526 // 505890: using guessed type int dword_505890;
1527
1528 //----- (0040A198) --------------------------------------------------------
1529 char __cdecl am_40A198()
1530 {
1531 int *v0; // edi@1
1532 int *v1; // edx@2
1533 signed int v2; // esi@2
1534 signed int v3; // eax@4
1535 signed int v4; // esi@12
1536 int v5; // eax@13
1537 int v6; // edx@13
1538 char *v7; // eax@13
1539 char result; // al@14
1540 char v9[108]; // [sp+8h] [bp-6Ch]@1
1541
1542 ArcomageGame::PlaySound(0x14u);
1543 memset(byte_5054E8, 0, sizeof(byte_5054E8));
1544 memset(v9, 0, sizeof(v9));
1545 v0 = stru_505708[0].arr_44;
1546 do
1547 {
1548 v1 = v0;
1549 v2 = 10;
1550 do
1551 {
1552 if ( *v1 > -1 )
1553 {
1554 v3 = 0;
1555 while ( dword_505554[v3] != *v1 || byte_5054E8[v3] )
1556 {
1557 ++v3;
1558 if ( v3 >= 108 )
1559 goto LABEL_10;
1560 }
1561 byte_5054E8[v3] = 1;
1562 }
1563 LABEL_10:
1564 ++v1;
1565 --v2;
1566 }
1567 while ( v2 );
1568 v0 += 47;
1569 }
1570 while ( (signed int)v0 < (signed int)&pArcomageGame->msg.pt.y );
1571 v4 = 0;
1572 do
1573 {
1574 do
1575 {
1576 v5 = rand();
1577 v6 = v5 % 108;
1578 v7 = &v9[v5 % 108];
1579 }
1580 while ( *v7 == 1 );
1581 *v7 = 1;
1582 dword_505314[v4] = dword_505554[v6];
1583 result = byte_5054E8[v6];
1584 array_4FAC10[9].field_4[v4++ + 4232] = result;
1585 }
1586 while ( v4 < 108 );
1587 dword_4FABC8 = 0;
1588 amuint_4FABC4 = -1;
1589 pArcomageGame->field_F6 = 1;
1590 return result;
1591 }
1592 // 4FABC4: using guessed type int amuint_4FABC4;
1593 // 4FABC8: using guessed type int dword_4FABC8;
1594 // 505314: using guessed type int dword_505314[];
1595 // 505554: using guessed type int dword_505554[];
1596 // 40A198: using guessed type char var_6C[108];
1597
1598 //----- (0040A255) --------------------------------------------------------
1599 int __fastcall am_40A255(int a1, int a2)
1600 {
1601 int i; // edi@1
1602 signed int v3; // esi@2
1603 int result; // eax@3
1604
1605 for ( i = 0; i < dword_4E1874; ++i )
1606 {
1607 v3 = 0;
1608 do
1609 result = am_40A283(v3++, a2);
1610 while ( v3 < 2 );
1611 }
1612 pArcomageGame->field_F6 = 1;
1613 return result;
1614 }
1615 // 4E1874: using guessed type int dword_4E1874;
1616
1617 //----- (0040A283) --------------------------------------------------------
1618 signed int __fastcall am_40A283(int a1, int a2)
1619 {
1620 signed int v2; // eax@1
1621 int v3; // edi@1
1622 int v4; // esi@1
1623 char v5; // bl@1
1624 signed int result; // eax@7
1625 int v7; // esi@8
1626
1627 v2 = dword_4FABC8;
1628 v3 = a1;
1629 v4 = a1;
1630 v5 = 0;
1631 do
1632 {
1633 if ( v2 >= 108 )
1634 {
1635 am_40A198();
1636 v2 = dword_4FABC8;
1637 }
1638 if ( !array_4FAC10[9].field_4[v2 + 4232] )
1639 {
1640 v3 = dword_505314[v2];
1641 v5 = 1;
1642 }
1643 ++v2;
1644 dword_4FABC8 = v2;
1645 }
1646 while ( !v5 );
1647 ArcomageGame::PlaySound(0x15u);
1648 result = am_40A324(v4);
1649 if ( result != -1 )
1650 {
1651 amuint_4FAA4C = result;
1652 stru_505708[0].arr_44[result + 47 * v4] = v3;
1653 v7 = 188 * v4 + 8 * result;
1654 *(int *)((char *)stru_505708[0].arr_6C[0] + v7) = rand_interval(-4, 4);
1655 result = rand_interval(-4, 4);
1656 *(int *)((char *)&stru_505708[0].arr_6C[0][1] + v7) = result;
1657 pArcomageGame->field_F6 = 1;
1658 byte_4FAA2D = 1;
1659 }
1660 return result;
1661 }
1662 // 4FAA2D: using guessed type char byte_4FAA2D;
1663 // 4FAA4C: using guessed type int amuint_4FAA4C;
1664 // 4FABC8: using guessed type int dword_4FABC8;
1665 // 505314: using guessed type int dword_505314[];
1666
1667 //----- (0040A324) --------------------------------------------------------
1668 signed int __fastcall am_40A324(int a1)
1669 {
1670 signed int result; // eax@1
1671 signed int v2; // edx@1
1672 char *v3; // ecx@1
1673
1674 result = -1;
1675 v2 = 0;
1676 v3 = (char *)stru_505708[a1].arr_44;
1677 while ( *(unsigned int *)v3 != -1 )
1678 {
1679 ++v2;
1680 v3 += 4;
1681 if ( v2 >= 10 )
1682 return result;
1683 }
1684 return v2;
1685 }
1686
1687 //----- (0040A346) --------------------------------------------------------
1688 int __fastcall am_40A346(int a1)
1689 {
1690 int v1; // ecx@1
1691 int result; // eax@1
1692
1693 v1 = a1;
1694 stru_505708[v1].field_38 += dword_4E1878 + stru_505708[v1].field_2C;
1695 stru_505708[v1].field_3C += dword_4E187C + stru_505708[v1].field_30;
1696 result = dword_4E1880 + stru_505708[v1].field_34;
1697 stru_505708[v1].field_40 += result;
1698 return result;
1699 }
1700 // 4E1878: using guessed type int dword_4E1878;
1701 // 4E187C: using guessed type int dword_4E187C;
1702 // 4E1880: using guessed type int dword_4E1880;
1703
1704 //----- (0040A383) --------------------------------------------------------
1705 void __cdecl am_40A383()
1706 {
1707 int v0; // eax@4
1708 int v1; // ecx@4
1709 unsigned __int8 v2; // sf@4
1710 unsigned __int8 v3; // of@4
1711 int v4; // eax@6
1712 char Dest[64]; // [sp+4h] [bp-64h]@4
1713 int v6; // [sp+44h] [bp-24h]@6
1714 int v7; // [sp+48h] [bp-20h]@6
1715 int v8; // [sp+4Ch] [bp-1Ch]@6
1716 int v9; // [sp+50h] [bp-18h]@6
1717 ArcomageGame_stru1 v10; // [sp+54h] [bp-14h]@7
1718 int v11[2]; // [sp+60h] [bp-8h]@4
1719
1720 if ( !pArcomageGame->field_F4 )
1721 {
1722 if ( LOBYTE(stru_505708[0].field_20) != 1 || LOBYTE(stru_505708[1].field_20) != 1 )
1723 {
1724 ++amuint_4FAA6C;
1725 am_byte_4FAA75 = 1;
1726 if ( amuint_4FAA6C >= 2 )
1727 amuint_4FAA6C = 0;
1728 }
1729 else
1730 {
1731 //nullsub_1();
1732 v11[0] = 0;
1733 v11[1] = 0;
1734 inv_strcpy("След", Dest);
1735 v0 = 0;
1736 v11[1] = 200;
1737 v11[0] = 320 - 12 * v0 / 2;
1738 pPrimaryWindow_draws_text(-1, Dest, v11);
1739 am_byte_4FAA75 = 1;
1740 v1 = amuint_4FAA6C + 1;
1741 v3 = __OFSUB__(amuint_4FAA6C + 1, 2);
1742 v2 = amuint_4FAA6C++ - 1 < 0;
1743 if ( !(v2 ^ v3) )
1744 {
1745 v1 = 0;
1746 amuint_4FAA6C = 0;
1747 }
1748 inv_strcpy(stru_505708[v1].pPlayerName, Dest);
1749 v4 = 0;
1750 v11[1] = 260;
1751 v11[0] = 320 - 12 * v4 / 2;
1752 pPrimaryWindow_draws_text(-1, Dest, v11);
1753 v6 = 0;
1754 v8 = 640;
1755 v7 = 0;
1756 v9 = 480;
1757 //nullsub_1();
1758 CallRenderPresent();
1759 //nullsub_1();
1760 while ( 1 )
1761 {
1762 while ( 1 )
1763 {
1764 while ( !ArcomageGame::MsgLoop(20, &v10) )
1765 ;
1766 if ( v10.field_0 != 1 )
1767 break;
1768 if ( v10.field_4 )
1769 goto LABEL_13;
1770 //nullsub_1();
1771 }
1772 if ( v10.field_0 > 4 )
1773 {
1774 if ( v10.field_0 <= 8 )
1775 goto LABEL_13;
1776 if ( v10.field_0 == 10 )
1777 break;
1778 }
1779 }
1780 pArcomageGame->field_F4 = 1;
1781 byte_4FAA74 = 1;
1782 LABEL_13:
1783 v11[0] = 0;
1784 v11[1] = 0;
1785 v6 = 0;
1786 v8 = 640;
1787 v7 = 0;
1788 v9 = 480;
1789 //nullsub_1();
1790 CallRenderPresent();
1791 }
1792 }
1793 }
1794
1795
1796 //----- (0040A514) --------------------------------------------------------
1797 bool __cdecl am_40A514()
1798 {
1799 bool result; // eax@1
1800 char *v1; // ecx@1
1801
1802 LOBYTE(result) = 0;
1803 v1 = (char *)&stru_505708[0].field_24;
1804 do
1805 {
1806 if ( *(unsigned int *)v1 <= 0 )
1807 LOBYTE(result) = 1;
1808 if ( *(unsigned int *)v1 >= dword_4E1884 )
1809 LOBYTE(result) = 1;
1810 if ( *((unsigned int *)v1 + 5) >= dword_4E1888
1811 || *((unsigned int *)v1 + 6) >= dword_4E1888
1812 || *((unsigned int *)v1 + 7) >= dword_4E1888 )
1813 LOBYTE(result) = 1;
1814 v1 += 188;
1815 }
1816 while ( (signed int)v1 < (signed int)&pArcomageGame->stru1.field_4 );
1817 if ( result )
1818 byte_4FAA2C = 1;
1819 return result;
1820 }
1821 // 4E1884: using guessed type int dword_4E1884;
1822 // 4E1888: using guessed type int dword_4E1888;
1823 // 4FAA2C: using guessed type char byte_4FAA2C;
1824
1825 //----- (0040A560) --------------------------------------------------------
1826 char am_40A560(unsigned int _this)
1827 {
1828 int v1; // ebp@0
1829 unsigned __int64 v2; // qax@3
1830 unsigned __int64 v3; // kr00_8@3
1831 int v4; // ecx@17
1832 int v5; // esi@67
1833 char Dest[100]; // [sp+8h] [bp-A8h]@67
1834 int v8; // [sp+6Ch] [bp-44h]@3
1835 int pSrcXYZW[4]; // [sp+70h] [bp-40h]@75
1836 int v10[4]; // [sp+80h] [bp-30h]@69
1837 int pTargetXY[2]; // [sp+90h] [bp-20h]@75
1838 ArcomageGame_stru1 a2; // [sp+98h] [bp-18h]@8
1839 int v13; // [sp+A4h] [bp-Ch]@1
1840 int a1; // [sp+A8h] [bp-8h]@1
1841 char v15; // [sp+AEh] [bp-2h]@63
1842 char v16; // [sp+AFh] [bp-1h]@1
1843
1844 uCardID = -1;
1845 a1 = _this;
1846 v16 = 0;
1847 v13 = 20;
1848 byte_4FAA00 = 0;
1849 dword_4FAA68 = 0;
1850 amuint_4FAA38 = 10;
1851 amuint_4FAA34 = 5;
1852 if ( amuint_4FAA4C != -1 )
1853 byte_4FAA2D = 1;
1854 do
1855 {
1856 do
1857 {
1858 do
1859 {
1860 v2 = pEventTimer->Time();
1861 v3 = v2 - pArcomageGame->event_timer_time;
1862 v8 = HIDWORD(v3);
1863 }
1864 while ( SHIDWORD(v3) < 0 );
1865 }
1866 while ( SHIDWORD(v2) < (signed int)(((unsigned int)v2 < pArcomageGame->event_timer_time)
1867 + ((unsigned __int64)pArcomageGame->event_timer_time >> 32)) | HIDWORD(v3) == 0
1868 && (unsigned int)v3 < 6 );
1869 pArcomageGame->event_timer_time = pEventTimer->Time();
1870 if ( pArcomageGame->field_F4 )
1871 v16 = 1;
1872 ArcomageGame::MsgLoop(0, &a2);
1873 switch ( a2.field_0 )
1874 {
1875 case 2:
1876 if ( a2.field_4 == 129 && a2.field_8 == 1 )
1877 {
1878 pAudioPlayer->StopChannels(-1, -1);
1879 dword_4FAA68 = 0;
1880 goto LABEL_16;
1881 }
1882 break;
1883 case 9:
1884 pArcomageGame->field_F6 = 1;
1885 break;
1886 case 0xA:
1887 pAudioPlayer->StopChannels(-1, -1);
1888 byte_4FAA74 = 1;
1889 LABEL_16:
1890 v16 = 1;
1891 pArcomageGame->field_F4 = 1;
1892 break;
1893 }
1894 v4 = amuint_4FAA6C;
1895 if ( LOBYTE(stru_505708[amuint_4FAA6C].field_20) != 1 && !byte_4FAA00 && !byte_4FAA2E && !byte_4FAA2D )
1896 {
1897 if ( am_byte_4FAA75 )
1898 am_byte_4FAA76 = 1;
1899 am_408BB4(amuint_4FAA6C);
1900 v4 = amuint_4FAA6C;
1901 byte_4FAA2E = 1;
1902 }
1903 if ( amuint_4FAA4C != -1 && amuint_4FAA38 > 10 )
1904 amuint_4FAA38 = 10;
1905 if ( byte_4FAA2E || byte_4FAA2D || LOBYTE(stru_505708[v4].field_20) != 1 )
1906 {
1907 pArcomageGame->field_F6 = 1;
1908 if ( byte_4FAA2D )
1909 {
1910 --amuint_4FAA38;
1911 if ( amuint_4FAA38 < 0 )
1912 {
1913 byte_4FAA2D = 0;
1914 amuint_4FAA38 = 10;
1915 v16 = 0;
1916 }
1917 }
1918 if ( byte_4FAA2E )
1919 {
1920 --v13;
1921 if ( v13 < 0 )
1922 {
1923 if ( dword_4FAA68 > 1 )
1924 {
1925 --dword_4FAA68;
1926 byte_4FAA00 = 0;
1927 }
1928 else
1929 {
1930 v16 = 1;
1931 }
1932 byte_4FAA2E = 0;
1933 v13 = 20;
1934 }
1935 }
1936 }
1937 else
1938 {
1939 if ( am_byte_4FAA77 )
1940 {
1941 if ( a2.field_0 == 7 && am_40BCFB(a1, dword_4FABBC) )
1942 {
1943 if ( am_byte_4FAA75 )
1944 am_byte_4FAA76 = 1;
1945 if ( dword_4FAA64 > 0 )
1946 {
1947 --dword_4FAA64;
1948 am_byte_4FAA77 = am_40BB49(a1) > dword_4E1874;
1949 }
1950 byte_4FAA2E = 1;
1951 }
1952 if ( a2.field_0 == 8 && am_40BCFB(a1, dword_4FABBC) )
1953 {
1954 if ( am_byte_4FAA75 )
1955 am_byte_4FAA76 = 1;
1956 if ( dword_4FAA64 > 0 )
1957 {
1958 --dword_4FAA64;
1959 am_byte_4FAA77 = am_40BB49(a1) > dword_4E1874;
1960 }
1961 byte_4FAA2E = 1;
1962 }
1963 }
1964 else
1965 {
1966 if ( a2.field_0 == 7 )
1967 {
1968 if ( am_40BE0E(a1, dword_4FABBC) )
1969 {
1970 byte_4FAA2E = 1;
1971 if ( am_byte_4FAA75 )
1972 am_byte_4FAA76 = 1;
1973 }
1974 }
1975 if ( a2.field_0 == 8 )
1976 {
1977 if ( am_40BCFB(a1, dword_4FABBC) )
1978 {
1979 byte_4FAA2E = 1;
1980 if ( am_byte_4FAA75 )
1981 am_byte_4FAA76 = 1;
1982 }
1983 }
1984 }
1985 }
1986 //nullsub_1();
1987 if ( false )
1988 {
1989 if ( !v15 )
1990 {
1991 //nullsub_1();
1992 v15 = 1;
1993 }
1994 }
1995 else
1996 {
1997 v15 = 0;
1998 }
1999 if ( false )
2000 {
2001 //nullsub_1();
2002 //nullsub_1();
2003 inv_strcpy(pAreYouSureWishToLeave, Dest);
2004 v5 = 0;//unk::const_0(&unk_4E19FC, 0);
2005 //nullsub_1();
2006 if ( v5 == 1 )
2007 {
2008 pAudioPlayer->StopChannels(-1, -1);
2009 v16 = 1;
2010 pArcomageGame->field_F4 = 1;
2011 dword_4FAA68 = 0;
2012 }
2013 v10[0] = 0;
2014 v10[2] = 640;
2015 v10[1] = 0;
2016 v10[3] = 480;
2017 //nullsub_1();
2018 }
2019 if ( dword_4FABB8 != am_40BB67(a1) )
2020 {
2021 dword_4FABB8 = am_40BB67(a1);
2022 pArcomageGame->field_F6 = 1;
2023 }
2024 if ( pArcomageGame->field_F6 )
2025 {
2026 am_blts(v13);
2027 DoBlt_Copy(pArcomageGame->pBackgroundPixels);
2028 pArcomageGame->field_F6 = 0;
2029 }
2030 if ( pArcomageGame->field_F9 )
2031 {
2032 pTargetXY[0] = 0;
2033 pTargetXY[1] = 0;
2034 pSrcXYZW[0] = 0;
2035 pSrcXYZW[2] = 640;
2036 pSrcXYZW[1] = 0;
2037 pSrcXYZW[3] = 480;
2038 am_BeginScene(pArcomageGame->pBackgroundPixels, -1, 1);
2039 Blt_Copy((ArcomageRect *)pSrcXYZW, pTargetXY, 2);
2040 am_EndScene();
2041 am_blts(v13);
2042 pRenderer->Present();
2043 pArcomageGame->field_F9 = 0;
2044 }
2045 }
2046 while ( !v16 );
2047 return dword_4FAA68 > 0;
2048 }
2049 // 40DB22: using guessed type uint __stdcall unk__const_0(uint, uint);
2050 // 4E1874: using guessed type int dword_4E1874;
2051 // 4FAA00: using guessed type char byte_4FAA00;
2052 // 4FAA2D: using guessed type char byte_4FAA2D;
2053 // 4FAA2E: using guessed type char byte_4FAA2E;
2054 // 4FAA34: using guessed type int amuint_4FAA34;
2055 // 4FAA38: using guessed type int amuint_4FAA38;
2056 // 4FAA4C: using guessed type int amuint_4FAA4C;
2057 // 4FAA64: using guessed type int dword_4FAA64;
2058 // 4FAA68: using guessed type int dword_4FAA68;
2059 // 4FAA74: using guessed type char byte_4FAA74;
2060 // 4FAA75: using guessed type char am_byte_4FAA75;
2061 // 4FAA76: using guessed type char am_byte_4FAA76;
2062 // 4FAA77: using guessed type char am_byte_4FAA77;
2063 // 4FABB8: using guessed type int dword_4FABB8;
2064
2065 //----- (0040A9AF) --------------------------------------------------------
2066 void __thiscall am_blts(int a1)
2067 {
2068 int v1; // esi@1
2069 stru272_stru0 **v2; // esi@1
2070
2071 v1 = a1;
2072 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1);
2073 am_chroma_blts();
2074 am_EndScene();
2075 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1);
2076 am_40B4B9();
2077 am_chroma_and_copy_blts();
2078 am_chroma_blt();
2079 am_DrawUI();
2080 am_EndScene();
2081 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1);
2082 am_40B76F(v1);
2083 v2 = (stru272_stru0 **)array_4FAC10;
2084 do
2085 {
2086 if ( *((unsigned char *)v2 - 64) )
2087 (*v2)->_40E133();
2088 v2 += 1067;
2089 }
2090 while ( (signed int)v2 < (signed int)&unk_5052C8 );
2091 dword_4FABBC = am_40BB67(amuint_4FAA6C);
2092 am_40AA4E();
2093 am_EndScene();
2094 }
2095
2096 //----- (0040AA4E) --------------------------------------------------------
2097 void __cdecl am_40AA4E()
2098 {
2099 signed int v0; // ebx@1
2100 char v1; // ch@2@3
2101 char *v2; // esi@4
2102 signed int v3; // edi@6
2103 int *v4; // esi@6
2104 int v5; // [sp-4h] [bp-2Ch]@4
2105 int v6; // [sp+Ch] [bp-1Ch]@10
2106 int v7; // [sp+10h] [bp-18h]@10
2107 int v8; // [sp+14h] [bp-14h]@10
2108 int v9; // [sp+18h] [bp-10h]@10
2109 int v10; // [sp+1Ch] [bp-Ch]@6
2110 char v11; // [sp+20h] [bp-8h]@1
2111 char v12; // [sp+21h] [bp-7h]@1
2112 char v13; // [sp+22h] [bp-6h]@1
2113 char v14; // [sp+24h] [bp-4h]@1
2114 char v15; // [sp+25h] [bp-3h]@1
2115 char v16; // [sp+26h] [bp-2h]@1
2116
2117 v14 = 0;
2118 v15 = -1;
2119 v16 = 0;
2120 v11 = -1;
2121 v12 = 0;
2122 v13 = 0;
2123 v0 = (signed int)byte_4FABD1;
2124 do
2125 {
2126 if ( *(unsigned char *)(v0 - 1) && (*(stru272_stru0 **)(v0 + 63))->_40E2A7() == 2 )
2127 {
2128 BYTE3(v5) = v1;
2129 v2 = &v14;
2130 if ( !*(unsigned char *)v0 )
2131 v2 = &v11;
2132 LOWORD(v5) = *(_WORD *)v2;
2133 BYTE2(v5) = v2[2];
2134 v10 = (unsigned __int16)R8G8B8_to_TargetFormat(v5);
2135 v3 = 0;
2136 v4 = (int *)(v0 + 71);
2137 do
2138 {
2139 if ( *(v4 - 1) > 0 )
2140 {
2141 if ( v3 % 2 )
2142 {
2143 Render::SetPixel((Vec2_int_ *)v4, v10);
2144 }
2145 else
2146 {
2147 v6 = *v4;
2148 v8 = v6 + 2;
2149 v7 = v4[1];
2150 v9 = v7 + 2;
2151 DrawRect((Vec4_int_ *)&v6, v10, 1);
2152 }
2153 }
2154 ++v3;
2155 v4 += 7;
2156 }
2157 while ( v3 < 150 );
2158 }
2159 v0 += 4268;
2160 }
2161 while ( v0 < (signed int)&array_4FAC10[9].field_4[4201] );
2162 }
2163
2164 //----- (0040AB0A) --------------------------------------------------------
2165 void __cdecl am_chroma_blts()
2166 {
2167 int v0; // eax@1
2168 int v1; // eax@1
2169 int v2; // eax@1
2170 int v3; // eax@1
2171 int v4; // eax@1
2172 int v5; // eax@1
2173 int pSrcXYZW[4]; // [sp+Ch] [bp-18h]@1
2174 int pTargetXY[2]; // [sp+1Ch] [bp-8h]@1
2175
2176 pSrcXYZW[1] = 0;
2177 pSrcXYZW[0] = 765;
2178 pSrcXYZW[2] = 843;
2179 pSrcXYZW[3] = 216;
2180 pTargetXY[0] = 8;
2181 pTargetXY[1] = 56;
2182 Blt_Copy((ArcomageRect *)pSrcXYZW, pTargetXY, 2);
2183 pTargetXY[0] = 555;
2184 pTargetXY[1] = 56;
2185 Blt_Copy((ArcomageRect *)pSrcXYZW, pTargetXY, 2);
2186 LOWORD(v0) = pArcomageGame->field_54;
2187 pTargetXY[0] = 8;
2188 pSrcXYZW[0] = 283;
2189 pSrcXYZW[2] = 361;
2190 pSrcXYZW[1] = 166;
2191 pSrcXYZW[3] = 190;
2192 pTargetXY[1] = 13;
2193 Blt_Chroma((ArcomageRect *)pSrcXYZW, pTargetXY, v0, 2);
2194 LOWORD(v1) = pArcomageGame->field_54;
2195 pTargetXY[0] = 555;
2196 pTargetXY[1] = 13;
2197 Blt_Chroma((ArcomageRect *)pSrcXYZW, pTargetXY, v1, 2);
2198 LOWORD(v2) = pArcomageGame->field_54;
2199 pSrcXYZW[0] = 234;
2200 pSrcXYZW[2] = 283;
2201 pSrcXYZW[1] = 166;
2202 pSrcXYZW[3] = 190;
2203 pTargetXY[0] = 100;
2204 pTargetXY[1] = 296;
2205 Blt_Chroma((ArcomageRect *)pSrcXYZW, pTargetXY, v2, 2);
2206 LOWORD(v3) = pArcomageGame->field_54;
2207 pTargetXY[0] = 492;
2208 pTargetXY[1] = 296;
2209 Blt_Chroma((ArcomageRect *)pSrcXYZW, pTargetXY, v3, 2);
2210 LOWORD(v4) = pArcomageGame->field_54;
2211 pSrcXYZW[0] = 192;
2212 pSrcXYZW[2] = 234;
2213 pSrcXYZW[1] = 166;
2214 pSrcXYZW[3] = 190;
2215 pTargetXY[0] = 168;
2216 pTargetXY[1] = 296;
2217 Blt_Chroma((ArcomageRect *)pSrcXYZW, pTargetXY, v4, 2);
2218 pTargetXY[0] = 430;
2219 LOWORD(v5) = pArcomageGame->field_54;
2220 pTargetXY[1] = 296;
2221 Blt_Chroma((ArcomageRect *)pSrcXYZW, pTargetXY, v5, 2);
2222 }
2223
2224 //----- (0040AC5F) --------------------------------------------------------
2225 void __cdecl am_DrawUI()
2226 {
2227 int v0; // ecx@7
2228 int v1; // ecx@9
2229 int v2; // eax@11
2230 int v3; // ecx@12
2231 int v4; // eax@14
2232 int v5; // ecx@14
2233 int v6; // eax@16
2234 int v7; // ecx@16
2235 int v8; // eax@18
2236 int v9; // ecx@18
2237 int v10; // eax@20
2238 char Dest[32]; // [sp+Ch] [bp-28h]@2
2239 int v12[2]; // [sp+2Ch] [bp-8h]@2
2240
2241 if ( am_byte_4FAA77 )
2242 {
2243 inv_strcpy(pGlobalTXT_LocalizationStrings[266], Dest);// DISCARD A CARD
2244 v12[0] = 320 - pArcomageGame->pFont2->GetLineWidth(Dest) / 2;
2245 v12[1] = 306;
2246 pPrimaryWindow_draws_text(-1, Dest, v12);
2247 }
2248 inv_strcpy((const char *)stru_505708, Dest);
2249 if ( !amuint_4FAA6C )
2250 inv_strcat("***", Dest);
2251 v12[0] = 47 - pArcomageGame->pFont1->GetLineWidth(Dest) / 2;
2252 v12[1] = 21;
2253 pPrimaryWindow_draws_text(-1, Dest, v12);
2254 inv_strcpy(stru_505708[1].pPlayerName, Dest);
2255 if ( amuint_4FAA6C == 1 )
2256 inv_strcat("***", Dest);
2257 v12[0] = 595 - pArcomageGame->pFont1->GetLineWidth(Dest) / 2;
2258 v12[1] = 21;
2259 pPrimaryWindow_draws_text(-1, Dest, v12);
2260 intToString(stru_505708[0].field_24, Dest);
2261 v12[0] = 123 - pArcomageGame->pFont1->GetLineWidth(Dest) / 2;
2262 v12[1] = 305;
2263 pPrimaryWindow_draws_text(-1, Dest, v12);
2264 intToString(stru_505708[1].field_24, Dest);
2265 v12[0] = 515 - pArcomageGame->pFont1->GetLineWidth(Dest) / 2;
2266 v12[1] = 305;
2267 pPrimaryWindow_draws_text(-1, Dest, v12);
2268 intToString(stru_505708[0].field_28, Dest);
2269 v12[0] = 188 - pArcomageGame->pFont1->GetLineWidth(Dest) / 2;
2270 v12[1] = 305;
2271 pPrimaryWindow_draws_text(-1, Dest, v12);
2272 intToString(stru_505708[1].field_28, Dest);
2273 v12[0] = 451 - pArcomageGame->pFont1->GetLineWidth(Dest) / 2;
2274 v12[1] = 305;
2275 pPrimaryWindow_draws_text(-1, Dest, v12);
2276 v0 = stru_505708[0].field_2C;
2277 if ( byte_4E185E )
2278 v0 = dword_4E1878 + stru_505708[0].field_2C;
2279 intToString(v0, Dest);
2280 v12[0] = 14 - 6 * 0 / 2;
2281 v12[1] = 92;
2282 am_40B102(-1, Dest, v12);
2283 v1 = stru_505708[1].field_2C;
2284 if ( byte_4E185E )
2285 v1 = dword_4E1878 + stru_505708[1].field_2C;
2286 intToString(v1, Dest);
2287 v2 = 0;
2288 v12[1] = 92;
2289 v12[0] = 561 - 6 * v2 / 2;
2290 am_40B102(-1, Dest, v12);
2291 if ( byte_4E185E )
2292 v3 = stru_505708[0].field_30 + dword_4E187C;
2293 else
2294 v3 = stru_505708[0].field_30;
2295 intToString(v3, Dest);
2296 v4 = 0;
2297 v12[1] = 164;
2298 v12[0] = 14 - 6 * v4 / 2;
2299 am_40B102(-1, Dest, v12);
2300 v5 = stru_505708[1].field_30;
2301 if ( byte_4E185E )
2302 v5 = dword_4E187C + stru_505708[1].field_30;
2303 intToString(v5, Dest);
2304 v6 = 0;
2305 v12[1] = 164;
2306 v12[0] = 561 - 6 * v6 / 2;
2307 am_40B102(-1, Dest, v12);
2308 v7 = stru_505708[0].field_34;
2309 if ( byte_4E185E )
2310 v7 = dword_4E1880 + stru_505708[0].field_34;
2311 intToString(v7, Dest);
2312 v8 = 0;
2313 v12[1] = 236;
2314 v12[0] = 14 - 6 * v8 / 2;
2315 am_40B102(-1, Dest, v12);
2316 v9 = stru_505708[1].field_34;
2317 if ( byte_4E185E )
2318 v9 = dword_4E1880 + stru_505708[1].field_34;
2319 intToString(v9, Dest);
2320 v10 = 0;
2321 v12[1] = 236;
2322 v12[0] = 561 - 6 * v10 / 2;
2323 am_40B102(-1, Dest, v12);
2324 intToString(stru_505708[0].field_38, Dest);
2325 v12[1] = 114;
2326 v12[0] = 10;
2327 am_40B17E(-1, (int)Dest, v12);
2328 intToString(stru_505708[1].field_38, Dest);
2329 v12[0] = 557;
2330 v12[1] = 114;
2331 am_40B17E(-1, (int)Dest, v12);
2332 intToString(stru_505708[0].field_3C, Dest);
2333 v12[0] = 10;
2334 v12[1] = 186;
2335 am_40B1F3(-1, (int)Dest, (int)v12);
2336 intToString(stru_505708[1].field_3C, Dest);
2337 v12[0] = 557;
2338 v12[1] = 186;
2339 am_40B1F3(-1, (int)Dest, (int)v12);
2340 intToString(stru_505708[0].field_40, Dest);
2341 v12[0] = 10;
2342 v12[1] = 258;
2343 am_40B268(-1, Dest, v12);
2344 intToString(stru_505708[1].field_40, Dest);
2345 v12[0] = 557;
2346 v12[1] = 258;
2347 am_40B268(-1, Dest, v12);
2348 }
2349 // 4E185E: using guessed type char byte_4E185E;
2350 // 4E1878: using guessed type int dword_4E1878;
2351 // 4E187C: using guessed type int dword_4E187C;
2352 // 4E1880: using guessed type int dword_4E1880;
2353 // 4FAA77: using guessed type char am_byte_4FAA77;
2354
2355 //----- (0040B102) --------------------------------------------------------
2356 void __fastcall am_40B102(int a1, char *a2, int *pXY)
2357 {
2358 char *v3; // esi@1
2359 int v4; // eax@1
2360 unsigned __int8 v5; // bl@2
2361 char v6; // zf@2
2362 int v7; // eax@3
2363 int v8; // ecx@3
2364 int v9; // [sp+8h] [bp-18h]@3
2365 int v10; // [sp+Ch] [bp-14h]@3
2366 int v11; // [sp+10h] [bp-10h]@3
2367 int v12; // [sp+14h] [bp-Ch]@3
2368 int v13; // [sp+18h] [bp-8h]@1
2369 int v14; // [sp+1Ch] [bp-4h]@1
2370
2371 v3 = a2;
2372 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1);
2373 v4 = pXY[1];
2374 v13 = *pXY;
2375 v14 = v4;
2376 do
2377 {
2378 v5 = *v3++;
2379 v6 = v5 == 0;
2380 if ( v5 )
2381 {
2382 v7 = 22 * v5;
2383 v8 = v7 - 864;
2384 v7 -= 842;
2385 v11 = v7;
2386 LOWORD(v7) = pArcomageGame->field_54;
2387 v9 = v8;
2388 v10 = 190;
2389 v12 = 207;
2390 Blt_Chroma((ArcomageRect *)&v9, &v13, v7, 1);
2391 v13 += 22;
2392 v6 = v5 == 0;
2393 }
2394 }
2395 while ( !v6 );
2396 am_EndScene();
2397 }
2398
2399 //----- (0040B17E) --------------------------------------------------------
2400 void __fastcall am_40B17E(int a1, int a2, int *pXY)
2401 {
2402 int v3; // esi@1
2403 int v4; // eax@1
2404 unsigned __int8 v5; // bl@2
2405 char v6; // zf@2
2406 int v7; // eax@3
2407 int v8; // [sp+8h] [bp-18h]@3
2408 int v9; // [sp+Ch] [bp-14h]@3
2409 int v10; // [sp+10h] [bp-10h]@3
2410 int v11; // [sp+14h] [bp-Ch]@3
2411 int v12; // [sp+18h] [bp-8h]@1
2412 int v13; // [sp+1Ch] [bp-4h]@1
2413
2414 v3 = a2;
2415 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1);
2416 v4 = pXY[1];
2417 v12 = *pXY;
2418 v13 = v4;
2419 do
2420 {
2421 v5 = *(unsigned char *)v3++;
2422 v6 = v5 == 0;
2423 if ( v5 )
2424 {
2425 v7 = 13 * v5;
2426 v8 = v7 - 370;
2427 v10 = v7 - 357;
2428 v9 = 128;
2429 v11 = 138;
2430 Blt_Copy((ArcomageRect *)&v8, &v12, 2);
2431 v12 += 13;
2432 v6 = v5 == 0;
2433 }
2434 }
2435 while ( !v6 );
2436 am_EndScene();
2437 }
2438
2439 //----- (0040B1F3) --------------------------------------------------------
2440 void __fastcall am_40B1F3(int a1, int a2, int a3)
2441 {
2442 int v3; // esi@1
2443 int v4; // eax@1
2444 unsigned __int8 v5; // bl@2
2445 char v6; // zf@2
2446 int v7; // eax@3
2447 int v8; // [sp+8h] [bp-18h]@3
2448 int v9; // [sp+Ch] [bp-14h]@3
2449 int v10; // [sp+10h] [bp-10h]@3
2450 int v11; // [sp+14h] [bp-Ch]@3
2451 int v12; // [sp+18h] [bp-8h]@1
2452 int v13; // [sp+1Ch] [bp-4h]@1
2453
2454 v3 = a2;
2455 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1);
2456 v4 = *(unsigned int *)(a3 + 4);
2457 v12 = *(unsigned int *)a3;
2458 v13 = v4;
2459 do
2460 {
2461 v5 = *(unsigned char *)v3++;
2462 v6 = v5 == 0;
2463 if ( v5 )
2464 {
2465 v7 = 13 * v5;
2466 v8 = v7 - 370;
2467 v10 = v7 - 357;
2468 v9 = 138;
2469 v11 = 148;
2470 Blt_Copy((ArcomageRect *)&v8, &v12, 2);
2471 v12 += 13;
2472 v6 = v5 == 0;
2473 }
2474 }
2475 while ( !v6 );
2476 am_EndScene();
2477 }
2478
2479 //----- (0040B268) --------------------------------------------------------
2480 void __fastcall am_40B268(int a1, char *a2, int *pXY)
2481 {
2482 char *v3; // esi@1
2483 int v4; // eax@1
2484 unsigned __int8 v5; // bl@2
2485 char v6; // zf@2
2486 int v7; // eax@3
2487 int v8; // [sp+8h] [bp-18h]@3
2488 int v9; // [sp+Ch] [bp-14h]@3
2489 int v10; // [sp+10h] [bp-10h]@3
2490 int v11; // [sp+14h] [bp-Ch]@3
2491 int v12; // [sp+18h] [bp-8h]@1
2492 int v13; // [sp+1Ch] [bp-4h]@1
2493
2494 v3 = a2;
2495 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1);
2496 v4 = pXY[1];
2497 v12 = *pXY;
2498 v13 = v4;
2499 do
2500 {
2501 v5 = *v3++;
2502 v6 = v5 == 0;
2503 if ( v5 )
2504 {
2505 v7 = 13 * v5;
2506 v8 = v7 - 370;
2507 v10 = v7 - 357;
2508 v9 = 148;
2509 v11 = 158;
2510 Blt_Copy((ArcomageRect *)&v8, &v12, 2);
2511 v12 += 13;
2512 v6 = v5 == 0;
2513 }
2514 }
2515 while ( !v6 );
2516 am_EndScene();
2517 }
2518
2519 //----- (0040B2DD) --------------------------------------------------------
2520 void __cdecl am_chroma_and_copy_blts()
2521 {
2522 int v0; // eax@1
2523 int v1; // esi@3
2524 int v2; // eax@3
2525 int v3; // eax@3
2526 int v4; // esi@5
2527 int v5; // eax@5
2528 int pSrcXYZW[4]; // [sp+0h] [bp-18h]@3
2529 int v7; // [sp+4h] [bp-14h]@3
2530 int v8; // [sp+8h] [bp-10h]@3
2531 int v9; // [sp+Ch] [bp-Ch]@3
2532 int pTargetXY[2]; // [sp+10h] [bp-8h]@3
2533
2534 v0 = stru_505708[0].field_24;
2535 if ( stru_505708[0].field_24 > dword_4E1884 )
2536 v0 = dword_4E1884;
2537 v7 = 0;
2538 pSrcXYZW[0] = 892;
2539 v8 = 937;
2540 pTargetXY[0] = 102;
2541 v1 = 200 * v0 / dword_4E1884;
2542 v9 = v1;
2543 pTargetXY[1] = 297 - v1;
2544 Blt_Copy((ArcomageRect *)pSrcXYZW, pTargetXY, 2);
2545 v7 = 0;
2546 v2 = 203 - v1;
2547 pTargetXY[1] = 203 - v1;
2548 LOWORD(v2) = pArcomageGame->field_54;
2549 pSrcXYZW[0] = 384;
2550 v8 = 452;
2551 v9 = 94;
2552 pTargetXY[0] = 91;
2553 Blt_Chroma((ArcomageRect *)pSrcXYZW, pTargetXY, v2, 2);
2554 v3 = stru_505708[1].field_24;
2555 if ( stru_505708[1].field_24 > dword_4E1884 )
2556 v3 = dword_4E1884;
2557 v7 = 0;
2558 pSrcXYZW[0] = 892;
2559 v8 = 937;
2560 pTargetXY[0] = 494;
2561 v4 = 200 * v3 / dword_4E1884;
2562 v9 = v4;
2563 pTargetXY[1] = 297 - v4;
2564 Blt_Copy((ArcomageRect *)pSrcXYZW, pTargetXY, 2);
2565 LOWORD(v5) = pArcomageGame->field_54;
2566 pSrcXYZW[0] = 384;
2567 v8 = 452;
2568 v7 = 94;
2569 v9 = 188;
2570 pTargetXY[0] = 483;
2571 pTargetXY[1] = 203 - v4;
2572 Blt_Chroma((ArcomageRect *)pSrcXYZW, pTargetXY, v5, 2);
2573 }
2574 // 4E1884: using guessed type int dword_4E1884;
2575
2576 //----- (0040B400) --------------------------------------------------------
2577 void __cdecl am_chroma_blt()
2578 {
2579 int v0; // eax@1
2580 int v1; // eax@4
2581 int v2; // ecx@4
2582 int v3; // eax@5
2583 int v4; // eax@8
2584 int v5; // esi@8
2585 int pSrcXYZW[4]; // [sp+4h] [bp-18h]@4
2586 int pTargetXY[2]; // [sp+14h] [bp-8h]@4
2587
2588 v0 = stru_505708[0].field_28;
2589 if ( stru_505708[0].field_28 <= 100 )
2590 {
2591 if ( stru_505708[0].field_28 <= 0 )
2592 goto LABEL_5;
2593 }
2594 else
2595 {
2596 v0 = 100;
2597 }
2598 pSrcXYZW[1] = 0;
2599 pSrcXYZW[0] = 843;
2600 v1 = 200 * v0 / 100;
2601 pSrcXYZW[2] = 867;
2602 pTargetXY[0] = 177;
2603 pSrcXYZW[3] = v1;
2604 v2 = 297 - v1;
2605 LOWORD(v1) = pArcomageGame->field_54;
2606 pTargetXY[1] = v2;
2607 Blt_Chroma((ArcomageRect *)pSrcXYZW, pTargetXY, v1, 2);
2608 LABEL_5:
2609 v3 = stru_505708[1].field_28;
2610 if ( stru_505708[1].field_28 <= 100 )
2611 {
2612 if ( stru_505708[1].field_28 <= 0 )
2613 return;
2614 }
2615 else
2616 {
2617 v3 = 100;
2618 }
2619 pSrcXYZW[1] = 0;
2620 pSrcXYZW[0] = 843;
2621 v4 = 200 * v3 / 100;
2622 pSrcXYZW[2] = 867;
2623 pTargetXY[0] = 439;
2624 pSrcXYZW[3] = v4;
2625 v5 = 297 - v4;
2626 LOWORD(v4) = pArcomageGame->field_54;
2627 pTargetXY[1] = v5;
2628 Blt_Chroma((ArcomageRect *)pSrcXYZW, pTargetXY, v4, 2);
2629 }
2630
2631 //----- (0040B4B9) --------------------------------------------------------
2632 void __cdecl am_40B4B9()
2633 {
2634 int v0; // esi@1
2635 int v1; // ebx@1
2636 int v2; // edi@1
2637 int v3; // edx@2
2638 int v4; // eax@3
2639 int v5; // ecx@3
2640 int v6; // eax@3
2641 unsigned int v7; // ecx@4
2642 int v8; // eax@16
2643 int v9; // ecx@16
2644 int v10; // eax@16
2645 signed int v11; // edi@18
2646 int v12; // esi@20
2647 unsigned int v13; // ecx@20
2648 int v14; // eax@23
2649 unsigned int v15; // eax@25
2650 unsigned int v16; // ecx@25
2651 int *v17; // esi@26
2652 unsigned int v18; // eax@29
2653 int *v19; // ecx@29
2654 int v20; // ecx@31
2655 int v21; // [sp-4h] [bp-2Ch]@8
2656 int pSrcXYZW[4]; // [sp+Ch] [bp-1Ch]@8
2657 int pTargetXY[2]; // [sp+1Ch] [bp-Ch]@1
2658 int v24; // [sp+24h] [bp-4h]@1
2659
2660 v0 = am_40BB49(amuint_4FAA6C);
2661 v1 = 0;
2662 v2 = 0;
2663 pTargetXY[1] = 327;
2664 v24 = (640 - 96 * v0) / (v0 + 1);
2665 pTargetXY[0] = (640 - 96 * v0) / (v0 + 1);
2666 while ( v2 < v0 )
2667 {
2668 v3 = amuint_4FAA6C;
2669 if ( am_byte_4E185D != (_BYTE)v1 )
2670 {
2671 v4 = 188 * amuint_4FAA6C + 8 * v2;
2672 v5 = *(int *)((char *)stru_505708[0].arr_6C[0] + v4);
2673 v6 = *(int *)((char *)&stru_505708[0].arr_6C[0][1] + v4);
2674 pTargetXY[0] += v5;
2675 pTargetXY[1] += v6;
2676 }
2677 v7 = stru_505708[0].arr_44[v2 + 47 * amuint_4FAA6C];
2678 if ( v7 == -1 )
2679 {
2680 ++v0;
2681 goto LABEL_15;
2682 }
2683 if ( v2 != amuint_4FAA4C )
2684 {
2685 if ( LOBYTE(stru_505708[amuint_4FAA6C].field_20) == (_BYTE)v1 && byte_505881 == (_BYTE)v1 )
2686 {
2687 pSrcXYZW[0] = 192;
2688 pSrcXYZW[2] = 288;
2689 pSrcXYZW[1] = v1;
2690 pSrcXYZW[3] = 128;
2691 v21 = 2;
2692 LABEL_12:
2693 Blt_Copy((ArcomageRect *)pSrcXYZW, pTargetXY, v21);
2694 goto LABEL_13;
2695 }
2696 ArcomageGame::GetCardRect(v7, (ArcomageRect *)pSrcXYZW);
2697 if ( !am_40BF15(amuint_4FAA6C, v2) )
2698 {
2699 v1 = 0;
2700 v21 = 0;
2701 goto LABEL_12;
2702 }
2703 Blt_Copy((ArcomageRect *)pSrcXYZW, pTargetXY, 2);
2704 v1 = 0;
2705 }
2706 LABEL_13:
2707 v3 = amuint_4FAA6C;
2708 pTargetXY[0] += v24 + 96;
2709 LABEL_15:
2710 if ( am_byte_4E185D != (_BYTE)v1 )
2711 {
2712 v8 = 188 * v3 + 8 * v2;
2713 v9 = *(int *)((char *)stru_505708[0].arr_6C[0] + v8);
2714 v10 = *(int *)((char *)&stru_505708[0].arr_6C[0][1] + v8);
2715 pTargetXY[0] -= v9;
2716 pTargetXY[1] -= v10;
2717 }
2718 ++v2;
2719 }
2720 v11 = 0;
2721 do
2722 {
2723 if ( am_byte_4FAA76 == (_BYTE)v1 )
2724 {
2725 v12 = 4 * v11;
2726 v13 = amuint_4FAA78[8 * v11];
2727 if ( v13 != -1 )
2728 {
2729 ArcomageGame::GetCardRect(v13, (ArcomageRect *)pSrcXYZW);
2730 Blt_Copy((ArcomageRect *)pSrcXYZW, amuint_4FAA90[v12], v1);
2731 }
2732 if ( am_byte_4FAA7C[v12 * 8] != (_BYTE)v1 )
2733 {
2734 pTargetXY[0] = amuint_4FAA90[v12][0] + 12;
2735 v14 = amuint_4FAA90[v12][1] + 40;
2736 pTargetXY[1] = amuint_4FAA90[v12][1] + 40;
2737 LOWORD(v14) = pArcomageGame->field_54;
2738 pSrcXYZW[0] = 843;
2739 pSrcXYZW[2] = 916;
2740 pSrcXYZW[1] = 200;
2741 pSrcXYZW[3] = 216;
2742 Blt_Chroma((ArcomageRect *)pSrcXYZW, pTargetXY, v14, 2);
2743 }
2744 }
2745 else
2746 {
2747 if ( amuint_4FAA34 <= v1 )
2748 {
2749 if ( v11 == 9 )
2750 {
2751 am_byte_4FAA76 = v1;
2752 am_byte_4FAA75 = v1;
2753 amuint_4FAA34 = 5;
2754 }
2755 v18 = 32 * v11;
2756 v19 = &amuint_4FAA78[8 * v11];
2757 if ( *v19 != -1 )
2758 amuint_4FABC4 = *v19;
2759 *v19 = -1;
2760 amuint_4FAA90[v18 / 8][0] = amuint_4FAA80[v18 / 4];
2761 v20 = amuint_4FAA84[v18 / 4];
2762 am_byte_4FAA7C[v18] = v1;
2763 amuint_4FAA90[v18 / 8][1] = v20;
2764 }
2765 else
2766 {
2767 v15 = 32 * v11;
2768 v16 = amuint_4FAA78[8 * v11];
2769 if ( v16 != -1 )
2770 {
2771 v17 = amuint_4FAA90[v15 / 8];
2772 *v17 += amuint_4FAA88[v15 / 4];
2773 amuint_4FAA90[v15 / 8][1] += amuint_4FAA8C[v15 / 4];
2774 ArcomageGame::GetCardRect(v16, (ArcomageRect *)pSrcXYZW);
2775 Blt_Copy((ArcomageRect *)pSrcXYZW, v17, v1);
2776 }
2777 }
2778 }
2779 ++v11;
2780 }
2781 while ( v11 < 10 );
2782 if ( am_byte_4FAA76 != (_BYTE)v1 )
2783 --amuint_4FAA34;
2784 pSrcXYZW[0] = 192;
2785 pSrcXYZW[2] = 288;
2786 pSrcXYZW[1] = v1;
2787 pSrcXYZW[3] = 128;
2788 pTargetXY[0] = 120;
2789 pTargetXY[1] = 18;
2790 Blt_Copy((ArcomageRect *)pSrcXYZW, pTargetXY, v1);
2791 }
2792 // 4E185D: using guessed type char am_byte_4E185D;
2793 // 4FAA34: using guessed type int amuint_4FAA34;
2794 // 4FAA4C: using guessed type int amuint_4FAA4C;
2795 // 4FAA75: using guessed type char am_byte_4FAA75;
2796 // 4FAA76: using guessed type char am_byte_4FAA76;
2797 // 4FAA78: using guessed type int amuint_4FAA78[];
2798 // 4FAA80: using guessed type int amuint_4FAA80[];
2799 // 4FAA84: using guessed type int amuint_4FAA84[];
2800 // 4FAA88: using guessed type int amuint_4FAA88[];
2801 // 4FAA8C: using guessed type int amuint_4FAA8C[];
2802 // 4FABC4: using guessed type int amuint_4FABC4;
2803 // 505881: using guessed type char byte_505881;
2804
2805
2806
2807 //----- (0040B76F) --------------------------------------------------------
2808 void __fastcall am_40B76F(int a1)
2809 {
2810 int v1; // eax@3
2811 int v2; // eax@3
2812 int v3; // esi@4
2813 int v4; // eax@4
2814 int *v5; // edx@6
2815 int *v6; // ecx@6
2816 signed int v7; // ebx@11
2817 int v8; // eax@15
2818 signed int v9; // ecx@15
2819 int v10; // eax@20
2820 int v11; // ecx@20
2821 int v12; // eax@20
2822 unsigned int v13; // ecx@21
2823 double v14; // st7@22
2824 int *v15; // edx@23
2825 int v16; // eax@32
2826 char v17; // zf@37
2827 int v18; // eax@41
2828 int v19; // eax@46
2829 int v20; // ecx@46
2830 int v21; // eax@46
2831 int v22; // [sp-4h] [bp-2Ch]@6
2832 int v23; // [sp-4h] [bp-2Ch]@28
2833 int pSrcXYZW[4]; // [sp+Ch] [bp-1Ch]@6
2834 int pTargetXY[2]; // [sp+1Ch] [bp-Ch]@20
2835 int v26; // [sp+24h] [bp-4h]@1
2836
2837 v26 = a1;
2838 if ( amuint_4FAA4C != -1 )
2839 {
2840 if ( amuint_4FAA38 >= 9 )
2841 {
2842 am_uint_4FAA44_blt_xy[1] = 18;
2843 am_uint_4FAA44_blt_xy[0] = 120;
2844 v1 = am_40BB49(amuint_4FAA6C);
2845 v2 = (640 - 96 * v1) / v1 + 96;
2846 if ( am_byte_4E185D )
2847 {
2848 v3 = 188 * amuint_4FAA6C + 8 * amuint_4FAA4C;
2849 amuint_4FAA3C_blt_xy[0] = (amuint_4FAA4C * v2 + *(int *)((char *)stru_505708[0].arr_6C[0] + v3) - 120) / 10;
2850 v4 = (*(int *)((char *)&stru_505708[0].arr_6C[0][1] + v3) + 309) / 10;
2851 }
2852 else
2853 {
2854 amuint_4FAA3C_blt_xy[0] = (amuint_4FAA4C * v2 - 120) / 10;
2855 v4 = 30;
2856 }
2857 am_uint_4FAA44_blt_xy[1] += v4;
2858 am_uint_4FAA44_blt_xy[0] += amuint_4FAA3C_blt_xy[0];
2859 pSrcXYZW[1] = 0;
2860 amuint_4FAA3C_blt_xy[1] = v4;
2861 pSrcXYZW[0] = 192;
2862 pSrcXYZW[2] = 288;
2863 pSrcXYZW[3] = 128;
2864 v22 = 2;
2865 v5 = am_uint_4FAA44_blt_xy;
2866 v6 = pSrcXYZW;
2867 goto LABEL_7;
2868 }
2869 pSrcXYZW[1] = 0;
2870 v6 = pSrcXYZW;
2871 v5 = am_uint_4FAA44_blt_xy;
2872 v22 = 2;
2873 pSrcXYZW[3] = 128;
2874 pSrcXYZW[2] = 288;
2875 pSrcXYZW[0] = 192;
2876 if ( amuint_4FAA38 )
2877 {
2878 am_uint_4FAA44_blt_xy[0] += amuint_4FAA3C_blt_xy[0];
2879 am_uint_4FAA44_blt_xy[1] += amuint_4FAA3C_blt_xy[1];
2880 LABEL_7:
2881 Blt_Copy((ArcomageRect *)v6, v5, v22);
2882 goto LABEL_11;
2883 }
2884 am_uint_4FAA44_blt_xy[0] += amuint_4FAA3C_blt_xy[0];
2885 am_uint_4FAA44_blt_xy[1] += amuint_4FAA3C_blt_xy[1];
2886 Blt_Copy((ArcomageRect *)pSrcXYZW, am_uint_4FAA44_blt_xy, 2);
2887 amuint_4FAA4C = -1;
2888 }
2889 LABEL_11:
2890 v7 = (signed int)amuint_4FAA78;
2891 if ( uCardID != -1 )
2892 {
2893 if ( v26 <= 10 )
2894 {
2895 if ( v26 == 10 )
2896 {
2897 ArcomageGame::GetCardRect(uCardID, (ArcomageRect *)pSrcXYZW);
2898 v8 = 0;
2899 v9 = (signed int)amuint_4FAA78;
2900 while ( *(unsigned int *)v9 != -1 )
2901 {
2902 v9 += 32;
2903 ++v8;
2904 if ( v9 >= (signed int)&dword_4FABB8 )
2905 goto LABEL_20;
2906 }
2907 amuint_4FAA78[8 * v8] = uCardID;
2908 am_byte_4FAA7C[32 * v8] = 1;
2909 LABEL_20:
2910 v10 = 8 * v8;
2911 v11 = amuint_4FAA80[v10];
2912 v12 = amuint_4FAA84[v10];
2913 pTargetXY[0] = v11;
2914 pTargetXY[1] = v12;
2915 Blt_Copy((ArcomageRect *)pSrcXYZW, pTargetXY, 0);
2916 uCardID = -1;
2917 }
2918 }
2919 else
2920 {
2921 ArcomageGame::GetCardRect(uCardID, (ArcomageRect *)pSrcXYZW);
2922 amuint_4FAA5C_blt_xy[0] += amuint_4FAA54_blt_xy[0];
2923 amuint_4FAA5C_blt_xy[1] += amuint_4FAA54_blt_xy[1];
2924 Blt_Copy((ArcomageRect *)pSrcXYZW, amuint_4FAA5C_blt_xy, 0);
2925 }
2926 }
2927 v13 = amuint_4FABC0;
2928 if ( amuint_4FABC0 != -1 )
2929 {
2930 v14 = (double)v26;
2931 if ( v14 > 15.0 )
2932 {
2933 ArcomageGame::GetCardRect(amuint_4FABC0, (ArcomageRect *)pSrcXYZW);
2934 v15 = amuint_4FAA5C_blt_xy;
2935 amuint_4FAA5C_blt_xy[0] += amuint_4FAA54_blt_xy[0];
2936 amuint_4FAA5C_blt_xy[1] += amuint_4FAA54_blt_xy[1];
2937 LABEL_28:
2938 v23 = 2;
2939 LABEL_29:
2940 Blt_Copy((ArcomageRect *)pSrcXYZW, v15, v23);
2941 return;
2942 }
2943 if ( v14 == 15.0 )
2944 {
2945 am_40BF77(amuint_4FAA6C, amuint_4FABC0);
2946 v13 = amuint_4FABC0;
2947 goto LABEL_26;
2948 }
2949 if ( v14 == 5.0 )
2950 {
2951 amuint_4FAA5C_blt_xy[0] = 272;
2952 amuint_4FAA5C_blt_xy[1] = 173;
2953 v16 = 0;
2954 do
2955 {
2956 if ( *(unsigned int *)v7 == -1 )
2957 break;
2958 v7 += 32;
2959 ++v16;
2960 }
2961 while ( v7 < (signed int)&dword_4FABB8 );
2962 v26 = 32 * v16;
2963 amuint_4FAA54_blt_xy[0] = (amuint_4FAA80[8 * v16] - 272) / 5;
2964 amuint_4FAA54_blt_xy[1] = (amuint_4FAA84[8 * v16] - 173) / 5;
2965 ArcomageGame::GetCardRect(amuint_4FABC0, (ArcomageRect *)pSrcXYZW);
2966 pTargetXY[0] = 272;
2967 pTargetXY[1] = 173;
2968 goto LABEL_27;
2969 }
2970 if ( v14 >= 5.0 )
2971 {
2972 v17 = v26 == 0;
2973 }
2974 else
2975 {
2976 v17 = v26 == 0;
2977 if ( v26 > 0 )
2978 {
2979 ArcomageGame::GetCardRect(amuint_4FABC0, (ArcomageRect *)pSrcXYZW);
2980 v15 = amuint_4FAA5C_blt_xy;
2981 amuint_4FAA5C_blt_xy[0] += amuint_4FAA54_blt_xy[0];
2982 amuint_4FAA5C_blt_xy[1] += amuint_4FAA54_blt_xy[1];
2983 v23 = 0;
2984 goto LABEL_29;
2985 }
2986 }
2987 if ( !v17 )
2988 {
2989 LABEL_26:
2990 ArcomageGame::GetCardRect(v13, (ArcomageRect *)pSrcXYZW);
2991 pTargetXY[0] = 272;
2992 pTargetXY[1] = 173;
2993 LABEL_27:
2994 v15 = pTargetXY;
2995 goto LABEL_28;
2996 }
2997 ArcomageGame::GetCardRect(amuint_4FABC0, (ArcomageRect *)pSrcXYZW);
2998 v18 = 0;
2999 while ( *(unsigned int *)v7 != -1 )
3000 {
3001 v7 += 32;
3002 ++v18;
3003 if ( v7 >= (signed int)&dword_4FABB8 )
3004 goto LABEL_46;
3005 }
3006 amuint_4FAA78[8 * v18] = amuint_4FABC0;
3007 LABEL_46:
3008 v19 = 8 * v18;
3009 v20 = amuint_4FAA80[v19];
3010 v21 = amuint_4FAA84[v19];
3011 pTargetXY[0] = v20;
3012 pTargetXY[1] = v21;
3013 Blt_Copy((ArcomageRect *)pSrcXYZW, pTargetXY, 0);
3014 amuint_4FABC0 = -1;
3015 }
3016 }
3017 // 4E185D: using guessed type char am_byte_4E185D;
3018 // 4FAA38: using guessed type int amuint_4FAA38;
3019 // 4FAA4C: using guessed type int amuint_4FAA4C;
3020 // 4FAA78: using guessed type int amuint_4FAA78[];
3021 // 4FAA80: using guessed type int amuint_4FAA80[];
3022 // 4FAA84: using guessed type int amuint_4FAA84[];
3023 // 4FABB8: using guessed type int dword_4FABB8;
3024
3025 //----- (0040BB12) --------------------------------------------------------
3026 void ArcomageGame::GetCardRect(unsigned int uCardID, ArcomageRect *pCardRect)
3027 {
3028 ArcomageRect *pXYZW; // esi@1
3029 int v3; // edx@1
3030 int v4; // ecx@1
3031
3032 pXYZW = pCardRect;
3033 v3 = pCards[uCardID].slot % 10;
3034 v4 = (pCards[uCardID].slot / 10 << 7) + 220;
3035 pXYZW->y = v4;
3036 pXYZW->x = 96 * v3;
3037 pXYZW->w = v4 + 128;
3038 pXYZW->z = 96 * v3 + 96;
3039 }
3040
3041 //----- (0040BB49) --------------------------------------------------------
3042 int __fastcall am_40BB49(int a1)
3043 {
3044 int result; // eax@1
3045 char *v2; // ecx@1
3046 signed int v3; // edx@1
3047
3048 result = 0;
3049 v2 = (char *)stru_505708[a1].arr_44;
3050 v3 = 10;
3051 do
3052 {
3053 if ( *(unsigned int *)v2 != -1 )
3054 ++result;
3055 v2 += 4;
3056 --v3;
3057 }
3058 while ( v3 );
3059 return result;
3060 }
3061
3062 //----- (0040BB67) --------------------------------------------------------
3063 signed int __fastcall am_40BB67(int a1)
3064 {
3065 int v1; // esi@1
3066 signed int result; // eax@1
3067 int v3; // ebx@1
3068 char v4; // zf@1
3069 int v5; // eax@3
3070 int v6; // eax@4
3071 int v7; // ecx@6
3072 char *v8; // eax@6
3073 int v9; // eax@10
3074 int v10; // ecx@10
3075 int v11; // eax@10
3076 char v12; // ch@2@11
3077 int v13; // ST00_4@12
3078 unsigned __int16 v14; // ax@12
3079 int v15; // eax@13
3080 int v16; // ecx@13
3081 int v17; // eax@13
3082 char v18; // al@16
3083 char v19; // ch@2@16
3084 int v20; // ST00_4@19
3085 unsigned __int16 v21; // ax@19
3086 int pXYZW[4]; // [sp+Ch] [bp-3Ch]@3
3087 stru273 v26; // [sp+1Ch] [bp-2Ch]@2
3088 int a1a; // [sp+28h] [bp-20h]@1
3089 int v25; // [sp+2Ch] [bp-1Ch]@3
3090 int var18; // [sp+30h] [bp-18h]@3
3091 int i; // [sp+34h] [bp-14h]@4
3092 int v28; // [sp+38h] [bp-10h]@1
3093 int a2; // [sp+3Ch] [bp-Ch]@3
3094 int v30; // [sp+40h] [bp-8h]@1
3095 char v31; // [sp+44h] [bp-4h]@12
3096 char v32; // [sp+45h] [bp-3h]@12
3097 char v33; // [sp+46h] [bp-2h]@12
3098
3099 v1 = a1;
3100 v30 = 0;
3101 result = -1;
3102 v3 = 188 * a1;
3103 a1a = a1;
3104 v4 = LOBYTE(stru_505708[a1].field_20) == 0;
3105 v28 = -1;
3106 if ( !v4 )
3107 {
3108 if ( v26._40DD2F() )
3109 {
3110 v5 = am_40BB49(v1);
3111 a2 = 0;
3112 v25 = v5;
3113 pXYZW[1] = 327;
3114 pXYZW[3] = 455;
3115 pXYZW[0] = (640 - 96 * v5) / (v5 + 1);
3116 var18 = pXYZW[0] + 96;
3117 pXYZW[2] = pXYZW[0] + 96;
3118 if ( v5 > 0 )
3119 {
3120 v6 = 47 * v1;
3121 for ( i = 47 * v1; ; v6 = i )
3122 {
3123 v7 = v30;
3124 v8 = (char *)&stru_505708[0].arr_44[v30 + v6];
3125 if ( *(unsigned int *)v8 == -1 )
3126 {
3127 do
3128 {
3129 v8 += 4;
3130 ++v7;
3131 }
3132 while ( *(unsigned int *)v8 == -1 );
3133 v30 = v7;
3134 }
3135 if ( am_byte_4E185D )
3136 {
3137 v9 = v3 + 8 * v7;
3138 v10 = *(int *)((char *)stru_505708[0].arr_6C[0] + v9);
3139 v11 = *(int *)((char *)&stru_505708[0].arr_6C[0][1] + v9);
3140 pXYZW[0] += v10;
3141 pXYZW[2] += v10;
3142 pXYZW[1] += v11;
3143 pXYZW[3] += v11;
3144 }
3145 if ( v26.Inside((Vec4_int_ *)pXYZW) )
3146 break;
3147 v31 = 0;
3148 v32 = 0;
3149 v33 = 0;
3150 BYTE3(v13) = v12;
3151 LOWORD(v13) = *(_WORD *)&v31;
3152 BYTE2(v13) = 0;
3153 v14 = R8G8B8_to_TargetFormat(v13);
3154 DrawRect((Vec4_int_ *)pXYZW, v14, 0);
3155 pXYZW[0] += var18;
3156 pXYZW[2] += var18;
3157 if ( am_byte_4E185D )
3158 {
3159 v15 = v3 + 8 * v30;
3160 v16 = *(int *)((char *)stru_505708[0].arr_6C[0] + v15);
3161 v17 = *(int *)((char *)&stru_505708[0].arr_6C[0][1] + v15);
3162 pXYZW[0] -= v16;
3163 pXYZW[2] -= v16;
3164 pXYZW[1] -= v17;
3165 pXYZW[3] -= v17;
3166 }
3167 ++v30;
3168 ++a2;
3169 if ( a2 >= v25 )
3170 goto LABEL_20;
3171 }
3172 v28 = a2;
3173 v18 = am_40BF15(a1a, a2);
3174 v31 = -1;
3175 if ( v18 )
3176 {
3177 v32 = -1;
3178 v33 = -1;
3179 }
3180 else
3181 {
3182 v32 = 0;
3183 v33 = 0;
3184 }
3185 BYTE3(v20) = v19;
3186 LOWORD(v20) = *(_WORD *)&v31;
3187 BYTE2(v20) = v33;
3188 v21 = R8G8B8_to_TargetFormat(v20);
3189 DrawRect((Vec4_int_ *)pXYZW, v21, 0);
3190 }
3191 }
3192 LABEL_20:
3193 result = v28;
3194 }
3195 return result;
3196 }
3197 // 4E185D: using guessed type char am_byte_4E185D;
3198
3199 //----- (0040BCFB) --------------------------------------------------------
3200 char __fastcall am_40BCFB(int a1, signed int a2)
3201 {
3202 int v2; // esi@2
3203 signed int v3; // edi@2
3204 char *v4; // eax@2
3205 int v5; // ecx@7
3206 int v6; // ebx@7
3207 int v7; // esi@8
3208 int v8; // eax@8
3209 int v9; // esi@8
3210 int v10; // ecx@8
3211 int v11; // eax@8
3212 int v12; // eax@8
3213 signed int v13; // edx@9
3214 unsigned int v14; // eax@12
3215 char result; // al@12
3216
3217 if ( a2 <= -1 )
3218 goto LABEL_16;
3219 v2 = 0;
3220 v3 = 0;
3221 v4 = (char *)stru_505708[a1].arr_44;
3222 do
3223 {
3224 if ( *(unsigned int *)v4 != -1 )
3225 {
3226 if ( a2 == v2 )
3227 break;
3228 ++v2;
3229 }
3230 ++v3;
3231 v4 += 4;
3232 }
3233 while ( v3 < 10 );
3234 v5 = v3 + 47 * a1;
3235 v6 = 4 * v5 + 5265228;
3236 if ( BYTE3(pCards[stru_505708[0].arr_44[v5]].field_28) )
3237 {
3238 ArcomageGame::PlaySound(0x16u);
3239 v7 = amuint_4FAA6C;
3240 v8 = am_40BB49(amuint_4FAA6C);
3241 v9 = 188 * v7 + 8 * v3;
3242 v10 = 96 * v3 + *(int *)((char *)stru_505708[0].arr_6C[0] + v9) + (640 - 96 * v8) / (v8 + 1);
3243 v11 = *(int *)((char *)&stru_505708[0].arr_6C[0][1] + v9) + 327;
3244 amuint_4FAA5C_blt_xy[0] = v10;
3245 amuint_4FAA5C_blt_xy[1] = v11;
3246 v12 = 0;
3247 if ( !am_byte_4FAA75 )
3248 {
3249 v13 = (signed int)amuint_4FAA78;
3250 do
3251 {
3252 if ( *(unsigned int *)v13 == -1 )
3253 break;
3254 v13 += 32;
3255 ++v12;
3256 }
3257 while ( v13 < (signed int)&dword_4FABB8 );
3258 }
3259 pArcomageGame->field_F6 = 1;
3260 amuint_4FAA54_blt_xy[0] = (amuint_4FAA80[8 * v12] - v10) / 10;
3261 amuint_4FAA54_blt_xy[1] = (amuint_4FAA84[8 * v12] - 327) / 10;
3262 v14 = *(unsigned int *)v6;
3263 *(unsigned int *)v6 = -1;
3264 am_byte_4FAA77 = 0;
3265 uCardID = v14;
3266 result = 1;
3267 }
3268 else
3269 {
3270 LABEL_16:
3271 result = 0;
3272 }
3273 return result;
3274 }
3275 // 4FAA75: using guessed type char am_byte_4FAA75;
3276 // 4FAA77: using guessed type char am_byte_4FAA77;
3277 // 4FAA78: using guessed type int amuint_4FAA78[];
3278 // 4FAA80: using guessed type int amuint_4FAA80[];
3279 // 4FAA84: using guessed type int amuint_4FAA84[];
3280 // 4FABB8: using guessed type int dword_4FABB8;
3281
3282 //----- (0040BE0E) --------------------------------------------------------
3283 bool __fastcall am_40BE0E(int a1, signed int a2)
3284 {
3285 bool result; // eax@0
3286 int v3; // ebp@1
3287 int v4; // ecx@2
3288 ArcomageGame_stru0 *v5; // esi@2
3289 int v6; // edi@2
3290 int v7; // eax@2
3291 int v8; // ebx@8
3292 int v9; // eax@8
3293 int v10; // ebx@8
3294 int v11; // ebp@8
3295 int v12; // ecx@8
3296 int v13; // eax@8
3297 ArcomageCard *v14; // eax@8
3298 int v15; // ecx@8
3299 int v16; // ecx@8
3300
3301 v3 = a1;
3302 if ( a2 <= -1 )
3303 goto LABEL_12;
3304 v4 = 0;
3305 v5 = &stru_505708[v3];
3306 v6 = 0;
3307 v7 = (int)v5->arr_44;
3308 do
3309 {
3310 if ( *(unsigned int *)v7 != -1 )
3311 {
3312 if ( a2 == v4 )
3313 break;
3314 ++v4;
3315 }
3316 ++v6;
3317 v7 += 4;
3318 }
3319 while ( v6 < 10 );
3320 result = am_40BF15(v3, v6);
3321 if ( result )
3322 {
3323 ArcomageGame::PlaySound(0x17u);
3324 v8 = amuint_4FAA6C;
3325 v9 = am_40BB49(amuint_4FAA6C);
3326 v10 = 188 * v8 + 8 * v6;
3327 v11 = v6 + 47 * v3;
3328 amuint_4FAA54_blt_xy[1] = -30;
3329 pArcomageGame->field_F6 = 1;
3330 v12 = 96 * v6 + *(int *)((char *)stru_505708[0].arr_6C[0] + v10) + (640 - 96 * v9) / (v9 + 1);
3331 v13 = *(int *)((char *)&stru_505708[0].arr_6C[0][1] + v10) + 327;
3332 amuint_4FAA5C_blt_xy[0] = v12;
3333 amuint_4FAA5C_blt_xy[1] = v13;
3334 amuint_4FAA54_blt_xy[0] = (272 - v12) / 5;
3335 v14 = &pCards[v5->arr_44[v6]];
3336 v5->field_38 -= LOBYTE(v14->field_28);
3337 v15 = BYTE1(v14->field_28);
3338 v5->field_40 -= BYTE2(v14->field_28);
3339 v5->field_3C -= v15;
3340 result = 4 * v11 + 5265228;
3341 v16 = stru_505708[0].arr_44[v11];
3342 stru_505708[0].arr_44[v11] = -1;
3343 amuint_4FABC0 = v16;
3344 LOBYTE(result) = 1;
3345 }
3346 else
3347 {
3348 LABEL_12:
3349 LOBYTE(result) = 0;
3350 }
3351 return result;
3352 }
3353
3354 //----- (0040BF15) --------------------------------------------------------
3355 bool __fastcall am_40BF15(int a1, int a2)
3356 {
3357 ArcomageGame_stru0 *v2; // esi@1
3358 bool result; // eax@1
3359 ArcomageCard *v4; // ecx@1
3360
3361 v2 = &stru_505708[a1];
3362 LOBYTE(result) = 1;
3363 v4 = &pCards[v2->arr_44[a2]];
3364 if ( SBYTE1(v4->field_24) > v2->field_2C )
3365 LOBYTE(result) = 0;
3366 if ( SBYTE2(v4->field_24) > v2->field_30 )
3367 LOBYTE(result) = 0;
3368 if ( SBYTE3(v4->field_24) > v2->field_34 )
3369 LOBYTE(result) = 0;
3370 if ( SLOBYTE(v4->field_28) > v2->field_38 )
3371 LOBYTE(result) = 0;
3372 if ( SBYTE1(v4->field_28) > v2->field_3C )
3373 LOBYTE(result) = 0;
3374 if ( SBYTE2(v4->field_28) > v2->field_40 )
3375 LOBYTE(result) = 0;
3376 return result;
3377 }
3378
3379
3380
3381
3382 //----- (0040BF77) --------------------------------------------------------
3383 void __fastcall am_40BF77(int a1, unsigned int uCardID)
3384 {
3385 ArcomageGame_stru0 *v2; // esi@1
3386 int v3; // eax@1
3387 ArcomageGame_stru0 *v4; // edi@1
3388 int v5; // eax@2
3389 char v6; // sf@2
3390 unsigned __int8 v7; // of@2
3391 int v8; // eax@3
3392 int v9; // eax@4
3393 char v10; // zf@5
3394 int v11; // eax@8
3395 unsigned __int8 v12; // zf@8
3396 char v13; // sf@8
3397 unsigned __int8 v14; // of@8
3398 int v15; // eax@9
3399 int v16; // eax@10
3400 char v17; // zf@12
3401 char v18; // al@15
3402 int v19; // eax@16
3403 int v20; // eax@17
3404 int v21; // eax@22
3405 int v22; // eax@23
3406 int v23; // eax@26
3407 int v24; // edx@26
3408 signed int v25; // ebx@26
3409 ArcomageCard *v26; // ebx@28
3410 int v27; // eax@28
3411 int v28; // edx@33
3412 int v29; // eax@33
3413 int v30; // eax@35
3414 int v31; // edx@40
3415 int v32; // eax@40
3416 int v33; // eax@42
3417 int v34; // edx@47
3418 int v35; // eax@47
3419 int v36; // eax@49
3420 int v37; // edx@54
3421 int v38; // eax@54
3422 bool v39; // eax@56
3423 int v40; // edx@61
3424 int v41; // eax@61
3425 int v42; // eax@63
3426 int v43; // edx@68
3427 int v44; // eax@68
3428 char v45; // al@70
3429 int v46; // eax@72
3430 int v47; // edx@77
3431 int v48; // eax@77
3432 int v49; // eax@79
3433 int v50; // edx@84
3434 int v51; // eax@84
3435 int v52; // eax@86
3436 int v53; // eax@91
3437 int v54; // edx@91
3438 int v55; // eax@93
3439 int v56; // eax@98
3440 int v57; // edx@98
3441 int v58; // eax@100
3442 int v59; // eax@105
3443 int v60; // edx@105
3444 int v61; // eax@107
3445 int v62; // eax@112
3446 int v63; // edx@112
3447 int v64; // eax@114
3448 int v65; // eax@119
3449 int v66; // edx@119
3450 int v67; // eax@121
3451 int v68; // eax@126
3452 int v69; // edx@126
3453 char v70; // al@128
3454 int v71; // eax@130
3455 int v72; // eax@135
3456 int v73; // edx@135
3457 int v74; // eax@137
3458 int v75; // eax@142
3459 int v76; // edx@142
3460 int v77; // eax@144
3461 int v78; // eax@151
3462 int v79; // ecx@151
3463 int v80; // eax@155
3464 int v81; // eax@162
3465 int v82; // ecx@162
3466 int v83; // eax@166
3467 int v84; // eax@173
3468 int v85; // ecx@173
3469 int v86; // eax@177
3470 int v87; // eax@184
3471 int v88; // ecx@184
3472 bool v89; // eax@188
3473 int v90; // eax@195
3474 int v91; // ecx@195
3475 int v92; // eax@199
3476 int v93; // eax@206
3477 int v94; // ecx@206
3478 char v95; // al@210
3479 int v96; // eax@211
3480 int v97; // edx@211
3481 int v98; // eax@211
3482 int v99; // eax@211
3483 int v100; // eax@212
3484 int v101; // eax@219
3485 int v102; // ecx@219
3486 int v103; // eax@223
3487 int v104; // eax@231
3488 int v105; // edx@231
3489 signed int v106; // ebx@231
3490 ArcomageCard *v107; // ebx@233
3491 int v108; // eax@233
3492 int v109; // edx@238
3493 int v110; // eax@238
3494 int v111; // eax@240
3495 int v112; // edx@245
3496 int v113; // eax@245
3497 int v114; // eax@247
3498 int v115; // edx@252
3499 int v116; // eax@252
3500 int v117; // eax@254
3501 int v118; // edx@259
3502 int v119; // eax@259
3503 bool v120; // eax@261
3504 int v121; // edx@266
3505 int v122; // eax@266
3506 int v123; // eax@268
3507 int v124; // edx@273
3508 int v125; // eax@273
3509 char v126; // al@275
3510 int v127; // eax@277
3511 int v128; // edx@282
3512 int v129; // eax@282
3513 int v130; // eax@284
3514 int v131; // edx@289
3515 int v132; // eax@289
3516 int v133; // eax@291
3517 int v134; // eax@296
3518 int v135; // edx@296
3519 int v136; // eax@298
3520 int v137; // eax@303
3521 int v138; // edx@303
3522 int v139; // eax@305
3523 int v140; // eax@310
3524 int v141; // edx@310
3525 int v142; // eax@312
3526 int v143; // eax@317
3527 int v144; // edx@317
3528 int v145; // eax@319
3529 int v146; // eax@324
3530 int v147; // edx@324
3531 int v148; // eax@326
3532 int v149; // eax@331
3533 int v150; // edx@331
3534 char v151; // al@333
3535 int v152; // eax@335
3536 int v153; // eax@340
3537 int v154; // edx@340
3538 int v155; // eax@342
3539 int v156; // eax@347
3540 int v157; // edx@347
3541 int v158; // eax@349
3542 int v159; // eax@356
3543 int v160; // ecx@356
3544 int v161; // eax@360
3545 int v162; // eax@367
3546 int v163; // ecx@367
3547 int v164; // eax@371
3548 int v165; // eax@378
3549 int v166; // ecx@378
3550 int v167; // eax@382
3551 int v168; // eax@389
3552 int v169; // ecx@389
3553 bool v170; // eax@393
3554 int v171; // eax@400
3555 int v172; // ecx@400
3556 int v173; // eax@404
3557 int v174; // eax@411
3558 int v175; // ecx@411
3559 char v176; // al@415
3560 int v177; // eax@416
3561 int v178; // edx@416
3562 int v179; // eax@416
3563 int v180; // eax@416
3564 int v181; // eax@417
3565 int v182; // eax@424
3566 int v183; // ecx@424
3567 int v184; // eax@429
3568 int v185; // ecx@429
3569 signed int v186; // esi@511
3570 Vec2_int_ v187; // [sp+Ch] [bp-64h]@488
3571 //int v188; // [sp+10h] [bp-60h]@488
3572 int v189; // [sp+14h] [bp-5Ch]@1
3573 ArcomageCard *pCard; // [sp+18h] [bp-58h]@1
3574 int v191; // [sp+1Ch] [bp-54h]@1
3575 int v192; // [sp+20h] [bp-50h]@1
3576 int v193; // [sp+24h] [bp-4Ch]@1
3577 int v194; // [sp+28h] [bp-48h]@1
3578 int v195; // [sp+2Ch] [bp-44h]@1
3579 int v196; // [sp+30h] [bp-40h]@1
3580 int v197; // [sp+34h] [bp-3Ch]@1
3581 int v198; // [sp+38h] [bp-38h]@1
3582 int v199; // [sp+3Ch] [bp-34h]@1
3583 int v200; // [sp+40h] [bp-30h]@1
3584 int v201; // [sp+44h] [bp-2Ch]@1
3585 int v202; // [sp+48h] [bp-28h]@1
3586 int v203; // [sp+4Ch] [bp-24h]@1
3587 int v204; // [sp+50h] [bp-20h]@1
3588 bool v205; // [sp+54h] [bp-1Ch]@1
3589 int v206; // [sp+58h] [bp-18h]@1
3590 int v207; // [sp+5Ch] [bp-14h]@1
3591 int v208; // [sp+60h] [bp-10h]@1
3592 int v209; // [sp+64h] [bp-Ch]@1
3593 int v210; // [sp+68h] [bp-8h]@1
3594 int v211; // [sp+6Ch] [bp-4h]@1
3595
3596 v194 = 0;
3597 v210 = 0;
3598 v208 = 0;
3599 v197 = 0;
3600 v205 = 0;
3601 v203 = 0;
3602 v201 = 0;
3603 v199 = 0;
3604 v192 = 0;
3605 v196 = 0;
3606 v211 = 0;
3607 v209 = 0;
3608 v207 = 0;
3609 v206 = 0;
3610 v204 = 0;
3611 v202 = 0;
3612 v200 = 0;
3613 v198 = 0;
3614 v191 = 0;
3615 v195 = 0;
3616 v193 = a1;
3617 v2 = &stru_505708[a1];
3618 pCard = &pCards[uCardID];
3619 v3 = pCard->field_2C;
3620 v189 = (a1 + 1) % 2;
3621 v4 = &stru_505708[v189];
3622 switch ( v3 )
3623 {
3624 case 2:
3625 v5 = v2->field_2C;
3626 v7 = __OFSUB__(v5, v4->field_2C);
3627 v6 = v5 - v4->field_2C < 0;
3628 goto LABEL_18;
3629 case 3:
3630 v8 = v2->field_30;
3631 v7 = __OFSUB__(v8, v4->field_30);
3632 v6 = v8 - v4->field_30 < 0;
3633 goto LABEL_18;
3634 case 4:
3635 v9 = v2->field_34;
3636 v7 = __OFSUB__(v9, v4->field_34);
3637 v6 = v9 - v4->field_34 < 0;
3638 goto LABEL_18;
3639 case 5:
3640 v10 = v2->field_2C == v4->field_2C;
3641 goto LABEL_21;
3642 case 6:
3643 v10 = v2->field_30 == v4->field_30;
3644 goto LABEL_21;
3645 case 7:
3646 v10 = v2->field_34 == v4->field_34;
3647 goto LABEL_21;
3648 case 8:
3649 v11 = v2->field_2C;
3650 v14 = __OFSUB__(v11, v4->field_2C);
3651 v12 = v11 == v4->field_2C;
3652 v13 = v11 - v4->field_2C < 0;
3653 goto LABEL_24;
3654 case 9:
3655 v15 = v2->field_30;
3656 v14 = __OFSUB__(v15, v4->field_30);
3657 v12 = v15 == v4->field_30;
3658 v13 = v15 - v4->field_30 < 0;
3659 goto LABEL_24;
3660 case 10:
3661 v16 = v2->field_34;
3662 v14 = __OFSUB__(v16, v4->field_34);
3663 v12 = v16 == v4->field_34;
3664 v13 = v16 - v4->field_34 < 0;
3665 goto LABEL_24;
3666 case 11:
3667 v10 = v2->field_28 == 0;
3668 goto LABEL_21;
3669 case 12:
3670 v17 = v2->field_28 == 0;
3671 goto LABEL_15;
3672 case 13:
3673 v10 = v4->field_28 == 0;
3674 goto LABEL_21;
3675 case 14:
3676 v17 = v4->field_28 == 0;
3677 LABEL_15:
3678 v18 = !v17;
3679 goto LABEL_25;
3680 case 15:
3681 v19 = v2->field_28;
3682 v7 = __OFSUB__(v19, v4->field_28);
3683 v6 = v19 - v4->field_28 < 0;
3684 goto LABEL_18;
3685 case 16:
3686 v20 = v2->field_24;
3687 v7 = __OFSUB__(v20, v4->field_24);
3688 v6 = v20 - v4->field_24 < 0;
3689 LABEL_18:
3690 v18 = v6 ^ v7;
3691 goto LABEL_25;
3692 case 17:
3693 v10 = v2->field_28 == v4->field_28;
3694 goto LABEL_21;
3695 case 18:
3696 v10 = v2->field_24 == v4->field_24;
3697 LABEL_21:
3698 v18 = v10;
3699 goto LABEL_25;
3700 case 19:
3701 v21 = v2->field_28;
3702 v14 = __OFSUB__(v21, v4->field_28);
3703 v12 = v21 == v4->field_28;
3704 v13 = v21 - v4->field_28 < 0;
3705 goto LABEL_24;
3706 case 20:
3707 v22 = v2->field_24;
3708 v14 = __OFSUB__(v22, v4->field_24);
3709 v12 = v22 == v4->field_24;
3710 v13 = v22 - v4->field_24 < 0;
3711 LABEL_24:
3712 v18 = !((unsigned __int8)(v13 ^ v14) | v12);
3713 LABEL_25:
3714 if ( v18 )
3715 goto LABEL_26;
3716 goto LABEL_231;
3717 default:
3718 LABEL_26:
3719 v23 = BYTE1(pCard->field_30);
3720 v24 = v23 + (LOBYTE(pCard->field_30) == 1);
3721 v25 = 0;
3722 dword_4FAA68 = v23 + (LOBYTE(pCard->field_30) == 1);
3723 dword_4FAA64 = v23;
3724 if ( v23 > 0 )
3725 {
3726 do
3727 {
3728 am_40A283(v193, v24);
3729 ++v25;
3730 }
3731 while ( v25 < SBYTE1(pCard->field_30) );
3732 }
3733 v26 = pCard;
3734 am_byte_4FAA77 = am_40BB49(v193) > dword_4E1874;
3735 LOBYTE(v27) = BYTE2(pCard->field_30);
3736 if ( (_BYTE)v27 )
3737 {
3738 if ( (_BYTE)v27 == 99 )
3739 {
3740 v28 = v2->field_2C;
3741 v29 = v4->field_2C;
3742 if ( v28 < v29 )
3743 {
3744 v2->field_2C = v29;
3745 v194 = v29 - v28;
3746 }
3747 }
3748 else
3749 {
3750 v27 = (char)v27;
3751 v6 = (char)v27 + v2->field_2C < 0;
3752 v2->field_2C += (char)v27;
3753 if ( v6 )
3754 v2->field_2C = 0;
3755 v194 = v27;
3756 }
3757 }
3758 LOBYTE(v30) = BYTE3(v26->field_30);
3759 if ( (_BYTE)v30 )
3760 {
3761 if ( (_BYTE)v30 == 99 )
3762 {
3763 v31 = v2->field_30;
3764 v32 = v4->field_30;
3765 if ( v31 < v32 )
3766 {
3767 v2->field_30 = v32;
3768 v210 = v32 - v31;
3769 }
3770 }
3771 else
3772 {
3773 v30 = (char)v30;
3774 v6 = (char)v30 + v2->field_30 < 0;
3775 v2->field_30 += (char)v30;
3776 if ( v6 )
3777 v2->field_30 = 0;
3778 v210 = v30;
3779 }
3780 }
3781 LOBYTE(v33) = LOBYTE(v26->field_34);
3782 if ( (_BYTE)v33 )
3783 {
3784 if ( (_BYTE)v33 == 99 )
3785 {
3786 v34 = v2->field_34;
3787 v35 = v4->field_34;
3788 if ( v34 < v35 )
3789 {
3790 v2->field_34 = v35;
3791 v208 = v35 - v34;
3792 }
3793 }
3794 else
3795 {
3796 v33 = (char)v33;
3797 v6 = (char)v33 + v2->field_34 < 0;
3798 v2->field_34 += (char)v33;
3799 if ( v6 )
3800 v2->field_34 = 0;
3801 v208 = v33;
3802 }
3803 }
3804 LOBYTE(v36) = BYTE1(v26->field_34);
3805 if ( (_BYTE)v36 )
3806 {
3807 if ( (_BYTE)v36 == 99 )
3808 {
3809 v37 = v2->field_38;
3810 v38 = v4->field_38;
3811 if ( v37 < v38 )
3812 {
3813 v2->field_38 = v38;
3814 v197 = v38 - v37;
3815 }
3816 }
3817 else
3818 {
3819 v36 = (char)v36;
3820 v6 = (char)v36 + v2->field_38 < 0;
3821 v2->field_38 += (char)v36;
3822 if ( v6 )
3823 v2->field_38 = 0;
3824 v197 = v36;
3825 }
3826 }
3827 LOBYTE(v39) = BYTE2(v26->field_34);
3828 if ( v39 )
3829 {
3830 if ( v39 == 99 )
3831 {
3832 v40 = v2->field_3C;
3833 v41 = v4->field_3C;
3834 if ( v40 < v41 )
3835 {
3836 v2->field_3C = v41;
3837 v205 = v41 - v40;
3838 }
3839 }
3840 else
3841 {
3842 v39 = v39;
3843 v6 = v39 + v2->field_3C < 0;
3844 v2->field_3C += v39;
3845 if ( v6 )
3846 v2->field_3C = 0;
3847 v205 = v39;
3848 }
3849 }
3850 LOBYTE(v42) = BYTE3(v26->field_34);
3851 if ( (_BYTE)v42 )
3852 {
3853 if ( (_BYTE)v42 == 99 )
3854 {
3855 v43 = v2->field_40;
3856 v44 = v4->field_40;
3857 if ( v43 < v44 )
3858 {
3859 v2->field_40 = v44;
3860 v203 = v44 - v43;
3861 }
3862 }
3863 else
3864 {
3865 v42 = (char)v42;
3866 v6 = (char)v42 + v2->field_40 < 0;
3867 v2->field_40 += (char)v42;
3868 if ( v6 )
3869 v2->field_40 = 0;
3870 v203 = v42;
3871 }
3872 }
3873 v45 = v26->field_38[0];
3874 if ( v45 )
3875 {
3876 v196 = am_40D402(v193, v45);
3877 v192 = v26->field_38[0] - v196;
3878 }
3879 LOBYTE(v46) = v26->field_38[1];
3880 if ( (_BYTE)v46 )
3881 {
3882 if ( (_BYTE)v46 == 99 )
3883 {
3884 v47 = v2->field_28;
3885 v48 = v4->field_28;
3886 if ( v47 < v48 )
3887 {
3888 v2->field_28 = v48;
3889 v201 = v48 - v47;
3890 }
3891 }
3892 else
3893 {
3894 v46 = (char)v46;
3895 v6 = (char)v46 + v2->field_28 < 0;
3896 v2->field_28 += (char)v46;
3897 if ( v6 )
3898 v2->field_28 = 0;
3899 v201 = v46;
3900 }
3901 }
3902 LOBYTE(v49) = v26->field_38[2];
3903 if ( (_BYTE)v49 )
3904 {
3905 if ( (_BYTE)v49 == 99 )
3906 {
3907 v50 = v2->field_24;
3908 v51 = v4->field_24;
3909 if ( v50 < v51 )
3910 {
3911 v2->field_24 = v51;
3912 v199 = v51 - v50;
3913 }
3914 }
3915 else
3916 {
3917 v49 = (char)v49;
3918 v6 = (char)v49 + v2->field_24 < 0;
3919 v2->field_24 += (char)v49;
3920 if ( v6 )
3921 v2->field_24 = 0;
3922 v199 = v49;
3923 }
3924 }
3925 LOBYTE(v52) = v26->field_38[3];
3926 if ( (_BYTE)v52 )
3927 {
3928 if ( (_BYTE)v52 == 99 )
3929 {
3930 v53 = v2->field_2C;
3931 v54 = v4->field_2C;
3932 if ( v53 > v54 )
3933 {
3934 v4->field_2C = v53;
3935 v211 = v53 - v54;
3936 }
3937 }
3938 else
3939 {
3940 v52 = (char)v52;
3941 v6 = (char)v52 + v4->field_2C < 0;
3942 v4->field_2C += (char)v52;
3943 if ( v6 )
3944 v4->field_2C = 0;
3945 v211 = v52;
3946 }
3947 }
3948 LOBYTE(v55) = v26->field_38[4];
3949 if ( (_BYTE)v55 )
3950 {
3951 if ( (_BYTE)v55 == 99 )
3952 {
3953 v56 = v2->field_30;
3954 v57 = v4->field_30;
3955 if ( v56 > v57 )
3956 {
3957 v4->field_30 = v56;
3958 v209 = v56 - v57;
3959 }
3960 }
3961 else
3962 {
3963 v55 = (char)v55;
3964 v6 = (char)v55 + v4->field_30 < 0;
3965 v4->field_30 += (char)v55;
3966 if ( v6 )
3967 v4->field_30 = 0;
3968 v209 = v55;
3969 }
3970 }
3971 LOBYTE(v58) = v26->field_38[5];
3972 if ( (_BYTE)v58 )
3973 {
3974 if ( (_BYTE)v58 == 99 )
3975 {
3976 v59 = v2->field_34;
3977 v60 = v4->field_34;
3978 if ( v59 > v60 )
3979 {
3980 v4->field_34 = v59;
3981 v207 = v59 - v60;
3982 }
3983 }
3984 else
3985 {
3986 v58 = (char)v58;
3987 v6 = (char)v58 + v4->field_34 < 0;
3988 v4->field_34 += (char)v58;
3989 if ( v6 )
3990 v4->field_34 = 0;
3991 v207 = v58;
3992 }
3993 }
3994 LOBYTE(v61) = v26->field_38[6];
3995 if ( (_BYTE)v61 )
3996 {
3997 if ( (_BYTE)v61 == 99 )
3998 {
3999 v62 = v2->field_38;
4000 v63 = v4->field_38;
4001 if ( v62 > v63 )
4002 {
4003 v4->field_38 = v62;
4004 v206 = v62 - v63;
4005 }
4006 }
4007 else
4008 {
4009 v61 = (char)v61;
4010 v6 = (char)v61 + v4->field_38 < 0;
4011 v4->field_38 += (char)v61;
4012 if ( v6 )
4013 v4->field_38 = 0;
4014 v206 = v61;
4015 }
4016 }
4017 LOBYTE(v64) = v26->field_38[7];
4018 if ( (_BYTE)v64 )
4019 {
4020 if ( (_BYTE)v64 == 99 )
4021 {
4022 v65 = v2->field_3C;
4023 v66 = v4->field_3C;
4024 if ( v65 > v66 )
4025 {
4026 v4->field_3C = v65;
4027 v204 = v65 - v66;
4028 }
4029 }
4030 else
4031 {
4032 v64 = (char)v64;
4033 v6 = (char)v64 + v4->field_3C < 0;
4034 v4->field_3C += (char)v64;
4035 if ( v6 )
4036 v4->field_3C = 0;
4037 v204 = v64;
4038 }
4039 }
4040 LOBYTE(v67) = v26->field_38[8];
4041 if ( (_BYTE)v67 )
4042 {
4043 if ( (_BYTE)v67 == 99 )
4044 {
4045 v68 = v2->field_40;
4046 v69 = v4->field_40;
4047 if ( v68 > v69 )
4048 {
4049 v4->field_40 = v68;
4050 v202 = v68 - v69;
4051 }
4052 }
4053 else
4054 {
4055 v67 = (char)v67;
4056 v6 = (char)v67 + v4->field_40 < 0;
4057 v4->field_40 += (char)v67;
4058 if ( v6 )
4059 v4->field_40 = 0;
4060 v202 = v67;
4061 }
4062 }
4063 v70 = v26->field_38[9];
4064 if ( v70 )
4065 {
4066 v195 = am_40D402(v189, v70);
4067 v191 = v26->field_38[9] - v195;
4068 }
4069 LOBYTE(v71) = v26->field_38[10];
4070 if ( (_BYTE)v71 )
4071 {
4072 if ( (_BYTE)v71 == 99 )
4073 {
4074 v72 = v2->field_28;
4075 v73 = v4->field_28;
4076 if ( v72 > v73 )
4077 {
4078 v4->field_28 = v72;
4079 v200 = v72 - v73;
4080 }
4081 }
4082 else
4083 {
4084 v71 = (char)v71;
4085 v6 = (char)v71 + v4->field_28 < 0;
4086 v4->field_28 += (char)v71;
4087 if ( v6 )
4088 v4->field_28 = 0;
4089 v200 = v71;
4090 }
4091 }
4092 LOBYTE(v74) = v26->field_38[11];
4093 if ( (_BYTE)v74 )
4094 {
4095 if ( (_BYTE)v74 == 99 )
4096 {
4097 v75 = v2->field_24;
4098 v76 = v4->field_24;
4099 if ( v75 > v76 )
4100 {
4101 v4->field_24 = v75;
4102 v198 = v75 - v76;
4103 }
4104 }
4105 else
4106 {
4107 v74 = (char)v74;
4108 v6 = (char)v74 + v4->field_24 < 0;
4109 v4->field_24 += (char)v74;
4110 if ( v6 )
4111 v4->field_24 = 0;
4112 v198 = v74;
4113 }
4114 }
4115 LOBYTE(v77) = v26->field_38[12];
4116 if ( (_BYTE)v77 )
4117 {
4118 if ( (_BYTE)v77 == 99 )
4119 {
4120 v78 = v2->field_2C;
4121 v79 = v4->field_2C;
4122 if ( v78 != v79 )
4123 {
4124 if ( v78 <= v79 )
4125 {
4126 v2->field_2C = v79;
4127 v194 = v79 - v78;
4128 }
4129 else
4130 {
4131 v4->field_2C = v78;
4132 v211 = v78 - v79;
4133 }
4134 }
4135 }
4136 else
4137 {
4138 v77 = (char)v77;
4139 v2->field_2C += (char)v77;
4140 v4->field_2C += (char)v77;
4141 if ( v2->field_2C < 0 )
4142 v2->field_2C = 0;
4143 if ( v4->field_2C < 0 )
4144 v4->field_2C = 0;
4145 v194 = v77;
4146 v211 = v77;
4147 }
4148 }
4149 LOBYTE(v80) = v26->field_38[13];
4150 if ( (_BYTE)v80 )
4151 {
4152 if ( (_BYTE)v80 == 99 )
4153 {
4154 v81 = v2->field_30;
4155 v82 = v4->field_30;
4156 if ( v81 != v82 )
4157 {
4158 if ( v81 <= v82 )
4159 {
4160 v2->field_30 = v82;
4161 v210 = v82 - v81;
4162 }
4163 else
4164 {
4165 v4->field_30 = v81;
4166 v209 = v81 - v82;
4167 }
4168 }
4169 }
4170 else
4171 {
4172 v80 = (char)v80;
4173 v2->field_30 += (char)v80;
4174 v4->field_30 += (char)v80;
4175 if ( v2->field_30 < 0 )
4176 v2->field_30 = 0;
4177 if ( v4->field_30 < 0 )
4178 v4->field_30 = 0;
4179 v209 = v80;
4180 v210 = v80;
4181 }
4182 }
4183 LOBYTE(v83) = v26->field_38[14];
4184 if ( (_BYTE)v83 )
4185 {
4186 if ( (_BYTE)v83 == 99 )
4187 {
4188 v84 = v2->field_34;
4189 v85 = v4->field_34;
4190 if ( v84 != v85 )
4191 {
4192 if ( v84 <= v85 )
4193 {
4194 v2->field_34 = v85;
4195 v208 = v85 - v84;
4196 }
4197 else
4198 {
4199 v4->field_34 = v84;
4200 v207 = v84 - v85;
4201 }
4202 }
4203 }
4204 else
4205 {
4206 v83 = (char)v83;
4207 v2->field_34 += (char)v83;
4208 v4->field_34 += (char)v83;
4209 if ( v2->field_34 < 0 )
4210 v2->field_34 = 0;
4211 if ( v4->field_34 < 0 )
4212 v4->field_34 = 0;
4213 v208 = v83;
4214 v207 = v83;
4215 }
4216 }
4217 LOBYTE(v86) = v26->field_38[15];
4218 if ( (_BYTE)v86 )
4219 {
4220 if ( (_BYTE)v86 == 99 )
4221 {
4222 v87 = v2->field_38;
4223 v88 = v4->field_38;
4224 if ( v87 != v88 )
4225 {
4226 if ( v87 <= v88 )
4227 {
4228 v2->field_38 = v88;
4229 v197 = v88 - v87;
4230 }
4231 else
4232 {
4233 v4->field_38 = v87;
4234 v206 = v87 - v88;
4235 }
4236 }
4237 }
4238 else
4239 {
4240 v86 = (char)v86;
4241 v2->field_38 += (char)v86;
4242 v4->field_38 += (char)v86;
4243 if ( v2->field_38 < 0 )
4244 v2->field_38 = 0;
4245 if ( v4->field_38 < 0 )
4246 v4->field_38 = 0;
4247 v197 = v86;
4248 v206 = v86;
4249 }
4250 }
4251 LOBYTE(v89) = v26->field_48[0];
4252 if ( v89 )
4253 {
4254 if ( v89 == 99 )
4255 {
4256 v90 = v2->field_3C;
4257 v91 = v4->field_3C;
4258 if ( v90 != v91 )
4259 {
4260 if ( v90 <= v91 )
4261 {
4262 v205 = v91 > v90;
4263 v2->field_3C = v91;
4264 }
4265 else
4266 {
4267 v204 = 1;
4268 v4->field_3C = v90;
4269 }
4270 }
4271 }
4272 else
4273 {
4274 v89 = v89;
4275 v2->field_3C += v89;
4276 v4->field_3C += v89;
4277 if ( v2->field_3C < 0 )
4278 v2->field_3C = 0;
4279 if ( v4->field_3C < 0 )
4280 v4->field_3C = 0;
4281 v205 = v89;
4282 v204 = v89;
4283 }
4284 }
4285 LOBYTE(v92) = v26->field_48[1];
4286 if ( (_BYTE)v92 )
4287 {
4288 if ( (_BYTE)v92 == 99 )
4289 {
4290 v93 = v2->field_40;
4291 v94 = v4->field_40;
4292 if ( v93 != v94 )
4293 {
4294 if ( v93 <= v94 )
4295 {
4296 v2->field_40 = v94;
4297 v203 = v94 - v93;
4298 }
4299 else
4300 {
4301 v4->field_40 = v93;
4302 v202 = v93 - v94;
4303 }
4304 }
4305 }
4306 else
4307 {
4308 v92 = (char)v92;
4309 v2->field_40 += (char)v92;
4310 v4->field_40 += (char)v92;
4311 if ( v2->field_40 < 0 )
4312 v2->field_40 = 0;
4313 if ( v4->field_40 < 0 )
4314 v4->field_40 = 0;
4315 v203 = v92;
4316 v202 = v92;
4317 }
4318 }
4319 v95 = v26->field_48[2];
4320 if ( v95 )
4321 {
4322 v96 = am_40D402(v193, v95);
4323 v97 = v26->field_48[2];
4324 v196 = v96;
4325 v98 = am_40D402(v189, v97);
4326 v195 = v98;
4327 v99 = v26->field_48[2] - v98;
4328 v192 = v26->field_48[2] - v196;
4329 v191 = v99;
4330 }
4331 LOBYTE(v100) = v26->field_48[3];
4332 if ( (_BYTE)v100 )
4333 {
4334 if ( (_BYTE)v100 == 99 )
4335 {
4336 v101 = v2->field_28;
4337 v102 = v4->field_28;
4338 if ( v101 != v102 )
4339 {
4340 if ( v101 <= v102 )
4341 {
4342 v2->field_28 = v102;
4343 v201 = v102 - v101;
4344 }
4345 else
4346 {
4347 v4->field_28 = v101;
4348 v200 = v101 - v102;
4349 }
4350 }
4351 }
4352 else
4353 {
4354 v100 = (char)v100;
4355 v2->field_28 += (char)v100;
4356 v4->field_28 += (char)v100;
4357 if ( v2->field_28 < 0 )
4358 v2->field_28 = 0;
4359 if ( v4->field_28 < 0 )
4360 v4->field_28 = 0;
4361 v201 = v100;
4362 v200 = v100;
4363 }
4364 }
4365 LOBYTE(v103) = v26->field_48[4];
4366 break;
4367 case 0:
4368 LABEL_231:
4369 v104 = pCard->field_48[6];
4370 v105 = v104 + (pCard->field_48[5] == 1);
4371 v106 = 0;
4372 dword_4FAA68 = v104 + (pCard->field_48[5] == 1);
4373 dword_4FAA64 = v104;
4374 if ( v104 > 0 )
4375 {
4376 do
4377 {
4378 am_40A283(v193, v105);
4379 ++v106;
4380 }
4381 while ( v106 < pCard->field_48[6] );
4382 }
4383 v107 = pCard;
4384 am_byte_4FAA77 = am_40BB49(v193) > dword_4E1874;
4385 LOBYTE(v108) = pCard->field_48[7];
4386 if ( (_BYTE)v108 )
4387 {
4388 if ( (_BYTE)v108 == 99 )
4389 {
4390 v109 = v2->field_2C;
4391 v110 = v4->field_2C;
4392 if ( v109 < v110 )
4393 {
4394 v2->field_2C = v110;
4395 v194 = v110 - v109;
4396 }
4397 }
4398 else
4399 {
4400 v108 = (char)v108;
4401 v6 = (char)v108 + v2->field_2C < 0;
4402 v2->field_2C += (char)v108;
4403 if ( v6 )
4404 v2->field_2C = 0;
4405 v194 = v108;
4406 }
4407 }
4408 LOBYTE(v111) = v107->field_48[8];
4409 if ( (_BYTE)v111 )
4410 {
4411 if ( (_BYTE)v111 == 99 )
4412 {
4413 v112 = v2->field_30;
4414 v113 = v4->field_30;
4415 if ( v112 < v113 )
4416 {
4417 v2->field_30 = v113;
4418 v210 = v113 - v112;
4419 }
4420 }
4421 else
4422 {
4423 v111 = (char)v111;
4424 v6 = (char)v111 + v2->field_30 < 0;
4425 v2->field_30 += (char)v111;
4426 if ( v6 )
4427 v2->field_30 = 0;
4428 v210 = v111;
4429 }
4430 }
4431 LOBYTE(v114) = v107->field_48[9];
4432 if ( (_BYTE)v114 )
4433 {
4434 if ( (_BYTE)v114 == 99 )
4435 {
4436 v115 = v2->field_34;
4437 v116 = v4->field_34;
4438 if ( v115 < v116 )
4439 {
4440 v2->field_34 = v116;
4441 v208 = v116 - v115;
4442 }
4443 }
4444 else
4445 {
4446 v114 = (char)v114;
4447 v6 = (char)v114 + v2->field_34 < 0;
4448 v2->field_34 += (char)v114;
4449 if ( v6 )
4450 v2->field_34 = 0;
4451 v208 = v114;
4452 }
4453 }
4454 LOBYTE(v117) = v107->field_48[10];
4455 if ( (_BYTE)v117 )
4456 {
4457 if ( (_BYTE)v117 == 99 )
4458 {
4459 v118 = v2->field_38;
4460 v119 = v4->field_38;
4461 if ( v118 < v119 )
4462 {
4463 v2->field_38 = v119;
4464 v197 = v119 - v118;
4465 }
4466 }
4467 else
4468 {
4469 v117 = (char)v117;
4470 v6 = (char)v117 + v2->field_38 < 0;
4471 v2->field_38 += (char)v117;
4472 if ( v6 )
4473 v2->field_38 = 0;
4474 v197 = v117;
4475 }
4476 }
4477 LOBYTE(v120) = v107->field_48[11];
4478 if ( v120 )
4479 {
4480 if ( v120 == 99 )
4481 {
4482 v121 = v2->field_3C;
4483 v122 = v4->field_3C;
4484 if ( v121 < v122 )
4485 {
4486 v2->field_3C = v122;
4487 v205 = v122 - v121;
4488 }
4489 }
4490 else
4491 {
4492 v120 = v120;
4493 v6 = v120 + v2->field_3C < 0;
4494 v2->field_3C += v120;
4495 if ( v6 )
4496 v2->field_3C = 0;
4497 v205 = v120;
4498 }
4499 }
4500 LOBYTE(v123) = v107->field_48[12];
4501 if ( (_BYTE)v123 )
4502 {
4503 if ( (_BYTE)v123 == 99 )
4504 {
4505 v124 = v2->field_40;
4506 v125 = v4->field_40;
4507 if ( v124 < v125 )
4508 {
4509 v2->field_40 = v125;
4510 v203 = v125 - v124;
4511 }
4512 }
4513 else
4514 {
4515 v123 = (char)v123;
4516 v6 = (char)v123 + v2->field_40 < 0;
4517 v2->field_40 += (char)v123;
4518 if ( v6 )
4519 v2->field_40 = 0;
4520 v203 = v123;
4521 }
4522 }
4523 v126 = v107->field_48[13];
4524 if ( v126 )
4525 {
4526 v196 = am_40D402(v193, v126);
4527 v192 = v107->field_48[13] - v196;
4528 }
4529 LOBYTE(v127) = v107->field_48[14];
4530 if ( (_BYTE)v127 )
4531 {
4532 if ( (_BYTE)v127 == 99 )
4533 {
4534 v128 = v2->field_28;
4535 v129 = v4->field_28;
4536 if ( v128 < v129 )
4537 {
4538 v2->field_28 = v129;
4539 v201 = v129 - v128;
4540 }
4541 }
4542 else
4543 {
4544 v127 = (char)v127;
4545 v6 = (char)v127 + v2->field_28 < 0;
4546 v2->field_28 += (char)v127;
4547 if ( v6 )
4548 v2->field_28 = 0;
4549 v201 = v127;
4550 }
4551 }
4552 LOBYTE(v130) = v107->field_48[15];
4553 if ( (_BYTE)v130 )
4554 {
4555 if ( (_BYTE)v130 == 99 )
4556 {
4557 v131 = v2->field_24;
4558 v132 = v4->field_24;
4559 if ( v131 < v132 )
4560 {
4561 v2->field_24 = v132;
4562 v199 = v132 - v131;
4563 }
4564 }
4565 else
4566 {
4567 v130 = (char)v130;
4568 v6 = (char)v130 + v2->field_24 < 0;
4569 v2->field_24 += (char)v130;
4570 if ( v6 )
4571 v2->field_24 = 0;
4572 v199 = v130;
4573 }
4574 }
4575 LOBYTE(v133) = v107->field_58[0];
4576 if ( (_BYTE)v133 )
4577 {
4578 if ( (_BYTE)v133 == 99 )
4579 {
4580 v134 = v2->field_2C;
4581 v135 = v4->field_2C;
4582 if ( v134 > v135 )
4583 {
4584 v4->field_2C = v134;
4585 v211 = v134 - v135;
4586 }
4587 }
4588 else
4589 {
4590 v133 = (char)v133;
4591 v6 = (char)v133 + v4->field_2C < 0;
4592 v4->field_2C += (char)v133;
4593 if ( v6 )
4594 v4->field_2C = 0;
4595 v211 = v133;
4596 }
4597 }
4598 LOBYTE(v136) = v107->field_58[1];
4599 if ( (_BYTE)v136 )
4600 {
4601 if ( (_BYTE)v136 == 99 )
4602 {
4603 v137 = v2->field_30;
4604 v138 = v4->field_30;
4605 if ( v137 > v138 )
4606 {
4607 v4->field_30 = v137;
4608 v209 = v137 - v138;
4609 }
4610 }
4611 else
4612 {
4613 v136 = (char)v136;
4614 v6 = (char)v136 + v4->field_30 < 0;
4615 v4->field_30 += (char)v136;
4616 if ( v6 )
4617 v4->field_30 = 0;
4618 v209 = v136;
4619 }
4620 }
4621 LOBYTE(v139) = v107->field_58[2];
4622 if ( (_BYTE)v139 )
4623 {
4624 if ( (_BYTE)v139 == 99 )
4625 {
4626 v140 = v2->field_34;
4627 v141 = v4->field_34;
4628 if ( v140 > v141 )
4629 {
4630 v4->field_34 = v140;
4631 v207 = v140 - v141;
4632 }
4633 }
4634 else
4635 {
4636 v139 = (char)v139;
4637 v6 = (char)v139 + v4->field_34 < 0;
4638 v4->field_34 += (char)v139;
4639 if ( v6 )
4640 v4->field_34 = 0;
4641 v207 = v139;
4642 }
4643 }
4644 LOBYTE(v142) = v107->field_58[3];
4645 if ( (_BYTE)v142 )
4646 {
4647 if ( (_BYTE)v142 == 99 )
4648 {
4649 v143 = v2->field_38;
4650 v144 = v4->field_38;
4651 if ( v143 > v144 )
4652 {
4653 v4->field_38 = v143;
4654 v206 = v143 - v144;
4655 }
4656 }
4657 else
4658 {
4659 v142 = (char)v142;
4660 v6 = (char)v142 + v4->field_38 < 0;
4661 v4->field_38 += (char)v142;
4662 if ( v6 )
4663 v4->field_38 = 0;
4664 v206 = v142;
4665 }
4666 }
4667 LOBYTE(v145) = v107->field_58[4];
4668 if ( (_BYTE)v145 )
4669 {
4670 if ( (_BYTE)v145 == 99 )
4671 {
4672 v146 = v2->field_3C;
4673 v147 = v4->field_3C;
4674 if ( v146 > v147 )
4675 {
4676 v4->field_3C = v146;
4677 v204 = v146 - v147;
4678 }
4679 }
4680 else
4681 {
4682 v145 = (char)v145;
4683 v6 = (char)v145 + v4->field_3C < 0;
4684 v4->field_3C += (char)v145;
4685 if ( v6 )
4686 v4->field_3C = 0;
4687 v204 = v145;
4688 }
4689 }
4690 LOBYTE(v148) = v107->field_58[5];
4691 if ( (_BYTE)v148 )
4692 {
4693 if ( (_BYTE)v148 == 99 )
4694 {
4695 v149 = v2->field_40;
4696 v150 = v4->field_40;
4697 if ( v149 > v150 )
4698 {
4699 v4->field_40 = v149;
4700 v202 = v149 - v150;
4701 }
4702 }
4703 else
4704 {
4705 v148 = (char)v148;
4706 v6 = (char)v148 + v4->field_40 < 0;
4707 v4->field_40 += (char)v148;
4708 if ( v6 )
4709 v4->field_40 = 0;
4710 v202 = v148;
4711 }
4712 }
4713 v151 = v107->field_58[6];
4714 if ( v151 )
4715 {
4716 v195 = am_40D402(v189, v151);
4717 v191 = v107->field_58[6] - v195;
4718 }
4719 LOBYTE(v152) = v107->field_58[7];
4720 if ( (_BYTE)v152 )
4721 {
4722 if ( (_BYTE)v152 == 99 )
4723 {
4724 v153 = v2->field_28;
4725 v154 = v4->field_28;
4726 if ( v153 > v154 )
4727 {
4728 v4->field_28 = v153;
4729 v200 = v153 - v154;
4730 }
4731 }
4732 else
4733 {
4734 v152 = (char)v152;
4735 v6 = (char)v152 + v4->field_28 < 0;
4736 v4->field_28 += (char)v152;
4737 if ( v6 )
4738 v4->field_28 = 0;
4739 v200 = v152;
4740 }
4741 }
4742 LOBYTE(v155) = v107->field_58[8];
4743 if ( (_BYTE)v155 )
4744 {
4745 if ( (_BYTE)v155 == 99 )
4746 {
4747 v156 = v2->field_24;
4748 v157 = v4->field_24;
4749 if ( v156 > v157 )
4750 {
4751 v4->field_24 = v156;
4752 v198 = v156 - v157;
4753 }
4754 }
4755 else
4756 {
4757 v155 = (char)v155;
4758 v6 = (char)v155 + v4->field_24 < 0;
4759 v4->field_24 += (char)v155;
4760 if ( v6 )
4761 v4->field_24 = 0;
4762 v198 = v155;
4763 }
4764 }
4765 LOBYTE(v158) = v107->field_58[9];
4766 if ( (_BYTE)v158 )
4767 {
4768 if ( (_BYTE)v158 == 99 )
4769 {
4770 v159 = v2->field_2C;
4771 v160 = v4->field_2C;
4772 if ( v159 != v160 )
4773 {
4774 if ( v159 <= v160 )
4775 {
4776 v2->field_2C = v160;
4777 v194 = v160 - v159;
4778 }
4779 else
4780 {
4781 v4->field_2C = v159;
4782 v211 = v159 - v160;
4783 }
4784 }
4785 }
4786 else
4787 {
4788 v158 = (char)v158;
4789 v2->field_2C += (char)v158;
4790 v4->field_2C += (char)v158;
4791 if ( v2->field_2C < 0 )
4792 v2->field_2C = 0;
4793 if ( v4->field_2C < 0 )
4794 v4->field_2C = 0;
4795 v194 = v158;
4796 v211 = v158;
4797 }
4798 }
4799 LOBYTE(v161) = v107->field_58[10];
4800 if ( (_BYTE)v161 )
4801 {
4802 if ( (_BYTE)v161 == 99 )
4803 {
4804 v162 = v2->field_30;
4805 v163 = v4->field_30;
4806 if ( v162 != v163 )
4807 {
4808 if ( v162 <= v163 )
4809 {
4810 v2->field_30 = v163;
4811 v210 = v163 - v162;
4812 }
4813 else
4814 {
4815 v4->field_30 = v162;
4816 v209 = v162 - v163;
4817 }
4818 }
4819 }
4820 else
4821 {
4822 v161 = (char)v161;
4823 v2->field_30 += (char)v161;
4824 v4->field_30 += (char)v161;
4825 if ( v2->field_30 < 0 )
4826 v2->field_30 = 0;
4827 if ( v4->field_30 < 0 )
4828 v4->field_30 = 0;
4829 v209 = v161;
4830 v210 = v161;
4831 }
4832 }
4833 LOBYTE(v164) = v107->field_58[11];
4834 if ( (_BYTE)v164 )
4835 {
4836 if ( (_BYTE)v164 == 99 )
4837 {
4838 v165 = v2->field_34;
4839 v166 = v4->field_34;
4840 if ( v165 != v166 )
4841 {
4842 if ( v165 <= v166 )
4843 {
4844 v2->field_34 = v166;
4845 v208 = v166 - v165;
4846 }
4847 else
4848 {
4849 v4->field_34 = v165;
4850 v207 = v165 - v166;
4851 }
4852 }
4853 }
4854 else
4855 {
4856 v164 = (char)v164;
4857 v2->field_34 += (char)v164;
4858 v4->field_34 += (char)v164;
4859 if ( v2->field_34 < 0 )
4860 v2->field_34 = 0;
4861 if ( v4->field_34 < 0 )
4862 v4->field_34 = 0;
4863 v208 = v164;
4864 v207 = v164;
4865 }
4866 }
4867 LOBYTE(v167) = v107->field_58[12];
4868 if ( (_BYTE)v167 )
4869 {
4870 if ( (_BYTE)v167 == 99 )
4871 {
4872 v168 = v2->field_38;
4873 v169 = v4->field_38;
4874 if ( v168 != v169 )
4875 {
4876 if ( v168 <= v169 )
4877 {
4878 v2->field_38 = v169;
4879 v197 = v169 - v168;
4880 }
4881 else
4882 {
4883 v4->field_38 = v168;
4884 v206 = v168 - v169;
4885 }
4886 }
4887 }
4888 else
4889 {
4890 v167 = (char)v167;
4891 v2->field_38 += (char)v167;
4892 v4->field_38 += (char)v167;
4893 if ( v2->field_38 < 0 )
4894 v2->field_38 = 0;
4895 if ( v4->field_38 < 0 )
4896 v4->field_38 = 0;
4897 v197 = v167;
4898 v206 = v167;
4899 }
4900 }
4901 LOBYTE(v170) = v107->field_58[13];
4902 if ( v170 )
4903 {
4904 if ( v170 == 99 )
4905 {
4906 v171 = v2->field_3C;
4907 v172 = v4->field_3C;
4908 if ( v171 != v172 )
4909 {
4910 if ( v171 <= v172 )
4911 {
4912 v205 = v172 > v171;
4913 v2->field_3C = v172;
4914 }
4915 else
4916 {
4917 v204 = 1;
4918 v4->field_3C = v171;
4919 }
4920 }
4921 }
4922 else
4923 {
4924 v170 = v170;
4925 v2->field_3C += v170;
4926 v4->field_3C += v170;
4927 if ( v2->field_3C < 0 )
4928 v2->field_3C = 0;
4929 if ( v4->field_3C < 0 )
4930 v4->field_3C = 0;
4931 v205 = v170;
4932 v204 = v170;
4933 }
4934 }
4935 LOBYTE(v173) = v107->field_58[14];
4936 if ( (_BYTE)v173 )
4937 {
4938 if ( (_BYTE)v173 == 99 )
4939 {
4940 v174 = v2->field_40;
4941 v175 = v4->field_40;
4942 if ( v174 != v175 )
4943 {
4944 if ( v174 <= v175 )
4945 {
4946 v2->field_40 = v175;
4947 v203 = v175 - v174;
4948 }
4949 else
4950 {
4951 v4->field_40 = v174;
4952 v202 = v174 - v175;
4953 }
4954 }
4955 }
4956 else
4957 {
4958 v173 = (char)v173;
4959 v2->field_40 += (char)v173;
4960 v4->field_40 += (char)v173;
4961 if ( v2->field_40 < 0 )
4962 v2->field_40 = 0;
4963 if ( v4->field_40 < 0 )
4964 v4->field_40 = 0;
4965 v203 = v173;
4966 v202 = v173;
4967 }
4968 }
4969 v176 = v107->field_58[15];
4970 if ( v176 )
4971 {
4972 v177 = am_40D402(v193, v176);
4973 v178 = v107->field_58[15];
4974 v196 = v177;
4975 v179 = am_40D402(v189, v178);
4976 v195 = v179;
4977 v180 = v107->field_58[15] - v179;
4978 v192 = v107->field_58[15] - v196;
4979 v191 = v180;
4980 }
4981 LOBYTE(v181) = LOBYTE(v107->field_68);
4982 if ( (_BYTE)v181 )
4983 {
4984 if ( (_BYTE)v181 == 99 )
4985 {
4986 v182 = v2->field_28;
4987 v183 = v4->field_28;
4988 if ( v182 != v183 )
4989 {
4990 if ( v182 <= v183 )
4991 {
4992 v2->field_28 = v183;
4993 v201 = v183 - v182;
4994 }
4995 else
4996 {
4997 v4->field_28 = v182;
4998 v200 = v182 - v183;
4999 }
5000 }
5001 }
5002 else
5003 {
5004 v181 = (char)v181;
5005 v2->field_28 += (char)v181;
5006 v4->field_28 += (char)v181;
5007 if ( v2->field_28 < 0 )
5008 v2->field_28 = 0;
5009 if ( v4->field_28 < 0 )
5010 v4->field_28 = 0;
5011 v201 = v181;
5012 v200 = v181;
5013 }
5014 }
5015 LOBYTE(v103) = BYTE1(v107->field_68);
5016 break;
5017 }
5018 if ( (_BYTE)v103 )
5019 {
5020 if ( (_BYTE)v103 == 99 )
5021 {
5022 v184 = v2->field_24;
5023 v185 = v4->field_24;
5024 if ( v184 != v185 )
5025 {
5026 if ( v184 <= v185 )
5027 {
5028 v2->field_24 = v185;
5029 v199 = v185 - v184;
5030 }
5031 else
5032 {
5033 v4->field_24 = v184;
5034 v198 = v184 - v185;
5035 }
5036 }
5037 }
5038 else
5039 {
5040 v103 = (char)v103;
5041 v2->field_24 += (char)v103;
5042 v4->field_24 += (char)v103;
5043 if ( v2->field_24 < 0 )
5044 v2->field_24 = 0;
5045 if ( v4->field_24 < 0 )
5046 v4->field_24 = 0;
5047 v199 = v103;
5048 v198 = v103;
5049 }
5050 }
5051 if ( v194 > 0 || v211 > 0 )
5052 ArcomageGame::PlaySound(0x1Eu);
5053 if ( v194 < 0 || v211 < 0 )
5054 ArcomageGame::PlaySound(0x1Fu);
5055 if ( v210 > 0 || v209 > 0 )
5056 ArcomageGame::PlaySound(0x21u);
5057 if ( v210 < 0 || v209 < 0 )
5058 ArcomageGame::PlaySound(0x22u);
5059 if ( v208 > 0 || v207 > 0 )
5060 ArcomageGame::PlaySound(0x24u);
5061 if ( v208 < 0 || v207 < 0 )
5062 ArcomageGame::PlaySound(0x25u);
5063 if ( v197 > 0 || v206 > 0 )
5064 ArcomageGame::PlaySound(0x27u);
5065 if ( v197 < 0 || v206 < 0 )
5066 ArcomageGame::PlaySound(0x28u);
5067 if ( v205 > 0 || v204 > 0 )
5068 ArcomageGame::PlaySound(0x2Au);
5069 if ( v205 < 0 || v204 < 0 )
5070 ArcomageGame::PlaySound(0x2Bu);
5071 if ( v203 > 0 || v202 > 0 )
5072 ArcomageGame::PlaySound(0x2Du);
5073 if ( v203 < 0 || v202 < 0 )
5074 ArcomageGame::PlaySound(0x2Eu);
5075 if ( v192 || v191 || v196 || v195 )
5076 ArcomageGame::PlaySound(0x30u);
5077 if ( v201 > 0 || v200 > 0 )
5078 ArcomageGame::PlaySound(0x31u);
5079 if ( v201 < 0 || v200 < 0 )
5080 ArcomageGame::PlaySound(0x32u);
5081 if ( v199 > 0 || v198 > 0 )
5082 ArcomageGame::PlaySound(0x34u);
5083 if ( v199 < 0 || v198 < 0 )
5084 ArcomageGame::PlaySound(0x35u);
5085 if ( v193 )
5086 {
5087 if ( v194 )
5088 {
5089 v187.x = 573;
5090 v187.y = 92;
5091 am_40D2B4(&v187, v194);
5092 }
5093 if ( v211 )
5094 {
5095 v187.x = 26;
5096 v187.y = 92;
5097 am_40D2B4(&v187, v211);
5098 }
5099 if ( v210 )
5100 {
5101 v187.x = 573;
5102 v187.y = 164;
5103 am_40D2B4(&v187, v210);
5104 }
5105 if ( v209 )
5106 {
5107 v187.x = 26;
5108 v187.y = 164;
5109 am_40D2B4(&v187, v209);
5110 }
5111 if ( v208 )
5112 {
5113 v187.x = 573;
5114 v187.y = 236;
5115 am_40D2B4(&v187, v208);
5116 }
5117 if ( v207 )
5118 {
5119 v187.x = 26;
5120 v187.y = 236;
5121 am_40D2B4(&v187, v207);
5122 }
5123 if ( v197 )
5124 {
5125 v187.x = 563;
5126 v187.y = 114;
5127 am_40D2B4(&v187, v197);
5128 }
5129 if ( v206 )
5130 {
5131 v187.x = 16;
5132 v187.y = 114;
5133 am_40D2B4(&v187, v206);
5134 }
5135 if ( v205 )
5136 {
5137 v187.x = 563;
5138 v187.y = 186;
5139 am_40D2B4(&v187, v205);
5140 }
5141 if ( v204 )
5142 {
5143 v187.x = 16;
5144 v187.y = 186;
5145 am_40D2B4(&v187, v204);
5146 }
5147 if ( v203 )
5148 {
5149 v187.x = 563;
5150 v187.y = 258;
5151 am_40D2B4(&v187, v203);
5152 }
5153 if ( v202 )
5154 {
5155 v187.x = 16;
5156 v187.y = 258;
5157 am_40D2B4(&v187, v202);
5158 }
5159 v186 = 296;
5160 if ( v201 )
5161 {
5162 v187.x = 442;
5163 v187.y = 296;
5164 am_40D2B4(&v187, v201);
5165 }
5166 if ( v200 )
5167 {
5168 v187.x = 180;
5169 v187.y = 296;
5170 am_40D2B4(&v187, v200);
5171 }
5172 if ( v199 )
5173 {
5174 v187.x = 514;
5175 v187.y = 296;
5176 am_40D2B4(&v187, v199);
5177 }
5178 if ( v198 )
5179 {
5180 v187.x = 122;
5181 v187.y = 296;
5182 am_40D2B4(&v187, v198);
5183 }
5184 if ( v196 )
5185 {
5186 v187.x = 442;
5187 v187.y = 296;
5188 am_40D2B4(&v187, v196);
5189 }
5190 if ( v192 )
5191 {
5192 v187.x = 514;
5193 v187.y = 296;
5194 am_40D2B4(&v187, v192);
5195 }
5196 if ( v195 )
5197 {
5198 v187.x = 180;
5199 v187.y = 296;
5200 am_40D2B4(&v187, v195);
5201 }
5202 if ( v191 )
5203 {
5204 v187.x = 122;
5205 goto LABEL_567;
5206 }
5207 }
5208 else
5209 {
5210 if ( v194 )
5211 {
5212 v187.x = 26;
5213 v187.y = 92;
5214 am_40D2B4(&v187, v194);
5215 }
5216 if ( v211 )
5217 {
5218 v187.x = 573;
5219 v187.y = 92;
5220 am_40D2B4(&v187, v211);
5221 }
5222 if ( v210 )
5223 {
5224 v187.x = 26;
5225 v187.y = 164;
5226 am_40D2B4(&v187, v210);
5227 }
5228 if ( v209 )
5229 {
5230 v187.x = 573;
5231 v187.y = 164;
5232 am_40D2B4(&v187, v209);
5233 }
5234 if ( v208 )
5235 {
5236 v187.x = 26;
5237 v187.y = 236;
5238 am_40D2B4(&v187, v208);
5239 }
5240 if ( v207 )
5241 {
5242 v187.x = 573;
5243 v187.y = 236;
5244 am_40D2B4(&v187, v207);
5245 }
5246 if ( v197 )
5247 {
5248 v187.x = 16;
5249 v187.y = 114;
5250 am_40D2B4(&v187, v197);
5251 }
5252 if ( v206 )
5253 {
5254 v187.x = 563;
5255 v187.y = 114;
5256 am_40D2B4(&v187, v206);
5257 }
5258 if ( v205 )
5259 {
5260 v187.x = 16;
5261 v187.y = 186;
5262 am_40D2B4(&v187, v205);
5263 }
5264 if ( v204 )
5265 {
5266 v187.x = 563;
5267 v187.y = 186;
5268 am_40D2B4(&v187, v204);
5269 }
5270 if ( v203 )
5271 {
5272 v187.x = 16;
5273 v187.y = 258;
5274 am_40D2B4(&v187, v203);
5275 }
5276 if ( v202 )
5277 {
5278 v187.x = 563;
5279 v187.y = 258;
5280 am_40D2B4(&v187, v202);
5281 }
5282 v186 = 296;
5283 if ( v201 )
5284 {
5285 v187.x = 180;
5286 v187.y = 296;
5287 am_40D2B4(&v187, v201);
5288 }
5289 if ( v200 )
5290 {
5291 v187.x = 442;
5292 v187.y = 296;
5293 am_40D2B4(&v187, v200);
5294 }
5295 if ( v199 )
5296 {
5297 v187.x = 122;
5298 v187.y = 296;
5299 am_40D2B4(&v187, v199);
5300 }
5301 if ( v198 )
5302 {
5303 v187.x = 514;
5304 v187.y = 296;
5305 am_40D2B4(&v187, v198);
5306 }
5307 if ( v196 )
5308 {
5309 v187.x = 180;
5310 v187.y = 296;
5311 am_40D2B4(&v187, v196);
5312 }
5313 if ( v192 )
5314 {
5315 v187.x = 122;
5316 v187.y = 296;
5317 am_40D2B4(&v187, v192);
5318 }
5319 if ( v195 )
5320 {
5321 v187.x = 442;
5322 v187.y = 296;
5323 am_40D2B4(&v187, v195);
5324 }
5325 if ( v191 )
5326 {
5327 v187.x = 514;
5328 LABEL_567:
5329 v187.y = v186;
5330 am_40D2B4(&v187, v191);
5331 return;
5332 }
5333 }
5334 }
5335
5336
5337
5338
5339 //----- (0040D2B4) --------------------------------------------------------
5340 int __fastcall am_40D2B4(Vec2_int_ *a1, int a2)
5341 {
5342 int v2; // ebp@1
5343 Vec2_int_ *v3; // edi@1
5344 char *v4; // ebx@1
5345 int result; // eax@3
5346 unsigned int v6; // esi@7
5347 stru272_stru0 *v7; // ecx@10
5348 stru272_stru0 *v8; // ecx@12
5349 int v9; // edx@17
5350 int v10; // ecx@17
5351 signed int v11; // [sp+10h] [bp-8h]@1
5352 stru272_stru0 **v12; // [sp+14h] [bp-4h]@1
5353
5354 v11 = 0;
5355 v2 = a2;
5356 v3 = a1;
5357 v4 = byte_4FABD0;
5358 v12 = (stru272_stru0 **)array_4FAC10;
5359 while ( *v4 )
5360 {
5361 result = (*v12)->_40E2A7();
5362 if ( !result )
5363 {
5364 *v4 = 0;
5365 --v11;
5366 v12 -= 1067;
5367 v4 -= 4268;
5368 }
5369 ++v11;
5370 v12 += 1067;
5371 v4 += 4268;
5372 if ( v11 >= 10 )
5373 return result;
5374 }
5375 v6 = 4268 * v11;
5376 byte_4FABD0[4268 * v11] = 1;
5377 if ( v2 <= 0 )
5378 {
5379 byte_4FABD1[v6] = 0;
5380 v2 = -v2;
5381 }
5382 else
5383 {
5384 byte_4FABD1[v6] = 1;
5385 }
5386 *(unsigned int *)((char *)&unk_4FABD4 + v6) = v3->x - 20;
5387 dword_4FABDC[v6 / 4] = v3->x + 20;
5388 dword_4FABD8[v6 / 4] = v3->y - 20;
5389 dword_4FABE0[v6 / 4] = v3->y + 20;
5390 v7 = array_4FAC10[v6 / 0x10AC].ptr_0;
5391 dword_4FABE4[v6 / 4] = -60;
5392 dword_4FABE8[v6 / 4] = 60;
5393 dword_4FABEC[v6 / 4] = 180;
5394 dword_4FABF0[v6 / 4] = 0x3F000000u;
5395 dword_4FABF4[v6 / 4] = 150;
5396 dword_4FABF8[v6 / 4] = 0x42480000u;
5397 dword_4FABFC[v6 / 4] = 0x40400000u;
5398 dword_4FAC00[v6 / 4] = 0x41000000u;
5399 dword_4FAC04[v6 / 4] = 5;
5400 dword_4FAC08[v6 / 4] = 15;
5401 dword_4FAC0C[v6 / 4] = (int)array_4FAC10[v6 / 0x10AC].field_4;
5402 v7->_40E01A((int)((char *)&unk_4FABD4 + v6));
5403 if ( 10 * v2 > 150 )
5404 v2 = 15;
5405 v8 = array_4FAC10[v6 / 0x10AC].ptr_0;
5406 if ( v8->field_0 != 0x67707274 )
5407 return 2;
5408 if ( !v8->field_59 )
5409 return 3;
5410 v8->field_8 = 10 * v2;
5411 v9 = v8->field_4;
5412 v8->field_30 = 0.0;
5413 v8->field_58 = 0;
5414 v8->field_44 = 0;
5415 v8->field_4C = 0;
5416 v8->field_48 = 0;
5417 v8->field_50 = 0;
5418 v10 = v8->field_54;
5419 do
5420 {
5421 *(unsigned int *)v10 = 0;
5422 v10 += 28;
5423 --v9;
5424 }
5425 while ( v9 );
5426 return 0;
5427 }
5428 // 40D2B4: using guessed type int __fastcall am_40D2B4(uint, uint);
5429 // 4FABD8: using guessed type int dword_4FABD8[];
5430 // 4FABDC: using guessed type int dword_4FABDC[];
5431 // 4FABE0: using guessed type int dword_4FABE0[];
5432 // 4FABE4: using guessed type int dword_4FABE4[];
5433 // 4FABE8: using guessed type int dword_4FABE8[];
5434 // 4FABEC: using guessed type int dword_4FABEC[];
5435 // 4FABF0: using guessed type int dword_4FABF0[];
5436 // 4FABF4: using guessed type int dword_4FABF4[];
5437 // 4FABF8: using guessed type int dword_4FABF8[];
5438 // 4FABFC: using guessed type int dword_4FABFC[];
5439 // 4FAC00: using guessed type int dword_4FAC00[];
5440 // 4FAC04: using guessed type int dword_4FAC04[];
5441 // 4FAC08: using guessed type int dword_4FAC08[];
5442 // 4FAC0C: using guessed type int dword_4FAC0C[];
5443
5444 //----- (0040D402) --------------------------------------------------------
5445 int __fastcall am_40D402(int a1, int a2)
5446 {
5447 ArcomageGame_stru0 *v2; // ecx@1
5448 int v3; // esi@1
5449 int result; // eax@3
5450
5451 v2 = &stru_505708[a1];
5452 v3 = v2->field_28;
5453 if ( v3 <= 0 )
5454 {
5455 result = 0;
5456 }
5457 else
5458 {
5459 if ( v3 >= -a2 )
5460 {
5461 result = a2;
5462 v2->field_28 = a2 + v3;
5463 goto LABEL_7;
5464 }
5465 a2 += v3;
5466 result = -v3;
5467 v2->field_28 = 0;
5468 }
5469 v2->field_24 += a2;
5470 LABEL_7:
5471 if ( v2->field_24 < 0 )
5472 v2->field_24 = 0;
5473 return result;
5474 }
5475 // 40D402: using guessed type int __fastcall am_40D402(uint, uint);
5476
5477 //----- (0040D444) --------------------------------------------------------
5478 int __cdecl am_40D444()
5479 {
5480 int v0; // esi@1
5481 int v1; // edi@1
5482 int v2; // eax@1
5483 int v3; // eax@23
5484 int v4; // edx@25
5485 int v5; // ecx@28
5486 int v6; // eax@28
5487 GUIWindow *v7; // ecx@50
5488 signed int v8; // eax@50
5489 char *v9; // eax@52
5490 signed int v10; // eax@54
5491 char *v11; // esi@59
5492 char *v12; // esi@65
5493 signed int v14; // [sp-4h] [bp-58h]@46
5494 char pText[64]; // [sp+Ch] [bp-48h]@1
5495 int xy[2]; // [sp+4Ch] [bp-8h]@1
5496
5497 v0 = -1;
5498 v1 = -1;
5499 //nullsub_1();
5500 xy[0] = 0;
5501 xy[1] = 0;
5502 inv_strcpy("Победи", pText);
5503 v2 = 0;
5504 xy[1] = 160;
5505 xy[0] = 320 - 12 * v2 / 2;
5506 pPrimaryWindow_draws_text(-1, pText, xy);
5507 if ( stru_505708[0].field_24 < dword_4E1884 )
5508 {
5509 if ( stru_505708[1].field_24 < dword_4E1884 )
5510 goto LABEL_10;
5511 v0 = 2;
5512 }
5513 else
5514 {
5515 if ( stru_505708[1].field_24 < dword_4E1884 )
5516 {
5517 v0 = 1;
5518 }
5519 else
5520 {
5521 if ( stru_505708[0].field_24 == stru_505708[1].field_24 )
5522 {
5523 v0 = 0;
5524 v1 = 4;
5525 goto LABEL_10;
5526 }
5527 v0 = (stru_505708[0].field_24 <= stru_505708[1].field_24) + 1;
5528 }
5529 }
5530 v1 = 0;
5531 LABEL_10:
5532 if ( stru_505708[0].field_24 <= 0 )
5533 {
5534 if ( stru_505708[1].field_24 > 0 )
5535 {
5536 v0 = 2;
5537 }
5538 else
5539 {
5540 if ( stru_505708[0].field_24 == stru_505708[1].field_24 )
5541 {
5542 LABEL_20:
5543 if ( stru_505708[0].field_28 == stru_505708[1].field_28 )
5544 {
5545 v0 = 0;
5546 v1 = 4;
5547 }
5548 else
5549 {
5550 v0 = (stru_505708[0].field_28 <= stru_505708[1].field_28) + 1;
5551 v1 = 1;
5552 }
5553 goto LABEL_23;
5554 }
5555 v0 = (stru_505708[0].field_24 <= stru_505708[1].field_24) + 1;
5556 }
5557 goto LABEL_17;
5558 }
5559 if ( stru_505708[1].field_24 <= 0 )
5560 {
5561 v0 = 1;
5562 LABEL_17:
5563 v1 = 2;
5564 }
5565 if ( !v0 && v1 == 4 )
5566 goto LABEL_20;
5567 LABEL_23:
5568 v3 = stru_505708[0].field_38;
5569 if ( stru_505708[0].field_38 <= stru_505708[0].field_3C )
5570 {
5571 v3 = stru_505708[0].field_40;
5572 v4 = stru_505708[0].field_3C;
5573 if ( stru_505708[0].field_3C > stru_505708[0].field_40 )
5574 goto LABEL_28;
5575 }
5576 else
5577 {
5578 if ( stru_505708[0].field_38 <= stru_505708[0].field_40 )
5579 {
5580 v4 = stru_505708[0].field_40;
5581 goto LABEL_28;
5582 }
5583 }
5584 v4 = v3;
5585 LABEL_28:
5586 v5 = stru_505708[1].field_38;
5587 v6 = stru_505708[1].field_3C;
5588 if ( stru_505708[1].field_38 <= stru_505708[1].field_3C )
5589 {
5590 v5 = stru_505708[1].field_40;
5591 if ( stru_505708[1].field_3C > stru_505708[1].field_40 )
5592 goto LABEL_33;
5593 goto LABEL_32;
5594 }
5595 v6 = stru_505708[1].field_40;
5596 if ( stru_505708[1].field_38 > stru_505708[1].field_40 )
5597 LABEL_32:
5598 v6 = v5;
5599 LABEL_33:
5600 if ( v0 == -1 )
5601 {
5602 if ( v1 != -1 )
5603 goto LABEL_49;
5604 if ( v4 < dword_4E1888 )
5605 {
5606 if ( v6 < dword_4E1888 )
5607 goto LABEL_49;
5608 v0 = 2;
5609 }
5610 else
5611 {
5612 if ( v6 < dword_4E1888 )
5613 {
5614 v0 = 1;
5615 }
5616 else
5617 {
5618 if ( v4 == v6 )
5619 goto LABEL_46;
5620 v0 = (v4 <= v6) + 1;
5621 }
5622 }
5623 v1 = 3;
5624 }
5625 if ( !v0 && v1 == 4 )
5626 {
5627 if ( v4 != v6 )
5628 {
5629 v14 = 5;
5630 v0 = (v4 <= v6) + 1;
5631 goto LABEL_48;
5632 }
5633 LABEL_46:
5634 v0 = 0;
5635 v14 = 4;
5636 LABEL_48:
5637 v1 = v14;
5638 }
5639 LABEL_49:
5640 pArcomageGame->field_B0 = v1;
5641 pArcomageGame->uGameResult = v0;
5642 if ( v0 == 1 )
5643 {
5644 v7 = ptr_507BC0;
5645 v8 = (signed int)ptr_507BC0->ptr_1C;
5646 if ( v8 >= 108 )
5647 {
5648 if ( v8 <= 120 )
5649 {
5650 v9 = (char *)&pParty->uNumGoldInBank + v8 + 1;
5651 if ( !*v9 )
5652 {
5653 *v9 = 1;
5654
5655 //auto _a = (signed __int64)(p2DEvents_minus1__20[13 * (unsigned int)v7->ptr_1C] * 100.0);
5656 auto _a = (signed __int64)(p2DEvents[(unsigned int)v7->ptr_1C - 1].fPriceMultiplier * 100.0);
5657 party_finds_gold(_a, 0);
5658 }
5659 }
5660 }
5661 v10 = 108;
5662 do
5663 {
5664 if ( !*((unsigned char *)&pParty->uNumGoldInBank + v10 + 1) )
5665 break;
5666 ++v10;
5667 }
5668 while ( v10 <= 120 );
5669 if ( v10 == 121 )
5670 _449B7E_toggle_bit(pParty->_award_bits, 238, 1u);
5671 v11 = pParty->pPlayers[0].field_152;
5672 do
5673 {
5674 if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)v11, 1) )
5675 _449B7E_toggle_bit((unsigned char *)v11, 103, 1u);
5676 v11 += 6972;
5677 }
5678 while ( (signed int)v11 < (signed int)((char *)&pParty->field_777C[36] + 2) );
5679 ++pParty->field_874;
5680 if ( pParty->field_874 > 1000000 )
5681 pParty->field_874 = 1000000;
5682 }
5683 else
5684 {
5685 v12 = pParty->pPlayers[0].field_152;
5686 do
5687 {
5688 if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)v12, 1) )
5689 _449B7E_toggle_bit((unsigned char *)v12, 104, 1u);
5690 v12 += 6972;
5691 }
5692 while ( (signed int)v12 < (signed int)((char *)&pParty->field_777C[36] + 2) );
5693 ++pParty->field_878;
5694 if ( pParty->field_878 > 1000000 )
5695 pParty->field_878 = 1000000;
5696 }
5697 return 0;
5698 }
5699
5700
5701
5702 //----- (00409C8B) --------------------------------------------------------
5703 void __cdecl PrepareArcomage()
5704 {
5705 int v0; // ecx@3
5706 signed __int64 v1; // qax@4
5707 int v2; // esi@4
5708 __int16 *v3; // esi@5
5709 signed int v4; // edi@5
5710 stru272 *v5; // esi@7
5711 int v6; // edx@9
5712 int v7; // ecx@9
5713 int pXYZW[4]; // [sp+8h] [bp-1Ch]@5
5714 int pXY[2]; // [sp+18h] [bp-Ch]@5
5715 int v10; // [sp+20h] [bp-4h]@3
5716
5717 if (pAsyncMouse)
5718 pAsyncMouse->_409E3D(1);
5719 pAudioPlayer->StopChannels(-1, -1);
5720 strcpy(pArcomageGame->pPlayer1Name, pArcomagePlayer1Name);
5721 strcpy(pArcomageGame->pPlayer2Name, pArcomagePlayer2Name);
5722 am_byte_4FAA76 = 0;
5723 am_byte_4FAA75 = 0;
5724 v10 = 1;
5725 v0 = (int)am_byte_4FAA7C;
5726 do
5727 {
5728 v1 = v10;
5729 *(int *)(v0 - 4) = -1;
5730 *(char *)v0 = 0;
5731 v0 += 32;
5732 v2 = 138 * (unsigned __int64)(v1 / 4) + 18;
5733 HIDWORD(v1) = 100 * (unsigned __int64)(v1 % 4) + 120;
5734 *(int *)(v0 - 28) = HIDWORD(v1);
5735 *(int *)(v0 - 24) = v2;
5736 *(int *)(v0 - 20) = (120 - HIDWORD(v1)) / 5;
5737 ++v10;
5738 *(int *)(v0 - 16) = (18 - v2) / 5;
5739 *(int *)(v0 - 12) = *(int *)(v0 - 28);
5740 *(int *)(v0 - 8) = *(int *)(v0 - 24);
5741 }
5742 while ( v10 - 1 < 10 );
5743 pXY[0] = 0;
5744 pXY[1] = 0;
5745 ArcomageGame::LoadBackground();
5746 pXYZW[0] = 0;
5747 pXYZW[2] = 640;
5748 pXYZW[1] = 0;
5749 pXYZW[3] = 480;
5750 am_BeginScene(pArcomageGame->pBackgroundPixels, -1, 1);
5751 Blt_Copy((ArcomageRect *)pXYZW, pXY, 2);
5752 am_EndScene();
5753 pRenderer->Present();
5754 ArcomageGame::LoadSprites();
5755 CallRenderPresent();
5756 v3 = am_sounds;
5757 v4 = 120;
5758 do
5759 {
5760 *v3 = pSoundList->LoadSound(v4++, 0);
5761 ++v3;
5762 }
5763 while ( (signed int)v3 <= (signed int)&unk_4FAA20 );
5764 v5 = array_4FAC10;
5765 do
5766 {
5767 v5->_40DFD1();
5768 ++v5;
5769 }
5770 while ( (signed int)v5 < (signed int)&unk_5052C8 );
5771 dword_4FABBC = -1;
5772 amuint_4FAA4C = -1;
5773 byte_4FAA74 = 0;
5774 pArcomageGame->field_F4 = 0;
5775 byte_4FAA2C = 0;
5776 byte_505880 = 0;
5777 dword_4FAA70 = 0;
5778 am_byte_4FAA77 = 0;
5779 am_409FE9();
5780 am_40A255(v7, v6);
5781 //nullsub_1();
5782 pArcomageGame->field_F5 = 0;
5783 pArcomageGame->pFont1 = pFontComic;
5784 pArcomageGame->pFont2 = pFontArrus;
5785 }
5786
5787
5788 //----- (0040D711) --------------------------------------------------------
5789 ArcomageGame::ArcomageGame()
5790 {
5791 ArcomageGame *v1; // esi@1
5792
5793 v1 = this;
5794 this->field_4 = 0;
5795 //RGBTexture::RGBTexture(&this->pGameBackground);
5796 //RGBTexture::RGBTexture(&v1->pSprites);
5797 v1->bGameInProgress = 0;
5798 v1->field_F9 = 0;
5799 }