//
// cocos2d::CCLabelAtlas::updateAtlasValues from 0x100799940 to 0x100799c0b (715 bytes)
//
// 1 xrefs:
// > ??> @ 0x10098e570
//
// 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
//
void __fastcall cocos2d::CCLabelAtlas::updateAtlasValues(cocos2d::CCLabelAtlas *a1)
{
unsigned int sizex2; // eax
unsigned int size; // eax
std::array *longStorage; // r13
__int64 v5; // r14
__int64 v6; // r12
unsigned int v7; // r15d
int v8; // r12d
__m128 m_uItemWidth; // xmm0
cocos2d::CCDirector *v10; // rax
cocos2d::CCDirector *v11; // rax
__m128 inserted; // xmm0
__m128d si128; // xmm1
__m128d v14; // xmm2
__int64 v15; // rax
__m128d v16; // xmm1
__m128 v17; // xmm0
__m128 v18; // xmm5
__m128 v19; // xmm1
double *v20; // rcx
__int64 v21; // rsi
__m128 v22; // xmm2
__m128 v23; // xmm3
float v24; // xmm4_4
unsigned int v25; // eax
int v26; // edx
__int64 r; // rdx
GLubyte g; // di
GLubyte b; // r8
cocos2d::CCTextureAtlas *m_pTextureAtlas; // rdi
unsigned int v31; // eax
__m128i v32; // [rsp+0h] [rbp-50h] BYREF
__m128 v33; // [rsp+10h] [rbp-40h]
sizex2 = a1->m_sString.m_data.m_short.sizex2;
if ( (sizex2 & 1) != 0 )
{
size = a1->m_sString.m_data.m_long.size;
longStorage = (std::array *)a1->m_sString.m_data.m_long.longStorage;
}
else
{
size = sizex2 >> 1;
longStorage = &a1->m_sString.m_data.m_short.shortStorage;
}
v5 = size;
v6 = ((__int64 (__fastcall *)(cocos2d::CCTextureAtlas *))a1->m_pTextureAtlas->getTexture)(a1->m_pTextureAtlas);
v7 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v6 + 88LL))(v6);
v8 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v6 + 96LL))(v6);
m_uItemWidth = (__m128)a1->m_uItemWidth;
v32 = (__m128i)m_uItemWidth;
v10 = cocos2d::CCDirector::sharedDirector();
m_uItemWidth.f32[0] = sub_1004849C0((__int64)v10);
v33 = m_uItemWidth;
inserted = (__m128)_mm_insert_epi32(_mm_load_si128(&v32), a1->m_uItemHeight, 1);
v32 = (__m128i)inserted;
v11 = cocos2d::CCDirector::sharedDirector();
inserted.f32[0] = sub_1004849C0((__int64)v11);
if ( a1->m_bIgnoreContentScaleFactor )
{
si128 = (__m128d)_mm_load_si128((const __m128i *)&xmmword_100817DC0);
v33 = _mm_cvtpd_ps(_mm_sub_pd((__m128d)_mm_or_si128(_mm_cvtepu32_epi64(*(__m64 *)&a1->m_uItemWidth), (__m128i)si128), si128));
}
else
{
v14 = (__m128d)_mm_load_si128((const __m128i *)&xmmword_100817DC0);
v33 = _mm_mul_ps(
_mm_insert_ps(v33, inserted, 16),
_mm_cvtpd_ps(_mm_sub_pd((__m128d)_mm_or_si128(_mm_cvtepu32_epi64(*(__m64 *)v32.i8), (__m128i)v14), v14)));
}
((void (__fastcall *)(cocos2d::CCTextureAtlas *))a1->m_pTextureAtlas->getCapacity)(a1->m_pTextureAtlas);
v15 = ((__int64 (__fastcall *)(cocos2d::CCTextureAtlas *))a1->m_pTextureAtlas->getQuads)(a1->m_pTextureAtlas);
if ( v5 )
{
v16 = (__m128d)_mm_load_si128((const __m128i *)&xmmword_100817DC0);
v17 = _mm_cvtpd_ps(
_mm_sub_pd(
(__m128d)_mm_or_si128(_mm_cvtepu32_epi64(_mm_insert_epi32(_mm_cvtsi32_si128(v7), v8, 1)), (__m128i)v16),
v16));
v18 = v33;
v19 = _mm_div_ps(v33, v17);
v20 = (double *)(v15 + 88);
v21 = 0;
do
{
v22 = _mm_div_ps(
_mm_mul_ps(
_mm_cvtepi32_ps(
_mm_insert_epi32(
_mm_cvtsi32_si128((unsigned __int8)(longStorage->__elems_[v21] - LOBYTE(a1->m_uMapStartChar)) % a1->m_uItemsPerRow),
(unsigned __int8)(longStorage->__elems_[v21] - LOBYTE(a1->m_uMapStartChar)) / a1->m_uItemsPerRow,
1)),
v18),
v17);
v23 = _mm_add_ps(v19, v22);
*((_DWORD *)v20 - 18) = v22.i32[0];
v24 = _mm_movehdup_ps(v22).f32[0];
*((float *)v20 - 17) = v24;
*((_DWORD *)v20 - 6) = v23.i32[0];
*((float *)v20 - 5) = v24;
*((_DWORD *)v20 - 12) = v22.i32[0];
*((_DWORD *)v20 - 11) = _mm_extract_ps(v23, 1);
_mm_storel_ps(v20, v23);
v25 = a1->m_uItemWidth;
v26 = v21++;
v22.f32[0] = (float)(int)(v25 * v26);
v23.f32[0] = (float)(int)(v25 * v21);
*((_DWORD *)v20 - 16) = v22.i32[0];
*(double *)((char *)v20 - 60) = 0.0;
*((_DWORD *)v20 - 4) = v23.i32[0];
*(double *)((char *)v20 - 12) = 0.0;
*((_DWORD *)v20 - 22) = v22.i32[0];
v22.f32[0] = (float)(int)a1->m_uItemHeight;
*((_DWORD *)v20 - 21) = v22.i32[0];
*((_DWORD *)v20 - 20) = 0;
*((_DWORD *)v20 - 10) = v23.i32[0];
*((_DWORD *)v20 - 9) = v22.i32[0];
*((_DWORD *)v20 - 8) = 0;
LOBYTE(v25) = a1->_displayedOpacity;
r = a1->_displayedColor.r;
g = a1->_displayedColor.g;
b = a1->_displayedColor.b;
*((_BYTE *)v20 - 76) = r;
*((_BYTE *)v20 - 75) = g;
*((_BYTE *)v20 - 74) = b;
*((_BYTE *)v20 - 73) = v25;
*((_BYTE *)v20 - 28) = r;
*((_BYTE *)v20 - 27) = g;
*((_BYTE *)v20 - 26) = b;
*((_BYTE *)v20 - 25) = v25;
*((_BYTE *)v20 - 52) = r;
*((_BYTE *)v20 - 51) = g;
*((_BYTE *)v20 - 50) = b;
*((_BYTE *)v20 - 49) = v25;
*((_BYTE *)v20 - 4) = r;
*((_BYTE *)v20 - 3) = g;
*((_BYTE *)v20 - 2) = b;
*((_BYTE *)v20 - 1) = v25;
v20 += 12;
}
while ( v5 != v21 );
m_pTextureAtlas = a1->m_pTextureAtlas;
LOBYTE(m_pTextureAtlas->m_uTotalQuads) = 1;
v31 = ((__int64 (__fastcall *)(cocos2d::CCTextureAtlas *, __int64, __int64, double *))m_pTextureAtlas->getTotalQuads)(
m_pTextureAtlas,
v21,
r,
v20);
if ( v31 < (unsigned int)v5 )
cocos2d::CCTextureAtlas::increaseTotalQuadsWith(a1->m_pTextureAtlas, v5 - v31);
}
}