//
// CustomSongWidget::onDownload from 0x4e5b4c to 0x4e5c6c (288 bytes)
//
// 2 xrefs:
// > CustomSongWidget::musicActionFinished @ 0x4e5c84
// > CustomSongWidget::FLAlert_Clicked @ 0x4e5cc6
//
// 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 11:51:05 +0000
//
MusicDownloadManager *__fastcall CustomSongWidget::onDownload(
CustomSongWidget *this,
cocos2d::CCObject *a2,
int a3,
int a4)
{
GameManager *v5; // r0
GameManager *v6; // r0
MusicDownloadManager *result; // r0
MusicDownloadManager *v8; // r0
int v9; // r5
MusicDownloadManager *v10; // r0
int v11; // r0
int v12; // r2
int v13; // r3
int v14; // r1
int v15; // r3
int v16; // r3
MusicDownloadManager *v18; // r0
MusicDownloadManager *v19; // r0
(*(void (__fastcall **)(_DWORD, _DWORD))(**((_DWORD **)this + 73) + 172))(*((_DWORD *)this + 73), 0);
v5 = *((GameManager **)this + 86);
if ( v5 )
v5 = (GameManager *)(*(int (__fastcall **)(GameManager *, _DWORD))(*(_DWORD *)v5 + 172))(v5, 0);
v6 = (GameManager *)GameManager::sharedState(v5);
result = (MusicDownloadManager *)GameManager::getGameVariable(v6, "0016");
if ( !result )
{
v8 = (MusicDownloadManager *)MusicDownloadManager::sharedState(nullptr);
return (MusicDownloadManager *)MusicDownloadManager::showTOS(v8, (CustomSongWidget *)((char *)this + 268));
}
v9 = *((unsigned __int8 *)this + 377);
if ( *((_BYTE *)this + 377) )
{
(*(void (__fastcall **)(_DWORD, _DWORD))(**((_DWORD **)this + 74) + 172))(*((_DWORD *)this + 74), 0);
v10 = (MusicDownloadManager *)(*(int (__fastcall **)(_DWORD, int))(**((_DWORD **)this + 75) + 172))(
*((_DWORD *)this + 75),
1);
v11 = MusicDownloadManager::sharedState(v10);
v13 = *(unsigned __int8 *)(v11 + 288);
v14 = v13 << 31;
if ( (v13 & 1) != 0 )
v15 = *(_DWORD *)(v11 + 292);
else
v15 = v13 >> 1;
if ( v15 )
return CustomSongWidget::startMultiAssetDownload(this, v14, v12, a4);
LABEL_17:
*((_BYTE *)this + 376) = 1;
v18 = (MusicDownloadManager *)MusicDownloadManager::sharedState((MusicDownloadManager *)v11);
return (MusicDownloadManager *)MusicDownloadManager::getCustomContentURL(v18);
}
if ( !*((_DWORD *)this + 68) )
return result;
(*(void (__fastcall **)(_DWORD, int))(**((_DWORD **)this + 83) + 172))(*((_DWORD *)this + 83), 1);
(*(void (__fastcall **)(_DWORD, int))(**((_DWORD **)this + 74) + 172))(*((_DWORD *)this + 74), v9);
(*(void (__fastcall **)(_DWORD, int))(**((_DWORD **)this + 75) + 172))(*((_DWORD *)this + 75), 1);
v11 = (*(int (__fastcall **)(_DWORD, int))(**((_DWORD **)this + 80) + 172))(*((_DWORD *)this + 80), v9);
if ( *((int *)this + 90) > 9999999 )
{
v11 = MusicDownloadManager::sharedState((MusicDownloadManager *)v11);
v16 = *(unsigned __int8 *)(v11 + 288);
if ( !((v16 & 1) != 0 ? *(_DWORD *)(v11 + 292) : v16 >> 1) )
goto LABEL_17;
}
if ( *(_BYTE *)(*((_DWORD *)this + 68) + 329) )
return (MusicDownloadManager *)CustomSongWidget::startDownload(this);
*((_BYTE *)this + 355) = 1;
v19 = (MusicDownloadManager *)MusicDownloadManager::sharedState((MusicDownloadManager *)v11);
return (MusicDownloadManager *)MusicDownloadManager::getSongInfo(v19, *((_DWORD *)this + 90), 1);
}