//
// sub_1800AA460 from 0x1800aa460 to 0x1800aa68f (559 bytes)
//
// 2 xrefs:
// > sub_1800AA090 @ 0x1800aa372
// > ??> @ 0x1801b7f50
//
// 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
//
char __fastcall sub_1800AA460(__int64 a1, __int64 a2)
{
int v3; // edx
unsigned int v4; // r15d
cocos2d::CCConfiguration *v6; // rax
__int64 v7; // r14
cocos2d::CCConfiguration *v8; // rax
unsigned __int8 v9; // al
_QWORD *v10; // rcx
unsigned int v11; // edx
__int64 v12; // rax
unsigned int v14; // ebx
unsigned int v15; // edi
unsigned int v16; // r12d
__int64 v17; // rsi
__int64 v18; // rcx
int v19; // r13d
cocos2d::CCConfiguration *v20; // rax
int v21; // r8d
unsigned int v22; // ecx
unsigned int v23; // edx
unsigned int v24; // eax
unsigned int v25; // edx
unsigned int v26; // eax
__int64 v27; // rcx
v3 = *(_DWORD *)(a2 + 44);
v4 = 0;
if ( word_1801A3250 != (_WORD)v3 )
return 0;
if ( byte_1801A3252 != BYTE2(v3) )
return 0;
if ( byte_1801A3253 != HIBYTE(v3) )
return 0;
v6 = cocos2d::CCConfiguration::sharedConfiguration();
v7 = *(unsigned __int8 *)(a2 + 16);
if ( !cocos2d::CCConfiguration::supportsNPOT(v6)
&& (*(_DWORD *)(a2 + 8) != (unsigned int)sub_180095970(*(_DWORD *)(a2 + 8))
|| *(_DWORD *)(a2 + 4) != (unsigned int)sub_180095970(*(_DWORD *)(a2 + 4))) )
{
return 0;
}
v8 = cocos2d::CCConfiguration::sharedConfiguration();
v9 = cocos2d::CCConfiguration::supportsPVRTC(v8);
v10 = &unk_1801A3260;
v11 = 2 * v9 + 9;
v12 = 0;
while ( *v10 != v7 )
{
v12 = (unsigned int)(v12 + 1);
v10 += 2;
if ( (unsigned int)v12 >= v11 )
return 0;
}
*(_QWORD *)(a1 + 336) = *((_QWORD *)&unk_1801A3260 + 2 * v12 + 1);
*(_DWORD *)(a1 + 312) = 0;
v14 = *(_DWORD *)(a2 + 8);
*(_DWORD *)(a1 + 316) = v14;
v15 = *(_DWORD *)(a2 + 4);
*(_DWORD *)(a1 + 320) = v15;
*(_BYTE *)(a1 + 328) = *(_DWORD *)(a2 + 40) != 0;
v16 = *(_DWORD *)(a2 + 20);
v17 = a2 + 52;
v18 = *(_QWORD *)(a1 + 336);
*(_DWORD *)(a1 + 332) = *(_DWORD *)(v18 + 20);
v19 = *(_DWORD *)(v18 + 12);
if ( v16 )
{
do
{
if ( (_DWORD)v7 == 24 )
{
v21 = 32;
v22 = v14 >> 3;
}
else
{
if ( (_DWORD)v7 != 25 )
{
if ( (_DWORD)v7 == 26 )
{
v20 = cocos2d::CCConfiguration::sharedConfiguration();
if ( !cocos2d::CCConfiguration::supportsBGRA8888(v20) )
return 0;
}
v21 = 1;
v22 = v14;
v23 = v15;
goto LABEL_20;
}
v21 = 16;
v22 = v14 >> 2;
}
v23 = v15 >> 2;
LABEL_20:
if ( v22 < 2 )
v22 = 2;
if ( v23 < 2 )
v23 = 2;
v24 = v23 * ((unsigned int)(v21 * v19) >> 3);
v25 = v16 - v4;
v26 = v22 * v24;
if ( v16 - v4 > v26 )
v25 = v26;
v14 >>= 1;
v27 = v17 + v4;
v15 >>= 1;
v4 += v25;
*(_QWORD *)(a1 + 16LL * *(unsigned int *)(a1 + 312) + 56) = v27;
*(_DWORD *)(a1 + 16 * ((unsigned int)(*(_DWORD *)(a1 + 312))++ + 4LL)) = v25;
if ( v14 <= 1 )
v14 = 1;
if ( v15 <= 1 )
v15 = 1;
}
while ( v4 < v16 );
}
return 1;
}