//
// GJGarageLayer::getItems from 0x1402767f0 to 0x140276ab8 (712 bytes)
//
// 3 xrefs:
// > GJGarageLayer::setupPage @ 0x1402761e8
// > GJGarageLayer::getItems_1 @ 0x1402767d0
// > ??> @ 0x1406d0f8c
//
// 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=4
cocos2d::CCArray *GJGarageLayer::getItems(GJGarageLayer *a1, int a2, int a3, IconType a4, int a5)
{
GameManager *v8; // rcx
UnlockType v9; // r13d
__int64 v10; // rcx
cocos2d::CCArray *v11; // r14
int v12; // ecx
int v13; // r12d
unsigned int v14; // esi
GameManager *v15; // rcx
bool isIconUnlocked; // r15
GJItemIcon *BrowserItem; // r14
float v18; // xmm0_4
float v19; // xmm7_4
CCMenuItemSpriteExtra *v20; // rax
CCMenuItemSpriteExtra *v21; // rdi
CCMenuItemSpriteExtra_vtbl *v22; // rbx
__int64 v23; // rax
GJItemIcon_vtbl *v24; // rbx
float *v25; // rax
const cocos2d::CCPoint *v26; // rax
cocos2d::CCArray *v27; // rbx
struct cocos2d::CCSprite *v29; // [rsp+30h] [rbp-98h]
void *v30; // [rsp+38h] [rbp-90h]
CCMenuItemSpriteExtra *v31; // [rsp+40h] [rbp-88h]
void *v32; // [rsp+D0h] [rbp+8h]
cocos2d::CCArray *v33; // [rsp+D0h] [rbp+8h]
IconType v34; // [rsp+E8h] [rbp+20h] BYREF
v34 = a4;
*(_DWORD *)sub_14012CE70((__int64 *)&a1->m_iconPages, (int *)&v34) = a3;
if ( !qword_1406C2ED8 )
{
v32 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v32);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
}
v9 = GameManager::iconTypeToUnlockType(v8, v34);
v11 = (cocos2d::CCArray *)cocos2d::CCArray::create(v10);
v33 = v11;
v29 = cocos2d::CCSprite::createWithSpriteFrameName("playerSquare_001.png");
a1->m_currentIcon = nullptr;
v12 = 36 * a3;
v13 = 36 * a3 + 36;
if ( a2 < v13 )
v13 = a2;
v14 = v12 + 1;
if ( v12 + 1 <= v13 )
{
while ( 1 )
{
v15 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v30 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v30);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v15 = (GameManager *)qword_1406C2ED8;
}
isIconUnlocked = GameManager::isIconUnlocked(v15, v14, v34);
BrowserItem = GJItemIcon::createBrowserItem(v9, v14);
if ( BrowserItem )
break;
v27 = v33;
LABEL_19:
if ( (int)++v14 > v13 )
return v27;
}
v18 = GJItemIcon::scaleForType(v9);
v19 = v18;
((void (__fastcall *)(GJItemIcon *))BrowserItem->setScale_0)(BrowserItem);
v31 = (CCMenuItemSpriteExtra *)operator new(0x208u);
v20 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(v31);
v21 = v20;
if ( v20 )
{
if ( CCMenuItemSpriteExtra::init(
v20,
BrowserItem,
nullptr,
a1,
(cocos2d::SEL_MenuHandler *)GJGarageLayer::onSelect) )
{
cocos2d::CCObject::autorelease(v21);
LABEL_14:
v22 = v21->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v23 = (__int64)v29->getContentSize(v29);
v22->setContentSize(v21, (const cocos2d::CCSize *)v23);
v24 = BrowserItem->cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v21->getContentSize(v21);
v25 = (float *)v21->getContentSize(v21);
cocos2d::CCPoint::CCPoint(v18, *v25 * 0.5);
v24->setPosition_0(BrowserItem, v26);
v21->setTag(v21, v14);
LODWORD(v21->m_startPosition.x) = v34;
v27 = v33;
cocos2d::CCArray::addObject(v33, v21);
if ( v14 == a5 )
a1->m_currentIcon = v21;
if ( !isIconUnlocked )
GJItemIcon::changeToLockedState(BrowserItem, 1.0 / v19);
goto LABEL_19;
}
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64))v21->~CCMenuItemSpriteExtra)(v21, 1);
}
v21 = nullptr;
goto LABEL_14;
}
return v11;
}