Skip to content

Decompiled : Decoding Wall AID

iamkisly edited this page Dec 19, 2016 · 4 revisions
char aArtWallSSCC_ar[] = "art\\wall\\%s%s%c%c.art"; // idb

//----- (00457AB0) --------------------------------------------------------
int __cdecl sub_457AB0(int a1, int a2, int a3, int a4, char *a5)
//a5 - dest
{
  signed int v5; // eax@2

  if ( BYTE1(a3) & 4 )
  {
    v5 = 1;
  }
  else if ( a3 & 0x80 )
  {
    if ( a2 < 1 || a2 > 6 )
      v5 = 2;
    else
      v5 = 1;
  }
  else
  {
    v5 = 0;
  }
  sprintf(a5, aArtWallSSCC_ar, a1, off_578E80[a2], *((_BYTE *)off_578E7C[0] + v5), a4 + 48);
  return 1;
}
// 578E7C: using guessed type void **off_578E7C[5];
// 578E80: using guessed type void **off_578E80[4];

Ахтунг!

void **off_578E7C[5] = { &off_578FEC, &off_578FE8, &off_578FE4, &off_578FE8, &off_578FE0 }; // weak
void **off_578E80[4] = { &off_578FE8, &off_578FE4, &off_578FE8, &off_578FE0 }; // weak

Взызываем sub_457AB0

//----- (004579A0) --------------------------------------------------------
int __cdecl sub_4579A0(int a1, char *a2)
{
  int v2; // esi@1
  int result; // eax@2
  int v4; // edi@3
  int v5; // ebp@3
  __int16 v6; // bx@3
  int v7; // esi@3
  signed __int16 v8; // ax@7
  int v9; // ebx@13
  int v10; // ecx@23
  int v11; // [sp+14h] [bp+4h]@3

  v2 = a1;
  if ( sub_516C10(a1) == 1 )
  {
    v11 = sub_517FE0(a1);
    v4 = sub_516D90(v2);
    v5 = sub_517F70(v2);
    v6 = sub_518080(v2);
    v7 = sub_518010(v2);
    if ( v4 == 2 || v4 == 3 || v4 == 6 || v4 == 7 )
    {
      v8 = 0;
      if ( HIBYTE(v6) & 4 )
        v8 = 128;
      if ( v6 & 0x80 )
        HIBYTE(v8) |= 4u;
      v6 = v8;
    }
    if ( HIBYTE(v6) & 4 )
    {
      v9 = 1024;
      if ( v5 == 7 )
        v5 = 0;
    }
    else if ( v6 & 0x80 )
    {
      v9 = 128;
      if ( v5 == 8 )
        v5 = 0;
    }
    else
    {
      v9 = 0;
    }
    if ( v11 < dword_5AA07C )
    {
      if ( v4 / 2 && v4 / 2 != 3 )
        v10 = *((_DWORD *)dword_5AA084 + 8 * v11 + 3);
      else
        v10 = *((_DWORD *)dword_5AA084 + 8 * v11 + 1);
      if ( v10 < dword_5AA080 )
        result = sub_457AB0(*((_DWORD *)dword_5AA094 + v10), v5, v9, v7, a2);
      else
        result = 0;
    }
    else
    {
      result = 0;
    }
  }
  else
  {
    result = 0;
  }
  return result;
}
// 5AA080: using guessed type int dword_5AA080;
//----- (00517FE0) --------------------------------------------------------
int __cdecl sub_517FE0(unsigned int a1)
{
  int result; // eax@2

  if ( sub_516C10(a1) == 1 )
    result = (a1 >> 20) & 0xFF;
  else
    result = 0;
  return result;
}
//----- (00516D90) --------------------------------------------------------
int __cdecl sub_516D90(unsigned int a1)
{
  unsigned int v1; // eax@1
  int result; // eax@8

  v1 = sub_516C10(a1);
  if ( v1 && v1 != 5 && v1 != 8 && v1 != 10 && v1 != 6 && v1 != 11 )
  {
    if ( v1 == 9 )
    {
      result = (a1 >> 9) & 7;
    }
    else if ( v1 == 14 )
    {
      result = (a1 >> 9) & 7;
    }
    else
    {
      result = (a1 >> 11) & 7;
    }
  }
  else
  {
    result = 0;
  }
  return result;
}

sub_517F70

//----- (00517F70) --------------------------------------------------------
int __cdecl sub_517F70(unsigned int a1)
{
  int result; // eax@2

  if ( sub_516C10(a1) == 1 )
    result = (a1 >> 14) & 0x3F;
  else
    result = 0;
  return result;
}
//----- (00518080) --------------------------------------------------------
int __cdecl sub_518080(unsigned int a1)
{
  unsigned int v1; // eax@1
  int result; // eax@2

  v1 = sub_516C10(a1);
  switch ( v1 )
  {
    case 1u:
      result = a1 & 0x480;
      break;
    case 3u:
      result = a1 & 0x200;
      break;
    case 6u:
      result = a1 & 0x800;
      break;
    default:
      result = 0;
      break;
  }
  return result;
}
//----- (00518010) --------------------------------------------------------
int __cdecl sub_518010(unsigned int a1)
{
  int result; // eax@2

  if ( sub_516C10(a1) == 1 )
    result = (a1 >> 8) & 3;
  else
    result = 0;
  return result;
}