//
// CCAnimatedSprite::loadType from 0x1003500e0 to 0x1003507e2 (1794 bytes)
//
// 1 xrefs:
// > CCAnimatedSprite::initWithType @ 0x100350090
//
// 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 CCAnimatedSprite::loadType(CCAnimatedSprite *a1, const char *a2, cocos2d::CCTexture2D *a3, bool a4)
{
double v4; // xmm0_8
_BOOL4 v5; // r14d
size_t v7; // rax
std::string::size_type v8; // r12
char *data; // r14
size_t v10; // r15
std::string::pointer v11; // r14
unsigned int sizex2; // eax
std::size_t size; // rax
std::array *longStorage; // rdi
size_t v15; // rdx
std::string::pointer v16; // rsi
bool v17; // zf
char v18; // r13
CCPartAnimSprite *m_paSprite; // rdi
cocos2d::CCSprite *m_fbfSprite; // rdi
SpriteAnimationManager *m_animationManager; // rdi
cocos2d::CCSprite *v22; // rdi
CCPartAnimSprite *v23; // rdi
ObjectManager *v24; // rax
cocos2d::CCDictionary *Definition; // r13
cocos2d::CCString *v26; // r14
const char *v27; // r15
const char *v28; // r14
size_t v29; // rax
std::string::size_type v30; // r12
char *v31; // r13
const char *v32; // r15
size_t v33; // r14
cocos2d::CCTextureCache *v34; // rax
cocos2d::CCString *v35; // r14
cocos2d::CCString *v36; // r15
bool v37; // r12
bool v38; // r15
cocos2d::CCString *v39; // rax
const char *CString; // rax
cocos2d::CCSprite *v41; // r14
__int64 v42; // rax
cocos2d::CCString *v43; // rax
const char *v44; // r14
CCPartAnimSprite *v45; // r14
__int64 v46; // rax
size_t v47; // rax
size_t v48; // r15
char *v49; // r14
size_t v50; // r12
cocos2d::CCObject *v51; // rax
CCPartAnimSprite *v52; // rdi
cocos2d::CCSprite *v53; // rdi
std::array *p_shortStorage; // r14
SpriteAnimationManager *v55; // rbx
size_t v56; // rax
size_t v57; // r15
char *v58; // r12
size_t v59; // r13
SpriteAnimationManager **p_m_animationManager; // [rsp+8h] [rbp-98h]
_QWORD v62[2]; // [rsp+18h] [rbp-88h] BYREF
void *v63; // [rsp+28h] [rbp-78h]
_QWORD v64[2]; // [rsp+30h] [rbp-70h] BYREF
void *v65; // [rsp+40h] [rbp-60h]
_BOOL4 v66; // [rsp+4Ch] [rbp-54h]
cocos2d::CCDictionary *v67; // [rsp+50h] [rbp-50h]
cocos2d::CCTexture2D *v68; // [rsp+58h] [rbp-48h]
std::string __dst[2]; // [rsp+60h] [rbp-40h] BYREF
v5 = a4;
v68 = a3;
v7 = strlen(a2);
if ( v7 >= 0xFFFFFFFFFFFFFFF8LL )
goto LABEL_92;
v8 = v7;
v66 = v5;
if ( v7 >= 0x17 )
{
v10 = 26;
if ( (v7 | 7) != 0x17 )
v10 = (v7 | 7) + 1;
data = (char *)operator new(v10);
__dst[0].__r_.__value_.__r.__words[2] = (std::string::size_type)data;
__dst[0].__r_.__value_.__r.__words[0] = v10 + 1;
__dst[0].__r_.__value_.__l.__size_ = v8;
goto LABEL_8;
}
__dst[0].__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v7);
data = __dst[0].__r_.__value_.__s.__data_;
if ( v7 )
LABEL_8:
memcpy(data, a2, v8);
data[v8] = 0;
v11 = __dst[0].__r_.__value_.__l.__data_;
sizex2 = a1->m_unkString1.m_data.m_short.sizex2;
if ( (sizex2 & 1) != 0 )
{
size = a1->m_unkString1.m_data.m_long.size;
longStorage = (std::array *)a1->m_unkString1.m_data.m_long.longStorage;
}
else
{
size = sizex2 >> 1;
longStorage = &a1->m_unkString1.m_data.m_short.shortStorage;
}
v15 = *(_BYTE *)&__dst[0].__r_.__value_.__l.0 >> 1;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
v15 = __dst[0].__r_.__value_.__l.__size_;
v16 = __dst[0].__r_.__value_.__l.__data_;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) == 0 )
v16 = __dst[0].__r_.__value_.__s.__data_;
v17 = v15 == size;
if ( v15 >= size )
v15 = size;
v18 = v17 & (memcmp(longStorage, v16, v15) == 0);
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
operator delete(v11);
if ( !v18 )
{
m_paSprite = a1->m_paSprite;
if ( m_paSprite )
((void (__fastcall *)(CCPartAnimSprite *))m_paSprite->cleanup)(m_paSprite);
m_fbfSprite = a1->m_fbfSprite;
if ( m_fbfSprite )
((void (__fastcall *)(cocos2d::CCSprite *))m_fbfSprite->cleanup)(m_fbfSprite);
m_animationManager = a1->m_animationManager;
if ( m_animationManager )
SpriteAnimationManager::doCleanup(m_animationManager);
v22 = a1->m_fbfSprite;
if ( v22 )
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v22->removeFromParentAndCleanup)(v22, 1);
v23 = a1->m_paSprite;
if ( v23 )
((void (__fastcall *)(CCPartAnimSprite *, __int64))v23->removeFromParentAndCleanup)(v23, 1);
v4 = 0.0;
*(_OWORD *)&a1->m_fbfSprite = 0;
*(_OWORD *)&a1->m_animationManager = 0;
p_m_animationManager = &a1->m_animationManager;
a1->m_spriteMode = 0;
v24 = ObjectManager::instance();
Definition = ObjectManager::getDefinition(v24, a2);
if ( v68 )
{
LABEL_46:
__dst[0].__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)12;
*(_DWORD *)((char *)&__dst[0].__r_.__value_.__l.0 + 1) = 1181053813;
*(_WORD *)((char *)__dst[0].__r_.__value_.__r.__words + 5) = 17986;
__dst[0].__r_.__value_.__s.__data_[6] = 0;
v35 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey_1((__int64)Definition, (char *)__dst);
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst[0].__r_.__value_.__l.__data_);
strcpy((char *)__dst, "\nusePA");
v36 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey_1((__int64)Definition, (char *)__dst);
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst[0].__r_.__value_.__l.__data_);
if ( v35 )
{
v37 = cocos2d::CCString::boolValue(v35);
if ( v36 )
{
LABEL_52:
v38 = cocos2d::CCString::boolValue(v36);
goto LABEL_55;
}
}
else
{
v37 = 0;
if ( v36 )
goto LABEL_52;
}
v38 = 0;
LABEL_55:
strcpy((char *)__dst, " defaultAnimation");
v4 = *(double *)"defaultAnimation";
v39 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey_1((__int64)Definition, (char *)__dst);
CString = cocos2d::CCString::getCString(v39);
std::string::assign((std::string *)&a1->m_currentAnim, CString);
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
{
operator delete(__dst[0].__r_.__value_.__l.__data_);
if ( !v37 )
{
LABEL_57:
if ( !v38 )
goto LABEL_64;
goto LABEL_61;
}
}
else if ( !v37 )
{
goto LABEL_57;
}
sub_10028CC00((__int64)__dst, 0.0, 0.0, (__m128)0LL, (__m128)0LL);
v41 = cocos2d::CCSprite::createWithTexture(v68, (const cocos2d::CCRect *)__dst);
a1->m_fbfSprite = v41;
*(float *)&v67 = *(float *)((__int64 (__fastcall *)(CCAnimatedSprite *))a1->getContentSize)(a1) * 0.5;
v42 = ((__int64 (__fastcall *)(CCAnimatedSprite *))a1->getContentSize)(a1);
*(_QWORD *)&v4 = (unsigned int)v67;
sub_10028CBE0((float *)__dst, *(float *)&v67, 0.5 * *(float *)(v42 + 4));
((void (__fastcall *)(cocos2d::CCSprite *, std::string *))v41->setPosition)(v41, __dst);
((void (__fastcall *)(CCAnimatedSprite *, cocos2d::CCSprite *))a1->addChild)(a1, a1->m_fbfSprite);
a1->m_sprite = a1->m_fbfSprite;
if ( !v38 )
goto LABEL_64;
LABEL_61:
__dst[0].__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)16;
*(std::string::size_type *)((char *)__dst[0].__r_.__value_.__r.__words + 1) = 0x637365446D696E61LL;
__dst[0].__r_.__value_.__s.__data_[8] = 0;
v43 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey_1((__int64)Definition, (__int64)__dst);
v44 = cocos2d::CCString::getCString(v43);
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst[0].__r_.__value_.__l.__data_);
v45 = CCPartAnimSprite::createWithAnimDesc(v44, v68, v66);
a1->m_paSprite = v45;
*(float *)&v68 = *(float *)((__int64 (__fastcall *)(CCAnimatedSprite *))a1->getContentSize)(a1) * 0.5;
v46 = ((__int64 (__fastcall *)(CCAnimatedSprite *))a1->getContentSize)(a1);
*(_QWORD *)&v4 = (unsigned int)v68;
sub_10028CBE0((float *)__dst, *(float *)&v68, 0.5 * *(float *)(v46 + 4));
((void (__fastcall *)(CCPartAnimSprite *, std::string *))v45->setPosition)(v45, __dst);
((void (__fastcall *)(CCAnimatedSprite *, CCPartAnimSprite *))a1->addChild)(a1, a1->m_paSprite);
a1->m_sprite = a1->m_paSprite;
LABEL_64:
a1->m_spriteMode = 0;
v47 = strlen(a2);
if ( v47 >= 0xFFFFFFFFFFFFFFF8LL )
goto LABEL_92;
v48 = v47;
if ( v47 >= 0x17 )
{
v50 = 26;
if ( (v47 | 7) != 0x17 )
v50 = (v47 | 7) + 1;
v49 = (char *)operator new(v50);
v63 = v49;
v62[0] = v50 + 1;
v62[1] = v48;
}
else
{
LOBYTE(v62[0]) = 2 * v47;
v49 = (char *)v62 + 1;
if ( !v47 )
{
LABEL_72:
v49[v48] = 0;
v51 = (cocos2d::CCObject *)SpriteAnimationManager::createWithOwner(a1, v62);
*p_m_animationManager = (SpriteAnimationManager *)v51;
if ( (v62[0] & 1) != 0 )
{
operator delete(v63);
v51 = *p_m_animationManager;
}
cocos2d::CCObject::retain(v51);
v52 = a1->m_paSprite;
if ( v52 )
((void (__fastcall *)(CCPartAnimSprite *, _QWORD))v52->setVisible)(v52, 0);
v53 = a1->m_fbfSprite;
if ( v53 )
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))v53->setVisible)(v53, 0);
((void (__fastcall *)(CCAnimatedSprite *, __int64))a1->setVisible)(a1, 1);
if ( (a1->m_currentAnim.m_data.m_short.sizex2 & 1) != 0 )
p_shortStorage = (std::array *)a1->m_currentAnim.m_data.m_long.longStorage;
else
p_shortStorage = &a1->m_currentAnim.m_data.m_short.shortStorage;
v55 = a1->m_animationManager;
v56 = strlen(p_shortStorage->__elems_);
if ( v56 < 0xFFFFFFFFFFFFFFF8LL )
{
v57 = v56;
if ( v56 >= 0x17 )
{
v59 = 26;
if ( (v56 | 7) != 0x17 )
v59 = (v56 | 7) + 1;
v58 = (char *)operator new(v59);
v65 = v58;
v64[0] = v59 + 1;
v64[1] = v57;
}
else
{
LOBYTE(v64[0]) = 2 * v56;
v58 = (char *)v64 + 1;
if ( !v56 )
{
LABEL_89:
v58[v57] = 0;
SpriteAnimationManager::runAnimation(v55, v64);
if ( (v64[0] & 1) != 0 )
operator delete(v65);
return;
}
}
memmove(v58, p_shortStorage, v57);
goto LABEL_89;
}
LABEL_92:
sub_100006BF0(v4);
}
}
memcpy(v49, a2, v48);
goto LABEL_72;
}
__dst[0].__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)22;
*(std::string::size_type *)((char *)__dst[0].__r_.__value_.__r.__words + 1) = 0x6853657469727073LL;
LODWORD(__dst[0].__r_.__value_.__r.__words[1]) = 1952802152;
__dst[0].__r_.__value_.__s.__data_[11] = 0;
v26 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey_1((__int64)Definition, (char *)__dst);
v67 = Definition;
v27 = __dst[0].__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst[0].__r_.__value_.__l.__data_);
v28 = cocos2d::CCString::getCString(v26);
v29 = strlen(v28);
if ( v29 >= 0xFFFFFFFFFFFFFFF8LL )
goto LABEL_92;
v30 = v29;
if ( v29 >= 0x17 )
{
v32 = v28;
v33 = 26;
if ( (v29 | 7) != 0x17 )
v33 = (v29 | 7) + 1;
v31 = (char *)operator new(v33);
__dst[0].__r_.__value_.__r.__words[2] = (std::string::size_type)v31;
__dst[0].__r_.__value_.__r.__words[0] = v33 + 1;
v28 = v32;
v27 = __dst[0].__r_.__value_.__s.__data_;
__dst[0].__r_.__value_.__l.__size_ = v30;
}
else
{
__dst[0].__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v29);
v31 = __dst[0].__r_.__value_.__s.__data_;
if ( !v29 )
goto LABEL_42;
}
memmove(v31, v28, v30);
LABEL_42:
v31[v30] = 0;
std::string::append(__dst, ".png");
Definition = v67;
v34 = cocos2d::CCTextureCache::sharedTextureCache();
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
v27 = __dst[0].__r_.__value_.__l.__data_;
v68 = cocos2d::CCTextureCache::addImage(v34, v27, 0);
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst[0].__r_.__value_.__l.__data_);
goto LABEL_46;
}
}