//
// GameStatsManager::isItemUnlocked from 0x7b9b00 to 0x7b9c94 (404 bytes)
//
// 20 xrefs:
// > GameManager::isIconUnlocked @ 0x5f28e4
// > GameManager::isColorUnlocked @ 0x5f2d9c
// > GameManager::dataLoaded @ 0x5faf24
// > LevelPage::onSecretDoor @ 0x79bf48
// > LevelSelectLayer::init @ 0x79dc54
// > GameStatsManager::isPathUnlocked @ 0x7b9cb8
// > GameStatsManager::isItemEnabled @ 0x7bcdb0
// > GameStatsManager::recountSpecialStats @ 0x7bdc20
// > SongInfoLayer::onMenuMusic @ 0x7de640
// > SongInfoLayer::onPracticeMusic @ 0x7de6d8
// > SongInfoLayer::init @ 0x7df668
// > GameOptionsLayer::onPracticeMusicSync @ 0x8d5d28
// > GameOptionsLayer::setupOptions @ 0x8dbfc0
// > GauntletSelectLayer::onPlay @ 0x917d34
// > SecretLayer3::onClick @ 0x93e67c
// > SecretLayer3::onClick @ 0x93eb30
// > SecretLayer3::onClick @ 0x93ece4
// > GJPathSprite::updateState @ 0xa6ee94
// > GJPathPage::init @ 0xa6f5a4
// > ??> @ 0x5e608
//
// 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
//
bool GameStatsManager::isItemUnlocked(GameStatsManager *a1, UnlockType a2, int a3)
{
GameStatsManager *v5; // x0
GJStoreItem *StoreItem; // x20
GameStatsManager *v7; // x0
cocos2d::CCString *SpecialChestKeyForItem; // x20
GameStatsManager *v10; // x0
int SecretChestForItem; // w0
GameStatsManager *v12; // x0
GameStatsManager *v13; // x0
GameStatsManager *v14; // x21
char *CString; // x0
char *v16; // x0
unsigned int *v17; // x2
int v18; // w1
int v19; // [xsp+38h] [xbp+38h]
char *v20; // [xsp+50h] [xbp+50h] BYREF
v5 = GameStatsManager::sharedState();
StoreItem = GameStatsManager::getStoreItem(v5, a3);
if ( StoreItem
&& (v7 = GameStatsManager::sharedState(),
GameStatsManager::isStoreItemUnlocked(v7, StoreItem->m_index.random - StoreItem->m_index.seed))
|| (v10 = GameStatsManager::sharedState(),
SecretChestForItem = GameStatsManager::getSecretChestForItem(v10, a3, a2),
SecretChestForItem > 0)
&& (v19 = SecretChestForItem,
v12 = GameStatsManager::sharedState(),
GameStatsManager::isSecretChestUnlocked(v12, v19)) )
{
LOBYTE(SpecialChestKeyForItem) = 1;
}
else
{
v13 = GameStatsManager::sharedState();
SpecialChestKeyForItem = GameStatsManager::getSpecialChestKeyForItem(v13, a3, a2);
if ( SpecialChestKeyForItem )
{
v14 = GameStatsManager::sharedState();
CString = (char *)cocos2d::CCString::getCString(SpecialChestKeyForItem);
sub_D153B8((int)&v20, CString);
LOBYTE(SpecialChestKeyForItem) = GameStatsManager::isSpecialChestUnlocked((__int64)v14, &v20);
v16 = v20 - 24;
if ( v20 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v17 = (unsigned int *)(v20 - 8);
do
v18 = __ldaxr(v17);
while ( __stlxr(v18 - 1, v17) );
}
else
{
v18 = *((_DWORD *)v20 - 2);
*((_DWORD *)v20 - 2) = v18 - 1;
}
if ( v18 <= 0 )
operator delete(v16);
}
}
}
return (char)SpecialChestKeyForItem;
}