//
// cocos2d::CCTexturePVR::unpackPVRv3Data from 0x100271a30 to 0x100271d06 (726 bytes)
//
// 1 xrefs:
// > cocos2d::CCTexturePVR::initWithContentsOfFile @ 0x1002722a9
//
// This function is hookable on this platform (idp: pc, 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 12:27:37 +0000
//
char __fastcall cocos2d::CCTexturePVR::unpackPVRv3Data(__int64 a1, __int64 a2, unsigned int a3)
{
unsigned __int64 v3; // r14
__int64 v4; // rax
__int64 *v5; // rax
unsigned int v6; // r8d
__int64 v7; // r9
__int64 v8; // rdx
char result; // al
__int64 v10; // r11
bool v11; // zf
unsigned int v12; // r14d
unsigned int v13; // r13d
unsigned int v14; // r10d
int v15; // r12d
unsigned int v16; // r12d
unsigned int *v17; // r15
unsigned __int64 v18; // rbx
unsigned int v19; // esi
unsigned int v20; // edi
int v21; // edx
unsigned int v22; // edx
unsigned int v23; // esi
int v24; // edx
int v25; // esi
__int64 v26; // rax
__int64 v27; // [rsp-50h] [rbp-50h]
unsigned __int64 v30; // [rsp-38h] [rbp-38h]
if ( a3 < 0x34 || *(_DWORD *)a2 != 55727696 )
return 0;
v3 = *(_QWORD *)(a2 + 8);
v4 = ((__int64 (*)(void))cocos2d::CCConfiguration::sharedConfiguration)();
cocos2d::CCConfiguration::supportsPVRTC(v4);
v30 = v3;
if ( qword_100BDE870 == v3 )
{
v5 = &qword_100BDE870;
v6 = a3;
v7 = a2;
v8 = a1;
}
else
{
v6 = a3;
v7 = a2;
v8 = a1;
if ( qword_100BDE880 == v3 )
{
v5 = &qword_100BDE880;
}
else if ( qword_100BDE890 == v3 )
{
v5 = &qword_100BDE890;
}
else if ( qword_100BDE8A0 == v3 )
{
v5 = &qword_100BDE8A0;
}
else if ( qword_100BDE8B0 == v3 )
{
v5 = &qword_100BDE8B0;
}
else if ( qword_100BDE8C0 == v3 )
{
v5 = &qword_100BDE8C0;
}
else if ( qword_100BDE8D0 == v3 )
{
v5 = &qword_100BDE8D0;
}
else if ( qword_100BDE8E0 == v3 )
{
v5 = &qword_100BDE8E0;
}
else
{
if ( qword_100BDE8F0 != v3 )
return 0;
v5 = &qword_100BDE8F0;
}
}
v10 = v5[1];
*(_QWORD *)(v8 + 336) = v10;
*(_BYTE *)(v8 + 328) = *(_BYTE *)(v10 + 17);
v11 = (*(_BYTE *)(v7 + 4) & 2) == 0;
*(_BYTE *)(v8 + 330) = 1;
if ( !v11 )
*(_BYTE *)(v8 + 329) = 1;
v12 = *(_DWORD *)(v7 + 24);
v13 = *(_DWORD *)(v7 + 28);
*(_DWORD *)(v8 + 316) = v13;
*(_DWORD *)(v8 + 320) = v12;
v14 = *(_DWORD *)(v7 + 44);
v15 = *(_DWORD *)(v7 + 48);
*(_DWORD *)(v8 + 312) = v14;
result = 1;
if ( v14 )
{
v16 = v15 + 52;
v27 = v8;
v17 = (unsigned int *)(v8 + 64);
v18 = 0;
do
{
if ( v30 < 2 )
{
v19 = v13 >> 3;
v20 = v12 >> 2;
v21 = 32;
}
else if ( v30 - 2 >= 2 )
{
v21 = 1;
v19 = v13;
v20 = v12;
if ( v30 == 0x808080861726762LL )
{
v26 = cocos2d::CCConfiguration::sharedConfiguration(v12, v13, 1, v10, v6);
if ( !(unsigned __int8)cocos2d::CCConfiguration::supportsBGRA8888(v26) )
return 0;
v10 = *(_QWORD *)(v27 + 336);
v14 = *(_DWORD *)(v27 + 312);
v21 = 1;
v19 = v13;
v20 = v12;
v6 = a3;
v7 = a2;
}
}
else
{
v19 = v13 >> 2;
v20 = v12 >> 2;
v21 = 16;
}
if ( v19 < 3 )
v19 = 2;
if ( v20 < 3 )
v20 = 2;
v22 = v19 * v20 * ((unsigned int)(*(_DWORD *)(v10 + 12) * v21) >> 3);
v23 = v6 - v16;
if ( v6 - v16 >= v22 )
v23 = v22;
*((_QWORD *)v17 - 1) = v7 + v16;
v16 += v23;
v24 = v13 >> 1;
if ( v13 < 2 )
v24 = 1;
*v17 = v23;
v25 = v12 >> 1;
if ( v12 < 2 )
v25 = 1;
++v18;
v17 += 4;
v12 = v25;
v13 = v24;
}
while ( v18 < v14 );
return 1;
}
return result;
}