//
// GJBaseGameLayer::getSavedPosition from 0x1001eb5a4 to 0x1001eb820 (636 bytes)
//
// 1 xrefs:
// > GJBaseGameLayer::processAdvancedFollowAction @ 0x1001f9ac4
//
// 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
//
cocos2d::CCPoint __fastcall GJBaseGameLayer::getSavedPosition(GJBaseGameLayer *a1, int a2, float a3)
{
__int64 *v3; // x8
__int64 *v5; // x19
float v6; // s8
int v7; // w21
PlayerObject *m_player1; // x8
PlayerObject *m_player2; // x0
__int64 *p_m_cameraPosition; // x1
GameObject *MainObject; // x0
int m_unkUint12; // w22
GameObject *v13; // x0
int v14; // w8
__n128 v15; // q0
__n128 v16; // q1
int v17; // w9
int v18; // w8
float v19; // s8
int v20; // w9
int v21; // w21
int v22; // w22
std::__vector_base::pointer begin; // x8
std::__vector_base::pointer v24; // x8
__n128 v25; // q0
__n128 v26; // q1
float32x2_t v29; // [xsp+Ch] [xbp-64h] BYREF
float32x2_t v30; // [xsp+14h] [xbp-5Ch] BYREF
float32x2_t v31; // [xsp+1Ch] [xbp-54h] BYREF
int m_uniqueID; // [xsp+24h] [xbp-4Ch] BYREF
int *p_m_uniqueID; // [xsp+28h] [xbp-48h] BYREF
cocos2d::CCPoint v34; // 0:kr00_8.8
cocos2d::CCPoint result; // 0:s0.4,4:s1.4
v5 = v3;
if ( a3 <= 0.0 )
{
if ( a2 == -3 )
{
p_m_cameraPosition = (__int64 *)&a1->m_gameState.m_cameraPosition;
}
else
{
if ( a2 == -2 )
{
m_player2 = a1->m_player2;
}
else
{
if ( a2 != -1 )
{
MainObject = GJBaseGameLayer::tryGetMainObject(a1, a2);
if ( MainObject )
{
v34 = ((cocos2d::CCPoint (__fastcall *)(GameObject *))MainObject->getRealPosition)(MainObject);
result.x = v34.x;
result.y = v34.y;
return result;
}
goto LABEL_28;
}
m_player2 = a1->m_player1;
}
p_m_cameraPosition = (__int64 *)((__int64 (__fastcall *)(PlayerObject *))m_player2->getPosition)(m_player2);
}
LABEL_29:
result.x = sub_1000229B8(v5, p_m_cameraPosition);
return result;
}
v6 = fmax(
a3 / 0.00416666667
+ (float)((float)(unsigned int)(a1->m_gameState.m_unkUint6 - a1->m_gameState.m_unkUint5) / -1000.0),
0.0);
v7 = vcvtps_s32_f32(v6);
if ( a1->m_gameState.m_unkUint11 <= v7 )
{
LABEL_28:
p_m_cameraPosition = &qword_10086C9A0;
goto LABEL_29;
}
m_uniqueID = a2;
if ( a2 == -3 )
{
m_unkUint12 = a1->m_gameState.m_unkUint12;
if ( m_unkUint12 < 0 )
goto LABEL_28;
}
else
{
if ( a2 == -2 )
{
m_player1 = a1->m_player2;
}
else
{
if ( a2 != -1 )
{
v13 = GJBaseGameLayer::tryGetMainObject(a1, a2);
if ( !v13 )
goto LABEL_28;
m_unkUint12 = v13->m_unk52C;
m_uniqueID = v13->m_uniqueID;
if ( m_unkUint12 < 0 )
goto LABEL_28;
goto LABEL_23;
}
m_player1 = a1->m_player1;
}
m_unkUint12 = m_player1->m_unk52C;
if ( m_unkUint12 < 0 )
goto LABEL_28;
}
LABEL_23:
if ( sub_100018814(&a1->m_savePositionValues.__table_.__bucket_list_.__ptr_.__value_, &m_uniqueID) )
{
p_m_uniqueID = &m_uniqueID;
v14 = *((_DWORD *)sub_10001D150(
(unsigned __int64)&a1->m_savePositionValues,
&m_uniqueID,
(__int64)&unk_10063A31C,
&p_m_uniqueID)
+ 5);
v17 = (v14 & ((a1->m_gameState.m_unkUint11 % v14 - v7) >> 31)) + a1->m_gameState.m_unkUint11 % v14 - v7;
if ( v17 + 1 < v14 )
v18 = v17 + 1;
else
v18 = 0;
v19 = (float)v7 - v6;
v20 = v17 + m_unkUint12;
v21 = v18 + m_unkUint12;
v22 = 2 * (v18 + m_unkUint12);
begin = a1->m_gameState.m_unkVecFloat1.__begin_;
v15.n128_f32[0] = begin[2 * v20];
v16.n128_f32[0] = begin[2 * v20 + 1];
sub_100022980(v15, v16, &p_m_uniqueID);
v24 = a1->m_gameState.m_unkVecFloat1.__begin_;
v25.n128_f32[0] = v24[v22];
v26.n128_f32[0] = v24[2 * v21 + 1];
sub_100022980(v25, v26, &v31);
sub_1000229F0(&v31, (float32x2_t *)&p_m_uniqueID, &v30);
sub_100022A14(&v30, &v29, v19);
result.x = sub_1000229DC((float32x2_t *)&p_m_uniqueID, &v29, (float32x2_t *)v5).f32[0];
}
else
{
result.x = sub_1000229B8(v5, &qword_10086C9A0);
}
return result;
}