//
// cocos2d::ZipUtils::ccDecodeEncodedPvr from 0x1800a3390 to 0x1800a357b (491 bytes)
//
// 5 xrefs:
// > cocos2d::ZipUtils::ccInflateCCZFile @ 0x1800a37bb
// > ??> @ 0x18013fa48
// > ??> @ 0x18013fa8c
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b7a70
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
void __fastcall cocos2d::ZipUtils::ccDecodeEncodedPvr(unsigned int *a1, int a2)
{
unsigned int *v2; // r14
__int64 v3; // r12
unsigned int v4; // eax
unsigned int v5; // r11d
int v6; // r15d
unsigned int *v7; // rdi
unsigned int __near **v8; // r10
__int64 v9; // rbp
__int64 v10; // rsi
__int64 v11; // rbx
unsigned int v12; // r8d
__int64 v13; // rcx
int v14; // r9d
int v15; // r11d
__int64 v16; // rdx
__int64 v17; // r8
__int64 v18; // rcx
int v19; // eax
__int64 v20; // rdx
__int64 v21; // rcx
__int64 v22; // rax
v2 = a1;
v3 = a2;
if ( !cocos2d::ZipUtils::s_bEncryptionKeyIsValid )
{
v4 = dword_1801A9A5C;
v5 = 0;
v6 = 6;
do
{
v5 -= 1640531527;
v7 = (unsigned int *)&unk_1801A8A64;
v8 = &cocos2d::ZipUtils::s_uEncryptionKey;
v9 = 1023;
v10 = (v5 >> 2) & 3;
v11 = 0;
do
{
v12 = *v7++;
v8 = (unsigned int __near **)((char *)v8 + 4);
v13 = v10 ^ v11++ & 3;
*((_DWORD *)v8 - 1) += ((v5 ^ v12) + (*((_DWORD *)&cocos2d::ZipUtils::s_uEncryptedPvrKeyParts + v13) ^ v4))
^ (((16 * v4) ^ (v12 >> 3)) + ((v4 >> 5) ^ (4 * v12)));
v4 = *((_DWORD *)v8 - 1);
--v9;
}
while ( v9 );
v4 = (((v5 ^ (unsigned int)cocos2d::ZipUtils::s_uEncryptionKey)
+ (*((_DWORD *)&cocos2d::ZipUtils::s_uEncryptedPvrKeyParts + (v10 ^ 3)) ^ v4))
^ (((16 * v4) ^ ((unsigned int)cocos2d::ZipUtils::s_uEncryptionKey >> 3))
+ ((v4 >> 5) ^ (4 * (_DWORD)cocos2d::ZipUtils::s_uEncryptionKey))))
+ dword_1801A9A5C;
dword_1801A9A5C = v4;
--v6;
}
while ( v6 );
v2 = a1;
cocos2d::ZipUtils::s_bEncryptionKeyIsValid = 1;
}
v14 = 0;
v15 = 0;
if ( a2 > 0LL )
{
v16 = 0;
v17 = 0;
do
{
if ( v16 >= 512 )
break;
v18 = v17 + 1;
v2[v16] ^= *((_DWORD *)&cocos2d::ZipUtils::s_uEncryptionKey + v17);
++v15;
++v16;
v19 = v14 + 1;
v14 = 0;
if ( v17 + 1 < 1024 )
v14 = v19;
v17 = 0;
if ( v18 < 1024 )
v17 = v18;
}
while ( v16 < v3 );
}
v20 = v15;
if ( v15 < v3 )
{
v21 = v14;
do
{
v2[v20] ^= *((_DWORD *)&cocos2d::ZipUtils::s_uEncryptionKey + v21);
v22 = v21 + 1;
v21 = 0;
v20 += 64;
if ( v22 < 1024 )
v21 = v22;
}
while ( v20 < v3 );
}
}