//
// sub_1800DDC10 from 0x1800ddc10 to 0x1800de0dd (1229 bytes)
//
// 2 xrefs:
// > sub_1800D6480 @ 0x1800d64fd
// > ??> @ 0x1801bae84
//
// 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_1800DDC10(_QWORD *a1, int *a2, __int64 a3)
{
unsigned int v4; // ebx
__int64 v7; // r15
__int64 v9; // rax
unsigned int v10; // eax
const char *v11; // rax
unsigned int v12; // eax
const char *v13; // rax
int v14; // ecx
int v15; // r9d
int v16; // eax
int v17; // ecx
int v18; // r8d
int v19; // eax
int v20; // edx
int v21; // eax
__int64 v22; // rax
__int64 v23; // rcx
__int64 v24; // rax
__int64 v25; // rcx
__int64 v26; // rax
__int64 v27; // rcx
int v28; // eax
__int64 v29; // rcx
__int64 v30; // rcx
__int64 v31; // rax
__int64 v32; // rbx
__int64 v33; // rdx
__int64 v34; // rax
unsigned int v35; // eax
const char *v36; // rax
unsigned int v37; // ecx
__int64 v38; // rax
__int64 v39; // rcx
__int64 v40; // r8
__int64 v41; // rax
__int64 v42; // rcx
__int64 v43; // rax
unsigned int v44; // eax
const char *v45; // rax
bool v46; // zf
const CHAR **v47; // r14
const CHAR *v48; // rbx
__int64 v49; // rdi
HMODULE LibraryA; // rax
__int64 v51; // [rsp+20h] [rbp-E0h] BYREF
int v52; // [rsp+30h] [rbp-D0h] BYREF
_DWORD v53[39]; // [rsp+34h] [rbp-CCh]
_QWORD v54[3]; // [rsp+D0h] [rbp-30h] BYREF
_QWORD v55[3]; // [rsp+E8h] [rbp-18h] BYREF
v4 = 0;
v7 = 0;
if ( !qword_1801AC168 )
{
sub_1800D3530(0x10006u, "EGL: API not available");
return 0;
}
v9 = *((_QWORD *)a2 + 5);
if ( v9 )
v7 = *(_QWORD *)(v9 + 664);
if ( !(unsigned int)sub_1800DE6B0(a2, a3, &v51) )
return 0;
if ( *a2 == 196610 )
{
if ( !(unsigned int)qword_1801AC1D0(12448) )
{
v10 = qword_1801AC1B8();
v11 = (const char *)sub_1800DEAE0(v10);
sub_1800D3530(0x10006u, "EGL: Failed to bind OpenGL ES: %s", v11);
return 0;
}
}
else if ( !(unsigned int)qword_1801AC1D0(12450) )
{
v12 = qword_1801AC1B8();
v13 = (const char *)sub_1800DEAE0(v12);
sub_1800D3530(0x10006u, "EGL: Failed to bind OpenGL: %s", v13);
return 0;
}
v14 = *a2;
if ( dword_1801AC17C )
{
v15 = 0;
v16 = 0;
if ( v14 == 196609 )
{
v17 = a2[7];
v16 = a2[4] != 0 ? 2 : 0;
if ( v17 == 204801 )
{
v15 = 1;
}
else if ( v17 == 204802 )
{
v15 = 2;
}
}
v18 = v16 | 1;
if ( !a2[5] )
v18 = v16;
v19 = a2[8];
switch ( v19 )
{
case 0:
goto LABEL_27;
case 200705:
v53[0] = 12734;
break;
case 200706:
v53[0] = 12735;
break;
default:
LABEL_26:
v18 |= 4u;
LABEL_27:
v20 = a2[2];
if ( v20 != 1 || a2[3] )
{
v53[v4 - 1] = 12440;
v21 = a2[3];
v53[v4] = v20;
v53[v4 + 1] = 12539;
v53[v4 + 2] = v21;
v4 += 4;
}
if ( a2[6] && dword_1801AC180 )
{
v22 = v4;
v23 = v4 + 1;
v4 += 2;
v53[v22 - 1] = 12723;
v53[v23 - 1] = 1;
}
if ( v15 )
{
v24 = v4;
v25 = v4 + 1;
v4 += 2;
v53[v24 - 1] = 12541;
v53[v25 - 1] = v15;
}
if ( v18 )
{
v26 = v4;
v27 = v4 + 1;
v4 += 2;
v53[v26 - 1] = 12540;
v53[v27 - 1] = v18;
}
goto LABEL_39;
}
v4 = 2;
v52 = 12733;
goto LABEL_26;
}
if ( v14 == 196610 )
{
v4 = 2;
v53[0] = a2[2];
v52 = 12440;
}
LABEL_39:
if ( !dword_1801AC18C )
goto LABEL_45;
v28 = a2[9];
if ( v28 == 217090 )
{
v29 = v4 + 1;
v53[v4 - 1] = 8343;
v53[v29 - 1] = 0;
}
else
{
if ( v28 != 217089 )
goto LABEL_45;
v29 = v4 + 1;
v53[v4 - 1] = 8343;
v53[v29 - 1] = 8344;
}
v4 = v29 + 1;
LABEL_45:
v30 = qword_1801AC168;
v31 = v4;
v32 = v51;
v33 = v51;
v53[v31 - 1] = 12344;
v53[v31] = 12344;
v34 = qword_1801AC1D8(v30, v33, v7, &v52);
a1[83] = v34;
if ( v34 )
{
v37 = 0;
if ( *(_DWORD *)(a3 + 52) && dword_1801AC184 )
{
v52 = 12445;
v37 = 2;
v53[0] = 12425;
}
if ( !*(_DWORD *)(a3 + 56) )
{
v38 = v37;
v39 = v37 + 1;
v53[v38 - 1] = 12422;
v53[v39 - 1] = 12421;
v37 = v39 + 1;
}
v40 = a1[110];
v41 = v37;
v42 = qword_1801AC168;
v53[v41 - 1] = 12344;
v53[v41] = 12344;
v43 = qword_1801AC1F0(v42, v32, v40, &v52);
a1[84] = v43;
if ( v43 )
{
a1[82] = v32;
if ( dword_1801AC188 )
goto LABEL_65;
v46 = *a2 == 196610;
v55[0] = "GLESv1_CM.dll";
v55[1] = "libGLES_CM.dll";
v54[0] = "GLESv2.dll";
v54[1] = "libGLESv2.dll";
v55[2] = 0;
v54[2] = 0;
v51 = 0;
if ( v46 )
{
v47 = (const CHAR **)v54;
if ( a2[2] == 1 )
v47 = (const CHAR **)v55;
v48 = *v47;
if ( *v47 )
{
v49 = 0;
do
{
if ( dword_1801AC178 == (strncmp(v48, "lib", 3u) == 0) )
{
LibraryA = LoadLibraryA(v48);
a1[85] = LibraryA;
if ( LibraryA )
break;
}
v48 = v47[++v49];
}
while ( v48 );
}
}
if ( a1[85] )
{
LABEL_65:
a1[73] = sub_1800DEC20;
a1[74] = sub_1800DECD0;
a1[75] = sub_1800DED20;
a1[76] = sub_1800DEAA0;
a1[77] = sub_1800DEBD0;
a1[78] = sub_1800DEA20;
return 1;
}
else
{
sub_1800D3530(0x10006u, "EGL: Failed to load client library");
return 0;
}
}
else
{
v44 = qword_1801AC1B8();
v45 = (const char *)sub_1800DEAE0(v44);
sub_1800D3530(0x10008u, "EGL: Failed to create window surface: %s", v45);
return 0;
}
}
else
{
v35 = qword_1801AC1B8();
v36 = (const char *)sub_1800DEAE0(v35);
sub_1800D3530(0x10007u, "EGL: Failed to create context: %s", v36);
return 0;
}
}