//
// cocos2d::CCTileMapAtlas::initWithTileFile from 0x10022ca00 to 0x10022cbd4 (468 bytes)
//
// 1 xrefs:
// > cocos2d::CCTileMapAtlas::create @ 0x10022c968
//
// 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
//
bool __fastcall cocos2d::CCTileMapAtlas::initWithTileFile(
cocos2d::CCTileMapAtlas *a1,
const char *a2,
const char *a3,
int a4,
int a5)
{
cocos2d::CCFileUtils *v9; // rax
char *v10; // rdi
cocos2d::sImageTGA *m_pTGAInfo; // rax
__int64 width; // rcx
unsigned int v13; // r8d
__int64 height; // rdx
unsigned __int8 *imageData; // r14
unsigned __int8 *v16; // rax
__int64 i; // r11
__int64 v18; // r13
unsigned __int8 *v19; // r10
bool result; // al
bool v21; // r15
cocos2d::CCDictionary *v22; // r14
char v23; // [rsp+10h] [rbp-40h] BYREF
char v24; // [rsp+11h] [rbp-3Fh] BYREF
void *__p; // [rsp+20h] [rbp-30h]
v9 = cocos2d::CCFileUtils::sharedFileUtils();
((void (__fastcall *)(char *, cocos2d::CCFileUtils *, const char *, _QWORD))v9->createCCArrayWithContentsOfFile)(
&v23,
v9,
a3,
0);
if ( (v23 & 1) != 0 )
v10 = (char *)__p;
else
v10 = &v24;
m_pTGAInfo = (cocos2d::sImageTGA *)sub_1002BA5A0(v10);
a1->m_pTGAInfo = m_pTGAInfo;
if ( (v23 & 1) != 0 )
{
operator delete(__p);
m_pTGAInfo = a1->m_pTGAInfo;
}
a1->m_nItemsToRender = 0;
width = m_pTGAInfo->width;
v13 = 0;
if ( width > 0 )
{
height = m_pTGAInfo->height;
if ( height > 0 )
{
imageData = m_pTGAInfo->imageData;
v13 = 0;
v16 = imageData;
for ( i = 0; i != width; ++i )
{
if ( (_WORD)height == 1 )
{
v18 = 0;
}
else
{
v19 = v16;
v18 = 0;
do
{
if ( *v19 )
a1->m_nItemsToRender = ++v13;
if ( v19[3 * width] )
a1->m_nItemsToRender = ++v13;
v18 += 2;
v19 += 6 * width;
}
while ( (height & 0x7FFE) != v18 );
}
if ( (height & 1) != 0 && imageData[3 * i + 3 * width * v18] )
a1->m_nItemsToRender = ++v13;
v16 += 3;
}
}
}
result = cocos2d::CCAtlasNode::initWithTileFile(a1, a2, a4, a5, v13);
if ( result )
{
v21 = result;
v22 = (cocos2d::CCDictionary *)operator new(0x48u);
cocos2d::CCDictionary::CCDictionary(v22);
a1->m_pPosToAtlasIndex = v22;
((void (__fastcall *)(cocos2d::CCTileMapAtlas *))a1->updateAtlasValues)(a1);
sub_10028CBF0(
&v23,
(float)(a1->m_uItemWidth * a1->m_pTGAInfo->width),
(float)(a1->m_uItemHeight * a1->m_pTGAInfo->height));
((void (__fastcall *)(cocos2d::CCTileMapAtlas *, char *))a1->setContentSize)(a1, &v23);
return v21;
}
return result;
}