//
// PlayerObject::toggleRobotMode from 0x1004188e0 to 0x100418d0c (1068 bytes)
//
// 13 xrefs:
// > GJBaseGameLayer::setupLevelStart @ 0x100123bea
// > GJBaseGameLayer::setupLevelStart @ 0x100123ee3
// > GJBaseGameLayer::switchToRobotMode @ 0x1001245b6
// > PlayerObject::switchedToMode @ 0x100412d14
// > PlayerObject::switchedToMode @ 0x100412d50
// > PlayerObject::toggleFlyMode @ 0x10041633b
// > PlayerObject::toggleBirdMode @ 0x100416e3e
// > PlayerObject::toggleSwingMode @ 0x100417544
// > PlayerObject::toggleDartMode @ 0x100417f4b
// > PlayerObject::toggleRollMode @ 0x10041857b
// > PlayerObject::toggleSpiderMode @ 0x100418ed8
// > PlayerObject::copyAttributes @ 0x10041b66c
// > MenuGameLayer::resetPlayer @ 0x1004faa25
//
// 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 __fastcall PlayerObject::toggleRobotMode(PlayerObject *a1, bool a2, bool a3)
{
size_t v3; // r14
cocos2d::CCNode *m_mainLayer; // rdi
cocos2d::CCSpriteBatchNode *m_robotBatchNode; // rsi
cocos2d::CCNode_vtbl *v7; // rax
_BOOL4 v8; // r15d
int v9; // esi
__int64 v10; // xmm0_8
PlayerObject *v11; // rdi
int m_maybeSavedPlayerFrame; // esi
__int128 v13; // xmm0
cocos2d::CCString *v14; // rax
const char *CString; // r13
size_t v16; // rax
size_t v17; // r12
char *v18; // r15
cocos2d::CCSprite *m_iconSprite; // r12
cocos2d::CCSpriteFrameCache *v20; // rax
bool v21; // r15
const char *v22; // rsi
cocos2d::CCSpriteFrame *v23; // rax
GJRobotSprite *m_robotSprite; // rdi
void **p_longStorage; // rax
GJRobotSprite *v26; // r12
__int128 v27; // [rsp+0h] [rbp-80h] BYREF
char *longStorage; // [rsp+10h] [rbp-70h] BYREF
__int128 v29; // [rsp+20h] [rbp-60h] BYREF
char v30; // [rsp+30h] [rbp-50h] BYREF
_BOOL4 v31; // [rsp+38h] [rbp-48h]
int v32; // [rsp+3Ch] [rbp-44h]
_QWORD __dst[2]; // [rsp+40h] [rbp-40h] BYREF
void *__p; // [rsp+50h] [rbp-30h]
LODWORD(v3) = a2;
if ( a1->m_isRobot != a2 )
{
a1->m_gameModeChangedTime = a1->m_totalTime;
a1->m_isRobot = a2;
m_mainLayer = a1->m_mainLayer;
m_robotBatchNode = a1->m_robotBatchNode;
v7 = m_mainLayer->__vftable;
if ( !(_BYTE)v3 )
{
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCSpriteBatchNode *, _QWORD))v7->removeChild_0)(
m_mainLayer,
m_robotBatchNode,
0);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))a1->m_iconSprite->setVisible)(a1->m_iconSprite, 1);
SpriteAnimationManager::stopAnimations(a1->m_robotSprite->m_animationManager);
if ( a1->m_vehicleSize == 1.0 || !a1->m_defaultMiniIcon )
{
m_maybeSavedPlayerFrame = a1->m_maybeSavedPlayerFrame;
v11 = a1;
}
else
{
v11 = a1;
m_maybeSavedPlayerFrame = 0;
}
PlayerObject::updatePlayerFrame(v11, m_maybeSavedPlayerFrame);
LABEL_41:
PlayerObject::updatePlayerGlow(a1);
*(_WORD *)&a1->m_isRotating = 0;
a1->m_isBallRotating = 0;
a1->m_rotationSpeed = 0.0;
if ( (_BYTE)v3 )
{
PlayerObject::updatePlayerArt(a1);
PlayerObject::updateDashArt(a1);
}
return;
}
v8 = a3;
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCSpriteBatchNode *, __int64))v7->addChild_0)(
m_mainLayer,
m_robotBatchNode,
2);
PlayerObject::toggleFlyMode(a1, 0, 0);
PlayerObject::toggleBirdMode(a1, 0, 0);
if ( a1->m_isBall )
{
a1->m_gameModeChangedTime = a1->m_totalTime;
a1->m_isBall = 0;
if ( a1->m_vehicleSize == 1.0 || (v9 = 0, !a1->m_defaultMiniIcon) )
v9 = a1->m_maybeSavedPlayerFrame;
PlayerObject::updatePlayerFrame(a1, v9);
if ( a1->m_isUpsideDown )
v10 = 1127481344;
else
v10 = 0;
((void (__fastcall *)(PlayerObject *, double))a1->setRotation)(a1, *(double *)&v10);
*(_WORD *)&a1->m_isRotating = 0;
a1->m_isBallRotating = 0;
a1->m_rotationSpeed = 0.0;
}
PlayerObject::toggleDartMode(a1, 0, 0);
PlayerObject::toggleSpiderMode(a1, 0, 0);
PlayerObject::toggleSwingMode(a1, 0, 0);
a1->m_accelerationOrSpeed = 1.5;
*(_WORD *)&a1->m_isRotating = 0;
a1->m_isBallRotating = 0;
a1->m_rotationSpeed = 0.0;
*(_QWORD *)&v13 = 0;
((void (__fastcall *)(PlayerObject *, double))a1->setRotation)(a1, 0.0);
GameManager::sharedState();
v14 = (cocos2d::CCString *)sub_1007AB580("robot_%02d_01_001.png", v27);
CString = cocos2d::CCString::getCString(v14);
v16 = strlen(CString);
if ( v16 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(0.0);
v17 = v16;
v31 = v8;
if ( v16 >= 0x17 )
{
v32 = v3;
v3 = 26;
if ( (v16 | 7) != 0x17 )
v3 = (v16 | 7) + 1;
v18 = (char *)operator new(v3);
__p = v18;
__dst[0] = v3 + 1;
LOBYTE(v3) = v32;
__dst[1] = v17;
}
else
{
LOBYTE(__dst[0]) = 2 * v16;
v18 = (char *)__dst + 1;
if ( !v16 )
{
LABEL_24:
v18[v17] = 0;
m_iconSprite = a1->m_iconSprite;
v20 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
v21 = v31;
if ( (__dst[0] & 1) != 0 )
v22 = (const char *)__p;
else
v22 = (char *)__dst + 1;
v23 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v20, v22);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCSpriteFrame *))m_iconSprite->setDisplayFrame)(
m_iconSprite,
v23);
if ( a1->m_isPlatformer && (*(double *)&v13 = a1->m_platformerXVelocity, *(double *)&v13 == 0.0) )
{
m_robotSprite = a1->m_robotSprite;
LOBYTE(v29) = 12;
strcpy((char *)&v29 + 1, "idle01");
CCAnimatedSprite::runAnimation((__int64)m_robotSprite, &v29, *(double *)&v13);
if ( (v29 & 1) == 0 )
{
LABEL_37:
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))a1->m_iconSprite->setVisible)(a1->m_iconSprite, 0);
if ( !v21 )
PlayerObject::spawnPortalCircle(a1, (cocos2d::ccColor3B)3289855, 50.0);
GJActionManager::stopInternalAction(a1->m_actionManager, 6);
((void (__fastcall *)(PlayerObject *, float))a1->setScaleX)(a1, a1->m_vehicleSize);
((void (__fastcall *)(PlayerObject *, float))a1->setScaleY)(a1, a1->m_vehicleSize);
if ( (__dst[0] & 1) != 0 )
operator delete(__p);
goto LABEL_41;
}
p_longStorage = (void **)&v30;
}
else
{
v26 = a1->m_robotSprite;
if ( (a1->m_currentRobotAnimation.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(
&v27,
a1->m_currentRobotAnimation.m_data.m_long.longStorage,
a1->m_currentRobotAnimation.m_data.m_long.size,
*(double *)&v13);
}
else
{
longStorage = a1->m_currentRobotAnimation.m_data.m_long.longStorage;
v13 = *(_OWORD *)&a1->m_currentRobotAnimation.m_data.m_short.sizex2;
v27 = v13;
}
CCAnimatedSprite::runAnimation((__int64)v26, &v27, *(double *)&v13);
if ( (v27 & 1) == 0 )
goto LABEL_37;
p_longStorage = (void **)&longStorage;
}
operator delete(*p_longStorage);
goto LABEL_37;
}
}
memmove(v18, CString, v17);
goto LABEL_24;
}
}