//
// sub_670DB0 from 0x670db0 to 0x670efe (334 bytes)
//
// 0 xrefs:
//
// 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_670DB0(int a1)
{
_DWORD *v2; // r5
int v3; // r3
int result; // r0
int v5; // r2
int v6; // r3
int v7; // r1
int v8; // r3
v2 = *(_DWORD **)(a1 + 392);
v3 = v2[5];
switch ( v3 )
{
case 1:
sub_670A6C((_DWORD *)a1);
sub_670BFC((_DWORD *)a1);
if ( *(_DWORD *)(a1 + 364) || !*(_DWORD *)(a1 + 372) )
{
(**(void (__fastcall ***)(int, int))(a1 + 424))(a1, 1);
result = (**(int (__fastcall ***)(int, int))(a1 + 404))(a1, 2);
v2[3] = 0;
goto LABEL_10;
}
v8 = v2[6];
v2[5] = 2;
v2[6] = v8 + 1;
break;
case 0:
sub_670A6C((_DWORD *)a1);
sub_670BFC((_DWORD *)a1);
if ( !*(_DWORD *)(a1 + 208) )
{
(**(void (__fastcall ***)(int))(a1 + 412))(a1);
(**(void (__fastcall ***)(int))(a1 + 416))(a1);
(**(void (__fastcall ***)(int, _DWORD))(a1 + 400))(a1, 0);
}
(**(void (__fastcall ***)(int))(a1 + 420))(a1);
(**(void (__fastcall ***)(int, _DWORD))(a1 + 424))(a1, *(_DWORD *)(a1 + 216));
if ( (int)v2[7] <= 1 )
v7 = 0;
else
v7 = 3;
(**(void (__fastcall ***)(int, int))(a1 + 404))(a1, v7);
result = (**(int (__fastcall ***)(int, _DWORD))(a1 + 396))(a1, 0);
if ( *(_DWORD *)(a1 + 216) )
v2[3] = 0;
else
v2[3] = 1;
goto LABEL_10;
case 2:
break;
default:
*(_DWORD *)(*(_DWORD *)a1 + 20) = 49;
result = (**(int (__fastcall ***)(int))a1)(a1);
goto LABEL_10;
}
if ( !*(_DWORD *)(a1 + 216) )
{
sub_670A6C((_DWORD *)a1);
sub_670BFC((_DWORD *)a1);
}
(**(void (__fastcall ***)(int, _DWORD))(a1 + 424))(a1, 0);
(**(void (__fastcall ***)(int, int))(a1 + 404))(a1, 2);
if ( !v2[8] )
(*(void (__fastcall **)(int))(*(_DWORD *)(a1 + 408) + 4))(a1);
result = (*(int (__fastcall **)(int))(*(_DWORD *)(a1 + 408) + 8))(a1);
v2[3] = 0;
LABEL_10:
v5 = v2[6];
v2[4] = v5 == v2[7] - 1;
v6 = *(_DWORD *)(a1 + 8);
if ( v6 )
{
*(_DWORD *)(v6 + 12) = v5;
*(_DWORD *)(*(_DWORD *)(a1 + 8) + 16) = v2[7];
}
return result;
}