//
// cocos2d::CCTiledGrid3D::calculateVertexPoints from 0xadb5e8 to 0xadb854 (620 bytes)
//
// 2 xrefs:
// > ??> @ 0x51a20
// > ??> @ 0x1201730
//
// 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::CCTiledGrid3D::calculateVertexPoints(cocos2d::CCTiledGrid3D *a1)
{
float v2; // s10
float v3; // s8
float height; // s9
int v5; // w20
void *v6; // x0
cocos2d::CCTiledGrid3D_vtbl *v7; // x0
void *v8; // x0
__int64 v9; // x19
size_t v10; // x21
float *v11; // x0
void *v12; // x22
cocos2d::CCTiledGrid3D_vtbl *v13; // x19
_WORD *v14; // x0
float width; // s18
float v16; // s4
float *v17; // x3
float v18; // s17
int v19; // w2
float x; // s5
_BOOL4 m_bIsTextureFlipped; // w5
float y; // s16
int v23; // w4
float v24; // s4
float v25; // s3
float v26; // s5
float v27; // s7
float v28; // s6
float v29; // s0
float v30; // s1
float v31; // s0
float v32; // s1
__int16 v33; // w3
_WORD *v34; // x2
__int16 v35; // w6
float *v36; // [xsp+58h] [xbp+58h]
v2 = (float)a1->m_pTexture->getPixelsWide(a1->m_pTexture);
v3 = (float)a1->m_pTexture->getPixelsHigh(a1->m_pTexture);
height = cocos2d::CCTexture2D::getContentSizeInPixels(a1->m_pTexture)->height;
v5 = (int)(float)(a1->m_sGridSize.width * a1->m_sGridSize.height);
if ( *(_QWORD *)&a1[1].m_uID )
{
free(*(void **)&a1[1].m_uID);
*(_QWORD *)&a1[1].m_uID = 0;
}
v6 = *(void **)&a1[1].m_nTag;
if ( v6 )
{
free(v6);
*(_QWORD *)&a1[1].m_nTag = 0;
}
v7 = a1[1].__vftable;
if ( v7 )
{
free(v7);
a1[1].__vftable = nullptr;
}
v8 = *(void **)&a1[1].m_uAutoReleaseCount;
if ( v8 )
free(v8);
v9 = 4 * v5;
v10 = 12 * v9;
v11 = (float *)malloc(12 * v9);
*(_QWORD *)&a1[1].m_uID = v11;
v36 = v11;
v12 = malloc(12 * v9);
*(_QWORD *)&a1[1].m_nTag = v12;
v13 = (cocos2d::CCTiledGrid3D_vtbl *)malloc(8 * v9);
a1[1].__vftable = v13;
v14 = malloc(12LL * v5);
*(_QWORD *)&a1[1].m_uAutoReleaseCount = v14;
width = a1->m_sGridSize.width;
if ( width > 0.0 )
{
v16 = 0.0;
v17 = v36;
v18 = a1->m_sGridSize.height;
v19 = 0;
do
{
if ( v18 > 0.0 )
{
x = a1->m_obStep.x;
m_bIsTextureFlipped = a1->m_bIsTextureFlipped;
y = a1->m_obStep.y;
v23 = 0;
v24 = v16 * x;
v25 = 0.0;
v26 = x + v24;
v27 = v24 / v2;
v28 = v26 / v2;
do
{
v29 = v25 * y;
++v23;
*v17 = v24;
v17 += 12;
v25 = (float)v23;
*(v17 - 10) = 0.0;
v30 = v29 + y;
*(v17 - 11) = v29;
*(v17 - 8) = v29;
*(v17 - 9) = v26;
*(v17 - 5) = v29 + y;
*(v17 - 2) = v29 + y;
*(v17 - 7) = 0.0;
*(v17 - 6) = v24;
*(v17 - 4) = 0.0;
*(v17 - 3) = v26;
*(v17 - 1) = 0.0;
if ( m_bIsTextureFlipped )
{
v29 = height - v29;
v30 = height - v30;
}
v31 = v29 / v3;
v13 = (cocos2d::CCTiledGrid3D_vtbl *)((char *)v13 + 32);
*(float *)&v13[-1].setTag = v27;
*(float *)&v13[-1].blit = v28;
*(float *)&v13[-1].reuse = v27;
*(float *)&v13[-1].calculateVertexPoints = v28;
v32 = v30 / v3;
*((float *)&v13[-1].setTag + 1) = v31;
*((float *)&v13[-1].blit + 1) = v31;
*((float *)&v13[-1].reuse + 1) = v32;
*((float *)&v13[-1].calculateVertexPoints + 1) = v32;
}
while ( (float)v23 < v18 );
}
v16 = (float)++v19;
}
while ( (float)v19 < width );
}
if ( v5 > 0 )
{
v33 = 0;
v34 = &v14[6 * (v5 - 1) + 6];
do
{
*v14 = v33;
v14 += 6;
*(v14 - 5) = v33 + 1;
v35 = v33 + 3;
*(v14 - 4) = v33 + 2;
*(v14 - 3) = v33 + 1;
*(v14 - 2) = v33 + 2;
v33 += 4;
*(v14 - 1) = v35;
}
while ( v14 != v34 );
}
memcpy(v12, v36, v10);
}