changeset 1264:6bc88137a019

Merge
author Gloval
date Thu, 13 Jun 2013 00:56:22 +0400
parents 73269755dd89 (diff) 0aeac0b9ca30 (current diff)
children 71ebff35c428
files Arcomage.cpp mm7_3.cpp mm7_5.cpp mm7_data.cpp mm7_data.h
diffstat 6 files changed, 292 insertions(+), 310 deletions(-) [+]
line wrap: on
line diff
--- a/Arcomage.cpp	Wed Jun 12 21:07:34 2013 +0200
+++ b/Arcomage.cpp	Thu Jun 13 00:56:22 2013 +0400
@@ -25,26 +25,24 @@
 
 
 void SetStartConditions();
-
-
 void SetStartGameData();
 void FillPlayerDeck();
 void InitalHandsFill();
 void GetNextCardFromDeck(int player_num);
 int  GetEmptyCardSlotIndex(int player_num);
 void IncreaseResourcesInTurn(int player_num);
-void  TurnChange();
+void TurnChange();
 bool IsGameOver();
 int  CalculateCardPower(ArcomagePlayer* player, ArcomagePlayer* enemy, ArcomageCard* pCard, int mastery);
 char PlayerTurn(int player_num);
-void DrawGameUI(int a1); // idb
-void am_40AA4E();
+void DrawGameUI(int  animation_stage); 
+void DrawSparks();
 void DrawRectanglesForText();
 void DrawPlayersText();
-void DrawPlayerLevels(int a1, char *text, POINT *pXY); // idb
-void DrawBricksCount(int a1, char* text, POINT *pXY); // idb
+void DrawPlayerLevels(int a1, char *text, POINT *pXY); 
+void DrawBricksCount(int a1, char* text, POINT *pXY); 
 void DrawGemsCount(int a1, char* text, POINT* pXY);
-void DrawBeastsCount(int a1, char *text, POINT *pXY); // idb
+void DrawBeastsCount(int a1, char *text, POINT *pXY);
 void DrawPlayersTowers();
 void DrawPlayersWall();
 void DrawCards();
@@ -54,7 +52,7 @@
 bool DiscardCard(int player_num, signed int card_slot_index);
 bool PlayCard(int player_num, signed int card_slot_num);
 bool CanCardBePlayed(int player_num, int hand_card_indx);
-void ApplyCardToPlayer(int player_num, unsigned int uCardID); // idb
+void ApplyCardToPlayer(int player_num, unsigned int uCardID); 
 int  am_40D2B4(POINT* a1, int a2); // weak
 int  ApplyDamageToBuildings(int player_num, int damage); // weak
 void GameResultsApply();
@@ -64,9 +62,10 @@
 void __fastcall Blt_Chroma(RECT  *pSrcXYZW, POINT *pTargetXY, int a3, int a4);
 void  Blt_Copy(RECT *pSrcRect, POINT *pTargetXY, int a3);
 void __cdecl am_EndScene();
-void __fastcall DrawRect(RECT *pXYZW, unsigned __int16 uColor, char bSolidFill); // idb
-void  SetPixel(POINT *pTargetXY, unsigned __int16 uColor);
-int __fastcall rand_interval(int a, int b); // idb
+void DrawRect(RECT *pXYZW, unsigned __int16 uColor, char bSolidFill);
+void SetPixel2sq( POINT *pTargetXY, unsigned __int16 uColor );
+void SetPixel(POINT *pTargetXY, unsigned __int16 uColor);
+int  rand_interval(int min, int max); // idb
 void __fastcall intToString(int val, char *pOut);
 
 /*  388 */
@@ -129,10 +128,10 @@
 
   int x;
   int y;
-  char field_8;
-  char field_9;
-  char field_A;
-  char field_B;
+  char curr_mouse_left;
+  char mouse_left_state_changed;
+  char curr_mouse_right;
+  char mouse_right_state_changed;
 };
 #pragma pack(pop)
 
@@ -145,12 +144,12 @@
     };
 #pragma pack(pop)
 
-am_2  stru_4FA9B0[10];
+am_2  cards_power[10];
 std::array<__int16, 12> am_sounds;
 
 char byte_4E185C  = 1; // weak
 char am_byte_4E185D = 1; // weak
-char byte_4E185E = 1; // weak
+char use_start_bonus = 1; // weak
 
 int start_tower_height;
 int start_wall_height; 
@@ -173,7 +172,7 @@
 char byte_4FAA2D; // weak
 
 int current_player_num; // idb
-char hand_full; // weak
+char need_to_discard_card; // weak
 
 signed int current_card_slot_index; 
 int played_card_id; // idb 4FABC0
@@ -220,12 +219,12 @@
 
   this->x = pArcomageGame->mouse_x;
   this->y = pArcomageGame->mouse_y;
-  this->field_8 = pArcomageGame->mouse_left;
-  this->field_9 = pArcomageGame->mouse_left == pArcomageGame->field_F7;
-  this->field_A = pArcomageGame->mouse_right;
-  this->field_B = pArcomageGame->mouse_right == pArcomageGame->field_F8;
-  pArcomageGame->field_F7 = pArcomageGame->mouse_left;
-  pArcomageGame->field_F8 = pArcomageGame->mouse_right;
+  this->curr_mouse_left = pArcomageGame->mouse_left;
+  this->mouse_left_state_changed = pArcomageGame->mouse_left == pArcomageGame->prev_mouse_left;
+  this->curr_mouse_right = pArcomageGame->mouse_right;
+  this->mouse_right_state_changed = pArcomageGame->mouse_right == pArcomageGame->prev_mouse_right;
+  pArcomageGame->prev_mouse_left = pArcomageGame->mouse_left;
+  pArcomageGame->prev_mouse_right = pArcomageGame->mouse_right;
   return true;
 }
 
@@ -244,7 +243,7 @@
     v2 = (stru272_stru0 *)malloc(0x5Cu);
     *a1 = v2;
     v2->signature = SIG_trpg;
-    v2->field_8 = 0;
+    v2->position_in_sparks_arr = 0;
     v2->field_30 = 0.0;
     v2->field_58 = 0;
     v2->field_59 = 0;
@@ -266,16 +265,16 @@
     }
 
 //----- (0040E01A) --------------------------------------------------------
-int stru272_stru0::_40E01A( stru272_stru2* a2 )
+int stru272_stru0::StartFill( stru272_stru2* a2 )
     {
     auto a1 = this;
     if ( a1->signature == SIG_trpg )
         {
         a1->field_4 = a2->field_20;
-        a1->field_C = a2->field_0 << 16;
-        a1->field_10 = a2->field_4 << 16;
-        a1->field_14 = a2->field_8 << 16;
-        a1->field_18 = a2->field_C << 16;
+        a1->field_C = a2->effect_area.left << 16;
+        a1->field_10 = a2->effect_area.top << 16;
+        a1->field_14 = a2->effect_area.right << 16;
+        a1->field_18 = a2->effect_area.bottom << 16;
         a1->field_1C = a2->field_10;
         a1->field_20 = a2->field_14;
         a1->field_24 = a2->field_18;
@@ -285,7 +284,7 @@
         a1->field_38 = (int)(a2->field_2Cf * 65536.0);
         a1->field_3C = a2->field_30;
         a1->field_40 = a2->field_34;
-        a1->field_54 = a2->field_38;
+        a1->field_54 = a2->sparks_array;
         a1->field_59 = 1;
 
         return 0;
@@ -301,14 +300,14 @@
         {
         if ( a2 )
             {
-            field_8 = 0;
+            position_in_sparks_arr = 0;
             field_30 = 0.0;
             }
         if ( field_59 && a3 )
             {
 
             for (int i=0; i<field_4; ++i)
-                field_54[i].field_0 = 0;
+                field_54[i].have_spark = 0;
              field_58 = 0;
             }
         return 0;
@@ -318,7 +317,7 @@
     }
 
 //----- (0040E133) --------------------------------------------------------
-int stru272_stru0::_40E133()
+int stru272_stru0::DrawEffect()
     {
 
     stru272_stru0 *v1; // edi@1
@@ -346,7 +345,7 @@
     v1 = this;
     if ( this->signature != SIG_trpg )
         return 2;
-    v3 = this->field_8;
+    v3 = this->position_in_sparks_arr;
     v22 = this->field_30;
     v4 = v3;
     if ( v3 > 0 )
@@ -362,28 +361,29 @@
         v7 = this->field_54;
         v20 = this->field_28;
         v21 = this->field_4;
-        while ( v7->field_0 <= 0 )
+        while ( v7->have_spark <= 0 )
             {
             if ( v22 >= 1.0 )
                 {
                 v12 = v1->field_40;
                 v13 = v1->field_3C;
-                v7->field_0 = v13 + rand() % (v12 - v13 + 1);
+                v7->have_spark = rand_interval(v13,v12);
                 v7->field_14 = (rand() % 17 - 8) << 16;
                 v7->field_18 = (rand() % 17 - 8) << 16;
+
                 v14 = v1->field_14 - 1;
                 v15 = v1->field_C;
-                v16 = v15 + rand() % (v14 - v15 + 1);
+                v16 = rand_interval(v15,v14);
                 v7->field_C = v16;
-                v7->field_4.x = v16 >> 16;
+                v7->spark_position.x = v16 >> 16;
 
                 v17 = v1->field_18 - 1;
                 v18 = v1->field_10;
-                v22 = v22 - 1.0;
-                v19 = v18 + rand() % (v17 - v18 + 1);
+                v19 = rand_interval(v17, v18);
                 v7->field_10 = v19;
-                v7->field_4.y = v19 >> 16;
-                --v1->field_8;
+                v7->spark_position.y = v19 >> 16;
+                --v1->position_in_sparks_arr;
+                v22 = v22 - 1.0;
                 goto LABEL_13;
                 }
 LABEL_14:
@@ -397,17 +397,17 @@
                 }
             }
         v8 = v7->field_14;
-        --v7->field_0;
+        --v7->have_spark;
         v9 = v8 + v7->field_C;
 
         v10 = v20 + v7->field_18;
         v7->field_C = v9;
-        v7->field_4.x = v9 >> 16;
+        v7->spark_position.x = v9 >> 16;
 
         v11 = v10 + v7->field_10;
         v7->field_18 = v10;
         v7->field_10 = v11;
-        v7->field_4.y = v11 >> 16;
+        v7->spark_position.y = v11 >> 16;
 LABEL_13:
         v6 = 1;
         goto LABEL_14;
@@ -421,7 +421,7 @@
 
     if (signature == SIG_trpg )
         {
-        if ( field_8 <= 0 )
+        if ( position_in_sparks_arr <= 0 )
             return field_58 != 0 ? 2 : 0;
         else
             return 1;
@@ -1126,7 +1126,7 @@
      byte_4FAA00 = 1;
     if ( opponent_mastery == 0)
         {
-        if ( hand_full==0 )  //am_byte_4FAA77
+        if ( need_to_discard_card==0 )  //am_byte_4FAA77
             {
            for(int i = 0; i<10 ; ++i )
                 {
@@ -1142,9 +1142,6 @@
         }
     else if (( opponent_mastery == 1 )|| ( opponent_mastery == 2 ))
         {
-        v8 = player_num;
-        
-        v124 = player_num;
         player = &am_Players[player_num];
         enemy = &am_Players[(player_num + 1) % 2];
         all_player_cards_count = GetPlayerHandCardCount(player_num);
@@ -1152,48 +1149,48 @@
             {
             if ( i >= all_player_cards_count )
                 {
-                stru_4FA9B0[i].slot_index = -1;
-                stru_4FA9B0[i].card_power = -9999;
+                cards_power[i].slot_index = -1;
+                cards_power[i].card_power = -9999;
                 }
             else
                 {
-                stru_4FA9B0[i].slot_index = i;
-                stru_4FA9B0[i].card_power = 0;
+                cards_power[i].slot_index = i;
+                cards_power[i].card_power = 0;
                 }
             }
         for(int i = 0; i< all_player_cards_count ; ++i )
             {   
-               v12 = &pCards[am_Players[player_num].cards_at_hand[stru_4FA9B0[i].slot_index]];          
-               stru_4FA9B0[i].card_power = CalculateCardPower(player, enemy, v12, opponent_mastery-1);
+               v12 = &pCards[am_Players[player_num].cards_at_hand[cards_power[i].slot_index]];          
+               cards_power[i].card_power = CalculateCardPower(player, enemy, v12, opponent_mastery-1);
             }
 
             for (int j = all_player_cards_count - 1; j >= 0; --j )
                 {
                     for (int m=0; m<j; ++m )
                         {
-                        if ( stru_4FA9B0[m].card_power < stru_4FA9B0[m+1].card_power )
+                        if ( cards_power[m].card_power < cards_power[m+1].card_power )
                             {
-                            v56 = stru_4FA9B0[m].slot_index;
-                            v57 = stru_4FA9B0[m].card_power;
-                            stru_4FA9B0[m].slot_index = stru_4FA9B0[m+1].slot_index;
-                            stru_4FA9B0[m].card_power = stru_4FA9B0[m+1].card_power;
-                            stru_4FA9B0[m+1].slot_index = v56;
-                            stru_4FA9B0[m+1].card_power = v57;
+                            v56 = cards_power[m].slot_index;
+                            v57 = cards_power[m].card_power;
+                            cards_power[m].slot_index = cards_power[m+1].slot_index;
+                            cards_power[m].card_power = cards_power[m+1].card_power;
+                            cards_power[m+1].slot_index = v56;
+                            cards_power[m+1].card_power = v57;
                             }
                         }
                 }                           
             v59 = all_player_cards_count - 1;
-            if ( hand_full )
+            if ( need_to_discard_card )
                 {
                 if ( all_player_cards_count - 1 >= 0 )
                     {
-                    while ( !pCards[am_Players[player_num].cards_at_hand[stru_4FA9B0[v59].slot_index]].attack_or_defence )
+                    while ( !pCards[am_Players[player_num].cards_at_hand[cards_power[v59].slot_index]].can_be_discarded )
                         {
                         --v59;
                         if ( v59 < 0 )
                             return DiscardCard(player_num, v132);
                         }
-                    v132 = stru_4FA9B0[v59].slot_index;
+                    v132 = cards_power[v59].slot_index;
                     }
                 }
             else
@@ -1201,24 +1198,24 @@
                 v60 = 0;
                 if ( all_player_cards_count - 1 >= 0 )
                     {
-                    while ( !pCards[am_Players[player_num].cards_at_hand[stru_4FA9B0[v59].slot_index]].attack_or_defence )
+                    while ( !pCards[am_Players[player_num].cards_at_hand[cards_power[v59].slot_index]].can_be_discarded )
                         {
                         --v59;
                         if ( v59 < 0 )
                             goto LABEL_150;
                         }
-                    v132 = stru_4FA9B0[v59].slot_index;
+                    v132 = cards_power[v59].slot_index;
                     }
 LABEL_150:
-                if ( v130 > 0 )
+                if ( (all_player_cards_count - 1)> 0 )
                     {
-                    while ( !CanCardBePlayed(player_num, stru_4FA9B0[v60].slot_index) || stru_4FA9B0[v60].card_power < 0 )
+                    while ( !CanCardBePlayed(player_num, cards_power[v60].slot_index) || cards_power[v60].card_power < 0 )
                         {
                         ++v60;
-                        if ( v60 >= v130 )
+                        if ( v60 >= all_player_cards_count - 1 )
                             return DiscardCard(player_num, v132);
                         }
-                    return PlayCard(v8, stru_4FA9B0[v60].slot_index);
+                    return PlayCard(player_num, cards_power[v60].slot_index);
                     }
                 }
             return DiscardCard(player_num, v132);
@@ -1254,11 +1251,11 @@
         byte_4FAA24 = PlayerTurn(current_player_num);
         if ( GetPlayerHandCardCount(current_player_num) <= minimum_cards_at_hand )
           break;
-        hand_full = 1;
+        need_to_discard_card = 1;
         if ( pArcomageGame->field_F4 )
           goto LABEL_8;
       }
-      hand_full = 0;
+      need_to_discard_card = 0;
     }
     pArcomageGame->GameOver = IsGameOver();
     if ( !pArcomageGame->GameOver )
@@ -1348,8 +1345,7 @@
       am_Players[i].card_shift[j].x = 0;
       am_Players[i].card_shift[j].y = 0;
       }
-    }
-   
+    }  
   }
   strcpy(deckMaster.name, pDeckMaster);
   for (i=0, card_dispenser_counter=-2, card_id_counter=0; i<DECK_SIZE; ++i, ++card_dispenser_counter)
@@ -1391,11 +1387,9 @@
 //----- (0040A198) --------------------------------------------------------
 void FillPlayerDeck()
     {
- 
-  signed int v3; // eax@4
-  int v6; // edx@13
-  char v7; // eax@13
-  char card_taken_flags[DECK_SIZE]; // [sp+8h] [bp-6Ch]@1
+  signed int m;
+  int rand_deck_pos; 
+  char card_taken_flags[DECK_SIZE]; 
   int i,j;
 
   ArcomageGame::PlaySound(20);
@@ -1408,11 +1402,11 @@
     {
       if ( am_Players[i].cards_at_hand[j] > -1 )
       {
-        for (v3 = 0; v3<DECK_SIZE; ++v3)
+        for (m = 0; m<DECK_SIZE; ++m)
             {
-            if (deckMaster.cards_IDs[v3] == am_Players[i].cards_at_hand[j] && deckMaster.cardsInUse[v3] == 0)
+            if (deckMaster.cards_IDs[m] == am_Players[i].cards_at_hand[j] && deckMaster.cardsInUse[m] == 0)
                 {
-                    deckMaster.cardsInUse[v3] = 1;
+                    deckMaster.cardsInUse[m] = 1;
                     break;
                 }
             }
@@ -1423,14 +1417,12 @@
   for (i=0; i<DECK_SIZE; ++i)
   {
     do
-    {
-      v6 = rand() % DECK_SIZE;
-      v7 = card_taken_flags[v6];
-    }
-    while ( v7 == 1 );
-    card_taken_flags[v6]=1;
-    playDeck.cards_IDs[i]  = deckMaster.cards_IDs[v6];
-    playDeck.cardsInUse[i] = deckMaster.cardsInUse[v6];
+      rand_deck_pos = rand() % DECK_SIZE;
+    while (card_taken_flags[rand_deck_pos] == 1 );
+
+    card_taken_flags[rand_deck_pos]=1;
+    playDeck.cards_IDs[i]  = deckMaster.cards_IDs[rand_deck_pos];
+    playDeck.cardsInUse[i] = deckMaster.cardsInUse[rand_deck_pos];
   }
 
   deck_walk_index = 0;
@@ -1513,20 +1505,16 @@
 {
   am_Players[player_num].resource_bricks += quarry_bonus + am_Players[player_num].quarry_level;
   am_Players[player_num].resource_gems   += magic_bonus  + am_Players[player_num].magic_level;
-  am_Players[player_num].resource_beasts += zoo_bonus  + am_Players[player_num].zoo_level;
+  am_Players[player_num].resource_beasts += zoo_bonus    + am_Players[player_num].zoo_level;
 }
 
 
 //----- (0040A383) --------------------------------------------------------
 void TurnChange()
     {
-  int v0; // eax@4
-  int v1; // ecx@4
-  unsigned __int8 v2; // sf@4
-  unsigned __int8 v3; // of@4
-  int v4; // eax@6
-  char Dest[64]; // [sp+4h] [bp-64h]@4
-  RECT v6; // [sp+44h] [bp-24h]@6
+
+  char player_name[64]; // [sp+4h] [bp-64h]@4
+ // RECT v6; // [sp+44h] [bp-24h]@6
  
   ArcomageGame_stru1 v10; // [sp+54h] [bp-14h]@7
   POINT v11; // [sp+60h] [bp-8h]@4
@@ -1545,23 +1533,20 @@
       //nullsub_1();
    //   v11.x = 0;
    //   v11.y = 0;
-      strcpy(Dest,"The Next Player is: ");//"Ρλεδ"
+      strcpy(player_name,"The Next Player is: ");//"Ρλεδ"
      // v0 = 0;
       v11.y = 200;
       v11.x = 320; // - 12 * v0 / 2;
-      pPrimaryWindow_draws_text(-1, Dest, &v11);
+      pPrimaryWindow_draws_text(-1, player_name, &v11);
       am_byte_4FAA75 = 1;
-      v1 = ++current_player_num;
-      if ( v1 >= 2  )
-      {
-        v1 = 0;
+      ++current_player_num;
+      if ( current_player_num >= 2  )
         current_player_num = 0;
-      }
-      strcpy(Dest, am_Players[v1].pPlayerName);
+      strcpy(player_name, am_Players[current_player_num].pPlayerName);
      // v4 = 0;
       v11.y = 260;
       v11.x = 320;// - 12 * v4 / 2;
-      pPrimaryWindow_draws_text(-1, Dest, &v11);
+      pPrimaryWindow_draws_text(-1, player_name, &v11);
      /* v6.left = 0;
       v6.right = 640;
       v6.top = 0;
@@ -1570,28 +1555,25 @@
       CallRenderPresent();
       //nullsub_1();
       while ( 1 )
-      {
-        while ( 1 )
-        {
+      {  
           while ( !ArcomageGame::MsgLoop(20, &v10) )
             ;
-          if ( v10.field_0 != 1 )
-            break;
-          if ( v10.field_4 )
-            goto LABEL_13;
-          //nullsub_1();
-        }
-        if ( v10.field_0 > 4 )
-        {
-          if ( v10.field_0 <= 8 )
-            goto LABEL_13;
-          if ( v10.field_0 == 10 )
-            break;
-        }
+          if ( v10.field_0 == 1 )
+              {
+              if ( v10.field_4 )
+                  break;
+              //nullsub_1();
+              continue;
+              }
+           if (( v10.field_0 > 4 )&& ( v10.field_0 <= 8 )) 
+               break;
+           if ( v10.field_0 == 10 )
+               {
+               pArcomageGame->field_F4 = 1;
+               byte_4FAA74 = 1;
+               break;
+               }
       }
-      pArcomageGame->field_F4 = 1;
-      byte_4FAA74 = 1;
-LABEL_13:
       /*  v11.x = 0;
       v11.y = 0;
       v6.left = 0;
@@ -1643,13 +1625,13 @@
   int v10[4]; // [sp+80h] [bp-30h]@69
   POINT pTargetXY; // [sp+90h] [bp-20h]@75
   ArcomageGame_stru1 a2; // [sp+98h] [bp-18h]@8
-  int v13; // [sp+A4h] [bp-Ch]@1
+  int animation_stage; // [sp+A4h] [bp-Ch]@1
   char v15; // [sp+AEh] [bp-2h]@63
-  char v16; // [sp+AFh] [bp-1h]@1
+  bool break_loop; // [sp+AFh] [bp-1h]@1
 
   uCardID = -1;
-  v16 = 0;
-  v13 = 20;
+  break_loop = false;
+  animation_stage = 20;
   byte_4FAA00 = 0;
   dword_4FAA68 = 0;
   amuint_4FAA38 = 10;
@@ -1667,7 +1649,7 @@
     
     pArcomageGame->event_timer_time = (unsigned int )pEventTimer->Time();
     if ( pArcomageGame->field_F4 )
-      v16 = 1;
+      break_loop = 1;
     ArcomageGame::MsgLoop(0, &a2);
     switch ( a2.field_0 )
     {
@@ -1676,7 +1658,7 @@
         {
           pAudioPlayer->StopChannels(-1, -1);
           dword_4FAA68 = 0;
-          v16 = 1;
+          break_loop = true;
           pArcomageGame->field_F4 = 1;
         }
         break;
@@ -1686,12 +1668,13 @@
       case 10:
         pAudioPlayer->StopChannels(-1, -1);
         byte_4FAA74 = 1;
-        v16 = 1;
+        break_loop = true;
         pArcomageGame->field_F4 = 1;
         break;
     }
 
-    if (am_Players[current_player_num].IsHisTurn != 1 && !byte_4FAA00 && !byte_4FAA2E && !byte_4FAA2D )
+    if (am_Players[current_player_num].IsHisTurn != 1 && 
+        !byte_4FAA00 && !byte_4FAA2E && !byte_4FAA2D )
     {
       if ( am_byte_4FAA75 )
         am_byte_4FAA76 = 1;
@@ -1710,13 +1693,13 @@
         {
           byte_4FAA2D = 0;
           amuint_4FAA38 = 10;
-          v16 = 0;
+          break_loop = false;
         }
       }
       if ( byte_4FAA2E )
       {
-        --v13;
-        if ( v13 < 0 )
+        --animation_stage;
+        if ( animation_stage < 0 )
         {
           if ( dword_4FAA68 > 1 )
           {
@@ -1725,16 +1708,16 @@
           }
           else
           {
-            v16 = 1;
+            break_loop = true;
           }
           byte_4FAA2E = 0;
-          v13 = 20;
+          animation_stage = 20;
         }
       }
     }
     else
     {
-      if ( hand_full )
+      if ( need_to_discard_card )
       {
         if ( a2.field_0 == 7 && DiscardCard(player_num, current_card_slot_index) )
         {
@@ -1743,7 +1726,7 @@
           if ( dword_4FAA64 > 0 )
           {
             --dword_4FAA64;
-            hand_full = GetPlayerHandCardCount(player_num) > minimum_cards_at_hand;
+            need_to_discard_card = GetPlayerHandCardCount(player_num) > minimum_cards_at_hand;
           }
           byte_4FAA2E = 1;
         }
@@ -1754,7 +1737,7 @@
           if ( dword_4FAA64 > 0 )
           {
             --dword_4FAA64;
-            hand_full = GetPlayerHandCardCount(player_num) > minimum_cards_at_hand;
+            need_to_discard_card = GetPlayerHandCardCount(player_num) > minimum_cards_at_hand;
           }
           byte_4FAA2E = 1;
         }
@@ -1817,12 +1800,12 @@
     //}
     if ( dword_4FABB8 != DrawCardsRectangles(player_num) )
     {
-    dword_4FABB8 = DrawCardsRectangles(player_num);
-    pArcomageGame->field_F6 = 1;
+        dword_4FABB8 = DrawCardsRectangles(player_num);
+        pArcomageGame->field_F6 = 1;
     }
     if ( pArcomageGame->field_F6 )
     {
-      DrawGameUI(v13);
+      DrawGameUI(animation_stage);
       DoBlt_Copy(pArcomageGame->pBackgroundPixels);
       pArcomageGame->field_F6 = 0;
     }
@@ -1837,18 +1820,18 @@
       am_BeginScene(pArcomageGame->pBackgroundPixels, -1, 1);
       Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
       am_EndScene();
-      DrawGameUI(v13);
+      DrawGameUI(animation_stage);
       pRenderer->Present();
       pArcomageGame->field_F9 = 0;
     }
   }
-  while ( !v16 );
+  while ( !break_loop );
   return dword_4FAA68 > 0;
 }
 
 
 //----- (0040A9AF) --------------------------------------------------------
-void DrawGameUI( int a1 )
+void DrawGameUI( int animation_stage )
     {
 
   am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1);
@@ -1863,54 +1846,41 @@
   am_EndScene();
 
   am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1);
-  DrawCardAnimation(a1);
+  DrawCardAnimation(animation_stage);
 
   for( int i=0; i<10; ++i)
       {
-      if (array_4FABD0[i].field_0)
-          array_4FABD0[i].field_40->_40E133();
+      if (array_4FABD0[i].have_effect)
+          array_4FABD0[i].field_40->DrawEffect();
       }
   current_card_slot_index = DrawCardsRectangles(current_player_num);
-  am_40AA4E();
+  DrawSparks();
   am_EndScene();
 }
 
 //----- (0040AA4E) --------------------------------------------------------
-void am_40AA4E()
+void DrawSparks()
     {
-  int v5; // [sp-4h] [bp-2Ch]@4
-  unsigned int v7;
-  int v8; // [sp+14h] [bp-14h]@10
-  int v9; // [sp+18h] [bp-10h]@10
-  RECT pXYZW;
-
-  v9 = 0x0000FF00;
-  v8 = 0x000000FF;
+  int rgb_pixel_color; // [sp-4h] [bp-2Ch]@4
+  unsigned int pixel_color;
 
   for (int i=0; i<10; ++i)
       {
-        if(array_4FABD0[i].field_0 && (array_4FABD0[i].field_40->_40E2A7()==2))
+        if(array_4FABD0[i].have_effect && (array_4FABD0[i].field_40->_40E2A7()==2))
             {
-
-            v5 = v9;
-            if ( !array_4FABD0[i].field_1 )
-                v5 = v8;
-
-             v7 = R8G8B8_to_TargetFormat(v5);
+            rgb_pixel_color = 0x0000FF00;
+            if ( !array_4FABD0[i].effect_sign )
+                rgb_pixel_color =  0x000000FF;
+
+             pixel_color = R8G8B8_to_TargetFormat(rgb_pixel_color);
              for(int j=0; j<150; ++j )
                  {
-                 if (array_4FABD0[i].field_44[j].field_0 > 0)
+                 if (array_4FABD0[i].effect_sparks[j].have_spark > 0)
                      {
                       if (j%2)
-                           SetPixel(&array_4FABD0[i].field_44[j].field_4, v7);
+                           SetPixel(&array_4FABD0[i].effect_sparks[j].spark_position, pixel_color);
                       else
-                          {
-                          pXYZW.left = array_4FABD0[i].field_44[j].field_4.x;
-                          pXYZW.right = pXYZW.left + 2;
-                          pXYZW.top = array_4FABD0[i].field_44[j].field_4.y;
-                          pXYZW.bottom = pXYZW.top + 2;
-                          DrawRect(&pXYZW, v7, 1);
-                          }
+                          SetPixel2sq(&array_4FABD0[i].effect_sparks[j].spark_position, pixel_color);
                      }
                  }
             }
@@ -1925,8 +1895,8 @@
   RECT pSrcRect; // [sp+Ch] [bp-18h]@1
   POINT pTargetXY; // [sp+1Ch] [bp-8h]@1
 //resources rectangles
+  pSrcRect.left    = 765;
   pSrcRect.top     = 0;
-  pSrcRect.left    = 765;
   pSrcRect.right   = 843;
   pSrcRect.bottom  = 216;
 
@@ -1940,8 +1910,8 @@
 
   //players name rectangle
   pSrcRect.left   = 283;
+  pSrcRect.top    = 166;
   pSrcRect.right  = 361;
-  pSrcRect.top    = 166;
   pSrcRect.bottom = 190;
   pTargetXY.x = 8;
   pTargetXY.y = 13;
@@ -1953,8 +1923,8 @@
 
   //tower height rectangle
   pSrcRect.left   = 234;
+  pSrcRect.top    = 166;
   pSrcRect.right  = 283;
-  pSrcRect.top    = 166;
   pSrcRect.bottom = 190;
   pTargetXY.x = 100;
   pTargetXY.y = 296;
@@ -1965,9 +1935,9 @@
   Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2);
 
   //wall height rectangle
-  pSrcRect.left   = 192;
+  pSrcRect.left   = 192; 
+  pSrcRect.top    = 166;
   pSrcRect.right  = 234;
-  pSrcRect.top    = 166;
   pSrcRect.bottom = 190;
   pTargetXY.x = 168;
   pTargetXY.y = 296;
@@ -1986,7 +1956,7 @@
   char text_buff[32]; // [sp+Ch] [bp-28h]@2
   POINT text_position; // [sp+2Ch] [bp-8h]@2
 
-  if ( hand_full )
+  if ( need_to_discard_card )
   {
     strcpy(text_buff, pGlobalTXT_LocalizationStrings[266]);// DISCARD A CARD
     text_position.x = 320 - pArcomageGame->pfntArrus->GetLineWidth(text_buff) / 2;
@@ -2028,7 +1998,7 @@
   pPrimaryWindow_draws_text(-1, text_buff, &text_position);
 
   res_value = am_Players[0].quarry_level;
-  if ( byte_4E185E )
+  if ( use_start_bonus )
     res_value =am_Players[0].quarry_level + quarry_bonus;
   intToString(res_value, text_buff);
   text_position.x = 14;// - 6 * 0 / 2;
@@ -2036,7 +2006,7 @@
   DrawPlayerLevels(-1, text_buff, &text_position);
 
   res_value = am_Players[1].quarry_level;
-  if ( byte_4E185E )
+  if ( use_start_bonus )
     res_value = am_Players[1].quarry_level + quarry_bonus;
   intToString(res_value, text_buff);
 //  v2 = 0;
@@ -2045,7 +2015,7 @@
   DrawPlayerLevels(-1, text_buff, &text_position);
 
   res_value = am_Players[0].magic_level;
-  if ( byte_4E185E )
+  if ( use_start_bonus )
     res_value = am_Players[0].magic_level + magic_bonus;    
   intToString(res_value, text_buff);
  // v4 = 0;
@@ -2054,8 +2024,8 @@
   DrawPlayerLevels(-1, text_buff, &text_position);
 
   res_value = am_Players[1].magic_level;
-  if ( byte_4E185E )
-    res_value = am_Players[1].magic_level+magic_bonus;
+  if ( use_start_bonus )
+    res_value = am_Players[1].magic_level + magic_bonus;
   intToString(res_value, text_buff);
  // v6 = 0;
   text_position.y = 164;
@@ -2063,7 +2033,7 @@
   DrawPlayerLevels(-1, text_buff, &text_position);
 
   res_value = am_Players[0].zoo_level;
-  if ( byte_4E185E )
+  if ( use_start_bonus )
     res_value = am_Players[0].zoo_level + zoo_bonus;
   intToString(res_value, text_buff);
  // v8 = 0;
@@ -2072,7 +2042,7 @@
   DrawPlayerLevels(-1, text_buff, &text_position);
 
   res_value = am_Players[1].zoo_level;
-  if ( byte_4E185E )
+  if ( use_start_bonus )
     res_value =  am_Players[1].zoo_level + zoo_bonus;
   intToString(res_value, text_buff);
  // v10 = 0;
@@ -2648,17 +2618,7 @@
             if (shown_cards[v17].uCardId==-1)
                 break;
             }
-        /* v17 = 0;
-        do
-        {
-        if ( v7->uCardId == -1 )
-        break;
-        ++v7;
-        ++v17;
-        }
-        while ( v7 < &dword_4FABB8 );*/
-           // v26 = 32 * v17;
-
+        
             amuint_4FAA54_blt_xy.x = (shown_cards[v17].field_8.x - 272) / 5;
             amuint_4FAA54_blt_xy.y = (shown_cards[v17].field_8.y - 173) / 5;
             pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW);
@@ -2907,7 +2867,7 @@
     }
   }
 
-  if ( pCards[am_Players[player_num].cards_at_hand[i]].attack_or_defence) 
+  if ( pCards[am_Players[player_num].cards_at_hand[i]].can_be_discarded) 
   {
     ArcomageGame::PlaySound(22);
     v8 = GetPlayerHandCardCount(current_player_num);
@@ -2927,21 +2887,15 @@
     pArcomageGame->field_F6 = 1;
     amuint_4FAA54_blt_xy.x = (shown_cards[v12].field_8.x - v10) / 10;
     amuint_4FAA54_blt_xy.y = (shown_cards[v12].field_8.y - 327) / 10;
-
     uCardID = am_Players[player_num].cards_at_hand[i];
     am_Players[player_num].cards_at_hand[i] = -1;
-    hand_full = 0;
+    need_to_discard_card = 0;
     return true;
   }
   else
     return false;
 }
-// 4FAA75: using guessed type char am_byte_4FAA75;
-// 4FAA77: using guessed type char am_byte_4FAA77;
-// 4FAA78: using guessed type int amuint_4FAA78[];
-// 4FAA80: using guessed type int amuint_4FAA80[];
-// 4FAA84: using guessed type int amuint_4FAA84[];
-// 4FABB8: using guessed type int dword_4FABB8;
+
 
 //----- (0040BE0E) --------------------------------------------------------
 bool PlayCard( int player_num, signed int card_slot_num )
@@ -2950,25 +2904,25 @@
   int v3; // ebp@1
   int v4; // ecx@2
   ArcomagePlayer *v5; // esi@2
-  int v6; // edi@2
+  int card_index; // edi@2
   int v7; // eax@2
   int v8; // ebx@8
-  int v9; // eax@8
+  int cards_at_hand; // eax@8
   int v10; // ebx@8
   int v11; // ebp@8
   int v12; // ecx@8
   int v13; // eax@8
-  ArcomageCard *v14; // eax@8
+  ArcomageCard *pCard; // eax@8
   int v15; // ecx@8
   int v16; // ecx@8
 
   if ( card_slot_num <= -1 )
     return false;
+
   v4 = 0;
-
-  for (v6=0; v6<10; ++v6)
+  for (card_index=0; card_index<10; ++card_index)
   {
-    if ( am_Players[player_num].cards_at_hand[v6] != -1 )
+    if ( am_Players[player_num].cards_at_hand[card_index] != -1 )
     {
       if ( card_slot_num == v4 )
         break;
@@ -2976,28 +2930,29 @@
     }
   }
 
-  if (CanCardBePlayed(player_num, v6) )
+  if (CanCardBePlayed(player_num, card_index) )
   {
     ArcomageGame::PlaySound(23);
-    v9 = GetPlayerHandCardCount(current_player_num);
-  //  v10 = 188 * v8 + 8 * v6;
-  //  v11 = v6 + 47 * v3;
+    cards_at_hand = GetPlayerHandCardCount(current_player_num);
     pArcomageGame->field_F6 = 1;
-    v12 =  am_Players[player_num].card_shift[v6].x + (640 - 96 * v9) / (v9 + 1)+ 96 * v6 +(640 - 96 * v9) / (v9 + 1);
+    v12 =  am_Players[player_num].card_shift[card_index].x + 
+         (640 - 96 * cards_at_hand) / (cards_at_hand + 1)+ 
+         96 * card_index ;
+        
   //  v13 = *(int *)((char *)&am_Players[0].arr_6C[0][1] + v10) + 327;
     amuint_4FAA5C_blt_xy.x = v12;//v12;
-    amuint_4FAA5C_blt_xy.y = am_Players[player_num].card_shift[v6].y + 327;//v13;
+    amuint_4FAA5C_blt_xy.y = am_Players[player_num].card_shift[card_index].y + 327;//v13;
 
     amuint_4FAA54_blt_xy.x = (272 - v12) / 5;
     amuint_4FAA54_blt_xy.y = -30;
 
-    v14 = &pCards[am_Players[player_num].cards_at_hand[v6]];
-    am_Players[player_num].resource_bricks -= v14->needed_bricks;
-    am_Players[player_num].resource_beasts -= v14->needed_beasts;
-    am_Players[player_num].resource_gems   -= v14->needed_gems;
-    played_card_id = am_Players[player_num].cards_at_hand[v6];
-    am_Players[player_num].cards_at_hand[v6] = -1;
-    return true;;
+    pCard = &pCards[am_Players[player_num].cards_at_hand[card_index]];
+    am_Players[player_num].resource_bricks -= pCard->needed_bricks;
+    am_Players[player_num].resource_beasts -= pCard->needed_beasts;
+    am_Players[player_num].resource_gems   -= pCard->needed_gems;
+    played_card_id = am_Players[player_num].cards_at_hand[card_index];
+    am_Players[player_num].cards_at_hand[card_index] = -1;
+    return true;
   }
   else
    return false;
@@ -3153,76 +3108,87 @@
             v5 = player->quarry_level;
             v7 = __OFSUB__(v5, enemy->quarry_level);
             v6 = v5 - enemy->quarry_level < 0;
-            goto LABEL_18;
+            v18 = v6 ^ v7;
+            goto LABEL_25;
         case 3:
             v8 = player->magic_level;
             v7 = __OFSUB__(v8, enemy->magic_level);
             v6 = v8 - enemy->magic_level < 0;
-            goto LABEL_18;
+            v18 = v6 ^ v7;
+            goto LABEL_25;
         case 4:
             v9 = player->zoo_level;
             v7 = __OFSUB__(v9, enemy->zoo_level);
             v6 = v9 - enemy->zoo_level < 0;
-            goto LABEL_18;
+            v18 = v6 ^ v7;
+            goto LABEL_25;
         case 5:
             v10 = player->quarry_level == enemy->quarry_level;
-            goto LABEL_21;
+            v18 = v10;
+            goto LABEL_25;
         case 6:
             v10 = player->magic_level == enemy->magic_level;
-            goto LABEL_21;
+            v18 = v10;
+            goto LABEL_25;
         case 7:
             v10 = player->zoo_level == enemy->zoo_level;
-            goto LABEL_21;
+            v18 = v10;
+            goto LABEL_25;
         case 8:
             v11 = player->quarry_level;
             v14 = __OFSUB__(v11, enemy->quarry_level);
             v12 = v11 == enemy->quarry_level;
             v13 = v11 - enemy->quarry_level < 0;
-            goto LABEL_24;
+            v18 = !((v13 ^ v14) | v12);
+            goto LABEL_25;
         case 9:
             v15 = player->magic_level;
             v14 = __OFSUB__(v15, enemy->magic_level);
             v12 = v15 == enemy->magic_level;
             v13 = v15 - enemy->magic_level < 0;
-            goto LABEL_24;
+            v18 = !((v13 ^ v14) | v12);
+            goto LABEL_25;
         case 10:
             v16 = player->zoo_level;
             v14 = __OFSUB__(v16, enemy->zoo_level);
             v12 = v16 == enemy->zoo_level;
             v13 = v16 - enemy->zoo_level < 0;
-            goto LABEL_24;
+            v18 = !((v13 ^ v14) | v12);
+            goto LABEL_25;
         case 11:
             v10 = player->wall_height == 0;
-            goto LABEL_21;
+            v18 = v10;
+            goto LABEL_25;
         case 12:
             v17 = player->wall_height == 0;
-            goto LABEL_15;
+            v18 = !v17;
+            goto LABEL_25;
         case 13:
             v10 = enemy->wall_height == 0;
-            goto LABEL_21;
+            v18 = v10;
+            goto LABEL_25;
         case 14:
             v17 = enemy->wall_height == 0;
-LABEL_15:
             v18 = !v17;
             goto LABEL_25;
         case 15:
             v19 = player->wall_height;
             v7 = __OFSUB__(v19, enemy->wall_height);
             v6 = v19 - enemy->wall_height < 0;
-            goto LABEL_18;
+            v18 = v6 ^ v7;
+            goto LABEL_25;
         case 16:
             v20 = player->tower_height;
             v7 = __OFSUB__(v20, enemy->tower_height);
             v6 = v20 - enemy->tower_height < 0;
-LABEL_18:
             v18 = v6 ^ v7;
             goto LABEL_25;
         case 17:
             v10 = player->wall_height == enemy->wall_height;
-            goto LABEL_21;
+            v18 = v10;
+            goto LABEL_25;
         case 18:
             v10 = player->tower_height == enemy->tower_height;
-LABEL_21:
             v18 = v10;
             goto LABEL_25;
         case 19:
@@ -3230,13 +3196,13 @@
             v14 = __OFSUB__(v21, enemy->wall_height);
             v12 = v21 == enemy->wall_height;
             v13 = v21 - enemy->wall_height < 0;
-            goto LABEL_24;
+            v18 = !((v13 ^ v14) | v12);
+            goto LABEL_25;
         case 20:
             v22 = player->tower_height;
             v14 = __OFSUB__(v22, enemy->tower_height);
             v12 = v22 == enemy->tower_height;
             v13 = v22 - enemy->tower_height < 0;
-LABEL_24:
             v18 = !((v13 ^ v14) | v12);
 LABEL_25:
             if ( v18 )
@@ -3244,7 +3210,7 @@
             goto LABEL_231;
         default:
 LABEL_26:
-            v23 = pCard->can_draw_extra_card;
+            v23 = pCard->draw_extra_card_count;
             v24 = 0;
             dword_4FAA68 = v23 + (pCard->field_30 == 1);
             dword_4FAA64 = v23;
@@ -3255,10 +3221,10 @@
                     GetNextCardFromDeck(player_num);
                     ++v24;
                     }
-                    while ( v24 < pCard->can_draw_extra_card );
+                    while ( v24 < pCard->draw_extra_card_count );
                 }
 
-            hand_full = GetPlayerHandCardCount(player_num) > minimum_cards_at_hand;
+            need_to_discard_card = GetPlayerHandCardCount(player_num) > minimum_cards_at_hand;
 
 
             APPLY_TO_PLAYER(player, enemy, quarry_level,    pCard->to_player_quarry_lvl, quarry_p);
@@ -3321,7 +3287,7 @@
                     while ( v104 < pCard->can_draw_extra_card2 );
                 }
 
-            hand_full = GetPlayerHandCardCount(player_num) > minimum_cards_at_hand;
+            need_to_discard_card = GetPlayerHandCardCount(player_num) > minimum_cards_at_hand;
 
             APPLY_TO_PLAYER(player, enemy, quarry_level,    pCard->to_player_quarry_lvl2, quarry_p);
             APPLY_TO_PLAYER(player, enemy, magic_level,     pCard->to_player_magic_lvl2,  magic_p);
@@ -3660,7 +3626,7 @@
 
 
 //----- (0040D2B4) --------------------------------------------------------
-int am_40D2B4( POINT* a1, int a2 )
+int am_40D2B4( POINT* startXY, int effect_value )
     {
   int v2; // ebp@1
   POINT *v3; // edi@1
@@ -3671,14 +3637,14 @@
  
 
   v11 = 0;
-  v2 = a2;
-  v3 = a1;
-  while ( array_4FABD0[v11].field_0 )
+  v2 = effect_value;
+
+  while ( array_4FABD0[v11].have_effect )
       {
       result = array_4FABD0[v11].field_40->_40E2A7();
       if ( !result )
           {
-          array_4FABD0[v11].field_0 = 0;
+          array_4FABD0[v11].have_effect = 0;
           --v11;
           }
       ++v11;
@@ -3686,20 +3652,20 @@
           return result;
       }
   v6 = v11;
-  array_4FABD0[v11].field_0 = 1;
-  if ( v2 <= 0 )
+  array_4FABD0[v11].have_effect = 1;
+  if ( effect_value <= 0 )
       {
-      array_4FABD0[v6].field_1 = 0;
-      v2 = -v2;
+      array_4FABD0[v6].effect_sign = 0;
+      effect_value = -effect_value;
       }
   else
       {
-      array_4FABD0[v6].field_1 = 1;
+      array_4FABD0[v6].effect_sign = 1;
       }
-  array_4FABD0[v6].field_4.field_0 = v3->x - 20;
-  array_4FABD0[v6].field_4.field_8 = v3->x + 20;
-  array_4FABD0[v6].field_4.field_4 = v3->y - 20;
-  array_4FABD0[v6].field_4.field_C = v3->y + 20;
+  array_4FABD0[v6].field_4.effect_area.left = startXY->x - 20;
+  array_4FABD0[v6].field_4.effect_area.right = startXY->x + 20;
+  array_4FABD0[v6].field_4.effect_area.top = startXY->y - 20;
+  array_4FABD0[v6].field_4.effect_area.bottom = startXY->y + 20;
   array_4FABD0[v6].field_4.field_10 = -60;
   array_4FABD0[v6].field_4.field_14 = 60;
   array_4FABD0[v6].field_4.field_18 = 180;
@@ -3710,17 +3676,17 @@
   array_4FABD0[v6].field_4.field_2Cf = 8.0;
   array_4FABD0[v6].field_4.field_30 = 5;
   array_4FABD0[v6].field_4.field_34 = 15;
-  array_4FABD0[v6].field_4.field_38 = &array_4FABD0[v6].field_44[0];
+  array_4FABD0[v6].field_4.sparks_array = &array_4FABD0[v6].effect_sparks[0];
   v8 = array_4FABD0[v6].field_40;
-  v8->_40E01A(&array_4FABD0[v6].field_4);
-  if ( 10 * v2 > 150 )
-      v2 = 15;
+  v8->StartFill(&array_4FABD0[v6].field_4);
+  if ( 10 * effect_value > 150 )
+      effect_value = 15;
 
   if ( v8->signature != SIG_trpg )
     return 2;
   if ( !v8->field_59 )
     return 3;
-  v8->field_8 = 10 * v2;
+  v8->position_in_sparks_arr = 10 * effect_value;
   v8->field_30 = 0.0;
   v8->field_58 = 0;
   v8->field_44 = 0;
@@ -3728,7 +3694,7 @@
   v8->field_48 = 0;
   v8->field_50 = 0;
   for (int i=0; i<v8->field_4; ++i)
-      v8->field_54[i].field_0=0;
+      v8->field_54[i].have_spark=0;
   return 0;
 }
 
@@ -4039,9 +4005,8 @@
   for (int i=0; i<12; ++i)
     am_sounds[i] = pSoundList->LoadSound(v4++, 0);
 
-
   for (int i=0; i<10; ++i)
-     array_4FABD0[i].field_40->Ctor(&array_4FABD0[i].field_40);
+     stru272_stru0::Ctor(&array_4FABD0[i].field_40);
   
   current_card_slot_index = -1;
   amuint_4FAA4C = -1;
@@ -4050,7 +4015,7 @@
   byte_4FAA2C = 0;
   byte_505880 = 0;
   dword_4FAA70 = 0;
-  hand_full = 0;
+  need_to_discard_card = 0;
   SetStartGameData();
   InitalHandsFill();
   //nullsub_1();
@@ -4071,10 +4036,6 @@
 }
 
 
-
-
-
-
 //----- (00409BE8) --------------------------------------------------------
 void SetStartConditions()
 {
@@ -4110,7 +4071,7 @@
 
 
 //----- (0040DB27) --------------------------------------------------------
-void __fastcall DrawRect(RECT *pXYZW, unsigned __int16 uColor, char bSolidFill)
+void DrawRect( RECT *pXYZW, unsigned __int16 uColor, char bSolidFill )
     {
     RECT *v3; // esi@1
 
@@ -4132,6 +4093,23 @@
     pRenderer->EndScene();
     }
 
+void SetPixel2sq( POINT *pTargetXY, unsigned __int16 uColor )
+    {
+    pRenderer->BeginScene();
+    if ( pRenderer->uNumSceneBegins )
+        {
+        int xVal = pTargetXY->x;
+        int yVal = pTargetXY->y;
+        if ( xVal >= 0 && xVal <= 639 && yVal >= 0 && yVal <= 479)
+            {
+            pRenderer->pTargetSurface[xVal + pRenderer->uTargetSurfacePitch * yVal] = uColor;
+            pRenderer->pTargetSurface[xVal+1 + pRenderer->uTargetSurfacePitch * yVal] = uColor;
+            pRenderer->pTargetSurface[xVal + pRenderer->uTargetSurfacePitch * (yVal+1)] = uColor;
+            pRenderer->pTargetSurface[xVal+1 + pRenderer->uTargetSurfacePitch * (yVal+1)] = uColor;
+            }
+        pRenderer->EndScene();
+        }
+    }
 
 //----- (0040DBD3) --------------------------------------------------------
 void SetPixel( POINT *pTargetXY, unsigned __int16 uColor )
@@ -4151,9 +4129,9 @@
 
 
 //----- (0040DDB1) --------------------------------------------------------
-int __fastcall rand_interval(int a, int b)
+int rand_interval( int min, int max )
     {
-    return a + rand() % (b - a + 1);
+    return min + rand() % (max - min + 1);
     }
 
 
--- a/Arcomage.h	Wed Jun 12 21:07:34 2013 +0200
+++ b/Arcomage.h	Thu Jun 13 00:56:22 2013 +0400
@@ -38,10 +38,10 @@
   char needed_bricks;
   char needed_gems;
   char needed_beasts;
-  char attack_or_defence;
+  char can_be_discarded;
   int  compare_param;
   char field_30;
-  char can_draw_extra_card;
+  char draw_extra_card_count;
   char to_player_quarry_lvl;
   char to_player_magic_lvl;
   char to_player_zoo_lvl;
@@ -184,8 +184,8 @@
   char field_F4;
   char GameOver;
   char field_F6;
-  char field_F7;
-  char field_F8;
+  char prev_mouse_left;
+  char prev_mouse_right;
   char field_F9;
   char bGameInProgress;
 };
@@ -202,8 +202,8 @@
 #pragma pack(push, 1)
 struct stru272_stru1
 {
-  int field_0;
-  POINT field_4;
+  int have_spark;
+  POINT spark_position;
   int field_C;
   int field_10;
   int field_14;
@@ -215,10 +215,11 @@
 #pragma pack(push, 1)
 struct stru272_stru2
 {
-  int field_0;
-  int field_4;
-  int field_8;
-  int field_C;
+/*int field_0;
+int field_4;
+int field_8;
+int field_C;*/
+  RECT effect_area;
   int field_10;
   int field_14;
   int field_18;
@@ -229,7 +230,7 @@
   float field_2Cf;
   int field_30;
   int field_34;
-  stru272_stru1* field_38;
+  stru272_stru1* sparks_array;
 };
 #pragma pack(pop)
 
@@ -240,14 +241,14 @@
 {
   static void Ctor(stru272_stru0 **a1);
   int Dtor();
-  int _40E01A(stru272_stru2* a2);
+  int StartFill(stru272_stru2* a2);
   int Empty(char a2, char a3);
-  int _40E133();
+  int DrawEffect();
   int _40E2A7();
 
   int signature;
   int field_4;
-  int field_8;
+  int position_in_sparks_arr;
   int field_C;
   int field_10;
   int field_14;
@@ -289,13 +290,13 @@
 #pragma pack(push, 1)
 struct stru272
 {
-  char field_0;
-  char field_1;
+  char have_effect;
+  char effect_sign;
   char _pad_2;
   char _pad_3;
   stru272_stru2 field_4;
   stru272_stru0 *field_40;
-  stru272_stru1 field_44[150];
+  stru272_stru1 effect_sparks[150];
 };
 #pragma pack(pop)
 
--- a/mm7_3.cpp	Wed Jun 12 21:07:34 2013 +0200
+++ b/mm7_3.cpp	Thu Jun 13 00:56:22 2013 +0400
@@ -16,7 +16,7 @@
 #include "Mouse.h"
 #include "Keyboard.h"
 #include "stru6.h"
-
+#include "FactionTable.h"
 #include "MapInfo.h"
 #include "Game.h"
 #include "GUIWindow.h"
@@ -14792,8 +14792,9 @@
 				if ( target_pid_type == OBJECT_Actor )
 				{
 					v36 = v75.uDistance;
-					v37 = (unsigned __int8)*(&byte_5C8D1A[89 * (pActor->pMonsterInfo.uID - 1) / 3]
-						+ (pActors[PID_ID(target_pid)].pMonsterInfo.uID - 1) / 3);
+					//v37 = (unsigned __int8)*(&byte_5C8D1A[89 * (pActor->pMonsterInfo.uID - 1) / 3]
+					//	+ (pActors[PID_ID(target_pid)].pMonsterInfo.uID - 1) / 3);
+                    v37 =pFactionTable->relations[(pActor->pMonsterInfo.uID-1) / 3 + 1][(pActors[PID_ID(target_pid)].pMonsterInfo.uID - 1) / 3 + 1];
 				}
 				else
 				{
--- a/mm7_5.cpp	Wed Jun 12 21:07:34 2013 +0200
+++ b/mm7_5.cpp	Thu Jun 13 00:56:22 2013 +0400
@@ -17,7 +17,8 @@
 #include "Keyboard.h"
 #include "GammaControl.h"
 #include "stru11.h"
-
+#include "mm7_data.h"
+#include "FactionTable.h"
 #include "Vis.h"
 #include "mm7.h"
 #include "Game.h"
@@ -6933,7 +6934,8 @@
           v20 = 0;
         }
         if (PID_TYPE(v22) == OBJECT_Actor)
-          v10 = (unsigned __int8)*(&byte_5C8D1A[89 * (pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID - 1) / 3] + (v5->pMonsterInfo.uID - 1) / 3);
+          //v10 = (unsigned __int8)*(&byte_5C8D1A[89 * (pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID - 1) / 3] + (v5->pMonsterInfo.uID - 1) / 3);
+          v10 = pFactionTable->relations[(pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID) / 3 + 1][(v5->pMonsterInfo.uID - 1) / 3 + 1];
         else
           v10 = 4;
         if ( v10 == 1 )
--- a/mm7_data.cpp	Wed Jun 12 21:07:34 2013 +0200
+++ b/mm7_data.cpp	Thu Jun 13 00:56:22 2013 +0400
@@ -1137,7 +1137,7 @@
 char *pSkillDescTXT_Raw;
 
 struct FactionTable *pFactionTable;
-std::array<char, 777> byte_5C8D1A; // weak
+//std::array<char, 777> byte_5C8D1A; // weak
 
 std::array<char, 777> byte_5E4C15; // weak
 std::array<char *, 14> pSomeItemsNames;
--- a/mm7_data.h	Wed Jun 12 21:07:34 2013 +0200
+++ b/mm7_data.h	Thu Jun 13 00:56:22 2013 +0400
@@ -778,7 +778,7 @@
 extern char *pStatsTXT_Raw;
 extern char *pSkillDescTXT_Raw;
 extern struct FactionTable *pFactionTable;
-extern std::array<char, 777> byte_5C8D1A; // weak
+//extern std::array<char, 777> byte_5C8D1A; // weak
 
 extern std::array<char, 777> byte_5E4C15; // weak
 extern std::array<char *, 14> pSomeItemsNames;