//
// sub_7C8A4 from 0x7c8a4 to 0x7c95c (184 bytes)
//
// 2 xrefs:
// > sub_7BA6C @ 0x7bde0
// > sub_7BF6C @ 0x7c168
//
// 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
//
int __fastcall sub_7C8A4(_DWORD *a1, unsigned __int8 *a2, int a3, int a4)
{
int v5; // r0
size_t v9; // r2
int v10; // r3
int v11; // r1
unsigned __int8 *v12; // r0
int v13; // r0
int v14; // r0
int result; // r0
int v16; // r1
int v17; // r3
v5 = a1[56];
v9 = *(_DWORD *)(v5 + 18612);
if ( !v9 )
{
result = sub_7C558(a1, a2, nullptr, nullptr, nullptr);
if ( result )
return result;
v5 = a1[56];
v9 = *(_DWORD *)(v5 + 18612);
}
v10 = *(_DWORD *)(v5 + 18584);
*(_DWORD *)(v5 + 18584) = (v10 & 1) == 0;
v11 = v5 + 18584;
v12 = (unsigned __int8 *)(v5 + 2304 * v10 + 512);
*(_DWORD *)(v11 + 8) = 0;
*(_DWORD *)(v11 + 12) = v12;
qmemcpy(v12, a2 + 4, v9);
v13 = a1[56];
if ( *(_DWORD *)(v13 + 18532) )
{
sub_7C4BC((int)a1, 16);
v13 = a1[56];
}
v14 = *(_DWORD *)(v13 + 18528);
if ( v14 == 3 )
{
result = sub_80E24(a1, a3, a4);
}
else if ( v14 == 2 )
{
result = sub_7DD44(a1, a3, a4);
}
else
{
result = 0;
}
v16 = a1[56];
v17 = *(_DWORD *)(v16 + 18612);
*(_DWORD *)(v16 + 18612) = 0;
*(_DWORD *)(v16 + 18616) = v17;
return result;
}