//
// cocos2d::CCTexturePVR::unpackPVRv3Data from 0x803178 to 0x8032fc (388 bytes)
//
// 1 xrefs:
// > cocos2d::CCTexturePVR::initWithContentsOfFile @ 0x8035ee
//
// 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::unpackPVRv3Data(
cocos2d::CCTexturePVR *this,
unsigned __int8 *a2,
unsigned int a3)
{
unsigned __int64 v7; // r8
cocos2d::CCConfiguration *v8; // r0
int v9; // r0
int v10; // r1
bool v11; // zf
unsigned int v12; // r0
int v13; // lr
char *v14; // r4
int v15; // r3
unsigned int v16; // r4
unsigned int v17; // r5
cocos2d::CCTexturePVR *v18; // r1
unsigned int v19; // r12
int v20; // r11
unsigned int v21; // r3
int v22; // lr
cocos2d::CCConfiguration *v23; // r0
unsigned int v24; // r3
cocos2d::CCTexturePVR *v25; // [sp+0h] [bp-Ch]
unsigned int v26; // [sp+4h] [bp-8h]
if ( a3 < 0x34 || bswap32(*(_DWORD *)a2) != 1347834371 )
return 0;
v7 = *((_QWORD *)a2 + 1);
v8 = (cocos2d::CCConfiguration *)cocos2d::CCConfiguration::sharedConfiguration(this);
v9 = cocos2d::CCConfiguration::supportsPVRTC(v8);
v10 = 0;
v11 = v9 == 0;
v12 = (unsigned int)&cocos2d::v3_pixel_formathash;
if ( v11 )
v13 = 9;
else
v13 = 13;
while ( 1 )
{
v14 = (char *)&cocos2d::v3_pixel_formathash + 16 * v10;
if ( *(_QWORD *)v14 == v7 )
break;
if ( ++v10 == v13 )
return 0;
}
v15 = *((_DWORD *)v14 + 2);
*((_DWORD *)this + 51) = v15;
*((_BYTE *)this + 196) = *(_BYTE *)(v15 + 17);
if ( (*((_DWORD *)a2 + 1) & 2) != 0 )
*((_BYTE *)this + 197) = 1;
*((_BYTE *)this + 198) = 1;
v16 = *((_DWORD *)a2 + 7);
v17 = *((_DWORD *)a2 + 6);
*((_DWORD *)this + 46) = v16;
v18 = this;
*((_DWORD *)this + 47) = v17;
v19 = 0;
v20 = *((_DWORD *)a2 + 12) + 52;
*((_DWORD *)this + 45) = *((_DWORD *)a2 + 11);
while ( v19 < *((_DWORD *)this + 45) )
{
if ( v7 >= 4 )
{
if ( v7 == 0x808080861726762LL )
{
v25 = v18;
v26 = v19;
v23 = (cocos2d::CCConfiguration *)cocos2d::CCConfiguration::sharedConfiguration((cocos2d::CCConfiguration *)v12);
if ( !cocos2d::CCConfiguration::supportsBGRA8888(v23) )
return 0;
v21 = v17;
v12 = v16;
v22 = 1;
v18 = v25;
v19 = v26;
}
else
{
v21 = v17;
v12 = v16;
v22 = 1;
}
}
else
{
v21 = v17 >> 2;
if ( v7 >= 2 )
{
v12 = v16 >> 2;
v22 = 16;
}
else
{
v12 = v16 >> 3;
v22 = 32;
}
}
++v19;
v18 = (cocos2d::CCTexturePVR *)((char *)v18 + 8);
if ( v12 <= 1 )
v12 = 2;
if ( v21 <= 1 )
v21 = 2;
v24 = v21 * ((unsigned int)(*(_DWORD *)(*((_DWORD *)this + 51) + 12) * v22) >> 3) * v12;
*((_DWORD *)v18 + 11) = &a2[v20];
if ( v24 >= a3 - v20 )
v24 = a3 - v20;
v16 >>= 1;
*((_DWORD *)v18 + 12) = v24;
v20 += v24;
if ( !v16 )
v16 = 1;
v17 >>= 1;
if ( !v17 )
v17 = 1;
}
return 1;
}