//
// cocos2d::CCTexturePVR::initWithContentsOfFile from 0x803448 to 0x803640 (504 bytes)
//
// 2 xrefs:
// > cocos2d::CCTexture2D::initWithPVRFile @ 0x7ff3e2
// > cocos2d::CCTexturePVR::create @ 0x80366c
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:01:22 +0000
//
int __fastcall cocos2d::CCTexturePVR::initWithContentsOfFile(cocos2d::CCTexturePVR *this, char *a2)
{
size_t v4; // r0
size_t v5; // r4
char *v6; // r3
unsigned __int8 *v7; // r9
unsigned int v8; // r4
unsigned int v9; // r3
char *v10; // r2
char *v11; // r10
char *v12; // r3
int v13; // r0
unsigned __int8 *v14; // r4
int v15; // r3
unsigned int v16; // r0
unsigned __int8 *v17; // r9
unsigned int v18; // r3
unsigned __int8 *v19; // r4
unsigned __int8 **v20; // r2
int v21; // r0
unsigned int v22; // r2
int GLTexture; // r4
unsigned int v24; // r1
GLuint v25; // r2
unsigned __int8 *v27; // [sp+10h] [bp-20h] BYREF
unsigned int v28; // [sp+14h] [bp-1Ch] BYREF
unsigned __int8 *v29[2]; // [sp+18h] [bp-18h] BYREF
unsigned int v30; // [sp+20h] [bp-10h] BYREF
size_t v31; // [sp+24h] [bp-Ch]
void *v32; // [sp+28h] [bp-8h]
v27 = nullptr;
v28 = 0;
v30 = 0;
v31 = 0;
v32 = nullptr;
v4 = strlen(a2);
v5 = v4;
if ( v4 > 0xA )
{
v31 = v4;
v30 = (v4 + 16) & 0xFFFFFFF0 | 1;
v6 = (char *)operator new((v4 + 16) & 0xFFFFFFF0);
v32 = v6;
LABEL_5:
v4 = (size_t)memcpy(v6, a2, v5);
v6 = (char *)v4;
goto LABEL_6;
}
LOBYTE(v30) = 2 * v4;
v6 = (char *)&v30 + 1;
if ( v4 )
goto LABEL_5;
LABEL_6:
v7 = (unsigned __int8 *)&v30 + 1;
v6[v5] = 0;
v8 = 0;
while ( (v30 & 1) == 0 )
{
v9 = (int)(unsigned __int8)v30 >> 1;
if ( v8 >= v9 )
goto LABEL_16;
v10 = (char *)&v30 + 1;
LABEL_9:
v11 = &v10[v8];
if ( (v30 & 1) != 0 )
v12 = (char *)v32;
else
v12 = (char *)&v30 + 1;
v13 = (unsigned __int8)v12[v8++];
v4 = tolower(v13);
*v11 = v4;
}
v9 = v31;
v10 = (char *)v32;
if ( v8 < v31 )
goto LABEL_9;
v7 = (unsigned __int8 *)v32;
LABEL_16:
if ( v9 > 3 )
{
v14 = &v7[v9];
v4 = (size_t)std::__search(
v29,
v7,
&v7[v9],
".ccz",
(unsigned __int8 *)"",
(int (__fastcall *)(int, _DWORD))std::char_traits::eq);
if ( v29[0] != v14 && v29[0] - v7 != -1 )
{
v16 = cocos2d::ZipUtils::ccInflateCCZFile(
(cocos2d::ZipUtils *)a2,
(char *)&v27,
(unsigned __int8 **)(v29[0] - v7 + 1),
v15);
goto LABEL_26;
}
}
if ( (v30 & 1) != 0 )
{
v17 = (unsigned __int8 *)v32;
v18 = v31;
}
else
{
v18 = (int)(unsigned __int8)v30 >> 1;
v17 = (unsigned __int8 *)&v30 + 1;
}
if ( v18 <= 2
|| (v19 = &v17[v18],
v4 = (size_t)std::__search(
v29,
v17,
&v17[v18],
".gz",
(unsigned __int8 *)"",
(int (__fastcall *)(int, _DWORD))std::char_traits::eq),
v29[0] == v19)
|| v29[0] - v17 == -1 )
{
v21 = cocos2d::CCFileUtils::sharedFileUtils((cocos2d::CCFileUtils *)v4);
v27 = (unsigned __int8 *)(*(int (__fastcall **)(int, char *, const char *, unsigned int *))(*(_DWORD *)v21 + 16))(
v21,
a2,
"rb",
&v28);
}
else
{
v16 = cocos2d::ZipUtils::ccInflateGZipFile((cocos2d::ZipUtils *)a2, (char *)&v27, v20);
LABEL_26:
v28 = v16;
}
v22 = v28;
if ( (v28 & 0x80000000) == 0 )
{
*((_DWORD *)this + 45) = 0;
*((_DWORD *)this + 48) = 0;
*((_DWORD *)this + 47) = 0;
*((_DWORD *)this + 46) = 0;
*((_DWORD *)this + 51) = 0;
*((_BYTE *)this + 196) = 0;
*((_BYTE *)this + 198) = 0;
*((_BYTE *)this + 197) = 0;
*((_BYTE *)this + 199) = 0;
if ( !cocos2d::CCTexturePVR::unpackPVRv2Data(this, v27, v22)
&& !cocos2d::CCTexturePVR::unpackPVRv3Data(this, v27, v28)
|| (GLTexture = cocos2d::CCTexturePVR::createGLTexture(this, v24, v25)) == 0 )
{
if ( v27 )
{
operator delete[](v27);
v27 = nullptr;
}
goto LABEL_29;
}
if ( v27 )
{
operator delete[](v27);
v27 = nullptr;
}
}
else
{
LABEL_29:
GLTexture = 0;
cocos2d::CCObject::release(this);
}
if ( (v30 & 1) != 0 )
operator delete(v32);
return GLTexture;
}