//
// PlayLayer::addObject from 0x1000b1fa0 to 0x1000b2ae9 (2889 bytes)
//
// 3 xrefs:
// > PlayLayer::processCreateObjectsFromSetup @ 0x1000ada57
// > PlayLayer::setupHasCompleted @ 0x1000ae7ed
// > PlayLayer::addObject @ 0x1000b24a3
//
// 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 __fastcall PlayLayer::addObject(PlayLayer *a1, GameObject *a2)
{
TeleportPortalObject *m_activeMainColorID; // rsi
__int64 v5; // rdx
int m_objectID; // eax
const char *BallFrame; // rax
GameObject *v8; // r15
int v9; // esi
__int64 v10; // rsi
double v11; // xmm0_8
TeleportPortalObject *v12; // r15
double v13; // xmm0_8
unsigned __int8 v14; // al
int v15; // edx
PlayerObject *m_player1; // rax
__int16 v17; // cx
GLubyte b; // al
PlayerObject *v19; // rax
bool v20; // r15
int v21; // eax
const char *v22; // rdi
StartPosObject *m_startPosObject; // rdi
int m_targetOrder; // r15d
GameObject *v25; // r12
double v26; // xmm0_8
unsigned __int8 v27; // al
unsigned __int8 v28; // al
float *v29; // rax
__int64 v30; // rdx
int v31; // ecx
float v32; // xmm0_4
char v33; // al
int v34; // [rsp-44h] [rbp-44h] BYREF
float v35[2]; // [rsp-3Ch] [rbp-3Ch] BYREF
float v36; // [rsp-34h] [rbp-34h]
double v37; // 0:xmm0_8.8
if ( !a2 )
return;
if ( ((unsigned int (__fastcall *)(GameObject *))a2->getType)(a2) == 25 )
GameObject::determineSlopeDirection(a2);
else
GameObject::updateIsOriented(a2);
((void (__fastcall *)(GameObject *, _QWORD))a2->setVisible)(a2, 0);
((void (__fastcall *)(float *, GameObject *))a2->getStartPos)(v35, a2);
if ( v35[0] > a1->m_maxObjectX )
{
((void (__fastcall *)(float *, GameObject *))a2->getStartPos)(v35, a2);
a1->m_maxObjectX = v35[0];
}
if ( !GameObject::isSettingsObject(a2)
&& (((unsigned int (__fastcall *)(GameObject *))a2->getType)(a2) != 20
|| a2->m_classType == Effect && LOBYTE(a2[1].m_sAdditionalTransform.b)
|| a2->m_objectID == 2063) )
{
((void (__fastcall *)(PlayLayer *, GameObject *))a1->addToSection)(a1, a2);
}
else
{
a2->m_outerSectionIndex = -1;
}
sub_10071FCD0(a1->m_objects, a2);
GJBaseGameLayer::addToGroups(a1, a2, 1);
if ( a2->m_objectID == 1615 )
{
GJBaseGameLayer::addObjectCounter(a1, (LabelGameObject *)a2);
}
else if ( ((unsigned int (__fastcall *)(GameObject *))a2->getType)(a2) == 30
|| ((unsigned int (__fastcall *)(GameObject *))a2->getType)(a2) == 31 )
{
sub_10071FCD0(a1->m_collectibles, a2);
}
m_activeMainColorID = (TeleportPortalObject *)(unsigned int)a2->m_activeMainColorID;
GameObject::getActiveColorForMode(a2, (int)m_activeMainColorID, 1);
if ( GameObject::hasSecondaryColor(a2) )
{
m_activeMainColorID = (TeleportPortalObject *)(unsigned int)a2->m_activeDetailColorID;
GameObject::getActiveColorForMode(a2, (int)m_activeMainColorID, 0);
}
if ( a2->m_isTrigger
&& a2->m_classType == Effect
&& (!LOBYTE(a2[1].m_sAdditionalTransform.b) && BYTE1(a2[1].m_sAdditionalTransform.b) != 1
|| ((unsigned __int8 (__fastcall *)(GameObject *))a2->isSpecialSpawnObject)(a2)) )
{
m_activeMainColorID = (TeleportPortalObject *)a2;
sub_10071FCD0(a1->m_spawnObjectsArray, a2);
}
if ( !a1->m_isPlatformer )
{
m_objectID = a2->m_objectID;
if ( m_objectID != 747 )
goto LABEL_29;
LABEL_35:
v10 = ((__int64 (__fastcall *)(GameObject *))a2->getPosition)(a2);
v11 = sub_10028CC60(v35);
v35[1] = *(float *)(((__int64 (__fastcall *)(GameObject *, __int64, double))a2->getPosition)(a2, v10, v11) + 4)
+ a2[1].m_sQuad.bl.texCoords.u;
*(float *)&v11 = TeleportPortalObject::getTeleportXOff((TeleportPortalObject *)a2, a1->m_gameLayerT1);
v35[0] = *(float *)&v11 + v35[0];
v12 = TeleportPortalObject::create("portal_16_front_001.png", 0);
*(_QWORD *)&a2[1].m_sQuad.bl.vertices.y = v12;
v12->m_objectID = 749;
((void (__fastcall *)(TeleportPortalObject *))v12->customSetup)(v12);
v13 = sub_10028CC60(&v34);
((void (__fastcall *)(TeleportPortalObject *, int *, double))v12->setStartPos)(v12, &v34, v13);
v12->m_unk40C = 1;
v12->m_zOrder = a2->m_zOrder;
v12->m_defaultZOrder = a2->m_defaultZOrder;
v14 = ((__int64 (__fastcall *)(GameObject *))a2->isFlipX)(a2);
((void (__fastcall *)(TeleportPortalObject *, _QWORD))v12->setFlipX)(v12, v14 ^ 1u);
v12->m_startFlipX = ((__int64 (__fastcall *)(GameObject *))a2->isFlipX)(a2) ^ 1;
v12->m_isDontEnter = a2->m_isDontEnter;
v12->m_isDontFade = a2->m_isDontFade;
v12->m_hasNoEffects = a2->m_hasNoEffects;
v36 = ((float (__fastcall *)(GameObject *))a2->getRotation)(a2);
((void (__fastcall *)(TeleportPortalObject *))v12->setRotation)(v12);
*(float *)&v13 = v36;
v12->m_startRotationX = v36;
v12->m_startRotationY = *(float *)&v13;
GameObject::copyGroups(v12);
GameObject::updateCustomScaleX(v12, a2->m_scaleX);
GameObject::updateCustomScaleY(v12, a2->m_scaleY);
*(_QWORD *)&v12->m_mainColorKeyIndex = *(_QWORD *)&a2->m_mainColorKeyIndex;
if ( a2->m_isHide )
v12->m_isHide = 1;
((void (__fastcall *)(TeleportPortalObject *, GameObject *))v12->saveActiveColors)(v12, a2);
m_activeMainColorID = v12;
PlayLayer::addObject(a1, v12);
m_objectID = a2->m_objectID;
if ( m_objectID <= 743 )
goto LABEL_30;
goto LABEL_38;
}
a2->m_tempOffsetXRelated = 0;
m_objectID = a2->m_objectID;
if ( m_objectID == 747 )
goto LABEL_35;
LABEL_29:
if ( m_objectID <= 743 )
{
LABEL_30:
switch ( m_objectID )
{
case 10:
case 11:
case 12:
case 13:
case 45:
case 46:
case 47:
case 99:
case 101:
case 111:
goto LABEL_69;
case 14:
case 18:
case 19:
case 20:
case 21:
case 22:
case 23:
case 24:
case 25:
case 26:
case 27:
case 28:
case 32:
case 33:
case 34:
case 35:
case 37:
case 38:
case 39:
case 40:
case 41:
case 42:
case 43:
case 44:
case 48:
case 49:
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
case 56:
case 57:
case 58:
case 59:
case 60:
case 61:
case 62:
case 63:
case 64:
case 65:
case 66:
case 67:
case 68:
case 69:
case 70:
case 71:
case 72:
case 73:
case 74:
case 75:
case 76:
case 77:
case 78:
case 79:
case 80:
case 81:
case 82:
case 83:
case 85:
case 86:
case 87:
case 88:
case 89:
case 90:
case 91:
case 92:
case 93:
case 94:
case 95:
case 96:
case 97:
case 98:
case 100:
case 102:
case 103:
case 104:
case 106:
case 107:
case 108:
case 109:
case 110:
case 112:
case 113:
case 114:
case 115:
case 116:
case 117:
case 118:
case 119:
case 120:
case 121:
case 122:
case 123:
case 124:
case 125:
case 126:
case 127:
case 128:
case 129:
case 130:
case 131:
case 132:
case 133:
case 134:
case 135:
case 136:
case 137:
case 138:
case 139:
case 140:
goto LABEL_114;
case 15:
case 16:
case 17:
BallFrame = GameObject::getBallFrame((GameObject *)(unsigned int)a1->m_pulseRodIndex, (int)m_activeMainColorID);
v8 = GameObject::createWithFrame(BallFrame);
v8->m_objectID = 37;
((void (__fastcall *)(GameObject *))v8->customSetup)(v8);
v9 = a2->m_activeMainColorID;
if ( v9 != 1004 )
GameObject::setMainColorMode(v8, v9);
GameObject::setDefaultMainColorMode(a2, 0);
((void (__fastcall *)(GameObject *))a2->saveActiveColors)(a2);
((void (__fastcall *)(GameObject *))v8->saveActiveColors)(v8);
*(_QWORD *)&a2->m_mainColorKeyIndex = 0;
*(_QWORD *)&v8->m_mainColorKeyIndex = 0;
sub_10028CBE0(&v34, a2->m_obRect.size.width * 0.5, a2->m_obRect.size.height + 10.0);
cocos2d::CCNode::convertToWorldSpace((cocos2d::CCNode *)v35, (const cocos2d::CCPoint *)a2);
*(cocos2d::CCPoint *)&v37 = cocos2d::CCNode::convertToNodeSpace(
(cocos2d::CCNode *)&v34,
(const cocos2d::CCPoint *)a1->m_gameBlendingLayerT1);
((void (__fastcall *)(GameObject *, int *, double))v8->setStartPos)(v8, &v34, v37);
((void (__fastcall *)(GameObject *, float))v8->setScale)(v8, 0.1);
((void (__fastcall *)(PlayLayer *, GameObject *))a1->addToSection)(a1, v8);
sub_10071FCD0(a1->m_objects, v8);
((void (__fastcall *)(GameObject *, _QWORD))v8->setVisible)(v8, 0);
GameObject::copyGroups(v8);
GJBaseGameLayer::addToGroups(a1, v8, 1);
break;
case 29:
case 30:
case 105:
goto LABEL_50;
case 31:
if ( !*(_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;
v36 = *(float *)((__int64 (__fastcall *)(StartPosObject *, TeleportPortalObject *, __int64, _QWORD))m_startPosObject->getPosition)(
m_startPosObject,
m_activeMainColorID,
v5,
(unsigned int)(m_objectID - 10));
}
else
{
v36 = 0.0;
m_targetOrder = -1;
}
if ( (v29 = (float *)((__int64 (__fastcall *)(GameObject *))a2->getPosition)(a2),
v30 = *(_QWORD *)&a2[1].m_sQuad.bl.vertices.y,
v31 = *(_DWORD *)(v30 + 372),
v31 > m_targetOrder)
|| (v32 = *v29, v33 = *(_BYTE *)(v30 + 370), v32 > v36) && !v33 && v31 >= m_targetOrder
|| v36 > v32 && v33 && v31 >= m_targetOrder )
{
GJBaseGameLayer::setStartPosObject(a1, (StartPosObject *)a2);
a1->m_isTestMode = 1;
}
}
break;
case 36:
case 84:
case 141:
goto LABEL_66;
default:
if ( (unsigned int)(m_objectID - 286) < 2 || m_objectID == 660 )
goto LABEL_69;
break;
}
goto LABEL_114;
}
LABEL_38:
if ( m_objectID <= 1329 )
{
switch ( m_objectID )
{
case 744:
goto LABEL_50;
case 745:
case 747:
case 749:
goto LABEL_69;
case 746:
case 748:
goto LABEL_114;
default:
if ( (unsigned int)(m_objectID - 899) <= 0x10 && (v15 = 65539, _bittest(&v15, m_objectID - 899)) )
{
LABEL_50:
if ( BYTE1(a2[1].m_sAdditionalTransform.tx) == 1 )
{
m_player1 = a1->m_player1;
v17 = *(_WORD *)&m_player1->m_playerColor1.r;
b = m_player1->m_playerColor1.b;
}
else
{
if ( BYTE2(a2[1].m_sAdditionalTransform.tx) != 1 )
goto LABEL_114;
v19 = a1->m_player1;
v17 = *(_WORD *)&v19->m_playerColor2.r;
b = v19->m_playerColor2.b;
}
BYTE2(a2[1].m_obAnchorPointInPoints.y) = b;
LOWORD(a2[1].m_obAnchorPointInPoints.y) = v17;
}
else if ( m_objectID == 1022 )
{
goto LABEL_66;
}
break;
}
goto LABEL_114;
}
if ( m_objectID > 1932 )
{
if ( m_objectID > 2901 )
{
if ( m_objectID != 2902 && m_objectID != 2926 )
goto LABEL_114;
}
else if ( m_objectID != 1933 && m_objectID != 2064 )
{
goto LABEL_114;
}
LABEL_69:
if ( a2->m_isHide )
goto LABEL_114;
v20 = GJBaseGameLayer::addGuideArt(a1, a2);
v21 = a2->m_objectID;
v22 = "portal_01_back_001.png";
if ( v21 <= 286 )
{
if ( v21 > 98 )
{
if ( v21 > 110 )
{
if ( v21 == 111 )
{
v22 = "portal_10_back_001.png";
}
else if ( v21 == 286 )
{
v22 = "portal_11_back_001.png";
}
}
else if ( v21 == 99 )
{
v22 = "portal_08_back_001.png";
}
else if ( v21 == 101 )
{
v22 = "portal_09_back_001.png";
}
}
else
{
switch ( v21 )
{
case 11:
v22 = "portal_02_back_001.png";
break;
case 12:
v22 = "portal_03_back_001.png";
break;
case 13:
v22 = "portal_04_back_001.png";
break;
case 45:
v22 = "portal_05_back_001.png";
break;
case 46:
v22 = "portal_06_back_001.png";
break;
case 47:
v22 = "portal_07_back_001.png";
break;
default:
goto LABEL_113;
}
}
goto LABEL_113;
}
if ( v21 > 1330 )
{
if ( v21 <= 2063 )
{
if ( v21 == 1331 )
{
v22 = "portal_17_back_001.png";
}
else if ( v21 == 1933 )
{
v22 = "portal_18_back_001.png";
}
goto LABEL_113;
}
if ( v21 == 2064 )
{
LABEL_99:
v22 = "portal_16_back_001.png";
goto LABEL_113;
}
if ( v21 != 2902 )
{
if ( v21 == 2926 )
v22 = "portal_19_back_001.png";
goto LABEL_113;
}
}
else
{
if ( v21 <= 744 )
{
if ( v21 == 287 )
{
v22 = "portal_12_back_001.png";
}
else if ( v21 == 660 )
{
v22 = "portal_13_back_001.png";
}
goto LABEL_113;
}
if ( v21 == 745 )
{
v22 = "portal_14_back_001.png";
goto LABEL_113;
}
if ( v21 != 747 )
{
if ( v21 != 749 )
goto LABEL_113;
goto LABEL_99;
}
}
v22 = "portal_15_back_001.png";
LABEL_113:
v25 = GameObject::createWithFrame(v22);
v25->m_objectID = 38;
((void (__fastcall *)(GameObject *, __int64))v25->setType)(v25, 7);
v25->m_isDecoration2 = 1;
((void (__fastcall *)(GameObject *))v25->customSetup)(v25);
((void (__fastcall *)(GameObject *))a2->getPosition)(a2);
v26 = sub_10028CC60(v35);
((void (__fastcall *)(GameObject *, float *, double))v25->setStartPos)(v25, v35, v26);
v25->m_unk40C = 1;
v25->m_defaultZLayer = 4;
v25->m_defaultZOrder = v20 + GameObject::getObjectZOrder(a2) - 100;
v27 = ((__int64 (__fastcall *)(GameObject *))a2->isFlipX)(a2);
((void (__fastcall *)(GameObject *, _QWORD))v25->setFlipX)(v25, v27);
v28 = ((__int64 (__fastcall *)(GameObject *))a2->isFlipY)(a2);
((void (__fastcall *)(GameObject *, _QWORD))v25->setFlipY)(v25, v28);
((void (__fastcall *)(GameObject *))a2->getRotationX)(a2);
((void (__fastcall *)(GameObject *))v25->setRotationX)(v25);
((void (__fastcall *)(GameObject *))a2->getRotationY)(a2);
((void (__fastcall *)(GameObject *))v25->setRotationY)(v25);
*(_QWORD *)&v25->m_startRotationX = *(_QWORD *)&a2->m_startRotationX;
v25->m_startFlipX = a2->m_startFlipX;
v25->m_startFlipY = a2->m_startFlipY;
GameObject::updateCustomScaleX(v25, a2->m_scaleX);
GameObject::updateCustomScaleY(v25, a2->m_scaleY);
*(_QWORD *)&v25->m_startScaleX = *(_QWORD *)&a2->m_startScaleX;
v25->m_isDontEnter = a2->m_isDontEnter;
v25->m_isDontFade = a2->m_isDontFade;
v25->m_hasNoEffects = a2->m_hasNoEffects;
((void (__fastcall *)(PlayLayer *, GameObject *))a1->addToSection)(a1, v25);
sub_10071FCD0(a1->m_objects, v25);
GameObject::copyGroups(v25);
GJBaseGameLayer::addToGroups(a1, v25, 1);
a2->m_unk40C = 1;
a2->m_defaultZOrder = v20 | 0xC;
((void (__fastcall *)(GameObject *))v25->saveActiveColors)(v25);
*(_QWORD *)&v25->m_mainColorKeyIndex = *(_QWORD *)&a2->m_mainColorKeyIndex;
goto LABEL_114;
}
if ( m_objectID > 1332 )
{
if ( m_objectID != 1333 )
{
if ( m_objectID == 1816
&& BYTE5(a2[1].CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCRGBAProtocol::__vftable) == 1 )
{
sub_10071FCD0(a1->m_collisionBlocks, a2);
}
goto LABEL_114;
}
goto LABEL_66;
}
if ( m_objectID == 1330 )
{
LABEL_66:
GJBaseGameLayer::addGuideArt(a1, a2);
goto LABEL_114;
}
if ( m_objectID == 1331 )
goto LABEL_69;
LABEL_114:
if ( GameObject::isSpeedObject(a2) && LOBYTE(a2[1].m_pobTexture)
|| a2->m_classType == Effect && LOBYTE(a2[1].m_obRect.origin.y) == 1 && LOBYTE(a2[1].m_pobTexture) == 1 )
{
EffectGameObject::updateSpeedModType((EffectGameObject *)a2);
sub_10071FCD0(a1->m_speedObjects, a2);
}
}