//
// CCAnimatedSprite::tweenToAnimation from 0x571608 to 0x5718f4 (748 bytes)
//
// 13 xrefs:
// > PlayerObject::playingEndEffect @ 0x628e24
// > PlayerObject::boostPlayer @ 0x62950c
// > PlayerObject::updateMove @ 0x62b59c
// > PlayerObject::updateMove @ 0x62c3f0
// > PlayerObject::updateJump @ 0x634f1c
// > PlayerObject::updateJump @ 0x6353b8
// > PlayerObject::updateJump @ 0x635454
// > PlayerObject::updateJump @ 0x635848
// > PlayerObject::updateJump @ 0x635ae0
// > PlayerObject::ringJump @ 0x63c4d8
// > AnimatedGameObject::playAnimation @ 0x7576e4
// > GJMapObject::monsterIdle @ 0x97db4c
// > ??> @ 0x9bbb0
//
// 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 CCAnimatedSprite::tweenToAnimation(__int64 a1, const std::string *a2, float a3)
{
SpriteAnimationManager *v5; // x22
int AnimType; // w23
char *v8; // x0
_QWORD *v10; // x0
unsigned __int64 v11; // x23
unsigned __int64 v12; // x25
size_t v13; // x2
unsigned __int64 v14; // x23
__int64 v15; // x0
cocos2d::CCDictionary *v16; // x25
cocos2d::CCString *v17; // x0
char *CString; // x0
cocos2d::CCSpriteFrame *v19; // x25
char *v20; // x21
cocos2d::CCSequence *v21; // x21
cocos2d::CCFiniteTimeAction *v22; // x0
cocos2d::CCAction *v23; // x21
unsigned int *v24; // x1
int v25; // w2
unsigned int *v26; // x1
int v27; // w0
std::string v28; // [xsp+60h] [xbp+60h] BYREF
v5 = *(SpriteAnimationManager **)(a1 + 616);
sub_D18D28(&v28, a2);
AnimType = SpriteAnimationManager::getAnimType(v5, (std::string)&v28);
v8 = (char *)v28.m_data.m_data - 24;
if ( (__int64 *)v28.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v24 = (unsigned int *)((char *)v28.m_data.m_data - 8);
do
v25 = __ldaxr(v24);
while ( __stlxr(v25 - 1, v24) );
}
else
{
v25 = *((_DWORD *)v28.m_data.m_data - 2);
*((_DWORD *)v28.m_data.m_data - 2) = v25 - 1;
}
if ( v25 <= 0 )
operator delete(v8);
}
if ( AnimType == 2 )
{
v10 = *(_QWORD **)(a1 + 608);
v11 = *(v10 - 3);
v12 = *((_QWORD *)a2->m_data.m_data - 3);
v13 = v12 > v11 ? *(v10 - 3) : *((_QWORD *)a2->m_data.m_data - 3);
if ( memcmp(v10, a2->m_data.m_data, v13)
|| (v14 = v11 - v12, v14 + 0x80000000 > 0xFFFFFFFF)
|| (_DWORD)v14
|| !cocos2d::CCNode::getActionByTag((cocos2d::CCNode *)a1, 1) )
{
SpriteAnimationManager::stopAnimations(*(SpriteAnimationManager **)(a1 + 616));
cocos2d::CCNode::stopActionByTag((cocos2d::CCNode *)a1, 1);
sub_D18EA8(a1 + 608, a2);
v15 = cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(*(_QWORD *)(a1 + 616) + 376LL), a2);
if ( v15 )
{
v16 = *(cocos2d::CCDictionary **)(*(_QWORD *)(a1 + 616) + 376LL);
if ( *(_DWORD *)(v15 + 28) )
{
CCPartAnimSprite::tweenToFrame(*(CCPartAnimSprite **)(a1 + 640), (cocos2d::CCSpriteFrame *)v15, a3);
}
else
{
v17 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%s_first",
(const char *)a2->m_data.m_data);
CString = (char *)cocos2d::CCString::getCString(v17);
sub_D153B8((int)&v28, CString);
v19 = (cocos2d::CCSpriteFrame *)cocos2d::CCDictionary::objectForKey(v16, &v28);
v20 = (char *)v28.m_data.m_data - 24;
if ( (__int64 *)v28.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v26 = (unsigned int *)((char *)v28.m_data.m_data - 8);
do
v27 = __ldaxr(v26);
while ( __stlxr(v27 - 1, v26) );
}
else
{
v27 = *((_DWORD *)v28.m_data.m_data - 2);
*((_DWORD *)v28.m_data.m_data - 2) = v27 - 1;
}
if ( v27 <= 0 )
operator delete(v20);
}
CCPartAnimSprite::tweenToFrame(*(CCPartAnimSprite **)(a1 + 640), v19, a3);
}
sub_D18EA8(a1 + 608, a2);
v21 = (cocos2d::CCSequence *)cocos2d::CCDelayTime::create(a3);
v22 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCCallFunc::create(
a1,
CCAnimatedSprite::tweenToAnimationFinished,
0);
v23 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v21, v22, 0);
v23->setTag(v23, 1);
cocos2d::CCNode::runAction((cocos2d::CCNode *)a1, v23);
}
}
}
return _stack_chk_guard;
}