//
// MusicDownloadManager::createCustomSFXPlacement from 0x140486430 to 0x140486700 (720 bytes)
//
// 3 xrefs:
// > sub_140487D30 @ 0x14048813d
// > SFXBrowser::sfxFolderPicked @ 0x14061c30b
// > ??> @ 0x140928c34
//
// 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=2
struct cocos2d::CCObject *__fastcall MusicDownloadManager::createCustomSFXPlacement(
__int64 a1,
int a2,
int a3,
__int64 a4,
int a5)
{
__int64 v6; // r13
int v8; // esi
int v9; // r15d
cocos2d::CCDictionary *v10; // rcx
struct cocos2d::CCObject *v11; // rax
struct cocos2d::CCObject *CustomSFXRoot; // rbp
__int64 v13; // rax
cocos2d::CCDictionary *v14; // rcx
struct cocos2d::CCObject *v15; // rax
cocos2d::CCDictionary *v16; // rcx
struct cocos2d::CCObject *v17; // r14
_QWORD *v18; // rax
__int64 v19; // rax
char v20; // bl
cocos2d::CCString *v21; // rax
const char *CString; // rax
size_t v23; // r8
void *v24; // rcx
cocos2d::CCDictionary *v25; // rcx
int v26; // eax
cocos2d::CCDictionary *v27; // rcx
struct cocos2d::CCObject *v28; // rax
int v29; // ecx
int v30; // ebx
int v31; // eax
struct cocos2d::CCObject *v32; // rbx
void *Block[2]; // [rsp+40h] [rbp-98h] BYREF
__int128 v35; // [rsp+50h] [rbp-88h]
_BYTE v36[32]; // [rsp+60h] [rbp-78h] BYREF
v6 = a2;
v8 = a5;
v9 = 0;
v10 = *(cocos2d::CCDictionary **)(a1 + 920);
if ( !v10
|| a3 <= 0
|| (v11 = cocos2d::CCDictionary::objectForKey(v10, a3), (CustomSFXRoot = v11) == nullptr)
|| !*((_BYTE *)v11 + 72)
&& ((v13 = *((int *)v11 + 15), (v14 = *(cocos2d::CCDictionary **)(a1 + 920)) == nullptr)
|| (int)v13 <= 0
|| (v15 = cocos2d::CCDictionary::objectForKey(v14, v13), (CustomSFXRoot = v15) == nullptr)
|| !*((_BYTE *)v15 + 72)) )
{
CustomSFXRoot = MusicDownloadManager::getCustomSFXRoot(a1);
}
v16 = *(cocos2d::CCDictionary **)(a1 + 408);
if ( v16 )
v17 = cocos2d::CCDictionary::objectForKey(v16, v6);
else
v17 = nullptr;
v18 = sub_140486190(Block, (char *)a4);
sub_140059C40(a4, (__int64)v18);
sub_14003D310((__int64)Block);
if ( !*(_QWORD *)(a4 + 16) )
{
if ( v17 )
{
v19 = sub_14003F4F0((__int64)v36, (__int64)v17 + 80);
v20 = 1;
}
else
{
v21 = cocos2d::CCString::createWithFormat("SFX %i", v6);
CString = cocos2d::CCString::getCString(v21);
*(_OWORD *)Block = 0;
v35 = 0;
v23 = -1;
do
++v23;
while ( CString[v23] );
sub_14003D230(Block, CString, v23);
v19 = (__int64)Block;
v20 = 2;
}
sub_140059C40(a4, v19);
if ( (v20 & 2) != 0 )
{
v20 &= ~2u;
if ( *((_QWORD *)&v35 + 1) > 0xFu )
{
v24 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v35 + 1) + 1LL) >= 0x1000 )
{
v24 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v24 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v24);
}
}
if ( (v20 & 1) != 0 )
sub_14003D310((__int64)v36);
}
if ( (unsigned int)(a5 - 2) > 0xFFFFFD
|| (v25 = *(cocos2d::CCDictionary **)(a1 + 920)) != nullptr && cocos2d::CCDictionary::objectForKey(v25, a5) )
{
while ( 1 )
{
v26 = *(_DWORD *)(a1 + 928);
v27 = *(cocos2d::CCDictionary **)(a1 + 920);
if ( !v27 || v26 <= 0 )
break;
v28 = cocos2d::CCDictionary::objectForKey(v27, *(int *)(a1 + 928));
v8 = *(_DWORD *)(a1 + 928);
v29 = v8 + 1;
if ( !v28 )
goto LABEL_35;
*(_DWORD *)(a1 + 928) = v29;
}
v8 = *(_DWORD *)(a1 + 928);
v29 = v26 + 1;
LABEL_35:
*(_DWORD *)(a1 + 928) = v29;
}
if ( v17 )
{
v9 = *((_DWORD *)v17 + 17);
v30 = *((_DWORD *)v17 + 16);
}
else
{
v30 = 0;
}
v31 = sub_14003F4F0((__int64)v36, a4);
v32 = (struct cocos2d::CCObject *)SFXInfoObject::create(v6, v31, *((_DWORD *)CustomSFXRoot + 19), v30, v9);
*((_DWORD *)v32 + 19) = v8;
cocos2d::CCDictionary::setObject(*(cocos2d::CCDictionary **)(a1 + 920), v32, v8);
cocos2d::CCArray::addObject(*((cocos2d::CCArray **)CustomSFXRoot + 22), v32);
sub_14003D310(a4);
return v32;
}