//
// EndPortalObject::init from 0x1003fe6fc to 0x1003fe9cc (720 bytes)
//
// 2 xrefs:
// > EndPortalObject::create @ 0x1003fe6b0
// > ??> @ 0x100815f78
//
// 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
//
bool __fastcall EndPortalObject::init(EndPortalObject *a1)
{
_BOOL4 v2; // w20
cocos2d::CCDirector *v3; // x0
cocos2d::CCParticleSystemQuad *v4; // x0
cocos2d::CCParticleSystemQuad *v5; // x21
__n128 v6; // q0
__n128 v7; // q1
PlayerObject *m_player1; // x8
unsigned __int16 b; // w9
float32x2_t v10; // d8
int8x8_t v11; // d1
PlayerObject *v12; // x8
unsigned __int16 v13; // w9
int8x8_t v14; // d1
GameManager *v15; // x0
int v16; // w23
unsigned int i; // w24
cocos2d::CCSprite *v18; // x22
__n128 v19; // q0
__n128 v20; // q1
float32x2_t v22; // [xsp+8h] [xbp-68h] BYREF
float v23; // [xsp+10h] [xbp-60h]
int v24; // [xsp+14h] [xbp-5Ch]
float v25; // [xsp+1Ch] [xbp-54h]
v2 = GameObject::init(a1, "block001_01_001.png");
if ( v2 )
{
((void (__fastcall *)(EndPortalObject *, void *))a1->setTextureRect)(a1, &unk_10086E960);
v3 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v3);
a1->m_isInvisible = 0;
a1->m_unk3F8 = 1;
a1->m_objectType = Decoration;
v4 = GameObject::createAndAddParticle(a1, 7, "endEffectPortal.plist", 4, kCCPositionTypeGrouped);
if ( v4 )
{
v5 = v4;
v6 = ((__n128 (__fastcall *)(cocos2d::CCParticleSystemQuad *, float))v4->setStartRadius)(v4, v25 * 0.5);
v6.n128_u32[0] = -15.0;
v7.n128_u32[0] = 0;
sub_100022980(v6, v7, &v22);
sub_1000229D0(&a1->m_particleOffset, (double *)&v22);
m_player1 = GameManager::sharedState()->m_playLayer->m_player1;
b = m_player1->m_playerColor1.b;
v10 = (float32x2_t)vdup_n_s32(0x437F0000u);
*(cocos2d::ccColor3B *)v11.i8 = m_player1->m_playerColor1;
v11.i32[1] = (unsigned __int32)v11.i32[0] >> 8;
v22 = vdiv_f32(vcvt_f32_u32((uint32x2_t)vand_s8(v11, (int8x8_t)0xFF000000FFLL)), v10);
v23 = (float)b / 255.0;
v24 = 1065353216;
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *, float32x2_t *))v5->setStartColor)(v5, &v22);
v12 = GameManager::sharedState()->m_playLayer->m_player1;
v13 = v12->m_playerColor1.b;
*(cocos2d::ccColor3B *)v14.i8 = v12->m_playerColor1;
v14.i32[1] = (unsigned __int32)v14.i32[0] >> 8;
v22 = vdiv_f32(vcvt_f32_u32((uint32x2_t)vand_s8(v14, (int8x8_t)0xFF000000FFLL)), v10);
v23 = (float)v13 / 255.0;
v24 = 1065353216;
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *, float32x2_t *))v5->setEndColor)(v5, &v22);
}
a1->m_gradientBar = cocos2d::CCSprite::createWithSpriteFrameName("gradientBar.png");
v15 = GameManager::sharedState();
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *, cocos2d::CCSprite *))v15->m_playLayer->m_gameBlendingLayerT1->addChild)(
v15->m_playLayer->m_gameBlendingLayerT1,
a1->m_gradientBar);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))a1->m_gradientBar->setBlendFunc)(
a1->m_gradientBar,
0x100000302LL);
((void (__fastcall *)(cocos2d::CCSprite *, float))a1->m_gradientBar->setScaleY)(
a1->m_gradientBar,
(float)(v25 * 1.5) / a1->m_gradientBar->m_obRect.size.height);
v16 = llroundf((float)(v25 * 1.5) / 30.0);
if ( v16 >= 1 )
{
for ( i = 0; i != v16; ++i )
{
v18 = cocos2d::CCSprite::createWithSpriteFrameName("square_02_001.png");
((void (__fastcall *)(EndPortalObject *, cocos2d::CCSprite *))a1->addChild)(a1, v18);
v19 = ((__n128 (__fastcall *)(cocos2d::CCSprite *, float))v18->setRotation)(v18, -90.0);
v20.n128_f32[0] = (float)((float)i * -30.0) + (float)((float)((unsigned int)v16 >> 1) * 30.0);
v19.n128_u32[0] = 0;
sub_100022980(v19, v20, &v22);
((void (__fastcall *)(cocos2d::CCSprite *, float32x2_t *))v18->setPosition)(v18, &v22);
}
}
a1->m_unk370 = 1;
}
return v2;
}