//
// SecretLayer5::onSubmit from 0x1403f6c30 to 0x1403f7341 (1809 bytes)
//
// 3 xrefs:
// > SecretLayer5::init @ 0x1403f4ba1
// > ??> @ 0x1406d8294
// > ??> @ 0x1406d82a0
//
// 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=8
void SecretLayer5::onSubmit(SecretLayer5 *a1, cocos2d::CCObject *a2)
{
cocos2d::CCLabelProtocol *v3; // rcx
const char *v4; // rax
size_t v5; // r8
bool v6; // bl
MusicDownloadManager *v7; // rax
__int64 v8; // rsi
int v9; // ebx
__int64 v10; // r8
__int64 v11; // r9
_WORD *v12; // rax
cocos2d::CCParticleSystemQuad *v13; // rsi
void *v14; // rcx
float v15; // xmm0_4
const cocos2d::CCPoint *v16; // rax
__int64 m_chatIndex; // rdx
std::_Vector_val>::pointer Myfirst; // r8
std::_Simple_types::value_type v19; // ebx
unsigned int v20; // eax
unsigned __int64 i; // rdx
__int64 v22; // rbx
struct cocos2d::CCDelayTime *v23; // rax
struct cocos2d::CCSequence *v24; // rax
cocos2d::ccColor3B *v25; // r8
__int64 v26; // rbx
struct cocos2d::CCDelayTime *v27; // rax
struct cocos2d::CCSequence *v28; // rax
cocos2d::ccColor3B *v29; // r8
struct cocos2d::CCFadeTo *v30; // rax
cocos2d::ccColor3B *v31; // r8
bool v32; // dl
__int64 v33; // rdx
__int64 v34; // rcx
__int64 v35; // r8
__int64 v36; // r9
void **v37; // r15
char *v38; // r14
unsigned __int64 v39; // r13
__int64 v40; // rbx
unsigned __int64 v41; // rsi
__int64 v42; // rcx
__int64 v43; // rbx
struct cocos2d::CCDelayTime *v44; // rax
struct cocos2d::CCSequence *v45; // rax
cocos2d::ccColor3B *v46; // r8
char *v47; // rax
float v48; // [rsp+20h] [rbp-E0h]
float v49; // [rsp+20h] [rbp-E0h]
float v50; // [rsp+20h] [rbp-E0h]
float v51; // [rsp+20h] [rbp-E0h]
void **v52; // [rsp+30h] [rbp-D0h] BYREF
FMODAudioEngine *v53; // [rsp+38h] [rbp-C8h]
void *Block[2]; // [rsp+40h] [rbp-C0h] BYREF
__int64 v55; // [rsp+50h] [rbp-B0h]
unsigned __int64 v56; // [rsp+58h] [rbp-A8h]
void *Src[2]; // [rsp+60h] [rbp-A0h] BYREF
unsigned __int64 v58; // [rsp+70h] [rbp-90h]
unsigned __int64 v59; // [rsp+78h] [rbp-88h]
_QWORD v60[4]; // [rsp+80h] [rbp-80h] BYREF
cocos2d::ParticleStruct v61[16]; // [rsp+A0h] [rbp-60h] BYREF
int v62; // [rsp+1424h] [rbp+1324h]
if ( !a1->m_loading && !a1->m_uiLocked )
{
a1->m_rewardStatus = 0;
sub_14003CCE0((void **)&a1->m_chestID, byte_140518980, 0);
a1->m_loading = 1;
v3 = &a1->m_textInput->m_textField->cocos2d::CCLabelProtocol;
v4 = v3->getString(v3);
*(_OWORD *)Src = 0;
v58 = 0;
v59 = 0;
v5 = -1;
do
++v5;
while ( v4[v5] );
sub_14003A930(Src, v4, v5);
*(_OWORD *)Block = 0;
v55 = 0;
v56 = 15;
LOBYTE(Block[0]) = 0;
CCTextInputNode::setString((__int64)a1->m_textInput, Block);
*(_OWORD *)Block = 0;
v55 = 1;
v56 = 15;
LOWORD(Block[0]) = (unsigned __int8)asc_140518984[0];
CCTextInputNode::updateLabel(a1->m_textInput, (__int64)Block);
v6 = (float)((float)rand() / 32767.0) <= 0.5;
v7 = MusicDownloadManager::sharedState();
MusicDownloadManager::pathForSFX((__int64)v7, v60, v6 + 9982);
v52 = Block;
v8 = sub_14003BDB0((__int64)Block, (__int64)v60);
v9 = qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v53 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v53);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v9 = qword_1406C2E88;
}
rand();
FMODAudioEngine::playEffect(v9, v8, v10, v11, 1056964608);
*(_OWORD *)Block = 0;
v55 = 0;
v56 = 15;
v12 = sub_14003AA10(0xC0u);
Block[0] = v12;
v55 = 179;
v56 = 191;
qmemcpy(
v12,
"40a0.21a0.81a0.2a180a90a10a12a6a90a12a0a0a0a0a0a0a25a10a0a10a0a0a0.815686a0a1a0a1a0a4a1a0a0a0.733333a0a0a0a1a0a1a0"
"a0a0a0.2a0a0a0a0a0a0a0a0a2a1a1a0a0a26a0a0a0a0a0a0a0a0a0a0a0a0a0a",
178);
v12[89] = (unsigned __int8)a40a021a081a02a[178];
if ( v55 )
{
sub_140063B90((__int64)v61);
GameToolbox::particleStringToStruct((__int64 *)Block, (__int64)v61);
v13 = GameToolbox::particleFromStruct(v61, nullptr, 0);
sub_14003A830((__int64)&v61[0].sFrame);
}
else
{
v13 = nullptr;
}
if ( v56 > 0xF )
{
v14 = Block[0];
if ( v56 + 1 >= 0x1000 )
{
v14 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v14 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v14);
}
v55 = 0;
v56 = 15;
LOBYTE(Block[0]) = 0;
v15 = ((float (__fastcall *)(SecretLayer5 *, cocos2d::CCParticleSystemQuad *, __int64))a1->addChild_0)(a1, v13, 30);
cocos2d::CCPoint::CCPoint(v15, 0.0);
v16 = a1->m_textInput->getPosition_0(a1->m_textInput);
cocos2d::CCPoint::operator+(v16, &v52);
v13->setPosition_0(v13, (const cocos2d::CCPoint *)&v52);
m_chatIndex = a1->m_chatIndex;
a1->m_chatIndex = m_chatIndex + 1;
Myfirst = a1->m_soundEffects._Mypair._Myval2._Myfirst;
if ( (int)m_chatIndex + 1 > (unsigned __int64)(a1->m_soundEffects._Mypair._Myval2._Mylast - Myfirst - 1) )
{
v19 = Myfirst[m_chatIndex];
v20 = rand();
v62 = -1;
LODWORD(v61[0].Duration) = v20;
for ( i = 1; i < 0x270; ++i )
{
v20 = i + 1812433253 * (v20 ^ (v20 >> 30));
*((_DWORD *)&v61[0].Duration + i) = v20;
}
v61[0].TotalParticles = 624;
sub_1403F8010(a1->m_soundEffects._Mypair._Myval2._Myfirst, a1->m_soundEffects._Mypair._Myval2._Mylast, v61);
a1->m_chatIndex = 0;
if ( *a1->m_soundEffects._Mypair._Myval2._Myfirst == v19 )
a1->m_chatIndex = 1;
}
v22 = cocos2d::CCCallFunc::create(a1, SecretLayer5::fadeInSubmitMessage);
v23 = cocos2d::CCDelayTime::create(0.30000001);
v24 = cocos2d::CCSequence::create(v23, v22, 0);
cocos2d::CCNode::runAction((CCLightFlash *)a1, (cocos2d::CCPoint)v24, v25, 0.0, v48);
v26 = cocos2d::CCCallFunc::create(a1, SecretLayer5::animateHead);
v27 = cocos2d::CCDelayTime::create(0.0);
v28 = cocos2d::CCSequence::create(v27, v26, 0);
cocos2d::CCNode::runAction((CCLightFlash *)a1, (cocos2d::CCPoint)v28, v29, 0.0, v49);
a1->m_textInput->setTouchEnabled(a1->m_textInput, 0);
a1->m_textInput->onClickTrackNode(a1->m_textInput, 0);
a1->m_textInput->setVisible(a1->m_textInput, 0);
cocos2d::CCNode::stopAllActions(a1->m_inputBackground);
v30 = cocos2d::CCFadeTo::create(0.5, 0);
cocos2d::CCNode::runAction((CCLightFlash *)a1->m_inputBackground, (cocos2d::CCPoint)v30, v31, 0.0, v50);
LoadingCircleSprite::fadeInCircle(a1->m_circleSprite, v32, 0.80000001, 150.0);
a1->m_wraithButton->setEnabled(a1->m_wraithButton, 0);
v53 = (FMODAudioEngine *)Block;
*(_OWORD *)Block = 0;
v55 = 0;
v56 = 0;
v37 = Src;
v38 = (char *)Src[0];
v39 = v59;
if ( v59 > 0xF )
v37 = (void **)Src[0];
v40 = 0x7FFFFFFFFFFFFFFFLL;
v41 = v58;
if ( v58 > 0x7FFFFFFFFFFFFFFFLL )
sub_140007B50(v34, v33, v35, v36);
v56 = 15;
if ( v58 > 0xF )
{
if ( (v58 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
v40 = v58 | 0xF;
if ( (v58 | 0xF) < 0x16 )
v40 = 22;
}
Block[0] = sub_14003AA10(v40 + 1);
v55 = v41;
v56 = v40;
memcpy(Block[0], v37, v41 + 1);
}
else
{
v55 = v58;
*(_OWORD *)Block = *(_OWORD *)v37;
}
v42 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v52 = (void **)operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v52);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v42 = qword_1406C2EC0;
}
GameLevelManager::getGJSecretReward(v42, (const char *)Block);
v43 = cocos2d::CCCallFunc::create(a1, SecretLayer5::finishLoadingState);
v44 = cocos2d::CCDelayTime::create(4.0);
v45 = cocos2d::CCSequence::create(v44, v43, 0);
cocos2d::CCNode::runAction((CCLightFlash *)a1, (cocos2d::CCPoint)v45, v46, 150.0, v51);
sub_14003A830((__int64)v60);
if ( v39 > 0xF )
{
v47 = v38;
if ( v39 + 1 >= 0x1000 )
{
v38 = *((char **)v38 - 1);
if ( (unsigned __int64)(v47 - v38 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v38);
}
}
}