//
// MultilineBitmapFont::stringWithMaxWidth from 0x100235350 to 0x1002356ac (860 bytes)
//
// 1 xrefs:
// > MultilineBitmapFont::initWithFont @ 0x100234618
//
// 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 __usercall MultilineBitmapFont::stringWithMaxWidth(
__int64 a1@,
__int64 a2@,
_QWORD *a3@,
float a4@,
float a5@)
{
__int64 v10; // x28
float v11; // s9
int v12; // w27
int v13; // w24
int v14; // w23
__int64 v15; // x19
unsigned int v16; // s11
int v17; // w25
std::string *v18; // x1
std::string *v19; // x0
std::string *v20; // x0
int v21; // w8
unsigned int v22; // w10
int v23; // w8
int v24; // w19
int v25; // w8
int v26; // w20
unsigned int v27; // w21
std::string::size_type size; // x8
cocos2d::CCString *v29; // x0
char *CString; // x0
unsigned int v31; // [xsp+14h] [xbp-CCh]
std::string v32; // [xsp+18h] [xbp-C8h] BYREF
std::string __str; // [xsp+30h] [xbp-B0h] BYREF
std::string v34; // [xsp+50h] [xbp-90h] BYREF
std::allocator __a; // [xsp+6Fh] [xbp-71h] BYREF
v10 = *(char *)(a2 + 23);
if ( v10 < 0 )
v10 = *(_QWORD *)(a2 + 8);
sub_100009900(&v34, "");
v11 = a4 + a4;
if ( (int)v10 < 1 )
{
v14 = 0;
v21 = 0;
v22 = 0;
v12 = 0;
}
else
{
v12 = 0;
v31 = 0;
v13 = 0;
v14 = 0;
v15 = a1 + 596;
do
{
if ( v11 <= (float)v14 )
break;
if ( *(char *)(a2 + 23) < 0 )
sub_1000097D0(&__str, *(void **)a2, *(_QWORD *)(a2 + 8));
else
__str = *(std::string *)a2;
v16 = *(_DWORD *)(v15 + 4LL * *std::string::at(&__str, v12));
std::string::basic_string(&v32, &__str, v12, 1u, &__a);
v17 = std::string::compare(&v32, "\n");
if ( v17 )
{
if ( std::string::compare(&v32, "’") && *std::string::at(&v32, 0) == 32 )
{
v31 = (unsigned int)(float)((float)*(unsigned int *)(v15 + 4LL * *std::string::at(&__str, v12)) * a5);
v13 = v14;
}
v18 = (v32.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL
? &v32
: (std::string *)v32.__r_.__value_.__r.__words[0];
v19 = std::string::append(&v34, (const std::string::value_type *)v18);
std::string::operator=(&v34, v19);
}
else
{
v20 = std::string::append(&v34, " ");
std::string::operator=(&v34, v20);
v12 = 1000;
}
if ( SHIBYTE(v32.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v32.__r_.__value_.__l.__data_);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
v14 = (int)(float)((float)v14 + (float)(a5 * (float)v16));
if ( !v17 )
break;
++v12;
}
while ( v12 < (int)v10 );
v21 = v13 / 2;
v22 = v31;
}
if ( (*(_BYTE *)(a1 + 1828) & 1) == 0 && v11 > (float)v14 )
*(_DWORD *)(a1 + 1824) = v14 / 2 - v22;
*(_BYTE *)(a1 + 1828) = 1;
if ( v21 > *(_DWORD *)(a1 + 1824) )
*(_DWORD *)(a1 + 1824) = v21;
if ( v12 >= (int)v10 )
goto LABEL_52;
v23 = SHIBYTE(v34.__r_.__value_.__r.__words[2]);
if ( SHIBYTE(v34.__r_.__value_.__r.__words[2]) < 0 )
{
v23 = v34.__r_.__value_.__r.__words[1];
if ( v34.__r_.__value_.__l.__size_ < v12 )
{
LABEL_36:
v24 = v12 - v23;
goto LABEL_38;
}
}
else if ( v12 > (unsigned int)SHIBYTE(v34.__r_.__value_.__r.__words[2]) )
{
goto LABEL_36;
}
v24 = 0;
LABEL_38:
if ( v24 <= v12 )
v25 = v12;
else
v25 = v24;
v26 = v25 + 1;
v27 = ~v24 + v12;
while ( (v27 & 0x80000000) == 0 && *std::string::at(&v34, v27) != 32 )
{
++v24;
--v27;
if ( v26 == v24 )
{
v24 = v26;
break;
}
}
if ( v24 - v12 <= -2 )
{
size = HIBYTE(v34.__r_.__value_.__r.__words[2]);
if ( (v34.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
size = v34.__r_.__value_.__l.__size_;
std::string::basic_string(&__str, &v34, 0, size - v24, (std::allocator *)&v32);
if ( SHIBYTE(v34.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v34.__r_.__value_.__l.__data_);
v34 = __str;
}
LABEL_52:
v29 = (cocos2d::CCString *)sub_100268E48(&v34);
CString = (char *)cocos2d::CCString::getCString(v29);
sub_100009900(a3, CString);
if ( SHIBYTE(v34.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v34.__r_.__value_.__l.__data_);
}