//
// cocos2d::CCTextureCache::addImageAsyncCallBack from 0x801020 to 0x8011ca (426 bytes)
//
// 0 xrefs:
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:01:20 +0000
//
int __fastcall cocos2d::CCTextureCache::addImageAsyncCallBack(int this, float a2)
{
_DWORD *v2; // r4
int v3; // r2
unsigned int v4; // r3
void **v5; // r1
unsigned int v6; // r0
_DWORD *v7; // r8
char *v8; // r5
_DWORD *v9; // r9
int v10; // r7
cocos2d::CCTexture2D *v11; // r10
cocos2d::CCTexture2D *v12; // r6
size_t v13; // r0
char *v14; // r2
int v15; // r3
int v16; // r0
char *v17; // r0
cocos2d::CCDirector *v18; // r0
int v19; // r0
int v20; // r0
cocos2d::CCObject *v21; // [sp+4h] [bp-40h]
char *v22; // [sp+8h] [bp-3Ch]
int v23; // [sp+Ch] [bp-38h]
int v24; // [sp+24h] [bp-20h]
int v25[3]; // [sp+30h] [bp-14h] BYREF
v2 = (_DWORD *)dword_D3118C;
v23 = this;
if ( dword_D3118C )
{
while ( 1 )
{
pthread_mutex_lock((pthread_mutex_t *)&unk_D31190);
v3 = v2[5];
if ( !v3 )
break;
v4 = v2[4];
v5 = (void **)v2[1];
v6 = v4++ >> 10;
v7 = *((_DWORD **)v5[v6] + (v2[4] & 0x3FF));
v2[5] = v3 - 1;
v2[4] = v4;
if ( v4 >= 0x800 )
{
operator delete(*v5);
v2[1] += 4;
v2[4] -= 1024;
}
pthread_mutex_unlock((pthread_mutex_t *)&unk_D31190);
v8 = (char *)*v7;
v21 = (cocos2d::CCObject *)v7[1];
*((_DWORD *)v21 + 17) = *(_DWORD *)(*v7 + 28);
v9 = *((_DWORD **)v8 + 3);
v10 = *((_DWORD *)v8 + 5);
v22 = *((char **)v8 + 4);
if ( (*v8 & 1) != 0 )
v11 = *((cocos2d::CCTexture2D **)v8 + 2);
else
v11 = (cocos2d::CCTexture2D *)(v8 + 1);
v12 = (cocos2d::CCTexture2D *)operator new(0x60u);
cocos2d::CCTexture2D::CCTexture2D(v12);
cocos2d::CCTexture2D::initWithImage(v12, v21);
cocos2d::VolatileTexture::addImageTexture(v12, v11, v7[2]);
memset(v25, 0, sizeof(v25));
v24 = *(_DWORD *)(v23 + 52);
v13 = strlen((const char *)v11);
std::string::__init(v25, v11, v13);
cocos2d::CCDictionary::setObject(v24, v12, (int)v25);
std::string::~string((int)v25);
cocos2d::CCObject::autorelease(v12);
if ( v9 && (v22 || (v10 & 1) != 0) )
{
(*(void (__fastcall **)(cocos2d::CCTexture2D *, _DWORD))(*(_DWORD *)v12 + 36))(v12, *((_DWORD *)v8 + 6));
v16 = v10 >> 1;
if ( (v10 & 1) != 0 )
{
v14 = v22;
v15 = *(_DWORD *)((char *)v9 + v16);
}
v17 = (char *)v9 + v16;
if ( (v10 & 1) != 0 )
(*(void (__fastcall **)(char *, cocos2d::CCTexture2D *))&v14[v15])(v17, v12);
else
((void (__fastcall *)(char *, cocos2d::CCTexture2D *))v22)(v17, v12);
cocos2d::CCObject::release(v9);
}
cocos2d::CCObject::release(v21);
std::string::~string((int)v8);
operator delete(v8);
operator delete(v7);
if ( !--dword_D31194 )
{
v19 = cocos2d::CCDirector::sharedDirector(v18);
v20 = (*(int (__fastcall **)(int))(*(_DWORD *)v19 + 64))(v19);
cocos2d::CCScheduler::unscheduleSelector(v20, (int)cocos2d::CCTextureCache::addImageAsyncCallBack, 0, v23);
}
}
return pthread_mutex_unlock((pthread_mutex_t *)&unk_D31190);
}
return this;
}