//
// MusicDownloadManager::createCustomSFXFolder from 0x140486290 to 0x140486429 (409 bytes)
//
// 5 xrefs:
// > SFXFolderPickerPopup::setTextPopupClosed @ 0x1400c681f
// > sub_140487D30 @ 0x1404880f2
// > sub_140487D30 @ 0x14048811b
// > SFXBrowser::setTextPopupClosed @ 0x14061ead9
// > ??> @ 0x140928c28
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// 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:32:46 +0000
//
// Hidden C++ exception states: #wind=1
struct cocos2d::CCObject *__fastcall MusicDownloadManager::createCustomSFXFolder(
__int64 a1,
__int64 a2,
int a3,
int a4)
{
__int64 v4; // rsi
cocos2d::CCDictionary *v7; // rcx
struct cocos2d::CCObject *v8; // rax
struct cocos2d::CCObject *CustomSFXRoot; // rbp
cocos2d::CCDictionary *v10; // rcx
__int64 v11; // rax
struct cocos2d::CCObject *v12; // rax
_QWORD *v13; // rax
cocos2d::CCDictionary *v14; // rcx
int v15; // eax
cocos2d::CCDictionary *v16; // rcx
struct cocos2d::CCObject *v17; // rax
int v18; // ecx
__int64 v19; // rax
struct cocos2d::CCObject *v20; // rbx
_QWORD v22[4]; // [rsp+30h] [rbp-58h] BYREF
v4 = a4;
v7 = *(cocos2d::CCDictionary **)(a1 + 920);
if ( !v7
|| a3 <= 0
|| (v8 = cocos2d::CCDictionary::objectForKey(v7, a3),
CustomSFXRoot = v8,
v10 = *(cocos2d::CCDictionary **)(a1 + 920),
!v8)
|| !*((_BYTE *)v8 + 72)
&& ((v11 = *((int *)v8 + 15), !v10)
|| (int)v11 <= 0
|| (v12 = cocos2d::CCDictionary::objectForKey(v10, v11), (CustomSFXRoot = v12) == nullptr)
|| !*((_BYTE *)v12 + 72)) )
{
CustomSFXRoot = MusicDownloadManager::getCustomSFXRoot(a1);
}
v13 = sub_140486190(v22, (char *)a2);
sub_140059C40(a2, (__int64)v13);
sub_14003D310((__int64)v22);
if ( !*(_QWORD *)(a2 + 16) )
sub_1400405A0((void **)a2, "New Folder", 0xAu);
if ( (unsigned int)(v4 - 2) > 0xFFFFFD
|| (v14 = *(cocos2d::CCDictionary **)(a1 + 920)) != nullptr && cocos2d::CCDictionary::objectForKey(v14, v4) )
{
while ( 1 )
{
v15 = *(_DWORD *)(a1 + 928);
v16 = *(cocos2d::CCDictionary **)(a1 + 920);
if ( !v16 || v15 <= 0 )
break;
v17 = cocos2d::CCDictionary::objectForKey(v16, *(int *)(a1 + 928));
LODWORD(v4) = *(_DWORD *)(a1 + 928);
v18 = v4 + 1;
if ( !v17 )
goto LABEL_20;
*(_DWORD *)(a1 + 928) = v18;
}
LODWORD(v4) = *(_DWORD *)(a1 + 928);
v18 = v15 + 1;
LABEL_20:
*(_DWORD *)(a1 + 928) = v18;
}
v19 = sub_14003F4F0((__int64)v22, a2);
v20 = (struct cocos2d::CCObject *)SFXFolderObject::create(
(unsigned int)v4,
v19,
*((unsigned int *)CustomSFXRoot + 19));
*((_DWORD *)v20 + 19) = v4;
cocos2d::CCDictionary::setObject(*(cocos2d::CCDictionary **)(a1 + 920), v20, (int)v4);
cocos2d::CCArray::addObject(*((cocos2d::CCArray **)CustomSFXRoot + 22), v20);
sub_14003D310(a2);
return v20;
}