//
// GJBaseGameLayer::getSavedPosition from 0x8837f0 to 0x883a94 (676 bytes)
//
// 2 xrefs:
// > GJBaseGameLayer::processAdvancedFollowAction @ 0x883c04
// > ??> @ 0x4f158
//
// 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 GJBaseGameLayer::getSavedPosition(GJBaseGameLayer *a1, int a2, float a3)
{
cocos2d::CCPoint *v3; // x8
cocos2d::CCPoint *v4; // x20
double v6; // d0
float v7; // s8
int v8; // w24
GameObject *v9; // x0
int m_unk52C; // w22
int v11; // w3
float v12; // s8
int v13; // w2
int v14; // w1
int v15; // w2
int v16; // w1
int v17; // w22
GameObject *MainObject; // x0
PlayerObject *m_player1; // x1
const cocos2d::CCPoint *v22; // x0
int m_uniqueID; // [xsp+8Ch] [xbp+8Ch] BYREF
cocos2d::CCPoint v24; // [xsp+90h] [xbp+90h] BYREF
cocos2d::CCPoint v25; // [xsp+98h] [xbp+98h] BYREF
__int64 v26; // [xsp+A0h] [xbp+A0h] BYREF
cocos2d::CCPoint v27; // [xsp+A8h] [xbp+A8h] BYREF
char v28[8]; // [xsp+B0h] [xbp+B0h] BYREF
cocos2d::CCPoint result; // 0:s0.4,4:s1.4
v4 = v3;
if ( a3 <= 0.0 )
{
switch ( a2 )
{
case -1:
m_player1 = a1->m_player1;
break;
case -2:
m_player1 = a1->m_player2;
break;
case -3:
cocos2d::CCPoint::CCPoint(v3, &a1->m_gameState.m_cameraPosition);
return result;
default:
MainObject = GJBaseGameLayer::tryGetMainObject(a1, a2);
if ( MainObject )
{
MainObject->getRealPosition(MainObject);
return result;
}
goto LABEL_17;
}
v22 = m_player1->getPosition(m_player1);
cocos2d::CCPoint::CCPoint(v4, v22);
return result;
}
v6 = a3 / 0.00416666667
- (float)((float)(unsigned int)(a1->m_gameState.m_unkUint6 - a1->m_gameState.m_unkUint5) / 1000.0);
if ( v6 <= 0.0 )
{
v7 = 0.0;
v8 = 0;
}
else
{
v7 = v6;
v8 = vcvtps_s32_f32(v7);
}
if ( a1->m_gameState.m_unkUint11 <= v8 )
goto LABEL_17;
m_uniqueID = a2;
switch ( a2 )
{
case -1:
m_unk52C = a1->m_player1->m_unk52C;
goto LABEL_10;
case -2:
m_unk52C = a1->m_player2->m_unk52C;
goto LABEL_10;
case -3:
m_unk52C = a1->m_gameState.m_unkUint12;
goto LABEL_10;
}
v9 = GJBaseGameLayer::tryGetMainObject(a1, a2);
if ( !v9 )
{
LABEL_17:
cocos2d::CCPoint::CCPoint(v4, &stru_1242DA8);
return result;
}
m_unk52C = v9->m_unk52C;
m_uniqueID = v9->m_uniqueID;
LABEL_10:
if ( m_unk52C < 0 || !sub_855C48(&a1->m_savePositionValues._M_h._M_buckets, m_uniqueID) )
goto LABEL_17;
v11 = *(_DWORD *)std::__detail::_Map_base,std::allocator>,std::__detail::_Select1st,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits,true>::operator[](
&a1->m_savePositionValues._M_h._M_buckets,
&m_uniqueID);
v12 = (float)v8 - v7;
v13 = a1->m_gameState.m_unkUint11 % v11 - v8;
if ( v13 < 0 )
v13 += v11;
v14 = v13 + m_unk52C;
v15 = v13 + 1;
v16 = 2 * v14;
if ( v11 <= v15 )
v15 = 0;
v17 = 2 * (v15 + m_unk52C);
cocos2d::CCPoint::CCPoint(
&v24,
a1->m_gameState.m_unkVecFloat1.m_start[v16],
a1->m_gameState.m_unkVecFloat1.m_start[v16 + 1]);
cocos2d::CCPoint::CCPoint(
&v25,
a1->m_gameState.m_unkVecFloat1.m_start[v17],
a1->m_gameState.m_unkVecFloat1.m_start[v17 + 1]);
cocos2d::CCPoint::operator-(&v26, &v25, &v24);
cocos2d::CCPoint::operator*(&v26, v12);
cocos2d::CCPoint::operator+(&v27, &v24, v28);
cocos2d::CCPoint::CCPoint(v4, &v27);
return result;
}