//
// SpriteAnimationManager::runAnimation from 0x590224 to 0x590578 (852 bytes)
//
// 8 xrefs:
// > CCAnimatedSprite::loadType @ 0x570964
// > CCAnimatedSprite::runAnimation @ 0x571318
// > CCAnimatedSprite::runAnimationForced @ 0x571520
// > AnimatedGameObject::updateObjectAnimation @ 0x756734
// > AnimatedGameObject::updateObjectAnimation @ 0x7567a0
// > GJMapObject::startMonsterJumpLoop @ 0x97e510
// > GJMapObject::createMonster @ 0x97e7c8
// > ??> @ 0xa80d8
//
// 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::runAnimation(__int64 a1, const void **a2)
{
size_t v4; // x20
const void *v5; // x0
size_t v6; // x22
const void *v7; // x1
size_t v8; // x2
size_t v9; // x20
int Prio; // w25
char *v11; // x0
int v12; // w26
char *v13; // x0
char *v14; // x0
stl::StringData::Internal *m_data; // x20
char *v16; // x21
unsigned int *v17; // x20
int v18; // w0
unsigned int *v20; // x20
unsigned int *v21; // x1
int v22; // w2
unsigned int *v23; // x1
int v24; // w2
unsigned int *v25; // x1
int v26; // w2
std::string v27; // [xsp+60h] [xbp+60h] BYREF
v4 = *(_QWORD *)(*(_QWORD *)(a1 + 384) - 24LL);
v5 = *(const void **)(a1 + 384);
v6 = *((_QWORD *)*a2 - 3);
v7 = *a2;
if ( v6 > v4 )
v8 = v4;
else
v8 = v6;
if ( !memcmp(v5, v7, v8) )
{
v9 = v4 - v6;
if ( v9 + 0x80000000 <= 0xFFFFFFFF && !(_DWORD)v9 )
return _stack_chk_guard;
}
sub_D18D28(&v27, a2);
Prio = SpriteAnimationManager::getPrio(a1, &v27);
v11 = (char *)v27.m_data.m_data - 24;
if ( (__int64 *)v27.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v21 = (unsigned int *)((char *)v27.m_data.m_data - 8);
do
v22 = __ldaxr(v21);
while ( __stlxr(v22 - 1, v21) );
}
else
{
v22 = *((_DWORD *)v27.m_data.m_data - 2);
*((_DWORD *)v27.m_data.m_data - 2) = v22 - 1;
}
if ( v22 <= 0 )
operator delete(v11);
}
sub_D153B8((int)&v27, *(char **)(a1 + 384));
v12 = SpriteAnimationManager::getPrio(a1, &v27);
v13 = (char *)v27.m_data.m_data - 24;
if ( (__int64 *)v27.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v23 = (unsigned int *)((char *)v27.m_data.m_data - 8);
do
v24 = __ldaxr(v23);
while ( __stlxr(v24 - 1, v23) );
}
else
{
v24 = *((_DWORD *)v27.m_data.m_data - 2);
*((_DWORD *)v27.m_data.m_data - 2) = v24 - 1;
}
if ( v24 <= 0 )
operator delete(v13);
}
if ( Prio > v12 )
{
sub_D18D28(&v27, a2);
SpriteAnimationManager::queueAnimation(a1, (__int64)&v27);
m_data = v27.m_data.m_data;
v16 = (char *)v27.m_data.m_data - 24;
if ( (__int64 *)v27.m_data.m_data - 3 == &qword_124B6B0 )
return _stack_chk_guard;
if ( &pthread_create )
{
v20 = (unsigned int *)((char *)v27.m_data.m_data - 8);
do
v18 = __ldaxr(v20);
while ( __stlxr(v18 - 1, v20) );
LABEL_14:
if ( v18 <= 0 )
operator delete(v16);
return _stack_chk_guard;
}
LABEL_39:
v18 = *((_DWORD *)m_data - 2);
*((_DWORD *)m_data - 2) = v18 - 1;
goto LABEL_14;
}
sub_D153B8((int)&v27, *(char **)(a1 + 384));
SpriteAnimationManager::queueAnimation(a1, (__int64)&v27);
v14 = (char *)v27.m_data.m_data - 24;
if ( (__int64 *)v27.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v25 = (unsigned int *)((char *)v27.m_data.m_data - 8);
do
v26 = __ldaxr(v25);
while ( __stlxr(v26 - 1, v25) );
}
else
{
v26 = *((_DWORD *)v27.m_data.m_data - 2);
*((_DWORD *)v27.m_data.m_data - 2) = v26 - 1;
}
if ( v26 <= 0 )
operator delete(v14);
}
sub_D18D28(&v27, a2);
SpriteAnimationManager::executeAnimation(a1, &v27);
m_data = v27.m_data.m_data;
v16 = (char *)v27.m_data.m_data - 24;
if ( (__int64 *)v27.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v17 = (unsigned int *)((char *)v27.m_data.m_data - 8);
do
v18 = __ldaxr(v17);
while ( __stlxr(v18 - 1, v17) );
goto LABEL_14;
}
goto LABEL_39;
}
return _stack_chk_guard;
}