//
// cocos2d::CCTMXLayer::setupTiles from 0x10025a040 to 0x10025a37d (829 bytes)
//
// 1 xrefs:
// > cocos2d::CCTMXTiledMap::parseLayer @ 0x100518a59
//
// 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::CCTMXLayer::setupTiles(cocos2d::CCTMXLayer *a1)
{
cocos2d::CCTexture2D *v2; // rax
const cocos2d::CCSize *ContentSizeInPixels; // rsi
cocos2d::CCTexture2D *v4; // rax
float v5; // xmm0_4
float v6; // xmm3_4
__int64 v7; // rax
char *v8; // r12
float v9; // xmm2_4
float v10; // xmm1_4
float v11; // xmm0_4
cocos2d::CCObjectType m_eObjType; // edx
char *v13; // r14
cocos2d::CCSprite *v14; // r12
cocos2d::CCPoint v15; // xmm0_8
float v16; // r15d
unsigned int v17; // r13d
float x; // eax
float y; // eax
float v20; // r13d
cocos2d::CCDirector *v21; // rax
float v22; // xmm0_4
cocos2d::CCDirector *v23; // rax
float v24; // xmm0_4
cocos2d::CCDirector *v25; // rax
float v26; // xmm0_4
cocos2d::CCDirector *v27; // rax
float v28; // xmm0_4
double v29; // xmm0_8
__int64 v30; // rdi
void *v31; // r15
__int64 v32; // rax
char v33; // [rsp+8h] [rbp-78h] BYREF
char v34[8]; // [rsp+10h] [rbp-70h] BYREF
__int64 v35; // [rsp+18h] [rbp-68h]
cocos2d::CCTMXTilesetInfo v36; // [rsp+24h] [rbp-5Ch] BYREF
v2 = (cocos2d::CCTexture2D *)((__int64 (__fastcall *)(cocos2d::CCTextureAtlas *))a1->m_pobTextureAtlas->getTexture)(a1->m_pobTextureAtlas);
ContentSizeInPixels = cocos2d::CCTexture2D::getContentSizeInPixels(v2);
sub_10028CFF0(*(_QWORD *)&a1[1].m_uAutoReleaseCount + 128LL, ContentSizeInPixels);
v4 = (cocos2d::CCTexture2D *)((__int64 (__fastcall *)(cocos2d::CCTextureAtlas *))a1->m_pobTextureAtlas->getTexture)(a1->m_pobTextureAtlas);
cocos2d::CCTexture2D::setAliasTexParameters(v4);
cocos2d::CCTMXLayer::parseInternalProperties(a1);
v5 = *(float *)&a1[1].cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
if ( v5 > 0.0 )
{
v6 = *(float *)(&a1->m_bManualSortAllChildrenDirty + 3);
if ( v6 > 0.0 )
{
v7 = 0;
v8 = &v33;
v9 = *(float *)(&a1->m_bManualSortAllChildrenDirty + 3);
v10 = 0.0;
do
{
if ( v9 > 0.0 )
{
v35 = v7;
v11 = 0.0;
m_eObjType = 1;
*(float *)&v36.m_uIndexInArray = v10;
do
{
v20 = *(float *)(*(_QWORD *)&a1[1].m_nTag + 4LL * (unsigned int)(int)(float)((float)(v9 * v10) + v11));
if ( v20 != 0.0 )
{
v36.m_eObjType = m_eObjType;
sub_10028CBE0(&v36.m_nTag, v11, v10);
cocos2d::CCTMXTilesetInfo::rectForGID(&v36, *(_QWORD *)&a1[1].m_uAutoReleaseCount);
v36.m_nZOrder = (int)v36.__vftable;
v21 = cocos2d::CCDirector::sharedDirector();
v22 = sub_1004849C0(v21);
*(float *)&v36.m_nZOrder = *(float *)&v36.m_nZOrder / v22;
v36.m_uUnknown = HIDWORD(v36.__vftable);
v23 = cocos2d::CCDirector::sharedDirector();
v24 = sub_1004849C0(v23);
*(float *)&v36.m_uUnknown = *(float *)&v36.m_uUnknown / v24;
v36.m_unknown2 = v36.m_uID;
v25 = cocos2d::CCDirector::sharedDirector();
v26 = sub_1004849C0(v25);
*(float *)&v36.m_unknown2 = *(float *)&v36.m_unknown2 / v26;
v36.m_uAutoReleaseCount = v36.m_nLuaID;
v27 = cocos2d::CCDirector::sharedDirector();
v28 = sub_1004849C0(v27);
sub_10028CC00(
v8,
COERCE_DOUBLE((unsigned __int64)(unsigned int)v36.m_nZOrder),
COERCE_DOUBLE((unsigned __int64)(unsigned int)v36.m_uUnknown),
*(float *)&v36.m_unknown2,
*(float *)&v36.m_uAutoReleaseCount / v28);
sub_10028D1A0(&v36, v8);
*(float *)&v36.m_nZOrder = (float)(*(float *)&v36.m_uReference
* *(float *)(&a1->m_bManualSortAllChildrenDirty + 3))
+ *(float *)&v36.m_nTag;
v29 = sub_10028D180(v8);
v30 = *(_QWORD *)&a1[1].m_obAnchorPointInPoints.y;
if ( v30 )
{
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v30 + 1104LL))(v30, 0);
(*(void (__fastcall **)(_QWORD, char *, _QWORD, char *))(**(_QWORD **)&a1[1].m_obAnchorPointInPoints.y
+ 1128LL))(
*(_QWORD *)&a1[1].m_obAnchorPointInPoints.y,
v8,
0,
v34);
}
else
{
v31 = operator new(0x258u);
sub_1002881A0(v31, &v36, v29);
*(_QWORD *)&a1[1].m_obAnchorPointInPoints.y = v31;
v32 = ((__int64 (__fastcall *)(cocos2d::CCTextureAtlas *))a1->m_pobTextureAtlas->getTexture)(a1->m_pobTextureAtlas);
(*(void (__fastcall **)(void *, __int64, char *, _QWORD))(*(_QWORD *)v31 + 1008LL))(v31, v32, v8, 0);
}
v13 = v8;
*(_QWORD *)&v36.m_nZOrder = (unsigned int)(int)*(float *)&v36.m_nZOrder;
(*(void (__fastcall **)(_QWORD, cocos2d::CCTMXLayer *))(**(_QWORD **)&a1[1].m_obAnchorPointInPoints.y
+ 1104LL))(
*(_QWORD *)&a1[1].m_obAnchorPointInPoints.y,
a1);
v14 = *(cocos2d::CCSprite **)&a1[1].m_obAnchorPointInPoints.y;
*(double *)&v15 = sub_10028CC60(v13);
v16 = v20;
cocos2d::CCTMXLayer::setupTileSprite(a1, v14, v15, (unsigned int)v13);
v17 = **(_DWORD **)&a1[1].m_obAnchorPoint.y;
cocos2d::CCSpriteBatchNode::insertQuadFromSprite(a1, v14, v17);
sub_1006683C0(*(_QWORD *)&a1[1].m_obAnchorPoint.y, *(_QWORD *)&v36.m_nZOrder, v17);
x = a1[1].m_obPosition.x;
if ( LODWORD(v16) < LODWORD(x) )
x = v16;
a1[1].m_obPosition.x = x;
y = a1[1].m_obPosition.y;
if ( LODWORD(v16) > LODWORD(y) )
y = v16;
a1[1].m_obPosition.y = y;
v6 = *(float *)(&a1->m_bManualSortAllChildrenDirty + 3);
v8 = v13;
v10 = *(float *)&v36.m_uIndexInArray;
m_eObjType = v36.m_eObjType;
}
v11 = (float)m_eObjType++;
v9 = v6;
}
while ( v6 > v11 );
v5 = *(float *)&a1[1].cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v9 = v6;
LODWORD(v7) = v35;
}
v7 = (unsigned int)(v7 + 1);
v10 = (float)(int)v7;
}
while ( v5 > (float)(int)v7 );
}
}
}