//
// sub_85DF8 from 0x85df8 to 0x85ed2 (218 bytes)
//
// 2 xrefs:
// > sub_85790 @ 0x85862
// > sub_85790 @ 0x859ca
//
// 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_85DF8(int *a1, _WORD *a2, int a3, int a4, int a5, int a6)
{
int v8; // r0
unsigned int v9; // r10
int v10; // r8
int v11; // r1
int v12; // r4
int v13; // r9
unsigned int v14; // r11
int v15; // r0
int v16; // r0
int v17; // r0
int v18; // r0
int v21; // [sp+Ch] [bp-2Ch]
while ( 1 )
{
if ( !a3 )
return 0;
v8 = *a1;
v9 = (unsigned __int8)BYTE2(*a1);
if ( v9 > 0x58 )
break;
v10 = a5 - 1;
v11 = (__int16)v8;
*a2 = v8;
a2 += a6;
v12 = 4;
v21 = a3 - 1;
while ( v10 )
{
v13 = a6;
v14 = *((unsigned __int8 *)a1 + v12);
v15 = sub_85EDC(v14 & 0xF, v11, asc_40A28[v9]);
*a2 = v15;
v11 = v15;
a2 += v13;
v16 = dword_40ADC[v14 & 0xF] + v9;
if ( v16 >= 88 )
v16 = 88;
v9 = v16 & ~(v16 >> 31);
if ( v10 == 1 )
{
a6 = v13;
v10 = 0;
}
else
{
v17 = sub_85EDC(v14 >> 4, v11, asc_40A28[v9]);
*a2 = v17;
v11 = v17;
a6 = v13;
a2 += v13;
v10 -= 2;
v18 = dword_40ADC[v14 >> 4] + v9;
if ( v18 >= 88 )
v18 = 88;
v9 = v18 & ~(v18 >> 31);
}
++v12;
}
a3 = v21;
a1 = (int *)((char *)a1 + a4);
}
return 13;
}