//
// GauntletSelectLayer::setupGauntlets from 0x10059f370 to 0x10059f87d (1293 bytes)
//
// 2 xrefs:
// > GauntletSelectLayer::init @ 0x10059f0a6
// > GauntletSelectLayer::loadLevelsFinished @ 0x10059f9fc
//
// 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 12:32:32 +0000
//
__int64 __fastcall GauntletSelectLayer::setupGauntlets(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // r13
__int64 v3; // rbx
__int64 result; // rax
__int64 v5; // rax
__int64 v6; // rbx
int v7; // r15d
__int64 v8; // rax
unsigned int v9; // r15d
__int64 v10; // r15
void *v11; // r12
__int64 v12; // rax
_DWORD *v13; // r15
__int64 v14; // r14
__int64 v15; // rax
__m128 v16; // xmm0
_QWORD *v17; // rsi
__int64 v18; // rdx
__int64 v19; // rcx
__int64 v20; // rbx
__int64 v21; // rdi
__int64 v22; // r14
unsigned int v23; // ebx
__int64 v24; // r15
__int64 v25; // r13
__int64 v26; // r14
__int64 v27; // rsi
_QWORD *v28; // rax
__int64 *v29; // r15
__int64 v30; // rbx
__int64 v31; // rax
float v32; // xmm1_4
unsigned int v33; // ebx
unsigned int v34; // [rsp+0h] [rbp-A0h] BYREF
double v35; // [rsp+8h] [rbp-98h] BYREF
unsigned __int64 v36; // [rsp+10h] [rbp-90h] BYREF
__int64 v37; // [rsp+18h] [rbp-88h]
__int64 v38; // [rsp+20h] [rbp-80h]
__int64 v39; // [rsp+28h] [rbp-78h]
__int64 v40; // [rsp+30h] [rbp-70h] BYREF
int v41; // [rsp+38h] [rbp-68h]
float v42; // [rsp+3Ch] [rbp-64h]
int v43; // [rsp+40h] [rbp-60h]
int v44; // [rsp+44h] [rbp-5Ch]
__int64 v45; // [rsp+48h] [rbp-58h]
__int64 *v46; // [rsp+50h] [rbp-50h]
__int64 v47; // [rsp+58h] [rbp-48h]
__int64 v48; // [rsp+60h] [rbp-40h]
__int64 v49; // [rsp+68h] [rbp-38h]
char v50; // [rsp+77h] [rbp-29h]
v1 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(&v40, v1);
v2 = sub_1007FE900(&v40);
v47 = sub_1007FE900(&v40);
v45 = sub_1007FE900(&v40);
sub_100278250((float *)&v34, *(float *)&v40 * 0.5, (float)(*((float *)&v40 + 1) * 0.5) + -11.0);
v3 = *(_QWORD *)(GameLevelManager::sharedState() + 1072);
result = cocos2d::CCDictionary::count(v3);
if ( (_DWORD)result )
{
v46 = (__int64 *)a1;
v43 = *(_DWORD *)(GameManager::sharedState() + 1084);
v50 = *(_BYTE *)(GameLevelManager::sharedState() + 1448);
*(_BYTE *)(GameLevelManager::sharedState() + 1448) = 0;
v5 = GameLevelManager::sharedState();
v49 = 0;
v37 = v2;
if ( v3 )
{
v6 = *(_QWORD *)(v3 + 56);
if ( v6 )
{
v44 = *(_DWORD *)(v5 + 908);
v7 = 1;
v49 = 0;
do
{
v14 = *(_QWORD *)(v6 + 264);
v6 = *(_QWORD *)(v6 + 288);
if ( *(_DWORD *)(v14 + 328) == 7 )
{
v15 = GameManager::sharedState();
if ( !(unsigned __int8)GameManager::getUGV(v15, "19") )
continue;
}
v48 = v6;
v41 = v7;
v16 = 0;
v16.f32[0] = (float)v7 / 3.0;
v9 = (int)(float)(_mm_round_ss(v16, v16, 10).f32[0] + -1.0);
if ( (unsigned int)sub_1007FEF90(v2) <= v9 )
{
v17 = cocos2d::CCLayer::create();
sub_1007FEBF0(v2, v17);
v20 = cocos2d::CCMenu::create(v2, v17, v18, v19);
(*(void (__fastcall **)(_QWORD *, __int64))(*v17 + 456LL))(v17, v20);
v21 = v45;
v38 = v20;
sub_1007FEBF0(v45, v20);
v39 = sub_1007FE900(v21);
sub_1007FEBF0(v47, v39);
if ( !v50 )
{
LABEL_5:
v8 = v49;
if ( *(_DWORD *)(v14 + 328) != v43 )
v9 = v49;
if ( v43 >= 2 )
v8 = v9;
goto LABEL_9;
}
}
else
{
sub_1007FEFE0(v2, v9);
v39 = sub_1007FEFE0(v47, v9);
v38 = sub_1007FEFE0(v45, v9);
if ( !v50 )
goto LABEL_5;
}
if ( v44 <= 0 )
goto LABEL_10;
v8 = v49;
if ( *(_DWORD *)(v14 + 328) == v44 )
v8 = v9;
LABEL_9:
v49 = v8;
LABEL_10:
v10 = GauntletNode::create(v14);
cocos2d::CCDictionary::setObject_1(v46[62], v10, *(int *)(v14 + 328));
v11 = cocos2d::CCNode::create();
sub_100278260((float *)&v36, 110.0, 234.0);
(*(void (__fastcall **)(void *, unsigned __int64 *))(*(_QWORD *)v11 + 320LL))(v11, &v36);
(*(void (__fastcall **)(void *, __int64))(*(_QWORD *)v11 + 456LL))(v11, v10);
v42 = *(float *)(*(__int64 (__fastcall **)(void *))(*(_QWORD *)v11 + 328LL))(v11) * 0.5;
v12 = (*(__int64 (__fastcall **)(void *))(*(_QWORD *)v11 + 328LL))(v11);
sub_100278250((float *)&v35, v42, *(float *)(v12 + 4) * 0.5);
cocos2d::CCNode::convertToNodeSpace((double *)&v36, (__int64)v11, (unsigned int *)&v35);
(*(void (__fastcall **)(__int64, unsigned __int64 *))(*(_QWORD *)v10 + 184LL))(v10, &v36);
v13 = CCMenuItemSpriteExtra::create((__int64)v11, 0, (__int64)v46, (__int64)GauntletSelectLayer::onPlay, 0);
v13[100] = 1065772646;
(*(void (__fastcall **)(_DWORD *, _QWORD))(*(_QWORD *)v13 + 72LL))(v13, *(unsigned int *)(v14 + 328));
(*(void (__fastcall **)(__int64, _DWORD *))(*(_QWORD *)v38 + 456LL))(v38, v13);
sub_1007FEBF0(v39, v13);
v7 = v41 + 1;
v2 = v37;
v6 = v48;
}
while ( v6 );
}
}
v22 = v47;
if ( (unsigned int)sub_1007FEF90(v47) )
{
v23 = 0;
v24 = v37;
do
{
v25 = sub_1007FEFE0(v2, v23);
v48 = sub_1007FEFE0(v22, v23);
v26 = sub_1007FEFE0(v45, v23);
cocos2d::CCNode::convertToWorldSpace(&v35, v25, &v34);
v27 = v26;
v22 = v47;
cocos2d::CCNode::convertToNodeSpace((double *)&v36, v27, (unsigned int *)&v35);
v2 = v24;
GameToolbox::alignItemsHorisontally(v48, &v36, 1, (__m128)0x42E00000u);
++v23;
}
while ( v23 < (unsigned int)sub_1007FEF90(v22) );
}
v28 = BoomScrollLayer::create(v2, 0, 1u, 0, 0);
v29 = v46;
v46[55] = (__int64)v28;
v28[68] = v29 + 51;
(*(void (__fastcall **)(__int64 *, _QWORD *))(*v29 + 456))(v29, v28);
v30 = v29[55];
*(float *)&v48 = *(float *)&v40 * 0.5;
v31 = cocos2d::CCDirector::sharedDirector();
v32 = sub_100479750(v31) + 15.0;
sub_100278250((float *)&v36, *(float *)&v48, v32);
result = BoomScrollLayer::setPagesIndicatorPosition(v30, &v36);
v33 = v49;
if ( (int)v49 > 0 )
{
if ( v33 == (unsigned int)BoomScrollLayer::getTotalPages(v29[55]) - 1 )
GauntletSelectLayer::goToPage(v29, v33 - 1, 1);
return GauntletSelectLayer::goToPage(v29, v33, 1);
}
}
return result;
}