diff --git a/LEGO1/lego/legoomni/include/infocenterstate.h b/LEGO1/lego/legoomni/include/infocenterstate.h index 977ea3d1..1bf64cc9 100644 --- a/LEGO1/lego/legoomni/include/infocenterstate.h +++ b/LEGO1/lego/legoomni/include/infocenterstate.h @@ -30,9 +30,9 @@ public: inline MxS16 GetInfocenterBufferSize() { return sizeof(m_buffer) / sizeof(m_buffer[0]); } inline MxStillPresenter* GetInfocenterBufferElement(MxS32 p_index) { return m_buffer[p_index]; } - inline Shuffle& GetUnknown0x08() { return m_unk0x08; } - inline Shuffle& GetUnknown0x14() { return m_unk0x14; } - inline Shuffle& GetUnknown0x68() { return m_unk0x68; } + inline Playlist& GetUnknown0x08() { return m_unk0x08; } + inline Playlist& GetUnknown0x14() { return m_unk0x14; } + inline Playlist& GetUnknown0x68() { return m_unk0x68; } inline MxU32 GetUnknown0x74() { return m_unk0x74; } inline void SetUnknown0x74(MxU32 p_unk0x74) { m_unk0x74 = p_unk0x74; } @@ -41,11 +41,11 @@ public: // InfocenterState::`scalar deleting destructor' private: - Shuffle m_unk0x08; // 0x08 - Shuffle m_unk0x14; // 0x14 - Shuffle m_unk0x20[3]; // 0x20 - Shuffle m_unk0x44[3]; // 0x44 - Shuffle m_unk0x68; // 0x68 + Playlist m_unk0x08; // 0x08 + Playlist m_unk0x14; // 0x14 + Playlist m_unk0x20[3]; // 0x20 + Playlist m_unk0x44[3]; // 0x44 + Playlist m_unk0x68; // 0x68 MxU32 m_unk0x74; // 0x74 MxStillPresenter* m_buffer[7]; // 0x78 }; diff --git a/LEGO1/lego/legoomni/include/legostate.h b/LEGO1/lego/legoomni/include/legostate.h index 42fd0fe9..2ed94a3e 100644 --- a/LEGO1/lego/legoomni/include/legostate.h +++ b/LEGO1/lego/legoomni/include/legostate.h @@ -45,45 +45,52 @@ public: // LegoState::`scalar deleting destructor' // SIZE 0x0c - class Shuffle { + class Playlist { public: + enum Mode { + e_loop, + e_once, + e_random, + e_loopSkipFirst + }; + // FUNCTION: LEGO1 0x10017c00 - Shuffle() + Playlist() { m_objectIds = NULL; m_length = 0; - m_unk0x06 = 0; - m_unk0x08 = 0; + m_mode = e_loop; + m_nextIndex = 0; } - Shuffle(MxU32* p_objectIds, MxU16 p_length) + Playlist(MxU32* p_objectIds, MxS16 p_length) { m_objectIds = p_objectIds; m_length = p_length; - m_unk0x06 = 0; - m_unk0x08 = 0; + m_mode = e_loop; + m_nextIndex = 0; } // FUNCTION: LEGO1 0x10071800 - Shuffle& operator=(const Shuffle& p_shuffle) + Playlist& operator=(const Playlist& p_shuffle) { m_objectIds = p_shuffle.m_objectIds; m_length = p_shuffle.m_length; - m_unk0x08 = p_shuffle.m_unk0x08; - m_unk0x06 = p_shuffle.m_unk0x06; + m_nextIndex = p_shuffle.m_nextIndex; + m_mode = p_shuffle.m_mode; return *this; } - MxU32 FUN_10014d00(); - MxBool FUN_10014de0(MxU32 p_objectId); + MxU32 Next(); + MxBool Contains(MxU32 p_objectId); - inline void SetUnknown0x08(MxU16 p_unk0x08) { m_unk0x08 = p_unk0x08; } + inline void SetUnknown0x08(MxS16 p_unk0x08) { m_nextIndex = p_unk0x08; } private: - MxU32* m_objectIds; // 0x00 - MxU16 m_length; // 0x04 - undefined2 m_unk0x06; // 0x06 - MxU16 m_unk0x08; // 0x08 + MxU32* m_objectIds; // 0x00 + MxS16 m_length; // 0x04 + MxS16 m_mode; // 0x06 + MxS16 m_nextIndex; // 0x08 }; }; diff --git a/LEGO1/lego/legoomni/include/legovehiclebuildstate.h b/LEGO1/lego/legoomni/include/legovehiclebuildstate.h index 03e72ae9..229fdcfb 100644 --- a/LEGO1/lego/legoomni/include/legovehiclebuildstate.h +++ b/LEGO1/lego/legoomni/include/legovehiclebuildstate.h @@ -29,7 +29,7 @@ public: // LegoVehicleBuildState::`scalar deleting destructor' private: - Shuffle m_unk0x08[4]; // 0x08 + Playlist m_unk0x08[4]; // 0x08 // This can be one of the following: // * LegoRaceCarBuildState diff --git a/LEGO1/lego/legoomni/include/radiostate.h b/LEGO1/lego/legoomni/include/radiostate.h index 5ffd0176..6dcdafd9 100644 --- a/LEGO1/lego/legoomni/include/radiostate.h +++ b/LEGO1/lego/legoomni/include/radiostate.h @@ -36,9 +36,9 @@ public: MxBool FUN_1002d0c0(const MxAtomId& p_atom, MxU32 p_objectId); private: - Shuffle m_unk0x08[3]; // 0x08 - MxS16 m_unk0x2c; // 0x2c - MxBool m_active; // 0x2e + Playlist m_unk0x08[3]; // 0x08 + MxS16 m_unk0x2c; // 0x2c + MxBool m_active; // 0x2e }; #endif // RADIOSTATE_H diff --git a/LEGO1/lego/legoomni/src/common/legostate.cpp b/LEGO1/lego/legoomni/src/common/legostate.cpp index fe418e50..a8c2cc6b 100644 --- a/LEGO1/lego/legoomni/src/common/legostate.cpp +++ b/LEGO1/lego/legoomni/src/common/legostate.cpp @@ -1,18 +1,59 @@ #include "legostate.h" -DECOMP_SIZE_ASSERT(LegoState, 0x08) -DECOMP_SIZE_ASSERT(LegoState::Shuffle, 0x0c) +#include -// STUB: LEGO1 0x10014d00 -MxU32 LegoState::Shuffle::FUN_10014d00() +DECOMP_SIZE_ASSERT(LegoState, 0x08) +DECOMP_SIZE_ASSERT(LegoState::Playlist, 0x0c) + +// FUNCTION: LEGO1 0x10014d00 +MxU32 LegoState::Playlist::Next() { - // TODO - return m_objectIds[0]; + MxU32 objectId; + + switch (m_mode) { + case e_loop: + objectId = m_objectIds[m_nextIndex]; + if (m_nextIndex - m_length == -1) { + m_nextIndex = 0; + } + else { + m_nextIndex++; + } + break; + + case e_once: + objectId = m_objectIds[m_nextIndex]; + if (m_length > m_nextIndex + 1) { + m_nextIndex++; + } + break; + + case e_random: + m_nextIndex = rand() % m_length; + objectId = m_objectIds[m_nextIndex]; + break; + + case e_loopSkipFirst: + objectId = m_objectIds[m_nextIndex]; + if (m_nextIndex - m_length == -1) { + m_nextIndex = 1; + } + else { + m_nextIndex++; + } + } + + return objectId; } -// STUB: LEGO1 0x10014de0 -MxBool LegoState::Shuffle::FUN_10014de0(MxU32 p_objectId) +// FUNCTION: LEGO1 0x10014de0 +MxBool LegoState::Playlist::Contains(MxU32 p_objectId) { - // TODO + for (MxS16 i = 0; i < m_length; i++) { + if (m_objectIds[i] == p_objectId) { + return TRUE; + } + } + return FALSE; } diff --git a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp index 3913d355..ba357dc3 100644 --- a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp +++ b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp @@ -538,7 +538,7 @@ MxU8 Infocenter::HandleClick(LegoControlManagerEvent& p_param) m_transitionDestination = 5; } else { - MxU32 objectId = m_infocenterState->GetUnknown0x68().FUN_10014d00(); + MxU32 objectId = m_infocenterState->GetUnknown0x68().Next(); PlayAction((InfomainScript) objectId); } @@ -553,7 +553,7 @@ MxU8 Infocenter::HandleClick(LegoControlManagerEvent& p_param) m_transitionDestination = 13; } else { - MxU32 objectId = m_infocenterState->GetUnknown0x68().FUN_10014d00(); + MxU32 objectId = m_infocenterState->GetUnknown0x68().Next(); PlayAction((InfomainScript) objectId); } @@ -658,10 +658,10 @@ MxLong Infocenter::HandleNotification0(MxNotificationParam& p_param) InfomainScript objectId; if (GameState()->GetUnknown10()) { - objectId = (InfomainScript) m_infocenterState->GetUnknown0x14().FUN_10014d00(); + objectId = (InfomainScript) m_infocenterState->GetUnknown0x14().Next(); } else { - objectId = (InfomainScript) m_infocenterState->GetUnknown0x08().FUN_10014d00(); + objectId = (InfomainScript) m_infocenterState->GetUnknown0x08().Next(); } PlayAction(objectId); diff --git a/LEGO1/lego/legoomni/src/infocenter/infocenterstate.cpp b/LEGO1/lego/legoomni/src/infocenter/infocenterstate.cpp index a6de4a6f..55f4f4d8 100644 --- a/LEGO1/lego/legoomni/src/infocenter/infocenterstate.cpp +++ b/LEGO1/lego/legoomni/src/infocenter/infocenterstate.cpp @@ -84,26 +84,26 @@ Infocenter::InfomainScript g_unk0x100f7760[2] = {Infocenter::c_bricksterDialogue // FUNCTION: LEGO1 0x10071600 InfocenterState::InfocenterState() { - m_unk0x08 = LegoState::Shuffle((MxU32*) g_unk0x100f76a8, sizeof(g_unk0x100f76a8) / sizeof(g_unk0x100f76a8[0])); + m_unk0x08 = LegoState::Playlist((MxU32*) g_unk0x100f76a8, sizeof(g_unk0x100f76a8) / sizeof(g_unk0x100f76a8[0])); - m_unk0x14 = LegoState::Shuffle((MxU32*) g_unk0x100f76e0, sizeof(g_unk0x100f76e0) / sizeof(g_unk0x100f76e0[0]) - 1); + m_unk0x14 = LegoState::Playlist((MxU32*) g_unk0x100f76e0, sizeof(g_unk0x100f76e0) / sizeof(g_unk0x100f76e0[0]) - 1); m_unk0x20[0] = - LegoState::Shuffle((MxU32*) g_unk0x100f76f8, sizeof(g_unk0x100f76f8) / sizeof(g_unk0x100f76f8[0]) - 1); + LegoState::Playlist((MxU32*) g_unk0x100f76f8, sizeof(g_unk0x100f76f8) / sizeof(g_unk0x100f76f8[0]) - 1); m_unk0x20[1] = - LegoState::Shuffle((MxU32*) g_unk0x100f7710, sizeof(g_unk0x100f7710) / sizeof(g_unk0x100f7710[0]) - 1); + LegoState::Playlist((MxU32*) g_unk0x100f7710, sizeof(g_unk0x100f7710) / sizeof(g_unk0x100f7710[0]) - 1); - m_unk0x20[2] = LegoState::Shuffle((MxU32*) g_unk0x100f7720, sizeof(g_unk0x100f7720) / sizeof(g_unk0x100f7720[0])); + m_unk0x20[2] = LegoState::Playlist((MxU32*) g_unk0x100f7720, sizeof(g_unk0x100f7720) / sizeof(g_unk0x100f7720[0])); - m_unk0x44[0] = LegoState::Shuffle((MxU32*) g_unk0x100f7730, sizeof(g_unk0x100f7730) / sizeof(g_unk0x100f7730[0])); + m_unk0x44[0] = LegoState::Playlist((MxU32*) g_unk0x100f7730, sizeof(g_unk0x100f7730) / sizeof(g_unk0x100f7730[0])); - m_unk0x44[1] = LegoState::Shuffle((MxU32*) g_unk0x100f7740, sizeof(g_unk0x100f7740) / sizeof(g_unk0x100f7740[0])); + m_unk0x44[1] = LegoState::Playlist((MxU32*) g_unk0x100f7740, sizeof(g_unk0x100f7740) / sizeof(g_unk0x100f7740[0])); m_unk0x44[2] = - LegoState::Shuffle((MxU32*) g_unk0x100f7750, sizeof(g_unk0x100f7750) / sizeof(g_unk0x100f7750[0]) - 1); + LegoState::Playlist((MxU32*) g_unk0x100f7750, sizeof(g_unk0x100f7750) / sizeof(g_unk0x100f7750[0]) - 1); - m_unk0x68 = LegoState::Shuffle((MxU32*) g_unk0x100f7760, sizeof(g_unk0x100f7760) / sizeof(g_unk0x100f7760[0])); + m_unk0x68 = LegoState::Playlist((MxU32*) g_unk0x100f7760, sizeof(g_unk0x100f7760) / sizeof(g_unk0x100f7760[0])); memset(m_buffer, 0, sizeof(m_buffer)); } diff --git a/LEGO1/lego/legoomni/src/isle/radiostate.cpp b/LEGO1/lego/legoomni/src/isle/radiostate.cpp index 676bd753..077864a7 100644 --- a/LEGO1/lego/legoomni/src/isle/radiostate.cpp +++ b/LEGO1/lego/legoomni/src/isle/radiostate.cpp @@ -53,13 +53,13 @@ RadioState::RadioState() MxS32 random = rand(); m_unk0x2c = random % 3; - m_unk0x08[0] = LegoState::Shuffle((MxU32*) g_unk0x100f3218, sizeof(g_unk0x100f3218) / sizeof(g_unk0x100f3218[0])); + m_unk0x08[0] = LegoState::Playlist((MxU32*) g_unk0x100f3218, sizeof(g_unk0x100f3218) / sizeof(g_unk0x100f3218[0])); m_unk0x08[0].SetUnknown0x08(rand() % (sizeof(g_unk0x100f3218) / sizeof(g_unk0x100f3218[0]))); - m_unk0x08[1] = LegoState::Shuffle((MxU32*) g_unk0x100f3230, sizeof(g_unk0x100f3230) / sizeof(g_unk0x100f3230[0])); + m_unk0x08[1] = LegoState::Playlist((MxU32*) g_unk0x100f3230, sizeof(g_unk0x100f3230) / sizeof(g_unk0x100f3230[0])); m_unk0x08[1].SetUnknown0x08(rand() % (sizeof(g_unk0x100f3230) / sizeof(g_unk0x100f3230[0]))); - m_unk0x08[2] = LegoState::Shuffle((MxU32*) g_unk0x100f3268, sizeof(g_unk0x100f3268) / sizeof(g_unk0x100f3268[0])); + m_unk0x08[2] = LegoState::Playlist((MxU32*) g_unk0x100f3268, sizeof(g_unk0x100f3268) / sizeof(g_unk0x100f3268[0])); m_unk0x08[2].SetUnknown0x08(rand() % (sizeof(g_unk0x100f3268) / sizeof(g_unk0x100f3268[0]))); m_active = FALSE; @@ -81,7 +81,7 @@ MxU32 RadioState::FUN_1002d090() m_unk0x2c++; } - return m_unk0x08[m_unk0x2c].FUN_10014d00(); + return m_unk0x08[m_unk0x2c].Next(); } // FUNCTION: LEGO1 0x1002d0c0 @@ -89,7 +89,7 @@ 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)) { + if (m_unk0x08[i].Contains(p_objectId)) { return TRUE; } }