//
// cocos2d::CCAnimate::initWithAnimation from 0x5b8fb8 to 0x5b9150 (408 bytes)
//
// 2 xrefs:
// > cocos2d::CCAnimate::create @ 0x5b91a8
// > cocos2d::CCAnimate::copyWithZone @ 0x5b9268
//
// 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
//
bool cocos2d::CCAnimate::initWithAnimation(cocos2d::CCAnimate *a1, cocos2d::CCAnimation *a2)
{
float v4; // s18
_BOOL4 v5; // r8
cocos2d::CCObject *m_pSplitTimes; // r0
int m_nNextFrame; // r7
unsigned int v8; // r0
int v9; // r1
int v10; // r2
const void *v11; // r11
int v12; // r9
signed int v13; // r10
int v14; // r3
char *v15; // r0
char *v16; // r4
cocos2d::CCArray *m_pFrames; // r3
float m_fTotalDelayUnits; // s19
cocos2d::ccArray *data; // r2
cocos2d::CCObject **arr; // r7
float v21; // s17
cocos2d::CCObject **v22; // r6
int v23; // r3
int v24; // t1
int v25; // r9
float *v26; // r4
float v27; // s16
float v28; // s16
int v29; // r4
int v30; // r3
bool v31; // cf
unsigned int v32; // r4
char *v33; // r11
const void *v34; // r1
signed int v35; // r10
char *v36; // r10
v4 = COERCE_FLOAT(((int (__fastcall *)(cocos2d::CCAnimation *))a2->getTotalDelayUnits)(a2));
v5 = cocos2d::CCActionInterval::initWithDuration(a1, v4 * (float)a2->m_uLoops);
if ( v5 )
{
a1->m_pOrigFrame = nullptr;
if ( (cocos2d::CCAnimation *)a1->m_pSplitTimes != a2 )
{
cocos2d::CCObject::retain(a2);
m_pSplitTimes = (cocos2d::CCObject *)a1->m_pSplitTimes;
if ( m_pSplitTimes )
cocos2d::CCObject::release(m_pSplitTimes);
a1->m_pSplitTimes = (std::vector *)a2;
}
a1->m_uExecutedLoops = 0;
*(_DWORD *)&a1->m_bRecenterFrames = 0;
m_nNextFrame = a1->m_nNextFrame;
v8 = cocos2d::CCArray::count(a2->m_pFrames);
if ( v8 >= 0x40000000 )
sub_7731C4("vector::reserve", v9, v10);
v11 = *(const void **)m_nNextFrame;
if ( v8 > (*(_DWORD *)(m_nNextFrame + 8) - *(_DWORD *)m_nNextFrame) >> 2 )
{
v12 = 4 * v8;
v13 = *(_DWORD *)(m_nNextFrame + 4) - (_DWORD)v11;
v14 = v13 >> 2;
if ( v8 )
{
v15 = (char *)operator new(4 * v8);
v14 = v13 >> 2;
v16 = v15;
}
else
{
v16 = nullptr;
}
if ( v14 )
memmove(v16, v11, v13);
if ( *(_DWORD *)m_nNextFrame )
operator delete(*(void **)m_nNextFrame);
*(_DWORD *)m_nNextFrame = v16;
*(_DWORD *)(m_nNextFrame + 4) = &v16[v13];
*(_DWORD *)(m_nNextFrame + 8) = &v16[v12];
}
m_pFrames = a2->m_pFrames;
m_fTotalDelayUnits = a2->m_fTotalDelayUnits;
if ( m_pFrames )
{
data = m_pFrames->data;
if ( data->num )
{
arr = data->arr;
v21 = 0.0;
v22 = &arr[data->num] + 0x3FFFFFFF;
while ( 1 )
{
while ( 1 )
{
if ( arr > v22 )
return v5;
v24 = (int)*arr++;
v23 = v24;
if ( !v24 )
return v5;
v25 = a1->m_nNextFrame;
v26 = *(float **)(v25 + 4);
v27 = v21 * (float)(v4 / m_fTotalDelayUnits);
v21 = v21 + *(float *)(v23 + 56);
v28 = v27 / v4;
if ( v26 == *(float **)(v25 + 8) )
break;
if ( v26 )
*v26 = v28;
*(_DWORD *)(v25 + 4) = v26 + 1;
}
v29 = ((int)v26 - *(_DWORD *)v25) >> 2;
v30 = v29 ? v29 : 1;
v31 = __CFADD__(v30, v29);
v32 = v30 + v29;
if ( v31 || v32 >= 0x40000000 )
break;
if ( v32 )
goto LABEL_32;
v33 = nullptr;
LABEL_33:
v34 = *(const void **)v25;
v35 = *(_DWORD *)(v25 + 4) - *(_DWORD *)v25;
if ( &v33[v35] )
*(float *)&v33[v35] = v28;
if ( v35 >> 2 )
memmove(v33, v34, v35);
v36 = &v33[v35 + 4];
if ( *(_DWORD *)v25 )
operator delete(*(void **)v25);
*(_DWORD *)v25 = v33;
*(_DWORD *)(v25 + 4) = v36;
*(_DWORD *)(v25 + 8) = &v33[4 * v32];
}
v32 = 0x3FFFFFFF;
LABEL_32:
v33 = (char *)operator new(4 * v32);
goto LABEL_33;
}
}
}
return v5;
}