//
// cocos2d::CCTextureCache::addImage from 0xb34ed8 to 0xb35414 (1340 bytes)
//
// 89 xrefs:
// > ButtonSprite::updateBGImage @ 0x56fdc8
// > CCAnimatedSprite::loadType @ 0x570be4
// > CCAnimatedSprite::initWithType @ 0x570fdc
// > LoadingLayer::loadAssets @ 0x5c4694
// > LoadingLayer::loadAssets @ 0x5c46c0
// > LoadingLayer::loadAssets @ 0x5c46ec
// > LoadingLayer::loadAssets @ 0x5c4718
// > LoadingLayer::loadAssets @ 0x5c473c
// > LoadingLayer::loadAssets @ 0x5c4768
// > LoadingLayer::loadAssets @ 0x5c479c
// > LoadingLayer::loadAssets @ 0x5c47c0
// > LoadingLayer::loadAssets @ 0x5c47e4
// > LoadingLayer::loadAssets @ 0x5c47f8
// > LoadingLayer::loadAssets @ 0x5c480c
// > LoadingLayer::loadAssets @ 0x5c4830
// > LoadingLayer::loadAssets @ 0x5c485c
// > LoadingLayer::loadAssets @ 0x5c4880
// > LoadingLayer::loadAssets @ 0x5c4894
// > LoadingLayer::loadAssets @ 0x5c48a8
// > LoadingLayer::loadAssets @ 0x5c48bc
// > LoadingLayer::loadAssets @ 0x5c48d0
// > LoadingLayer::loadAssets @ 0x5c49cc
// > LoadingLayer::loadAssets @ 0x5c49e0
// > LoadingLayer::loadAssets @ 0x5c49f4
// > LoadingLayer::loadAssets @ 0x5c4a08
// > LoadingLayer::loadAssets @ 0x5c4a1c
// > LoadingLayer::loadAssets @ 0x5c4a30
// > LoadingLayer::loadAssets @ 0x5c4ac4
// > LoadingLayer::loadAssets @ 0x5c4ad8
// > LoadingLayer::init @ 0x5c52c8
// > GameManager::loadFont @ 0x5ebbd4
// > GameManager::loadDeathEffect @ 0x5ebd30
// > GameManager::loadBackground @ 0x5ebe74
// > GameManager::loadMiddleground @ 0x5ec000
// > GameManager::loadMiddleground @ 0x5ec028
// > GameManager::loadGround @ 0x5ec2bc
// > GameManager::loadGround @ 0x5ec310
// > GameManager::loadIcon @ 0x5fd774
// > PlayerObject::setupStreak @ 0x63d350
// > PlayerObject::update @ 0x63f864
// > GameObject::createWithKey @ 0x654498
// > LevelEditorLayer::updateLevelFont @ 0x660c84
// > LevelEditorLayer::updateLevelFont @ 0x660eb0
// > EditorUI::getCreateBtn @ 0x694b50
// > AudioEffectsLayer::init @ 0x78f128
// > GJMoreGamesLayer::getMoreGamesList @ 0x7d9a94
// > GJBaseGameLayer::createTextLayers @ 0x85851c
// > GJBaseGameLayer::createTextLayers @ 0x8586cc
// > GJBaseGameLayer::createTextLayers @ 0x858704
// > GJBaseGameLayer::setupLayers @ 0x89ea74
// > GJBaseGameLayer::setupLayers @ 0x89ea90
// > GJBaseGameLayer::setupLayers @ 0x89eaa8
// > GJBaseGameLayer::setupLayers @ 0x89eac0
// > GJBaseGameLayer::setupLayers @ 0x89ead8
// > GJBaseGameLayer::setupLayers @ 0x89eaf0
// > FMODLevelVisualizer::init @ 0x8d5108
// > GJPromoPopup::init @ 0x8d98bc
// > CurrencyRewardLayer::init @ 0x910798
// > GauntletSelectLayer::init @ 0x91c52c
// > GJShopLayer::init @ 0x92def8
// > SecretLayer2::init @ 0x9422a4
// > SecretLayer3::init @ 0x944cfc
// > SecretLayer4::init @ 0x94a814
// > WorldSelectLayer::init @ 0x96111c
// > LevelAreaLayer::init @ 0xa2f724
// > LevelAreaInnerLayer::init @ 0xa305e8
// > SecretRewardsLayer::init @ 0xa623e4
// > GJPathsLayer::init @ 0xa6ef54
// > SecretLayer5::init @ 0xa95b20
// > SecretLayer5::init @ 0xa95b44
// > SecretLayer6::init @ 0xa96eb0
// > cocos2d::CCAtlasNode::initWithTileFile @ 0xaca4f8
// > cocos2d::CCLabelAtlas::initWithString @ 0xae1be0
// > cocos2d::CCLabelBMFont::setFntFile @ 0xae7700
// > cocos2d::CCLabelBMFont::initWithString @ 0xae8450
// > cocos2d::CCMotionStreak::initWithFade @ 0xaf7d7c
// > cocos2d::CCParticleSystem::initWithDictionary @ 0xb01794
// > cocos2d::CCParticleBatchNode::initWithFile @ 0xb0214c
// > cocos2d::CCAnimation::addSpriteFrameWithFileName @ 0xb13720
// > cocos2d::CCSprite::initWithFile @ 0xb14be4
// > cocos2d::CCSprite::initWithFile @ 0xb14ca0
// > cocos2d::CCSpriteBatchNode::initWithFile @ 0xb18368
// > cocos2d::CCSpriteFrame::getTexture @ 0xb196b0
// > cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile @ 0xb1a780
// > cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile @ 0xb1bc7c
// > cocos2d::CCTextureAtlas::initWithFile @ 0xb331dc
// > cocos2d::CCTextureCache::reloadTexture @ 0xb3555c
// > cocos2d::CCTMXLayer::initWithTilesetInfo @ 0xb38c7c
// > ??> @ 0xc0408
//
// 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
//
cocos2d::CCTexture2D *cocos2d::CCTextureCache::addImage(cocos2d::CCTextureCache *a1, const char *a2, bool a3)
{
_BOOL4 v3; // w21
cocos2d::CCFileUtils *v5; // x0
char *v6; // x0
char *v7; // x1
cocos2d::CCDictionary *m_pTextures; // x21
cocos2d::CCTexture2D *v9; // x21
char *v10; // x0
char *v11; // x0
unsigned int *v13; // x1
int v14; // w2
unsigned int *v15; // x1
int v16; // w2
__int64 v17; // x26
unsigned int v18; // w28
__int64 v19; // x0
_BYTE *v20; // x23
unsigned __int8 *v21; // x0
cocos2d::CCImage *v22; // x23
void *v23; // x0
char *v24; // x0
unsigned int *v25; // x1
int v26; // w2
unsigned int *v27; // x1
int v28; // w2
unsigned int *v29; // x1
int v30; // w2
cocos2d::CCImage::EImageFormat v31; // w26
cocos2d::CCDictionary *v32; // x24
char *v33[2]; // [xsp+0h] [xbp+0h] BYREF
char *v34; // [xsp+78h] [xbp+78h] BYREF
char *v35; // [xsp+80h] [xbp+80h] BYREF
__int64 v36; // [xsp+88h] [xbp+88h] BYREF
const char *v37; // [xsp+90h] [xbp+90h] BYREF
v3 = a3;
sub_D153B8((int)&v34, (char *)a2);
v5 = cocos2d::CCFileUtils::sharedFileUtils();
((void (__fastcall *)(const char **__return_ptr, cocos2d::CCFileUtils *, char *, _BOOL4))v5->createCCArrayWithContentsOfFile)(
&v37,
v5,
v34,
v3);
sub_D163D4(&v34, &v37);
v6 = (char *)(v37 - 24);
if ( v37 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v25 = (unsigned int *)(v37 - 8);
do
v26 = __ldaxr(v25);
while ( __stlxr(v26 - 1, v25) );
}
else
{
v26 = *((_DWORD *)v37 - 2);
*((_DWORD *)v37 - 2) = v26 - 1;
}
if ( v26 <= 0 )
operator delete(v6);
}
v7 = v34;
if ( *((_QWORD *)v34 - 3) )
{
m_pTextures = a1->m_pTextures;
sub_D153B8((int)&v37, v34);
v9 = (cocos2d::CCTexture2D *)cocos2d::CCDictionary::objectForKey((__int64)m_pTextures, &v37);
v10 = (char *)(v37 - 24);
if ( v37 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_4;
if ( &pthread_create )
{
v15 = (unsigned int *)(v37 - 8);
do
v16 = __ldaxr(v15);
while ( __stlxr(v16 - 1, v15) );
}
else
{
v16 = *((_DWORD *)v37 - 2);
*((_DWORD *)v37 - 2) = v16 - 1;
}
if ( v16 > 0 )
{
LABEL_4:
if ( v9 )
goto LABEL_5;
}
else
{
operator delete(v10);
if ( v9 )
goto LABEL_5;
}
v17 = 0;
sub_D18D28(&v35);
v18 = 0;
sub_D18D28(&v36);
v19 = v36;
if ( *(_QWORD *)(v36 - 24) )
{
do
{
if ( (*(_DWORD *)(v19 - 8) & 0x80000000) == 0 )
sub_D176A8(&v36);
v20 = (_BYTE *)(v36 + v17);
v21 = (unsigned __int8 *)(v36 + v17);
if ( (*(_DWORD *)(v36 - 8) & 0x80000000) == 0 )
{
sub_D176A8(&v36);
v21 = (unsigned __int8 *)(v36 + v17);
}
v17 = ++v18;
*v20 = tolower(*v21);
v19 = v36;
}
while ( (unsigned __int64)v18 < *(_QWORD *)(v36 - 24) );
}
if ( sub_D1641C((unsigned int)v33 + 136, ".pvr") == -1 )
{
if ( sub_D1641C((unsigned int)v33 + 136, ".pkm") == -1 )
{
v31 = kFmtPng;
if ( sub_D1641C((unsigned int)v33 + 136, ".png") == -1 )
{
if ( sub_D1641C((unsigned int)v33 + 136, ".jpg") == -1 && sub_D1641C((unsigned int)v33 + 136, ".jpeg") == -1 )
{
if ( sub_D1641C((unsigned int)v33 + 136, ".tif") == -1 && sub_D1641C((unsigned int)v33 + 136, ".tiff") == -1 )
{
if ( sub_D1641C((unsigned int)v33 + 136, ".webp") == -1 )
v31 = kFmtUnKnown;
else
v31 = kFmtWebp;
}
else
{
v31 = kFmtTiff;
}
}
else
{
v31 = kFmtJpg;
}
}
v22 = (cocos2d::CCImage *)operator new(0x50u);
cocos2d::CCImage::CCImage(v22);
if ( cocos2d::CCImage::initWithImageFile(v22, v35, v31) )
{
v9 = (cocos2d::CCTexture2D *)operator new(0x68u);
cocos2d::CCTexture2D::CCTexture2D(v9);
if ( cocos2d::CCTexture2D::initWithImage(v9, v22) )
{
cocos2d::VolatileTexture::addImageTexture((cocos2d::VolatileTexture *)v9, (cocos2d::CCTexture2D *)v35, v31);
v32 = a1->m_pTextures;
sub_D153B8((int)&v37, v34);
cocos2d::CCDictionary::setObject((__int64)v32, v9, &v37);
if ( v37 - 24 != (const char *)&qword_124B6B0 )
sub_B33D08((void *)(v37 - 24));
cocos2d::CCObject::release(v9);
}
}
}
else
{
v22 = nullptr;
v9 = cocos2d::CCTextureCache::addETCImage(a1, v35);
}
}
else
{
v22 = nullptr;
v9 = cocos2d::CCTextureCache::addPVRImage(a1, v35);
}
v23 = (void *)(v36 - 24);
if ( (__int64 *)(v36 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v29 = (unsigned int *)(v36 - 8);
do
v30 = __ldaxr(v29);
while ( __stlxr(v30 - 1, v29) );
}
else
{
v30 = *(_DWORD *)(v36 - 8);
*(_DWORD *)(v36 - 8) = v30 - 1;
}
if ( v30 <= 0 )
operator delete(v23);
}
v24 = v35 - 24;
if ( v35 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v27 = (unsigned int *)(v35 - 8);
do
v28 = __ldaxr(v27);
while ( __stlxr(v28 - 1, v27) );
}
else
{
v28 = *((_DWORD *)v35 - 2);
*((_DWORD *)v35 - 2) = v28 - 1;
}
if ( v28 <= 0 )
operator delete(v24);
}
if ( v22 )
cocos2d::CCObject::release(v22);
LABEL_5:
v7 = v34;
v11 = v34 - 24;
if ( v34 - 24 == (char *)&qword_124B6B0 )
return v9;
goto LABEL_8;
}
v11 = v34 - 24;
v9 = nullptr;
if ( v34 - 24 == (char *)&qword_124B6B0 )
return v9;
LABEL_8:
if ( &pthread_create )
{
v13 = (unsigned int *)(v7 - 8);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *((_DWORD *)v7 - 2);
*((_DWORD *)v7 - 2) = v14 - 1;
}
if ( v14 <= 0 )
operator delete(v11);
return v9;
}