//
// GJGarageLayer::onSelect from 0x7929e0 to 0x792ea8 (1224 bytes)
//
// 3 xrefs:
// > ??> @ 0x64410
// > GJGarageLayer::getItems @ 0x796c24
// > ??> @ 0x122b3c0
//
// 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 GJGarageLayer::onSelect(GJGarageLayer *a1, cocos2d::CCObject *a2)
{
int v4; // w0
IconType m_nTag; // w21
unsigned int v6; // w22
GameManager *v7; // x0
cocos2d::CCSprite *m_cursor1; // x24
void (__fastcall *setPosition)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x26
cocos2d::CCNode *v10; // x27
const cocos2d::CCPoint *v11; // x0
void (__fastcall *showUnlockPopup)(GJGarageLayer *__hidden, int, UnlockType); // x19
GameManager *v13; // x0
UnlockType v14; // w0
GameManager *v15; // x0
SimplePlayer *m_playerObject; // x19
void (__fastcall *setScale)(cocos2d::CCSprite *__hidden, float); // x24
long double v18; // q0
void (__fastcall *v19)(GJGarageLayer *__hidden, int, UnlockType); // x19
GameManager *v20; // x0
UnlockType v21; // w0
GameManager *v22; // x0
GameManager *v23; // x24
int v24; // w0
GameManager *v25; // x0
GameManager *v26; // x24
int v27; // w0
GameManager *v28; // x0
GameManager *v29; // x24
int v30; // w0
GameManager *v31; // x0
GameManager *v32; // x24
int v33; // w0
GameManager *v34; // x0
GameManager *v35; // x24
int v36; // w0
GameManager *v37; // x0
GameManager *v38; // x24
int v39; // w0
GameManager *v40; // x0
GameManager *v41; // x24
int v42; // w0
GameManager *v43; // x0
GameManager *v44; // x24
int v45; // w0
GameManager *v46; // x0
GameManager *v47; // x24
int v48; // w0
GameManager *v49; // x0
GameManager *v50; // x24
int v51; // w0
GameManager *v52; // x0
GameManager *v53; // x24
int v54; // w0
GameManager *v55; // x0
GameManager *v56; // x24
int v57; // w0
_BYTE v58[8]; // [xsp+60h] [xbp+60h] BYREF
cocos2d::CCPoint v59; // 0:kr00_8.8
v4 = a2->getTag(a2);
m_nTag = a2[8].m_nTag;
v6 = v4;
v7 = GameManager::sharedState();
if ( !GameManager::isIconUnlocked(v7, v6, m_nTag) )
{
showUnlockPopup = a1->showUnlockPopup;
v13 = GameManager::sharedState();
v14 = GameManager::iconTypeToUnlockType(v13, m_nTag);
showUnlockPopup(a1, v6, v14);
return;
}
GameManager::sharedState()->m_scoreValid = 0;
switch ( m_nTag )
{
case Cube:
v25 = GameManager::sharedState();
v25->m_playerFrame.value = v6;
v26 = v25;
v27 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0);
v26->m_playerFrame.seed = v27;
v26->m_playerFrame.random = v6 + v27;
break;
case Ship:
v28 = GameManager::sharedState();
v28->m_playerShip.value = v6;
v29 = v28;
v30 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0);
v29->m_playerShip.seed = v30;
v29->m_playerShip.random = v6 + v30;
break;
case Ball:
v31 = GameManager::sharedState();
v31->m_playerBall.value = v6;
v32 = v31;
v33 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0);
v32->m_playerBall.seed = v33;
v32->m_playerBall.random = v6 + v33;
break;
case Ufo:
v34 = GameManager::sharedState();
v34->m_playerBird.value = v6;
v35 = v34;
v36 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0);
v35->m_playerBird.seed = v36;
v35->m_playerBird.random = v6 + v36;
break;
case Wave:
v37 = GameManager::sharedState();
v37->m_playerDart.value = v6;
v38 = v37;
v39 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0);
v38->m_playerDart.seed = v39;
v38->m_playerDart.random = v6 + v39;
break;
case Robot:
v40 = GameManager::sharedState();
v40->m_playerRobot.value = v6;
v41 = v40;
v42 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0);
v41->m_playerRobot.seed = v42;
v41->m_playerRobot.random = v6 + v42;
break;
case Spider:
v43 = GameManager::sharedState();
v43->m_playerSpider.value = v6;
v44 = v43;
v45 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0);
v44->m_playerSpider.seed = v45;
v44->m_playerSpider.random = v6 + v45;
break;
case Swing:
v46 = GameManager::sharedState();
v46->m_playerSwing.value = v6;
v47 = v46;
v48 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0);
v47->m_playerSwing.seed = v48;
v47->m_playerSwing.random = v6 + v48;
break;
case Jetpack:
v49 = GameManager::sharedState();
v49->m_playerJetpack.value = v6;
v50 = v49;
v51 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0);
v50->m_playerJetpack.seed = v51;
v50->m_playerJetpack.random = v6 + v51;
break;
case DeathEffect:
v52 = GameManager::sharedState();
v52->m_playerDeathEffect.value = v6;
v53 = v52;
v54 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0);
v53->m_playerDeathEffect.seed = v54;
v53->m_playerDeathEffect.random = v6 + v54;
break;
case Special:
v55 = GameManager::sharedState();
v55->m_playerStreak.value = v6;
v56 = v55;
v57 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0);
v56->m_playerStreak.seed = v57;
v56->m_playerStreak.random = v6 + v57;
break;
case ShipFire:
v22 = GameManager::sharedState();
v22->m_playerShipFire.value = v6;
v23 = v22;
v24 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0);
v23->m_playerShipFire.seed = v24;
v23->m_playerShipFire.random = v6 + v24;
break;
default:
break;
}
SimplePlayer::updateColors(a1->m_playerObject);
if ( v6 == 2 && m_nTag == Special )
{
GJGarageLayer::playRainbowEffect(a1);
goto LABEL_6;
}
if ( m_nTag != ShipFire )
{
LABEL_6:
m_cursor1 = a1->m_cursor1;
goto LABEL_7;
}
m_cursor1 = a1->m_cursor2;
LABEL_7:
setPosition = m_cursor1->setPosition;
v10 = (cocos2d::CCNode *)((__int64 (__fastcall *)(cocos2d::CCObject *))a2->__vftable[6].~CCObject_0)(a2);
v11 = (const cocos2d::CCPoint *)((__int64 (__fastcall *)(cocos2d::CCObject *))a2->__vftable[2].acceptVisitor)(a2);
v59 = cocos2d::CCNode::convertToWorldSpace(v10, v11);
((void (__fastcall *)(cocos2d::CCSprite *, _BYTE *, float, float))setPosition)(m_cursor1, v58, v59.x, v59.y);
m_cursor1->setVisible(m_cursor1, 1);
if ( (unsigned int)m_nTag <= Jetpack )
{
SimplePlayer::updatePlayerFrame(a1->m_playerObject, v6, a1->m_iconType);
v15 = GameManager::sharedState();
m_playerObject = a1->m_playerObject;
v15->m_playerIconType = a1->m_iconType;
setScale = m_playerObject->setScale;
if ( GameManager::sharedState()->m_playerIconType == Jetpack )
LODWORD(v18) = 1.5;
else
LODWORD(v18) = 1070386381;
setScale(m_playerObject, v18);
if ( v6 != a1->m_iconID )
goto LABEL_9;
goto LABEL_18;
}
if ( v6 == a1->m_iconID )
{
LABEL_18:
if ( m_nTag == a1->m_selectedIconType )
{
v19 = a1->showUnlockPopup;
v20 = GameManager::sharedState();
v21 = GameManager::iconTypeToUnlockType(v20, m_nTag);
v19(a1, v6, v21);
}
}
LABEL_9:
a1->m_iconID = v6;
a1->m_selectedIconType = m_nTag;
}