//
// cocos2d::CCLabelBMFont::createFontChars from 0x1002fb780 to 0x1002fbdb8 (1592 bytes)
//
// 1 xrefs:
// > cocos2d::CCLabelBMFont::setString @ 0x1002fbf20
//
// 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::CCLabelBMFont::createFontChars(cocos2d::CCLabelBMFont *a1)
{
unsigned __int16 *m_sString; // x0
int v3; // w0
unsigned int v4; // w21
cocos2d::CCBMFontConfiguration *m_pConfiguration; // x8
std::set *m_pCharacterSet; // x22
__int64 v7; // x10
unsigned __int16 *v8; // x11
int v9; // w9
int v10; // t1
float v11; // s8
cocos2d::CCDirector *v12; // x0
float v13; // s0
float v14; // s9
float v15; // s8
cocos2d::CCDirector *v16; // x0
float v17; // s0
int m_nCommonHeight; // w8
int v19; // w23
__int64 v20; // x20
int v21; // w28
std::__compressed_pair *>> *p_pair1; // x27
__int64 v23; // x26
__int64 v24; // x24
__int64 v25; // x25
std::__tree_end_node *>::pointer left; // x8
int v27; // w21
std::__compressed_pair *>> *v28; // x9
std::__tree_end_node *>::pointer v29; // x10
unsigned int v30; // w11
bool v31; // cf
_BOOL4 v32; // w11
std::__compressed_pair *>> *v33; // x9
unsigned int v34; // w10
_BOOL4 v35; // w10
int v36; // w0
int m_nExtraKerning; // w8
cocos2d::tCCFontDefHashElement *m_pFontDefDictionary; // x9
int v39; // w10
unsigned int v40; // w11
unsigned int v41; // w12
int v42; // w10
unsigned int v43; // w11
unsigned int v44; // w12
int v45; // w10
unsigned int v46; // w11
UT_hash_table *tbl; // x10
UT_hash_handle *hh_head; // x9
int v49; // w22
std::ptrdiff_t v50; // x21
__int16 v51; // w8
float v52; // s8
cocos2d::CCDirector *v53; // x0
float v54; // s0
float v55; // s9
float v56; // s8
cocos2d::CCDirector *v57; // x0
float v58; // s0
float v59; // s10
float v60; // s9
cocos2d::CCDirector *v61; // x0
float v62; // s0
float v63; // s13
float v64; // s10
cocos2d::CCDirector *v65; // x0
float v66; // s0
__int64 v67; // x0
float *v68; // x21
float v69; // s8
float v70; // s8
cocos2d::CCDirector *v71; // x0
float v72; // s0
float v73; // s9
cocos2d::CCDirector *v74; // x0
cocos2d::CCTexture2D *m_pSomeTexture; // x1
float v76; // s8
float v77; // s9
float v78; // s10
cocos2d::CCDirector *v79; // x0
__n128 v80; // q1
__n128 v81; // q0
float v82; // s8
cocos2d::CCDirector *v83; // x0
float v84; // s0
float v85; // s9
float v86; // s8
cocos2d::CCDirector *v87; // x0
__n128 v88; // q1
__n128 v89; // q0
unsigned int v90; // w8
float v91; // s0
float v92; // s8
cocos2d::CCDirector *v93; // x0
float v94; // s0
float v95; // s9
float v96; // s8
cocos2d::CCDirector *v97; // x0
float v98; // s0
unsigned int v99; // [xsp+8h] [xbp-D8h]
unsigned int v100; // [xsp+Ch] [xbp-D4h]
int v101; // [xsp+10h] [xbp-D0h] BYREF
float v102[4]; // [xsp+18h] [xbp-C8h] BYREF
int v103; // [xsp+28h] [xbp-B8h]
int v104; // [xsp+2Ch] [xbp-B4h] BYREF
__int64 v105; // [xsp+30h] [xbp-B0h] BYREF
float v106; // [xsp+38h] [xbp-A8h]
float v107; // [xsp+3Ch] [xbp-A4h]
int v108; // [xsp+40h] [xbp-A0h]
__int16 v109; // [xsp+44h] [xbp-9Ch]
float32x2_t v110; // [xsp+48h] [xbp-98h] BYREF
float v111; // [xsp+50h] [xbp-90h] BYREF
float v112; // [xsp+54h] [xbp-8Ch]
__int64 v113; // [xsp+58h] [xbp-88h] BYREF
sub_100022AFC(&v113, &dbl_10086DDB8);
m_sString = a1->m_sString;
if ( m_sString && (v3 = cocos2d::cc_wcslen(m_sString)) != 0 )
{
v4 = v3;
m_pConfiguration = a1->m_pConfiguration;
m_pCharacterSet = m_pConfiguration->m_pCharacterSet;
v7 = (unsigned int)(v3 - 1);
if ( v3 == 1 )
{
v9 = 1;
}
else
{
v8 = a1->m_sString;
v9 = 1;
do
{
v10 = *v8++;
if ( v10 == 10 )
++v9;
--v7;
}
while ( v7 );
}
m_nCommonHeight = m_pConfiguration->m_nCommonHeight;
v99 = m_nCommonHeight * v9;
v19 = m_nCommonHeight * v9 - m_nCommonHeight;
sub_100022B90(&v110);
sub_100022B90(&v105);
v20 = 0;
v21 = 0;
v100 = 0;
p_pair1 = &m_pCharacterSet->__tree_.__pair1_;
v23 = 0xFFFF;
v24 = v4;
do
{
v25 = a1->m_sString[v20];
if ( (_DWORD)v25 == 10 )
{
v21 = 0;
v19 -= a1->m_pConfiguration->m_nCommonHeight;
}
else
{
left = p_pair1->__value_.__left_;
if ( p_pair1->__value_.__left_ )
{
v27 = a1->m_sString[v20];
v28 = p_pair1;
v29 = p_pair1->__value_.__left_;
do
{
v30 = *((_DWORD *)v29 + 7);
v31 = v30 >= (unsigned int)v25;
v32 = v30 < (unsigned int)v25;
if ( v31 )
v28 = (std::__compressed_pair *>> *)v29;
v29 = *((std::__tree_end_node *>::pointer *)v29 + v32);
}
while ( v29 );
if ( v28 != p_pair1 && HIDWORD(v28[3].__value_.__left_) <= (unsigned int)v25 )
goto LABEL_31;
}
if ( (unsigned int)(v25 - 97) <= 0x19 && left )
{
v25 = (unsigned int)(v25 - 32);
v27 = (unsigned __int16)v25;
v33 = p_pair1;
do
{
v34 = *((_DWORD *)left + 7);
v31 = v34 >= (unsigned __int16)v25;
v35 = v34 < (unsigned __int16)v25;
if ( v31 )
v33 = (std::__compressed_pair *>> *)left;
left = *((std::__tree_end_node *>::pointer *)left + v35);
}
while ( left );
if ( v33 != p_pair1 && HIDWORD(v33[3].__value_.__left_) <= (unsigned __int16)v25 )
{
LABEL_31:
v36 = cocos2d::CCLabelBMFont::kerningAmountForFirst(a1, v23, v25);
m_nExtraKerning = a1->m_nExtraKerning;
v103 = v27;
m_pFontDefDictionary = a1->m_pConfiguration->m_pFontDefDictionary;
if ( !m_pFontDefDictionary )
goto LABEL_38;
v39 = (v27 + 17973517) ^ 0x7F76D;
v40 = (-1622558010 - v39) ^ (v39 << 8);
v41 = (-17973517 - v39 - v40) ^ (v40 >> 13);
v42 = (v39 - v40 - v41) ^ (v41 >> 12);
v43 = (v40 - v41 - v42) ^ (v42 << 16);
v44 = (v41 - v42 - v43) ^ (v43 >> 5);
v45 = (v42 - v43 - v44) ^ (v44 >> 3);
v46 = (v44 - v45 - ((v43 - v44 - v45) ^ (v45 << 10))) ^ (((v43 - v44 - v45) ^ (v45 << 10)) >> 15);
tbl = m_pFontDefDictionary->hh.tbl;
hh_head = tbl->buckets[v46 & (tbl->num_buckets - 1)].hh_head;
if ( hh_head )
{
v49 = m_nExtraKerning + v36;
while ( 1 )
{
v50 = (std::ptrdiff_t)hh_head - tbl->hho;
if ( *(_DWORD *)(v50 + 80) == 4 && **(_DWORD **)(v50 + 72) == v103 )
break;
hh_head = *(UT_hash_handle **)(v50 + 64);
if ( !hh_head )
{
v25 = v23;
goto LABEL_51;
}
}
v104 = *(_DWORD *)(v50 + 4);
sub_100022BB0(&v105, v50 + 8);
v51 = *(_WORD *)(v50 + 28);
v108 = *(_DWORD *)(v50 + 24);
v109 = v51;
sub_100022BB0(&v110, (__int64)&v105);
v52 = v110.f32[0];
v53 = cocos2d::CCDirector::sharedDirector();
v54 = sub_1001765E4((__int64)v53);
v55 = v110.f32[1];
v56 = v52 / v54;
v57 = cocos2d::CCDirector::sharedDirector();
v58 = sub_1001765E4((__int64)v57);
v59 = v111;
v60 = v55 / v58;
v61 = cocos2d::CCDirector::sharedDirector();
v62 = sub_1001765E4((__int64)v61);
v63 = v112;
v64 = v59 / v62;
v65 = cocos2d::CCDirector::sharedDirector();
v66 = sub_1001765E4((__int64)v65);
sub_100022990(v102, v56, v60, v64, v63 / v66);
sub_100022BB0(&v110, (__int64)v102);
v110 = vadd_f32((float32x2_t)a1->m_tImageOffset, v110);
v67 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, __int64))a1->getChildByTag)(a1, v20);
if ( v67 )
{
v68 = (float *)v67;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v67 + 328LL))(v67, 1);
v69 = (float)v49;
}
else
{
v68 = (float *)operator new(0x280u);
sub_1002FCE68();
v70 = (float)(__int16)v108;
v71 = cocos2d::CCDirector::sharedDirector();
v72 = v70 / sub_1001765E4((__int64)v71);
v69 = (float)v49;
v68[149] = v72 + (float)v49;
v73 = (float)((float)a1->m_pConfiguration->m_nCommonHeight - v107) * 0.5;
v74 = cocos2d::CCDirector::sharedDirector();
v68[150] = v73 / sub_1001765E4((__int64)v74);
if ( a1->m_bIsBatched )
m_pSomeTexture = a1->m_pSomeTexture;
else
m_pSomeTexture = (cocos2d::CCTexture2D *)((__int64 (__fastcall *)(cocos2d::CCTextureAtlas *))a1->m_pobTextureAtlas->getTexture)(a1->m_pobTextureAtlas);
(*(void (__fastcall **)(float *, cocos2d::CCTexture2D *, float32x2_t *))(*(_QWORD *)v68 + 1000LL))(
v68,
m_pSomeTexture,
&v110);
if ( a1->m_bIsBatched )
sub_10024A2D0((__int64)a1->m_pTargetArray);
else
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float *, __int64, __int64))a1->addChild_1)(
a1,
v68,
v20,
v20);
cocos2d::CCObject::release((cocos2d::CCObject *)v68);
(*(void (__fastcall **)(float *, bool))(*(_QWORD *)v68 + 976LL))(v68, a1->m_bIsOpacityModifyRGB);
(*(void (__fastcall **)(float *, cocos2d::ccColor3B *))(*(_QWORD *)v68 + 952LL))(
v68,
&a1->m_tDisplayedColor);
(*(void (__fastcall **)(float *, _QWORD))(*(_QWORD *)v68 + 904LL))(v68, a1->m_cDisplayedOpacity);
}
(*(void (__fastcall **)(float *, float32x2_t *, _QWORD, float *))(*(_QWORD *)v68 + 1128LL))(
v68,
&v110,
0,
&v111);
v76 = (float)((float)((float)v21 + (float)(__int16)v108) + (float)(v106 * 0.5)) + v69;
v77 = (float)v19 + (float)(a1->m_pConfiguration->m_nCommonHeight - SHIWORD(v108));
v78 = v112;
v79 = cocos2d::CCDirector::sharedDirector();
v80.n128_f32[0] = v77 + (float)((float)(v78 * -0.5) * sub_1001765E4((__int64)v79));
v81.n128_f32[0] = v76;
sub_100022980(v81, v80, v102);
v82 = v102[0];
v83 = cocos2d::CCDirector::sharedDirector();
v84 = sub_1001765E4((__int64)v83);
v85 = v102[1];
v86 = v82 / v84;
v87 = cocos2d::CCDirector::sharedDirector();
v88.n128_f32[0] = v85 / sub_1001765E4((__int64)v87);
v89.n128_f32[0] = v86;
sub_100022980(v89, v88, &v101);
(*(void (__fastcall **)(float *, int *))(*(_QWORD *)v68 + 184LL))(v68, &v101);
v21 += v49 + v109;
v90 = v100;
if ( (int)v100 <= v21 )
v90 = v21;
v100 = v90;
}
else
{
LABEL_38:
v25 = v23;
}
LABEL_51:
v23 = v25;
}
}
}
++v20;
}
while ( v20 != v24 );
v91 = (float)v109;
if ( v106 <= v91 )
v92 = (float)v100;
else
v92 = (float)(v106 + (float)v100) - v91;
*(float *)&v113 = v92;
*((float *)&v113 + 1) = (float)v99;
v93 = cocos2d::CCDirector::sharedDirector();
v94 = sub_1001765E4((__int64)v93);
v95 = *((float *)&v113 + 1);
v96 = v92 / v94;
v97 = cocos2d::CCDirector::sharedDirector();
v98 = sub_1001765E4((__int64)v97);
sub_100022988(v102, v96, v95 / v98);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float *))a1->setContentSize)(a1, v102);
}
else
{
v11 = *(float *)&v113;
v12 = cocos2d::CCDirector::sharedDirector();
v13 = sub_1001765E4((__int64)v12);
v14 = *((float *)&v113 + 1);
v15 = v11 / v13;
v16 = cocos2d::CCDirector::sharedDirector();
v17 = sub_1001765E4((__int64)v16);
sub_100022988((float *)&v104, v15, v14 / v17);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int *))a1->setContentSize)(a1, &v104);
}
}