//
// SFXBrowser::fitFolderPath from 0x6c53dc to 0x6c5884 (1192 bytes)
//
// 2 xrefs:
// > SFXBrowser::updateSelectionUI @ 0x6c5b2e
// > SFXBrowser::setupList @ 0x6c5f70
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:56:54 +0000
//
int __fastcall SFXBrowser::fitFolderPath(SFXBrowser *this)
{
int result; // r0
int v3; // r5
int (__fastcall *v4)(int, _BYTE *); // r8
int v5; // r9
float v6; // s16
float v7; // r0
cocos2d::CCDirector *v8; // r0
int v9; // r3
int v11; // r8
float v12; // s16
int v13; // r5
float v14; // s16
int v15; // r6
int v16; // r7
int v17; // r0
unsigned int v18; // r0
unsigned int v19; // r5
size_t v20; // r5
char *v21; // r3
int v22; // r10
size_t v23; // r5
size_t v24; // r8
char *v25; // r11
unsigned int v26; // r6
char *v27; // r3
unsigned int v28; // r6
char *v29; // r1
char *v30; // r1
int i; // r5
const cocos2d::CCPoint *v32; // r11
const cocos2d::CCPoint *v33; // r5
float v34; // r0
int v35; // r3
unsigned int v36; // r3
char *v37; // r2
int v38; // r8
void (__fastcall *v39)(int, char *); // r10
char *v40; // r1
size_t v41; // r2
int *v42; // r3
size_t v43; // r1
char *v44; // r2
char *v45; // r1
float v46; // r1
float v47; // s17
void (__fastcall *v48)(int, char *); // [sp+4h] [bp-88h]
float v49; // [sp+4h] [bp-88h]
char *v50; // [sp+Ch] [bp-80h]
float v51[2]; // [sp+10h] [bp-7Ch] BYREF
float v52[2]; // [sp+18h] [bp-74h] BYREF
char v53[8]; // [sp+20h] [bp-6Ch] BYREF
_BYTE v54[8]; // [sp+28h] [bp-64h] BYREF
int v55; // [sp+30h] [bp-5Ch] BYREF
unsigned int v56; // [sp+34h] [bp-58h]
char *v57; // [sp+38h] [bp-54h]
int v58; // [sp+3Ch] [bp-50h] BYREF
size_t v59; // [sp+40h] [bp-4Ch]
char *v60; // [sp+44h] [bp-48h]
int v61[3]; // [sp+48h] [bp-44h] BYREF
int v62; // [sp+54h] [bp-38h] BYREF
size_t v63; // [sp+58h] [bp-34h]
char *v64; // [sp+5Ch] [bp-30h]
_BYTE v65[16]; // [sp+60h] [bp-2Ch] BYREF
_DWORD v66[5]; // [sp+70h] [bp-1Ch]
result = *((_DWORD *)this + 140);
if ( !result || !*((_DWORD *)this + 139) )
return result;
(*(void (__fastcall **)(int, int))(*(_DWORD *)result + 172))(result, *((unsigned __int8 *)this + 624) ^ 1);
v3 = *((_DWORD *)this + 140);
v4 = *(int (__fastcall **)(int, _BYTE *))(*(_DWORD *)v3 + 92);
v5 = (*(int (__fastcall **)(_DWORD))(**((_DWORD **)this + 139) + 96))(*((_DWORD *)this + 139));
v6 = -*(float *)(*(int (__fastcall **)(_DWORD))(**((_DWORD **)this + 139) + 164))(*((_DWORD *)this + 139));
v7 = (*(float (__fastcall **)(_DWORD))(**((_DWORD **)this + 139) + 84))(*((_DWORD *)this + 139));
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v54, (float)(v6 * v7) - 2.0, 0.0);
cocos2d::CCPoint::operator+(v65, v5, v54);
v8 = (cocos2d::CCDirector *)v4(v3, v65);
if ( *((_BYTE *)this + 624) )
return (*(int (__fastcall **)(_DWORD, void *))(**((_DWORD **)this + 140) + 464))(
*((_DWORD *)this + 140),
&unk_B6B226);
v9 = *((unsigned __int8 *)this + 568);
if ( !((v9 & 1) != 0 ? *((_DWORD *)this + 143) : v9 >> 1) )
return (*(int (__fastcall **)(_DWORD, void *))(**((_DWORD **)this + 140) + 464))(
*((_DWORD *)this + 140),
&unk_B6B226);
cocos2d::CCDirector::sharedDirector(v8);
v11 = 0;
cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)v51);
v66[0] = *((_DWORD *)this + 161);
v66[1] = *((_DWORD *)this + 168);
v12 = (float)(v51[0] * 0.5) - 170.0;
v66[2] = *((_DWORD *)this + 169);
v66[3] = *((_DWORD *)this + 170);
v66[4] = *((_DWORD *)this + 171);
do
{
v13 = v66[v11];
if ( v13 )
{
if ( (*(int (__fastcall **)(_DWORD))(*(_DWORD *)v13 + 176))(v66[v11]) )
{
if ( (*(int (__fastcall **)(int))(*(_DWORD *)v13 + 256))(v13) )
{
cocos2d::CCNode::boundingBox((cocos2d::CCNode *)v65);
v32 = *((const cocos2d::CCPoint **)this + 115);
v33 = (const cocos2d::CCPoint *)(*(int (__fastcall **)(int))(*(_DWORD *)v13 + 256))(v13);
v49 = COERCE_FLOAT(cocos2d::CCRect::getMaxX((cocos2d::CCRect *)v65));
v34 = COERCE_FLOAT(cocos2d::CCRect::getMidY((cocos2d::CCRect *)v65));
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v53, v49, v34);
cocos2d::CCNode::convertToWorldSpace((cocos2d::CCNode *)v54, v33);
cocos2d::CCNode::convertToNodeSpace((cocos2d::CCNode *)v52, v32);
if ( v12 < v52[0] )
v12 = v52[0];
}
}
}
++v11;
}
while ( v11 != 5 );
v14 = (float)((*(float (__fastcall **)(_DWORD))(**((_DWORD **)this + 140) + 112))(*((_DWORD *)this + 140)) - v12)
- 10.0;
std::string::basic_string(&v55, (int)this + 568);
v15 = (unsigned __int8)v55;
v58 = 0;
v16 = v55 & 1;
v59 = 0;
v60 = nullptr;
if ( v16 )
{
v17 = v56;
if ( v56 <= 2 )
goto LABEL_16;
}
else
{
v17 = (int)(unsigned __int8)v55 >> 1;
if ( v17 <= 2 )
goto LABEL_16;
}
v18 = v17 - 3;
if ( v16 )
v19 = v56;
else
v19 = (int)(unsigned __int8)v55 >> 1;
if ( v18 > v19 )
sub_389E68();
v20 = v19 - v18;
if ( v20 <= 2 )
{
if ( !v16 )
{
v21 = (char *)&v55 + 1;
LABEL_31:
if ( !v20 )
goto LABEL_16;
goto LABEL_32;
}
LABEL_29:
v21 = v57;
goto LABEL_31;
}
if ( v16 )
{
v20 = 3;
goto LABEL_29;
}
v21 = (char *)&v55 + 1;
v20 = 3;
LABEL_32:
if ( memcmp(&v21[v18], " \\ ", v20) || v20 != 3 )
goto LABEL_16;
if ( v16 )
v35 = v56;
else
v35 = v15 >> 1;
v36 = v35 - 3;
if ( v16 )
{
if ( v36 > v56 )
LABEL_69:
sub_389E68();
v37 = v57;
v56 = v36;
}
else
{
if ( v36 > (unsigned int)v15 >> 1 )
goto LABEL_69;
LOBYTE(v55) = 2 * v36;
v37 = (char *)&v55 + 1;
}
v37[v36] = 0;
std::string::assign(&v58, " \\ ");
LABEL_16:
(*(void (__fastcall **)(_DWORD, int))(**((_DWORD **)this + 140) + 80))(*((_DWORD *)this + 140), 1058642330);
v22 = *((_DWORD *)this + 140);
v48 = *(void (__fastcall **)(int, char *))(*(_DWORD *)v22 + 464);
v62 = 0;
v63 = 0;
v64 = nullptr;
if ( (v55 & 1) != 0 )
v23 = v56;
else
v23 = (int)(unsigned __int8)v55 >> 1;
if ( (v58 & 1) != 0 )
v24 = v59;
else
v24 = (int)(unsigned __int8)v58 >> 1;
if ( (v55 & 1) != 0 )
v25 = v57;
else
v25 = (char *)&v55 + 1;
v26 = v24 + v23;
if ( v24 + v23 > 0xFFFFFFEF )
sub_389EB0();
if ( v26 > 0xA )
{
v28 = (v26 + 16) & 0xFFFFFFF0;
v27 = (char *)operator new(v28);
v64 = v27;
v62 = v28 | 1;
v63 = v23;
}
else
{
LOBYTE(v62) = 2 * v23;
v27 = (char *)&v62 + 1;
}
v50 = v27;
std::char_traits::copy(v27, v25, v23);
v50[v23] = 0;
if ( (v58 & 1) != 0 )
v29 = v60;
else
v29 = (char *)&v58 + 1;
std::string::append(&v62, v29, v24);
if ( (v62 & 1) != 0 )
v30 = v64;
else
v30 = (char *)&v62 + 1;
v48(v22, v30);
std::string::~string((int)&v62);
for ( i = GameToolbox::pathSegmentCount((unsigned __int8 *)&v55, " \\ ") - 1;
i > 0
&& (float)(*(float *)(*(int (__fastcall **)(_DWORD))(**((_DWORD **)this + 140) + 164))(*((_DWORD *)this + 140))
* 0.6) > v14;
--i )
{
v38 = *((_DWORD *)this + 140);
v39 = *(void (__fastcall **)(int, char *))(*(_DWORD *)v38 + 464);
GameToolbox::keepLastPathSegments(v61, (unsigned __int8 *)&v55, " \\ ", i);
if ( (v58 & 1) != 0 )
{
v40 = v60;
v41 = v59;
}
else
{
v41 = (int)(unsigned __int8)v58 >> 1;
v40 = (char *)&v58 + 1;
}
v42 = std::string::append(v61, v40, v41);
v43 = v42[1];
v44 = (char *)v42[2];
v62 = *v42;
v63 = v43;
v64 = v44;
*v42 = 0;
v42[1] = 0;
v42[2] = 0;
if ( (v62 & 1) != 0 )
v45 = v64;
else
v45 = (char *)&v62 + 1;
v39(v38, v45);
std::string::~string((int)&v62);
std::string::~string((int)v61);
}
if ( v14 < 1.0 )
v46 = 1.0;
else
v46 = v14;
cocos2d::CCLabelBMFont::limitLabelWidth(*((cocos2d::CCLabelBMFont **)this + 140), v46, 0.6, 0.45);
v47 = *(float *)(*(int (__fastcall **)(_DWORD))(**((_DWORD **)this + 140) + 164))(*((_DWORD *)this + 140));
if ( (float)(v47 * (*(float (__fastcall **)(_DWORD))(**((_DWORD **)this + 140) + 84))(*((_DWORD *)this + 140))) > v14 )
(*(void (__fastcall **)(_DWORD, void *))(**((_DWORD **)this + 140) + 464))(*((_DWORD *)this + 140), &unk_B6B226);
std::string::~string((int)&v58);
return std::string::~string((int)&v55);
}