//
// MultilineBitmapFont::initWithFont from 0x100234470 to 0x100234b98 (1832 bytes)
//
// 1 xrefs:
// > MultilineBitmapFont::createWithFont @ 0x1002343e8
//
// 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)
{
__int64 v14; // x20
cocos2d::CCDirector *v15; // x0
float v16; // s10
__int64 v17; // x0
cocos2d::CCObject *v18; // x0
__int64 v19; // x0
cocos2d::CCObject *v20; // x0
__int64 v21; // x0
cocos2d::CCObject *v22; // x0
BitmapFontCache *v23; // x0
FontObject *v24; // x25
__int64 i; // x26
int v26; // w22
int v27; // w20
float v28; // s9
unsigned __int64 size; // x2
void **v30; // x0
cocos2d::CCLabelBMFont *v31; // x26
__n128 v32; // q1
__n128 v33; // q0
__n128 v34; // q0
float v35; // s10
float v36; // s14
float v37; // s10
float v38; // s0
__n128 v39; // q0
__n128 v40; // q1
__n128 v41; // q0
float v42; // s10
float v43; // s14
__int64 v44; // x0
__n128 v45; // q0
__n128 v46; // q1
__n128 v47; // q0
__n128 v48; // q1
unsigned __int32 v49; // s10
float v50; // s14
__n128 v51; // q1
__n128 v52; // q0
int v53; // w21
int v54; // w20
int v55; // w21
__int64 v56; // x0
__int64 v57; // x27
int v58; // w8
__int64 v59; // x28
int v61; // w25
__int64 v63; // x28
int v64; // w25
__int64 v65; // x0
int v66; // w8
int v67; // w8
float v68; // s0
__int16 v69; // w8
__int64 v70; // x0
__int64 j; // x27
__int64 v72; // x28
__int64 v73; // x0
__int64 v74; // x0
__n128 v75; // q1
int v76; // w8
__n128 v77; // q0
int v78; // w9
int v79; // w9
unsigned int v81; // [xsp+4h] [xbp-12Ch]
const char *v82; // [xsp+8h] [xbp-128h]
std::string *v83; // [xsp+10h] [xbp-120h]
int v86; // [xsp+28h] [xbp-108h]
int v87; // [xsp+34h] [xbp-FCh]
int v88; // [xsp+38h] [xbp-F8h] BYREF
void *__dst[2]; // [xsp+40h] [xbp-F0h] BYREF
std::string::size_type v90; // [xsp+50h] [xbp-E0h]
void *__p[2]; // [xsp+60h] [xbp-D0h] BYREF
std::string::size_type v92; // [xsp+70h] [xbp-C0h]
void *v93[2]; // [xsp+80h] [xbp-B0h] BYREF
signed __int64 v94; // [xsp+90h] [xbp-A0h]
v14 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a1 + 80LL))(a1);
if ( !(_DWORD)v14 )
return v14;
*(_BYTE *)(a1 + 1860) = a6;
v15 = cocos2d::CCDirector::sharedDirector();
v16 = sub_1001765E4((__int64)v15);
v18 = (cocos2d::CCObject *)sub_10024A15C(v17);
*(_QWORD *)(a1 + 1800) = v18;
cocos2d::CCObject::retain(v18);
v20 = (cocos2d::CCObject *)sub_10024A15C(v19);
*(_QWORD *)(a1 + 1808) = v20;
cocos2d::CCObject::retain(v20);
v22 = (cocos2d::CCObject *)sub_10024A15C(v21);
*(_QWORD *)(a1 + 1816) = v22;
cocos2d::CCObject::retain(v22);
v23 = BitmapFontCache::sharedFontCache();
v24 = BitmapFontCache::fontWithConfigFile(v23, a2, a7);
for ( i = 0; i != 300; ++i )
*(_DWORD *)(a1 + 4 * i + 596) = FontObject::getFontWidth(v24, i);
if ( (*(_BYTE *)(a1 + 1860) & 1) == 0 )
{
if ( SHIBYTE(a3->__r_.__value_.__r.__words[2]) < 0 )
{
sub_1000097D0(__p, a3->__r_.__value_.__l.__data_, a3->__r_.__value_.__l.__size_);
}
else
{
*(_OWORD *)__p = *(_OWORD *)&a3->__r_.__value_.__l.__data_;
v92 = a3->__r_.__value_.__r.__words[2];
}
MultilineBitmapFont::readColorInfo((__int64 *)v93, a1, __p);
if ( SHIBYTE(a3->__r_.__value_.__r.__words[2]) < 0 )
operator delete(a3->__r_.__value_.__l.__data_);
*(_OWORD *)&a3->__r_.__value_.__l.__data_ = *(_OWORD *)v93;
a3->__r_.__value_.__r.__words[2] = v94;
if ( SHIBYTE(v92) < 0 )
operator delete(__p[0]);
}
v81 = v14;
v26 = 0;
v27 = 0;
v28 = v16 * a8;
v82 = a2;
v83 = a3;
while ( (SHIBYTE(a3->__r_.__value_.__r.__words[2]) & 0x80000000) == 0 )
{
if ( !*((_BYTE *)&a3->__r_.__value_.__s + 23) )
goto LABEL_73;
*(_OWORD *)__dst = *(_OWORD *)&a3->__r_.__value_.__l.__data_;
v90 = a3->__r_.__value_.__r.__words[2];
LABEL_18:
MultilineBitmapFont::stringWithMaxWidth(v93, a1, __dst, v28, a7);
if ( SHIBYTE(v90) < 0 )
operator delete(__dst[0]);
if ( v94 >= 0 )
v30 = v93;
else
v30 = (void **)v93[0];
v31 = cocos2d::CCLabelBMFont::create_1((const char *)v30, a2);
v32.n128_f32[0] = (float)-(v27 * a5);
v33.n128_u32[0] = 0;
sub_100022980(v33, v32, &v88);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int *))v31->setPosition)(v31, &v88);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v31->setScale)(v31, a7);
v34 = sub_10024A2D0(*(_QWORD *)(a1 + 1816), v31);
v35 = *(float *)(a1 + 1856);
v36 = *(float *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, __n128))v31->getContentSize)(v31, v34);
if ( v35 >= (float)(v36 * ((float (__fastcall *)(cocos2d::CCLabelBMFont *))v31->getScale)(v31)) )
{
v38 = *(float *)(a1 + 1856);
}
else
{
v37 = *(float *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v31->getContentSize)(v31);
v38 = v37 * ((float (__fastcall *)(cocos2d::CCLabelBMFont *))v31->getScale)(v31);
}
*(float *)(a1 + 1856) = v38;
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float *))v31->setAnchorPoint)(v31, a4);
v39.n128_u32[0] = *(_DWORD *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v31->getAnchorPoint)(v31);
if ( v39.n128_f32[0] == 0.5 )
{
v40.n128_u32[0] = *(_DWORD *)(((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, float))v31->getAnchorPoint)(
v31,
v39.n128_f32[0])
+ 4);
v41.n128_u32[0] = 0;
sub_100022980(v41, v40, &v88);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int *))v31->setAnchorPoint)(v31, &v88);
v42 = *(float *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v31->getPosition)(v31);
v43 = *(float *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v31->getContentSize)(v31);
v44 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v31->getPosition)(v31);
v45.n128_f32[0] = roundf(v42 + (float)(v43 * -0.5));
v46.n128_u32[0] = *(_DWORD *)(v44 + 4);
sub_100022980(v45, v46, &v88);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int *))v31->setPosition)(v31, &v88);
}
if ( *(float *)(((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, __n128))v31->getAnchorPoint)(v31, v39) + 4) == 0.5 )
{
v47.n128_u32[0] = *(_DWORD *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v31->getAnchorPoint)(v31);
v48.n128_u32[0] = 0;
sub_100022980(v47, v48, &v88);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int *))v31->setAnchorPoint)(v31, &v88);
v49 = *(_DWORD *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v31->getPosition)(v31);
v50 = *(float *)(((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v31->getPosition)(v31) + 4);
v51.n128_f32[0] = roundf(
v50
+ (float)(*(float *)(((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v31->getContentSize)(v31)
+ 4)
* -0.5));
v52.n128_u32[0] = v49;
sub_100022980(v52, v51, &v88);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int *))v31->setPosition)(v31, &v88);
}
v87 = v27;
if ( v94 >= 0 )
v53 = HIBYTE(v94);
else
v53 = (int)v93[1];
qsort(
*(void **)(*(_QWORD *)(*(_QWORD *)(a1 + 1800) + 56LL) + 16LL),
**(unsigned int **)(*(_QWORD *)(a1 + 1800) + 56LL),
8u,
(int (__cdecl *)(const void *, const void *))sub_100234334);
v54 = 0;
v86 = v53;
v55 = v26 + v53;
while ( (unsigned int)sub_10024A36C(*(_QWORD *)(a1 + 1800)) )
{
v56 = sub_10024A388(*(_QWORD *)(a1 + 1800), 0);
v57 = v56;
v58 = *(_DWORD *)(v56 + 60);
LODWORD(v59) = v58 - v26;
if ( v58 < v26 || v58 > v55 )
break;
v61 = *(_DWORD *)(v56 + 64);
if ( v61 == -1 || v61 <= v55 )
{
sub_10024A44C(*(_QWORD *)(a1 + 1800), 0, 1);
}
else
{
*(_DWORD *)(v56 + 60) = v55 + 1;
v61 = v55;
}
if ( (_DWORD)v59 == 1 )
v59 = 0;
else
v59 = (unsigned int)v59;
++v54;
v63 = (unsigned int)v59
- (((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, __int64))v31->getChildByTag)(v31, v59) == 0);
if ( *(_DWORD *)(v57 + 64) == -1 )
{
v70 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, __int64))v31->getChildByTag)(v31, v63);
if ( v70 && *(_DWORD *)(v57 + 56) == 4 )
*(_DWORD *)(v70 + 612) = *(_DWORD *)(v57 + 76);
}
else if ( (int)v63 <= v61 - v26 )
{
v64 = 1 - v26 + v61;
do
{
v65 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, __int64))v31->getChildByTag)(v31, v63);
if ( v65 )
{
v66 = *(_DWORD *)(v57 + 56);
switch ( v66 )
{
case 1:
v69 = *(_WORD *)(v57 + 68);
BYTE2(v88) = *(_BYTE *)(v57 + 70);
LOWORD(v88) = v69;
(*(void (__fastcall **)(__int64, int *))(*(_QWORD *)v65 + 944LL))(v65, &v88);
break;
case 2:
*(_BYTE *)(v65 + 604) = 1;
*(_DWORD *)(v65 + 608) = *(_DWORD *)(v57 + 72);
break;
case 3:
*(float *)(v65 + 620) = (float)*(int *)(v57 + 80);
v67 = *(_DWORD *)(v57 + 84);
if ( v67 < 1 )
v68 = 0.0;
else
v68 = 1.0 / (float)(unsigned int)v67;
*(float *)(v65 + 616) = v68;
*(_DWORD *)(v65 + 628) = v54;
break;
}
}
v63 = (unsigned int)(v63 + 1);
}
while ( v64 != (_DWORD)v63 );
}
}
(*(void (__fastcall **)(__int64, cocos2d::CCLabelBMFont *))(*(_QWORD *)a1 + 440LL))(a1, v31);
a3 = v83;
for ( j = 0;
(unsigned int)j < ((unsigned int (__fastcall *)(cocos2d::CCLabelBMFont *))v31->getChildrenCount)(v31);
j = (unsigned int)(j + 1) )
{
v72 = *(_QWORD *)(a1 + 1808);
v73 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))v31->getChildren)(v31);
v74 = sub_10024A388(v73, j);
sub_10024A2D0(v72, v74);
}
std::string::erase(v83, 0, v86);
if ( SHIBYTE(v94) < 0 )
operator delete(v93[0]);
v27 = v87 + 1;
v26 = v55;
a2 = v82;
}
size = a3->__r_.__value_.__l.__size_;
if ( size )
{
sub_1000097D0(__dst, a3->__r_.__value_.__l.__data_, size);
goto LABEL_18;
}
LABEL_73:
cocos2d::CCObject::release(*(cocos2d::CCObject **)(a1 + 1800));
*(_QWORD *)(a1 + 1800) = 0;
v76 = (v27 - 1) * a5;
*(_DWORD *)(a1 + 1840) = v76;
v77.n128_u32[0] = 0;
v78 = (int)(float)(v28 + 0.0);
*(_DWORD *)(a1 + 1844) = v78;
v14 = v81;
if ( *a4 != 0.0 )
{
if ( *a4 == 1.0 )
v79 = -v78;
else
v79 = v78 / -2;
v77.n128_f32[0] = (float)v79;
}
v77.n128_f32[0] = -v77.n128_f32[0];
v75.n128_f32[0] = (float)v76;
sub_100022980(v77, v75, v93);
sub_1000229D0((_QWORD *)(a1 + 1848), (double *)v93);
return v14;
}