//
// sub_1800E0D20 from 0x1800e0d20 to 0x1800e1090 (880 bytes)
//
// 5 xrefs:
// > sub_1800E0280 @ 0x1800e02f3
// > ??> @ 0x18014c764
// > ??> @ 0x18014c774
// > ??> @ 0x18014c788
// > ??> @ 0x1801c5124
//
// 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_1800E0D20(_DWORD *a1, int *a2, _QWORD *a3)
{
unsigned int v3; // r15d
_DWORD *v4; // r13
int v5; // r12d
int v6; // r14d
_QWORD *v8; // rsi
char *v9; // rax
unsigned int v10; // ecx
int v11; // edi
char *v12; // r15
__int64 v13; // rbx
int *v14; // rax
int *v15; // rbx
const char *v16; // rdx
unsigned int v17; // ecx
unsigned int v18; // [rsp+20h] [rbp-60h]
int v19; // [rsp+24h] [rbp-5Ch] BYREF
char v20[4]; // [rsp+28h] [rbp-58h] BYREF
int v21; // [rsp+2Ch] [rbp-54h] BYREF
int v22; // [rsp+30h] [rbp-50h] BYREF
int v23; // [rsp+34h] [rbp-4Ch] BYREF
int v24; // [rsp+38h] [rbp-48h] BYREF
int v25; // [rsp+3Ch] [rbp-44h] BYREF
int v26; // [rsp+40h] [rbp-40h] BYREF
int v27; // [rsp+44h] [rbp-3Ch] BYREF
int v28; // [rsp+48h] [rbp-38h] BYREF
void *Block; // [rsp+50h] [rbp-30h]
_QWORD *v30; // [rsp+58h] [rbp-28h]
int v34; // [rsp+C8h] [rbp+48h] BYREF
v3 = 0;
v4 = a1;
v5 = 0;
if ( *a1 == 196610 )
{
v6 = 1;
if ( a1[2] != 1 )
v6 = 4;
}
else
{
v6 = 8;
}
if ( a2[11] )
{
sub_1800DB260(0x10009u, "EGL: Stereo rendering not supported");
return 0;
}
eglGetConfigs(qword_1801B61E8, 0, 0, &v34);
if ( !v34 )
{
sub_1800DB260(0x10006u, "EGL: No EGLConfigs returned");
return 0;
}
v8 = calloc(v34, 8u);
v30 = v8;
eglGetConfigs(qword_1801B61E8, v8, (unsigned int)v34, &v34);
v9 = (char *)calloc(v34, 0x48u);
v10 = 0;
Block = v9;
v11 = 0;
v18 = 0;
if ( v34 <= 0 )
goto LABEL_19;
v12 = v9 + 8;
do
{
v13 = *v8;
eglGetConfigAttrib(qword_1801B61E8, *v8, 12351, &v19);
if ( v19 != 12430 )
goto LABEL_16;
eglGetConfigAttrib(qword_1801B61E8, v13, 12339, v20);
if ( (v20[0] & 4) == 0 )
goto LABEL_16;
eglGetConfigAttrib(qword_1801B61E8, v13, 12352, &v21);
if ( (v6 & v21) == 0 )
{
v5 = 1;
LABEL_16:
v10 = v18;
goto LABEL_17;
}
eglGetConfigAttrib(qword_1801B61E8, v13, 12324, &v22);
*((_DWORD *)v12 - 2) = v22;
eglGetConfigAttrib(qword_1801B61E8, v13, 12323, &v23);
*((_DWORD *)v12 - 1) = v23;
eglGetConfigAttrib(qword_1801B61E8, v13, 12322, &v24);
*(_DWORD *)v12 = v24;
eglGetConfigAttrib(qword_1801B61E8, v13, 12321, &v25);
*((_DWORD *)v12 + 1) = v25;
eglGetConfigAttrib(qword_1801B61E8, v13, 12325, &v26);
*((_DWORD *)v12 + 2) = v26;
eglGetConfigAttrib(qword_1801B61E8, v13, 12326, &v27);
*((_DWORD *)v12 + 3) = v27;
eglGetConfigAttrib(qword_1801B61E8, v13, 12337, &v28);
*((_DWORD *)v12 + 10) = v28;
v10 = v18 + 1;
*((_DWORD *)v12 + 12) = a2[14];
*((_QWORD *)v12 + 7) = v13;
v12 += 72;
++v18;
LABEL_17:
++v11;
++v8;
}
while ( v11 < v34 );
v4 = a1;
v3 = 0;
v9 = (char *)Block;
v8 = v30;
LABEL_19:
v14 = sub_1800D6EF0(a2, (__int64)v9, v10);
v15 = v14;
if ( v14 )
{
*a3 = *((_QWORD *)v14 + 8);
goto LABEL_30;
}
if ( !v5 )
{
v16 = "EGL: Failed to find a suitable EGLConfig";
v17 = 65545;
goto LABEL_29;
}
if ( *v4 == 196610 )
{
v16 = "EGL: Failed to find support for OpenGL ES 1.x";
v17 = 65542;
if ( v4[2] != 1 )
v16 = "EGL: Failed to find support for OpenGL ES 2 or later";
LABEL_29:
sub_1800DB260(v17, v16);
}
else
{
sub_1800DB260(0x10006u, "EGL: Failed to find support for OpenGL");
}
LABEL_30:
free(v8);
free(Block);
LOBYTE(v3) = v15 != nullptr;
return v3;
}