//
// cocos2d::CCTexturePVR::unpackPVRv2Data from 0x100284c10 to 0x100284e79 (617 bytes)
//
// 1 xrefs:
// > cocos2d::CCTexturePVR::initWithContentsOfFile @ 0x1002856e6
//
// 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 *v3; // rax
int v4; // r14d
cocos2d::CCConfiguration *v5; // rax
char v6; // al
__int64 v7; // rdx
int v8; // ecx
__int64 v9; // rdx
unsigned int v10; // r15d
unsigned int v11; // r12d
unsigned int v12; // r9d
unsigned __int8 *v13; // rbx
int v14; // r10d
cocos2d::CCTexturePVR *v15; // r11
unsigned int m_uIndexInArray; // eax
unsigned int v17; // r13d
unsigned int v19; // edx
unsigned int v20; // ecx
int v21; // esi
unsigned int v22; // ecx
unsigned int v23; // edx
__int64 v24; // rsi
int v25; // ecx
int v26; // edx
unsigned int v27; // ebx
cocos2d::CCConfiguration *v28; // rax
__int64 v29; // r15
__int64 v30; // r15
char v31; // cl
unsigned __int8 *v32; // [rsp-58h] [rbp-58h]
unsigned __int8 v33; // [rsp-48h] [rbp-48h]
cocos2d::CCTexturePVR *v34; // [rsp-40h] [rbp-40h]
int v35; // [rsp-38h] [rbp-38h]
if ( *((_DWORD *)a2 + 11) != 559044176 )
return 0;
v34 = a1;
v3 = cocos2d::CCConfiguration::sharedConfiguration();
v4 = *((_DWORD *)a2 + 4);
if ( !cocos2d::CCConfiguration::supportsNPOT(v3) )
{
v29 = *((unsigned int *)a2 + 2);
if ( sub_1005772B0(v29) != v29 )
return 0;
v30 = *((unsigned int *)a2 + 1);
if ( sub_1005772B0(v30) != v30 )
return 0;
}
v33 = v4;
v5 = cocos2d::CCConfiguration::sharedConfiguration();
cocos2d::CCConfiguration::supportsPVRTC(v5);
v6 = 1;
if ( (unsigned __int8)(v4 - 16) <= 0xBu && (v7 = (unsigned __int8)(v4 - 16), v8 = 3311, _bittest(&v8, v7)) )
{
v9 = *(_QWORD *)((char *)&dword_100818B84[2] + dword_100818B84[v7]);
a1[6].__vftable = (cocos2d::CCTexturePVR_vtbl *)v9;
a1[5].m_uIndexInArray = 0;
v10 = *((_DWORD *)a2 + 2);
a1[5].m_uUnknown = v10;
v11 = *((_DWORD *)a2 + 1);
a1[5].m_unknown2 = v11;
LOBYTE(a1[5].m_uOrderOfArrival) = *((_DWORD *)a2 + 10) != 0;
v12 = *((_DWORD *)a2 + 5);
a1[5].m_unknown5 = *(_DWORD *)(v9 + 20);
v6 = 1;
if ( v12 )
{
v13 = a2 + 52;
v14 = *(_DWORD *)(v9 + 12);
v15 = a1 + 1;
m_uIndexInArray = 0;
v4 = (unsigned __int8)v4;
v17 = 0;
v32 = a2 + 52;
v35 = v14;
while ( 1 )
{
if ( v33 == 26 )
{
v27 = v12;
v28 = cocos2d::CCConfiguration::sharedConfiguration();
if ( !cocos2d::CCConfiguration::supportsBGRA8888(v28) )
{
v6 = 0;
goto LABEL_33;
}
a1 = v34;
m_uIndexInArray = v34[5].m_uIndexInArray;
v21 = 1;
v19 = v10;
v20 = v11;
v12 = v27;
v13 = v32;
v14 = v35;
v15 = v34 + 1;
v4 = v33;
}
else if ( v4 == 25 )
{
v19 = v10 >> 2;
v20 = v11 >> 2;
v21 = 16;
}
else if ( v4 == 24 )
{
v19 = v10 >> 3;
v20 = v11 >> 2;
v21 = 32;
}
else
{
v21 = 1;
v19 = v10;
v20 = v11;
}
if ( v19 < 3 )
v19 = 2;
if ( v20 < 3 )
v20 = 2;
v22 = ((unsigned int)(v14 * v21) >> 3) * v19 * v20;
v23 = v12 - v17;
if ( v12 - v17 >= v22 )
v23 = v22;
v24 = 16LL * m_uIndexInArray;
*(cocos2d::CCTexturePVR_vtbl **)((char *)&v15->__vftable + v24) = (cocos2d::CCTexturePVR_vtbl *)&v13[v17];
*(unsigned int *)((char *)&v15->m_uID + v24) = v23;
++m_uIndexInArray;
v17 += v23;
v25 = v10 >> 1;
if ( v10 < 2 )
v25 = 1;
v26 = v11 >> 1;
if ( v11 < 2 )
v26 = 1;
a1[5].m_uIndexInArray = m_uIndexInArray;
v11 = v26;
v10 = v25;
if ( v17 >= v12 )
{
v31 = 1;
v6 = 1;
return v31 & v6;
}
}
}
v31 = 1;
}
else
{
LABEL_33:
v31 = 0;
}
return v31 & v6;
}