//
// sub_848A6 from 0x848a6 to 0x84934 (142 bytes)
//
// 1 xrefs:
// > sub_82958 @ 0x82958
//
// 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_848A6(int a1, int a2, unsigned int a3, int a4)
{
unsigned int v6; // r0
int v8; // r6
__int16 v9; // r5
if ( a4 == 2 )
{
v6 = *(_DWORD *)(a1 + 1516);
if ( v6 != a3 )
{
if ( v6 > a3 )
{
sub_4F22C(a1, 0);
v8 = 1;
}
else
{
v8 = 0;
}
while ( *(_DWORD *)(a1 + 1516) < a3 )
sub_82996(a1, 1);
if ( v8 )
{
v9 = *(_WORD *)(a1 + 2420);
sub_4F378(a1);
*(_WORD *)(a1 + 2420) = v9;
}
}
}
else
{
if ( a4 != 256 )
return 19;
sub_4F22C(a1, 0);
if ( (*(_BYTE *)(a1 + 209) & 0x40) != 0 )
{
while ( *(_DWORD *)(a1 + 2440) < (signed int)a3 && !*(_BYTE *)(a1 + 2421) )
sub_82996(a1, 1);
}
else
{
*(_DWORD *)(a1 + 2456) = a3;
*(_DWORD *)(a1 + 2440) = a3;
}
}
return 0;
}