//
// cocos2d::CCTMXLayer::insertTileForGID from 0x100244fc0 to 0x1002451c3 (515 bytes)
//
// 1 xrefs:
// > cocos2d::CCTMXLayer::setTileGID @ 0x100245554
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// 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:27:19 +0000
//
__int64 *__fastcall cocos2d::CCTMXLayer::insertTileForGID(__int64 a1, unsigned int a2, float *a3)
{
__int64 v4; // rdx
__int64 v6; // rsi
__int64 v7; // rdi
float v8; // xmm0_4
__int64 v9; // rdi
float v10; // xmm0_4
__int64 v11; // rdi
float v12; // xmm0_4
__int64 v13; // rax
float v14; // xmm0_4
double v15; // xmm3_8
__int64 v16; // r15
__int64 *v17; // r12
int v18; // ebx
unsigned int *v19; // rcx
__int64 v20; // rax
__int64 v21; // rcx
__int64 v22; // r13
__int64 v23; // rdi
__int64 v24; // rax
unsigned int *v25; // rax
__int64 v26; // rcx
__int64 *v27; // rax
unsigned __int64 v28; // rcx
__int64 v29; // rdx
unsigned int v30; // esi
float v32[4]; // [rsp+4h] [rbp-5Ch] BYREF
_DWORD v33[4]; // [rsp+14h] [rbp-4Ch] BYREF
unsigned int v34; // [rsp+24h] [rbp-3Ch]
float v35; // [rsp+28h] [rbp-38h]
float v36; // [rsp+2Ch] [rbp-34h]
float v37; // [rsp+30h] [rbp-30h]
float v38; // [rsp+34h] [rbp-2Ch]
v4 = a2;
v34 = a2;
v6 = *(_QWORD *)(a1 + 384);
cocos2d::CCTMXTilesetInfo::rectForGID(v33, v6, v4);
v36 = *(float *)v33;
v7 = cocos2d::CCDirector::sharedDirector(v33, v6);
v8 = sub_100479350(v7);
v36 = v36 / v8;
v37 = *(float *)&v33[1];
v9 = cocos2d::CCDirector::sharedDirector(v7, v6);
v10 = sub_100479350(v9);
v37 = v37 / v10;
v38 = *(float *)&v33[2];
v11 = cocos2d::CCDirector::sharedDirector(v9, v6);
v12 = sub_100479350(v11);
v38 = v38 / v12;
v35 = *(float *)&v33[3];
v13 = cocos2d::CCDirector::sharedDirector(v11, v6);
v14 = sub_100479350(v13);
*(_QWORD *)&v15 = LODWORD(v35);
*(float *)&v15 = v35 / v14;
sub_100278270(
v32,
COERCE_DOUBLE((unsigned __int64)LODWORD(v36)),
COERCE_DOUBLE((unsigned __int64)LODWORD(v37)),
COERCE_DOUBLE((unsigned __int64)LODWORD(v38)),
v15);
sub_100278810(v33, v32);
v16 = (unsigned int)(int)(float)((float)(a3[1] * *(float *)(a1 + 356)) + *a3);
sub_1002787F0(v32, v33);
v17 = (__int64 *)cocos2d::CCTMXLayer::reusedTileWithRect(a1, (__int64)v32);
sub_1002782D0(v32, a3);
v18 = v34;
cocos2d::CCTMXLayer::setupTileSprite(a1, v17, v32, v34);
v19 = *(unsigned int **)(a1 + 464);
v20 = *v19;
if ( *v19 )
{
v21 = *((_QWORD *)v19 + 2);
v22 = 0;
while ( *(_DWORD *)(v21 + 8 * v22) <= (int)v16 )
{
if ( v20 == ++v22 )
{
LODWORD(v22) = v20;
break;
}
}
}
else
{
LODWORD(v22) = 0;
}
cocos2d::CCSpriteBatchNode::insertQuadFromSprite(a1, (__int64)v17, v22);
sub_1007478F0(*(_QWORD *)(a1 + 464), v16, (unsigned int)v22);
v23 = *(_QWORD *)(a1 + 208);
if ( v23 )
{
if ( (unsigned int)sub_1007FEF90(v23) )
{
v24 = *(_QWORD *)(a1 + 208);
if ( v24 )
{
v25 = *(unsigned int **)(v24 + 56);
v26 = *v25;
if ( *v25 )
{
v27 = *((__int64 **)v25 + 2);
v28 = (unsigned __int64)&v27[v26 - 1];
do
{
v29 = *v27;
if ( !*v27 )
break;
v30 = *(_DWORD *)(v29 + 360);
if ( v30 >= (unsigned int)v22 )
*(_DWORD *)(v29 + 360) = v30 + 1;
++v27;
}
while ( (unsigned __int64)v27 <= v28 );
}
}
}
}
*(_DWORD *)(*(_QWORD *)(a1 + 376) + 4 * v16) = v18;
return v17;
}