Clear unknowns in Radio and RadioState (#1573)

This commit is contained in:
Fabian Neundorf 2025-06-19 23:52:02 +02:00 committed by GitHub
parent cf32607933
commit 6159d23cde
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 30 deletions

View File

@ -39,13 +39,13 @@ public:
void SetActive(MxBool p_active) { m_active = p_active; } void SetActive(MxBool p_active) { m_active = p_active; }
undefined4 FUN_1002d090(); MxU32 NextPlaylistObjectId();
MxBool FUN_1002d0c0(const MxAtomId& p_atom, MxU32 p_objectId); MxBool IsRadioObjectId(const MxAtomId& p_atom, MxU32 p_objectId);
// TODO: Most likely getters/setters are not used according to BETA. // TODO: Most likely getters/setters are not used according to BETA.
Playlist m_unk0x08[3]; // 0x08 Playlist m_playlists[3]; // 0x08
MxS16 m_unk0x2c; // 0x2c MxS16 m_activePlaylist; // 0x2c
MxBool m_active; // 0x2e MxBool m_active; // 0x2e
}; };
@ -85,7 +85,7 @@ public:
private: private:
RadioState* m_state; // 0x08 RadioState* m_state; // 0x08
MxBool m_unk0x0c; // 0x0c MxBool m_enabled; // 0x0c
MxBool m_audioEnabled; // 0x0d MxBool m_audioEnabled; // 0x0d
MxLong HandleEndAction(MxEndActionNotificationParam& p_param); MxLong HandleEndAction(MxEndActionNotificationParam& p_param);

View File

@ -18,7 +18,7 @@ DECOMP_SIZE_ASSERT(Radio, 0x10)
DECOMP_SIZE_ASSERT(RadioState, 0x30) DECOMP_SIZE_ASSERT(RadioState, 0x30)
// GLOBAL: LEGO1 0x100f3218 // GLOBAL: LEGO1 0x100f3218
JukeboxScript::Script g_unk0x100f3218[] = { JukeboxScript::Script g_jingles[] = {
JukeboxScript::c_sns002ra_Audio, JukeboxScript::c_sns002ra_Audio,
JukeboxScript::c_sns001ja_Audio, JukeboxScript::c_sns001ja_Audio,
JukeboxScript::c_snsc01js_Audio, JukeboxScript::c_snsc01js_Audio,
@ -28,7 +28,7 @@ JukeboxScript::Script g_unk0x100f3218[] = {
}; };
// GLOBAL: LEGO1 0x100f3230 // GLOBAL: LEGO1 0x100f3230
JukeboxScript::Script g_unk0x100f3230[] = { JukeboxScript::Script g_news[] = {
JukeboxScript::c_ham035ra_Audio, JukeboxScript::c_ham035ra_Audio,
JukeboxScript::c_ham039ra_Audio, JukeboxScript::c_ham039ra_Audio,
JukeboxScript::c_sns005ra_Audio, JukeboxScript::c_sns005ra_Audio,
@ -46,7 +46,7 @@ JukeboxScript::Script g_unk0x100f3230[] = {
}; };
// GLOBAL: LEGO1 0x100f3268 // GLOBAL: LEGO1 0x100f3268
JukeboxScript::Script g_unk0x100f3268[] = { JukeboxScript::Script g_songs[] = {
JukeboxScript::c_CentralRoads_Music, JukeboxScript::c_CentralRoads_Music,
JukeboxScript::c_BeachBlvd_Music, JukeboxScript::c_BeachBlvd_Music,
JukeboxScript::c_ResidentalArea_Music, JukeboxScript::c_ResidentalArea_Music,
@ -64,7 +64,7 @@ Radio::Radio()
NotificationManager()->Register(this); NotificationManager()->Register(this);
ControlManager()->Register(this); ControlManager()->Register(this);
m_unk0x0c = TRUE; m_enabled = TRUE;
CreateState(); CreateState();
} }
@ -86,7 +86,7 @@ MxLong Radio::Notify(MxParam& p_param)
{ {
MxLong result = 0; MxLong result = 0;
if (m_unk0x0c) { if (m_enabled) {
MxNotificationParam& param = (MxNotificationParam&) p_param; MxNotificationParam& param = (MxNotificationParam&) p_param;
switch (param.GetNotification()) { switch (param.GetNotification()) {
case c_notificationEndAction: case c_notificationEndAction:
@ -108,7 +108,7 @@ void Radio::Play()
CurrentWorld(); CurrentWorld();
MxDSAction action; MxDSAction action;
action.SetObjectId(m_state->FUN_1002d090()); action.SetObjectId(m_state->NextPlaylistObjectId());
action.SetAtomId(*g_jukeboxScript); action.SetAtomId(*g_jukeboxScript);
action.SetLoopCount(1); action.SetLoopCount(1);
@ -174,11 +174,11 @@ MxLong Radio::HandleControl(LegoControlManagerNotificationParam& p_param)
MxLong Radio::HandleEndAction(MxEndActionNotificationParam& p_param) MxLong Radio::HandleEndAction(MxEndActionNotificationParam& p_param)
{ {
if (m_state->IsActive() && if (m_state->IsActive() &&
m_state->FUN_1002d0c0(p_param.GetAction()->GetAtomId(), p_param.GetAction()->GetObjectId())) { m_state->IsRadioObjectId(p_param.GetAction()->GetAtomId(), p_param.GetAction()->GetObjectId())) {
MxDSAction action; MxDSAction action;
action.SetAtomId(*g_jukeboxScript); action.SetAtomId(*g_jukeboxScript);
action.SetObjectId(m_state->FUN_1002d090()); action.SetObjectId(m_state->NextPlaylistObjectId());
action.SetLoopCount(1); action.SetLoopCount(1);
BackgroundAudioManager()->PlayMusic(action, 3, MxPresenter::e_repeating); BackgroundAudioManager()->PlayMusic(action, 3, MxPresenter::e_repeating);
@ -191,8 +191,8 @@ MxLong Radio::HandleEndAction(MxEndActionNotificationParam& p_param)
// FUNCTION: LEGO1 0x1002cdc0 // FUNCTION: LEGO1 0x1002cdc0
void Radio::Initialize(MxBool p_und) void Radio::Initialize(MxBool p_und)
{ {
if (m_unk0x0c != p_und) { if (m_enabled != p_und) {
m_unk0x0c = p_und; m_enabled = p_und;
CreateState(); CreateState();
} }
} }
@ -216,39 +216,39 @@ RadioState::RadioState()
srand(Timer()->GetTime()); srand(Timer()->GetTime());
MxS32 random = rand(); MxS32 random = rand();
m_unk0x2c = random % 3; m_activePlaylist = random % 3;
m_unk0x08[0] = Playlist((MxU32*) g_unk0x100f3218, sizeOfArray(g_unk0x100f3218), Playlist::e_loop); m_playlists[0] = Playlist((MxU32*) g_jingles, sizeOfArray(g_jingles), Playlist::e_loop);
m_unk0x08[0].m_nextIndex = (rand() % sizeOfArray(g_unk0x100f3218)); m_playlists[0].m_nextIndex = (rand() % sizeOfArray(g_jingles));
m_unk0x08[1] = Playlist((MxU32*) g_unk0x100f3230, sizeOfArray(g_unk0x100f3230), Playlist::e_loop); m_playlists[1] = Playlist((MxU32*) g_news, sizeOfArray(g_news), Playlist::e_loop);
m_unk0x08[1].m_nextIndex = (rand() % sizeOfArray(g_unk0x100f3230)); m_playlists[1].m_nextIndex = (rand() % sizeOfArray(g_news));
m_unk0x08[2] = Playlist((MxU32*) g_unk0x100f3268, sizeOfArray(g_unk0x100f3268), Playlist::e_loop); m_playlists[2] = Playlist((MxU32*) g_songs, sizeOfArray(g_songs), Playlist::e_loop);
m_unk0x08[2].m_nextIndex = (rand() % sizeOfArray(g_unk0x100f3268)); m_playlists[2].m_nextIndex = (rand() % sizeOfArray(g_songs));
m_active = FALSE; m_active = FALSE;
} }
// FUNCTION: LEGO1 0x1002d090 // FUNCTION: LEGO1 0x1002d090
MxU32 RadioState::FUN_1002d090() MxU32 RadioState::NextPlaylistObjectId()
{ {
if (m_unk0x2c == 2) { if (m_activePlaylist == 2) {
m_unk0x2c = 0; m_activePlaylist = 0;
} }
else { else {
m_unk0x2c++; m_activePlaylist++;
} }
return m_unk0x08[m_unk0x2c].Next(); return m_playlists[m_activePlaylist].Next();
} }
// FUNCTION: LEGO1 0x1002d0c0 // FUNCTION: LEGO1 0x1002d0c0
MxBool RadioState::FUN_1002d0c0(const MxAtomId& p_atom, MxU32 p_objectId) MxBool RadioState::IsRadioObjectId(const MxAtomId& p_atom, MxU32 p_objectId)
{ {
if (*g_jukeboxScript == p_atom) { if (*g_jukeboxScript == p_atom) {
for (MxS16 i = 0; i < 3; i++) { for (MxS16 i = 0; i < 3; i++) {
if (m_unk0x08[i].Contains(p_objectId)) { if (m_playlists[i].Contains(p_objectId)) {
return TRUE; return TRUE;
} }
} }