//
// MoreVideoOptionsLayer::init from 0x140378c20 to 0x14037971b (2811 bytes)
//
// 5 xrefs:
// > VideoOptionsLayer::onAdvanced @ 0x140377f75
// > VideoOptionsLayer::onAdvanced @ 0x140377f7c
// > VideoOptionsLayer::onAdvanced @ 0x140377f66
// > ??> @ 0x1405c60a8
// > ??> @ 0x1406d5c60
//
// 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
//
// Hidden C++ exception states: #wind=5
bool MoreVideoOptionsLayer::init(MoreVideoOptionsLayer *a1)
{
bool result; // al
GameManager *v3; // rcx
_BOOL8 v4; // rdx
__int64 v5; // rcx
__int64 v6; // rax
cocos2d::CCTouchDispatcher *v7; // rax
_BOOL8 v8; // rdx
__int64 v9; // rcx
cocos2d::CCDirector *v10; // rax
cocos2d::CCLayer *v11; // rax
struct cocos2d::CCRect *v12; // rax
struct cocos2d::extension::CCScale9Sprite *v13; // rdi
cocos2d::extension::CCScale9Sprite_vtbl *v14; // rbx
const cocos2d::CCSize *v15; // rax
size_t v16; // rsi
float v17; // xmm0_4
cocos2d::extension::CCScale9Sprite_vtbl *v18; // rbx
double v19; // xmm0_8
const cocos2d::CCPoint *v20; // rax
struct cocos2d::CCLabelBMFont *v21; // rdi
cocos2d::CCLabelBMFont_vtbl *v22; // rbx
const cocos2d::CCPoint *v23; // rax
double v24; // xmm0_8
__int64 v25; // rcx
cocos2d::CCDictionary *v26; // rax
__int64 v27; // rcx
cocos2d::CCDictionary *v28; // rax
__int64 v29; // rcx
cocos2d::CCMenu *v30; // rax
__int64 v31; // rcx
cocos2d::CCArray *v32; // rax
struct cocos2d::CCLabelBMFont *v33; // rbx
float v34; // xmm0_4
struct cocos2d::CCRect *v35; // rax
struct cocos2d::extension::CCScale9Sprite *v36; // rbx
__int64 v37; // rdx
const char *v38; // r9
CCTextInputNode *v39; // rax
CCTextInputNode *m_fpsInput; // rcx
CCTextInputNode *v41; // rcx
std::string *p_m_allowedChars; // rcx
CCTextInputNode *v43; // rcx
CCTextInputNode *v44; // rcx
__int64 v45; // rax
float v46; // xmm6_4
float v47; // xmm0_4
cocos2d::CCString *v48; // rax
char *CString; // rax
cocos2d::CCString *v50; // rax
__int64 v51; // rdx
__int64 v52; // rcx
__int64 v53; // r8
__int64 v54; // r9
__int128 v55; // xmm0
void **v56; // rsi
__int64 v57; // rbx
unsigned __int64 v58; // rdi
ButtonSprite *v59; // rbx
CCMenuItemSpriteExtra *v60; // rdi
CCMenuItemSpriteExtra_vtbl *v61; // rbx
struct cocos2d::CCPoint v62; // rax
struct cocos2d::CCSprite *v63; // rax
CCMenuItemSpriteExtra *v64; // rdi
float v65; // xmm0_4
CCMenuItemSpriteExtra_vtbl *v66; // rbx
struct cocos2d::CCPoint v67; // rax
struct cocos2d::CCSprite *v68; // rax
CCMenuItemSpriteExtra *v69; // rax
CCMenuItemSpriteExtra_vtbl *v70; // rbx
__int64 v71; // rcx
cocos2d::CCDirector *v72; // rax
float v73; // xmm0_4
struct cocos2d::CCPoint v74; // rax
cocos2d::CCSprite *v75; // rbx
CCMenuItemSpriteExtra *v76; // rax
CCMenuItemSpriteExtra_vtbl *v77; // rbx
__int64 v78; // rcx
cocos2d::CCDirector *v79; // rax
float v80; // xmm0_4
struct cocos2d::CCPoint v81; // rax
int v82; // [rsp+28h] [rbp-E0h]
cocos2d::CCPoint v83; // [rsp+58h] [rbp-B0h] BYREF
__int64 v84; // [rsp+60h] [rbp-A8h]
ButtonSprite *v85; // [rsp+68h] [rbp-A0h] BYREF
cocos2d::CCSize v86; // [rsp+70h] [rbp-98h] BYREF
_QWORD v87[3]; // [rsp+78h] [rbp-90h] BYREF
unsigned __int64 v88; // [rsp+90h] [rbp-78h]
__int64 v89; // [rsp+98h] [rbp-70h]
_DWORD v90[4]; // [rsp+A0h] [rbp-68h] BYREF
__int64 v91; // [rsp+B0h] [rbp-58h]
__int64 v92; // [rsp+B8h] [rbp-50h]
cocos2d::CCRect v93; // [rsp+C0h] [rbp-48h] BYREF
void *Src[2]; // [rsp+D0h] [rbp-38h] BYREF
unsigned __int64 v95; // [rsp+E0h] [rbp-28h]
unsigned __int64 v96; // [rsp+E8h] [rbp-20h]
v83.x = 8388608.0;
result = cocos2d::CCLayerColor::initWithColor(a1, (const struct cocos2d::_ccColor4B *)&v83);
if ( result )
{
v3 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v86 = (cocos2d::CCSize)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(*(_QWORD *)&v86);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v3 = (GameManager *)qword_1406C2ED8;
}
if ( GameManager::getGameVariable(v3, "0168") )
a1->m_noElasticity = 1;
if ( !a1->m_forcePrioRegistered )
{
a1->m_forcePrioRegistered = 1;
v6 = cocos2d::CCDirector::sharedDirector(v5);
v7 = (cocos2d::CCTouchDispatcher *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v6 + 144LL))(v6);
cocos2d::CCTouchDispatcher::registerForcePrio(v7, a1, 2);
}
LOBYTE(v4) = 1;
a1->setTouchEnabled(a1, v4);
LOBYTE(v8) = 1;
a1->setKeypadEnabled(a1, v8);
v10 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v9);
cocos2d::CCDirector::getWinSize(v10);
v11 = (cocos2d::CCLayer *)cocos2d::CCLayer::create();
a1->m_mainLayer = v11;
a1->addChild_1(a1, v11);
cocos2d::CCRect::CCRect(&v93, 0.0, 0.0, 80.0, 80.0);
v13 = cocos2d::extension::CCScale9Sprite::create("GJ_square01.png", v12);
v14 = v13->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCSize::CCSize(&v86, 360.0, 260.0);
v14->setContentSize(v13, v15);
v16 = -1;
v17 = ((float (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::extension::CCScale9Sprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v13,
0xFFFFFFFFLL);
v18 = v13->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v19 = cocos2d::CCPoint::CCPoint(v17, *(float *)&v84 * 0.5);
v18->setPosition_0(v13, v20);
v21 = cocos2d::CCLabelBMFont::create("Advanced Video Options", (const char *)&qword_14052A4D8);
v22 = v21->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(*(float *)&v19, *(float *)&v84 * 0.5);
v22->setPosition_0(v21, v23);
v24 = ((double (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::CCLabelBMFont *))a1->m_mainLayer->addChild_1)(
a1->m_mainLayer,
v21);
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *))v21->setScale_0)(v21);
a1->m_joystickConnected = -1;
v26 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create(v25);
a1->m_variables = v26;
cocos2d::CCObject::retain(v26);
v28 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create(v27);
a1->m_values = v28;
cocos2d::CCObject::retain(v28);
v30 = (cocos2d::CCMenu *)cocos2d::CCMenu::create(v29);
a1->m_buttonMenu = v30;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v30, 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.");
v32 = (cocos2d::CCArray *)cocos2d::CCArray::create(v31);
a1->m_fpsNodes = v32;
cocos2d::CCObject::retain(v32);
cocos2d::CCPoint::CCPoint(*(float *)&v24, (float)((float)(*(float *)&v84 * 0.5) - 180.0) + 75.0);
v33 = cocos2d::CCLabelBMFont::create("FPS", (const char *)&qword_14052A4D8);
v34 = ((float (__fastcall *)(struct cocos2d::CCLabelBMFont *))v33->setScale_0)(v33);
cocos2d::CCPoint::CCPoint(v34, 0.0);
cocos2d::CCPoint::operator+(v87, &v83);
v33->setPosition_0(v33, &v83);
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v33);
cocos2d::CCArray::addObject(a1->m_fpsNodes, v33);
cocos2d::CCRect::CCRect(&v93, 0.0, 0.0, 40.0, 40.0);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)&v87[1], &v93);
v36 = cocos2d::extension::CCScale9Sprite::create("square02_small.png", v35);
LOBYTE(v37) = 100;
v36->setOpacity(&v36->cocos2d::CCRGBAProtocol, v37);
cocos2d::CCSize::CCSize(&v86, 100.0, 30.0);
v36->setContentSize(v36, &v86);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v36, -1);
v36->setPosition_0(v36, (const cocos2d::CCPoint *)v87);
cocos2d::CCArray::addObject(a1->m_fpsNodes, v36);
v39 = CCTextInputNode::create(100.0, 50.0, "FPS", v38, v82, (const char *)&qword_14052A4D8);
a1->m_fpsInput = v39;
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v39, 20);
a1->m_fpsInput->m_delegate = &a1->TextInputDelegate;
a1->m_fpsInput->setPosition_0(a1->m_fpsInput, (const cocos2d::CCPoint *)v87);
m_fpsInput = a1->m_fpsInput;
m_fpsInput->m_maxLabelScale = 0.69999999;
CCTextInputNode::refreshLabel(m_fpsInput);
v41 = a1->m_fpsInput;
v41->m_maxLabelWidth = 200.0;
CCTextInputNode::refreshLabel(v41);
a1->m_fpsInput->m_textField->setVisible(a1->m_fpsInput->m_textField, 0);
a1->m_fpsInput->m_maxLabelLength = 8;
v90[3] = 0;
v91 = 11;
v92 = 15;
strcpy((char *)v90, "0123456789.");
v85 = (ButtonSprite *)v90;
p_m_allowedChars = &a1->m_fpsInput->m_allowedChars;
if ( p_m_allowedChars != (std::string *)v90 )
sub_14003CCE0((void **)p_m_allowedChars, v90, 0xBu);
sub_14003A830((__int64)v90);
LOWORD(v83.x) = -21896;
v43 = a1->m_fpsInput;
*(_WORD *)&v43->m_placeholderColor.r = -21896;
v43->m_placeholderColor.b = -16;
CCTextInputNode::refreshLabel(v43);
v44 = a1->m_fpsInput;
v44->m_placeholderScale = 0.5;
CCTextInputNode::refreshLabel(v44);
cocos2d::CCArray::addObject(a1->m_fpsNodes, a1->m_fpsInput);
v45 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v85 = (ButtonSprite *)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v85);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v45 = qword_1406C2ED8;
}
v46 = fmaxf(60.0, *(float *)(v45 + 1072));
*(_OWORD *)Src = 0;
v95 = 0;
v96 = 15;
LOBYTE(Src[0]) = 0;
v47 = floorf(v46);
if ( v47 == v46 )
{
v48 = cocos2d::CCString::createWithFormat("%i", (int)v47);
CString = (char *)cocos2d::CCString::getCString(v48);
do
++v16;
while ( CString[v16] );
}
else
{
v50 = cocos2d::CCString::createWithFormat("%.03f", v46);
CString = (char *)cocos2d::CCString::getCString(v50);
do
++v16;
while ( CString[v16] );
}
sub_14003CCE0(Src, CString, v16);
LODWORD(v55) = 0;
*(_OWORD *)&v87[1] = 0;
v88 = 0;
v89 = 0;
v56 = Src;
if ( v96 > 0xF )
v56 = (void **)Src[0];
v57 = 0x7FFFFFFFFFFFFFFFLL;
v58 = v95;
if ( v95 > 0x7FFFFFFFFFFFFFFFLL )
sub_140007B50(v52, v51, v53, v54);
v89 = 15;
if ( v95 > 0xF )
{
if ( (v95 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
v57 = v95 | 0xF;
if ( (v95 | 0xF) < 0x16 )
v57 = 22;
}
v87[1] = sub_14003AA10(v57 + 1);
v88 = v58;
v89 = v57;
memcpy((void *)v87[1], v56, v58 + 1);
}
else
{
v88 = v95;
v55 = *(_OWORD *)v56;
*(_OWORD *)&v87[1] = *(_OWORD *)v56;
}
CCTextInputNode::setString((__int64)a1->m_fpsInput, &v87[1]);
v85 = (ButtonSprite *)operator new(0x2C0u);
v59 = ButtonSprite::ButtonSprite(v85);
if ( v59 )
{
if ( ButtonSprite::init_1(v59, "Apply", 40, 0, 0.5, 0, (const char *)&qword_14052A4D8, "GJ_button_04.png", 25.0) )
{
cocos2d::CCObject::autorelease(v59);
}
else
{
((void (__fastcall *)(ButtonSprite *, __int64))v59->~ButtonSprite)(v59, 1);
v59 = nullptr;
}
}
v60 = CCMenuItemSpriteExtra::create(v59, nullptr, a1, (cocos2d::SEL_MenuHandler *)MoreVideoOptionsLayer::onApplyFPS);
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v60);
cocos2d::CCArray::addObject(a1->m_fpsNodes, v60);
cocos2d::CCPoint::CCPoint(*(float *)&v55, 90.0);
cocos2d::CCPoint::operator+(v87, &v83);
v61 = v60->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v62 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v87[1]);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v61->setPosition_0)(v60, v62);
MoreVideoOptionsLayer::updateFPSButtons(a1);
sub_14003A830((__int64)Src);
v63 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_closeBtn_001.png");
v64 = CCMenuItemSpriteExtra::create(v63, nullptr, a1, (cocos2d::SEL_MenuHandler *)MoreVideoOptionsLayer::onClose);
HIDWORD(v64->m_pfnSelector.adj) = 1069547520;
v65 = ((float (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))a1->m_buttonMenu->addChild_1)(
a1->m_buttonMenu,
v64);
v66 = v64->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v65, (float)((float)(*(float *)&v84 * 0.5) - 180.0) + 5.0);
v67 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v85);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v66->setPosition_0)(v64, v67);
v68 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
v69 = CCMenuItemSpriteExtra::create(v68, nullptr, a1, (cocos2d::SEL_MenuHandler *)MoreVideoOptionsLayer::onPrevPage);
a1->m_prevButton = v69;
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v69);
v70 = a1->m_prevButton->__vftable;
v72 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v71);
v73 = cocos2d::CCDirector::getScreenLeft(v72) + 24.0;
cocos2d::CCPoint::CCPoint(v73, v73);
v74 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v85);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v70->setPosition_0)(a1->m_prevButton, v74);
v75 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
cocos2d::CCSprite::setFlipX(v75, 1);
v76 = CCMenuItemSpriteExtra::create(v75, nullptr, a1, (cocos2d::SEL_MenuHandler *)MoreVideoOptionsLayer::onNextPage);
a1->m_nextButton = v76;
a1->m_buttonMenu->addChild_1(a1->m_buttonMenu, v76);
v77 = a1->m_nextButton->__vftable;
v79 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v78);
v80 = cocos2d::CCDirector::getScreenRight(v79) - 24.0;
cocos2d::CCPoint::CCPoint(v80, v80);
v81 = cocos2d::CCNode::convertToNodeSpace(a1->m_buttonMenu, (const struct cocos2d::CCPoint *)&v85);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v77->setPosition_0)(a1->m_nextButton, v81);
MoreVideoOptionsLayer::goToPage(a1, 0);
return 1;
}
return result;
}