//
// SpriteAnimationManager::executeAnimation from 0x58fd60 to 0x590224 (1220 bytes)
//
// 3 xrefs:
// > SpriteAnimationManager::runAnimation @ 0x590350
// > SpriteAnimationManager::runQueuedAnimation @ 0x590684
// > ??> @ 0xa6b48
//
// 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
//
__int64 __fastcall SpriteAnimationManager::executeAnimation(__int64 a1, const std::string *a2)
{
_QWORD *v4; // x0
unsigned __int64 v5; // x21
stl::StringData::Internal *m_data; // x1
unsigned __int64 v7; // x23
size_t v8; // x2
unsigned __int64 v9; // x21
char *v10; // x0
__int64 v11; // x24
int v12; // w25
spriteMode AnimType; // w26
char *v14; // x0
const char *v15; // x1
cocos2d::CCDictionary *v16; // x22
cocos2d::CCString *v17; // x0
char *CString; // x0
__int64 v19; // x22
char *v20; // x0
spriteMode v22; // w25
char *v23; // x22
unsigned int *v24; // x1
int v25; // w2
_BOOL4 v26; // w28
_DWORD *v27; // x26
size_t v28; // x3
stl::StringData::Internal *v29; // x0
size_t v30; // x27
size_t v31; // x2
size_t v32; // x27
char *v33; // x0
unsigned int *v34; // x26
int v35; // w1
unsigned int *v36; // x21
int v37; // w0
unsigned int *v38; // x1
int v39; // w2
unsigned int *v40; // x21
int v41; // w1
_QWORD v42[2]; // [xsp+0h] [xbp+0h] BYREF
size_t v43; // [xsp+68h] [xbp+68h]
void *v44; // [xsp+80h] [xbp+80h] BYREF
v4 = *(_QWORD **)(a1 + 384);
v5 = *(v4 - 3);
m_data = a2->m_data.m_data;
v7 = *((_QWORD *)m_data - 3);
if ( v7 > v5 )
v8 = *(v4 - 3);
else
v8 = *((_QWORD *)m_data - 3);
if ( !memcmp(v4, m_data, v8) )
{
v9 = v5 - v7;
if ( v9 + 0x80000000 <= 0xFFFFFFFF && !(_DWORD)v9 )
return _stack_chk_guard;
}
cocos2d::CCNode::stopAllActions(*(cocos2d::CCNode **)(*(_QWORD *)(a1 + 320) + 624LL));
sub_D18EA8(a1 + 384, a2);
sub_D18D28(&v44, a2);
SpriteAnimationManager::playSoundForAnimation(a1, (const std::string *)&v44);
v10 = (char *)v44 - 24;
if ( (char *)v44 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v24 = (unsigned int *)((char *)v44 - 8);
do
v25 = __ldaxr(v24);
while ( __stlxr(v25 - 1, v24) );
}
else
{
v25 = *((_DWORD *)v44 - 2);
*((_DWORD *)v44 - 2) = v25 - 1;
}
if ( v25 <= 0 )
operator delete(v10);
}
v11 = cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(a1 + 376), a2);
if ( !*(_DWORD *)(v11 + 28) )
{
v12 = *(_DWORD *)(*(_QWORD *)(a1 + 320) + 648LL);
sub_D18D28(&v44, a2);
AnimType = (unsigned int)SpriteAnimationManager::getAnimType(a1, (const std::string *)&v44);
v14 = (char *)v44 - 24;
if ( (char *)v44 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v38 = (unsigned int *)((char *)v44 - 8);
do
v39 = __ldaxr(v38);
while ( __stlxr(v39 - 1, v38) );
}
else
{
v39 = *((_DWORD *)v44 - 2);
*((_DWORD *)v44 - 2) = v39 - 1;
}
if ( v39 <= 0 )
operator delete(v14);
}
CCAnimatedSprite::willPlayAnimation(*(CCAnimatedSprite **)(a1 + 320));
CCAnimatedSprite::switchToMode(*(CCAnimatedSprite **)(a1 + 320), AnimType);
if ( v12 != *(_DWORD *)(*(_QWORD *)(a1 + 320) + 648LL) )
goto LABEL_10;
v26 = 0;
sub_D153B8((unsigned int)v42 + 128, "spawn");
v27 = v44;
v28 = *((_QWORD *)v44 - 3);
v29 = a2->m_data.m_data;
v30 = *((_QWORD *)a2->m_data.m_data - 3);
v43 = v28;
if ( v28 > v30 )
v31 = v30;
else
v31 = v28;
if ( !memcmp(v29, v44, v31) )
{
v32 = v30 - v43;
if ( v32 + 0x80000000 <= 0xFFFFFFFF )
v26 = v32 == 0;
}
v33 = (char *)(v27 - 6);
if ( v27 - 6 == (_DWORD *)&qword_124B6B0 )
goto LABEL_30;
if ( &pthread_create )
{
v34 = v27 - 2;
do
v35 = __ldaxr(v34);
while ( __stlxr(v35 - 1, v34) );
}
else
{
v35 = *(v27 - 2);
*(v27 - 2) = v35 - 1;
}
if ( v35 > 0 )
{
LABEL_30:
if ( v26 )
goto LABEL_10;
}
else
{
operator delete(v33);
if ( v26 )
{
LABEL_10:
v15 = (const char *)a2->m_data.m_data;
v16 = *(cocos2d::CCDictionary **)(a1 + 376);
v17 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%s_first", v15);
CString = (char *)cocos2d::CCString::getCString(v17);
sub_D153B8((unsigned int)v42 + 128, CString);
v19 = cocos2d::CCDictionary::objectForKey(v16, (const std::string *)&v44);
v20 = (char *)v44 - 24;
if ( (char *)v44 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v40 = (unsigned int *)((char *)v44 - 8);
do
v41 = __ldaxr(v40);
while ( __stlxr(v41 - 1, v40) );
}
else
{
v41 = *((_DWORD *)v44 - 2);
*((_DWORD *)v44 - 2) = v41 - 1;
}
if ( v41 <= 0 )
operator delete(v20);
}
if ( (unsigned int)(*(_DWORD *)(v19 + 28) - 1) <= 1 )
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(*(_QWORD *)(a1 + 320) + 624LL) + 1144LL))(
*(_QWORD *)(*(_QWORD *)(a1 + 320) + 624LL),
v19);
}
}
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v11 + 72LL))(v11, 1);
cocos2d::CCNode::runAction(*(cocos2d::CCNode **)(*(_QWORD *)(a1 + 320) + 624LL), (cocos2d::CCAction *)v11);
return _stack_chk_guard;
}
sub_D18D28(&v44, a2);
v22 = (unsigned int)SpriteAnimationManager::getAnimType(a1, (const std::string *)&v44);
v23 = (char *)v44 - 24;
if ( (char *)v44 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v36 = (unsigned int *)((char *)v44 - 8);
do
v37 = __ldaxr(v36);
while ( __stlxr(v37 - 1, v36) );
}
else
{
v37 = *((_DWORD *)v44 - 2);
*((_DWORD *)v44 - 2) = v37 - 1;
}
if ( v37 <= 0 )
operator delete(v23);
}
CCAnimatedSprite::willPlayAnimation(*(CCAnimatedSprite **)(a1 + 320));
CCAnimatedSprite::switchToMode(*(CCAnimatedSprite **)(a1 + 320), v22);
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(*(_QWORD *)(a1 + 320) + 624LL) + 1144LL))(
*(_QWORD *)(*(_QWORD *)(a1 + 320) + 624LL),
v11);
return _stack_chk_guard;
}