//
// TopArtistsLayer::loadPage from 0x1404cb750 to 0x1404cbbb2 (1122 bytes)
//
// 3 xrefs:
// > TopArtistsLayer::onNextPage @ 0x1404cbbc8
// > TopArtistsLayer::onPrevPage @ 0x1404cbbd8
// > ??> @ 0x1406dd3ac
//
// 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=10
void TopArtistsLayer::loadPage(TopArtistsLayer *a1, int a2)
{
cocos2d::CCString *v3; // rax
const char *CString; // rax
size_t v5; // rbx
size_t v6; // r8
cocos2d::CCString *v7; // rax
const char *v8; // rax
size_t v9; // r8
_BOOL8 v10; // rdx
_BOOL8 v11; // rdx
void **v12; // rsi
GameLevelManager *v13; // rcx
_BOOL8 v14; // rdx
GameLevelManager *v15; // rcx
void **v16; // rdx
cocos2d::CCArray *StoredOnlineLevels; // rsi
GameLevelManager *v18; // rcx
void **v19; // rdx
const char *PageInfo; // rax
void **v21; // r8
void **v22; // r8
_BOOL8 v23; // rdx
GameLevelManager *v24; // rcx
void *v25; // rcx
void *v26; // rcx
void *v27; // [rsp+20h] [rbp-29h]
void *v28; // [rsp+20h] [rbp-29h]
void *v29; // [rsp+20h] [rbp-29h]
void *v30; // [rsp+20h] [rbp-29h]
void *v31; // [rsp+20h] [rbp-29h]
void *v32; // [rsp+20h] [rbp-29h]
void *v33; // [rsp+20h] [rbp-29h]
__int128 v34; // [rsp+28h] [rbp-21h] BYREF
__int64 v35; // [rsp+38h] [rbp-11h]
__int64 v36; // [rsp+40h] [rbp-9h]
void *v37[2]; // [rsp+48h] [rbp-1h] BYREF
__int64 v38; // [rsp+58h] [rbp+Fh]
unsigned __int64 v39; // [rsp+60h] [rbp+17h]
void *Block[2]; // [rsp+68h] [rbp+1Fh] BYREF
__int64 v41; // [rsp+78h] [rbp+2Fh]
unsigned __int64 v42; // [rsp+80h] [rbp+37h]
a1->m_page = a2;
if ( !qword_1406C2EC0 )
{
v27 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v27);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
}
v3 = cocos2d::CCString::createWithFormat("topArtists_%i", a1->m_page);
CString = cocos2d::CCString::getCString(v3);
*(_OWORD *)v37 = 0;
v38 = 0;
v39 = 0;
v5 = -1;
v6 = -1;
do
++v6;
while ( CString[v6] );
sub_14003A930(v37, CString, v6);
if ( !qword_1406C2EC0 )
{
v28 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v28);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
}
v7 = cocos2d::CCString::createWithFormat("topArtists_%i", a1->m_page + 1);
v8 = cocos2d::CCString::getCString(v7);
*(_OWORD *)Block = 0;
v41 = 0;
v42 = 0;
v9 = -1;
do
++v9;
while ( v8[v9] );
sub_14003A930(Block, v8, v9);
LOBYTE(v10) = 1;
a1->m_loadingCircle->setVisible(a1->m_loadingCircle, v10);
if ( a1->m_page <= 0 )
v11 = 0;
else
LOBYTE(v11) = 1;
a1->m_prevButton->setVisible(a1->m_prevButton, v11);
v12 = Block;
if ( v42 > 0xF )
v12 = (void **)Block[0];
v13 = (GameLevelManager *)qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v29 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v29);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v13 = (GameLevelManager *)qword_1406C2EC0;
}
if ( GameLevelManager::getStoredOnlineLevels(v13, (const char *)v12) )
LOBYTE(v14) = 1;
else
v14 = 0;
a1->m_nextButton->setVisible(a1->m_nextButton, v14);
v15 = (GameLevelManager *)qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v30 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v30);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v15 = (GameLevelManager *)qword_1406C2EC0;
}
v16 = v37;
if ( v39 > 0xF )
v16 = (void **)v37[0];
StoredOnlineLevels = GameLevelManager::getStoredOnlineLevels(v15, (const char *)v16);
v18 = (GameLevelManager *)qword_1406C2EC0;
if ( StoredOnlineLevels )
{
if ( !qword_1406C2EC0 )
{
v31 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v31);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v18 = (GameLevelManager *)qword_1406C2EC0;
}
v19 = v37;
if ( v39 > 0xF )
v19 = (void **)v37[0];
PageInfo = GameLevelManager::getPageInfo(v18, (const char *)v19);
v34 = 0;
v35 = 0;
v36 = 0;
do
++v5;
while ( PageInfo[v5] );
sub_14003A930(&v34, PageInfo, v5);
v21 = v37;
if ( v39 > 0xF )
v21 = (void **)v37[0];
a1->setupPageInfo(&a1->OnlineListDelegate, (std::string *)&v34, (const char *)v21);
v22 = v37;
if ( v39 > 0xF )
v22 = (void **)v37[0];
a1->loadListFinished(&a1->OnlineListDelegate, StoredOnlineLevels, (const char *)v22);
}
else
{
if ( !qword_1406C2EC0 )
{
v32 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v32);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v18 = (GameLevelManager *)qword_1406C2EC0;
}
GameLevelManager::makeTimeStamp(v18, "upd_artists");
LOBYTE(v23) = 1;
a1->m_loadingCircle->setVisible(a1->m_loadingCircle, v23);
TopArtistsLayer::setupLeaderboard(a1, nullptr);
v24 = (GameLevelManager *)qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v33 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v33);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v24 = (GameLevelManager *)qword_1406C2EC0;
}
v24->m_onlineListDelegate = &a1->OnlineListDelegate;
GameLevelManager::getTopArtists(v24, a1->m_page, a1->m_itemCount);
a1->m_pageInfoLabel->setString(&a1->m_pageInfoLabel->cocos2d::CCLabelProtocol, " ");
}
if ( v42 > 0xF )
{
v25 = Block[0];
if ( v42 + 1 >= 0x1000 )
{
v25 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v25 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v25);
}
if ( v39 > 0xF )
{
v26 = v37[0];
if ( v39 + 1 >= 0x1000 )
{
v26 = *((void **)v37[0] - 1);
if ( (unsigned __int64)((char *)v37[0] - (char *)v26 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v26);
}
}