From fb2e9fb5ec8512d04da7d028198ac8f97535eedf Mon Sep 17 00:00:00 2001 From: Ramen2X Date: Fri, 27 Dec 2024 13:00:56 -0500 Subject: [PATCH 01/15] rename MxSmack to MxSmk (#1288) * rename MxSmack to MxSmk * format --- CMakeLists.txt | 2 +- LEGO1/omni/include/mxbitmap.h | 2 +- LEGO1/omni/include/{mxsmack.h => mxsmk.h} | 14 ++-- LEGO1/omni/include/mxsmkpresenter.h | 4 +- .../omni/src/video/mxloopingsmkpresenter.cpp | 4 +- .../omni/src/video/{mxsmack.cpp => mxsmk.cpp} | 80 +++++++++---------- LEGO1/omni/src/video/mxsmkpresenter.cpp | 20 ++--- 7 files changed, 63 insertions(+), 63 deletions(-) rename LEGO1/omni/include/{mxsmack.h => mxsmk.h} (85%) rename LEGO1/omni/src/video/{mxsmack.cpp => mxsmk.cpp} (74%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 65e55304..e2fc1192 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -261,7 +261,7 @@ function(add_lego_libraries NAME) LEGO1/omni/src/stream/mxstreamchunk.cpp LEGO1/omni/src/video/mxregioncursor.cpp LEGO1/omni/src/video/mxregion.cpp - LEGO1/omni/src/video/mxsmack.cpp + LEGO1/omni/src/video/mxsmk.cpp LEGO1/omni/src/stream/mxramstreamcontroller.cpp LEGO1/omni/src/stream/mxdsbuffer.cpp LEGO1/omni/src/stream/mxdiskstreamcontroller.cpp diff --git a/LEGO1/omni/include/mxbitmap.h b/LEGO1/omni/include/mxbitmap.h index 5df4c8ba..da42e3c3 100644 --- a/LEGO1/omni/include/mxbitmap.h +++ b/LEGO1/omni/include/mxbitmap.h @@ -90,7 +90,7 @@ public: // DECOMP: This could be a free function. It is static here because it has no // reference to "this". In the beta it is called in two places: // 1. GetBmiHeightAbs - // 2. MxSmack::LoadFrame + // 2. MxSmk::LoadFrame // FUNCTION: BETA10 0x1002c690 static MxLong HeightAbs(MxLong p_value) { return p_value > 0 ? p_value : -p_value; } diff --git a/LEGO1/omni/include/mxsmack.h b/LEGO1/omni/include/mxsmk.h similarity index 85% rename from LEGO1/omni/include/mxsmack.h rename to LEGO1/omni/include/mxsmk.h index e7fdf3ce..ec611f97 100644 --- a/LEGO1/omni/include/mxsmack.h +++ b/LEGO1/omni/include/mxsmk.h @@ -1,5 +1,5 @@ -#ifndef MXSMACK_H -#define MXSMACK_H +#ifndef MXSMK_H +#define MXSMK_H #include "decomp.h" #include "mxrectlist.h" @@ -28,7 +28,7 @@ extern "C" } // SIZE 0x6b8 -struct MxSmack { +struct MxSmk { SmackTag m_smackTag; // 0x00 undefined m_unk0x390[784]; // 0x390 MxU32* m_frameSizes; // 0x6a0 @@ -38,12 +38,12 @@ struct MxSmack { MxU32 m_maxFrameSize; // 0x6b0 MxU8* m_unk0x6b4; // 0x6b4 - static MxResult LoadHeader(MxU8* p_data, MxSmack* p_mxSmack); - static void Destroy(MxSmack* p_mxSmack); + static MxResult LoadHeader(MxU8* p_data, MxSmk* p_mxSmk); + static void Destroy(MxSmk* p_mxSmk); static MxResult LoadFrame( MxBITMAPINFO* p_bitmapInfo, MxU8* p_bitmapData, - MxSmack* p_mxSmack, + MxSmk* p_mxSmk, MxU8* p_chunkData, MxBool p_paletteChanged, MxRectList* p_list @@ -51,4 +51,4 @@ struct MxSmack { static MxBool GetRect(MxU8* p_unk0x6b4, MxU16* p_und, u32* p_smackRect, MxRect32* p_rect); }; -#endif // MXSMACK_H +#endif // MXSMK_H diff --git a/LEGO1/omni/include/mxsmkpresenter.h b/LEGO1/omni/include/mxsmkpresenter.h index 01b6744d..53f7831f 100644 --- a/LEGO1/omni/include/mxsmkpresenter.h +++ b/LEGO1/omni/include/mxsmkpresenter.h @@ -2,7 +2,7 @@ #define MXSMKPRESENTER_H #include "decomp.h" -#include "mxsmack.h" +#include "mxsmk.h" #include "mxvideopresenter.h" // VTABLE: LEGO1 0x100dc348 @@ -48,7 +48,7 @@ private: void Destroy(MxBool p_fromDestructor); protected: - MxSmack m_mxSmack; // 0x64 + MxSmk m_mxSmk; // 0x64 MxU32 m_currentFrame; // 0x71c }; diff --git a/LEGO1/omni/src/video/mxloopingsmkpresenter.cpp b/LEGO1/omni/src/video/mxloopingsmkpresenter.cpp index ca043243..72f663e0 100644 --- a/LEGO1/omni/src/video/mxloopingsmkpresenter.cpp +++ b/LEGO1/omni/src/video/mxloopingsmkpresenter.cpp @@ -41,10 +41,10 @@ void MxLoopingSmkPresenter::Destroy(MxBool p_fromDestructor) // FUNCTION: LEGO1 0x100b4a00 void MxLoopingSmkPresenter::VTable0x88() { - if (m_mxSmack.m_smackTag.Frames == m_currentFrame) { + if (m_mxSmk.m_smackTag.Frames == m_currentFrame) { m_currentFrame = 0; // TODO: struct incorrect, Palette at wrong offset? - memset(&m_mxSmack.m_smackTag.Palette[4], 0, sizeof(m_mxSmack.m_smackTag.Palette)); + memset(&m_mxSmk.m_smackTag.Palette[4], 0, sizeof(m_mxSmk.m_smackTag.Palette)); } } diff --git a/LEGO1/omni/src/video/mxsmack.cpp b/LEGO1/omni/src/video/mxsmk.cpp similarity index 74% rename from LEGO1/omni/src/video/mxsmack.cpp rename to LEGO1/omni/src/video/mxsmk.cpp index d0a9480c..0f2bdd77 100644 --- a/LEGO1/omni/src/video/mxsmack.cpp +++ b/LEGO1/omni/src/video/mxsmk.cpp @@ -1,15 +1,15 @@ -#include "mxsmack.h" +#include "mxsmk.h" #include "mxbitmap.h" #include DECOMP_SIZE_ASSERT(SmackTag, 0x390); -DECOMP_SIZE_ASSERT(MxSmack, 0x6b8); +DECOMP_SIZE_ASSERT(MxSmk, 0x6b8); // FUNCTION: LEGO1 0x100c5a90 // FUNCTION: BETA10 0x10151e70 -MxResult MxSmack::LoadHeader(MxU8* p_data, MxSmack* p_mxSmack) +MxResult MxSmk::LoadHeader(MxU8* p_data, MxSmk* p_mxSmk) { // Macros for readability // If bit0 of SmackerType is set, there is an extra frame ("ring frame") @@ -29,15 +29,15 @@ MxResult MxSmack::LoadHeader(MxU8* p_data, MxSmack* p_mxSmack) MxU32 size; MxS32 width; - if (!p_data || !p_mxSmack) { + if (!p_data || !p_mxSmk) { return FAILURE; } - SmackTag* smackTag = &p_mxSmack->m_smackTag; - p_mxSmack->m_frameTypes = NULL; - p_mxSmack->m_frameSizes = NULL; - p_mxSmack->m_huffmanTrees = NULL; - p_mxSmack->m_huffmanTables = NULL; + SmackTag* smackTag = &p_mxSmk->m_smackTag; + p_mxSmk->m_frameTypes = NULL; + p_mxSmk->m_frameSizes = NULL; + p_mxSmk->m_huffmanTrees = NULL; + p_mxSmk->m_huffmanTables = NULL; memcpy(smackTag, p_data, SmackHeaderSize(smackTag)); p_data += SmackHeaderSize(smackTag); @@ -52,11 +52,11 @@ MxResult MxSmack::LoadHeader(MxU8* p_data, MxSmack* p_mxSmack) memcpy(frameSizes, p_data, FRAME_COUNT(smackTag) * sizeof(MxU32)); p_data += FRAME_COUNT(smackTag) * sizeof(MxU32); - p_mxSmack->m_maxFrameSize = 0; + p_mxSmk->m_maxFrameSize = 0; for (i = 0; i < FRAME_COUNT(smackTag); i++) { - if (p_mxSmack->m_maxFrameSize < frameSizes[i]) { - p_mxSmack->m_maxFrameSize = frameSizes[i]; + if (p_mxSmk->m_maxFrameSize < frameSizes[i]) { + p_mxSmk->m_maxFrameSize = frameSizes[i]; } } @@ -82,17 +82,17 @@ MxResult MxSmack::LoadHeader(MxU8* p_data, MxSmack* p_mxSmack) p_data += smackTag->tablesize; sizetables = SmackGetSizeTables(); - p_mxSmack->m_huffmanTables = + p_mxSmk->m_huffmanTables = new MxU8[smackTag->codesize + smackTag->detailsize + smackTag->typesize + smackTag->absize + sizetables]; - if (!p_mxSmack->m_huffmanTables) { + if (!p_mxSmk->m_huffmanTables) { result = FAILURE; goto done; } SmackDoTables( huffmanTrees, - p_mxSmack->m_huffmanTables, + p_mxSmk->m_huffmanTables, smackTag->codesize, smackTag->absize, smackTag->detailsize, @@ -100,11 +100,11 @@ MxResult MxSmack::LoadHeader(MxU8* p_data, MxSmack* p_mxSmack) ); size = SmackGetSizeDeltas(smackTag->Width, smackTag->Height) + 32; - p_mxSmack->m_unk0x6b4 = new MxU8[size]; - memset(p_mxSmack->m_unk0x6b4, 0, size); + p_mxSmk->m_unk0x6b4 = new MxU8[size]; + memset(p_mxSmk->m_unk0x6b4, 0, size); - width = p_mxSmack->m_smackTag.Width; - data = (MxU32*) p_mxSmack->m_unk0x6b4; + width = p_mxSmk->m_smackTag.Width; + data = (MxU32*) p_mxSmk->m_unk0x6b4; *data = 1; data++; @@ -128,9 +128,9 @@ MxResult MxSmack::LoadHeader(MxU8* p_data, MxSmack* p_mxSmack) *data = smackTag->Height; done: - p_mxSmack->m_frameTypes = frameTypes; - p_mxSmack->m_frameSizes = frameSizes; - p_mxSmack->m_huffmanTrees = huffmanTrees; + p_mxSmk->m_frameTypes = frameTypes; + p_mxSmk->m_frameSizes = frameSizes; + p_mxSmk->m_huffmanTrees = huffmanTrees; return result; #undef FRAME_COUNT @@ -138,38 +138,38 @@ done: // FUNCTION: LEGO1 0x100c5d40 // FUNCTION: BETA10 0x10152298 -void MxSmack::Destroy(MxSmack* p_mxSmack) +void MxSmk::Destroy(MxSmk* p_mxSmk) { - if (p_mxSmack->m_frameSizes) { - delete[] p_mxSmack->m_frameSizes; + if (p_mxSmk->m_frameSizes) { + delete[] p_mxSmk->m_frameSizes; } - if (p_mxSmack->m_frameTypes) { - delete[] p_mxSmack->m_frameTypes; + if (p_mxSmk->m_frameTypes) { + delete[] p_mxSmk->m_frameTypes; } - if (p_mxSmack->m_huffmanTrees) { - delete[] p_mxSmack->m_huffmanTrees; + if (p_mxSmk->m_huffmanTrees) { + delete[] p_mxSmk->m_huffmanTrees; } - if (p_mxSmack->m_huffmanTables) { - delete[] p_mxSmack->m_huffmanTables; + if (p_mxSmk->m_huffmanTables) { + delete[] p_mxSmk->m_huffmanTables; } - if (p_mxSmack->m_unk0x6b4) { - delete[] p_mxSmack->m_unk0x6b4; + if (p_mxSmk->m_unk0x6b4) { + delete[] p_mxSmk->m_unk0x6b4; } } // FUNCTION: LEGO1 0x100c5db0 // FUNCTION: BETA10 0x10152391 -MxResult MxSmack::LoadFrame( +MxResult MxSmk::LoadFrame( MxBITMAPINFO* p_bitmapInfo, MxU8* p_bitmapData, - MxSmack* p_mxSmack, + MxSmk* p_mxSmk, MxU8* p_chunkData, MxBool p_paletteChanged, MxRectList* p_list ) { p_bitmapInfo->m_bmiHeader.biHeight = -MxBitmap::HeightAbs(p_bitmapInfo->m_bmiHeader.biHeight); - *(MxU8**) (p_mxSmack->m_unk0x6b4 + 4) = p_bitmapData; + *(MxU8**) (p_mxSmk->m_unk0x6b4 + 4) = p_bitmapData; // Reference: https://wiki.multimedia.cx/index.php/Smacker#Palette_Chunk if (p_paletteChanged) { @@ -179,7 +179,7 @@ MxResult MxSmack::LoadFrame( MxU8* intoPalette = palette; MxU16 paletteIndex = 0; // TODO: struct incorrect, Palette at wrong offset? - MxU8* currentPalette = &p_mxSmack->m_smackTag.Palette[4]; + MxU8* currentPalette = &p_mxSmk->m_smackTag.Palette[4]; do { if (*intoChunk & 0x80) { @@ -217,13 +217,13 @@ MxResult MxSmack::LoadFrame( p_chunkData += *p_chunkData * 4; } - SmackDoFrameToBuffer(p_chunkData, p_mxSmack->m_huffmanTables, p_mxSmack->m_unk0x6b4); + SmackDoFrameToBuffer(p_chunkData, p_mxSmk->m_huffmanTables, p_mxSmk->m_unk0x6b4); MxU16 und = 1; u32 smackRect[4]; MxRect32 rect; - while (GetRect(p_mxSmack->m_unk0x6b4, &und, smackRect, &rect)) { + while (GetRect(p_mxSmk->m_unk0x6b4, &und, smackRect, &rect)) { MxRect32* newRect = new MxRect32(rect); p_list->Append(newRect); } @@ -233,7 +233,7 @@ MxResult MxSmack::LoadFrame( // FUNCTION: LEGO1 0x100c6050 // FUNCTION: BETA10 0x10152739 -MxBool MxSmack::GetRect(MxU8* p_unk0x6b4, MxU16* p_und, u32* p_smackRect, MxRect32* p_rect) +MxBool MxSmk::GetRect(MxU8* p_unk0x6b4, MxU16* p_und, u32* p_smackRect, MxRect32* p_rect) { u32 left, bottom, top, right; diff --git a/LEGO1/omni/src/video/mxsmkpresenter.cpp b/LEGO1/omni/src/video/mxsmkpresenter.cpp index 6e38c43d..5bbddbe9 100644 --- a/LEGO1/omni/src/video/mxsmkpresenter.cpp +++ b/LEGO1/omni/src/video/mxsmkpresenter.cpp @@ -24,7 +24,7 @@ MxSmkPresenter::~MxSmkPresenter() void MxSmkPresenter::Init() { m_currentFrame = 0; - memset(&m_mxSmack, 0, sizeof(m_mxSmack)); + memset(&m_mxSmk, 0, sizeof(m_mxSmk)); SetBit1(FALSE); SetBit2(FALSE); } @@ -34,7 +34,7 @@ void MxSmkPresenter::Destroy(MxBool p_fromDestructor) { m_criticalSection.Enter(); - MxSmack::Destroy(&m_mxSmack); + MxSmk::Destroy(&m_mxSmk); Init(); m_criticalSection.Leave(); @@ -47,7 +47,7 @@ void MxSmkPresenter::Destroy(MxBool p_fromDestructor) // FUNCTION: LEGO1 0x100b3940 void MxSmkPresenter::LoadHeader(MxStreamChunk* p_chunk) { - MxSmack::LoadHeader(p_chunk->GetData(), &m_mxSmack); + MxSmk::LoadHeader(p_chunk->GetData(), &m_mxSmk); } // FUNCTION: LEGO1 0x100b3960 @@ -58,7 +58,7 @@ void MxSmkPresenter::CreateBitmap() } m_frameBitmap = new MxBitmap; - m_frameBitmap->SetSize(m_mxSmack.m_smackTag.Width, m_mxSmack.m_smackTag.Height, NULL, FALSE); + m_frameBitmap->SetSize(m_mxSmk.m_smackTag.Width, m_mxSmk.m_smackTag.Height, NULL, FALSE); } // FUNCTION: LEGO1 0x100b3a00 @@ -68,12 +68,12 @@ void MxSmkPresenter::LoadFrame(MxStreamChunk* p_chunk) MxU8* bitmapData = m_frameBitmap->GetImage(); MxU8* chunkData = p_chunk->GetData(); - MxBool paletteChanged = m_mxSmack.m_frameTypes[m_currentFrame] & 1; + MxBool paletteChanged = m_mxSmk.m_frameTypes[m_currentFrame] & 1; m_currentFrame++; VTable0x88(); MxRectList rects(TRUE); - MxSmack::LoadFrame(bitmapInfo, bitmapData, &m_mxSmack, chunkData, paletteChanged, &rects); + MxSmk::LoadFrame(bitmapInfo, bitmapData, &m_mxSmk, chunkData, paletteChanged, &rects); if (((MxDSMediaAction*) m_action)->GetPaletteManagement() && paletteChanged) { RealizePalette(); @@ -93,17 +93,17 @@ void MxSmkPresenter::LoadFrame(MxStreamChunk* p_chunk) // FUNCTION: LEGO1 0x100b4260 void MxSmkPresenter::VTable0x88() { - if ((m_mxSmack.m_smackTag.SmackerType & 1) != 0) { - MxU32 und = (m_currentFrame % m_mxSmack.m_smackTag.Frames); + if ((m_mxSmk.m_smackTag.SmackerType & 1) != 0) { + MxU32 und = (m_currentFrame % m_mxSmk.m_smackTag.Frames); if (1 < m_currentFrame && und == 1) { m_currentFrame = 1; } } else { - if (m_mxSmack.m_smackTag.Frames == m_currentFrame) { + if (m_mxSmk.m_smackTag.Frames == m_currentFrame) { m_currentFrame = 0; // TODO: struct incorrect, Palette at wrong offset? - memset(&m_mxSmack.m_smackTag.Palette[4], 0, sizeof(m_mxSmack.m_smackTag.Palette)); + memset(&m_mxSmk.m_smackTag.Palette[4], 0, sizeof(m_mxSmk.m_smackTag.Palette)); } } } From d5fdea372b16e780e16ba08d7f947f59db57a4b7 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 27 Dec 2024 11:11:25 -0700 Subject: [PATCH 02/15] Match `LegoAnimationManager::FUN_10063b90` (#1289) --- .../legoomni/src/common/legoanimationmanager.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp index 6ce38281..58f9c578 100644 --- a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp @@ -2342,11 +2342,11 @@ MxBool LegoAnimationManager::FUN_10063b90(LegoWorld* p_world, LegoExtraActor* p_ { const char** cycles = g_cycles[g_characters[p_characterId].m_unk0x16]; const char* vehicleWC; + LegoLocomotionAnimPresenter* presenter; if (g_characters[p_characterId].m_vehicleId >= 0 && g_vehicles[g_characters[p_characterId].m_vehicleId].m_unk0x04 && (vehicleWC = cycles[10]) != NULL) { - LegoLocomotionAnimPresenter* presenter = - (LegoLocomotionAnimPresenter*) p_world->Find("LegoAnimPresenter", vehicleWC); + presenter = (LegoLocomotionAnimPresenter*) p_world->Find("LegoAnimPresenter", vehicleWC); if (presenter != NULL) { presenter->FUN_1006d680(p_actor, 1.7f); @@ -2359,8 +2359,7 @@ MxBool LegoAnimationManager::FUN_10063b90(LegoWorld* p_world, LegoExtraActor* p_ else { vehicleWC = cycles[p_mood]; if (vehicleWC != NULL) { - LegoLocomotionAnimPresenter* presenter = - (LegoLocomotionAnimPresenter*) p_world->Find("LegoAnimPresenter", vehicleWC); + presenter = (LegoLocomotionAnimPresenter*) p_world->Find("LegoAnimPresenter", vehicleWC); if (presenter != NULL) { presenter->FUN_1006d680(p_actor, 0.7f); @@ -2373,8 +2372,7 @@ MxBool LegoAnimationManager::FUN_10063b90(LegoWorld* p_world, LegoExtraActor* p_ vehicleWC = cycles[p_mood + 4]; if (vehicleWC != NULL) { - LegoLocomotionAnimPresenter* presenter = - (LegoLocomotionAnimPresenter*) p_world->Find("LegoAnimPresenter", vehicleWC); + presenter = (LegoLocomotionAnimPresenter*) p_world->Find("LegoAnimPresenter", vehicleWC); if (presenter != NULL) { presenter->FUN_1006d680(p_actor, 4.0f); @@ -2387,8 +2385,7 @@ MxBool LegoAnimationManager::FUN_10063b90(LegoWorld* p_world, LegoExtraActor* p_ vehicleWC = cycles[p_mood + 7]; if (vehicleWC != NULL) { - LegoLocomotionAnimPresenter* presenter = - (LegoLocomotionAnimPresenter*) p_world->Find("LegoAnimPresenter", vehicleWC); + presenter = (LegoLocomotionAnimPresenter*) p_world->Find("LegoAnimPresenter", vehicleWC); if (presenter != NULL) { presenter->FUN_1006d680(p_actor, 0.0f); From a3b191f6011cd1a00dbeaef461e8b78f35b3da4e Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 27 Dec 2024 12:05:22 -0700 Subject: [PATCH 03/15] Match `MxPresenter::StartAction` (#1290) --- LEGO1/omni/src/common/mxpresenter.cpp | 46 +++++++++++++-------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/LEGO1/omni/src/common/mxpresenter.cpp b/LEGO1/omni/src/common/mxpresenter.cpp index ea6e5978..a2084656 100644 --- a/LEGO1/omni/src/common/mxpresenter.cpp +++ b/LEGO1/omni/src/common/mxpresenter.cpp @@ -41,17 +41,15 @@ void MxPresenter::Init() } // FUNCTION: LEGO1 0x100b4d80 +// FUNCTION: BETA10 0x1012e120 MxResult MxPresenter::StartAction(MxStreamController*, MxDSAction* p_action) { AUTOLOCK(m_criticalSection); - this->m_action = p_action; + m_action = p_action; + m_location = MxPoint32(m_action->GetLocation()[0], m_action->GetLocation()[1]); + m_displayZ = m_action->GetLocation()[2]; - const Mx3DPointFloat& location = this->m_action->GetLocation(); - MxS32 previousTickleState = this->m_currentTickleState; - - this->m_location = MxPoint32(this->m_action->GetLocation()[0], this->m_action->GetLocation()[1]); - this->m_displayZ = this->m_action->GetLocation()[2]; ProgressTickleState(e_ready); return SUCCESS; @@ -60,22 +58,22 @@ MxResult MxPresenter::StartAction(MxStreamController*, MxDSAction* p_action) // FUNCTION: LEGO1 0x100b4e40 void MxPresenter::EndAction() { - if (this->m_action == NULL) { + if (m_action == NULL) { return; } AUTOLOCK(m_criticalSection); - if (!this->m_compositePresenter) { + if (!m_compositePresenter) { MxOmni::GetInstance()->NotifyCurrentEntity( - MxEndActionNotificationParam(c_notificationEndAction, NULL, this->m_action, TRUE) + MxEndActionNotificationParam(c_notificationEndAction, NULL, m_action, TRUE) ); } - this->m_action = NULL; + m_action = NULL; MxS32 previousTickleState = 1 << m_currentTickleState; - this->m_previousTickleStates |= previousTickleState; - this->m_currentTickleState = e_idle; + m_previousTickleStates |= previousTickleState; + m_currentTickleState = e_idle; } // FUNCTION: LEGO1 0x100b4fc0 @@ -129,39 +127,39 @@ MxResult MxPresenter::Tickle() { AUTOLOCK(m_criticalSection); - switch (this->m_currentTickleState) { + switch (m_currentTickleState) { case e_ready: - this->ReadyTickle(); + ReadyTickle(); if (m_currentTickleState != e_starting) { break; } case e_starting: - this->StartingTickle(); + StartingTickle(); if (m_currentTickleState != e_streaming) { break; } case e_streaming: - this->StreamingTickle(); + StreamingTickle(); if (m_currentTickleState != e_repeating) { break; } case e_repeating: - this->RepeatingTickle(); + RepeatingTickle(); if (m_currentTickleState != e_freezing) { break; } case e_freezing: - this->FreezingTickle(); + FreezingTickle(); if (m_currentTickleState != e_done) { break; } case e_done: - this->DoneTickle(); + DoneTickle(); default: break; } @@ -172,14 +170,14 @@ MxResult MxPresenter::Tickle() // FUNCTION: LEGO1 0x100b52d0 void MxPresenter::Enable(MxBool p_enable) { - if (this->m_action && this->IsEnabled() != p_enable) { - MxU32 flags = this->m_action->GetFlags(); + if (m_action && IsEnabled() != p_enable) { + MxU32 flags = m_action->GetFlags(); if (p_enable) { - this->m_action->SetFlags(flags | MxDSAction::c_enabled); + m_action->SetFlags(flags | MxDSAction::c_enabled); } else { - this->m_action->SetFlags(flags & ~MxDSAction::c_enabled); + m_action->SetFlags(flags & ~MxDSAction::c_enabled); } } } @@ -266,5 +264,5 @@ MxEntity* MxPresenter::CreateEntity(const char* p_defaultName) // FUNCTION: BETA10 0x1012ebaf MxBool MxPresenter::IsEnabled() { - return this->m_action && this->m_action->GetFlags() & MxDSAction::c_enabled; + return m_action && m_action->GetFlags() & MxDSAction::c_enabled; } From 2422d997cf1956de7bf952e0d249402e797317f5 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 27 Dec 2024 12:14:16 -0700 Subject: [PATCH 04/15] Match some more `MxDiskStreamController` functions (#1291) --- LEGO1/omni/src/stream/mxdiskstreamcontroller.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/LEGO1/omni/src/stream/mxdiskstreamcontroller.cpp b/LEGO1/omni/src/stream/mxdiskstreamcontroller.cpp index 3553ca05..f7bae81d 100644 --- a/LEGO1/omni/src/stream/mxdiskstreamcontroller.cpp +++ b/LEGO1/omni/src/stream/mxdiskstreamcontroller.cpp @@ -277,15 +277,17 @@ MxDSStreamingAction* MxDiskStreamController::FUN_100c7db0() } // FUNCTION: LEGO1 0x100c7f40 +// FUNCTION: BETA10 0x101553e0 void MxDiskStreamController::FUN_100c7f40(MxDSStreamingAction* p_streamingaction) { AUTOLOCK(m_criticalSection); if (p_streamingaction) { - m_list0x64.push_back(p_streamingaction); + m_list0x64.PushBack(p_streamingaction); } } // FUNCTION: LEGO1 0x100c7ff0 +// FUNCTION: BETA10 0x10155471 MxResult MxDiskStreamController::VTable0x20(MxDSAction* p_action) { AUTOLOCK(m_criticalSection); @@ -389,7 +391,7 @@ MxResult MxDiskStreamController::FUN_100c8360(MxDSStreamingAction* p_action) action2->SetObjectId(p_action->GetObjectId()); } - m_list0x90.push_back(action2); + m_list0x90.PushBack(action2); } } @@ -405,6 +407,7 @@ void MxDiskStreamController::InsertToList74(MxDSBuffer* p_buffer) } // FUNCTION: LEGO1 0x100c8540 +// FUNCTION: BETA10 0x10155a05 void MxDiskStreamController::FUN_100c8540() { AUTOLOCK(m_criticalSection); @@ -429,6 +432,7 @@ void MxDiskStreamController::FUN_100c8540() } // FUNCTION: LEGO1 0x100c8640 +// FUNCTION: BETA10 0x10155ba0 MxResult MxDiskStreamController::Tickle() { if (m_unk0xc4) { @@ -461,7 +465,6 @@ void MxDiskStreamController::FUN_100c8720() while (!m_list0xb8.empty()) { action = (MxDSStreamingAction*) m_list0xb8.front(); m_list0xb8.pop_front(); - FUN_100c7cb0(action); } } From 8afa64048bcaab317ac9dd42df9568905edd3c3a Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 27 Dec 2024 13:03:04 -0700 Subject: [PATCH 05/15] More BETA matches in `MxDiskStreamController` (#1292) * More BETA matches in `MxDiskStreamController` * Fix --- .../src/common/legoanimationmanager.cpp | 9 ++- LEGO1/omni/include/mxdiskstreamcontroller.h | 3 + LEGO1/omni/include/mxstreamcontroller.h | 4 +- .../src/stream/mxdiskstreamcontroller.cpp | 72 ++++++++++++------- LEGO1/omni/src/stream/mxstreamcontroller.cpp | 12 ++-- 5 files changed, 65 insertions(+), 35 deletions(-) diff --git a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp index 58f9c578..5206d936 100644 --- a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp @@ -2478,6 +2478,8 @@ MxBool LegoAnimationManager::FUN_10064010(LegoPathBoundary* p_boundary, LegoUnkn Vector3* v1 = p_edge->CWVertex(*p_boundary); Vector3* v2 = p_edge->CCWVertex(*p_boundary); + assert(v1 && v2); + p1 = *v2; p1 -= *v1; p1 *= p_destScale; @@ -2490,7 +2492,12 @@ MxBool LegoAnimationManager::FUN_10064010(LegoPathBoundary* p_boundary, LegoUnkn boundingBox.Min() -= vec; boundingBox.Max() = p1; boundingBox.Max() += vec; - return GetViewManager()->IsBoundingBoxInFrustum(boundingBox) == FALSE; + + if (GetViewManager()->IsBoundingBoxInFrustum(boundingBox) == FALSE) { + return TRUE; + } + + return FALSE; } // FUNCTION: LEGO1 0x10064120 diff --git a/LEGO1/omni/include/mxdiskstreamcontroller.h b/LEGO1/omni/include/mxdiskstreamcontroller.h index d2950e49..6bf7c418 100644 --- a/LEGO1/omni/include/mxdiskstreamcontroller.h +++ b/LEGO1/omni/include/mxdiskstreamcontroller.h @@ -97,4 +97,7 @@ private: // TEMPLATE: BETA10 0x10150e60 // MxUtilityList::PushBack +// TEMPLATE: BETA10 0x10150ff0 +// MxUtilityList::PushBack + #endif // MXDISKSTREAMCONTROLLER_H diff --git a/LEGO1/omni/include/mxstreamcontroller.h b/LEGO1/omni/include/mxstreamcontroller.h index 67f6fed0..907b99f8 100644 --- a/LEGO1/omni/include/mxstreamcontroller.h +++ b/LEGO1/omni/include/mxstreamcontroller.h @@ -74,14 +74,14 @@ public: MxStreamProvider* GetProvider() { return m_provider; } MxDSObjectList& GetUnk0x3c() { return m_unk0x3c; } MxDSObjectList& GetUnk0x54() { return m_unk0x54; } - MxDSSubscriberList& GetSubscriberList() { return m_subscriberList; } + MxDSSubscriberList& GetSubscriberList() { return m_subscribers; } protected: MxCriticalSection m_criticalSection; // 0x08 MxAtomId m_atom; // 0x24 MxStreamProvider* m_provider; // 0x28 undefined4* m_unk0x2c; // 0x2c - MxDSSubscriberList m_subscriberList; // 0x30 + MxDSSubscriberList m_subscribers; // 0x30 MxDSObjectList m_unk0x3c; // 0x3c MxNextActionDataStartList m_nextActionList; // 0x48 MxDSObjectList m_unk0x54; // 0x54 diff --git a/LEGO1/omni/src/stream/mxdiskstreamcontroller.cpp b/LEGO1/omni/src/stream/mxdiskstreamcontroller.cpp index f7bae81d..40ae8ae9 100644 --- a/LEGO1/omni/src/stream/mxdiskstreamcontroller.cpp +++ b/LEGO1/omni/src/stream/mxdiskstreamcontroller.cpp @@ -8,6 +8,8 @@ #include "mxomni.h" #include "mxticklemanager.h" +#include + DECOMP_SIZE_ASSERT(MxDiskStreamController, 0xc8); // FUNCTION: LEGO1 0x100c7120 @@ -17,6 +19,7 @@ MxDiskStreamController::MxDiskStreamController() } // FUNCTION: LEGO1 0x100c7530 +// FUNCTION: BETA10 0x10153a2d MxDiskStreamController::~MxDiskStreamController() { AUTOLOCK(m_criticalSection); @@ -35,6 +38,8 @@ MxDiskStreamController::~MxDiskStreamController() #endif } + assert(m_subscribers.size() == 0); + MxDSObject* object; while (m_unk0x3c.PopFront(object)) { delete object; @@ -65,28 +70,32 @@ MxDiskStreamController::~MxDiskStreamController() } // FUNCTION: LEGO1 0x100c7790 +// FUNCTION: BETA10 0x10153ea8 MxResult MxDiskStreamController::Open(const char* p_filename) { AUTOLOCK(m_criticalSection); MxResult result = MxStreamController::Open(p_filename); - if (result == SUCCESS) { - m_provider = new MxDiskStreamProvider(); - if (m_provider == NULL) { - result = FAILURE; - } - else { - result = m_provider->SetResourceToGet(this); - if (result != SUCCESS) { - delete m_provider; - m_provider = NULL; - } - else { - TickleManager()->RegisterClient(this, 10); - } - } + if (result != SUCCESS) { + goto done; } + m_provider = new MxDiskStreamProvider(); + if (m_provider == NULL) { + result = FAILURE; + goto done; + } + + result = m_provider->SetResourceToGet(this); + if (result != SUCCESS) { + delete m_provider; + m_provider = NULL; + goto done; + } + + TickleManager()->RegisterClient(this, 10); + +done: return result; } @@ -97,6 +106,7 @@ MxResult MxDiskStreamController::VTable0x18(undefined4, undefined4) } // FUNCTION: LEGO1 0x100c7890 +// FUNCTION: BETA10 0x101543bb MxResult MxDiskStreamController::FUN_100c7890(MxDSStreamingAction* p_action) { AUTOLOCK(m_criticalSection); @@ -104,7 +114,7 @@ MxResult MxDiskStreamController::FUN_100c7890(MxDSStreamingAction* p_action) return FAILURE; } - m_list0x80.push_back(p_action); + m_list0x80.PushBack(p_action); FUN_100c7970(); return SUCCESS; } @@ -122,6 +132,7 @@ void MxDiskStreamController::FUN_100c7970() } // FUNCTION: LEGO1 0x100c7980 +// FUNCTION: BETA10 0x10154848 void MxDiskStreamController::FUN_100c7980() { MxDSBuffer* buffer; @@ -159,24 +170,33 @@ void MxDiskStreamController::FUN_100c7980() } // FUNCTION: LEGO1 0x100c7ac0 +// FUNCTION: BETA10 0x10154abb MxDSStreamingAction* MxDiskStreamController::VTable0x28() { AUTOLOCK(m_criticalSection); MxDSObject* oldAction; - MxDSStreamingAction* result = NULL; + + assert(m_provider); + MxDSStreamingAction* request = NULL; MxU32 filesize = m_provider->GetFileSize(); - if (m_unk0x3c.PopFront(oldAction)) { - result = new MxDSStreamingAction((MxDSStreamingAction&) *oldAction); - if (result) { - MxU32 offset = result->GetBufferOffset() + filesize; - ((MxDSStreamingAction*) oldAction)->SetUnknown94(offset); - ((MxDSStreamingAction*) oldAction)->SetBufferOffset(offset); - m_unk0x3c.push_back(oldAction); - } + if (!m_unk0x3c.PopFront(oldAction)) { + goto done; } - return result; + request = new MxDSStreamingAction((MxDSStreamingAction&) *oldAction); + assert(request); + + if (!request) { + goto done; + } + + ((MxDSStreamingAction*) oldAction)->SetUnknown94(request->GetBufferOffset() + filesize); + ((MxDSStreamingAction*) oldAction)->SetBufferOffset(((MxDSStreamingAction*) oldAction)->GetUnknown94()); + m_unk0x3c.PushBack(oldAction); + +done: + return request; } // FUNCTION: LEGO1 0x100c7c00 diff --git a/LEGO1/omni/src/stream/mxstreamcontroller.cpp b/LEGO1/omni/src/stream/mxstreamcontroller.cpp index 88919aef..958fa371 100644 --- a/LEGO1/omni/src/stream/mxstreamcontroller.cpp +++ b/LEGO1/omni/src/stream/mxstreamcontroller.cpp @@ -32,7 +32,7 @@ MxStreamController::~MxStreamController() AUTOLOCK(m_criticalSection); MxDSSubscriber* subscriber; - while (m_subscriberList.PopFront(subscriber)) { + while (m_subscribers.PopFront(subscriber)) { delete subscriber; } @@ -80,14 +80,14 @@ MxResult MxStreamController::Open(const char* p_filename) // FUNCTION: BETA10 0x1014e730 void MxStreamController::AddSubscriber(MxDSSubscriber* p_subscriber) { - m_subscriberList.PushBack(p_subscriber); + m_subscribers.PushBack(p_subscriber); } // FUNCTION: LEGO1 0x100c1620 // FUNCTION: BETA10 0x1014e7b4 void MxStreamController::RemoveSubscriber(MxDSSubscriber* p_subscriber) { - m_subscriberList.Remove(p_subscriber); + m_subscribers.Remove(p_subscriber); } // FUNCTION: LEGO1 0x100c1690 @@ -173,7 +173,7 @@ MxResult MxStreamController::FUN_100c1a00(MxDSAction* p_action, MxU32 p_offset) } if (newUnknown24 == -1) { - for (MxDSSubscriberList::iterator it = m_subscriberList.begin(); it != m_subscriberList.end(); it++) { + for (MxDSSubscriberList::iterator it = m_subscribers.begin(); it != m_subscribers.end(); it++) { MxDSSubscriber* subscriber = *it; if (subscriber->GetObjectId() == p_action->GetObjectId()) { @@ -288,7 +288,7 @@ MxResult MxStreamController::FUN_100c1f00(MxDSAction* p_action) chunk->SetChunkFlags(DS_CHUNK_BIT3); chunk->SetObjectId(objectId); - if (chunk->SendChunk(m_subscriberList, FALSE, p_action->GetUnknown24()) != SUCCESS) { + if (chunk->SendChunk(m_subscribers, FALSE, p_action->GetUnknown24()) != SUCCESS) { delete chunk; } @@ -318,7 +318,7 @@ MxNextActionDataStart* MxStreamController::FindNextActionDataStartFromStreamingA // FUNCTION: BETA10 0x1014f3b5 MxBool MxStreamController::IsStoped(MxDSObject* p_obj) { - MxDSSubscriber* subscriber = m_subscriberList.Find(p_obj); + MxDSSubscriber* subscriber = m_subscribers.Find(p_obj); if (subscriber) { MxTrace( From 29e77210e82bfefdcb0e2c98c71c07bdcfed9ddd Mon Sep 17 00:00:00 2001 From: MS Date: Fri, 27 Dec 2024 19:21:49 -0500 Subject: [PATCH 06/15] Rename some things in Infocenter (#1293) --- LEGO1/lego/legoomni/include/infocenter.h | 10 +- LEGO1/lego/legoomni/src/worlds/infocenter.cpp | 129 ++++++++++-------- 2 files changed, 74 insertions(+), 65 deletions(-) diff --git a/LEGO1/lego/legoomni/include/infocenter.h b/LEGO1/lego/legoomni/include/infocenter.h index 90ec3ea3..b1a943cf 100644 --- a/LEGO1/lego/legoomni/include/infocenter.h +++ b/LEGO1/lego/legoomni/include/infocenter.h @@ -69,9 +69,9 @@ struct InfocenterMapEntry { // FUNCTION: LEGO1 0x1006ec80 InfocenterMapEntry() {} - MxStillPresenter* m_presenter; // 0x00 - undefined4 m_unk0x04; // 0x04 - MxRect32 m_area; // 0x08 + MxStillPresenter* m_destCtl; // 0x00 + undefined4 m_unk0x04; // 0x04 + MxRect32 m_area; // 0x08 }; // VTABLE: LEGO1 0x100d9338 @@ -161,9 +161,9 @@ private: Cutscene m_currentCutscene; // 0x108 Radio m_radio; // 0x10c MxStillPresenter* m_unk0x11c; // 0x11c - InfocenterMapEntry m_mapAreas[7]; // 0x120 + InfocenterMapEntry m_glowInfo[7]; // 0x120 MxS16 m_unk0x1c8; // 0x1c8 - MxStillPresenter* m_frameHotBitmap; // 0x1cc + MxStillPresenter* m_frame; // 0x1cc MxS16 m_infoManDialogueTimer; // 0x1d0 MxS16 m_bookAnimationTimer; // 0x1d2 MxU16 m_unk0x1d4; // 0x1d4 diff --git a/LEGO1/lego/legoomni/src/worlds/infocenter.cpp b/LEGO1/lego/legoomni/src/worlds/infocenter.cpp index 55f0abc8..d7fea12f 100644 --- a/LEGO1/lego/legoomni/src/worlds/infocenter.cpp +++ b/LEGO1/lego/legoomni/src/worlds/infocenter.cpp @@ -132,12 +132,12 @@ Infocenter::Infocenter() m_selectedCharacter = e_noCharacter; m_unk0x11c = NULL; m_infocenterState = NULL; - m_frameHotBitmap = NULL; + m_frame = NULL; m_destLocation = LegoGameState::e_undefined; m_currentInfomainScript = InfomainScript::c_noneInfomain; m_currentCutscene = e_noIntro; - memset(&m_mapAreas, 0, sizeof(m_mapAreas)); + memset(&m_glowInfo, 0, sizeof(m_glowInfo)); m_unk0x1c8 = -1; SetAppCursor(e_cursorBusy); @@ -612,6 +612,7 @@ void Infocenter::ReadyWorld() } // FUNCTION: LEGO1 0x1006f9a0 +// FUNCTION: BETA10 0x1002ef2f void Infocenter::InitializeBitmaps() { m_radio.Initialize(TRUE); @@ -632,56 +633,64 @@ void Infocenter::InitializeBitmaps() ((MxPresenter*) Find(m_atomId, InfomainScript::c_Laura_Ctl))->Enable(TRUE); ((MxPresenter*) Find(m_atomId, InfomainScript::c_Radio_Ctl))->Enable(TRUE); - m_mapAreas[0].m_presenter = (MxStillPresenter*) Find("MxStillPresenter", "Info_A_Bitmap"); - m_mapAreas[0].m_area.SetLeft(391); - m_mapAreas[0].m_area.SetTop(182); - m_mapAreas[0].m_area.SetRight(427); - m_mapAreas[0].m_area.SetBottom(230); - m_mapAreas[0].m_unk0x04 = 3; + m_glowInfo[0].m_destCtl = (MxStillPresenter*) Find("MxStillPresenter", "Info_A_Bitmap"); + assert(m_glowInfo[0].m_destCtl); + m_glowInfo[0].m_area.SetLeft(391); + m_glowInfo[0].m_area.SetTop(182); + m_glowInfo[0].m_area.SetRight(427); + m_glowInfo[0].m_area.SetBottom(230); + m_glowInfo[0].m_unk0x04 = 3; - m_mapAreas[1].m_presenter = (MxStillPresenter*) Find("MxStillPresenter", "Boat_A_Bitmap"); - m_mapAreas[1].m_area.SetLeft(304); - m_mapAreas[1].m_area.SetTop(225); - m_mapAreas[1].m_area.SetRight(350); - m_mapAreas[1].m_area.SetBottom(268); - m_mapAreas[1].m_unk0x04 = 10; + m_glowInfo[1].m_destCtl = (MxStillPresenter*) Find("MxStillPresenter", "Boat_A_Bitmap"); + assert(m_glowInfo[1].m_destCtl); + m_glowInfo[1].m_area.SetLeft(304); + m_glowInfo[1].m_area.SetTop(225); + m_glowInfo[1].m_area.SetRight(350); + m_glowInfo[1].m_area.SetBottom(268); + m_glowInfo[1].m_unk0x04 = 10; - m_mapAreas[2].m_presenter = (MxStillPresenter*) Find("MxStillPresenter", "Race_A_Bitmap"); - m_mapAreas[2].m_area.SetLeft(301); - m_mapAreas[2].m_area.SetTop(133); - m_mapAreas[2].m_area.SetRight(347); - m_mapAreas[2].m_area.SetBottom(181); - m_mapAreas[2].m_unk0x04 = 11; + m_glowInfo[2].m_destCtl = (MxStillPresenter*) Find("MxStillPresenter", "Race_A_Bitmap"); + assert(m_glowInfo[1].m_destCtl); // DECOMP: intentional typo + m_glowInfo[2].m_area.SetLeft(301); + m_glowInfo[2].m_area.SetTop(133); + m_glowInfo[2].m_area.SetRight(347); + m_glowInfo[2].m_area.SetBottom(181); + m_glowInfo[2].m_unk0x04 = 11; - m_mapAreas[3].m_presenter = (MxStillPresenter*) Find("MxStillPresenter", "Pizza_A_Bitmap"); - m_mapAreas[3].m_area.SetLeft(289); - m_mapAreas[3].m_area.SetTop(182); - m_mapAreas[3].m_area.SetRight(335); - m_mapAreas[3].m_area.SetBottom(225); - m_mapAreas[3].m_unk0x04 = 12; + m_glowInfo[3].m_destCtl = (MxStillPresenter*) Find("MxStillPresenter", "Pizza_A_Bitmap"); + assert(m_glowInfo[3].m_destCtl); + m_glowInfo[3].m_area.SetLeft(289); + m_glowInfo[3].m_area.SetTop(182); + m_glowInfo[3].m_area.SetRight(335); + m_glowInfo[3].m_area.SetBottom(225); + m_glowInfo[3].m_unk0x04 = 12; - m_mapAreas[4].m_presenter = (MxStillPresenter*) Find("MxStillPresenter", "Gas_A_Bitmap"); - m_mapAreas[4].m_area.SetLeft(350); - m_mapAreas[4].m_area.SetTop(161); - m_mapAreas[4].m_area.SetRight(391); - m_mapAreas[4].m_area.SetBottom(209); - m_mapAreas[4].m_unk0x04 = 13; + m_glowInfo[4].m_destCtl = (MxStillPresenter*) Find("MxStillPresenter", "Gas_A_Bitmap"); + assert(m_glowInfo[4].m_destCtl); + m_glowInfo[4].m_area.SetLeft(350); + m_glowInfo[4].m_area.SetTop(161); + m_glowInfo[4].m_area.SetRight(391); + m_glowInfo[4].m_area.SetBottom(209); + m_glowInfo[4].m_unk0x04 = 13; - m_mapAreas[5].m_presenter = (MxStillPresenter*) Find("MxStillPresenter", "Med_A_Bitmap"); - m_mapAreas[5].m_area.SetLeft(392); - m_mapAreas[5].m_area.SetTop(130); - m_mapAreas[5].m_area.SetRight(438); - m_mapAreas[5].m_area.SetBottom(176); - m_mapAreas[5].m_unk0x04 = 14; + m_glowInfo[5].m_destCtl = (MxStillPresenter*) Find("MxStillPresenter", "Med_A_Bitmap"); + assert(m_glowInfo[5].m_destCtl); + m_glowInfo[5].m_area.SetLeft(392); + m_glowInfo[5].m_area.SetTop(130); + m_glowInfo[5].m_area.SetRight(438); + m_glowInfo[5].m_area.SetBottom(176); + m_glowInfo[5].m_unk0x04 = 14; - m_mapAreas[6].m_presenter = (MxStillPresenter*) Find("MxStillPresenter", "Cop_A_Bitmap"); - m_mapAreas[6].m_area.SetLeft(396); - m_mapAreas[6].m_area.SetTop(229); - m_mapAreas[6].m_area.SetRight(442); - m_mapAreas[6].m_area.SetBottom(272); - m_mapAreas[6].m_unk0x04 = 15; + m_glowInfo[6].m_destCtl = (MxStillPresenter*) Find("MxStillPresenter", "Cop_A_Bitmap"); + assert(m_glowInfo[6].m_destCtl); + m_glowInfo[6].m_area.SetLeft(396); + m_glowInfo[6].m_area.SetTop(229); + m_glowInfo[6].m_area.SetRight(442); + m_glowInfo[6].m_area.SetBottom(272); + m_glowInfo[6].m_unk0x04 = 15; - m_frameHotBitmap = (MxStillPresenter*) Find("MxStillPresenter", "FrameHot_Bitmap"); + m_frame = (MxStillPresenter*) Find("MxStillPresenter", "FrameHot_Bitmap"); + assert(m_frame); UpdateFrameHot(TRUE); } @@ -831,7 +840,7 @@ MxU8 Infocenter::HandleButtonUp(MxS32 p_x, MxS32 p_y) if (m_unk0x1c8 != -1) { m_infoManDialogueTimer = 0; - switch (m_mapAreas[m_unk0x1c8].m_unk0x04) { + switch (m_glowInfo[m_unk0x1c8].m_unk0x04) { case 3: GameState()->SetActor(m_selectedCharacter); @@ -1304,11 +1313,11 @@ MxBool Infocenter::VTable0x5c() void Infocenter::FUN_10070d10(MxS32 p_x, MxS32 p_y) { MxS16 i; - for (i = 0; i < (MxS32) (sizeof(m_mapAreas) / sizeof(m_mapAreas[0])); i++) { - MxS32 right = m_mapAreas[i].m_area.GetRight(); - MxS32 bottom = m_mapAreas[i].m_area.GetBottom(); - MxS32 left = m_mapAreas[i].m_area.GetLeft(); - MxS32 top = m_mapAreas[i].m_area.GetTop(); + for (i = 0; i < (MxS32) (sizeof(m_glowInfo) / sizeof(m_glowInfo[0])); i++) { + MxS32 right = m_glowInfo[i].m_area.GetRight(); + MxS32 bottom = m_glowInfo[i].m_area.GetBottom(); + MxS32 left = m_glowInfo[i].m_area.GetLeft(); + MxS32 top = m_glowInfo[i].m_area.GetTop(); if (left <= p_x && p_x <= right && top <= p_y && p_y <= bottom) { break; @@ -1321,12 +1330,12 @@ void Infocenter::FUN_10070d10(MxS32 p_x, MxS32 p_y) if (i != m_unk0x1c8) { if (m_unk0x1c8 != -1) { - m_mapAreas[m_unk0x1c8].m_presenter->Enable(FALSE); + m_glowInfo[m_unk0x1c8].m_destCtl->Enable(FALSE); } m_unk0x1c8 = i; if (i != -1) { - m_mapAreas[i].m_presenter->Enable(TRUE); + m_glowInfo[i].m_destCtl->Enable(TRUE); } } } @@ -1362,18 +1371,18 @@ void Infocenter::UpdateFrameHot(MxBool p_display) return; } - MxS32 originalDisplayZ = m_frameHotBitmap->GetDisplayZ(); + MxS32 originalDisplayZ = m_frame->GetDisplayZ(); - m_frameHotBitmap->SetDisplayZ(1000); + m_frame->SetDisplayZ(1000); VideoManager()->SortPresenterList(); - m_frameHotBitmap->Enable(TRUE); - m_frameHotBitmap->SetPosition(x, y); - m_frameHotBitmap->SetDisplayZ(originalDisplayZ); + m_frame->Enable(TRUE); + m_frame->SetPosition(x, y); + m_frame->SetDisplayZ(originalDisplayZ); } else { - if (m_frameHotBitmap) { - m_frameHotBitmap->Enable(FALSE); + if (m_frame) { + m_frame->Enable(FALSE); } } } From 2303dafaae902f203d95c86424feecfda06d8a90 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 28 Dec 2024 09:11:00 -0700 Subject: [PATCH 07/15] Match `LegoInputManager::ProcessOneEvent` (#1294) --- LEGO1/lego/legoomni/src/input/legoinputmanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp index 31c4eabd..3aa0208c 100644 --- a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp +++ b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp @@ -466,7 +466,7 @@ MxBool LegoInputManager::ProcessOneEvent(LegoEventNotificationParam& p_param) LegoROI* roi = PickROI(p_param.GetX(), p_param.GetY()); p_param.SetROI(roi); - if (roi && roi->GetVisibility()) { + if (roi && roi->GetVisibility() == TRUE) { for (OrientableROI* parent = roi->GetParentROI(); parent; parent = parent->GetParentROI()) { roi = (LegoROI*) parent; } From 63bfb95d8089841a0e3ff854657ef33d34c866ec Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 28 Dec 2024 09:43:06 -0700 Subject: [PATCH 08/15] Match `LegoActor::SetROI` (#1295) --- LEGO1/lego/legoomni/src/entity/legoactor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LEGO1/lego/legoomni/src/entity/legoactor.cpp b/LEGO1/lego/legoomni/src/entity/legoactor.cpp index 413b5171..16787149 100644 --- a/LEGO1/lego/legoomni/src/entity/legoactor.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoactor.cpp @@ -127,7 +127,7 @@ void LegoActor::SetROI(LegoROI* p_roi, MxBool p_bool1, MxBool p_bool2) if (p_roi) { const char* name = p_roi->GetName(); - for (MxU32 i = 1; i <= sizeOfArray(g_actorNames) - 1; i++) { + for (MxU32 i = 1; i <= sizeOfArray(g_actorNames) - 2; i++) { if (!strcmpi(name, g_actorNames[i])) { m_type = e_actor; m_actorId = i; From fd27efcc22e3d93d3eff52b21e5de05527fcbf79 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 28 Dec 2024 10:00:53 -0700 Subject: [PATCH 09/15] Match `LegoCarBuild::FUN_10024c20` (#1296) --- LEGO1/lego/legoomni/src/build/legocarbuild.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/LEGO1/lego/legoomni/src/build/legocarbuild.cpp b/LEGO1/lego/legoomni/src/build/legocarbuild.cpp index 69d2e8a0..ce45ab75 100644 --- a/LEGO1/lego/legoomni/src/build/legocarbuild.cpp +++ b/LEGO1/lego/legoomni/src/build/legocarbuild.cpp @@ -1203,7 +1203,7 @@ undefined4 LegoCarBuild::FUN_10024c20(LegoEventNotificationParam* p_param) assert(destWorld); m_buildState->m_animationState = LegoVehicleBuildState::e_exiting; - if (m_unk0x258->AllPartsPlaced()) { + if (!m_unk0x258->AllPartsPlaced()) { FUN_100243a0(); } else { @@ -1211,8 +1211,7 @@ undefined4 LegoCarBuild::FUN_10024c20(LegoEventNotificationParam* p_param) } } else { - MxNotificationParam param; - NotificationManager()->Send(this, param); + NotificationManager()->Send(this, MxNotificationParam()); } break; case 2: @@ -1239,9 +1238,8 @@ undefined4 LegoCarBuild::FUN_10024c20(LegoEventNotificationParam* p_param) FUN_10024ef0(); } else { - MxNotificationParam p; // In BETA10, NotificationManager->Send() also takes __FILE__ and __LINE__ arguments - NotificationManager()->Send(this, p); + NotificationManager()->Send(this, MxNotificationParam()); } break; } From e4e8ad6da5c1fb4f11c5cb7e8fafddb13d5a5af1 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 28 Dec 2024 10:23:27 -0700 Subject: [PATCH 10/15] Match `LegoWorld::Tickle` (#1297) --- LEGO1/lego/legoomni/src/entity/legoworld.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LEGO1/lego/legoomni/src/entity/legoworld.cpp b/LEGO1/lego/legoomni/src/entity/legoworld.cpp index ee144513..f5e0e8b2 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworld.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworld.cpp @@ -783,7 +783,7 @@ MxResult LegoWorld::Tickle() ReadyWorld(); return TRUE; case e_two: - if (PresentersPending()) { + if (PresentersPending() == TRUE) { break; } default: From a97934e1880b6821ac453e9452f9698eaf74c10a Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 28 Dec 2024 10:30:07 -0700 Subject: [PATCH 11/15] Match `LegoNavController::ProcessKeyboardInput` (#1298) --- .../legoomni/src/entity/legonavcontroller.cpp | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp index da82d9a7..9a7bf108 100644 --- a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp @@ -582,29 +582,33 @@ MxResult LegoNavController::ProcessKeyboardInput() m_unk0x6c = TRUE; MxS32 hMax; - if ((keyFlags & LegoInputManager::c_leftOrRight) == LegoInputManager::c_left) { + switch (keyFlags & LegoInputManager::c_leftOrRight) { + case LegoInputManager::c_left: hMax = 0; - } - else if ((keyFlags & LegoInputManager::c_leftOrRight) == LegoInputManager::c_right) { + break; + case LegoInputManager::c_right: hMax = m_hMax; - } - else { + break; + default: m_targetRotationalVel = 0.0; m_rotationalAccel = m_maxRotationalDeccel; bool1 = TRUE; + break; } MxS32 vMax; - if ((keyFlags & LegoInputManager::c_upOrDown) == LegoInputManager::c_up) { + switch (keyFlags & LegoInputManager::c_upOrDown) { + case LegoInputManager::c_up: vMax = 0; - } - else if ((keyFlags & LegoInputManager::c_upOrDown) == LegoInputManager::c_down) { + break; + case LegoInputManager::c_down: vMax = m_vMax; - } - else { + break; + default: m_targetLinearVel = 0.0; m_linearAccel = m_maxLinearDeccel; bool2 = TRUE; + break; } MxFloat val = keyFlags & LegoInputManager::c_bit5 ? 1.0f : 4.0f; From 724a566c2e56f4923f4c247b20648179dc3e98c6 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 28 Dec 2024 10:41:35 -0700 Subject: [PATCH 12/15] Match `MxDiskStreamProvider::FUN_100d1780` (#1299) --- LEGO1/omni/src/stream/mxdiskstreamprovider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LEGO1/omni/src/stream/mxdiskstreamprovider.cpp b/LEGO1/omni/src/stream/mxdiskstreamprovider.cpp index eb6cbc54..c71441bb 100644 --- a/LEGO1/omni/src/stream/mxdiskstreamprovider.cpp +++ b/LEGO1/omni/src/stream/mxdiskstreamprovider.cpp @@ -201,7 +201,7 @@ MxResult MxDiskStreamProvider::FUN_100d1780(MxDSStreamingAction* p_action) { AUTOLOCK(m_criticalSection); - m_list.push_back(p_action); + m_list.PushBack(p_action); } m_unk0x35 = TRUE; From 3140ba73eb12782cdcefe6edb8fa2ea0c00bc494 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 28 Dec 2024 11:10:02 -0700 Subject: [PATCH 13/15] Match `TglD3DRMIMAGE::FillRowsOfTexture` (#1300) --- LEGO1/tgl/d3drm/impl.h | 2 +- LEGO1/tgl/d3drm/texture.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/LEGO1/tgl/d3drm/impl.h b/LEGO1/tgl/d3drm/impl.h index a2998c7a..eba702cb 100644 --- a/LEGO1/tgl/d3drm/impl.h +++ b/LEGO1/tgl/d3drm/impl.h @@ -411,7 +411,7 @@ public: Result CreateBuffer(int width, int height, int depth, void* pBuffer, int useBuffer); void Destroy(); - void FillRowsOfTexture(int y, int height, char* content); + Result FillRowsOfTexture(int y, int height, char* content); Result InitializePalette(int paletteSize, PaletteEntry* pEntries); D3DRMIMAGE m_image; diff --git a/LEGO1/tgl/d3drm/texture.cpp b/LEGO1/tgl/d3drm/texture.cpp index d02b8840..79452ba6 100644 --- a/LEGO1/tgl/d3drm/texture.cpp +++ b/LEGO1/tgl/d3drm/texture.cpp @@ -129,10 +129,11 @@ Result TglD3DRMIMAGE::CreateBuffer(int width, int height, int depth, void* pBuff } // FUNCTION: LEGO1 0x100a1510 -void TglD3DRMIMAGE::FillRowsOfTexture(int y, int height, char* pContent) +Result TglD3DRMIMAGE::FillRowsOfTexture(int y, int height, char* pContent) { // The purpose is clearly this but I can't get the assembly to line up. memcpy((char*) m_image.buffer1 + (y * m_image.bytes_per_line), pContent, height * m_image.bytes_per_line); + return Success; } // FUNCTION: LEGO1 0x100a1550 From 9b96f3c338242d6bfbf9ed2a56be0271b2990606 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 28 Dec 2024 13:17:03 -0700 Subject: [PATCH 14/15] Match `LegoWorld::Find` (#1301) --- LEGO1/lego/legoomni/src/entity/legoworld.cpp | 27 ++++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/LEGO1/lego/legoomni/src/entity/legoworld.cpp b/LEGO1/lego/legoomni/src/entity/legoworld.cpp index f5e0e8b2..e00d4365 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworld.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworld.cpp @@ -554,15 +554,15 @@ MxCore* LegoWorld::Find(const char* p_class, const char* p_name) MxPresenter* presenter; while (cursor.Next(presenter)) { - MxDSAction* action = presenter->GetAction(); - if (!strcmp(action->GetObjectName(), p_name)) { + if (!strcmp(presenter->GetAction()->GetObjectName(), p_name)) { return presenter; } } return NULL; } - else if (!strcmp(p_class, "MxEntity")) { + + if (!strcmp(p_class, "MxEntity")) { LegoEntityListCursor cursor(m_entityList); LegoEntity* entity; @@ -579,7 +579,8 @@ MxCore* LegoWorld::Find(const char* p_class, const char* p_name) return NULL; } - else if (!strcmp(p_class, "LegoAnimPresenter")) { + + if (!strcmp(p_class, "LegoAnimPresenter")) { MxPresenterListCursor cursor(&m_animPresenters); MxPresenter* presenter; @@ -591,20 +592,18 @@ MxCore* LegoWorld::Find(const char* p_class, const char* p_name) return NULL; } - else { - for (MxCoreSet::iterator it = m_set0xa8.begin(); it != m_set0xa8.end(); it++) { - if ((*it)->IsA(p_class) && (*it)->IsA("MxPresenter")) { - MxPresenter* presenter = (MxPresenter*) *it; - MxDSAction* action = presenter->GetAction(); - if (!strcmp(action->GetObjectName(), p_name)) { - return *it; - } + for (MxCoreSet::iterator i = m_set0xa8.begin(); i != m_set0xa8.end(); i++) { + if ((*i)->IsA(p_class) && (*i)->IsA("MxPresenter")) { + assert(((MxPresenter*) (*i))->GetAction()); + + if (!strcmp(((MxPresenter*) (*i))->GetAction()->GetObjectName(), p_name)) { + return *i; } } - - return NULL; } + + return NULL; } // FUNCTION: LEGO1 0x10021790 From d97ce96768657e72720a57498544a7ac90036a22 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sun, 29 Dec 2024 09:14:36 -0700 Subject: [PATCH 15/15] Use Windows virtual key macros for keys (#1302) * Use Windows virtual key macros for keys * Add `VK_OEM_MINUS` * Fix missing key * Name variable --- .../legoomni/src/entity/legonavcontroller.cpp | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp index 9a7bf108..58b27935 100644 --- a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp @@ -30,6 +30,11 @@ DECOMP_SIZE_ASSERT(LegoNavController, 0x70) +// MSVC 4.20 didn't define a macro for this key +#ifndef VK_OEM_MINUS +#define VK_OEM_MINUS 0xBD +#endif + ////////////////////////////////////////////////////////////////////// #ifndef M_PI @@ -109,7 +114,7 @@ char g_debugPassword[] = "OGEL"; char* g_currentInput = g_debugPassword; // GLOBAL: LEGO1 0x100f66cc -MxS32 g_unk0x100f66cc = -1; +MxS32 g_nextCharacter = -1; // GLOBAL: LEGO1 0x100f66d0 MxBool g_enableMusic = TRUE; @@ -697,29 +702,29 @@ MxLong LegoNavController::Notify(MxParam& p_param) } break; } - case 'k': - case 'm': { // Keys need to be uppercased to trigger this code, but seems dysfunctional - if (g_unk0x100f66cc == -1) { - g_unk0x100f66cc = 0; + case VK_ADD: + case VK_SUBTRACT: { // Cycles through characters and puts them in front of you + if (g_nextCharacter == -1) { + g_nextCharacter = 0; } else { - CharacterManager()->ReleaseActor(CharacterManager()->GetActorName(g_unk0x100f66cc)); + CharacterManager()->ReleaseActor(CharacterManager()->GetActorName(g_nextCharacter)); - if (key == 'k') { - g_unk0x100f66cc++; - if (g_unk0x100f66cc >= CharacterManager()->GetNumActors()) { - g_unk0x100f66cc = 0; + if (key == VK_ADD) { + g_nextCharacter++; + if (g_nextCharacter >= CharacterManager()->GetNumActors()) { + g_nextCharacter = 0; } } else { - g_unk0x100f66cc--; - if (g_unk0x100f66cc < 0) { - g_unk0x100f66cc = CharacterManager()->GetNumActors() - 1; + g_nextCharacter--; + if (g_nextCharacter < 0) { + g_nextCharacter = CharacterManager()->GetNumActors() - 1; } } } - LegoROI* roi = CharacterManager()->GetActorROI(CharacterManager()->GetActorName(g_unk0x100f66cc), TRUE); + LegoROI* roi = CharacterManager()->GetActorROI(CharacterManager()->GetActorName(g_nextCharacter), TRUE); if (roi != NULL) { MxMatrix mat; ViewROI* viewRoi = LegoOmni::GetInstance()->GetVideoManager()->GetViewROI(); @@ -732,7 +737,7 @@ MxLong LegoNavController::Notify(MxParam& p_param) } break; } - case '{': { // Saves the game. Can't actually be triggered + case VK_F12: { // Saves the game InfocenterState* state = (InfocenterState*) GameState()->GetState("InfocenterState"); if (state && state->HasRegistered()) { GameState()->Save(0); @@ -998,7 +1003,7 @@ MxLong LegoNavController::Notify(MxParam& p_param) case 'X': RealtimeView::SetUserMaxLOD(3.6); break; - case 'j': { + case VK_MULTIPLY: { MxU8 newActor = GameState()->GetActorId() + 1; if (newActor > LegoActor::c_laura) { @@ -1008,10 +1013,10 @@ MxLong LegoNavController::Notify(MxParam& p_param) GameState()->SetActorId(newActor); break; } - case 'o': + case VK_DIVIDE: GameState()->SetActorId(LegoActor::c_brickster); break; - case 'z': + case VK_F11: if (GameState()->m_isDirty) { GameState()->m_isDirty = FALSE; } @@ -1019,7 +1024,7 @@ MxLong LegoNavController::Notify(MxParam& p_param) GameState()->m_isDirty = TRUE; } break; - case 0xbd: + case VK_OEM_MINUS: g_unk0x100f66bc = LegoAnimationManager::e_unk1; break; }