//
// GJBaseGameLayer::positionUIObjects from 0x878604 to 0x878b54 (1360 bytes)
//
// 2 xrefs:
// > GJBaseGameLayer::updateSpecialGroupData @ 0x897fb4
// > ??> @ 0x9bc28
//
// 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 GJBaseGameLayer::positionUIObjects(GJBaseGameLayer *a1)
{
cocos2d::CCDirector *v2; // x0
cocos2d::CCArray *v3; // x0
__int64 v4; // x0
cocos2d::CCArray *m_objects; // x24
cocos2d::CCArray *v6; // x21
cocos2d::ccArray *data; // x25
cocos2d::CCObject **arr; // x27
__int64 v9; // x4
char *v10; // x26
float v11; // s13
cocos2d::CCObject **v12; // x28
float v13; // s12
cocos2d::CCObject *v14; // x27
GameObject *GroupParent; // x22
GameObject *MainObject; // x0
void *v17; // x5
cocos2d::CCArray *v18; // x24
cocos2d::ccArray *v19; // x0
GameObject **v20; // x23
__int64 v21; // x24
char *v22; // x1
GameObject **v23; // x24
GameObject *v24; // x23
unsigned __int64 v25; // x22
unsigned int m_eObjType; // w1
int m_uIndexInArray; // w0
cocos2d::ccArray *v28; // x0
GameObject **v29; // x2
GameObject **v30; // x5
GameObject *v31; // x20
GameObject **v32; // x23
float v33; // s0
float v34; // s0
float x; // s0
float v36; // s1
float v37; // s0
float v38; // s1
float v39; // s1
float v40; // s0
GameObject **v41; // [xsp+98h] [xbp+98h]
void (__fastcall *v42)(GameObject *__hidden, cocos2d::CCPoint); // [xsp+A0h] [xbp+A0h]
GameObject *v43; // [xsp+B0h] [xbp+B0h]
GJBaseGameLayer *v44; // [xsp+D8h] [xbp+D8h]
GJBaseGameLayer *setStartPos; // [xsp+D8h] [xbp+D8h]
GJBaseGameLayer *v46; // [xsp+D8h] [xbp+D8h]
cocos2d::CCArray *Group; // [xsp+E8h] [xbp+E8h]
float v48; // [xsp+F8h] [xbp+F8h]
float v49; // [xsp+FCh] [xbp+FCh]
cocos2d::CCPoint v50; // [xsp+100h] [xbp+100h] BYREF
float v51; // [xsp+108h] [xbp+108h]
float v52; // [xsp+10Ch] [xbp+10Ch]
cocos2d::CCPoint v53; // [xsp+110h] [xbp+110h] BYREF
cocos2d::CCPoint v54; // [xsp+118h] [xbp+118h] BYREF
__int64 v55; // [xsp+120h] [xbp+120h] BYREF
char v56[8]; // [xsp+128h] [xbp+128h] BYREF
cocos2d::CCPoint v57; // [xsp+130h] [xbp+130h] BYREF
v2 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v2);
v3 = (cocos2d::CCArray *)cocos2d::CCPoint::CCPoint(&v50, v48 * 0.5, v49 * 0.5);
v4 = cocos2d::CCArray::create(v3);
m_objects = a1->m_objects;
v6 = (cocos2d::CCArray *)v4;
if ( m_objects )
{
data = m_objects->data;
if ( data->num )
{
arr = data->arr;
v9 = 8LL * data->num - 8;
v10 = (char *)arr + v9;
if ( arr <= (cocos2d::CCObject **)((char *)arr + v9) )
{
if ( *arr )
{
v11 = (float)(v48 * 0.5) / 240.0;
v12 = data->arr;
v13 = (float)(v49 * 0.5) / 160.0;
v14 = *arr;
while ( 1 )
{
if ( HIDWORD(v14[18].__vftable) == 3613 )
{
Group = GJBaseGameLayer::getGroup(a1, v14[25].m_uOrderOfArrival);
GroupParent = GJBaseGameLayer::getGroupParent(a1, v14[25].m_uOrderOfArrival);
MainObject = GJBaseGameLayer::tryGetMainObject(a1, v14[25].m_unknown5);
v17 = MainObject;
if ( GroupParent )
{
v44 = (GJBaseGameLayer *)MainObject;
v18 = v6;
cocos2d::CCArray::removeAllObjects(v6);
cocos2d::CCArray::addObject(v6, GroupParent);
v17 = v44;
}
else
{
v18 = Group;
}
if ( v18 )
{
if ( v17 )
{
(*(void (__fastcall **)(void *))(*(_QWORD *)v17 + 1800LL))(v17);
v19 = v18->data;
if ( v19->num )
{
v20 = (GameObject **)v19->arr;
v21 = 8LL * v19->num - 8;
v22 = (char *)v20 + v21;
if ( v20 <= (GameObject **)((char *)v20 + v21) )
{
if ( *v20 )
{
v23 = (GameObject **)v19->arr;
v24 = *v20;
v43 = GroupParent;
v25 = (unsigned __int64)v22;
if ( !v24->m_isUIObject )
goto LABEL_21;
while ( v25 >= (unsigned __int64)++v23 )
{
v24 = *v23;
if ( !*v23 )
break;
if ( !v24->m_isUIObject )
{
LABEL_21:
GJBaseGameLayer::addUIObject(a1, v24);
v24->getStartPos(v24);
cocos2d::CCPoint::CCPoint(&v54, &v53);
m_eObjType = v14[32].m_eObjType;
m_uIndexInArray = v14[32].m_uIndexInArray;
if ( m_eObjType <= 1 )
{
x = v53.x;
v36 = v51;
if ( v53.x >= v51 )
{
if ( !m_uIndexInArray || m_uIndexInArray == 5 )
{
if ( v53.y >= v52 )
m_uIndexInArray = 8;
else
m_uIndexInArray = 7;
goto LABEL_69;
}
LABEL_70:
v39 = x - (float)(v36 + 240.0);
if ( LOBYTE(v14[32].m_uUnknown) )
v39 = v39 * v11;
v37 = v48 + v39;
}
else
{
if ( !m_uIndexInArray || m_uIndexInArray == 5 )
{
if ( v53.y >= v52 )
m_uIndexInArray = 8;
else
m_uIndexInArray = 7;
goto LABEL_63;
}
LABEL_54:
v37 = x - (float)(v36 - 240.0);
if ( LOBYTE(v14[32].m_uUnknown) )
v37 = v37 * v11;
}
v54.x = v37;
goto LABEL_27;
}
if ( !m_uIndexInArray || m_uIndexInArray == 5 )
{
if ( v53.y >= v52 )
m_uIndexInArray = 8;
else
m_uIndexInArray = 7;
}
if ( m_eObjType != 2 )
{
if ( m_eObjType != 3 )
{
if ( m_eObjType != 4 )
goto LABEL_27;
LABEL_69:
x = v53.x;
v36 = v51;
goto LABEL_70;
}
LABEL_63:
x = v53.x;
v36 = v51;
goto LABEL_54;
}
v33 = v53.x - v51;
if ( LOBYTE(v14[32].m_uUnknown) )
v33 = v33 * v11;
v54.x = v33 + (float)(v48 * 0.5);
LABEL_27:
if ( m_uIndexInArray == 6 )
{
v34 = v53.y - v52;
if ( BYTE1(v14[32].m_uUnknown) )
v34 = v34 * v13;
v54.y = v34 + (float)(v49 * 0.5);
}
else
{
if ( m_uIndexInArray == 7 )
{
v38 = v53.y - (float)(v52 - 160.0);
if ( BYTE1(v14[32].m_uUnknown) )
v38 = v38 * v13;
}
else
{
if ( m_uIndexInArray != 8 )
goto LABEL_30;
v40 = v53.y - (float)(v52 + 160.0);
if ( BYTE1(v14[32].m_uUnknown) )
v40 = v40 * v13;
v38 = v49 + v40;
}
v54.y = v38;
}
LABEL_30:
setStartPos = (GJBaseGameLayer *)v24->setStartPos;
cocos2d::CCPoint::CCPoint(&v57, &v54);
((void (__fastcall *)(GameObject *, cocos2d::CCPoint *))setStartPos)(v24, &v57);
if ( v24 == v43 )
{
if ( Group )
{
cocos2d::CCPoint::operator-(&v55, &v54, &v53);
v28 = Group->data;
if ( v28->num )
{
v29 = (GameObject **)v28->arr;
v30 = &v29[v28->num - 1];
if ( v29 <= v30 )
{
if ( *v29 )
{
v46 = a1;
v31 = *v29;
v32 = (GameObject **)v28->arr;
do
{
if ( !v31->m_isUIObject )
{
v41 = v30;
GJBaseGameLayer::addUIObject(v46, v31);
v42 = v31->setStartPos;
v31->getStartPos(v31);
cocos2d::CCPoint::operator+(&v57, v56, &v55);
((void (__fastcall *)(GameObject *, cocos2d::CCPoint *))v42)(v31, &v57);
v30 = v41;
}
if ( v30 < ++v32 )
break;
v31 = *v32;
}
while ( *v32 );
a1 = v46;
}
}
}
}
}
}
}
}
}
}
}
}
}
if ( v10 >= (char *)++v12 )
{
v14 = *v12;
if ( *v12 )
continue;
}
return;
}
}
}
}
}
}