mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-24 17:04:17 +00:00
Implement/match Radio, RadioState (#509)
* WIP RadioState * WIP * WIP * Implement/match Radio/RadioState * Fix naming * Use sizeof
This commit is contained in:
committed by
GitHub
parent
743e042564
commit
cdf76754f7
@@ -2,17 +2,7 @@
|
||||
|
||||
#include "decomp.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(LegoVehicleBuildState, 0x50); // 1000acd7
|
||||
DECOMP_SIZE_ASSERT(LegoVehicleBuildState::UnkStruct, 0x0c);
|
||||
|
||||
// FUNCTION: LEGO1 0x10017c00
|
||||
LegoVehicleBuildState::UnkStruct::UnkStruct()
|
||||
{
|
||||
m_unk0x04 = 0;
|
||||
m_unk0x00 = 0;
|
||||
m_unk0x06 = 0;
|
||||
m_unk0x08 = 0;
|
||||
}
|
||||
DECOMP_SIZE_ASSERT(LegoVehicleBuildState, 0x50)
|
||||
|
||||
// FUNCTION: LEGO1 0x10025f30
|
||||
LegoVehicleBuildState::LegoVehicleBuildState(char* p_classType)
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
#include "legostate.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(LegoState, 0x08)
|
||||
DECOMP_SIZE_ASSERT(LegoState::StateStruct, 0x0c)
|
||||
|
||||
// STUB: LEGO1 0x10014d00
|
||||
MxU32 LegoState::StateStruct::FUN_10014d00()
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x10014de0
|
||||
MxBool LegoState::StateStruct::FUN_10014de0(MxU32 p_objectId)
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10017c00
|
||||
LegoState::StateStruct::StateStruct()
|
||||
{
|
||||
m_unk0x04 = 0;
|
||||
m_unk0x00 = 0;
|
||||
m_unk0x06 = 0;
|
||||
m_unk0x08 = 0;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "legocontrolmanager.h"
|
||||
#include "legogamestate.h"
|
||||
#include "legoomni.h"
|
||||
#include "mxbackgroundaudiomanager.h"
|
||||
#include "mxcontrolpresenter.h"
|
||||
#include "mxnotificationmanager.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(Radio, 0x10);
|
||||
@@ -17,16 +19,119 @@ Radio::Radio()
|
||||
CreateRadioState();
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x1002c990
|
||||
// FUNCTION: LEGO1 0x1002c990
|
||||
Radio::~Radio()
|
||||
{
|
||||
// TODO
|
||||
if (m_state->IsActive()) {
|
||||
BackgroundAudioManager()->Stop();
|
||||
m_state->SetActive(FALSE);
|
||||
}
|
||||
|
||||
ControlManager()->Unregister(this);
|
||||
NotificationManager()->Unregister(this);
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x1002ca30
|
||||
// FUNCTION: LEGO1 0x1002ca30
|
||||
MxLong Radio::Notify(MxParam& p_param)
|
||||
{
|
||||
// TODO
|
||||
MxLong result = 0;
|
||||
|
||||
if (m_unk0x0c) {
|
||||
switch (((MxNotificationParam&) p_param).GetType()) {
|
||||
case c_notificationEndAction:
|
||||
result = HandleEndAction((MxEndActionNotificationParam&) p_param);
|
||||
break;
|
||||
case c_notificationType17:
|
||||
result = HandleNotification17((LegoControlManagerEvent&) p_param);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1002ca70
|
||||
void Radio::Play()
|
||||
{
|
||||
if (!m_state->IsActive()) {
|
||||
GetCurrentWorld();
|
||||
|
||||
MxDSAction action;
|
||||
action.SetObjectId(m_state->FUN_1002d090());
|
||||
action.SetAtomId(*g_jukeboxScript);
|
||||
action.SetLoopCount(1);
|
||||
|
||||
m_bgAudioPreviouslyEnabled = BackgroundAudioManager()->GetMusicEnabled();
|
||||
if (!m_bgAudioPreviouslyEnabled) {
|
||||
BackgroundAudioManager()->Enable(TRUE);
|
||||
}
|
||||
|
||||
BackgroundAudioManager()->PlayMusic(action, 3, 4);
|
||||
m_state->SetActive(TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1002cb70
|
||||
void Radio::Stop()
|
||||
{
|
||||
if (m_state->IsActive()) {
|
||||
LegoWorld* world = GetCurrentWorld();
|
||||
|
||||
MxControlPresenter* presenter = (MxControlPresenter*) world->Find(world->GetAtom(), 18);
|
||||
|
||||
if (presenter)
|
||||
presenter->VTable0x6c(0);
|
||||
|
||||
BackgroundAudioManager()->Stop();
|
||||
BackgroundAudioManager()->Enable(m_bgAudioPreviouslyEnabled);
|
||||
m_state->SetActive(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1002cbc0
|
||||
MxLong Radio::HandleNotification17(LegoControlManagerEvent& p_param)
|
||||
{
|
||||
MxDSAction action; // Unused
|
||||
MxS32 objectId = p_param.GetClickedObjectId();
|
||||
|
||||
if (objectId == 18) {
|
||||
if (m_state->IsActive()) {
|
||||
Stop();
|
||||
}
|
||||
else {
|
||||
Play();
|
||||
}
|
||||
|
||||
if (GetCurrentWorld()) {
|
||||
#ifdef COMPAT_MODE
|
||||
MxNotificationParam param(c_notificationEndAction, this);
|
||||
GetCurrentWorld()->Notify(param);
|
||||
#else
|
||||
GetCurrentWorld()->Notify(MxNotificationParam(c_notificationType0, this));
|
||||
#endif
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1002ccc0
|
||||
MxLong Radio::HandleEndAction(MxEndActionNotificationParam& p_param)
|
||||
{
|
||||
if (m_state->IsActive() &&
|
||||
m_state->FUN_1002d0c0(p_param.GetAction()->GetAtomId(), p_param.GetAction()->GetObjectId())) {
|
||||
|
||||
MxDSAction action;
|
||||
action.SetAtomId(*g_jukeboxScript);
|
||||
action.SetObjectId(m_state->FUN_1002d090());
|
||||
action.SetLoopCount(1);
|
||||
|
||||
BackgroundAudioManager()->PlayMusic(action, 3, 4);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,115 @@
|
||||
#include "radiostate.h"
|
||||
|
||||
// STUB: LEGO1 0x1002ce10
|
||||
#include "jukebox.h"
|
||||
#include "legoomni.h"
|
||||
#include "mxtimer.h"
|
||||
|
||||
// GLOBAL: LEGO1 0x100f3218
|
||||
JukeBox::JukeBoxScript g_unk0x100f3218[6] = {
|
||||
JukeBox::e_legoRadioReminder1,
|
||||
JukeBox::e_legoRadioJingle1,
|
||||
JukeBox::e_legoRadioJingle2,
|
||||
JukeBox::e_legoRadioJingle3,
|
||||
JukeBox::e_legoRadioJingle4,
|
||||
JukeBox::e_legoRadioReminder2
|
||||
};
|
||||
|
||||
// GLOBAL: LEGO1 0x100f3230
|
||||
JukeBox::JukeBoxScript g_unk0x100f3230[14] = {
|
||||
JukeBox::e_legoRadioRacingAd,
|
||||
JukeBox::e_legoRadioNews1,
|
||||
JukeBox::e_legoRadioNews2,
|
||||
JukeBox::e_legoRadioPizzaAd1,
|
||||
JukeBox::e_legoRadioBricksterPSA,
|
||||
JukeBox::e_legoRadioSports1,
|
||||
JukeBox::e_legoRadioIntermission1,
|
||||
JukeBox::e_legoRadioIntermission2,
|
||||
JukeBox::e_legoRadioPizzaAd2,
|
||||
JukeBox::e_legoRadioWeatherReport,
|
||||
JukeBox::e_legoRadioSports2,
|
||||
JukeBox::e_legoRadioPizzaAd3,
|
||||
JukeBox::e_legoRadioIntermission3,
|
||||
JukeBox::e_legoRadioSuperStoreAd,
|
||||
};
|
||||
|
||||
// GLOBAL: LEGO1 0x100f3268
|
||||
JukeBox::JukeBoxScript g_unk0x100f3268[9] = {
|
||||
JukeBox::e_centralRoads,
|
||||
JukeBox::e_beachBlvd,
|
||||
JukeBox::e_residentialArea,
|
||||
JukeBox::e_legoRadioLuckyYou,
|
||||
JukeBox::e_legoRadioJazzInterlude,
|
||||
JukeBox::e_legoRadioPianoInterlude1,
|
||||
JukeBox::e_legoRadioPoliceStation,
|
||||
JukeBox::e_legoRadioPianoInterlude2,
|
||||
JukeBox::e_legoRadioCredits,
|
||||
};
|
||||
|
||||
// FUNCTION: LEGO1 0x1002ce10
|
||||
RadioState::RadioState()
|
||||
{
|
||||
// TODO
|
||||
srand(Timer()->GetTime());
|
||||
|
||||
MxS32 random = rand();
|
||||
m_unk0x2c = random % 3;
|
||||
|
||||
// TODO: Most likely inline function
|
||||
|
||||
m_unk0x08[0].m_unk0x04 = sizeof(g_unk0x100f3218) / sizeof(g_unk0x100f3218[0]);
|
||||
m_unk0x08[0].m_unk0x00 = g_unk0x100f3218;
|
||||
m_unk0x08[0].m_unk0x08 = 0;
|
||||
m_unk0x08[0].m_unk0x06 = 0;
|
||||
|
||||
random = rand();
|
||||
|
||||
m_unk0x08[1].m_unk0x08 = 0;
|
||||
m_unk0x08[1].m_unk0x06 = 0;
|
||||
m_unk0x08[1].m_unk0x04 = sizeof(g_unk0x100f3230) / sizeof(g_unk0x100f3230[0]);
|
||||
m_unk0x08[1].m_unk0x00 = g_unk0x100f3230;
|
||||
|
||||
m_unk0x08[0].m_unk0x08 = (MxU32) random % (sizeof(g_unk0x100f3218) / sizeof(g_unk0x100f3218[0]));
|
||||
random = rand();
|
||||
|
||||
m_unk0x08[2].m_unk0x08 = 0;
|
||||
m_unk0x08[2].m_unk0x06 = 0;
|
||||
m_unk0x08[2].m_unk0x04 = sizeof(g_unk0x100f3268) / sizeof(g_unk0x100f3268[0]);
|
||||
m_unk0x08[2].m_unk0x00 = g_unk0x100f3268;
|
||||
|
||||
m_unk0x08[1].m_unk0x08 = (MxU32) random % (sizeof(g_unk0x100f3230) / sizeof(g_unk0x100f3230[0]));
|
||||
random = rand();
|
||||
|
||||
m_unk0x08[2].m_unk0x08 = (MxU32) random % (sizeof(g_unk0x100f3268) / sizeof(g_unk0x100f3268[0]));
|
||||
|
||||
m_active = FALSE;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x1002cf50
|
||||
// FUNCTION: LEGO1 0x1002cf50
|
||||
MxBool RadioState::VTable0x14()
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1002d090
|
||||
MxU32 RadioState::FUN_1002d090()
|
||||
{
|
||||
if (m_unk0x2c == 2) {
|
||||
m_unk0x2c = 0;
|
||||
}
|
||||
else {
|
||||
m_unk0x2c++;
|
||||
}
|
||||
|
||||
return m_unk0x08[m_unk0x2c].FUN_10014d00();
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1002d0c0
|
||||
MxBool RadioState::FUN_1002d0c0(const MxAtomId& p_atom, MxU32 p_objectId)
|
||||
{
|
||||
if (*g_jukeboxScript == p_atom) {
|
||||
for (MxS16 i = 0; i < 3; i++)
|
||||
if (m_unk0x08[i].FUN_10014de0(p_objectId))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user