//
// CCAnimatedSprite::loadType from 0x140040250 to 0x140040b7d (2349 bytes)
//
// 4 xrefs:
// > CCAnimatedSprite::initWithType @ 0x14004022a
// > GJRobotSprite::init @ 0x1402a69df
// > AnimatedGameObject::init @ 0x1404a2ce7
// > ??> @ 0x1406c4224
//
// 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
//
// Hidden C++ exception states: #wind=7
void CCAnimatedSprite::loadType(CCAnimatedSprite *a1, const char *a2, cocos2d::CCTexture2D *a3, bool a4)
{
size_t v6; // rsi
size_t v7; // r8
void **v8; // rdx
char *v9; // r15
std::string *p_m_unkString1; // rcx
std::size_t m_size; // r12
size_t v12; // r8
size_t v13; // r13
_BOOL8 v14; // rdx
__int64 v15; // rbx
char *v16; // rax
CCPartAnimSprite *m_paSprite; // rcx
cocos2d::CCSprite *m_fbfSprite; // rcx
SpriteAnimationManager *m_animationManager; // rbx
cocos2d::CCSprite *v20; // rcx
CCPartAnimSprite *v21; // rcx
ObjectManager *v22; // rax
cocos2d::CCDictionary *Definition; // r13
cocos2d::CCString *v24; // rbx
const char *CString; // rax
size_t v26; // r8
void **v27; // rbx
cocos2d::CCTextureCache *v28; // rax
void *v29; // rcx
cocos2d::CCString *v30; // r15
void *v31; // rcx
cocos2d::CCString *v32; // rbx
void *v33; // rcx
bool v34; // r12
bool v35; // r15
cocos2d::CCString *v36; // rax
char *v37; // rax
size_t v38; // r8
void *v39; // rcx
const struct cocos2d::CCRect *v40; // rax
cocos2d::CCTexture2D *v41; // r12
cocos2d::CCSprite *v42; // rax
cocos2d::CCSprite_vtbl *v43; // rbx
float height; // xmm6_4
const cocos2d::CCSize *v45; // rax
const cocos2d::CCPoint *v46; // rax
cocos2d::CCString *v47; // rax
const char *v48; // r15
void *v49; // rcx
CCPartAnimSprite *v50; // rbx
CCPartAnimSprite_vtbl *v51; // rbx
float v52; // xmm6_4
const cocos2d::CCSize *v53; // rax
const cocos2d::CCPoint *v54; // rax
size_t v55; // r8
char *v56; // rbx
__int64 v57; // rax
_BOOL8 v58; // rdx
CCPartAnimSprite *v59; // rcx
cocos2d::CCSprite *v60; // rcx
std::string *p_m_currentAnim; // rdx
bool v62; // [rsp+38h] [rbp-79h]
struct cocos2d::CCTexture2D *v64; // [rsp+40h] [rbp-71h] BYREF
void *Buf2[2]; // [rsp+48h] [rbp-69h] BYREF
size_t Size; // [rsp+58h] [rbp-59h]
unsigned __int64 v67; // [rsp+60h] [rbp-51h]
void *v68[2]; // [rsp+68h] [rbp-49h] BYREF
__int64 v69; // [rsp+78h] [rbp-39h]
unsigned __int64 v70; // [rsp+80h] [rbp-31h]
void *Block[2]; // [rsp+88h] [rbp-29h] BYREF
__int64 v72; // [rsp+98h] [rbp-19h]
unsigned __int64 v73; // [rsp+A0h] [rbp-11h]
v64 = a3;
*(_OWORD *)Buf2 = 0;
Size = 0;
v67 = 0;
v6 = -1;
v7 = -1;
do
++v7;
while ( a2[v7] );
sub_14003A930(Buf2, a2, v7);
v8 = Buf2;
v62 = v67 > 0xF;
v9 = (char *)Buf2[0];
if ( v67 > 0xF )
v8 = (void **)Buf2[0];
p_m_unkString1 = &a1->m_unkString1;
if ( a1->m_unkString1.m_data.m_capacity > 0xF )
p_m_unkString1 = (std::string *)a1->m_unkString1.m_data.m_bigStorage;
m_size = a1->m_unkString1.m_data.m_size;
v12 = m_size;
v13 = Size;
if ( Size < m_size )
v12 = Size;
LODWORD(v15) = memcmp(p_m_unkString1, v8, v12);
if ( !(_DWORD)v15 )
{
if ( m_size >= v13 )
v15 = m_size > v13;
else
LODWORD(v15) = -1;
}
if ( v62 )
{
v16 = v9;
if ( v67 + 1 >= 0x1000 )
{
v9 = *((char **)v9 - 1);
if ( (unsigned __int64)(v16 - v9 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v9);
}
if ( (_DWORD)v15 )
{
m_paSprite = a1->m_paSprite;
if ( m_paSprite )
m_paSprite->cleanup(m_paSprite);
m_fbfSprite = a1->m_fbfSprite;
if ( m_fbfSprite )
m_fbfSprite->cleanup(m_fbfSprite);
m_animationManager = a1->m_animationManager;
if ( m_animationManager )
{
cocos2d::CCDictionary::removeAllObjects(m_animationManager->m_frameDict);
cocos2d::CCObject::release(m_animationManager);
}
v20 = a1->m_fbfSprite;
if ( v20 )
{
LOBYTE(v14) = 1;
v20->removeFromParentAndCleanup(v20, v14);
}
v21 = a1->m_paSprite;
if ( v21 )
{
LOBYTE(v14) = 1;
v21->removeFromParentAndCleanup(v21, v14);
}
a1->m_spriteMode = 0;
a1->m_animationManager = nullptr;
a1->m_fbfSprite = nullptr;
a1->m_paSprite = nullptr;
a1->m_sprite = nullptr;
v22 = ObjectManager::instance();
Definition = ObjectManager::getDefinition(v22, a2);
if ( !v64 )
{
Size = 11;
v67 = 15;
Buf2[0] = (void *)0x6853657469727073LL;
Buf2[1] = (void *)7628133;
v24 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(Definition, Buf2);
sub_14003A830((__int64)Buf2);
CString = cocos2d::CCString::getCString(v24);
*(_OWORD *)Block = 0;
v72 = 0;
v73 = 0;
v26 = -1;
do
++v26;
while ( CString[v26] );
sub_14003A930(Block, CString, v26);
sub_140041270(Block, ".png", 4u);
v27 = Block;
if ( v73 > 0xF )
v27 = (void **)Block[0];
v28 = (cocos2d::CCTextureCache *)cocos2d::CCTextureCache::sharedTextureCache();
v64 = cocos2d::CCTextureCache::addImage(v28, (const char *)v27, 0);
if ( v73 > 0xF )
{
v29 = Block[0];
if ( v73 + 1 >= 0x1000 )
{
v29 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v29 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v29);
}
v72 = 0;
v73 = 15;
LOBYTE(Block[0]) = 0;
}
*(_OWORD *)v68 = 0;
v69 = 6;
v70 = 15;
strcpy((char *)v68, "useFBF");
v30 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(Definition, v68);
if ( v70 > 0xF )
{
v31 = v68[0];
if ( v70 + 1 >= 0x1000 )
{
v31 = *((void **)v68[0] - 1);
if ( (unsigned __int64)((char *)v68[0] - (char *)v31 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v31);
}
v69 = 0;
v70 = 15;
LOBYTE(v68[0]) = 0;
*(_OWORD *)Buf2 = 0;
Size = 5;
v67 = 15;
strcpy((char *)Buf2, "usePA");
v32 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(Definition, Buf2);
if ( v67 > 0xF )
{
v33 = Buf2[0];
if ( v67 + 1 >= 0x1000 )
{
v33 = *((void **)Buf2[0] - 1);
if ( (unsigned __int64)((char *)Buf2[0] - (char *)v33 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v33);
}
Size = 0;
v67 = 15;
LOBYTE(Buf2[0]) = 0;
v34 = v30 && cocos2d::CCString::boolValue(v30);
v35 = v32 && cocos2d::CCString::boolValue(v32);
*(_OWORD *)Buf2 = 0;
Size = 0;
v67 = 15;
Buf2[0] = sub_14003AA10(0x20u);
Size = 16;
v67 = 31;
strcpy((char *)Buf2[0], "defaultAnimation");
v36 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(Definition, Buf2);
v37 = (char *)cocos2d::CCString::getCString(v36);
v38 = -1;
do
++v38;
while ( v37[v38] );
sub_14003CCE0((void **)&a1->m_currentAnim, v37, v38);
if ( v67 > 0xF )
{
v39 = Buf2[0];
if ( v67 + 1 >= 0x1000 )
{
v39 = *((void **)Buf2[0] - 1);
if ( (unsigned __int64)((char *)Buf2[0] - (char *)v39 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v39);
}
if ( v34 )
{
v40 = (const struct cocos2d::CCRect *)cocos2d::CCRect::CCRect((cocos2d::CCRect *)v68, 0.0, 0.0, 0.0, 0.0);
v41 = v64;
v42 = cocos2d::CCSprite::createWithTexture(v64, v40);
a1->m_fbfSprite = v42;
v43 = v42->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
height = a1->getContentSize(a1)->height;
v45 = a1->getContentSize(a1);
v46 = (const cocos2d::CCPoint *)cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v64,
v45->width * 0.5,
height * 0.5);
v43->setPosition_0(a1->m_fbfSprite, v46);
a1->addChild_1(a1, a1->m_fbfSprite);
a1->m_sprite = a1->m_fbfSprite;
}
else
{
v41 = v64;
}
if ( v35 )
{
Buf2[1] = nullptr;
Size = 8;
v67 = 15;
Buf2[0] = (void *)0x637365446D696E61LL;
v47 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(Definition, Buf2);
v48 = cocos2d::CCString::getCString(v47);
if ( v67 > 0xF )
{
v49 = Buf2[0];
if ( v67 + 1 >= 0x1000 )
{
v49 = *((void **)Buf2[0] - 1);
if ( (unsigned __int64)((char *)Buf2[0] - (char *)v49 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v49);
}
Size = 0;
v67 = 15;
LOBYTE(Buf2[0]) = 0;
v50 = (CCPartAnimSprite *)operator new(0x280u);
v64 = (struct cocos2d::CCTexture2D *)v50;
cocos2d::CCSprite::CCSprite(v50);
v50->cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable = (CCPartAnimSprite_vtbl *)&CCPartAnimSprite::`vftable';
v50->cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCRGBAProtocol::__vftable = (cocos2d::CCRGBAProtocol_vtbl *)&CCPartAnimSprite::`vftable';
v50->cocos2d::CCSprite::cocos2d::CCTextureProtocol::cocos2d::CCBlendProtocol::__vftable = (cocos2d::CCTextureProtocol_vtbl *)&CCPartAnimSprite::`vftable';
v50->m_spritePartIDs = nullptr;
v50->m_spriteFrame = nullptr;
v50->m_hasChanged = 0;
cocos2d::CCSize::CCSize(&v50->m_unkSize);
v50->m_spriteParts = nullptr;
if ( CCPartAnimSprite::initWithAnimDesc(v50, v48, v41, a4) )
{
cocos2d::CCObject::autorelease(v50);
}
else
{
((void (__fastcall *)(CCPartAnimSprite *, __int64))v50->~CCPartAnimSprite)(v50, 1);
v50 = nullptr;
}
a1->m_paSprite = v50;
v51 = v50->cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v52 = a1->getContentSize(a1)->height;
v53 = a1->getContentSize(a1);
v54 = (const cocos2d::CCPoint *)cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v64, v53->width * 0.5, v52 * 0.5);
v51->setPosition_0(a1->m_paSprite, v54);
a1->addChild_1(a1, a1->m_paSprite);
a1->m_sprite = a1->m_paSprite;
}
a1->m_spriteMode = 0;
*(_OWORD *)Buf2 = 0;
Size = 0;
v67 = 0;
v55 = -1;
do
++v55;
while ( a2[v55] );
sub_14003A930(Buf2, a2, v55);
v64 = (struct cocos2d::CCTexture2D *)Buf2;
v56 = (char *)operator new(0x1D8u);
v68[0] = v56;
cocos2d::CCNode::CCNode((cocos2d::CCNode *)v56);
*(_QWORD *)v56 = &SpriteAnimationManager::`vftable';
*((_QWORD *)v56 + 40) = 0;
*((_QWORD *)v56 + 41) = 0;
*((_QWORD *)v56 + 42) = 0;
*((_QWORD *)v56 + 43) = 0;
*((_OWORD *)v56 + 22) = 0;
*((_QWORD *)v56 + 46) = 0;
*((_QWORD *)v56 + 47) = 15;
v56[352] = 0;
*((_QWORD *)v56 + 50) = 0;
*(_OWORD *)(v56 + 408) = 0;
*((_QWORD *)v56 + 53) = 0;
*((_QWORD *)v56 + 54) = 15;
v56[408] = 0;
*(_OWORD *)(v56 + 440) = 0;
*((_QWORD *)v56 + 57) = 0;
*((_QWORD *)v56 + 58) = 15;
v56[440] = 0;
v57 = sub_14003BDB0((__int64)Block, (__int64)Buf2);
if ( (unsigned __int8)SpriteAnimationManager::initWithOwner(v56, a1, v57) )
{
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v56);
}
else
{
(*(void (__fastcall **)(char *, __int64))(*(_QWORD *)v56 + 8LL))(v56, 1);
v56 = nullptr;
}
sub_14003A830((__int64)Buf2);
a1->m_animationManager = (SpriteAnimationManager *)v56;
cocos2d::CCObject::retain((cocos2d::CCObject *)v56);
v59 = a1->m_paSprite;
if ( v59 )
v59->setVisible(v59, 0);
v60 = a1->m_fbfSprite;
if ( v60 )
v60->setVisible(v60, 0);
LOBYTE(v58) = 1;
a1->setVisible(a1, v58);
p_m_currentAnim = &a1->m_currentAnim;
if ( a1->m_currentAnim.m_data.m_capacity > 0xF )
p_m_currentAnim = (std::string *)p_m_currentAnim->m_data.m_bigStorage;
*(_OWORD *)Buf2 = 0;
Size = 0;
v67 = 0;
do
++v6;
while ( p_m_currentAnim->m_data.m_smallStorage._Elems[v6] );
sub_14003A930(Buf2, p_m_currentAnim, v6);
SpriteAnimationManager::runAnimation(a1->m_animationManager, Buf2);
}
}