//
// CustomSongWidget::downloadAssetFailed from 0x3e0ab4 to 0x3e0b9c (232 bytes)
//
// 2 xrefs:
// > CustomSongWidget::downloadSongFailed @ 0x3e0bb0
// > CustomSongWidget::downloadSFXFailed @ 0x3e0bda
//
// 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
//
void CustomSongWidget::downloadAssetFailed(CustomSongWidget *a1, int a2, GJAssetType a3, GJSongError a4)
{
GJAssetDownloadAction *m_start; // r4
GJAssetDownloadAction *m_finish; // r5
int p_m_assetType; // r3
int v8; // r2
int v9; // r7
int v10; // r5
int v11; // r6
int i; // r9
int *v13; // r4
int v14; // r9
_DWORD *v15; // r11
int v16; // [sp+4h] [bp-8h]
m_start = a1->m_undownloadedAssets.m_start;
m_finish = a1->m_undownloadedAssets.m_finish;
while ( m_start != m_finish )
{
p_m_assetType = (int)&m_start[1].m_assetType;
if ( m_start->m_id == a2 && m_start->m_assetType == a3 )
{
++m_start->m_status;
v8 = 0;
LOBYTE(m_start[1].m_id) = 0;
if ( m_finish != (GJAssetDownloadAction *)p_m_assetType )
{
v9 = 1;
v10 = ((char *)m_finish - (char *)m_start) >> 4;
if ( v10 != 2 )
{
while ( 1 )
{
v11 = v10 - v9;
if ( v9 >= v10 - v9 )
{
v13 = &m_start->m_id + 4 * v10;
v14 = 0;
p_m_assetType = (int)&v13[-4 * v11];
v15 = (_DWORD *)p_m_assetType;
while ( v14 < v9 )
{
v15 -= 4;
v13 -= 4;
v16 = p_m_assetType;
++v14;
std::swap(v15, v13, v8, p_m_assetType);
p_m_assetType = v16;
}
m_start = (GJAssetDownloadAction *)(p_m_assetType - 16 * (v9 & ~(v9 >> 31)));
v9 = v10 % v11;
if ( !(v10 % v11) )
goto LABEL_6;
}
else
{
for ( i = 0; i < v11; ++i )
std::swap(
&m_start->m_id + 4 * i,
&m_start->m_id + 4 * i + 4 * v9,
v8,
p_m_assetType);
m_start = (GJAssetDownloadAction *)((char *)m_start + 16 * (v11 & ~(v11 >> 31)));
if ( !(v10 % v9) )
goto LABEL_6;
v11 = v9;
v9 -= v10 % v9;
}
v10 = v11;
}
}
std::swap(m_start, &m_start[1].m_assetType, 0, p_m_assetType);
}
LABEL_6:
CustomSongWidget::processNextMultiAsset(a1);
return;
}
m_start = (GJAssetDownloadAction *)((char *)m_start + 16);
}
}