//
// cocos2d::CCAnimationCache::parseVersion1 from 0xb13b7c to 0xb13e30 (692 bytes)
//
// 2 xrefs:
// > cocos2d::CCAnimationCache::addAnimationsWithDictionary @ 0xb145d4
// > ??> @ 0xc0b70
//
// 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 cocos2d::CCAnimationCache::parseVersion1(cocos2d::CCAnimationCache *a1, cocos2d::CCDictionary *a2)
{
cocos2d::CCSpriteFrameCache *v2; // x25
cocos2d::CCDictElement *m_pElements; // x26
cocos2d::CCDictElement *i; // x23
__int64 m_pObject; // x19
cocos2d::CCArray *v6; // x24
char *v7; // x0
cocos2d::CCString *v8; // x0
char *v9; // x0
cocos2d::CCArray *v10; // x0
cocos2d::CCArray *v11; // x22
cocos2d::ccArray *data; // x0
cocos2d::CCString **arr; // x27
cocos2d::CCString **j; // x21
const char *CString; // x0
cocos2d::CCSpriteFrame *v16; // x1
cocos2d::CCAnimationFrame *v17; // x19
cocos2d::CCObject *v18; // x2
cocos2d::CCAnimationCache *v19; // x0
unsigned int *v20; // x1
int v21; // w2
unsigned int *v22; // x1
int v23; // w2
cocos2d::CCSpriteFrame *v25; // [xsp+88h] [xbp+88h]
cocos2d::CCAnimation *v26; // [xsp+88h] [xbp+88h]
const char *v27; // [xsp+A0h] [xbp+A0h] BYREF
v2 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
if ( a2 )
{
m_pElements = a2->m_pElements;
if ( m_pElements )
{
for ( i = (cocos2d::CCDictElement *)m_pElements->hh.next; ; i = (cocos2d::CCDictElement *)i->hh.next )
{
m_pObject = (__int64)m_pElements->m_pObject;
sub_D153B8((int)&v27, "frames");
v6 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(m_pObject, &v27);
v7 = (char *)(v27 - 24);
if ( v27 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v22 = (unsigned int *)(v27 - 8);
do
v23 = __ldaxr(v22);
while ( __stlxr(v23 - 1, v22) );
}
else
{
v23 = *((_DWORD *)v27 - 2);
*((_DWORD *)v27 - 2) = v23 - 1;
}
if ( v23 <= 0 )
operator delete(v7);
}
sub_D153B8((int)&v27, "delay");
v8 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(m_pObject, &v27);
cocos2d::CCString::floatValue(v8);
v9 = (char *)(v27 - 24);
if ( v27 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v20 = (unsigned int *)(v27 - 8);
do
v21 = __ldaxr(v20);
while ( __stlxr(v21 - 1, v20) );
}
else
{
v21 = *((_DWORD *)v27 - 2);
*((_DWORD *)v27 - 2) = v21 - 1;
}
if ( v21 <= 0 )
operator delete(v9);
}
if ( !v6 )
goto LABEL_14;
v10 = (cocos2d::CCArray *)cocos2d::CCArray::count(v6);
v11 = cocos2d::CCArray::createWithCapacity(v10);
cocos2d::CCObject::retain(v11);
data = v6->data;
if ( data->num )
{
arr = (cocos2d::CCString **)data->arr;
for ( j = &arr[data->num - 1]; j >= arr; ++arr )
{
if ( !*arr )
break;
CString = cocos2d::CCString::getCString(*arr);
v16 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v2, CString);
if ( v16 )
{
v25 = v16;
v17 = (cocos2d::CCAnimationFrame *)operator new(0x50u);
cocos2d::CCAnimationFrame::CCAnimationFrame(v17);
cocos2d::CCAnimationFrame::initWithSpriteFrame(v17, v25, 1.0, nullptr);
cocos2d::CCArray::addObject(v11, (cocos2d::_ccArray *)v17, v18);
cocos2d::CCObject::release(v17);
}
}
}
if ( (unsigned int)cocos2d::CCArray::count(v11) )
{
cocos2d::CCArray::count(v11);
cocos2d::CCArray::count(v6);
v26 = cocos2d::CCAnimation::create();
v19 = cocos2d::CCAnimationCache::sharedAnimationCache();
cocos2d::CCAnimationCache::addAnimation(v19, v26, (const char *)m_pElements);
cocos2d::CCObject::release(v11);
if ( !i )
return;
}
else
{
LABEL_14:
if ( !i )
return;
}
m_pElements = i;
}
}
}
}