//
// MoreVideoOptionsLayer::init from 0x1404ce990 to 0x1404cf44c (2748 bytes)
//
// 5 xrefs:
// > VideoOptionsLayer::onAdvanced @ 0x1404cdce5
// > VideoOptionsLayer::onAdvanced @ 0x1404cdcec
// > VideoOptionsLayer::onAdvanced @ 0x1404cdcd6
// > ??> @ 0x1407d0d28
// > ??> @ 0x1409296e4
//
// 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 11:32:59 +0000
//
// Hidden C++ exception states: #wind=4
bool __fastcall MoreVideoOptionsLayer::init(__int64 a1)
{
bool result; // al
__int64 v3; // rcx
__int64 v4; // rdx
__int64 v5; // rdx
__int64 v6; // rcx
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 *v10; // rdi
__int64 v11; // rbx
__int64 v12; // rax
size_t v13; // rsi
__int64 v14; // rbx
__int64 v15; // rax
struct cocos2d::CCLabelBMFont *v16; // rdi
__int64 v17; // rbx
__int64 v18; // rax
__int64 v19; // rcx
cocos2d::CCObject *v20; // rax
__int64 v21; // rcx
cocos2d::CCObject *v22; // rax
__int64 v23; // rcx
__int64 v24; // rax
__int64 v25; // rcx
cocos2d::CCObject *v26; // rax
struct cocos2d::CCObject *v27; // rbx
__int64 v28; // rax
__int64 v29; // rax
struct cocos2d::CCObject *v30; // rbx
__int64 v31; // rdx
__int64 v32; // rdx
__int64 v33; // rcx
char *v34; // rax
__int64 v35; // rcx
__int64 v36; // rcx
__int64 v37; // rcx
__int64 v38; // rcx
__int64 v39; // rax
float v40; // xmm6_4
float v41; // xmm0_4
cocos2d::CCString *v42; // rax
char *CString; // rax
__int64 v44; // rcx
void **v45; // rsi
unsigned __int64 v46; // rdi
__int64 v47; // rbx
cocos2d::CCObject *v48; // rbx
struct cocos2d::CCObject *v49; // rdi
__int64 v50; // rax
__int64 v51; // rbx
__int64 v52; // rax
int v53; // eax
cocos2d::CCObject *v54; // rsi
__int64 v55; // rdi
__int64 v56; // rbx
__int64 v57; // rax
__int64 v58; // rax
float v59; // xmm7_4
int v60; // eax
cocos2d::CCObject *v61; // rax
__int64 v62; // rsi
__int64 v63; // rcx
cocos2d::CCDirector *v64; // rax
float v65; // xmm0_4
__int64 v66; // rbx
__int64 v67; // rdi
__int64 v68; // rax
__int64 v69; // rax
cocos2d::CCSprite *v70; // rax
cocos2d::CCObject *v71; // rax
__int64 v72; // rsi
__int64 v73; // rcx
cocos2d::CCDirector *v74; // rax
float v75; // xmm0_4
__int64 v76; // rbx
__int64 v77; // rdi
__int64 v78; // rax
__int64 v79; // rax
int v80; // [rsp+58h] [rbp-79h] BYREF
float v81; // [rsp+60h] [rbp-71h] BYREF
float v82; // [rsp+64h] [rbp-6Dh]
void *v83; // [rsp+68h] [rbp-69h] BYREF
__int128 v84; // [rsp+70h] [rbp-61h] BYREF
__int64 v85; // [rsp+80h] [rbp-51h]
__int64 v86; // [rsp+88h] [rbp-49h]
void *v87; // [rsp+90h] [rbp-41h] BYREF
_BYTE v88[8]; // [rsp+98h] [rbp-39h] BYREF
_BYTE v89[16]; // [rsp+A0h] [rbp-31h] BYREF
void *Src[2]; // [rsp+B0h] [rbp-21h] BYREF
unsigned __int64 v91; // [rsp+C0h] [rbp-11h]
unsigned __int64 v92; // [rsp+C8h] [rbp-9h]
v80 = 1258291200;
result = cocos2d::CCLayerColor::initWithColor((cocos2d::CCLayerColor *)a1, (const struct cocos2d::_ccColor4B *)&v80);
if ( result )
{
v3 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v87 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v87);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v3 = qword_14090BFD0;
}
if ( GameManager::getGameVariable(v3, "0168") )
*(_BYTE *)(a1 + 596) = 1;
FLAlertLayer::incrementForcePrio((struct cocos2d::CCObject *)a1);
LOBYTE(v4) = 1;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 920LL))(a1, v4);
LOBYTE(v5) = 1;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 992LL))(a1, v5);
v7 = cocos2d::CCDirector::sharedDirector(v6);
cocos2d::CCDirector::getWinSize(v7, &v81);
v8 = cocos2d::CCLayer::create();
*(_QWORD *)(a1 + 584) = v8;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 464LL))(a1, v8);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v89, 0.0, 0.0, 80.0, 80.0);
v10 = (__int64 *)cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v9);
v11 = *v10;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v87, 360.0, 260.0);
(*(void (__fastcall **)(__int64 *, __int64))(v11 + 312))(v10, v12);
v13 = -1;
(*(void (__fastcall **)(_QWORD, __int64 *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
v10,
0xFFFFFFFFLL);
v14 = *v10;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v87, v81 * 0.5, v82 * 0.5);
(*(void (__fastcall **)(__int64 *, __int64))(v14 + 184))(v10, v15);
v16 = cocos2d::CCLabelBMFont::create("Advanced Video Options", (const char *)&qword_140704F78);
v17 = *(_QWORD *)v16;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v87, v81 * 0.5, (float)((float)(v82 * 0.5) + 130.0) - 16.0);
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *, __int64))(v17 + 184))(v16, v18);
(*(void (__fastcall **)(_QWORD, struct cocos2d::CCLabelBMFont *))(**(_QWORD **)(a1 + 584) + 464LL))(
*(_QWORD *)(a1 + 584),
v16);
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *))(*(_QWORD *)v16 + 160LL))(v16);
*(_DWORD *)(a1 + 640) = -1;
v20 = (cocos2d::CCObject *)cocos2d::CCDictionary::create(v19);
*(_QWORD *)(a1 + 688) = v20;
cocos2d::CCObject::retain(v20);
v22 = (cocos2d::CCObject *)cocos2d::CCDictionary::create(v21);
*(_QWORD *)(a1 + 680) = v22;
cocos2d::CCObject::retain(v22);
v24 = cocos2d::CCMenu::create(v23);
*(_QWORD *)(a1 + 552) = v24;
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(*(_QWORD *)(a1 + 584), v24, 10);
MoreVideoOptionsLayer::addToggle(
a1,
"Vertical Sync",
"0030",
"Fixes screen tearing in fullscreen mode. Can cause issues in windowed mode.");
MoreVideoOptionsLayer::addToggle(
a1,
"Smooth Fix",
"0023",
"Makes some optimizations that can reduce lag. Disable if game speed becomes inconsistent.");
MoreVideoOptionsLayer::addToggle(a1, "Show FPS", "0115", "Shows frames per second while playing.");
MoreVideoOptionsLayer::addToggle(
a1,
"Unlock FPS",
"0116",
"Lets you set a custom target frames per second. Automatically disabled when vertical sync is enabled.");
v26 = (cocos2d::CCObject *)cocos2d::CCArray::create(v25);
*(_QWORD *)(a1 + 720) = v26;
cocos2d::CCObject::retain(v26);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v88,
(float)((float)(v81 * 0.5) - 180.0) + 75.0,
(float)((float)(v82 * 0.5) - 130.0) + 35.0);
v27 = cocos2d::CCLabelBMFont::create("FPS", (const char *)&qword_140704F78);
(*(void (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v27 + 160LL))(v27);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v83, 0.0, 25.0);
cocos2d::CCPoint::operator+(v88, &v80, v28);
(*(void (__fastcall **)(struct cocos2d::CCObject *, int *))(*(_QWORD *)v27 + 184LL))(v27, &v80);
(*(void (__fastcall **)(_QWORD, struct cocos2d::CCObject *))(**(_QWORD **)(a1 + 584) + 464LL))(
*(_QWORD *)(a1 + 584),
v27);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 720), v27);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v89, 0.0, 0.0, 40.0, 40.0);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)&v84, (const struct cocos2d::CCRect *)v89);
v30 = (struct cocos2d::CCObject *)cocos2d::extension::CCScale9Sprite::create("square02_small.png", v29);
LOBYTE(v31) = 100;
(*(void (__fastcall **)(__int64, __int64))(*((_QWORD *)v30 + 40) + 40LL))((__int64)v30 + 320, v31);
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v87, 100.0, 30.0);
(*(void (__fastcall **)(struct cocos2d::CCObject *, void **))(*(_QWORD *)v30 + 312LL))(v30, &v87);
(*(void (__fastcall **)(_QWORD, struct cocos2d::CCObject *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(
*(_QWORD *)(a1 + 584),
v30,
0xFFFFFFFFLL);
(*(void (__fastcall **)(struct cocos2d::CCObject *, _BYTE *))(*(_QWORD *)v30 + 184LL))(v30, v88);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 720), v30);
v34 = CCTextInputNode::create(v33, v32, (__int64)"FPS");
*(_QWORD *)(a1 + 712) = v34;
(*(void (__fastcall **)(_QWORD, char *, __int64))(**(_QWORD **)(a1 + 584) + 456LL))(*(_QWORD *)(a1 + 584), v34, 20);
*(_QWORD *)(*(_QWORD *)(a1 + 712) + 600LL) = a1 + 544;
(*(void (__fastcall **)(_QWORD, _BYTE *))(**(_QWORD **)(a1 + 712) + 184LL))(*(_QWORD *)(a1 + 712), v88);
v35 = *(_QWORD *)(a1 + 712);
*(_DWORD *)(v35 + 564) = 1060320051;
CCTextInputNode::refreshLabel(v35);
v36 = *(_QWORD *)(a1 + 712);
*(_DWORD *)(v36 + 560) = 1128792064;
CCTextInputNode::refreshLabel(v36);
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(*(_QWORD *)(a1 + 712) + 592LL) + 336LL))(
*(_QWORD *)(*(_QWORD *)(a1 + 712) + 592LL),
0);
*(_DWORD *)(*(_QWORD *)(a1 + 712) + 608LL) = 8;
v85 = 11;
v86 = 15;
*(_QWORD *)&v84 = 0x3736353433323130LL;
*((_QWORD *)&v84 + 1) = 3029304;
CCTextInputNode::setAllowedChars(*(_QWORD *)(a1 + 712), (void **)&v84);
LOWORD(v80) = -21896;
v37 = *(_QWORD *)(a1 + 712);
*(_WORD *)(v37 + 572) = -21896;
*(_BYTE *)(v37 + 574) = -16;
CCTextInputNode::refreshLabel(v37);
v38 = *(_QWORD *)(a1 + 712);
*(_DWORD *)(v38 + 568) = 1056964608;
CCTextInputNode::refreshLabel(v38);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 720), *(struct cocos2d::CCObject **)(a1 + 712));
v39 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v83 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v83);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v39 = qword_14090BFD0;
}
v40 = fmaxf(60.0, *(float *)(v39 + 1136));
*(_OWORD *)Src = 0;
v91 = 0;
v92 = 15;
LOBYTE(Src[0]) = 0;
v41 = floorf(v40);
if ( v41 == v40 )
v42 = cocos2d::CCString::createWithFormat((const char *)&word_1406ED6F8, (unsigned int)(int)v41);
else
v42 = cocos2d::CCString::createWithFormat("%.03f", v40);
CString = (char *)cocos2d::CCString::getCString(v42);
do
++v13;
while ( CString[v13] );
sub_1400405A0(Src, CString, v13);
v84 = 0;
v85 = 0;
v86 = 0;
v45 = Src;
if ( v92 > 0xF )
v45 = (void **)Src[0];
v46 = v91;
v47 = 0x7FFFFFFFFFFFFFFFLL;
if ( v91 > 0x7FFFFFFFFFFFFFFFLL )
sub_140009D90(v44);
if ( v91 > 0xF )
{
if ( (v91 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
v47 = v91 | 0xF;
if ( (v91 | 0xF) < 0x16 )
v47 = 22;
}
*(_QWORD *)&v84 = sub_14003D460(v47 + 1);
v85 = v46;
v86 = v47;
memcpy((void *)v84, v45, v46 + 1);
}
else
{
v85 = v91;
v86 = 15;
v84 = *(_OWORD *)v45;
}
CCTextInputNode::setString(*(_QWORD **)(a1 + 712), &v84);
v83 = operator new(0x2C8u);
v48 = (cocos2d::CCObject *)ButtonSprite::ButtonSprite((__int64)v83);
if ( v48 )
{
if ( ButtonSprite::init_1(
(__int64)v48,
(__int64)"Apply",
40,
0,
1056964608,
0,
&qword_140704F78,
(__int64)"GJ_button_04.png",
1103626240) )
{
cocos2d::CCObject::autorelease(v48);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v48 + 8LL))(v48, 1);
LODWORD(v48) = 0;
}
}
v49 = CCMenuItemSpriteExtra::create((int)v48, 0, a1, (__int64)MoreVideoOptionsLayer::onApplyFPS);
(*(void (__fastcall **)(_QWORD, struct cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(
*(_QWORD *)(a1 + 552),
v49);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 720), v49);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v83, 90.0, 0.0);
cocos2d::CCPoint::operator+(v88, &v80, v50);
v51 = *(_QWORD *)v49;
cocos2d::CCNode::convertToNodeSpace(*(_QWORD *)(a1 + 552), &v84, &v80);
(*(void (__fastcall **)(struct cocos2d::CCObject *, __int64))(v51 + 184))(v49, v52);
MoreVideoOptionsLayer::updateFPSButtons(a1);
sub_14003D310((__int64)Src);
v53 = (unsigned int)cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
v54 = CCMenuItemSpriteExtra::create(v53, 0, a1, (__int64)MoreVideoOptionsLayer::onClose);
*((_DWORD *)v54 + 93) = 1069547520;
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v54);
v55 = *(_QWORD *)v54;
v56 = *(_QWORD *)(a1 + 552);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v84,
(float)((float)(v81 * 0.5) - 180.0) + 5.0,
(float)((float)(v82 * 0.5) + 130.0) - 5.0);
cocos2d::CCNode::convertToNodeSpace(v56, &v83, v57);
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(v55 + 184))(v54, v58);
v59 = v82 * 0.5;
v60 = (unsigned int)cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
v61 = CCMenuItemSpriteExtra::create(v60, 0, a1, (__int64)MoreVideoOptionsLayer::onPrevPage);
*(_QWORD *)(a1 + 696) = v61;
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v61);
v62 = **(_QWORD **)(a1 + 696);
v64 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v63);
v65 = cocos2d::CCDirector::getScreenLeft(v64) + 24.0;
v66 = *(_QWORD *)(a1 + 552);
v67 = *(_QWORD *)(a1 + 696);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v84, v65, v59);
cocos2d::CCNode::convertToNodeSpace(v66, &v83, v68);
(*(void (__fastcall **)(__int64, __int64))(v62 + 184))(v67, v69);
v70 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
LODWORD(v66) = (_DWORD)v70;
cocos2d::CCSprite::setFlipX(v70, 1);
v71 = CCMenuItemSpriteExtra::create(v66, 0, a1, (__int64)MoreVideoOptionsLayer::onNextPage);
*(_QWORD *)(a1 + 704) = v71;
(*(void (__fastcall **)(_QWORD, cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(*(_QWORD *)(a1 + 552), v71);
v72 = **(_QWORD **)(a1 + 704);
v74 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v73);
v75 = cocos2d::CCDirector::getScreenRight(v74) - 24.0;
v76 = *(_QWORD *)(a1 + 552);
v77 = *(_QWORD *)(a1 + 704);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v84, v75, v59);
cocos2d::CCNode::convertToNodeSpace(v76, &v83, v78);
(*(void (__fastcall **)(__int64, __int64))(v72 + 184))(v77, v79);
MoreVideoOptionsLayer::goToPage(a1, 0);
return 1;
}
return result;
}