//
// cocos2d::CCTextureCache::addETCImage from 0x1800aae10 to 0x1800ab0a0 (656 bytes)
//
// 3 xrefs:
// > cocos2d::CCTextureCache::addImage @ 0x1800ab50c
// > ??> @ 0x18014cf68
// > ??> @ 0x1801c20d0
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// 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 11:22:17 +0000
//
// Hidden C++ exception states: #wind=5
struct cocos2d::CCTexture2D *__fastcall cocos2d::CCTextureCache::addETCImage(cocos2d::CCTextureCache *this, char *a2)
{
char *v3; // rdx
cocos2d::CCObject *v4; // rbx
void *v5; // rcx
struct cocos2d::CCFileUtils *v6; // rax
char **v7; // r8
cocos2d::CCTexture2D *v8; // rax
const char *v9; // rdx
char *v10; // rdx
void *v11; // rcx
char *v12; // rcx
char *v13; // rcx
char *Str[3]; // [rsp+38h] [rbp-11h] BYREF
unsigned __int64 v16; // [rsp+50h] [rbp+7h]
char *v17[2]; // [rsp+58h] [rbp+Fh] BYREF
__m128i si128; // [rsp+68h] [rbp+1Fh]
void *Block[3]; // [rsp+78h] [rbp+2Fh] BYREF
unsigned __int64 v20; // [rsp+90h] [rbp+47h]
sub_180005A10(Str, a2);
v3 = (char *)Str;
if ( v16 > 0xF )
v3 = Str[0];
sub_180005A10(Block, v3);
v4 = (cocos2d::CCObject *)cocos2d::CCDictionary::objectForKey(*((_QWORD *)this + 7), (__int64)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 )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free_0(v5);
}
if ( !v4 )
{
v6 = cocos2d::CCFileUtils::sharedFileUtils();
v7 = Str;
if ( v16 > 0xF )
v7 = (char **)Str[0];
(*(void (__fastcall **)(struct cocos2d::CCFileUtils *, char **, char **, _QWORD))(*(_QWORD *)v6 + 40LL))(
v6,
v17,
v7,
0);
v8 = (cocos2d::CCTexture2D *)sub_1800E4AC0(0x68u);
if ( v8 )
v4 = cocos2d::CCTexture2D::CCTexture2D(v8);
else
v4 = nullptr;
if ( v4 )
{
v9 = (const char *)v17;
if ( si128.m128i_i64[1] > 0xFuLL )
v9 = v17[0];
if ( cocos2d::CCTexture2D::initWithETCFile(v4, v9) )
{
v10 = (char *)Str;
if ( v16 > 0xF )
v10 = Str[0];
sub_180005A10(Block, v10);
cocos2d::CCDictionary::setObject(*((_QWORD *)this + 7), v4, (__int64)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 )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free_0(v11);
}
cocos2d::CCObject::autorelease(v4);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v4 + 8LL))(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 )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free_0(v12);
}
si128 = _mm_load_si128((const __m128i *)&xmmword_1800EC500);
LOBYTE(v17[0]) = 0;
}
if ( v16 > 0xF )
{
v13 = Str[0];
if ( v16 + 1 >= 0x1000 )
{
v13 = *((char **)Str[0] - 1);
if ( (unsigned __int64)(Str[0] - v13 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free_0(v13);
}
return v4;
}