//
// MusicDownloadManager::dataLoaded from 0x829e78 to 0x82a430 (1464 bytes)
//
// 2 xrefs:
// > GameManager::dataLoaded @ 0x5faed8
// > ??> @ 0x506b8
//
// 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 MusicDownloadManager::dataLoaded(MusicDownloadManager *a1, DS_Dictionary *a2)
{
unsigned int v3; // w19
cocos2d::CCArray *v4; // x23
cocos2d::CCString *v5; // x0
char *CString; // x22
cocos2d::CCDictionary *m_songObjects; // x24
__int64 v8; // x27
char *v9; // x0
unsigned int v10; // w19
cocos2d::CCArray *v11; // x23
cocos2d::CCString *v12; // x0
char *v13; // x22
cocos2d::CCDictionary *v14; // x24
__int64 v15; // x27
char *v16; // x0
int m_songPriority; // w20
int IntegerForKey; // w0
unsigned int *v19; // x1
int v20; // w2
cocos2d::CCObject *v21; // x27
char *v22; // x0
char *v23; // x0
unsigned int *v24; // x1
int v25; // w2
unsigned int *v26; // x1
int v27; // w2
cocos2d::CCObject *v28; // x27
char *v29; // x0
char *v30; // x0
unsigned int *v31; // x1
int v32; // w2
unsigned int *v33; // x1
int v34; // w2
unsigned int *v35; // x1
int v36; // w2
cocos2d::CCDictionary *v37; // x0
cocos2d::CCDictionary *v38; // x19
cocos2d::CCDictionary *v39; // x1
cocos2d::CCDictionary *v40; // x0
cocos2d::CCDictionary *v41; // x0
cocos2d::CCDictionary *v42; // x19
cocos2d::CCDictionary *m_MDLM003; // x1
_QWORD v44[2]; // [xsp+0h] [xbp+0h] BYREF
char *v45; // [xsp+68h] [xbp+68h]
char *v46; // [xsp+70h] [xbp+70h]
cocos2d::CCDictionary *DictForKey; // [xsp+78h] [xbp+78h]
DS_Dictionary *v48; // [xsp+80h] [xbp+80h]
int v49[2]; // [xsp+88h] [xbp+88h]
char v50; // [xsp+90h] [xbp+90h] BYREF
char v51; // [xsp+98h] [xbp+98h] BYREF
std::string v52; // [xsp+A8h] [xbp+A8h] BYREF
std::string v53; // [xsp+B0h] [xbp+B0h] BYREF
v48 = a2;
if ( a1->m_songObjects )
{
v3 = 0;
DictForKey = DS_Dictionary::getDictForKey(v48, "MDLM_001", 0);
v4 = cocos2d::CCDictionary::allKeys(DictForKey);
v46 = &v50;
v45 = &v51;
if ( (unsigned int)cocos2d::CCArray::count(v4) )
{
do
{
v5 = cocos2d::CCArray::stringAtIndex(v4, v3);
CString = (char *)cocos2d::CCString::getCString(v5);
m_songObjects = a1->m_songObjects;
sub_D153B8((unsigned int)v44 + 176, CString);
v8 = cocos2d::CCDictionary::objectForKey(m_songObjects, &v53);
v9 = (char *)v53.m_data.m_data - 24;
if ( (__int64 *)v53.m_data.m_data - 3 == &qword_124B6B0 )
goto LABEL_4;
if ( &pthread_create )
{
v19 = (unsigned int *)((char *)v53.m_data.m_data - 8);
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *((_DWORD *)v53.m_data.m_data - 2);
*((_DWORD *)v53.m_data.m_data - 2) = v20 - 1;
}
if ( v20 > 0 )
{
LABEL_4:
if ( v8 )
goto LABEL_5;
}
else
{
operator delete(v9);
if ( v8 )
goto LABEL_5;
}
*(_QWORD *)v49 = a1->m_songObjects;
sub_D153B8((int)&v52, CString);
v21 = (cocos2d::CCObject *)cocos2d::CCDictionary::objectForKey(DictForKey, &v52);
sub_D153B8((int)&v53, CString);
cocos2d::CCDictionary::setObject(v49[0], v21);
v22 = (char *)v53.m_data.m_data - 24;
if ( (__int64 *)v53.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v35 = (unsigned int *)((char *)v53.m_data.m_data - 8);
do
v36 = __ldaxr(v35);
while ( __stlxr(v36 - 1, v35) );
}
else
{
v36 = *((_DWORD *)v53.m_data.m_data - 2);
*((_DWORD *)v53.m_data.m_data - 2) = v36 - 1;
}
if ( v36 <= 0 )
operator delete(v22);
}
v23 = (char *)v52.m_data.m_data - 24;
if ( (__int64 *)v52.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v24 = (unsigned int *)((char *)v52.m_data.m_data - 8);
do
v25 = __ldaxr(v24);
while ( __stlxr(v25 - 1, v24) );
}
else
{
v25 = *((_DWORD *)v52.m_data.m_data - 2);
*((_DWORD *)v52.m_data.m_data - 2) = v25 - 1;
}
if ( v25 <= 0 )
{
++v3;
operator delete(v23);
continue;
}
}
LABEL_5:
++v3;
}
while ( v3 < (unsigned int)cocos2d::CCArray::count(v4) );
}
LABEL_7:
if ( a1->m_MDLM003 )
goto LABEL_8;
LABEL_63:
v41 = DS_Dictionary::getDictForKey(v48, "MDLM_003", 0);
v42 = v41;
m_MDLM003 = a1->m_MDLM003;
if ( v41 != m_MDLM003 )
{
if ( v41 )
{
cocos2d::CCObject::retain(v41);
m_MDLM003 = a1->m_MDLM003;
}
if ( m_MDLM003 )
cocos2d::CCObject::release(m_MDLM003);
a1->m_MDLM003 = v42;
}
goto LABEL_13;
}
v37 = DS_Dictionary::getDictForKey(v48, "MDLM_001", 0);
v38 = v37;
v39 = a1->m_songObjects;
if ( v37 == v39 )
goto LABEL_7;
if ( v37 )
{
cocos2d::CCObject::retain(v37);
v39 = a1->m_songObjects;
}
if ( v39 )
cocos2d::CCObject::release(v39);
v40 = a1->m_MDLM003;
a1->m_songObjects = v38;
if ( !v40 )
goto LABEL_63;
LABEL_8:
v10 = 0;
DictForKey = DS_Dictionary::getDictForKey(v48, "MDLM_003", 0);
v11 = cocos2d::CCDictionary::allKeys(DictForKey);
v46 = &v50;
v45 = &v51;
if ( (unsigned int)cocos2d::CCArray::count(v11) )
{
do
{
v12 = cocos2d::CCArray::stringAtIndex(v11, v10);
v13 = (char *)cocos2d::CCString::getCString(v12);
v14 = a1->m_MDLM003;
sub_D153B8((unsigned int)v44 + 176, v13);
v15 = cocos2d::CCDictionary::objectForKey(v14, &v53);
v16 = (char *)v53.m_data.m_data - 24;
if ( (__int64 *)v53.m_data.m_data - 3 == &qword_124B6B0 )
goto LABEL_10;
if ( &pthread_create )
{
v26 = (unsigned int *)((char *)v53.m_data.m_data - 8);
do
v27 = __ldaxr(v26);
while ( __stlxr(v27 - 1, v26) );
}
else
{
v27 = *((_DWORD *)v53.m_data.m_data - 2);
*((_DWORD *)v53.m_data.m_data - 2) = v27 - 1;
}
if ( v27 > 0 )
{
LABEL_10:
if ( v15 )
goto LABEL_11;
}
else
{
operator delete(v16);
if ( v15 )
goto LABEL_11;
}
*(_QWORD *)v49 = a1->m_MDLM003;
sub_D153B8((int)&v52, v13);
v28 = (cocos2d::CCObject *)cocos2d::CCDictionary::objectForKey(DictForKey, &v52);
sub_D153B8((int)&v53, v13);
cocos2d::CCDictionary::setObject(v49[0], v28);
v29 = (char *)v53.m_data.m_data - 24;
if ( (__int64 *)v53.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v33 = (unsigned int *)((char *)v53.m_data.m_data - 8);
do
v34 = __ldaxr(v33);
while ( __stlxr(v34 - 1, v33) );
}
else
{
v34 = *((_DWORD *)v53.m_data.m_data - 2);
*((_DWORD *)v53.m_data.m_data - 2) = v34 - 1;
}
if ( v34 <= 0 )
operator delete(v29);
}
v30 = (char *)v52.m_data.m_data - 24;
if ( (__int64 *)v52.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v31 = (unsigned int *)((char *)v52.m_data.m_data - 8);
do
v32 = __ldaxr(v31);
while ( __stlxr(v32 - 1, v31) );
}
else
{
v32 = *((_DWORD *)v52.m_data.m_data - 2);
*((_DWORD *)v52.m_data.m_data - 2) = v32 - 1;
}
if ( v32 <= 0 )
{
++v10;
operator delete(v30);
continue;
}
}
LABEL_11:
++v10;
}
while ( v10 < (unsigned int)cocos2d::CCArray::count(v11) );
}
LABEL_13:
m_songPriority = a1->m_songPriority;
if ( m_songPriority < DS_Dictionary::getIntegerForKey(v48, "MDLM_002") )
IntegerForKey = DS_Dictionary::getIntegerForKey(v48, "MDLM_002");
else
IntegerForKey = a1->m_songPriority;
a1->m_songPriority = IntegerForKey;
}