//
// cocos2d::CCSpriteFrameCache::removeSpriteFramesFromTexture from 0xb1aaa8 to 0xb1ace0 (568 bytes)
//
// 1 xrefs:
// > ??> @ 0x9e0e8
//
// 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
//
void cocos2d::CCSpriteFrameCache::removeSpriteFramesFromTexture(
cocos2d::CCSpriteFrameCache *a1,
cocos2d::CCTexture2D *a2)
{
cocos2d::CCArray *v4; // x28
cocos2d::CCDictionary *v5; // x0
cocos2d::CCDictElement *m_pElements; // x22
cocos2d::CCDictElement *next; // x20
cocos2d::CCSpriteFrameCache_vtbl *v8; // x27
cocos2d::CCSpriteFrame *v9; // x2
char *v10; // x0
char *v11; // x0
unsigned int *v12; // x1
int v13; // w2
unsigned int *v14; // x1
int v15; // w3
cocos2d::CCObject *v16; // x0
cocos2d::CCObject *v17; // x2
char *v18; // x0
unsigned int *v19; // x1
int v20; // w2
_QWORD v21[2]; // [xsp+0h] [xbp+0h] BYREF
cocos2d::CCSpriteFrame *v22; // [xsp+60h] [xbp+60h]
char *v23; // [xsp+68h] [xbp+68h]
char v24; // [xsp+80h] [xbp+80h] BYREF
char *v25; // [xsp+88h] [xbp+88h]
const char *v26; // [xsp+90h] [xbp+90h] BYREF
v4 = cocos2d::CCArray::create(_stack_chk_guard);
v5 = (cocos2d::CCDictionary *)a1[1].__vftable;
if ( v5 )
{
m_pElements = v5->m_pElements;
if ( m_pElements )
{
next = (cocos2d::CCDictElement *)m_pElements->hh.next;
v23 = &v24;
while ( 1 )
{
sub_D153B8((unsigned int)v21 + 136, (char *)m_pElements);
v8 = a1[1].__vftable;
sub_D153B8((unsigned int)v21 + 144, v25);
v9 = (cocos2d::CCSpriteFrame *)cocos2d::CCDictionary::objectForKey((__int64)v8, &v26);
v10 = (char *)(v26 - 24);
if ( v26 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v14 = (unsigned int *)(v26 - 8);
do
v15 = __ldaxr(v14);
while ( __stlxr(v15 - 1, v14) );
}
else
{
v15 = *((_DWORD *)v26 - 2);
*((_DWORD *)v26 - 2) = v15 - 1;
}
if ( v15 <= 0 )
{
v22 = v9;
operator delete(v10);
v9 = v22;
}
}
if ( v9 )
{
if ( a2 == cocos2d::CCSpriteFrame::getTexture(v9) )
{
sub_D153B8((unsigned int)v21 + 144, (char *)m_pElements);
v16 = cocos2d::CCString::create();
cocos2d::CCArray::addObject(v4, (cocos2d::_ccArray *)v16, v17);
v18 = (char *)(v26 - 24);
if ( v26 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v19 = (unsigned int *)(v26 - 8);
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *((_DWORD *)v26 - 2);
*((_DWORD *)v26 - 2) = v20 - 1;
}
if ( v20 <= 0 )
operator delete(v18);
}
}
}
v11 = v25 - 24;
if ( v25 - 24 == (char *)&qword_124B6B0 )
goto LABEL_8;
if ( &pthread_create )
{
v12 = (unsigned int *)(v25 - 8);
do
v13 = __ldaxr(v12);
while ( __stlxr(v13 - 1, v12) );
}
else
{
v13 = *((_DWORD *)v25 - 2);
*((_DWORD *)v25 - 2) = v13 - 1;
}
if ( v13 > 0 )
{
LABEL_8:
if ( !next )
goto LABEL_15;
}
else
{
operator delete(v11);
if ( !next )
{
LABEL_15:
v5 = (cocos2d::CCDictionary *)a1[1].__vftable;
break;
}
}
m_pElements = next;
next = (cocos2d::CCDictElement *)next->hh.next;
}
}
}
cocos2d::CCDictionary::removeObjectsForKeys(v5, v4);
}