//
// CCAnimatedSprite::initWithType from 0x140040030 to 0x14004024b (539 bytes)
//
// 2 xrefs:
// > GJShopLayer::init @ 0x1402aa5a6
// > ??> @ 0x1406c4218
//
// 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=3
bool CCAnimatedSprite::initWithType(CCAnimatedSprite *a1, const char *a2, cocos2d::CCTexture2D *a3, bool a4)
{
struct cocos2d::CCTexture2D *v5; // rbx
ObjectManager *v8; // rax
cocos2d::CCDictionary *Definition; // rax
cocos2d::CCString *v10; // rax
const char *CString; // rax
size_t v12; // r8
void *v13; // rcx
void **v14; // rbx
cocos2d::CCTextureCache *v15; // rax
void *v16; // rcx
const struct cocos2d::CCRect *v17; // rax
bool result; // al
void *Block[2]; // [rsp+30h] [rbp-50h] BYREF
__int64 v20; // [rsp+40h] [rbp-40h]
unsigned __int64 v21; // [rsp+48h] [rbp-38h]
void *Src[2]; // [rsp+50h] [rbp-30h] BYREF
__m128i si128; // [rsp+60h] [rbp-20h]
v5 = a3;
if ( !a3 )
{
v8 = ObjectManager::instance();
Definition = ObjectManager::getDefinition(v8, a2);
HIDWORD(Block[1]) = 0;
v20 = 11;
v21 = 15;
strcpy((char *)Block, "spriteSheet");
v10 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(Definition, Block);
CString = cocos2d::CCString::getCString(v10);
*(_OWORD *)Src = 0;
si128 = 0;
v12 = -1;
do
++v12;
while ( CString[v12] );
sub_14003A930(Src, CString, v12);
if ( v21 > 0xF )
{
v13 = Block[0];
if ( v21 + 1 >= 0x1000 )
{
v13 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v13 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v13);
}
v20 = 0;
v21 = 15;
LOBYTE(Block[0]) = 0;
sub_140041270(Src, ".png", 4u);
v14 = Src;
if ( si128.m128i_i64[1] > 0xFuLL )
v14 = (void **)Src[0];
v15 = (cocos2d::CCTextureCache *)cocos2d::CCTextureCache::sharedTextureCache();
v5 = cocos2d::CCTextureCache::addImage(v15, (const char *)v14, 0);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v16 = Src[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v16 = *((void **)Src[0] - 1);
if ( (unsigned __int64)((char *)Src[0] - (char *)v16 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v16);
}
si128 = _mm_load_si128((const __m128i *)&xmmword_140623F30);
LOBYTE(Src[0]) = 0;
}
v17 = (const struct cocos2d::CCRect *)cocos2d::CCRect::CCRect((cocos2d::CCRect *)Block, 0.0, 0.0, 0.0, 0.0);
result = cocos2d::CCSprite::initWithTexture(a1, v5, v17);
if ( result )
{
a1->m_bDontDraw = 1;
sub_14003CCE0((void **)&a1->m_unkString1, byte_140518980, 0);
CCAnimatedSprite::loadType(a1, a2, v5, a4);
return 1;
}
return result;
}