//
// GameObject::getColorKey from 0x14019cd30 to 0x14019d1df (1199 bytes)
//
// 4 xrefs:
// > GameObject::getColorKey @ 0x14019cf34
// > LevelEditorLayer::getLevelString @ 0x1402d6e91
// > PlayLayer::processCreateObjectsFromSetup @ 0x1403ad5e0
// > ??> @ 0x1406cbe50
//
// 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
//
// Hidden C++ exception states: #wind=2
_QWORD *__fastcall GameObject::getColorKey(__int64 a1, _QWORD *a2, bool a3, unsigned __int8 a4)
{
bool v5; // r15
unsigned __int64 v8; // rdi
unsigned int *v9; // rdx
unsigned int v10; // eax
__int64 v11; // rdx
unsigned int *v12; // rdi
unsigned int v13; // eax
unsigned int v14; // edi
__int64 v15; // r8
__int64 ColorKey; // rax
__int64 v17; // rax
int v18; // esi
int v19; // r14d
__int64 v20; // rsi
__int64 v21; // rax
__int64 v22; // rdx
_BYTE *v23; // rax
size_t v24; // r8
__int128 v26; // [rsp+20h] [rbp-E0h] BYREF
_BYTE v27[16]; // [rsp+38h] [rbp-C8h] BYREF
_BYTE v28[40]; // [rsp+48h] [rbp-B8h] BYREF
_BYTE v29[528]; // [rsp+70h] [rbp-90h] BYREF
v5 = a3;
*(_QWORD *)&v26 = a2;
v8 = 0;
if ( !a3 )
v5 = *(_BYTE *)(a1 + 1046) != 0;
fmt::BasicWriter::BasicWriter(v29);
if ( v5 )
{
v9 = *(unsigned int **)(a1 + 1104);
if ( v9 )
{
v10 = v9[1];
v11 = *v9;
if ( v10 == (_DWORD)v11 || !(_DWORD)v11 )
v11 = v10;
}
else
{
v11 = 0;
}
fmt::BasicWriter::operator<<(v29, v11);
if ( *(_BYTE *)(*(_QWORD *)(a1 + 1104) + 32LL) )
{
*(_QWORD *)&v26 = &unk_14055D9E4;
*((_QWORD *)&v26 + 1) = 0;
fmt::BasicWriter::operator<<(v29, &v26);
fmt::BasicWriter::operator<<(v29);
fmt::BasicWriter::operator<<(v29);
fmt::BasicWriter::operator<<(v29);
fmt::BasicWriter::operator<<(v29, *(unsigned __int8 *)(*(_QWORD *)(a1 + 1104) + 28LL));
fmt::BasicWriter::operator<<(v29, *(unsigned __int8 *)(*(_QWORD *)(a1 + 1104) + 29LL));
}
if ( *(_BYTE *)(a1 + 1046) )
{
*(_QWORD *)&v26 = &unk_14055D9E8;
*((_QWORD *)&v26 + 1) = 0;
fmt::BasicWriter::operator<<(v29, &v26);
}
goto LABEL_24;
}
v12 = *(unsigned int **)(a1 + 1112);
if ( !v12 )
{
fmt::BasicWriter::operator<<(v29, 0);
LABEL_20:
v8 = 0;
goto LABEL_21;
}
v13 = v12[1];
v14 = *v12;
if ( v13 == v14 || !v14 )
v14 = v13;
fmt::BasicWriter::operator<<(v29, v14);
if ( v14 != 1012 )
goto LABEL_20;
v26 = (unsigned __int64)&unk_14055D9E4;
v8 = 0;
fmt::BasicWriter::operator<<(v29, &v26);
LOBYTE(v15) = 1;
ColorKey = GameObject::getColorKey(a1, v28, v15, a4);
v26 = *(_OWORD *)fmt::BasicStringRef::BasicStringRef(v27, ColorKey);
fmt::BasicWriter::operator<<(v29, &v26);
sub_14003A830((__int64)v28);
LABEL_21:
v17 = *(_QWORD *)(a1 + 1112);
if ( v17 && *(_BYTE *)(v17 + 32) )
{
*(_QWORD *)&v26 = &unk_14055D9E4;
*((_QWORD *)&v26 + 1) = 0;
fmt::BasicWriter::operator<<(v29, &v26);
fmt::BasicWriter::operator<<(v29);
fmt::BasicWriter::operator<<(v29);
fmt::BasicWriter::operator<<(v29);
fmt::BasicWriter::operator<<(v29, *(unsigned __int8 *)(*(_QWORD *)(a1 + 1112) + 28LL));
fmt::BasicWriter::operator<<(v29, *(unsigned __int8 *)(*(_QWORD *)(a1 + 1112) + 29LL));
}
LABEL_24:
*(_QWORD *)&v26 = &unk_14055D9E4;
*((_QWORD *)&v26 + 1) = 0;
fmt::BasicWriter::operator<<(v29, &v26);
if ( a4 )
{
v18 = 0;
if ( *(__int16 *)(a1 + 1192) > 0 )
{
*(_QWORD *)&v26 = &unk_14055D9E4;
*((_QWORD *)&v26 + 1) = 0;
do
{
fmt::BasicWriter::operator<<(v29, (unsigned int)*(__int16 *)(v8 + *(_QWORD *)(a1 + 1184)));
v26 = (unsigned __int64)&unk_14055D9E4;
fmt::BasicWriter::operator<<(v29, &v26);
++v18;
v8 += 2LL;
}
while ( v18 < *(__int16 *)(a1 + 1192) );
}
}
else
{
v19 = 0;
if ( *(__int16 *)(a1 + 1176) > 0 )
{
*(_QWORD *)&v26 = &unk_14055D9E4;
*((_QWORD *)&v26 + 1) = 0;
v20 = 0;
do
{
if ( v8 <= 9 && (v21 = *(_QWORD *)(a1 + 1168)) != 0 )
v22 = (unsigned int)*(__int16 *)(v20 + v21);
else
v22 = 0;
fmt::BasicWriter::operator<<(v29, v22);
v26 = (unsigned __int64)&unk_14055D9E4;
fmt::BasicWriter::operator<<(v29, &v26);
++v19;
++v8;
v20 += 2;
}
while ( v19 < *(__int16 *)(a1 + 1176) );
}
}
*(_QWORD *)&v26 = &unk_14055D9E4;
*((_QWORD *)&v26 + 1) = 0;
fmt::BasicWriter::operator<<(v29, &v26);
fmt::BasicWriter::operator<<(v29, v5);
v23 = (_BYTE *)fmt::BasicWriter::c_str(v29);
*(_OWORD *)a2 = 0;
a2[2] = 0;
a2[3] = 0;
v24 = -1;
do
++v24;
while ( v23[v24] );
sub_14003A930(a2, v23, v24);
fmt::BasicWriter::~BasicWriter(v29);
return a2;
}