//
// cocos2d::CCMotionStreak::update from 0x100576a90 to 0x100577110 (1664 bytes)
//
// 1 xrefs:
// > ??> @ 0x100965928
//
// 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 __fastcall cocos2d::CCMotionStreak::update(cocos2d::CCMotionStreak *a1, float a2)
{
cocos2d::CCMotionStreak *v2; // r8
unsigned int m_uNuPoints; // eax
float v4; // xmm0_4
unsigned __int64 v5; // r14
unsigned int v6; // r15d
unsigned __int64 v7; // r12
__int64 v8; // rdi
float *m_pPointState; // rcx
float v10; // xmm1_4
cocos2d::CCPoint *m_pPointVertexes; // rsi
int v12; // ebx
__int64 v13; // rax
unsigned int v14; // esi
double *v15; // r14
float v16; // xmm1_4
float m_fMinSeg; // xmm0_4
unsigned int v18; // esi
bool v19; // al
double *v20; // rsi
float v21; // xmm0_4
float v22; // xmm1_4
bool v23; // cf
bool v24; // zf
double *p_m_tPositionR; // r14
float v26; // xmm0_4
__int64 v27; // rbx
unsigned __int64 v28; // r15
__int64 v29; // rcx
__int64 v30; // rax
GLubyte *m_pColorPointer; // rcx
GLubyte *v32; // rcx
unsigned int v33; // edx
unsigned int v34; // ecx
bool m_bRepeatMode; // al
int v36; // edx
unsigned int v37; // eax
unsigned __int64 v38; // rcx
__m128 v39; // xmm1
unsigned __int64 v40; // rdx
float v41; // xmm0_4
unsigned int v42; // eax
unsigned __int64 v43; // rcx
__m128 v44; // xmm2
unsigned __int64 v45; // [rsp-60h] [rbp-60h] BYREF
unsigned __int64 v46; // [rsp-58h] [rbp-58h] BYREF
__int64 v47; // [rsp-50h] [rbp-50h]
double v48; // [rsp-44h] [rbp-44h] BYREF
float v49; // [rsp-3Ch] [rbp-3Ch]
cocos2d::CCMotionStreak *v50; // [rsp-38h] [rbp-38h]
if ( !a1->m_bStartingPositionInitialized )
return;
v2 = a1;
m_uNuPoints = a1->m_uNuPoints;
v50 = a1;
if ( m_uNuPoints )
{
v4 = a2 * a1->m_fFadeDelta;
v5 = 0;
v6 = 1;
v7 = 0;
v8 = 0;
v49 = v4;
while ( 1 )
{
m_pPointState = v2->m_pPointState;
v10 = m_pPointState[v7] - v4;
m_pPointState[v7] = v10;
if ( v10 <= 0.0 )
{
v8 = (unsigned int)(v8 + 1);
goto LABEL_5;
}
if ( (_DWORD)v8 )
{
m_pPointState[(unsigned int)(v7 - v8)] = v10;
m_pPointVertexes = v2->m_pPointVertexes;
v47 = v8;
sub_10028CC90(&m_pPointVertexes[(unsigned int)(v7 - v8)], (double *)&m_pPointVertexes[v5 / 8]);
v2 = v50;
v50->m_pVertices[v6 - 2 * (_DWORD)v8 - 1] = v50->m_pVertices[v6 - 1];
v2->m_pVertices[v6 - 2 * (_DWORD)v8] = v2->m_pVertices[v6];
v12 = 8 * (v7 - v8);
v13 = (unsigned int)(v5 - 8 * v8);
v2->m_pColorPointer[v13] = v2->m_pColorPointer[(unsigned int)v5];
v2->m_pColorPointer[(unsigned int)(v5 - 8 * v8 + 1)] = v2->m_pColorPointer[(unsigned int)(v5 + 1)];
v2->m_pColorPointer[(unsigned int)(v13 + 2)] = v2->m_pColorPointer[(unsigned int)(v5 + 2)];
v2->m_pColorPointer[(unsigned int)(v13 + 4)] = v2->m_pColorPointer[(unsigned int)(v5 + 4)];
v2->m_pColorPointer[(unsigned int)(v13 + 5)] = v2->m_pColorPointer[(unsigned int)(v5 + 5)];
v2->m_pColorPointer[(unsigned int)(v13 + 6)] = v2->m_pColorPointer[(unsigned int)(v5 + 6)];
LOBYTE(v13) = -1;
if ( !v2->m_bDontOpacityFade )
goto LABEL_12;
}
else
{
v12 = v5;
LOBYTE(v13) = -1;
if ( !v2->m_bDontOpacityFade )
LABEL_12:
LODWORD(v13) = (int)(float)(v2->m_pPointState[(unsigned int)(v7 - v8)] * 255.0);
}
v2->m_pColorPointer[v12 + 3] = v13;
v2->m_pColorPointer[v12 + 7] = v13;
m_uNuPoints = v2->m_uNuPoints;
v4 = v49;
LABEL_5:
++v7;
v5 += 8LL;
v6 += 2;
if ( v7 >= m_uNuPoints )
goto LABEL_14;
}
}
LODWORD(v8) = 0;
m_uNuPoints = 0;
LABEL_14:
v14 = m_uNuPoints - v8;
v2->m_uNuPoints = m_uNuPoints - v8;
if ( m_uNuPoints - (unsigned int)v8 < v2->m_uMaxPoints && v2->m_bStroke )
{
if ( m_uNuPoints == (_DWORD)v8 )
{
LABEL_23:
if ( v14 )
{
if ( v2->m_fMaxSeg != 0.0 )
{
p_m_tPositionR = (double *)&v2->m_tPositionR;
v26 = cocos2d::ccpDistance(&v2->m_pPointVertexes[v14 - 1], &v2->m_tPositionR);
v2 = v50;
v14 = v50->m_uNuPoints;
if ( v26 > v50->m_fMaxSeg )
{
if ( v14 )
{
v27 = 0;
v28 = 0;
do
{
sub_10028CC90(&v2->m_pPointVertexes[v27], p_m_tPositionR);
v2 = v50;
v50->m_pPointState[v28++] = 0.0;
++v27;
}
while ( v28 < v2->m_uNuPoints );
}
v2->m_uNuPoints = 1;
sub_10028CC90(v2->m_pPointVertexes, p_m_tPositionR);
v2 = v50;
*v50->m_pPointState = 1.0;
v14 = v2->m_uNuPoints;
}
}
}
else
{
v14 = 0;
}
sub_10028CC90(&v2->m_pPointVertexes[v14], (double *)&v2->m_tPositionR);
v2 = v50;
v29 = v50->m_uNuPoints;
v50->m_pPointState[v29] = 1.0;
v30 = (unsigned int)(8 * v29);
m_pColorPointer = v2->m_pColorPointer;
*(_WORD *)&m_pColorPointer[v30] = *(_WORD *)&v2->_displayedColor.r;
m_pColorPointer[v30 + 2] = v2->_displayedColor.b;
v32 = v2->m_pColorPointer;
v32[v30 + 6] = v2->_displayedColor.b;
*(_WORD *)&v32[v30 + 4] = *(_WORD *)&v2->_displayedColor.r;
v2->m_pColorPointer[v30 + 3] = -1;
v2->m_pColorPointer[v30 + 7] = -1;
v33 = v2->m_uNuPoints;
if ( v33 && v2->m_bFastMode )
{
if ( v33 == 1 )
{
v33 = 0;
v34 = 2;
}
else
{
v34 = 1;
}
cocos2d::ccVertexLineToPolygon(v2->m_pPointVertexes, v2->m_fStroke, v2->m_pVertices, v33, v34);
v2 = v50;
}
++v2->m_uNuPoints;
goto LABEL_38;
}
sub_10028CC60(&v45, (double *)&v2->m_pPointVertexes[v14 - 1]);
v15 = (double *)&v50->m_tPositionR;
sub_10028CC60(&v46, (double *)&v50->m_tPositionR);
sub_10028CD00(&v48, &v45, &v46);
v2 = v50;
v16 = (float)(*(float *)&v48 * *(float *)&v48) + (float)(*((float *)&v48 + 1) * *((float *)&v48 + 1));
m_fMinSeg = v50->m_fMinSeg;
v18 = v50->m_uNuPoints;
if ( v18 == 1 )
{
v19 = 0;
}
else
{
v20 = (double *)&v50->m_pPointVertexes[v18 - 2];
*(float *)&v47 = (float)(*(float *)&v48 * *(float *)&v48) + (float)(*((float *)&v48 + 1) * *((float *)&v48 + 1));
v49 = m_fMinSeg;
sub_10028CC60(&v45, v20);
sub_10028CC60(&v46, v15);
sub_10028CD00(&v48, &v45, &v46);
v2 = v50;
v21 = (float)(*(float *)&v48 * *(float *)&v48) + (float)(*((float *)&v48 + 1) * *((float *)&v48 + 1));
v22 = v2->m_fMinSeg + v2->m_fMinSeg;
v23 = v22 < v21;
v24 = v22 == v21;
m_fMinSeg = v49;
v16 = *(float *)&v47;
v19 = !v23 && !v24;
}
if ( m_fMinSeg <= v16 && !v19 )
{
v14 = v2->m_uNuPoints;
goto LABEL_23;
}
}
LABEL_38:
if ( !v2->m_bFastMode )
{
cocos2d::ccVertexLineToPolygon(v2->m_pPointVertexes, v2->m_fStroke, v2->m_pVertices, 0, v2->m_uNuPoints);
v2 = v50;
}
m_bRepeatMode = v2->m_bRepeatMode;
if ( m_bRepeatMode && (_DWORD)v8 != 0 )
v2->m_fRepeatTime = (float)(int)v8 + v2->m_fRepeatTime;
v2->m_idk = 0;
v36 = v2->m_uNuPoints;
if ( v36 && (m_bRepeatMode || v2->m_uPreviousNuPoints != v36) )
{
if ( m_bRepeatMode )
{
v37 = 1;
v38 = 0;
do
{
v39 = 0;
v39.f32[0] = (float)((float)(int)v38 + v2->m_fRepeatTime) * v2->m_fRepeatSpeed;
_mm_storel_ps((double *)&v2->m_pTexCoords[v37 - 1], _mm_unpacklo_ps((__m128)0LL, v39));
_mm_storel_ps((double *)&v2->m_pTexCoords[v37], _mm_insert_ps((__m128)xmmword_1008165D0, v39, 16));
++v38;
v40 = v2->m_uNuPoints;
v37 += 2;
}
while ( v38 < v40 );
}
else
{
v41 = 1.0 / (float)v36;
v42 = 1;
v43 = 0;
do
{
v44 = 0;
v44.f32[0] = (float)(int)v43 * v41;
_mm_storel_ps((double *)&v2->m_pTexCoords[v42 - 1], _mm_unpacklo_ps((__m128)0LL, v44));
_mm_storel_ps((double *)&v2->m_pTexCoords[v42], _mm_insert_ps((__m128)xmmword_1008165D0, v44, 16));
++v43;
v40 = v2->m_uNuPoints;
v42 += 2;
}
while ( v43 < v40 );
}
v2->m_uPreviousNuPoints = v40;
}
}