//
// cocos2d::CCTexturePVR::unpackPVRv2Data from 0x100370340 to 0x100370550 (528 bytes)
//
// 1 xrefs:
// > cocos2d::CCTexturePVR::initWithContentsOfFile @ 0x100370ad4
//
// 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::unpackPVRv2Data(cocos2d::CCTexturePVR *a1, unsigned __int8 *a2, unsigned int a3)
{
cocos2d::CCConfiguration *v5; // x0
cocos2d::CCTexturePVR_vtbl *v6; // x22
cocos2d::CCConfiguration *v7; // x0
_BOOL4 v8; // w0
__int64 v9; // x9
cocos2d::CCTexturePVR_vtbl **i; // x8
char v11; // w8
__int64 v13; // x21
__int64 v14; // x21
cocos2d::CCTexturePVR_vtbl *v15; // x9
int32x2_t v16; // d8
unsigned int v17; // w21
unsigned int m_uIndexInArray; // w8
unsigned int v19; // w23
unsigned __int8 *v20; // x20
int v21; // w24
uint32x2_t v22; // d0
int v23; // w9
cocos2d::CCConfiguration *v24; // x0
__int32 v25; // w10
__int32 v26; // w11
unsigned int v27; // w9
char *v28; // x11
int8x8_t v29; // d1
if ( *((_DWORD *)a2 + 11) != 559044176 )
return 0;
v5 = cocos2d::CCConfiguration::sharedConfiguration();
v6 = (cocos2d::CCTexturePVR_vtbl *)a2[16];
if ( !cocos2d::CCConfiguration::supportsNPOT(v5) )
{
v13 = *((unsigned int *)a2 + 2);
if ( sub_100084720(v13) != v13 )
return 0;
v14 = *((unsigned int *)a2 + 1);
if ( sub_100084720(v14) != v14 )
return 0;
}
v7 = cocos2d::CCConfiguration::sharedConfiguration();
v8 = cocos2d::CCConfiguration::supportsPVRTC(v7);
v9 = 11;
if ( !v8 )
v9 = 9;
for ( i = (cocos2d::CCTexturePVR_vtbl **)&off_1007F5020; *(i - 1) != v6; i += 2 )
{
if ( !--v9 )
{
v11 = 1;
return v11 & v9;
}
}
v15 = *i;
a1[6].__vftable = *i;
a1[5].m_uIndexInArray = 0;
v16 = *(int32x2_t *)(a2 + 4);
*(int32x2_t *)&a1[5].m_uUnknown = vrev64_s32(v16);
LOBYTE(a1[5].m_uOrderOfArrival) = *((_DWORD *)a2 + 10) != 0;
v17 = *((_DWORD *)a2 + 5);
a1[5].m_unknown5 = HIDWORD(v15->~CCTexturePVR_0);
if ( !v17 )
{
LABEL_30:
v11 = 1;
LOBYTE(v9) = 1;
return v11 & v9;
}
m_uIndexInArray = 0;
v19 = 0;
v20 = a2 + 52;
v21 = HIDWORD(v15->~CCTexturePVR);
while ( (_DWORD)v6 != 26 )
{
if ( (_DWORD)v6 == 25 )
{
v22 = vshr_n_u32((uint32x2_t)v16, 2u);
v23 = 16;
}
else
{
if ( (_DWORD)v6 != 24 )
goto LABEL_22;
v22 = vshl_u32((uint32x2_t)v16, (uint32x2_t)0xFFFFFFFDFFFFFFFELL);
v23 = 32;
}
LABEL_23:
v25 = v22.i32[1];
if ( v22.i32[1] <= 2u )
v25 = 2;
v26 = v22.i32[0];
if ( v22.i32[0] <= 2u )
v26 = 2;
v27 = ((unsigned int)(v23 * v21) >> 3) * v25 * v26;
if ( v17 - v19 < v27 )
v27 = v17 - v19;
v28 = (char *)&a1[1] + 16 * m_uIndexInArray;
*(_QWORD *)v28 = &v20[v19];
*((_DWORD *)v28 + 2) = v27;
a1[5].m_uIndexInArray = ++m_uIndexInArray;
v19 += v27;
v29 = (int8x8_t)vcgt_u32((uint32x2_t)v16, (uint32x2_t)0x100000001LL);
v16 = vsub_s32((int32x2_t)vand_s8((int8x8_t)vshr_n_u32((uint32x2_t)v16, 1u), v29), (int32x2_t)vmvn_s8(v29));
if ( v19 >= v17 )
goto LABEL_30;
}
v24 = cocos2d::CCConfiguration::sharedConfiguration();
if ( cocos2d::CCConfiguration::supportsBGRA8888(v24) )
{
m_uIndexInArray = a1[5].m_uIndexInArray;
LABEL_22:
v23 = 1;
v22 = (uint32x2_t)v16;
goto LABEL_23;
}
v11 = 0;
LOBYTE(v9) = 0;
return v11 & v9;
}