//
// cocos2d::CCTextureCache::addPVRImage from 0x1800a8810 to 0x1800a8a4b (571 bytes)
//
// 3 xrefs:
// > cocos2d::CCTextureCache::addImage @ 0x1800a7873
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b7e3c
//
// 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
//
struct cocos2d::CCTexture2D *__fastcall cocos2d::CCTextureCache::addPVRImage(cocos2d::CCTextureCache *this, char *a2)
{
void **v3; // rdx
cocos2d::CCTexture2D *v4; // rbx
void *v5; // rcx
struct cocos2d::CCFileUtils *v6; // rax
void **v7; // r8
cocos2d::CCTexture2D *v8; // rax
char *v9; // rdx
void **v10; // rdx
void *v11; // rcx
char *v12; // rcx
void *v13; // rcx
void *v15[3]; // [rsp+28h] [rbp-11h] BYREF
unsigned __int64 v16; // [rsp+40h] [rbp+7h]
char *v17[2]; // [rsp+48h] [rbp+Fh] BYREF
__m128i si128; // [rsp+58h] [rbp+1Fh]
void *Block[3]; // [rsp+68h] [rbp+2Fh] BYREF
unsigned __int64 v20; // [rsp+80h] [rbp+47h]
sub_180005910(v15, a2);
v3 = v15;
if ( v16 > 0xF )
v3 = (void **)v15[0];
sub_180005910(Block, v3);
v4 = (cocos2d::CCTexture2D *)cocos2d::CCDictionary::objectForKey((__int64)this->m_pTextures, (unsigned __int8 *)Block);
if ( v20 > 0xF )
{
v5 = Block[0];
if ( v20 + 1 >= 0x1000 )
{
v5 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v5 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v5);
}
if ( !v4 )
{
v6 = cocos2d::CCFileUtils::sharedFileUtils();
v7 = v15;
if ( v16 > 0xF )
v7 = (void **)v15[0];
((void (__fastcall *)(struct cocos2d::CCFileUtils *, char **, void **, _QWORD))v6->createCCArrayWithContentsOfFile)(
v6,
v17,
v7,
0);
v8 = (cocos2d::CCTexture2D *)operator new(0x68u);
if ( v8 )
v4 = cocos2d::CCTexture2D::CCTexture2D(v8);
else
v4 = nullptr;
if ( v4 )
{
v9 = (char *)v17;
if ( si128.m128i_i64[1] > 0xFuLL )
v9 = v17[0];
if ( (unsigned __int8)cocos2d::CCTexture2D::initWithPVRFile(v4, v9) )
{
v10 = v15;
if ( v16 > 0xF )
v10 = (void **)v15[0];
sub_180005910(Block, v10);
cocos2d::CCDictionary::setObject((__int64)this->m_pTextures, v4, (unsigned __int8 *)Block);
if ( v20 > 0xF )
{
v11 = Block[0];
if ( v20 + 1 >= 0x1000 )
{
v11 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v11 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v11);
}
cocos2d::CCObject::autorelease(v4);
}
else
{
((void (__fastcall *)(cocos2d::CCTexture2D *, __int64))v4->~CCTexture2D)(v4, 1);
v4 = nullptr;
}
}
if ( si128.m128i_i64[1] > 0xFuLL )
{
v12 = v17[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v12 = *((char **)v17[0] - 1);
if ( (unsigned __int64)(v17[0] - v12 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v12);
}
si128 = _mm_load_si128((const __m128i *)&xmmword_1800E7160);
LOBYTE(v17[0]) = 0;
}
if ( v16 > 0xF )
{
v13 = v15[0];
if ( v16 + 1 >= 0x1000 )
{
v13 = *((void **)v15[0] - 1);
if ( (unsigned __int64)((char *)v15[0] - (char *)v13 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v13);
}
return v4;
}