//
// PlayerObject::enablePlayerControls from 0x63cb68 to 0x63ce74 (780 bytes)
//
// 3 xrefs:
// > GJBaseGameLayer::toggleLockPlayer @ 0x865cec
// > GJBaseGameLayer::toggleLockPlayer @ 0x865cfc
// > ??> @ 0x49548
//
// 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
//
void PlayerObject::enablePlayerControls(PlayerObject *a1)
{
std::_rb_tree_base *p_m_header; // x21
std::_rb_tree_base *m_parent; // x0
std::_rb_tree_base *v4; // x1
std::_rb_tree_base *v5; // x2
std::map *p_m_holdingButtons; // x22
__int64 v7; // x19
__int64 insert_hint_unique_pos; // x0
__int64 v9; // x1
__int64 v10; // x3
_BOOL8 v11; // x0
std::_rb_tree_base *v12; // x2
std::_rb_tree_base *v13; // x1
__int64 v14; // x19
__int64 v15; // x0
__int64 v16; // x1
__int64 v17; // x3
_BOOL8 v18; // x0
__int64 v19; // x19
__int64 v20; // x0
__int64 v21; // x1
__int64 v22; // x3
_BOOL8 v23; // x0
void *v24; // x0
void *v25; // x0
void *v26; // x0
__int64 v27; // [xsp+38h] [xbp+38h]
__int64 v28; // [xsp+38h] [xbp+38h]
__int64 v29; // [xsp+38h] [xbp+38h]
p_m_header = &a1->m_holdingButtons.m_header;
m_parent = a1->m_holdingButtons.m_header.m_parent;
a1->m_controlsDisabled = 0;
v4 = p_m_header;
v5 = m_parent;
if ( m_parent )
{
do
{
while ( *(int *)&v5[1].m_isblack > 1 )
{
v4 = v5;
v5 = v5->m_left;
if ( !v5 )
goto LABEL_4;
}
v5 = v5->m_right;
}
while ( v5 );
LABEL_4:
if ( p_m_header != v4 && *(int *)&v4[1].m_isblack <= 2 )
{
if ( !*(&v4[1].m_isblack + 4) )
{
v12 = m_parent;
goto LABEL_13;
}
LABEL_35:
PlayerObject::switchedDirTo(a1, (PlayerButton)2);
goto LABEL_36;
}
}
v27 = (__int64)v4;
p_m_holdingButtons = &a1->m_holdingButtons;
v7 = operator new(0x28u);
*(_DWORD *)(v7 + 32) = 2;
*(_BYTE *)(v7 + 36) = 0;
insert_hint_unique_pos = std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::_M_get_insert_hint_unique_pos(
&a1->m_holdingButtons.compare.pad,
v27,
(int *)(v7 + 32));
v10 = insert_hint_unique_pos;
if ( v9 )
{
v11 = insert_hint_unique_pos
|| p_m_header == (std::_rb_tree_base *)v9
|| *(_DWORD *)(v7 + 32) < *(_DWORD *)(v9 + 32);
sub_CFAD74(v11, v7, v9, p_m_header);
++a1->m_holdingButtons.m_nodecount;
}
else
{
v24 = (void *)v7;
v7 = v10;
operator delete(v24);
}
if ( *(_BYTE *)(v7 + 36) )
goto LABEL_35;
m_parent = a1->m_holdingButtons.m_header.m_parent;
v12 = m_parent;
if ( !m_parent )
{
v13 = p_m_header;
LABEL_44:
v29 = (__int64)v13;
v19 = operator new(0x28u);
*(_DWORD *)(v19 + 32) = 3;
*(_BYTE *)(v19 + 36) = 0;
v20 = std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::_M_get_insert_hint_unique_pos(
p_m_holdingButtons,
v29,
(int *)(v19 + 32));
v22 = v20;
if ( v21 )
{
v23 = v20 || p_m_header == (std::_rb_tree_base *)v21 || *(_DWORD *)(v19 + 32) < *(_DWORD *)(v21 + 32);
sub_CFAD74(v23, v19, v21, p_m_header);
++p_m_holdingButtons->m_nodecount;
}
else
{
v26 = (void *)v19;
v19 = v22;
operator delete(v26);
}
if ( !*(_BYTE *)(v19 + 36) )
{
LABEL_36:
m_parent = a1->m_holdingButtons.m_header.m_parent;
if ( !m_parent )
goto LABEL_37;
goto LABEL_19;
}
LABEL_50:
PlayerObject::switchedDirTo(a1, (PlayerButton)3);
goto LABEL_36;
}
LABEL_13:
v13 = p_m_header;
do
{
while ( *(int *)&v12[1].m_isblack > 2 )
{
v13 = v12;
v12 = v12->m_left;
if ( !v12 )
goto LABEL_16;
}
v12 = v12->m_right;
}
while ( v12 );
LABEL_16:
if ( p_m_header == v13 || *(int *)&v13[1].m_isblack > 3 )
{
p_m_holdingButtons = &a1->m_holdingButtons;
goto LABEL_44;
}
if ( *(&v13[1].m_isblack + 4) )
goto LABEL_50;
LABEL_19:
v14 = (__int64)p_m_header;
do
{
while ( *(int *)&m_parent[1].m_isblack > 0 )
{
v14 = (__int64)m_parent;
m_parent = m_parent->m_left;
if ( !m_parent )
goto LABEL_22;
}
m_parent = m_parent->m_right;
}
while ( m_parent );
LABEL_22:
if ( (std::_rb_tree_base *)v14 != p_m_header )
{
if ( *(int *)(v14 + 32) <= 1 )
goto LABEL_29;
goto LABEL_24;
}
LABEL_37:
v14 = (__int64)p_m_header;
LABEL_24:
v28 = v14;
v14 = operator new(0x28u);
*(_DWORD *)(v14 + 32) = 1;
*(_BYTE *)(v14 + 36) = 0;
v15 = std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::_M_get_insert_hint_unique_pos(
&a1->m_holdingButtons.compare.pad,
v28,
(int *)(v14 + 32));
v17 = v15;
if ( v16 )
{
v18 = v15 || p_m_header == (std::_rb_tree_base *)v16 || *(_DWORD *)(v14 + 32) < *(_DWORD *)(v16 + 32);
sub_CFAD74(v18, v14, v16, p_m_header);
++a1->m_holdingButtons.m_nodecount;
}
else
{
v25 = (void *)v14;
v14 = v17;
operator delete(v25);
}
LABEL_29:
if ( *(_BYTE *)(v14 + 36) )
PlayerObject::pushButton(a1, Jump);
}