//
// cocos2d::CCTextureCache::addImage from 0x1005edad0 to 0x1005ee0c3 (1523 bytes)
//
// 95 xrefs:
// > EditorUI::getCreateBtn @ 0x100033765
// > ButtonSprite::updateBGImage @ 0x100093349
// > LevelEditorLayer::updateLevelFont @ 0x1000f11f5
// > LevelEditorLayer::updateLevelFont @ 0x1000f14dc
// > GJBaseGameLayer::setupLayers @ 0x1001116af
// > GJBaseGameLayer::setupLayers @ 0x1001116c8
// > GJBaseGameLayer::setupLayers @ 0x1001116e2
// > GJBaseGameLayer::setupLayers @ 0x1001116fc
// > GJBaseGameLayer::setupLayers @ 0x100111715
// > GJBaseGameLayer::setupLayers @ 0x10011172f
// > GJBaseGameLayer::createTextLayers @ 0x10011f9d9
// > GJBaseGameLayer::createTextLayers @ 0x10011fba4
// > GJBaseGameLayer::createTextLayers @ 0x10011fbe2
// > cocos2d::CCSpriteBatchNode::create @ 0x100176587
// > cocos2d::CCSpriteBatchNode::initWithFile @ 0x1001765ef
// > cocos2d::CCTMXLayer::initWithTilesetInfo @ 0x100259b09
// > LevelAreaLayer::init @ 0x10027797e
// > LevelAreaInnerLayer::init @ 0x100279d5d
// > cocos2d::CCSprite::initWithFile_1 @ 0x1002889a5
// > cocos2d::CCSprite::initWithFile @ 0x100288a30
// > cocos2d::CCAnimation::addSpriteFrameWithFileName @ 0x100296ea2
// > FMODLevelVisualizer::init @ 0x1002b07db
// > GJPromoPopup::init @ 0x1002b64c1
// > GJPathsLayer::init @ 0x1002fe3b5
// > cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile_1 @ 0x10031cec0
// > cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile_2 @ 0x10031d13b
// > GJShopLayer::init @ 0x100323322
// > cocos2d::CCAtlasNode::create @ 0x10032aaa0
// > cocos2d::CCAtlasNode::initWithTileFile @ 0x10032ab2a
// > CCAnimatedSprite::initWithType @ 0x100350025
// > CCAnimatedSprite::loadType @ 0x10035039f
// > cocos2d::CCSpriteFrame::getTexture @ 0x10035866f
// > GameManager::loadIcon @ 0x1003820bb
// > GameManager::loadFont @ 0x1003830af
// > GameManager::loadDeathEffect @ 0x100383210
// > GameManager::loadBackground @ 0x10038338b
// > GameManager::loadMiddleground @ 0x10038358a
// > GameManager::loadMiddleground @ 0x1003835b8
// > GameManager::loadGround @ 0x1003838a7
// > GameManager::loadGround @ 0x1003838e2
// > LoadingLayer::init @ 0x1003a271f
// > LoadingLayer::loadAssets @ 0x1003a2f0b
// > LoadingLayer::loadAssets @ 0x1003a2f2f
// > LoadingLayer::loadAssets @ 0x1003a305a
// > LoadingLayer::loadAssets @ 0x1003a3084
// > LoadingLayer::loadAssets @ 0x1003a30ae
// > LoadingLayer::loadAssets @ 0x1003a30c4
// > LoadingLayer::loadAssets @ 0x1003a30da
// > LoadingLayer::loadAssets @ 0x1003a3104
// > LoadingLayer::loadAssets @ 0x1003a325f
// > LoadingLayer::loadAssets @ 0x1003a3289
// > LoadingLayer::loadAssets @ 0x1003a329f
// > LoadingLayer::loadAssets @ 0x1003a32b5
// > LoadingLayer::loadAssets @ 0x1003a32cb
// > LoadingLayer::loadAssets @ 0x1003a335e
// > LoadingLayer::loadAssets @ 0x1003a3385
// > LoadingLayer::loadAssets @ 0x1003a33c1
// > LoadingLayer::loadAssets @ 0x1003a33eb
// > LoadingLayer::loadAssets @ 0x1003a3412
// > LoadingLayer::loadAssets @ 0x1003a3428
// > LoadingLayer::loadAssets @ 0x1003a343e
// > LoadingLayer::loadAssets @ 0x1003a3454
// > LoadingLayer::loadAssets @ 0x1003a346a
// > LoadingLayer::loadAssets @ 0x1003a3480
// > LoadingLayer::loadAssets @ 0x1003a3512
// > LoadingLayer::loadAssets @ 0x1003a3528
// > SecretLayer4::init @ 0x1003b0cb8
// > WorldSelectLayer::init @ 0x1003c1dec
// > cocos2d::CCParticleBatchNode::create @ 0x1003c8b25
// > cocos2d::CCParticleBatchNode::initWithFile @ 0x1003c8b8f
// > PlayerObject::setupStreak @ 0x1003fca5d
// > PlayerObject::update @ 0x1003fdf18
// > SecretLayer5::init @ 0x10047a089
// > SecretLayer5::init @ 0x10047a0b3
// > SecretLayer6::init @ 0x10047eba5
// > SecretLayer2::init @ 0x10049d1d8
// > SecretLayer3::init @ 0x1004a3647
// > cocos2d::CCTextureAtlas::create @ 0x1004ace96
// > cocos2d::CCTextureAtlas::initWithFile @ 0x1004acf0f
// > AudioEffectsLayer::init @ 0x1004af7f7
// > PlatformToolbox::spriteFromSavedFile @ 0x1004c4572
// > GauntletSelectLayer::init @ 0x1005713b5
// > cocos2d::CCMotionStreak::create_1 @ 0x100576401
// > cocos2d::CCMotionStreak::initWithFade_1 @ 0x1005764a2
// > GameObject::createWithKey @ 0x10059d616
// > cocos2d::CCLabelBMFont::initWithString @ 0x1005d8797
// > cocos2d::CCLabelBMFont::setFntFile @ 0x1005db4f5
// > cocos2d::CCTextureCache::reloadTexture @ 0x1005eec4e
// > SecretRewardsLayer::init @ 0x1006300e2
// > GJMoreGamesLayer::getMoreGamesList @ 0x1007953d6
// > cocos2d::CCLabelAtlas::create @ 0x1007991fd
// > cocos2d::CCLabelAtlas::initWithString_1 @ 0x1007992ae
// > cocos2d::CCLabelAtlas::initWithString_2 @ 0x1007997df
// > CurrencyRewardLayer::init @ 0x1007a5ce3
// > cocos2d::CCParticleSystem::initWithDictionary @ 0x1007c8495
//
// 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 *__fastcall cocos2d::CCTextureCache::addImage(
cocos2d::CCTextureCache *a1,
const char *a2,
bool a3)
{
double v3; // xmm0_8
size_t v5; // rax
size_t v6; // rbx
char *v7; // r13
size_t v8; // r14
cocos2d::CCFileUtils *v9; // rax
char *v10; // rdx
double v11; // xmm0_8
cocos2d::CCDictionary *m_pTextures; // r15
const char *v13; // r12
size_t v14; // rax
size_t v15; // r13
char *v16; // rbx
cocos2d::CCTexture2D *v17; // r15
size_t v18; // r14
unsigned int v19; // eax
char *v20; // rbx
__int64 v21; // r15
unsigned __int8 v22; // r14
unsigned __int64 v23; // rdx
char *v24; // rax
char v25; // al
char *v26; // rcx
char *v27; // r15
char *v28; // r12
void *v29; // rax
char *v30; // rax
__int64 v31; // r15
char *v32; // r14
__int64 v33; // rdx
void *v34; // rax
char *v35; // rax
void *v36; // rax
char *v37; // rax
const char *v38; // rsi
const char *v39; // rsi
cocos2d::CCImage::EImageFormat v40; // r15d
cocos2d::CCImage *v41; // r14
const char *v42; // rsi
__int64 v43; // rbx
cocos2d::CCTexture2D *v45; // rax
void *v46[3]; // [rsp+0h] [rbp-B0h] BYREF
const char *v47; // [rsp+18h] [rbp-98h]
cocos2d::CCDictionary **p_m_pTextures; // [rsp+20h] [rbp-90h]
cocos2d::CCTextureCache *v49; // [rsp+28h] [rbp-88h]
__int128 __s; // [rsp+30h] [rbp-80h] BYREF
void *v51; // [rsp+40h] [rbp-70h]
__int128 v52; // [rsp+50h] [rbp-60h] BYREF
void *v53; // [rsp+60h] [rbp-50h]
__int128 __dst; // [rsp+70h] [rbp-40h] BYREF
void *__p; // [rsp+80h] [rbp-30h]
v49 = a1;
v5 = strlen(a2);
if ( v5 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v3);
v6 = v5;
if ( v5 >= 0x17 )
{
v8 = 26;
if ( (v5 | 7) != 0x17 )
v8 = (v5 | 7) + 1;
v7 = (char *)operator new(v8);
__p = v7;
*(_QWORD *)&__dst = v8 + 1;
*((_QWORD *)&__dst + 1) = v6;
goto LABEL_8;
}
LOBYTE(__dst) = 2 * v5;
v7 = (char *)&__dst + 1;
if ( v5 )
LABEL_8:
memcpy(v7, a2, v6);
v7[v6] = 0;
v9 = cocos2d::CCFileUtils::sharedFileUtils();
v10 = (char *)&__dst + 1;
if ( (__dst & 1) != 0 )
v10 = (char *)__p;
((void (__fastcall *)(__int128 *, cocos2d::CCFileUtils *, char *, bool))v9->createCCArrayWithContentsOfFile)(
&v52,
v9,
v10,
a3);
if ( (__dst & 1) != 0 )
operator delete(__p);
__p = v53;
v11 = *(double *)&v52;
__dst = v52;
if ( (v52 & 1) == 0 )
{
if ( (_BYTE)v52 )
{
p_m_pTextures = &v49->m_pTextures;
m_pTextures = v49->m_pTextures;
v13 = (char *)&__dst + 1;
goto LABEL_18;
}
LABEL_22:
v17 = nullptr;
goto LABEL_98;
}
if ( !*((_QWORD *)&__dst + 1) )
goto LABEL_22;
p_m_pTextures = &v49->m_pTextures;
m_pTextures = v49->m_pTextures;
v13 = (const char *)__p;
LABEL_18:
v14 = strlen(v13);
if ( v14 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(*(double *)&v52);
v15 = v14;
v47 = (char *)&__dst + 1;
if ( v14 >= 0x17 )
{
v18 = 26;
if ( (v14 | 7) != 0x17 )
v18 = (v14 | 7) + 1;
v16 = (char *)operator new(v18);
v53 = v16;
*(_QWORD *)&v52 = v18 | 1;
*((_QWORD *)&v52 + 1) = v15;
goto LABEL_26;
}
LOBYTE(v52) = 2 * v14;
v16 = (char *)&v52 + 1;
if ( v14 )
LABEL_26:
memmove(v16, v13, v15);
v16[v15] = 0;
v17 = (cocos2d::CCTexture2D *)cocos2d::CCDictionary::objectForKey_1((__int64)m_pTextures, (char *)&v52);
if ( (v52 & 1) != 0 )
operator delete(v53);
if ( v17 )
goto LABEL_98;
if ( (__dst & 1) != 0 )
{
sub_100006B70(&v52, __p, *((unsigned __int64 *)&__dst + 1), v11);
if ( (__dst & 1) != 0 )
{
sub_100006B70(&__s, __p, *((unsigned __int64 *)&__dst + 1), v11);
goto LABEL_35;
}
}
else
{
v53 = __p;
v52 = __dst;
}
v51 = __p;
v11 = *(double *)&__dst;
__s = __dst;
LABEL_35:
v19 = 0;
v20 = (char *)&__s + 1;
while ( 1 )
{
v21 = v19;
v22 = __s;
if ( (__s & 1) != 0 )
break;
v23 = (unsigned __int8)__s >> 1;
if ( v19 >= (unsigned int)v23 )
{
v27 = (char *)&__s + 1;
if ( v23 < 4 )
goto LABEL_54;
goto LABEL_48;
}
LABEL_41:
v24 = (char *)&__s + 1;
if ( (__s & 1) != 0 )
v24 = (char *)v51;
v25 = __tolower(v24[v21]);
v26 = (char *)&__s + 1;
if ( (__s & 1) != 0 )
v26 = (char *)v51;
v26[v21] = v25;
v19 = v21 + 1;
}
v23 = *((_QWORD *)&__s + 1);
if ( *((_QWORD *)&__s + 1) > (unsigned __int64)v19 )
goto LABEL_41;
v27 = (char *)v51;
if ( *((_QWORD *)&__s + 1) < 4u )
goto LABEL_54;
LABEL_48:
v28 = &v27[v23];
v29 = v27;
do
{
v30 = (char *)memchr(v29, 46, v23 - 3);
if ( !v30 )
break;
if ( *(_DWORD *)v30 == 1920364590 )
{
if ( v30 == v28 || v30 - v27 == -1 )
break;
if ( (v52 & 1) != 0 )
v38 = (const char *)v53;
else
v38 = (char *)&v52 + 1;
v45 = cocos2d::CCTextureCache::addPVRImage(v49, v38);
LABEL_105:
v17 = v45;
v41 = nullptr;
if ( (__s & 1) == 0 )
goto LABEL_91;
goto LABEL_95;
}
v29 = v30 + 1;
v23 = v28 - (_BYTE *)v29;
}
while ( v28 - (_BYTE *)v29 >= 4 );
LABEL_54:
if ( (v22 & 1) != 0 )
v20 = (char *)v51;
v31 = v22 >> 1;
if ( (v22 & 1) != 0 )
v31 = *((_QWORD *)&__s + 1);
if ( v31 >= 4 )
{
v32 = &v20[v31];
v33 = v31;
v34 = v20;
do
{
v35 = (char *)memchr(v34, 46, v33 - 3);
if ( !v35 )
break;
if ( *(_DWORD *)v35 == 1835757614 )
{
if ( v35 != v32 && v35 - v20 != -1 )
{
if ( (v52 & 1) != 0 )
v39 = (const char *)v53;
else
v39 = (char *)&v52 + 1;
v45 = cocos2d::CCTextureCache::addETCImage(v49, v39);
goto LABEL_105;
}
break;
}
v34 = v35 + 1;
v33 = v32 - (_BYTE *)v34;
}
while ( v32 - (_BYTE *)v34 >= 4 );
v36 = v20;
do
{
v37 = (char *)memchr(v36, 46, v31 - 3);
if ( !v37 )
break;
if ( *(_DWORD *)v37 == 1735290926 )
{
v40 = kFmtPng;
if ( v37 != v32 && v37 - v20 != -1 )
goto LABEL_80;
break;
}
v36 = v37 + 1;
v31 = v32 - (_BYTE *)v36;
}
while ( v32 - (_BYTE *)v36 >= 4 );
}
v40 = kFmtJpg;
if ( sub_1005EE1A0(&__s, ".jpg", 0) == -1 )
{
v40 = kFmtJpg;
if ( sub_1005EE1A0(&__s, ".jpeg", 0) == -1 )
{
v40 = kFmtTiff;
if ( sub_1005EE1A0(&__s, ".tif", 0) == -1 && sub_1005EE1A0(&__s, ".tiff", 0) == -1 )
v40 = 2 * (sub_1005EE1A0(&__s, ".webp", 0) == -1) + 3;
}
}
LABEL_80:
v41 = (cocos2d::CCImage *)operator new(0x50u);
cocos2d::CCImage::CCImage((__int64)v41);
if ( (v52 & 1) != 0 )
v42 = (const char *)v53;
else
v42 = (char *)&v52 + 1;
if ( cocos2d::CCImage::initWithImageFile(v41, v42, v40) )
{
v17 = (cocos2d::CCTexture2D *)operator new(0x68u);
sub_100477FC0((__int64)v17);
if ( cocos2d::CCTexture2D::initWithImage(v17, v41) )
{
if ( (__dst & 1) != 0 )
v47 = (const char *)__p;
v43 = (__int64)*p_m_pTextures;
sub_100030790(v46, v47, v11);
cocos2d::CCDictionary::setObject_1(v43, v17, (char *)v46);
if ( ((__int64)v46[0] & 1) != 0 )
operator delete(v46[2]);
cocos2d::CCObject::release(v17);
}
if ( (__s & 1) == 0 )
{
LABEL_91:
if ( (v52 & 1) == 0 )
goto LABEL_92;
LABEL_96:
operator delete(v53);
if ( v41 )
goto LABEL_97;
goto LABEL_98;
}
}
else
{
v17 = nullptr;
if ( (__s & 1) == 0 )
goto LABEL_91;
}
LABEL_95:
operator delete(v51);
if ( (v52 & 1) != 0 )
goto LABEL_96;
LABEL_92:
if ( v41 )
LABEL_97:
cocos2d::CCObject::release(v41);
LABEL_98:
if ( (__dst & 1) != 0 )
operator delete(__p);
return v17;
}