//
// EndPortalObject::init from 0x10039c420 to 0x10039c745 (805 bytes)
//
// 2 xrefs:
// > EndPortalObject::create @ 0x10039c3d9
// > ??> @ 0x100923388
//
// 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)
{
__m128 v1; // xmm2
bool result; // al
__m128 v3; // xmm0
cocos2d::CCParticleSystemQuad *v4; // rax
cocos2d::CCParticleSystemQuad *v5; // r14
PlayerObject *m_player1; // rax
__m128 v7; // xmm0
__m128 v8; // xmm1
PlayerObject *v9; // rax
__m128 v10; // xmm0
__m128 v11; // xmm1
__m128 v12; // xmm2
GameManager *v13; // rax
__m128 v14; // xmm1
__m128 v15; // xmm0
int v16; // r13d
int v17; // r14d
cocos2d::CCSprite *v18; // r12
__m128 v19; // [rsp+8h] [rbp-48h] BYREF
char v20; // [rsp+18h] [rbp-38h] BYREF
float v21; // [rsp+1Ch] [rbp-34h]
float v22; // [rsp+20h] [rbp-30h]
bool v23; // [rsp+27h] [rbp-29h]
result = GameObject::init(a1, "block001_01_001.png");
if ( result )
{
v23 = result;
((void (__fastcall *)(EndPortalObject *, void *))a1->setTextureRect)(a1, &unk_1009A0FB8);
cocos2d::CCDirector::sharedDirector();
*(cocos2d::CCSize *)v3.f32 = cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)&v20);
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;
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *, float))v4->setStartRadius)(v4, v21 * 0.5);
sub_10028CBE0(v19.f32, -15.0, 0.0);
sub_10028CC90(&a1->m_particleOffset, (double *)v19.i64);
m_player1 = GameManager::sharedState()->m_playLayer->m_player1;
v7 = 0;
v8 = 0;
v8.f32[0] = (float)(unsigned __int8)*(_WORD *)&m_player1->m_playerColor1.r / 255.0;
v1.f32[0] = (float)HIBYTE(*(unsigned __int16 *)&m_player1->m_playerColor1.r) / 255.0;
v7.f32[0] = (float)m_player1->m_playerColor1.b / 255.0;
v19 = _mm_movelh_ps(_mm_insert_ps(v8, v1, 16), _mm_blend_ps(v7, (__m128)xmmword_1008150D0, 14));
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *, __m128 *))v5->setStartColor)(v5, &v19);
v9 = GameManager::sharedState()->m_playLayer->m_player1;
v10 = 0;
v10.f32[0] = (float)v9->m_playerColor1.b;
LODWORD(v9) = *(unsigned __int16 *)&v9->m_playerColor1.r;
v11 = 0;
v12 = 0;
v11.f32[0] = (float)(unsigned __int8)v9 / 255.0;
v12.f32[0] = (float)((unsigned int)v9 >> 8) / 255.0;
v10.f32[0] = v10.f32[0] / 255.0;
v3 = _mm_blend_ps(v10, (__m128)xmmword_1008150D0, 14);
v19 = _mm_movelh_ps(_mm_insert_ps(v11, v12, 16), v3);
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *, __m128 *))v5->setEndColor)(v5, &v19);
}
a1->m_gradientBar = cocos2d::CCSprite::createWithSpriteFrameName("gradientBar.png");
v13 = GameManager::sharedState();
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *, cocos2d::CCSprite *, double))v13->m_playLayer->m_gameBlendingLayerT1->addChild)(
v13->m_playLayer->m_gameBlendingLayerT1,
a1->m_gradientBar,
*(double *)v3.i64);
((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)(v21 * 1.5) / a1->m_gradientBar->m_obRect.size.height);
v14 = (__m128)0x3FC00000u;
v14.f32[0] = (float)(1.5 * v21) / 30.0;
v15 = _mm_or_ps(_mm_and_ps((__m128)xmmword_1008150B0, v14), (__m128)xmmword_1008150C0);
v15.f32[0] = v15.f32[0] + v14.f32[0];
v16 = (int)_mm_round_ss(v15, v15, 11).f32[0];
if ( v16 > 0 )
{
v17 = 0;
v22 = (float)((unsigned int)v16 >> 1) * 30.0;
do
{
v18 = cocos2d::CCSprite::createWithSpriteFrameName("square_02_001.png");
((void (__fastcall *)(EndPortalObject *, cocos2d::CCSprite *))a1->addChild)(a1, v18);
((void (__fastcall *)(cocos2d::CCSprite *, float))v18->setRotation)(v18, -90.0);
sub_10028CBE0(v19.f32, 0.0, (float)((float)v17 * -30.0) + v22);
((void (__fastcall *)(cocos2d::CCSprite *, __m128 *))v18->setPosition)(v18, &v19);
++v17;
}
while ( v16 != v17 );
}
a1->m_unk370 = 1;
return v23;
}
return result;
}