//
// GJOptionsLayer::onToggle from 0x100287b30 to 0x100287c5e (302 bytes)
//
// 2 xrefs:
// > sub_100287300 @ 0x100287494
// > GameOptionsLayer::setupOptions @ 0x10029e828
//
// 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:27:45 +0000
//
void __fastcall GJOptionsLayer::onToggle(_QWORD *a1, __int64 a2)
{
__int64 v4; // r15
__int64 v5; // rsi
__int64 v6; // rdi
__int64 v7; // rax
__int64 v8; // rdx
__int64 v9; // r15
double v10; // xmm0_8
__int64 v11; // rax
__int64 v12; // r14
__int64 CString; // rax
const char *v14; // r15
size_t v15; // rax
size_t v16; // r14
char *v17; // r12
unsigned int v18; // eax
size_t v19; // r13
_QWORD __dst[2]; // [rsp+0h] [rbp-40h] BYREF
void *__p; // [rsp+10h] [rbp-30h]
v4 = a1[131];
v5 = (*(int (__fastcall **)(__int64))(*(_QWORD *)a2 + 64LL))(a2);
v6 = v4;
v7 = cocos2d::CCDictionary::objectForKey_1(v4);
if ( !v7 )
{
v18 = (*(__int64 (__fastcall **)(__int64, __int64))(*(_QWORD *)a2 + 64LL))(a2, v5);
(*(void (__fastcall **)(_QWORD *, _QWORD))(*a1 + 1520LL))(a1, v18);
return;
}
v9 = v7;
*(_QWORD *)&v10 = GameManager::sharedState(v6, v5, v8).u64[0];
v12 = v11;
CString = cocos2d::CCString::getCString(v9);
GameManager::toggleGameVariable(v12, CString);
v14 = (const char *)cocos2d::CCString::getCString(v9);
v15 = strlen(v14);
if ( v15 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v16 = v15;
if ( v15 >= 0x17 )
{
v19 = 26;
if ( (v15 | 7) != 0x17 )
v19 = (v15 | 7) + 1;
v17 = (char *)operator new(v19);
__p = v17;
__dst[0] = v19 + 1;
__dst[1] = v16;
goto LABEL_10;
}
LOBYTE(__dst[0]) = 2 * v15;
v17 = (char *)__dst + 1;
if ( v15 )
LABEL_10:
memmove(v17, v14, v16);
v17[v16] = 0;
(*(void (__fastcall **)(_QWORD *, _QWORD *, double))(*a1 + 1512LL))(a1, __dst, v10);
if ( (__dst[0] & 1) != 0 )
operator delete(__p);
}