//
// GJBaseGameLayer::getSavedPosition from 0x10012bbb0 to 0x10012c0b7 (1287 bytes)
//
// 1 xrefs:
// > GJBaseGameLayer::processAdvancedFollowAction @ 0x100149386
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
// local variable allocation has failed, the output may be wrong!
cocos2d::CCPoint __fastcall GJBaseGameLayer::getSavedPosition(GJBaseGameLayer *a1, int a2, float a3)
{
int v3; // edx
__m128 v5; // xmm1
__m128 v6; // xmm0
int v7; // r12d
int m_unknown5; // r14d
int m_uReference; // ecx
__int64 v10; // rdi
GJBaseGameLayer *v11; // rdi
__int64 v12; // r14
cocos2d::CCDictionary *v13; // rdi
unsigned int v14; // r15d
__int64 v15; // rsi
cocos2d::CCObject *v16; // rax
__int64 v17; // r13
cocos2d::CCDictionary *v18; // rdi
unsigned int v19; // r14d
__int64 v20; // rsi
cocos2d::CCObject *v21; // rax
unsigned __int64 v22; // r10
float *v23; // rdi
unsigned __int64 v24; // r15
unsigned __int64 v25; // r9
unsigned int v26; // eax
bool v27; // cf
intptr_t v28; // r15
__int64 v29; // rax
cocos2d::CCObject *v30; // r14
__int64 v31; // r12
intptr_t v32; // r15
cocos2d::CCObject *v33; // r14
__int64 **v34; // rax
__int64 *v35; // r11
unsigned __int64 v36; // r10
unsigned __int64 v37; // rax
__int64 v38; // rax
int v39; // ecx
int v40; // edx
int v41; // eax
int v42; // r13d
_BYTE v43[8]; // [rsp+0h] [rbp-50h] BYREF
_BYTE v44[8]; // [rsp+8h] [rbp-48h] BYREF
_BYTE v45[8]; // [rsp+10h] [rbp-40h] BYREF
int *v46; // [rsp+18h] [rbp-38h] BYREF
int v47; // [rsp+20h] [rbp-30h] BYREF
float v48; // [rsp+24h] [rbp-2Ch]
cocos2d::CCPoint result; // 0:xmm0_8.8
if ( a3 <= 0.0 )
{
if ( v3 != -3 )
{
if ( v3 == -2 )
{
v10 = *(_QWORD *)(*(_QWORD *)&a2 + 3240LL);
}
else
{
if ( v3 != -1 )
{
if ( v3 > 0 )
{
v12 = *(_QWORD *)&a2;
v13 = *(cocos2d::CCDictionary **)(*(_QWORD *)&a2 + 3656LL);
v14 = v3;
v15 = (unsigned int)v3;
v16 = cocos2d::CCDictionary::objectForKey(v13, (unsigned int)v3);
if ( v16 )
return ((cocos2d::CCPoint (__fastcall *)(GJBaseGameLayer *, cocos2d::CCObject *))v16->__vftable[16].getTag)(
a1,
v16);
v26 = v14;
v27 = v14 < 0x270F;
v28 = 9999;
if ( v27 )
v28 = v26;
v29 = v12;
v30 = *(cocos2d::CCObject **)(*(_QWORD *)(v12 + 3584) + 8 * v28);
if ( v30
|| (v31 = v29,
v30 = (cocos2d::CCObject *)sub_10071F9E0(v13, v15),
cocos2d::CCDictionary::setObject(*(cocos2d::CCDictionary **)(v31 + 3560), v30, v28),
(*(_QWORD *)(*(_QWORD *)(v31 + 3584) + 8 * v28) = v30) != 0) )
{
if ( (unsigned int)sub_100720070(v30) == 1 )
{
v16 = (cocos2d::CCObject *)sub_1007200C0(v30, 0);
if ( v16 )
return ((cocos2d::CCPoint (__fastcall *)(GJBaseGameLayer *, cocos2d::CCObject *))v16->__vftable[16].getTag)(
a1,
v16);
}
}
}
goto LABEL_65;
}
v10 = *(_QWORD *)(*(_QWORD *)&a2 + 3232LL);
}
(*(void (__fastcall **)(__int64))(*(_QWORD *)v10 + 192LL))(v10);
v11 = a1;
LABEL_66:
*(double *)&result = sub_10028CC60(v11);
return result;
}
goto LABEL_65;
}
v5 = 0;
*(double *)v5.i64 = fmax(
(float)((float)(*(_DWORD *)(*(_QWORD *)&a2 + 964LL) - *(_DWORD *)(*(_QWORD *)&a2 + 960LL))
/ -1000.0)
+ a3 / 0.004166666666666667,
0.0);
v5.f32[0] = *(double *)v5.i64;
v6 = _mm_round_ss((__m128)0LL, v5, 10);
v7 = (int)v6.f32[0];
if ( *(_DWORD *)(*(_QWORD *)&a2 + 1140LL) <= (int)v6.f32[0] )
goto LABEL_65;
v47 = v3;
switch ( v3 )
{
case -3:
m_unknown5 = *(_DWORD *)(*(_QWORD *)&a2 + 1144LL);
m_uReference = -3;
if ( m_unknown5 < 0 )
goto LABEL_65;
goto LABEL_26;
case -2:
m_unknown5 = *(_DWORD *)(*(_QWORD *)(*(_QWORD *)&a2 + 3240LL) + 1340LL);
m_uReference = -2;
if ( m_unknown5 < 0 )
goto LABEL_65;
goto LABEL_26;
case -1:
m_unknown5 = *(_DWORD *)(*(_QWORD *)(*(_QWORD *)&a2 + 3232LL) + 1340LL);
m_uReference = -1;
if ( m_unknown5 < 0 )
goto LABEL_65;
goto LABEL_26;
}
if ( v3 <= 0 )
goto LABEL_65;
v48 = v5.f32[0];
v17 = *(_QWORD *)&a2;
v18 = *(cocos2d::CCDictionary **)(*(_QWORD *)&a2 + 3656LL);
v19 = v3;
v20 = (unsigned int)v3;
v21 = cocos2d::CCDictionary::objectForKey(v18, (unsigned int)v3);
if ( v21 )
{
*(_QWORD *)&a2 = v17;
v5.f32[0] = v48;
}
else
{
v32 = 9999;
if ( v19 < 0x270F )
v32 = v19;
v33 = *(cocos2d::CCObject **)(*(_QWORD *)(v17 + 3584) + 8 * v32);
if ( !v33 )
{
v33 = (cocos2d::CCObject *)sub_10071F9E0(v18, v20);
cocos2d::CCDictionary::setObject(*(cocos2d::CCDictionary **)(v17 + 3560), v33, v32);
*(_QWORD *)(*(_QWORD *)(v17 + 3584) + 8 * v32) = v33;
if ( !v33 )
goto LABEL_65;
}
if ( (unsigned int)sub_100720070(v33) != 1 )
goto LABEL_65;
v21 = (cocos2d::CCObject *)sub_1007200C0(v33, 0);
v5.f32[0] = v48;
if ( !v21 )
goto LABEL_65;
*(_QWORD *)&a2 = v17;
}
m_uReference = v21[16].m_uReference;
m_unknown5 = v21[23].m_unknown5;
v47 = m_uReference;
if ( m_unknown5 < 0 )
{
LABEL_65:
v11 = a1;
goto LABEL_66;
}
LABEL_26:
v22 = *(_QWORD *)(*(_QWORD *)&a2 + 13048LL);
if ( !v22 )
goto LABEL_65;
v23 = (float *)(*(_QWORD *)&a2 + 13040LL);
v24 = (0x101010101010101LL
* ((((v22 - ((v22 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v22 - ((v22 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)
+ ((((v22 - ((v22 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v22 - ((v22 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)) >> 4))
& 0xF0F0F0F0F0F0F0FLL)) >> 56;
if ( v24 > 1 )
{
v25 = m_uReference;
if ( v22 <= m_uReference )
{
if ( (v22 | m_uReference) >> 32 )
v25 = m_uReference % v22;
else
v25 = m_uReference % (unsigned int)v22;
}
}
else
{
v25 = m_uReference & (v22 - 1);
}
v34 = *(__int64 ***)(*(_QWORD *)v23 + 8 * v25);
if ( !v34 )
goto LABEL_65;
v35 = *v34;
if ( !*v34 )
goto LABEL_65;
if ( (unsigned int)v24 < 2 )
{
v36 = v22 - 1;
while ( 1 )
{
v38 = v35[1];
if ( v38 == m_uReference )
{
if ( *((_DWORD *)v35 + 4) == m_uReference )
goto LABEL_67;
}
else if ( (v36 & v38) != v25 )
{
goto LABEL_65;
}
v35 = (__int64 *)*v35;
if ( !v35 )
goto LABEL_65;
}
}
while ( 1 )
{
v37 = v35[1];
if ( v37 == m_uReference )
break;
if ( v37 < v22 )
goto LABEL_57;
if ( (v22 | v37) >> 32 )
{
v37 %= v22;
LABEL_57:
if ( v37 != v25 )
goto LABEL_65;
goto LABEL_52;
}
if ( (unsigned int)v37 % (unsigned int)v22 != v25 )
goto LABEL_65;
LABEL_52:
v35 = (__int64 *)*v35;
if ( !v35 )
goto LABEL_65;
}
if ( *((_DWORD *)v35 + 4) != m_uReference )
goto LABEL_52;
LABEL_67:
v46 = &v47;
v48 = v5.f32[0];
v39 = *((_DWORD *)sub_100055BA0(v23, &v47, v6, (__int64)&unk_100816AE0, &v46) + 5);
v40 = *(_DWORD *)(*(_QWORD *)&a2 + 1140LL) % v39 - v7;
v41 = v39 & (v40 >> 31);
v42 = 0;
if ( v41 + v40 + 1 < v39 )
v42 = v41 + v40 + 1;
v48 = (float)v7 - v48;
sub_10028CBE0(
&v46,
*(float *)(*(_QWORD *)(*(_QWORD *)&a2 + 1112LL) + 8LL * (v41 + m_unknown5 + v40)),
*(float *)(*(_QWORD *)(*(_QWORD *)&a2 + 1112LL) + 4LL * (2 * (v41 + m_unknown5 + v40) + 1)));
sub_10028CBE0(
v45,
*(float *)(*(_QWORD *)(*(_QWORD *)&a2 + 1112LL) + 8LL * (m_unknown5 + v42)),
*(float *)(*(_QWORD *)(*(_QWORD *)&a2 + 1112LL) + 4LL * (2 * (m_unknown5 + v42) + 1)));
sub_10028CD00(v43, v45, &v46);
result = (cocos2d::CCPoint)LODWORD(v48);
sub_10028CD40(v44, v43, v48);
sub_10028CCE0(a1, &v46);
return result;
}