//
// GameManager::firstLoad from 0x5f0838 to 0x5f0fdc (1956 bytes)
//
// 2 xrefs:
// > ??> @ 0x860e8
// > ??> @ 0x1149d78
//
// 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 GameManager::firstLoad(GameManager *a1)
{
stl::StringData::Internal *v1; // x2
cocos2d::CCDictionary *v3; // x24
char *v4; // x19
cocos2d::CCString *i; // x0
__int64 v6; // x1
void *v7; // x0
char *CString; // x20
GameManager *v9; // x0
int IntGameVariable; // w0
cocos2d::CCString *v11; // x0
char *v12; // x0
const std::string *v13; // x1
cocos2d::CCObject *v14; // x25
char *v15; // x0
unsigned int *v16; // x1
int v17; // w2
unsigned int *v18; // x1
int v19; // w2
_BOOL4 UGV; // w28
cocos2d::CCDictionary *v21; // x0
cocos2d::CCDictionary *v22; // x19
cocos2d::CCDictionary *m_valueKeeper; // x1
cocos2d::CCDictionary *v24; // x0
cocos2d::CCDictionary *v25; // x19
cocos2d::CCDictionary *m_unlockValueKeeper; // x1
char *v27; // x0
int v28; // w0
int v29; // w0
int v30; // w0
_BOOL4 m_shouldLoadUnlockValueKeeper; // w1
int v32; // w0
AchievementManager *v33; // x0
GameLevelManager *v34; // x0
GameStatsManager *v35; // x0
MusicDownloadManager *v36; // x0
GJAccountManager *v37; // x0
GJMultiplayerManager *v38; // x0
KeybindingsManager *v39; // x0
_BOOL4 v40; // w0
unsigned int v41; // w19
cocos2d::CCArray *v42; // x23
cocos2d::CCString *v43; // x0
char *v44; // x22
cocos2d::CCString *v45; // x0
int v46; // w2
char *v47; // x0
unsigned int *v48; // x1
int v49; // w3
FMODAudioEngine *v50; // x0
FMODAudioEngine *v51; // x0
unsigned int *v52; // x2
int v53; // w1
cocos2d::CCDictionary *v54; // x0
cocos2d::CCDictionary *v55; // x19
cocos2d::CCDictionary *m_customObjectDict; // x1
int v57; // [xsp+70h] [xbp+70h]
__int64 v58; // [xsp+98h] [xbp+98h] BYREF
std::string v59[2]; // [xsp+A0h] [xbp+A0h] BYREF
v1 = (stl::StringData::Internal *)_stack_chk_guard;
a1->m_clickedYouTube = 0;
a1->m_clickedFacebook = 0;
a1->m_clickedTwitter = 0;
a1->m_clickedTwitch = 0;
a1->m_clickedDiscord = 0;
a1->m_clickedReddit = 0;
a1->m_socialsDuration = 0.0;
v59[1].m_data.m_data = v1;
GameManager::resetDPadSettings(a1, 0);
GameManager::resetDPadSettings(a1, 1);
if ( !a1->m_shouldLoadUnlockValueKeeper )
{
v3 = nullptr;
UGV = 0;
goto LABEL_23;
}
if ( !a1->m_valueKeeper )
{
v3 = nullptr;
if ( !a1->m_unlockValueKeeper )
goto LABEL_63;
LABEL_21:
UGV = GameManager::getUGV(a1, "30");
goto LABEL_23;
}
v3 = cocos2d::CCDictionary::create();
v4 = (char *)&dword_0 + 1;
for ( i = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%04i",
(const char *)&dword_0 + 1);
;
i = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%04i",
(const char *)(unsigned int)v4) )
{
CString = (char *)cocos2d::CCString::getCString(i);
v9 = GameManager::sharedState();
IntGameVariable = GameManager::getIntGameVariable(v9, CString);
if ( IntGameVariable <= 0 )
goto LABEL_5;
v11 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)IntGameVariable);
v12 = (char *)cocos2d::CCString::getCString(v11);
sub_D153B8((int)&v58, v12);
v14 = (cocos2d::CCObject *)cocos2d::CCString::create((cocos2d::CCString *)&v58, v13);
sub_D153B8((int)v59, CString);
cocos2d::CCDictionary::setObject((int)v3, v14);
v15 = (char *)v59[0].m_data.m_data - 24;
if ( (__int64 *)v59[0].m_data.m_data - 3 == &qword_124B6B0 )
goto LABEL_4;
if ( &pthread_create )
{
v16 = (unsigned int *)((char *)v59[0].m_data.m_data - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *((_DWORD *)v59[0].m_data.m_data - 2);
*((_DWORD *)v59[0].m_data.m_data - 2) = v17 - 1;
}
if ( v17 > 0 )
{
LABEL_4:
v6 = v58;
v7 = (void *)(v58 - 24);
if ( (__int64 *)(v58 - 24) == &qword_124B6B0 )
goto LABEL_5;
}
else
{
operator delete(v15);
v6 = v58;
v7 = (void *)(v58 - 24);
if ( (__int64 *)(v58 - 24) == &qword_124B6B0 )
goto LABEL_5;
}
if ( &pthread_create )
{
v18 = (unsigned int *)(v6 - 8);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *(_DWORD *)(v6 - 8);
*(_DWORD *)(v6 - 8) = v19 - 1;
}
if ( v19 <= 0 )
break;
LABEL_5:
LODWORD(v4) = (_DWORD)v4 + 1;
if ( (_DWORD)v4 == 182 )
goto LABEL_19;
LABEL_6:
;
}
LODWORD(v4) = (_DWORD)v4 + 1;
operator delete(v7);
if ( (_DWORD)v4 != 182 )
goto LABEL_6;
LABEL_19:
UGV = 0;
if ( a1->m_shouldLoadUnlockValueKeeper )
{
if ( a1->m_unlockValueKeeper )
goto LABEL_21;
LABEL_63:
UGV = 0;
}
LABEL_23:
v21 = cocos2d::CCDictionary::create();
v22 = v21;
m_valueKeeper = a1->m_valueKeeper;
if ( v21 != m_valueKeeper )
{
if ( v21 )
{
cocos2d::CCObject::retain(v21);
m_valueKeeper = a1->m_valueKeeper;
}
if ( m_valueKeeper )
cocos2d::CCObject::release(m_valueKeeper);
a1->m_valueKeeper = v22;
}
v24 = cocos2d::CCDictionary::create();
v25 = v24;
m_unlockValueKeeper = a1->m_unlockValueKeeper;
if ( m_unlockValueKeeper != v24 )
{
if ( v24 )
{
cocos2d::CCObject::retain(v24);
m_unlockValueKeeper = a1->m_unlockValueKeeper;
}
if ( m_unlockValueKeeper )
cocos2d::CCObject::release(m_unlockValueKeeper);
a1->m_unlockValueKeeper = v25;
}
if ( !a1->m_customObjectDict )
{
v54 = cocos2d::CCDictionary::create();
v55 = v54;
m_customObjectDict = a1->m_customObjectDict;
if ( m_customObjectDict != v54 )
{
if ( v54 )
{
cocos2d::CCObject::retain(v54);
m_customObjectDict = a1->m_customObjectDict;
}
if ( m_customObjectDict )
cocos2d::CCObject::release(m_customObjectDict);
a1->m_customObjectDict = v55;
}
}
if ( !a1->m_shouldLoadUnlockValueKeeper )
{
PlatformToolbox::getUniqueUserID((PlatformToolbox *)a1->m_shouldLoadUnlockValueKeeper, v59);
sub_D163D4(&a1->m_playerUDID, v59);
v27 = (char *)v59[0].m_data.m_data - 24;
if ( (__int64 *)v59[0].m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v52 = (unsigned int *)((char *)v59[0].m_data.m_data - 8);
do
v53 = __ldaxr(v52);
while ( __stlxr(v53 - 1, v52) );
}
else
{
v53 = *((_DWORD *)v59[0].m_data.m_data - 2);
*((_DWORD *)v59[0].m_data.m_data - 2) = v53 - 1;
}
if ( v53 <= 0 )
operator delete(v27);
}
}
sub_D1798C(&a1->m_playerName, "Player", 6);
a1->m_playerUserID.value = 0;
v28 = rand();
a1->m_hasRP.value = 0;
v29 = (int)(float)((float)((float)v28 * 4.6566e-10) * 1000.0);
a1->m_playerUserID.seed = v29;
a1->m_playerUserID.random = v29;
v30 = rand();
a1->m_hasDRP = 0;
m_shouldLoadUnlockValueKeeper = a1->m_shouldLoadUnlockValueKeeper;
v32 = (int)(float)((float)((float)v30 * 4.6566e-10) * 1000.0);
a1->m_hasRP.seed = v32;
a1->m_hasRP.random = v32;
if ( !m_shouldLoadUnlockValueKeeper )
{
a1->m_firstSetup = 1;
a1->m_showedMenu = 1;
a1->m_unknownBool4 = 1;
}
GameManager::resetAllIcons(a1);
if ( !a1->m_shouldLoadUnlockValueKeeper )
{
v50 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::setBackgroundMusicVolume(v50, 1.0);
v51 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::setEffectsVolume(v51, 1.0);
}
v33 = AchievementManager::sharedState();
AchievementManager::firstSetup(v33);
v34 = GameLevelManager::sharedState();
GameLevelManager::firstSetup(v34);
v35 = GameStatsManager::sharedState();
GameStatsManager::firstSetup(v35);
v36 = MusicDownloadManager::sharedState();
MusicDownloadManager::firstSetup(v36);
v37 = GJAccountManager::sharedState();
GJAccountManager::firstSetup(v37);
v38 = GJMultiplayerManager::sharedState();
GJMultiplayerManager::firstSetup(v38);
v39 = KeybindingsManager::sharedState();
KeybindingsManager::firstSetup(v39);
v40 = a1->m_shouldLoadUnlockValueKeeper;
if ( a1->m_shouldLoadUnlockValueKeeper )
{
if ( v3 )
{
v41 = 0;
v42 = cocos2d::CCDictionary::allKeys(v3);
while ( v41 < (unsigned int)cocos2d::CCArray::count(v42) )
{
v43 = cocos2d::CCArray::stringAtIndex(v42, v41);
v44 = (char *)cocos2d::CCString::getCString(v43);
sub_D153B8((int)v59, v44);
v45 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(v3, v59);
v46 = cocos2d::CCString::intValue(v45);
v47 = (char *)v59[0].m_data.m_data - 24;
if ( (__int64 *)v59[0].m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v48 = (unsigned int *)((char *)v59[0].m_data.m_data - 8);
do
v49 = __ldaxr(v48);
while ( __stlxr(v49 - 1, v48) );
}
else
{
v49 = *((_DWORD *)v59[0].m_data.m_data - 2);
*((_DWORD *)v59[0].m_data.m_data - 2) = v49 - 1;
}
if ( v49 <= 0 )
{
v57 = v46;
operator delete(v47);
v46 = v57;
}
}
++v41;
GameManager::setIntGameVariable(a1, v44, v46);
}
v40 = a1->m_shouldLoadUnlockValueKeeper;
}
}
else
{
a1->m_resolution = -1;
a1->m_showSongMarkers = 1;
a1->m_showBPMMarkers = 0;
a1->m_showProgressBar = 0;
a1->m_performanceMode = 0;
a1->m_vsyncEnabled = 1;
a1->m_showedRateDiffDialog = 0;
a1->m_showedRateStarDialog = 0;
a1->m_showedLowDetailDialog = 0;
a1->m_recordGameplay = 0;
GameManager::setGameVariable(a1, "0002", 1);
GameManager::setGameVariable(a1, "0001", 1);
GameManager::setGameVariable(a1, "0026", 1);
GameManager::setGameVariable(a1, "0027", 1);
GameManager::setGameVariable(a1, "0023", 1);
GameManager::setGameVariable(a1, "0038", 1);
GameManager::setGameVariable(a1, "0043", 1);
GameManager::setGameVariable(a1, "0044", 1);
GameManager::setIntGameVariable(a1, "0050", 2);
GameManager::setIntGameVariable(a1, "0049", 6);
GameManager::setGameVariable(a1, "0046", 1);
GameManager::setGameVariable(a1, "0044", 1);
GameManager::setGameVariable(a1, "0036", 1);
GameManager::setGameVariable(a1, "0118", 1);
GameManager::setGameVariable(a1, "0117", 1);
GameManager::setGameVariable(a1, "0158", 1);
GameManager::setGameVariable(a1, "0121", 1);
GameManager::setGameVariable(a1, "0037", 1);
v40 = a1->m_shouldLoadUnlockValueKeeper;
}
if ( v40 && UGV )
GameManager::setUGV(a1, "30", 1);
a1->m_loaded = 1;
}