//
// GJBaseGameLayer::loadUpToPosition from 0x496d40 to 0x496faa (618 bytes)
//
// 1 xrefs:
// > GJBaseGameLayer::loadStartPosObject @ 0x497022
//
// 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 v8; // s18
float v9; // r1
int v10; // r5
float (__fastcall *timeForPos)(GJBaseGameLayer *__hidden, cocos2d::CCPoint, int, int, bool, int); // r7
float v12; // s17
int v13; // r7
const cocos2d::CCPoint *v14; // r0
cocos2d::CCPoint *(__fastcall *posForTime)(cocos2d::CCPoint *__return_ptr __struct_ptr, GJBaseGameLayer *__hidden, float); // r3
float v16; // s16
float x; // s21
float v18; // s22
float y; // s21
float v20; // s21
GJEffectManager *m_effectManager; // r0
bool v22; // r2
PlayerObject *m_player1; // r0
GJEffectManager *v24; // r3
PlayerObject *v25; // r0
cocos2d::CCPoint v26; // [sp+Ch] [bp-14h] BYREF
cocos2d::CCPoint v27; // [sp+14h] [bp-Ch] BYREF
v8 = 0.0;
a1->resetSPTriggered(a1);
GJBaseGameLayer::resetSongTriggerValues(a1);
v9 = a2;
v10 = 0;
timeForPos = a1->timeForPos;
cocos2d::CCPoint::CCPoint(&v27, v9, 0.0);
v12 = COERCE_FLOAT(
((int (__fastcall *)(GJBaseGameLayer *, cocos2d::CCPoint *, int, int, _DWORD, _DWORD))timeForPos)(
a1,
&v27,
a3,
a4,
0,
0));
if ( v12 > 3600.0 )
v12 = 3600.0;
v13 = (int)(float)(ceilf(v12 / 0.016667) + 1.0);
v14 = a1->m_player1->getPosition(a1->m_player1);
cocos2d::CCPoint::CCPoint(&v26, v14);
a1->m_player1->setPosition(a1->m_player1, &stru_AC68C0);
while ( v10 < v13 )
{
posForTime = a1->posForTime;
if ( (float)(v8 + 0.016667) <= v12 )
v16 = 0.016667;
else
v16 = v12 - v8;
a1->m_gameState.m_levelTime = a1->m_gameState.m_levelTime + v16;
v8 = v8 + v16;
a1->m_gameState.m_totalTime = a1->m_gameState.m_totalTime + v16;
((void (__fastcall *)(cocos2d::CCPoint *, GJBaseGameLayer *, _DWORD))posForTime)(&v27, a1, LODWORD(v8));
x = v27.x;
v18 = x - a1->m_player1->getPosition(a1->m_player1)->x;
y = v27.y;
v20 = y - a1->m_player1->getPosition(a1->m_player1)->y;
a1->m_player1->setPosition(a1->m_player1, &v27);
GJEffectManager::updateEffects(a1->m_effectManager, v16);
GJEffectManager::preCollisionCheck(a1->m_effectManager);
std::_Rb_tree,std::tuple,std::_Identity>,std::less>,std::allocator>>::clear((int)&a1->m_spawnTuples);
GJEffectManager::updateSpawnTriggers(a1->m_effectManager, v16);
std::_Rb_tree,std::tuple,std::_Identity>,std::less>,std::allocator>>::clear((int)&a1->m_spawnTuples);
m_effectManager = a1->m_effectManager;
m_effectManager->m_unk780 = v18;
m_effectManager->m_unk784 = v20;
m_effectManager->m_unk788 = v18;
m_effectManager->m_unk78C = v20;
GJEffectManager::updateTimers(m_effectManager, v16, 1.0);
GJEffectManager::prepareMoveActions(a1->m_effectManager, v16, 0);
v22 = v10++ == v13 - 1;
GJBaseGameLayer::processMoveActionsStep(a1, v16, v22);
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);
}
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);
v24 = a1->m_effectManager;
v25 = a1->m_player1;
v24->m_unk780 = 0.0;
v24->m_unk784 = 0.0;
v24->m_unk788 = 0.0;
v24->m_unk78C = 0.0;
v25->setPosition(v25, &v26);
}