Refactor JukeBox, add enum for music (#988)

* Refactor JukeBox, add enum for music

* add BETA annotation

* Fix BETA annotation

* Fix BETA annotation

* Fix
This commit is contained in:
Christian Semmler
2024-06-03 07:00:38 -04:00
committed by GitHub
parent 828b35e9d2
commit 73bb37596e
12 changed files with 102 additions and 105 deletions

View File

@@ -430,7 +430,7 @@ void IslePathActor::RegisterSpawnLocations()
JukeboxScript::c_noneJukebox
);
g_spawnLocations[27] = SpawnLocation(
LegoGameState::e_unk54,
LegoGameState::e_jukeboxExterior,
g_isleScript,
0,
"int36",

View File

@@ -55,37 +55,37 @@ void JukeBoxEntity::StartAction()
MxDSAction action;
BackgroundAudioManager()->Stop();
JukeBoxState* state = (JukeBoxState*) GameState()->GetState("JukeBoxState");
state->SetActive(TRUE);
state->m_active = TRUE;
switch (state->GetState()) {
case 0:
switch (state->m_music) {
case JukeBoxState::e_pasquell:
InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz001bd_RunAnim, NULL);
GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic1);
GameState()->m_jukeboxMusic = JukeboxScript::c_JBMusic1;
break;
case 1:
case JukeBoxState::e_right:
InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz006bd_RunAnim, NULL);
GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic2);
GameState()->m_jukeboxMusic = JukeboxScript::c_JBMusic2;
break;
case 2:
case JukeBoxState::e_decal:
InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz003bd_RunAnim, NULL);
GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic3);
GameState()->m_jukeboxMusic = JukeboxScript::c_JBMusic3;
break;
case 3:
case JukeBoxState::e_wallis:
InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz002bd_RunAnim, NULL);
GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic4);
GameState()->m_jukeboxMusic = JukeboxScript::c_JBMusic4;
break;
case 4:
case JukeBoxState::e_nelson:
InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz007bd_RunAnim, NULL);
GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic5);
GameState()->m_jukeboxMusic = JukeboxScript::c_JBMusic5;
break;
case 5:
case JukeBoxState::e_torpedos:
InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz004bd_RunAnim, NULL);
GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic6);
GameState()->m_jukeboxMusic = JukeboxScript::c_JBMusic6;
break;
}
action.SetAtomId(*g_jukeboxScript);
action.SetObjectId(GameState()->GetUnknown0x41c());
action.SetObjectId(GameState()->m_jukeboxMusic);
m_audioEnabled = BackgroundAudioManager()->GetEnabled();
if (!m_audioEnabled) {
@@ -100,30 +100,30 @@ void JukeBoxEntity::StopAction(JukeboxScript::Script p_script)
{
JukeBoxState* state = (JukeBoxState*) GameState()->GetState("JukeBoxState");
if (state && state->IsActive()) {
if (state && state->m_active) {
switch (p_script) {
case JukeboxScript::c_JBMusic1:
state->SetActive(FALSE);
state->m_active = FALSE;
InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz001bd_RunAnim, NULL);
break;
case JukeboxScript::c_JBMusic2:
state->SetActive(FALSE);
state->m_active = FALSE;
InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz006bd_RunAnim, NULL);
break;
case JukeboxScript::c_JBMusic3:
state->SetActive(FALSE);
state->m_active = FALSE;
InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz003bd_RunAnim, NULL);
break;
case JukeboxScript::c_JBMusic4:
state->SetActive(FALSE);
state->m_active = FALSE;
InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz002bd_RunAnim, NULL);
break;
case JukeboxScript::c_JBMusic5:
state->SetActive(FALSE);
state->m_active = FALSE;
InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz007bd_RunAnim, NULL);
break;
case JukeboxScript::c_JBMusic6:
state->SetActive(FALSE);
state->m_active = FALSE;
InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz004bd_RunAnim, NULL);
break;
}

View File

@@ -124,7 +124,7 @@ LegoGameState::LegoGameState()
m_actorId = 0;
m_savePath = NULL;
m_stateArray = NULL;
m_unk0x41c = JukeboxScript::c_noneJukebox;
m_jukeboxMusic = JukeboxScript::c_noneJukebox;
m_currentArea = e_undefined;
m_previousArea = e_undefined;
m_unk0x42c = e_undefined;
@@ -982,7 +982,7 @@ void LegoGameState::SwitchArea(Area p_area)
VideoManager()->SetUnk0x554(TRUE);
InvokeAction(Extra::ActionType::e_opendisk, *g_jukeboxwScript, JukeboxwScript::c__StartUp, NULL);
break;
case e_unk54:
case e_jukeboxExterior:
LoadIsle();
break;
case e_histbook:

View File

@@ -437,7 +437,7 @@ MxBool RemoveFromWorld(MxAtomId& p_entityAtom, MxS32 p_entityId, MxAtomId& p_wor
}
// FUNCTION: LEGO1 0x1003ef00
void FUN_1003ef00(MxBool p_enable)
void EnableAnimations(MxBool p_enable)
{
if (p_enable) {
AnimationManager()->Resume();

View File

@@ -100,7 +100,7 @@ MxResult Hospital::Create(MxDSAction& p_dsAction)
GameState()->StopArea(LegoGameState::e_previousArea);
InputManager()->Register(this);
FUN_1003ef00(FALSE);
EnableAnimations(FALSE);
return result;
}

View File

@@ -113,7 +113,7 @@ MxResult Isle::Create(MxDSAction& p_dsAction)
}
m_act1state = act1state;
FUN_1003ef00(TRUE);
EnableAnimations(TRUE);
GameState()->SetDirty(TRUE);
}
@@ -270,7 +270,7 @@ void Isle::ReadyWorld()
m_act1state->SetUnknown21(0);
}
else if (GameState()->GetLoadedAct() != LegoGameState::e_act1) {
FUN_1003ef00(TRUE);
EnableAnimations(TRUE);
FUN_10032620();
m_act1state->FUN_10034d00();
FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
@@ -548,7 +548,7 @@ void Isle::Enable(MxBool p_enable)
GameState()->StopArea(LegoGameState::e_previousArea);
GameState()->m_previousArea = GameState()->m_currentArea;
FUN_1003ef00(TRUE);
EnableAnimations(TRUE);
if (m_act1state->m_unk0x018 == 0) {
MxS32 locations[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
@@ -748,7 +748,7 @@ void Isle::Enable(MxBool p_enable)
}
m_act1state->m_unk0x018 = 0;
FUN_1003ef00(FALSE);
EnableAnimations(FALSE);
AnimationManager()->FUN_10064670(NULL);
break;
}
@@ -781,7 +781,7 @@ void Isle::Enable(MxBool p_enable)
}
m_act1state->m_unk0x018 = 0;
FUN_1003ef00(TRUE);
EnableAnimations(TRUE);
break;
}
case 7:
@@ -806,12 +806,12 @@ void Isle::Enable(MxBool p_enable)
m_act1state->m_unk0x018 = 0;
((IslePathActor*) CurrentActor())
->SpawnPlayer(
LegoGameState::e_unk54,
LegoGameState::e_jukeboxExterior,
TRUE,
IslePathActor::c_spawnBit1 | IslePathActor::c_playMusic | IslePathActor::c_spawnBit3
);
GameState()->m_currentArea = LegoGameState::e_unk66;
FUN_1003ef00(TRUE);
EnableAnimations(TRUE);
m_jukebox->StartAction();
break;
}

View File

@@ -58,7 +58,7 @@ MxResult JukeBox::Create(MxDSAction& p_dsAction)
m_state = (JukeBoxState*) GameState()->GetState("JukeBoxState");
if (!m_state) {
m_state = (JukeBoxState*) GameState()->CreateState("JukeBoxState");
m_state->SetState(0);
m_state->m_music = JukeBoxState::e_pasquell;
}
GameState()->SetCurrentArea(LegoGameState::e_jukeboxw);
@@ -89,24 +89,27 @@ MxLong JukeBox::Notify(MxParam& p_param)
}
// FUNCTION: LEGO1 0x1005d9f0
// FUNCTION: BETA10 0x10037e39
void JukeBox::ReadyWorld()
{
MxStillPresenter* presenter = NULL;
switch (m_state->GetState()) {
case 1:
switch (m_state->m_music) {
case JukeBoxState::e_pasquell:
break;
case JukeBoxState::e_right:
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Right_Bitmap");
break;
case 2:
case JukeBoxState::e_decal:
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Decal_Bitmap");
break;
case 3:
case JukeBoxState::e_wallis:
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Wallis_Bitmap");
break;
case 4:
case JukeBoxState::e_nelson:
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Nelson_Bitmap");
break;
case 5:
case JukeBoxState::e_torpedos:
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Torpedos_Bitmap");
break;
}
@@ -119,47 +122,48 @@ void JukeBox::ReadyWorld()
}
// FUNCTION: LEGO1 0x1005da70
// FUNCTION: BETA10 0x10037f6d
MxBool JukeBox::HandleControl(LegoControlManagerEvent& p_param)
{
MxStillPresenter* presenter;
if (p_param.GetUnknown0x28() == 1) {
switch (p_param.GetClickedObjectId()) {
if (p_param.m_unk0x28 == 1) {
switch (p_param.m_clickedObjectId) {
case JukeboxwScript::c_Dback_Ctl:
switch (m_state->GetState()) {
case JukeboxScript::c_MusicTheme1:
m_state->SetState(JukeboxScript::c_ResidentalArea_Music);
switch (m_state->m_music) {
case JukeBoxState::e_pasquell:
m_state->m_music = JukeBoxState::e_torpedos;
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Torpedos_Bitmap");
presenter->Enable(TRUE);
break;
case JukeboxScript::c_MusicTheme3:
m_state->SetState(JukeboxScript::c_MusicTheme1);
case JukeBoxState::e_right:
m_state->m_music = JukeBoxState::e_pasquell;
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Right_Bitmap");
presenter->Enable(FALSE);
break;
case JukeboxScript::c_Act2Cave:
m_state->SetState(JukeboxScript::c_MusicTheme3);
case JukeBoxState::e_decal:
m_state->m_music = JukeBoxState::e_right;
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Decal_Bitmap");
presenter->Enable(FALSE);
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Right_Bitmap");
presenter->Enable(TRUE);
break;
case JukeboxScript::c_BrickstrChase:
m_state->SetState(JukeboxScript::c_Act2Cave);
case JukeBoxState::e_wallis:
m_state->m_music = JukeBoxState::e_decal;
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Wallis_Bitmap");
presenter->Enable(FALSE);
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Decal_Bitmap");
presenter->Enable(TRUE);
break;
case JukeboxScript::c_BrickHunt:
m_state->SetState(JukeboxScript::c_BrickstrChase);
case JukeBoxState::e_nelson:
m_state->m_music = JukeBoxState::e_wallis;
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Nelson_Bitmap");
presenter->Enable(FALSE);
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Wallis_Bitmap");
presenter->Enable(TRUE);
break;
case JukeboxScript::c_ResidentalArea_Music:
m_state->SetState(JukeboxScript::c_BrickHunt);
case JukeBoxState::e_torpedos:
m_state->m_music = JukeBoxState::e_nelson;
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Torpedos_Bitmap");
presenter->Enable(FALSE);
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Nelson_Bitmap");
@@ -168,52 +172,51 @@ MxBool JukeBox::HandleControl(LegoControlManagerEvent& p_param)
}
break;
case JukeboxwScript::c_Dfwd_Ctl:
switch (m_state->GetState()) {
case JukeboxScript::c_MusicTheme1:
m_state->SetState(JukeboxScript::c_MusicTheme3);
switch (m_state->m_music) {
case JukeBoxState::e_pasquell:
m_state->m_music = JukeBoxState::e_right;
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Right_Bitmap");
presenter->Enable(TRUE);
break;
case JukeboxScript::c_MusicTheme3:
m_state->SetState(JukeboxScript::c_Act2Cave);
case JukeBoxState::e_right:
m_state->m_music = JukeBoxState::e_decal;
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Right_Bitmap");
presenter->Enable(FALSE);
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Decal_Bitmap");
presenter->Enable(TRUE);
break;
case JukeboxScript::c_Act2Cave:
m_state->SetState(JukeboxScript::c_BrickstrChase);
case JukeBoxState::e_decal:
m_state->m_music = JukeBoxState::e_wallis;
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Decal_Bitmap");
presenter->Enable(FALSE);
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Wallis_Bitmap");
presenter->Enable(TRUE);
break;
case JukeboxScript::c_BrickstrChase:
m_state->SetState(JukeboxScript::c_BrickHunt);
case JukeBoxState::e_wallis:
m_state->m_music = JukeBoxState::e_nelson;
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Wallis_Bitmap");
presenter->Enable(FALSE);
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Nelson_Bitmap");
presenter->Enable(TRUE);
break;
case JukeboxScript::c_BrickHunt:
m_state->SetState(JukeboxScript::c_ResidentalArea_Music);
case JukeBoxState::e_nelson:
m_state->m_music = JukeBoxState::e_torpedos;
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Nelson_Bitmap");
presenter->Enable(FALSE);
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Torpedos_Bitmap");
presenter->Enable(TRUE);
break;
case JukeboxScript::c_ResidentalArea_Music:
m_state->SetState(JukeboxScript::c_MusicTheme1);
case JukeBoxState::e_torpedos:
m_state->m_music = JukeBoxState::e_pasquell;
presenter = (MxStillPresenter*) Find("MxStillPresenter", "Torpedos_Bitmap");
presenter->Enable(FALSE);
break;
}
break;
case JukeboxwScript::c_Note_Ctl:
LegoGameState* gameState = GameState();
Act1State* act1State = (Act1State*) gameState->GetState("Act1State");
act1State->SetUnknown18(11);
m_destLocation = LegoGameState::Area::e_unk54;
Act1State* act1State = (Act1State*) GameState()->GetState("Act1State");
act1State->m_unk0x018 = 11;
m_destLocation = LegoGameState::Area::e_jukeboxExterior;
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, 0, FALSE);
break;
}