//
// GauntletLayer::setupGauntlet from 0x91e364 to 0x91f33c (4056 bytes)
//
// 3 xrefs:
// > GauntletLayer::init @ 0x91f8d8
// > GauntletLayer::loadLevelsFinished @ 0x91fd0c
// > ??> @ 0x41fe8
//
// 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
//
void GauntletLayer::setupGauntlet(GauntletLayer *a1, cocos2d::CCArray *a2)
{
cocos2d::CCDirector *v3; // x0
__int64 v4; // x19
void *v5; // x0
void *v6; // x0
signed int i; // w26
__int64 v8; // x19
GameStatsManager *v9; // x0
signed int v10; // w28
GJGameLevel *v11; // x27
float v12; // s1
GauntletSprite *v13; // x0
GauntletSprite *v14; // x24
CCMenuItemSpriteExtra *v15; // x23
float v16; // s1
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x19
cocos2d::CCNode *v18; // x19
void (__fastcall *v19)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x25
float v20; // s8
cocos2d::CCNode *v21; // x25
float v22; // s8
cocos2d::CCSprite *v23; // x24
void (__fastcall *v24)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x25
void *v25; // x0
float v26; // s0
void (__fastcall *v27)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x25
cocos2d::CCString *v28; // x0
cocos2d::CCLabelBMFont *v29; // x25
void (__fastcall *setAnchorPoint)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::CCPoint *); // x24
void (__fastcall *v31)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x24
cocos2d::CCSprite *v32; // x24
GameStatsManager *v33; // x0
float v34; // s0
float v35; // s1
cocos2d::CCSprite *v36; // x27
const cocos2d::CCPoint *v37; // x1
float v38; // s2
int k; // w23
cocos2d::CCSprite *v40; // x19
void (__fastcall *setColor)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x2
char v42; // w3
float v43; // s0
float v44; // s1
float v45; // s8
cocos2d::CCScaleTo *v46; // x0
cocos2d::CCActionInterval *v47; // x0
cocos2d::CCFadeIn *v48; // x25
unsigned __int8 r; // w27
__int64 v50; // x0
cocos2d::CCTintTo *v51; // x27
cocos2d::CCFiniteTimeAction *v52; // x25
float v53; // s0
cocos2d::CCSequence *v54; // x0
cocos2d::CCAction *v55; // x0
void *v56; // x0
char *v57; // x25
unsigned int *v58; // x24
int v59; // w0
cocos2d::CCArray *v60; // x0
unsigned int j; // w19
__int64 v62; // x0
CCMenuItemSpriteExtra_vtbl *v63; // x2
cocos2d::CCSequence *v64; // x19
cocos2d::CCFiniteTimeAction *v65; // x0
cocos2d::CCAction *v66; // x0
void (__fastcall *v67)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x19
cocos2d::CCSprite *v68; // x27
unsigned int *v69; // x1
int v70; // w2
unsigned int *v71; // x1
int v72; // w2
unsigned int *v73; // x1
int v74; // w2
unsigned int *v75; // x1
int v76; // w2
void (__fastcall *v77)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // [xsp+D0h] [xbp+D0h]
void (__fastcall *v78)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // [xsp+D0h] [xbp+D0h]
void (__fastcall *v79)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // [xsp+D0h] [xbp+D0h]
void (__fastcall *v80)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // [xsp+D0h] [xbp+D0h]
cocos2d::CCMenu *v81; // [xsp+F8h] [xbp+F8h]
cocos2d::CCLabelBMFont *v82; // [xsp+100h] [xbp+100h]
cocos2d::CCLabelBMFont *v83; // [xsp+100h] [xbp+100h]
unsigned __int8 g; // [xsp+100h] [xbp+100h]
cocos2d::CCSpawn *v85; // [xsp+110h] [xbp+110h]
float v86; // [xsp+120h] [xbp+120h]
unsigned int v87; // [xsp+124h] [xbp+124h]
_BYTE v89[8]; // [xsp+130h] [xbp+130h] BYREF
float v90; // [xsp+138h] [xbp+138h]
float v91; // [xsp+13Ch] [xbp+13Ch]
cocos2d::CCPoint v92; // [xsp+140h] [xbp+140h] BYREF
char *v93; // [xsp+148h] [xbp+148h] BYREF
__int64 v94; // [xsp+150h] [xbp+150h] BYREF
cocos2d::CCPoint v95; // [xsp+158h] [xbp+158h] BYREF
__int64 v96; // [xsp+160h] [xbp+160h] BYREF
cocos2d::CCPoint v97; // [xsp+168h] [xbp+168h] BYREF
cocos2d::CCPoint v98; // [xsp+170h] [xbp+170h] BYREF
cocos2d::CCPoint v99; // [xsp+178h] [xbp+178h] BYREF
cocos2d::CCPoint v100; // [xsp+180h] [xbp+180h] BYREF
cocos2d::CCPoint v101; // [xsp+188h] [xbp+188h] BYREF
cocos2d::CCPoint v102; // [xsp+190h] [xbp+190h] BYREF
cocos2d::CCPoint v103; // [xsp+198h] [xbp+198h] BYREF
cocos2d::CCPoint v104; // [xsp+1A0h] [xbp+1A0h] BYREF
cocos2d::CCPoint v105; // [xsp+1A8h] [xbp+1A8h] BYREF
cocos2d::CCPoint v106; // [xsp+1B0h] [xbp+1B0h] BYREF
cocos2d::CCPoint v107; // [xsp+1B8h] [xbp+1B8h] BYREF
cocos2d::CCPoint v108; // [xsp+1C0h] [xbp+1C0h] BYREF
cocos2d::CCPoint v109; // 0:kr08_8.8
cocos2d::SEL_MenuHandler v110; // 0:x2.16
if ( a2 && (unsigned int)cocos2d::CCArray::count(a2) == 5 && !a1->m_levels )
{
a1->m_levels = a2;
cocos2d::CCObject::retain(a2);
v3 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v3);
v81 = cocos2d::CCMenu::create();
a1->addChild_0(a1, v81, 2);
cocos2d::CCPoint::CCPoint(&v92, v90 * 0.5, (float)(v91 * 0.5) + -12.0);
GauntletNode::frameForType(a1->m_gauntletType, (__int64)&v93);
sub_D153B8((int)&v94, v93);
sub_D153B8((int)&v107, "_001");
sub_D153B8((int)&v108, "_locked_001");
while ( 1 )
{
v4 = sub_D1641C((int)&v94, *(void **)&v107);
if ( v4 == -1 )
break;
((void (__fastcall *)(_QWORD, _QWORD, _QWORD, _QWORD, _QWORD))sub_D1861C)(
&v94,
v4,
*(_QWORD *)(*(_QWORD *)&v107 - 24LL),
v108,
*(_QWORD *)(*(_QWORD *)&v108 - 24LL));
}
v5 = (void *)(*(_QWORD *)&v108 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v108 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v75 = (unsigned int *)(*(_QWORD *)&v108 - 8LL);
do
v76 = __ldaxr(v75);
while ( __stlxr(v76 - 1, v75) );
}
else
{
v76 = *(_DWORD *)(*(_QWORD *)&v108 - 8LL);
*(_DWORD *)(*(_QWORD *)&v108 - 8LL) = v76 - 1;
}
if ( v76 <= 0 )
operator delete(v5);
}
v6 = (void *)(*(_QWORD *)&v107 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v107 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v71 = (unsigned int *)(*(_QWORD *)&v107 - 8LL);
do
v72 = __ldaxr(v71);
while ( __stlxr(v72 - 1, v71) );
}
else
{
v72 = *(_DWORD *)(*(_QWORD *)&v107 - 8LL);
*(_DWORD *)(*(_QWORD *)&v107 - 8LL) = v72 - 1;
}
if ( v72 <= 0 )
operator delete(v6);
}
for ( i = 0; i < (unsigned int)cocos2d::CCArray::count(a1->m_levels); ++i )
{
v8 = cocos2d::CCArray::objectAtIndex(a1->m_levels, i);
v9 = GameStatsManager::sharedState();
if ( !GameStatsManager::hasCompletedGauntletLevel(v9, *(_DWORD *)(v8 + 328) - *(_DWORD *)(v8 + 332)) )
break;
}
cocos2d::CCPoint::CCPoint(&v95, &stru_1243370);
v10 = 0;
v86 = yOffsetForGauntlet(a1->m_gauntletType);
do
{
v11 = (GJGameLevel *)cocos2d::CCArray::objectAtIndex(a1->m_levels, v10);
v87 = v10 > 0 && v10 == i && !v11->m_gauntletLevel2;
v12 = -50.0;
if ( (v10 & 1) != 0 )
v12 = 50.0;
cocos2d::CCPoint::CCPoint(&v108, (float)(v10 - 2) * 90.0, v12);
cocos2d::CCPoint::operator+(&v96, &v92, &v108);
v13 = GauntletSprite::create(a1->m_gauntletType, (unsigned __int8)v87 | (v10 > i));
v110.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v14 = v13;
v110.adj = (size_t)GauntletLayer::onLevel;
v15 = CCMenuItemSpriteExtra::create(v13, nullptr, v110);
v15->m_scaleMultiplier = 1.2;
CCMenuItemSpriteExtra::setSizeMult(v15, 1.2);
v15->setTag(v15, v10);
v81->addChild(v81, v15);
v16 = 0.0;
setPosition = v15->setPosition;
if ( (v10 & 1) == 0 )
v16 = -6.0;
cocos2d::CCPoint::CCPoint(&v106, 0.0, v16);
cocos2d::CCPoint::operator+(&v107, &v96, &v106);
v109 = cocos2d::CCNode::convertToNodeSpace(v81, &v107);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCPoint *, float, float))setPosition)(
v15,
&v108,
v109.x,
v109.y);
v18 = cocos2d::CCNode::create();
v18->setContentSize(v18, &stru_1243378);
v14->addChild_0(v14, v18, 1);
v19 = v18->setPosition;
v14->getScaledContentSize(v14);
v20 = v106.x * 0.5;
((void (__fastcall *)(cocos2d::CCPoint *__return_ptr, GauntletSprite *))v14->getScaledContentSize)(&v107, v14);
cocos2d::CCPoint::CCPoint(&v108, v20, v107.y * 0.5);
v19(v18, &v108);
v21 = cocos2d::CCNode::create();
v21->setContentSize(v21, &stru_1243378);
v14->addChild_0(v14, v21, -1);
v82 = (cocos2d::CCLabelBMFont *)v21->setPosition;
v14->getScaledContentSize(v14);
v22 = v106.x * 0.5;
((void (__fastcall *)(cocos2d::CCPoint *__return_ptr, GauntletSprite *))v14->getScaledContentSize)(&v107, v14);
cocos2d::CCPoint::CCPoint(&v108, v22, v107.y * 0.5);
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCPoint *))v82)(v21, &v108);
v23 = cocos2d::CCSprite::createWithSpriteFrameName(v93);
v21->addChild_0(v21, v23, -1);
v24 = v23->setPosition;
cocos2d::CCPoint::CCPoint(&v108, 0.0, -10.0);
v24(v23, &v108);
v23->setScaleY(v23, 1.2);
v23->setColor(v23, (const cocos2d::ccColor3B *)&unk_EF4C40);
v23->setOpacity(v23, 75);
if ( v10 > i )
{
v15->setEnabled(v15, 0);
}
else
{
sub_D18D28(&v106);
v83 = cocos2d::CCLabelBMFont::create();
v25 = (void *)(*(_QWORD *)&v106 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v106 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v69 = (unsigned int *)(*(_QWORD *)&v106 - 8LL);
do
v70 = __ldaxr(v69);
while ( __stlxr(v70 - 1, v69) );
}
else
{
v70 = *(_DWORD *)(*(_QWORD *)&v106 - 8LL);
*(_DWORD *)(*(_QWORD *)&v106 - 8LL) = v70 - 1;
}
if ( v70 <= 0 )
operator delete(v25);
}
v26 = 80.0;
if ( (v10 & 1) != 0 )
v26 = 120.0;
cocos2d::CCLabelBMFont::limitLabelWidth(v83, v26, 0.5, 0.0);
v18->addChild_0(v18, v83, 3);
v27 = v83->setPosition;
cocos2d::CCPoint::CCPoint(&v108, 0.0, v86 + 40.0);
v27(v83, &v108);
v28 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)(v11->m_stars.random - v11->m_stars.seed));
cocos2d::CCString::getCString(v28);
v29 = cocos2d::CCLabelBMFont::create();
setAnchorPoint = v29->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v108, 1.0, 0.5);
setAnchorPoint(v29, &v108);
v29->setScale(v29, 0.4);
v18->addChild_0(v18, v29, 2);
v31 = v29->setPosition;
cocos2d::CCPoint::CCPoint(&v108, -4.0, -38.0);
v31(v29, &v108);
v32 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_bigStar_001.png");
v77 = v32->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v108, 0.0, 0.5);
v77(v32, &v108);
v32->setScale(v32, 0.4);
v18->addChild_0(v18, v32, 2);
v78 = v32->setPosition;
cocos2d::CCPoint::CCPoint(&v108, -4.0, -38.0);
v78(v32, &v108);
v33 = GameStatsManager::sharedState();
if ( GameStatsManager::hasCompletedLevel(v33, v11) )
{
v68 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_completesIcon_001.png");
v79 = v68->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v108, 0.0, 0.5);
v79(v68, &v108);
v18->addChild_0(v18, v68, 5);
v68->setScale(v68, 0.8);
v80 = v68->setPosition;
cocos2d::CCPoint::CCPoint(&v108, 8.0, -5.0);
v80(v68, &v108);
}
v36 = nullptr;
if ( v10 == 4 )
{
v36 = cocos2d::CCSprite::createWithSpriteFrameName("miniSkull_001.png");
v18->addChild_0(v18, v36, 4);
v36->setScale(v36, 1.2);
v67 = v36->setPosition;
cocos2d::CCPoint::CCPoint(&v108, 0.0, 5.0);
v67(v36, &v108);
}
if ( v87 )
{
v60 = (cocos2d::CCArray *)cocos2d::CCArray::create((cocos2d::CCArray *)v87);
a1->m_activeObjects = v60;
cocos2d::CCObject::retain(v60);
cocos2d::CCArray::addObject(a1->m_activeObjects, v83);
cocos2d::CCArray::addObject(a1->m_activeObjects, v29);
cocos2d::CCArray::addObject(a1->m_activeObjects, v32);
if ( v36 )
cocos2d::CCArray::addObject(a1->m_activeObjects, v36);
for ( j = 0; j < (unsigned int)cocos2d::CCArray::count(a1->m_activeObjects); ++j )
{
v62 = cocos2d::CCArray::objectAtIndex(a1->m_activeObjects, j);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v62 + 328LL))(v62, 0);
}
v63 = v15->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_activeItemButton = v15;
v63->setEnabled(v15, 0);
v64 = (cocos2d::CCSequence *)cocos2d::CCDelayTime::create(2.0);
v65 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCCallFunc::create(a1, GauntletLayer::unlockActiveItem, 0);
v66 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v64, v65, 0);
cocos2d::CCNode::runAction(a1, v66);
}
}
if ( v10 > 0 && v10 <= i )
{
v37 = &v95;
if ( (v10 & 1) == 0 )
v37 = (const cocos2d::CCPoint *)&v96;
cocos2d::CCPoint::CCPoint(&v97, v37);
v97.y = v97.y - 2.0;
if ( (v10 & 1) != 0 )
v38 = v97.x + 27.0;
else
v38 = v97.x - 27.0;
v97.x = v38;
cocos2d::CCPoint::CCPoint(&v98, -2.0, -1.0);
cocos2d::CCPoint::CCPoint(&v99, 10.0, 2.5);
cocos2d::CCPoint::CCPoint(&v100, 21.0, 11.5);
cocos2d::CCPoint::CCPoint(&v101, 25.0, 26.0);
cocos2d::CCPoint::CCPoint(&v102, 20.5, 41.0);
cocos2d::CCPoint::CCPoint(&v103, 15.0, 56.0);
cocos2d::CCPoint::CCPoint(&v104, 10.5, 71.0);
cocos2d::CCPoint::CCPoint(&v105, 14.5, 85.5);
cocos2d::CCPoint::CCPoint(&v106, 25.0, 96.0);
for ( k = 1; k != 9; ++k )
{
while ( 1 )
{
cocos2d::CCPoint::CCPoint(&v107);
cocos2d::CCPoint::operator=(&v107, v43, v44);
if ( (v10 & 1) == 0 )
v107.x = -v107.x;
cocos2d::CCPoint::operator+(&v108, &v97, &v107);
v40 = cocos2d::CCSprite::createWithSpriteFrameName("uiDot_001.png");
a1->addChild_0(a1, v40, 1);
setColor = v40->setColor;
v42 = (k & 1) != 0 ? -103 : -78;
v89[0] = v42;
v89[1] = v42;
v89[2] = v42;
setColor(v40, (const cocos2d::ccColor3B *)v89);
v40->setPosition(v40, &v108);
if ( v87 )
break;
if ( ++k == 9 )
goto LABEL_49;
}
v40->setOpacity(v40, 0);
v45 = v40->getScale(v40);
v46 = (cocos2d::CCScaleTo *)((__int64 (__fastcall *)(cocos2d::CCSprite *, float))v40->setScale)(
v40,
v45 * 2.5);
v47 = (cocos2d::CCActionInterval *)cocos2d::CCScaleTo::create(v46, 0.3, v45);
v85 = (cocos2d::CCSpawn *)cocos2d::CCEaseBounceOut::create(v47);
v48 = cocos2d::CCFadeIn::create(0.1);
r = v40->getColor(v40)->r;
g = v40->getColor(v40)->g;
v50 = (__int64)v40->getColor(v40);
v51 = cocos2d::CCTintTo::create(0.5, r, g, *(_BYTE *)(v50 + 2));
v40->setColor(v40, (const cocos2d::ccColor3B *)&off_EF4C38);
v52 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCSpawn::create(v85, v48, v51, 0);
if ( (v10 & 1) != 0 )
v53 = (float)((float)k * 0.15) + 0.65;
else
v53 = (float)((float)(9 - k) * 0.15) + 0.65;
v54 = (cocos2d::CCSequence *)cocos2d::CCDelayTime::create(v53);
v55 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v54, v52, 0);
cocos2d::CCNode::runAction(v40, v55);
}
}
LABEL_49:
cocos2d::CCPoint::operator=(&v95, v34, v35);
++v10;
}
while ( v10 != 5 );
v56 = (void *)(v94 - 24);
if ( (__int64 *)(v94 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v73 = (unsigned int *)(v94 - 8);
do
v74 = __ldaxr(v73);
while ( __stlxr(v74 - 1, v73) );
}
else
{
v74 = *(_DWORD *)(v94 - 8);
*(_DWORD *)(v94 - 8) = v74 - 1;
}
if ( v74 <= 0 )
operator delete(v56);
}
v57 = v93 - 24;
if ( v93 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v58 = (unsigned int *)(v93 - 8);
do
v59 = __ldaxr(v58);
while ( __stlxr(v59 - 1, v58) );
}
else
{
v59 = *((_DWORD *)v93 - 2);
*((_DWORD *)v93 - 2) = v59 - 1;
}
if ( v59 <= 0 )
operator delete(v57);
}
}
}