Skip to content

Instantly share code, notes, and snippets.

@encrypted-def
Created March 10, 2018 16:16
Show Gist options
  • Save encrypted-def/cf9ea524cc9d24f215f0215e8673d592 to your computer and use it in GitHub Desktop.
Save encrypted-def/cf9ea524cc9d24f215f0215e8673d592 to your computer and use it in GitHub Desktop.
[Reversing] Pikachu Volleyball sub_402DC0
signed int __thiscall sub_402DC0(int this)
{
int v1; // esi@1
int v2; // edi@1
int v3; // eax@1
bool v4; // sf@1
int v5; // eax@1
int v6; // eax@2
signed int v7; // ecx@6
int v8; // eax@6
signed int v9; // ebx@9
__int64 v10; // qax@14
int v11; // eax@17
int v12; // ebp@19
int v13; // ecx@20
signed int result; // eax@20
int v15; // edx@21
v1 = this;
v2 = *(_DWORD *)(this + 56);
v3 = *(_DWORD *)(this + 56) / 2;
v4 = *(_DWORD *)(this + 72) + v3 < 0;
v5 = *(_DWORD *)(this + 72) + v3;
*(_DWORD *)(this + 72) = v5;
if ( v4 )
{
v6 = v5 + 50;
LABEL_5:
*(_DWORD *)(this + 72) = v6;
goto LABEL_6;
}
if ( v5 > 50 )
{
v6 = v5 - 50;
goto LABEL_5;
}
LABEL_6:
v7 = *(_DWORD *)(this + 48);
*(_DWORD *)(v1 + 68) = *(_DWORD *)(v1 + 72) / 10;
v8 = v7 + v2 - 20;
if ( v8 < 0 || v8 > 412 )
*(_DWORD *)(v1 + 56) = -v2;
v9 = *(_DWORD *)(v1 + 52);
if ( v9 + *(_DWORD *)(v1 + 60) - 20 < -20 )
*(_DWORD *)(v1 + 60) = 1;
if ( abs(v7 - 216) <= 24 && v9 > 176 )
{
if ( v9 <= 192 )
{
v11 = *(_DWORD *)(v1 + 60);
if ( v11 > 0 )
*(_DWORD *)(v1 + 60) = -v11;
}
else
{
v10 = *(_DWORD *)(v1 + 56);
if ( v7 >= 216 )
*(_DWORD *)(v1 + 56) = (HIDWORD(v10) ^ v10) - HIDWORD(v10);
else
*(_DWORD *)(v1 + 56) = -((HIDWORD(v10) ^ v10) - HIDWORD(v10));
}
}
v12 = *(_DWORD *)(v1 + 60);
if ( v9 + v12 <= 252 )
{
v15 = v7 + *(_DWORD *)(v1 + 56);
*(_DWORD *)(v1 + 52) = v9 + v12;
result = 0;
*(_DWORD *)(v1 + 48) = v15;
*(_DWORD *)(v1 + 60) = v12 + 1;
}
else
{
sub_408470(100 * (v7 - 216));
(*(void (__stdcall **)(_DWORD))(**(_DWORD **)(v1 + 40) + 16))(0);
v13 = *(_DWORD *)(v1 + 48);
*(_DWORD *)(v1 + 60) = -*(_DWORD *)(v1 + 60);
*(_DWORD *)(v1 + 80) = v13;
result = 1;
*(_DWORD *)(v1 + 52) = 252;
*(_DWORD *)(v1 + 76) = 20;
*(_DWORD *)(v1 + 84) = 272;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment