//
// GJBaseGameLayer::handleButton from 0x88c758 to 0x88c9bc (612 bytes)
//
// 2 xrefs:
// > GJBaseGameLayer::processQueuedButtons @ 0x88ca14
// > ??> @ 0xa5810
//
// 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 GJBaseGameLayer::handleButton(GJBaseGameLayer *a1, bool a2, int a3, bool a4)
{
float *v4; // x20
_BOOL4 v6; // w21
unsigned int v7; // w22
unsigned int m_twoPlayerMode; // w24
bool hasActiveDualTouch; // w0
int m_clickIndex; // w0
PlayerObject *m_player1; // x0
_BOOL4 v13; // w25
unsigned int v14; // w2
GJGameEvent v15; // w1
int v16; // w3
GameManager *v17; // x0
PlayerObject *m_player2; // x0
bool v19; // w0
bool v20; // w0
v4 = &a1->m_varianceValues.__elems_[1975];
v6 = a2;
v7 = a4;
m_twoPlayerMode = a1->m_levelSettings->m_twoPlayerMode;
if ( !a1->m_isPlatformer && !a1->m_useReplay )
{
v17 = GameManager::sharedState();
if ( GameManager::getGameVariable(v17, "0010") )
v7 ^= 1u;
}
hasActiveDualTouch = GJEffectManager::hasActiveDualTouch(a1->m_effectManager);
if ( v6 )
{
*((_BYTE *)v4 + 236) = hasActiveDualTouch;
}
else if ( !*((_BYTE *)v4 + 236) )
{
goto LABEL_6;
}
if ( v7 < hasActiveDualTouch )
goto LABEL_9;
LABEL_6:
if ( v7 < m_twoPlayerMode || !GJBaseGameLayer::isButtonAllowed(a1, v6, a3, 1) )
{
if ( *((_BYTE *)v4 + 236)
|| !a1->m_gameState.m_isDualMode
|| v7 > (m_twoPlayerMode ^ 1)
|| !GJBaseGameLayer::isButtonAllowed(a1, v6, a3, 0) )
{
goto LABEL_9;
}
goto LABEL_40;
}
m_player1 = a1->m_player1;
if ( v6 )
v13 = PlayerObject::pushButton(m_player1, (PlayerButton)a3);
else
v13 = PlayerObject::releaseButton(m_player1, (PlayerButton)a3);
if ( !*((_BYTE *)v4 + 236)
&& a1->m_gameState.m_isDualMode
&& v7 <= (m_twoPlayerMode ^ 1)
&& GJBaseGameLayer::isButtonAllowed(a1, v6, a3, 0) )
{
LABEL_40:
m_player2 = a1->m_player2;
if ( v6 )
{
v19 = PlayerObject::pushButton(m_player2, (PlayerButton)a3);
v14 = m_twoPlayerMode;
if ( !v19 )
goto LABEL_9;
goto LABEL_26;
}
v20 = PlayerObject::releaseButton(m_player2, (PlayerButton)a3);
v14 = m_twoPlayerMode;
if ( !v20 )
goto LABEL_9;
LABEL_45:
if ( (unsigned int)(a3 - 1) > 2 )
goto LABEL_9;
v15 = dword_EED690[a3 - 1];
goto LABEL_28;
}
if ( !v13 )
goto LABEL_9;
v14 = 0;
if ( !v6 )
goto LABEL_45;
LABEL_26:
if ( (unsigned int)(a3 - 1) > 2 )
goto LABEL_9;
v15 = dword_EED680[a3 - 1];
LABEL_28:
if ( v15 )
{
if ( v14 )
v16 = 2;
else
v16 = 1;
GJBaseGameLayer::gameEventTriggered(a1, v15, 0, v16);
}
LABEL_9:
if ( !a1->m_player1->m_isDead )
GJEffectManager::playerButton(a1->m_effectManager, v6, v7);
if ( !*((_BYTE *)v4 + 496) )
GJBaseGameLayer::recordAction(a1, a3, v6, m_twoPlayerMode & (v7 ^ 1));
if ( v6 )
{
m_clickIndex = a1->m_clickIndex;
++a1->m_clicks;
a1->m_clickIndex = m_clickIndex + 1;
if ( a3 == 1 )
*((_BYTE *)v4 + 248) = 1;
}
}