//
// cocos2d::CCTexturePVR::unpackPVRv3Data from 0x5f66e0 to 0x5f6864 (388 bytes)
//
// 1 xrefs:
// > cocos2d::CCTexturePVR::initWithContentsOfFile @ 0x5f6a98
//
// 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::unpackPVRv3Data(cocos2d::CCTexturePVR *a1, unsigned __int8 *a2, unsigned int a3)
{
unsigned __int64 v7; // r8
cocos2d::CCConfiguration *v8; // r0
_BOOL4 v9; // r0
int v10; // r1
int v11; // lr
char *v12; // r4
int v13; // r3
unsigned int v14; // r4
unsigned int v15; // r5
cocos2d::CCTexturePVR *v16; // r1
cocos2d::CCObjectType v17; // r12
int v18; // r11
unsigned int v19; // r3
unsigned int v20; // r0
int v21; // lr
cocos2d::CCConfiguration *v22; // r0
unsigned int v23; // r3
cocos2d::CCTexturePVR *v24; // [sp+0h] [bp-Ch]
cocos2d::CCObjectType v25; // [sp+4h] [bp-8h]
if ( a3 < 0x34 || bswap32(*(_DWORD *)a2) != 1347834371 )
return 0;
v7 = *((_QWORD *)a2 + 1);
v8 = cocos2d::CCConfiguration::sharedConfiguration();
v9 = cocos2d::CCConfiguration::supportsPVRTC(v8);
v10 = 0;
if ( v9 )
v11 = 13;
else
v11 = 9;
while ( 1 )
{
v12 = (char *)&cocos2d::v3_pixel_formathash + 16 * v10;
if ( *(_QWORD *)v12 == v7 )
break;
if ( ++v10 == v11 )
return 0;
}
v13 = *((_DWORD *)v12 + 2);
a1[3].m_unknown5 = v13;
LOBYTE(a1[3].m_nZOrder) = *(_BYTE *)(v13 + 17);
if ( (*((_DWORD *)a2 + 1) & 2) != 0 )
BYTE1(a1[3].m_nZOrder) = 1;
BYTE2(a1[3].m_nZOrder) = 1;
v14 = *((_DWORD *)a2 + 7);
v15 = *((_DWORD *)a2 + 6);
a1[3].m_uIndexInArray = v14;
v16 = a1;
a1[3].m_uUnknown = v15;
v17 = 0;
v18 = *((_DWORD *)a2 + 12) + 52;
a1[3].m_eObjType = *((_DWORD *)a2 + 11);
while ( (unsigned int)v17 < a1[3].m_eObjType )
{
if ( v7 >= 4 )
{
if ( v7 == 0x808080861726762LL )
{
v24 = v16;
v25 = v17;
v22 = cocos2d::CCConfiguration::sharedConfiguration();
if ( !cocos2d::CCConfiguration::supportsBGRA8888(v22) )
return 0;
v19 = v15;
v20 = v14;
v21 = 1;
v16 = v24;
v17 = v25;
}
else
{
v19 = v15;
v20 = v14;
v21 = 1;
}
}
else
{
v19 = v15 >> 2;
if ( v7 >= 2 )
{
v20 = v14 >> 2;
v21 = 16;
}
else
{
v20 = v14 >> 3;
v21 = 32;
}
}
++v17;
v16 = (cocos2d::CCTexturePVR *)((char *)v16 + 8);
if ( v20 <= 1 )
v20 = 2;
if ( v19 <= 1 )
v19 = 2;
v23 = v19 * ((unsigned int)(*(_DWORD *)(a1[3].m_unknown5 + 12) * v21) >> 3) * v20;
v16->m_uOrderOfArrival = (int)&a2[v18];
if ( v23 >= a3 - v18 )
v23 = a3 - v18;
v14 >>= 1;
v16->m_unknown5 = v23;
v18 += v23;
if ( !v14 )
v14 = 1;
v15 >>= 1;
if ( !v15 )
v15 = 1;
}
return 1;
}