Skip to content

Commit 42168f9

Browse files
committed
Animation system: Match a lot of stuff. General: Cleanup
1 parent 7ac449e commit 42168f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2659
-357
lines changed

configure.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#
1212
# Append --help to see available options.
1313
###
14+
# fmt: off
1415

1516
import argparse
1617
import sys
@@ -131,7 +132,7 @@
131132
config.objdiff_path = args.objdiff
132133
config.binutils_path = args.binutils
133134
config.compilers_path = args.compilers
134-
config.generate_map = args.map
135+
config.generate_map = True # Always do map cause it's annoying to pass --map every time
135136
config.non_matching = args.non_matching
136137
config.sjiswrap_path = args.sjiswrap
137138
config.progress = args.progress
@@ -459,16 +460,16 @@ def MatchingFor(*versions):
459460
DolphinLib(
460461
"ax",
461462
[
462-
Object(NonMatching, "3rdParty/dolphin/ax/AX.c"),
463-
Object(NonMatching, "3rdParty/dolphin/ax/AXAlloc.c"),
464-
Object(NonMatching, "3rdParty/dolphin/ax/AXAux.c"),
465-
Object(NonMatching, "3rdParty/dolphin/ax/AXCL.c"),
463+
Object(Matching, "3rdParty/dolphin/ax/AX.c"),
464+
Object(Matching, "3rdParty/dolphin/ax/AXAlloc.c"),
465+
Object(Matching, "3rdParty/dolphin/ax/AXAux.c"),
466+
Object(Matching, "3rdParty/dolphin/ax/AXCL.c"),
466467
Object(NonMatching, "3rdParty/dolphin/ax/AXOut.c"),
467468
Object(NonMatching, "3rdParty/dolphin/ax/AXSPB.c"),
468469
Object(NonMatching, "3rdParty/dolphin/ax/AXVPB.c"),
469-
Object(NonMatching, "3rdParty/dolphin/ax/AXComp.c"),
470-
Object(NonMatching, "3rdParty/dolphin/ax/DSPCode.c"),
471-
Object(NonMatching, "3rdParty/dolphin/ax/AXProf.c"),
470+
Object(Matching, "3rdParty/dolphin/ax/AXComp.c"),
471+
Object(Matching, "3rdParty/dolphin/ax/DSPCode.c"),
472+
Object(Matching, "3rdParty/dolphin/ax/AXProf.c"),
472473
],
473474
),
474475
DolphinLib(
@@ -745,8 +746,8 @@ def MatchingFor(*versions):
745746
Object(NonMatching, "Engine/ABC_Agent.cpp"),
746747
Object(NonMatching, "Engine/WorldLightning_Z.cpp"),
747748
Object(NonMatching, "Engine/HFog_Z.cpp"),
748-
Object(NonMatching, "Engine/AnimationMaterial_Z.cpp"),
749-
Object(NonMatching, "Engine/AnimationMorph_Z.cpp"),
749+
Object(Matching, "Engine/AnimationMaterial_Z.cpp"),
750+
Object(Matching, "Engine/AnimationMorph_Z.cpp"),
750751
Object(NonMatching, "Engine/Manipulator_Z.cpp"),
751752
Object(Matching, "Engine/Parameters_Z.cpp"),
752753
Object(NonMatching, "Engine/MovieManipulator_Z.cpp"),
@@ -859,7 +860,7 @@ def MatchingFor(*versions):
859860
Object(Matching, "Engine/String_Z.cpp"),
860861
Object(NonMatching, "Engine/StreamManager_Z.cpp"),
861862
Object(NonMatching, "Engine/GameManagerCmd_Z.cpp"),
862-
Object(NonMatching, "Engine/Animation_Z.cpp"),
863+
Object(Matching, "Engine/Animation_Z.cpp"),
863864
Object(NonMatching, "Engine/LodMoveCollCling_Z.cpp"),
864865
Object(NonMatching, "Engine/KeyframerRot_Z.cpp"),
865866
Object(NonMatching, "Engine/ObjectsBreakCollShadow_Z.cpp"),
@@ -876,7 +877,7 @@ def MatchingFor(*versions):
876877
Object(NonMatching, "Engine/AStar_Z.cpp"),
877878
Object(NonMatching, "Engine/Ghost_Z.cpp"),
878879
Object(NonMatching, "Engine/AnimFrameLoad_Z.cpp"),
879-
Object(NonMatching, "Engine/AnimationLoad_Z.cpp"),
880+
Object(Matching, "Engine/AnimationLoad_Z.cpp"),
880881
Object(NonMatching, "Engine/RendererPrimitiveBuffers_Z.cpp"),
881882
Object(NonMatching, "Engine/WaterHeightmap_Z.cpp"),
882883
Object(NonMatching, "Engine/Light_Z.cpp"),
@@ -944,7 +945,7 @@ def MatchingFor(*versions):
944945
Object(NonMatching, "Engine/LodMoveCollShadow_Z.cpp"),
945946
Object(NonMatching, "Engine/GraphLevel_Z.cpp"),
946947
Object(NonMatching, "Engine/SplineZoneLoad_Z.cpp"),
947-
Object(NonMatching, "Engine/KeyframerLoad_Z.cpp"),
948+
Object(Matching, "Engine/KeyframerLoad_Z.cpp"),
948949
Object(NonMatching, "Engine/Main_Z.cpp"),
949950
Object(Matching, "Engine/Object_Z.cpp"),
950951
Object(NonMatching, "Engine/Menu2DDraw_Z.cpp"),
@@ -960,7 +961,7 @@ def MatchingFor(*versions):
960961
Object(NonMatching, "Engine/Fonts_Z.cpp"),
961962
Object(NonMatching, "Engine/PlayParticles_Z.cpp"),
962963
Object(NonMatching, "Engine/NetManager_Z.cpp"),
963-
Object(NonMatching, "Engine/AnimationMesh_Z.cpp"),
964+
Object(Matching, "Engine/AnimationMesh_Z.cpp"),
964965
Object(NonMatching, "Engine/CollisionVol_Z.cpp"),
965966
Object(NonMatching, "Engine/LodCollision_Z.cpp"),
966967
Object(NonMatching, "Engine/RtcPlayer_Z.cpp"),

src/Engine/AnimMessage_Z.cpp

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
#include "AnimMessage_Z.h"
2+
#include "Program_Z.h"
3+
4+
// TODO: Finish matching
5+
S32 KeyframerMessage_Z::Get(
6+
Float i_StartTime,
7+
Float i_CurTime,
8+
Float i_MaxTime,
9+
const Message_Z& i_Msg,
10+
RegMessage_Z& o_Value
11+
) {
12+
S32 l_KeyIndex0 = -1;
13+
S32 l_KeyIndex1 = -1;
14+
S32 l_Idx;
15+
for (l_Idx = 0; l_Idx < GetNbKeys(); l_Idx++) {
16+
if (m_Keys[l_Idx].GetTime() >= i_StartTime) {
17+
l_KeyIndex0 = l_Idx;
18+
break;
19+
}
20+
}
21+
if (i_CurTime >= i_MaxTime) {
22+
l_KeyIndex1 = GetNbKeys() - 1;
23+
}
24+
else {
25+
for (l_Idx = GetNbKeys() - 1; l_Idx >= 0; l_Idx--) {
26+
if (m_Keys[l_Idx].GetTime() < i_CurTime) {
27+
l_KeyIndex1 = l_Idx;
28+
break;
29+
}
30+
}
31+
}
32+
if (l_KeyIndex1 >= 0 && l_KeyIndex0 >= 0) {
33+
const KeyMessage_Z* l_CurKey = &m_Keys[l_KeyIndex0];
34+
for (l_Idx = l_KeyIndex0; l_Idx <= l_KeyIndex1; l_Idx++, l_CurKey++) {
35+
Float l_Time = l_CurKey->GetTime();
36+
S32 l_Size = l_CurKey->m_Messages.GetSize();
37+
Message_Z* l_CurMsg = l_CurKey->m_Messages.GetArrayPtr();
38+
for (S32 l_MsgIdx = 0; l_MsgIdx < l_Size; l_MsgIdx++, l_CurMsg++) {
39+
if (l_CurMsg->m_Id == i_Msg.m_Id && l_CurMsg->m_U32Param == i_Msg.m_U32Param) {
40+
o_Value = *l_CurMsg;
41+
o_Value.m_Time = l_Time;
42+
return 1;
43+
}
44+
}
45+
}
46+
}
47+
return 0;
48+
}
49+
50+
// TODO: Finish matching
51+
S32 KeyframerMessage_Z::GetValue(
52+
Float i_StartTime,
53+
Float i_CurTime,
54+
Float i_MaxTime,
55+
RegMessage_Z* o_Value,
56+
S32& io_MsgNb,
57+
S32 i_MsgId
58+
) const {
59+
if (i_CurTime < i_StartTime) {
60+
GetValue(i_StartTime, i_MaxTime, i_MaxTime, o_Value, io_MsgNb, -1);
61+
return GetValue(0, i_CurTime, i_MaxTime, o_Value, io_MsgNb, -1);
62+
}
63+
S32 l_KeyIndex0 = -1;
64+
S32 l_KeyIndex1 = -1;
65+
S32 l_Idx;
66+
for (l_Idx = 0; l_Idx < GetNbKeys(); l_Idx++) {
67+
if (m_Keys[l_Idx].GetTime() >= i_StartTime) {
68+
l_KeyIndex0 = l_Idx;
69+
break;
70+
}
71+
}
72+
if (i_CurTime >= i_MaxTime) {
73+
l_KeyIndex1 = GetNbKeys() - 1;
74+
}
75+
else {
76+
for (l_Idx = GetNbKeys() - 1; l_Idx >= 0; l_Idx--) {
77+
if (m_Keys[l_Idx].GetTime() < i_CurTime) {
78+
l_KeyIndex1 = l_Idx;
79+
break;
80+
}
81+
}
82+
}
83+
if (l_KeyIndex1 >= 0 && l_KeyIndex0 >= 0) {
84+
const KeyMessage_Z* l_CurKey = &m_Keys[l_KeyIndex0];
85+
for (l_Idx = l_KeyIndex0; l_Idx <= l_KeyIndex1; l_Idx++, l_CurKey++) {
86+
Float l_Time = l_CurKey->GetTime();
87+
S32 l_Size = l_CurKey->m_Messages.GetSize();
88+
Message_Z* l_CurMsg = l_CurKey->m_Messages.GetArrayPtr();
89+
for (S32 l_MsgIdx = 0; l_MsgIdx < l_Size; l_MsgIdx++, l_CurMsg++) {
90+
if (i_MsgId < 0 || l_CurMsg->m_Id == i_MsgId) {
91+
o_Value[io_MsgNb] = *l_CurMsg;
92+
o_Value[io_MsgNb++].m_Time = l_Time;
93+
}
94+
}
95+
}
96+
}
97+
return l_KeyIndex1;
98+
}
99+
100+
// TODO: Finish matching
101+
S32 KeyframerMessage_Z::GetCctValue(
102+
S32 i_StartKey,
103+
S32 i_KeyCount,
104+
Float i_StartTime,
105+
Float i_CurTime,
106+
Float i_MaxTime,
107+
RegMessage_Z* o_Value,
108+
S32& io_MsgNb
109+
) const {
110+
if (i_CurTime < i_StartTime) {
111+
GetCctValue(i_StartKey, i_KeyCount, i_StartTime, i_MaxTime, i_MaxTime, o_Value, io_MsgNb);
112+
return GetCctValue(i_StartKey, i_KeyCount, 0, i_CurTime, i_MaxTime, o_Value, io_MsgNb);
113+
}
114+
S32 l_KeyIndex0 = -1;
115+
S32 l_KeyIndex1 = -1;
116+
S32 l_Idx;
117+
S32 l_LastKey = i_StartKey + i_KeyCount;
118+
for (l_Idx = i_StartKey; l_Idx < l_LastKey; l_Idx++) {
119+
if (m_Keys[l_Idx].GetTime() >= i_StartTime) {
120+
l_KeyIndex0 = l_Idx;
121+
break;
122+
}
123+
}
124+
if (i_CurTime >= i_MaxTime) {
125+
l_KeyIndex1 = i_StartKey + i_KeyCount - 1;
126+
}
127+
else {
128+
for (l_Idx = l_LastKey - 1; l_Idx >= i_StartKey; l_Idx--) {
129+
if (m_Keys[l_Idx].GetTime() < i_CurTime) {
130+
l_KeyIndex1 = l_Idx;
131+
break;
132+
}
133+
}
134+
}
135+
if (l_KeyIndex1 >= 0 && l_KeyIndex0 >= 0) {
136+
const KeyMessage_Z* l_CurKey = &m_Keys[l_KeyIndex0];
137+
for (l_Idx = l_KeyIndex0; l_Idx <= l_KeyIndex1; l_Idx++, l_CurKey++) {
138+
Float l_Time = l_CurKey->GetTime();
139+
S32 l_Size = l_CurKey->m_Messages.GetSize();
140+
Message_Z* l_CurMsg = l_CurKey->m_Messages.GetArrayPtr();
141+
for (S32 l_MsgIdx = 0; l_MsgIdx < l_Size; l_MsgIdx++, l_CurMsg++) {
142+
o_Value[io_MsgNb] = *l_CurMsg;
143+
o_Value[io_MsgNb++].m_Time = l_Time;
144+
}
145+
}
146+
}
147+
return l_KeyIndex1;
148+
}
149+
150+
// TODO: Finish matching
151+
void KeyframerMessage_Z::Load(void** i_Data) {
152+
S32 l_KeyNb;
153+
LOADDYNARRAYSIZENB_Z(m_Keys, l_KeyNb);
154+
for (S32 i = 0; i < l_KeyNb; i++) {
155+
S32 l_MsgNb;
156+
LOAD_Z(m_Keys[i].m_Time);
157+
LOAD_Z(l_MsgNb);
158+
m_Keys[i].SetNb(l_MsgNb);
159+
for (S32 j = 0; j < l_MsgNb; j++) {
160+
// TODO: Variation of LOADRANGE_Z, if it's used in many more places consider making a macro
161+
LOADBYTES_Z(&m_Keys[i].m_Messages[j].m_Id, ((U8*)&m_Keys[i].m_Messages[j].m_NameParam - (U8*)&m_Keys[i].m_Messages[j].m_Id));
162+
// Can't get it to load a ptr to the dyn array into a register (addi r6, r31, 0x4),
163+
// instead it just ends up loading the dyn array's message pointer directly (addi r0, r28, 0x8)
164+
Message_ZDA& msgs = m_Keys[i].GetMessages();
165+
gData.ClassMgr->LoadName(msgs[j].m_NameParam, i_Data);
166+
}
167+
}
168+
}
169+
170+
void KeyframerMessage_Z::MarkHandles() {
171+
S32 i;
172+
S32 j;
173+
KeyMessage_ZDA& l_Keys = GetKeys();
174+
for (i = 0; i < l_Keys.GetSize(); i++) {
175+
KeyMessage_Z& l_CurKey = l_Keys[i];
176+
for (j = 0; j < l_CurKey.GetNb(); j++) {
177+
if (l_CurKey.IsLinkHdl(j)) {
178+
gData.ClassMgr->MarkU32Handle(l_CurKey.Get(j).m_U32Param);
179+
}
180+
}
181+
}
182+
}
183+
184+
void KeyframerMessage_Z::EndLoad() {
185+
S32 i;
186+
S32 j;
187+
KeyMessage_ZDA& l_Keys = GetKeys();
188+
for (i = 0; i < l_Keys.GetSize(); i++) {
189+
KeyMessage_Z& l_CurKey = l_Keys[i];
190+
for (j = 0; j < l_CurKey.GetNb(); j++) {
191+
if (l_CurKey.IsLinkHdl(j)) {
192+
BaseObject_ZHdl l_Hdl;
193+
gData.ClassMgr->UpdateLinkFromId(l_Hdl, l_CurKey.Get(j).m_U32Param);
194+
l_CurKey.Get(j).m_U32Param = gData.ClassMgr->HandleToU32(l_Hdl);
195+
}
196+
}
197+
}
198+
}
199+
200+
void KeyframerMessage_Z::EndLinks(const ResourceObjectLink_Z& i_ResObjLink) {
201+
S32 i;
202+
S32 j;
203+
KeyMessage_ZDA& l_Keys = GetKeys();
204+
for (i = 0; i < GetNbKeys(); i++) {
205+
KeyMessage_Z& l_CurKey = l_Keys[i];
206+
for (j = 0; j < l_CurKey.GetNb(); j++) {
207+
if (l_CurKey.IsLinkHdl(j)) {
208+
BaseObject_ZHdl l_Hdl;
209+
i_ResObjLink.UpdateLinkFromId(l_Hdl, l_CurKey.Get(j).m_U32Param);
210+
l_CurKey.Get(j).m_U32Param = gData.ClassMgr->HandleToU32(l_Hdl);
211+
}
212+
}
213+
}
214+
}

src/Engine/AnimationLoad_Z.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,43 @@ void Animation_Z::Load(void** i_Data) {
1919
GetDebugName();
2020
}
2121
}
22+
23+
void Animation_Z::EndLoad() {
24+
ResourceObject_Z::EndLoad();
25+
AnimationNode_Z::EndLoad(m_NodeKfr);
26+
}
27+
28+
void Animation_Z::AfterEndLoad() {
29+
S32 i;
30+
S32 l_Nb = GetNbAnimationNode();
31+
for (i = 0; i < l_Nb; i++) {
32+
m_NodeCct[i].m_BoneID = (S16)gData.AnimMgr->GetNodeByName(m_NodeCct[i].m_BoneName);
33+
}
34+
l_Nb = GetNbAnimationMtl();
35+
for (i = 0; i < l_Nb; i++) {
36+
m_MtlCct[i].m_MtlID = (S16)gData.AnimMgr->GetMaterialByName(m_MtlCct[i].m_MtlName);
37+
}
38+
l_Nb = GetNbAnimationMesh();
39+
for (i = 0; i < l_Nb; i++) {
40+
m_MeshCct[i].m_ObjectID = (S16)gData.AnimMgr->GetMeshByName(m_MeshCct[i].m_ObjectName);
41+
}
42+
l_Nb = GetNbAnimationMorph();
43+
for (i = 0; i < l_Nb; i++) {
44+
m_MorphCct[i].m_ObjectID = (S16)gData.AnimMgr->GetMeshByName(m_MorphCct[i].m_ObjectName);
45+
}
46+
}
47+
48+
void Animation_Z::EndLoadLinks() {
49+
m_NodeKfr.m_MsgKfr.EndLinks(m_ResObjLink);
50+
}
51+
52+
void Animation_Z::Clean() {
53+
m_NodeCct.SetSize(0);
54+
m_MtlCct.SetSize(0);
55+
m_MeshCct.SetSize(0);
56+
m_MorphCct.SetSize(0);
57+
m_NodeKfr.Flush();
58+
m_MeshKfr.Flush();
59+
m_MtlKfr.Flush();
60+
m_MorphKfr.Flush();
61+
}

0 commit comments

Comments
 (0)