//
// GJBaseGameLayer::queueButton from 0x864054 to 0x8641c0 (364 bytes)
//
// 28 xrefs:
// > UILayer::handleKeypress @ 0x5c6d88
// > UILayer::handleKeypress @ 0x5c6e1c
// > UILayer::handleKeypress @ 0x5c6e58
// > UILayer::handleKeypress @ 0x5c6e90
// > UILayer::handleKeypress @ 0x5c6ea8
// > UILayer::handleKeypress @ 0x5c6ef0
// > UILayer::handleKeypress @ 0x5c7030
// > UILayer::handleKeypress @ 0x5c7050
// > UILayer::processUINodeTouch @ 0x5c73e4
// > UILayer::processUINodeTouch @ 0x5c7428
// > UILayer::processUINodeTouch @ 0x5c7444
// > UILayer::processUINodeTouch @ 0x5c7470
// > UILayer::processUINodeTouch @ 0x5c74a8
// > UILayer::processUINodeTouch @ 0x5c74c4
// > UILayer::processUINodeTouch @ 0x5c7504
// > UILayer::processUINodeTouch @ 0x5c7544
// > UILayer::processUINodeTouch @ 0x5c7560
// > UILayer::ccTouchBegan @ 0x5c7744
// > UILayer::ccTouchBegan @ 0x5c77c0
// > UILayer::ccTouchEnded @ 0x5c789c
// > UILayer::ccTouchEnded @ 0x5c78bc
// > PlayLayer::resetLevel @ 0x5e572c
// > PlayLayer::resetLevel @ 0x5e594c
// > EditorUI::playerTouchBegan @ 0x690610
// > EditorUI::playerTouchBegan @ 0x690634
// > EditorUI::playerTouchEnded @ 0x690680
// > EditorUI::playerTouchEnded @ 0x6906a0
// > ??> @ 0x8e500
//
// 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::queueButton(GJBaseGameLayer *a1, int a2, bool a3, bool a4, double a5)
{
float *v5; // x21
PlayerButtonCommand *m_finish; // x4
PlayerButtonCommand *m_start; // x0
signed __int64 v10; // x24
unsigned __int64 v12; // x19
unsigned __int64 v13; // x6
unsigned __int64 v14; // x22
PlayerButtonCommand *v15; // x23
char *v16; // x5
bool v17; // [xsp+50h] [xbp+50h]
bool v18; // [xsp+58h] [xbp+58h]
if ( !a2 )
return;
v5 = &a1->m_varianceValues.__elems_[1975];
m_finish = a1->m_queuedButtons.m_finish;
if ( m_finish != a1->m_queuedButtons.m_reserveEnd )
{
if ( m_finish )
{
m_finish->m_button = a2;
m_finish->m_isPush = a3;
m_finish->m_isPlayer2 = a4;
m_finish->m_step = 0;
*(&m_finish->m_step + 1) = 0;
m_finish->m_timestamp = a5;
}
a1->m_queuedButtons.m_finish = m_finish + 1;
return;
}
m_start = a1->m_queuedButtons.m_start;
v10 = (char *)m_finish - (char *)m_start;
v12 = 0xAAAAAAAAAAAAAAABLL * (((char *)m_finish - (char *)m_start) >> 3);
if ( v12 )
{
v13 = 0x5555555555555556LL * (((char *)m_finish - (char *)m_start) >> 3);
v14 = -16;
if ( 0xAAAAAAAAAAAAAAABLL * (((char *)m_finish - (char *)m_start) >> 3) <= v13 && v13 <= 0xAAAAAAAAAAAAAAALL )
{
v15 = nullptr;
v14 = 16 * (((char *)m_finish - (char *)m_start) >> 3);
if ( !v13 )
goto LABEL_10;
}
}
else
{
v14 = 24;
}
v17 = a4;
v18 = a3;
v15 = (PlayerButtonCommand *)operator new(v14);
m_start = a1->m_queuedButtons.m_start;
a4 = v17;
v10 = (char *)a1->m_queuedButtons.m_finish - (char *)m_start;
a3 = v18;
v12 = 0xAAAAAAAAAAAAAAABLL * (v10 >> 3);
LABEL_10:
v16 = (char *)v15 + v10;
if ( (char *)v15 + v10 )
{
*(PlayerButton *)((char *)&v15->m_button + v10) = a2;
v16[4] = a3;
v16[5] = a4;
*((_DWORD *)v16 + 2) = 0;
*((_DWORD *)v16 + 3) = 0;
*((double *)v16 + 2) = a5;
}
if ( v12 )
{
memmove(v15, m_start, v10);
m_start = a1->m_queuedButtons.m_start;
}
if ( m_start )
operator delete(m_start);
a1->m_queuedButtons.m_start = v15;
*((_QWORD *)v5 + 106) = (char *)v15 + v10 + 24;
*((_QWORD *)v5 + 107) = (char *)v15 + v14;
}