//
// PlayerObject::unrotateGameplayObject from 0x1003f84f0 to 0x1003f8781 (657 bytes)
//
// 4 xrefs:
// > PlayerObject::handleRotatedCollisionInternal @ 0x1003f3cfb
// > PlayerObject::handleRotatedCollisionInternal @ 0x1003f3d17
// > PlayerObject::unrotatePreSlopeObjects @ 0x1003f87b7
// > PlayerObject::spiderTestJumpInternal @ 0x1003faf55
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:29:59 +0000
//
void __fastcall PlayerObject::unrotateGameplayObject(__int64 a1, _DWORD *a2)
{
unsigned __int64 v2; // r9
__int64 *v3; // rdi
unsigned __int64 v4; // rcx
unsigned __int64 v5; // rdx
unsigned __int64 v6; // r11
unsigned __int64 v7; // r8
__int64 **v8; // rax
__int64 *v9; // r10
__int64 v10; // rax
unsigned __int64 v11; // rax
__int64 v13; // r15
unsigned __int64 *LastPosition; // r12
float v15; // xmm0_4
float v16; // xmm1_4
unsigned __int64 v17; // [rsp-48h] [rbp-48h] BYREF
unsigned __int64 *v18; // [rsp-40h] [rbp-40h] BYREF
char v19; // [rsp-31h] [rbp-31h] BYREF
v2 = *(_QWORD *)(a1 + 1704);
if ( v2 )
{
v3 = (__int64 *)(a1 + 1696);
v4 = (int)a2[229];
v5 = ((v2 - ((v2 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v2 - ((v2 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)
+ ((((v2 - ((v2 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v2 - ((v2 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)) >> 4);
v6 = (0x101010101010101LL * (v5 & 0xF0F0F0F0F0F0F0FLL)) >> 56;
if ( v6 > 1 )
{
v7 = (int)a2[229];
if ( v2 <= v4 )
{
if ( (v2 | v4) >> 32 )
{
v5 = v4 % v2;
v7 = v4 % v2;
}
else
{
v5 = (unsigned int)v4 % (unsigned int)v2;
v7 = v5;
}
}
}
else
{
v7 = v4 & (v2 - 1);
}
v8 = *(__int64 ***)(*v3 + 8 * v7);
if ( v8 )
{
v9 = *v8;
if ( *v8 )
{
if ( (unsigned int)v6 < 2 )
{
--v2;
while ( 1 )
{
v10 = v9[1];
if ( v10 == v4 )
{
if ( *((_DWORD *)v9 + 4) == (_DWORD)v4 )
goto LABEL_27;
}
else if ( (v2 & v10) != v7 )
{
return;
}
v9 = (__int64 *)*v9;
if ( !v9 )
return;
}
}
do
{
v11 = v9[1];
if ( v11 == v4 )
{
if ( *((_DWORD *)v9 + 4) == (_DWORD)v4 )
{
LABEL_27:
(*(void (__fastcall **)(_DWORD *, __int64, unsigned __int64, unsigned __int64, unsigned __int64, unsigned __int64))(*(_QWORD *)a2 + 1776LL))(
a2,
1,
v5,
v4,
v7,
v2);
LODWORD(v17) = a2[229];
v18 = &v17;
v13 = sub_10040B1E0(v3, &v17, &unk_100A09E3E, &v18, &v19);
GameObject::addToTempOffset(a2, -*(double *)(v13 + 24), -*(double *)(v13 + 32));
LastPosition = (unsigned __int64 *)GameObject::getLastPosition(a2);
v15 = *(double *)(v13 + 24);
v16 = *(double *)(v13 + 32);
sub_100278250((float *)&v17, -v15, -v16);
sub_100278350((double *)&v18, LastPosition, &v17);
GameObject::setLastPosition(a2, &v18);
_mm_storel_ps(
(double *)(a2 + 243),
_mm_add_ps((__m128)*(unsigned __int64 *)(a2 + 243), (__m128)xmmword_100A09DB0));
(*(void (__fastcall **)(_DWORD *, double))(*(_QWORD *)a2 + 1480LL))(a2, 0.0);
if ( (*(unsigned int (__fastcall **)(_DWORD *))(*(_QWORD *)a2 + 1800LL))(a2) == 25 )
GameObject::determineSlopeDirection(a2);
LODWORD(v18) = a2[229];
sub_10001C120(v3, (int *)&v18);
return;
}
}
else
{
if ( v11 < v2 )
goto LABEL_23;
if ( (v2 | v11) >> 32 )
{
v5 = v11 % v2;
v11 %= v2;
LABEL_23:
if ( v11 != v7 )
return;
goto LABEL_18;
}
v5 = (unsigned int)v11 % (unsigned int)v2;
if ( v5 != v7 )
return;
}
LABEL_18:
v9 = (__int64 *)*v9;
}
while ( v9 );
}
}
}
}