//
// GauntletSelectLayer::setupGauntlets from 0x1402feba0 to 0x1402ff3a5 (2053 bytes)
//
// 3 xrefs:
// > GauntletSelectLayer::init @ 0x1402fe4e4
// > GauntletSelectLayer::loadLevelsFinished @ 0x1402fe99b
// > ??> @ 0x14091e428
//
// 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:30:07 +0000
//
// Hidden C++ exception states: #wind=7
double __fastcall GauntletSelectLayer::setupGauntlets(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rcx
cocos2d::CCArray *v3; // r12
__int64 v4; // rcx
cocos2d::CCArray *v5; // rsi
__int64 v6; // rcx
double result; // xmm0_8
__int64 v8; // r14
cocos2d::CCDictionary *v9; // r14
int v10; // r13d
__int64 v11; // rax
int v12; // ebx
int v13; // edi
__int64 v14; // r14
__int64 i; // r15
cocos2d::CCObject *v16; // r14
unsigned int v17; // edi
struct cocos2d::CCObject *v18; // r12
struct cocos2d::CCObject *v19; // rbx
__int64 v20; // rcx
__int64 v21; // rcx
__int64 *v22; // rsi
__int64 v23; // rdi
__int64 v24; // rbx
__int64 v25; // rax
__int64 v26; // rbx
float v27; // xmm6_4
float *v28; // rax
__int64 v29; // rax
__int64 v30; // rax
struct cocos2d::CCObject *v31; // rbx
unsigned int v32; // r14d
__int64 v33; // rdx
cocos2d::CCArray *v34; // r13
struct cocos2d::CCObject *v35; // rdi
struct cocos2d::CCObject *v36; // r15
struct cocos2d::CCObject *v37; // rbx
__int64 v38; // rax
__int64 v39; // rax
__int64 v40; // r12
float v41; // xmm6_4
unsigned int *v42; // rbx
__int64 v43; // rcx
__int64 *v44; // rbx
__int64 *j; // rsi
__int64 v46; // rdi
float v47; // xmm0_4
float v48; // xmm6_4
unsigned int *v49; // rsi
__int64 v50; // rax
__int64 **v51; // rsi
__int64 **k; // r15
__int64 *v53; // rdi
__int64 v54; // rbx
double v55; // xmm0_8
__int64 v56; // rax
__int64 v57; // rax
float v58; // xmm0_4
unsigned int v59; // eax
char *v60; // rax
__int64 v61; // rcx
cocos2d::CCDirector *v62; // rax
float v63; // xmm0_4
__int64 v64; // rbx
__int64 v65; // rax
__int64 v66; // rcx
cocos2d::CCArray *v67; // rcx
__int64 v68; // r8
cocos2d::CCArray *v69; // [rsp+38h] [rbp-A9h]
int v70; // [rsp+40h] [rbp-A1h]
cocos2d::CCArray *v71; // [rsp+48h] [rbp-99h] BYREF
__int64 v72; // [rsp+50h] [rbp-91h]
cocos2d::CCArray *v73; // [rsp+58h] [rbp-89h]
float v74[2]; // [rsp+60h] [rbp-81h] BYREF
_BYTE v75[8]; // [rsp+68h] [rbp-79h] BYREF
_BYTE v76[8]; // [rsp+70h] [rbp-71h] BYREF
_BYTE v77[8]; // [rsp+78h] [rbp-69h] BYREF
_BYTE v78[8]; // [rsp+80h] [rbp-61h] BYREF
void *v79; // [rsp+88h] [rbp-59h]
__int64 *v80; // [rsp+90h] [rbp-51h]
void *v82; // [rsp+150h] [rbp+6Fh] BYREF
struct cocos2d::CCObject *v83; // [rsp+158h] [rbp+77h]
int v84; // [rsp+160h] [rbp+7Fh] BYREF
v1 = cocos2d::CCDirector::sharedDirector(a1);
cocos2d::CCDirector::getWinSize(v1, v74);
v3 = (cocos2d::CCArray *)cocos2d::CCArray::create(v2);
v73 = v3;
v5 = (cocos2d::CCArray *)cocos2d::CCArray::create(v4);
v69 = v5;
v71 = (cocos2d::CCArray *)cocos2d::CCArray::create(v6);
result = cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v75, v74[0] * 0.5, (float)(v74[1] * 0.5) - 11.0);
v8 = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v82 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v82);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v8 = *(_QWORD *)&qword_14090BFB0;
}
v9 = *(cocos2d::CCDictionary **)(v8 + 1184);
if ( cocos2d::CCDictionary::count(v9) )
{
if ( !qword_14090BFD0 )
{
v82 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v82);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
}
LODWORD(v72) = *(_DWORD *)(qword_14090BFD0 + 1116);
v10 = 0;
LODWORD(v83) = 0;
v11 = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v82 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v82);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v11 = *(_QWORD *)&qword_14090BFB0;
}
LOBYTE(v82) = *(_BYTE *)(v11 + 1576);
*(_BYTE *)(v11 + 1576) = 0;
v12 = *(_DWORD *)(v11 + 1004);
v70 = v12;
v13 = 1;
v84 = 1;
if ( v9 )
{
v14 = *((_QWORD *)v9 + 7);
if ( v14 )
{
for ( i = *(_QWORD *)(v14 + 288); ; i = *(_QWORD *)(i + 288) )
{
v16 = *(cocos2d::CCObject **)(v14 + 264);
if ( *((_DWORD *)v16 + 82) != 7 )
goto LABEL_15;
if ( !qword_14090BFD0 )
{
v79 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v79);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
}
if ( GameManager::getUGV(qword_14090BFD0, &word_140737FE4) )
{
LABEL_15:
v17 = (int)(float)(ceilf((float)v13 / 3.0) - 1.0);
if ( cocos2d::CCArray::count(v3) <= v17 )
{
v19 = (struct cocos2d::CCObject *)cocos2d::CCLayer::create();
cocos2d::CCArray::addObject(v3, v19);
v18 = (struct cocos2d::CCObject *)cocos2d::CCMenu::create(v20);
(*(void (__fastcall **)(struct cocos2d::CCObject *, struct cocos2d::CCObject *))(*(_QWORD *)v19 + 464LL))(
v19,
v18);
cocos2d::CCArray::addObject(v71, v18);
v83 = (struct cocos2d::CCObject *)cocos2d::CCArray::create(v21);
cocos2d::CCArray::addObject(v5, v83);
v12 = v70;
}
else
{
cocos2d::CCArray::objectAtIndex(v3, v17);
v83 = cocos2d::CCArray::objectAtIndex(v5, v17);
v18 = cocos2d::CCArray::objectAtIndex(v71, v17);
}
if ( (_BYTE)v82 )
{
if ( v12 > 0 && *((_DWORD *)v16 + 82) == v12 )
v10 = v17;
}
else if ( *((_DWORD *)v16 + 82) == (_DWORD)v72 && (int)v72 > 1 )
{
v10 = v17;
}
v22 = (__int64 *)operator new(0x168u);
v80 = v22;
memset(v22, 0, 0x168u);
cocos2d::CCNode::CCNode((cocos2d::CCNode *)v22);
*v22 = (__int64)&GauntletNode::`vftable';
v22[40] = 0;
v22[41] = 0;
v22[43] = 0;
*((_BYTE *)v22 + 352) = 0;
if ( cocos2d::CCNode::init((cocos2d::CCNode *)v22) )
{
v22[43] = (__int64)v16;
cocos2d::CCObject::retain(v16);
*((_BYTE *)v22 + 352) = 0;
GauntletNode::generateNode(v22);
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v22);
}
else
{
(*(void (__fastcall **)(__int64 *, __int64))(*v22 + 8))(v22, 1);
v22 = nullptr;
}
cocos2d::CCDictionary::setObject(
*(cocos2d::CCDictionary **)(a1 + 496),
(struct cocos2d::CCObject *)v22,
*((int *)v16 + 82));
v23 = cocos2d::CCNode::create();
v24 = *(_QWORD *)v23;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)v76, 110.0, 234.0);
(*(void (__fastcall **)(__int64, __int64))(v24 + 312))(v23, v25);
(*(void (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v23 + 464LL))(v23, v22);
v26 = *v22;
v27 = *(float *)((*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v23 + 320LL))(v23) + 4) * 0.5;
v28 = (float *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v23 + 320LL))(v23);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v77, *v28 * 0.5, v27);
cocos2d::CCNode::convertToNodeSpace(v23, v78, v29);
(*(void (__fastcall **)(__int64 *, __int64))(v26 + 184))(v22, v30);
v31 = CCMenuItemSpriteExtra::create(v23, 0, a1, (__int64)GauntletSelectLayer::onPlay);
*((_DWORD *)v31 + 100) = 1065772646;
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)v31 + 64LL))(
v31,
*((unsigned int *)v16 + 82));
(*(void (__fastcall **)(struct cocos2d::CCObject *, struct cocos2d::CCObject *))(*(_QWORD *)v18 + 464LL))(
v18,
v31);
cocos2d::CCArray::addObject(v83, v31);
v13 = ++v84;
v5 = v69;
v3 = v73;
v12 = v70;
}
v14 = i;
if ( !i )
break;
}
LODWORD(v83) = v10;
}
}
v32 = 0;
if ( cocos2d::CCArray::count(v5) )
{
v34 = v71;
do
{
v35 = cocos2d::CCArray::objectAtIndex(v3, v32);
v36 = cocos2d::CCArray::objectAtIndex(v5, v32);
v37 = cocos2d::CCArray::objectAtIndex(v34, v32);
cocos2d::CCNode::convertToWorldSpace(v35, v78, v75);
cocos2d::CCNode::convertToNodeSpace(v37, v77, v38);
v40 = v39;
v41 = -112.0;
if ( v36 )
{
v42 = *((unsigned int **)v36 + 7);
v43 = *v42;
if ( (_DWORD)v43 )
{
v44 = *((__int64 **)v42 + 2);
for ( j = &v44[v43 - 1]; v44 <= j; ++v44 )
{
v46 = *v44;
if ( !*v44 )
break;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v84, (const struct cocos2d::CCSize *)&unk_140909BF8);
v47 = (*(float (__fastcall **)(__int64))(*(_QWORD *)v46 + 128LL))(v46);
v41 = v41 + (float)((float)(v47 * *(float *)&v84) + 112.0);
}
v5 = v69;
}
}
v48 = (float)-v41 * 0.5;
if ( v36 )
{
v49 = *((unsigned int **)v36 + 7);
v50 = *v49;
if ( (_DWORD)v50 )
{
v51 = *((__int64 ***)v49 + 2);
for ( k = &v51[v50 - 1]; v51 <= k; ++v51 )
{
v53 = *v51;
if ( !*v51 )
break;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v82, (const struct cocos2d::CCSize *)&unk_140909BF8);
v54 = *v53;
v55 = (*(double (__fastcall **)(__int64 *))(*v53 + 128))(v53);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v76,
(float)((float)(*(float *)&v55 * *(float *)&v82) * 0.5) + v48,
0.0);
(*(void (__fastcall **)(__int64 *, __int64))(v54 + 184))(v53, v56);
v57 = (*(__int64 (__fastcall **)(__int64 *))(*v53 + 200))(v53);
cocos2d::CCPoint::operator+(v40, &v71, v57);
(*(void (__fastcall **)(__int64 *, cocos2d::CCArray **))(*v53 + 184))(v53, &v71);
v58 = (*(float (__fastcall **)(__int64 *))(*v53 + 128))(v53);
v48 = v48 + (float)((float)(v58 * *(float *)&v82) + 112.0);
}
}
v5 = v69;
}
++v32;
v59 = cocos2d::CCArray::count(v5);
v3 = v73;
}
while ( v32 < v59 );
v10 = (int)v83;
}
v60 = BoomScrollLayer::create((int)v73, v33, 1u, 0, 0);
*(_QWORD *)(a1 + 440) = v60;
*((_QWORD *)v60 + 68) = a1 + 408;
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a1 + 464LL))(a1, *(_QWORD *)(a1 + 440));
v62 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v61);
v63 = cocos2d::CCDirector::getScreenBottom(v62) + 15.0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v82, v74[0] * 0.5, v63);
v64 = *(_QWORD *)(a1 + 440);
result = cocos2d::CCPoint::operator=(v64 + 572, v65);
BoomScrollLayer::updateDots(v64);
if ( v10 > 0 )
{
v66 = *(_QWORD *)(a1 + 440);
if ( *(_BYTE *)(v66 + 456) )
v67 = *(cocos2d::CCArray **)(v66 + 448);
else
v67 = *(cocos2d::CCArray **)(v66 + 480);
if ( v10 == cocos2d::CCArray::count(v67) - 1 )
{
LOBYTE(v68) = 1;
GauntletSelectLayer::goToPage(a1, (unsigned int)(v10 - 1), v68);
}
LOBYTE(v68) = 1;
return GauntletSelectLayer::goToPage(a1, (unsigned int)v10, v68);
}
}
return result;
}