//
// MultilineBitmapFont::initWithFont from 0x1004871c0 to 0x100487a4a (2186 bytes)
//
// 1 xrefs:
// > MultilineBitmapFont::createWithFont @ 0x100487142
//
// 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
//
__int64 __fastcall MultilineBitmapFont::initWithFont(
__int64 a1,
const char *a2,
std::string *a3,
float *a4,
int a5,
char a6,
float a7,
float a8)
{
const char *v9; // r12
__int64 result; // rax
cocos2d::CCDirector *v12; // rdi
cocos2d::CCObject *v13; // rax
cocos2d::CCObject *v14; // rdi
cocos2d::CCObject *v15; // rax
cocos2d::CCObject *v16; // rdi
cocos2d::CCObject *v17; // rax
BitmapFontCache *v18; // rax
double v19; // xmm0_8
FontObject *v20; // r14
__int64 i; // r15
bool v22; // zf
__int64 v23; // r14
std::string *v24; // rbx
double v25; // xmm0_8
int v26; // r13d
double v27; // xmm1_8
unsigned __int64 size; // rdx
const char *v29; // rdi
cocos2d::CCLabelBMFont *v30; // r15
float v31; // xmm0_4
float v32; // xmm0_4
float v33; // xmm0_4
__int64 v34; // rax
__int64 v35; // rax
__m128 v36; // xmm1
__m128 v37; // xmm0
float *v38; // rax
__int64 v39; // rax
__m128 v40; // xmm1
__m128 v41; // xmm0
int v42; // ebx
int v43; // ebx
__int64 v44; // r13
int v45; // eax
unsigned int v46; // r12d
int v47; // r14d
unsigned int v48; // r12d
int v49; // r14d
__int64 v50; // rax
int v51; // ecx
int v52; // ecx
__int16 v53; // cx
__int64 v54; // rax
unsigned int j; // r12d
__int64 v56; // r13
__int64 v57; // rax
__int64 v58; // rsi
int v59; // r13d
float v60; // xmm0_4
int v61; // eax
__int64 v62; // rbx
int v63; // [rsp+0h] [rbp-100h]
__int128 v65; // [rsp+10h] [rbp-F0h] BYREF
void *__p; // [rsp+20h] [rbp-E0h]
__int128 v67; // [rsp+30h] [rbp-D0h] BYREF
void *data; // [rsp+40h] [rbp-C0h]
std::string *v69; // [rsp+50h] [rbp-B0h]
float *v70; // [rsp+58h] [rbp-A8h]
void **v71; // [rsp+60h] [rbp-A0h]
int v72; // [rsp+68h] [rbp-98h]
int v73; // [rsp+6Ch] [rbp-94h]
__m128 v74; // [rsp+70h] [rbp-90h]
__int128 v75; // [rsp+80h] [rbp-80h] BYREF
void *v76; // [rsp+90h] [rbp-70h] BYREF
__int64 v77; // [rsp+98h] [rbp-68h]
__int64 v78; // [rsp+A0h] [rbp-60h]
int v79; // [rsp+ACh] [rbp-54h]
__m128 v80; // [rsp+B0h] [rbp-50h]
float v81; // [rsp+C4h] [rbp-3Ch]
float v82; // [rsp+C8h] [rbp-38h]
float v83[2]; // [rsp+CCh] [rbp-34h] BYREF
unsigned __int8 v84; // [rsp+D7h] [rbp-29h]
v79 = a5;
v70 = a4;
v80.f32[0] = a8;
v81 = a7;
v69 = a3;
v9 = a2;
result = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a1 + 80LL))(a1);
if ( !(_BYTE)result )
return result;
v84 = result;
*(_BYTE *)(a1 + 1860) = a6;
v12 = cocos2d::CCDirector::sharedDirector();
v82 = sub_1004849C0((__int64)v12);
v13 = (cocos2d::CCObject *)sub_10071F9E0(v12, a2);
*(_QWORD *)(a1 + 1800) = v13;
v14 = v13;
cocos2d::CCObject::retain(v13);
v15 = (cocos2d::CCObject *)sub_10071F9E0(v14, a2);
*(_QWORD *)(a1 + 1808) = v15;
v16 = v15;
cocos2d::CCObject::retain(v15);
v17 = (cocos2d::CCObject *)sub_10071F9E0(v16, a2);
*(_QWORD *)(a1 + 1816) = v17;
cocos2d::CCObject::retain(v17);
v18 = BitmapFontCache::sharedFontCache();
*(_QWORD *)&v19 = LODWORD(v81);
v20 = BitmapFontCache::fontWithConfigFile(v18, a2, v81);
for ( i = 0; i != 300; ++i )
*(_DWORD *)(a1 + 4 * i + 596) = FontObject::getFontWidth(v20, i);
v22 = *(_BYTE *)(a1 + 1860) == 0;
v23 = a1;
v24 = v69;
if ( v22 )
{
if ( (*(_BYTE *)&v69->__r_.__value_.__s.0 & 1) != 0 )
{
sub_100006B70(&v65, v69->__r_.__value_.__l.__data_, v69->__r_.__value_.__l.__size_, v19);
}
else
{
__p = v69->__r_.__value_.__l.__data_;
v65 = *(_OWORD *)&v69->__r_.__value_.__l.0;
}
MultilineBitmapFont::readColorInfo(&v75, v23, &v65);
if ( (*(_BYTE *)&v24->__r_.__value_.__s.0 & 1) != 0 )
operator delete(v24->__r_.__value_.__l.__data_);
v24->__r_.__value_.__r.__words[2] = (std::string::size_type)v76;
*(_OWORD *)&v24->__r_.__value_.__l.0 = v75;
if ( (v65 & 1) != 0 )
operator delete(__p);
}
*(_QWORD *)&v25 = LODWORD(v82);
*(float *)&v25 = v82 * v80.f32[0];
v82 = v82 * v80.f32[0];
v71 = &v76;
v77 = 0;
v26 = 0;
v78 = v23;
while ( (*(_BYTE *)&v24->__r_.__value_.__s.0 & 1) == 0 )
{
if ( !*(_BYTE *)&v24->__r_.__value_.__s.0 )
goto LABEL_65;
v67 = *(_OWORD *)&v24->__r_.__value_.__l.0;
data = v24->__r_.__value_.__l.__data_;
*(_QWORD *)&v27 = LODWORD(v81);
LABEL_19:
MultilineBitmapFont::stringWithMaxWidth(&v75, v23, &v67, v82, v27);
if ( (v67 & 1) != 0 )
operator delete(data);
v29 = (char *)&v75 + 1;
if ( (v75 & 1) != 0 )
v29 = (const char *)v76;
v30 = cocos2d::CCLabelBMFont::create_3(v29, v9);
sub_10028CBE0(v83, 0.0, (float)-(v79 * v26));
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float *))v30->setPosition)(v30, v83);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v30->setScale)(v30, v81);
sub_10071FCD0(*(_QWORD *)(v23 + 1816), v30);
v80.i32[0] = *(_DWORD *)(v23 + 1856);
v74.i32[0] = *(_DWORD *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v30->getContentSize)(v30);
v31 = ((float (__fastcall *)(cocos2d::CCLabelBMFont *))v30->getScale)(v30);
if ( (float)(v74.f32[0] * v31) <= v80.f32[0] )
{
v33 = *(float *)(v23 + 1856);
}
else
{
v80.i32[0] = *(_DWORD *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v30->getContentSize)(v30);
v32 = ((float (__fastcall *)(cocos2d::CCLabelBMFont *))v30->getScale)(v30);
v33 = v80.f32[0] * v32;
}
*(float *)(v23 + 1856) = v33;
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float *))v30->setAnchorPoint)(v30, v70);
if ( *(float *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v30->getAnchorPoint)(v30) == 0.5 )
{
v34 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v30->getAnchorPoint)(v30);
sub_10028CBE0(v83, 0.0, *(float *)(v34 + 4));
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float *))v30->setAnchorPoint)(v30, v83);
v80 = (__m128)*(unsigned int *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v30->getPosition)(v30);
v74.i32[0] = *(_DWORD *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v30->getContentSize)(v30);
v35 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v30->getPosition)(v30);
v36 = v80;
v36.f32[0] = v80.f32[0] + (float)(v74.f32[0] * -0.5);
v37 = _mm_or_ps(_mm_and_ps(v36, (__m128)xmmword_1008150B0), (__m128)xmmword_1008150C0);
v37.f32[0] = v37.f32[0] + v36.f32[0];
sub_10028CBE0(v83, _mm_round_ss(v37, v37, 11).f32[0], *(float *)(v35 + 4));
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float *))v30->setPosition)(v30, v83);
}
*(_QWORD *)&v25 = *(unsigned int *)(((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v30->getAnchorPoint)(v30) + 4);
if ( *(float *)&v25 == 0.5 )
{
v38 = (float *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v30->getAnchorPoint)(v30);
sub_10028CBE0(v83, *v38, 0.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float *))v30->setAnchorPoint)(v30, v83);
v80.i32[0] = *(_DWORD *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v30->getPosition)(v30);
v74 = (__m128)*(unsigned int *)(((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v30->getPosition)(v30) + 4);
v39 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v30->getContentSize)(v30);
v40 = v74;
v40.f32[0] = v74.f32[0] + (float)(*(float *)(v39 + 4) * -0.5);
v41 = _mm_or_ps(_mm_and_ps(v40, (__m128)xmmword_1008150B0), (__m128)xmmword_1008150C0);
v41.f32[0] = v41.f32[0] + v40.f32[0];
v40.f32[0] = _mm_round_ss((__m128)0LL, v41, 11).f32[0];
*(_QWORD *)&v25 = v80.u32[0];
sub_10028CBE0(v83, v80.f32[0], v40.f32[0]);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float *))v30->setPosition)(v30, v83);
}
if ( (v75 & 1) != 0 )
v42 = DWORD2(v75);
else
v42 = (unsigned __int8)v75 >> 1;
v73 = v26;
qsort(
*(void **)(*(_QWORD *)(*(_QWORD *)(v23 + 1800) + 56LL) + 16LL),
**(unsigned int **)(*(_QWORD *)(v23 + 1800) + 56LL),
8u,
(int (__cdecl *)(const void *, const void *))sub_100487030);
v80.i32[0] = v77 + v42;
v63 = v42;
v74.i32[0] = v77 + v42 + 1;
v72 = 1 - v77;
v43 = 0;
while ( 1 )
{
v23 = v78;
if ( !(unsigned int)sub_100720070(*(_QWORD *)(v78 + 1800)) )
break;
v44 = sub_1007200C0(*(_QWORD *)(v23 + 1800), 0);
v45 = *(_DWORD *)(v44 + 60);
v46 = v45 - v77;
if ( v45 < (int)v77 || v45 > v80.i32[0] )
break;
v47 = *(_DWORD *)(v44 + 64);
if ( v47 == -1 || v47 <= v80.i32[0] )
{
sub_100720230(*(_QWORD *)(v78 + 1800), 0, 1);
}
else
{
*(_DWORD *)(v44 + 60) = v74.i32[0];
v47 = v80.i32[0];
}
if ( v46 == 1 )
v46 = 0;
++v43;
v48 = v46 - (((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, _QWORD))v30->getChildByTag)(v30, v46) == 0);
if ( *(_DWORD *)(v44 + 64) == -1 )
{
v54 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, _QWORD))v30->getChildByTag)(v30, v48);
if ( v54 && *(_DWORD *)(v44 + 56) == 4 )
{
*(_QWORD *)&v25 = *(unsigned int *)(v44 + 76);
*(_DWORD *)(v54 + 612) = LODWORD(v25);
}
}
else if ( (int)v48 <= v47 - (int)v77 )
{
v49 = v72 + v47;
do
{
v50 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, _QWORD))v30->getChildByTag)(v30, v48);
if ( v50 )
{
v51 = *(_DWORD *)(v44 + 56);
switch ( v51 )
{
case 1:
v53 = *(_WORD *)(v44 + 68);
BYTE2(v83[0]) = *(_BYTE *)(v44 + 70);
LOWORD(v83[0]) = v53;
(*(void (__fastcall **)(__int64, float *))(*(_QWORD *)v50 + 944LL))(v50, v83);
break;
case 2:
*(_BYTE *)(v50 + 604) = 1;
*(_QWORD *)&v25 = *(unsigned int *)(v44 + 72);
*(_DWORD *)(v50 + 608) = LODWORD(v25);
break;
case 3:
*(float *)(v50 + 620) = (float)*(int *)(v44 + 80);
v52 = *(_DWORD *)(v44 + 84);
if ( v52 <= 0 )
{
v25 = 0.0;
}
else
{
HIDWORD(v25) = 0;
*(float *)&v25 = 1.0 / (float)v52;
}
*(_DWORD *)(v50 + 616) = LODWORD(v25);
*(_DWORD *)(v50 + 628) = v43;
break;
}
}
++v48;
}
while ( v49 != v48 );
}
}
(*(void (__fastcall **)(__int64, cocos2d::CCLabelBMFont *))(*(_QWORD *)v23 + 440LL))(v23, v30);
v24 = v69;
for ( j = 0; j < ((unsigned int (__fastcall *)(cocos2d::CCLabelBMFont *))v30->getChildrenCount)(v30); ++j )
{
v56 = *(_QWORD *)(v23 + 1808);
v57 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v30->getChildren)(v30);
v58 = sub_1007200C0(v57, j);
sub_10071FCD0(v56, v58);
}
std::string::erase(v24, 0, v63);
if ( (v75 & 1) != 0 )
operator delete(v76);
v26 = v73 + 1;
v77 = v80.u32[0];
v9 = a2;
}
size = v24->__r_.__value_.__l.__size_;
if ( size )
{
sub_100006B70(&v67, v24->__r_.__value_.__l.__data_, size, v25);
*(_QWORD *)&v27 = LODWORD(v81);
goto LABEL_19;
}
LABEL_65:
cocos2d::CCObject::release(*(cocos2d::CCObject **)(v23 + 1800));
*(_QWORD *)(v23 + 1800) = 0;
v59 = v79 * (v26 - 1);
*(_DWORD *)(v23 + 1840) = v59;
v60 = 0.0;
v61 = (int)(float)(v82 + 0.0);
*(_DWORD *)(v23 + 1844) = v61;
v62 = v23;
if ( *v70 != 0.0 )
{
if ( *v70 == 1.0 )
v60 = (float)-v61;
else
v60 = (float)(v61 / -2);
v62 = v78;
}
sub_10028CBE0((float *)&v75, -v60, (float)v59);
sub_10028CC90((_QWORD *)(v62 + 1848), (double *)&v75);
return v84;
}