//
// SpriteAnimationManager::callAnimationFinished from 0x58e404 to 0x58e5f0 (492 bytes)
//
// 3 xrefs:
// > ??> @ 0x6ee98
// > SpriteAnimationManager::animationFinished @ 0x58e1c0
// > ??> @ 0x122ba38
//
// 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::callAnimationFinished(SpriteAnimationManager *a1)
{
std::string *p_m_currentAnimation; // x24
stl::StringData::Internal *m_data; // x0
unsigned __int64 v4; // x19
unsigned __int64 v5; // x20
size_t v6; // x2
unsigned __int64 v7; // x19
char *v8; // x0
unsigned __int8 *v9; // x0
unsigned int *v10; // x1
int v11; // w2
unsigned int *v12; // x1
int v13; // w2
const unsigned __int8 *v14; // [xsp+58h] [xbp+58h] BYREF
void *v15; // [xsp+60h] [xbp+60h] BYREF
p_m_currentAnimation = &a1->m_currentAnimation;
sub_D153B8((int)&v15, "not_used");
m_data = a1->m_currentAnimation.m_data.m_data;
v4 = *((_QWORD *)m_data - 3);
v5 = *((_QWORD *)v15 - 3);
if ( v5 > v4 )
v6 = *((_QWORD *)m_data - 3);
else
v6 = *((_QWORD *)v15 - 3);
if ( !memcmp(m_data, v15, v6) )
{
v7 = v4 - v5;
if ( v7 + 0x80000000 <= 0xFFFFFFFF && !(_DWORD)v7 )
p_m_currentAnimation = &a1->m_nextAnimation;
}
sub_D18D28(&v14, p_m_currentAnimation);
v8 = (char *)v15 - 24;
if ( (char *)v15 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v10 = (unsigned int *)((char *)v15 - 8);
do
v11 = __ldaxr(v10);
while ( __stlxr(v11 - 1, v10) );
}
else
{
v11 = *((_DWORD *)v15 - 2);
*((_DWORD *)v15 - 2) = v11 - 1;
}
if ( v11 <= 0 )
operator delete(v8);
}
a1->m_sprite->animationFinished(a1->m_sprite, v14);
v9 = (unsigned __int8 *)(v14 - 24);
if ( v14 - 24 != (const unsigned __int8 *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v12 = (unsigned int *)(v14 - 8);
do
v13 = __ldaxr(v12);
while ( __stlxr(v13 - 1, v12) );
}
else
{
v13 = *((_DWORD *)v14 - 2);
*((_DWORD *)v14 - 2) = v13 - 1;
}
if ( v13 <= 0 )
operator delete(v9);
}
}