//
// MultilineBitmapFont::initWithFont from 0x14006bed0 to 0x14006c77e (2222 bytes)
//
// 2 xrefs:
// > TextArea::setString @ 0x14007731e
// > ??> @ 0x1406c6060
//
// 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=3
char __fastcall MultilineBitmapFont::initWithFont(
__int64 a1,
const char *a2,
cocos2d::CCPoint a3,
float a4,
float a5,
float *a6,
int a7,
char a8)
{
__int64 v8; // r14
__int64 v10; // r15
float *v11; // r12
int v12; // esi
__int64 v13; // rcx
int v15; // ebx
cocos2d::CCDirector *v16; // rax
float v17; // xmm11_4
__int64 v18; // rcx
cocos2d::CCObject *v19; // rax
__int64 v20; // rcx
cocos2d::CCObject *v21; // rax
__int64 v22; // rcx
cocos2d::CCObject *v23; // rax
BitmapFontCache *v24; // rcx
cocos2d::CCObject *v25; // rbx
cocos2d::CCObject *v26; // rax
FontObject *v27; // rax
_DWORD *v28; // rdx
char *v29; // rax
__int64 v30; // r8
__int64 v31; // rax
__int64 ColorInfo; // rax
float v33; // xmm8_4
int v34; // edi
__int64 v35; // rax
const char *v36; // rcx
struct cocos2d::CCLabelBMFont *v37; // rsi
cocos2d::CCLabelBMFont_vtbl *v38; // rbx
const cocos2d::CCPoint *v39; // rax
float v40; // xmm7_4
float width; // xmm6_4
cocos2d::CCLabelBMFont_vtbl *v42; // rbx
__int64 v43; // rax
const cocos2d::CCPoint *v44; // rax
float x; // xmm6_4
float v46; // xmm6_4
float *v47; // rax
bool v48; // cf
float v49; // xmm6_4
cocos2d::CCLabelBMFont_vtbl *v50; // rax
float v51; // xmm6_4
float v52; // xmm0_4
float v53; // xmm6_4
cocos2d::CCLabelBMFont_vtbl *v54; // rbx
__int64 v55; // rax
const cocos2d::CCPoint *v56; // rax
float *v57; // rax
cocos2d::CCLabelBMFont_vtbl *v58; // rbx
const cocos2d::CCPoint *v59; // rax
float y; // xmm6_4
float v61; // xmm6_4
__int64 v62; // rax
float v63; // xmm6_4
cocos2d::CCLabelBMFont_vtbl *v64; // rax
float v65; // xmm6_4
float v66; // xmm0_4
float v67; // xmm6_4
float *v68; // rax
cocos2d::CCLabelBMFont_vtbl *v69; // rbx
const cocos2d::CCPoint *v70; // rax
int v71; // edi
int v72; // r12d
int v73; // ebx
signed int v74; // r13d
struct cocos2d::CCObject *v75; // rax
struct cocos2d::CCObject *v76; // rdi
int v77; // r14d
signed int m_uID; // r15d
int v79; // r14d
int v80; // r15d
int v81; // ebx
int v82; // r14d
__int64 v83; // rax
__int64 v84; // rdx
int m_eObjType; // eax
unsigned int i; // ebx
cocos2d::CCArray *v87; // rax
struct cocos2d::CCObject *v88; // rax
unsigned __int64 v89; // rax
unsigned __int64 v90; // rbx
char *v91; // rcx
unsigned __int64 v92; // rbx
int v93; // ecx
int v94; // eax
__int64 v95; // rax
__int16 m_nLuaID; // [rsp+30h] [rbp-D0h] BYREF
char v97; // [rsp+32h] [rbp-CEh]
signed int v98; // [rsp+34h] [rbp-CCh]
int v99; // [rsp+38h] [rbp-C8h]
int v100; // [rsp+3Ch] [rbp-C4h]
int v101; // [rsp+40h] [rbp-C0h]
cocos2d::CCObject *v102; // [rsp+48h] [rbp-B8h]
int v103; // [rsp+50h] [rbp-B0h]
__int64 v104; // [rsp+58h] [rbp-A8h]
const char *v105; // [rsp+60h] [rbp-A0h]
unsigned __int64 *v106; // [rsp+68h] [rbp-98h]
__int64 v107; // [rsp+70h] [rbp-90h]
cocos2d::CCPoint v108; // [rsp+78h] [rbp-88h] BYREF
cocos2d::CCPoint v109; // [rsp+80h] [rbp-80h] BYREF
cocos2d::CCPoint v110; // [rsp+88h] [rbp-78h] BYREF
cocos2d::CCPoint v111; // [rsp+90h] [rbp-70h] BYREF
cocos2d::CCPoint v112[2]; // [rsp+98h] [rbp-68h] BYREF
_QWORD v113[2]; // [rsp+A8h] [rbp-58h] BYREF
int v114; // [rsp+B8h] [rbp-48h]
unsigned __int64 v115; // [rsp+C0h] [rbp-40h]
_BYTE v116[32]; // [rsp+C8h] [rbp-38h] BYREF
v8 = (__int64)a3;
v106 = (unsigned __int64 *)a3;
v105 = a2;
v10 = a1;
v104 = a1;
v112[1] = a3;
v11 = a6;
v107 = (__int64)a6;
v12 = a7;
v103 = a7;
if ( !(*(unsigned __int8 (__fastcall **)(__int64))(*(_QWORD *)a1 + 72LL))(a1) )
{
sub_14003A830(v8);
return 0;
}
*(_BYTE *)(v10 + 1860) = a8;
v15 = 0;
v99 = 0;
v16 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v13);
v17 = a5 * cocos2d::CCDirector::getContentScaleFactor(v16);
v19 = (cocos2d::CCObject *)cocos2d::CCArray::create(v18);
*(_QWORD *)(v10 + 1800) = v19;
cocos2d::CCObject::retain(v19);
v21 = (cocos2d::CCObject *)cocos2d::CCArray::create(v20);
*(_QWORD *)(v10 + 1808) = v21;
cocos2d::CCObject::retain(v21);
v23 = (cocos2d::CCObject *)cocos2d::CCArray::create(v22);
*(_QWORD *)(v10 + 1816) = v23;
cocos2d::CCObject::retain(v23);
v24 = (BitmapFontCache *)qword_1406C2E78;
if ( !qword_1406C2E78 )
{
v25 = (cocos2d::CCObject *)operator new(0x40u);
v102 = v25;
cocos2d::CCObject::CCObject(v25);
v25->__vftable = (cocos2d::CCObject_vtbl *)&BitmapFontCache::`vftable';
v25[1].__vftable = nullptr;
qword_1406C2E78 = (__int64)v25;
v26 = (cocos2d::CCObject *)cocos2d::CCDictionary::create();
v25[1].__vftable = (cocos2d::CCObject_vtbl *)v26;
cocos2d::CCObject::retain(v26);
v24 = (BitmapFontCache *)qword_1406C2E78;
v15 = v99;
}
v27 = BitmapFontCache::fontWithConfigFile(v24, a2, a4);
v28 = (_DWORD *)(v10 + 600);
v29 = (char *)v27 - v10;
v30 = 150;
do
{
*v28 = *(_DWORD *)((char *)v28 + (_QWORD)v29 - 544);
v28[1] = *(_DWORD *)((char *)v28 + (_QWORD)v29 - 540);
v28 += 2;
--v30;
}
while ( v30 );
if ( !*(_BYTE *)(v10 + 1860) )
{
v31 = sub_14003BDB0((__int64)v113, v8);
ColorInfo = MultilineBitmapFont::readColorInfo(v10, v116, v31);
sub_140051590(v8, ColorInfo);
sub_14003A830((__int64)v116);
}
v98 = 0;
v33 = 0.0;
if ( *(_QWORD *)(v8 + 16) )
{
v34 = 0;
v101 = 0;
do
{
v35 = sub_14003BDB0((__int64)v116, v8);
MultilineBitmapFont::stringWithMaxWidth(v10, v113, v35);
v36 = (const char *)v113;
if ( v115 > 0xF )
v36 = (const char *)v113[0];
v37 = cocos2d::CCLabelBMFont::create(v36, v105);
v38 = v37->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(&v109, 0.0, (float)v34);
v38->setPosition_0(v37, v39);
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *))v37->setScale_0)(v37);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(v10 + 1816), v37);
v40 = *(float *)(v10 + 1856);
width = v37->getContentSize(v37)->width;
*(float *)(v10 + 1856) = fmaxf(v40, v37->getScale(v37) * width);
v37->setAnchorPoint(v37, (const cocos2d::CCPoint *)v11);
if ( v37->getAnchorPoint(v37)->x == 0.5 )
{
v42 = v37->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v43 = (__int64)v37->getAnchorPoint(v37);
cocos2d::CCPoint::CCPoint(&v110, 0.0, *(float *)(v43 + 4));
v42->setAnchorPoint(v37, v44);
x = v37->getPosition_0(v37)->x;
v46 = x - (float)(v37->getContentSize(v37)->width * 0.5);
v47 = (float *)v37->getPosition_0(v37);
v48 = v46 < 0.0;
v49 = *v47;
v50 = v37->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
if ( v48 )
{
v53 = (float)(v49 - (float)(v50->getContentSize(v37)->width * 0.5)) - 0.5;
v52 = ceilf(v53);
}
else
{
v51 = (float)(v49 - (float)(v50->getContentSize(v37)->width * 0.5)) + 0.5;
v52 = floorf(v51);
}
v54 = v37->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v55 = (__int64)v37->getPosition_0(v37);
cocos2d::CCPoint::CCPoint(&v111, v52, *(float *)(v55 + 4));
v54->setPosition_0(v37, v56);
}
if ( v37->getAnchorPoint(v37)->y == 0.5 )
{
v57 = (float *)v37->getAnchorPoint(v37);
v58 = v37->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v112, *v57, 0.0);
v58->setAnchorPoint(v37, v59);
y = v37->getPosition_0(v37)->y;
v61 = y - (float)(v37->getContentSize(v37)->height * 0.5);
v62 = (__int64)v37->getPosition_0(v37);
v48 = v61 < 0.0;
v63 = *(float *)(v62 + 4);
v64 = v37->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
if ( v48 )
{
v67 = (float)(v63 - (float)(v64->getContentSize(v37)->height * 0.5)) - 0.5;
v66 = ceilf(v67);
}
else
{
v65 = (float)(v63 - (float)(v64->getContentSize(v37)->height * 0.5)) + 0.5;
v66 = floorf(v65);
}
v68 = (float *)v37->getPosition_0(v37);
v69 = v37->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(&v108, *v68, v66);
v69->setPosition_0(v37, v70);
}
v71 = v114;
v100 = v114;
qsort(
*(void **)(*(_QWORD *)(*(_QWORD *)(v10 + 1800) + 56LL) + 16LL),
**(unsigned int **)(*(_QWORD *)(v10 + 1800) + 56LL),
8u,
(_CoreCrtNonSecureSearchSortCompareFunction)sub_14006BEC0);
v72 = 0;
v73 = v98;
LODWORD(v102) = v98 + v71;
v74 = v98 + v71;
while ( cocos2d::CCArray::count(*(cocos2d::CCArray **)(v10 + 1800)) )
{
v75 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(v10 + 1800), 0);
v76 = v75;
++v72;
v77 = HIDWORD(v75[1].__vftable);
if ( v77 < v73 || (v74 = v73 + v100, v77 > v73 + v100) )
{
v74 = (int)v102;
break;
}
m_uID = v75[1].m_uID;
if ( m_uID == -1 || m_uID <= v74 )
{
cocos2d::CCArray::removeObjectAtIndex(*(cocos2d::CCArray **)(v104 + 1800), 0, 1);
}
else
{
HIDWORD(v75[1].__vftable) = v74 + 1;
m_uID = v74;
}
v79 = v77 - v73;
v80 = m_uID - v73;
v81 = 0;
if ( v79 != 1 )
v81 = v79;
v82 = v81 - 1;
if ( v37->getChildByTag(v37, v81) )
v82 = v81;
if ( v76[1].m_uID == -1 )
{
v83 = (__int64)v37->getChildByTag(v37, v82);
if ( !v83 || LODWORD(v76[1].__vftable) != 4 )
goto LABEL_51;
*(_DWORD *)(v83 + 616) = v76[1].m_uReference;
v10 = v104;
v73 = v98;
}
else
{
for ( ; v82 <= v80; ++v82 )
{
v84 = (__int64)v37->getChildByTag(v37, v82);
if ( v84 )
{
switch ( LODWORD(v76[1].__vftable) )
{
case 1:
m_nLuaID = v76[1].m_nLuaID;
v97 = BYTE2(v76[1].m_nLuaID);
(**(void (__fastcall ***)(__int64, __int16 *))(v84 + 320))(v84 + 320, &m_nLuaID);
break;
case 2:
*(_BYTE *)(v84 + 608) = 1;
*(_DWORD *)(v84 + 612) = v76[1].m_nTag;
break;
case 3:
*(float *)(v84 + 624) = (float)(int)v76[1].m_uAutoReleaseCount;
m_eObjType = v76[1].m_eObjType;
if ( m_eObjType > 0 )
*(float *)(v84 + 620) = 1.0 / (float)m_eObjType;
else
*(_DWORD *)(v84 + 620) = 0;
*(_DWORD *)(v84 + 632) = v72;
break;
}
}
}
LABEL_51:
v10 = v104;
v73 = v98;
}
}
v98 = v74;
(*(void (__fastcall **)(__int64, struct cocos2d::CCLabelBMFont *))(*(_QWORD *)v10 + 448LL))(v10, v37);
for ( i = 0; i < v37->getChildrenCount(v37); ++i )
{
v87 = v37->getChildren(v37);
v88 = cocos2d::CCArray::objectAtIndex(v87, i);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(v10 + 1808), v88);
}
v89 = v100;
v8 = (__int64)v106;
v90 = v106[2];
if ( v90 < v100 )
v89 = v106[2];
v91 = (char *)v106;
if ( v106[3] > 0xF )
v91 = (char *)*v106;
v92 = v90 - v89;
memmove(v91, &v91[v89], v92 + 1);
*(_QWORD *)(v8 + 16) = v92;
v15 = ++v99;
v12 = v103;
v34 = v101 - v103;
v101 -= v103;
sub_14003A830((__int64)v113);
v11 = (float *)v107;
}
while ( *(_QWORD *)(v8 + 16) );
}
cocos2d::CCObject::release(*(cocos2d::CCObject **)(v10 + 1800));
*(_QWORD *)(v10 + 1800) = 0;
v93 = v12 * (v15 - 1);
*(_DWORD *)(v10 + 1840) = v93;
v94 = (int)(float)(v17 + 0.0);
*(_DWORD *)(v10 + 1844) = v94;
if ( *v11 != 0.0 )
{
if ( *v11 != 1.0 )
v94 /= 2;
v33 = (float)-v94;
}
cocos2d::CCPoint::CCPoint(&v108, -v33, (float)v93);
cocos2d::CCPoint::operator=(v10 + 1848, v95);
sub_14003A830(v8);
return 1;
}