//
// sub_1800A9E90 from 0x1800a9e90 to 0x1800aa083 (499 bytes)
//
// 2 xrefs:
// > sub_1800AA090 @ 0x1800aa392
// > ??> @ 0x1801b7f38
//
// 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_1800A9E90(__int64 a1)
{
unsigned int v2; // ebx
unsigned int height; // edi
cocos2d *v4; // rcx
GLint v5; // r8d
__int64 v6; // rax
__int64 v7; // rsi
unsigned int v8; // r14d
GLenum format; // r12d
GLenum type; // r13d
char v11; // r15
cocos2d::CCConfiguration *v12; // rax
v2 = *(_DWORD *)(a1 + 316);
height = *(_DWORD *)(a1 + 320);
if ( *(_DWORD *)(a1 + 312) )
{
v4 = (cocos2d *)*(unsigned int *)(a1 + 324);
if ( (_DWORD)v4 )
cocos2d::ccGLDeleteTexture(v4);
glPixelStorei(0xCF5u, 1);
glGenTextures(1, (GLuint *)(a1 + 324));
cocos2d::ccGLBindTexture2D((cocos2d *)*(unsigned int *)(a1 + 324));
v5 = 9729;
if ( *(_DWORD *)(a1 + 312) != 1 )
v5 = 9985;
glTexParameteri(0xDE1u, 0x2801u, v5);
glTexParameteri(0xDE1u, 0x2800u, 9729);
glTexParameteri(0xDE1u, 0x2802u, 33071);
glTexParameteri(0xDE1u, 0x2803u, 33071);
}
v6 = *(_QWORD *)(a1 + 336);
v7 = 0;
v8 = *(_DWORD *)v6;
format = *(_DWORD *)(v6 + 4);
type = *(_DWORD *)(v6 + 8);
v11 = *(_BYTE *)(v6 + 16);
if ( !*(_DWORD *)(a1 + 312) )
return 1;
while ( 1 )
{
if ( v11 )
{
v12 = cocos2d::CCConfiguration::sharedConfiguration();
if ( !(unsigned __int8)cocos2d::CCConfiguration::supportsPVRTC(v12) )
return 0;
_glewCompressedTexImage2D(
3553,
(unsigned int)v7,
v8,
v2,
height,
0,
*(_DWORD *)(a1 + 16 * (v7 + 4)),
*(_QWORD *)(a1 + 16LL * (unsigned int)v7 + 56));
}
else
{
glTexImage2D(0xDE1u, v7, v8, v2, height, 0, format, type, *(const GLvoid **)(a1 + 16LL * (unsigned int)v7 + 56));
}
if ( (_DWORD)v7 && v2 == height )
sub_180095970(v2);
if ( glGetError() )
break;
v2 >>= 1;
v7 = (unsigned int)(v7 + 1);
height >>= 1;
if ( v2 <= 1 )
v2 = 1;
if ( height <= 1 )
height = 1;
if ( (unsigned int)v7 >= *(_DWORD *)(a1 + 312) )
return 1;
}
return 0;
}