//
// GJGarageLayer::onArrow from 0x10036cab0 to 0x10036cbfe (334 bytes)
//
// 2 xrefs:
// > GJGarageLayer::setupIconSelect @ 0x10036bd14
// > GJGarageLayer::setupIconSelect @ 0x10036bdec
//
// 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 __fastcall GJGarageLayer::onArrow(GJGarageLayer *a1, cocos2d::CCObject *a2)
{
int v2; // r15d
GameManager *v3; // rax
GameManager *v4; // rax
int v5; // eax
std::__tree_end_node *>::pointer left; // rcx
IconType m_iconType; // r12d
std::__compressed_pair *>> *p_pair1; // r14
std::__compressed_pair *>> *v9; // r13
IconType v10; // ecx
std::__compressed_pair *>> *v11; // r15
std::__tree_end_node *> *v12; // rax
int v13; // edx
int v14; // eax
int v15; // esi
int v16; // [rsp+0h] [rbp-30h]
int v17; // [rsp+4h] [rbp-2Ch]
v2 = ((__int64 (__fastcall *)(cocos2d::CCObject *))a2->getTag)(a2);
v3 = GameManager::sharedState();
GameManager::activeIconForType(v3, a1->m_iconType);
v4 = GameManager::sharedState();
v5 = GameManager::countForType(v4, a1->m_iconType);
left = a1->m_iconPages.__tree_.__pair1_.__value_.__left_;
m_iconType = a1->m_iconType;
if ( left )
{
while ( 1 )
{
while ( 1 )
{
v9 = (std::__compressed_pair *>> *)left;
v10 = *((_DWORD *)left + 7);
if ( m_iconType >= v10 )
break;
left = v9->__value_.__left_;
p_pair1 = v9;
if ( !v9->__value_.__left_ )
goto LABEL_8;
}
if ( m_iconType <= v10 )
break;
left = v9[1].__value_.__left_;
if ( !left )
{
p_pair1 = v9 + 1;
goto LABEL_8;
}
}
}
else
{
p_pair1 = &a1->m_iconPages.__tree_.__pair1_;
v9 = &a1->m_iconPages.__tree_.__pair1_;
LABEL_8:
v17 = v5;
v16 = v2;
v11 = v9;
v9 = (std::__compressed_pair *>> *)operator new(0x28u);
HIDWORD(v9[3].__value_.__left_) = m_iconType;
LODWORD(v9[4].__value_.__left_) = 0;
*(_OWORD *)&v9->__value_.__left_ = 0;
v9[2].__value_.__left_ = (std::__tree_end_node *>::pointer)v11;
p_pair1->__value_.__left_ = (std::__tree_end_node *>::pointer)v9;
v12 = (std::__tree_end_node *> *)a1->m_iconPages.__tree_.__begin_node_->__left_;
if ( v12 )
a1->m_iconPages.__tree_.__begin_node_ = v12;
sub_100054DD0((__int64 *)a1->m_iconPages.__tree_.__pair1_.__value_.__left_, (__int64 *)v9);
++a1->m_iconPages.__tree_.__pair3_.__value_;
m_iconType = a1->m_iconType;
v2 = v16;
v5 = v17;
}
v13 = v5 / 36;
v14 = LODWORD(v9[4].__value_.__left_) + 2 * (v2 == 1) - 1;
v15 = 0;
if ( v14 <= v13 )
v15 = LODWORD(v9[4].__value_.__left_) + 2 * (v2 == 1) - 1;
if ( v14 < 0 )
v15 = v13;
GJGarageLayer::setupPage(a1, v15, m_iconType);
}