//
// GameManager::firstLoad from 0x10038a600 to 0x10038aea7 (2215 bytes)
//
// 1 xrefs:
// > ??> @ 0x10091edd0
//
// 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 __fastcall GameManager::firstLoad(GameManager *a1)
{
GameManager *v1; // r15
double v2; // xmm0_8
bool m_shouldLoadUnlockValueKeeper; // al
unsigned int i; // r15d
cocos2d::CCString *v5; // rax
const char *CString; // rax
const char *v7; // r13
void *v8; // r14
cocos2d::CCString *v9; // rax
const char *v10; // r12
size_t v11; // rax
size_t v12; // r14
char *v13; // rbx
__int64 v14; // rax
size_t v15; // r13
cocos2d::CCObject *v16; // r14
size_t v17; // rax
size_t v18; // r12
char *v19; // rbx
__int64 v20; // rax
size_t v21; // r13
int v22; // eax
cocos2d::CCDictionary *v23; // rax
cocos2d::CCObject *m_valueKeeper; // rdi
cocos2d::CCDictionary *v25; // r14
cocos2d::CCDictionary *v26; // rax
cocos2d::CCObject *m_unlockValueKeeper; // rdi
cocos2d::CCDictionary *v28; // r14
cocos2d::CCDictionary *v29; // rax
cocos2d::CCObject *m_customObjectDict; // rdi
cocos2d::CCDictionary *v31; // r14
int v32; // eax
FMODAudioEngine *v33; // rax
FMODAudioEngine *v34; // rax
AchievementManager *v35; // rax
GameLevelManager *v36; // rax
GameStatsManager *v37; // rax
MusicDownloadManager *v38; // rax
GJAccountManager *v39; // rax
GJMultiplayerManager *v40; // rax
KeybindingsManager *v41; // rax
cocos2d::CCArray *v42; // r12
unsigned int v43; // r13d
cocos2d::CCString *v44; // rax
const char *v45; // r14
size_t v46; // rax
size_t v47; // r15
char *v48; // rbx
__int64 v49; // rax
size_t v50; // r12
cocos2d::CCString *v51; // rax
int v52; // ebx
char v53; // [rsp+0h] [rbp-80h]
_QWORD v55[2]; // [rsp+10h] [rbp-70h] BYREF
void *__p; // [rsp+20h] [rbp-60h]
char *v57; // [rsp+28h] [rbp-58h]
cocos2d::CCDictionary *v58; // [rsp+30h] [rbp-50h]
int v59; // [rsp+3Ch] [rbp-44h]
__int128 __dst; // [rsp+40h] [rbp-40h] BYREF
void *v61; // [rsp+50h] [rbp-30h]
v1 = a1;
a1->m_socialsDuration = 0.0;
*(_DWORD *)&a1->m_clickedFacebook = 0;
*(_WORD *)&a1->m_clickedDiscord = 0;
*(_QWORD *)&a1->m_dpad1.m_width = 0x7800000118LL;
*(_QWORD *)&a1->m_dpad1.m_deadzone = 0x3F80000000000000LL;
*(_QWORD *)&a1->m_dpad1.m_opacity = 0x41200000000000FFLL;
a1->m_dpad1.m_modeB = 0;
sub_10028CBE0((float *)&__dst, 95.0, 36.0);
v2 = sub_10028CC90(&a1->m_dpad1.m_position, (double *)&__dst);
*(_WORD *)&a1->m_dpad1.m_oneButton = 0;
a1->m_dpad1.m_snap = 0;
a1->m_dpad1.m_split = 0;
GameManager::resetDPadSettings(a1, 1);
m_shouldLoadUnlockValueKeeper = a1->m_shouldLoadUnlockValueKeeper;
if ( !m_shouldLoadUnlockValueKeeper || !a1->m_valueKeeper )
{
v58 = nullptr;
if ( m_shouldLoadUnlockValueKeeper )
goto LABEL_32;
goto LABEL_35;
}
v58 = cocos2d::CCDictionary::create();
for ( i = 1; i != 182; ++i )
{
v5 = (cocos2d::CCString *)sub_1007AB580("%04i", v53);
CString = cocos2d::CCString::getCString(v5);
v7 = CString;
if ( qword_1009A0E18 )
{
if ( GameManager::getIntGameVariable((GameManager *)qword_1009A0E18, CString) <= 0 )
continue;
}
else
{
v8 = operator new(0x638u);
sub_10038CE40(v8);
qword_1009A0E18 = (__int64)v8;
(*(void (__fastcall **)(void *, _QWORD, double))(*(_QWORD *)v8 + 80LL))(v8, i, v2);
if ( GameManager::getIntGameVariable((GameManager *)qword_1009A0E18, v7) <= 0 )
continue;
}
v9 = (cocos2d::CCString *)sub_1007AB580("%i", v53);
v10 = cocos2d::CCString::getCString(v9);
v11 = strlen(v10);
if ( v11 >= 0xFFFFFFFFFFFFFFF8LL )
LABEL_81:
sub_100006BF0(v2);
v12 = v11;
v57 = (char *)v7;
if ( v11 >= 0x17 )
{
v14 = v11 | 7;
v15 = 26;
if ( (v12 | 7) != 0x17 )
v15 = v14 + 1;
v13 = (char *)operator new(v15);
v61 = v13;
*(_QWORD *)&__dst = v15 + 1;
*((_QWORD *)&__dst + 1) = v12;
v7 = v57;
LABEL_16:
memmove(v13, v10, v12);
goto LABEL_17;
}
LOBYTE(__dst) = 2 * v11;
v13 = (char *)&__dst + 1;
if ( v11 )
goto LABEL_16;
LABEL_17:
v13[v12] = 0;
v16 = (cocos2d::CCObject *)sub_1007AB360(&__dst);
v17 = strlen(v7);
if ( v17 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v2);
v18 = v17;
if ( v17 >= 0x17 )
{
v20 = v17 | 7;
v21 = 26;
if ( (v18 | 7) != 0x17 )
v21 = v20 + 1;
v19 = (char *)operator new(v21);
__p = v19;
v55[0] = v21 | 1;
v55[1] = v18;
v7 = v57;
}
else
{
LOBYTE(v55[0]) = 2 * v17;
v19 = (char *)v55 + 1;
if ( !v17 )
goto LABEL_25;
}
memmove(v19, v7, v18);
LABEL_25:
v19[v18] = 0;
cocos2d::CCDictionary::setObject_1((__int64)v58, v16, (char *)v55);
if ( (v55[0] & 1) != 0 )
operator delete(__p);
if ( (__dst & 1) != 0 )
operator delete(v61);
}
v1 = a1;
if ( a1->m_shouldLoadUnlockValueKeeper )
{
LABEL_32:
if ( v1->m_unlockValueKeeper )
{
LOBYTE(v22) = GameManager::getUGV(v1, "30");
v59 = v22;
v23 = cocos2d::CCDictionary::create();
m_valueKeeper = v1->m_valueKeeper;
if ( m_valueKeeper == v23 )
goto LABEL_41;
goto LABEL_36;
}
}
LABEL_35:
v59 = 0;
v23 = cocos2d::CCDictionary::create();
m_valueKeeper = v1->m_valueKeeper;
if ( m_valueKeeper == v23 )
goto LABEL_41;
LABEL_36:
v25 = v23;
if ( v23 )
{
cocos2d::CCObject::retain(v23);
m_valueKeeper = v1->m_valueKeeper;
}
if ( m_valueKeeper )
cocos2d::CCObject::release(m_valueKeeper);
v1->m_valueKeeper = v25;
LABEL_41:
v26 = cocos2d::CCDictionary::create();
m_unlockValueKeeper = v1->m_unlockValueKeeper;
if ( m_unlockValueKeeper != v26 )
{
v28 = v26;
if ( v26 )
{
cocos2d::CCObject::retain(v26);
m_unlockValueKeeper = v1->m_unlockValueKeeper;
}
if ( m_unlockValueKeeper )
cocos2d::CCObject::release(m_unlockValueKeeper);
v1->m_unlockValueKeeper = v28;
}
if ( !v1->m_customObjectDict )
{
v29 = cocos2d::CCDictionary::create();
m_customObjectDict = v1->m_customObjectDict;
if ( m_customObjectDict != v29 )
{
v31 = v29;
if ( v29 )
{
cocos2d::CCObject::retain(v29);
m_customObjectDict = v1->m_customObjectDict;
}
if ( m_customObjectDict )
cocos2d::CCObject::release(m_customObjectDict);
v1->m_customObjectDict = v31;
}
}
if ( !v1->m_shouldLoadUnlockValueKeeper )
{
PlatformToolbox::getUserID(&__dst, v2);
if ( (v1->m_playerUDID.m_data.m_short.sizex2 & 1) != 0 )
operator delete(v1->m_playerUDID.m_data.m_long.longStorage);
v1->m_playerUDID.m_data.m_long.longStorage = (char *)v61;
*(_OWORD *)&v1->m_playerUDID.m_data.m_short.sizex2 = __dst;
}
std::string::assign((std::string *)&v1->m_playerName, "Player");
v1->m_playerUserID.value = 0;
v32 = (int)(float)((float)((float)rand() * 4.6566129e-10) * 1000.0);
v1->m_playerUserID.seed = v32;
v1->m_playerUserID.random = v32;
v1->m_hasRP.value = 0;
HIDWORD(v2) = 0;
*(float *)&v2 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
v1->m_hasRP.seed = (int)*(float *)&v2;
v1->m_hasRP.random = (int)*(float *)&v2;
v1->m_hasDRP = 0;
if ( !v1->m_shouldLoadUnlockValueKeeper )
{
*(_WORD *)&v1->m_firstSetup = 257;
v1->m_unknownBool4 = 1;
}
GameManager::resetAllIcons(v1);
if ( !v1->m_shouldLoadUnlockValueKeeper )
{
v33 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::setBackgroundMusicVolume(v33, 1.0);
v34 = FMODAudioEngine::sharedEngine();
*(_QWORD *)&v2 = 1065353216;
FMODAudioEngine::setEffectsVolume(v34, 1.0);
}
v35 = AchievementManager::sharedState();
AchievementManager::firstSetup(v35);
v36 = GameLevelManager::sharedState();
GameLevelManager::firstSetup(v36);
v37 = GameStatsManager::sharedState();
GameStatsManager::firstSetup(v37);
v38 = MusicDownloadManager::sharedState();
MusicDownloadManager::firstSetup(v38);
v39 = GJAccountManager::sharedState();
GJAccountManager::firstSetup(v39);
v40 = GJMultiplayerManager::sharedState();
GJMultiplayerManager::firstSetup(v40);
v41 = KeybindingsManager::sharedState();
KeybindingsManager::firstSetup(v41);
if ( v1->m_shouldLoadUnlockValueKeeper )
{
if ( v58 )
{
v42 = cocos2d::CCDictionary::allKeys(v58);
if ( (unsigned int)sub_100720070(v42) )
{
v43 = 0;
v57 = (char *)v42;
do
{
v44 = cocos2d::CCArray::stringAtIndex(v42, v43);
v45 = cocos2d::CCString::getCString(v44);
v46 = strlen(v45);
if ( v46 >= 0xFFFFFFFFFFFFFFF8LL )
goto LABEL_81;
v47 = v46;
if ( v46 >= 0x17 )
{
v49 = v46 | 7;
v50 = 26;
if ( (v47 | 7) != 0x17 )
v50 = v49 + 1;
v48 = (char *)operator new(v50);
v61 = v48;
*(_QWORD *)&__dst = v50 + 1;
*((_QWORD *)&__dst + 1) = v47;
v42 = (cocos2d::CCArray *)v57;
}
else
{
LOBYTE(__dst) = 2 * v46;
v48 = (char *)&__dst + 1;
if ( !v46 )
goto LABEL_75;
}
memmove(v48, v45, v47);
LABEL_75:
v48[v47] = 0;
v51 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey_1((__int64)v58, (__int64)&__dst);
v52 = cocos2d::CCString::intValue(v51);
v1 = a1;
if ( (__dst & 1) != 0 )
operator delete(v61);
GameManager::setIntGameVariable(a1, v45, v52);
++v43;
}
while ( v43 < (unsigned int)sub_100720070(v42) );
}
}
}
else
{
v1->m_resolution = -1;
v1->m_performanceMode = 0;
v1->m_vsyncEnabled = 1;
*(_WORD *)&v1->m_showedRateDiffDialog = 0;
v1->m_showedLowDetailDialog = 0;
*(_DWORD *)&v1->m_showSongMarkers = 1;
GameManager::setGameVariable(v1, "0002", 1);
GameManager::setGameVariable(v1, "0001", 1);
GameManager::setGameVariable(v1, "0026", 1);
GameManager::setGameVariable(v1, "0027", 1);
GameManager::setGameVariable(v1, "0038", 1);
GameManager::setGameVariable(v1, "0043", 1);
GameManager::setGameVariable(v1, "0044", 1);
GameManager::setIntGameVariable(v1, "0050", 2);
GameManager::setIntGameVariable(v1, "0049", 6);
GameManager::setGameVariable(v1, "0046", 1);
GameManager::setGameVariable(v1, "0044", 1);
GameManager::setGameVariable(v1, "0036", 1);
GameManager::setGameVariable(v1, "0118", 1);
GameManager::setGameVariable(v1, "0117", 1);
GameManager::setGameVariable(v1, "0158", 1);
GameManager::setGameVariable(v1, "0121", 1);
GameManager::setGameVariable(v1, "0037", 1);
GameManager::setGameVariable(v1, "0030", 1);
GameManager::setGameVariable(v1, "0013", 1);
GameManager::setGameVariable(v1, "0018", 1);
}
if ( (v1->m_shouldLoadUnlockValueKeeper & (unsigned __int8)v59) == 1 )
GameManager::setUGV(v1, "30", 1);
v1->m_loaded = 1;
}