From 94300afb6cf7dab80251426c46453d9e0d4ea609 Mon Sep 17 00:00:00 2001 From: jonschz <17198703+jonschz@users.noreply.github.com> Date: Tue, 17 Jun 2025 23:10:00 +0200 Subject: [PATCH 1/6] Add minimal documentation for ALPHA, README cleanup (#1570) * Add minimal documentation for ALPHA * README cleanup --------- Co-authored-by: jonschz --- reccmp-project.yml | 5 +++++ tools/README.md | 21 +++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/reccmp-project.yml b/reccmp-project.yml index b433ce46..fd9a2ef1 100644 --- a/reccmp-project.yml +++ b/reccmp-project.yml @@ -38,3 +38,8 @@ targets: - 0x100fb080 # memset etc. - 0x100f9570 + ALPHA: + filename: ALPHA.DLL + source-root: LEGO1 + hash: + sha256: dc7e5ed8ec9d96851126a40c4d23755f1783a8df61def44c667dfaa992ac509e diff --git a/tools/README.md b/tools/README.md index 95d8fb00..0d75e48e 100644 --- a/tools/README.md +++ b/tools/README.md @@ -32,23 +32,28 @@ It is therefore advisable to search for the corresponding function in `BETA10` w Unfortunately, some code has been changed after this beta version was created. Therefore, we are not aiming for a perfect binary match of `BETA10`. In case of discrepancies, `LEGO1` (as defined above) is our "gold standard" for matching. -### Re-compiling a beta build (**WIP**) +## Pre-Alpha + +* `ALPHA` -> `LEGO1D.DLL` + +This debug build is hardly used since it has little benefit over `BETA10`. + + +# Re-compiling a beta build If you want to match the code against `BETA10`, use the following `cmake` setup to create a debug build: ``` -cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_BUILD_TYPE=Debug -DISLE_USE_SMARTHEAP=OFF +cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_BUILD_TYPE=Debug -DISLE_USE_SMARTHEAP=OFF -DISLE_BUILD_BETA10=ON -DISLE_BUILD_LEGO1=OFF ``` -**TODO**: If you can figure out how to make a debug build with SmartHeap enabled, please add it here. -If you want to run scripts to compare your debug build to `BETA10` (e.g. `reccmp-reccmp`), it is advisable to add a copy of `LEGO1D.DLL` to `/legobin` and rename it to `BETA10.DLL`. +If you can figure out how to make a debug build with SmartHeap enabled, please add it here. -### Finding matching functions +If you want to run scripts to compare your debug build to `BETA10` (e.g. `reccmp-reccmp`), it is advisable to add a copy of `LEGO1D.DLL` from Beta 1.0 to `/legobin` and rename it to `BETA10.DLL`. Analogously, you can add `LEGO1D.DLL` from the Pre-Alpha and rename it to `ALPHA.DLL`. + +# Finding matching functions This is not a recipe, but rather a list of things you can try. * If you are working on a virtual function in a class, try to find the class' vtable. Many (but not all) classes implement `ClassName()`. These functions are usually easy to find by searching the memory for the string consisting of the class name. Keep in mind that not all child classes overwrite this function, so if the function you found is used in multiple vtables (or if you found multiple `ClassName()`-like functions), make sure you actually have the parent's vtable. * If that does not help, you can try to walk up the call tree and try to locate a function that calls the function you are interested in. * Assertions can also help you - most `.cpp` file names have already been matched based on `BETA10`, so you can search for the name of your `.cpp` file and check all the assertions in that file. While that does not find all functions in a given source file, it usually finds the more complex ones. * _If you have found any other strategies, please add them here._ - -## Others (**WIP**) -* `ALPHA` (only used twice) From cf326079331f3de5f83f6fe6105215d579ab0645 Mon Sep 17 00:00:00 2001 From: Fabian Neundorf Date: Wed, 18 Jun 2025 16:06:43 +0200 Subject: [PATCH 2/6] Clear unknown in `ViewROI` and `ViewManager` (#1571) --- .../src/common/legocharactermanager.cpp | 4 +- .../legoomni/src/common/legoplantmanager.cpp | 4 +- .../legoomni/src/entity/legonavcontroller.cpp | 2 +- LEGO1/viewmanager/viewmanager.cpp | 99 ++++++++++--------- LEGO1/viewmanager/viewmanager.h | 8 +- LEGO1/viewmanager/viewroi.h | 13 ++- 6 files changed, 68 insertions(+), 62 deletions(-) diff --git a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp index ff5241bb..485d3511 100644 --- a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp @@ -643,7 +643,7 @@ MxBool LegoCharacterManager::SetHeadTexture(LegoROI* p_roi, LegoTextureInfo* p_t lodList->Release(); lodList = dupLodList; - if (head->GetUnknown0xe0() >= 0) { + if (head->GetLodLevel() >= 0) { VideoManager()->Get3DManager()->GetLego3DView()->GetViewManager()->RemoveROIDetailFromScene(head); } @@ -844,7 +844,7 @@ MxBool LegoCharacterManager::SwitchVariant(LegoROI* p_roi) lodList->Release(); lodList = dupLodList; - if (childROI->GetUnknown0xe0() >= 0) { + if (childROI->GetLodLevel() >= 0) { VideoManager()->Get3DManager()->GetLego3DView()->GetViewManager()->RemoveROIDetailFromScene(childROI); } diff --git a/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp b/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp index ca587de2..734806fc 100644 --- a/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp @@ -394,7 +394,7 @@ MxBool LegoPlantManager::SwitchColor(LegoEntity* p_entity) ViewLODList* lodList = GetViewLODListManager()->Lookup(g_plantLodNames[info->m_variant][info->m_color]); - if (roi->GetUnknown0xe0() >= 0) { + if (roi->GetLodLevel() >= 0) { VideoManager()->Get3DManager()->GetLego3DView()->GetViewManager()->RemoveROIDetailFromScene(roi); } @@ -423,7 +423,7 @@ MxBool LegoPlantManager::SwitchVariant(LegoEntity* p_entity) ViewLODList* lodList = GetViewLODListManager()->Lookup(g_plantLodNames[info->m_variant][info->m_color]); - if (roi->GetUnknown0xe0() >= 0) { + if (roi->GetLodLevel() >= 0) { VideoManager()->Get3DManager()->GetLego3DView()->GetViewManager()->RemoveROIDetailFromScene(roi); } diff --git a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp index 1cc1f852..1c306c1b 100644 --- a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp @@ -701,7 +701,7 @@ MxLong LegoNavController::Notify(MxParam& p_param) Mx3DPointFloat roiPosition(roi->GetWorldPosition()); roiPosition -= viewPosition; - if (roiPosition.LenSquared() < 2000.0 || roi->GetUnknown0xe0() > 0) { + if (roiPosition.LenSquared() < 2000.0 || roi->GetLodLevel() > 0) { entity->ClickAnimation(); } } diff --git a/LEGO1/viewmanager/viewmanager.cpp b/LEGO1/viewmanager/viewmanager.cpp index caca5868..44635ffd 100644 --- a/LEGO1/viewmanager/viewmanager.cpp +++ b/LEGO1/viewmanager/viewmanager.cpp @@ -25,7 +25,7 @@ float g_minLODThreshold = 0.00097656297; int g_maxLODLevels = 6; // GLOBAL: LEGO1 0x1010105c -float g_unk0x1010105c = 0.000125F; +float g_viewDistance = 0.000125F; // GLOBAL: LEGO1 0x10101060 float g_elapsedSeconds = 0; @@ -65,19 +65,19 @@ unsigned int ViewManager::IsBoundingBoxInFrustum(const BoundingBox& p_bounding_b { const Vector3* box[] = {&p_bounding_box.Min(), &p_bounding_box.Max()}; - float und[8][3]; + float box_corners[8][3]; int i, j, k; for (i = 0; i < 8; i++) { for (j = 0; j < 3; j++) { - und[i][j] = box[g_boundingBoxCornerMap[i][j]]->operator[](j); + box_corners[i][j] = box[g_boundingBoxCornerMap[i][j]]->operator[](j); } } for (i = 0; i < 6; i++) { for (k = 0; k < 8; k++) { - if (frustum_planes[i][0] * und[k][0] + frustum_planes[i][2] * und[k][2] + frustum_planes[i][1] * und[k][1] + - frustum_planes[i][3] >= + if (frustum_planes[i][0] * box_corners[k][0] + frustum_planes[i][2] * box_corners[k][2] + + frustum_planes[i][1] * box_corners[k][1] + frustum_planes[i][3] >= 0.0f) { break; } @@ -98,7 +98,7 @@ void ViewManager::Remove(ViewROI* p_roi) if (*it == p_roi) { rois.erase(it); - if (p_roi->GetUnknown0xe0() >= 0) { + if (p_roi->GetLodLevel() >= 0) { RemoveROIDetailFromScene(p_roi); } @@ -106,7 +106,7 @@ void ViewManager::Remove(ViewROI* p_roi) if (comp != NULL) { for (CompoundObject::const_iterator it = comp->begin(); !(it == comp->end()); it++) { - if (((ViewROI*) *it)->GetUnknown0xe0() >= 0) { + if (((ViewROI*) *it)->GetLodLevel() >= 0) { RemoveROIDetailFromScene((ViewROI*) *it); } } @@ -128,11 +128,11 @@ void ViewManager::RemoveAll(ViewROI* p_roi) rois.erase(rois.begin(), rois.end()); } else { - if (p_roi->GetUnknown0xe0() >= 0) { + if (p_roi->GetLodLevel() >= 0) { RemoveROIDetailFromScene(p_roi); } - p_roi->SetUnknown0xe0(-1); + p_roi->SetLodLevel(ViewROI::c_lodLevelUnset); const CompoundObject* comp = p_roi->GetComp(); if (comp != NULL) { @@ -146,15 +146,15 @@ void ViewManager::RemoveAll(ViewROI* p_roi) } // FUNCTION: LEGO1 0x100a65b0 -void ViewManager::UpdateROIDetailBasedOnLOD(ViewROI* p_roi, int p_und) +void ViewManager::UpdateROIDetailBasedOnLOD(ViewROI* p_roi, int p_lodLevel) { - if (p_roi->GetLODCount() <= p_und) { - p_und = p_roi->GetLODCount() - 1; + if (p_roi->GetLODCount() <= p_lodLevel) { + p_lodLevel = p_roi->GetLODCount() - 1; } - int unk0xe0 = p_roi->GetUnknown0xe0(); + int lodLevel = p_roi->GetLodLevel(); - if (unk0xe0 == p_und) { + if (lodLevel == p_lodLevel) { return; } @@ -162,8 +162,8 @@ void ViewManager::UpdateROIDetailBasedOnLOD(ViewROI* p_roi, int p_und) Tgl::MeshBuilder* meshBuilder; ViewLOD* lod; - if (unk0xe0 < 0) { - lod = (ViewLOD*) p_roi->GetLOD(p_und); + if (lodLevel < 0) { + lod = (ViewLOD*) p_roi->GetLOD(p_lodLevel); if (lod->GetUnknown0x08() & ViewLOD::c_bit4) { scene->Add((Tgl::MeshBuilder*) group); @@ -171,7 +171,7 @@ void ViewManager::UpdateROIDetailBasedOnLOD(ViewROI* p_roi, int p_und) } } else { - lod = (ViewLOD*) p_roi->GetLOD(unk0xe0); + lod = (ViewLOD*) p_roi->GetLOD(lodLevel); if (lod != NULL) { meshBuilder = lod->GetMeshBuilder(); @@ -181,7 +181,7 @@ void ViewManager::UpdateROIDetailBasedOnLOD(ViewROI* p_roi, int p_und) } } - lod = (ViewLOD*) p_roi->GetLOD(p_und); + lod = (ViewLOD*) p_roi->GetLOD(p_lodLevel); } if (lod->GetUnknown0x08() & ViewLOD::c_bit4) { @@ -190,18 +190,18 @@ void ViewManager::UpdateROIDetailBasedOnLOD(ViewROI* p_roi, int p_und) if (meshBuilder != NULL) { group->Add(meshBuilder); SetAppData(p_roi, reinterpret_cast(p_roi)); - p_roi->SetUnknown0xe0(p_und); + p_roi->SetLodLevel(p_lodLevel); return; } } - p_roi->SetUnknown0xe0(-1); + p_roi->SetLodLevel(ViewROI::c_lodLevelUnset); } // FUNCTION: LEGO1 0x100a66a0 void ViewManager::RemoveROIDetailFromScene(ViewROI* p_roi) { - const ViewLOD* lod = (const ViewLOD*) p_roi->GetLOD(p_roi->GetUnknown0xe0()); + const ViewLOD* lod = (const ViewLOD*) p_roi->GetLOD(p_roi->GetLodLevel()); if (lod != NULL) { const Tgl::MeshBuilder* meshBuilder = NULL; @@ -216,60 +216,61 @@ void ViewManager::RemoveROIDetailFromScene(ViewROI* p_roi) scene->Remove(roiGeometry); } - p_roi->SetUnknown0xe0(-1); + p_roi->SetLodLevel(ViewROI::c_lodLevelUnset); } // FUNCTION: LEGO1 0x100a66f0 // FUNCTION: BETA10 0x1017297f -inline void ViewManager::ManageVisibilityAndDetailRecursively(ViewROI* p_from, int p_und) +inline void ViewManager::ManageVisibilityAndDetailRecursively(ViewROI* p_from, int p_lodLevel) { assert(p_from); - if (!p_from->GetVisibility() && p_und != -2) { - ManageVisibilityAndDetailRecursively(p_from, -2); + if (!p_from->GetVisibility() && p_lodLevel != ViewROI::c_lodLevelInvisible) { + ManageVisibilityAndDetailRecursively(p_from, ViewROI::c_lodLevelInvisible); } else { const CompoundObject* comp = p_from->GetComp(); - if (p_und == -1) { + if (p_lodLevel == ViewROI::c_lodLevelUnset) { if (p_from->GetWorldBoundingSphere().Radius() > 0.001F) { - float und = ProjectedSize(p_from->GetWorldBoundingSphere()); + float projectedSize = ProjectedSize(p_from->GetWorldBoundingSphere()); - if (und < seconds_allowed * g_unk0x1010105c) { - if (p_from->GetUnknown0xe0() != -2) { - ManageVisibilityAndDetailRecursively(p_from, -2); + if (projectedSize < seconds_allowed * g_viewDistance) { + if (p_from->GetLodLevel() != ViewROI::c_lodLevelInvisible) { + ManageVisibilityAndDetailRecursively(p_from, ViewROI::c_lodLevelInvisible); } return; } else { - p_und = CalculateLODLevel(und, RealtimeView::GetUserMaxLodPower() * seconds_allowed, p_from); + p_lodLevel = + CalculateLODLevel(projectedSize, RealtimeView::GetUserMaxLodPower() * seconds_allowed, p_from); } } } - if (p_und == -2) { - if (p_from->GetUnknown0xe0() >= 0) { + if (p_lodLevel == ViewROI::c_lodLevelInvisible) { + if (p_from->GetLodLevel() >= 0) { RemoveROIDetailFromScene(p_from); - p_from->SetUnknown0xe0(-2); + p_from->SetLodLevel(ViewROI::c_lodLevelInvisible); } if (comp != NULL) { for (CompoundObject::const_iterator it = comp->begin(); it != comp->end(); it++) { - ManageVisibilityAndDetailRecursively((ViewROI*) *it, p_und); + ManageVisibilityAndDetailRecursively((ViewROI*) *it, p_lodLevel); } } } else if (comp == NULL) { if (p_from->GetLODs() != NULL && p_from->GetLODCount() > 0) { - UpdateROIDetailBasedOnLOD(p_from, p_und); + UpdateROIDetailBasedOnLOD(p_from, p_lodLevel); } } else { - p_from->SetUnknown0xe0(-1); + p_from->SetLodLevel(ViewROI::c_lodLevelUnset); for (CompoundObject::const_iterator it = comp->begin(); it != comp->end(); it++) { - ManageVisibilityAndDetailRecursively((ViewROI*) *it, p_und); + ManageVisibilityAndDetailRecursively((ViewROI*) *it, p_lodLevel); } } } @@ -292,7 +293,7 @@ void ViewManager::Update(float p_previousRenderTime, float) } for (CompoundObject::iterator it = rois.begin(); it != rois.end(); it++) { - ManageVisibilityAndDetailRecursively((ViewROI*) *it, -1); + ManageVisibilityAndDetailRecursively((ViewROI*) *it, ViewROI::c_lodLevelUnset); } stopWatch.Stop(); @@ -353,37 +354,37 @@ inline int ViewManager::CalculateFrustumTransformations() } // FUNCTION: BETA10 0x10172be5 -inline int ViewManager::CalculateLODLevel(float p_und1, float p_und2, ViewROI* from) +inline int ViewManager::CalculateLODLevel(float p_maximumScale, float p_initialScale, ViewROI* from) { - int result; + int lodLevel; assert(from); - if (IsROIVisibleAtLOD(from) != 0) { - if (p_und1 < g_minLODThreshold) { + if (GetFirstLODIndex(from) != 0) { + if (p_maximumScale < g_minLODThreshold) { return 0; } else { - result = 1; + lodLevel = 1; } } else { - result = 0; + lodLevel = 0; } - for (float i = p_und2; result < g_maxLODLevels; result++) { - if (i >= p_und1) { + for (float i = p_initialScale; lodLevel < g_maxLODLevels; lodLevel++) { + if (i >= p_maximumScale) { break; } i *= g_LODScaleFactor; } - return result; + return lodLevel; } // FUNCTION: BETA10 0x10172cb0 -inline int ViewManager::IsROIVisibleAtLOD(ViewROI* p_roi) +inline int ViewManager::GetFirstLODIndex(ViewROI* p_roi) { const LODListBase* lods = p_roi->GetLODs(); diff --git a/LEGO1/viewmanager/viewmanager.h b/LEGO1/viewmanager/viewmanager.h index 550dd667..1f12cb28 100644 --- a/LEGO1/viewmanager/viewmanager.h +++ b/LEGO1/viewmanager/viewmanager.h @@ -24,20 +24,20 @@ public: void Remove(ViewROI* p_roi); void RemoveAll(ViewROI* p_roi); unsigned int IsBoundingBoxInFrustum(const BoundingBox& p_bounding_box); - void UpdateROIDetailBasedOnLOD(ViewROI* p_roi, int p_und); + void UpdateROIDetailBasedOnLOD(ViewROI* p_roi, int p_lodLevel); void RemoveROIDetailFromScene(ViewROI* p_roi); void SetPOVSource(const OrientableROI* point_of_view); float ProjectedSize(const BoundingSphere& p_bounding_sphere); ViewROI* Pick(Tgl::View* p_view, unsigned long x, unsigned long y); void SetResolution(int width, int height); void SetFrustrum(float fov, float front, float back); - inline void ManageVisibilityAndDetailRecursively(ViewROI* p_from, int p_und); + inline void ManageVisibilityAndDetailRecursively(ViewROI* p_from, int p_lodLevel); void Update(float p_previousRenderTime, float); inline int CalculateFrustumTransformations(); void UpdateViewTransformations(); - inline static int CalculateLODLevel(float p_und1, float p_und2, ViewROI* from); - inline static int IsROIVisibleAtLOD(ViewROI* p_roi); + inline static int CalculateLODLevel(float p_maximumScale, float p_initalScale, ViewROI* from); + inline static int GetFirstLODIndex(ViewROI* p_roi); // FUNCTION: BETA10 0x100576b0 const CompoundObject& GetROIs() { return rois; } diff --git a/LEGO1/viewmanager/viewroi.h b/LEGO1/viewmanager/viewroi.h index 5cd8d1af..63e82154 100644 --- a/LEGO1/viewmanager/viewroi.h +++ b/LEGO1/viewmanager/viewroi.h @@ -16,11 +16,16 @@ // SIZE 0xe4 class ViewROI : public OrientableROI { public: + enum { + c_lodLevelUnset = -1, + c_lodLevelInvisible = -2, + }; + ViewROI(Tgl::Renderer* pRenderer, ViewLODList* lodList) { SetLODList(lodList); geometry = pRenderer->CreateGroup(); - m_unk0xe0 = -1; + m_lodLevel = c_lodLevelUnset; } // FUNCTION: LEGO1 0x100a9e20 @@ -56,8 +61,8 @@ public: virtual Tgl::Group* GetGeometry(); // vtable+0x30 virtual const Tgl::Group* GetGeometry() const; // vtable+0x34 - int GetUnknown0xe0() { return m_unk0xe0; } - void SetUnknown0xe0(int p_unk0xe0) { m_unk0xe0 = p_unk0xe0; } + int GetLodLevel() { return m_lodLevel; } + void SetLodLevel(int p_lodLevel) { m_lodLevel = p_lodLevel; } static unsigned char SetLightSupport(unsigned char p_lightSupport); @@ -65,7 +70,7 @@ protected: void UpdateWorldDataWithTransformAndChildren(const Matrix4& parent2world) override; // vtable+0x28 Tgl::Group* geometry; // 0xdc - int m_unk0xe0; // 0xe0 + int m_lodLevel; // 0xe0 }; // SYNTHETIC: LEGO1 0x100aa250 From 6159d23cde3ed6fa5f1556af8c44abb514dd30cb Mon Sep 17 00:00:00 2001 From: Fabian Neundorf Date: Thu, 19 Jun 2025 23:52:02 +0200 Subject: [PATCH 3/6] Clear unknowns in `Radio` and `RadioState` (#1573) --- LEGO1/lego/legoomni/include/radio.h | 12 +++--- LEGO1/lego/legoomni/src/actors/radio.cpp | 48 ++++++++++++------------ 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/LEGO1/lego/legoomni/include/radio.h b/LEGO1/lego/legoomni/include/radio.h index 9ff8cb9c..4b7e1202 100644 --- a/LEGO1/lego/legoomni/include/radio.h +++ b/LEGO1/lego/legoomni/include/radio.h @@ -39,14 +39,14 @@ public: void SetActive(MxBool p_active) { m_active = p_active; } - undefined4 FUN_1002d090(); - MxBool FUN_1002d0c0(const MxAtomId& p_atom, MxU32 p_objectId); + MxU32 NextPlaylistObjectId(); + MxBool IsRadioObjectId(const MxAtomId& p_atom, MxU32 p_objectId); // TODO: Most likely getters/setters are not used according to BETA. - Playlist m_unk0x08[3]; // 0x08 - MxS16 m_unk0x2c; // 0x2c - MxBool m_active; // 0x2e + Playlist m_playlists[3]; // 0x08 + MxS16 m_activePlaylist; // 0x2c + MxBool m_active; // 0x2e }; // VTABLE: LEGO1 0x100d6d10 @@ -85,7 +85,7 @@ public: private: RadioState* m_state; // 0x08 - MxBool m_unk0x0c; // 0x0c + MxBool m_enabled; // 0x0c MxBool m_audioEnabled; // 0x0d MxLong HandleEndAction(MxEndActionNotificationParam& p_param); diff --git a/LEGO1/lego/legoomni/src/actors/radio.cpp b/LEGO1/lego/legoomni/src/actors/radio.cpp index db5017f2..d32955fe 100644 --- a/LEGO1/lego/legoomni/src/actors/radio.cpp +++ b/LEGO1/lego/legoomni/src/actors/radio.cpp @@ -18,7 +18,7 @@ DECOMP_SIZE_ASSERT(Radio, 0x10) DECOMP_SIZE_ASSERT(RadioState, 0x30) // GLOBAL: LEGO1 0x100f3218 -JukeboxScript::Script g_unk0x100f3218[] = { +JukeboxScript::Script g_jingles[] = { JukeboxScript::c_sns002ra_Audio, JukeboxScript::c_sns001ja_Audio, JukeboxScript::c_snsc01js_Audio, @@ -28,7 +28,7 @@ JukeboxScript::Script g_unk0x100f3218[] = { }; // GLOBAL: LEGO1 0x100f3230 -JukeboxScript::Script g_unk0x100f3230[] = { +JukeboxScript::Script g_news[] = { JukeboxScript::c_ham035ra_Audio, JukeboxScript::c_ham039ra_Audio, JukeboxScript::c_sns005ra_Audio, @@ -46,7 +46,7 @@ JukeboxScript::Script g_unk0x100f3230[] = { }; // GLOBAL: LEGO1 0x100f3268 -JukeboxScript::Script g_unk0x100f3268[] = { +JukeboxScript::Script g_songs[] = { JukeboxScript::c_CentralRoads_Music, JukeboxScript::c_BeachBlvd_Music, JukeboxScript::c_ResidentalArea_Music, @@ -64,7 +64,7 @@ Radio::Radio() NotificationManager()->Register(this); ControlManager()->Register(this); - m_unk0x0c = TRUE; + m_enabled = TRUE; CreateState(); } @@ -86,7 +86,7 @@ MxLong Radio::Notify(MxParam& p_param) { MxLong result = 0; - if (m_unk0x0c) { + if (m_enabled) { MxNotificationParam& param = (MxNotificationParam&) p_param; switch (param.GetNotification()) { case c_notificationEndAction: @@ -108,7 +108,7 @@ void Radio::Play() CurrentWorld(); MxDSAction action; - action.SetObjectId(m_state->FUN_1002d090()); + action.SetObjectId(m_state->NextPlaylistObjectId()); action.SetAtomId(*g_jukeboxScript); action.SetLoopCount(1); @@ -174,11 +174,11 @@ MxLong Radio::HandleControl(LegoControlManagerNotificationParam& p_param) MxLong Radio::HandleEndAction(MxEndActionNotificationParam& p_param) { if (m_state->IsActive() && - m_state->FUN_1002d0c0(p_param.GetAction()->GetAtomId(), p_param.GetAction()->GetObjectId())) { + m_state->IsRadioObjectId(p_param.GetAction()->GetAtomId(), p_param.GetAction()->GetObjectId())) { MxDSAction action; action.SetAtomId(*g_jukeboxScript); - action.SetObjectId(m_state->FUN_1002d090()); + action.SetObjectId(m_state->NextPlaylistObjectId()); action.SetLoopCount(1); BackgroundAudioManager()->PlayMusic(action, 3, MxPresenter::e_repeating); @@ -191,8 +191,8 @@ MxLong Radio::HandleEndAction(MxEndActionNotificationParam& p_param) // FUNCTION: LEGO1 0x1002cdc0 void Radio::Initialize(MxBool p_und) { - if (m_unk0x0c != p_und) { - m_unk0x0c = p_und; + if (m_enabled != p_und) { + m_enabled = p_und; CreateState(); } } @@ -216,39 +216,39 @@ RadioState::RadioState() srand(Timer()->GetTime()); MxS32 random = rand(); - m_unk0x2c = random % 3; + m_activePlaylist = random % 3; - m_unk0x08[0] = Playlist((MxU32*) g_unk0x100f3218, sizeOfArray(g_unk0x100f3218), Playlist::e_loop); - m_unk0x08[0].m_nextIndex = (rand() % sizeOfArray(g_unk0x100f3218)); + m_playlists[0] = Playlist((MxU32*) g_jingles, sizeOfArray(g_jingles), Playlist::e_loop); + m_playlists[0].m_nextIndex = (rand() % sizeOfArray(g_jingles)); - m_unk0x08[1] = Playlist((MxU32*) g_unk0x100f3230, sizeOfArray(g_unk0x100f3230), Playlist::e_loop); - m_unk0x08[1].m_nextIndex = (rand() % sizeOfArray(g_unk0x100f3230)); + m_playlists[1] = Playlist((MxU32*) g_news, sizeOfArray(g_news), Playlist::e_loop); + m_playlists[1].m_nextIndex = (rand() % sizeOfArray(g_news)); - m_unk0x08[2] = Playlist((MxU32*) g_unk0x100f3268, sizeOfArray(g_unk0x100f3268), Playlist::e_loop); - m_unk0x08[2].m_nextIndex = (rand() % sizeOfArray(g_unk0x100f3268)); + m_playlists[2] = Playlist((MxU32*) g_songs, sizeOfArray(g_songs), Playlist::e_loop); + m_playlists[2].m_nextIndex = (rand() % sizeOfArray(g_songs)); m_active = FALSE; } // FUNCTION: LEGO1 0x1002d090 -MxU32 RadioState::FUN_1002d090() +MxU32 RadioState::NextPlaylistObjectId() { - if (m_unk0x2c == 2) { - m_unk0x2c = 0; + if (m_activePlaylist == 2) { + m_activePlaylist = 0; } else { - m_unk0x2c++; + m_activePlaylist++; } - return m_unk0x08[m_unk0x2c].Next(); + return m_playlists[m_activePlaylist].Next(); } // FUNCTION: LEGO1 0x1002d0c0 -MxBool RadioState::FUN_1002d0c0(const MxAtomId& p_atom, MxU32 p_objectId) +MxBool RadioState::IsRadioObjectId(const MxAtomId& p_atom, MxU32 p_objectId) { if (*g_jukeboxScript == p_atom) { for (MxS16 i = 0; i < 3; i++) { - if (m_unk0x08[i].Contains(p_objectId)) { + if (m_playlists[i].Contains(p_objectId)) { return TRUE; } } From f9e34c46e351f0c678f59d4f32aa58a328862f17 Mon Sep 17 00:00:00 2001 From: Fabian Neundorf Date: Fri, 20 Jun 2025 00:38:31 +0200 Subject: [PATCH 4/6] Clear unknowns in `PizzeriaState`, `Pizza` and `PizzaMissionState` (#1574) --- LEGO1/lego/legoomni/include/pizza.h | 14 +-- LEGO1/lego/legoomni/include/pizzeria.h | 6 +- LEGO1/lego/legoomni/src/actors/pizza.cpp | 102 ++++++++++---------- LEGO1/lego/legoomni/src/actors/pizzeria.cpp | 26 ++--- 4 files changed, 74 insertions(+), 74 deletions(-) diff --git a/LEGO1/lego/legoomni/include/pizza.h b/LEGO1/lego/legoomni/include/pizza.h index 89b19cb0..b81b76f8 100644 --- a/LEGO1/lego/legoomni/include/pizza.h +++ b/LEGO1/lego/legoomni/include/pizza.h @@ -125,10 +125,10 @@ public: MxResult Serialize(LegoStorage* p_storage) override; // vtable+0x1c // FUNCTION: BETA10 0x100ef470 - void SetUnknown0xb0(MxU32 p_unk0xb0) { m_unk0xb0 = p_unk0xb0; } + void SetPlayedAction(MxU32 p_playedAction) { m_playedAction = p_playedAction; } // FUNCTION: BETA10 0x100ef850 - MxU32 GetUnknown0xb0() { return m_unk0xb0; } + MxU32 GetPlayedAction() { return m_playedAction; } // FUNCTION: BETA10 0x10088850 MxS16 GetHighScore(MxU8 p_actorId) { return GetMission(p_actorId)->m_hiScore; } @@ -137,12 +137,12 @@ public: // PizzaMissionState::`scalar deleting destructor' Mission* GetMission(MxU8 p_actorId); - MxS16 FUN_10039540(); + MxS16 GetActorState(); PizzeriaState* m_pizzeriaState; // 0x08 undefined4 m_unk0x0c; // 0x0c Mission m_missions[5]; // 0x10 - MxU32 m_unk0xb0; // 0xb0 + MxU32 m_playedAction; // 0xb0 static IsleScript::Script g_pepperActions[]; static IsleScript::Script g_mamaActions[]; @@ -202,9 +202,9 @@ private: PizzaMissionState::Mission* m_mission; // 0x80 SkateBoard* m_skateBoard; // 0x84 Act1State* m_act1state; // 0x88 - IsleScript::Script m_unk0x8c; // 0x8c - MxLong m_unk0x90; // 0x90 - MxLong m_unk0x94; // 0x94 + IsleScript::Script m_speechAction; // 0x8c + MxLong m_startTime; // 0x90 + MxLong m_duration; // 0x94 MxBool m_unk0x98; // 0x98 }; diff --git a/LEGO1/lego/legoomni/include/pizzeria.h b/LEGO1/lego/legoomni/include/pizzeria.h index a959abb3..cdfe7d45 100644 --- a/LEGO1/lego/legoomni/include/pizzeria.h +++ b/LEGO1/lego/legoomni/include/pizzeria.h @@ -34,11 +34,11 @@ public: // SYNTHETIC: LEGO1 0x10017ce0 // PizzeriaState::`scalar deleting destructor' - MxS16 FUN_10017d50(); + MxS16 GetActorState(); MxU32 NextAction(); - Playlist m_unk0x08[5]; // 0x08 - MxS32 m_unk0x44[5]; // 0x44 + Playlist m_playerPlaylists[5]; // 0x08 + MxS32 m_states[5]; // 0x44 static IsleScript::Script g_pepperActions[]; static IsleScript::Script g_mamaActions[]; diff --git a/LEGO1/lego/legoomni/src/actors/pizza.cpp b/LEGO1/lego/legoomni/src/actors/pizza.cpp index 98d711f2..18da7fca 100644 --- a/LEGO1/lego/legoomni/src/actors/pizza.cpp +++ b/LEGO1/lego/legoomni/src/actors/pizza.cpp @@ -136,9 +136,9 @@ Pizza::Pizza() m_mission = NULL; m_skateBoard = NULL; m_act1state = NULL; - m_unk0x8c = IsleScript::c_noneIsle; + m_speechAction = IsleScript::c_noneIsle; m_unk0x98 = FALSE; - m_unk0x90 = INT_MIN; + m_startTime = INT_MIN; } // FUNCTION: LEGO1 0x10038100 @@ -188,7 +188,7 @@ void Pizza::FUN_10038220(IsleScript::Script p_objectId) AnimationManager()->EnableCamAnims(FALSE); AnimationManager()->FUN_1005f6d0(FALSE); PlayAction(p_objectId, FALSE); - m_unk0x8c = IsleScript::c_noneIsle; + m_speechAction = IsleScript::c_noneIsle; } // FUNCTION: LEGO1 0x100382b0 @@ -196,8 +196,8 @@ void Pizza::FUN_10038220(IsleScript::Script p_objectId) void Pizza::FUN_100382b0() { if (m_state->m_unk0x0c != 8) { - if (m_unk0x8c != IsleScript::c_noneIsle) { - InvokeAction(Extra::e_stop, *g_isleScript, m_unk0x8c, NULL); + if (m_speechAction != IsleScript::c_noneIsle) { + InvokeAction(Extra::e_stop, *g_isleScript, m_speechAction, NULL); } m_act1state->m_unk0x018 = 0; @@ -209,10 +209,10 @@ void Pizza::FUN_100382b0() m_mission->m_startTime = INT_MIN; m_mission = NULL; m_unk0x98 = FALSE; - m_unk0x8c = IsleScript::c_noneIsle; + m_speechAction = IsleScript::c_noneIsle; BackgroundAudioManager()->RaiseVolume(); TickleManager()->UnregisterClient(this); - m_unk0x90 = INT_MIN; + m_startTime = INT_MIN; m_skateBoard->EnableScenePresentation(FALSE); m_skateBoard->SetPizzaVisible(FALSE); MxTrace("Pizza mission: idle\n"); @@ -254,7 +254,7 @@ MxLong Pizza::HandleClick() IsleScript::Script action; - switch (m_state->FUN_10039540()) { + switch (m_state->GetActorState()) { case 0: action = m_mission->m_actions[m_mission->m_numActions + 3]; break; @@ -284,7 +284,7 @@ MxLong Pizza::HandlePathStruct(LegoPathStructNotificationParam& p_param) if (p_param.GetTrigger() == LegoPathStruct::c_s && p_param.GetData() == 0x12e && GameState()->GetActorId() == LegoActor::c_pepper) { m_state->m_unk0x0c = 5; - m_state->SetUnknown0xb0(SndanimScript::c_TRS302_OpenJailDoor); + m_state->SetPlayedAction(SndanimScript::c_TRS302_OpenJailDoor); if (time < m_mission->GetRedFinishTime()) { m_mission->UpdateScore(LegoState::e_red); @@ -325,26 +325,26 @@ MxLong Pizza::HandlePathStruct(LegoPathStructNotificationParam& p_param) case IsleScript::c_pps025ni_RunAnim: case IsleScript::c_pps026ni_RunAnim: case IsleScript::c_pps027ni_RunAnim: - m_unk0x90 = Timer()->GetTime(); - m_unk0x94 = 3800; + m_startTime = Timer()->GetTime(); + m_duration = 3800; break; case IsleScript::c_pgs050nu_RunAnim: case IsleScript::c_pgs051nu_RunAnim: case IsleScript::c_pgs052nu_RunAnim: - m_unk0x90 = Timer()->GetTime(); - m_unk0x94 = 6400; + m_startTime = Timer()->GetTime(); + m_duration = 6400; break; case IsleScript::c_prt072sl_RunAnim: case IsleScript::c_prt073sl_RunAnim: case IsleScript::c_prt074sl_RunAnim: - m_unk0x90 = Timer()->GetTime(); - m_unk0x94 = 7000; + m_startTime = Timer()->GetTime(); + m_duration = 7000; break; case IsleScript::c_pho104re_RunAnim: case IsleScript::c_pho105re_RunAnim: case IsleScript::c_pho106re_RunAnim: - m_unk0x90 = Timer()->GetTime(); - m_unk0x94 = 6500; + m_startTime = Timer()->GetTime(); + m_duration = 6500; break; } @@ -376,8 +376,8 @@ MxResult Pizza::Tickle() { MxLong time = Timer()->GetTime(); - if (m_unk0x90 != INT_MIN && m_unk0x94 + m_unk0x90 <= time) { - m_unk0x90 = INT_MIN; + if (m_startTime != INT_MIN && m_duration + m_startTime <= time) { + m_startTime = INT_MIN; m_skateBoard->EnableScenePresentation(FALSE); m_skateBoard->SetPizzaVisible(FALSE); TickleManager()->UnregisterClient(this); @@ -395,29 +395,29 @@ MxResult Pizza::Tickle() InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_Avo917In_PlayWav, NULL); MxTrace("Pizza mission: timeout, stop\n"); } - else if (time >= m_mission->m_startTime + 35000 && m_unk0x8c == IsleScript::c_noneIsle) { + else if (time >= m_mission->m_startTime + 35000 && m_speechAction == IsleScript::c_noneIsle) { switch (GameState()->GetActorId()) { case LegoActor::c_pepper: - m_unk0x8c = IsleScript::c_Avo914In_PlayWav; + m_speechAction = IsleScript::c_Avo914In_PlayWav; break; case LegoActor::c_mama: - m_unk0x8c = IsleScript::c_Avo910In_PlayWav; + m_speechAction = IsleScript::c_Avo910In_PlayWav; break; case LegoActor::c_papa: - m_unk0x8c = IsleScript::c_Avo912In_PlayWav; + m_speechAction = IsleScript::c_Avo912In_PlayWav; break; case LegoActor::c_nick: - m_unk0x8c = IsleScript::c_Avo911In_PlayWav; + m_speechAction = IsleScript::c_Avo911In_PlayWav; break; case LegoActor::c_laura: - m_unk0x8c = IsleScript::c_Avo913In_PlayWav; + m_speechAction = IsleScript::c_Avo913In_PlayWav; break; } BackgroundAudioManager()->LowerVolume(); - if (m_unk0x8c != IsleScript::c_noneIsle) { - InvokeAction(Extra::e_start, *g_isleScript, m_unk0x8c, NULL); + if (m_speechAction != IsleScript::c_noneIsle) { + InvokeAction(Extra::e_start, *g_isleScript, m_speechAction, NULL); } } } @@ -447,14 +447,14 @@ MxLong Pizza::HandleEndAction(MxEndActionNotificationParam& p_param) MxLong result = 0; MxU32 objectId = p_param.GetAction()->GetObjectId(); - if (m_unk0x8c == objectId) { + if (m_speechAction == objectId) { BackgroundAudioManager()->RaiseVolume(); return 1; } switch (m_state->m_unk0x0c) { case 1: - if (m_state->GetUnknown0xb0() == objectId) { + if (m_state->GetPlayedAction() == objectId) { m_state->m_unk0x0c = 2; m_mission->m_startTime = Timer()->GetTime(); TickleManager()->RegisterClient(this, 200); @@ -462,7 +462,7 @@ MxLong Pizza::HandleEndAction(MxEndActionNotificationParam& p_param) } break; case 3: - if (m_state->GetUnknown0xb0() == objectId) { + if (m_state->GetPlayedAction() == objectId) { m_mission->m_startTime = Timer()->GetTime(); PizzaMissionState::Mission* mission = m_mission; @@ -471,7 +471,7 @@ MxLong Pizza::HandleEndAction(MxEndActionNotificationParam& p_param) } m_state->m_unk0x0c = 4; - m_state->SetUnknown0xb0(IsleScript::c_noneIsle); + m_state->SetPlayedAction(IsleScript::c_noneIsle); UserActor()->SetActorState(LegoPathActor::c_initial); m_skateBoard->SetPizzaVisible(TRUE); m_world->PlaceActor(m_skateBoard, "int37", 2, 0.5, 3, 0.5); @@ -490,7 +490,7 @@ MxLong Pizza::HandleEndAction(MxEndActionNotificationParam& p_param) } break; case 5: - if (m_state->GetUnknown0xb0() == objectId) { + if (m_state->GetPlayedAction() == objectId) { StopActions(); if (GameState()->GetActorId() == LegoActor::c_pepper) { @@ -506,24 +506,24 @@ MxLong Pizza::HandleEndAction(MxEndActionNotificationParam& p_param) break; case 2: action = IsleScript::c_pja129br_RunAnim; - m_unk0x90 = Timer()->GetTime(); - m_unk0x94 = 500; + m_startTime = Timer()->GetTime(); + m_duration = 500; m_mission->m_unk0x14++; m_state->m_unk0x0c = 6; MxTrace("Pizza mission: succeeds\n"); break; case 3: action = IsleScript::c_pja131br_RunAnim; - m_unk0x90 = Timer()->GetTime(); - m_unk0x94 = 500; + m_startTime = Timer()->GetTime(); + m_duration = 500; m_state->m_unk0x0c = 6; break; } } else { action = IsleScript::c_pja132br_RunAnim; - m_unk0x90 = Timer()->GetTime(); - m_unk0x94 = 2300; + m_startTime = Timer()->GetTime(); + m_duration = 2300; m_state->m_unk0x0c = 8; InputManager()->DisableInputProcessing(); InputManager()->SetUnknown336(TRUE); @@ -535,16 +535,16 @@ MxLong Pizza::HandleEndAction(MxEndActionNotificationParam& p_param) else { FUN_100382b0(); m_state->m_unk0x0c = 0; - m_state->SetUnknown0xb0(IsleScript::c_noneIsle); + m_state->SetPlayedAction(IsleScript::c_noneIsle); } } break; case 6: - if (m_state->GetUnknown0xb0() == objectId) { + if (m_state->GetPlayedAction() == objectId) { if (objectId == IsleScript::c_pja126br_RunAnim) { PlayAction(IsleScript::c_pja127br_RunAnim, TRUE); - m_unk0x90 = Timer()->GetTime(); - m_unk0x94 = 700; + m_startTime = Timer()->GetTime(); + m_duration = 700; } else if (objectId == IsleScript::c_pja129br_RunAnim) { PlayAction(IsleScript::c_pja130br_RunAnim, TRUE); @@ -552,12 +552,12 @@ MxLong Pizza::HandleEndAction(MxEndActionNotificationParam& p_param) else { FUN_100382b0(); m_state->m_unk0x0c = 0; - m_state->SetUnknown0xb0(IsleScript::c_noneIsle); + m_state->SetPlayedAction(IsleScript::c_noneIsle); } } break; case 8: - if (m_state->GetUnknown0xb0() == objectId) { + if (m_state->GetPlayedAction() == objectId) { m_act1state->m_unk0x018 = 0; m_state->m_unk0x0c = 0; GameState()->m_currentArea = LegoGameState::e_isle; @@ -567,7 +567,7 @@ MxLong Pizza::HandleEndAction(MxEndActionNotificationParam& p_param) } break; case 9: - if (m_state->GetUnknown0xb0() == objectId) { + if (m_state->GetPlayedAction() == objectId) { FUN_100382b0(); } break; @@ -580,10 +580,10 @@ MxLong Pizza::HandleEndAction(MxEndActionNotificationParam& p_param) // FUNCTION: BETA10 0x100ef520 void Pizza::PlayAction(MxU32 p_objectId, MxBool p_param7) { - m_state->SetUnknown0xb0(p_objectId); + m_state->SetPlayedAction(p_objectId); - if (m_unk0x8c != IsleScript::c_noneIsle) { - InvokeAction(Extra::e_stop, *g_isleScript, m_unk0x8c, NULL); + if (m_speechAction != IsleScript::c_noneIsle) { + InvokeAction(Extra::e_stop, *g_isleScript, m_speechAction, NULL); } AnimationManager() @@ -601,7 +601,7 @@ PizzaMissionState::PizzaMissionState() m_missions[3] = Mission(LegoActor::c_nick, 2, g_nickFinishTimes, g_nickActions, 4); m_missions[4] = Mission(LegoActor::c_laura, 2, g_lauraFinishTimes, g_lauraActions, 4); m_pizzeriaState = (PizzeriaState*) GameState()->GetState("PizzeriaState"); - m_unk0xb0 = IsleScript::c_noneIsle; + m_playedAction = IsleScript::c_noneIsle; } // FUNCTION: LEGO1 0x100393c0 @@ -645,7 +645,7 @@ PizzaMissionState::Mission* PizzaMissionState::GetMission(MxU8 p_actorId) } // FUNCTION: LEGO1 0x10039540 -MxS16 PizzaMissionState::FUN_10039540() +MxS16 PizzaMissionState::GetActorState() { - return m_pizzeriaState->FUN_10017d50(); + return m_pizzeriaState->GetActorState(); } diff --git a/LEGO1/lego/legoomni/src/actors/pizzeria.cpp b/LEGO1/lego/legoomni/src/actors/pizzeria.cpp index d2d98956..a040f337 100644 --- a/LEGO1/lego/legoomni/src/actors/pizzeria.cpp +++ b/LEGO1/lego/legoomni/src/actors/pizzeria.cpp @@ -89,18 +89,18 @@ MxLong Pizzeria::HandleClick() // FUNCTION: BETA10 0x100efd14 PizzeriaState::PizzeriaState() { - m_unk0x08[0] = Playlist((MxU32*) g_pepperActions, sizeOfArray(g_pepperActions), Playlist::e_once); - m_unk0x08[1] = Playlist((MxU32*) g_mamaActions, sizeOfArray(g_mamaActions), Playlist::e_once); - m_unk0x08[2] = Playlist((MxU32*) g_papaActions, sizeOfArray(g_papaActions), Playlist::e_once); - m_unk0x08[3] = Playlist((MxU32*) g_nickActions, sizeOfArray(g_nickActions), Playlist::e_once); - m_unk0x08[4] = Playlist((MxU32*) g_lauraActions, sizeOfArray(g_lauraActions), Playlist::e_once); - memset(m_unk0x44, -1, sizeof(m_unk0x44)); + m_playerPlaylists[0] = Playlist((MxU32*) g_pepperActions, sizeOfArray(g_pepperActions), Playlist::e_once); + m_playerPlaylists[1] = Playlist((MxU32*) g_mamaActions, sizeOfArray(g_mamaActions), Playlist::e_once); + m_playerPlaylists[2] = Playlist((MxU32*) g_papaActions, sizeOfArray(g_papaActions), Playlist::e_once); + m_playerPlaylists[3] = Playlist((MxU32*) g_nickActions, sizeOfArray(g_nickActions), Playlist::e_once); + m_playerPlaylists[4] = Playlist((MxU32*) g_lauraActions, sizeOfArray(g_lauraActions), Playlist::e_once); + memset(m_states, -1, sizeof(m_states)); } // FUNCTION: LEGO1 0x10017d50 -MxS16 PizzeriaState::FUN_10017d50() +MxS16 PizzeriaState::GetActorState() { - return m_unk0x44[GameState()->GetActorId() - 1]; + return m_states[GameState()->GetActorId() - 1]; } // FUNCTION: LEGO1 0x10017d70 @@ -109,11 +109,11 @@ MxU32 PizzeriaState::NextAction() { MxU8 actorId = GameState()->GetActorId(); - if (m_unk0x44[actorId - 1] < 2) { - m_unk0x44[actorId - 1]++; + if (m_states[actorId - 1] < 2) { + m_states[actorId - 1]++; } - return m_unk0x08[actorId - 1].Next(); + return m_playerPlaylists[actorId - 1].Next(); } // FUNCTION: LEGO1 0x10017da0 @@ -124,12 +124,12 @@ MxResult PizzeriaState::Serialize(LegoStorage* p_storage) if (p_storage->IsReadMode()) { for (MxS16 i = 0; i < 5; i++) { - p_storage->ReadS16(m_unk0x08[i].m_nextIndex); + p_storage->ReadS16(m_playerPlaylists[i].m_nextIndex); } } else { for (MxS16 i = 0; i < 5; i++) { - p_storage->WriteS16(m_unk0x08[i].m_nextIndex); + p_storage->WriteS16(m_playerPlaylists[i].m_nextIndex); } } From 4691b0253cac09c19fad7b902353e46a9f790b68 Mon Sep 17 00:00:00 2001 From: jonschz <17198703+jonschz@users.noreply.github.com> Date: Fri, 20 Jun 2025 06:53:42 +0200 Subject: [PATCH 5/6] Fix BETA10 linker settings (#1572) Co-authored-by: jonschz --- CMakeLists.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37aa52ce..064a207e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -483,7 +483,12 @@ if(ISLE_BUILD_BETA10) OUT_TARGETS beta10_targets ) reccmp_add_target(beta10 ID BETA10) + + # Enable `#ifdef BETA10` conditions target_compile_definitions(beta10 PRIVATE BETA10) + foreach(tgt IN LISTS beta10_targets) + target_compile_definitions(${tgt} PRIVATE BETA10) + endforeach() endif() if (ISLE_BUILD_APP) @@ -600,10 +605,13 @@ if (MSVC_FOR_DECOMP) endif() endif() + # Setting the MSVC_RUNTIME_LIBRARY for all libraries as well as `lego1` produces the results + # that are most consistent with the LEGO1.DLL and BETA10.DLL originals we have. + # Equivalent to target_compile_options(... PRIVATE "/MT$<$:d>") + set_property(TARGET ${lego1_targets} ${beta10_targets} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") if(TARGET lego1) target_link_options(lego1 PRIVATE "/OPT:REF") - # Equivalent to target_compile_options(... PRIVATE "/MT$<$:d>") - set_property(TARGET lego1 ${lego1_targets} ${beta10_targets} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + set_property(TARGET lego1 PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() set(CMAKE_CXX_FLAGS "/W3 /GX /D \"WIN32\" /D \"_WINDOWS\"") From 72eb19442443624642ebaca746a3ade7859783a3 Mon Sep 17 00:00:00 2001 From: Florian Kaiser Date: Sat, 21 Jun 2025 01:24:32 +0200 Subject: [PATCH 6/6] Clear unknowns in `LegoAnimPresenter` and related classes (#1565) * Clear unknowns in `LegoAnimPresenter` and related classes * Update LEGO1/lego/legoomni/include/legoanimpresenter.h --------- Co-authored-by: Christian Semmler --- .../lego/legoomni/include/legoanimpresenter.h | 17 +-- .../src/build/legocarbuildpresenter.cpp | 8 +- .../legoomni/src/video/legoanimpresenter.cpp | 100 +++++++++--------- .../src/video/legohideanimpresenter.cpp | 6 +- .../src/video/legolocomotionanimpresenter.cpp | 6 +- LEGO1/lego/sources/anim/legoanim.cpp | 30 +++--- LEGO1/lego/sources/anim/legoanim.h | 32 +++--- LEGO1/lego/sources/roi/legoroi.cpp | 31 +++--- LEGO1/lego/sources/roi/legoroi.h | 9 +- 9 files changed, 127 insertions(+), 112 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoanimpresenter.h b/LEGO1/lego/legoomni/include/legoanimpresenter.h index fce22592..85917cbc 100644 --- a/LEGO1/lego/legoomni/include/legoanimpresenter.h +++ b/LEGO1/lego/legoomni/include/legoanimpresenter.h @@ -103,12 +103,17 @@ protected: LegoChar* FUN_10069150(const LegoChar* p_und1); void FUN_100692b0(); void FUN_100695c0(); - LegoChar* FUN_100697c0(const LegoChar* p_und1, const LegoChar* p_und2); + LegoChar* GetVariableOrIdentity(const LegoChar* p_varName, const LegoChar* p_prefix); LegoBool FUN_100698b0(const CompoundObject& p_rois, const LegoChar* p_und2); - LegoROI* FUN_100699e0(const LegoChar* p_und); + LegoROI* FindROI(const LegoChar* p_name); void FUN_10069b10(); - void FUN_1006a3c0(LegoAnimStructMap& p_map, LegoTreeNode* p_node, LegoROI* p_roi); - void FUN_1006a4f0(LegoAnimStructMap& p_map, LegoAnimNodeData* p_data, const LegoChar* p_und, LegoROI* p_roi); + void UpdateStructMapAndROIIndex(LegoAnimStructMap& p_map, LegoTreeNode* p_node, LegoROI* p_roi); + void UpdateStructMapAndROIIndexForNode( + LegoAnimStructMap& p_map, + LegoAnimNodeData* p_data, + const LegoChar* p_und, + LegoROI* p_roi + ); void FUN_1006aa60(); void FUN_1006ab70(); LegoBool FUN_1006aba0(); @@ -121,8 +126,8 @@ protected: LegoAnim* m_anim; // 0x64 LegoROI** m_roiMap; // 0x68 MxU32 m_roiMapSize; // 0x6c - LegoROIList* m_unk0x70; // 0x70 - LegoROIList* m_unk0x74; // 0x74 + LegoROIList* m_sceneROIs; // 0x70 + LegoROIList* m_managedActors; // 0x74 Matrix4* m_unk0x78; // 0x78 MxU32 m_flags; // 0x7c LegoWorld* m_currentWorld; // 0x80 diff --git a/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp b/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp index 2dd76641..87c896dc 100644 --- a/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp +++ b/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp @@ -336,9 +336,9 @@ void LegoCarBuildAnimPresenter::SwapNodesByName(LegoChar* p_name1, LegoChar* p_n strcpy(node1->GetName(), node2->GetName()); strcpy(node2->GetName(), buffer); - LegoU16 val1 = node1->GetUnknown0x20(); - node1->SetUnknown0x20(node2->GetUnknown0x20()); - node2->SetUnknown0x20(val1); + LegoU16 val1 = node1->GetROIIndex(); + node1->SetROIIndex(node2->GetROIIndex()); + node2->SetROIIndex(val1); } } @@ -456,7 +456,7 @@ void LegoCarBuildAnimPresenter::FUN_100795d0(LegoChar* p_param) assert(newHideKey); newHideKey->SetTime(0); - newHideKey->SetUnknown0x08(FALSE); + newHideKey->SetVisible(FALSE); data->SetNumMorphKeys(1); data->SetMorphKeys(newHideKey); diff --git a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp index 51835a42..54b1da70 100644 --- a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp @@ -47,8 +47,8 @@ void LegoAnimPresenter::Init() m_anim = NULL; m_roiMap = NULL; m_roiMapSize = 0; - m_unk0x74 = NULL; - m_unk0x70 = NULL; + m_managedActors = NULL; + m_sceneROIs = NULL; m_unk0x78 = NULL; m_flags = 0; m_unk0xa8.Clear(); @@ -81,13 +81,13 @@ void LegoAnimPresenter::Destroy(MxBool p_fromDestructor) delete[] m_roiMap; } - if (m_unk0x70 != NULL) { - delete m_unk0x70; + if (m_sceneROIs != NULL) { + delete m_sceneROIs; } - if (m_unk0x74 != NULL) { + if (m_managedActors != NULL) { FUN_1006aa60(); - delete m_unk0x74; + delete m_managedActors; } if (m_unk0x78 != NULL) { @@ -214,13 +214,13 @@ LegoChar* LegoAnimPresenter::FUN_10069150(const LegoChar* p_und1) // FUNCTION: LEGO1 0x100692b0 void LegoAnimPresenter::FUN_100692b0() { - m_unk0x74 = new LegoROIList(); + m_managedActors = new LegoROIList(); - if (m_unk0x74) { + if (m_managedActors) { LegoU32 numActors = m_anim->GetNumActors(); for (LegoU32 i = 0; i < numActors; i++) { - LegoChar* str = FUN_100697c0(m_anim->GetActorName(i), NULL); + LegoChar* str = GetVariableOrIdentity(m_anim->GetActorName(i), NULL); undefined4 unk0x04 = m_anim->GetActorUnknown0x04(i); LegoROI* roi = NULL; @@ -280,7 +280,7 @@ void LegoAnimPresenter::FUN_100692b0() } if (roi != NULL) { - m_unk0x74->Append(roi); + m_managedActors->Append(roi); } delete[] str; @@ -292,9 +292,9 @@ void LegoAnimPresenter::FUN_100692b0() // FUNCTION: BETA10 0x1004f359 void LegoAnimPresenter::FUN_100695c0() { - m_unk0x70 = new LegoROIList(); + m_sceneROIs = new LegoROIList(); - if (m_unk0x70) { + if (m_sceneROIs) { const CompoundObject& rois = VideoManager()->Get3DManager()->GetLego3DView()->GetViewManager()->GetROIs(); LegoU32 numActors = m_anim->GetNumActors(); @@ -324,23 +324,23 @@ void LegoAnimPresenter::FUN_100695c0() } // FUNCTION: LEGO1 0x100697c0 -LegoChar* LegoAnimPresenter::FUN_100697c0(const LegoChar* p_und1, const LegoChar* p_und2) +LegoChar* LegoAnimPresenter::GetVariableOrIdentity(const LegoChar* p_varName, const LegoChar* p_prefix) { - const LegoChar* str = p_und1; - const char* var = VariableTable()->GetVariable(p_und1); + const LegoChar* str = p_varName; + const char* var = VariableTable()->GetVariable(p_varName); if (*var) { str = var; } - LegoU32 len = strlen(str) + (p_und2 ? strlen(p_und2) : 0) + 2; + LegoU32 len = strlen(str) + (p_prefix ? strlen(p_prefix) : 0) + 2; LegoChar* result = new LegoChar[len]; if (result != NULL) { *result = '\0'; - if (p_und2) { - strcpy(result, p_und2); + if (p_prefix) { + strcpy(result, p_prefix); strcat(result, ":"); } @@ -356,7 +356,7 @@ LegoBool LegoAnimPresenter::FUN_100698b0(const CompoundObject& p_rois, const Leg LegoBool result = FALSE; LegoChar* str; - if (*(str = FUN_100697c0(p_und2, NULL)) == '*') { + if (*(str = GetVariableOrIdentity(p_und2, NULL)) == '*') { LegoChar* tmp = FUN_10069150(str); delete[] str; str = tmp; @@ -369,7 +369,7 @@ LegoBool LegoAnimPresenter::FUN_100698b0(const CompoundObject& p_rois, const Leg if (name != NULL) { if (!strcmpi(name, str)) { - m_unk0x70->Append(roi); + m_sceneROIs->Append(roi); result = TRUE; break; } @@ -382,20 +382,20 @@ LegoBool LegoAnimPresenter::FUN_100698b0(const CompoundObject& p_rois, const Leg } // FUNCTION: LEGO1 0x100699e0 -LegoROI* LegoAnimPresenter::FUN_100699e0(const LegoChar* p_und) +LegoROI* LegoAnimPresenter::FindROI(const LegoChar* p_name) { - LegoROIListCursor cursor(m_unk0x70); + LegoROIListCursor cursor(m_sceneROIs); LegoROI* roi; while (cursor.Next(roi)) { - LegoChar* und = FUN_100697c0(roi->GetName(), NULL); + LegoChar* nameOrVar = GetVariableOrIdentity(roi->GetName(), NULL); - if (und != NULL && !strcmpi(und, p_und)) { - delete[] und; + if (nameOrVar != NULL && !strcmpi(nameOrVar, p_name)) { + delete[] nameOrVar; return roi; } - delete[] und; + delete[] nameOrVar; } return NULL; @@ -410,7 +410,7 @@ void LegoAnimPresenter::FUN_10069b10() memset(m_unk0x8c, 0, m_unk0x94 * sizeof(*m_unk0x8c)); } - FUN_1006a3c0(anims, m_anim->GetRoot(), NULL); + UpdateStructMapAndROIIndex(anims, m_anim->GetRoot(), NULL); if (m_roiMap != NULL) { delete[] m_roiMap; @@ -443,7 +443,7 @@ void LegoAnimPresenter::FUN_10069b10() } // FUNCTION: LEGO1 0x1006a3c0 -void LegoAnimPresenter::FUN_1006a3c0(LegoAnimStructMap& p_map, LegoTreeNode* p_node, LegoROI* p_roi) +void LegoAnimPresenter::UpdateStructMapAndROIIndex(LegoAnimStructMap& p_map, LegoTreeNode* p_node, LegoROI* p_roi) { LegoROI* roi = p_roi; LegoChar* und = NULL; @@ -456,27 +456,27 @@ void LegoAnimPresenter::FUN_1006a3c0(LegoAnimStructMap& p_map, LegoTreeNode* p_n name = und2 = FUN_10069150(name); } - und = FUN_100697c0(name, p_roi != NULL ? p_roi->GetName() : NULL); + und = GetVariableOrIdentity(name, p_roi != NULL ? p_roi->GetName() : NULL); if (p_roi == NULL) { - roi = FUN_100699e0(und); + roi = FindROI(und); if (roi != NULL) { - FUN_1006a4f0(p_map, data, und, roi); + UpdateStructMapAndROIIndexForNode(p_map, data, und, roi); } else { - data->SetUnknown0x20(0); + data->SetROIIndex(0); } } else { LegoROI* child = p_roi->FindChildROI(name, p_roi); if (child != NULL) { - FUN_1006a4f0(p_map, data, und, child); + UpdateStructMapAndROIIndexForNode(p_map, data, und, child); } else { - if (FUN_100699e0(name) != NULL) { - FUN_1006a3c0(p_map, p_node, NULL); + if (FindROI(name) != NULL) { + UpdateStructMapAndROIIndex(p_map, p_node, NULL); delete[] und; delete[] und2; return; @@ -490,12 +490,12 @@ void LegoAnimPresenter::FUN_1006a3c0(LegoAnimStructMap& p_map, LegoTreeNode* p_n MxS32 count = p_node->GetNumChildren(); for (MxS32 i = 0; i < count; i++) { - FUN_1006a3c0(p_map, p_node->GetChild(i), roi); + UpdateStructMapAndROIIndex(p_map, p_node->GetChild(i), roi); } } // FUNCTION: LEGO1 0x1006a4f0 -void LegoAnimPresenter::FUN_1006a4f0( +void LegoAnimPresenter::UpdateStructMapAndROIIndexForNode( LegoAnimStructMap& p_map, LegoAnimNodeData* p_data, const LegoChar* p_und, @@ -510,7 +510,7 @@ void LegoAnimPresenter::FUN_1006a4f0( animStruct.m_index = p_map.size() + 1; animStruct.m_roi = p_roi; - p_data->SetUnknown0x20(animStruct.m_index); + p_data->SetROIIndex(animStruct.m_index); LegoChar* und = new LegoChar[strlen(p_und) + 1]; strcpy(und, p_und); @@ -518,7 +518,7 @@ void LegoAnimPresenter::FUN_1006a4f0( p_map[und] = animStruct; } else { - p_data->SetUnknown0x20((*it).second.m_index); + p_data->SetROIIndex((*it).second.m_index); } } @@ -526,7 +526,7 @@ void LegoAnimPresenter::FUN_1006a4f0( // FUNCTION: BETA10 0x1004feee void LegoAnimPresenter::FUN_1006aa60() { - LegoROIListCursor cursor(m_unk0x74); + LegoROIListCursor cursor(m_managedActors); LegoROI* roi; while (cursor.Next(roi)) { @@ -542,10 +542,10 @@ void LegoAnimPresenter::FUN_1006aa60() void LegoAnimPresenter::FUN_1006ab70() { if (m_unk0x96) { - AnimationManager()->FUN_10063270(m_unk0x74, this); + AnimationManager()->FUN_10063270(m_managedActors, this); } else { - AnimationManager()->FUN_10063780(m_unk0x74); + AnimationManager()->FUN_10063780(m_managedActors); } } @@ -565,10 +565,10 @@ MxBool LegoAnimPresenter::FUN_1006abb0(LegoTreeNode* p_node, LegoROI* p_roi) MxS32 i, count; if (name != NULL && *name != '-') { - und = FUN_100697c0(name, p_roi != NULL ? p_roi->GetName() : NULL); + und = GetVariableOrIdentity(name, p_roi != NULL ? p_roi->GetName() : NULL); if (p_roi == NULL) { - roi = FUN_100699e0(und); + roi = FindROI(und); if (roi == NULL) { goto done; @@ -578,7 +578,7 @@ MxBool LegoAnimPresenter::FUN_1006abb0(LegoTreeNode* p_node, LegoROI* p_roi) LegoROI* child = p_roi->FindChildROI(name, p_roi); if (child == NULL) { - if (FUN_100699e0(name) != NULL) { + if (FindROI(name) != NULL) { if (FUN_1006abb0(p_node, NULL)) { result = TRUE; } @@ -828,9 +828,9 @@ void LegoAnimPresenter::StartingTickle() VTable0x8c(); done: - if (m_unk0x70 != NULL) { - delete m_unk0x70; - m_unk0x70 = NULL; + if (m_sceneROIs != NULL) { + delete m_sceneROIs; + m_sceneROIs = NULL; } } @@ -893,7 +893,7 @@ void LegoAnimPresenter::FUN_1006b900(LegoAnim* p_anim, MxLong p_time, Matrix4* p mat = *p_matrix; } else { - LegoROI* roi = m_roiMap[data->GetUnknown0x20()]; + LegoROI* roi = m_roiMap[data->GetROIIndex()]; if (roi != NULL) { mat = roi->GetLocal2World(); @@ -918,7 +918,7 @@ void LegoAnimPresenter::FUN_1006b9a0(LegoAnim* p_anim, MxLong p_time, Matrix4* p mat = *p_matrix; } else { - LegoROI* roi = m_roiMap[data->GetUnknown0x20()]; + LegoROI* roi = m_roiMap[data->GetROIIndex()]; if (roi != NULL) { mat = roi->GetLocal2World(); diff --git a/LEGO1/lego/legoomni/src/video/legohideanimpresenter.cpp b/LEGO1/lego/legoomni/src/video/legohideanimpresenter.cpp index 64a06a08..89768b3e 100644 --- a/LEGO1/lego/legoomni/src/video/legohideanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legohideanimpresenter.cpp @@ -104,10 +104,10 @@ void LegoHideAnimPresenter::FUN_1006db60(LegoTreeNode* p_node, LegoTime p_time) MxBool previousB = FALSE; if (m_roiMap != NULL) { - LegoROI* roi = m_roiMap[data->GetUnknown0x20()]; + LegoROI* roi = m_roiMap[data->GetROIIndex()]; if (roi != NULL) { - newB = data->FUN_100a0990(p_time); + newB = data->GetVisibility(p_time); previousB = roi->GetVisibility(); roi->SetVisibility(newB); } @@ -117,7 +117,7 @@ void LegoHideAnimPresenter::FUN_1006db60(LegoTreeNode* p_node, LegoTime p_time) LegoPathBoundary* boundary = m_boundaryMap[data->GetUnknown0x22()]; if (boundary != NULL) { - newB = data->FUN_100a0990(p_time); + newB = data->GetVisibility(p_time); previousB = boundary->GetFlag0x10(); boundary->SetFlag0x10(newB); } diff --git a/LEGO1/lego/legoomni/src/video/legolocomotionanimpresenter.cpp b/LEGO1/lego/legoomni/src/video/legolocomotionanimpresenter.cpp index 0272e50d..90b98e91 100644 --- a/LEGO1/lego/legoomni/src/video/legolocomotionanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legolocomotionanimpresenter.cpp @@ -157,8 +157,8 @@ void LegoLocomotionAnimPresenter::FUN_1006d680(LegoAnimActor* p_actor, MxFloat p variableTable->SetVariable(key, ""); - if (m_unk0x70 != NULL) { - delete m_unk0x70; - m_unk0x70 = NULL; + if (m_sceneROIs != NULL) { + delete m_sceneROIs; + m_sceneROIs = NULL; } } diff --git a/LEGO1/lego/sources/anim/legoanim.cpp b/LEGO1/lego/sources/anim/legoanim.cpp index 152bce19..3b8caafc 100644 --- a/LEGO1/lego/sources/anim/legoanim.cpp +++ b/LEGO1/lego/sources/anim/legoanim.cpp @@ -348,7 +348,7 @@ LegoResult LegoTranslationKey::Read(LegoStorage* p_storage) } if (m_x > 1e-05F || m_x < -1e-05F || m_y > 1e-05F || m_y < -1e-05F || m_z > 1e-05F || m_z < -1e-05F) { - m_flags |= c_bit1; + m_flags |= c_active; } return SUCCESS; @@ -415,7 +415,7 @@ LegoResult LegoRotationKey::Read(LegoStorage* p_storage) } if (m_angle != 1.0F) { - m_flags |= c_bit1; + m_flags |= c_active; } return SUCCESS; @@ -480,7 +480,7 @@ LegoResult LegoScaleKey::Read(LegoStorage* p_storage) } if (m_x > 1.00001 || m_x < 0.99999 || m_y > 1.00001 || m_y < 0.99999 || m_z > 1.00001 || m_z < 0.99999) { - m_flags |= c_bit1; + m_flags |= c_active; } return SUCCESS; @@ -522,7 +522,7 @@ LegoAnimNodeData::LegoAnimNodeData() m_name = NULL; m_translationKeys = NULL; - m_unk0x20 = 0; + m_roiIndex = 0; m_rotationKeys = NULL; m_unk0x22 = 0; m_scaleKeys = NULL; @@ -785,7 +785,7 @@ inline void LegoAnimNodeData::GetTranslation( case 0: return; case 1: - if (!p_translationKeys[i].TestBit1()) { + if (!p_translationKeys[i].IsActive()) { return; } @@ -794,7 +794,7 @@ inline void LegoAnimNodeData::GetTranslation( z = p_translationKeys[i].GetZ(); break; case 2: - if (!p_translationKeys[i].TestBit1() && !p_translationKeys[i + 1].TestBit1()) { + if (!p_translationKeys[i].IsActive() && !p_translationKeys[i + 1].IsActive()) { return; } @@ -841,7 +841,7 @@ inline void LegoAnimNodeData::GetTranslation( case 0: return; case 1: - if (p_rotationKeys[i].TestBit1()) { + if (p_rotationKeys[i].IsActive()) { p_matrix.FromQuaternion(Mx4DPointFloat( p_rotationKeys[i].GetX(), p_rotationKeys[i].GetY(), @@ -854,19 +854,19 @@ inline void LegoAnimNodeData::GetTranslation( Mx4DPointFloat a; MxQuaternionTransformer b; - if (p_rotationKeys[i].TestBit1() || p_rotationKeys[i + 1].TestBit1()) { + if (p_rotationKeys[i].IsActive() || p_rotationKeys[i + 1].IsActive()) { a[0] = p_rotationKeys[i].GetX(); a[1] = p_rotationKeys[i].GetY(); a[2] = p_rotationKeys[i].GetZ(); a[3] = p_rotationKeys[i].GetAngle(); - if (p_rotationKeys[i + 1].TestBit3()) { + if (p_rotationKeys[i + 1].ShouldSkipInterpolation()) { p_matrix.FromQuaternion(a); return; } Mx4DPointFloat c; - if (p_rotationKeys[i + 1].TestBit2()) { + if (p_rotationKeys[i + 1].ShouldNegateRotation()) { c[0] = -p_rotationKeys[i + 1].GetX(); c[1] = -p_rotationKeys[i + 1].GetY(); c[2] = -p_rotationKeys[i + 1].GetZ(); @@ -920,7 +920,7 @@ inline void LegoAnimNodeData::GetScale( } // FUNCTION: LEGO1 0x100a0990 -LegoBool LegoAnimNodeData::FUN_100a0990(LegoFloat p_time) +LegoBool LegoAnimNodeData::GetVisibility(LegoFloat p_time) { LegoU32 i, n; LegoU32 index = GetMorphIndex(); @@ -935,7 +935,7 @@ LegoBool LegoAnimNodeData::FUN_100a0990(LegoFloat p_time) break; case 1: case 2: - result = m_morphKeys[i].GetUnknown0x08(); + result = m_morphKeys[i].IsVisible(); break; } @@ -1171,7 +1171,7 @@ undefined4 LegoAnim::GetActorUnknown0x04(LegoU32 p_index) // FUNCTION: BETA10 0x1018027c LegoMorphKey::LegoMorphKey() { - m_unk0x08 = 0; + m_visible = FALSE; } // FUNCTION: LEGO1 0x100a0f70 @@ -1183,7 +1183,7 @@ LegoResult LegoMorphKey::Read(LegoStorage* p_storage) return result; } - if ((result = p_storage->Read(&m_unk0x08, sizeof(LegoU8))) != SUCCESS) { + if ((result = p_storage->Read(&m_visible, sizeof(LegoU8))) != SUCCESS) { return result; } @@ -1200,7 +1200,7 @@ LegoResult LegoMorphKey::Write(LegoStorage* p_storage) return result; } - if ((result = p_storage->Write(&m_unk0x08, sizeof(LegoU8))) != SUCCESS) { + if ((result = p_storage->Write(&m_visible, sizeof(LegoU8))) != SUCCESS) { return result; } diff --git a/LEGO1/lego/sources/anim/legoanim.h b/LEGO1/lego/sources/anim/legoanim.h index 0df350a9..9b81b531 100644 --- a/LEGO1/lego/sources/anim/legoanim.h +++ b/LEGO1/lego/sources/anim/legoanim.h @@ -11,9 +11,9 @@ class Matrix4; class LegoAnimKey { public: enum Flags { - c_bit1 = 0x01, - c_bit2 = 0x02, - c_bit3 = 0x04 + c_active = 0x01, + c_negateRotation = 0x02, + c_skipInterpolation = 0x04 }; LegoAnimKey(); @@ -25,18 +25,18 @@ public: // FUNCTION: BETA10 0x100738a0 void SetTime(MxS32 p_time) { m_time = p_time; } - LegoU32 TestBit1() { return m_flags & c_bit1; } - LegoU32 TestBit2() { return m_flags & c_bit2; } - LegoU32 TestBit3() { return m_flags & c_bit3; } + LegoU32 IsActive() { return m_flags & c_active; } + LegoU32 ShouldNegateRotation() { return m_flags & c_negateRotation; } + LegoU32 ShouldSkipInterpolation() { return m_flags & c_skipInterpolation; } // FUNCTION: BETA10 0x100739a0 void FUN_100739a0(MxS32 p_param) { if (p_param) { - m_flags |= c_bit1; + m_flags |= c_active; } else { - m_flags &= ~c_bit1; + m_flags &= ~c_active; } } @@ -127,13 +127,13 @@ public: LegoMorphKey(); LegoResult Read(LegoStorage* p_storage); LegoResult Write(LegoStorage* p_storage); - LegoBool GetUnknown0x08() { return m_unk0x08; } + LegoBool IsVisible() { return m_visible; } // FUNCTION: BETA10 0x100738d0 - void SetUnknown0x08(LegoBool p_unk0x08) { m_unk0x08 = p_unk0x08; } + void SetVisible(LegoBool p_visible) { m_visible = p_visible; } protected: - LegoBool m_unk0x08; // 0x08 + LegoBool m_visible; // 0x08 }; // SIZE 0x0c @@ -160,7 +160,7 @@ public: void SetName(LegoChar* p_name); LegoResult CreateLocalTransform(LegoFloat p_time, Matrix4& p_matrix); - LegoBool FUN_100a0990(LegoFloat p_time); + LegoBool GetVisibility(LegoFloat p_time); // FUNCTION: BETA10 0x100595d0 LegoChar* GetName() { return m_name; } @@ -187,7 +187,7 @@ public: LegoU32 GetMorphIndex() { return m_morphIndex; } // FUNCTION: BETA10 0x1005abc0 - LegoU16 GetUnknown0x20() { return m_unk0x20; } + LegoU16 GetROIIndex() { return m_roiIndex; } // FUNCTION: BETA10 0x1005d5c0 LegoU16 GetUnknown0x22() { return m_unk0x22; } @@ -214,7 +214,7 @@ public: void SetNumMorphKeys(LegoU16 p_numMorphKeys) { m_numMorphKeys = p_numMorphKeys; } // FUNCTION: BETA10 0x10059600 - void SetUnknown0x20(LegoU16 p_unk0x20) { m_unk0x20 = p_unk0x20; } + void SetROIIndex(LegoU16 p_roiIndex) { m_roiIndex = p_roiIndex; } // FUNCTION: BETA10 0x1005f2e0 void SetUnknown0x22(LegoU16 p_unk0x22) { m_unk0x22 = p_unk0x22; } @@ -225,7 +225,7 @@ public: } // FUNCTION: BETA10 0x1005d580 - LegoBool FUN_100a0990(LegoTime p_time) { return FUN_100a0990((LegoFloat) p_time); } + LegoBool GetVisibility(LegoTime p_time) { return GetVisibility((LegoFloat) p_time); } inline static void GetTranslation( LegoU16 p_numTranslationKeys, @@ -279,7 +279,7 @@ protected: LegoRotationKey* m_rotationKeys; // 0x14 LegoScaleKey* m_scaleKeys; // 0x18 LegoMorphKey* m_morphKeys; // 0x1c - LegoU16 m_unk0x20; // 0x20 + LegoU16 m_roiIndex; // 0x20 LegoU16 m_unk0x22; // 0x22 LegoU32 m_translationIndex; // 0x24 LegoU32 m_rotationIndex; // 0x28 diff --git a/LEGO1/lego/sources/roi/legoroi.cpp b/LEGO1/lego/sources/roi/legoroi.cpp index fd5d3e88..dd72f7f0 100644 --- a/LEGO1/lego/sources/roi/legoroi.cpp +++ b/LEGO1/lego/sources/roi/legoroi.cpp @@ -337,7 +337,7 @@ done: } // FUNCTION: LEGO1 0x100a8cb0 -LegoResult LegoROI::FUN_100a8cb0(LegoAnimNodeData* p_data, LegoTime p_time, Matrix4& p_matrix) +LegoResult LegoROI::CreateLocalTransform(LegoAnimNodeData* p_data, LegoTime p_time, Matrix4& p_matrix) { p_matrix.SetIdentity(); p_data->CreateLocalTransform(p_time, p_matrix); @@ -379,27 +379,32 @@ LegoROI* LegoROI::FindChildROI(const LegoChar* p_name, LegoROI* p_roi) } // FUNCTION: LEGO1 0x100a8da0 -LegoResult LegoROI::FUN_100a8da0(LegoTreeNode* p_node, const Matrix4& p_matrix, LegoTime p_time, LegoROI* p_roi) +LegoResult LegoROI::ApplyAnimationTransformation( + LegoTreeNode* p_node, + const Matrix4& p_matrix, + LegoTime p_time, + LegoROI* p_parentROI +) { MxMatrix mat; LegoAnimNodeData* data = (LegoAnimNodeData*) p_node->GetData(); const LegoChar* name = data->GetName(); - LegoROI* roi = FindChildROI(name, p_roi); + LegoROI* roi = FindChildROI(name, p_parentROI); if (roi == NULL) { roi = FindChildROI(name, this); } if (roi != NULL) { - FUN_100a8cb0(data, p_time, mat); + CreateLocalTransform(data, p_time, mat); roi->m_local2world.Product(mat, p_matrix); roi->UpdateWorldData(); - LegoBool und = data->FUN_100a0990(p_time); + LegoBool und = data->GetVisibility(p_time); roi->SetVisibility(und); for (LegoU32 i = 0; i < p_node->GetNumChildren(); i++) { - FUN_100a8da0(p_node->GetChild(i), roi->m_local2world, p_time, roi); + ApplyAnimationTransformation(p_node->GetChild(i), roi->m_local2world, p_time, roi); } } else { @@ -416,14 +421,14 @@ void LegoROI::FUN_100a8e80(LegoTreeNode* p_node, Matrix4& p_matrix, LegoTime p_t MxMatrix mat; LegoAnimNodeData* data = (LegoAnimNodeData*) p_node->GetData(); - FUN_100a8cb0(data, p_time, mat); + CreateLocalTransform(data, p_time, mat); - LegoROI* roi = p_roiMap[data->GetUnknown0x20()]; + LegoROI* roi = p_roiMap[data->GetROIIndex()]; if (roi != NULL) { roi->m_local2world.Product(mat, p_matrix); roi->UpdateWorldData(); - LegoBool und = data->FUN_100a0990(p_time); + LegoBool und = data->GetVisibility(p_time); roi->SetVisibility(und); for (LegoU32 i = 0; i < p_node->GetNumChildren(); i++) { @@ -447,9 +452,9 @@ void LegoROI::FUN_100a8fd0(LegoTreeNode* p_node, Matrix4& p_matrix, LegoTime p_t MxMatrix mat; LegoAnimNodeData* data = (LegoAnimNodeData*) p_node->GetData(); - FUN_100a8cb0(data, p_time, mat); + CreateLocalTransform(data, p_time, mat); - LegoROI* roi = p_roiMap[data->GetUnknown0x20()]; + LegoROI* roi = p_roiMap[data->GetROIIndex()]; if (roi != NULL) { roi->m_local2world.Product(mat, p_matrix); @@ -474,9 +479,9 @@ LegoResult LegoROI::SetFrame(LegoAnim* p_anim, LegoTime p_time) MxMatrix mat; mat = m_local2world; - mat.SetIdentity(); + mat.SetIdentity(); // this clears the matrix, assignment above is redundant - return FUN_100a8da0(root, mat, p_time, this); + return ApplyAnimationTransformation(root, mat, p_time, this); } // FUNCTION: LEGO1 0x100a9170 diff --git a/LEGO1/lego/sources/roi/legoroi.h b/LEGO1/lego/sources/roi/legoroi.h index f3a76899..28119c72 100644 --- a/LEGO1/lego/sources/roi/legoroi.h +++ b/LEGO1/lego/sources/roi/legoroi.h @@ -32,7 +32,12 @@ public: LegoStorage* p_storage ); LegoROI* FindChildROI(const LegoChar* p_name, LegoROI* p_roi); - LegoResult FUN_100a8da0(LegoTreeNode* p_node, const Matrix4& p_matrix, LegoTime p_time, LegoROI* p_roi); + LegoResult ApplyAnimationTransformation( + LegoTreeNode* p_node, + const Matrix4& p_matrix, + LegoTime p_time, + LegoROI* p_roi + ); static void FUN_100a8e80(LegoTreeNode* p_node, Matrix4& p_matrix, LegoTime p_time, LegoROI** p_roiMap); static void FUN_100a8fd0(LegoTreeNode* p_node, Matrix4& p_matrix, LegoTime p_time, LegoROI** p_roiMap); LegoResult SetFrame(LegoAnim* p_anim, LegoTime p_time); @@ -51,7 +56,7 @@ public: void ClearMeshOffset(); void SetDisplayBB(int p_displayBB); - static LegoResult FUN_100a8cb0(LegoAnimNodeData* p_data, LegoTime p_time, Matrix4& p_matrix); + static LegoResult CreateLocalTransform(LegoAnimNodeData* p_data, LegoTime p_time, Matrix4& p_matrix); static void FUN_100a81b0(const LegoChar* p_error, const LegoChar* p_name); static void configureLegoROI(int p_roi); static void SetColorOverride(ColorOverride p_colorOverride);