// Recovered decompilation of functions attributed to bt/btplayer.cpp
// (from BTL4OPT.EXE via embedded assert paths). Pseudocode — reconstruct against the header.

/* ---- @ 004c0200 ---- */

void __cdecl FUN_004c0200(int param_1,int param_2)

{
  int iVar1;
  int iVar2;
  float10 fVar3;
  float local_10;
  
  if (*(int *)(param_2 + 0x20) != 0) {
    FUN_0040385c(s_BTPlayer__ScoreInflictedMessageH_00513110,s_d__tesla_bt_bt_btplayer_cpp_0051316a,
                 0x18b);
  }
  iVar2 = (**(code **)(*(int *)(*(int *)(DAT_004efc94 + 0x2c) + 0x54) + 0xc))
                    (*(int *)(DAT_004efc94 + 0x2c) + 0x54,param_2 + 0x34);
  iVar1 = *(int *)(param_1 + 0x1fc);
  fVar3 = FUN_004c052c(param_1,(float *)(param_2 + 0x24),iVar2,0.0);
  local_10 = (float)fVar3;
  if (iVar2 == iVar1) {
    local_10 = -local_10;
  }
  *(float *)(param_1 + 0x278) =
       (*(float *)(iVar2 + 0x4bc) / *(float *)(iVar1 + 0x4bc)) * local_10 +
       *(float *)(param_1 + 0x278);
  return;
}



/* ---- @ 004c02a8 ---- */

void __cdecl FUN_004c02a8(int param_1,int param_2)

{
  if ((*(uint *)(param_1 + 0x28) & 0xc) == 4) {
    FUN_0040385c(s_BTPlayer__ScoreUpdateMessageHand_00513186,s_d__tesla_bt_bt_btplayer_cpp_005131cf,
                 0x1d5);
  }
  FUN_0042da20(param_1,param_2);
  return;
}



/* ---- @ 004c02e4 ---- */

void __cdecl FUN_004c02e4(int param_1,int param_2)

{
  int *piVar1;
  int iVar2;
  int iVar3;
  undefined4 uVar4;
  float10 fVar5;
  undefined4 uVar6;
  undefined4 local_4c [10];
  int local_24;
  undefined4 local_20;
  int local_1c;
  undefined4 local_18;
  undefined4 *local_14;
  float local_10;
  int local_c;
  int local_8;
  
  if ((*(uint *)(param_1 + 0x28) & 0xc) == 4) {
    FUN_0040385c(s_BTPlayer__ScoreMessageHandler_sh_005131eb,s_d__tesla_bt_bt_btplayer_cpp_0051322e,
                 0x1e9);
  }
  if (*(int *)(param_1 + 0x40) != 4) {
    local_8 = param_2 + 0x34;
    iVar3 = (**(code **)(*(int *)(*(int *)(DAT_004efc94 + 0x2c) + 0x54) + 0xc))
                      (*(int *)(DAT_004efc94 + 0x2c) + 0x54,local_8);
    local_c = *(int *)(param_1 + 0x1fc);
    iVar2 = *(int *)(param_2 + 0x20);
    if (iVar2 == 0) {
      FUN_0040385c(s_BTPlayer__ScoreMessageHandler_sh_0051324a,
                   s_d__tesla_bt_bt_btplayer_cpp_0051329a,0x296);
    }
    else if (iVar2 == 1) {
      if (iVar3 != local_c) {
        fVar5 = FUN_00429b94(*(int *)(param_1 + 0x208),(float *)(param_2 + 0x24));
        local_10 = (*(float *)(local_c + 0x4bc) / *(float *)(iVar3 + 0x4bc)) * (float)fVar5;
      }
      local_1c = FUN_00429078(*(int *)(DAT_004efc94 + 0x2c));
      if ((local_1c != 0) && (*(int *)(param_1 + 600) == 0)) {
        local_20 = *(undefined4 *)(param_2 + 0x30);
        local_24 = FUN_004078fc(*(float *)(param_2 + 0x24));
        uVar6 = local_20;
        uVar4 = FUN_004dcd94();
        FUN_004c1944(local_4c,*(undefined4 *)(param_1 + 0x18c),
                     *(undefined4 *)(*(int *)(iVar3 + 400) + 0x18c),local_24,
                     *(undefined4 *)(param_2 + 0x2c),*(undefined4 *)(param_2 + 0x28),uVar4,uVar6);
        (**(code **)(**(int **)(DAT_004efc94 + 0x20) + 0x18))
                  (*(int **)(DAT_004efc94 + 0x20),local_4c,5,*(undefined4 *)(local_1c + 0xc));
      }
    }
    else if (iVar2 == 2) {
      fVar5 = FUN_004c052c(param_1,(float *)(param_2 + 0x24),iVar3,*(float *)(param_2 + 0x1c));
      local_10 = (*(float *)(iVar3 + 0x4bc) / *(float *)(local_c + 0x4bc)) * (float)fVar5;
      if (iVar3 == local_c) {
        local_10 = -local_10;
      }
      else {
        *(int *)(param_1 + 0x27c) = *(int *)(param_1 + 0x27c) + 1;
        piVar1 = (int *)(*(int *)(iVar3 + 400) + 0x27c);
        *piVar1 = *piVar1 + 1;
      }
      local_14 = FUN_00402f74(0x512f6c);
      if (local_14 != (undefined4 *)0x0) {
        local_18 = *(undefined4 *)(iVar3 + 400);
        FUN_0042d990(local_14,local_18,0,0x40c00000);
        *local_14 = &PTR_LAB_00513344;
        local_14[6] = 0;
      }
      FUN_0042e580(param_1,local_14);
      if (iVar3 == *(int *)(param_1 + 0x284)) {
        FUN_004b04d8(**(int **)(*(int *)(param_1 + 0x1fc) + 0x128),iVar3);
      }
    }
    *(float *)(param_2 + 0x1c) = local_10;
    FUN_0042da20(param_1,param_2);
  }
  return;
}



