//
// GJEffectManager::playerButton from 0x14036c910 to 0x14036cb6c (604 bytes)
//
// 2 xrefs:
// > GJBaseGameLayer::handleButton @ 0x14033c7b6
// > ??> @ 0x1409219ec
//
// 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:30:58 +0000
//
// Hidden C++ exception states: #wind=1
unsigned __int64 __fastcall GJEffectManager::playerButton(__int64 a1, unsigned __int8 a2, char a3)
{
int v6; // r12d
__int64 v7; // rsi
__int64 v8; // r9
unsigned __int64 result; // rax
__int64 v10; // r14
int v11; // eax
int v12; // r8d
int v13; // eax
__int64 v14; // r9
unsigned int v15; // ecx
int v16; // eax
unsigned __int8 v17; // bl
int v18; // ecx
int v19; // eax
int v20; // eax
int *v21; // rdx
char v22; // cl
int v23; // eax
char v24[16]; // [rsp+30h] [rbp-58h] BYREF
_QWORD v25[4]; // [rsp+40h] [rbp-48h] BYREF
int v26; // [rsp+90h] [rbp+8h] BYREF
v6 = 0;
v7 = *(_QWORD *)(a1 + 496);
v8 = *(_QWORD *)(a1 + 504) - v7;
result = (unsigned __int64)((unsigned __int128)(v8 * (__int128)0x4924924924924925LL) >> 64) >> 63;
if ( v8 / 56 )
{
v10 = 0;
do
{
if ( !*(_BYTE *)(v10 + v7) && (!*(_BYTE *)(v10 + v7 + 28) || !a3) )
{
v11 = *(_DWORD *)(v10 + v7 + 16);
if ( !v11 )
goto LABEL_12;
if ( v11 == 1 )
{
if ( a3 )
goto LABEL_12;
}
else if ( v11 == 2 && !a3 )
{
LABEL_12:
if ( a2 || *(_BYTE *)(v10 + v7 + 8) )
{
v12 = *(_DWORD *)(v10 + v7 + 4);
v13 = v12;
if ( v12 < 0 )
v13 = 0;
if ( v13 > 9999 )
v13 = 9999;
v14 = *(_QWORD *)(a1 + 1280);
v15 = v13 & 0x1F;
v16 = *(_DWORD *)(v14 + 4 * ((unsigned __int64)v13 >> 5));
v17 = !_bittest(&v16, v15);
if ( *(_BYTE *)(v10 + v7 + 8) && (v18 = *(_DWORD *)(v10 + v7 + 12)) != 0 )
{
v17 = a2;
if ( v18 != 1 )
v17 = a2 ^ 1;
}
else
{
v19 = *(_DWORD *)(v10 + v7 + 12);
if ( v19 )
v17 = v19 == 1;
}
if ( *(_QWORD *)(a1 + 320) )
{
sub_14018CFB0(v25, v10 + v7 + 32);
(***(void (__fastcall ****)(_QWORD, _QWORD, _QWORD, _QWORD *, _DWORD, _DWORD))(a1 + 320))(
*(_QWORD *)(a1 + 320),
*(unsigned int *)(v10 + v7 + 4),
v17,
v25,
*(_DWORD *)(v10 + v7 + 20),
*(_DWORD *)(v10 + v7 + 24));
sub_140069730((__int64)v25);
}
else
{
v20 = *(_DWORD *)(v10 + v7 + 4);
if ( v12 < 0 )
v20 = 0;
if ( v20 <= 9999 )
{
if ( v12 < 0 )
v12 = 0;
}
else
{
v12 = 9999;
}
v26 = v12;
v21 = (int *)(v14 + 4 * ((unsigned __int64)v12 >> 5));
v22 = v12 & 0x1F;
v23 = *v21;
if ( v17 )
{
*v21 = v23 | (1 << v22);
sub_140066A60((_QWORD *)(a1 + 1312), (unsigned __int8 *)&v26);
}
else
{
*v21 = v23 & ~(1 << v22);
sub_140068190(a1 + 1312, (__int64)v24, (unsigned __int8 *)&v26);
}
}
}
}
}
++v6;
v10 += 56;
v7 = *(_QWORD *)(a1 + 496);
result = v6;
}
while ( v6 < (unsigned __int64)((*(_QWORD *)(a1 + 504) - v7) / 56) );
}
return result;
}