//
// SpriteAnimationManager::queueAnimation from 0x58fb98 to 0x58fd48 (432 bytes)
//
// 3 xrefs:
// > SpriteAnimationManager::runAnimation @ 0x590324
// > SpriteAnimationManager::runAnimation @ 0x5903e4
// > ??> @ 0x5b3c8
//
// 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::queueAnimation(__int64 a1, __int64 a2)
{
int Prio; // w23
char *v5; // x0
int v6; // w20
char *v7; // x0
unsigned int *v9; // x1
int v10; // w2
unsigned int *v11; // x1
int v12; // w2
std::string v13; // [xsp+50h] [xbp+50h] BYREF
sub_D18D28(&v13, a2);
Prio = SpriteAnimationManager::getPrio(a1, &v13);
v5 = (char *)v13.m_data.m_data - 24;
if ( (__int64 *)v13.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v11 = (unsigned int *)((char *)v13.m_data.m_data - 8);
do
v12 = __ldaxr(v11);
while ( __stlxr(v12 - 1, v11) );
}
else
{
v12 = *((_DWORD *)v13.m_data.m_data - 2);
*((_DWORD *)v13.m_data.m_data - 2) = v12 - 1;
}
if ( v12 <= 0 )
operator delete(v5);
}
sub_D153B8((int)&v13, *(char **)(a1 + 352));
v6 = SpriteAnimationManager::getPrio(a1, &v13);
v7 = (char *)v13.m_data.m_data - 24;
if ( (__int64 *)v13.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v9 = (unsigned int *)((char *)v13.m_data.m_data - 8);
do
v10 = __ldaxr(v9);
while ( __stlxr(v10 - 1, v9) );
}
else
{
v10 = *((_DWORD *)v13.m_data.m_data - 2);
*((_DWORD *)v13.m_data.m_data - 2) = v10 - 1;
}
if ( v10 <= 0 )
operator delete(v7);
}
if ( Prio <= v6 )
sub_D18EA8(a1 + 352, a2);
return _stack_chk_guard;
}