//
// CCAnimatedSprite::initWithType from 0x570e80 to 0x5710d4 (596 bytes)
//
// 4 xrefs:
// > CCAnimatedSprite::createWithType @ 0x571160
// > GJRobotSprite::init @ 0x8e3678
// > AnimatedShopKeeper::init @ 0x92dbc4
// > ??> @ 0x443d0
//
// 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
//
bool CCAnimatedSprite::initWithType(CCAnimatedSprite *a1, const char *a2, cocos2d::CCTexture2D *a3, bool a4)
{
cocos2d::CCTexture2D *v4; // x20
char v8; // w21
ObjectManager *v10; // x0
cocos2d::CCDictionary *Definition; // x20
cocos2d::CCString *v12; // x0
char *CString; // x0
void *v14; // x0
cocos2d::CCTextureCache *v15; // x0
char *v16; // x0
unsigned int *v17; // x1
int v18; // w2
unsigned int *v19; // x1
int v20; // w2
char *v21; // [xsp+60h] [xbp+60h] BYREF
cocos2d::CCRect v22; // [xsp+68h] [xbp+68h] BYREF
v4 = a3;
if ( !a3 )
{
v10 = ObjectManager::instance();
Definition = ObjectManager::getDefinition(v10, a2);
sub_D153B8((int)&v22, "spriteSheet");
v12 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(Definition, (const std::string *)&v22);
CString = (char *)cocos2d::CCString::getCString(v12);
sub_D153B8((int)&v21, CString);
v14 = (void *)(*(_QWORD *)&v22.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v22.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v19 = (unsigned int *)(*(_QWORD *)&v22.origin - 8LL);
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *(_DWORD *)(*(_QWORD *)&v22.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v22.origin - 8LL) = v20 - 1;
}
if ( v20 <= 0 )
operator delete(v14);
}
sub_D15FD4(&v21, ".png", 4);
v15 = cocos2d::CCTextureCache::sharedTextureCache();
v4 = cocos2d::CCTextureCache::addImage(v15, v21, 0);
v16 = v21 - 24;
if ( v21 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v17 = (unsigned int *)(v21 - 8);
do
v18 = __ldaxr(v17);
while ( __stlxr(v18 - 1, v17) );
}
else
{
v18 = *((_DWORD *)v21 - 2);
*((_DWORD *)v21 - 2) = v18 - 1;
}
if ( v18 <= 0 )
operator delete(v16);
}
}
cocos2d::CCRect::CCRect(&v22, 0.0, 0.0, 0.0, 0.0);
v8 = cocos2d::CCSprite::initWithTexture(a1, v4, &v22);
if ( v8 )
{
a1->m_bDontDraw = 1;
sub_D1798C(&a1->m_unkString1, &byte_F288A0, 0);
CCAnimatedSprite::loadType(a1, a2, v4, a4);
}
return v8;
}