//
// GJBigSprite::finishedLoadingSpriteAsync from 0x97f5f0 to 0x97f7b4 (452 bytes)
//
// 3 xrefs:
// > ??> @ 0x6ac80
// > GJBigSprite::loadSpriteAsync @ 0x97f414
// > ??> @ 0x122b7d0
//
// 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 GJBigSprite::finishedLoadingSpriteAsync(GJBigSprite *a1, cocos2d::CCObject *a2)
{
int v3; // w22
const char *v4; // x1
__int64 v5; // x20
__int64 v6; // x0
char *v7; // x0
unsigned int *v8; // x2
int v9; // w1
cocos2d::CCNode *v10; // x22
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x23
__int64 v12; // x0
cocos2d::CCNode_vtbl *v13; // x1
const char *v14; // [xsp+50h] [xbp+50h] BYREF
v3 = a2->getTag(a2);
v5 = cocos2d::CCArray::objectAtIndex(a1->m_spriteNodes, v3);
if ( *(_BYTE *)(v5 + 352) )
{
v6 = *(_QWORD *)(v5 + 328);
if ( v6 )
{
if ( (*(unsigned int (__fastcall **)(__int64))(*(_QWORD *)v6 + 64LL))(v6) == -1 )
{
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)(v5 + 328) + 520LL))(*(_QWORD *)(v5 + 328));
*(_QWORD *)(v5 + 328) = 0;
}
else if ( *(_QWORD *)(v5 + 328) )
{
return;
}
}
v10 = (cocos2d::CCNode *)cocos2d::CCSprite::create(*(cocos2d::CCSprite **)(v5 + 320), v4);
setPosition = v10->setPosition;
v12 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v5 + 192LL))(v5);
setPosition(v10, (const cocos2d::CCPoint *)v12);
a1->addChild(a1, v10);
v13 = v10->__vftable;
*(_QWORD *)(v5 + 328) = v10;
v13->setScale(v10, 1.002);
return;
}
sub_D18D28(&v14);
GJBigSprite::unloadSprite((__int64)a1, &v14, v3);
v7 = (char *)(v14 - 24);
if ( v14 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v8 = (unsigned int *)(v14 - 8);
do
v9 = __ldaxr(v8);
while ( __stlxr(v9 - 1, v8) );
}
else
{
v9 = *((_DWORD *)v14 - 2);
*((_DWORD *)v14 - 2) = v9 - 1;
}
if ( v9 <= 0 )
operator delete(v7);
}
}