//
// sub_6290A4 from 0x6290a4 to 0x6291ec (328 bytes)
//
// 5 xrefs:
// > sub_60F254 @ 0x60f5e2
// > sub_62931C @ 0x629b44
// > sub_633450 @ 0x633556
// > sub_63F2EC @ 0x63f4c0
// > sub_63F5CC @ 0x63f700
//
// 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_6290A4(int *a1, unsigned int a2, unsigned int *a3)
{
int v4; // r4
unsigned int v6; // r6
int v7; // r0
unsigned int v8; // r0
unsigned int v9; // r5
const char *v10; // r9
size_t v11; // r2
unsigned int v12; // r5
size_t v13; // r6
void *v14; // r0
size_t v15; // r8
bool v16; // zf
int v18; // r2
_BYTE v19[16]; // [sp+Ch] [bp-10h] BYREF
v4 = *a1;
v6 = a2;
if ( *(_BYTE *)(*a1 + 329) )
{
v6 = a2 - 12;
v7 = *(_DWORD *)(v4 + 324) + 10;
*(_DWORD *)(v4 + 324) = v7;
}
else
{
v7 = *(_DWORD *)(v4 + 324);
}
v8 = (*(int (__fastcall **)(int, int, unsigned int, _DWORD))(v4 + 34728))(v7, 1, v6, *(_DWORD *)(v4 + 34732));
v9 = v8;
if ( v8 == 0x10000000 )
{
sub_6180F8(v4, "operation aborted by callback");
*a3 = 0;
return 42;
}
else if ( v8 == 268435457 )
{
if ( (*(_DWORD *)(a1[166] + 64) & 0x10) != 0 )
{
sub_6180F8(v4, "Read callback asked for PAUSE when not supported!");
return 26;
}
else
{
v18 = *(unsigned __int8 *)(v4 + 329);
*(_DWORD *)(v4 + 304) |= 0x20u;
if ( v18 )
*(_DWORD *)(v4 + 324) -= 10;
*a3 = 0;
return 0;
}
}
else if ( v6 < v8 )
{
*a3 = 0;
sub_6180F8(v4, "read function returned funny value");
return 26;
}
else
{
if ( !*(_BYTE *)(v4 + 331) && *(_BYTE *)(v4 + 329) )
{
if ( *(_BYTE *)(v4 + 891) )
{
v10 = "\n";
}
else if ( *(_BYTE *)(v4 + 590) )
{
v10 = "\n";
}
else
{
v10 = (const char *)&word_9B1DDC;
}
v11 = sub_624640(v19, 11, "%x%s", v8, v10);
v12 = v9 + v11;
v13 = v11;
v14 = (void *)(*(_DWORD *)(v4 + 324) - v11);
*(_DWORD *)(v4 + 324) = v14;
memcpy(v14, v19, v11);
v15 = strlen(v10);
memcpy((void *)(*(_DWORD *)(v4 + 324) + v12), v10, v15);
v16 = v12 == v13;
v9 = v12 + v15;
if ( v16 )
*(_BYTE *)(v4 + 308) = 1;
}
*a3 = v9;
return 0;
}
}