//
// PlayerObject::toggleRobotMode from 0x43e4a8 to 0x43e6aa (514 bytes)
//
// 4 xrefs:
// > PlayerObject::switchedToMode @ 0x43e708
// > PlayerObject::copyAttributes @ 0x43f968
// > MenuGameLayer::resetPlayer @ 0x49290e
// > GJBaseGameLayer::switchToRobotMode @ 0x58ee92
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:48:24 +0000
//
char *__fastcall PlayerObject::toggleRobotMode(char *this, int a2, int a3)
{
int v3; // r4
int *v6; // r0
int v7; // r3
GameManager *v8; // r0
int v9; // r0
const char *v10; // r1
cocos2d::CCString *v11; // r0
const char *CString; // r7
size_t v13; // r0
cocos2d::CCSpriteFrameCache *v14; // r0
int v15; // r7
void (__fastcall *v16)(int, int); // r10
cocos2d::CCSpriteFrameCache *v17; // r0
char *v18; // r1
int v19; // r0
int v20; // r10
int *v21; // r7
int v22; // r2
int v23; // r3
int v24; // r2
int v25; // r3
const char *v26; // r1
int v27; // [sp+4h] [bp-2Ch]
int v28[2]; // [sp+8h] [bp-28h] BYREF
char *v29; // [sp+10h] [bp-20h]
int v30[3]; // [sp+14h] [bp-1Ch] BYREF
int v31[3]; // [sp+20h] [bp-10h] BYREF
v3 = (int)this;
if ( (unsigned __int8)*(this + 1957) != a2 )
{
*((_QWORD *)this + 199) = *((_QWORD *)this + 266);
v6 = *((int **)this + 293);
*(_BYTE *)(v3 + 1957) = a2;
v7 = *v6;
if ( a2 )
{
(*(void (**)(void))(v7 + 232))();
PlayerObject::switchedToMode(v3, 27);
*(_QWORD *)(v3 + 1680) = 0x3FF8000000000000LL;
PlayerObject::stopRotation((PlayerObject *)v3, 0, 12);
v8 = (GameManager *)(*(int (__fastcall **)(int, _DWORD))(*(_DWORD *)v3 + 180))(v3, 0);
v9 = GameManager::sharedState(v8);
v10 = (const char *)(*(_DWORD *)(v9 + 576) - *(_DWORD *)(v9 + 580));
if ( (int)v10 >= 68 )
v10 = (const char *)&dword_44;
if ( (int)v10 < 1 )
v10 = (char *)&dword_0 + 1;
v11 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"robot_%02d_01_001.png", v10);
v28[0] = 0;
v28[1] = 0;
v29 = nullptr;
CString = (const char *)cocos2d::CCString::getCString(v11);
v13 = strlen(CString);
v14 = (cocos2d::CCSpriteFrameCache *)std::string::__init(v28, CString, v13);
v15 = *(_DWORD *)(v3 + 1492);
v16 = *(void (__fastcall **)(int, int))(*(_DWORD *)v15 + 580);
v17 = (cocos2d::CCSpriteFrameCache *)cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache(v14);
if ( (v28[0] & 1) != 0 )
v18 = v29;
else
v18 = (char *)v28 + 1;
v19 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v17, v18);
v16(v15, v19);
v20 = *(_DWORD *)(v3 + 1732);
if ( *(_BYTE *)(v3 + 2320) && *(double *)(v3 + 2200) == 0.0 )
{
v21 = v30;
memset(v30, 0, sizeof(v30));
std::string::__init(v30, "idle01", 6u);
CCAnimatedSprite::runAnimation(v20, (int)v30, v22, v23);
}
else
{
v21 = v31;
std::string::basic_string(v31, v3 + 2400);
CCAnimatedSprite::runAnimation(v20, (int)v31, v24, v25);
}
std::string::~string((int)v21);
(*(void (__fastcall **)(_DWORD, _DWORD))(**(_DWORD **)(v3 + 1492) + 172))(*(_DWORD *)(v3 + 1492), 0);
if ( !a3 )
{
LOWORD(v27) = 13055;
BYTE2(v27) = 50;
PlayerObject::spawnPortalCircle(v3, v27, (CCCircleWave *)0x42480000);
}
PlayerObject::updatePlayerScale((GJActionManager **)v3);
std::string::~string((int)v28);
}
else
{
(*(void (**)(void))(v7 + 276))();
(*(void (__fastcall **)(_DWORD, int))(**(_DWORD **)(v3 + 1492) + 172))(*(_DWORD *)(v3 + 1492), 1);
SpriteAnimationManager::stopAnimations(*(SpriteAnimationManager **)(*(_DWORD *)(v3 + 1732) + 532));
if ( *(float *)(v3 + 2008) != 1.0 && *(_BYTE *)(v3 + 2152) )
v26 = nullptr;
else
v26 = *(const char **)(v3 + 1320);
PlayerObject::updatePlayerFrame((PlayerObject *)v3, v26);
}
PlayerObject::updatePlayerGlow((PlayerObject *)v3);
this = PlayerObject::stopRotation((PlayerObject *)v3, 1, 13);
if ( a2 )
return (char *)PlayerObject::modeDidChange((PlayerObject *)v3);
}
return this;
}