//
// AchievementsLayer::loadPage from 0x140097a20 to 0x140097c0e (494 bytes)
//
// 6 xrefs:
// > AchievementsLayer::customSetup @ 0x140097946
// > AchievementsLayer::keyDown @ 0x1400979db
// > AchievementsLayer::keyDown @ 0x140097a08
// > AchievementsLayer::onNextPage @ 0x140097c18
// > AchievementsLayer::onPrevPage @ 0x140097c28
// > ??> @ 0x140912cec
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:26:03 +0000
//
__int64 __fastcall AchievementsLayer::loadPage(__int64 a1, __int64 a2)
{
int v2; // ebx
__int64 v4; // rcx
cocos2d::CCArray *v5; // rdi
__int64 v6; // rcx
cocos2d::CCArray *v7; // r15
int v8; // esi
signed int v9; // r12d
unsigned int v10; // ebx
struct cocos2d::CCObject *v11; // rax
unsigned int v12; // ebx
unsigned int v13; // eax
__int64 *v14; // rcx
__int64 v15; // rdx
__int64 v16; // rdx
__int64 v17; // rdx
signed int v18; // ebx
__int64 v19; // rcx
void (__fastcall *v20)(__int64, __int64); // r8
cocos2d::CCString *v21; // rax
const char *CString; // rax
__int64 v23; // r8
int v24; // r8d
int v25; // r9d
__int64 v26; // rbx
v2 = a2;
*(_DWORD *)(a1 + 608) = a2;
v4 = *(_QWORD *)(a1 + 624);
if ( (int)a2 <= 0 )
a2 = 0;
else
LOBYTE(a2) = 1;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v4 + 336LL))(v4, a2);
v5 = *(cocos2d::CCArray **)(AchievementManager::sharedState() + 368);
v7 = (cocos2d::CCArray *)cocos2d::CCArray::create(v6);
v8 = 10 * v2;
v9 = cocos2d::CCArray::count(v5);
if ( v5 )
{
if ( cocos2d::CCArray::count(v5) )
{
v10 = 10 * v2;
if ( !__OFSUB__(v8, v8 + 10) )
{
do
{
if ( v10 > cocos2d::CCArray::count(v5) - 1 )
break;
v11 = cocos2d::CCArray::objectAtIndex(v5, v10);
cocos2d::CCArray::addObject(v7, v11);
++v10;
}
while ( (int)v10 < v8 + 10 );
}
}
}
v12 = cocos2d::CCArray::count(v5);
v13 = cocos2d::CCArray::count(v7);
v14 = *(__int64 **)(a1 + 616);
v15 = *v14;
if ( v13 + v8 >= v12 )
v15 = 0;
else
LOBYTE(v15) = 1;
(*(void (__fastcall **)(__int64 *, __int64))(*v14 + 336))(v14, v15);
if ( v8 )
LOBYTE(v16) = 1;
else
v16 = 0;
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 624) + 336LL))(*(_QWORD *)(a1 + 624), v16);
v18 = v8 + 10;
v19 = *(_QWORD *)(a1 + 616);
v20 = *(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v19 + 336LL);
if ( v8 + 10 < v9 )
{
LOBYTE(v17) = 1;
v20(v19, v17);
}
else
{
v20(v19, 0);
v18 = v9;
}
v21 = cocos2d::CCString::createWithFormat("%i to %i of %i", v8 + 1, v18, v9);
CString = cocos2d::CCString::getCString(v21);
(**(void (__fastcall ***)(__int64, const char *))(*(_QWORD *)(a1 + 632) + 360LL))(
*(_QWORD *)(a1 + 632) + 360LL,
CString);
LOBYTE(v23) = 1;
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 568) + 552LL))(*(_QWORD *)(a1 + 568), 9, v23);
v26 = CustomListView::create((_DWORD)v7, 0, v24, v25);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v26 + 64LL))(v26, 9);
return (*(__int64 (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 568) + 456LL))(
*(_QWORD *)(a1 + 568),
v26,
6);
}