//
// SimplePlayer::init from 0x140279490 to 0x140279b6c (1756 bytes)
//
// 2 xrefs:
// > SimplePlayer::create @ 0x14027944b
// > ??> @ 0x1406d1070
//
// 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
//
// Hidden C++ exception states: #wind=7
bool SimplePlayer::init(SimplePlayer *a1, int a2)
{
__int64 v4; // r8
int v5; // ecx
int v6; // eax
int v7; // r12d
_BYTE *v8; // rax
size_t v9; // r8
__int64 v10; // rdx
__int64 v11; // rcx
__int64 v12; // r8
__int64 v13; // r9
void **v14; // r15
__int64 v15; // rdi
unsigned __int64 v16; // rbx
unsigned __int64 v17; // rsi
void **v18; // r15
unsigned __int64 v19; // rsi
void **v20; // rsi
bool v21; // bl
GameManager *v22; // rcx
void **v23; // rcx
cocos2d::CCSprite *v24; // rax
void **v25; // rcx
cocos2d::CCSprite *v26; // rax
cocos2d::CCSprite_vtbl *v27; // rbx
struct cocos2d::CCPoint v28; // rax
void **v29; // rcx
cocos2d::CCSprite *v30; // rax
cocos2d::CCSprite_vtbl *v31; // rbx
struct cocos2d::CCPoint v32; // rax
void **v33; // rcx
cocos2d::CCSprite *v34; // rax
cocos2d::CCSprite_vtbl *v35; // rbx
struct cocos2d::CCPoint v36; // rax
void **v37; // rcx
cocos2d::CCSprite *v38; // rax
cocos2d::CCSprite_vtbl *v39; // rbx
struct cocos2d::CCPoint v40; // rax
void *v41; // rcx
void *v42; // rcx
void *v43; // rcx
bool v45; // [rsp+20h] [rbp-E0h]
__int64 *v46; // [rsp+30h] [rbp-D0h] BYREF
__int64 v47; // [rsp+38h] [rbp-C8h]
void *v48[2]; // [rsp+40h] [rbp-C0h] BYREF
unsigned __int64 v49; // [rsp+50h] [rbp-B0h]
unsigned __int64 v50; // [rsp+58h] [rbp-A8h]
void *v51[2]; // [rsp+60h] [rbp-A0h] BYREF
unsigned __int64 v52; // [rsp+70h] [rbp-90h]
unsigned __int64 v53; // [rsp+78h] [rbp-88h]
void *Block[2]; // [rsp+80h] [rbp-80h] BYREF
unsigned __int64 v55; // [rsp+90h] [rbp-70h]
unsigned __int64 v56; // [rsp+98h] [rbp-68h]
void *Src[2]; // [rsp+A0h] [rbp-60h] BYREF
unsigned __int64 v58; // [rsp+B0h] [rbp-50h]
unsigned __int64 v59; // [rsp+B8h] [rbp-48h]
_BYTE v60[528]; // [rsp+C0h] [rbp-40h] BYREF
v4 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v46 = (__int64 *)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v46);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v4 = qword_1406C2ED8;
}
v5 = *(_DWORD *)(v4 + 1176);
*(_DWORD *)(v4 + 1176) = v5 + 1;
a1->m_iconRequestID = v5;
v6 = 485;
if ( a2 < 485 )
v6 = a2;
v7 = 1;
if ( v6 > 1 )
v7 = v6;
fmt::BasicWriter::BasicWriter(v60);
v46 = &qword_14055CF60;
v47 = 0;
fmt::BasicWriter::operator<<(v60, &v46);
if ( v7 < 10 )
{
v46 = (__int64 *)"0";
v47 = 0;
fmt::BasicWriter::operator<<(v60, &v46);
}
fmt::BasicWriter::operator<<(v60, (unsigned int)v7);
v8 = (_BYTE *)fmt::BasicWriter::c_str(v60);
*(_OWORD *)Src = 0;
v58 = 0;
v59 = 0;
v9 = -1;
do
++v9;
while ( v8[v9] );
sub_14003A930(Src, v8, v9);
*(_OWORD *)v51 = 0;
v52 = 0;
v53 = 0;
v14 = Src;
v45 = v59 > 0xF;
if ( v59 > 0xF )
v14 = (void **)Src[0];
v15 = 0x7FFFFFFFFFFFFFFFLL;
v16 = v58;
if ( v58 > 0x7FFFFFFFFFFFFFFFLL )
sub_140007B50(v11, v10, v12, v13);
v53 = 15;
if ( v58 > 0xF )
{
v17 = v58 | 0xF;
if ( (v58 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
if ( v17 < 0x16 )
v17 = 22;
}
else
{
v17 = 0x7FFFFFFFFFFFFFFFLL;
}
v51[0] = sub_14003AA10(v17 + 1);
v52 = v16;
v53 = v17;
memcpy(v51[0], v14, v16 + 1);
}
else
{
v52 = v58;
*(_OWORD *)v51 = *(_OWORD *)v14;
}
sub_140041270(v51, (void *)"_001.png", 8u);
*(_OWORD *)v48 = 0;
v49 = 0;
v18 = Src;
if ( v45 )
v18 = (void **)Src[0];
v50 = 15;
if ( v16 > 0xF )
{
v19 = v16 | 0xF;
if ( (v16 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
if ( v19 < 0x16 )
v19 = 22;
}
else
{
v19 = 0x7FFFFFFFFFFFFFFFLL;
}
v48[0] = sub_14003AA10(v19 + 1);
v49 = v16;
v50 = v19;
memcpy(v48[0], v18, v16 + 1);
}
else
{
v49 = v16;
*(_OWORD *)v48 = *(_OWORD *)v18;
}
sub_140041270(v48, "_2_001.png", 0xAu);
*(_OWORD *)Block = 0;
v55 = 0;
v20 = Src;
if ( v45 )
v20 = (void **)Src[0];
v56 = 15;
if ( v16 > 0xF )
{
if ( (v16 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
v15 = v16 | 0xF;
if ( (v16 | 0xF) < 0x16 )
v15 = 22;
}
Block[0] = sub_14003AA10(v15 + 1);
v55 = v16;
v56 = v15;
memcpy(Block[0], v20, v16 + 1);
}
else
{
v55 = v16;
*(_OWORD *)Block = *(_OWORD *)v20;
}
sub_140041270(Block, "_glow_001.png", 0xDu);
if ( cocos2d::CCSprite::init(a1) )
{
a1->setTextureRect_0(a1, &stru_1406C1DF0);
v22 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v46 = (__int64 *)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v46);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v22 = (GameManager *)qword_1406C2ED8;
}
GameManager::loadIcon(v22, v7, 0, a1->m_iconRequestID);
v23 = v51;
if ( v53 > 0xF )
v23 = (void **)v51[0];
v24 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)v23);
a1->m_firstLayer = v24;
a1->addChild_0(a1, v24, 1);
v25 = v48;
if ( v50 > 0xF )
v25 = (void **)v48[0];
v26 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)v25);
a1->m_secondLayer = v26;
a1->m_firstLayer->addChild_0(a1->m_firstLayer, v26, -1);
v27 = a1->m_secondLayer->__vftable;
v28 = cocos2d::CCNode::convertToNodeSpace(a1->m_firstLayer, (const struct cocos2d::CCPoint *)&v46);
((void (__fastcall *)(cocos2d::CCSprite *, struct cocos2d::CCPoint))v27->setPosition_0)(a1->m_secondLayer, v28);
v29 = v48;
if ( v50 > 0xF )
v29 = (void **)v48[0];
v30 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)v29);
a1->m_birdDome = v30;
a1->m_firstLayer->addChild_0(a1->m_firstLayer, v30, -2);
v31 = a1->m_birdDome->__vftable;
v32 = cocos2d::CCNode::convertToNodeSpace(a1->m_firstLayer, (const struct cocos2d::CCPoint *)&v46);
((void (__fastcall *)(cocos2d::CCSprite *, struct cocos2d::CCPoint))v31->setPosition_0)(a1->m_birdDome, v32);
v33 = Block;
if ( v56 > 0xF )
v33 = (void **)Block[0];
v34 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)v33);
a1->m_outlineSprite = v34;
a1->m_firstLayer->addChild_0(a1->m_firstLayer, v34, -3);
v35 = a1->m_outlineSprite->__vftable;
v36 = cocos2d::CCNode::convertToNodeSpace(a1->m_firstLayer, (const struct cocos2d::CCPoint *)&v46);
((void (__fastcall *)(cocos2d::CCSprite *, struct cocos2d::CCPoint))v35->setPosition_0)(a1->m_outlineSprite, v36);
a1->m_outlineSprite->setVisible(a1->m_outlineSprite, 0);
v37 = v48;
if ( v50 > 0xF )
v37 = (void **)v48[0];
v38 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)v37);
a1->m_detailSprite = v38;
a1->m_firstLayer->addChild_0(a1->m_firstLayer, v38, 1);
v39 = a1->m_detailSprite->__vftable;
v40 = cocos2d::CCNode::convertToNodeSpace(a1->m_firstLayer, (const struct cocos2d::CCPoint *)&v46);
((void (__fastcall *)(cocos2d::CCSprite *, struct cocos2d::CCPoint))v39->setPosition_0)(a1->m_detailSprite, v40);
SimplePlayer::updatePlayerFrame(a1, v7, Cube);
v21 = 1;
}
else
{
v21 = 0;
}
if ( v56 > 0xF )
{
v41 = Block[0];
if ( v56 + 1 >= 0x1000 )
{
v41 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v41 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v41);
}
v55 = 0;
v56 = 15;
LOBYTE(Block[0]) = 0;
if ( v50 > 0xF )
{
v42 = v48[0];
if ( v50 + 1 >= 0x1000 )
{
v42 = *((void **)v48[0] - 1);
if ( (unsigned __int64)((char *)v48[0] - (char *)v42 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v42);
}
v49 = 0;
v50 = 15;
LOBYTE(v48[0]) = 0;
if ( v53 > 0xF )
{
v43 = v51[0];
if ( v53 + 1 >= 0x1000 )
{
v43 = *((void **)v51[0] - 1);
if ( (unsigned __int64)((char *)v51[0] - (char *)v43 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v43);
}
v52 = 0;
v53 = 15;
LOBYTE(v51[0]) = 0;
sub_14003A830((__int64)Src);
fmt::BasicWriter::~BasicWriter(v60);
return v21;
}