//
// CCAnimatedSprite::initWithType from 0x140043a60 to 0x140043ccd (621 bytes)
//
// 2 xrefs:
// > GJShopLayer::init @ 0x1403b08a0
// > ??> @ 0x14090f734
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:25:30 +0000
//
// Hidden C++ exception states: #wind=3
bool __fastcall CCAnimatedSprite::initWithType(
__int64 a1,
__int64 a2,
struct cocos2d::CCTexture2D *a3,
unsigned __int8 a4)
{
struct cocos2d::CCTexture2D *v5; // rbx
__int64 v8; // rax
__int64 Definition; // rax
cocos2d::CCString *v10; // rax
const char *CString; // rax
size_t v12; // r8
void *v13; // rcx
__m128i v14; // xmm6
void **v15; // rbx
cocos2d::CCTextureCache *v16; // rax
void *v17; // r8
const struct cocos2d::CCRect *v18; // rax
bool result; // al
void *Block[2]; // [rsp+30h] [rbp-78h] BYREF
__m128i si128; // [rsp+40h] [rbp-68h]
void *Src[2]; // [rsp+50h] [rbp-58h] BYREF
__m128i v23; // [rsp+60h] [rbp-48h]
v5 = a3;
if ( !a3 )
{
v8 = ObjectManager::instance();
Definition = ObjectManager::getDefinition(v8, a2);
HIDWORD(Block[1]) = 0;
si128 = _mm_load_si128((const __m128i *)&xmmword_1408365C0);
strcpy((char *)Block, "spriteSheet");
v10 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(Definition, Block);
CString = cocos2d::CCString::getCString(v10);
*(_OWORD *)Src = 0;
v23 = 0;
v12 = -1;
do
++v12;
while ( CString[v12] );
sub_14003D230(Src, CString, v12);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v13 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v13 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v13 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v13);
}
v14 = _mm_load_si128((const __m128i *)&Size);
si128 = v14;
LOBYTE(Block[0]) = 0;
sub_140044D80(Src, ".png", 4u);
v15 = Src;
if ( v23.m128i_i64[1] > 0xFuLL )
v15 = (void **)Src[0];
v16 = (cocos2d::CCTextureCache *)cocos2d::CCTextureCache::sharedTextureCache();
v5 = cocos2d::CCTextureCache::addImage(v16, (const char *)v15, 0);
if ( v23.m128i_i64[1] > 0xFuLL )
{
v17 = Src[0];
if ( (unsigned __int64)(v23.m128i_i64[1] + 1) >= 0x1000 )
{
v17 = *((void **)Src[0] - 1);
if ( (unsigned __int64)((char *)Src[0] - (char *)v17 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v17);
v14 = _mm_load_si128((const __m128i *)&Size);
}
v23 = v14;
LOBYTE(Src[0]) = 0;
}
v18 = (const struct cocos2d::CCRect *)cocos2d::CCRect::CCRect((cocos2d::CCRect *)Block, 0.0, 0.0, 0.0, 0.0);
result = cocos2d::CCSprite::initWithTexture((cocos2d::CCSprite *)a1, v5, v18);
if ( result )
{
*(_BYTE *)(a1 + 559) = 1;
sub_1400405A0((void **)(a1 + 600), &byte_1406ED6E0, 0);
CCAnimatedSprite::loadType(a1, a2, v5, a4);
return 1;
}
return result;
}