//
// cocos2d::CCTexturePVR::unpackPVRv2Data from 0xda9a00 to 0xda9d4c (844 bytes)
//
// 2 xrefs:
// > cocos2d::CCTexturePVR::initWithContentsOfFile @ 0xdaa42c
// > ??> @ 0x105958
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 13:08:34 +0000
//
__int64 __fastcall cocos2d::CCTexturePVR::unpackPVRv2Data(cocos2d::CCTexturePVR *this, unsigned __int8 *a2)
{
unsigned int v2; // w23
unsigned int v4; // w2
cocos2d::CCConfiguration *v7; // x0
cocos2d::CCConfiguration *POT; // 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 v19; // w3
int v20; // w2
char *v21; // x4
unsigned int v22; // w2
int v23; // w3
cocos2d::CCConfiguration *v24; // x0
char v25; // w0
int v26; // w24
cocos2d *v27; // x22
cocos2d *v28; // x22
unsigned int v29; // w22
unsigned int v30; // w19
unsigned int v31; // w25
v4 = *((_DWORD *)a2 + 11);
if ( (unsigned __int8)v4 != 80 || BYTE1(v4) != 86 || BYTE2(v4) != 82 || HIBYTE(v4) != 33 )
return 0;
v7 = (cocos2d::CCConfiguration *)cocos2d::CCConfiguration::sharedConfiguration(this);
v26 = *((_DWORD *)a2 + 4);
POT = (cocos2d::CCConfiguration *)cocos2d::CCConfiguration::supportsNPOT(v7);
v2 = (unsigned __int8)POT;
if ( !(_BYTE)POT )
{
v27 = (cocos2d *)*((unsigned int *)a2 + 2);
if ( v27 != (cocos2d *)cocos2d::ccNextPOT(v27) )
return v2;
v28 = (cocos2d *)*((unsigned int *)a2 + 1);
POT = (cocos2d::CCConfiguration *)cocos2d::ccNextPOT(v28);
if ( v28 != POT )
return v2;
}
v9 = (cocos2d::CCConfiguration *)cocos2d::CCConfiguration::sharedConfiguration(POT);
if ( (unsigned __int8)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:
*((_DWORD *)this + 78) = 0;
v12 = *((_QWORD *)&unk_13FBB40 + 2 * (v11 & 0xF) + 1);
*((_QWORD *)this + 42) = v12;
v29 = *((_DWORD *)a2 + 2);
*((_DWORD *)this + 79) = v29;
v30 = *((_DWORD *)a2 + 1);
*((_DWORD *)this + 80) = v30;
*((_BYTE *)this + 328) = *((_DWORD *)a2 + 10) != 0;
v31 = *((_DWORD *)a2 + 5);
v13 = 0;
*((_DWORD *)this + 83) = *(_DWORD *)(v12 + 20);
for ( i = *(_DWORD *)(v12 + 12); v31 > v13; *((_DWORD *)this + 78) = 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 *)cocos2d::CCConfiguration::sharedConfiguration((cocos2d::CCConfiguration *)((char *)&dword_0 + 1));
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;
v19 = *((_DWORD *)this + 78);
if ( v16 <= 1 )
v16 = 2;
v20 = v16 * (v18 >> 3);
if ( v15 <= 1 )
v15 = 2;
v21 = (char *)this + 16 * *((unsigned int *)this + 78);
v22 = v20 * v15;
v29 >>= 1;
v30 >>= 1;
if ( v22 > v31 - v13 )
v22 = v31 - v13;
*((_DWORD *)v21 + 16) = v22;
*((_QWORD *)v21 + 7) = &a2[v13 + 52];
v13 += v22;
if ( !v29 )
v29 = 1;
v23 = v19 + 1;
if ( !v30 )
v30 = 1;
}
return 1;
}