//
// cocos2d::CCTexturePVR::unpackPVRv2Data from 0xb37310 to 0xb3765c (844 bytes)
//
// 2 xrefs:
// > cocos2d::CCTexturePVR::initWithContentsOfFile @ 0xb37cc0
// > ??> @ 0xc9318
//
// 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 cocos2d::CCTexturePVR::unpackPVRv2Data(cocos2d::CCTexturePVR *a1, unsigned __int8 *a2, unsigned int a3)
{
bool v3; // w23
unsigned int v5; // w2
cocos2d::CCConfiguration *v8; // x0
cocos2d::CCConfiguration *v9; // x0
int v10; // w1
char v11; // w0
__int64 v12; // x2
unsigned int v13; // w23
int i; // w27
unsigned int v15; // w1
unsigned int v16; // w2
char *v17; // x0
unsigned int v18; // w0
int m_uIndexInArray; // w3
int v20; // w2
char *v21; // x4
unsigned int v22; // w2
int v23; // w3
cocos2d::CCConfiguration *v24; // x0
bool v25; // w0
int v26; // w24
cocos2d *v27; // x22
cocos2d *v28; // x22
unsigned int v29; // w22
unsigned int v30; // w19
bool v31; // w0
unsigned int v32; // w25
v5 = *((_DWORD *)a2 + 11);
if ( (unsigned __int8)v5 != 80 || BYTE1(v5) != 86 || BYTE2(v5) != 82 || HIBYTE(v5) != 33 )
return 0;
v8 = cocos2d::CCConfiguration::sharedConfiguration();
v26 = *((_DWORD *)a2 + 4);
v3 = cocos2d::CCConfiguration::supportsNPOT(v8);
if ( !v3 )
{
v27 = (cocos2d *)*((unsigned int *)a2 + 2);
if ( v27 != (cocos2d *)cocos2d::ccNextPOT(v27) )
return v3;
v28 = (cocos2d *)*((unsigned int *)a2 + 1);
if ( v28 != (cocos2d *)cocos2d::ccNextPOT(v28) )
return v3;
}
v9 = cocos2d::CCConfiguration::sharedConfiguration();
if ( cocos2d::CCConfiguration::supportsPVRTC(v9) )
v10 = 11;
else
v10 = 9;
switch ( (unsigned __int8)v26 )
{
case 0x1Au:
v11 = 0;
goto LABEL_25;
case 0x12u:
v11 = 1;
goto LABEL_25;
case 0x10u:
v11 = 2;
goto LABEL_25;
case 0x11u:
v11 = 3;
goto LABEL_25;
case 0x13u:
v11 = 4;
goto LABEL_25;
case 0x15u:
v11 = 5;
goto LABEL_25;
case 0x1Bu:
v11 = 6;
goto LABEL_25;
case 0x16u:
v11 = 7;
goto LABEL_25;
case 0x17u:
v11 = 8;
goto LABEL_25;
}
if ( v10 == 9 )
return 0;
if ( (unsigned __int8)v26 == 24 )
{
v11 = 9;
goto LABEL_25;
}
if ( (unsigned __int8)v26 != 25 )
return 0;
v11 = 10;
LABEL_25:
a1[5].m_uIndexInArray = 0;
v12 = *((_QWORD *)&unk_111C170 + 2 * (v11 & 0xF) + 1);
a1[6].__vftable = (cocos2d::CCTexturePVR_vtbl *)v12;
v29 = *((_DWORD *)a2 + 2);
v30 = *((_DWORD *)a2 + 1);
v31 = *((_DWORD *)a2 + 10) != 0;
a1[5].m_uUnknown = v29;
a1[5].m_unknown2 = v30;
LOBYTE(a1[5].m_uOrderOfArrival) = v31;
v32 = *((_DWORD *)a2 + 5);
v13 = 0;
a1[5].m_unknown5 = *(_DWORD *)(v12 + 20);
for ( i = *(_DWORD *)(v12 + 12); v32 > v13; a1[5].m_uIndexInArray = v23 )
{
if ( (unsigned __int8)v26 == 25 )
{
v16 = v29 >> 2;
v15 = v30 >> 2;
LODWORD(v17) = 16;
}
else
{
v15 = v30;
v16 = v29;
v17 = (char *)&dword_0 + 1;
if ( (unsigned __int8)v26 == 26 )
{
v24 = cocos2d::CCConfiguration::sharedConfiguration();
v25 = cocos2d::CCConfiguration::supportsBGRA8888(v24);
v15 = v30;
v16 = v29;
if ( !v25 )
return 0;
LODWORD(v17) = 1;
}
else if ( (unsigned __int8)v26 == 24 )
{
v16 = v29 >> 3;
v15 = v30 >> 2;
LODWORD(v17) = 32;
}
}
v18 = (_DWORD)v17 * i;
m_uIndexInArray = a1[5].m_uIndexInArray;
if ( v16 <= 1 )
v16 = 2;
v20 = v16 * (v18 >> 3);
if ( v15 <= 1 )
v15 = 2;
v21 = (char *)a1 + 16 * (unsigned int)a1[5].m_uIndexInArray;
v22 = v20 * v15;
v29 >>= 1;
v30 >>= 1;
if ( v22 > v32 - v13 )
v22 = v32 - v13;
*((_DWORD *)v21 + 16) = v22;
*((_QWORD *)v21 + 7) = &a2[v13 + 52];
v13 += v22;
if ( !v29 )
v29 = 1;
v23 = m_uIndexInArray + 1;
if ( !v30 )
v30 = 1;
}
return 1;
}