//
// cocos2d::CCLabelBMFont::createFontChars from 0x180047e00 to 0x180048660 (2144 bytes)
//
// 4 xrefs:
// > cocos2d::CCLabelBMFont::setFntFile @ 0x18004c648
// > cocos2d::CCLabelBMFont::setString @ 0x18004c9c1
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b1914
//
// 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=1
void __fastcall cocos2d::CCLabelBMFont::createFontChars(cocos2d::CCLabelBMFont *this)
{
unsigned __int16 v2; // di
const unsigned __int16 *v3; // rdx
int v4; // ebx
unsigned __int16 *m_sString; // rcx
unsigned int v6; // r14d
cocos2d::CCBMFontConfiguration *m_pConfiguration; // r8
__int64 v8; // rdx
unsigned __int16 *v9; // rcx
int v10; // eax
int v11; // r13d
unsigned int v12; // r12d
__int64 v13; // rcx
std::_Tree_node::value_type v14; // r14d
std::_Tree_val>::_Nodeptr Myhead; // rax
std::_Tree_node::_Nodeptr Parent; // r8
std::_Tree_val>::_Nodeptr v17; // rdx
char Isnil; // r11
std::_Tree_node::_Nodeptr v19; // rcx
__int16 v20; // r10
std::_Tree_val>::_Nodeptr v21; // rcx
int v22; // r15d
cocos2d::tCCFontDefHashElement *m_pFontDefDictionary; // r10
int v24; // r8d
unsigned int v25; // edx
unsigned int v26; // ecx
int v27; // r8d
unsigned int v28; // edx
unsigned int v29; // ecx
int v30; // r8d
unsigned int v31; // ecx
UT_hash_table *tbl; // rdx
UT_hash_handle *hh_head; // rbx
std::ptrdiff_t hho; // rcx
__int64 v35; // rbx
__int64 v36; // rbx
cocos2d::CCDirector *v37; // rax
float ContentScaleFactor; // xmm0_4
float v39; // xmm8_4
cocos2d::CCDirector *v40; // rax
float v41; // xmm0_4
float v42; // xmm7_4
cocos2d::CCDirector *v43; // rax
float v44; // xmm0_4
float v45; // xmm6_4
cocos2d::CCDirector *v46; // rax
float v47; // xmm0_4
cocos2d::CCRect *v48; // rax
__int64 v49; // rax
__int64 v50; // rdx
float *v51; // rdi
float v52; // xmm7_4
cocos2d::CCFontSprite *v53; // rax
float v54; // xmm6_4
cocos2d::CCDirector *v55; // rax
float v56; // xmm6_4
cocos2d::CCDirector *v57; // rax
cocos2d::CCTexture2D *m_pSomeTexture; // rax
float v59; // xmm6_4
cocos2d::CCDirector *v60; // rax
float v61; // xmm0_4
__int64 v62; // rbx
cocos2d::CCDirector *v63; // rax
float v64; // xmm0_4
float v65; // xmm6_4
cocos2d::CCDirector *v66; // rax
float v67; // xmm0_4
float *v68; // rax
int v69; // eax
float v70; // xmm1_4
float v71; // xmm0_4
cocos2d::CCLabelBMFont_vtbl *v72; // rbx
cocos2d::CCDirector *v73; // rax
float v74; // xmm0_4
float v75; // xmm6_4
cocos2d::CCDirector *v76; // rax
float v77; // xmm0_4
float *v78; // rax
__int64 v79; // [rsp+38h] [rbp-99h]
float v80; // [rsp+40h] [rbp-91h] BYREF
float v81; // [rsp+44h] [rbp-8Dh]
cocos2d::CCRect v82; // [rsp+48h] [rbp-89h] BYREF
int v83; // [rsp+58h] [rbp-79h]
cocos2d::CCRect v84; // [rsp+5Ch] [rbp-75h] BYREF
__int16 v85; // [rsp+6Ch] [rbp-65h]
__int16 v86; // [rsp+6Eh] [rbp-63h]
__int16 v87; // [rsp+70h] [rbp-61h]
float v88[2]; // [rsp+78h] [rbp-59h] BYREF
std::set *m_pCharacterSet; // [rsp+80h] [rbp-51h]
cocos2d::CCFontSprite *v90; // [rsp+88h] [rbp-49h]
float v91; // [rsp+90h] [rbp-41h] BYREF
cocos2d::CCRect v92; // [rsp+98h] [rbp-39h] BYREF
int v93; // [rsp+138h] [rbp+67h] BYREF
int v94; // [rsp+140h] [rbp+6Fh]
unsigned int v95; // [rsp+148h] [rbp+77h]
int v96; // [rsp+150h] [rbp+7Fh]
v93 = 0;
v2 = -1;
cocos2d::cc_timeval::operator=(&v80, dword_1801A83B0);
v94 = 0;
v4 = 1;
m_sString = this->m_sString;
if ( m_sString )
{
v6 = cocos2d::cc_wcslen((cocos2d *)m_sString, v3);
v95 = v6;
if ( v6 )
{
m_pConfiguration = this->m_pConfiguration;
m_pCharacterSet = m_pConfiguration->m_pCharacterSet;
v8 = v6 - 1;
if ( v6 != 1 )
{
v9 = this->m_sString;
do
{
v10 = v4 + 1;
if ( *v9 != 10 )
v10 = v4;
v4 = v10;
++v9;
--v8;
}
while ( v8 );
}
v96 = v4 * m_pConfiguration->m_nCommonHeight;
v11 = m_pConfiguration->m_nCommonHeight * (v4 - 1);
cocos2d::CCRect::CCRect(&v82);
cocos2d::CCRect::CCRect(&v84);
v12 = 0;
v13 = 0;
v79 = 0;
do
{
v14 = *(unsigned __int16 *)((char *)this->m_sString + v13);
if ( v14 == 10 )
{
v93 = 0;
v11 -= this->m_pConfiguration->m_nCommonHeight;
}
else
{
Myhead = m_pCharacterSet->_Mypair._Myval2._Myval2._Myhead;
Parent = m_pCharacterSet->_Mypair._Myval2._Myval2._Myhead->_Parent;
v17 = m_pCharacterSet->_Mypair._Myval2._Myval2._Myhead;
Isnil = Parent->_Isnil;
if ( !Isnil )
{
v19 = m_pCharacterSet->_Mypair._Myval2._Myval2._Myhead->_Parent;
do
{
if ( v19->_Myval >= v14 )
{
v17 = v19;
v19 = v19->_Left;
}
else
{
v19 = v19->_Right;
}
}
while ( !v19->_Isnil );
v13 = v79;
}
if ( v17->_Isnil || v14 < v17->_Myval || v17 == Myhead )
{
v20 = v14;
switch ( v14 )
{
case 'a':
LOWORD(v14) = 65;
goto LABEL_48;
case 'b':
LOWORD(v14) = 66;
goto LABEL_48;
case 'c':
LOWORD(v14) = 67;
goto LABEL_48;
case 'd':
LOWORD(v14) = 68;
goto LABEL_48;
case 'e':
LOWORD(v14) = 69;
goto LABEL_48;
case 'f':
LOWORD(v14) = 70;
goto LABEL_48;
case 'g':
LOWORD(v14) = 71;
goto LABEL_48;
case 'h':
LOWORD(v14) = 72;
goto LABEL_48;
case 'i':
LOWORD(v14) = 73;
goto LABEL_48;
case 'j':
LOWORD(v14) = 74;
goto LABEL_48;
case 'k':
LOWORD(v14) = 75;
goto LABEL_48;
case 'l':
LOWORD(v14) = 76;
goto LABEL_48;
case 'm':
LOWORD(v14) = 77;
goto LABEL_48;
case 'n':
LOWORD(v14) = 78;
goto LABEL_48;
case 'o':
LOWORD(v14) = 79;
goto LABEL_48;
case 'p':
LOWORD(v14) = 80;
goto LABEL_48;
case 'q':
LOWORD(v14) = 81;
goto LABEL_48;
case 'r':
LOWORD(v14) = 82;
goto LABEL_48;
case 's':
LOWORD(v14) = 83;
goto LABEL_48;
case 't':
LOWORD(v14) = 84;
goto LABEL_48;
case 'u':
LOWORD(v14) = 85;
goto LABEL_48;
case 'v':
LOWORD(v14) = 86;
goto LABEL_48;
case 'w':
LOWORD(v14) = 87;
goto LABEL_48;
case 'x':
LOWORD(v14) = 88;
goto LABEL_48;
case 'y':
LOWORD(v14) = 89;
goto LABEL_48;
case 'z':
LOWORD(v14) = 90;
LABEL_48:
if ( (_WORD)v14 != v20 )
{
v21 = m_pCharacterSet->_Mypair._Myval2._Myval2._Myhead;
if ( !Isnil )
{
do
{
if ( Parent->_Myval >= (unsigned __int16)v14 )
{
v21 = Parent;
Parent = Parent->_Left;
}
else
{
Parent = Parent->_Right;
}
}
while ( !Parent->_Isnil );
}
if ( !v21->_Isnil && (unsigned __int16)v14 >= v21->_Myval && v21 != Myhead )
break;
}
goto LABEL_80;
default:
goto LABEL_81;
}
}
v22 = this->m_nExtraKerning + cocos2d::CCLabelBMFont::kerningAmountForFirst(this, v2, v14);
m_pFontDefDictionary = this->m_pConfiguration->m_pFontDefDictionary;
if ( m_pFontDefDictionary )
{
v24 = ((v14 & 0xFF00) + 17973517 + (unsigned __int8)v14) ^ 0x7F76D;
v25 = (v24 << 8) ^ (-1622558010 - v24);
v26 = (v25 >> 13) ^ (-17973517 - v25 - v24);
v27 = (v26 >> 12) ^ (v24 - v25 - v26);
v28 = (v27 << 16) ^ (v25 - v27 - v26);
v29 = (v28 >> 5) ^ (v26 - v28 - v27);
v30 = (v29 >> 3) ^ (v27 - v28 - v29);
v31 = (((v30 << 10) ^ (v28 - v30 - v29)) >> 15) ^ (v29 - ((v30 << 10) ^ (v28 - v30 - v29)) - v30);
tbl = m_pFontDefDictionary->hh.tbl;
hh_head = tbl->buckets[(tbl->num_buckets - 1) & v31].hh_head;
if ( hh_head )
{
hho = tbl->hho;
v35 = (__int64)hh_head - hho;
if ( v35 )
{
while ( *(_DWORD *)(v35 + 80) != 4 || **(_DWORD **)(v35 + 72) != (unsigned __int16)v14 )
{
v36 = *(_QWORD *)(v35 + 64);
if ( v36 )
{
v35 = v36 - hho;
if ( v35 )
continue;
}
goto LABEL_80;
}
v83 = *(_DWORD *)(v35 + 4);
cocos2d::CCRect::operator=((float *)&v84.origin, (float *)(v35 + 8));
v85 = *(_WORD *)(v35 + 24);
v86 = *(_WORD *)(v35 + 26);
v87 = *(_WORD *)(v35 + 28);
cocos2d::CCRect::operator=((float *)&v82.origin, (float *)&v84.origin);
v37 = cocos2d::CCDirector::sharedDirector();
ContentScaleFactor = cocos2d::CCDirector::getContentScaleFactor(v37);
v39 = v82.size.height / ContentScaleFactor;
v40 = cocos2d::CCDirector::sharedDirector();
v41 = cocos2d::CCDirector::getContentScaleFactor(v40);
v42 = v82.size.width / v41;
v43 = cocos2d::CCDirector::sharedDirector();
v44 = cocos2d::CCDirector::getContentScaleFactor(v43);
v45 = v82.origin.y / v44;
v46 = cocos2d::CCDirector::sharedDirector();
v47 = cocos2d::CCDirector::getContentScaleFactor(v46);
v48 = cocos2d::CCRect::CCRect(&v92, v82.origin.x / v47, v45, v42, v39);
cocos2d::CCRect::operator=((float *)&v82.origin, (float *)&v48->origin);
v82.origin.x = v82.origin.x + this->m_tImageOffset.x;
v82.origin.y = v82.origin.y + this->m_tImageOffset.y;
v49 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, _QWORD))this->getChildByTag)(this, v12);
v51 = (float *)v49;
if ( v49 )
{
LOBYTE(v50) = 1;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v49 + 320LL))(v49, v50);
v52 = (float)v22;
}
else
{
v53 = (cocos2d::CCFontSprite *)operator new(0x288u);
v90 = v53;
if ( v53 )
v51 = (float *)cocos2d::CCFontSprite::CCFontSprite(v53);
else
v51 = nullptr;
v54 = (float)v85;
v52 = (float)v22;
v55 = cocos2d::CCDirector::sharedDirector();
v51[150] = (float)(v54 / cocos2d::CCDirector::getContentScaleFactor(v55)) + (float)v22;
v56 = (float)((float)this->m_pConfiguration->m_nCommonHeight - v84.size.height) * 0.5;
v57 = cocos2d::CCDirector::sharedDirector();
v51[151] = v56 / cocos2d::CCDirector::getContentScaleFactor(v57);
if ( this->m_bIsBatched )
m_pSomeTexture = this->m_pSomeTexture;
else
m_pSomeTexture = (cocos2d::CCTexture2D *)((__int64 (__fastcall *)(cocos2d::CCTextureAtlas *))this->m_pobTextureAtlas->getTexture)(this->m_pobTextureAtlas);
(*(void (__fastcall **)(float *, cocos2d::CCTexture2D *, cocos2d::CCRect *))(*(_QWORD *)v51 + 880LL))(
v51,
m_pSomeTexture,
&v82);
if ( this->m_bIsBatched )
cocos2d::CCArray::addObject(this->m_pTargetArray, (struct cocos2d::CCObject *)v51);
else
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float *, _QWORD, _QWORD))this->addChild)(
this,
v51,
v12,
v12);
cocos2d::CCObject::release((cocos2d::CCObject *)v51);
(*(void (__fastcall **)(float *, bool))(*((_QWORD *)v51 + 40) + 48LL))(
v51 + 80,
this->m_bIsOpacityModifyRGB);
(*(void (__fastcall **)(float *, cocos2d::ccColor3B *))(*((_QWORD *)v51 + 40) + 80LL))(
v51 + 80,
&this->m_tDisplayedColor);
(*(void (__fastcall **)(float *, _QWORD))(*((_QWORD *)v51 + 40) + 104LL))(
v51 + 80,
this->m_cDisplayedOpacity);
}
(*(void (__fastcall **)(float *, cocos2d::CCRect *, _QWORD, cocos2d::CCSize *))(*(_QWORD *)v51 + 968LL))(
v51,
&v82,
0,
&v82.size);
v59 = (float)(this->m_pConfiguration->m_nCommonHeight - v86) + (float)v11;
v60 = cocos2d::CCDirector::sharedDirector();
v61 = cocos2d::CCDirector::getContentScaleFactor(v60);
kmVec2Fill(
v88,
(float)((float)((float)v85 + (float)v93) + (float)(v84.size.width * 0.5)) + v52,
v59 - (float)(v61 * (float)(v82.size.height * 0.5)));
v62 = *(_QWORD *)v51;
v63 = cocos2d::CCDirector::sharedDirector();
v64 = cocos2d::CCDirector::getContentScaleFactor(v63);
v65 = v88[1] / v64;
v66 = cocos2d::CCDirector::sharedDirector();
v67 = cocos2d::CCDirector::getContentScaleFactor(v66);
v68 = kmVec2Fill(&v91, v88[0] / v67, v65);
(*(void (__fastcall **)(float *, float *))(v62 + 184))(v51, v68);
v93 += v22 + v87;
v2 = v14;
v69 = v93;
if ( v94 >= v93 )
v69 = v94;
v94 = v69;
}
}
}
LABEL_80:
v13 = v79;
}
LABEL_81:
++v12;
v13 += 2;
v79 = v13;
}
while ( v12 < v95 );
v70 = (float)v87;
v71 = (float)v94;
if ( v84.size.width > v70 )
v71 = (float)(v71 + v84.size.width) - v70;
v80 = v71;
v81 = (float)v96;
}
}
v72 = this->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v73 = cocos2d::CCDirector::sharedDirector();
v74 = cocos2d::CCDirector::getContentScaleFactor(v73);
v75 = v81 / v74;
v76 = cocos2d::CCDirector::sharedDirector();
v77 = cocos2d::CCDirector::getContentScaleFactor(v76);
v78 = kmVec2Fill((float *)&v93, v80 / v77, v75);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float *))v72->setContentSize)(this, v78);
}