//
// cocos2d::CCTexturePVR::unpackPVRv3Data from 0x1800adea0 to 0x1800ae07c (476 bytes)
//
// 2 xrefs:
// > cocos2d::CCTexturePVR::initWithContentsOfFile @ 0x1800adb8c
// > ??> @ 0x1801c2220
//
// 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 11:22:18 +0000
//
char __fastcall cocos2d::CCTexturePVR::unpackPVRv3Data(__int64 a1, __int64 a2, unsigned int a3)
{
unsigned __int64 v6; // rsi
cocos2d::CCConfiguration *v7; // rax
unsigned __int8 v8; // al
__int64 v9; // r12
_QWORD *v10; // rcx
unsigned int v11; // edx
__int64 v12; // rax
__int64 v14; // rax
unsigned int v15; // ebx
unsigned int v16; // edi
int v17; // eax
unsigned int v18; // r15d
cocos2d::CCConfiguration *v19; // rax
int v20; // r9d
unsigned int v21; // edx
unsigned int v22; // eax
unsigned int v23; // r8d
unsigned int v24; // r9d
__int64 v25; // rcx
__int64 v26; // rax
if ( a3 < 0x34 || _byteswap_ulong(*(_DWORD *)a2) != 1347834371 )
return 0;
v6 = *(_QWORD *)(a2 + 8);
v7 = cocos2d::CCConfiguration::sharedConfiguration();
v8 = cocos2d::CCConfiguration::supportsPVRTC(v7);
v9 = 0;
v10 = &unk_1801AD150;
v11 = 4 * v8 + 9;
v12 = 0;
while ( *v10 != v6 )
{
v12 = (unsigned int)(v12 + 1);
v10 += 2;
if ( (unsigned int)v12 >= v11 )
return 0;
}
v14 = *((_QWORD *)&unk_1801AD150 + 2 * v12 + 1);
*(_QWORD *)(a1 + 336) = v14;
*(_BYTE *)(a1 + 328) = *(_BYTE *)(v14 + 17);
LODWORD(v14) = *(_DWORD *)(a2 + 4);
*(_BYTE *)(a1 + 330) = 1;
if ( (v14 & 2) != 0 )
*(_BYTE *)(a1 + 329) = 1;
v15 = *(_DWORD *)(a2 + 28);
v16 = *(_DWORD *)(a2 + 24);
*(_DWORD *)(a1 + 316) = v15;
*(_DWORD *)(a1 + 320) = v16;
v17 = *(_DWORD *)(a2 + 44);
v18 = *(_DWORD *)(a2 + 48) + 52;
*(_DWORD *)(a1 + 312) = v17;
if ( v17 )
{
while ( v6 >= 2 )
{
if ( v6 - 2 <= 1 )
{
v20 = 16;
v21 = v15 >> 2;
LABEL_17:
v22 = v16 >> 2;
goto LABEL_18;
}
if ( v6 == 0x808080861726762LL )
{
v19 = cocos2d::CCConfiguration::sharedConfiguration();
if ( !cocos2d::CCConfiguration::supportsBGRA8888(v19) )
return 0;
}
v20 = 1;
v21 = v15;
v22 = v16;
LABEL_18:
if ( v21 < 2 )
v21 = 2;
if ( v22 < 2 )
v22 = 2;
v23 = a3 - v18;
v24 = v21 * v22 * ((unsigned int)(*(_DWORD *)(*(_QWORD *)(a1 + 336) + 12LL) * v20) >> 3);
if ( a3 - v18 > v24 )
v23 = v24;
v25 = a2 + v18;
v15 >>= 1;
v18 += v23;
v16 >>= 1;
*(_QWORD *)(a1 + 16LL * (unsigned int)v9 + 56) = v25;
v26 = 2 * (v9 + 4);
v9 = (unsigned int)(v9 + 1);
*(_DWORD *)(a1 + 8 * v26) = v23;
if ( (unsigned int)v9 >= *(_DWORD *)(a1 + 312) )
return 1;
if ( v15 <= 1 )
v15 = 1;
if ( v16 <= 1 )
v16 = 1;
}
v20 = 32;
v21 = v15 >> 3;
goto LABEL_17;
}
return 1;
}