//
// SearchSFXPopup::init from 0xa5f2b0 to 0xa5f6f4 (1092 bytes)
//
// 2 xrefs:
// > SearchSFXPopup::create @ 0xa5f804
// > ??> @ 0xb0658
//
// 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
//
__int64 __fastcall SearchSFXPopup::init(SetTextPopup *a1)
{
unsigned int v2; // w27
cocos2d::CCPoint *p_m_textOffset; // x0
unsigned int v4; // w25
void *v5; // x0
void *v6; // x0
void *v7; // x0
cocos2d::CCDirector *v9; // x0
GameManager *v10; // x0
bool GameVariable; // w28
cocos2d::CCNode *m_buttonMenu; // x27
cocos2d::CCPoint *v13; // x0
unsigned int *v14; // x1
int v15; // w2
unsigned int *v16; // x1
int v17; // w2
unsigned int *v18; // x1
int v19; // w2
unsigned int *v20; // x1
int v21; // w2
unsigned int *p_m_caption; // x1
int m_data; // w2
cocos2d::CCObject *m_mainLayer; // [xsp+98h] [xbp+68h]
__int64 v25; // [xsp+C8h] [xbp+98h] BYREF
cocos2d::CCPoint v26; // [xsp+D0h] [xbp+A0h] BYREF
cocos2d::CCPoint v27; // [xsp+D8h] [xbp+A8h] BYREF
ButtonSprite *v28; // [xsp+E0h] [xbp+B0h] BYREF
sub_D18D28(&v25);
sub_D153B8((int)&v26, "Search");
sub_D153B8((int)&v27, "Find SFX");
sub_D153B8((int)&v28, "OK");
v2 = (unsigned __int8)SetTextPopup::init(a1, (__int64)&v25, (const char **)&v26, 20, 60.0, (__int64)&v27, &v28, 1u);
p_m_textOffset = &v28[-1].m_textOffset;
v4 = v2;
if ( &v28[-1].m_textOffset != (cocos2d::CCPoint *)&qword_124B6B0 )
{
if ( &pthread_create )
{
p_m_caption = (unsigned int *)&v28[-1].m_caption;
do
m_data = __ldaxr(p_m_caption);
while ( __stlxr(m_data - 1, p_m_caption) );
}
else
{
m_data = (int)v28[-1].m_caption.m_data.m_data;
LODWORD(v28[-1].m_caption.m_data.m_data) = m_data - 1;
}
if ( m_data <= 0 )
operator delete(p_m_textOffset);
}
v5 = (void *)(*(_QWORD *)&v27 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v27 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v18 = (unsigned int *)(*(_QWORD *)&v27 - 8LL);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *(_DWORD *)(*(_QWORD *)&v27 - 8LL);
*(_DWORD *)(*(_QWORD *)&v27 - 8LL) = v19 - 1;
}
if ( v19 <= 0 )
operator delete(v5);
}
v6 = (void *)(*(_QWORD *)&v26 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v26 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v20 = (unsigned int *)(*(_QWORD *)&v26 - 8LL);
do
v21 = __ldaxr(v20);
while ( __stlxr(v21 - 1, v20) );
}
else
{
v21 = *(_DWORD *)(*(_QWORD *)&v26 - 8LL);
*(_DWORD *)(*(_QWORD *)&v26 - 8LL) = v21 - 1;
}
if ( v21 <= 0 )
operator delete(v6);
}
v7 = (void *)(v25 - 24);
if ( (__int64 *)(v25 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = (unsigned int *)(v25 - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *(_DWORD *)(v25 - 8);
*(_DWORD *)(v25 - 8) = v17 - 1;
}
if ( v17 <= 0 )
operator delete(v7);
}
if ( v2 )
{
v9 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v9);
sub_D153B8((int)&v28, "Folder\nName");
v10 = GameManager::sharedState();
GameVariable = GameManager::getGameVariable(v10, "0147");
m_buttonMenu = a1->m_buttonMenu;
cocos2d::CCPoint::CCPoint(&v26, (float)(*(float *)&v25 * 0.5) + -124.0, (float)(*((float *)&v25 + 1) * 0.5) + 10.0);
m_mainLayer = a1->m_mainLayer;
cocos2d::CCPoint::CCPoint(&v27, 8.0, 0.0);
GameToolbox::createToggleButton(
0.8,
0.3,
0.0,
(__int64)&v28,
(void (__cdecl *)(cocos2d::CCObject *))SearchSFXPopup::onSearchFolders,
0,
GameVariable,
m_buttonMenu,
&v26,
a1,
m_mainLayer,
(float *)&v27,
(__int64)"bigFont.fnt",
0,
0,
nullptr);
v13 = &v28[-1].m_textOffset;
if ( &v28[-1].m_textOffset != (cocos2d::CCPoint *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v14 = (unsigned int *)&v28[-1].m_caption;
do
v15 = __ldaxr(v14);
while ( __stlxr(v15 - 1, v14) );
}
else
{
v15 = (int)v28[-1].m_caption.m_data.m_data;
LODWORD(v28[-1].m_caption.m_data.m_data) = v15 - 1;
}
if ( v15 <= 0 )
operator delete(v13);
}
}
return v4;
}