//
// MusicBrowser::setupList from 0x140339f20 to 0x14033a620 (1792 bytes)
//
// 6 xrefs:
// > MusicBrowser::trySetupMusicBrowser @ 0x140339cd6
// > MusicBrowser::onPage @ 0x14033a6f8
// > MusicBrowser::onClearSearch @ 0x14033a768
// > MusicBrowser::setTextPopupClosed @ 0x14033a942
// > MusicBrowser::FLAlert_Clicked @ 0x14033aab1
// > ??> @ 0x1406d5378
//
// 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
//
// Hidden C++ exception states: #wind=4
void MusicBrowser::setupList(MusicBrowser *a1, MusicSearchResult *a2)
{
MusicSearchResult *v2; // r14
size_t v4; // rsi
unsigned __int64 v5; // r13
MusicDownloadManager *v6; // rax
cocos2d::CCString *v7; // rax
const char *CString; // rax
size_t v9; // r8
__int64 v10; // rdx
__int64 v11; // rcx
__int64 v12; // r8
__int64 v13; // r9
void **v14; // r12
char *v15; // r15
__int64 v16; // rbx
unsigned __int64 v17; // r14
MusicBrowser_vtbl *v18; // rbx
cocos2d::CCNode *v19; // rax
char *v20; // rax
int m_ncsSongCount; // ebx
MusicDownloadManager *v22; // rax
const char *v23; // rdx
cocos2d::CCString *v24; // rax
const char *v25; // rax
size_t v26; // r8
const char *v27; // rdx
LoadingCircleSprite *m_circleSprite; // rbx
__int64 v29; // rcx
__int64 v30; // rax
cocos2d::CCTouchDispatcher *v31; // rax
MusicSearchResult *m_searchResult; // rcx
cocos2d::CCDirector *v33; // rax
__int64 v34; // rcx
cocos2d::CCArray *v35; // r12
MusicSearchResult *v36; // rcx
signed int v37; // ebx
signed int v38; // r15d
signed int v39; // r14d
struct cocos2d::CCObject *v40; // rax
TableViewCellDelegate *v41; // rdx
CustomListView *v42; // rax
const char *v43; // rdx
GJCommentListLayer *v44; // rax
float v45; // xmm0_4
GJCommentListLayer_vtbl *v46; // rbx
const cocos2d::CCPoint *v47; // rax
_BOOL8 v48; // rdx
_BOOL8 v49; // rdx
int v50; // ebx
unsigned int v51; // eax
_BOOL8 v52; // rdx
_BOOL8 v53; // rdx
ButtonSprite *v54; // rax
const char *v55; // rbx
const char *v56; // rdx
ButtonSprite *v57; // rax
int v58; // ebx
int v59; // edx
int v60; // r8d
cocos2d::CCString *v61; // rax
char *v62; // rax
void **v63; // rdx
void *v64; // rcx
int v65; // [rsp+20h] [rbp-B9h]
float v67; // [rsp+48h] [rbp-91h]
__int128 v68; // [rsp+58h] [rbp-81h] BYREF
__int64 v69; // [rsp+68h] [rbp-71h]
__int64 v70; // [rsp+70h] [rbp-69h]
__int128 *v71; // [rsp+78h] [rbp-61h]
void *Block[2]; // [rsp+80h] [rbp-59h] BYREF
__int64 v73; // [rsp+90h] [rbp-49h]
unsigned __int64 v74; // [rsp+98h] [rbp-41h]
void *Src[2]; // [rsp+A0h] [rbp-39h] BYREF
unsigned __int64 v76; // [rsp+B0h] [rbp-29h]
unsigned __int64 v77; // [rsp+B8h] [rbp-21h]
__int128 v78; // [rsp+C0h] [rbp-19h] BYREF
__int128 v79; // [rsp+D0h] [rbp-9h]
if ( a2 )
{
v2 = a2;
v4 = -1;
v5 = 15;
if ( a1->m_libraryVersion > 0 && a1->m_libraryVersion != MusicDownloadManager::sharedState()->m_musicLibraryVersion )
{
v6 = MusicDownloadManager::sharedState();
v7 = cocos2d::CCString::createWithFormat("Music Library Updated to version %i", v6->m_musicLibraryVersion);
CString = cocos2d::CCString::getCString(v7);
*(_OWORD *)Src = 0;
v76 = 0;
v77 = 0;
v9 = -1;
do
++v9;
while ( CString[v9] );
sub_14003A930(Src, CString, v9);
v71 = &v68;
v68 = 0;
v69 = 0;
v70 = 15;
LOBYTE(v68) = 0;
*(_OWORD *)Block = 0;
v73 = 0;
v74 = 0;
v14 = Src;
v15 = (char *)Src[0];
if ( v77 > 0xF )
v14 = (void **)Src[0];
v16 = 0x7FFFFFFFFFFFFFFFLL;
v17 = v76;
if ( v76 > 0x7FFFFFFFFFFFFFFFLL )
sub_140007B50(v11, v10, v12, v13);
v74 = 15;
if ( v76 > 0xF )
{
if ( (v76 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
v16 = v76 | 0xF;
if ( (v76 | 0xF) < 0x16 )
v16 = 22;
}
Block[0] = sub_14003AA10(v16 + 1);
v73 = v17;
v74 = v16;
memcpy(Block[0], v14, v17 + 1);
}
else
{
v73 = v76;
*(_OWORD *)Block = *(_OWORD *)v14;
}
v18 = a1->FLAlertLayer::cocos2d::CCLayerColor::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v19 = TextAlertPopup::create((__int64)Block, v10, v12, 150, (__int64)&v68);
v18->addChild_0(a1, v19, 100);
if ( v77 > 0xF )
{
v20 = v15;
if ( v77 + 1 >= 0x1000 )
{
v15 = *((char **)v15 - 1);
if ( (unsigned __int64)(v20 - v15 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v15);
}
v2 = a2;
}
a1->m_libraryVersion = MusicDownloadManager::sharedState()->m_musicLibraryVersion;
if ( a1->m_songType == 1 )
m_ncsSongCount = MusicDownloadManager::sharedState()->m_ncsSongCount;
else
m_ncsSongCount = MusicDownloadManager::sharedState()->m_musicObjectCount;
v22 = MusicDownloadManager::sharedState();
v23 = "Music";
if ( a1->m_songType == 1 )
v23 = "NCS";
v24 = cocos2d::CCString::createWithFormat(
"%s Library Version %i. Song Count: %i",
v23,
v22->m_musicLibraryVersion,
m_ncsSongCount);
v25 = cocos2d::CCString::getCString(v24);
v78 = 0;
v79 = 0;
v26 = -1;
do
++v26;
while ( v25[v26] );
sub_14003A930(&v78, v25, v26);
v27 = (const char *)&v78;
if ( *((_QWORD *)&v79 + 1) > 0xFu )
v27 = (const char *)v78;
a1->m_infoLabel->setString(&a1->m_infoLabel->cocos2d::CCLabelProtocol, v27);
m_circleSprite = a1->m_circleSprite;
cocos2d::CCNode::stopActionByTag(m_circleSprite, 0);
m_circleSprite->setOpacity(&m_circleSprite->cocos2d::CCRGBAProtocol, 0);
m_circleSprite->setVisible(m_circleSprite, 0);
if ( a1->m_listLayer )
{
v30 = cocos2d::CCDirector::sharedDirector(v29);
v31 = (cocos2d::CCTouchDispatcher *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v30 + 144LL))(v30);
cocos2d::CCTouchDispatcher::unregisterForcePrio(v31, a1->m_listLayer);
a1->m_listLayer->removeMeAndCleanup(a1->m_listLayer);
a1->m_listLayer = nullptr;
}
cocos2d::CCObject::retain(v2);
m_searchResult = a1->m_searchResult;
if ( m_searchResult )
cocos2d::CCObject::release(m_searchResult);
a1->m_searchResult = v2;
v33 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(m_searchResult);
cocos2d::CCDirector::getWinSize(v33);
v35 = (cocos2d::CCArray *)cocos2d::CCArray::create(v34);
v36 = a1->m_searchResult;
v37 = 10 * v36->m_startIndex;
v38 = cocos2d::CCArray::count(v36->m_filterObjects);
v39 = v37 + 10;
if ( !__OFSUB__(v37, v37 + 10) )
{
do
{
if ( v37 >= v38 )
break;
v40 = cocos2d::CCArray::objectAtIndex(a1->m_searchResult->m_filterObjects, v37);
cocos2d::CCArray::addObject(v35, v40);
++v37;
}
while ( v37 < v39 );
}
v41 = &a1->TableViewCellDelegate;
if ( !a1 )
v41 = nullptr;
v42 = CustomListView::create(v35, v41, 220.0, 340.0, v65, CustomMusic, 0.0);
v44 = GJCommentListLayer::create(v42, v43, (cocos2d::ccColor4B)-13487566, 340.0, 220.0, 1);
a1->m_listLayer = v44;
v45 = ((float (__fastcall *)(cocos2d::CCLayer *, GJCommentListLayer *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v44,
10);
v46 = a1->m_listLayer->__vftable;
cocos2d::CCPoint::CCPoint(v45, (float)(v67 - 340.0) * 0.5);
v46->setPosition_0(a1->m_listLayer, v47);
LOBYTE(v48) = 1;
a1->m_refreshButton->setVisible(a1->m_refreshButton, v48);
v50 = 0;
if ( (int)cocos2d::CCArray::count(a1->m_searchResult->m_filterObjects) > 0 )
{
v51 = cocos2d::CCArray::count(a1->m_searchResult->m_filterObjects);
v50 = (int)ceilf((float)((v51 - 1) / 0xA));
}
LOBYTE(v49) = a1->m_searchResult->m_startIndex > 0;
a1->m_prevButton->setVisible(a1->m_prevButton, v49);
LOBYTE(v52) = a1->m_searchResult->m_startIndex < v50;
a1->m_nextButton->setVisible(a1->m_nextButton, v52);
LOBYTE(v53) = a1->m_searchResult->m_searchQuery.m_data.m_size != 0;
a1->m_clearSearchButton->setVisible(a1->m_clearSearchButton, v53);
v54 = (ButtonSprite *)a1->m_tagFilterButton->getNormalImage(a1->m_tagFilterButton);
v55 = "GJ_button_01.png";
v56 = "GJ_button_01.png";
if ( a1->m_searchResult->m_tagFilter )
v56 = "GJ_button_02.png";
ButtonSprite::updateBGImage(v54, v56);
v57 = (ButtonSprite *)a1->m_artistFilterButton->getNormalImage(a1->m_artistFilterButton);
if ( a1->m_searchResult->m_artistFilter )
v55 = "GJ_button_02.png";
ButtonSprite::updateBGImage(v57, v55);
v58 = cocos2d::CCArray::count(a1->m_searchResult->m_filterObjects);
*(_OWORD *)Block = 0;
v73 = 0;
v74 = 15;
LOBYTE(Block[0]) = 0;
if ( v58 <= 0 )
{
v73 = 10;
strcpy((char *)Block, "No matches");
}
else
{
cocos2d::CCArray::count(a1->m_searchResult->m_filterObjects);
v59 = 10 * a1->m_searchResult->m_startIndex;
v60 = v58;
if ( v59 + 10 < v58 )
v60 = v59 + 10;
v61 = cocos2d::CCString::createWithFormat("%i to %i of %i", v59 + 1, v60, v58);
v62 = (char *)cocos2d::CCString::getCString(v61);
do
++v4;
while ( v62[v4] );
sub_14003CCE0(Block, v62, v4);
v5 = v74;
}
v63 = Block;
if ( v5 > 0xF )
v63 = (void **)Block[0];
a1->m_pageLabel->setString(&a1->m_pageLabel->cocos2d::CCLabelProtocol, (const char *)v63);
if ( v74 > 0xF )
{
v64 = Block[0];
if ( v74 + 1 >= 0x1000 )
{
v64 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v64 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v64);
}
sub_14003A830((__int64)&v78);
}
}