//
// PlayLayer::setupHasCompleted from 0x1000add40 to 0x1000ae9ea (3242 bytes)
//
// 1 xrefs:
// > PlayLayer::processCreateObjectsFromSetup @ 0x1000adc08
//
// 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 __fastcall PlayLayer::setupHasCompleted(PlayLayer *a1)
{
__m128 v1; // xmm1
__m128 v2; // xmm3
GJGameLevel *m_level; // rax
std::string *p_m_capacityString; // rax
LevelSettingsObject *m_levelSettings; // rax
LevelSettingsObject *v7; // rax
bool m_isPlatformer; // dl
ColorAction *ColorAction; // rax
PlayerObject *m_player1; // rcx
__int16 v11; // dx
ColorAction *v12; // rax
PlayerObject *v13; // rcx
__int16 v14; // dx
GameManager *v15; // rax
GameManager *v16; // r14
GameManager *v17; // rax
LevelSettingsObject *v18; // rax
int m_middleGroundIndex; // esi
PlayerObject *v20; // rax
__m128 v21; // xmm0
cocos2d::CCParticleSystemQuad *m_glitterParticles; // rdi
cocos2d::CCParticleSystemQuad *v23; // rdi
FMODAudioEngine *v24; // r14
_BOOL8 m_dontReset; // r9
int m_songID; // r14d
FMODAudioEngine *v27; // rax
MusicDownloadManager *v28; // rax
FMODAudioEngine *v29; // rax
AudioEffectsLayer *m_audioEffectsLayer; // rax
GameManager *v31; // r14
GameManager *v32; // rax
const char *FontFile; // rax
cocos2d::CCLabelBMFont *v34; // rax
cocos2d::CCLabelBMFont *v35; // rax
cocos2d::CCLabelBMFont *m_infoLabel; // r14
cocos2d::CCLabelBMFont *v37; // r14
unsigned int v38; // r14d
unsigned int v39; // eax
int v40; // ecx
int v41; // r8d
int v42; // r9d
cocos2d::CCAction *v43; // rax
cocos2d::CCSprite *v44; // rax
cocos2d::CCSprite *v45; // rax
cocos2d::CCTexture2D *v46; // rax
cocos2d::CCSprite *m_progressFill; // rdi
PlayerObject *v48; // rax
__int16 v49; // cx
cocos2d::CCSprite *v50; // r14
cocos2d::CCSprite *v51; // r14
cocos2d::CCSprite *m_progressBar; // r14
cocos2d::CCLabelBMFont *v53; // rax
cocos2d::CCLabelBMFont *m_percentageLabel; // r14
cocos2d::CCLabelBMFont *v55; // r14
bool v56; // al
LevelSettingsObject **v57; // r15
_BOOL4 v58; // r14d
StartPosObject *m_startPosObject; // rax
LevelSettingsObject **p_m_startSettings; // rcx
double v61; // xmm0_8
GameManager *v62; // rax
ObjectToolbox *v63; // rax
const char *v64; // r15
size_t v65; // rax
size_t v66; // r14
__int8 *v67; // r12
size_t v68; // r13
GameObject *v69; // rax
GameObject *m_anticheatSpike; // r14
char v71; // r15
GameObject *v72; // r14
GameObject *v73; // r14
double v74; // xmm0_8
GameObject *v75; // rsi
cocos2d::CCLabelBMFont *m_attemptLabel; // r14
unsigned int v77; // r14d
unsigned int v78; // eax
int v79; // ecx
int v80; // r8d
int v81; // r9d
cocos2d::CCAction *v82; // rsi
cocos2d::CCLabelBMFont *m_statusLabel; // rdi
bool m_isTestMode; // al
const char *v85; // rsi
FMODAudioEngine *v86; // rax
__int128 v87; // [rsp+0h] [rbp-100h] BYREF
_BYTE v88[16]; // [rsp+10h] [rbp-F0h] BYREF
void *v89; // [rsp+20h] [rbp-E0h]
_BYTE v90[16]; // [rsp+28h] [rbp-D8h] BYREF
void *v91; // [rsp+38h] [rbp-C8h]
__int128 v92; // [rsp+40h] [rbp-C0h] BYREF
void *__p; // [rsp+50h] [rbp-B0h]
__m128 v94; // [rsp+60h] [rbp-A0h] BYREF
void *v95; // [rsp+70h] [rbp-90h]
__m128 v96; // [rsp+80h] [rbp-80h] BYREF
void *v97; // [rsp+90h] [rbp-70h]
LevelSettingsObject **p_m_levelSettings; // [rsp+A0h] [rbp-60h]
_BYTE v99[8]; // [rsp+ACh] [rbp-54h] BYREF
float v100; // [rsp+B4h] [rbp-4Ch] BYREF
float v101; // [rsp+B8h] [rbp-48h]
float v102; // [rsp+BCh] [rbp-44h]
__m128 __dst; // [rsp+C0h] [rbp-40h] BYREF
void *v104; // [rsp+D0h] [rbp-30h]
double v105; // 0:xmm0_8.8
cocos2d::CCDirector::sharedDirector();
*(cocos2d::CCSize *)&v105 = cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)&v100);
GJBaseGameLayer::createTextLayers(a1);
GJBaseGameLayer::updateSpecialGroupData(a1);
PlayLayer::optimizeColorGroups(a1);
PlayLayer::optimizeOpacityGroups(a1);
PlayLayer::scanDynamicSaveObjects(a1);
PlayLayer::scanActiveSaveObjects(a1);
m_level = a1->m_level;
if ( (m_level->m_capacityString.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(
&v92,
m_level->m_capacityString.m_data.m_long.longStorage,
m_level->m_capacityString.m_data.m_long.size,
v105);
}
else
{
p_m_capacityString = &m_level->m_capacityString;
__p = p_m_capacityString->m_data.m_long.longStorage;
v92 = *(_OWORD *)&p_m_capacityString->m_data.m_short.sizex2;
}
GJBaseGameLayer::updateLayerCapacity(a1, &v92);
if ( (v92 & 1) != 0 )
operator delete(__p);
GJBaseGameLayer::increaseBatchNodeCapacity(a1);
m_levelSettings = a1->m_levelSettings;
if ( !m_levelSettings )
{
v7 = LevelSettingsObject::create();
a1->m_levelSettings = v7;
v7->m_level = a1->m_level;
cocos2d::CCObject::retain(v7);
m_levelSettings = a1->m_levelSettings;
}
m_isPlatformer = a1->m_isPlatformer;
a1->m_player1->m_isPlatformer = m_isPlatformer;
a1->m_player2->m_isPlatformer = m_isPlatformer;
ColorAction = GJEffectManager::getColorAction(m_levelSettings->m_effectManager, 1005);
ColorAction->m_duration = 0.0;
m_player1 = a1->m_player1;
v11 = *(_WORD *)&m_player1->m_playerColor1.r;
ColorAction->m_fromColor.b = m_player1->m_playerColor1.b;
*(_WORD *)&ColorAction->m_fromColor.r = v11;
ColorAction->m_blending = 1;
v12 = GJEffectManager::getColorAction(a1->m_levelSettings->GJBaseGameLayer::m_effectManager, 1006);
v12->m_duration = 0.0;
v13 = a1->m_player1;
v14 = *(_WORD *)&v13->m_playerColor2.r;
v12->m_fromColor.b = v13->m_playerColor2.b;
*(_WORD *)&v12->m_fromColor.r = v14;
v12->m_blending = 1;
v15 = GameManager::sharedState();
if ( v15->m_playerDeathEffect.random > v15->m_playerDeathEffect.seed )
{
v16 = GameManager::sharedState();
v17 = GameManager::sharedState();
GameManager::loadDeathEffect(v16, v17->m_playerDeathEffect.random - v17->m_playerDeathEffect.seed);
}
GJBaseGameLayer::createBackground(a1, a1->m_levelSettings->m_backgroundIndex);
v18 = a1->m_levelSettings;
m_middleGroundIndex = v18->m_middleGroundIndex;
if ( m_middleGroundIndex > 0 )
{
GJBaseGameLayer::createMiddleground(a1, m_middleGroundIndex);
v18 = a1->m_levelSettings;
}
GJBaseGameLayer::createGroundLayer(a1, v18->m_groundIndex, v18->m_groundLineIndex);
UILayer::togglePlatformerMode(a1->m_uiLayer, a1->m_isPlatformer);
v20 = a1->m_player1;
v21 = 0;
v21.f32[0] = (float)v20->m_playerColor1.b;
LODWORD(v20) = *(unsigned __int16 *)&v20->m_playerColor1.r;
v1.f32[0] = (float)(unsigned __int8)v20 / 255.0;
v2.f32[0] = (float)((unsigned int)v20 >> 8) / 255.0;
v21.f32[0] = v21.f32[0] / 255.0;
m_glitterParticles = a1->m_glitterParticles;
__dst = _mm_movelh_ps(_mm_insert_ps(v1, v2, 16), _mm_blend_ps(v21, (__m128)xmmword_1008150D0, 14));
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *, __m128 *))m_glitterParticles->setStartColor)(
m_glitterParticles,
&__dst);
v23 = a1->m_glitterParticles;
__dst = _mm_loadh_ps((const double *)&qword_100815CD0);
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *, __m128 *))v23->setEndColor)(v23, &__dst);
GJBaseGameLayer::resetPlayer(a1);
v24 = FMODAudioEngine::sharedEngine();
GJGameLevel::getAudioFileName(v88, a1->m_level);
m_dontReset = a1->m_levelSettings->m_dontReset;
v102 = 1.0;
FMODAudioEngine::loadMusic(v24, v88, 1, 0, 0, m_dontReset, 1.0, 0.0, 1.0);
if ( (v88[0] & 1) != 0 )
operator delete(v89);
m_songID = a1->m_levelSettings->GJBaseGameLayer::m_level->m_songID;
if ( m_songID || a1->m_level->m_audioTrack >= 20 )
{
v27 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::enableMetering(v27);
a1->m_skipAudioStep = 1;
v28 = MusicDownloadManager::sharedState();
MusicDownloadManager::incrementPriorityForSong(v28, m_songID);
}
else
{
v86 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::disableMetering(v86);
}
v29 = FMODAudioEngine::sharedEngine();
a1->m_isSilent = FMODAudioEngine::getBackgroundMusicVolume(v29) <= 0.0;
LevelTools::getAudioString(v90, (unsigned int)a1->m_level->m_audioTrack);
m_audioEffectsLayer = (AudioEffectsLayer *)AudioEffectsLayer::create(v90);
a1->m_audioEffectsLayer = m_audioEffectsLayer;
if ( (v90[0] & 1) != 0 )
{
operator delete(v91);
m_audioEffectsLayer = a1->m_audioEffectsLayer;
}
p_m_levelSettings = &a1->m_levelSettings;
((void (__fastcall *)(cocos2d::CCLayer *, AudioEffectsLayer *, __int64))a1->m_objectLayer->addChild_0)(
a1->m_objectLayer,
m_audioEffectsLayer,
1);
((void (__fastcall *)(AudioEffectsLayer *, _QWORD))a1->m_audioEffectsLayer->setVisible)(a1->m_audioEffectsLayer, 0);
v31 = GameManager::sharedState();
v32 = GameManager::sharedState();
FontFile = GameManager::getFontFile(v31, v32->m_loadedFont);
v34 = cocos2d::CCLabelBMFont::create_3("Attempt 1", FontFile);
a1->m_attemptLabel = v34;
((void (__fastcall *)(cocos2d::CCLayer *, cocos2d::CCLabelBMFont *, __int64))a1->m_objectLayer->addChild_0)(
a1->m_objectLayer,
v34,
1400);
if ( a1->m_doNot )
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))a1->m_attemptLabel->setScaleY)(a1->m_attemptLabel, -1.0);
v35 = cocos2d::CCLabelBMFont::create_3("", "chatFont.fnt");
a1->m_infoLabel = v35;
((void (__fastcall *)(PlayLayer *, cocos2d::CCLabelBMFont *, __int64))a1->addChild_0)(a1, v35, 1000);
m_infoLabel = a1->m_infoLabel;
sub_10028CBE0(&__dst, 0.0, 1.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __m128 *))m_infoLabel->setAnchorPoint)(m_infoLabel, &__dst);
v37 = a1->m_infoLabel;
sub_10028CBE0(&v87, 0.0, 0.0);
sub_10028CBE0(v99, 5.0, v101 + -10.0);
sub_10028CCE0(&__dst, &v87);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __m128 *))v37->setPosition)(v37, &__dst);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __int64))a1->m_infoLabel->setOpacity)(a1->m_infoLabel, 150);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))a1->m_infoLabel->setScale)(a1->m_infoLabel, 0.5);
PlayLayer::updateInfoLabel(a1);
((void (__fastcall *)(PlayLayer *))a1->toggleInfoLabel)(a1);
if ( a1->m_levelSettings->m_twoPlayerMode
&& !a1->m_isTestMode
&& a1->m_level->m_levelType != Editor
&& !a1->m_isPlatformer )
{
((void (__fastcall *)(cocos2d::CCLabelBMFont *, _QWORD))a1->m_attemptLabel->setVisible)(a1->m_attemptLabel, 0);
v38 = (unsigned int)cocos2d::CCDelayTime::create(0.5);
v39 = (unsigned int)cocos2d::CCCallFunc::create(
a1,
(cocos2d::SEL_CallFunc)(unsigned __int64)PlayLayer::showTwoPlayerGuide);
v43 = (cocos2d::CCAction *)sub_1003B5760(v38, v39, 0, v40, v41, v42);
cocos2d::CCNode::runAction(a1, v43);
v102 = 2.0;
}
*(_WORD *)&a1->m_freezeStartCamera = 257;
a1->m_skipArtReload = 1;
GJBaseGameLayer::updateCamera(a1, 0.0);
v44 = cocos2d::CCSprite::create_1("slidergroove2.png");
a1->m_progressBar = v44;
((void (__fastcall *)(PlayLayer *, cocos2d::CCSprite *, __int64))a1->addChild_0)(a1, v44, 10);
v45 = cocos2d::CCSprite::create_1("sliderBar2.png");
a1->m_progressFill = v45;
a1->m_progressWidth = a1->m_progressBar->m_obRect.size.width + -4.0;
a1->m_progressHeight = 8.0;
v87 = xmmword_100815E00;
v46 = (cocos2d::CCTexture2D *)((__int64 (__fastcall *)(cocos2d::CCSprite *))v45->getTexture)(v45);
cocos2d::CCTexture2D::setTexParameters(v46, (cocos2d::ccTexParams *)&v87);
m_progressFill = a1->m_progressFill;
v48 = a1->m_player1;
v49 = *(_WORD *)&v48->m_playerColor1.r;
__dst.i8[2] = v48->m_playerColor1.b;
__dst.i16[0] = v49;
((void (__fastcall *)(cocos2d::CCSprite *, __m128 *))m_progressFill->setColor)(m_progressFill, &__dst);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCSprite *, __int64))a1->m_progressBar->addChild_0)(
a1->m_progressBar,
a1->m_progressFill,
0xFFFFFFFFLL);
v50 = a1->m_progressFill;
sub_10028CBE0(&__dst, 0.0, 0.0);
((void (__fastcall *)(cocos2d::CCSprite *, __m128 *))v50->setAnchorPoint)(v50, &__dst);
v51 = a1->m_progressFill;
sub_10028CBE0(&__dst, 2.0, 4.0);
((void (__fastcall *)(cocos2d::CCSprite *, __m128 *))v51->setPosition)(v51, &__dst);
m_progressBar = a1->m_progressBar;
sub_10028CBE0(&__dst, v100 * 0.5, v101 + -8.0);
((void (__fastcall *)(cocos2d::CCSprite *, __m128 *))m_progressBar->setPosition)(m_progressBar, &__dst);
v53 = cocos2d::CCLabelBMFont::create_3("100%", "bigFont.fnt");
a1->m_percentageLabel = v53;
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))v53->setScale)(v53, 0.5);
((void (__fastcall *)(PlayLayer *, cocos2d::CCLabelBMFont *, __int64))a1->addChild_0)(a1, a1->m_percentageLabel, 15);
m_percentageLabel = a1->m_percentageLabel;
sub_10028CBE0(&__dst, (float)(v100 * 0.5) + 110.0, v101 + -8.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __m128 *))m_percentageLabel->setPosition)(m_percentageLabel, &__dst);
v55 = a1->m_percentageLabel;
sub_10028CBE0(&__dst, 0.0, 0.5);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __m128 *))v55->setAnchorPoint)(v55, &__dst);
PlayLayer::updateProgressbar(a1);
((void (__fastcall *)(PlayLayer *))a1->toggleProgressbar)(a1);
v56 = 1;
if ( a1->m_isTestMode )
{
v57 = p_m_levelSettings;
}
else
{
v57 = p_m_levelSettings;
if ( !(*p_m_levelSettings)->m_propertykA24 )
v56 = (*p_m_levelSettings)->m_spawnGroup > 0;
}
v58 = v56;
((void (__fastcall *)(PlayerObject *, bool))a1->m_player1->setVisible)(a1->m_player1, v56);
((void (__fastcall *)(PlayerObject *, _BOOL4))a1->m_player2->setVisible)(a1->m_player2, v58);
PlayLayer::loadDefaultColors(a1);
GJBaseGameLayer::updateLevelColors(a1);
m_startPosObject = a1->m_startPosObject;
p_m_startSettings = &m_startPosObject->m_startSettings;
if ( !m_startPosObject )
p_m_startSettings = v57;
GJBaseGameLayer::setupLevelStart(a1, *p_m_startSettings);
a1->m_objectsDeactivated = 1;
((void (__fastcall *)(PlayLayer *, double))a1->updateVisibility)(a1, 0.0);
v61 = 0.0;
GJBaseGameLayer::updateCamera(a1, 0.0);
((void (__fastcall *)(PlayLayer *, _QWORD))a1->toggleGlitter)(a1, 0);
v62 = GameManager::sharedState();
a1->m_disableGravityEffect = GameManager::getGameVariable(v62, "0072");
v63 = ObjectToolbox::sharedState();
v64 = ObjectToolbox::intKeyToFrame(v63, 8);
v65 = strlen(v64);
if ( v65 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(0.0);
v66 = v65;
if ( v65 >= 0x17 )
{
v68 = 26;
if ( (v65 | 7) != 0x17 )
v68 = (v65 | 7) + 1;
v67 = (__int8 *)operator new(v68);
v104 = v67;
__dst.i64[0] = v68 + 1;
__dst.i64[1] = v66;
goto LABEL_39;
}
__dst.i8[0] = 2 * v65;
v67 = &__dst.i8[1];
if ( v65 )
LABEL_39:
memmove(v67, v64, v66);
v67[v66] = 0;
v69 = GameObject::createWithKey(8);
a1->m_anticheatSpike = v69;
((void (__fastcall *)(GameObject *))v69->customSetup)(v69);
m_anticheatSpike = a1->m_anticheatSpike;
v71 = __dst.i8[0] & 1;
if ( (__dst.i8[0] & 1) != 0 )
{
sub_100006B70(&v94, v104, __dst.u64[1], 0.0);
}
else
{
v95 = v104;
v61 = *(double *)__dst.i64;
v94 = __dst;
}
GameObject::addColorSprite(m_anticheatSpike, &v94);
if ( (v94.i8[0] & 1) != 0 )
operator delete(v95);
v72 = a1->m_anticheatSpike;
if ( v71 )
{
sub_100006B70(&v96, v104, __dst.u64[1], v61);
}
else
{
v97 = v104;
v96 = __dst;
}
((void (__fastcall *)(GameObject *, __m128 *))v72->setupCustomSprites)(v72, &v96);
if ( (v96.i8[0] & 1) != 0 )
operator delete(v97);
v73 = a1->m_anticheatSpike;
((void (__fastcall *)(PlayerObject *))a1->m_player1->getPosition)(a1->m_player1);
v74 = sub_10028CC60(v99);
((void (__fastcall *)(GameObject *, _BYTE *, double))v73->setStartPos)(v73, v99, v74);
v75 = a1->m_anticheatSpike;
v75->m_bDontDraw = 1;
PlayLayer::addObject(a1, v75);
GJBaseGameLayer::createPlayerCollisionBlock(a1);
m_attemptLabel = a1->m_attemptLabel;
sub_10028CBE0(
v99,
(float)(v100 * 0.5) + a1->m_gameState.m_cameraPosition.x,
(float)((float)(0.5 * v101) + a1->m_gameState.m_cameraPosition.y) + 85.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, _BYTE *))m_attemptLabel->setPosition)(m_attemptLabel, v99);
if ( a1->m_isTestMode )
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __int64))a1->m_attemptLabel->setOpacity)(a1->m_attemptLabel, 50);
a1->m_freezeStartCamera = 1;
((void (__fastcall *)(PlayLayer *))a1->resetLevel)(a1);
a1->m_started = 0;
PlayLayer::prepareMusic(a1, 0);
if ( a1->m_passedIntegrity )
{
v77 = (unsigned int)cocos2d::CCDelayTime::create(v102);
v78 = (unsigned int)cocos2d::CCCallFunc::create(a1, (cocos2d::SEL_CallFunc)(unsigned __int64)PlayLayer::startGame);
}
else
{
v77 = (unsigned int)cocos2d::CCDelayTime::create(v102);
v78 = (unsigned int)cocos2d::CCCallFunc::create(a1, (cocos2d::SEL_CallFunc)(unsigned __int64)PlayLayer::onQuit);
}
v82 = (cocos2d::CCAction *)sub_1003B5760(v77, v78, 0, v79, v80, v81);
cocos2d::CCNode::runAction(a1, v82);
cocos2d::CCNode::scheduleUpdate(a1);
GJBaseGameLayer::checkSpawnObjects(a1);
GJEffectManager::updateEffects(a1->m_effectManager, 0.0);
((void (__fastcall *)(PlayLayer *, double))a1->updateVisibility)(a1, 0.0);
GJBaseGameLayer::updateLevelColors(a1);
GJBaseGameLayer::updateProximityVolumeEffects(a1);
m_statusLabel = a1->m_statusLabel;
if ( m_statusLabel )
{
m_isTestMode = 1;
if ( !a1->m_isIgnoreDamageEnabled )
m_isTestMode = a1->m_isTestMode;
((void (__fastcall *)(cocos2d::CCLabelBMFont *, bool))m_statusLabel->setVisible)(m_statusLabel, m_isTestMode);
if ( a1->m_ignoreDamage )
{
v85 = "Ignore Damage";
}
else if ( a1->m_isIgnoreDamageEnabled )
{
v85 = "Used Ignore Damage";
}
else
{
if ( !a1->m_isTestMode )
goto LABEL_66;
v85 = "Testmode";
}
((void (__fastcall *)(cocos2d::CCLabelBMFont *, const char *))a1->m_statusLabel->setString)(a1->m_statusLabel, v85);
}
LABEL_66:
if ( GJBaseGameLayer::shouldExitHackedLevel(a1) )
{
PlayLayer::removeAllObjects(a1);
PlayLayer::onQuit(a1);
}
if ( v71 )
operator delete(v104);
}