//
// PlayLayer::addObject from 0x5cc428 to 0x5ccff0 (3016 bytes)
//
// 5 xrefs:
// > PlayLayer::addObject @ 0x5ccdd4
// > PlayLayer::setupHasCompleted @ 0x5dcb0c
// > PlayLayer::processCreateObjectsFromSetup @ 0x5dd63c
// > PlayLayer::processCreateObjectsFromSetup @ 0x5dd6f8
// > ??> @ 0xa69f8
//
// 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 PlayLayer::addObject(PlayLayer *a1, GameObject *a2)
{
int v4; // w1
int m_objectID; // w0
StartPosObject *m_startPosObject; // x1
int m_targetOrder; // w22
float x; // s8
const cocos2d::CCPoint *v9; // x0
__int64 v10; // x1
float v11; // s0
int v12; // w0
unsigned int v13; // w1
_BOOL4 v14; // w24
int v15; // w1
const char *v16; // x0
GameObject *v17; // x0
GameObject_vtbl *v18; // x2
GameObject *v19; // x22
void (__fastcall *v20)(GameObject *__hidden, cocos2d::CCPoint); // x26
const cocos2d::CCPoint *v21; // x0
int v22; // w1
GameObject_vtbl *v23; // x3
bool (__fastcall *v24)(GameObject *__hidden); // x2
void (__fastcall *v25)(GameObject *__hidden, bool); // x23
unsigned int v26; // w0
void (__fastcall *setFlipY)(GameObject *__hidden, bool); // x23
int v28; // w0
void (__fastcall *setRotationX)(GameObject *__hidden, float); // x23
void (__fastcall *setRotationY)(GameObject *__hidden, float); // x23
bool m_startFlipX; // w2
float m_startRotationY; // w1
bool m_isDontEnter; // w4
void (__fastcall *addToSection)(GJBaseGameLayer *__hidden, GameObject *); // x2
float m_startScaleY; // w3
GameObject_vtbl *v36; // x1
PlayerObject *m_player1; // x0
GLubyte r; // w2
GLubyte g; // w1
const char *BallFrame; // x0
GameObject *v41; // x0
GameObject_vtbl *v42; // x1
GameObject *v43; // x22
int m_activeMainColorID; // w1
float width; // s1
float height; // s2
void (__fastcall *v47)(GameObject *__hidden, cocos2d::CCPoint); // x24
const cocos2d::CCPoint *v48; // x0
const cocos2d::CCPoint *v49; // x0
cocos2d::CCSpriteBatchNode *m_gameLayerT1; // x1
float TeleportXOff; // s0
TeleportPortalObject *v52; // x0
GameObject *v53; // x22
void (__fastcall *setStartPos)(GameObject *__hidden, cocos2d::CCPoint); // x25
GameObject_vtbl *v55; // x1
GameObject_vtbl *v56; // x2
bool (__fastcall *isFlipX)(GameObject *__hidden); // x1
void (__fastcall *setFlipX)(GameObject *__hidden, bool); // x25
bool v59; // w0
GameObject_vtbl *v60; // x1
float (__fastcall *getRotation)(cocos2d::CCNode *__hidden); // x1
float v62; // s8
int m_detailColorKeyIndex; // w1
_BOOL4 m_isHide; // w0
PlayerObject *v65; // x0
GLubyte v66; // w2
GLubyte v67; // w1
cocos2d::CCPoint v68; // [xsp+68h] [xbp+68h] BYREF
cocos2d::CCPoint v69; // [xsp+70h] [xbp+70h] BYREF
cocos2d::CCPoint v70; // 0:kr08_8.8
if ( !a2 )
return;
if ( a2->getType(a2) == Slope )
GameObject::determineSlopeDirection(a2);
else
GameObject::updateIsOriented(a2);
a2->setVisible(a2, 0);
a2->getStartPos(a2);
if ( v69.x > a1->m_maxObjectX )
{
a2->getStartPos(a2);
a1->m_maxObjectX = v69.x;
}
if ( !GameObject::isSettingsObject(a2)
&& (a2->getType(a2) != Modifier
|| a2->m_classType == Effect && LOBYTE(a2[1].m_sAdditionalTransform.b)
|| a2->m_objectID == 2063) )
{
a1->addToSection(a1, a2);
}
else
{
a2->m_outerSectionIndex = -1;
}
cocos2d::CCArray::addObject(a1->m_objects, a2);
GJBaseGameLayer::addToGroups(a1, a2, 1);
if ( a2->m_objectID == 1615 )
{
GJBaseGameLayer::addObjectCounter(a1, (LabelGameObject *)a2);
}
else if ( a2->getType(a2) == Collectible || a2->getType(a2) == (Collectible|0x1) )
{
cocos2d::CCArray::addObject(a1->m_collectibles, a2);
GameObject::getActiveColorForMode(a2, a2->m_activeMainColorID, 1);
if ( !GameObject::hasSecondaryColor(a2) )
goto LABEL_12;
goto LABEL_42;
}
GameObject::getActiveColorForMode(a2, a2->m_activeMainColorID, 1);
if ( !GameObject::hasSecondaryColor(a2) )
goto LABEL_12;
LABEL_42:
GameObject::getActiveColorForMode(a2, a2->m_activeDetailColorID, 0);
LABEL_12:
if ( a2->m_isTrigger
&& a2->m_classType == Effect
&& (!LOBYTE(a2[1].m_sAdditionalTransform.b) && !BYTE1(a2[1].m_sAdditionalTransform.b) || a2->isSpecialSpawnObject(a2)) )
{
cocos2d::CCArray::addObject(a1->m_spawnObjectsArray, a2);
}
if ( a1->m_isPlatformer )
a2->m_tempOffsetXRelated = 0;
m_objectID = a2->m_objectID;
if ( m_objectID == 747 )
{
v48 = a2->getPosition(a2);
cocos2d::CCPoint::CCPoint(&v68, v48);
v49 = a2->getPosition(a2);
m_gameLayerT1 = a1->m_gameLayerT1;
v68.y = v49->y + a2[1].m_sQuad.bl.texCoords.u;
TeleportXOff = TeleportPortalObject::getTeleportXOff((TeleportPortalObject *)a2, m_gameLayerT1);
v68.x = TeleportXOff + v68.x;
v52 = TeleportPortalObject::create("portal_16_front_001.png", 0);
*(_QWORD *)&a2[1].m_sQuad.bl.vertices.y = v52;
v53 = v52;
v52->m_objectID = 749;
v52->customSetup(v52);
setStartPos = v53->setStartPos;
cocos2d::CCPoint::CCPoint(&v69, &v68);
((void (__fastcall *)(GameObject *, cocos2d::CCPoint *))setStartPos)(v53, &v69);
v55 = a2->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v53->m_zOrder = a2->m_zOrder;
v56 = v53->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
isFlipX = v55->isFlipX;
v53->m_defaultZOrder = a2->m_defaultZOrder;
v53->m_unk40C = 1;
setFlipX = v56->setFlipX;
v59 = isFlipX(a2);
setFlipX(v53, !v59);
v53->m_startFlipX = ((__int64 (__fastcall *)(GameObject *))a2->isFlipX)(a2) ^ 1;
v60 = a2->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v53->m_isDontEnter = a2->m_isDontEnter;
getRotation = v60->getRotation;
v53->m_isDontFade = a2->m_isDontFade;
v53->m_hasNoEffects = a2->m_hasNoEffects;
v62 = getRotation(a2);
((void (__fastcall *)(GameObject *))v53->setRotation)(v53);
v53->m_startRotationX = v62;
v53->m_startRotationY = v62;
GameObject::copyGroups(v53);
GameObject::updateCustomScaleX(v53, a2->m_scaleX);
GameObject::updateCustomScaleY(v53, a2->m_scaleY);
m_detailColorKeyIndex = a2->m_detailColorKeyIndex;
m_isHide = a2->m_isHide;
v53->m_mainColorKeyIndex = a2->m_mainColorKeyIndex;
v53->m_detailColorKeyIndex = m_detailColorKeyIndex;
if ( m_isHide )
v53->m_isHide = 1;
v53->saveActiveColors(v53);
PlayLayer::addObject(a1, v53);
m_objectID = a2->m_objectID;
}
if ( m_objectID > 287 )
{
if ( m_objectID == 1022 )
goto LABEL_61;
if ( m_objectID <= 1022 )
{
if ( m_objectID == 747 )
goto LABEL_74;
if ( m_objectID <= 747 )
{
if ( m_objectID != 744 )
{
if ( m_objectID != 745 && m_objectID != 660 )
goto LABEL_37;
goto LABEL_74;
}
}
else if ( m_objectID > 900 )
{
if ( m_objectID != 915 )
goto LABEL_37;
}
else if ( m_objectID < 899 )
{
if ( m_objectID != 749 )
goto LABEL_37;
goto LABEL_74;
}
LABEL_92:
if ( BYTE1(a2[1].m_sAdditionalTransform.tx) )
{
m_player1 = a1->m_player1;
r = m_player1->m_playerColor1.r;
g = m_player1->m_playerColor1.g;
BYTE2(a2[1].m_obAnchorPointInPoints.y) = m_player1->m_playerColor1.b;
LOBYTE(a2[1].m_obAnchorPointInPoints.y) = r;
BYTE1(a2[1].m_obAnchorPointInPoints.y) = g;
}
else if ( BYTE2(a2[1].m_sAdditionalTransform.tx) )
{
v65 = a1->m_player1;
v66 = v65->m_playerColor2.r;
v67 = v65->m_playerColor2.g;
BYTE2(a2[1].m_obAnchorPointInPoints.y) = v65->m_playerColor2.b;
LOBYTE(a2[1].m_obAnchorPointInPoints.y) = v66;
BYTE1(a2[1].m_obAnchorPointInPoints.y) = v67;
}
goto LABEL_37;
}
if ( m_objectID == 1816 )
{
if ( BYTE5(a2[1].CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCRGBAProtocol::__vftable) )
cocos2d::CCArray::addObject(a1->m_collisionBlocks, a2);
goto LABEL_37;
}
if ( m_objectID <= 1816 )
{
if ( m_objectID == 1331 )
goto LABEL_74;
if ( m_objectID != 1333 && m_objectID != 1330 )
goto LABEL_37;
goto LABEL_61;
}
if ( m_objectID != 2064 )
{
if ( m_objectID <= 2064 )
{
if ( m_objectID != 1933 )
goto LABEL_37;
}
else if ( m_objectID != 2902 && m_objectID != 2926 )
{
goto LABEL_37;
}
}
LABEL_74:
if ( a2->m_isHide )
goto LABEL_37;
v14 = GJBaseGameLayer::addGuideArt(a1, a2);
v15 = a2->m_objectID;
if ( v15 == 286 )
{
v16 = "portal_11_back_001.png";
goto LABEL_83;
}
if ( v15 <= 286 )
{
if ( v15 == 46 )
{
v16 = "portal_06_back_001.png";
goto LABEL_83;
}
if ( v15 <= 46 )
{
if ( v15 == 12 )
{
v16 = "portal_03_back_001.png";
goto LABEL_83;
}
if ( v15 <= 12 )
{
v16 = "portal_02_back_001.png";
if ( v15 == 11 )
goto LABEL_83;
}
else
{
if ( v15 == 13 )
{
v16 = "portal_04_back_001.png";
goto LABEL_83;
}
v16 = "portal_05_back_001.png";
if ( v15 == 45 )
goto LABEL_83;
}
goto LABEL_126;
}
if ( v15 == 99 )
{
v16 = "portal_08_back_001.png";
goto LABEL_83;
}
if ( v15 <= 99 )
{
v16 = "portal_07_back_001.png";
if ( v15 == 47 )
goto LABEL_83;
goto LABEL_126;
}
if ( v15 == 101 )
{
v16 = "portal_09_back_001.png";
goto LABEL_83;
}
v16 = "portal_10_back_001.png";
if ( v15 != 111 )
LABEL_126:
v16 = "portal_01_back_001.png";
LABEL_83:
v17 = GameObject::createWithFrame(v16);
v18 = v17->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v19 = v17;
v17->m_objectID = 38;
v18->setType(v17, Decoration);
v19->m_isDecoration2 = 1;
v19->customSetup(v19);
v20 = v19->setStartPos;
v21 = a2->getPosition(a2);
cocos2d::CCPoint::CCPoint(&v69, v21);
((void (__fastcall *)(GameObject *, cocos2d::CCPoint *))v20)(v19, &v69);
v19->m_unk40C = 1;
v19->m_defaultZLayer = 4;
v22 = GameObject::getObjectZOrder(a2) - 100 + v14;
v23 = v19->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v24 = a2->isFlipX;
v19->m_defaultZOrder = v22;
v25 = v23->setFlipX;
v26 = ((__int64 (__fastcall *)(GameObject *))v24)(a2);
v25(v19, v26);
setFlipY = v19->setFlipY;
v28 = ((__int64 (__fastcall *)(GameObject *))a2->isFlipY)(a2);
setFlipY(v19, v28);
setRotationX = v19->setRotationX;
a2->getRotationX(a2);
((void (__fastcall *)(GameObject *))setRotationX)(v19);
setRotationY = v19->setRotationY;
a2->getRotationY(a2);
((void (__fastcall *)(GameObject *))setRotationY)(v19);
m_startFlipX = a2->m_startFlipX;
v19->m_startRotationX = a2->m_startRotationX;
m_startRotationY = a2->m_startRotationY;
v19->m_startFlipX = m_startFlipX;
v19->m_startFlipY = a2->m_startFlipY;
v19->m_startRotationY = m_startRotationY;
GameObject::updateCustomScaleX(v19, a2->m_scaleX);
GameObject::updateCustomScaleY(v19, a2->m_scaleY);
m_isDontEnter = a2->m_isDontEnter;
addToSection = a1->addToSection;
v19->m_startScaleX = a2->m_startScaleX;
m_startScaleY = a2->m_startScaleY;
v19->m_isDontEnter = m_isDontEnter;
v19->m_isDontFade = a2->m_isDontFade;
v19->m_startScaleY = m_startScaleY;
v19->m_hasNoEffects = a2->m_hasNoEffects;
addToSection(a1, v19);
cocos2d::CCArray::addObject(a1->m_objects, v19);
GameObject::copyGroups(v19);
GJBaseGameLayer::addToGroups(a1, v19, 1);
v36 = v19->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a2->m_unk40C = 1;
a2->m_defaultZOrder = v14 + 12;
v36->saveActiveColors(v19);
*(_QWORD *)&v19->m_mainColorKeyIndex = *(_QWORD *)&a2->m_mainColorKeyIndex;
goto LABEL_37;
}
if ( v15 != 749 )
{
if ( v15 <= 749 )
{
if ( v15 == 660 )
{
v16 = "portal_13_back_001.png";
goto LABEL_83;
}
if ( v15 <= 660 )
{
v16 = "portal_12_back_001.png";
if ( v15 == 287 )
goto LABEL_83;
goto LABEL_126;
}
if ( v15 == 745 )
{
v16 = "portal_14_back_001.png";
goto LABEL_83;
}
if ( v15 != 747 )
goto LABEL_126;
goto LABEL_150;
}
if ( v15 != 2064 )
{
if ( v15 <= 2064 )
{
if ( v15 == 1331 )
{
v16 = "portal_17_back_001.png";
goto LABEL_83;
}
v16 = "portal_18_back_001.png";
if ( v15 != 1933 )
goto LABEL_126;
goto LABEL_83;
}
if ( v15 != 2902 )
{
v16 = "portal_19_back_001.png";
if ( v15 == 2926 )
goto LABEL_83;
goto LABEL_126;
}
LABEL_150:
v16 = "portal_15_back_001.png";
goto LABEL_83;
}
}
v16 = "portal_16_back_001.png";
goto LABEL_83;
}
if ( m_objectID >= 286 )
goto LABEL_74;
if ( m_objectID == 36 )
goto LABEL_61;
if ( m_objectID <= 36 )
{
if ( m_objectID > 17 )
{
if ( m_objectID < 29 )
goto LABEL_37;
if ( m_objectID > 30 )
{
if ( m_objectID == 31 && !*(_BYTE *)(*(_QWORD *)&a2[1].m_sQuad.bl.vertices.y + 371LL) )
{
m_startPosObject = a1->m_startPosObject;
if ( m_startPosObject )
{
m_targetOrder = m_startPosObject->m_startSettings->m_targetOrder;
x = m_startPosObject->getPosition(a1->m_startPosObject)->x;
}
else
{
x = 0.0;
m_targetOrder = -1;
}
if ( (v9 = a2->getPosition(a2),
v10 = *(_QWORD *)&a2[1].m_sQuad.bl.vertices.y,
v11 = v9->x,
v12 = *(_DWORD *)(v10 + 372),
v13 = *(unsigned __int8 *)(v10 + 370),
v12 > m_targetOrder)
|| x < v11 && (m_targetOrder <= v12) > v13
|| x > v11 && v13 && m_targetOrder <= v12 )
{
GJBaseGameLayer::setStartPosObject(a1, (StartPosObject *)a2);
a1->m_isTestMode = 1;
}
}
goto LABEL_37;
}
goto LABEL_92;
}
if ( m_objectID < 15 )
{
if ( (unsigned int)(m_objectID - 10) > 3 )
goto LABEL_37;
goto LABEL_74;
}
BallFrame = GameObject::getBallFrame((GameObject *)(unsigned int)a1->m_pulseRodIndex, v4);
v41 = GameObject::createWithFrame(BallFrame);
v42 = v41->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v41->m_objectID = 37;
v43 = v41;
((void (*)(void))v42->customSetup)();
m_activeMainColorID = a2->m_activeMainColorID;
if ( m_activeMainColorID != 1004 )
GameObject::setMainColorMode(v43, m_activeMainColorID);
GameObject::setDefaultMainColorMode(a2, 0);
a2->saveActiveColors(a2);
v43->saveActiveColors(v43);
a2->m_mainColorKeyIndex = 0;
width = a2->m_obRect.size.width;
a2->m_detailColorKeyIndex = 0;
height = a2->m_obRect.size.height;
v43->m_mainColorKeyIndex = 0;
v43->m_detailColorKeyIndex = 0;
cocos2d::CCPoint::CCPoint(&v69, width * 0.5, height + 10.0);
cocos2d::CCNode::convertToWorldSpace(a2, &v69);
v47 = v43->setStartPos;
v70 = cocos2d::CCNode::convertToNodeSpace(a1->m_gameBlendingLayerT1, &v68);
((void (__fastcall *)(GameObject *, cocos2d::CCPoint *, float, float))v47)(v43, &v69, v70.x, v70.y);
v43->setScale(v43, 0.1);
a1->addToSection(a1, v43);
cocos2d::CCArray::addObject(a1->m_objects, v43);
v43->setVisible(v43, 0);
GameObject::copyGroups(v43);
GJBaseGameLayer::addToGroups(a1, v43, 1);
LABEL_37:
if ( GameObject::isSpeedObject(a2) )
goto LABEL_38;
goto LABEL_62;
}
if ( m_objectID == 99 )
goto LABEL_74;
if ( m_objectID <= 99 )
{
if ( m_objectID < 45 )
goto LABEL_37;
if ( m_objectID > 47 )
{
if ( m_objectID != 84 )
goto LABEL_37;
goto LABEL_61;
}
goto LABEL_74;
}
if ( m_objectID == 105 )
goto LABEL_92;
if ( m_objectID <= 105 )
{
if ( m_objectID != 101 )
goto LABEL_37;
goto LABEL_74;
}
if ( m_objectID == 111 )
goto LABEL_74;
if ( m_objectID != 141 )
goto LABEL_37;
LABEL_61:
GJBaseGameLayer::addGuideArt(a1, a2);
if ( GameObject::isSpeedObject(a2) )
{
LABEL_38:
if ( LOBYTE(a2[1].m_pobTexture) )
{
LABEL_39:
EffectGameObject::updateSpeedModType((EffectGameObject *)a2);
cocos2d::CCArray::addObject(a1->m_speedObjects, a2);
return;
}
}
LABEL_62:
if ( a2->m_classType == Effect && LOBYTE(a2[1].m_obRect.origin.y) && LOBYTE(a2[1].m_pobTexture) )
goto LABEL_39;
}