//
// sub_766D60 from 0x766d60 to 0x766dd6 (118 bytes)
//
// 2 xrefs:
// > sub_766DD8 @ 0x766e4e
// > sub_7671E0 @ 0x767246
//
// 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_766D60(int a1, unsigned int a2, int a3, __int16 a4, char a5)
{
int v5; // r5
unsigned int v6; // r4
unsigned int v7; // r3
int v9; // r4
int v10; // r3
int v11; // r3
if ( a5 )
{
v5 = a1;
do
{
v6 = a2 / 0xA;
v7 = a2 - 10 * v6;
a2 = v6;
*(_DWORD *)(v5 - 4) = *(_DWORD *)(a3 + 4 * (v7 + 4));
v5 -= 4;
}
while ( v6 );
}
else if ( (a4 & 0x4A) == 0x40 )
{
v5 = a1;
do
{
v11 = a2 & 7;
a2 >>= 3;
*(_DWORD *)(v5 - 4) = *(_DWORD *)(a3 + 4 * (v11 + 4));
v5 -= 4;
}
while ( a2 );
}
else
{
v5 = a1;
if ( (a4 & 0x4000) != 0 )
v9 = 20;
else
v9 = 4;
do
{
v10 = a2 & 0xF;
a2 >>= 4;
*(_DWORD *)(v5 - 4) = *(_DWORD *)(a3 + 4 * (v10 + v9));
v5 -= 4;
}
while ( a2 );
}
return (a1 - v5) >> 2;
}