//
// cocos2d::CCTMXLayer::insertTileForGID from 0x5f7920 to 0x5f7a7e (350 bytes)
//
// 1 xrefs:
// > cocos2d::CCTMXLayer::setTileGID @ 0x5f804c
//
// 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
//
cocos2d::CCSprite *cocos2d::CCTMXLayer::insertTileForGID(
cocos2d::CCTMXLayer *a1,
unsigned int a2,
const cocos2d::CCPoint *a3)
{
float x; // s18
cocos2d::CCDirector *v7; // r0
float v8; // r0
float y; // s17
float v10; // s18
cocos2d::CCDirector *v11; // r0
float v12; // r0
float width; // s16
float v14; // s17
cocos2d::CCDirector *v15; // r0
float v16; // r0
float height; // s19
float v18; // s16
cocos2d::CCDirector *v19; // r0
float v20; // r0
int v21; // r6
cocos2d::CCSprite *v22; // r7
cocos2d::CCPoint v23; // r2
unsigned int v24; // r5
cocos2d::CCArray *m_pChildren; // r0
cocos2d::CCArray *v26; // r3
cocos2d::ccArray *data; // r2
int v28; // r3
cocos2d::CCObject **arr; // r2
cocos2d::CCObject **v30; // r3
int v32; // r0
int v33; // t1
unsigned int v34; // r1
unsigned int v35; // [sp+0h] [bp-Ch]
cocos2d::CCRect v36; // [sp+Ch] [bp+0h] BYREF
cocos2d::CCRect v37; // [sp+1Ch] [bp+10h] BYREF
cocos2d::CCRect v38; // 0:r1.12,12:^0.4
cocos2d::CCTMXTilesetInfo::rectForGID(&v36, (cocos2d::CCTMXTilesetInfo *)a1[1].m_uAutoReleaseCount, a2);
x = v36.origin.x;
v7 = cocos2d::CCDirector::sharedDirector();
v8 = COERCE_FLOAT(cocos2d::CCDirector::getContentScaleFactor(v7));
y = v36.origin.y;
v10 = x / v8;
v11 = cocos2d::CCDirector::sharedDirector();
v12 = COERCE_FLOAT(cocos2d::CCDirector::getContentScaleFactor(v11));
width = v36.size.width;
v14 = y / v12;
v15 = cocos2d::CCDirector::sharedDirector();
v16 = COERCE_FLOAT(cocos2d::CCDirector::getContentScaleFactor(v15));
height = v36.size.height;
v18 = width / v16;
v19 = cocos2d::CCDirector::sharedDirector();
v20 = COERCE_FLOAT(cocos2d::CCDirector::getContentScaleFactor(v19));
cocos2d::CCRect::CCRect(&v37, v10, v14, v18, height / v20);
cocos2d::CCRect::operator=(&v36, &v37.origin.x);
v21 = (int)(float)(a3->x
+ (float)(a3->y
* *(float *)&a1[1].cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable));
cocos2d::CCRect::CCRect(&v37, &v36);
LODWORD(v38.origin.x) = &v37;
v22 = cocos2d::CCTMXLayer::reusedTileWithRect(a1, v38);
cocos2d::CCPoint::CCPoint(&v37.origin, a3);
LODWORD(v23.x) = &v37;
LODWORD(v23.y) = a2;
cocos2d::CCTMXLayer::setupTileSprite(a1, v22, v23, v35);
v24 = cocos2d::CCTMXLayer::atlasIndexForNewZ(a1, v21);
cocos2d::CCSpriteBatchNode::insertQuadFromSprite(a1, v22, v24);
cocos2d::ccCArrayInsertValueAtIndex((_DWORD *)LODWORD(a1[1].m_fScaleX), v21, v24);
m_pChildren = a1->m_pChildren;
if ( m_pChildren )
{
if ( cocos2d::CCArray::count(m_pChildren) )
{
v26 = a1->m_pChildren;
if ( v26 )
{
data = v26->data;
if ( data->num )
{
v28 = data->num + 0x40000000;
arr = data->arr;
v30 = &arr[v28 - 1];
while ( arr <= v30 )
{
v33 = (int)*arr++;
v32 = v33;
if ( !v33 )
break;
v34 = *(_DWORD *)(v32 + 288);
if ( v34 >= v24 )
*(_DWORD *)(v32 + 288) = v34 + 1;
}
}
}
}
}
*(_DWORD *)(a1[1].m_uReference + 4 * v21) = a2;
return v22;
}