//
// GauntletLayer::setupGauntlet from 0x4da6a4 to 0x4db080 (2524 bytes)
//
// 2 xrefs:
// > GauntletLayer::init @ 0x4db430
// > GauntletLayer::loadLevelsFinished @ 0x4db5f8
//
// 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 *v4; // r0
int i; // r2
int v6; // r8
unsigned int j; // r3
int v8; // r5
GameStatsManager *v9; // r0
float v10; // s17
GJGameLevel *v11; // r0
GJGameLevel *v12; // r11
int v13; // r3
float v14; // r2
bool v15; // r1
GauntletSprite *v16; // r7
CCMenuItemSpriteExtra *v17; // r6
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r10
float v19; // r2
cocos2d::CCNode *v20; // r5
void (__fastcall *v21)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r10
float v22; // s18
cocos2d::CCNode *v23; // r8
void (__fastcall *v24)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r10
float v25; // s18
cocos2d::CCSprite *v26; // r7
void (__fastcall *v27)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r10
float v28; // r1
void (__fastcall *v29)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r8
cocos2d::CCString *v30; // r0
cocos2d::CCLabelBMFont *v31; // r7
void (__fastcall *setAnchorPoint)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::CCPoint *); // r9
void (__fastcall *v33)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r9
cocos2d::CCSprite *v34; // r8
void (__fastcall *v35)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r10
void (__fastcall *v36)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r10
GameStatsManager *v37; // r0
int hasCompletedLevel; // r0
int v39; // r2
cocos2d::CCSprite *v40; // r9
void (__fastcall *v41)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r11
void (__fastcall *v42)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r11
bool v43; // r3
cocos2d::CCPoint *v44; // r1
cocos2d::CCSprite *v45; // r5
float v46; // s15
void (__fastcall *setColor)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // r2
int m; // r6
cocos2d::CCSprite *v49; // r9
void (__fastcall *v50)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r10
cocos2d::CCArray *v51; // r0
unsigned int k; // r5
int v53; // r0
CCMenuItemSpriteExtra_vtbl *v54; // r3
cocos2d::CCSequence *v55; // r5
cocos2d::CCFiniteTimeAction *v56; // r0
cocos2d::CCAction *v57; // r0
const cocos2d::CCPoint *v58; // r1
float v59; // s15
int v60; // r2
float v61; // s16
float v62; // r2
cocos2d::CCActionInterval *v63; // r0
cocos2d::CCEaseBounceOut *v64; // r8
cocos2d::CCFadeIn *v65; // r7
unsigned __int8 r; // r10
unsigned __int8 g; // r9
int v68; // r0
cocos2d::CCTintTo *v69; // r9
cocos2d::CCFiniteTimeAction *v70; // r7
int v71; // s14
cocos2d::CCSequence *v72; // r0
cocos2d::CCAction *v73; // r0
int v74; // [sp+0h] [bp-DCh]
signed int v75; // [sp+Ch] [bp-D0h]
int v76; // [sp+10h] [bp-CCh]
signed int v77; // [sp+18h] [bp-C4h]
cocos2d::CCLabelBMFont *v78; // [sp+1Ch] [bp-C0h]
cocos2d::CCMenu *v79; // [sp+20h] [bp-BCh]
_BYTE v80[4]; // [sp+38h] [bp-A4h] BYREF
cocos2d::CCSprite *v81; // [sp+3Ch] [bp-A0h] BYREF
char v82[4]; // [sp+40h] [bp-9Ch] BYREF
cocos2d::CCSize v83; // [sp+44h] [bp-98h] BYREF
cocos2d::CCPoint v84; // [sp+4Ch] [bp-90h] BYREF
cocos2d::CCPoint v85; // [sp+54h] [bp-88h] BYREF
_BYTE v86[8]; // [sp+5Ch] [bp-80h] BYREF
cocos2d::CCPoint v87; // [sp+64h] [bp-78h] BYREF
cocos2d::CCPoint v88; // [sp+6Ch] [bp-70h] BYREF
cocos2d::CCPoint v89; // [sp+74h] [bp-68h] BYREF
cocos2d::CCPoint v90; // [sp+7Ch] [bp-60h] BYREF
cocos2d::CCPoint v91; // [sp+84h] [bp-58h] BYREF
cocos2d::CCPoint v92; // [sp+8Ch] [bp-50h] BYREF
cocos2d::CCPoint v93; // [sp+94h] [bp-48h] BYREF
cocos2d::CCPoint v94; // [sp+9Ch] [bp-40h] BYREF
cocos2d::CCPoint v95; // [sp+A4h] [bp-38h] BYREF
cocos2d::CCPoint v96; // [sp+ACh] [bp-30h] BYREF
cocos2d::CCPoint v97; // [sp+B4h] [bp-28h] BYREF
cocos2d::CCPoint v98; // [sp+BCh] [bp-20h] BYREF
void (*v99)(GauntletLayer *, cocos2d::CCObject *); // [sp+C4h] [bp-18h]
int v100; // [sp+C8h] [bp-14h]
void (*v101)(GauntletLayer *); // [sp+CCh] [bp-10h]
int v102; // [sp+D0h] [bp-Ch]
if ( a2 && cocos2d::CCArray::count(a2) == 5 && !a1->m_levels )
{
a1->m_levels = a2;
cocos2d::CCObject::retain(a2);
v4 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(&v83, v4);
v79 = cocos2d::CCMenu::create();
a1->addChild_0(a1, v79, 2);
cocos2d::CCPoint::CCPoint(&v84, v83.width * 0.5, (float)(v83.height * 0.5) - 12.0);
GauntletNode::frameForType((int)&v81, a1->m_gauntletType);
sub_776584((int)v82, (char *)v81);
sub_776584((int)&v97, "_001");
sub_776584((int)&v98, "_locked_001");
for ( i = 0; ; i = *(_DWORD *)(LODWORD(v98.x) - 12) + v6 )
{
v6 = sub_774834(v82, &v97, i);
if ( v6 == -1 )
break;
sub_776454(v82, v6, *(_DWORD *)(LODWORD(v97.x) - 12), &v98);
}
sub_774008(&v98);
sub_774008(&v97);
for ( j = 0; ; j = v77 + 1 )
{
v77 = j;
if ( j >= cocos2d::CCArray::count(a1->m_levels) )
break;
v8 = cocos2d::CCArray::objectAtIndex(a1->m_levels, v77);
v9 = GameStatsManager::sharedState();
if ( !GameStatsManager::hasCompletedGauntletLevel(v9, *(_DWORD *)(v8 + 268) - *(_DWORD *)(v8 + 272)) )
break;
}
cocos2d::CCPoint::CCPoint(&v85, &stru_AC6E24);
v75 = 0;
v10 = COERCE_FLOAT(yOffsetForGauntlet(a1->m_gauntletType));
while ( 1 )
{
v11 = (GJGameLevel *)cocos2d::CCArray::objectAtIndex(a1->m_levels, v75);
v12 = v11;
if ( v75 == v77 )
{
if ( v75 )
v13 = !v11->m_gauntletLevel2;
else
v13 = 0;
}
else
{
v13 = 0;
}
v76 = v13;
if ( (v75 & 1) != 0 )
v14 = 50.0;
else
v14 = -50.0;
cocos2d::CCPoint::CCPoint(&v98, (float)(v75 - 2) * 90.0, v14);
cocos2d::CCPoint::operator+(v86, &v84, &v98);
if ( v75 <= v77 )
v15 = v76;
else
v15 = 1;
v74 = 0;
v16 = GauntletSprite::create(a1->m_gauntletType, v15);
v99 = GauntletLayer::onLevel;
v100 = 0;
v17 = CCMenuItemSpriteExtra::create(
v16,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(GauntletLayer::onLevel, (unsigned int)a1));
v17->m_scaleMultiplier = 1.2;
CCMenuItemSpriteExtra::setSizeMult(v17, 1.2);
v17->setTag(v17, v75);
v79->addChild(v79, v17);
setPosition = v17->setPosition;
if ( (v75 & 1) != 0 )
v19 = 0.0;
else
v19 = -6.0;
cocos2d::CCPoint::CCPoint(&v96, 0.0, v19);
cocos2d::CCPoint::operator+(&v97, v86, &v96);
cocos2d::CCNode::convertToNodeSpace(&v98, v79, &v97);
setPosition(v17, &v98);
v20 = cocos2d::CCNode::create();
v20->setContentSize(v20, &stru_AC6E2C);
v16->addChild_0(v16, v20, 1);
v21 = v20->setPosition;
v16->getScaledContentSize((cocos2d::CCSize *)&v96, v16);
v22 = v96.x * 0.5;
v16->getScaledContentSize((cocos2d::CCSize *)&v97, v16);
cocos2d::CCPoint::CCPoint(&v98, v22, v97.y * 0.5);
v21(v20, &v98);
v23 = cocos2d::CCNode::create();
v23->setContentSize(v23, &stru_AC6E2C);
v16->addChild_0(v16, v23, -1);
v24 = v23->setPosition;
v16->getScaledContentSize((cocos2d::CCSize *)&v96, v16);
v25 = v96.x * 0.5;
v16->getScaledContentSize((cocos2d::CCSize *)&v97, v16);
cocos2d::CCPoint::CCPoint(&v98, v25, v97.y * 0.5);
v24(v23, &v98);
v26 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)v81);
v23->addChild_0(v23, v26, -1);
v27 = v26->setPosition;
cocos2d::CCPoint::CCPoint(&v98, 0.0, -10.0);
v27(v26, &v98);
((void (__fastcall *)(cocos2d::CCSprite *, int))v26->setScaleY)(v26, 1067030938);
v26->setColor(v26, &stru_9AC8B0);
v26->setOpacity(v26, 75);
if ( v75 > v77 )
{
v17->setEnabled(v17, 0);
goto LABEL_41;
}
sub_775C20(&v96);
v78 = cocos2d::CCLabelBMFont::create();
sub_774008(&v96);
if ( (v75 & 1) != 0 )
v28 = 120.0;
else
v28 = 80.0;
cocos2d::CCLabelBMFont::limitLabelWidth(v78, v28, 0.5, 0.0);
v20->addChild_0(v20, v78, 3);
v29 = v78->setPosition;
cocos2d::CCPoint::CCPoint(&v98, 0.0, v10 + 40.0);
v29(v78, &v98);
v30 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(v12->m_stars.random - v12->m_stars.seed));
cocos2d::CCString::getCString(v30);
v31 = cocos2d::CCLabelBMFont::create();
setAnchorPoint = v31->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v98, 1.0, 0.5);
setAnchorPoint(v31, &v98);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int))v31->setScale)(v31, 1053609165);
v20->addChild_0(v20, v31, 2);
v33 = v31->setPosition;
cocos2d::CCPoint::CCPoint(&v98, -4.0, -38.0);
v33(v31, &v98);
v34 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_bigStar_001.png");
v35 = v34->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v98, 0.0, 0.5);
v35(v34, &v98);
((void (__fastcall *)(cocos2d::CCSprite *, int))v34->setScale)(v34, 1053609165);
v20->addChild_0(v20, v34, 2);
v36 = v34->setPosition;
cocos2d::CCPoint::CCPoint(&v98, -4.0, -38.0);
v36(v34, &v98);
v37 = GameStatsManager::sharedState();
hasCompletedLevel = GameStatsManager::hasCompletedLevel(v37, v12);
if ( hasCompletedLevel )
{
v40 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_completesIcon_001.png");
v41 = v40->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v98, 0.0, 0.5);
v41(v40, &v98);
v20->addChild_0(v20, v40, 5);
((void (__fastcall *)(cocos2d::CCSprite *, int))v40->setScale)(v40, 1061997773);
v42 = v40->setPosition;
cocos2d::CCPoint::CCPoint(&v98, 8.0, -5.0);
hasCompletedLevel = ((int (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCPoint *))v42)(v40, &v98);
}
if ( v75 == 4 )
{
v49 = cocos2d::CCSprite::createWithSpriteFrameName("miniSkull_001.png");
v20->addChild_0(v20, v49, 4);
((void (__fastcall *)(cocos2d::CCSprite *, int))v49->setScale)(v49, 1067030938);
v50 = v49->setPosition;
cocos2d::CCPoint::CCPoint(&v98, 0.0, 5.0);
hasCompletedLevel = ((int (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCPoint *))v50)(v49, &v98);
if ( !v76 )
goto LABEL_55;
}
else
{
if ( !v76 )
goto LABEL_54;
v49 = nullptr;
}
v51 = (cocos2d::CCArray *)cocos2d::CCArray::create((cocos2d::CCArray *)hasCompletedLevel);
a1->m_activeObjects = v51;
cocos2d::CCObject::retain(v51);
cocos2d::CCArray::addObject(a1->m_activeObjects, v78);
cocos2d::CCArray::addObject(a1->m_activeObjects, v31);
cocos2d::CCArray::addObject(a1->m_activeObjects, v34);
if ( v49 )
cocos2d::CCArray::addObject(a1->m_activeObjects, v49);
for ( k = 0; k < cocos2d::CCArray::count(a1->m_activeObjects); ++k )
{
v53 = cocos2d::CCArray::objectAtIndex(a1->m_activeObjects, k);
(*(void (__fastcall **)(int, _DWORD))(*(_DWORD *)v53 + 164))(v53, 0);
}
v54 = v17->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_activeItemButton = v17;
v54->setEnabled(v17, 0);
v55 = (cocos2d::CCSequence *)cocos2d::CCDelayTime::create(2.0);
v101 = GauntletLayer::unlockActiveItem;
v102 = 0;
v56 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCCallFunc::create(a1, GauntletLayer::unlockActiveItem, 0);
v57 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v55, v56, 0);
cocos2d::CCNode::runAction(a1, v57);
LABEL_54:
v43 = v75;
if ( v75 )
{
LABEL_55:
if ( (v75 & 1) != 0 )
v58 = &v85;
else
v58 = (const cocos2d::CCPoint *)v86;
cocos2d::CCPoint::CCPoint(&v87, v58);
v87.y = v87.y - 2.0;
if ( (v75 & 1) != 0 )
v59 = v87.x + 27.0;
else
v59 = v87.x - 27.0;
v87.x = v59;
cocos2d::CCPoint::CCPoint(&v88, -2.0, -1.0);
cocos2d::CCPoint::CCPoint(&v89, 10.0, 2.5);
cocos2d::CCPoint::CCPoint(&v90, 21.0, 11.5);
cocos2d::CCPoint::CCPoint(&v91, 25.0, 26.0);
cocos2d::CCPoint::CCPoint(&v92, 20.5, 41.0);
cocos2d::CCPoint::CCPoint(&v93, 15.0, 56.0);
cocos2d::CCPoint::CCPoint(&v94, 10.5, 71.0);
cocos2d::CCPoint::CCPoint(&v95, 14.5, 85.5);
cocos2d::CCPoint::CCPoint(&v96, 25.0, 96.0);
for ( m = 1; m != 9; ++m )
{
cocos2d::CCPoint::CCPoint(&v97);
switch ( m )
{
case 2:
v44 = &v90;
break;
case 3:
v44 = &v91;
break;
case 4:
v44 = &v92;
break;
case 5:
v44 = &v93;
break;
case 6:
v44 = &v94;
break;
case 7:
v44 = &v95;
break;
case 8:
v44 = &v96;
break;
default:
v44 = &v89;
break;
}
cocos2d::CCPoint::operator=((PlayerObject *)&v97, *(float *)&v44, v60, m - 2);
if ( (v75 & 1) == 0 )
v97.x = -v97.x;
cocos2d::CCPoint::operator+(&v98, &v87, &v97);
v45 = cocos2d::CCSprite::createWithSpriteFrameName("uiDot_001.png");
a1->addChild_0(a1, v45, 1);
v46 = 0.7;
setColor = v45->setColor;
if ( (m & 1) != 0 )
v46 = 0.6;
v80[0] = (unsigned int)(float)(v46 * 255.0);
v80[1] = v80[0];
v80[2] = v80[0];
setColor(v45, (const cocos2d::ccColor3B *)v80);
v45->setPosition(v45, &v98);
v43 = v76;
if ( v76 )
{
v45->setOpacity(v45, 0);
v61 = COERCE_FLOAT(((int (__fastcall *)(cocos2d::CCSprite *))v45->getScale)(v45));
((void (__fastcall *)(cocos2d::CCSprite *, _DWORD))v45->setScale)(v45, v61 * 2.5);
v63 = (cocos2d::CCActionInterval *)cocos2d::CCScaleTo::create((cocos2d::CCScaleTo *)0x3E99999A, v61, v62);
v64 = cocos2d::CCEaseBounceOut::create(v63);
v65 = cocos2d::CCFadeIn::create(0.1);
r = v45->getColor(v45)->r;
g = v45->getColor(v45)->g;
v68 = (int)v45->getColor(v45);
v69 = cocos2d::CCTintTo::create(0.5, r, g, *(_BYTE *)(v68 + 2));
v45->setColor(v45, &stru_9AC8A4);
v70 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCSpawn::create((cocos2d::CCSpawn *)v64, v65, v69, 0, v74);
if ( (v75 & 1) != 0 )
v71 = m;
else
v71 = 9 - m;
v72 = (cocos2d::CCSequence *)cocos2d::CCDelayTime::create((float)((float)v71 * 0.15) + 0.65);
v73 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v72, v70, 0);
cocos2d::CCNode::runAction(v45, v73);
}
}
}
LABEL_41:
cocos2d::CCPoint::operator=((PlayerObject *)&v85, COERCE_FLOAT(v86), v39, v43);
if ( ++v75 == 5 )
{
sub_774008(v82);
sub_774008(&v81);
return;
}
}
}
}