//
// GJBaseGameLayer::controlAreaEffect from 0x140330670 to 0x1403307df (367 bytes)
//
// 8 xrefs:
// > GJBaseGameLayer::controlTriggersInGroup @ 0x140325c52
// > GJBaseGameLayer::controlTriggersInGroup @ 0x140325c69
// > GJBaseGameLayer::controlTriggersInGroup @ 0x140325c80
// > GJBaseGameLayer::controlTriggersInGroup @ 0x140325c97
// > GJBaseGameLayer::controlTriggersInGroup @ 0x140325cae
// > ??> @ 0x1408b6614
// > ??> @ 0x1408b6624
// > ??> @ 0x14091f574
//
// 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:32 +0000
//
unsigned __int64 __fastcall GJBaseGameLayer::controlAreaEffect(__int64 a1, __int64 a2, unsigned __int64 a3, __int64 a4)
{
__int64 v4; // rsi
__int64 v6; // r10
__int64 v7; // rcx
unsigned int v8; // r12d
int v9; // ebp
__int64 *v10; // r14
unsigned __int64 result; // rax
__int64 v12; // r15
__int64 v13; // rcx
char v14; // dl
__int64 i; // rbx
__int64 v16; // rbx
__int64 v17; // rax
v4 = *(_QWORD *)(a3 + 8);
v6 = *(_QWORD *)a3;
v7 = v4 - *(_QWORD *)a3;
v8 = 0;
v9 = a4;
v10 = (__int64 *)a3;
result = (unsigned __int64)((unsigned __int128)(v7 * (__int128)0x469EE58469EE5847LL) >> 64) >> 63;
if ( v7 / 232 )
{
v12 = 0;
do
{
v13 = 232 * v12;
v14 = 1;
if ( *(_QWORD *)(232 * v12 + v6 + 160) == a2 )
{
if ( v9 )
{
if ( v9 == 1 )
{
*(_WORD *)(v13 + v6 + 188) = 257;
}
else if ( v9 == 2 )
{
*(_WORD *)(v13 + v6 + 188) = 0;
}
}
else
{
for ( i = v6 + 232LL * (int)v8 + 232; i != v4; i += 232 )
sub_140359F40(i - 232, i, a3, a4);
v16 = v10[1];
sub_140069730(v16 - 32);
sub_140358980(v16 - 232, v16 - 232);
v10[1] -= 232;
v14 = 0;
}
}
v4 = v10[1];
v17 = v12 + 1;
v6 = *v10;
a3 = v8 + 1;
if ( !v14 )
{
v17 = v12;
a3 = v8;
}
v12 = v17;
v8 = a3;
result = (int)a3;
}
while ( (int)a3 < (unsigned __int64)((v10[1] - v6) / 232) );
}
return result;
}