//
// cocos2d::CCTMXLayer::insertTileForGID from 0x804104 to 0x804262 (350 bytes)
//
// 1 xrefs:
// > cocos2d::CCTMXLayer::setTileGID @ 0x804bf4
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:01:22 +0000
//
cocos2d::CCSprite *__fastcall cocos2d::CCTMXLayer::insertTileForGID(
cocos2d::CCTMXLayer *this,
int a2,
const cocos2d::CCPoint *a3)
{
cocos2d::CCDirector *v6; // r0
float v7; // s18
cocos2d::CCDirector *v8; // r0
float v9; // r0
float v10; // s17
float v11; // s18
cocos2d::CCDirector *v12; // r0
float v13; // r0
float v14; // s16
float v15; // s17
cocos2d::CCDirector *v16; // r0
float v17; // r0
float v18; // s19
float v19; // s16
cocos2d::CCDirector *v20; // r0
float v21; // r0
int v22; // r6
cocos2d::CCSprite *v23; // r7
unsigned int v24; // r5
cocos2d::CCArray *v25; // r0
int v26; // r3
_DWORD *v27; // r2
int v28; // r3
int *v29; // r2
int *v30; // r3
int v32; // r0
int v33; // t1
unsigned int v34; // r1
float v35[4]; // [sp+Ch] [bp+0h] BYREF
float v36[4]; // [sp+1Ch] [bp+10h] BYREF
v6 = (cocos2d::CCDirector *)cocos2d::CCTMXTilesetInfo::rectForGID(
(cocos2d::CCTMXTilesetInfo *)v35,
*((_DWORD *)this + 77));
v7 = v35[0];
v8 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v6);
v9 = COERCE_FLOAT(cocos2d::CCDirector::getContentScaleFactor(v8));
v10 = v35[1];
v11 = v7 / v9;
v12 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector((cocos2d::CCDirector *)LODWORD(v9));
v13 = COERCE_FLOAT(cocos2d::CCDirector::getContentScaleFactor(v12));
v14 = v35[2];
v15 = v10 / v13;
v16 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector((cocos2d::CCDirector *)LODWORD(v13));
v17 = COERCE_FLOAT(cocos2d::CCDirector::getContentScaleFactor(v16));
v18 = v35[3];
v19 = v14 / v17;
v20 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector((cocos2d::CCDirector *)LODWORD(v17));
v21 = COERCE_FLOAT(cocos2d::CCDirector::getContentScaleFactor(v20));
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v36, v11, v15, v19, v18 / v21);
cocos2d::CCRect::operator=(v35, v36);
v22 = (int)(float)(*(float *)a3 + (float)(*((float *)a3 + 1) * *((float *)this + 72)));
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v36, (const cocos2d::CCRect *)v35);
v23 = (cocos2d::CCSprite *)cocos2d::CCTMXLayer::reusedTileWithRect((int)this, (int)v36);
cocos2d::CCPoint::CCPoint(v36, a3);
cocos2d::CCTMXLayer::setupTileSprite((unsigned __int8 *)this, (int)v23, v36, a2);
v24 = cocos2d::CCTMXLayer::atlasIndexForNewZ(this, v22);
cocos2d::CCSpriteBatchNode::insertQuadFromSprite(this, v23, v24);
cocos2d::ccCArrayInsertValueAtIndex(*((_DWORD **)this + 89), v22, v24);
v25 = *((cocos2d::CCArray **)this + 48);
if ( v25 )
{
if ( cocos2d::CCArray::count(v25) )
{
v26 = *((_DWORD *)this + 48);
if ( v26 )
{
v27 = *(_DWORD **)(v26 + 52);
if ( *v27 )
{
v28 = *v27 + 0x40000000;
v29 = (int *)v27[3];
v30 = &v29[v28 - 1];
while ( v29 <= v30 )
{
v33 = *v29++;
v32 = v33;
if ( !v33 )
break;
v34 = *(_DWORD *)(v32 + 288);
if ( v34 >= v24 )
*(_DWORD *)(v32 + 288) = v34 + 1;
}
}
}
}
}
*(_DWORD *)(*((_DWORD *)this + 76) + 4 * v22) = a2;
return v23;
}