//
// cocos2d::CCTextureCache::addImageAsync from 0x100113394 to 0x10011366c (728 bytes)
//
// 6 xrefs:
// > cocos2d::CCTextureCache::prepareAsyncLoading @ 0x100113390
// > GameManager::loadBackgroundAsync @ 0x100318570
// > GameManager::loadMiddlegroundAsync @ 0x1003187b0
// > GameManager::loadMiddlegroundAsync @ 0x100318800
// > GameManager::loadGroundAsync @ 0x100318ae4
// > GameManager::loadGroundAsync @ 0x100318b50
//
// 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
//
// local variable allocation has failed, the output may be wrong!
void __fastcall cocos2d::CCTextureCache::addImageAsync(
cocos2d::CCTextureCache *a1,
const char *a2,
cocos2d::CCObject *a3,
cocos2d::SEL_MenuHandler a4,
int a5,
cocos2d::CCTexture2DPixelFormat a6)
{
__int64 v7; // x22
signed __int64 adj; // x20
std::string::size_type ptr; // x19
cocos2d::CCFileUtils *v12; // x0
cocos2d::CCDictionary *m_pTextures; // x25
char *v14; // x1
__int64 v15; // x25
_QWORD *v16; // x0
_OWORD *v17; // x0
_OWORD *v18; // x0
__int64 v19; // x8
cocos2d::CCDirector *v20; // x0
cocos2d::CCScheduler *v21; // x0
std::string *v22; // x0
std::string *v23; // x24
void **v24; // x1
std::string *v25; // [xsp+8h] [xbp-88h] BYREF
void *__dst[2]; // [xsp+10h] [xbp-80h] BYREF
__int64 v27; // [xsp+20h] [xbp-70h]
void *__p[2]; // [xsp+30h] [xbp-60h] BYREF
__int64 v29; // [xsp+40h] [xbp-50h]
cocos2d::SEL_SCHEDULE v30; // 0:x1.16
v7 = *(_QWORD *)&a5;
adj = a4.adj;
ptr = (std::string::size_type)a4.ptr;
sub_100009900(__p, (char *)a2);
v12 = cocos2d::CCFileUtils::sharedFileUtils();
((void (__fastcall *)(void **__return_ptr))v12->createCCArrayWithContentsOfFile)(__dst);
if ( SHIBYTE(v29) < 0 )
operator delete(__p[0]);
*(_OWORD *)__p = *(_OWORD *)__dst;
v29 = v27;
m_pTextures = a1->m_pTextures;
if ( v27 >= 0 )
v14 = (char *)__p;
else
v14 = (char *)__dst[0];
sub_100009900(__dst, v14);
v15 = cocos2d::CCDictionary::objectForKey_1(m_pTextures, __dst);
if ( SHIBYTE(v27) < 0 )
operator delete(__dst[0]);
if ( SHIBYTE(v29) < 0 )
{
sub_1000097D0(__dst, __p[0], (unsigned __int64)__p[1]);
}
else
{
*(_OWORD *)__dst = *(_OWORD *)__p;
v27 = v29;
}
if ( v15 )
{
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v15 + 72LL))(v15, v7);
if ( a3 && adj & 1 | ptr )
{
v16 = (cocos2d::CCObject_vtbl **)((char *)&a3->__vftable + (adj >> 1));
if ( (adj & 1) != 0 )
ptr = *(_QWORD *)(*v16 + (unsigned int)ptr);
((void (__fastcall *)(_QWORD *, __int64))ptr)(v16, v15);
}
}
else
{
if ( !qword_10086B180 )
{
v17 = operator new(0x30u);
v17[1] = 0u;
v17[2] = 0u;
*v17 = 0u;
qword_10086B180 = (__int64)v17;
v18 = operator new(0x30u);
v18[1] = 0u;
v18[2] = 0u;
*v18 = 0u;
qword_10086B188 = (__int64)v18;
pthread_mutex_init(&stru_10086B190, nullptr);
pthread_mutex_init(&stru_10086B1D0, nullptr);
pthread_mutex_init(&stru_10086B210, nullptr);
pthread_cond_init(&stru_10086B150, nullptr);
pthread_create(&qword_10086B250, nullptr, (void *(__cdecl *)(void *))sub_1001136B0, nullptr);
byte_10086B148 = 0;
}
v19 = qword_10086B258;
if ( !qword_10086B258 )
{
v20 = cocos2d::CCDirector::sharedDirector();
v21 = (cocos2d::CCScheduler *)((__int64 (__fastcall *)(cocos2d::CCDirector *))v20->getScheduler)(v20);
v30.ptr = (void (__cdecl *)(float))cocos2d::CCTextureCache::addImageAsyncCallBack;
v30.adj = 0;
cocos2d::CCScheduler::scheduleSelector_1(v21, v30, a1, 0.0, 0);
v19 = qword_10086B258;
}
qword_10086B258 = v19 + 1;
if ( a3 )
cocos2d::CCObject::retain(a3);
v22 = (std::string *)operator new(0x38u);
v23 = v22;
v22[2].__r_.__value_.__r.__words[0] = 0;
*(_OWORD *)&v22->__r_.__value_.__r.__words[2] = 0u;
*(_OWORD *)&v22[1].__r_.__value_.__r.__words[1] = 0u;
*(_OWORD *)&v22->__r_.__value_.__l.__data_ = 0u;
v25 = v22;
if ( v27 >= 0 )
v24 = __dst;
else
v24 = (void **)__dst[0];
std::string::assign(v22, (const std::string::value_type *)v24);
v23[1].__r_.__value_.__r.__words[0] = (std::string::size_type)a3;
v23[1].__r_.__value_.__l.__size_ = ptr;
v23[1].__r_.__value_.__r.__words[2] = adj;
LODWORD(v23[2].__r_.__value_.__l.__data_) = v7;
HIDWORD(v23[2].__r_.__value_.__r.__words[0]) = a6;
pthread_mutex_lock(&stru_10086B190);
sub_1001151C0(qword_10086B180, &v25);
pthread_mutex_unlock(&stru_10086B190);
pthread_cond_signal(&stru_10086B150);
}
if ( SHIBYTE(v27) < 0 )
operator delete(__dst[0]);
if ( SHIBYTE(v29) < 0 )
operator delete(__p[0]);
}