//
// CCAnimatedSprite::loadType from 0x5706a8 to 0x570e80 (2008 bytes)
//
// 2 xrefs:
// > CCAnimatedSprite::initWithType @ 0x570f20
// > ??> @ 0x90a20
//
// 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 CCAnimatedSprite::loadType(CCAnimatedSprite *a1, const char *a2, cocos2d::CCTexture2D *a3, bool a4)
{
cocos2d::CCPoint origin; // x28
unsigned __int64 v8; // x27
stl::StringData::Internal *m_data; // x0
unsigned __int64 v10; // x21
size_t v11; // x2
int v12; // w24
__int64 v13; // x21
__int64 *v14; // x0
ObjectManager *v15; // x0
cocos2d::CCDictionary *Definition; // x24
cocos2d::CCString *v17; // x28
void *v18; // x0
cocos2d::CCString *v19; // x2
void *v20; // x0
bool v21; // w0
_BOOL4 v22; // w27
cocos2d::CCString *v23; // x0
size_t v24; // x0
void *v25; // x0
SpriteAnimationManager *m_animationManager; // x0
void *v27; // x2
CCPartAnimSprite *m_paSprite; // x0
cocos2d::CCSprite *m_fbfSprite; // x0
SpriteAnimationManager *v30; // x24
void *v31; // x20
unsigned int *v32; // x19
int v33; // w0
cocos2d::CCString *v34; // x0
const char *v35; // x24
void *v36; // x0
CCPartAnimSprite *v37; // x24
CCAnimatedSprite_vtbl *v38; // x1
void (__fastcall *v39)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x26
const cocos2d::CCSize *v40; // x0
unsigned int *v41; // x28
int v42; // w1
cocos2d::CCSprite *v43; // x28
CCAnimatedSprite_vtbl *v44; // x1
const cocos2d::CCSize *v45; // x0
cocos2d::CCString *v46; // x26
void *v47; // x0
char *CString; // x0
cocos2d::CCTextureCache *v49; // x0
void *v50; // x0
unsigned int *v51; // x1
int v52; // w2
unsigned int *v53; // x1
int v54; // w3
unsigned int *v55; // x1
int v56; // w2
unsigned int *v57; // x1
int v58; // w0
unsigned int *v59; // x1
int v60; // w2
unsigned int *v61; // x1
int v62; // w2
unsigned int *v63; // x1
int v64; // w2
const char *v65; // [xsp+70h] [xbp+70h]
float v66; // [xsp+70h] [xbp+70h]
void (__fastcall *setPosition)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // [xsp+80h] [xbp+80h]
cocos2d::CCString *v68; // [xsp+88h] [xbp+88h]
_BOOL4 v69; // [xsp+88h] [xbp+88h]
cocos2d::CCString *v70; // [xsp+88h] [xbp+88h]
float v72; // [xsp+90h] [xbp+90h]
cocos2d::CCRect v73; // [xsp+B8h] [xbp+B8h] BYREF
std::string v74; // 0:x2.8
sub_D153B8((int)&v73, (char *)a2);
origin = v73.origin;
v8 = *(_QWORD *)(*(_QWORD *)&v73.origin - 24LL);
m_data = a1->m_unkString1.m_data.m_data;
v10 = *((_QWORD *)m_data - 3);
if ( v8 > v10 )
v11 = *((_QWORD *)m_data - 3);
else
v11 = *(_QWORD *)(*(_QWORD *)&v73.origin - 24LL);
v12 = memcmp(m_data, *(const void **)&v73.origin, v11);
if ( v12 || (v12 = 0x7FFFFFFF, v13 = v10 - v8, v13 > 0x7FFFFFFF) )
{
v14 = (__int64 *)(*(_QWORD *)&origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&origin - 24LL) == &qword_124B6B0 )
goto LABEL_7;
}
else
{
v14 = (__int64 *)(*(_QWORD *)&origin - 24LL);
if ( v13 >= (__int64)0xFFFFFFFF80000000LL )
v12 = v13;
else
v12 = 0x80000000;
if ( v14 == &qword_124B6B0 )
goto LABEL_7;
}
if ( &pthread_create )
{
v41 = (unsigned int *)(*(_QWORD *)&origin - 8LL);
do
v42 = __ldaxr(v41);
while ( __stlxr(v42 - 1, v41) );
}
else
{
v42 = *(_DWORD *)(*(_QWORD *)&origin - 8LL);
*(_DWORD *)(*(_QWORD *)&origin - 8LL) = v42 - 1;
}
if ( v42 <= 0 )
operator delete(v14);
LABEL_7:
if ( !v12 )
return;
CCAnimatedSprite::cleanupSprite(a1);
v15 = ObjectManager::instance();
Definition = ObjectManager::getDefinition(v15, a2);
if ( !a3 )
{
sub_D153B8((int)&v73, "spriteSheet");
v46 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(Definition, (const std::string *)&v73);
v47 = (void *)(*(_QWORD *)&v73.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v73.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v63 = (unsigned int *)(*(_QWORD *)&v73.origin - 8LL);
do
v64 = __ldaxr(v63);
while ( __stlxr(v64 - 1, v63) );
}
else
{
v64 = *(_DWORD *)(*(_QWORD *)&v73.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v73.origin - 8LL) = v64 - 1;
}
if ( v64 <= 0 )
operator delete(v47);
}
CString = (char *)cocos2d::CCString::getCString(v46);
sub_D153B8((int)&v73, CString);
sub_D15FD4(&v73, ".png", 4);
v49 = cocos2d::CCTextureCache::sharedTextureCache();
a3 = cocos2d::CCTextureCache::addImage(v49, *(const char **)&v73.origin, 0);
v50 = (void *)(*(_QWORD *)&v73.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v73.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v51 = (unsigned int *)(*(_QWORD *)&v73.origin - 8LL);
do
v52 = __ldaxr(v51);
while ( __stlxr(v52 - 1, v51) );
}
else
{
v52 = *(_DWORD *)(*(_QWORD *)&v73.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v73.origin - 8LL) = v52 - 1;
}
if ( v52 <= 0 )
operator delete(v50);
}
}
sub_D153B8((int)&v73, "useFBF");
v17 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(Definition, (const std::string *)&v73);
v18 = (void *)(*(_QWORD *)&v73.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v73.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v59 = (unsigned int *)(*(_QWORD *)&v73.origin - 8LL);
do
v60 = __ldaxr(v59);
while ( __stlxr(v60 - 1, v59) );
}
else
{
v60 = *(_DWORD *)(*(_QWORD *)&v73.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v73.origin - 8LL) = v60 - 1;
}
if ( v60 <= 0 )
operator delete(v18);
}
sub_D153B8((int)&v73, "usePA");
v19 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(Definition, (const std::string *)&v73);
v20 = (void *)(*(_QWORD *)&v73.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v73.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v53 = (unsigned int *)(*(_QWORD *)&v73.origin - 8LL);
do
v54 = __ldaxr(v53);
while ( __stlxr(v54 - 1, v53) );
}
else
{
v54 = *(_DWORD *)(*(_QWORD *)&v73.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v73.origin - 8LL) = v54 - 1;
}
if ( v54 <= 0 )
{
v70 = v19;
operator delete(v20);
v19 = v70;
}
}
if ( v17 )
{
v68 = v19;
v21 = cocos2d::CCString::boolValue(v17);
v19 = v68;
v22 = v21;
if ( v68 )
{
LABEL_19:
v69 = cocos2d::CCString::boolValue(v19);
goto LABEL_20;
}
}
else
{
v22 = 0;
if ( v19 )
goto LABEL_19;
}
v69 = 0;
LABEL_20:
sub_D153B8((int)&v73, "defaultAnimation");
v23 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(Definition, (const std::string *)&v73);
v65 = cocos2d::CCString::getCString(v23);
v24 = strlen(v65);
sub_D1798C(&a1->m_currentAnim, v65, v24);
v25 = (void *)(*(_QWORD *)&v73.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v73.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v55 = (unsigned int *)(*(_QWORD *)&v73.origin - 8LL);
do
v56 = __ldaxr(v55);
while ( __stlxr(v56 - 1, v55) );
}
else
{
v56 = *(_DWORD *)(*(_QWORD *)&v73.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v73.origin - 8LL) = v56 - 1;
}
if ( v56 <= 0 )
operator delete(v25);
}
if ( v22 )
{
cocos2d::CCRect::CCRect(&v73, 0.0, 0.0, 0.0, 0.0);
v43 = cocos2d::CCSprite::createWithTexture(a3);
v44 = a1->cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_fbfSprite = v43;
setPosition = v43->setPosition;
v66 = v44->getContentSize(a1)->width * 0.5;
v45 = a1->getContentSize(a1);
cocos2d::CCPoint::CCPoint(&v73.origin, v66, v45->height * 0.5);
setPosition(v43, &v73.origin);
a1->addChild(a1, a1->m_fbfSprite);
a1->m_sprite = a1->m_fbfSprite;
}
if ( v69 )
{
sub_D153B8((int)&v73, "animDesc");
v34 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(Definition, (const std::string *)&v73);
v35 = cocos2d::CCString::getCString(v34);
v36 = (void *)(*(_QWORD *)&v73.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v73.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v61 = (unsigned int *)(*(_QWORD *)&v73.origin - 8LL);
do
v62 = __ldaxr(v61);
while ( __stlxr(v62 - 1, v61) );
}
else
{
v62 = *(_DWORD *)(*(_QWORD *)&v73.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v73.origin - 8LL) = v62 - 1;
}
if ( v62 <= 0 )
operator delete(v36);
}
v37 = CCPartAnimSprite::createWithAnimDesc(v35, a3, a4);
v38 = a1->cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_paSprite = v37;
v39 = v37->setPosition;
v72 = v38->getContentSize(a1)->width * 0.5;
v40 = a1->getContentSize(a1);
cocos2d::CCPoint::CCPoint(&v73.origin, v72, v40->height * 0.5);
v39(v37, &v73.origin);
a1->addChild(a1, a1->m_paSprite);
a1->m_sprite = a1->m_paSprite;
}
a1->m_spriteMode = 0;
sub_D153B8((int)&v73, (char *)a2);
m_animationManager = (SpriteAnimationManager *)SpriteAnimationManager::createWithOwner(
(SpriteAnimationManager *)a1,
(CCAnimatedSprite *)&v73,
v74);
a1->m_animationManager = m_animationManager;
v27 = (void *)(*(_QWORD *)&v73.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v73.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v57 = (unsigned int *)(*(_QWORD *)&v73.origin - 8LL);
do
v58 = __ldaxr(v57);
while ( __stlxr(v58 - 1, v57) );
}
else
{
v58 = *(_DWORD *)(*(_QWORD *)&v73.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v73.origin - 8LL) = v58 - 1;
}
if ( v58 <= 0 )
operator delete(v27);
m_animationManager = a1->m_animationManager;
}
cocos2d::CCObject::retain(m_animationManager);
m_paSprite = a1->m_paSprite;
if ( m_paSprite )
m_paSprite->setVisible(m_paSprite, 0);
m_fbfSprite = a1->m_fbfSprite;
if ( m_fbfSprite )
m_fbfSprite->setVisible(m_fbfSprite, 0);
a1->setVisible(a1, 1);
v30 = a1->m_animationManager;
sub_D153B8((int)&v73, (char *)a1->m_currentAnim.m_data.m_data);
SpriteAnimationManager::runAnimation(v30, (std::string)&v73);
v31 = (void *)(*(_QWORD *)&v73.origin - 24LL);
if ( (__int64 *)(*(_QWORD *)&v73.origin - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v32 = (unsigned int *)(*(_QWORD *)&v73.origin - 8LL);
do
v33 = __ldaxr(v32);
while ( __stlxr(v33 - 1, v32) );
}
else
{
v33 = *(_DWORD *)(*(_QWORD *)&v73.origin - 8LL);
*(_DWORD *)(*(_QWORD *)&v73.origin - 8LL) = v33 - 1;
}
if ( v33 <= 0 )
operator delete(v31);
}
}