//
// cocos2d::CCTMXLayer::initWithTilesetInfo from 0xdab320 to 0xdab6ec (972 bytes)
//
// 2 xrefs:
// > cocos2d::CCTMXLayer::create @ 0xdab72c
// > ??> @ 0xeccf8
//
// This function is hookable on this platform (idp: arm, 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 13:08:35 +0000
//
__int64 __fastcall cocos2d::CCTMXLayer::initWithTilesetInfo(
cocos2d::CCTMXLayer *this,
cocos2d::CCTMXTilesetInfo *a2,
cocos2d::CCTMXLayerInfo *a3,
cocos2d::CCTMXMapInfo *a4)
{
cocos2d::CCTextureCache *v8; // x0
float v9; // s8
cocos2d::CCTextureCache *v10; // x0
char *v11; // x1
cocos2d::CCTexture2D *v12; // x1
unsigned __int8 v13; // w0
unsigned int v14; // w24
char *v15; // x1
size_t v16; // x23
unsigned __int64 v17; // x28
void *v18; // x5
const void *v19; // x1
__int64 v20; // x6
__int64 v21; // x2
__int64 (__fastcall *v22)(cocos2d::CCTMXLayer *, cocos2d::CCObject *); // x23
cocos2d::CCDictionary *v23; // x0
cocos2d::CCDictionary *v24; // x1
cocos2d::CCObject *v25; // x0
cocos2d::CCDirector *v26; // x0
cocos2d::CCDirector *v27; // x0
float ContentScaleFactor; // s0
float v29; // s10
void (__fastcall *v30)(cocos2d::CCTMXLayer *, float *); // x20
cocos2d::CCDirector *v31; // x0
float v32; // s10
float v33; // s9
cocos2d::CCDirector *v34; // x0
cocos2d::CCDirector *v35; // x0
float v36; // s0
void (__fastcall *v37)(cocos2d::CCTMXLayer *, float *); // x20
float *v38; // x0
float v39; // s9
cocos2d::CCDirector *v40; // x0
float v41; // s9
float *v42; // x0
float v43; // s8
cocos2d::CCDirector *v44; // x0
float v45; // s0
unsigned __int64 v47; // x0
__int64 v48; // x0
__int64 v49; // x6
__int64 v50; // x0
char *v51; // x4
__int64 v52; // [xsp+88h] [xbp+88h]
__int64 v53; // [xsp+88h] [xbp+88h]
char *v54; // [xsp+90h] [xbp+90h]
void *v55; // [xsp+98h] [xbp+98h]
void *v56; // [xsp+98h] [xbp+98h]
void *v57; // [xsp+98h] [xbp+98h]
void *v58; // [xsp+98h] [xbp+98h]
float v59[2]; // [xsp+A0h] [xbp+A0h] BYREF
float v60[2]; // [xsp+A8h] [xbp+A8h] BYREF
float v61; // [xsp+B0h] [xbp+B0h] BYREF
float v62[2]; // [xsp+B8h] [xbp+B8h] BYREF
float v63; // [xsp+C0h] [xbp+C0h] BYREF
v8 = (cocos2d::CCTextureCache *)cocos2d::CCSize::CCSize(v59, (cocos2d::CCTMXLayerInfo *)((char *)a3 + 88));
v9 = v59[0] * v59[1];
if ( a2 )
{
v10 = cocos2d::CCTextureCache::sharedTextureCache(v8);
v11 = (char *)a2 + 105;
if ( (*((_BYTE *)a2 + 104) & 1) != 0 )
v11 = *((char **)a2 + 15);
v12 = (cocos2d::CCTexture2D *)cocos2d::CCTextureCache::addImage(v10, v11, 0);
}
else
{
v12 = nullptr;
}
v13 = cocos2d::CCSpriteBatchNode::initWithTexture(this, v12, (unsigned int)(float)((float)(v9 * 0.35) + 1.0));
v14 = v13;
if ( v13 )
{
if ( (char *)this + 408 == (char *)a3 + 64 )
{
LABEL_14:
cocos2d::CCSize::operator=((float *)this + 89, v59);
*((_QWORD *)this + 47) = *((_QWORD *)a3 + 12);
v21 = *(_QWORD *)this;
*((_DWORD *)this + 109) = *((_DWORD *)a3 + 27);
*((_DWORD *)this + 110) = *((_DWORD *)a3 + 28);
*((_BYTE *)this + 432) = *((_BYTE *)a3 + 105);
v22 = *(__int64 (__fastcall **)(cocos2d::CCTMXLayer *, cocos2d::CCObject *))(v21 + 952);
v23 = (cocos2d::CCDictionary *)(*(__int64 (__fastcall **)(cocos2d::CCTMXLayerInfo *))(*(_QWORD *)a3 + 80LL))(a3);
v25 = cocos2d::CCDictionary::createWithDictionary(v23, v24);
v26 = (cocos2d::CCDirector *)v22(this, v25);
v27 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v26);
ContentScaleFactor = cocos2d::CCDirector::getContentScaleFactor(v27);
*((_QWORD *)this + 48) = a2;
*((float *)this + 118) = ContentScaleFactor;
if ( a2 )
cocos2d::CCObject::retain((__int64)a2);
cocos2d::CCSize::operator=((float *)this + 91, (float *)a4 + 19);
*((_DWORD *)this + 98) = *((_DWORD *)a4 + 16);
cocos2d::CCTMXLayer::calculateLayerOffset(this, (cocos2d::CCTMXLayerInfo *)((char *)a3 + 116), v60);
v29 = v60[0];
v30 = *(void (__fastcall **)(cocos2d::CCTMXLayer *, float *))(*(_QWORD *)this + 184LL);
v31 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(*(cocos2d::CCDirector **)this);
v32 = v29 / cocos2d::CCDirector::getContentScaleFactor(v31);
v33 = v60[1];
v35 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v34);
v36 = cocos2d::CCDirector::getContentScaleFactor(v35);
cocos2d::CCPoint::CCPoint(&v63, v32, v33 / v36);
v30(this, &v63);
*((_QWORD *)this + 58) = cocos2d::ccCArrayNew((cocos2d *)(unsigned int)v9);
v37 = *(void (__fastcall **)(cocos2d::CCTMXLayer *, float *))(*(_QWORD *)this + 320LL);
v38 = cocos2d::CCSize::CCSize(
&v61,
*((float *)this + 89) * *((float *)this + 91),
*((float *)this + 90) * *((float *)this + 92));
v39 = v61;
v40 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector((cocos2d::CCDirector *)v38);
v41 = v39 / cocos2d::CCDirector::getContentScaleFactor(v40);
v42 = cocos2d::CCSize::CCSize(
v62,
*((float *)this + 89) * *((float *)this + 91),
*((float *)this + 90) * *((float *)this + 92));
v43 = v62[1];
v44 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector((cocos2d::CCDirector *)v42);
v45 = cocos2d::CCDirector::getContentScaleFactor(v44);
cocos2d::CCSize::CCSize(&v63, v41, v43 / v45);
v37(this, &v63);
*((_BYTE *)this + 448) = 0;
*((_DWORD *)this + 111) = 0;
return v14;
}
if ( (*((_BYTE *)a3 + 64) & 1) != 0 )
{
v15 = *((char **)a3 + 10);
v16 = *((_QWORD *)a3 + 9);
if ( (*((_BYTE *)this + 408) & 1) != 0 )
goto LABEL_9;
}
else
{
v15 = (char *)a3 + 65;
v16 = *((_BYTE *)a3 + 64) >> 1;
if ( (*((_BYTE *)this + 408) & 1) != 0 )
{
LABEL_9:
v17 = (*((_QWORD *)this + 51) & 0xFFFFFFFFFFFFFFFELL) - 1;
if ( v16 > v17 )
{
v54 = *((char **)this + 53);
if ( v17 > 0x7FFFFFFFFFFFFFE6LL )
{
v55 = v15;
v18 = (void *)operator new(0xFFFFFFFFFFFFFFEFLL);
v19 = v55;
v20 = -17;
if ( !v16 )
{
LABEL_12:
v52 = v20;
v56 = v18;
operator delete(v54);
v20 = v52;
v18 = v56;
LABEL_13:
*((_QWORD *)this + 53) = v18;
*((_QWORD *)this + 51) = v20;
*((_QWORD *)this + 52) = v16;
*((_BYTE *)v18 + v16) = 0;
goto LABEL_14;
}
goto LABEL_26;
}
LABEL_21:
v47 = 2 * v17;
if ( 2 * v17 < v16 )
v47 = v16;
if ( v47 <= 0x16 )
{
v49 = 23;
v48 = 23;
}
else
{
v48 = (v47 + 16) & 0xFFFFFFFFFFFFFFF0LL;
v49 = v48 | 1;
}
v53 = v49;
v57 = v15;
v50 = operator new(v48);
v19 = v57;
v18 = (void *)v50;
v20 = v53;
if ( !v16 )
{
LABEL_27:
if ( v17 == 22 )
goto LABEL_13;
goto LABEL_12;
}
LABEL_26:
v58 = (void *)v20;
v18 = memcpy(v18, v19, v16);
v20 = (__int64)v58;
goto LABEL_27;
}
v51 = *((char **)this + 53);
goto LABEL_31;
}
}
if ( v16 > 0x16 )
{
v17 = 22;
v54 = (char *)this + 409;
goto LABEL_21;
}
v51 = (char *)this + 409;
LABEL_31:
if ( v16 )
v51 = (char *)memmove(v51, v15, v16);
v51[v16] = 0;
if ( (*((_BYTE *)this + 408) & 1) != 0 )
*((_QWORD *)this + 52) = v16;
else
*((_BYTE *)this + 408) = 2 * v16;
goto LABEL_14;
}
return v14;
}