//
// SecretLayer2::onSecretLevel from 0x93aeb0 to 0x93b0fc (588 bytes)
//
// 3 xrefs:
// > ??> @ 0x31140
// > SecretLayer2::init @ 0x942a50
// > ??> @ 0x1229750
//
// 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 SecretLayer2::onSecretLevel(SecretLayer2 *a1, cocos2d::CCObject *a2)
{
GameStatsManager *v3; // x0
DialogObject *v4; // x0
DialogLayer *v5; // x21
void *v6; // x0
void *v7; // x0
GameLevelManager *v8; // x0
GJGameLevel *MainLevel; // x21
cocos2d::CCDirector *v10; // x20
cocos2d::CCScene *v11; // x0
cocos2d::CCTransitionFade *v12; // x0
unsigned int *v13; // x1
int v14; // w2
unsigned int *v15; // x1
int v16; // w2
__int64 v17; // [xsp+58h] [xbp+58h] BYREF
__int64 v18; // [xsp+60h] [xbp+60h] BYREF
v3 = GameStatsManager::sharedState();
if ( GameStatsManager::getStat(v3, "13") > 199 )
{
v8 = GameLevelManager::sharedState();
MainLevel = GameLevelManager::getMainLevel(v8, 3001, 0);
GameManager::sharedState()->m_sceneEnum = 12;
v10 = cocos2d::CCDirector::sharedDirector();
v11 = PlayLayer::scene(MainLevel, 0, 0);
v12 = cocos2d::CCTransitionFade::create(0.5, v11);
cocos2d::CCDirector::replaceScene(v10, v12);
}
else
{
sub_D153B8((int)&v17, "The Keymaster");
sub_D153B8((int)&v18, "You are not prepared.\nCollect more diamonds...");
v4 = (DialogObject *)DialogObject::create(1.0, (__int64)&v17, (__int64)&v18, 2, 0, (int)&unk_FFFFFF);
v5 = DialogLayer::create(v4, (int)&dword_0 + 2);
v6 = (void *)(v18 - 24);
if ( (__int64 *)(v18 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v15 = (unsigned int *)(v18 - 8);
do
v16 = __ldaxr(v15);
while ( __stlxr(v16 - 1, v15) );
}
else
{
v16 = *(_DWORD *)(v18 - 8);
*(_DWORD *)(v18 - 8) = v16 - 1;
}
if ( v16 <= 0 )
operator delete(v6);
}
v7 = (void *)(v17 - 24);
if ( (__int64 *)(v17 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v13 = (unsigned int *)(v17 - 8);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *(_DWORD *)(v17 - 8);
*(_DWORD *)(v17 - 8) = v14 - 1;
}
if ( v14 <= 0 )
operator delete(v7);
}
a1->addChild_0(a1, v5, 100);
DialogLayer::updateChatPlacement(v5, Center);
DialogLayer::animateInRandomSide(v5);
}
}