//
// cocos2d::CCMotionStreak::update from 0xaf73cc to 0xaf7938 (1388 bytes)
//
// 2 xrefs:
// > ??> @ 0x69e88
// > ??> @ 0x1210fb8
//
// 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::CCMotionStreak::update(cocos2d::CCMotionStreak *a1, float m_fMaxSeg)
{
float v2; // s1
unsigned int m_uNuPoints; // w0
unsigned int v5; // w3
float v6; // s8
int v7; // w23
unsigned int v8; // w26
unsigned int v9; // w24
unsigned int v10; // w20
unsigned int v11; // w25
unsigned int v12; // w21
GLubyte v13; // w0
float *m_pPointState; // x2
_BOOL4 v15; // w20
unsigned int m_uMaxPoints; // w0
_BOOL4 m_bRepeatMode; // w0
cocos2d::ccTex2F *m_pTexCoords; // x1
unsigned int v19; // w2
unsigned int v20; // w0
float v21; // s0
cocos2d::ccTex2F *v22; // x6
float *v23; // x5
GLfloat v24; // s0
cocos2d::CCPoint *m_pPointVertexes; // x3
cocos2d::ccVertex2F *m_pVertices; // x0
GLubyte *m_pColorPointer; // x9
cocos2d::CCPoint *p_m_tPositionR; // x23
unsigned int v29; // w5
GLubyte *v30; // x4
__int64 v31; // x0
__int64 v32; // x6
__int64 v33; // x1
GLubyte *v34; // x0
unsigned int v35; // w2
_BOOL4 m_bFastMode; // w0
cocos2d::CCPoint *v37; // x0
float m_fStroke; // s0
cocos2d::ccVertex2F *v39; // x1
cocos2d::ccTex2F *v40; // x1
unsigned int v41; // w2
unsigned int v42; // w0
float v43; // s0
float m_fRepeatTime; // s2
cocos2d::ccTex2F *v45; // x6
float m_fRepeatSpeed; // s1
float *v47; // x5
GLfloat v48; // s0
unsigned int v49; // w0
_BOOL4 v50; // w27
__int64 v51; // x21
unsigned int v52; // w24
unsigned int v53; // w1
cocos2d::CCPoint *v54; // x0
cocos2d::CCPoint v55; // [xsp+70h] [xbp+70h] BYREF
cocos2d::CCPoint v56; // [xsp+78h] [xbp+78h] BYREF
cocos2d::CCPoint v57; // [xsp+80h] [xbp+80h] BYREF
if ( !a1->m_bStartingPositionInitialized )
return;
m_uNuPoints = a1->m_uNuPoints;
v5 = m_uNuPoints;
v6 = m_fMaxSeg * a1->m_fFadeDelta;
if ( m_uNuPoints )
{
v7 = 1;
v8 = 0;
v9 = 1;
v10 = 0;
do
{
while ( 1 )
{
m_pPointState = a1->m_pPointState;
v2 = m_pPointState[v10] - v6;
m_pPointState[v10] = v2;
if ( v2 > 0.0 )
break;
++v10;
++v8;
v9 += 2;
v7 += 8;
if ( v10 >= m_uNuPoints )
goto LABEL_11;
}
v11 = v10 - v8;
v12 = 8 * (v10 - v8);
if ( v8 )
{
m_pPointVertexes = a1->m_pPointVertexes;
m_pPointState[v11] = v2;
cocos2d::CCPoint::operator=(&m_pPointVertexes[v11], m_fMaxSeg, v2, (float *)&m_pPointVertexes[v10]);
m_pVertices = a1->m_pVertices;
m_pColorPointer = a1->m_pColorPointer;
m_pVertices[2 * v11] = m_pVertices[2 * v10];
m_pVertices[2 * v11 + 1] = m_pVertices[v9];
m_pColorPointer[v12] = m_pColorPointer[8 * (v10 & 0x1FFFFFFF)];
a1->m_pColorPointer[v12 + 1] = a1->m_pColorPointer[v7];
a1->m_pColorPointer[v12 + 2] = a1->m_pColorPointer[v7 + 1];
a1->m_pColorPointer[v12 + 4] = a1->m_pColorPointer[4 * (v9 & 0x3FFFFFFF)];
a1->m_pColorPointer[v12 + 5] = a1->m_pColorPointer[v7 + 4];
a1->m_pColorPointer[v12 + 6] = a1->m_pColorPointer[v7 + 5];
}
v13 = -1;
if ( !a1->m_bDontOpacityFade )
{
v2 = a1->m_pPointState[v11] * 255.0;
v13 = (unsigned int)v2;
}
++v10;
v9 += 2;
v7 += 8;
a1->m_pColorPointer[v12 + 3] = v13;
a1->m_pColorPointer[v12 + 7] = v13;
m_uNuPoints = a1->m_uNuPoints;
}
while ( v10 < m_uNuPoints );
LABEL_11:
v5 = m_uNuPoints - v8;
v15 = v8 != 0;
}
else
{
v15 = 0;
v8 = 0;
}
m_uMaxPoints = a1->m_uMaxPoints;
a1->m_uNuPoints = v5;
if ( m_uMaxPoints > v5 && a1->m_bStroke )
{
if ( !v5 )
{
p_m_tPositionR = &a1->m_tPositionR;
goto LABEL_27;
}
p_m_tPositionR = &a1->m_tPositionR;
cocos2d::CCPoint::CCPoint(&v55, &a1->m_pPointVertexes[v5 - 1]);
cocos2d::CCPoint::CCPoint(&v56, &a1->m_tPositionR);
cocos2d::CCPoint::operator-((float *)&v55, (float *)&v56, &v57);
v5 = a1->m_uNuPoints;
v2 = v57.y * v57.y;
v49 = v5;
v50 = (float)((float)(v57.y * v57.y) + (float)(v57.x * v57.x)) < a1->m_fMinSeg;
if ( v5 == 1 )
{
if ( (float)((float)(v57.y * v57.y) + (float)(v57.x * v57.x)) >= a1->m_fMinSeg )
{
LABEL_41:
m_fMaxSeg = a1->m_fMaxSeg;
if ( m_fMaxSeg == 0.0 )
{
v5 = v49;
}
else
{
m_fMaxSeg = cocos2d::ccpDistance(&a1->m_pPointVertexes[v49 - 1], &a1->m_tPositionR);
v2 = a1->m_fMaxSeg;
if ( m_fMaxSeg > v2 )
{
v51 = 0;
v52 = 0;
if ( a1->m_uNuPoints )
{
do
{
++v52;
cocos2d::CCPoint::operator=(&a1->m_pPointVertexes[v51], m_fMaxSeg, v2, (float *)&a1->m_tPositionR);
v53 = a1->m_uNuPoints;
a1->m_pPointState[v51++] = 0.0;
}
while ( v52 < v53 );
}
v54 = a1->m_pPointVertexes;
a1->m_uNuPoints = 1;
cocos2d::CCPoint::operator=(v54, m_fMaxSeg, v2, (float *)&a1->m_tPositionR);
m_fMaxSeg = 1.0;
v5 = a1->m_uNuPoints;
*a1->m_pPointState = 1.0;
}
else
{
v5 = a1->m_uNuPoints;
}
}
LABEL_27:
cocos2d::CCPoint::operator=(&a1->m_pPointVertexes[v5], m_fMaxSeg, v2, (float *)p_m_tPositionR);
v29 = a1->m_uNuPoints;
v30 = a1->m_pColorPointer;
v31 = 8 * v29;
v32 = (unsigned int)(v31 + 3);
v33 = (unsigned int)(v31 + 7);
a1->m_pPointState[v29] = 1.0;
*(_WORD *)&v30[v31] = *(_WORD *)&a1->_displayedColor.r;
v30[v31 + 2] = a1->_displayedColor.b;
v34 = &a1->m_pColorPointer[v31];
*((_WORD *)v34 + 2) = *(_WORD *)&a1->_displayedColor.r;
v34[6] = a1->_displayedColor.b;
a1->m_pColorPointer[v32] = -1;
a1->m_pColorPointer[v33] = -1;
v35 = a1->m_uNuPoints;
m_bFastMode = a1->m_bFastMode;
if ( v35 && a1->m_bFastMode )
{
v37 = a1->m_pPointVertexes;
m_fStroke = a1->m_fStroke;
v39 = a1->m_pVertices;
if ( v35 <= 1 )
cocos2d::ccVertexLineToPolygon(v37, m_fStroke, v39, 0, 2u);
else
cocos2d::ccVertexLineToPolygon(v37, m_fStroke, v39, v35, 1u);
v35 = a1->m_uNuPoints;
m_bFastMode = a1->m_bFastMode;
}
v5 = v35 + 1;
a1->m_uNuPoints = v35 + 1;
if ( !m_bFastMode )
goto LABEL_33;
goto LABEL_14;
}
}
else
{
cocos2d::CCPoint::CCPoint(&v55, &a1->m_pPointVertexes[v5 - 2]);
cocos2d::CCPoint::CCPoint(&v56, &a1->m_tPositionR);
cocos2d::CCPoint::operator-((float *)&v55, (float *)&v56, &v57);
v5 = a1->m_uNuPoints;
m_fMaxSeg = a1->m_fMinSeg + a1->m_fMinSeg;
v2 = (float)(v57.y * v57.y) + (float)(v57.x * v57.x);
if ( v2 >= m_fMaxSeg && !v50 )
{
v49 = a1->m_uNuPoints;
if ( !v5 )
goto LABEL_27;
goto LABEL_41;
}
}
}
if ( !a1->m_bFastMode )
{
LABEL_33:
cocos2d::ccVertexLineToPolygon(a1->m_pPointVertexes, a1->m_fStroke, a1->m_pVertices, 0, v5);
v5 = a1->m_uNuPoints;
}
LABEL_14:
m_bRepeatMode = a1->m_bRepeatMode;
if ( v15 && a1->m_bRepeatMode )
a1->m_fRepeatTime = a1->m_fRepeatTime + (float)v8;
a1->m_idk = 0;
if ( v5 )
{
if ( a1->m_uPreviousNuPoints == v5 )
{
if ( !m_bRepeatMode )
return;
}
else if ( !m_bRepeatMode )
{
m_pTexCoords = a1->m_pTexCoords;
v19 = 1;
v20 = 0;
do
{
v21 = (float)v20;
v22 = &m_pTexCoords[2 * (v20 & 0x7FFFFFFF)];
v22->u = 0.0;
++v20;
v23 = (float *)&m_pTexCoords[v19];
v24 = (float)(1.0 / (float)v5) * v21;
v19 += 2;
v22->v = v24;
*v23 = 1.0;
v23[1] = v24;
}
while ( v20 != v5 );
a1->m_uPreviousNuPoints = v5;
return;
}
v40 = a1->m_pTexCoords;
v41 = 1;
v42 = 0;
do
{
v43 = (float)v42;
m_fRepeatTime = a1->m_fRepeatTime;
v45 = &v40[2 * (v42 & 0x7FFFFFFF)];
m_fRepeatSpeed = a1->m_fRepeatSpeed;
v45->u = 0.0;
++v42;
v47 = (float *)&v40[v41];
v41 += 2;
v48 = (float)(v43 + m_fRepeatTime) * m_fRepeatSpeed;
v45->v = v48;
*v47 = 1.0;
v47[1] = v48;
}
while ( v42 != v5 );
a1->m_uPreviousNuPoints = v5;
}
}