//
// PlayerObject::toggleSpiderMode from 0x100418d50 to 0x10041914f (1023 bytes)
//
// 13 xrefs:
// > GJBaseGameLayer::setupLevelStart @ 0x100123e0c
// > GJBaseGameLayer::setupLevelStart @ 0x100123f4d
// > GJBaseGameLayer::switchToSpiderMode @ 0x100124666
// > PlayerObject::switchedToMode @ 0x100412d34
// > PlayerObject::switchedToMode @ 0x100412d62
// > PlayerObject::toggleFlyMode @ 0x100416347
// > PlayerObject::toggleBirdMode @ 0x100416e4a
// > PlayerObject::toggleSwingMode @ 0x100417550
// > PlayerObject::toggleDartMode @ 0x100417f57
// > PlayerObject::toggleRollMode @ 0x100418587
// > PlayerObject::toggleRobotMode @ 0x100418a60
// > PlayerObject::copyAttributes @ 0x10041b67e
// > MenuGameLayer::resetPlayer @ 0x1004faa94
//
// 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::toggleSpiderMode(PlayerObject *a1, bool a2, bool a3)
{
size_t v3; // r14
cocos2d::CCNode *m_mainLayer; // rdi
cocos2d::CCSpriteBatchNode *m_spiderBatchNode; // rsi
cocos2d::CCNode_vtbl *v7; // rax
_BOOL4 v8; // r15d
int v9; // esi
__int64 v10; // xmm0_8
int m_maybeSavedPlayerFrame; // r15d
cocos2d::CCString *v12; // rax
const char *CString; // r13
size_t v14; // rax
size_t v15; // r12
char *v16; // r15
cocos2d::CCSprite *m_iconSprite; // r12
cocos2d::CCSpriteFrameCache *v18; // rax
bool v19; // r15
const char *v20; // rsi
cocos2d::CCSpriteFrame *v21; // rax
double m_platformerXVelocity; // xmm0_8
GJSpiderSprite *m_spiderSprite; // rdi
__int128 v24; // [rsp+0h] [rbp-60h] BYREF
void *__p; // [rsp+10h] [rbp-50h]
_BOOL4 v26; // [rsp+18h] [rbp-48h]
int v27; // [rsp+1Ch] [rbp-44h]
_QWORD __dst[2]; // [rsp+20h] [rbp-40h] BYREF
void *v29; // [rsp+30h] [rbp-30h]
LODWORD(v3) = a2;
if ( a1->m_isSpider != a2 )
{
a1->m_gameModeChangedTime = a1->m_totalTime;
a1->m_isSpider = a2;
m_mainLayer = a1->m_mainLayer;
m_spiderBatchNode = a1->m_spiderBatchNode;
v7 = m_mainLayer->__vftable;
if ( !(_BYTE)v3 )
{
m_maybeSavedPlayerFrame = 0;
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCSpriteBatchNode *, _QWORD))v7->removeChild_0)(
m_mainLayer,
m_spiderBatchNode,
0);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))a1->m_iconSprite->setVisible)(a1->m_iconSprite, 1);
SpriteAnimationManager::stopAnimations(a1->m_spiderSprite->m_animationManager);
if ( a1->m_vehicleSize == 1.0 || !a1->m_defaultMiniIcon )
m_maybeSavedPlayerFrame = a1->m_maybeSavedPlayerFrame;
PlayerObject::updatePlayerFrame(a1, m_maybeSavedPlayerFrame);
PlayerObject::resetPlayerIcon(a1);
goto LABEL_35;
}
v8 = a3;
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCSpriteBatchNode *, __int64))v7->addChild_0)(
m_mainLayer,
m_spiderBatchNode,
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::toggleRobotMode(a1, 0, 0);
PlayerObject::toggleSwingMode(a1, 0, 0);
a1->m_unkAngle1 = 27.0;
*(_QWORD *)&a1->m_width = 0x41D8000041D80000LL;
a1->m_accelerationOrSpeed = 1.5;
*(_WORD *)&a1->m_isRotating = 0;
a1->m_isBallRotating = 0;
a1->m_rotationSpeed = 0.0;
((void (__fastcall *)(PlayerObject *, double))a1->setRotation)(a1, 0.0);
GameManager::sharedState();
v12 = (cocos2d::CCString *)sub_1007AB580("spider_%02d_01_001.png", v24);
CString = cocos2d::CCString::getCString(v12);
v14 = strlen(CString);
if ( v14 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(0.0);
v15 = v14;
v26 = v8;
if ( v14 >= 0x17 )
{
v27 = v3;
v3 = 26;
if ( (v14 | 7) != 0x17 )
v3 = (v14 | 7) + 1;
v16 = (char *)operator new(v3);
v29 = v16;
__dst[0] = v3 + 1;
LOBYTE(v3) = v27;
__dst[1] = v15;
}
else
{
LOBYTE(__dst[0]) = 2 * v14;
v16 = (char *)__dst + 1;
if ( !v14 )
goto LABEL_23;
}
memmove(v16, CString, v15);
LABEL_23:
v16[v15] = 0;
m_iconSprite = a1->m_iconSprite;
v18 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
v19 = v26;
if ( (__dst[0] & 1) != 0 )
v20 = (const char *)v29;
else
v20 = (char *)__dst + 1;
v21 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v18, v20);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCSpriteFrame *))m_iconSprite->setDisplayFrame)(
m_iconSprite,
v21);
if ( a1->m_isPlatformer && (m_platformerXVelocity = a1->m_platformerXVelocity, m_platformerXVelocity == 0.0) )
{
m_spiderSprite = a1->m_spiderSprite;
LOBYTE(v24) = 12;
strcpy((char *)&v24 + 1, "idle01");
CCAnimatedSprite::runAnimation((__int64)m_spiderSprite, &v24, m_platformerXVelocity);
if ( (v24 & 1) != 0 )
operator delete(__p);
}
else
{
PlayerObject::playDynamicSpiderRun(a1);
}
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))a1->m_iconSprite->setVisible)(a1->m_iconSprite, 0);
if ( !v19 )
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(v29);
LABEL_35:
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);
}
}
}