//
// SecretLayer4::init from 0x10039a080 to 0x10039ac2f (2991 bytes)
//
// 2 xrefs:
// > SecretLayer4::create @ 0x10039a045
// > ??> @ 0x100b31a10
//
// 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 12:29:18 +0000
//
__int64 __fastcall SecretLayer4::init(__int64 a1, double a2)
{
__int64 result; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rsi
_QWORD *v8; // rax
_QWORD *v9; // rdi
__int64 v10; // rax
const char *v11; // rsi
__int64 v12; // rdi
__int64 v13; // r14
char *v14; // r15
__int64 v15; // rax
const char *v16; // rsi
__int64 v17; // rdi
__int64 v18; // r14
char *v19; // r15
__int64 v20; // rax
const char *v21; // rsi
__int64 v22; // rdi
__int64 v23; // r14
char *v24; // r15
__int64 v25; // rax
const char *v26; // rsi
__int64 v27; // rdi
__int64 v28; // r14
char *v29; // r15
__int64 v30; // rax
const char *v31; // rsi
__int64 v32; // rdi
__int64 v33; // r14
char *v34; // r15
__int64 v35; // rax
const char *v36; // rsi
__int64 v37; // rdi
__int64 v38; // r14
char *v39; // r15
__int64 v40; // rax
__int64 v41; // r14
void *v42; // r15
__int64 v43; // rax
int v44; // r14d
int v45; // eax
int v46; // ecx
int v47; // r8d
int v48; // r9d
__int64 v49; // rax
float *v50; // r14
__int64 v51; // r14
__int64 v52; // rax
__int64 v53; // r15
__int64 v54; // rdi
std::string::pointer data; // rsi
__int64 v56; // r15
void *v57; // rax
_QWORD *v58; // rdi
__int64 v59; // r14
double v60; // xmm0_8
char *v61; // rax
void *v62; // r15
int v63; // edx
int v64; // ecx
int v65; // r8d
int v66; // r9d
__int64 v67; // r14
__int64 v68; // rdi
__int64 v69; // rax
double v70; // xmm0_8
double v71; // xmm0_8
void *v72; // r15
double v73; // xmm0_8
char *v74; // r12
void *v75; // rax
__int64 v76; // r15
double v77; // xmm1_8
__int64 v78; // rax
bool isSpecialChestUnlocked; // r14
__int64 v80; // r14
__int64 v81; // rax
__int64 RewardForSpecialChest; // r15
_QWORD *v83; // r15
char *v84; // rbx
__int64 v85; // rax
unsigned __int64 v86; // [rsp+0h] [rbp-100h] BYREF
__m128 v87; // [rsp+8h] [rbp-F8h] BYREF
unsigned int v88; // [rsp+18h] [rbp-E8h] BYREF
void *v89[3]; // [rsp+20h] [rbp-E0h] BYREF
std::string v90; // [rsp+38h] [rbp-C8h] BYREF
char v91; // [rsp+50h] [rbp-B0h] BYREF
char v92[15]; // [rsp+51h] [rbp-AFh] BYREF
void *v93; // [rsp+60h] [rbp-A0h]
char v94; // [rsp+68h] [rbp-98h] BYREF
char v95[15]; // [rsp+69h] [rbp-97h] BYREF
void *v96; // [rsp+78h] [rbp-88h]
std::string v97; // [rsp+80h] [rbp-80h] BYREF
std::string __str; // [rsp+98h] [rbp-68h] BYREF
unsigned __int64 v99[2]; // [rsp+B0h] [rbp-50h] BYREF
unsigned __int64 v100; // [rsp+C0h] [rbp-40h] BYREF
float v101; // [rsp+C8h] [rbp-38h] BYREF
float v102; // [rsp+CCh] [rbp-34h]
float v103; // [rsp+D0h] [rbp-30h]
unsigned __int8 v104; // [rsp+D7h] [rbp-29h]
result = cocos2d::CCLayer::init(a1);
if ( !(_BYTE)result )
return result;
v104 = result;
v4 = cocos2d::CCTextureCache::sharedTextureCache(a1);
cocos2d::CCTextureCache::addImage(v4, "SecretSheet.png", 0);
v5 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile_2(v5, "SecretSheet.plist", a2);
v6 = GameManager::sharedState();
strcpy((char *)v89, " secretLoop03.mp3");
GameManager::fadeInMusic(*(__m128 *)"secretLoop03.mp3", v6, (unsigned __int8 *)v89);
if ( ((__int64)v89[0] & 1) != 0 )
operator delete(v89[2]);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1072LL))(a1, 1);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1088LL))(a1, 1);
v7 = cocos2d::CCDirector::sharedDirector(a1, 1);
cocos2d::CCDirector::getWinSize(&v101, v7);
v8 = cocos2d::CCDictionary::create();
*(_QWORD *)(a1 + 480) = v8;
v9 = v8;
cocos2d::CCObject::retain(v8);
v10 = AchievementManager::sharedState(v9, v7);
v11 = "geometry.ach.v3.secret01";
v12 = v10;
if ( !(unsigned __int8)AchievementManager::isAchievementEarned(v10, "geometry.ach.v3.secret01") )
{
v13 = *(_QWORD *)(a1 + 480);
v14 = (char *)cocos2d::CCNode::create();
(*(void (__fastcall **)(char *, __int64))(*(_QWORD *)v14 + 72LL))(v14, 1);
v12 = v13;
v11 = v14;
cocos2d::CCDictionary::setObject_1(v13, (__int64)v14, 1);
}
v15 = AchievementManager::sharedState(v12, v11);
v16 = "geometry.ach.v3.secret02";
v17 = v15;
if ( !(unsigned __int8)AchievementManager::isAchievementEarned(v15, "geometry.ach.v3.secret02") )
{
v18 = *(_QWORD *)(a1 + 480);
v19 = (char *)cocos2d::CCNode::create();
(*(void (__fastcall **)(char *, __int64))(*(_QWORD *)v19 + 72LL))(v19, 2);
v17 = v18;
v16 = v19;
cocos2d::CCDictionary::setObject_1(v18, (__int64)v19, 2);
}
v20 = AchievementManager::sharedState(v17, v16);
v21 = "geometry.ach.v3.secret03";
v22 = v20;
if ( !(unsigned __int8)AchievementManager::isAchievementEarned(v20, "geometry.ach.v3.secret03") )
{
v23 = *(_QWORD *)(a1 + 480);
v24 = (char *)cocos2d::CCNode::create();
(*(void (__fastcall **)(char *, __int64))(*(_QWORD *)v24 + 72LL))(v24, 3);
v22 = v23;
v21 = v24;
cocos2d::CCDictionary::setObject_1(v23, (__int64)v24, 3);
}
v25 = AchievementManager::sharedState(v22, v21);
v26 = "geometry.ach.v3.secret04";
v27 = v25;
if ( !(unsigned __int8)AchievementManager::isAchievementEarned(v25, "geometry.ach.v3.secret04") )
{
v28 = *(_QWORD *)(a1 + 480);
v29 = (char *)cocos2d::CCNode::create();
(*(void (__fastcall **)(char *, __int64))(*(_QWORD *)v29 + 72LL))(v29, 4);
v27 = v28;
v26 = v29;
cocos2d::CCDictionary::setObject_1(v28, (__int64)v29, 4);
}
v30 = AchievementManager::sharedState(v27, v26);
v31 = "geometry.ach.v3.secret05";
v32 = v30;
if ( !(unsigned __int8)AchievementManager::isAchievementEarned(v30, "geometry.ach.v3.secret05") )
{
v33 = *(_QWORD *)(a1 + 480);
v34 = (char *)cocos2d::CCNode::create();
(*(void (__fastcall **)(char *, __int64))(*(_QWORD *)v34 + 72LL))(v34, 5);
v32 = v33;
v31 = v34;
cocos2d::CCDictionary::setObject_1(v33, (__int64)v34, 5);
}
v35 = AchievementManager::sharedState(v32, v31);
v36 = "geometry.ach.v3.secret06";
v37 = v35;
if ( !(unsigned __int8)AchievementManager::isAchievementEarned(v35, "geometry.ach.v3.secret06") )
{
v38 = *(_QWORD *)(a1 + 480);
v39 = (char *)cocos2d::CCNode::create();
(*(void (__fastcall **)(char *, __int64))(*(_QWORD *)v39 + 72LL))(v39, 6);
v37 = v38;
v36 = v39;
cocos2d::CCDictionary::setObject_1(v38, (__int64)v39, 6);
}
v40 = AchievementManager::sharedState(v37, v36);
if ( !(unsigned __int8)AchievementManager::isAchievementEarned(v40, "geometry.ach.v3.secret07") )
{
v41 = *(_QWORD *)(a1 + 480);
v42 = cocos2d::CCNode::create();
(*(void (__fastcall **)(void *, __int64))(*(_QWORD *)v42 + 72LL))(v42, 7);
cocos2d::CCDictionary::setObject_1(v41, (__int64)v42, 7);
}
v43 = GameManager::sharedState();
if ( !(unsigned __int8)GameManager::getUGV(v43, "9") )
{
v44 = cocos2d::CCDelayTime::create(0.80000001);
v45 = cocos2d::CCCallFunc::create(a1, SecretLayer4::showFirstDialog, 0);
v49 = sub_10039EB60(v44, v45, 0, v46, v47, v48);
cocos2d::CCNode::runAction(a1, v49);
*(_DWORD *)(a1 + 436) = 30;
}
v50 = (float *)cocos2d::CCSprite::create_1((__int64)"GJ_gradientBG.png");
sub_100278250((float *)v99, 0.0, 0.0);
(*(void (__fastcall **)(float *, unsigned __int64 *))(*(_QWORD *)v50 + 296LL))(v50, v99);
(*(void (__fastcall **)(__int64, float *, __int64))(*(_QWORD *)a1 + 464LL))(a1, v50, 4294967293LL);
(*(void (__fastcall **)(float *, float))(*(_QWORD *)v50 + 128LL))(v50, (float)(v101 + 10.0) / v50[108]);
(*(void (__fastcall **)(float *, float))(*(_QWORD *)v50 + 144LL))(v50, (float)(v102 + 10.0) / v50[109]);
sub_100278250((float *)v99, -5.0, -5.0);
(*(void (__fastcall **)(float *, unsigned __int64 *))(*(_QWORD *)v50 + 184LL))(v50, v99);
strcpy((char *)v99, "K\n");
(*(void (__fastcall **)(float *, unsigned __int64 *))(*(_QWORD *)v50 + 960LL))(v50, v99);
sub_100278270((__int64)v99, 0.0, 0.0, (__m128)0x42200000u, (__m128)0x42200000u);
v51 = cocos2d::CCLabelBMFont::create_3("Chamber of Time", "goldFont.fnt");
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v51 + 160LL))(v51, 1.0);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 456LL))(a1, v51);
sub_100278250(v87.f32, v101 * 0.5, v102 + -24.0);
(*(void (__fastcall **)(__int64, __m128 *))(*(_QWORD *)v51 + 184LL))(v51, &v87);
sub_100278250((float *)&v86, v101 * 0.5, (float)(v102 * 0.5) + 50.0);
v52 = cocos2d::CCLabelBMFont::create_3(" ", "bigFont.fnt");
*(_QWORD *)(a1 + 464) = v52;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 456LL))(a1, v52);
v53 = *(_QWORD *)(a1 + 464);
sub_100278250((float *)&v100, 0.0, 43.0);
sub_100278350((double *)v87.i64, &v86, &v100);
(*(void (__fastcall **)(__int64, __m128 *))(*(_QWORD *)v53 + 184LL))(v53, &v87);
if ( !*(_DWORD *)(a1 + 440) )
{
v103 = (float)((float)*(int *)(a1 + 448) * -0.050000001) + 1.0;
if ( (float)((float)rand() * 4.6566129e-10) > v103 )
SecretLayer4::selectAThread(a1);
if ( !*(_DWORD *)(a1 + 440) )
{
SecretLayer4::getBasicMessage(&v97, a1);
v54 = *(_QWORD *)(a1 + 464);
if ( (*(_BYTE *)&v97.__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_25;
LABEL_27:
data = v97.__r_.__value_.__s.__data_;
goto LABEL_28;
}
}
SecretLayer4::getThreadMessage(&v97);
v54 = *(_QWORD *)(a1 + 464);
if ( (*(_BYTE *)&v97.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_27;
LABEL_25:
data = v97.__r_.__value_.__l.__data_;
LABEL_28:
(*(void (__fastcall **)(__int64, std::string::pointer))(*(_QWORD *)v54 + 928LL))(v54, data);
cocos2d::CCLabelBMFont::limitLabelWidth(*(_QWORD *)(a1 + 464), 320.0, 0.60000002, 0.0);
if ( (*(_BYTE *)&v97.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v97.__r_.__value_.__l.__data_);
sub_1002787F0(&v87, v99);
v56 = cocos2d::extension::CCScale9Sprite::create_2("square02b_small.png", &v87);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v56 + 912LL))(v56, 100);
sub_100278260(v87.f32, 200.0, 40.0);
(*(void (__fastcall **)(__int64, __m128 *))(*(_QWORD *)v56 + 320LL))(v56, &v87);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v56, 4294967294LL);
(*(void (__fastcall **)(__int64, unsigned __int64 *))(*(_QWORD *)v56 + 184LL))(v56, &v86);
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v56 + 960LL))(v56, &unk_100A08EE8);
v57 = CCTextInputNode::create((__int64)"...", (__int64)"Thonburi", 0x18u, (__int64)"bigFont.fnt", 180.0, 50.0);
*(_QWORD *)(a1 + 456) = v57;
(*(void (__fastcall **)(__int64, void *, __int64))(*(_QWORD *)a1 + 464LL))(a1, v57, 20);
v58 = *(_QWORD **)(a1 + 456);
v58[73] = a1 + 408;
(*(void (__fastcall **)(_QWORD *, unsigned __int64 *))(*v58 + 184LL))(v58, &v86);
CCTextInputNode::setMaxLabelScale(*(_QWORD *)(a1 + 456), 0.69999999);
CCTextInputNode::setMaxLabelWidth(*(_QWORD *)(a1 + 456), 180.0);
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(*(_QWORD *)(a1 + 456) + 576LL) + 344LL))(
*(_QWORD *)(*(_QWORD *)(a1 + 456) + 576LL),
0);
v59 = *(_QWORD *)(a1 + 456);
*(_DWORD *)(v59 + 592) = 100;
v90.__r_.__value_.__r.__words[2] = (std::string::size_type)operator new(0x68u);
v90.__r_.__value_.__r.__words[0] = 105;
v90.__r_.__value_.__l.__size_ = 97;
strcpy(
v90.__r_.__value_.__l.__data_,
" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,-!?:;)(/\\\"'`*=+-_%[]<>|@&^#{}%$~");
CCTextInputNode::setAllowedChars(v59, &v90);
if ( (*(_BYTE *)&v90.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v90.__r_.__value_.__l.__data_);
v60 = sub_10039B200(a1, "");
v61 = cocos2d::CCSprite::createWithSpriteFrameName((__int64)"GJ_arrow_01_001.png", v60);
v62 = CCMenuItemSpriteExtra::create((__int64)v61, 0, a1, (__int64)SecretLayer4::onBack, 0);
CCMenuItemSpriteExtra::setSizeMult((__int64)v62, 1.5);
v67 = sub_1008735E0((_DWORD)v62, 0, v63, v64, v65, v66);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v67, 1);
v68 = cocos2d::CCDirector::sharedDirector(a1, v67);
v103 = sub_100479760(v68) + 24.0;
v69 = cocos2d::CCDirector::sharedDirector(v68, v67);
v70 = sub_100479740(v69);
sub_100278250((float *)&v100, v103, *(float *)&v70 + -23.0);
v71 = (*(double (__fastcall **)(__int64, unsigned __int64 *))(*(_QWORD *)v67 + 184LL))(v67, &v100);
if ( (unsigned __int8)PlatformToolbox::isControllerConnected(v71) )
GameToolbox::addBackButton(a1, v62);
v72 = cocos2d::CCNode::create();
sub_100278260((float *)&v100, 80.0, 80.0);
v73 = (*(double (__fastcall **)(void *, unsigned __int64 *))(*(_QWORD *)v72 + 320LL))(v72, &v100);
v74 = cocos2d::CCSprite::createWithSpriteFrameName((__int64)"GJ_secretLock3_001.png", v73);
(*(void (__fastcall **)(void *, char *))(*(_QWORD *)v72 + 456LL))(v72, v74);
sub_100278250((float *)&v100, 40.0, 40.0);
(*(void (__fastcall **)(char *, unsigned __int64 *))(*(_QWORD *)v74 + 184LL))(v74, &v100);
v75 = CCMenuItemSpriteExtra::create((__int64)v72, 0, a1, (__int64)SecretLayer4::onSubmit, 0);
*(_QWORD *)(a1 + 472) = v75;
(*(void (__fastcall **)(__int64, void *))(*(_QWORD *)v67 + 456LL))(v67, v75);
v76 = *(_QWORD *)(a1 + 472);
*(_QWORD *)&v77 = LODWORD(v102);
*(float *)&v77 = (float)(v102 * 0.5) + -20.0;
sub_100278250((float *)&v88, v101 * 0.5, *(float *)&v77);
cocos2d::CCNode::convertToNodeSpace((double *)&v100, v67, &v88);
(*(void (__fastcall **)(__int64, unsigned __int64 *))(*(_QWORD *)v76 + 184LL))(v76, &v100);
CCMenuItemSpriteExtra::setSizeMult(*(_QWORD *)(a1 + 472), 1.0);
v78 = GameStatsManager::sharedState();
v91 = 8;
strcpy(v92, "0003");
isSpecialChestUnlocked = GameStatsManager::isSpecialChestUnlocked(v78, (__int64)&v91);
if ( (v91 & 1) != 0 )
operator delete(v93);
if ( !isSpecialChestUnlocked )
{
v80 = cocos2d::CCMenu::create();
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v80, 10);
v81 = GameStatsManager::sharedState();
v94 = 8;
strcpy(v95, "0003");
RewardForSpecialChest = GameStatsManager::getRewardForSpecialChest(v81, (__int64)&v94);
if ( (v94 & 1) != 0 )
operator delete(v96);
v83 = GJChestSprite::create(*(_DWORD *)(RewardForSpecialChest + 64));
GJChestSprite::switchToState(v83, 2, 0, COERCE_DOUBLE(1065353216), v77, (__m128)0x3F000000u);
(*(void (__fastcall **)(_QWORD *, float))(*v83 + 160LL))(v83, 0.60000002);
v84 = (char *)CCMenuItemSpriteExtra::create((__int64)v83, 0, a1, (__int64)SecretLayer4::onChest01, 0);
__str.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)28;
strcpy(__str.__r_.__value_.__s.__data_, "chestClick.ogg");
std::string::operator=((std::string *)(v84 + 440), &__str);
if ( (*(_BYTE *)&__str.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__str.__r_.__value_.__l.__data_);
sub_100278260((float *)&v100, 60.000004, 48.0);
(*(void (__fastcall **)(char *, unsigned __int64 *))(*(_QWORD *)v84 + 320LL))(v84, &v100);
v103 = *(float *)(*(__int64 (__fastcall **)(char *))(*(_QWORD *)v84 + 328LL))(v84) * 0.5;
v85 = (*(__int64 (__fastcall **)(char *))(*(_QWORD *)v84 + 328LL))(v84);
sub_100278250((float *)&v100, v103, 0.5 * *(float *)(v85 + 4));
(*(void (__fastcall **)(_QWORD *, unsigned __int64 *))(*v83 + 184LL))(v83, &v100);
(*(void (__fastcall **)(__int64, char *))(*(_QWORD *)v80 + 456LL))(v80, v84);
sub_100278250((float *)&v88, v101 + -60.0, 60.0);
cocos2d::CCNode::convertToNodeSpace((double *)&v100, v80, &v88);
(*(void (__fastcall **)(char *, unsigned __int64 *))(*(_QWORD *)v84 + 184LL))(v84, &v100);
}
return v104;
}