//
// cocos2d::CCTexturePVR::initWithContentsOfFile from 0x100272050 to 0x10027235e (782 bytes)
//
// 2 xrefs:
// > cocos2d::CCTexturePVR::create @ 0x1002723c0
// > cocos2d::CCTexture2D::initWithPVRFile @ 0x10046dc70
//
// 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 12:27:37 +0000
//
__int64 __fastcall cocos2d::CCTexturePVR::initWithContentsOfFile(__int64 a1, const char *a2)
{
size_t v2; // rax
size_t v3; // r15
char *v4; // r12
size_t v5; // r13
char *v6; // r13
unsigned int i; // eax
__int64 v8; // r12
unsigned __int64 v9; // rdx
char *v10; // rax
char v11; // al
char *v12; // rcx
char *v13; // r12
char *v14; // rbx
void *v15; // rax
char *v16; // rax
__int64 v17; // rdx
__int64 v18; // rbx
char *v19; // r15
void *v20; // rax
char *v21; // rax
__int64 v22; // rax
int v24; // eax
size_t __dst; // [rsp+10h] [rbp-50h] BYREF
unsigned __int64 v26; // [rsp+18h] [rbp-48h]
void *__s; // [rsp+20h] [rbp-40h]
void *__p; // [rsp+28h] [rbp-38h] BYREF
unsigned int v29[11]; // [rsp+34h] [rbp-2Ch] BYREF
__p = nullptr;
v29[0] = 0;
v2 = strlen(a2);
if ( v2 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v3 = v2;
if ( v2 >= 0x17 )
{
v5 = 26;
if ( (v2 | 7) != 0x17 )
v5 = (v2 | 7) + 1;
v4 = (char *)operator new(v5);
__s = v4;
__dst = v5 + 1;
v26 = v3;
}
else
{
LOBYTE(__dst) = 2 * v2;
v4 = (char *)&__dst + 1;
if ( !v2 )
goto LABEL_9;
}
memcpy(v4, a2, v3);
LABEL_9:
v6 = (char *)&__dst + 1;
v4[v3] = 0;
for ( i = 0; ; i = v8 + 1 )
{
v8 = i;
if ( (__dst & 1) != 0 )
break;
v9 = (unsigned __int8)__dst >> 1;
if ( i >= (unsigned int)v9 )
{
v13 = (char *)&__dst + 1;
if ( v9 < 4 )
goto LABEL_28;
goto LABEL_22;
}
LABEL_15:
v10 = (char *)&__dst + 1;
if ( (__dst & 1) != 0 )
v10 = (char *)__s;
v11 = __tolower(v10[v8]);
v12 = (char *)&__dst + 1;
if ( (__dst & 1) != 0 )
v12 = (char *)__s;
v12[v8] = v11;
}
v9 = v26;
if ( v26 > i )
goto LABEL_15;
v13 = (char *)__s;
if ( v26 < 4 )
goto LABEL_28;
LABEL_22:
v14 = &v13[v9];
v15 = v13;
do
{
v16 = (char *)memchr(v15, 46, v9 - 3);
if ( !v16 )
break;
if ( *(_DWORD *)v16 == 2053333806 )
{
if ( v16 == v14 || v16 - v13 == -1 )
break;
v24 = sub_1001E9C70((__int64)a2, &__p);
v18 = a1;
LABEL_54:
v29[0] = v24;
if ( v24 >= 0 )
goto LABEL_40;
goto LABEL_55;
}
v15 = v16 + 1;
v9 = v14 - (_BYTE *)v15;
}
while ( v14 - (_BYTE *)v15 >= 4 );
LABEL_28:
if ( (__dst & 1) != 0 )
v6 = (char *)__s;
v17 = (unsigned __int8)__dst >> 1;
if ( (__dst & 1) != 0 )
v17 = v26;
v18 = a1;
if ( v17 >= 3 )
{
v19 = &v6[v17];
v20 = v6;
do
{
v21 = (char *)memchr(v20, 46, v17 - 2);
if ( !v21 )
break;
if ( !(*(_WORD *)v21 ^ 0x672E | (unsigned __int8)v21[2] ^ 0x7A) )
{
if ( v21 == v19 || v21 - v6 == -1 )
break;
v24 = sub_1001E9BB0(a2, &__p);
goto LABEL_54;
}
v20 = v21 + 1;
v17 = v19 - (_BYTE *)v20;
}
while ( v19 - (_BYTE *)v20 >= 3 );
}
v22 = cocos2d::CCFileUtils::sharedFileUtils();
__p = (void *)(*(__int64 (__fastcall **)(__int64, const char *, const char *, unsigned int *))(*(_QWORD *)v22 + 32LL))(
v22,
a2,
"rb",
v29);
if ( (v29[0] & 0x80000000) != 0 )
{
LABEL_55:
cocos2d::CCObject::release(v18);
LODWORD(v18) = 0;
if ( (__dst & 1) == 0 )
return (unsigned int)v18;
goto LABEL_50;
}
LABEL_40:
*(_QWORD *)(v18 + 336) = 0;
*(_OWORD *)(v18 + 312) = 0;
*(_DWORD *)(v18 + 328) = 0;
if ( !cocos2d::CCTexturePVR::unpackPVRv2Data(v18, (unsigned int *)__p)
&& !cocos2d::CCTexturePVR::unpackPVRv3Data(v18, (__int64)__p, v29[0])
|| !(unsigned __int8)cocos2d::CCTexturePVR::createGLTexture(v18) )
{
if ( __p )
{
operator delete[](__p);
__p = nullptr;
}
cocos2d::CCObject::release(v18);
LODWORD(v18) = 0;
LABEL_49:
if ( (__dst & 1) != 0 )
goto LABEL_50;
return (unsigned int)v18;
}
LOBYTE(v18) = 1;
if ( !__p )
goto LABEL_49;
operator delete[](__p);
__p = nullptr;
if ( (__dst & 1) == 0 )
return (unsigned int)v18;
LABEL_50:
operator delete(__s);
return (unsigned int)v18;
}