//
// GJRateLevelLayer::setupRateInfo from 0x821c78 to 0x822904 (3212 bytes)
//
// 2 xrefs:
// > GJRateLevelLayer::rateInfoFinished @ 0x8229bc
// > ??> @ 0xa0248
//
// 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 GJRateLevelLayer::setupRateInfo(__int64 a1, _QWORD *a2)
{
cocos2d::CCString *v2; // x0
char *CString; // x0
cocos2d::CCArray *v4; // x26
void *v5; // x0
unsigned int v6; // w21
int v7; // w24
unsigned int v8; // w1
cocos2d::CCString *v9; // x0
const char *v10; // x0
int v11; // w0
float v12; // s8
unsigned int v13; // w21
int v14; // w25
unsigned int v15; // w27
cocos2d::CCString *v16; // x0
const char *v17; // x0
int v18; // w24
float v19; // s0
int v20; // w22
void *v21; // x0
cocos2d::CCArray **p_m_pTargetArray; // x0
cocos2d::CCSprite *v23; // x22
void (__fastcall *setScaleY)(cocos2d::CCSprite *__hidden, float); // x24
__int64 v25; // x0
void (__fastcall *setColor)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x2
void (__fastcall *setPosition)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x24
cocos2d::CCString *v28; // x0
char *v29; // x0
cocos2d::CCArray *v30; // x26
void *v31; // x0
unsigned int v32; // w24
int v33; // w22
unsigned int v34; // w1
cocos2d::CCString *v35; // x0
const char *v36; // x0
int v37; // w0
float v38; // s8
unsigned int v39; // w22
int i; // w28
cocos2d::CCString *v41; // x0
const char *v42; // x0
int v43; // w25
float v44; // s0
int v45; // w24
void *v46; // x0
cocos2d::CCArray **v47; // x0
_DWORD *v48; // x4
int v49; // w0
float v50; // s3
int v51; // w3
float v52; // s1
float v53; // s4
cocos2d::CCString *v54; // x0
size_t v55; // x0
cocos2d::CCLabelBMFont *v56; // x20
void (__fastcall *setAnchorPoint)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::CCPoint *); // x22
void (__fastcall *v58)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x22
cocos2d::CCArray **v59; // x0
unsigned int *p_m_nExtraKerning; // x21
int m_nExtraKerning; // w1
unsigned int *v63; // x21
int v64; // w1
unsigned int *v65; // x24
int v66; // w1
unsigned int *v67; // x24
int v68; // w1
unsigned int *v69; // x1
int v70; // w2
unsigned int *v71; // x21
int v72; // w1
unsigned int *v73; // x1
int v74; // w2
__int64 v75; // [xsp+0h] [xbp+0h] BYREF
cocos2d::CCArray *v76; // [xsp+90h] [xbp+90h]
char *v77; // [xsp+98h] [xbp+98h]
__int64 v78; // [xsp+A0h] [xbp+A0h]
__int64 v79; // [xsp+A8h] [xbp+A8h]
__int64 v80; // [xsp+B8h] [xbp+B8h]
__int64 v81; // [xsp+C0h] [xbp+C0h]
cocos2d::CCPoint v82; // [xsp+C8h] [xbp+C8h] BYREF
cocos2d::CCLabelBMFont *v83; // [xsp+D0h] [xbp+D0h] BYREF
cocos2d::CCPoint v84; // [xsp+D8h] [xbp+D8h] BYREF
cocos2d::CCPoint v85; // [xsp+E0h] [xbp+E0h] BYREF
v79 = a1;
v76 = sub_82052C(a2, ":");
v2 = cocos2d::CCArray::stringAtIndex(v76, 0);
CString = (char *)cocos2d::CCString::getCString(v2);
sub_D153B8((unsigned int)&v75 + 224, CString);
v4 = sub_82052C(&v85, &byte_F804F8);
v5 = (void *)(*(_QWORD *)&v85 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v85 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v73 = (unsigned int *)(*(_QWORD *)&v85 - 8LL);
do
v74 = __ldaxr(v73);
while ( __stlxr(v74 - 1, v73) );
}
else
{
v74 = *(_DWORD *)(*(_QWORD *)&v85 - 8LL);
*(_DWORD *)(*(_QWORD *)&v85 - 8LL) = v74 - 1;
}
if ( v74 <= 0 )
operator delete(v5);
}
v6 = 0;
v7 = 0;
while ( v6 < (unsigned int)cocos2d::CCArray::count(v4) )
{
v8 = v6++;
v9 = cocos2d::CCArray::stringAtIndex(v4, v8);
v10 = cocos2d::CCString::getCString(v9);
v11 = atoi(v10);
if ( v7 < v11 )
v7 = v11;
}
v12 = 10.0;
if ( (float)((float)v7 * 10.0) > 100.0 )
v12 = 100.0 / (float)v7;
v13 = 0;
v14 = -120;
v78 = v79 + 1080;
v77 = &byte_F288A0;
if ( (unsigned int)cocos2d::CCArray::count(v4) )
{
do
{
v15 = v13 + 1;
v16 = cocos2d::CCArray::stringAtIndex(v4, v13);
v17 = cocos2d::CCString::getCString(v16);
v18 = atoi(v17);
cocos2d::CCPoint::CCPoint(&v85, (float)v14, -42.0);
cocos2d::CCPoint::operator+(&v82, v78, &v85);
LOWORD(v80) = -26986;
BYTE2(v80) = -106;
LOWORD(v81) = 0;
BYTE2(v81) = 0;
GameToolbox::intToString((__int64 *)&v83, (GameToolbox *)(v13 + 1));
if ( v18 <= 0 )
{
LOWORD(v80) = 12371;
BYTE2(v80) = 23;
LOWORD(v81) = 8247;
BYTE2(v81) = 16;
sub_D1798C(&v83, v77, 0);
if ( v12 < 10.0 )
{
v19 = v12;
v18 = 1;
}
else
{
v19 = v12 * 0.5;
v18 = 1;
v82.y = v82.y - (float)((float)(v12 * 0.5) * 0.5);
}
}
else
{
v19 = v12;
switch ( v13 )
{
case 0u:
LOWORD(v80) = -11517;
v19 = v12;
BYTE2(v80) = -1;
break;
case 1u:
LOWORD(v80) = -27904;
v19 = v12;
BYTE2(v80) = -1;
break;
case 2u:
LOWORD(v80) = -1536;
v19 = v12;
BYTE2(v80) = 60;
break;
case 3u:
LOBYTE(v80) = 94;
v19 = v12;
*(_WORD *)((char *)&v80 + 1) = 216;
break;
case 4u:
LOWORD(v80) = -4610;
v19 = v12;
BYTE2(v80) = 20;
break;
case 5u:
LOBYTE(v80) = -1;
v19 = v12;
*(_WORD *)((char *)&v80 + 1) = 183;
break;
case 6u:
LOBYTE(v80) = -1;
v19 = v12;
*(_WORD *)((char *)&v80 + 1) = 120;
break;
case 7u:
LOWORD(v80) = 30207;
v19 = v12;
BYTE2(v80) = -21;
break;
case 8u:
LOWORD(v80) = 11775;
v19 = v12;
BYTE2(v80) = -20;
break;
case 9u:
LOBYTE(v80) = -1;
v19 = v12;
*(_WORD *)((char *)&v80 + 1) = 45;
break;
default:
break;
}
}
v20 = (int)v19;
cocos2d::CCPoint::CCPoint(&v84, &v82);
sub_D18D28(&v85);
GJRateLevelLayer::createStatPillar(v79, 10, v20, v18, v80, v81, (__int64)&v84, &v85);
v21 = (void *)(*(_QWORD *)&v85 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v85 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v63 = (unsigned int *)(*(_QWORD *)&v85 - 8LL);
do
v64 = __ldaxr(v63);
while ( __stlxr(v64 - 1, v63) );
}
else
{
v64 = *(_DWORD *)(*(_QWORD *)&v85 - 8LL);
*(_DWORD *)(*(_QWORD *)&v85 - 8LL) = v64 - 1;
}
if ( v64 <= 0 )
operator delete(v21);
}
p_m_pTargetArray = &v83[-1].m_pTargetArray;
if ( &v83[-1].m_pTargetArray != (cocos2d::CCArray **)&qword_124B6B0 )
{
if ( &pthread_create )
{
p_m_nExtraKerning = (unsigned int *)&v83[-1].m_nExtraKerning;
do
m_nExtraKerning = __ldaxr(p_m_nExtraKerning);
while ( __stlxr(m_nExtraKerning - 1, p_m_nExtraKerning) );
}
else
{
m_nExtraKerning = v83[-1].m_nExtraKerning;
v83[-1].m_nExtraKerning = m_nExtraKerning - 1;
}
if ( m_nExtraKerning <= 0 )
operator delete(p_m_pTargetArray);
}
v13 = v15;
v14 += 15;
}
while ( v15 < (unsigned int)cocos2d::CCArray::count(v4) );
}
v23 = cocos2d::CCSprite::createWithSpriteFrameName("whiteSquare60_001.png");
v23->setScaleX(v23, 0.06);
setScaleY = v23->setScaleY;
v25 = (__int64)v23->getContentSize(v23);
setScaleY(v23, 110.0 / *(float *)(v25 + 4));
setColor = v23->setColor;
LOWORD(v85.x) = 11086;
BYTE2(v85.x) = 24;
setColor(v23, (const cocos2d::ccColor3B *)&v85);
v23->setOpacity(v23, 4294967240LL);
(*(void (__fastcall **)(_QWORD, cocos2d::CCSprite *, __int64))(**(_QWORD **)(v79 + 576) + 448LL))(
*(_QWORD *)(v79 + 576),
v23,
3);
setPosition = v23->setPosition;
cocos2d::CCPoint::CCPoint(&v84, 38.0, 0.0);
cocos2d::CCPoint::operator+(&v85, v78, &v84);
setPosition(v23, &v85);
v28 = cocos2d::CCArray::stringAtIndex(v76, 1u);
v29 = (char *)cocos2d::CCString::getCString(v28);
sub_D153B8((int)&v85, v29);
v30 = sub_82052C(&v85, &byte_F804F8);
v31 = (void *)(*(_QWORD *)&v85 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v85 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v69 = (unsigned int *)(*(_QWORD *)&v85 - 8LL);
do
v70 = __ldaxr(v69);
while ( __stlxr(v70 - 1, v69) );
}
else
{
v70 = *(_DWORD *)(*(_QWORD *)&v85 - 8LL);
*(_DWORD *)(*(_QWORD *)&v85 - 8LL) = v70 - 1;
}
if ( v70 <= 0 )
operator delete(v31);
}
v32 = 0;
v33 = 0;
while ( v32 < (unsigned int)cocos2d::CCArray::count(v30) )
{
v34 = v32++;
v35 = cocos2d::CCArray::stringAtIndex(v30, v34);
v36 = cocos2d::CCString::getCString(v35);
v37 = atoi(v36);
if ( v33 < v37 )
v33 = v37;
}
v38 = 10.0;
if ( (float)((float)v33 * 10.0) > 100.0 )
v38 = 100.0 / (float)v33;
v77 = &byte_F288A0;
v39 = 0;
for ( i = 60; v39 < (unsigned int)cocos2d::CCArray::count(v30); i += 15 )
{
v41 = cocos2d::CCArray::stringAtIndex(v30, v39);
v42 = cocos2d::CCString::getCString(v41);
v43 = atoi(v42);
cocos2d::CCPoint::CCPoint(&v85, (float)i, -42.0);
cocos2d::CCPoint::operator+(&v82, v78, &v85);
LOWORD(v80) = -26986;
BYTE2(v80) = -106;
LOWORD(v81) = 0;
BYTE2(v81) = 0;
sub_D153B8((int)&v83, v77);
if ( v43 <= 0 )
{
LOWORD(v80) = 12371;
BYTE2(v80) = 23;
LOWORD(v81) = 8247;
BYTE2(v81) = 16;
sub_D1798C(&v83, v77, 0);
if ( v38 < 10.0 )
{
v44 = v38;
v43 = 1;
}
else
{
v44 = v38 * 0.5;
v43 = 1;
v82.y = v82.y - (float)((float)(v38 * 0.5) * 0.5);
}
}
else
{
switch ( v39 )
{
case 1u:
LOBYTE(v80) = -1;
*(_WORD *)((char *)&v80 + 1) = 255;
sub_D1798C(&v83, "F", 1);
break;
case 2u:
LOWORD(v80) = 32255;
BYTE2(v80) = 0;
sub_D1798C(&v83, "E", 1);
break;
case 3u:
LOWORD(v80) = 255;
BYTE2(v80) = -1;
sub_D1798C(&v83, "L", 1);
break;
case 4u:
LOWORD(v80) = -256;
BYTE2(v80) = -1;
sub_D1798C(&v83, &byte_F94BD0, 1);
break;
default:
sub_D1798C(&v83, "R", 1);
break;
}
v44 = v38;
}
v45 = (int)v44;
cocos2d::CCPoint::CCPoint(&v84, &v82);
sub_D18D28(&v85);
GJRateLevelLayer::createStatPillar(v79, 10, v45, v43, v80, v81, (__int64)&v84, &v85);
v46 = (void *)(*(_QWORD *)&v85 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v85 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v67 = (unsigned int *)(*(_QWORD *)&v85 - 8LL);
do
v68 = __ldaxr(v67);
while ( __stlxr(v68 - 1, v67) );
}
else
{
v68 = *(_DWORD *)(*(_QWORD *)&v85 - 8LL);
*(_DWORD *)(*(_QWORD *)&v85 - 8LL) = v68 - 1;
}
if ( v68 <= 0 )
operator delete(v46);
}
v47 = &v83[-1].m_pTargetArray;
if ( &v83[-1].m_pTargetArray != (cocos2d::CCArray **)&qword_124B6B0 )
{
if ( &pthread_create )
{
v65 = (unsigned int *)&v83[-1].m_nExtraKerning;
do
v66 = __ldaxr(v65);
while ( __stlxr(v66 - 1, v65) );
}
else
{
v66 = v83[-1].m_nExtraKerning;
v83[-1].m_nExtraKerning = v66 - 1;
}
if ( v66 <= 0 )
operator delete(v47);
}
++v39;
}
v48 = *(_DWORD **)(v79 + 1000);
v49 = v48[198];
v83 = (cocos2d::CCLabelBMFont *)&byte_124B6C8;
if ( (float)v49 <= 0.0 )
{
v54 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Req: %i",
(const char *)(unsigned int)v48[196]);
}
else
{
v51 = v48[200];
v52 = (float)(int)v48[199];
v53 = (float)(int)v48[201];
v50 = (float)v49;
v54 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"R: %i (%i- / %i+)\n%.1f | +%.1f | -%.1f | +-%.1f\nReq: %i",
(const char *)(unsigned int)(int)v50,
(unsigned int)(int)v53,
(unsigned int)(int)(float)v51,
(unsigned int)v48[196],
(float)(v52 / v50),
(float)((float)(v52 - v53) / (float)(v50 - v53)),
(float)((float)(v52 - (float)((float)v51 * 10.0)) / (float)(v50 - (float)v51)),
(float)((float)((float)(v52 - (float)((float)v51 * 10.0)) - v53)
/ (float)((float)(v50 - (float)v51) - v53)));
}
v77 = (char *)cocos2d::CCString::getCString(v54);
v55 = strlen(v77);
sub_D1798C(&v83, v77, v55);
v56 = cocos2d::CCLabelBMFont::create();
setAnchorPoint = v56->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v85, 0.0, 1.0);
setAnchorPoint(v56, &v85);
v56->setScale(v56, 0.6);
v56->setColor(v56, (const cocos2d::ccColor3B *)&unk_EEA030);
v56->setOpacity(v56, 4294967265LL);
(*(void (__fastcall **)(_QWORD, cocos2d::CCLabelBMFont *, __int64))(**(_QWORD **)(v79 + 576) + 448LL))(
*(_QWORD *)(v79 + 576),
v56,
2);
v58 = v56->setPosition;
cocos2d::CCPoint::CCPoint(&v84, -130.0, 48.0);
cocos2d::CCPoint::operator+(&v85, v78, &v84);
v58(v56, &v85);
v59 = &v83[-1].m_pTargetArray;
if ( &v83[-1].m_pTargetArray != (cocos2d::CCArray **)&qword_124B6B0 )
{
if ( &pthread_create )
{
v71 = (unsigned int *)&v83[-1].m_nExtraKerning;
do
v72 = __ldaxr(v71);
while ( __stlxr(v72 - 1, v71) );
}
else
{
v72 = v83[-1].m_nExtraKerning;
v83[-1].m_nExtraKerning = v72 - 1;
}
if ( v72 <= 0 )
operator delete(v59);
}
return _stack_chk_guard;
}