//
// GJSongBrowser::loadPage from 0x1402b7770 to 0x1402b79f1 (641 bytes)
//
// 5 xrefs:
// > GJSongBrowser::create @ 0x1402b7293
// > GJSongBrowser::init @ 0x1402b731f
// > GJSongBrowser::onNextPage @ 0x1402b7a08
// > GJSongBrowser::onPrevPage @ 0x1402b7a18
// > ??> @ 0x1406d2564
//
// 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
//
// local variable allocation has failed, the output may be wrong!
void GJSongBrowser::loadPage(GJSongBrowser *a1, int a2)
{
CCMenuItemSpriteExtra *m_leftArrow; // rcx
int v4; // r15d
unsigned int v5; // eax
cocos2d::CCArray *v6; // rbp
unsigned int i; // ebx
__int64 v8; // rcx
struct cocos2d::CCObject *v9; // rsi
MusicDownloadManager *v10; // rax
cocos2d::CCArray *v11; // r14
int v12; // esi
signed int v13; // r15d
unsigned int v14; // ebx
struct cocos2d::CCObject *v15; // rax
unsigned int v16; // ebx
__int64 v17; // rdx
_BOOL8 v18; // rdx
_BOOL8 v19; // rdx
CCMenuItemSpriteExtra *m_rightArrow; // rcx
signed int v21; // ebx
CCMenuItemSpriteExtra_vtbl *v22; // rax
cocos2d::CCString *v23; // rax
const char *CString; // rax
_BOOL8 v25; // r8
TableViewCellDelegate *v26; // rdx
CustomListView *v27; // rax
int v28; // [rsp+20h] [rbp-38h]
a1->m_page = a2;
m_leftArrow = a1->m_leftArrow;
v4 = a2;
if ( a2 <= 0 )
*(_QWORD *)&a2 = 0;
else
LOBYTE(a2) = 1;
m_leftArrow->setVisible(m_leftArrow, *(_QWORD *)&a2);
v5 = cocos2d::CCArray::count(a1->m_downloadedSongs);
v6 = cocos2d::CCArray::createWithCapacity(v5);
cocos2d::CCArray::addObjectsFromArray(v6, a1->m_downloadedSongs);
for ( i = 0; i < cocos2d::CCArray::count(v6); ++i )
{
v9 = cocos2d::CCArray::objectAtIndex(v6, i);
v10 = MusicDownloadManager::sharedState();
if ( !MusicDownloadManager::isSongDownloaded(v10, v9[5].m_unknown2) )
cocos2d::CCArray::removeObject(a1->m_downloadedSongs, v9, 1);
}
v11 = (cocos2d::CCArray *)cocos2d::CCArray::create(v8);
v12 = 10 * v4;
v13 = cocos2d::CCArray::count(a1->m_downloadedSongs);
if ( cocos2d::CCArray::count(a1->m_downloadedSongs) )
{
v14 = v12;
if ( !__OFSUB__(v12, v12 + 10) )
{
do
{
if ( v14 > cocos2d::CCArray::count(a1->m_downloadedSongs) - 1 )
break;
v15 = cocos2d::CCArray::objectAtIndex(a1->m_downloadedSongs, v14);
cocos2d::CCArray::addObject(v11, v15);
++v14;
}
while ( (int)v14 < v12 + 10 );
}
}
v16 = cocos2d::CCArray::count(a1->m_downloadedSongs);
v17 = cocos2d::CCArray::count(v11) + v12;
if ( (unsigned int)v17 >= v16 )
v17 = 0;
else
LOBYTE(v17) = 1;
a1->m_rightArrow->setVisible(a1->m_rightArrow, v17);
if ( v12 )
LOBYTE(v18) = 1;
else
v18 = 0;
a1->m_leftArrow->setVisible(a1->m_leftArrow, v18);
m_rightArrow = a1->m_rightArrow;
v21 = v12 + 10;
v22 = m_rightArrow->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
if ( v12 + 10 < v13 )
{
LOBYTE(v19) = 1;
v22->setVisible(m_rightArrow, v19);
}
else
{
v22->setVisible(m_rightArrow, 0);
v21 = v13;
}
v23 = cocos2d::CCString::createWithFormat("%i to %i of %i", v12 + 1, v21, v13);
CString = cocos2d::CCString::getCString(v23);
a1->m_countText->setString(&a1->m_countText->cocos2d::CCLabelProtocol, CString);
LOBYTE(v25) = 1;
a1->m_listLayer->removeChildByTag(a1->m_listLayer, 9, v25);
v26 = &a1->TableViewCellDelegate;
if ( !a1 )
v26 = nullptr;
v27 = CustomListView::create(v11, v26, 220.0, 356.0, v28, CustomSong, 0.0);
a1->m_listView = v27;
v27->setTag(v27, 9);
a1->m_listLayer->addChild_0(a1->m_listLayer, a1->m_listView, 6);
}