//
// GJItemIcon::init from 0x794308 to 0x79486c (1380 bytes)
//
// 2 xrefs:
// > GJItemIcon::create @ 0x794920
// > ??> @ 0x6b208
//
// 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
//
// local variable allocation has failed, the output may be wrong!
bool GJItemIcon::init(
GJItemIcon *a1,
UnlockType a2,
int a3,
cocos2d::ccColor3B a4,
cocos2d::ccColor3B a5,
bool a6,
bool a7,
bool a8,
cocos2d::ccColor3B a9)
{
_BOOL4 v12; // w26
_BOOL4 v13; // w27
bool v14; // w21
GameManager *v16; // x0
cocos2d::CCString *v17; // x0
const char *CString; // x0
cocos2d::CCSprite *v19; // x0
SimplePlayer *v20; // x22
void (__fastcall *v21)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x25
char *v22; // x22
unsigned int *v23; // x19
int v24; // w0
GameManager *v25; // x0
SimplePlayer_vtbl *v26; // x2
void (__fastcall *setColor)(SimplePlayer *__hidden, const cocos2d::ccColor3B *); // x2
cocos2d::CCLabelBMFont *v28; // x25
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x26
float v30; // s8
__int64 v31; // x0
GameManager *v32; // x0
IconType v33; // w24
GameManager *v34; // x0
__int64 v35; // x0
__int64 v36; // [xsp+80h] [xbp+80h] BYREF
__int64 v37; // [xsp+88h] [xbp+88h] BYREF
_BYTE v38[8]; // [xsp+98h] [xbp+98h] BYREF
cocos2d::CCSize v39; // [xsp+A0h] [xbp+A0h] BYREF
char *v40; // [xsp+A8h] [xbp+A8h] BYREF
cocos2d::CCPoint v41; // [xsp+B0h] [xbp+B0h] BYREF
cocos2d::ccColor3B v42; // 0:w0.3
v37 = *(_QWORD *)&a4.r;
v12 = a6;
v13 = a8;
v36 = *(_QWORD *)&a5.r;
v14 = cocos2d::CCSprite::init(a1);
if ( v14 )
{
a1->m_unlockID = a3;
a1->m_unlockType = a2;
v16 = GameManager::sharedState();
a1->m_iconRequestID = GameManager::getIconRequestID(v16);
a1->setTextureRect(a1, &stru_1242538);
cocos2d::CCSize::CCSize(&v39, 30.0, 30.0);
cocos2d::CCSize::operator=(&a1->m_playerSize, &v39);
a1->setContentSize(a1, &v39);
v40 = &byte_124B6C8;
switch ( a2 )
{
case 4:
sub_D1798C(&v40, "ship", 4);
break;
case 5:
sub_D1798C(&v40, "player_ball", 11);
break;
case 6:
sub_D1798C(&v40, "bird", 4);
break;
case 7:
sub_D1798C(&v40, "dart", 4);
break;
case 8:
sub_D1798C(&v40, "robot", 5);
break;
case 9:
sub_D1798C(&v40, "spider", 6);
break;
case 10:
sub_D1798C(&v40, "player_special", 14);
break;
case 11:
sub_D1798C(&v40, "explosionIcon", 13);
break;
case 12:
sub_D1798C(&v40, "gjItem", 6);
break;
case 13:
sub_D1798C(&v40, "swing", 5);
break;
case 14:
sub_D1798C(&v40, "jetpack", 7);
break;
case 15:
sub_D1798C(&v40, "shipfireIcon", 12);
break;
default:
sub_D1798C(&v40, "player", 6);
break;
}
switch ( a2 )
{
case 1:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 13:
case 14:
a1->m_isIcon = 1;
v20 = SimplePlayer::create((int)&dword_0 + 1);
v32 = GameManager::sharedState();
v33 = GameManager::unlockTypeToIconType(v32, a2);
v34 = GameManager::sharedState();
GameManager::isIconLoaded(v34, a3, v33);
SimplePlayer::updatePlayerFrame(v20, a3, v33);
SimplePlayer::setColors(v20, (const cocos2d::ccColor3B *)&v37, (const cocos2d::ccColor3B *)&v36);
v35 = (__int64)v20->m_firstLayer->getContentSize(v20->m_firstLayer);
cocos2d::CCSize::operator=(&a1->m_playerSize, v35);
break;
case 2:
case 3:
v19 = cocos2d::CCSprite::createWithSpriteFrameName("player_special_01_001.png");
v20 = (SimplePlayer *)v19;
if ( v12 )
goto LABEL_20;
v25 = GameManager::sharedState();
v42 = GameManager::colorForIdx(v25, a3);
v26 = v20->cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v38[0] = v42.r;
setColor = v26->setColor;
v38[1] = v42.g;
v38[2] = v42.b;
setColor(v20, (const cocos2d::ccColor3B *)v38);
if ( !v13 )
{
v28 = cocos2d::CCLabelBMFont::create();
v28->setScale(v28, 0.5);
v28->setColor(v28, (const cocos2d::ccColor3B *)v38);
v20->addChild_0(v20, v28, 1);
setPosition = v28->setPosition;
v30 = v20->getContentSize(v20)->width * 0.5;
v31 = (__int64)v20->getContentSize(v20);
cocos2d::CCPoint::CCPoint(&v41, v30, *(float *)(v31 + 4) * 0.5);
setPosition(v28, &v41);
}
break;
default:
if ( a1->m_unlockType == GJItem && (unsigned int)(a3 - 6) <= 9 )
{
v20 = (SimplePlayer *)GJPathSprite::create(a3 - 5);
}
else
{
v17 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%s_%02d_001.png",
v40,
(unsigned int)a3);
CString = cocos2d::CCString::getCString(v17);
v19 = cocos2d::CCSprite::createWithSpriteFrameName(CString);
v20 = (SimplePlayer *)v19;
if ( v12 )
{
LABEL_20:
v20->setColor((SimplePlayer *)v19, (const cocos2d::ccColor3B *)&unk_ECEDE0);
v20->setOpacity(v20, 120u);
}
}
break;
}
a1->addChild(a1, v20);
v21 = v20->setPosition;
cocos2d::CCPoint::CCPoint(&v41, v39.width * 0.5, v39.height * 0.5);
v21(v20, &v41);
a1->m_player = v20;
v22 = v40 - 24;
if ( v40 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v23 = (unsigned int *)(v40 - 8);
do
v24 = __ldaxr(v23);
while ( __stlxr(v24 - 1, v23) );
}
else
{
v24 = *((_DWORD *)v40 - 2);
*((_DWORD *)v40 - 2) = v24 - 1;
}
if ( v24 <= 0 )
operator delete(v22);
}
}
return v14;
}