//
// CustomSongWidget::onDownload from 0x10011f584 to 0x10011f72c (424 bytes)
//
// 4 xrefs:
// > CustomSongWidget::musicActionFinished @ 0x10012306c
// > sub_100123074 @ 0x100123094
// > CustomSongWidget::FLAlert_Clicked @ 0x100123118
// > CustomSongWidget::init @ 0x10011e7ac
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 10:59:14 +0000
//
void __fastcall CustomSongWidget::onDownload(__int64 a1)
{
__int64 v2; // x0
__int64 v3; // x0
__int64 v4; // x0
__n128 GameVariable; // q0
__int64 v6; // x0
__int64 v7; // x0
__int64 v8; // x0
__int64 v9; // x8
__int64 v10; // x0
__int64 v11; // x0
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 376) + 344LL))(*(_QWORD *)(a1 + 376), 0);
v2 = *(_QWORD *)(a1 + 480);
if ( v2 )
v2 = (*(__int64 (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v2 + 344LL))(v2, 0);
v3 = GameManager::sharedState(v2);
GameVariable = GameManager::getGameVariable(v3, "0016");
if ( (v4 & 1) == 0 )
{
v8 = MusicDownloadManager::sharedState(v4);
MusicDownloadManager::showTOS(v8, a1 + 328);
return;
}
if ( *(_BYTE *)(a1 + 529) == 1 )
{
(*(void (__fastcall **)(_QWORD, _QWORD, __n128))(**(_QWORD **)(a1 + 384) + 344LL))(
*(_QWORD *)(a1 + 384),
0,
GameVariable);
v6 = (*(__int64 (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 392) + 344LL))(*(_QWORD *)(a1 + 392), 1);
v7 = MusicDownloadManager::sharedState(v6);
if ( (*(char *)(v7 + 391) & 0x8000000000000000LL) != 0 )
{
if ( !*(_QWORD *)(v7 + 376) )
{
LABEL_18:
*(_BYTE *)(a1 + 528) = 1;
v10 = MusicDownloadManager::sharedState(v7);
MusicDownloadManager::getCustomContentURL(v10);
return;
}
}
else if ( !*(_BYTE *)(v7 + 391) )
{
goto LABEL_18;
}
sub_100121A4C(a1);
return;
}
if ( *(_QWORD *)(a1 + 336) )
{
(*(void (__fastcall **)(_QWORD, __int64, __n128))(**(_QWORD **)(a1 + 456) + 344LL))(
*(_QWORD *)(a1 + 456),
1,
GameVariable);
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 384) + 344LL))(*(_QWORD *)(a1 + 384), 0);
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 392) + 344LL))(*(_QWORD *)(a1 + 392), 1);
v7 = (*(__int64 (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 432) + 344LL))(*(_QWORD *)(a1 + 432), 0);
if ( *(int *)(a1 + 504) >= 10000000 )
{
v7 = MusicDownloadManager::sharedState(v7);
v9 = *(char *)(v7 + 391);
if ( v9 < 0 )
v9 = *(_QWORD *)(v7 + 376);
if ( !v9 )
goto LABEL_18;
}
if ( *(_BYTE *)(*(_QWORD *)(a1 + 336) + 433LL) == 1 )
{
CustomSongWidget::startDownload(a1);
}
else
{
*(_BYTE *)(a1 + 499) = 1;
v11 = MusicDownloadManager::sharedState(v7);
MusicDownloadManager::getSongInfo(v11, *(unsigned int *)(a1 + 504), 1);
}
}
}