//
// sub_7782E from 0x7782e to 0x778ce (160 bytes)
//
// 1 xrefs:
// > sub_7299C @ 0x7299c
//
// 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_7782E(int a1, int a2, unsigned int a3, int a4)
{
int v6; // r5
int i; // r4
int v8; // r0
int result; // r0
unsigned int v10; // r0
int v11; // r6
__int16 v12; // r5
int v13; // [sp+4h] [bp-14h] BYREF
if ( a4 == 2 )
{
v10 = *(_DWORD *)(a1 + 1516);
if ( v10 != a3 )
{
if ( v10 > a3 )
{
sub_729DA(a1, 0);
v11 = 1;
}
else
{
v11 = 0;
}
while ( *(_DWORD *)(a1 + 1516) < a3 )
sub_72A2E(a1, 1);
if ( v11 )
{
v12 = *(_WORD *)(a1 + 2420);
sub_4F378(a1);
*(_WORD *)(a1 + 2420) = v12;
}
}
}
else
{
if ( a4 != 256 )
return 19;
sub_729DA(a1, 0);
*(_DWORD *)(a1 + 2456) = a3;
*(_DWORD *)(a1 + 2440) = a3;
v6 = a1 + 15804;
for ( i = 0; i != 50; ++i )
{
v13 = 0;
v8 = *(_DWORD *)(v6 + 4 * i);
if ( v8 )
{
result = sub_485A8(v8, 0, &v13);
if ( result )
return result;
if ( v13 )
sub_AB144(v13);
}
}
}
return 0;
}