//
// PlayerObject::toggleRobotMode from 0x631898 to 0x631cb0 (1048 bytes)
//
// 8 xrefs:
// > PlayerObject::switchedToMode @ 0x630ac8
// > PlayerObject::switchedToMode @ 0x630b28
// > PlayerObject::switchedToMode @ 0x630b68
// > PlayerObject::copyAttributes @ 0x631db4
// > MenuGameLayer::resetPlayer @ 0x6c9694
// > GJBaseGameLayer::switchToRobotMode @ 0x859da4
// > GJBaseGameLayer::switchToRobotMode @ 0x859dbc
// > ??> @ 0xa0bc0
//
// 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 PlayerObject::toggleRobotMode(PlayerObject *a1, bool a2, bool a3)
{
_BOOL4 v4; // w22
double m_totalTime; // x0
cocos2d::CCNode *m_mainLayer; // x3
GameManager *v7; // x2
unsigned __int64 v8; // x1
cocos2d::CCString *v9; // x0
char *CString; // x0
cocos2d::CCSprite *m_iconSprite; // x24
void (__fastcall *setDisplayFrame)(cocos2d::CCSprite *__hidden, cocos2d::CCSpriteFrame *); // x25
cocos2d::CCSpriteFrameCache *v13; // x0
cocos2d::CCSpriteFrame *v14; // x0
GJRobotSprite *v15; // x24
void *v16; // x0
char *v17; // x0
GJRobotSprite *m_robotSprite; // x25
unsigned int *v19; // x1
int v20; // w2
unsigned int *v21; // x1
int v22; // w2
unsigned int *v23; // x1
int v24; // w2
cocos2d::ccColor3B v25; // [xsp+58h] [xbp+58h]
char *v26; // [xsp+60h] [xbp+60h] BYREF
__int64 v27; // [xsp+68h] [xbp+68h] BYREF
__int64 v28; // [xsp+70h] [xbp+70h] BYREF
v4 = a3;
if ( a1->m_isRobot == a2 )
return;
m_totalTime = a1->m_totalTime;
a1->m_isRobot = a2;
m_mainLayer = a1->m_mainLayer;
a1->m_gameModeChangedTime = m_totalTime;
if ( !a2 )
{
m_mainLayer->removeChild_0(m_mainLayer, a1->m_robotBatchNode, 0);
a1->m_iconSprite->setVisible(a1->m_iconSprite, 1);
SpriteAnimationManager::stopAnimations(a1->m_robotSprite->m_animationManager);
if ( a1->m_vehicleSize != 1.0 && a1->m_defaultMiniIcon )
PlayerObject::updatePlayerFrame(a1, 0);
else
PlayerObject::updatePlayerFrame(a1, a1->m_maybeSavedPlayerFrame);
PlayerObject::updatePlayerGlow(a1);
PlayerObject::stopRotation(a1, 1, 13);
return;
}
m_mainLayer->addChild_0(m_mainLayer, a1->m_robotBatchNode, 2);
PlayerObject::switchedToMode(a1, RobotPortal);
a1->m_accelerationOrSpeed = 1.5;
PlayerObject::stopRotation(a1, 0, 12);
a1->setRotation(a1, 0.0);
v7 = GameManager::sharedState();
LODWORD(v8) = v7->m_playerRobot.random - v7->m_playerRobot.seed;
if ( (int)v8 > 68 )
LODWORD(v8) = 68;
if ( (int)v8 <= 0 )
v8 = 1;
else
v8 = (unsigned int)v8;
v9 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"robot_%02d_01_001.png",
(const char *)v8);
CString = (char *)cocos2d::CCString::getCString(v9);
sub_D153B8((int)&v26, CString);
m_iconSprite = a1->m_iconSprite;
setDisplayFrame = m_iconSprite->setDisplayFrame;
v13 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
v14 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v13, v26);
setDisplayFrame(m_iconSprite, v14);
if ( a1->m_isPlatformer && a1->m_platformerXVelocity == 0.0 )
{
m_robotSprite = a1->m_robotSprite;
sub_D153B8((int)&v27, "idle01");
CCAnimatedSprite::runAnimation((__int64)m_robotSprite, (__int64)&v27);
v16 = (void *)(v27 - 24);
if ( (__int64 *)(v27 - 24) == &qword_124B6B0 )
goto LABEL_11;
if ( &pthread_create )
{
v19 = (unsigned int *)(v27 - 8);
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *(_DWORD *)(v27 - 8);
*(_DWORD *)(v27 - 8) = v20 - 1;
}
if ( v20 > 0 )
goto LABEL_11;
}
else
{
v15 = a1->m_robotSprite;
sub_D18D28(&v28, &a1->m_currentRobotAnimation);
CCAnimatedSprite::runAnimation((__int64)v15, (__int64)&v28);
v16 = (void *)(v28 - 24);
if ( (__int64 *)(v28 - 24) == &qword_124B6B0 )
goto LABEL_11;
if ( &pthread_create )
{
v23 = (unsigned int *)(v28 - 8);
do
v24 = __ldaxr(v23);
while ( __stlxr(v24 - 1, v23) );
}
else
{
v24 = *(_DWORD *)(v28 - 8);
*(_DWORD *)(v28 - 8) = v24 - 1;
}
if ( v24 > 0 )
goto LABEL_11;
}
operator delete(v16);
LABEL_11:
a1->m_iconSprite->setVisible(a1->m_iconSprite, 0);
if ( !v4 )
{
*(_WORD *)&v25.r = 13055;
v25.b = 50;
PlayerObject::spawnPortalCircle(a1, v25, 50.0);
}
PlayerObject::updatePlayerScale(a1);
v17 = v26 - 24;
if ( v26 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v21 = (unsigned int *)(v26 - 8);
do
v22 = __ldaxr(v21);
while ( __stlxr(v22 - 1, v21) );
}
else
{
v22 = *((_DWORD *)v26 - 2);
*((_DWORD *)v26 - 2) = v22 - 1;
}
if ( v22 <= 0 )
operator delete(v17);
}
PlayerObject::updatePlayerGlow(a1);
PlayerObject::stopRotation(a1, 1, 13);
PlayerObject::modeDidChange(a1);
}