//
// SongUsagePopup::buildUsageGrid from 0x140103030 to 0x1401033c1 (913 bytes)
//
// 2 xrefs:
// > SongUsagePopup::songUsageFinished @ 0x140102e6b
// > ??> @ 0x1409158d8
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:26:43 +0000
//
// Hidden C++ exception states: #wind=1
__int64 __fastcall SongUsagePopup::buildUsageGrid(__int64 a1, __int64 *a2)
{
__int64 *v2; // rbx
__int64 v3; // rdi
__int64 v4; // r12
__int64 v5; // r14
int v6; // ebp
__int64 v7; // r13
int v8; // r9d
__int64 v9; // r15
__int64 v10; // r8
float v11; // xmm7_4
float v12; // xmm6_4
__int64 v13; // rsi
__int64 v14; // rcx
__int64 v15; // rdi
__int64 v16; // rbx
__int64 v17; // rax
__m128i *v18; // rax
struct cocos2d::CCLabelBMFont *v19; // rdi
__int64 v20; // rbx
__int64 v21; // rax
float v22; // xmm7_4
float v23; // xmm6_4
__int64 v24; // rbx
__int64 v25; // rax
_BYTE v29[8]; // [rsp+38h] [rbp-F0h] BYREF
_BYTE v30[8]; // [rsp+40h] [rbp-E8h] BYREF
__m128i v31[2]; // [rsp+48h] [rbp-E0h] BYREF
v2 = a2;
v3 = a1;
v4 = (a2[1] - *a2) / 12;
v5 = cocos2d::CCNode::create();
(*(void (__fastcall **)(_QWORD, __int64, __int64))(**(_QWORD **)(v3 + 584) + 456LL))(*(_QWORD *)(v3 + 584), v5, 2);
v6 = 0;
v7 = (int)v4;
v8 = 7;
if ( (int)v4 > 0 )
{
v9 = 0;
do
{
v10 = (unsigned int)(v4 - 7 * (v6 / 7));
if ( (int)v10 > 7 )
v10 = 7;
v11 = (float)((float)(v6 % 7) - (float)((float)(v10 - 1) * 0.5)) * 50.0;
v12 = (float)(v6 / -7) * 72.0;
v13 = *v2;
v14 = *(unsigned int *)(v9 + *v2 + 4);
if ( !(_DWORD)v14 )
v14 = 0xFFFFFFFFLL;
v15 = GJDifficultySprite::create(v14, 0, v10, 7);
GJDifficultySprite::updateFeatureState(v15, *(unsigned int *)(v9 + v13));
(*(void (__fastcall **)(__int64))(*(_QWORD *)v15 + 160LL))(v15);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)v5 + 456LL))(v5, v15, 2);
v16 = *(_QWORD *)v15;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v30, v11, v12);
(*(void (__fastcall **)(__int64, __int64))(v16 + 184))(v15, v17);
v18 = GameToolbox::pointsToString(v31, *(_DWORD *)(v9 + v13 + 8));
if ( v18[1].m128i_i64[1] > 0xFuLL )
v18 = (__m128i *)v18->m128i_i64[0];
v19 = cocos2d::CCLabelBMFont::create(v18->m128i_i8, (const char *)&qword_140704F78);
sub_14003D310((__int64)v31);
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *))(*(_QWORD *)v19 + 160LL))(v19);
(*(void (__fastcall **)(__int64, struct cocos2d::CCLabelBMFont *, __int64))(*(_QWORD *)v5 + 456LL))(v5, v19, 2);
v20 = *(_QWORD *)v19;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v29, v11, v12 - 30.0);
(*(void (__fastcall **)(struct cocos2d::CCLabelBMFont *, __int64))(v20 + 184))(v19, v21);
++v6;
v9 += 12;
--v7;
v8 = 7;
v2 = a2;
}
while ( v7 );
v3 = a1;
}
v22 = (float)((float)(((int)v4 + 6) / 7 - 1) * 72.0) + 66.0;
if ( (int)v4 < 7 )
v8 = v4;
v23 = fminf(fminf(1.0, 340.0 / (float)((float)v8 * 50.0)), (float)(*(float *)(v3 + 728) - 108.0) / v22);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v5 + 160LL))(v5);
v24 = *(_QWORD *)v5;
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v29,
*(float *)(v3 + 732),
(float)((float)((float)(v22 * 0.5) - 26.0) * v23) + *(float *)(v3 + 736));
return (*(__int64 (__fastcall **)(__int64, __int64))(v24 + 184))(v5, v25);
}