//
// cocos2d::CCTMXLayer::initWithTilesetInfo from 0x8045fc to 0x8047f6 (506 bytes)
//
// 1 xrefs:
// > cocos2d::CCTMXLayer::create @ 0x804896
//
// 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
//
int __fastcall cocos2d::CCTMXLayer::initWithTilesetInfo(
cocos2d::CCTMXLayer *this,
cocos2d::CCTMXTilesetInfo *a2,
cocos2d::CCTMXLayerInfo *a3,
cocos2d::CCTMXMapInfo *a4)
{
cocos2d::CCTextureCache *v8; // r0
float v9; // s16
float v10; // s17
cocos2d::CCTextureCache *v11; // r0
const char *v12; // r1
cocos2d::CCTexture2D *v13; // r1
int v14; // r8
int (__fastcall *v15)(cocos2d::CCTMXLayer *, cocos2d::CCObject *); // r10
__int64 v16; // r0
cocos2d::CCObject *v17; // r0
cocos2d::CCDirector *v18; // r0
cocos2d::CCDirector *v19; // r0
int ContentScaleFactor; // r0
float v21; // r3
cocos2d::CCDirector *v22; // r0
float v23; // s18
void (__fastcall *v24)(cocos2d::CCTMXLayer *, float *); // r6
cocos2d::CCDirector *v25; // r0
float v26; // r0
float v27; // s17
float v28; // s18
cocos2d::CCDirector *v29; // r0
float v30; // r0
unsigned int v31; // r1
_DWORD *v32; // r0
int v33; // r3
float v34; // s15
float v35; // r1
void (__fastcall *v36)(cocos2d::CCTMXLayer *, float *); // r6
float *v37; // r0
float v38; // s17
cocos2d::CCDirector *v39; // r0
float v40; // s15
float *v41; // r0
float v42; // s16
cocos2d::CCDirector *v43; // r0
float v44; // r0
float v46; // [sp+4h] [bp-2Ch] BYREF
float v47; // [sp+8h] [bp-28h]
float v48[2]; // [sp+Ch] [bp-24h] BYREF
float v49[2]; // [sp+14h] [bp-1Ch] BYREF
float v50[2]; // [sp+1Ch] [bp-14h] BYREF
float v51[2]; // [sp+24h] [bp-Ch] BYREF
v8 = (cocos2d::CCTextureCache *)cocos2d::CCSize::CCSize(&v46, (cocos2d::CCTMXLayerInfo *)((char *)a3 + 68));
v9 = v46 * v47;
v10 = (float)((float)(v46 * v47) * 0.35) + 1.0;
if ( a2 )
{
v11 = (cocos2d::CCTextureCache *)cocos2d::CCTextureCache::sharedTextureCache(v8);
if ( (*((_BYTE *)a2 + 84) & 1) != 0 )
v12 = *((const char **)a2 + 23);
else
v12 = (char *)a2 + 85;
v13 = (cocos2d::CCTexture2D *)cocos2d::CCTextureCache::addImage(v11, v12, 0);
}
else
{
v13 = nullptr;
}
v14 = cocos2d::CCSpriteBatchNode::initWithTexture(this, v13, (cocos2d *)v10);
if ( v14 )
{
std::string::operator=((unsigned __int8 *)this + 320, (unsigned __int8 *)a3 + 56);
cocos2d::CCSize::operator=((float *)this + 72, &v46);
*((_DWORD *)this + 76) = *((_DWORD *)a3 + 19);
*((_DWORD *)this + 84) = *((_DWORD *)a3 + 21);
*((_DWORD *)this + 85) = *((_DWORD *)a3 + 22);
*((_BYTE *)this + 332) = *((_BYTE *)a3 + 81);
v15 = *(int (__fastcall **)(cocos2d::CCTMXLayer *, cocos2d::CCObject *))(*(_DWORD *)this + 476);
v16 = ((__int64 (__fastcall *)(cocos2d::CCTMXLayerInfo *))*(_DWORD *)(*(_DWORD *)a3 + 40))(a3);
v17 = cocos2d::CCDictionary::createWithDictionary(
(cocos2d::CCDictionary *)v16,
(cocos2d::CCDictionary *)HIDWORD(v16));
v18 = (cocos2d::CCDirector *)v15(this, v17);
v19 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v18);
ContentScaleFactor = cocos2d::CCDirector::getContentScaleFactor(v19);
*((_DWORD *)this + 77) = a2;
*((_DWORD *)this + 90) = ContentScaleFactor;
if ( a2 )
cocos2d::CCObject::retain((int)a2);
cocos2d::CCSize::operator=((float *)this + 74, (float *)a4 + 17);
v21 = *((float *)a4 + 14);
*((float *)this + 78) = v21;
v22 = cocos2d::CCTMXLayer::calculateLayerOffset((cocos2d::CCTMXLayer *)v48, this, (float *)a3 + 23, v21);
v23 = v48[0];
v24 = *(void (__fastcall **)(cocos2d::CCTMXLayer *, float *))(*(_DWORD *)this + 92);
v25 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v22);
v26 = COERCE_FLOAT(cocos2d::CCDirector::getContentScaleFactor(v25));
v27 = v48[1];
v28 = v23 / v26;
v29 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector((cocos2d::CCDirector *)LODWORD(v26));
v30 = COERCE_FLOAT(cocos2d::CCDirector::getContentScaleFactor(v29));
cocos2d::CCPoint::CCPoint(v51, v28, v27 / v30);
v24(this, v51);
v32 = cocos2d::ccCArrayNew((cocos2d *)v9, v31);
v33 = *(_DWORD *)this;
v34 = *((float *)this + 73) * *((float *)this + 75);
v35 = *((float *)this + 72) * *((float *)this + 74);
*((_DWORD *)this + 89) = v32;
v36 = *(void (__fastcall **)(cocos2d::CCTMXLayer *, float *))(v33 + 160);
v37 = cocos2d::CCSize::CCSize(v49, v35, v34);
v38 = v49[0];
v39 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector((cocos2d::CCDirector *)v37);
v40 = COERCE_FLOAT(cocos2d::CCDirector::getContentScaleFactor(v39));
v41 = cocos2d::CCSize::CCSize(
v50,
*((float *)this + 72) * *((float *)this + 74),
*((float *)this + 73) * *((float *)this + 75));
v42 = v50[1];
v43 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector((cocos2d::CCDirector *)v41);
v44 = COERCE_FLOAT(cocos2d::CCDirector::getContentScaleFactor(v43));
cocos2d::CCSize::CCSize(v51, v38 / v40, v42 / v44);
v36(this, v51);
*((_BYTE *)this + 348) = 0;
*((_DWORD *)this + 86) = 0;
}
return v14;
}