//
// SecretGame01Layer::resetGame from 0xa9413c to 0xa94858 (1820 bytes)
//
// 4 xrefs:
// > SecretLayer6::startGame01 @ 0xa94874
// > ??> @ 0x75858
// > SecretGame01Layer::scaleOutGame @ 0xa94c18
// > ??> @ 0x122be90
//
// 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
//
void SecretGame01Layer::resetGame(SecretGame01Layer *a1)
{
cocos2d::CCArray *m_gameObjects; // x2
cocos2d::ccArray *data; // x1
int RowsForDifficulty; // w27
cocos2d::CCDirector *v5; // x0
float v6; // s9
float v7; // s8
float v8; // s11
float v9; // s10
__int64 v10; // x19
void *v11; // x0
void *v12; // x0
char *v13; // x0
int v14; // w22
cocos2d::CCSprite *v15; // x20
void (__fastcall *setColor)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x3
cocos2d::CCSprite *v17; // x24
void (__fastcall *setPosition)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x28
void (__fastcall *v19)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x3
CCMenuItemSpriteExtra *v20; // x24
void (__fastcall *v21)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x19
cocos2d::CCScaleTo *v22; // x0
cocos2d::CCEaseElasticOut *v23; // x0
cocos2d::CCActionInterval *v24; // x1
cocos2d::CCAction *v25; // x0
cocos2d::CCSequence *v26; // x19
cocos2d::CCFiniteTimeAction *v27; // x0
cocos2d::CCAction *v28; // x0
char *v29; // x0
char *v30; // x24
cocos2d::CCObject **arr; // x19
cocos2d::CCObject **v32; // x20
cocos2d::CCObject *v33; // x0
unsigned int *v34; // x19
int v35; // w0
unsigned int *v36; // x1
int v37; // w2
unsigned int *v38; // x1
int v39; // w2
unsigned int *v40; // x1
int v41; // w2
unsigned int *v42; // x1
int v43; // w2
int v44; // [xsp+B4h] [xbp+B4h]
float v45; // [xsp+D0h] [xbp+D0h]
float v46; // [xsp+D4h] [xbp+D4h]
cocos2d::CCPoint v47; // [xsp+D8h] [xbp+D8h] BYREF
char *v48; // [xsp+E0h] [xbp+E0h] BYREF
const char *v49; // [xsp+E8h] [xbp+E8h] BYREF
char *v50; // [xsp+F0h] [xbp+F0h] BYREF
cocos2d::CCPoint v51; // [xsp+F8h] [xbp+F8h] BYREF
__int64 v52; // [xsp+100h] [xbp+100h] BYREF
cocos2d::CCPoint v53; // 0:kr08_8.8
cocos2d::CCPoint v54; // 0:kr10_8.8
cocos2d::SEL_MenuHandler v55; // 0:x2.16
m_gameObjects = a1->m_gameObjects;
if ( m_gameObjects )
{
data = m_gameObjects->data;
if ( data->num )
{
arr = data->arr;
v32 = &arr[data->num - 1];
if ( arr <= v32 )
{
v33 = *arr;
if ( *arr )
{
do
{
++arr;
v33->__vftable[6].acceptVisitor(v33, (cocos2d::CCDataVisitor *)((char *)&dword_0 + 1));
if ( v32 < arr )
break;
v33 = *arr;
}
while ( *arr );
m_gameObjects = a1->m_gameObjects;
}
}
}
}
cocos2d::CCArray::removeAllObjects(m_gameObjects);
RowsForDifficulty = SecretGame01Layer::getRowsForDifficulty(a1, a1->m_gameDifficulty);
v5 = cocos2d::CCDirector::sharedDirector();
v44 = RowsForDifficulty * RowsForDifficulty;
cocos2d::CCDirector::getWinSize(v5);
cocos2d::CCPoint::CCPoint(&v47, v45 * 0.5, v46 * 0.5);
v6 = (float)RowsForDifficulty * 0.5;
v7 = (float)(RowsForDifficulty - 1) * 0.5;
v8 = (float)(v47.y + (float)(v6 * 30.0)) + (float)(v7 * 8.0);
v9 = (float)(v47.x - (float)(v6 * 30.0)) - (float)(v7 * 8.0);
SecretGame01Layer::getFrameForDifficulty(a1, 0, (__int64)&v48);
sub_D153B8((int)&v50, v48);
sub_D153B8((int)&v51, "_001.png");
sub_D153B8((int)&v52, "_2_001.png");
while ( 1 )
{
v10 = sub_D1641C((int)&v50, *(void **)&v51);
if ( v10 == -1 )
break;
sub_D1861C(&v50, v10, *(_QWORD *)(*(_QWORD *)&v51 - 24LL), v52, *(_QWORD *)(v52 - 24));
}
v11 = (void *)(v52 - 24);
if ( (__int64 *)(v52 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v36 = (unsigned int *)(v52 - 8);
do
v37 = __ldaxr(v36);
while ( __stlxr(v37 - 1, v36) );
}
else
{
v37 = *(_DWORD *)(v52 - 8);
*(_DWORD *)(v52 - 8) = v37 - 1;
}
if ( v37 <= 0 )
operator delete(v11);
}
v12 = (void *)(*(_QWORD *)&v51 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v51 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v38 = (unsigned int *)(*(_QWORD *)&v51 - 8LL);
do
v39 = __ldaxr(v38);
while ( __stlxr(v39 - 1, v38) );
}
else
{
v39 = *(_DWORD *)(*(_QWORD *)&v51 - 8LL);
*(_DWORD *)(*(_QWORD *)&v51 - 8LL) = v39 - 1;
}
if ( v39 <= 0 )
operator delete(v12);
}
sub_D153B8((int)&v49, v50);
v13 = v50 - 24;
if ( v50 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v40 = (unsigned int *)(v50 - 8);
do
v41 = __ldaxr(v40);
while ( __stlxr(v41 - 1, v40) );
}
else
{
v41 = *((_DWORD *)v50 - 2);
*((_DWORD *)v50 - 2) = v41 - 1;
}
if ( v41 <= 0 )
operator delete(v13);
}
v14 = 0;
if ( v44 )
{
do
{
v15 = cocos2d::CCSprite::createWithSpriteFrameName(v48);
setColor = v15->setColor;
memset(&v52, 75, 3);
setColor(v15, (const cocos2d::ccColor3B *)&v52);
v17 = cocos2d::CCSprite::createWithSpriteFrameName(v49);
v15->addChild_0(v15, v17, -1);
setPosition = v17->setPosition;
v53 = cocos2d::CCNode::convertToNodeSpace(v15, &stru_1244660);
((void (__fastcall *)(cocos2d::CCSprite *, __int64 *, float, float))setPosition)(v17, &v52, v53.x, v53.y);
v19 = v17->setColor;
memset(&v52, 60, 3);
v19(v17, (const cocos2d::ccColor3B *)&v52);
v55.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v55.adj = (size_t)SecretGame01Layer::onSelectButton;
v20 = CCMenuItemSpriteExtra::create(v15, nullptr, v55);
CCMenuItemSpriteExtra::setSizeMult(v20, 1.2);
v20->setTag(v20, v14);
cocos2d::CCArray::addObject(a1->m_gameObjects, v20);
a1->m_mainMenu->addChild(a1->m_mainMenu, v20);
cocos2d::CCPoint::CCPoint(
&v51,
(float)(v9 + 15.0) + (float)((float)(v14 % RowsForDifficulty) * 38.0),
v8 - (float)((float)(int)vcvtms_s32_f32((float)v14 / (float)RowsForDifficulty) * 38.0));
v21 = v20->setPosition;
v54 = cocos2d::CCNode::convertToNodeSpace(a1->m_mainMenu, &v51);
((void (__fastcall *)(CCMenuItemSpriteExtra *, __int64 *, float, float))v21)(v20, &v52, v54.x, v54.y);
++v14;
v22 = (cocos2d::CCScaleTo *)((__int64 (__fastcall *)(cocos2d::CCSprite *, float))v15->setScale)(v15, 0.1);
v23 = (cocos2d::CCEaseElasticOut *)cocos2d::CCScaleTo::create(v22, 0.6, 1.0);
v25 = (cocos2d::CCAction *)cocos2d::CCEaseElasticOut::create(v23, v24, 0.6);
cocos2d::CCNode::runAction(v15, v25);
}
while ( v14 != v44 );
}
a1->m_mainMenu->setTouchEnabled(a1->m_mainMenu, 0);
a1->m_selectedObject = 0;
v26 = (cocos2d::CCSequence *)cocos2d::CCDelayTime::create(0.8);
v27 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCCallFunc::create(a1, SecretGame01Layer::gameStep01, 0);
v28 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v26, v27, 0);
cocos2d::CCNode::runAction(a1, v28);
v29 = (char *)(v49 - 24);
if ( v49 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v42 = (unsigned int *)(v49 - 8);
do
v43 = __ldaxr(v42);
while ( __stlxr(v43 - 1, v42) );
}
else
{
v43 = *((_DWORD *)v49 - 2);
*((_DWORD *)v49 - 2) = v43 - 1;
}
if ( v43 <= 0 )
operator delete(v29);
}
v30 = v48 - 24;
if ( v48 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v34 = (unsigned int *)(v48 - 8);
do
v35 = __ldaxr(v34);
while ( __stlxr(v35 - 1, v34) );
}
else
{
v35 = *((_DWORD *)v48 - 2);
*((_DWORD *)v48 - 2) = v35 - 1;
}
if ( v35 <= 0 )
operator delete(v30);
}
}