changeset 1252:fa6b8e839355

Merge
author Grumpy7
date Tue, 11 Jun 2013 15:26:53 +0200
parents 7ef8ae7ce42a (diff) fd532497ffab (current diff)
children fac7751b2dc9
files
diffstat 2 files changed, 282 insertions(+), 783 deletions(-) [+]
line wrap: on
line diff
--- a/Player.cpp	Tue Jun 11 10:57:29 2013 +0400
+++ b/Player.cpp	Tue Jun 11 15:26:53 2013 +0200
@@ -7871,7 +7871,7 @@
 void Player::SetVariable(enum VariableType var_type, signed int var_value)
 {
   signed int currPlayerId; // ebx@1
-  Player *v4; // esi@1
+  Player *unused4; // esi@1
   unsigned int v5; // edi@1
   unsigned int v6; // esi@13
   unsigned int v7; // esi@14
@@ -7879,7 +7879,7 @@
   ItemGen *v9; // ecx@17
   int v10; // eax@21
   signed int v11; // eax@30
-  Player *v12; // ecx@44
+  Player *unused12; // ecx@44
   char *v13; // ecx@45
   Player *v14; // ecx@49
   int v15; // ecx@86
@@ -7894,23 +7894,26 @@
   DDM_DLV_Header *v24; // ecx@148
   signed int v25; // eax@172
   int v26; // [sp-8h] [bp-3Ch]@84
-  signed int v27; // [sp-4h] [bp-38h]@4
+  signed int unused27; // [sp-4h] [bp-38h]@4
   int v28; // [sp-4h] [bp-38h]@84
   ItemGen item; // [sp+Ch] [bp-28h]@52
   char v30; // [sp+32h] [bp-2h]@1
   char v31; // [sp+33h] [bp-1h]@1
 
-  currPlayerId = 0;
   v30 = 0;
   v31 = 0;
-  v4 = this;
   v5 = 0;
-  if ( this == pPlayers[2] )
-    currPlayerId = 1;
-  else if ( this == pPlayers[3] )
-    currPlayerId = 2;
-  else if ( this == pPlayers[4] )
-     currPlayerId  = 3;
+
+  currPlayerId = -1;
+  for (int i = 1; i <= 4; i++)  //TODO: add a member variable for playerid in the future
+  {
+    if ( this == pPlayers[i] )
+    {
+      currPlayerId = i - 1;
+      break;
+    }
+  }
+  assert(currPlayerId != -1);
   if ( var_type > VAR_AutoNotes )
   {
     if ( var_type <= VAR_GoldInBank )
@@ -7982,26 +7985,26 @@
       pAudioPlayer->PlaySound(SOUND_20001, v25, v5, -1, v5, v5, v5, v5);
       return;
     }
-    if ( var_type != 307 )
+    if ( var_type != VAR_NumDeaths )
     {
       switch ( var_type )
       {
-        case 308:
+        case VAR_NumBounties:
           pParty->uNumBountiesCollected = var_value;
           break;
-        case 309:
+        case VAR_PrisonTerms:
           pParty->uNumPrisonTerms = var_value;
           break;
-        case 310:
+        case VAR_ArenaWinsPage:
           pParty->uNumArenaPageWins = var_value;
           break;
-        case 311:
+        case VAR_ArenaWinsSquire:
           pParty->uNumArenaSquireWins = var_value;
           break;
-        case 312:
+        case VAR_ArenaWinsKnight:
           pParty->uNumArenaKnightWins = var_value;
           break;
-        case 313:
+        case VAR_ArenaWinsLord:
           pParty->uNumArenaLordWins = var_value;
           break;
       }
@@ -8009,17 +8012,16 @@
     }
     pParty->uNumDeaths = var_value;
 LABEL_168:
-    if ( v30 != 1 )
-    {
+    if (v30 == 1)
+    {
+LABEL_169:
+      pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId);
+    }
 LABEL_170:
-      if ( v31 != 1 )
-        return;
-      v5 = 0;
-      goto LABEL_172;
-    }
-LABEL_169:
-    pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId);
-    goto LABEL_170;
+    if ( v31 != 1 )
+      return;
+    v5 = 0;
+    goto LABEL_172;
   }
   if ( var_type == VAR_AutoNotes )
   {
@@ -8038,191 +8040,186 @@
     v31 = 1;
     goto LABEL_168;
   }
-  if ( var_type <= VAR_ActualMight )
-  {
-    if ( var_type != VAR_ActualMight )
-    {
-      switch ( var_type )
-      {
-        case VAR_RandomGold:
-          v6 = rand() % var_value + 1;
-          Party::SetGold(v6);
-          sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[500], v6);// You have %lu gold
-          ShowStatusBarString(pTmpBuf.data(), 2u);
-          GameUI_DrawFoodAndGold();
-          return;
-        case VAR_RandomFood:
-          v7 = rand() % var_value + 1;
-          Party::SetFood(v7);
-          sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[501], v7);// You have %lu food
-          ShowStatusBarString(pTmpBuf.data(), 2u);
-          GameUI_DrawFoodAndGold();
-          goto LABEL_124;
-        case VAR_Sex:
-          this->uSex = (PLAYER_SEX)var_value;
-          goto LABEL_124;
-        case VAR_Class:
-          this->classType = (PLAYER_CLASS_TYPE)var_value;
-          if ( (char)var_value != 35 )
-            goto LABEL_124;
+  if ( var_type <= VAR_BaseLuck )
+  {
+    switch ( var_type )
+    {
+      case VAR_Sex:
+        this->uSex = (PLAYER_SEX)var_value;
+        goto LABEL_124;
+      case VAR_Class:
+        this->classType = (PLAYER_CLASS_TYPE)var_value;
+        if ( (char)var_value == PLAYER_CLASS_LICH )
+        {
           v8 = 0;
           v9 = this->pInventoryItems;
-          break;
-        case VAR_CurrentHP:
-          this->sHealth = var_value;
-          goto LABEL_124;
-        case VAR_MaxHP:
-          this->sHealth = GetMaxHealth();
-          return;
-        case VAR_CurrentSP:
-          this->sMana = var_value;
-          goto LABEL_124;
-        case VAR_MaxSP:
-          this->sMana = GetMaxMana();
-          return;
-        case VAR_ACModifier:
-          this->sACModifier = (unsigned __int8)var_value;
-          goto LABEL_124;
-        case VAR_BaseLevel:
-          this->uLevel = (unsigned __int8)var_value;
-          goto LABEL_124;
-        case VAR_LevelModifier:
-          this->sLevelModifier = (unsigned __int8)var_value;
-          goto LABEL_124;
-        case VAR_Age:
-          this->sAgeModifier = var_value;
-          return;
-        case VAR_Award:
-          if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & 
-			  pPlayers[currPlayerId + 1]->_guilds_member_bits[((signed __int16)var_value - 1)/ 8])
-            //&& dword_723E80_award_related[2 * a3] )
-			&& pAwards[var_value].pText )
+          while ( v9->uItemID != 615 )
           {
-            v30 = 1;
-            v31 = 1;
-            pPlayers[currPlayerId + 1]->PlaySound(SPEECH_96, 0);
+            ++v8;
+            ++v9;
+            if ( v8 >= 138 )
+              goto LABEL_22;
+          }
+          v10 = (int)((char *)this + 36 * v8);
+          *(int *)(v10 + 532) = 601;
+          *(char *)(v10 + 558) = currPlayerId + 1;
+LABEL_22:
+          if ( this->sResFireBase < 20 )
+            this->sResFireBase = 20;
+          if ( this->sResAirBase < 20 )
+            this->sResAirBase = 20;
+          if ( this->sResWaterBase < 20 )
+            this->sResWaterBase = 20;
+          if ( this->sResEarthBase < 20 )
+            this->sResEarthBase = 20;
+          this->sResMindBase = 200;
+          this->sResBodyBase = 200;
+          v11 = this->GetSexByVoice();
+          this->uPrevVoiceID = this->uVoiceID;
+          this->uPrevFace = this->uCurrentFace;
+          if ( v11 )
+          {
+            this->uCurrentFace = 21;
+            this->uVoiceID = 21;
+          }
+          else
+          {
+            this->uCurrentFace = 20;
+            this->uVoiceID = 20;
           }
-		  _449B7E_toggle_bit((unsigned char *)v4->_guilds_member_bits, var_value, 1u);
-          goto LABEL_168;
-        case VAR_Experience:
-          this->uExperience = var_value;
-          goto LABEL_124;
-        case VAR_QBits_QuestsDone:
-          if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & pParty->_quest_bits[((signed __int16)var_value - 1) >> 3])
-           // && (&dword_722F10)[4 * a3] )
-		   && pQuestTable[var_value-1] )
+          ReloadPlayerPortraits(currPlayerId, this->uCurrentFace);
+        }
+        goto LABEL_124;
+      case VAR_CurrentHP:
+        this->sHealth = var_value;
+        goto LABEL_124;
+      case VAR_MaxHP:
+        this->sHealth = GetMaxHealth();
+        return;
+      case VAR_CurrentSP:
+        this->sMana = var_value;
+        goto LABEL_124;
+      case VAR_MaxSP:
+        this->sMana = GetMaxMana();
+        return;
+      case VAR_ACModifier:
+        this->sACModifier = (unsigned __int8)var_value;
+        goto LABEL_124;
+      case VAR_BaseLevel:
+        this->uLevel = (unsigned __int8)var_value;
+        goto LABEL_124;
+      case VAR_LevelModifier:
+        this->sLevelModifier = (unsigned __int8)var_value;
+        goto LABEL_124;
+      case VAR_Age:
+        this->sAgeModifier = var_value;
+        return;
+      case VAR_Award:
+        if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & 
+			  pPlayers[currPlayerId + 1]->_guilds_member_bits[((signed __int16)var_value - 1)/ 8])
+              //&& dword_723E80_award_related[2 * a3] )
+		    && pAwards[var_value].pText )
+        {
+          v30 = 1;
+          v31 = 1;
+          pPlayers[currPlayerId + 1]->PlaySound(SPEECH_96, 0);
+        }
+        _449B7E_toggle_bit((unsigned char *)this->_guilds_member_bits, var_value, 1u);
+        goto LABEL_168;
+      case VAR_Experience:
+        this->uExperience = var_value;
+        goto LABEL_124;
+      case VAR_QBits_QuestsDone:
+        if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & pParty->_quest_bits[((signed __int16)var_value - 1) >> 3])
+          // && (&dword_722F10)[4 * a3] )
+		    && pQuestTable[var_value-1] )
           {
-            v14 = pPlayers[currPlayerId + 1];
-            bFlashQuestBook = 1;
-            v30 = 1;
-            v31 = 1;
-            v14->PlaySound(SPEECH_93, 0);
-          }
-          v13 = (char *)pParty->_quest_bits;
+          v14 = pPlayers[currPlayerId + 1];
+          bFlashQuestBook = 1;
+          v30 = 1;
+          v31 = 1;
+          v14->PlaySound(SPEECH_93, 0);
+        }
+        v13 = (char *)pParty->_quest_bits;
 LABEL_51:
-          _449B7E_toggle_bit((unsigned char *)v13, var_value, 1u);
-		  if (( v30 != 1 )&&( v31 != 1 ))
-				  return;
-		  else
-			  pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId);
-		  if ( v31 != 1 )
-			  return;
-		  v25 = 8 * currPlayerId + 400;
-		  LOBYTE(v25) = PID(OBJECT_Player,currPlayerId - 112);
-		  pAudioPlayer->PlaySound(SOUND_20001, v25, 0, -1, 0, 0, 0, 0);
-		  return;
-        case VAR_PlayerItemInHands:
-          item.Reset();
-          item.Reset();
-          item.uItemID = var_value;
-          item.uAttributes = 1;
-          pParty->SetHoldingItem(&item);
-          if ( var_value >= ITEM_ARTIFACT_PUCK && var_value <= ITEM_RELIC_MEKORIGS_HAMMER )
-            pParty->pIsArtifactFound[var_value-500] = 1;
-          return;
-        case VAR_FixedGold:
-          Party::SetGold(var_value);
+        _449B7E_toggle_bit((unsigned char *)v13, var_value, 1u);
+        if (( v30 != 1 )&&( v31 != 1 ))
           return;
-        case VAR_BaseMight:
-          this->uMight = (unsigned __int8)var_value;
-          goto LABEL_84;
-        case VAR_BaseIntellect:
-          this->uIntelligence = (unsigned __int8)var_value;
-          goto LABEL_84;
-        case VAR_BasePersonality:
-          this->uWillpower = (unsigned __int8)var_value;
-          goto LABEL_84;
-        case VAR_BaseEndurance:
-          this->uEndurance = (unsigned __int8)var_value;
-          goto LABEL_84;
-        case VAR_BaseSpeed:
-          this->uSpeed = (unsigned __int8)var_value;
-          goto LABEL_84;
-        case VAR_BaseAccuracy:
-          this->uAccuracy = (unsigned __int8)var_value;
-          goto LABEL_84;
-        case VAR_BaseLuck:
-          this->uLuck = (unsigned __int8)var_value;
-          goto LABEL_84;
-        case VAR_FixedFood:
-          Party::SetFood(var_value);
-          goto LABEL_124;
-        case VAR_MightBonus:
-          goto LABEL_64;
-        case VAR_IntellectBonus:
-          goto LABEL_68;
-        case VAR_PersonalityBonus:
-          goto LABEL_69;
-        case VAR_EnduranceBonus:
-          goto LABEL_70;
-        case VAR_SpeedBonus:
-          goto LABEL_71;
-        case VAR_AccuracyBonus:
-          goto LABEL_72;
-        case VAR_LuckBonus:
-          goto LABEL_73;
-        default:
+        else
+          pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId);
+        if ( v31 != 1 )
           return;
-      }
-      while ( v9->uItemID != 615 )
-      {
-        ++v8;
-        ++v9;
-        if ( v8 >= 138 )
-          goto LABEL_22;
-      }
-      v10 = (int)((char *)v4 + 36 * v8);
-      *(int *)(v10 + 532) = 601;
-      *(char *)(v10 + 558) = currPlayerId + 1;
-LABEL_22:
-      if ( v4->sResFireBase < 20 )
-        v4->sResFireBase = 20;
-      if ( v4->sResAirBase < 20 )
-        v4->sResAirBase = 20;
-      if ( v4->sResWaterBase < 20 )
-        v4->sResWaterBase = 20;
-      if ( v4->sResEarthBase < 20 )
-        v4->sResEarthBase = 20;
-      v4->sResMindBase = 200;
-      v4->sResBodyBase = 200;
-      v11 = v4->GetSexByVoice();
-      v4->uPrevVoiceID = v4->uVoiceID;
-      v4->uPrevFace = v4->uCurrentFace;
-      if ( v11 )
-      {
-        v4->uCurrentFace = 21;
-        v4->uVoiceID = 21;
-      }
-      else
-      {
-        v4->uCurrentFace = 20;
-        v4->uVoiceID = 20;
-      }
-      ReloadPlayerPortraits(currPlayerId, v4->uCurrentFace);
-      goto LABEL_124;
-    }
-LABEL_64:
-    this->uMightBonus = (unsigned __int8)var_value;
+        v25 = 8 * currPlayerId + 400;
+        LOBYTE(v25) = PID(OBJECT_Player,currPlayerId - 112);
+        pAudioPlayer->PlaySound(SOUND_20001, v25, 0, -1, 0, 0, 0, 0);
+        return;
+      case VAR_PlayerItemInHands:
+        item.Reset();
+        item.Reset();
+        item.uItemID = var_value;
+        item.uAttributes = 1;
+        pParty->SetHoldingItem(&item);
+        if ( var_value >= ITEM_ARTIFACT_PUCK && var_value <= ITEM_RELIC_MEKORIGS_HAMMER )
+          pParty->pIsArtifactFound[var_value-500] = 1;
+        return;
+      case VAR_FixedGold:
+        Party::SetGold(var_value);
+        return;
+      case VAR_RandomGold:
+        v6 = rand() % var_value + 1;
+        Party::SetGold(v6);
+        sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[500], v6);// You have %lu gold
+        ShowStatusBarString(pTmpBuf.data(), 2u);
+        GameUI_DrawFoodAndGold();
+        return;
+      case VAR_FixedFood:
+        Party::SetFood(var_value);
+        goto LABEL_124;
+      case VAR_RandomFood:
+        v7 = rand() % var_value + 1;
+        Party::SetFood(v7);
+        sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[501], v7);// You have %lu food
+        ShowStatusBarString(pTmpBuf.data(), 2u);
+        GameUI_DrawFoodAndGold();
+        goto LABEL_124;
+      case VAR_MightBonus:
+        goto LABEL_64;
+      case VAR_IntellectBonus:
+        goto LABEL_68;
+      case VAR_PersonalityBonus:
+        goto LABEL_69;
+      case VAR_EnduranceBonus:
+        goto LABEL_70;
+      case VAR_SpeedBonus:
+        goto LABEL_71;
+      case VAR_AccuracyBonus:
+        goto LABEL_72;
+      case VAR_LuckBonus:
+        goto LABEL_73;
+      case VAR_BaseMight:
+        this->uMight = (unsigned __int8)var_value;
+        goto LABEL_84;
+      case VAR_BaseIntellect:
+        this->uIntelligence = (unsigned __int8)var_value;
+        goto LABEL_84;
+      case VAR_BasePersonality:
+        this->uWillpower = (unsigned __int8)var_value;
+        goto LABEL_84;
+      case VAR_BaseEndurance:
+        this->uEndurance = (unsigned __int8)var_value;
+        goto LABEL_84;
+      case VAR_BaseSpeed:
+        this->uSpeed = (unsigned __int8)var_value;
+        goto LABEL_84;
+      case VAR_BaseAccuracy:
+        this->uAccuracy = (unsigned __int8)var_value;
+        goto LABEL_84;
+      case VAR_BaseLuck:
+        this->uLuck = (unsigned __int8)var_value;
+        goto LABEL_84;
+      default:
+        return;
+    }
 LABEL_111:
     v28 = 0;
     v26 = SPEECH_91;
@@ -8232,15 +8229,14 @@
     v19->PlaySound((PlayerSpeech)v26, v28);
     goto LABEL_169;
   }
-  if ( var_type <= VAR_FireResistanceBonus )
-  {
-    if ( var_type == VAR_FireResistanceBonus )
-    {
-      this->sResFireBonus = (unsigned __int8)var_value;
-      goto LABEL_111;
-    }
+  if ( var_type <= VAR_MagicResistance )
+  {
     switch ( var_type )
     {
+      case VAR_ActualMight:
+LABEL_64:
+        this->uMightBonus = (unsigned __int8)var_value;
+        goto LABEL_111;
       case VAR_ActualIntellect:
 LABEL_68:
         this->uIntelligenceBonus = (unsigned __int8)var_value;
@@ -8312,7 +8308,7 @@
         return;
       if ( var_type <= VAR_Eradicated )
       {
-        v4->SetCondition(var_type - 105, 1);
+        this->SetCondition(var_type - 105, 1);
       }
       else
       {
@@ -8322,14 +8318,14 @@
             byte_5E4C15[var_type] = var_value;
           return;
         }
-        memset(v4, 0, 0xA0u);
+        memset(this, 0, 0xA0u);
       }
 LABEL_124:
       v31 = 1;
       goto LABEL_169;
     }
 LABEL_106:
-    v16 = (int)((char *)&v4->pConditions[16] + 2 * var_type);
+    v16 = (int)((char *)&this->pConditions[16] + 2 * var_type);
     v17 = *(char *)v16;
     if ( var_value <= VAR_BodyResistanceBonus )
     {
@@ -8353,48 +8349,51 @@
 		  }
 	  pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId);
 	  goto LABEL_170;
-  if ( var_type <= VAR_BodyResistanceBonus )
+  if ( var_type <= VAR_MagicResistanceBonus )
   {
     switch ( var_type )
     {
-      case VAR_BodyResistanceBonus:
-        v4->sResBodyBonus = (unsigned __int8)var_value;
+      case VAR_FireResistanceBonus:
+        this->sResFireBonus = (unsigned __int8)var_value;
         break;
       case VAR_AirResistanceBonus:
-        v4->sResAirBonus = (unsigned __int8)var_value;
+        this->sResAirBonus = (unsigned __int8)var_value;
         break;
       case VAR_WaterResistanceBonus:
-        v4->sResWaterBonus = (unsigned __int8)var_value;
+        this->sResWaterBonus = (unsigned __int8)var_value;
         break;
       case VAR_EarthResistanceBonus:
-        v4->sResEarthBonus = (unsigned __int8)var_value;
+        this->sResEarthBonus = (unsigned __int8)var_value;
         break;
       case VAR_SpiritResistanceBonus:
-        v4->sResSpiritBonus = (unsigned __int8)var_value;
+        this->sResSpiritBonus = (unsigned __int8)var_value;
+        break;
+      case VAR_MindResistanceBonus:
+        this->sResMindBonus = (unsigned __int8)var_value;
+        break;
+      case VAR_BodyResistanceBonus:
+        this->sResBodyBonus = (unsigned __int8)var_value;
+        break;
+      case VAR_LightResistanceBonus:
+        this->sResLightBonus = (unsigned __int8)var_value;
+        break;
+      case VAR_DarkResistanceBonus:
+        this->sResDarkBonus = (unsigned __int8)var_value;
+        break;
+      case VAR_PhysicalResistanceBonus:
+        assert("VAR_PhysicalResistanceBonus variable unsupported" && false);
+        return;
+        break;
+      case VAR_MagicResistanceBonus:
+        this->sResMagicBonus = (unsigned __int8)var_value;
         break;
       default:
-        if ( var_type != 62 )
+          assert("Unexpected var_type" && false);
           return;
-        v4->sResMindBonus = (unsigned __int8)var_value;
         break;
     }
     goto LABEL_111;
   }
-  if ( var_type == VAR_LightResistanceBonus )
-  {
-    v4->sResLightBonus = (unsigned __int8)var_value;
-    goto LABEL_111;
-  }
-  if ( var_type == VAR_DarkResistanceBonus )
-  {
-    v4->sResDarkBonus = (unsigned __int8)var_value;
-    goto LABEL_111;
-  }
-  if ( var_type == VAR_MagicResistanceBonus )
-  {
-    v4->sResMagicBonus = (unsigned __int8)var_value;
-    goto LABEL_111;
-  }
   if ( var_type > VAR_MagicResistanceBonus && var_type <= VAR_DiplomacySkill )
 	  if ( v30 != 1 )
 		  {
--- a/mm7_2.cpp	Tue Jun 11 10:57:29 2013 +0400
+++ b/mm7_2.cpp	Tue Jun 11 15:26:53 2013 +0200
@@ -5607,43 +5607,46 @@
   pIcons_LOD->_4114F2();
 }
 
+void set_stru1_field_8_InArcomage(int inValue)
+{
+  switch(inValue)
+  {
+  case 91:LOBYTE(pArcomageGame->stru1.field_8) = 123;break;
+  case 92:LOBYTE(pArcomageGame->stru1.field_8) = 124;break;
+  case 93:LOBYTE(pArcomageGame->stru1.field_8) = 125;break;
+  case 96:LOBYTE(pArcomageGame->stru1.field_8) = 126;break;
+  case 61:LOBYTE(pArcomageGame->stru1.field_8) = 43;break;
+  case 55:LOBYTE(pArcomageGame->stru1.field_8) = 38;break;
+  case 56:LOBYTE(pArcomageGame->stru1.field_8) = 42;break;
+  case 57:LOBYTE(pArcomageGame->stru1.field_8) = 40;break;
+  case 59:LOBYTE(pArcomageGame->stru1.field_8) = 58;break;
+  case 54:LOBYTE(pArcomageGame->stru1.field_8) = 94;break;
+  case 50:LOBYTE(pArcomageGame->stru1.field_8) = 64;break;
+  case 51:LOBYTE(pArcomageGame->stru1.field_8) = 35;break;
+  case 52:LOBYTE(pArcomageGame->stru1.field_8) = 36;break;
+  case 53:LOBYTE(pArcomageGame->stru1.field_8) = 37;break;
+  case 49:LOBYTE(pArcomageGame->stru1.field_8) = 33;break;
+  case 39:LOBYTE(pArcomageGame->stru1.field_8) = 34;break;
+  case 44:LOBYTE(pArcomageGame->stru1.field_8) = 60;break;
+  case 46:LOBYTE(pArcomageGame->stru1.field_8) = 62;break;
+  case 47:LOBYTE(pArcomageGame->stru1.field_8) = 63;break;
+  case 48:LOBYTE(pArcomageGame->stru1.field_8) = 41;break;
+  default:LOBYTE(pArcomageGame->stru1.field_8) = inValue;break;
+  }
+}
+
+
 //----- (004637EB) --------------------------------------------------------
 int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam)
 {
-  //unsigned int v4; // esi@1
-  Render *v5; // ecx@14
   HANDLE v6; // eax@32
-  Keyboard *v7; // eax@33
-  //HDC v9; // edi@41
   HDC v10; // edi@50
   int v11; // esi@50
-  //char v12; // zf@132
   signed int v13; // eax@135
-  int v14; // eax@139
-  int v15; // eax@140
-  int v16; // eax@141
-  int v17; // eax@142
-  int v18; // eax@150
-  int v19; // eax@151
-  int v20; // eax@152
-  int v21; // eax@161
-  int v22; // eax@162
-  int v23; // eax@163
-  int v24; // eax@170
-  int v25; // eax@171
-  int v26; // eax@172
-  char v27; // al@174
-  //bool v28; // ebx@201
   char v29; // dl@209
-  char v30; // cl@210
   bool v31; // ebx@211
-  void *v32; // ebx@214
   float v33; // ST04_4@246
   float v34; // ST04_4@254
-  HWND v35; // [sp+8h] [bp-64h]@103
-  UINT v36; // [sp+Ch] [bp-60h]@103
-  WPARAM v37; // [sp+10h] [bp-5Ch]@103
-  LPARAM v38; // [sp+14h] [bp-58h]@103
   struct tagPAINTSTRUCT Paint; // [sp+24h] [bp-48h]@13
   int pXY[2]; // [sp+64h] [bp-8h]@261
   int a2; // [sp+7Ch] [bp+10h]@50
@@ -5881,7 +5884,6 @@
         ArcomageGame::OnMouseClick(1, 1);
         return DefWindowProcA(hWnd, Msg, wParam, lParam);
       case WM_LBUTTONUP:
-        v32 = 0;
         if ( !pArcomageGame->bGameInProgress )
           //goto LABEL_218;
         {
@@ -5892,7 +5894,6 @@
         ArcomageGame::OnMouseClick(0, 0);
         return DefWindowProcA(hWnd, Msg, wParam, lParam);
       case WM_RBUTTONUP:
-        v32 = 0;
         if ( !pArcomageGame->bGameInProgress )
         {
 //LABEL_218:
@@ -5901,10 +5902,7 @@
           return DefWindowProcA(hWnd, Msg, wParam, lParam);
         }
         pArcomageGame->stru1.field_0 = 4;
-        v29 = 0;
-        //goto LABEL_262;
-        v30 = 1;
-        ArcomageGame::OnMouseClick(v30, v29 != 0);
+        ArcomageGame::OnMouseClick(1, false);
         return DefWindowProcA(hWnd, Msg, wParam, lParam);
 
       case WM_LBUTTONDBLCLK:
@@ -6003,30 +6001,19 @@
   {
     if ( Msg == WM_WINDOWPOSCHANGED )
     {
-      if (pVideoPlayer)
-      {
-        if (pVideoPlayer->AnyMovieLoaded() && pVideoPlayer->pBinkBuffer)
-        {
-          BinkBufferSetOffset(pVideoPlayer->pBinkBuffer, 0, 0);
-          return DefWindowProcA(hWnd, Msg, wParam, lParam);
-        }
-      }
-      //goto _def_wnd_proc;
+      if (pVideoPlayer && pVideoPlayer->AnyMovieLoaded() && pVideoPlayer->pBinkBuffer)
+      {
+        BinkBufferSetOffset(pVideoPlayer->pBinkBuffer, 0, 0);
+      }
       return DefWindowProcA(hWnd, Msg, wParam, lParam);
     }
     if ( Msg != WM_KEYFIRST )
     {
-      if ( Msg == WM_KEYUP )
-      {
-        if ( wParam == VK_CONTROL )
-        {
-          dword_507B98_ctrl_pressed = 0;
-          return DefWindowProcA(hWnd, Msg, wParam, lParam);
-        }
-        //goto _def_wnd_proc;
-        return DefWindowProcA(hWnd, Msg, wParam, lParam);
-      }
-        return DefWindowProcA(hWnd, Msg, wParam, lParam);
+      if ( Msg == WM_KEYUP && wParam == VK_CONTROL )
+      {
+        dword_507B98_ctrl_pressed = 0;
+      }
+      return DefWindowProcA(hWnd, Msg, wParam, lParam);
     }
     if ( uGameMenuUI_CurentlySelectedKeyIdx != -1 )
     {
@@ -6074,508 +6061,23 @@
       if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_PRESS_ESCAPE_MESSAGE )
         return 0;
     }
+
     pArcomageGame->stru1.field_0 = 1;
-    if ( (unsigned __int16)GetAsyncKeyState(VK_SHIFT) >> 8 >= 0 )
-      v27 = MapVirtualKeyA((unsigned __int16)wParam, 2u);
-    else
-    {
-      v13 = (unsigned __int16)MapVirtualKeyA((unsigned __int16)wParam, 2u);
-      if ( (signed int)(unsigned __int16)v13 > 54 )
-      {
-        if ( v13 > 61 )
-        {
-          if ( v13 == 91 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 123;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 92 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 124;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 93 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 125;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 96 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 126;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-        }
-        else
-        {
-          if ( v13 == 61 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 43;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 55 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 38;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 56 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 42;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 57 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 40;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 59 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 58;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-        }
-      }
-      else
-      {
-        if ( (unsigned __int16)v13 == 54 )
-        {
-          LOBYTE(pArcomageGame->stru1.field_8) = 94;
-          //goto LABEL_181;
-          if ( wParam == 27 )
-          {
-            pArcomageGame->GameOver = 1;
-            pArcomageGame->field_F4 = 1;
-            pArcomageGame->uGameResult = 2;
-            pArcomageGame->field_B0 = -2;
-            //goto _def_wnd_proc;
-            return DefWindowProcA(hWnd, Msg, wParam, lParam);
-          }
-          if ( wParam != 114 )
-          {
-            if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-              SendMessageA(hWnd, 0x111u, 0x68u, 0);
-            //goto _def_wnd_proc;
-            return DefWindowProcA(hWnd, Msg, wParam, lParam);
-          }
-          SendMessageA(hWnd, WM_COMMAND, 103, 0);
-          return 0;
-        }
-        if ( v13 > 49 )
-        {
-          if ( v13 == 50 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 64;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 51 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 35;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 52 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 36;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 53 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 37;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-        }
-        else
-        {
-          if ( v13 == 49 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 33;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 39 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 34;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 44 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 60;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 46 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 62;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 47 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 63;
-            //goto LABEL_181;
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-          if ( v13 == 48 )
-          {
-            LOBYTE(pArcomageGame->stru1.field_8) = 41;
-//LABEL_181:
-            if ( wParam == 27 )
-            {
-              pArcomageGame->GameOver = 1;
-              pArcomageGame->field_F4 = 1;
-              pArcomageGame->uGameResult = 2;
-              pArcomageGame->field_B0 = -2;
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            if ( wParam != 114 )
-            {
-              if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-                SendMessageA(hWnd, 0x111u, 0x68u, 0);
-              //goto _def_wnd_proc;
-              return DefWindowProcA(hWnd, Msg, wParam, lParam);
-            }
-            SendMessageA(hWnd, WM_COMMAND, 103, 0);
-            return 0;
-          }
-        }
-      }
-      v27 = MapVirtualKeyA((unsigned __int16)wParam, 2u);
-    }
-    LOBYTE(pArcomageGame->stru1.field_8) = v27;
-    //goto LABEL_181;
+
+    v13 = (unsigned __int16)MapVirtualKeyA((unsigned __int16)wParam, 2u);
+    set_stru1_field_8_InArcomage(v13);
     if ( wParam == 27 )
     {
       pArcomageGame->GameOver = 1;
       pArcomageGame->field_F4 = 1;
       pArcomageGame->uGameResult = 2;
       pArcomageGame->field_B0 = -2;
-      //goto _def_wnd_proc;
       return DefWindowProcA(hWnd, Msg, wParam, lParam);
     }
     if ( wParam != 114 )
     {
       if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() )
-      SendMessageA(hWnd, 0x111u, 0x68u, 0);
-      //goto _def_wnd_proc;
+        SendMessageA(hWnd, 0x111u, 0x68u, 0);
       return DefWindowProcA(hWnd, Msg, wParam, lParam);
     }
     SendMessageA(hWnd, WM_COMMAND, 103, 0);
@@ -6704,7 +6206,6 @@
       if ( pArcomageGame->bGameInProgress )
       {
         pArcomageGame->field_F9 = 1;
-        v5 = pRenderer;
       }
       else
       {
@@ -6714,7 +6215,6 @@
           EndPaint(hWnd, &Paint);
           return 0;
         }
-        v5 = pRenderer;
       }
       pRenderer->Present();
 //LABEL_20: