Skip to content

Commit 9d9d491

Browse files
authored
Implement/match MithrilChain0x8 (isledecomp#140)
1 parent a3e4286 commit 9d9d491

3 files changed

Lines changed: 139 additions & 18 deletions

File tree

LEGORacers/include/mithrilchain0x8.h

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,46 @@ class BronzeFalcon0xc8770;
99
// SIZE 0x8
1010
class MithrilChain0x8 {
1111
public:
12+
// SIZE 0x18
13+
class Entry {
14+
public:
15+
enum {
16+
c_flagActive = 0x01,
17+
c_flagLooping = 0x02,
18+
c_flagExpired = 0x04,
19+
};
20+
21+
Entry();
22+
~Entry();
23+
24+
void Reset();
25+
void Deactivate();
26+
void Update(LegoU32 p_elapsedMs);
27+
void Draw(BronzeFalcon0xc8770* p_renderer);
28+
LegoBool IsActive() { return m_flags & c_flagActive; }
29+
30+
private:
31+
void Clear();
32+
33+
undefined4 m_unk0x00; // 0x00
34+
undefined4 m_unk0x04; // 0x04
35+
undefined m_unk0x08[4]; // 0x08
36+
LegoU32 m_remainingMs; // 0x0c
37+
LegoU32 m_durationMs; // 0x10
38+
LegoU8 m_flags; // 0x14
39+
undefined m_unk0x15[3]; // 0x15
40+
};
41+
1242
MithrilChain0x8();
1343
~MithrilChain0x8();
14-
void FUN_00494f60(LegoU32 p_unk0x04);
15-
void FUN_00494fa0(BronzeFalcon0xc8770* p_unk0x04);
44+
void Update(LegoU32 p_elapsedMs);
45+
void Draw(BronzeFalcon0xc8770* p_renderer);
1646

1747
private:
18-
undefined m_unk0x00[0x8 - 0x00]; // 0x00
48+
void Reset();
49+
50+
Entry* m_entries; // 0x00
51+
LegoU32 m_count; // 0x04
1952
};
2053

2154
#endif // MITHRILCHAIN0X8_H

LEGORacers/src/menumanager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ void MenuManager::Run()
374374
}
375375

376376
chain = &m_unk0x04.m_unk0x4374;
377-
chain->FUN_00494f60(frameDeltaMs);
377+
chain->Update(frameDeltaMs);
378378
m_unk0x4cd8->VTable0x54(TRUE);
379379
m_unk0x4cd8->VTable0xec(6);
380380
m_unk0x4cd8->VTable0xe8(TRUE);
@@ -386,7 +386,7 @@ void MenuManager::Run()
386386
m_unk0x4c74.FUN_00469550();
387387
}
388388

389-
chain->FUN_00494fa0(m_unk0x4cd8);
389+
chain->Draw(m_unk0x4cd8);
390390
m_unk0x4cd8->VTable0xe4();
391391
m_unk0x4cd8->VTable0xf0();
392392

LEGORacers/src/mithrilchain0x8.cpp

Lines changed: 101 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,119 @@
11
#include "mithrilchain0x8.h"
22

33
DECOMP_SIZE_ASSERT(MithrilChain0x8, 0x8)
4+
DECOMP_SIZE_ASSERT(MithrilChain0x8::Entry, 0x18)
45

5-
// STUB: LEGORACERS 0x0045c3b0
6+
// FUNCTION: LEGORACERS 0x0045c3b0
67
MithrilChain0x8::MithrilChain0x8()
8+
{
9+
m_entries = NULL;
10+
m_count = 0;
11+
}
12+
13+
// FUNCTION: LEGORACERS 0x00490500
14+
MithrilChain0x8::Entry::Entry()
15+
{
16+
Clear();
17+
}
18+
19+
// FUNCTION: LEGORACERS 0x00490510
20+
MithrilChain0x8::Entry::~Entry()
21+
{
22+
Reset();
23+
}
24+
25+
// FUNCTION: LEGORACERS 0x00490520
26+
void MithrilChain0x8::Entry::Reset()
27+
{
28+
Deactivate();
29+
}
30+
31+
// FUNCTION: LEGORACERS 0x00490530
32+
void MithrilChain0x8::Entry::Clear()
33+
{
34+
m_unk0x00 = 0;
35+
m_unk0x04 = 0;
36+
m_remainingMs = 0;
37+
m_durationMs = 0;
38+
m_flags = 0;
39+
m_unk0x08[0] = 0;
40+
m_unk0x08[1] = 0;
41+
m_unk0x08[2] = 0;
42+
m_unk0x08[3] = 0;
43+
}
44+
45+
// FUNCTION: LEGORACERS 0x00490580
46+
void MithrilChain0x8::Entry::Deactivate()
47+
{
48+
Clear();
49+
}
50+
51+
// FUNCTION: LEGORACERS 0x00490590
52+
void MithrilChain0x8::Entry::Update(LegoU32 p_elapsedMs)
53+
{
54+
if (m_flags & c_flagActive) {
55+
if (!m_remainingMs) {
56+
if (m_flags & c_flagExpired) {
57+
Deactivate();
58+
}
59+
else {
60+
m_flags |= c_flagExpired;
61+
}
62+
}
63+
64+
if (p_elapsedMs > m_remainingMs) {
65+
m_remainingMs = 0;
66+
return;
67+
}
68+
69+
m_remainingMs -= p_elapsedMs;
70+
}
71+
}
72+
73+
// STUB: LEGORACERS 0x004905e0
74+
void MithrilChain0x8::Entry::Draw(BronzeFalcon0xc8770*)
775
{
876
// TODO
9-
STUB(0x45c3b0);
77+
STUB(0x4905e0);
1078
}
1179

12-
// STUB: LEGORACERS 0x00494d90
80+
// FUNCTION: LEGORACERS 0x00494d90
1381
MithrilChain0x8::~MithrilChain0x8()
1482
{
15-
// TODO
16-
STUB(0x494d90);
83+
Reset();
1784
}
1885

19-
// STUB: LEGORACERS 0x00494f60
20-
void MithrilChain0x8::FUN_00494f60(LegoU32)
86+
// FUNCTION: LEGORACERS 0x00494da0
87+
void MithrilChain0x8::Reset()
2188
{
22-
// TODO
23-
STUB(0x494f60);
89+
if (m_entries) {
90+
for (LegoU32 i = 0; i < m_count; i++) {
91+
m_entries[i].Reset();
92+
}
93+
94+
delete[] m_entries;
95+
m_entries = NULL;
96+
}
97+
98+
m_count = 0;
2499
}
25100

26-
// STUB: LEGORACERS 0x00494fa0
27-
void MithrilChain0x8::FUN_00494fa0(BronzeFalcon0xc8770*)
101+
// FUNCTION: LEGORACERS 0x00494f60
102+
void MithrilChain0x8::Update(LegoU32 p_elapsedMs)
28103
{
29-
// TODO
30-
STUB(0x494fa0);
104+
for (LegoU32 i = 0; i < m_count; i++) {
105+
if (m_entries[i].IsActive()) {
106+
m_entries[i].Update(p_elapsedMs);
107+
}
108+
}
109+
}
110+
111+
// FUNCTION: LEGORACERS 0x00494fa0
112+
void MithrilChain0x8::Draw(BronzeFalcon0xc8770* p_renderer)
113+
{
114+
for (LegoU32 i = 0; i < m_count; i++) {
115+
if (m_entries[i].IsActive()) {
116+
m_entries[i].Draw(p_renderer);
117+
}
118+
}
31119
}

0 commit comments

Comments
 (0)