//
// sub_1800D2980 from 0x1800d2980 to 0x1800d2bbf (575 bytes)
//
// 2 xrefs:
// > sub_1800D44F0 @ 0x1800d4670
// > ??> @ 0x1801ba4d0
//
// 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
//
__int64 __fastcall sub_1800D2980(int *a1)
{
int v1; // r8d
int v3; // edx
__int64 v4; // rax
int v5; // r8d
int v6; // edx
int v7; // r9d
int v8; // r8d
int v9; // eax
int v10; // r8d
int v11; // r8d
v1 = a1[1];
if ( (unsigned int)(v1 - 221185) > 2 )
{
sub_1800D3530(65539, "Invalid context creation API 0x%08X", v1);
return 0;
}
v3 = *a1;
if ( *a1 && (unsigned int)(v3 - 196609) > 1 )
{
sub_1800D3530(65539, "Invalid client API 0x%08X", v3);
return 0;
}
v4 = *((_QWORD *)a1 + 5);
if ( v4 )
{
if ( !v3 || !*(_DWORD *)(v4 + 512) )
{
sub_1800D3530(65546, nullptr);
return 0;
}
if ( v1 != *(_DWORD *)(v4 + 516) )
{
sub_1800D3530(65539, "Context creation APIs do not match between contexts");
return 0;
}
}
if ( v3 == 196609 )
{
v5 = a1[2];
if ( v5 < 1 || (v6 = a1[3], v6 < 0) || v5 == 1 && v6 > 5 || v5 == 2 && v6 > 1 || v5 == 3 && v6 > 3 )
{
sub_1800D3530(65540, "Invalid OpenGL version %i.%i", v5, a1[3]);
return 0;
}
v7 = a1[7];
if ( v7 )
{
if ( (unsigned int)(v7 - 204801) > 1 )
{
sub_1800D3530(65539, "Invalid OpenGL profile 0x%08X", v7);
return 0;
}
if ( v5 <= 2 || v5 == 3 && v6 < 2 )
{
sub_1800D3530(65540, "Context profiles are only defined for OpenGL version 3.2 and above");
return 0;
}
}
if ( a1[4] && v5 <= 2 )
{
sub_1800D3530(65540, "Forward-compatibility is only defined for OpenGL version 3.0 and above");
return 0;
}
}
else if ( v3 == 196610 )
{
if ( (v8 = a1[2], v8 < 1) || (v9 = a1[3], v9 < 0) || v8 == 1 && v9 > 1 || v8 == 2 && v9 > 0 )
{
sub_1800D3530(65540, "Invalid OpenGL ES version %i.%i", v8, a1[3]);
return 0;
}
}
v10 = a1[8];
if ( v10 && (unsigned int)(v10 - 200705) > 1 )
{
sub_1800D3530(65539, "Invalid context robustness mode 0x%08X", v10);
return 0;
}
else
{
v11 = a1[9];
if ( v11 && (unsigned int)(v11 - 217089) > 1 )
{
sub_1800D3530(65539, "Invalid context release behavior 0x%08X", v11);
return 0;
}
else
{
return 1;
}
}
}