//
// LevelInfoLayer::setupPlatformerStats from 0x6d7904 to 0x6d7da8 (1188 bytes)
//
// 2 xrefs:
// > LevelInfoLayer::init @ 0x6dcf0c
// > ??> @ 0x82ad0
//
// 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 LevelInfoLayer::setupPlatformerStats(LevelInfoLayer *a1)
{
cocos2d::CCDirector *v2; // x0
int m_bestTime; // w4
const char *v4; // x1
unsigned int v5; // w2
unsigned int v6; // w3
unsigned int v7; // w4
cocos2d::CCString *v8; // x0
size_t v9; // x0
cocos2d::CCString *v10; // x0
size_t v11; // x0
float v12; // s8
cocos2d::CCLabelBMFont *v13; // x22
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x23
GameToolbox *m_bestPoints; // x0
cocos2d::CCArray **p_m_pTargetArray; // x22
__int64 *v17; // x0
__int64 v18; // x25
char *v19; // x0
cocos2d::CCLabelBMFont *v20; // x24
cocos2d::CCLabelBMFont *v21; // x0
const cocos2d::CCPoint *(__fastcall *getPosition)(cocos2d::CCNode *__hidden); // x1
void (__fastcall *v23)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x22
__int64 v24; // x26
void *v25; // x0
unsigned int *v26; // x25
int v27; // w1
unsigned int *p_m_nExtraKerning; // x19
int m_nExtraKerning; // w0
unsigned int *v30; // x2
int v31; // w1
const char *CString; // [xsp+68h] [xbp+68h]
const char *v33; // [xsp+68h] [xbp+68h]
float v34; // [xsp+78h] [xbp+78h]
cocos2d::CCLabelBMFont *v35; // [xsp+80h] [xbp+80h] BYREF
cocos2d::CCPoint v36; // [xsp+88h] [xbp+88h] BYREF
char *v37; // [xsp+90h] [xbp+90h] BYREF
v2 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v2);
sub_D153B8((int)&v35, "No Best Time");
m_bestTime = a1->m_level->m_bestTime;
if ( m_bestTime <= 0 )
{
v12 = -10.0;
}
else
{
v4 = (const char *)(unsigned int)(m_bestTime / 1000 / 3600);
v5 = m_bestTime / 1000 / 60 % 60;
v6 = m_bestTime / 1000 % 60;
v7 = m_bestTime % 1000;
if ( v5 | (unsigned int)v4 )
{
if ( (_DWORD)v4 )
v8 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%02d:%02d:%02d.%03d", v4);
else
v8 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%02d:%02d.%03d",
(const char *)v5,
v6,
v7);
}
else
{
v8 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i.%03d",
(const char *)v6,
v7);
}
CString = cocos2d::CCString::getCString(v8);
v9 = strlen(CString);
sub_D1798C(&v35, CString, v9);
v10 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Best Time: %s",
(const char *)v35);
v33 = cocos2d::CCString::getCString(v10);
v11 = strlen(v33);
sub_D1798C(&v35, v33, v11);
v12 = 0.0;
}
v13 = cocos2d::CCLabelBMFont::create();
a1->addChild_0(a1, v13, 3);
setPosition = v13->setPosition;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v37, v34 * 0.5, v12 + 145.0);
setPosition(v13, (const cocos2d::CCPoint *)&v37);
cocos2d::CCLabelBMFont::limitLabelWidth(v13, 200.0, 0.6, 0.0);
m_bestPoints = (GameToolbox *)(unsigned int)a1->m_level->m_bestPoints;
if ( (_DWORD)m_bestPoints )
{
GameToolbox::pointsToString(m_bestPoints, (__int64 *)&v37);
v17 = (__int64 *)sub_D17B90(&v37, 0, "Best Points: ", 13);
v18 = *v17;
*v17 = (__int64)&byte_124B6C8;
v19 = v37 - 24;
if ( v37 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v30 = (unsigned int *)(v37 - 8);
do
v31 = __ldaxr(v30);
while ( __stlxr(v31 - 1, v30) );
}
else
{
v31 = *((_DWORD *)v37 - 2);
*((_DWORD *)v37 - 2) = v31 - 1;
}
if ( v31 <= 0 )
operator delete(v19);
}
v20 = cocos2d::CCLabelBMFont::create();
a1->addChild_0(a1, v20, 3);
v21 = v13;
getPosition = v13->getPosition;
v23 = v20->setPosition;
v24 = (__int64)getPosition(v21);
cocos2d::CCPoint::CCPoint(&v36, 0.0, -28.0);
cocos2d::CCPoint::operator+(&v37, v24, &v36);
v23(v20, (const cocos2d::CCPoint *)&v37);
cocos2d::CCLabelBMFont::limitLabelWidth(v20, 200.0, 0.6, 0.0);
v25 = (void *)(v18 - 24);
if ( (__int64 *)(v18 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v26 = (unsigned int *)(v18 - 8);
do
v27 = __ldaxr(v26);
while ( __stlxr(v27 - 1, v26) );
}
else
{
v27 = *(_DWORD *)(v18 - 8);
*(_DWORD *)(v18 - 8) = v27 - 1;
}
if ( v27 <= 0 )
operator delete(v25);
}
}
p_m_pTargetArray = &v35[-1].m_pTargetArray;
if ( &v35[-1].m_pTargetArray != (cocos2d::CCArray **)&qword_124B6B0 )
{
if ( &pthread_create )
{
p_m_nExtraKerning = (unsigned int *)&v35[-1].m_nExtraKerning;
do
m_nExtraKerning = __ldaxr(p_m_nExtraKerning);
while ( __stlxr(m_nExtraKerning - 1, p_m_nExtraKerning) );
}
else
{
m_nExtraKerning = v35[-1].m_nExtraKerning;
v35[-1].m_nExtraKerning = m_nExtraKerning - 1;
}
if ( m_nExtraKerning <= 0 )
operator delete(p_m_pTargetArray);
}
}