diff --git a/LEGO1/legoomni.cpp b/LEGO1/legoomni.cpp index a37d9776..a6c1461d 100644 --- a/LEGO1/legoomni.cpp +++ b/LEGO1/legoomni.cpp @@ -212,12 +212,29 @@ GifManager* GetGifManager() return LegoOmni::GetInstance()->GetGifManager(); } +// OFFSET: LEGO1 0x100158e0 +MxDSAction& GetCurrentAction() +{ + return LegoOmni::GetInstance()->GetCurrentAction(); +} + // OFFSET: LEGO1 0x10015900 MxTransitionManager* TransitionManager() { return LegoOmni::GetInstance()->GetTransitionManager(); } +// OFFSET: LEGO1 0x10015910 +void PlayMusic(MxU32 p_index) +{ + // index is the entityid of the music in jukebox.si + MxDSAction action; + action.SetAtomId(*g_jukeboxScript); + action.SetObjectId(p_index); + + LegoOmni::GetInstance()->GetBackgroundAudioManager()->PlayMusic(action, 5, 4); +} + // OFFSET: LEGO1 0x100c0280 MxDSObject* CreateStreamObject(MxDSFile* p_file, MxS16 p_ofs) { diff --git a/LEGO1/legoomni.h b/LEGO1/legoomni.h index b8b9c1d5..469fd8cb 100644 --- a/LEGO1/legoomni.h +++ b/LEGO1/legoomni.h @@ -79,6 +79,7 @@ class LegoOmni : public MxOmni { LegoGameState* GetGameState() { return m_gameState; } MxBackgroundAudioManager* GetBackgroundAudioManager() { return m_bkgAudioManager; } MxTransitionManager* GetTransitionManager() { return m_transitionManager; } + MxDSAction& GetCurrentAction() { return m_action; } private: undefined4 m_unk68; @@ -124,5 +125,6 @@ LegoPlantManager* PlantManager(); MxBool KeyValueStringParse(char*, const char*, const char*); LegoWorld* GetCurrentWorld(); GifManager* GetGifManager(); +MxDSAction& GetCurrentAction(); #endif // LEGOOMNI_H diff --git a/LEGO1/mxbackgroundaudiomanager.cpp b/LEGO1/mxbackgroundaudiomanager.cpp index a792abe1..d7e120ca 100644 --- a/LEGO1/mxbackgroundaudiomanager.cpp +++ b/LEGO1/mxbackgroundaudiomanager.cpp @@ -183,6 +183,41 @@ void MxBackgroundAudioManager::StopAction(MxParam& p) Lego()->HandleNotificationType2(p); } +// OFFSET: LEGO1 0x1007f2f0 +MxResult MxBackgroundAudioManager::PlayMusic(MxDSAction& p_action, undefined4 p_unknown, undefined4 p_unknown2) +{ + if (!m_musicEnabled) + { + return SUCCESS; + } + if (m_action2.GetObjectId() == -1 && m_action1.GetObjectId() != p_action.GetObjectId()) + { + MxDSAction action; + action.SetAtomId(GetCurrentAction().GetAtomId()); + action.SetObjectId(GetCurrentAction().GetObjectId()); + action.SetUnknown24(GetCurrentAction().GetUnknown24()); + + m_action2.SetAtomId(p_action.GetAtomId()); + m_action2.SetObjectId(p_action.GetObjectId()); + m_action2.SetUnknown84(this); + m_action2.SetUnknown8c(this); + + MxResult result = Start(&m_action2); + + GetCurrentAction().SetAtomId(action.GetAtomId()); + GetCurrentAction().SetObjectId(action.GetObjectId()); + GetCurrentAction().SetUnknown24(action.GetUnknown24()); + + if (result == SUCCESS) + { + m_unk13c = p_unknown2; + m_unk140 = p_unknown; + } + return result; + } + return FAILURE; +} + // OFFSET: LEGO1 0x1007ee40 STUB MxResult MxBackgroundAudioManager::Tickle() { diff --git a/LEGO1/mxbackgroundaudiomanager.h b/LEGO1/mxbackgroundaudiomanager.h index 97aade9c..002da4c6 100644 --- a/LEGO1/mxbackgroundaudiomanager.h +++ b/LEGO1/mxbackgroundaudiomanager.h @@ -32,6 +32,7 @@ class MxBackgroundAudioManager : public MxCore { void StartAction(MxParam& p); void StopAction(MxParam& p); + MxResult PlayMusic(MxDSAction& p_action, undefined4 p_unknown, undefined4 p_unknown2); virtual MxResult Tickle() override; __declspec(dllexport) void Enable(unsigned char p); diff --git a/LEGO1/mxdsaction.cpp b/LEGO1/mxdsaction.cpp index 6dc334ec..91db4e57 100644 --- a/LEGO1/mxdsaction.cpp +++ b/LEGO1/mxdsaction.cpp @@ -28,7 +28,7 @@ MxDSAction::MxDSAction() this->m_up.Fill(FLT_MAX); this->m_unk84 = NULL; this->m_unk88 = 0; - this->m_omni = NULL; + this->m_unk8c = NULL; this->m_unkTimingField = INT_MIN; } @@ -54,7 +54,7 @@ void MxDSAction::CopyFrom(MxDSAction& p_dsAction) AppendData(p_dsAction.m_extraLength, p_dsAction.m_extraData); this->m_unk84 = p_dsAction.m_unk84; this->m_unk88 = p_dsAction.m_unk88; - this->m_omni = p_dsAction.m_omni; + this->m_unk8c = p_dsAction.m_unk8c; this->m_unkTimingField = p_dsAction.m_unkTimingField; } diff --git a/LEGO1/mxdsaction.h b/LEGO1/mxdsaction.h index 72d7afac..c56a71e4 100644 --- a/LEGO1/mxdsaction.h +++ b/LEGO1/mxdsaction.h @@ -63,7 +63,7 @@ class MxDSAction : public MxDSObject { inline void SetLoopCount(MxS32 p_loopCount) { m_loopCount = p_loopCount; } inline const MxVector3Data& GetLocation() const { return m_location; } inline void SetUnknown84(MxCore* p_unk84) { m_unk84 = p_unk84; } - inline void SetOmni(MxOmni* p_omni) { m_omni = p_omni; } + inline void SetUnknown8c(MxCore* p_unk8c) { m_unk8c = p_unk8c; } inline MxBool IsLooping() const { return m_flags & Flag_Looping; } inline MxBool IsBit3() const { return m_flags & Flag_Bit3; } @@ -85,7 +85,7 @@ class MxDSAction : public MxDSObject { MxU16 m_extraLength; MxCore* m_unk84; undefined4 m_unk88; - MxOmni* m_omni; // 0x8c + MxCore* m_unk8c; protected: MxLong m_unkTimingField; // 0x90 diff --git a/LEGO1/mxpresenter.cpp b/LEGO1/mxpresenter.cpp index 13df6a60..89dfddc8 100644 --- a/LEGO1/mxpresenter.cpp +++ b/LEGO1/mxpresenter.cpp @@ -65,7 +65,7 @@ void MxPresenter::SendTo_unkPresenter(MxOmni* p_omni) NotificationManager()->Send(m_unkPresenter, &MxNotificationParam(MXPRESENTER_NOTIFICATION, this)); - m_action->SetOmni(p_omni ? p_omni : MxOmni::GetInstance()); + m_action->SetUnknown8c(p_omni ? p_omni : MxOmni::GetInstance()); m_unkPresenter = NULL; } }