//
// sub_1800E13A0 from 0x1800e13a0 to 0x1800e15d0 (560 bytes)
//
// 2 xrefs:
// > sub_1800D7E10 @ 0x1800d7eb1
// > ??> @ 0x1801c519c
//
// 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:36 +0000
//
__int64 __fastcall sub_1800E13A0(_QWORD *a1, __int64 a2, _DWORD *a3)
{
__int64 v4; // rdi
__int64 v7; // r9
__int64 v9; // rax
__int64 (__fastcall *v10)(__int64 *, __int64); // r11
unsigned int v11; // edx
int v12; // eax
int v13; // r9d
int v14; // eax
__int64 v15; // rcx
__int64 v16; // rdx
__int64 v17; // rax
__int64 v18; // [rsp+30h] [rbp-B8h] BYREF
int v19; // [rsp+38h] [rbp-B0h]
int v20; // [rsp+3Ch] [rbp-ACh]
int v21; // [rsp+40h] [rbp-A8h]
int v22; // [rsp+44h] [rbp-A4h]
int v23; // [rsp+48h] [rbp-A0h]
int v24; // [rsp+4Ch] [rbp-9Ch]
int v25; // [rsp+50h] [rbp-98h]
int v26; // [rsp+54h] [rbp-94h]
v4 = 0;
v7 = (unsigned int)(a3[6] + a3[7] + a3[8] + a3[9]);
if ( *(_DWORD *)a2 == 196610 )
{
sub_1800DB260(0x10006u, "OSMesa: OpenGL ES is not available on OSMesa", a2, v7);
return 0;
}
v9 = *(_QWORD *)(a2 + 40);
if ( v9 )
v4 = *(_QWORD *)(v9 + 688);
v10 = (__int64 (__fastcall *)(__int64 *, __int64))qword_1801B62B0;
if ( qword_1801B62B0 )
{
v11 = 8;
v20 = a3[4];
v22 = a3[5];
v12 = *(_DWORD *)(a2 + 28);
v18 = 0x190800000022LL;
v19 = 48;
v21 = 49;
v23 = 50;
v24 = v7;
if ( v12 == 204801 )
{
v26 = 52;
}
else
{
if ( v12 != 204802 )
{
LABEL_11:
v13 = *(_DWORD *)(a2 + 8);
if ( *(_QWORD *)(a2 + 8) != 1 )
{
*((_DWORD *)&v18 + v11) = 54;
v14 = *(_DWORD *)(a2 + 12);
*((_DWORD *)&v18 + v11 + 1) = v13;
v15 = v11 + 2;
v16 = v11 + 3;
*((_DWORD *)&v18 + v15) = 55;
*((_DWORD *)&v18 + v16) = v14;
v11 = v16 + 1;
}
if ( *(_DWORD *)(a2 + 16) )
{
sub_1800DB260(0x10007u, "OSMesa: Forward-compatible contexts not supported");
return 0;
}
*(__int64 *)((char *)&v18 + 4 * v11) = 0;
v17 = v10(&v18, v4);
goto LABEL_19;
}
v26 = 53;
}
v11 = 10;
v25 = 51;
goto LABEL_11;
}
if ( *(_DWORD *)(a2 + 28) )
{
sub_1800DB260(0x10007u, "OSMesa: OpenGL profiles unavailable", a2, v7);
return 0;
}
v17 = qword_1801B62A8(6408, (unsigned int)a3[4], (unsigned int)a3[5], v7, v4);
LABEL_19:
a1[86] = v17;
if ( v17 )
{
a1[73] = sub_1800E1860;
a1[74] = nullsub_1;
a1[75] = nullsub_1;
a1[76] = sub_1800E1840;
a1[77] = &sub_1800E1850;
a1[78] = sub_1800E17F0;
return 1;
}
else
{
sub_1800DB260(0x10007u, "OSMesa: Failed to create context");
return 0;
}
}