//
// GJBaseGameLayer::loadUpToPosition from 0x89d2e8 to 0x89d6a8 (960 bytes)
//
// 2 xrefs:
// > GJBaseGameLayer::loadStartPosObject @ 0x89d744
// > ??> @ 0xb21e8
//
// 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
//
void GJBaseGameLayer::loadUpToPosition(GJBaseGameLayer *a1, float a2, int a3, int a4)
{
float (__fastcall *timeForPos)(GJBaseGameLayer *__hidden, cocos2d::CCPoint, int, int, bool, int); // x20
float v7; // s13
float v8; // s12
int v9; // w25
const cocos2d::CCPoint *v10; // x0
float v11; // s11
std::_Rb_tree_node_base *p_M_header; // x23
int v13; // w22
float v14; // s8
double v15; // d3
cocos2d::CCPoint (__fastcall *posForTime)(GJBaseGameLayer *__hidden, float); // x1
double v17; // d1
float x; // s9
const cocos2d::CCPoint *v19; // x0
float y; // s10
float v21; // s9
float v22; // s10
std::_Rb_tree_node_base::_Base_ptr M_parent; // x27
std::_Rb_tree_node_base::_Base_ptr v24; // x0
GJEffectManager *m_effectManager; // x0
std::_Rb_tree_node_base::_Base_ptr v26; // x27
std::_Rb_tree_node_base::_Base_ptr v27; // x0
GJEffectManager *v28; // x2
bool v29; // w1
PlayerObject *m_player1; // x0
GJEffectManager *v31; // x2
PlayerObject *v32; // x0
PlayerObject_vtbl *v33; // x3
void (__fastcall *setPosition)(PlayerObject *__hidden, const cocos2d::CCPoint *); // x3
__int64 v36; // [xsp+B8h] [xbp+B8h]
cocos2d::CCPoint v37; // [xsp+C8h] [xbp+C8h] BYREF
cocos2d::CCPoint v38; // [xsp+D0h] [xbp+D0h] BYREF
v36 = (unsigned int)a4;
a1->resetSPTriggered(a1);
GJBaseGameLayer::resetSongTriggerValues(a1);
timeForPos = a1->timeForPos;
cocos2d::CCPoint::CCPoint(&v38, a2, 0.0);
v7 = ((float (__fastcall *)(GJBaseGameLayer *, cocos2d::CCPoint *, _QWORD, __int64, _QWORD, _QWORD))timeForPos)(
a1,
&v38,
(unsigned int)a3,
v36,
0,
0);
if ( v7 > 3600.0 )
{
v8 = 216000.0;
v7 = 3600.0;
}
else
{
v8 = v7 / 0.016667;
}
v9 = (int)(float)(ceilf(v8) + 1.0);
v10 = a1->m_player1->getPosition(a1->m_player1);
cocos2d::CCPoint::CCPoint(&v37, v10);
a1->m_player1->setPosition(a1->m_player1, &stru_1242DA8);
if ( v9 > 0 )
{
v11 = 0.0;
p_M_header = &a1->m_spawnTuples._M_t._M_impl._M_header;
v13 = 0;
do
{
if ( v7 >= (float)(v11 + 0.016667) )
{
v11 = v11 + 0.016667;
v15 = 0.0166666675;
v14 = 0.016667;
}
else
{
v14 = v7 - v11;
v15 = (float)(v7 - v11);
v11 = (float)(v7 - v11) + v11;
}
posForTime = a1->posForTime;
v17 = a1->m_gameState.m_totalTime + v15;
a1->m_gameState.m_levelTime = a1->m_gameState.m_levelTime + v15;
a1->m_gameState.m_totalTime = v17;
((void (__fastcall *)(cocos2d::CCPoint *__return_ptr, GJBaseGameLayer *, float))posForTime)(&v38, a1, v11);
x = v38.x;
v19 = a1->m_player1->getPosition(a1->m_player1);
y = v38.y;
v21 = x - v19->x;
v22 = y - a1->m_player1->getPosition(a1->m_player1)->y;
a1->m_player1->setPosition(a1->m_player1, &v38);
GJEffectManager::updateEffects(a1->m_effectManager, v14);
GJEffectManager::preCollisionCheck(a1->m_effectManager);
M_parent = a1->m_spawnTuples._M_t._M_impl._M_header._M_parent;
while ( M_parent )
{
std::_Rb_tree,std::tuple,std::_Identity>,std::less>,std::allocator>>::_M_erase(
(__int64)&a1->m_spawnTuples,
M_parent->_M_right);
v24 = M_parent;
M_parent = M_parent->_M_left;
operator delete(v24);
}
a1->m_spawnTuples._M_t._M_impl._M_header._M_left = p_M_header;
a1->m_spawnTuples._M_t._M_impl._M_header._M_parent = nullptr;
a1->m_spawnTuples._M_t._M_impl._M_header._M_right = p_M_header;
m_effectManager = a1->m_effectManager;
a1->m_spawnTuples._M_t._M_impl._M_node_count = 0;
GJEffectManager::updateSpawnTriggers(m_effectManager, v14);
v26 = a1->m_spawnTuples._M_t._M_impl._M_header._M_parent;
while ( v26 )
{
std::_Rb_tree,std::tuple,std::_Identity>,std::less>,std::allocator>>::_M_erase(
(__int64)&a1->m_spawnTuples,
v26->_M_right);
v27 = v26;
v26 = v26->_M_left;
operator delete(v27);
}
v28 = a1->m_effectManager;
a1->m_spawnTuples._M_t._M_impl._M_header._M_left = p_M_header;
a1->m_spawnTuples._M_t._M_impl._M_header._M_parent = nullptr;
a1->m_spawnTuples._M_t._M_impl._M_header._M_right = p_M_header;
a1->m_spawnTuples._M_t._M_impl._M_node_count = 0;
v28->m_unk780 = v21;
v28->m_unk784 = v22;
v28->m_unk788 = v21;
v28->m_unk78C = v22;
GJEffectManager::updateTimers(v28, v14, 1.0);
GJEffectManager::prepareMoveActions(a1->m_effectManager, v14, 0);
v29 = v9 - 1 == v13++;
GJBaseGameLayer::processMoveActionsStep(a1, v14, v29);
GJEffectManager::postMoveActions(a1->m_effectManager);
GJBaseGameLayer::updateCollisionBlocks(a1);
GJBaseGameLayer::checkSpawnObjects(a1);
a1->m_gameState.m_currentChannel = a1->m_gameState.m_rotateChannel;
GJBaseGameLayer::checkSpawnObjects(a1);
GJEffectManager::postCollisionCheck(a1->m_effectManager);
GJEffectManager::processColors(a1->m_effectManager);
}
while ( v13 != v9 );
}
m_player1 = a1->m_player1;
m_player1->m_maybeReverseSpeed = 0.0;
m_player1->m_maybeReverseAcceleration = 0.0;
PlayerObject::setYVelocity(m_player1, 0.0, 0);
GJBaseGameLayer::toggleLockPlayer(a1, 0, 1);
GJBaseGameLayer::toggleLockPlayer(a1, 0, 0);
v31 = a1->m_effectManager;
v32 = a1->m_player1;
v33 = v32->GameObject::CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v31->m_unk780 = 0.0;
setPosition = v33->setPosition;
v31->m_unk784 = 0.0;
v31->m_unk788 = 0.0;
v31->m_unk78C = 0.0;
setPosition(v32, &v37);
}