//
// GJOptionsLayer::addToggleInternal from 0x14039b1a0 to 0x14039b63c (1180 bytes)
//
// 28 xrefs:
// > GJOptionsLayer::addGVToggle @ 0x14039b0cb
// > GameLevelOptionsLayer::setupOptions @ 0x1403aa62f
// > GameLevelOptionsLayer::setupOptions @ 0x1403aa65f
// > GameLevelOptionsLayer::setupOptions @ 0x1403aa692
// > GameLevelOptionsLayer::setupOptions @ 0x1403aa6c8
// > GameLevelOptionsLayer::setupOptions @ 0x1403aa715
// > LevelOptionsLayer::setupOptions @ 0x14045d26a
// > LevelOptionsLayer::setupOptions @ 0x14045d293
// > LevelOptionsLayer::setupOptions @ 0x14045d2cd
// > LevelOptionsLayer::setupOptions @ 0x14045d2f6
// > LevelOptionsLayer::setupOptions @ 0x14045d31f
// > LevelOptionsLayer::setupOptions @ 0x14045d348
// > LevelOptionsLayer::setupOptions @ 0x14045d371
// > LevelOptionsLayer::setupOptions @ 0x14045d3af
// > LevelOptionsLayer2::setupOptions @ 0x14045dbb1
// > LevelOptionsLayer2::setupOptions @ 0x14045dbe1
// > LevelOptionsLayer2::setupOptions @ 0x14045dc11
// > LevelOptionsLayer2::setupOptions @ 0x14045dc41
// > LevelOptionsLayer2::setupOptions @ 0x14045dc71
// > LevelOptionsLayer2::setupOptions @ 0x14045dca1
// > LevelOptionsLayer2::setupOptions @ 0x14045dcd1
// > LevelOptionsLayer2::setupOptions @ 0x14045dd01
// > LevelOptionsLayer2::setupOptions @ 0x14045dd31
// > LevelOptionsLayer2::setupOptions @ 0x14045dd61
// > LevelOptionsLayer2::setupOptions @ 0x14045dd91
// > LevelOptionsLayer2::setupOptions @ 0x14045ddc1
// > LevelOptionsLayer2::setupOptions @ 0x14045ddf5
// > ??> @ 0x140923318
//
// 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:31:15 +0000
//
// Hidden C++ exception states: #wind=3
struct cocos2d::CCObject *__fastcall GJOptionsLayer::addToggleInternal(
__int64 a1,
_BYTE *a2,
int a3,
unsigned __int8 a4,
_BYTE *a5)
{
int v7; // eax
signed int v8; // ebx
unsigned int v9; // r12d
__int64 v10; // r13
size_t v11; // rdi
size_t v12; // r8
float *v13; // rax
float *v14; // rbx
float v15; // xmm6_4
float v16; // xmm7_4
__int64 v17; // rax
struct cocos2d::CCObject *ToggleButton; // r15
cocos2d::CCArray *v19; // r12
__int64 v20; // rax
cocos2d::CCString *v21; // rax
const char *CString; // rax
size_t v23; // r8
__int64 v24; // rbx
__int64 v25; // rax
void *v26; // rcx
void *v27; // rcx
struct cocos2d::CCSprite *v28; // rax
int v29; // ebx
struct cocos2d::CCObject *v30; // rdi
__int64 v31; // rax
__int64 v32; // rbx
__int64 v33; // rax
unsigned __int8 v36[8]; // [rsp+88h] [rbp-78h] BYREF
__int128 *v37; // [rsp+90h] [rbp-70h] BYREF
_BYTE v38[8]; // [rsp+98h] [rbp-68h] BYREF
__int128 v39; // [rsp+A0h] [rbp-60h] BYREF
__int64 v40; // [rsp+B0h] [rbp-50h]
__int64 v41; // [rsp+B8h] [rbp-48h]
_BYTE v42[8]; // [rsp+C0h] [rbp-40h] BYREF
_BYTE v43[8]; // [rsp+C8h] [rbp-38h] BYREF
void *Block[2]; // [rsp+D0h] [rbp-30h] BYREF
__m128i si128; // [rsp+E0h] [rbp-20h]
void *v46[2]; // [rsp+F0h] [rbp-10h] BYREF
__int128 v47; // [rsp+100h] [rbp+0h]
*(_DWORD *)v36 = a3;
v7 = *(_DWORD *)(a1 + 1012);
*(_DWORD *)(a1 + 1012) = v7 + 1;
v8 = *(_DWORD *)(a1 + 1016);
v9 = (int)fmaxf(0.0, floorf((float)(v7 / *(_DWORD *)(a1 + 1008))));
if ( v8 <= (int)v9 )
v8 = v9;
*(_DWORD *)(a1 + 1016) = v8;
GJOptionsLayer::nextPosition(a1, v38, v9);
v10 = GJOptionsLayer::layerForPage(a1, v9);
v37 = &v39;
v39 = 0;
v40 = 0;
v41 = 0;
v11 = -1;
v12 = -1;
do
++v12;
while ( a2[v12] );
sub_14003D230(&v39, a2, v12);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v42, 8.0, 0.0);
v14 = v13;
v15 = *(float *)(a1 + 1024);
v16 = *(float *)(a1 + 1020);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v43, (const struct cocos2d::CCPoint *)v38);
ToggleButton = GameToolbox::createToggleButton(
(const char *)&v39,
(__int64)GJOptionsLayer::onToggle,
a4,
*(_QWORD *)(a1 + 552),
v17,
a1,
v10,
0.80000001,
v16,
v15,
v14,
(const char *)&qword_140704F78,
0,
0,
nullptr);
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)ToggleButton + 64LL))(
ToggleButton,
*(unsigned int *)v36);
*(_DWORD *)(*((_QWORD *)ToggleButton + 47) + 372LL) = 1065353216;
*(_DWORD *)(*((_QWORD *)ToggleButton + 48) + 372LL) = 1065353216;
CCMenuItemToggler::toggle((__int64)ToggleButton, *((unsigned __int8 *)ToggleButton + 392));
*(_QWORD *)(*(_QWORD *)sub_1400677E0((_QWORD *)(a1 + 1072), (__int64)Block, v36) + 24LL) = ToggleButton;
GJOptionsLayer::incrementCountForPage(a1, v9);
v19 = (cocos2d::CCArray *)GJOptionsLayer::objectsForPage(a1, v9);
cocos2d::CCArray::addObject(v19, ToggleButton);
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)ToggleButton + 336LL))(ToggleButton, 0);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v10 + 336LL))(v10, 0);
if ( a5 )
{
v20 = -1;
do
++v20;
while ( a5[v20] );
if ( v20 )
{
v21 = cocos2d::CCString::createWithFormat("info_%i", *(_DWORD *)v36);
CString = cocos2d::CCString::getCString(v21);
*(_OWORD *)v46 = 0;
v47 = 0;
v23 = -1;
do
++v23;
while ( CString[v23] );
sub_14003D230(v46, CString, v23);
*(_OWORD *)Block = 0;
si128 = 0;
do
++v11;
while ( a5[v11] );
sub_14003D230(Block, a5, v11);
v24 = *(_QWORD *)(a1 + 1032);
v25 = cocos2d::CCString::create(Block);
cocos2d::CCDictionary::setObject(v24, v25, v46);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v26 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v26 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v26 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v26);
}
si128 = _mm_load_si128((const __m128i *)&Size);
LOBYTE(Block[0]) = 0;
if ( *((_QWORD *)&v47 + 1) > 0xFu )
{
v27 = v46[0];
if ( (unsigned __int64)(*((_QWORD *)&v47 + 1) + 1LL) >= 0x1000 )
{
v27 = *((void **)v46[0] - 1);
if ( (unsigned __int64)((char *)v46[0] - (char *)v27 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v27);
}
v28 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_infoIcon_001.png");
v29 = (int)v28;
(*(void (__fastcall **)(struct cocos2d::CCSprite *))(*(_QWORD *)v28 + 160LL))(v28);
v30 = CCMenuItemSpriteExtra::create(v29, 0, a1, (__int64)GJOptionsLayer::onInfo);
*((_DWORD *)v30 + 93) = 0x40000000;
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)v30 + 64LL))(v30, *(unsigned int *)v36);
(*(void (__fastcall **)(_QWORD, struct cocos2d::CCObject *))(**(_QWORD **)(a1 + 552) + 464LL))(
*(_QWORD *)(a1 + 552),
v30);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)Block, -18.0, 16.0);
v32 = v31;
v33 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)ToggleButton + 200LL))(ToggleButton);
cocos2d::CCPoint::operator+(v33, &v37, v32);
(*(void (__fastcall **)(struct cocos2d::CCObject *, __int128 **))(*(_QWORD *)v30 + 184LL))(v30, &v37);
cocos2d::CCArray::addObject(v19, v30);
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)v30 + 336LL))(v30, 0);
}
}
return ToggleButton;
}