//
// PlayerObject::switchedDirTo from 0x100413d80 to 0x100413fa6 (550 bytes)
//
// 2 xrefs:
// > PlayerObject::pushButton @ 0x1004141aa
// > PlayerObject::enablePlayerControls @ 0x10041a99c
//
// 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
//
bool __fastcall PlayerObject::switchedDirTo(PlayerObject *a1, PlayerButton a2)
{
PlayerButton v2; // r13d
std::__compressed_pair *>> *p_pair1; // r12
std::__tree_end_node *>::pointer left; // rax
std::__compressed_pair *>> *v5; // r13
std::__compressed_pair *>> *v6; // r15
std::__tree_end_node *>::pointer v7; // rcx
int v8; // ecx
std::__compressed_pair *>> *v9; // r14
std::__tree_end_node *> *v10; // rax
std::__compressed_pair *>> *v11; // r15
int v12; // eax
std::__compressed_pair *>> *v13; // r14
std::__tree_end_node *> *v14; // rax
bool m_controlsDisabled; // al
v2 = a2;
if ( !a1->m_inputsLocked )
{
p_pair1 = &a1->m_holdingButtons.__tree_.__pair1_;
left = a1->m_holdingButtons.__tree_.__pair1_.__value_.__left_;
v5 = &a1->m_holdingButtons.__tree_.__pair1_;
v6 = &a1->m_holdingButtons.__tree_.__pair1_;
if ( left )
{
v7 = a1->m_holdingButtons.__tree_.__pair1_.__value_.__left_;
while ( 1 )
{
while ( 1 )
{
v6 = (std::__compressed_pair *>> *)v7;
v8 = *((_DWORD *)v7 + 7);
if ( v8 < 4 )
break;
v7 = v6->__value_.__left_;
v5 = v6;
if ( !v6->__value_.__left_ )
goto LABEL_9;
}
if ( v8 == 3 )
break;
v7 = v6[1].__value_.__left_;
if ( !v7 )
{
v5 = v6 + 1;
goto LABEL_9;
}
}
}
else
{
LABEL_9:
v9 = v6;
v6 = (std::__compressed_pair *>> *)operator new(0x28u);
HIDWORD(v6[3].__value_.__left_) = 3;
LOBYTE(v6[4].__value_.__left_) = 0;
*(_OWORD *)&v6->__value_.__left_ = 0;
v6[2].__value_.__left_ = (std::__tree_end_node *>::pointer)v9;
v5->__value_.__left_ = (std::__tree_end_node *>::pointer)v6;
v10 = (std::__tree_end_node *> *)a1->m_holdingButtons.__tree_.__begin_node_->__left_;
if ( v10 )
a1->m_holdingButtons.__tree_.__begin_node_ = v10;
sub_100054DD0((__int64 *)a1->m_holdingButtons.__tree_.__pair1_.__value_.__left_, (__int64 *)v6);
++a1->m_holdingButtons.__tree_.__pair3_.__value_;
left = a1->m_holdingButtons.__tree_.__pair1_.__value_.__left_;
}
v2 = a2;
LOBYTE(v6[4].__value_.__left_) = a2 == 3;
v11 = &a1->m_holdingButtons.__tree_.__pair1_;
LABEL_14:
if ( left )
{
do
{
v11 = (std::__compressed_pair *>> *)left;
v12 = *((_DWORD *)left + 7);
if ( v12 >= 3 )
{
left = v11->__value_.__left_;
p_pair1 = v11;
goto LABEL_14;
}
if ( v12 == 2 )
goto LABEL_22;
left = v11[1].__value_.__left_;
}
while ( left );
p_pair1 = v11 + 1;
}
v13 = v11;
v11 = (std::__compressed_pair *>> *)operator new(0x28u);
HIDWORD(v11[3].__value_.__left_) = 2;
LOBYTE(v11[4].__value_.__left_) = 0;
*(_OWORD *)&v11->__value_.__left_ = 0;
v11[2].__value_.__left_ = (std::__tree_end_node *>::pointer)v13;
p_pair1->__value_.__left_ = (std::__tree_end_node *>::pointer)v11;
v14 = (std::__tree_end_node *> *)a1->m_holdingButtons.__tree_.__begin_node_->__left_;
if ( v14 )
a1->m_holdingButtons.__tree_.__begin_node_ = v14;
sub_100054DD0((__int64 *)a1->m_holdingButtons.__tree_.__pair1_.__value_.__left_, (__int64 *)v11);
++a1->m_holdingButtons.__tree_.__pair3_.__value_;
LABEL_22:
LOBYTE(v11[4].__value_.__left_) = a2 == 2;
}
m_controlsDisabled = a1->m_controlsDisabled;
if ( !m_controlsDisabled )
{
if ( v2 == 3 )
{
a1->m_holdingRight = 1;
a1->m_leftPressedFirst = 0;
if ( a1->m_isSliding && a1->m_isSlidingRight )
{
a1->m_isSliding = 0;
a1->m_maybeSlopeForce = 0.0;
}
if ( a1->m_platformerXVelocity >= 0.0 )
return !m_controlsDisabled;
LABEL_34:
a1->m_isMoving = 0;
return !m_controlsDisabled;
}
*(_WORD *)&a1->m_holdingLeft = 257;
if ( a1->m_isSliding && !a1->m_isSlidingRight )
{
a1->m_isSliding = 0;
a1->m_maybeSlopeForce = 0.0;
}
if ( a1->m_platformerXVelocity > 0.0 )
goto LABEL_34;
}
return !m_controlsDisabled;
}