H4x0rBattie Advanced Cheater
Reputation: 0
Joined: 10 Nov 2016 Posts: 58
|
Posted: Sat Jan 14, 2017 11:47 am Post subject: Is anyone able to translate this pseudo code (C++) ? |
|
|
I did a bit of reversing. The below function is a drag calculation function for one game I work with.
I already worked for several days with a real life drag calculation function that was quite close to game one but it's not accurate enough at longer distances.
I figured out that I have to solve out the way the game does it and ended up reversing it.
Is anyone able to translate it to something more readable? You can use fictional float values in formulas. Thanks.
Code: |
__int64 __fastcall sub_145ABFD00(__int64 a1, __int64 a2, __m128i *a3, float a4)
{
__m128 v4; // xmm4@1
__int64 v5; // rax@1
float v6; // xmm5_4@1
float v7; // xmm0_4@1
__m128i v8; // xmm3@1
float v9; // xmm6_4@1
unsigned int v11; // [sp+20h] [bp+8h]@2
v4 = *(__m128 *)a3;
v5 = *(_QWORD *)(a1 + 16);
_mm_store_si128((__m128i *)a2, *a3);
v6 = a4;
v7 = a4 * *(float *)(v5 + 320);
v8 = (__m128i)_mm_mul_ps(v4, v4);
*(float *)(a2 + 4) = v7 + *(float *)(a2 + 4);
v9 = fsqrt(COERCE_FLOAT(_mm_add_ps(_mm_add_ps((__m128)_mm_shuffle_epi32(v8, 85), (__m128)_mm_shuffle_epi32(v8, 0)), (__m128)_mm_shuffle_epi32(v8, -86))));
if ( v9 != 0.0 )
{
v11 = (unsigned __int128)_mm_add_ps(
_mm_add_ps((__m128)_mm_shuffle_epi32(v8, 85), (__m128)_mm_shuffle_epi32(v8, 0)),
(__m128)_mm_shuffle_epi32(v8, -86));
*(__m128 *)a2 = _mm_sub_ps(
*(__m128 *)a2,
_mm_mul_ps(
_mm_mul_ps(
_mm_mul_ps(
_mm_div_ps(v4, _mm_shuffle_ps((__m128)LODWORD(v9), (__m128)LODWORD(v9), 0)),
_mm_shuffle_ps((__m128)v11, (__m128)v11, 0)),
_mm_shuffle_ps((__m128)*(_DWORD *)(v5 + 324), (__m128)*(_DWORD *)(v5 + 324), 0)),
_mm_shuffle_ps((__m128)LODWORD(v6), (__m128)LODWORD(v6), 0)));
}
return a2;
}
|
_________________
|
|