//
// MoreSearchLayer::onSongMode from 0x140316b90 to 0x140317047 (1207 bytes)
//
// 5 xrefs:
// > MoreSearchLayer::init @ 0x14031487c
// > MoreSearchLayer::init @ 0x140313f3f
// > MoreSearchLayer::init @ 0x140314075
// > ??> @ 0x1406d4970
// > ??> @ 0x1406d497c
//
// 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=6
void MoreSearchLayer::onSongMode(MoreSearchLayer *a1, cocos2d::CCObject *a2)
{
int v3; // r15d
unsigned __int8 v4; // r14
__int64 v5; // rbx
cocos2d::CCString *v6; // rax
char v7; // di
void *v8; // rcx
__int64 v9; // rbx
struct cocos2d::CCString *v10; // rax
void *v11; // rcx
__int64 v12; // rbx
struct cocos2d::CCString *v13; // rax
void *v14; // rcx
const char *v15; // rdi
const char *v16; // rbx
ButtonSprite *v17; // rax
ButtonSprite *v18; // rax
__int64 v19; // rbx
cocos2d::CCString *v20; // rax
bool v21; // bl
void *v22; // rcx
void *v23; // [rsp+20h] [rbp-50h]
void *v24; // [rsp+20h] [rbp-50h]
void *v25; // [rsp+20h] [rbp-50h]
void *v26; // [rsp+20h] [rbp-50h]
void *v27[2]; // [rsp+28h] [rbp-48h] BYREF
__int64 v28; // [rsp+38h] [rbp-38h]
unsigned __int64 v29; // [rsp+40h] [rbp-30h]
void *Block[2]; // [rsp+48h] [rbp-28h] BYREF
__int64 v31; // [rsp+58h] [rbp-18h]
unsigned __int64 v32; // [rsp+60h] [rbp-10h]
v3 = a2->getTag(a2);
v4 = v3 == 2;
v5 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v23 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v23);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v5 = qword_1406C2EC0;
}
*(_OWORD *)Block = 0;
Block[0] = sub_14003AA10(0x20u);
v31 = 17;
v32 = 31;
strcpy((char *)Block[0], "customsong_filter");
v6 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(*(_QWORD *)(v5 + 344), Block);
v7 = cocos2d::CCString::boolValue(v6);
if ( v32 > 0xF )
{
v8 = Block[0];
if ( v32 + 1 >= 0x1000 )
{
v8 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v8 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v8);
}
v31 = 0;
v32 = 15;
LOBYTE(Block[0]) = 0;
v9 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v24 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v24);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v9 = qword_1406C2EC0;
}
*(_OWORD *)v27 = 0;
v27[0] = sub_14003AA10(0x20u);
v28 = 17;
v29 = 31;
strcpy((char *)v27[0], "customsong_filter");
v10 = cocos2d::CCString::createWithFormat("%i", v4);
cocos2d::CCDictionary::setObject(*(_QWORD *)(v9 + 344), v10, v27);
if ( v29 > 0xF )
{
v11 = v27[0];
if ( v29 + 1 >= 0x1000 )
{
v11 = *((void **)v27[0] - 1);
if ( (unsigned __int64)((char *)v27[0] - (char *)v11 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v11);
}
v28 = 0;
v29 = 15;
LOBYTE(v27[0]) = 0;
if ( v7 != v4 )
{
v12 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v25 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v25);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v12 = qword_1406C2EC0;
}
v31 = 11;
v32 = 15;
Block[0] = (void *)0x6C69665F676E6F73LL;
Block[1] = (void *)7497076;
v13 = cocos2d::CCString::createWithFormat("%i", v3 != 2);
cocos2d::CCDictionary::setObject(*(_QWORD *)(v12 + 344), v13, Block);
if ( v32 > 0xF )
{
v14 = Block[0];
if ( v32 + 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);
}
*(_OWORD *)v27 = 0;
v28 = 0;
v29 = 15;
LOBYTE(v27[0]) = 0;
CCTextInputNode::setString((__int64)a1->m_enterSongID, v27);
}
v15 = "GJ_button_04.png";
v16 = "GJ_button_01.png";
if ( v3 == 2 )
v16 = "GJ_button_04.png";
v17 = (ButtonSprite *)a1->m_normalBtn->getNormalImage(a1->m_normalBtn);
ButtonSprite::updateBGImage(v17, v16);
if ( v3 == 2 )
v15 = "GJ_button_01.png";
v18 = (ButtonSprite *)a1->m_customBtn->getNormalImage(a1->m_customBtn);
ButtonSprite::updateBGImage(v18, v15);
v19 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v26 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v26);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v19 = qword_1406C2EC0;
}
*(_OWORD *)v27 = 0;
v28 = 0;
v29 = 15;
v27[0] = sub_14003AA10(0x20u);
v28 = 17;
v29 = 31;
strcpy((char *)v27[0], "enable_songFilter");
v20 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(*(_QWORD *)(v19 + 344), v27);
v21 = cocos2d::CCString::boolValue(v20);
if ( v29 > 0xF )
{
v22 = v27[0];
if ( v29 + 1 >= 0x1000 )
{
v22 = *((void **)v27[0] - 1);
if ( (unsigned __int64)((char *)v27[0] - (char *)v22 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v22);
}
v28 = 0;
v29 = 15;
LOBYTE(v27[0]) = 0;
MoreSearchLayer::toggleSongNodes(a1, v4, !v21);
MoreSearchLayer::updateAudioLabel(a1);
}