From fa6c62f7b319d0115e4ad700b47a089c9aff9cd1 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Mon, 5 May 2025 16:04:55 -0700 Subject: [PATCH 01/11] Match `MxCompositeMediaPresenter::Tickle` (#1437) * Match `MxCompositeMediaPresenter::Tickle` * Remove file --- LEGO1/lego/legoomni/src/common/mxcompositemediapresenter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LEGO1/lego/legoomni/src/common/mxcompositemediapresenter.cpp b/LEGO1/lego/legoomni/src/common/mxcompositemediapresenter.cpp index 36027f8e..dadd8de7 100644 --- a/LEGO1/lego/legoomni/src/common/mxcompositemediapresenter.cpp +++ b/LEGO1/lego/legoomni/src/common/mxcompositemediapresenter.cpp @@ -144,7 +144,7 @@ MxResult MxCompositeMediaPresenter::Tickle() { AUTOLOCK(m_criticalSection); - switch (m_currentTickleState) { + switch (GetCurrentTickleState()) { case e_ready: ProgressTickleState(e_starting); case e_starting: From 02c38d55a3eccebe7adffbe4308008ca30f37f5a Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Mon, 5 May 2025 17:19:23 -0700 Subject: [PATCH 02/11] Match `MxDisplaySurface::SetPalette` (#1438) * Match `MxDisplaySurface::SetPalette` * Match --- LEGO1/omni/src/video/mxdisplaysurface.cpp | 29 ++++++++++++++--------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/LEGO1/omni/src/video/mxdisplaysurface.cpp b/LEGO1/omni/src/video/mxdisplaysurface.cpp index 685c59be..95eb0f94 100644 --- a/LEGO1/omni/src/video/mxdisplaysurface.cpp +++ b/LEGO1/omni/src/video/mxdisplaysurface.cpp @@ -85,6 +85,7 @@ void MxDisplaySurface::ClearScreen() } // FUNCTION: LEGO1 0x100ba750 +// FUNCTION: BETA10 0x1013f6df MxU8 MxDisplaySurface::CountTotalBitsSetTo1(MxU32 p_param) { MxU8 count = 0; @@ -97,6 +98,7 @@ MxU8 MxDisplaySurface::CountTotalBitsSetTo1(MxU32 p_param) } // FUNCTION: LEGO1 0x100ba770 +// FUNCTION: BETA10 0x1013f724 MxU8 MxDisplaySurface::CountContiguousBitsSetTo1(MxU32 p_param) { MxU8 count = 0; @@ -271,24 +273,21 @@ void MxDisplaySurface::Destroy() } // FUNCTION: LEGO1 0x100baae0 +// FUNCTION: BETA10 0x1013fe15 void MxDisplaySurface::SetPalette(MxPalette* p_palette) { if (m_surfaceDesc.ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8) { m_ddSurface1->SetPalette(p_palette->CreateNativePalette()); m_ddSurface2->SetPalette(p_palette->CreateNativePalette()); - if ((m_videoParam.Flags().GetFullScreen() & 1) == 0) { + if (!m_videoParam.Flags().GetFullScreen()) { struct { WORD m_palVersion; WORD m_palNumEntries; PALETTEENTRY m_palPalEntry[256]; - } lpal; + } lpal = {0x300, 256}; - lpal.m_palVersion = 0x300; - lpal.m_palNumEntries = 256; - - memset(lpal.m_palPalEntry, 0, sizeof(lpal.m_palPalEntry)); - p_palette->GetEntries(lpal.m_palPalEntry); + p_palette->GetEntries((LPPALETTEENTRY) lpal.m_palPalEntry); HPALETTE hpal = CreatePalette((LPLOGPALETTE) &lpal); HDC hdc = ::GetDC(0); @@ -299,7 +298,10 @@ void MxDisplaySurface::SetPalette(MxPalette* p_palette) } } - if (m_surfaceDesc.ddpfPixelFormat.dwRGBBitCount == 16) { + switch (m_surfaceDesc.ddpfPixelFormat.dwRGBBitCount) { + case 8: + break; + case 16: { if (!m_16bitPal) { m_16bitPal = new MxU16[256]; } @@ -315,10 +317,15 @@ void MxDisplaySurface::SetPalette(MxPalette* p_palette) MxU8 totalBitsBlue = CountTotalBitsSetTo1(m_surfaceDesc.ddpfPixelFormat.dwBBitMask); for (MxS32 i = 0; i < 256; i++) { - m_16bitPal[i] = (((palette[i].peRed >> ((8 - totalBitsRed) & 0x1f)) << (contiguousBitsRed & 0x1f))) | - (((palette[i].peGreen >> ((8 - totalBitsGreen) & 0x1f)) << (contiguousBitsGreen & 0x1f))) | - (((palette[i].peBlue >> ((8 - totalBitsBlue) & 0x1f)) << (contiguousBitsBlue & 0x1f))); + m_16bitPal[i] = ((palette[i].peRed >> (8 - totalBitsRed)) << contiguousBitsRed) | + ((palette[i].peGreen >> (8 - totalBitsGreen)) << contiguousBitsGreen) | + ((palette[i].peBlue >> (8 - totalBitsBlue)) << contiguousBitsBlue); } + + break; + } + default: + break; } } From 2cab039a5f0b2565c99f4c08329617e0a2561b55 Mon Sep 17 00:00:00 2001 From: Florian Kaiser Date: Wed, 7 May 2025 21:43:54 +0200 Subject: [PATCH 03/11] Add info about long file path issue to README.md (#1442) * Add info about long file path issue to README.md * Update README.md --------- Co-authored-by: Christian Semmler --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c24dc4ef..9a12cbff 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ You will need the following software installed: cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo ``` - **Visual C++ 4.2 has issues with paths containing spaces**. If you get configure or build errors, make sure neither CMake, the repository, nor Visual C++ 4.2 is in a path that contains spaces. + - Be aware that long file paths (e.g., `C:\Users\LongUserName\LongerFolderName\isle`) may be truncated by `make`, resulting in “File not found” errors. - Replace `` with the source repository. This can be `..` if your build folder is inside the source repository. - `RelWithDebInfo` is recommended because it will produce debug symbols useful for further decompilation work. However, you can change this to `Release` if you don't need them. While `Debug` builds can be compiled and used, they are not recommended as the primary goal is to match the code to the original binary. This is because the retail binaries were compiled as `Release` builds. - `NMake Makefiles` is most recommended because it will be immediately compatible with Visual C++ 4.2. For faster builds, you can use `Ninja` (if you have it installed), however due to limitations in Visual C++ 4.2, you can only build `Release` builds this way (debug symbols cannot be generated with `Ninja`). From f851103d48106cfae5c1fc28041d8abc4093c617 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Wed, 7 May 2025 15:46:21 -0700 Subject: [PATCH 04/11] Match `LegoDeviceEnumerate::SupportsMMX` (#1443) * Match `LegoDeviceEnumerate::SupportsMMX` * Fix indent --- LEGO1/mxdirectx/legodxinfo.cpp | 77 ++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/LEGO1/mxdirectx/legodxinfo.cpp b/LEGO1/mxdirectx/legodxinfo.cpp index eb511f2b..6241b76a 100644 --- a/LEGO1/mxdirectx/legodxinfo.cpp +++ b/LEGO1/mxdirectx/legodxinfo.cpp @@ -201,42 +201,45 @@ int LegoDeviceEnumerate::FUN_1009d0d0() // FUNCTION: BETA10 0x1011cf54 int LegoDeviceEnumerate::SupportsMMX() { - if (!SupportsCPUID()) { - return 0; - } - int supports_mmx; + int supports_mmx = SupportsCPUID(); + + if (supports_mmx) { #ifdef _MSC_VER - __asm { - mov eax, 0x0 ; EAX=0: Highest Function Parameter and Manufacturer ID + __asm { + push ebx + mov eax, 0x0 ; EAX=0: Highest Function Parameter and Manufacturer ID #if _MSC_VER > 1100 - cpuid ; Run CPUID + cpuid ; Run CPUID #else - __emit 0x0f - __emit 0xa2 + __emit 0x0f + __emit 0xa2 #endif - mov eax, 0x1 ; EAX=1: Processor Info and Feature Bits (unused) + mov eax, 0x1 ; EAX=1: Processor Info and Feature Bits (unused) #if _MSC_VER > 1100 - cpuid ; Run CPUID + cpuid ; Run CPUID #else - __emit 0x0f - __emit 0xa2 + __emit 0x0f + __emit 0xa2 +#endif + xor eax, eax ; Zero EAX register + bt edx, 0x17 ; Test bit 0x17 (23): MMX instructions (64-bit SIMD) (Store in CF) + adc eax, eax ; Add with carry: EAX = EAX + EAX + CF = CF + pop ebx + mov supports_mmx, eax ; Save eax into C variable + } +#else + __asm__("movl $0x0, %%eax\n\t" // EAX=0: Highest Function Parameter and Manufacturer ID + "cpuid\n\t" // Run CPUID\n" + "mov $0x1, %%eax\n\t" // EAX=1: Processor Info and Feature Bits (unused) + "cpuid\n\t" // Run CPUID + "xorl %%eax, %%eax\n\t" // Zero EAX register + "btl $0x15, %%edx\n\t" // Test bit 0x17 (23): MMX instructions (64-bit SIMD) (Store in CF) + "adc %%eax, %%eax" // Add with carry: EAX = EAX + EAX + CF = CF + : "=a"(supports_mmx) // supports_mmx == EAX + ); #endif - xor eax, eax ; Zero EAX register - bt edx, 0x17 ; Test bit 0x17 (23): MMX instructions (64-bit SIMD) (Store in CF) - adc eax, eax ; Add with carry: EAX = EAX + EAX + CF = CF - mov supports_mmx, eax ; Save eax into C variable } -#else - __asm__("movl $0x0, %%eax\n\t" // EAX=0: Highest Function Parameter and Manufacturer ID - "cpuid\n\t" // Run CPUID\n" - "mov $0x1, %%eax\n\t" // EAX=1: Processor Info and Feature Bits (unused) - "cpuid\n\t" // Run CPUID - "xorl %%eax, %%eax\n\t" // Zero EAX register - "btl $0x15, %%edx\n\t" // Test bit 0x17 (23): MMX instructions (64-bit SIMD) (Store in CF) - "adc %%eax, %%eax" // Add with carry: EAX = EAX + EAX + CF = CF - : "=a"(supports_mmx) // supports_mmx == EAX - ); -#endif + return supports_mmx; } @@ -249,15 +252,15 @@ int LegoDeviceEnumerate::SupportsCPUID() #ifdef _MSC_VER #if defined(_M_IX86) __asm { - xor eax, eax ; Zero EAX register - pushfd ; Push EFLAGS register value on the stack - or dword ptr[esp], 0x200000 ; Set bit 0x200000: Able to use CPUID instruction (Pentium+) - popfd ; Write the updated value into the EFLAGS register - pushfd ; Push EFLAGS register value on the stack (again) - btr dword ptr[esp], 0x15 ; Test bit 0x15 (21) and reset (set CF) - adc eax, eax ; Add with carry: EAX = EAX + EAX + CF = CF - popfd ; Push EFLAGS register value on the stack (again, and makes sure the stack remains the same) - mov has_cpuid, eax ; Save eax into C variable + xor eax, eax ; Zero EAX register + pushfd ; Push EFLAGS register value on the stack + or dword ptr[esp], 0x200000 ; Set bit 0x200000: Able to use CPUID instruction (Pentium+) + popfd ; Write the updated value into the EFLAGS register + pushfd ; Push EFLAGS register value on the stack (again) + btr dword ptr[esp], 0x15 ; Test bit 0x15 (21) and reset (set CF) + adc eax, eax ; Add with carry: EAX = EAX + EAX + CF = CF + popfd ; Push EFLAGS register value on the stack (again, and makes sure the stack remains the same) + mov has_cpuid, eax ; Save eax into C variable } #elif defined(_M_X64) has_cpuid = 1; From 2fac11cff0d8757ae351898f60079e69f197337b Mon Sep 17 00:00:00 2001 From: MattKC <34096995+itsmattkc@users.noreply.github.com> Date: Wed, 7 May 2025 20:31:34 -0700 Subject: [PATCH 05/11] readme: update playlist link (#1444) Co-authored-by: MattKC --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9a12cbff..c246e850 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # LEGO Island Decompilation -[Development Vlog](https://www.youtube.com/playlist?list=PLbpl-gZkNl2COf_bB6cfgTapD5WduAfPz) | [Contributing](/CONTRIBUTING.md) | [Matrix](https://matrix.to/#/#isledecomp:matrix.org) | [Forums](https://forum.mattkc.com/viewforum.php?f=1) | [Patreon](https://www.patreon.com/mattkc) +[Development Vlog](https://www.youtube.com/playlist?list=PLbpl-gZkNl2Db4xcAsT_xOfOwRk-2DPHL) | [Contributing](/CONTRIBUTING.md) | [Matrix](https://matrix.to/#/#isledecomp:matrix.org) | [Forums](https://forum.mattkc.com/viewforum.php?f=1) | [Patreon](https://www.patreon.com/mattkc) This is a functionally complete decompilation of LEGO Island (Version 1.1, English). It aims to be as accurate as possible, matching the recompiled instructions to the original machine code as much as possible. The goal is to provide a workable codebase that can be modified, improved, and ported to other platforms later on. From c8ae2e22cc0362b7a87f3b35564f6ad28229ca73 Mon Sep 17 00:00:00 2001 From: Florian Kaiser Date: Thu, 8 May 2025 21:24:22 +0200 Subject: [PATCH 06/11] Update .gitignore to include .DS_Store (#1448) --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 81e69517..a40c129e 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,5 @@ tools/ghidra_scripts/import.log # These entries are kept for now since that convention has not always been around. ISLE.EXE LEGO1.DLL + +.DS_Store From 0a2d598b57b3f33523d24c659b5249a2589ba3df Mon Sep 17 00:00:00 2001 From: Florian Kaiser Date: Thu, 8 May 2025 21:26:48 +0200 Subject: [PATCH 07/11] Refactor `Deserialize` method parameters in MxDS classes to use `p_flags` instead of `p_unk0x24` (#1450) --- LEGO1/omni/src/action/mxdsaction.cpp | 4 ++-- LEGO1/omni/src/action/mxdsmediaaction.cpp | 4 ++-- LEGO1/omni/src/action/mxdsmultiaction.cpp | 6 +++--- LEGO1/omni/src/action/mxdsobject.cpp | 4 ++-- LEGO1/omni/src/action/mxdsselectaction.cpp | 6 +++--- LEGO1/omni/src/action/mxdssound.cpp | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/LEGO1/omni/src/action/mxdsaction.cpp b/LEGO1/omni/src/action/mxdsaction.cpp index 8dc22fcf..eeb3dc68 100644 --- a/LEGO1/omni/src/action/mxdsaction.cpp +++ b/LEGO1/omni/src/action/mxdsaction.cpp @@ -256,9 +256,9 @@ void MxDSAction::AppendExtra(MxU16 p_extraLength, const char* p_extraData) // FUNCTION: LEGO1 0x100adf70 // FUNCTION: BETA10 0x1012ba6a -void MxDSAction::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) +void MxDSAction::Deserialize(MxU8*& p_source, MxS16 p_flags) { - MxDSObject::Deserialize(p_source, p_unk0x24); + MxDSObject::Deserialize(p_source, p_flags); // clang-format off m_flags = *( MxU32*) p_source; p_source += sizeof(m_flags); diff --git a/LEGO1/omni/src/action/mxdsmediaaction.cpp b/LEGO1/omni/src/action/mxdsmediaaction.cpp index 00ed247a..dbd61ca4 100644 --- a/LEGO1/omni/src/action/mxdsmediaaction.cpp +++ b/LEGO1/omni/src/action/mxdsmediaaction.cpp @@ -129,9 +129,9 @@ MxU32 MxDSMediaAction::GetSizeOnDisk() // FUNCTION: LEGO1 0x100c8f60 // FUNCTION: BETA10 0x1015cc93 -void MxDSMediaAction::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) +void MxDSMediaAction::Deserialize(MxU8*& p_source, MxS16 p_flags) { - MxDSAction::Deserialize(p_source, p_unk0x24); + MxDSAction::Deserialize(p_source, p_flags); CopyMediaSrcPath((char*) p_source); p_source += strlen(m_mediaSrcPath) + 1; diff --git a/LEGO1/omni/src/action/mxdsmultiaction.cpp b/LEGO1/omni/src/action/mxdsmultiaction.cpp index d1214d3d..39adfe9b 100644 --- a/LEGO1/omni/src/action/mxdsmultiaction.cpp +++ b/LEGO1/omni/src/action/mxdsmultiaction.cpp @@ -149,9 +149,9 @@ MxU32 MxDSMultiAction::GetSizeOnDisk() // FUNCTION: LEGO1 0x100ca7b0 // FUNCTION: BETA10 0x10159b79 -void MxDSMultiAction::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) +void MxDSMultiAction::Deserialize(MxU8*& p_source, MxS16 p_flags) { - MxDSAction::Deserialize(p_source, p_unk0x24); + MxDSAction::Deserialize(p_source, p_flags); MxU32 extraFlag = *(MxU32*) (p_source + 4) & 1; p_source += 12; @@ -164,7 +164,7 @@ void MxDSMultiAction::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) MxU32 extraFlag = *(MxU32*) (p_source + 4) & 1; p_source += 8; - MxDSAction* action = (MxDSAction*) DeserializeDSObjectDispatch(p_source, p_unk0x24); + MxDSAction* action = (MxDSAction*) DeserializeDSObjectDispatch(p_source, p_flags); p_source += extraFlag; m_actionList->Append(action); diff --git a/LEGO1/omni/src/action/mxdsobject.cpp b/LEGO1/omni/src/action/mxdsobject.cpp index 6cea1ea0..ed2a43e8 100644 --- a/LEGO1/omni/src/action/mxdsobject.cpp +++ b/LEGO1/omni/src/action/mxdsobject.cpp @@ -156,7 +156,7 @@ MxU32 MxDSObject::GetSizeOnDisk() // FUNCTION: LEGO1 0x100bfa20 // FUNCTION: BETA10 0x10147d73 -void MxDSObject::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) +void MxDSObject::Deserialize(MxU8*& p_source, MxS16 p_flags) { SetSourceName((char*) p_source); p_source += strlen(m_sourceName) + 1; @@ -170,7 +170,7 @@ void MxDSObject::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) m_objectId = *(MxU32*) p_source; p_source += sizeof(m_objectId); - m_unk0x24 = p_unk0x24; + m_unk0x24 = p_flags; } // FUNCTION: LEGO1 0x100bfa80 diff --git a/LEGO1/omni/src/action/mxdsselectaction.cpp b/LEGO1/omni/src/action/mxdsselectaction.cpp index d66e761f..7171224f 100644 --- a/LEGO1/omni/src/action/mxdsselectaction.cpp +++ b/LEGO1/omni/src/action/mxdsselectaction.cpp @@ -92,11 +92,11 @@ MxU32 MxDSSelectAction::GetSizeOnDisk() // FUNCTION: LEGO1 0x100cbf60 // FUNCTION: BETA10 0x1015aa30 -void MxDSSelectAction::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) +void MxDSSelectAction::Deserialize(MxU8*& p_source, MxS16 p_flags) { MxDSAction* action = NULL; MxString string; - MxDSAction::Deserialize(p_source, p_unk0x24); + MxDSAction::Deserialize(p_source, p_flags); MxU32 extraFlag = *(MxU32*) (p_source + 4) & 1; p_source += 12; @@ -138,7 +138,7 @@ void MxDSSelectAction::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) MxU32 extraFlag = *(MxU32*) (p_source + 4) & 1; p_source += 8; - action = (MxDSAction*) DeserializeDSObjectDispatch(p_source, p_unk0x24); + action = (MxDSAction*) DeserializeDSObjectDispatch(p_source, p_flags); if (index == i) { m_actionList->Append(action); diff --git a/LEGO1/omni/src/action/mxdssound.cpp b/LEGO1/omni/src/action/mxdssound.cpp index 5a12aa90..b16214d5 100644 --- a/LEGO1/omni/src/action/mxdssound.cpp +++ b/LEGO1/omni/src/action/mxdssound.cpp @@ -58,9 +58,9 @@ MxDSAction* MxDSSound::Clone() // FUNCTION: LEGO1 0x100c95a0 // FUNCTION: BETA10 0x1015d272 -void MxDSSound::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) +void MxDSSound::Deserialize(MxU8*& p_source, MxS16 p_flags) { - MxDSMediaAction::Deserialize(p_source, p_unk0x24); + MxDSMediaAction::Deserialize(p_source, p_flags); m_volume = *(MxS32*) p_source; p_source += sizeof(m_volume); } From 9027849848111118a88be33d0a76caec51bab678 Mon Sep 17 00:00:00 2001 From: Florian Kaiser Date: Fri, 9 May 2025 12:44:53 +0200 Subject: [PATCH 08/11] Rename parameter `p_stack` to `p_stackSize` in `MxThread::Start` method (#1452) --- LEGO1/omni/include/mxthread.h | 2 +- LEGO1/omni/src/system/mxthread.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/LEGO1/omni/include/mxthread.h b/LEGO1/omni/include/mxthread.h index 57ed2443..6d148edd 100644 --- a/LEGO1/omni/include/mxthread.h +++ b/LEGO1/omni/include/mxthread.h @@ -14,7 +14,7 @@ public: // Note: Comes before virtual destructor virtual MxResult Run(); - MxResult Start(MxS32 p_stack, MxS32 p_flag); + MxResult Start(MxS32 p_stackSize, MxS32 p_flag); void Terminate(); void Sleep(MxS32 p_milliseconds); diff --git a/LEGO1/omni/src/system/mxthread.cpp b/LEGO1/omni/src/system/mxthread.cpp index b0bd5b51..f639f74d 100644 --- a/LEGO1/omni/src/system/mxthread.cpp +++ b/LEGO1/omni/src/system/mxthread.cpp @@ -25,13 +25,14 @@ MxThread::~MxThread() typedef unsigned(__stdcall* ThreadFunc)(void*); // FUNCTION: LEGO1 0x100bf610 -MxResult MxThread::Start(MxS32 p_stack, MxS32 p_flag) +MxResult MxThread::Start(MxS32 p_stackSize, MxS32 p_flag) { MxResult result = FAILURE; if (m_semaphore.Init(0, 1) == SUCCESS) { if ((m_hThread = - _beginthreadex(NULL, p_stack << 2, (ThreadFunc) &MxThread::ThreadProc, this, p_flag, &m_threadId))) { + _beginthreadex(NULL, p_stackSize * 4, (ThreadFunc) &MxThread::ThreadProc, this, p_flag, &m_threadId) + )) { result = SUCCESS; } } From 711134b3b82a6fe499a8004953bd37dcd2941191 Mon Sep 17 00:00:00 2001 From: Florian Kaiser Date: Fri, 9 May 2025 16:35:11 +0200 Subject: [PATCH 09/11] Replace `m_unk0x04` and `m_unk0x08` with `m_modelDataLength` and `m_modelDataOffset` (#1456) --- .../legoomni/src/entity/legoworldpresenter.cpp | 8 ++++---- LEGO1/modeldb/modeldb.cpp | 4 ++-- LEGO1/modeldb/modeldb.h | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp b/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp index 3a8842a5..a5f64321 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp @@ -342,15 +342,15 @@ MxResult LegoWorldPresenter::FUN_10067360(ModelDbPart& p_part, FILE* p_wdbFile) // FUNCTION: LEGO1 0x100674b0 MxResult LegoWorldPresenter::FUN_100674b0(ModelDbModel& p_model, FILE* p_wdbFile, LegoWorld* p_world) { - MxU8* buff = new MxU8[p_model.m_unk0x04]; + MxU8* buff = new MxU8[p_model.m_modelDataLength]; - fseek(p_wdbFile, p_model.m_unk0x08, SEEK_SET); - if (fread(buff, p_model.m_unk0x04, 1, p_wdbFile) != 1) { + fseek(p_wdbFile, p_model.m_modelDataOffset, SEEK_SET); + if (fread(buff, p_model.m_modelDataLength, 1, p_wdbFile) != 1) { return FAILURE; } MxDSChunk chunk; - chunk.SetLength(p_model.m_unk0x04); + chunk.SetLength(p_model.m_modelDataLength); chunk.SetData(buff); MxDSAction action; diff --git a/LEGO1/modeldb/modeldb.cpp b/LEGO1/modeldb/modeldb.cpp index c56e62b7..66958e73 100644 --- a/LEGO1/modeldb/modeldb.cpp +++ b/LEGO1/modeldb/modeldb.cpp @@ -28,10 +28,10 @@ MxResult ModelDbModel::Read(FILE* p_file) return FAILURE; } - if (fread(&m_unk0x04, sizeof(m_unk0x04), 1, p_file) != 1) { + if (fread(&m_modelDataLength, sizeof(m_modelDataLength), 1, p_file) != 1) { return FAILURE; } - if (fread(&m_unk0x08, sizeof(m_unk0x08), 1, p_file) != 1) { + if (fread(&m_modelDataOffset, sizeof(m_modelDataOffset), 1, p_file) != 1) { return FAILURE; } if (fread(&len, sizeof(len), 1, p_file) != 1) { diff --git a/LEGO1/modeldb/modeldb.h b/LEGO1/modeldb/modeldb.h index 911832e5..02642926 100644 --- a/LEGO1/modeldb/modeldb.h +++ b/LEGO1/modeldb/modeldb.h @@ -94,14 +94,14 @@ struct ModelDbModel { void Free(); MxResult Read(FILE* p_file); - char* m_modelName; // 0x00 - undefined4 m_unk0x04; // 0x04 - undefined4 m_unk0x08; // 0x08 - char* m_presenterName; // 0x0c - float m_location[3]; // 0x10 - float m_direction[3]; // 0x1c - float m_up[3]; // 0x28 - undefined m_unk0x34; // 0x34 + char* m_modelName; // 0x00 + MxU32 m_modelDataLength; // 0x04 + MxU32 m_modelDataOffset; // 0x08 + char* m_presenterName; // 0x0c + float m_location[3]; // 0x10 + float m_direction[3]; // 0x1c + float m_up[3]; // 0x28 + undefined m_unk0x34; // 0x34 }; // SIZE 0x18 From 3811d61ea4431f8bfb2c87c6eb47d4c06cf671a4 Mon Sep 17 00:00:00 2001 From: Florian Kaiser Date: Fri, 9 May 2025 16:40:00 +0200 Subject: [PATCH 10/11] Rename `c_bit5` to `c_ctrl` in `LegoInputManager`, change `m_unk0x6c` to `m_isAccelerating` and clear some local unknowns (#1458) --- .../lego/legoomni/include/legoinputmanager.h | 2 +- .../lego/legoomni/include/legonavcontroller.h | 2 +- .../legoomni/src/entity/legonavcontroller.cpp | 40 +++++++++++-------- .../legoomni/src/input/legoinputmanager.cpp | 2 +- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoinputmanager.h b/LEGO1/lego/legoomni/include/legoinputmanager.h index 9b47d7a8..a199d7d7 100644 --- a/LEGO1/lego/legoomni/include/legoinputmanager.h +++ b/LEGO1/lego/legoomni/include/legoinputmanager.h @@ -74,7 +74,7 @@ public: c_right = 0x02, c_up = 0x04, c_down = 0x08, - c_bit5 = 0x10, + c_ctrl = 0x10, c_leftOrRight = c_left | c_right, c_upOrDown = c_up | c_down diff --git a/LEGO1/lego/legoomni/include/legonavcontroller.h b/LEGO1/lego/legoomni/include/legonavcontroller.h index ef882450..adbed6a1 100644 --- a/LEGO1/lego/legoomni/include/legonavcontroller.h +++ b/LEGO1/lego/legoomni/include/legonavcontroller.h @@ -155,7 +155,7 @@ protected: float m_unk0x60; // 0x60 float m_unk0x64; // 0x64 float m_unk0x68; // 0x68 - MxBool m_unk0x6c; // 0x6c + MxBool m_isAccelerating; // 0x6c // one copy of defaults (these can be set by App.) static int g_defdeadZone; diff --git a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp index 24ea5af5..061ffdd6 100644 --- a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp @@ -135,7 +135,7 @@ LegoNavController::LegoNavController() m_rotationalAccel = 0.0f; m_trackDefault = FALSE; m_unk0x5d = FALSE; - m_unk0x6c = FALSE; + m_isAccelerating = FALSE; m_unk0x64 = 0.0f; m_unk0x68 = 0.0f; m_unk0x60 = 0.0f; @@ -564,8 +564,8 @@ MxResult LegoNavController::ProcessJoystickInput(MxBool& p_und) // FUNCTION: LEGO1 0x100558b0 MxResult LegoNavController::ProcessKeyboardInput() { - MxBool bool1 = FALSE; - MxBool bool2 = FALSE; + MxBool skipRotationVelAndAccelCalc = FALSE; + MxBool skipLinearVelAndAccelCalc = FALSE; LegoInputManager* inputManager = LegoOmni::GetInstance()->GetInputManager(); MxU32 keyFlags; @@ -574,18 +574,18 @@ MxResult LegoNavController::ProcessKeyboardInput() } if (keyFlags == 0) { - if (m_unk0x6c) { + if (m_isAccelerating) { m_targetRotationalVel = 0.0; m_targetLinearVel = 0.0; m_rotationalAccel = m_maxRotationalDeccel; m_linearAccel = m_maxLinearDeccel; - m_unk0x6c = FALSE; + m_isAccelerating = FALSE; } return FAILURE; } - m_unk0x6c = TRUE; + m_isAccelerating = TRUE; MxS32 hMax; switch (keyFlags & LegoInputManager::c_leftOrRight) { @@ -598,7 +598,7 @@ MxResult LegoNavController::ProcessKeyboardInput() default: m_targetRotationalVel = 0.0; m_rotationalAccel = m_maxRotationalDeccel; - bool1 = TRUE; + skipRotationVelAndAccelCalc = TRUE; break; } @@ -613,23 +613,31 @@ MxResult LegoNavController::ProcessKeyboardInput() default: m_targetLinearVel = 0.0; m_linearAccel = m_maxLinearDeccel; - bool2 = TRUE; + skipLinearVelAndAccelCalc = TRUE; break; } - MxFloat val = keyFlags & LegoInputManager::c_bit5 ? 1.0f : 4.0f; - MxFloat val2 = keyFlags & LegoInputManager::c_bit5 ? 1.0f : 2.0f; + MxFloat maxAccelDivisor = keyFlags & LegoInputManager::c_ctrl ? 1.0f : 4.0f; + MxFloat minAccelDivisor = keyFlags & LegoInputManager::c_ctrl ? 1.0f : 2.0f; - if (!bool1) { + if (!skipRotationVelAndAccelCalc) { m_targetRotationalVel = CalculateNewTargetVel(hMax, m_hMax / 2, m_maxRotationalVel); - m_rotationalAccel = - CalculateNewAccel(hMax, m_hMax / 2, m_maxRotationalAccel / val, (int) (m_minRotationalAccel / val2)); + m_rotationalAccel = CalculateNewAccel( + hMax, + m_hMax / 2, + m_maxRotationalAccel / maxAccelDivisor, + (int) (m_minRotationalAccel / minAccelDivisor) + ); } - if (!bool2) { + if (!skipLinearVelAndAccelCalc) { m_targetLinearVel = CalculateNewTargetVel(m_vMax - vMax, m_vMax / 2, m_maxLinearVel); - m_linearAccel = - CalculateNewAccel(m_vMax - vMax, m_vMax / 2, m_maxLinearAccel / val, (int) (m_minLinearAccel / val2)); + m_linearAccel = CalculateNewAccel( + m_vMax - vMax, + m_vMax / 2, + m_maxLinearAccel / maxAccelDivisor, + (int) (m_minLinearAccel / minAccelDivisor) + ); } return SUCCESS; diff --git a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp index e3523ca9..f3c7a9d3 100644 --- a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp +++ b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp @@ -195,7 +195,7 @@ MxResult LegoInputManager::GetNavigationKeyStates(MxU32& p_keyFlags) } if ((m_keyboardState[DIK_LCONTROL] | m_keyboardState[DIK_RCONTROL]) & 0x80) { - keyFlags |= c_bit5; + keyFlags |= c_ctrl; } p_keyFlags = keyFlags; From 5fd5a4cec04fcc3617dca3c93367006c2dad8377 Mon Sep 17 00:00:00 2001 From: Florian Kaiser Date: Fri, 9 May 2025 18:13:19 +0200 Subject: [PATCH 11/11] Clear unknowns in LegoROI and related classes (#1457) * Clear unknowns in LegoROI and related classes * Update names * Consistently naming: `GetTextureInfo` --------- Co-authored-by: Christian Semmler --- LEGO1/lego/legoomni/include/legogamestate.h | 4 +- .../src/build/legocarbuildpresenter.cpp | 4 +- .../src/common/legocharactermanager.cpp | 16 ++-- .../legoomni/src/common/legogamestate.cpp | 10 +-- .../src/video/legophonemepresenter.cpp | 2 +- LEGO1/lego/sources/roi/legolod.cpp | 28 +++---- LEGO1/lego/sources/roi/legolod.h | 10 +-- LEGO1/lego/sources/roi/legoroi.cpp | 73 ++++++++++--------- LEGO1/lego/sources/roi/legoroi.h | 20 ++--- 9 files changed, 84 insertions(+), 83 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legogamestate.h b/LEGO1/lego/legoomni/include/legogamestate.h index e088618d..b6a236b9 100644 --- a/LEGO1/lego/legoomni/include/legogamestate.h +++ b/LEGO1/lego/legoomni/include/legogamestate.h @@ -228,7 +228,7 @@ private: MxResult WriteEndOfVariables(LegoStorage* p_storage); MxS32 ReadVariable(LegoStorage* p_storage, MxVariableTable* p_to); void SetColors(); - void SetROIHandlerFunction(); + void SetROIColorOverride(); char* m_savePath; // 0x00 MxS16 m_stateCount; // 0x04 @@ -255,7 +255,7 @@ public: Area m_unk0x42c; // 0x42c }; -MxBool ROIHandlerFunction(const char* p_input, char* p_output, MxU32 p_copyLen); +MxBool ROIColorOverride(const char* p_input, char* p_output, MxU32 p_copyLen); // SYNTHETIC: LEGO1 0x1003c860 // LegoGameState::ScoreItem::ScoreItem diff --git a/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp b/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp index 31189d72..240e03c1 100644 --- a/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp +++ b/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp @@ -220,8 +220,8 @@ void LegoCarBuildAnimPresenter::StreamingTickle() LegoROI* roi = m_roiMap[j]; if (roi && roi->GetName() && (strcmpi(name, roi->GetName()) == 0)) { - roi->FUN_100a9dd0(); - roi->FUN_100a9350("lego red"); + roi->ClearMeshOffset(); + roi->SetLodColor("lego red"); } } } diff --git a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp index 8377e30f..3805ab5c 100644 --- a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp @@ -567,14 +567,14 @@ LegoROI* LegoCharacterManager::CreateActorROI(const char* p_key) LegoTextureInfo* textureInfo = textureContainer->Get(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]]); if (textureInfo != NULL) { - childROI->FUN_100a9210(textureInfo); - childROI->FUN_100a9170(1.0F, 1.0F, 1.0F, 0.0F); + childROI->SetTextureInfo(textureInfo); + childROI->SetLodColor(1.0F, 1.0F, 1.0F, 0.0F); } } else if (g_actorLODs[i + 1].m_flags & LegoActorLOD::c_flag2 || (i == 0 && part.m_unk0x00[part.m_unk0x08] == 0)) { LegoFloat red, green, blue, alpha; - childROI->FUN_100a9bf0(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]], red, green, blue, alpha); - childROI->FUN_100a9170(red, green, blue, alpha); + childROI->GetRGBAColor(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]], red, green, blue, alpha); + childROI->SetLodColor(red, green, blue, alpha); } comp->push_back(childROI); @@ -796,8 +796,8 @@ MxBool LegoCharacterManager::SwitchColor(LegoROI* p_roi, LegoROI* p_targetROI) } LegoFloat red, green, blue, alpha; - LegoROI::FUN_100a9bf0(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]], red, green, blue, alpha); - p_targetROI->FUN_100a9170(red, green, blue, alpha); + LegoROI::GetRGBAColor(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]], red, green, blue, alpha); + p_targetROI->SetLodColor(red, green, blue, alpha); return TRUE; } @@ -832,12 +832,12 @@ MxBool LegoCharacterManager::SwitchVariant(LegoROI* p_roi) Tgl::Renderer* renderer = VideoManager()->GetRenderer(); LegoFloat red, green, blue, alpha; - LegoROI::FUN_100a9bf0(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]], red, green, blue, alpha); + LegoROI::GetRGBAColor(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]], red, green, blue, alpha); for (MxS32 i = 0; i < lodSize; i++) { LegoLOD* lod = (LegoLOD*) (*lodList)[i]; LegoLOD* clone = lod->Clone(renderer); - clone->FUN_100aacb0(red, green, blue, alpha); + clone->SetColor(red, green, blue, alpha); dupLodList->PushBack(clone); } diff --git a/LEGO1/lego/legoomni/src/common/legogamestate.cpp b/LEGO1/lego/legoomni/src/common/legogamestate.cpp index cd4a6f1b..047f673a 100644 --- a/LEGO1/lego/legoomni/src/common/legogamestate.cpp +++ b/LEGO1/lego/legoomni/src/common/legogamestate.cpp @@ -145,7 +145,7 @@ const char* g_strDisable = "disable"; LegoGameState::LegoGameState() { SetColors(); - SetROIHandlerFunction(); + SetROIColorOverride(); m_stateCount = 0; m_actorId = 0; @@ -176,7 +176,7 @@ LegoGameState::LegoGameState() // FUNCTION: LEGO1 0x10039720 LegoGameState::~LegoGameState() { - LegoROI::FUN_100a9d30(NULL); + LegoROI::SetColorOverride(NULL); if (m_stateCount) { for (MxS16 i = 0; i < m_stateCount; i++) { @@ -1060,13 +1060,13 @@ void LegoGameState::SetColors() } // FUNCTION: LEGO1 0x1003bac0 -void LegoGameState::SetROIHandlerFunction() +void LegoGameState::SetROIColorOverride() { - LegoROI::FUN_100a9d30(&ROIHandlerFunction); + LegoROI::SetColorOverride(&ROIColorOverride); } // FUNCTION: LEGO1 0x1003bad0 -MxBool ROIHandlerFunction(const char* p_input, char* p_output, MxU32 p_copyLen) +MxBool ROIColorOverride(const char* p_input, char* p_output, MxU32 p_copyLen) { if (p_output != NULL && p_copyLen != 0 && (strnicmp(p_input, "INDIR-F-", strlen("INDIR-F-")) == 0 || diff --git a/LEGO1/lego/legoomni/src/video/legophonemepresenter.cpp b/LEGO1/lego/legoomni/src/video/legophonemepresenter.cpp index 824a4ce2..46d1edb8 100644 --- a/LEGO1/lego/legoomni/src/video/legophonemepresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legophonemepresenter.cpp @@ -56,7 +56,7 @@ void LegoPhonemePresenter::StartingTickle() } head = entityROI->FindChildROI("head", entityROI); - head->GetTexture(m_textureInfo); + head->GetTextureInfo(m_textureInfo); LegoPhonemeList* phonemeList = VideoManager()->GetPhonemeList(); LegoPhoneme* phoneme = new LegoPhoneme(m_roiName.GetData(), 1); diff --git a/LEGO1/lego/sources/roi/legolod.cpp b/LEGO1/lego/sources/roi/legolod.cpp index 7db2a0a9..d8b7e0d9 100644 --- a/LEGO1/lego/sources/roi/legolod.cpp +++ b/LEGO1/lego/sources/roi/legolod.cpp @@ -32,7 +32,7 @@ LegoLOD::LegoLOD(Tgl::Renderer* p_renderer) : ViewLOD(p_renderer) m_numMeshes = 0; m_numVertices = 0; m_numPolys = 0; - m_unk0x1c = 0; + m_meshOffset = 0; } // FUNCTION: LEGO1 0x100aa450 @@ -212,7 +212,7 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text if (textureName != NULL) { if (mesh->GetUnknown0x21()) { - LegoROI::FUN_100a9cf0(textureName, paletteEntries, sizeOfArray(paletteEntries)); + LegoROI::GetPaletteEntries(textureName, paletteEntries, sizeOfArray(paletteEntries)); } textureInfo = p_textureContainer->Get(mesh->GetTextureName()); @@ -232,7 +232,7 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text LegoFloat alpha = 0.0F; if (mesh->GetUnknown0x21()) { - LegoROI::FUN_100a9bf0(materialName, red, green, blue, alpha); + LegoROI::GetRGBAColor(materialName, red, green, blue, alpha); } else { red = mesh->GetColor().GetRed() / 255.0; @@ -265,7 +265,7 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text } } - m_unk0x1c = meshUnd2; + m_meshOffset = meshUnd2; if (textureVertices != NULL) { delete[] textureVertices; @@ -319,15 +319,15 @@ LegoLOD* LegoLOD::Clone(Tgl::Renderer* p_renderer) dupLod->m_numMeshes = m_numMeshes; dupLod->m_numVertices = m_numVertices; dupLod->m_numPolys = m_numPolys; - dupLod->m_unk0x1c = m_unk0x1c; + dupLod->m_meshOffset = m_meshOffset; return dupLod; } // FUNCTION: LEGO1 0x100aacb0 -LegoResult LegoLOD::FUN_100aacb0(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha) +LegoResult LegoLOD::SetColor(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha) { - for (LegoU32 i = m_unk0x1c; i < m_numMeshes; i++) { + for (LegoU32 i = m_meshOffset; i < m_numMeshes; i++) { if (!m_melems[i].m_unk0x04) { m_melems[i].m_tglMesh->SetColor(p_red, p_green, p_blue, p_alpha); } @@ -337,9 +337,9 @@ LegoResult LegoLOD::FUN_100aacb0(LegoFloat p_red, LegoFloat p_green, LegoFloat p } // FUNCTION: LEGO1 0x100aad00 -LegoResult LegoLOD::FUN_100aad00(LegoTextureInfo* p_textureInfo) +LegoResult LegoLOD::SetTextureInfo(LegoTextureInfo* p_textureInfo) { - for (LegoU32 i = m_unk0x1c; i < m_numMeshes; i++) { + for (LegoU32 i = m_meshOffset; i < m_numMeshes; i++) { if (m_melems[i].m_unk0x04) { LegoTextureInfo::SetGroupTexture(m_melems[i].m_tglMesh, p_textureInfo); m_melems[i].m_tglMesh->SetColor(1.0F, 1.0F, 1.0F, 0.0F); @@ -353,7 +353,7 @@ LegoResult LegoLOD::FUN_100aad00(LegoTextureInfo* p_textureInfo) // FUNCTION: LEGO1 0x100aad70 LegoResult LegoLOD::FUN_100aad70(LegoTextureInfo* p_textureInfo) { - for (LegoU32 i = m_unk0x1c; i < m_numMeshes; i++) { + for (LegoU32 i = m_meshOffset; i < m_numMeshes; i++) { if (m_melems[i].m_unk0x04) { LegoTextureInfo::SetGroupTexture(m_melems[i].m_tglMesh, p_textureInfo); } @@ -363,9 +363,9 @@ LegoResult LegoLOD::FUN_100aad70(LegoTextureInfo* p_textureInfo) } // FUNCTION: LEGO1 0x100aadc0 -LegoResult LegoLOD::GetTexture(LegoTextureInfo*& p_textureInfo) +LegoResult LegoLOD::GetTextureInfo(LegoTextureInfo*& p_textureInfo) { - for (LegoU32 i = m_unk0x1c; i < m_numMeshes; i++) { + for (LegoU32 i = m_meshOffset; i < m_numMeshes; i++) { if (m_melems[i].m_unk0x04) { if (LegoTextureInfo::GetGroupTexture(m_melems[i].m_tglMesh, p_textureInfo) == TRUE) { return SUCCESS; @@ -390,9 +390,9 @@ LegoBool LegoLOD::FUN_100aae20(const LegoChar* p_name) // FUNCTION: LEGO1 0x100aae60 // FUNCTION: BETA10 0x1018e50f -void LegoLOD::FUN_100aae60() +void LegoLOD::ClearMeshOffset() { - m_unk0x1c = 0; + m_meshOffset = 0; } inline BOOL GetMeshData(IDirect3DRMMesh*& mesh, D3DRMGROUPINDEX& index, Tgl::Mesh* pMesh) diff --git a/LEGO1/lego/sources/roi/legolod.h b/LEGO1/lego/sources/roi/legolod.h index 0d50e675..8b3409b8 100644 --- a/LEGO1/lego/sources/roi/legolod.h +++ b/LEGO1/lego/sources/roi/legolod.h @@ -29,11 +29,11 @@ public: LegoResult Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_textureContainer, LegoStorage* p_storage); LegoLOD* Clone(Tgl::Renderer* p_renderer); - LegoResult FUN_100aacb0(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha); - LegoResult FUN_100aad00(LegoTextureInfo* p_textureInfo); + LegoResult SetColor(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha); + LegoResult SetTextureInfo(LegoTextureInfo* p_textureInfo); LegoResult FUN_100aad70(LegoTextureInfo* p_textureInfo); - void FUN_100aae60(); - LegoResult GetTexture(LegoTextureInfo*& p_textureInfo); + void ClearMeshOffset(); + LegoResult GetTextureInfo(LegoTextureInfo*& p_textureInfo); static LegoBool FUN_100aae20(const LegoChar* p_name); @@ -45,7 +45,7 @@ protected: LegoU32 m_numMeshes; // 0x10 LegoU32 m_numVertices; // 0x14 LegoU32 m_numPolys; // 0x18 - undefined4 m_unk0x1c; // 0x1c + LegoU32 m_meshOffset; // 0x1c }; #endif // LEGOLOD_H diff --git a/LEGO1/lego/sources/roi/legoroi.cpp b/LEGO1/lego/sources/roi/legoroi.cpp index 25d6fb36..d3cd7e70 100644 --- a/LEGO1/lego/sources/roi/legoroi.cpp +++ b/LEGO1/lego/sources/roi/legoroi.cpp @@ -52,10 +52,10 @@ const char* g_unk0x10101380[] = {"bike", "moto", "haus", NULL}; const char* g_unk0x10101390[] = {"rcuser", "jsuser", "dunebugy", "chtrblad", "chtrbody", "chtrshld", NULL}; // GLOBAL: LEGO1 0x101013ac -ROIHandler g_unk0x101013ac = NULL; +ColorOverride g_colorOverride = NULL; // GLOBAL: LEGO1 0x101013b0 -TextureHandler g_unk0x101013b0 = NULL; +TextureHandler g_textureHandler = NULL; // FUNCTION: LEGO1 0x100a81b0 void LegoROI::FUN_100a81b0(const LegoChar* p_error, const LegoChar* p_name) @@ -299,16 +299,16 @@ LegoResult LegoROI::Read( goto done; } - FUN_100a9210(textureInfo); - FUN_100a9170(1.0F, 1.0F, 1.0F, 0.0F); + SetTextureInfo(textureInfo); + SetLodColor(1.0F, 1.0F, 1.0F, 0.0F); } else { LegoFloat red = 1.0F; LegoFloat green = 0.0F; LegoFloat blue = 1.0F; LegoFloat alpha = 0.0F; - FUN_100a9bf0(textureName, red, green, blue, alpha); - FUN_100a9170(red, green, blue, alpha); + GetRGBAColor(textureName, red, green, blue, alpha); + SetLodColor(red, green, blue, alpha); } } @@ -481,7 +481,7 @@ LegoResult LegoROI::SetFrame(LegoAnim* p_anim, LegoTime p_time) // FUNCTION: LEGO1 0x100a9170 // FUNCTION: BETA10 0x1018ae09 -LegoResult LegoROI::FUN_100a9170(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha) +LegoResult LegoROI::SetLodColor(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha) { LegoResult result = SUCCESS; CompoundObject::iterator it; @@ -490,14 +490,14 @@ LegoResult LegoROI::FUN_100a9170(LegoFloat p_red, LegoFloat p_green, LegoFloat p for (LegoU32 i = 0; i < lodCount; i++) { LegoLOD* lod = (LegoLOD*) GetLOD(i); - if (lod->FUN_100aacb0(p_red, p_green, p_blue, p_alpha) != SUCCESS) { + if (lod->SetColor(p_red, p_green, p_blue, p_alpha) != SUCCESS) { result = FAILURE; } } if (comp != NULL) { for (it = comp->begin(); it != comp->end(); it++) { - if (((LegoROI*) *it)->FUN_100a9170(p_red, p_green, p_blue, p_alpha) != SUCCESS) { + if (((LegoROI*) *it)->SetLodColor(p_red, p_green, p_blue, p_alpha) != SUCCESS) { result = FAILURE; } } @@ -507,7 +507,7 @@ LegoResult LegoROI::FUN_100a9170(LegoFloat p_red, LegoFloat p_green, LegoFloat p } // FUNCTION: LEGO1 0x100a9210 -LegoResult LegoROI::FUN_100a9210(LegoTextureInfo* p_textureInfo) +LegoResult LegoROI::SetTextureInfo(LegoTextureInfo* p_textureInfo) { LegoResult result = SUCCESS; CompoundObject::iterator it; @@ -516,14 +516,14 @@ LegoResult LegoROI::FUN_100a9210(LegoTextureInfo* p_textureInfo) for (LegoU32 i = 0; i < lodCount; i++) { LegoLOD* lod = (LegoLOD*) GetLOD(i); - if (lod->FUN_100aad00(p_textureInfo) != SUCCESS) { + if (lod->SetTextureInfo(p_textureInfo) != SUCCESS) { result = FAILURE; } } if (comp != NULL) { for (it = comp->begin(); it != comp->end(); it++) { - if (((LegoROI*) *it)->FUN_100a9210(p_textureInfo) != SUCCESS) { + if (((LegoROI*) *it)->SetTextureInfo(p_textureInfo) != SUCCESS) { result = FAILURE; } } @@ -534,7 +534,7 @@ LegoResult LegoROI::FUN_100a9210(LegoTextureInfo* p_textureInfo) // FUNCTION: LEGO1 0x100a92a0 // FUNCTION: BETA10 0x1018b12d -LegoResult LegoROI::GetTexture(LegoTextureInfo*& p_textureInfo) +LegoResult LegoROI::GetTextureInfo(LegoTextureInfo*& p_textureInfo) { CompoundObject::iterator it; @@ -542,14 +542,14 @@ LegoResult LegoROI::GetTexture(LegoTextureInfo*& p_textureInfo) for (LegoU32 i = 0; i < lodCount; i++) { LegoLOD* lod = (LegoLOD*) GetLOD(i); - if (lod->GetTexture(p_textureInfo) == SUCCESS) { + if (lod->GetTextureInfo(p_textureInfo) == SUCCESS) { return SUCCESS; } } if (comp != NULL) { for (it = comp->begin(); it != comp->end(); it++) { - if (((LegoROI*) *it)->GetTexture(p_textureInfo) == SUCCESS) { + if (((LegoROI*) *it)->GetTextureInfo(p_textureInfo) == SUCCESS) { return SUCCESS; } } @@ -562,16 +562,16 @@ LegoResult LegoROI::GetTexture(LegoTextureInfo*& p_textureInfo) // FUNCTION: BETA10 0x1018b22c LegoResult LegoROI::FUN_100a9330(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha) { - return FUN_100a9170(p_red, p_green, p_blue, p_alpha); + return SetLodColor(p_red, p_green, p_blue, p_alpha); } // FUNCTION: LEGO1 0x100a9350 // FUNCTION: BETA10 0x1018b25c -LegoResult LegoROI::FUN_100a9350(const LegoChar* p_color) +LegoResult LegoROI::SetLodColor(const LegoChar* p_name) { MxFloat red, green, blue, alpha; - if (ColorAliasLookup(p_color, red, green, blue, alpha)) { - return FUN_100a9170(red, green, blue, alpha); + if (ColorAliasLookup(p_name, red, green, blue, alpha)) { + return SetLodColor(red, green, blue, alpha); } return SUCCESS; @@ -579,10 +579,10 @@ LegoResult LegoROI::FUN_100a9350(const LegoChar* p_color) // FUNCTION: LEGO1 0x100a93b0 // FUNCTION: BETA10 0x1018b2c0 -LegoResult LegoROI::FUN_100a93b0(const LegoChar* p_color) +LegoResult LegoROI::FUN_100a93b0(const LegoChar* p_name) { MxFloat red, green, blue, alpha; - if (ColorAliasLookup(p_color, red, green, blue, alpha)) { + if (ColorAliasLookup(p_name, red, green, blue, alpha)) { return FUN_100a9330(red, green, blue, alpha); } @@ -755,20 +755,20 @@ void TimeROI::FUN_100a9b40(Matrix4& p_matrix, LegoTime p_time) } // FUNCTION: LEGO1 0x100a9bf0 -LegoBool LegoROI::FUN_100a9bf0(const LegoChar* p_param, float& p_red, float& p_green, float& p_blue, float& p_alpha) +LegoBool LegoROI::GetRGBAColor(const LegoChar* p_name, float& p_red, float& p_green, float& p_blue, float& p_alpha) { - if (p_param == NULL) { + if (p_name == NULL) { return FALSE; } - if (g_unk0x101013ac) { - char buf[32]; - if (g_unk0x101013ac(p_param, buf, sizeof(buf))) { - p_param = buf; + char p_updatedName[32]; + if (g_colorOverride) { + if (g_colorOverride(p_name, p_updatedName, sizeof(p_updatedName))) { + p_name = p_updatedName; } } - return ColorAliasLookup(p_param, p_red, p_green, p_blue, p_alpha); + return ColorAliasLookup(p_name, p_red, p_green, p_blue, p_alpha); } // FUNCTION: LEGO1 0x100a9c50 @@ -789,14 +789,15 @@ LegoBool LegoROI::ColorAliasLookup(const LegoChar* p_param, float& p_red, float& } // FUNCTION: LEGO1 0x100a9cf0 -LegoBool LegoROI::FUN_100a9cf0(const LegoChar* p_param, unsigned char* paletteEntries, LegoU32 p_numEntries) +LegoBool LegoROI::GetPaletteEntries(const LegoChar* p_name, unsigned char* paletteEntries, LegoU32 p_numEntries) { - if (p_param == NULL) { + if (p_name == NULL) { return FALSE; } - if (g_unk0x101013b0 != NULL) { - return g_unk0x101013b0(p_param, paletteEntries, p_numEntries); + // Note: g_textureHandler is never set in the code base + if (g_textureHandler != NULL) { + return g_textureHandler(p_name, paletteEntries, p_numEntries); } paletteEntries[0] = '\0'; @@ -804,9 +805,9 @@ LegoBool LegoROI::FUN_100a9cf0(const LegoChar* p_param, unsigned char* paletteEn } // FUNCTION: LEGO1 0x100a9d30 -void LegoROI::FUN_100a9d30(ROIHandler p_func) +void LegoROI::SetColorOverride(ColorOverride p_colorOverride) { - g_unk0x101013ac = p_func; + g_colorOverride = p_colorOverride; } // FUNCTION: LEGO1 0x100a9d40 @@ -828,12 +829,12 @@ void LegoROI::SetName(const LegoChar* p_name) // FUNCTION: LEGO1 0x100a9dd0 // FUNCTION: BETA10 0x1018bfdb -void LegoROI::FUN_100a9dd0() +void LegoROI::ClearMeshOffset() { int lodCount = GetLODCount(); for (LegoS32 i = 0; i < lodCount; i++) { LegoLOD* lod = (LegoLOD*) GetLOD(i); - lod->FUN_100aae60(); + lod->ClearMeshOffset(); } } diff --git a/LEGO1/lego/sources/roi/legoroi.h b/LEGO1/lego/sources/roi/legoroi.h index f69936dc..3ba5a472 100644 --- a/LEGO1/lego/sources/roi/legoroi.h +++ b/LEGO1/lego/sources/roi/legoroi.h @@ -4,7 +4,7 @@ #include "misc/legotypes.h" #include "viewmanager/viewroi.h" -typedef unsigned char (*ROIHandler)(const char*, char*, unsigned int); +typedef unsigned char (*ColorOverride)(const char*, char*, unsigned int); typedef unsigned char (*TextureHandler)(const char*, unsigned char*, unsigned int); class LegoEntity; @@ -36,26 +36,26 @@ public: 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); - LegoResult FUN_100a9170(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha); - LegoResult FUN_100a9210(LegoTextureInfo* p_textureInfo); - LegoResult GetTexture(LegoTextureInfo*& p_textureInfo); + LegoResult SetLodColor(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha); + LegoResult SetTextureInfo(LegoTextureInfo* p_textureInfo); + LegoResult GetTextureInfo(LegoTextureInfo*& p_textureInfo); LegoResult FUN_100a9330(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha); - LegoResult FUN_100a9350(const LegoChar* p_color); - LegoResult FUN_100a93b0(const LegoChar* p_color); + LegoResult SetLodColor(const LegoChar* p_name); + LegoResult FUN_100a93b0(const LegoChar* p_name); LegoU32 FUN_100a9410(Vector3& p_v1, Vector3& p_v2, float p_f1, float p_f2, Vector3& p_v3, LegoBool p_collideBox); void SetName(const LegoChar* p_name); float IntrinsicImportance() const override; // vtable+0x04 void UpdateWorldBoundingVolumes() override; // vtable+0x18 - void FUN_100a9dd0(); + void ClearMeshOffset(); void SetDisplayBB(int p_displayBB); static LegoResult FUN_100a8cb0(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 FUN_100a9d30(ROIHandler p_func); - static LegoBool FUN_100a9bf0(const LegoChar* p_param, float& p_red, float& p_green, float& p_blue, float& p_alpha); + static void SetColorOverride(ColorOverride p_colorOverride); + static LegoBool GetRGBAColor(const LegoChar* p_name, float& p_red, float& p_green, float& p_blue, float& p_alpha); static LegoBool ColorAliasLookup( const LegoChar* p_param, float& p_red, @@ -63,7 +63,7 @@ public: float& p_blue, float& p_alpha ); - static LegoBool FUN_100a9cf0(const LegoChar* p_param, unsigned char* paletteEntries, LegoU32 p_numEntries); + static LegoBool GetPaletteEntries(const LegoChar* p_name, unsigned char* paletteEntries, LegoU32 p_numEntries); // FUNCTION: BETA10 0x1000f320 const LegoChar* GetName() const { return m_name; }