//
// SpriteAnimationManager::runQueuedAnimation from 0x590578 to 0x590768 (496 bytes)
//
// 2 xrefs:
// > SpriteAnimationManager::finishAnimation @ 0x590818
// > ??> @ 0x3ec70
//
// 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
//
void SpriteAnimationManager::runQueuedAnimation(SpriteAnimationManager *a1)
{
_DWORD *v2; // x22
unsigned __int64 v3; // x26
stl::StringData::Internal *m_data; // x0
unsigned __int64 v5; // x20
size_t v6; // x2
int v7; // w19
__int64 v8; // x20
__int64 *v9; // x0
char *v10; // x19
unsigned int *v11; // x22
int v12; // w1
unsigned int *v13; // x22
int v14; // w0
void *v15; // [xsp+70h] [xbp+70h] BYREF
sub_D153B8((int)&v15, "not_used");
v2 = v15;
v3 = *((_QWORD *)v15 - 3);
m_data = a1->m_queuedAnimation.m_data.m_data;
v5 = *((_QWORD *)m_data - 3);
if ( v3 > v5 )
v6 = *((_QWORD *)m_data - 3);
else
v6 = *((_QWORD *)v15 - 3);
v7 = memcmp(m_data, v15, v6);
if ( v7 || (v7 = 0x7FFFFFFF, v8 = v5 - v3, v8 > 0x7FFFFFFF) )
{
v9 = (__int64 *)(v2 - 6);
if ( v2 - 6 == (_DWORD *)&qword_124B6B0 )
goto LABEL_7;
}
else
{
v9 = (__int64 *)(v2 - 6);
if ( v8 >= (__int64)0xFFFFFFFF80000000LL )
v7 = v8;
else
v7 = 0x80000000;
if ( v9 == &qword_124B6B0 )
goto LABEL_7;
}
if ( &pthread_create )
{
v11 = v2 - 2;
do
v12 = __ldaxr(v11);
while ( __stlxr(v12 - 1, v11) );
}
else
{
v12 = *(v2 - 2);
*(v2 - 2) = v12 - 1;
}
if ( v12 <= 0 )
operator delete(v9);
LABEL_7:
if ( v7 )
{
sub_D153B8((int)&v15, (char *)a1->m_queuedAnimation.m_data.m_data);
SpriteAnimationManager::executeAnimation((__int64)a1, (const std::string *)&v15);
v10 = (char *)v15 - 24;
if ( (char *)v15 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v13 = (unsigned int *)((char *)v15 - 8);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *((_DWORD *)v15 - 2);
*((_DWORD *)v15 - 2) = v14 - 1;
}
if ( v14 <= 0 )
operator delete(v10);
}
sub_D1798C(&a1->m_queuedAnimation, "not_used", 8);
}
}