//
// MultilineBitmapFont::stringWithMaxWidth from 0x2f0df8 to 0x2f1020 (552 bytes)
//
// 1 xrefs:
// > MultilineBitmapFont::initWithFont @ 0x2f169a
//
// 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
//
int __fastcall MultilineBitmapFont::stringWithMaxWidth(int a1, int a2, _DWORD *a3, float a4, float a5)
{
unsigned int v7; // r5
int v8; // r6
int v9; // r4
const std::string *v11; // r1
int v12; // r0
int v13; // r0
int v14; // r3
unsigned int v15; // r5
int v16; // r5
int v17; // r3
int v18; // r6
cocos2d::CCString *v19; // r0
char *CString; // r0
int v22; // [sp+4h] [bp-30h]
int v23; // [sp+8h] [bp-2Ch]
int v24; // [sp+Ch] [bp-28h]
int v26; // [sp+20h] [bp-14h] BYREF
_BYTE v27[4]; // [sp+24h] [bp-10h] BYREF
char *v28; // [sp+28h] [bp-Ch] BYREF
v7 = 0;
v8 = 0;
v9 = 0;
v23 = *(_DWORD *)(*a3 - 12);
sub_776584((int)&v26, (char *)&unk_939830);
v22 = 0;
while ( v9 < v23 && (float)v8 < (float)(a4 + a4) )
{
sub_775C20(v27, a3);
v24 = (int)(float)((float)v8
+ (float)(a5 * (float)*(unsigned int *)(a2 + 4 * *(unsigned __int8 *)sub_7757BC(v27, v9) + 508)));
sub_776158(&v28, v27, v9, 1);
if ( !sub_774E98((int)&v28, "\n") )
{
v12 = sub_774544((int)&v26, " ");
sub_775D40(&v26, v12);
v9 = 1000;
sub_774008(&v28);
sub_774008(v27);
v8 = v24;
break;
}
if ( sub_774E98((int)&v28, byte_948BD5) && *(_BYTE *)sub_7757BC(&v28, 0) == 32 )
{
v22 = v8;
v7 = (unsigned int)(float)(a5 * (float)*(unsigned int *)(a2 + 4 * *(unsigned __int8 *)sub_7757BC(v27, v9) + 508));
}
v13 = sub_774544((int)&v26, v28);
sub_775D40(&v26, v13);
++v9;
sub_774008(&v28);
sub_774008(v27);
v8 = v24;
}
v14 = v22 / 2;
if ( !*(_BYTE *)(a2 + 1724) && (float)v8 < (float)(a4 + a4) )
*(_DWORD *)(a2 + 1720) = v8 / 2 - v7;
*(_BYTE *)(a2 + 1724) = 1;
if ( v14 > *(_DWORD *)(a2 + 1720) )
*(_DWORD *)(a2 + 1720) = v14;
if ( v23 > v9 )
{
v15 = *(_DWORD *)(v26 - 12);
if ( v15 >= v9 )
v16 = 0;
else
v16 = v9 - v15;
v17 = v9 - v16;
do
{
if ( v17 <= 0 )
break;
v18 = v17 - 1;
if ( *(_BYTE *)sub_7757BC(&v26, v17 - 1) == 32 )
break;
++v16;
v17 = v18;
}
while ( v16 <= v9 );
if ( v9 - v16 > 1 )
{
sub_776158(&v28, &v26, 0, *(_DWORD *)(v26 - 12) - v16);
sub_774794(&v26, &v28);
sub_774008(&v28);
}
}
v19 = (cocos2d::CCString *)cocos2d::CCString::create((cocos2d::CCString *)&v26, v11);
CString = (char *)cocos2d::CCString::getCString(v19);
sub_776584(a1, CString);
sub_774008(&v26);
return a1;
}