//
// cocos2d::CCTexturePVR::unpackPVRv2Data from 0x802fd0 to 0x80316a (410 bytes)
//
// 1 xrefs:
// > cocos2d::CCTexturePVR::initWithContentsOfFile @ 0x8035d6
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:01:21 +0000
//
int __fastcall cocos2d::CCTexturePVR::unpackPVRv2Data(
cocos2d::CCTexturePVR *this,
unsigned __int8 *a2,
unsigned int a3)
{
unsigned int v5; // r3
cocos2d::CCConfiguration *v6; // r4
cocos2d::CCConfiguration *v7; // r0
int v8; // r6
cocos2d::CCConfiguration *POT; // r0
unsigned int v10; // r1
cocos2d *v11; // r5
unsigned int v12; // r1
cocos2d *v13; // r5
cocos2d::CCConfiguration *v14; // r0
int v15; // r4
bool v16; // zf
cocos2d::CCConfiguration *v17; // r0
int v18; // r12
char *v19; // r5
int v20; // r3
unsigned int v21; // r4
unsigned int v22; // r5
unsigned int v23; // r11
int v24; // r10
unsigned int v25; // r1
unsigned int v26; // r2
int v27; // r3
cocos2d::CCConfiguration *v28; // r0
unsigned int v29; // r3
unsigned int v30; // r3
int v31; // r2
int v32; // r2
unsigned __int8 *v33; // r1
unsigned int v34; // r9
v5 = *((_DWORD *)a2 + 11);
if ( (unsigned __int8)v5 != 80 || BYTE1(v5) != 86 || BYTE2(v5) != 82 || HIBYTE(v5) != 33 )
return 0;
v7 = (cocos2d::CCConfiguration *)cocos2d::CCConfiguration::sharedConfiguration(this);
v8 = *((_DWORD *)a2 + 4);
POT = (cocos2d::CCConfiguration *)cocos2d::CCConfiguration::supportsNPOT(v7);
v6 = POT;
if ( POT
|| (v11 = *((cocos2d **)a2 + 2), v11 == (cocos2d *)cocos2d::ccNextPOT(v11, v10))
&& (v13 = *((cocos2d **)a2 + 1), POT = (cocos2d::CCConfiguration *)cocos2d::ccNextPOT(v13, v12), v13 == POT) )
{
v14 = (cocos2d::CCConfiguration *)cocos2d::CCConfiguration::sharedConfiguration(POT);
v15 = 0;
v16 = cocos2d::CCConfiguration::supportsPVRTC(v14) == 0;
v17 = (cocos2d::CCConfiguration *)(unsigned __int8)v8;
if ( v16 )
v18 = 9;
else
v18 = 11;
while ( 1 )
{
v19 = (char *)&unk_C75248 + 16 * v15;
if ( *(_QWORD *)v19 == (unsigned __int8)v8 )
break;
if ( ++v15 == v18 )
return 0;
}
v20 = *((_DWORD *)v19 + 2);
*((_DWORD *)this + 45) = 0;
*((_DWORD *)this + 51) = v20;
v21 = *((_DWORD *)a2 + 2);
*((_DWORD *)this + 46) = v21;
v22 = *((_DWORD *)a2 + 1);
*((_DWORD *)this + 47) = v22;
*((_BYTE *)this + 196) = *((_DWORD *)a2 + 10) != 0;
v34 = *((_DWORD *)a2 + 5);
v23 = 0;
*((_DWORD *)this + 50) = *(_DWORD *)(v20 + 20);
v24 = *(_DWORD *)(v20 + 12);
while ( 1 )
{
if ( v23 >= v34 )
return 1;
switch ( (unsigned __int8)v8 )
{
case 0x19u:
v25 = v21 >> 2;
v26 = v22 >> 2;
v27 = 16;
break;
case 0x1Au:
v28 = (cocos2d::CCConfiguration *)cocos2d::CCConfiguration::sharedConfiguration(v17);
if ( !cocos2d::CCConfiguration::supportsBGRA8888(v28) )
return 0;
break;
case 0x18u:
v25 = v21 >> 3;
v26 = v22 >> 2;
v27 = 32;
break;
default:
v26 = v22;
v25 = v21;
v27 = 1;
break;
}
v29 = v24 * v27;
if ( v25 <= 1 )
v25 = 2;
if ( v26 <= 1 )
v26 = 2;
v30 = (v29 >> 3) * v25 * v26;
v31 = *((_DWORD *)this + 45);
v17 = (cocos2d::CCTexturePVR *)((char *)this + 8 * v31);
v32 = v31 + 1;
if ( v30 >= v34 - v23 )
v30 = v34 - v23;
v21 >>= 1;
*((_DWORD *)v17 + 14) = v30;
if ( !v21 )
v21 = 1;
v22 >>= 1;
v33 = &a2[v23 + 52];
v23 += v30;
*((_DWORD *)v17 + 13) = v33;
if ( !v22 )
v22 = 1;
*((_DWORD *)this + 45) = v32;
}
}
return (int)v6;
}