//
// cocos2d::CCTexturePVR::unpackPVRv2Data from 0x1002717c0 to 0x100271a29 (617 bytes)
//
// 1 xrefs:
// > cocos2d::CCTexturePVR::initWithContentsOfFile @ 0x100272296
//
// 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::unpackPVRv2Data(__int64 a1, unsigned int *a2)
{
__int64 v2; // rax
unsigned int v3; // r14d
__int64 v4; // rax
char v5; // al
__int64 v6; // rdx
int v7; // ecx
__int64 v8; // rdx
unsigned int v9; // r15d
unsigned int v10; // r12d
unsigned int v11; // r9d
unsigned int *v12; // rbx
int v13; // r10d
__int64 v14; // r11
unsigned int v15; // eax
unsigned int v16; // r13d
unsigned int v18; // edx
unsigned int v19; // ecx
int v20; // esi
unsigned int v21; // ecx
unsigned int v22; // edx
__int64 v23; // rsi
int v24; // ecx
int v25; // edx
unsigned int v26; // ebx
__int64 v27; // rax
__int64 v28; // r15
__int64 v29; // r15
char v30; // cl
unsigned int *v31; // [rsp-58h] [rbp-58h]
unsigned __int8 v32; // [rsp-48h] [rbp-48h]
__int64 v33; // [rsp-40h] [rbp-40h]
int v34; // [rsp-38h] [rbp-38h]
if ( a2[11] != 559044176 )
return 0;
v33 = a1;
v2 = cocos2d::CCConfiguration::sharedConfiguration();
v3 = a2[4];
if ( !(unsigned __int8)cocos2d::CCConfiguration::supportsNPOT(v2) )
{
v28 = a2[2];
if ( sub_1005A4800(v28) != v28 )
return 0;
v29 = a2[1];
if ( sub_1005A4800(v29) != v29 )
return 0;
}
v32 = v3;
v4 = cocos2d::CCConfiguration::sharedConfiguration();
cocos2d::CCConfiguration::supportsPVRTC(v4);
v5 = 1;
if ( (unsigned __int8)(v3 - 16) <= 0xBu && (v6 = (unsigned __int8)(v3 - 16), v7 = 3311, _bittest(&v7, v6)) )
{
v8 = *(_QWORD *)((char *)&dword_100A07084[2] + dword_100A07084[v6]);
*(_QWORD *)(a1 + 336) = v8;
*(_DWORD *)(a1 + 312) = 0;
v9 = a2[2];
*(_DWORD *)(a1 + 316) = v9;
v10 = a2[1];
*(_DWORD *)(a1 + 320) = v10;
*(_BYTE *)(a1 + 328) = a2[10] != 0;
v11 = a2[5];
*(_DWORD *)(a1 + 332) = *(_DWORD *)(v8 + 20);
v5 = 1;
if ( v11 )
{
v12 = a2 + 13;
v13 = *(_DWORD *)(v8 + 12);
v14 = a1 + 56;
v15 = 0;
v3 = (unsigned __int8)v3;
v16 = 0;
v31 = a2 + 13;
v34 = v13;
while ( 1 )
{
if ( v32 == 26 )
{
v26 = v11;
v27 = cocos2d::CCConfiguration::sharedConfiguration();
if ( !(unsigned __int8)cocos2d::CCConfiguration::supportsBGRA8888(v27) )
{
v5 = 0;
goto LABEL_33;
}
a1 = v33;
v15 = *(_DWORD *)(v33 + 312);
v20 = 1;
v18 = v9;
v19 = v10;
v11 = v26;
v12 = v31;
v13 = v34;
v14 = v33 + 56;
v3 = v32;
}
else if ( v3 == 25 )
{
v18 = v9 >> 2;
v19 = v10 >> 2;
v20 = 16;
}
else if ( v3 == 24 )
{
v18 = v9 >> 3;
v19 = v10 >> 2;
v20 = 32;
}
else
{
v20 = 1;
v18 = v9;
v19 = v10;
}
if ( v18 < 3 )
v18 = 2;
if ( v19 < 3 )
v19 = 2;
v21 = ((unsigned int)(v13 * v20) >> 3) * v18 * v19;
v22 = v11 - v16;
if ( v11 - v16 >= v21 )
v22 = v21;
v23 = 16LL * v15;
*(_QWORD *)(v14 + v23) = (char *)v12 + v16;
*(_DWORD *)(v14 + v23 + 8) = v22;
++v15;
v16 += v22;
v24 = v9 >> 1;
if ( v9 < 2 )
v24 = 1;
v25 = v10 >> 1;
if ( v10 < 2 )
v25 = 1;
*(_DWORD *)(a1 + 312) = v15;
v10 = v25;
v9 = v24;
if ( v16 >= v11 )
{
v30 = 1;
v5 = 1;
return v30 & v5;
}
}
}
v30 = 1;
}
else
{
LABEL_33:
v30 = 0;
}
return v30 & v5;
}