//
// cocos2d::CCTexturePVR::initWithContentsOfFile from 0x1002854a0 to 0x1002857ae (782 bytes)
//
// 2 xrefs:
// > cocos2d::CCTexturePVR::create @ 0x100285810
// > cocos2d::CCTexture2D::initWithPVRFile @ 0x100479310
//
// 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
//
bool __fastcall cocos2d::CCTexturePVR::initWithContentsOfFile(cocos2d::CCTexturePVR *a1, const char *a2)
{
double v2; // xmm0_8
size_t v3; // rax
size_t v4; // r15
char *v5; // r12
size_t v6; // r13
char *v7; // r13
unsigned int i; // eax
__int64 v9; // r12
unsigned __int64 v10; // rdx
char *v11; // rax
char v12; // al
char *v13; // rcx
char *v14; // r12
char *v15; // rbx
void *v16; // rax
char *v17; // rax
__int64 v18; // rdx
cocos2d::CCTexturePVR *v19; // rbx
char *v20; // r15
void *v21; // rax
char *v22; // rax
cocos2d::CCFileUtils *v23; // rax
unsigned int v24; // edx
bool v25; // bl
int v27; // eax
size_t __dst; // [rsp+10h] [rbp-50h] BYREF
unsigned __int64 v29; // [rsp+18h] [rbp-48h]
void *__s; // [rsp+20h] [rbp-40h]
void *__p; // [rsp+28h] [rbp-38h] BYREF
unsigned int v32[11]; // [rsp+34h] [rbp-2Ch] BYREF
__p = nullptr;
v32[0] = 0;
v3 = strlen(a2);
if ( v3 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v2);
v4 = v3;
if ( v3 >= 0x17 )
{
v6 = 26;
if ( (v3 | 7) != 0x17 )
v6 = (v3 | 7) + 1;
v5 = (char *)operator new(v6);
__s = v5;
__dst = v6 + 1;
v29 = v4;
}
else
{
LOBYTE(__dst) = 2 * v3;
v5 = (char *)&__dst + 1;
if ( !v3 )
goto LABEL_9;
}
memcpy(v5, a2, v4);
LABEL_9:
v7 = (char *)&__dst + 1;
v5[v4] = 0;
for ( i = 0; ; i = v9 + 1 )
{
v9 = i;
if ( (__dst & 1) != 0 )
break;
v10 = (unsigned __int8)__dst >> 1;
if ( i >= (unsigned int)v10 )
{
v14 = (char *)&__dst + 1;
if ( v10 < 4 )
goto LABEL_28;
goto LABEL_22;
}
LABEL_15:
v11 = (char *)&__dst + 1;
if ( (__dst & 1) != 0 )
v11 = (char *)__s;
v12 = __tolower(v11[v9]);
v13 = (char *)&__dst + 1;
if ( (__dst & 1) != 0 )
v13 = (char *)__s;
v13[v9] = v12;
}
v10 = v29;
if ( v29 > i )
goto LABEL_15;
v14 = (char *)__s;
if ( v29 < 4 )
goto LABEL_28;
LABEL_22:
v15 = &v14[v10];
v16 = v14;
do
{
v17 = (char *)memchr(v16, 46, v10 - 3);
if ( !v17 )
break;
if ( *(_DWORD *)v17 == 2053333806 )
{
if ( v17 == v15 || v17 - v14 == -1 )
break;
v27 = sub_100206820((__int64)a2, &__p);
v19 = a1;
LABEL_54:
v32[0] = v27;
if ( v27 >= 0 )
goto LABEL_40;
goto LABEL_55;
}
v16 = v17 + 1;
v10 = v15 - (_BYTE *)v16;
}
while ( v15 - (_BYTE *)v16 >= 4 );
LABEL_28:
if ( (__dst & 1) != 0 )
v7 = (char *)__s;
v18 = (unsigned __int8)__dst >> 1;
if ( (__dst & 1) != 0 )
v18 = v29;
v19 = a1;
if ( v18 >= 3 )
{
v20 = &v7[v18];
v21 = v7;
do
{
v22 = (char *)memchr(v21, 46, v18 - 2);
if ( !v22 )
break;
if ( !(*(_WORD *)v22 ^ 0x672E | (unsigned __int8)v22[2] ^ 0x7A) )
{
if ( v22 == v20 || v22 - v7 == -1 )
break;
v27 = sub_100206760(a2, &__p);
goto LABEL_54;
}
v21 = v22 + 1;
v18 = v20 - (_BYTE *)v21;
}
while ( v20 - (_BYTE *)v21 >= 3 );
}
v23 = cocos2d::CCFileUtils::sharedFileUtils();
__p = (void *)((__int64 (__fastcall *)(cocos2d::CCFileUtils *, const char *, const char *, unsigned int *))v23->addSearchResolutionsOrder)(
v23,
a2,
"rb",
v32);
if ( (v32[0] & 0x80000000) != 0 )
{
LABEL_55:
cocos2d::CCObject::release(v19);
v25 = 0;
if ( (__dst & 1) == 0 )
return v25;
goto LABEL_50;
}
LABEL_40:
v19[6].__vftable = nullptr;
*(_OWORD *)&v19[5].m_uIndexInArray = 0;
v19[5].m_uOrderOfArrival = 0;
if ( !cocos2d::CCTexturePVR::unpackPVRv2Data(v19, (unsigned __int8 *)__p, v24)
&& !cocos2d::CCTexturePVR::unpackPVRv3Data(v19, (unsigned __int8 *)__p, v32[0])
|| !cocos2d::CCTexturePVR::createGLTexture(v19) )
{
if ( __p )
{
operator delete[](__p);
__p = nullptr;
}
cocos2d::CCObject::release(v19);
v25 = 0;
LABEL_49:
if ( (__dst & 1) != 0 )
goto LABEL_50;
return v25;
}
v25 = 1;
if ( !__p )
goto LABEL_49;
operator delete[](__p);
__p = nullptr;
if ( (__dst & 1) == 0 )
return v25;
LABEL_50:
operator delete(__s);
return v25;
}