//
// sub_980DFC from 0x980dfc to 0x980ec8 (204 bytes)
//
// 2 xrefs:
// > sub_980DE4 @ 0x980df8
// > sub_980EF4 @ 0x980f0a
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:06:07 +0000
//
unsigned __int16 *__fastcall sub_980DFC(int a1)
{
int *v2; // r0
unsigned __int16 *v3; // r4
unsigned int v4; // r1
int *v5; // r5
unsigned int v6; // r2
int *v7; // r1
unsigned int v8; // r0
unsigned __int16 v9; // r0
unsigned __int16 *v10; // r0
int v11; // r0
void *v13; // [sp+0h] [bp-10h] BYREF
v13 = &unk_D33CF0;
pthread_mutex_lock((pthread_mutex_t *)&unk_D33CF0);
v2 = (int *)dword_D33CF4;
if ( !dword_D33CF4 )
{
v2 = dword_D33D00;
dword_D33CF4 = (int)dword_D33D00;
dword_D33D00[0] = 8388736;
}
v3 = nullptr;
if ( v2 && v2 != (int *)&unk_D33F00 )
{
v4 = a1 + 3;
v5 = nullptr;
v6 = (v4 >> 2) + 1;
v3 = nullptr;
while ( 1 )
{
v7 = v2;
v8 = *((unsigned __int16 *)v2 + 1);
if ( v8 > v6 )
{
v9 = v8 - v6;
*((_WORD *)v7 + 1) = v9;
LOWORD(v7[v9]) = 0;
v10 = (unsigned __int16 *)&v7[v9];
v3 = v10 + 2;
v10[1] = v6;
goto LABEL_16;
}
if ( v8 == v6 )
break;
v2 = &dword_D33D00[*(unsigned __int16 *)v7];
if ( v2 )
{
v5 = v7;
if ( v2 != (int *)&unk_D33F00 )
continue;
}
goto LABEL_16;
}
v11 = *(unsigned __int16 *)v7;
if ( v5 )
*(_WORD *)v5 = v11;
else
dword_D33CF4 = (int)&dword_D33D00[v11];
*(_WORD *)v7 = 0;
v3 = (unsigned __int16 *)(v7 + 1);
}
LABEL_16:
sub_981058(&v13);
return v3;
}