//
// GJSongBrowser::loadPage from 0x5bee6c to 0x5bf02c (448 bytes)
//
// 4 xrefs:
// > GJSongBrowser::init @ 0x5bf05c
// > GJSongBrowser::onNextPage @ 0x5bf078
// > GJSongBrowser::onPrevPage @ 0x5bf084
// > ??> @ 0x2d9f0
//
// 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 GJSongBrowser::loadPage(GJSongBrowser *a1, int a2)
{
CCMenuItemSpriteExtra *m_leftArrow; // x2
unsigned int v5; // w19
cocos2d::CCArray *v6; // x0
unsigned int v7; // w1
cocos2d::CCArray *v8; // x20
bool v9; // cf
unsigned int v10; // w1
cocos2d::CCArray *v11; // x0
cocos2d::CCObject *v12; // x21
MusicDownloadManager *v13; // x0
cocos2d::CCArray *v14; // x20
int v15; // w21
int v16; // w24
unsigned int v17; // w19
bool v18; // cc
unsigned int v19; // w1
cocos2d::CCObject *v20; // x0
unsigned int v21; // w19
m_leftArrow = a1->m_leftArrow;
a1->m_page = a2;
if ( a2 <= 0 )
m_leftArrow->setVisible(m_leftArrow, 0);
else
m_leftArrow->setVisible(m_leftArrow, 1);
v5 = 0;
v6 = (cocos2d::CCArray *)cocos2d::CCArray::count(a1->m_downloadedSongs);
v8 = (cocos2d::CCArray *)cocos2d::CCArray::createWithCapacity(v6, v7);
cocos2d::CCArray::addObjectsFromArray(v8, a1->m_downloadedSongs);
while ( 1 )
{
v9 = v5 >= (unsigned int)cocos2d::CCArray::count(v8);
v10 = v5;
v11 = v8;
++v5;
if ( v9 )
break;
while ( 1 )
{
v12 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(v11, v10);
v13 = MusicDownloadManager::sharedState();
if ( MusicDownloadManager::isSongDownloaded(v13, v12[5].m_uUnknown) )
break;
cocos2d::CCArray::removeObject(a1->m_downloadedSongs, v12, 1);
v9 = v5 >= (unsigned int)cocos2d::CCArray::count(v8);
v10 = v5;
v11 = v8;
++v5;
if ( v9 )
goto LABEL_8;
}
}
LABEL_8:
v14 = (cocos2d::CCArray *)cocos2d::CCArray::create(v11);
v15 = 10 * a2;
v16 = cocos2d::CCArray::count(a1->m_downloadedSongs);
if ( (unsigned int)cocos2d::CCArray::count(a1->m_downloadedSongs) )
{
v17 = 10 * a2;
do
{
v18 = v17 > (unsigned int)cocos2d::CCArray::count(a1->m_downloadedSongs) - 1;
v19 = v17++;
if ( v18 )
break;
v20 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(a1->m_downloadedSongs, v19);
cocos2d::CCArray::addObject(v14, v20);
}
while ( v17 != v15 + 10 );
}
v21 = cocos2d::CCArray::count(v14) + v15;
if ( v21 < (unsigned int)cocos2d::CCArray::count(a1->m_downloadedSongs) )
a1->m_rightArrow->setVisible(a1->m_rightArrow, 1);
else
a1->m_rightArrow->setVisible(a1->m_rightArrow, 0);
GJSongBrowser::setupPageInfo(a1, v16, v15, 10);
GJSongBrowser::setupSongBrowser(a1, v14);
}