//
// GJItemIcon::init from 0x14027ab10 to 0x14027b21c (1804 bytes)
//
// 10 xrefs:
// > AchievementBar::init @ 0x140081701
// > CommunityCreditsPage::init @ 0x140095850
// > AchievementCell::loadFromDict @ 0x1400ad732
// > GJItemIcon::createStoreItem @ 0x14027a9a4
// > GJItemIcon::createBrowserItem @ 0x14027aacb
// > GJPathPage::init @ 0x14028656b
// > RewardUnlockLayer::playRewardEffect @ 0x1403cf8e1
// > RewardUnlockLayer::playRewardEffect @ 0x1403d00b6
// > ShardsPage::init @ 0x14048c06b
// > ??> @ 0x1406d1100
//
// 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
//
// Hidden C++ exception states: #wind=5
bool GJItemIcon::init(
GJItemIcon *a1,
UnlockType a2,
int a3,
cocos2d::ccColor3B *a4,
cocos2d::ccColor3B *a5,
bool a6,
bool a7,
bool a8,
cocos2d::ccColor3B *a9)
{
bool result; // al
__int64 v14; // rdx
int v15; // ecx
float v16; // xmm0_4
__int16 v17; // ax
GameManager *v18; // rcx
SimplePlayer *v19; // rsi
__int64 v20; // rdi
__int64 v21; // r8
__int64 v22; // rax
struct cocos2d::CCSprite *v23; // rax
cocos2d::ccColor3B *v24; // rcx
__int16 *v25; // rcx
struct cocos2d::CCLabelBMFont *v26; // rdi
cocos2d::CCLabelBMFont_vtbl *v27; // rbx
float *v28; // rax
const cocos2d::CCPoint *v29; // rax
cocos2d::CCString *v30; // rax
const char *CString; // rax
__int64 v32; // rdx
float v33; // xmm0_4
SimplePlayer_vtbl *v34; // rbx
const cocos2d::CCPoint *v35; // rax
void *v36; // rcx
void *v37; // [rsp+20h] [rbp-61h] BYREF
cocos2d::CCSize v38; // [rsp+28h] [rbp-59h] BYREF
void *v39; // [rsp+30h] [rbp-51h]
void *Block[2]; // [rsp+38h] [rbp-49h] BYREF
__int64 v41; // [rsp+48h] [rbp-39h]
unsigned __int64 v42; // [rsp+50h] [rbp-31h]
result = cocos2d::CCSprite::init(a1);
if ( result )
{
a1->m_unlockID = a3;
a1->m_unlockType = a2;
v14 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v37 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v37);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v14 = qword_1406C2ED8;
}
v15 = *(_DWORD *)(v14 + 1176);
*(_DWORD *)(v14 + 1176) = v15 + 1;
a1->m_iconRequestID = v15;
a1->setTextureRect_0(a1, &stru_1406C1DF0);
cocos2d::CCSize::CCSize(&v38, 30.0, 30.0);
cocos2d::CCSize::operator=(&a1->m_playerSize, &v38);
a1->setContentSize(a1, &v38);
v16 = 0.0;
*(_OWORD *)Block = 0;
v42 = 15;
LOBYTE(Block[0]) = 0;
switch ( a2 )
{
case 4:
v41 = 4;
strcpy((char *)Block, "ship");
goto LABEL_19;
case 5:
v41 = 11;
v16 = 7.3154135e34;
strcpy((char *)Block, "player_ball");
goto LABEL_19;
case 6:
v41 = 4;
strcpy((char *)Block, "bird");
goto LABEL_19;
case 7:
v41 = 4;
strcpy((char *)Block, "dart");
goto LABEL_19;
case 8:
v41 = 5;
strcpy((char *)Block, "robot");
goto LABEL_19;
case 9:
LODWORD(Block[0]) = 1684631667;
v17 = 29285;
goto LABEL_18;
case 10:
v41 = 14;
v16 = 7.3154135e34;
strcpy((char *)Block, "player_special");
goto LABEL_19;
case 11:
v41 = 13;
v16 = 1.162843e27;
strcpy((char *)Block, "explosionIcon");
goto LABEL_19;
case 12:
LODWORD(Block[0]) = 1950968423;
v17 = 28005;
goto LABEL_18;
case 13:
v41 = 5;
strcpy((char *)Block, "swing");
goto LABEL_19;
case 14:
v41 = 7;
Block[0] = (void *)0x6B63617074656ALL;
goto LABEL_19;
case 15:
v41 = 12;
v16 = 2.8894511e29;
strcpy((char *)Block, "shipfireIcon");
goto LABEL_19;
default:
LODWORD(Block[0]) = 2036427888;
v17 = 29285;
LABEL_18:
v41 = 6;
WORD2(Block[0]) = v17;
BYTE6(Block[0]) = 0;
LABEL_19:
switch ( a2 )
{
case 1:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 13:
case 14:
a1->m_isIcon = 1;
v19 = SimplePlayer::create(1);
if ( !qword_1406C2ED8 )
{
v37 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v37);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
}
v20 = GameManager::unlockTypeToIconType(v18, a2);
if ( !v21 )
{
v37 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v37);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v21 = qword_1406C2ED8;
}
LODWORD(v37) = a3 + *(_DWORD *)(*(_QWORD *)(v21 + 1136) + 4 * v20) - 1;
sub_14012CE70((__int64 *)(v21 + 1088), (int *)&v37);
SimplePlayer::updatePlayerFrame(v19, a3, (IconType)v20);
v19->m_firstLayer->setColor(&v19->m_firstLayer->cocos2d::CCRGBAProtocol, a4);
v19->m_secondLayer->setColor(&v19->m_secondLayer->cocos2d::CCRGBAProtocol, a5);
SimplePlayer::updateColors(v19);
v22 = (__int64)v19->m_firstLayer->getContentSize(v19->m_firstLayer);
cocos2d::CCSize::operator=(&a1->m_playerSize, v22);
break;
case 2:
case 3:
v23 = cocos2d::CCSprite::createWithSpriteFrameName("player_special_01_001.png");
v19 = (SimplePlayer *)v23;
if ( a6 )
goto LABEL_36;
v24 = (cocos2d::ccColor3B *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v39 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v39);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v24 = (cocos2d::ccColor3B *)qword_1406C2ED8;
}
GameManager::colorForIdx(v24, (GameManager *)&v37, a3);
v19->setColor(&v19->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&v37);
if ( !a8 )
{
v25 = &word_140531EA0;
if ( a2 == Col1 )
v25 = &word_140531EA4;
v26 = cocos2d::CCLabelBMFont::create((const char *)v25, (const char *)&qword_14052A4D8);
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *))v26->setScale_0)(v26);
v26->setColor(&v26->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&v37);
v19->addChild_0(v19, v26, 1);
v27 = v26->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v19->getContentSize(v19);
v28 = (float *)v19->getContentSize(v19);
cocos2d::CCPoint::CCPoint(v16, *v28 * 0.5);
v27->setPosition_0(v26, v29);
}
break;
default:
if ( a1->m_unlockType == GJItem && (unsigned int)(a3 - 6) <= 9 )
{
v19 = (SimplePlayer *)GJPathSprite::create(a3 - 5);
}
else
{
v30 = cocos2d::CCString::createWithFormat("%s_%02d_001.png", (const char *)Block, a3);
CString = cocos2d::CCString::getCString(v30);
v23 = cocos2d::CCSprite::createWithSpriteFrameName(CString);
v19 = (SimplePlayer *)v23;
if ( a6 )
{
LABEL_36:
v23->setColor(&v23->cocos2d::CCRGBAProtocol, &stru_140529AB8);
LOBYTE(v32) = 120;
v19->setOpacity(&v19->cocos2d::CCRGBAProtocol, v32);
}
}
break;
}
v33 = ((float (__fastcall *)(GJItemIcon *, SimplePlayer *))a1->addChild_1)(a1, v19);
v34 = v19->cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v33, v38.width * 0.5);
v34->setPosition_0(v19, v35);
a1->m_player = v19;
if ( v42 > 0xF )
{
v36 = Block[0];
if ( v42 + 1 >= 0x1000 )
{
v36 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v36 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v36);
}
result = 1;
break;
}
}
return result;
}