//
// cocos2d::CCTileMapAtlas::updateAtlasValues from 0x1800ab8c0 to 0x1800abbab (747 bytes)
//
// 3 xrefs:
// > ??> @ 0x180105918
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b8088
//
// 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
//
// Hidden C++ exception states: #wind=2
void __fastcall cocos2d::CCTileMapAtlas::updateAtlasValues(cocos2d::CCTileMapAtlas *this)
{
void *v2; // rsi
signed int v3; // r15d
int v4; // ebx
cocos2d::sImageTGA *m_pTGAInfo; // rdx
int v6; // r12d
cocos2d::sImageTGA *v7; // rcx
unsigned __int8 *imageData; // rcx
__int64 v9; // rdx
const struct cocos2d::CCPoint *v10; // rax
cocos2d::CCString *v11; // rbx
cocos2d::CCObject *v12; // rax
cocos2d::CCObject *v13; // r14
std::string *CString; // rax
std::string *v15; // rbp
size_t v16; // rbx
unsigned __int64 v17; // rdi
size_t v18; // rax
void *v19; // rax
void *v20; // rcx
struct cocos2d::_ccColor3B v21; // [rsp+20h] [rbp-68h] BYREF
int v22; // [rsp+24h] [rbp-64h]
float v23; // [rsp+28h] [rbp-60h] BYREF
cocos2d::CCObject *v24; // [rsp+30h] [rbp-58h]
__int128 v25; // [rsp+38h] [rbp-50h] BYREF
size_t v26; // [rsp+48h] [rbp-40h]
unsigned __int64 v27; // [rsp+50h] [rbp-38h]
v2 = nullptr;
v3 = 0;
v4 = 0;
v22 = 0;
m_pTGAInfo = this->m_pTGAInfo;
if ( m_pTGAInfo->width > 0 )
{
while ( 1 )
{
v6 = 0;
v7 = m_pTGAInfo;
if ( m_pTGAInfo->height > 0 )
break;
LABEL_30:
v22 = ++v4;
m_pTGAInfo = v7;
if ( v4 >= v7->width )
return;
}
while ( 1 )
{
if ( v3 < this->m_nItemsToRender )
{
imageData = m_pTGAInfo->imageData;
v9 = v4 + v6 * m_pTGAInfo->width;
v21 = *(struct cocos2d::_ccColor3B *)&imageData[2 * v9 + v9];
if ( v21.r )
break;
}
LABEL_29:
++v6;
v7 = this->m_pTGAInfo;
m_pTGAInfo = v7;
if ( v6 >= v7->height )
goto LABEL_30;
}
v10 = (const struct cocos2d::CCPoint *)kmVec2Fill(&v23, (float)v4, (float)v6);
cocos2d::CCTileMapAtlas::updateAtlasValueAt(this, v10, &v21, v3);
v11 = cocos2d::CCString::createWithFormat("%d,%d", v4, v6);
v12 = (cocos2d::CCObject *)operator new(0x40u);
v13 = v12;
v24 = v12;
if ( v12 )
{
cocos2d::CCObject::CCObject(v12);
v13->__vftable = (cocos2d::CCObject_vtbl *)&cocos2d::CCInteger::`vftable';
LODWORD(v13[1].__vftable) = v3;
}
else
{
v13 = nullptr;
}
cocos2d::CCObject::autorelease(v13);
CString = cocos2d::CCString::getCString(v11);
v15 = CString;
v25 = 0;
v26 = 0;
v27 = 0;
v16 = -1;
do
++v16;
while ( CString->m_data.m_smallStorage._Elems[v16] );
if ( v16 > 0x7FFFFFFFFFFFFFFFLL )
std::vector::_Xlen();
v27 = 15;
if ( v16 <= 0xF )
{
v26 = v16;
memcpy(&v25, CString, v16);
*((_BYTE *)&v25 + v16) = 0;
LABEL_24:
cocos2d::CCDictionary::setObject((__int64)this->m_pPosToAtlasIndex, v13, (unsigned __int8 *)&v25);
if ( v27 > 0xF )
{
v20 = (void *)v25;
if ( v27 + 1 >= 0x1000 )
{
v20 = *(void **)(v25 - 8);
if ( (unsigned __int64)(v25 - (_QWORD)v20 - 8) > 0x1F )
LABEL_32:
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v20);
}
++v3;
v4 = v22;
goto LABEL_29;
}
v17 = v16 | 0xF;
if ( (v16 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
if ( v17 < 0x16 )
v17 = 22;
if ( v17 + 1 < 0x1000 )
{
if ( v17 != -1 )
v2 = operator new(v17 + 1);
LABEL_23:
*(_QWORD *)&v25 = v2;
v26 = v16;
v27 = v17;
memcpy(v2, v15, v16);
*((_BYTE *)v2 + v16) = 0;
v2 = nullptr;
goto LABEL_24;
}
v18 = v17 + 40;
if ( v17 + 40 < v17 + 1 )
Concurrency::cancel_current_task();
}
else
{
v17 = 0x7FFFFFFFFFFFFFFFLL;
v18 = 0x8000000000000027uLL;
}
v19 = operator new(v18);
if ( !v19 )
goto LABEL_32;
v2 = (void *)(((unsigned __int64)v19 + 39) & 0xFFFFFFFFFFFFFFE0uLL);
*((_QWORD *)v2 - 1) = v19;
goto LABEL_23;
}
}