//
// cocos2d::CCTexturePVR::unpackPVRv2Data from 0x1800adc60 to 0x1800ade9f (575 bytes)
//
// 2 xrefs:
// > cocos2d::CCTexturePVR::initWithContentsOfFile @ 0x1800adb78
// > ??> @ 0x1801c2214
//
// 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::unpackPVRv2Data(__int64 a1, __int64 a2)
{
int v3; // ecx
unsigned int v4; // r14d
cocos2d::CCConfiguration *v6; // rax
__int64 v7; // r15
cocos2d::CCConfiguration *v8; // rax
unsigned __int8 v9; // al
_QWORD *v10; // rcx
unsigned int v11; // edx
__int64 v12; // rax
__int64 v14; // rcx
unsigned int v15; // ebx
unsigned int v16; // edi
unsigned int v17; // r12d
__int64 v18; // rsi
int v19; // r13d
__int64 v20; // rdx
cocos2d::CCConfiguration *v21; // rax
int v22; // r9d
unsigned int v23; // ecx
unsigned int v24; // r8d
unsigned int v25; // eax
unsigned int v26; // ecx
__int64 v27; // rax
v3 = *(_DWORD *)(a2 + 44);
v4 = 0;
if ( word_1801AD220 != (_WORD)v3 )
return 0;
if ( byte_1801AD222 != BYTE2(v3) )
return 0;
if ( byte_1801AD223 != HIBYTE(v3) )
return 0;
v6 = cocos2d::CCConfiguration::sharedConfiguration();
v7 = *(unsigned __int8 *)(a2 + 16);
if ( !cocos2d::CCConfiguration::supportsNPOT(v6)
&& (*(_DWORD *)(a2 + 8) != (unsigned int)sub_1800992B0(*(_DWORD *)(a2 + 8))
|| *(_DWORD *)(a2 + 4) != (unsigned int)sub_1800992B0(*(_DWORD *)(a2 + 4))) )
{
return 0;
}
v8 = cocos2d::CCConfiguration::sharedConfiguration();
v9 = cocos2d::CCConfiguration::supportsPVRTC(v8);
v10 = &unk_1801AD230;
v11 = 2 * v9 + 9;
v12 = 0;
while ( *v10 != v7 )
{
v12 = (unsigned int)(v12 + 1);
v10 += 2;
if ( (unsigned int)v12 >= v11 )
return 0;
}
v14 = *((_QWORD *)&unk_1801AD230 + 2 * v12 + 1);
*(_QWORD *)(a1 + 336) = v14;
*(_DWORD *)(a1 + 312) = 0;
v15 = *(_DWORD *)(a2 + 8);
*(_DWORD *)(a1 + 316) = v15;
v16 = *(_DWORD *)(a2 + 4);
*(_DWORD *)(a1 + 320) = v16;
*(_BYTE *)(a1 + 328) = *(_DWORD *)(a2 + 40) != 0;
v17 = *(_DWORD *)(a2 + 20);
v18 = a2 + 52;
*(_DWORD *)(a1 + 332) = *(_DWORD *)(v14 + 20);
v19 = *(_DWORD *)(v14 + 12);
if ( v17 )
{
v20 = 0;
while ( (_DWORD)v7 != 24 )
{
if ( (_DWORD)v7 == 25 )
{
v22 = 16;
v23 = v15 >> 2;
LABEL_20:
v24 = v16 >> 2;
goto LABEL_21;
}
if ( (_DWORD)v7 == 26 )
{
v21 = cocos2d::CCConfiguration::sharedConfiguration();
if ( !cocos2d::CCConfiguration::supportsBGRA8888(v21) )
return 0;
}
v20 = *(unsigned int *)(a1 + 312);
v22 = 1;
v23 = v15;
v24 = v16;
LABEL_21:
if ( v23 < 2 )
v23 = 2;
if ( v24 < 2 )
v24 = 2;
v25 = v23 * v24 * ((unsigned int)(v22 * v19) >> 3);
v26 = v17 - v4;
if ( v17 - v4 > v25 )
v26 = v25;
v27 = v4;
v4 += v26;
v15 >>= 1;
v16 >>= 1;
*(_QWORD *)(a1 + 16 * v20 + 56) = v18 + v27;
*(_DWORD *)(a1 + 16 * (*(unsigned int *)(a1 + 312) + 4LL)) = v26;
v20 = (unsigned int)(*(_DWORD *)(a1 + 312) + 1);
*(_DWORD *)(a1 + 312) = v20;
if ( v4 >= v17 )
return 1;
if ( v15 <= 1 )
v15 = 1;
if ( v16 <= 1 )
v16 = 1;
}
v22 = 32;
v23 = v15 >> 3;
goto LABEL_20;
}
return 1;
}