//
// AudioEffectsLayer::init from 0x78eebc to 0x78f2b0 (1012 bytes)
//
// 2 xrefs:
// > AudioEffectsLayer::create @ 0x78f36c
// > ??> @ 0x8cf70
//
// 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 AudioEffectsLayer::init(AudioEffectsLayer *a1, char **a2)
{
cocos2d::CCArray *v4; // x0
cocos2d::CCArray *v5; // x28
__int64 v6; // x20
__int64 v7; // x3
unsigned __int64 v8; // x19
__int64 v9; // x26
const std::string *v10; // x1
cocos2d::CCObject *v11; // x0
void *v12; // x0
char *v13; // x0
unsigned int *v14; // x1
int v15; // w2
unsigned int *v16; // x1
int v17; // w2
char *v18; // x0
__int64 v19; // x19
void *v20; // x0
cocos2d::CCArray *m_unk1bc; // x0
AudioEffectsLayer *v22; // x19
cocos2d::CCTextureCache *v23; // x0
cocos2d::CCTexture2D *v24; // x0
cocos2d::CCSpriteBatchNode *v25; // x0
AudioEffectsLayer_vtbl *v26; // x2
unsigned int *v27; // x19
int v28; // w1
unsigned int *v29; // x1
int v30; // w2
AudioEffectsLayer *v31[14]; // [xsp+0h] [xbp+0h] BYREF
AudioEffectsLayer *v32; // [xsp+70h] [xbp+70h]
unsigned __int8 v33; // [xsp+7Fh] [xbp+7Fh]
char v34; // [xsp+98h] [xbp+98h] BYREF
__int64 v35; // [xsp+A0h] [xbp+A0h] BYREF
char *v36; // [xsp+A8h] [xbp+A8h] BYREF
__int64 v37; // [xsp+B0h] [xbp+B0h] BYREF
v32 = a1;
LODWORD(v37) = 0;
v33 = cocos2d::CCLayerColor::initWithColor(a1, (const cocos2d::_ccColor4B *)&v37);
if ( !v33 )
return v33;
v4 = (cocos2d::CCArray *)sub_D153B8((int)&v35, *a2);
v5 = (cocos2d::CCArray *)cocos2d::CCArray::create(v4);
v6 = sub_D168E0((unsigned int)v31 + 160, "~", 0, 1u);
v7 = v6;
v8 = 0;
v9 = *(_QWORD *)(v35 - 24);
v31[13] = (AudioEffectsLayer *)&v34;
while ( 1 )
{
sub_D14F84(&v36, &v35, v8, v7);
if ( v9 != v8 || *((_QWORD *)v36 - 3) )
{
sub_D153B8((int)&v37, v36);
v11 = (cocos2d::CCObject *)cocos2d::CCString::create((cocos2d::CCString *)&v37, v10);
cocos2d::CCArray::addObject(v5, v11);
v12 = (void *)(v37 - 24);
if ( (__int64 *)(v37 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = (unsigned int *)(v37 - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *(_DWORD *)(v37 - 8);
*(_DWORD *)(v37 - 8) = v17 - 1;
}
if ( v17 <= 0 )
break;
}
}
if ( v6 == -1 )
goto LABEL_21;
LABEL_9:
v8 = v6 + 1;
v6 = sub_D168E0((int)&v35, "~", (int)v6 + 1, 1u);
v13 = v36 - 24;
if ( v36 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v14 = (unsigned int *)(v36 - 8);
do
v15 = __ldaxr(v14);
while ( __stlxr(v15 - 1, v14) );
}
else
{
v15 = *((_DWORD *)v36 - 2);
*((_DWORD *)v36 - 2) = v15 - 1;
}
if ( v15 <= 0 )
operator delete(v13);
}
v7 = v6 - v8;
if ( *(_QWORD *)(v35 - 24) < v8 )
sub_D13C5C(
"%s: __pos (which is %zu) > this->size() (which is %zu)",
"basic_string::substr",
v8,
*(_QWORD *)(v35 - 24));
}
operator delete(v12);
if ( v6 != -1 )
goto LABEL_9;
LABEL_21:
v18 = v36 - 24;
if ( v36 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v29 = (unsigned int *)(v36 - 8);
do
v30 = __ldaxr(v29);
while ( __stlxr(v30 - 1, v29) );
}
else
{
v30 = *((_DWORD *)v36 - 2);
*((_DWORD *)v36 - 2) = v30 - 1;
}
if ( v30 <= 0 )
operator delete(v18);
}
v19 = v35;
v32->m_unk1bc = v5;
v20 = (void *)(v19 - 24);
if ( (__int64 *)(v19 - 24) == &qword_124B6B0 )
{
m_unk1bc = v5;
}
else
{
if ( &pthread_create )
{
v27 = (unsigned int *)(v19 - 8);
do
v28 = __ldaxr(v27);
while ( __stlxr(v28 - 1, v27) );
}
else
{
v28 = *(_DWORD *)(v19 - 8);
*(_DWORD *)(v19 - 8) = v28 - 1;
}
if ( v28 <= 0 )
operator delete(v20);
m_unk1bc = v32->m_unk1bc;
}
cocos2d::CCObject::retain(m_unk1bc);
v22 = v32;
AudioEffectsLayer::resetAudioVars(v32);
v23 = cocos2d::CCTextureCache::sharedTextureCache();
v24 = cocos2d::CCTextureCache::addImage(v23, "GJ_GameSheet.png", 0);
v25 = cocos2d::CCSpriteBatchNode::createWithTexture(v24, (unsigned int)&off_18 + 5);
v26 = v22->cocos2d::CCLayerColor::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v22->m_batchNode = v25;
((void (__fastcall *)(AudioEffectsLayer *))v26->addChild)(v22);
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *, __int64))v22->m_batchNode->setBlendFunc)(
v22->m_batchNode,
0x100000302LL);
v22->m_audioScale = 0.1;
return v33;
}