//
// PlayerObject::createSpider from 0x6224ac to 0x622844 (920 bytes)
//
// 4 xrefs:
// > PlayerObject::updatePlayerSpiderFrame @ 0x627954
// > PlayerObject::updatePlayerSpiderFrame @ 0x62795c
// > PlayerObject::init @ 0x63db08
// > ??> @ 0x3ba18
//
// 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::createSpider(PlayerObject *a1, int a2)
{
GLubyte g; // w27
GLubyte r; // w28
_BOOL4 v6; // w22
GJSpiderSprite *m_spiderSprite; // x1
void *v8; // x0
GJSpiderSprite *v9; // x0
cocos2d::CCTexture2D *v10; // x0
cocos2d::CCSpriteBatchNode *v11; // x0
cocos2d::CCSpriteBatchNode_vtbl *v12; // x2
GJSpiderSprite *v13; // x0
GJSpiderSprite *v14; // x0
GJSpiderSprite *v15; // x22
void *v16; // x0
void *v17; // x0
unsigned int *v18; // x1
int v19; // w2
unsigned int *v20; // x19
int v21; // w1
unsigned int *v22; // x1
int v23; // w2
_BOOL4 v24; // [xsp+6Ch] [xbp+6Ch]
GLubyte b; // [xsp+70h] [xbp+70h]
GLubyte v26; // [xsp+74h] [xbp+74h]
GLubyte v27; // [xsp+78h] [xbp+78h]
GLubyte v28; // [xsp+7Ch] [xbp+7Ch]
__int64 v29; // [xsp+90h] [xbp+90h] BYREF
__int64 v30; // [xsp+98h] [xbp+98h] BYREF
__int64 v31; // [xsp+A0h] [xbp+A0h] BYREF
v6 = a1->m_spiderSprite != nullptr;
sub_D153B8((int)&v29, &byte_F288A0);
if ( v6 )
{
m_spiderSprite = a1->m_spiderSprite;
b = m_spiderSprite->m_color.b;
r = m_spiderSprite->m_color.r;
g = m_spiderSprite->m_color.g;
v26 = m_spiderSprite->m_secondColor.r;
v27 = m_spiderSprite->m_secondColor.g;
v28 = m_spiderSprite->m_secondColor.b;
v24 = m_spiderSprite->m_glowSprite->isVisible(m_spiderSprite->m_glowSprite);
sub_D18D28(&v30, &a1->m_spiderSprite->m_animationManager->m_currentAnimation);
sub_D163D4(&v29, &v30);
v8 = (void *)(v30 - 24);
if ( (__int64 *)(v30 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v18 = (unsigned int *)(v30 - 8);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *(_DWORD *)(v30 - 8);
*(_DWORD *)(v30 - 8) = v19 - 1;
}
if ( v19 <= 0 )
operator delete(v8);
}
a1->m_spiderBatchNode->removeMeAndCleanup(a1->m_spiderBatchNode);
cocos2d::CCObject::release(a1->m_spiderBatchNode);
a1->m_spiderSprite = nullptr;
}
v9 = GJSpiderSprite::create(a2);
a1->m_spiderSprite = v9;
v9->m_delegate = &a1->AnimatedSpriteDelegate;
v10 = a1->m_spiderSprite->getTexture(a1->m_spiderSprite);
v11 = cocos2d::CCSpriteBatchNode::createWithTexture(v10, (unsigned int)&off_18 + 1);
v12 = v11->cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_spiderBatchNode = v11;
v12->addChild(v11, a1->m_spiderSprite);
cocos2d::CCObject::retain(a1->m_spiderBatchNode);
if ( v6 )
{
if ( a1->m_isSpider )
a1->m_mainLayer->addChild_0(a1->m_mainLayer, a1->m_spiderBatchNode, 2);
v13 = a1->m_spiderSprite;
v13->m_color.b = b;
v13->m_color.r = r;
v13->m_color.g = g;
v14 = a1->m_spiderSprite;
v14->m_secondColor.r = v26;
v14->m_secondColor.g = v27;
v14->m_secondColor.b = v28;
GJRobotSprite::updateColors(a1->m_spiderSprite);
GJRobotSprite::updateGlowColor(a1->m_spiderSprite, (cocos2d::ccColor3B)*(_QWORD *)&a1->m_playerColor2.r, 0);
v15 = a1->m_spiderSprite;
sub_D18D28(&v31, &v29);
CCAnimatedSprite::runAnimation((__int64)v15, (__int64)&v31);
v16 = (void *)(v31 - 24);
if ( (__int64 *)(v31 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v22 = (unsigned int *)(v31 - 8);
do
v23 = __ldaxr(v22);
while ( __stlxr(v23 - 1, v22) );
}
else
{
v23 = *(_DWORD *)(v31 - 8);
*(_DWORD *)(v31 - 8) = v23 - 1;
}
if ( v23 <= 0 )
operator delete(v16);
}
if ( v24 )
GJRobotSprite::showGlow(a1->m_spiderSprite);
}
v17 = (void *)(v29 - 24);
if ( (__int64 *)(v29 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v20 = (unsigned int *)(v29 - 8);
do
v21 = __ldaxr(v20);
while ( __stlxr(v21 - 1, v20) );
}
else
{
v21 = *(_DWORD *)(v29 - 8);
*(_DWORD *)(v29 - 8) = v21 - 1;
}
if ( v21 <= 0 )
operator delete(v17);
}
}