Skip to content

Commit 53907d3

Browse files
authored
A few matches (bfbbdecomp#462)
* Match parse_tag_var * Match zNPCCommon::SndIsAnyPlaying * Match xNPCBasic::Reset * Couple more * Match xEntMotionInit * Match xEntMechForward
1 parent c2d6858 commit 53907d3

File tree

9 files changed

+201
-81
lines changed

9 files changed

+201
-81
lines changed

src/SB/Core/gc/iTRC.cpp

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -73,71 +73,69 @@ void ROMFont::DrawTextBox(int, int, int, int, char*)
7373

7474
}
7575

76-
77-
78-
int ResetButton::EnableReset()
79-
{
80-
return ResetButton::mResetEnabled = 1;
76+
void ResetButton::EnableReset()
77+
{
78+
ResetButton::mResetEnabled = 1;
8179
}
8280

83-
int ResetButton::DisableReset()
84-
{
85-
return ResetButton::mResetEnabled = 0;
81+
void ResetButton::DisableReset()
82+
{
83+
ResetButton::mResetEnabled = 0;
8684
}
8785

8886
void ResetButton::SetSndKillFunction(void (*Func)())
8987
{
90-
88+
ResetButton::mSndKill = Func;
9189
}
9290

9391
void ResetButton::CheckResetButton()
9492
{
95-
93+
9694
}
9795

9896
bool iTRCDisk::Init(void)
9997
{
100-
bool RFInit = ROMFont::Init();
101-
return RFInit;
98+
return ROMFont::Init();
10299
}
103100

104-
void iTRCDisk::SetErrorMessage(const char*)
101+
void iTRCDisk::SetErrorMessage(const char* message)
105102
{
106-
103+
strcpy(mMessage, message);
107104
}
108105

109106
void iTRCDisk::ResetMessage()
110107
{
108+
memset(mMessage, 0, 0x100);
111109
}
112110

113-
void iTRCDisk::SetPadStopRumblingFunction(void (*)(void))
111+
void iTRCDisk::SetPadStopRumblingFunction(void (*Func)())
114112
{
115-
113+
mPadStopRumbling = Func;
116114
}
117115

118-
void iTRCDisk::SetSndSuspendFunction(void (*)(void))
116+
void iTRCDisk::SetSndSuspendFunction(void (*Func)())
119117
{
120-
118+
mSndSuspend = Func;
121119
}
122120

123-
void iTRCDisk::SetSndResumeFunction(void (*)(void))
121+
void iTRCDisk::SetSndResumeFunction(void (*Func)())
124122
{
125-
123+
mSndResume = Func;
126124
}
127125

128-
void iTRCDisk::SetSndKillFunction(void (*)(void))
126+
void iTRCDisk::SetSndKillFunction(void (*Func)())
129127
{
130-
128+
mSndKill = Func;
131129
}
132130

133-
void iTRCDisk::SetMovieSuspendFunction(void (*)(void))
131+
void iTRCDisk::SetMovieSuspendFunction(void (*Func)())
134132
{
135-
133+
mMovieSuspendFunction = Func;
136134
}
137135

138-
void iTRCDisk::SetMovieResumeFunction(void (*)(void))
136+
void iTRCDisk::SetMovieResumeFunction(void (*Func)())
139137
{
140-
138+
mMovieResumeFunction = Func;
141139
}
142140

143141
bool iTRCDisk::IsDiskIDed()
@@ -147,7 +145,7 @@ bool iTRCDisk::IsDiskIDed()
147145

148146
void iTRCDisk::DisplayErrorMessage()
149147
{
150-
148+
151149
}
152150

153151
void iTRCDisk::SetDVDState()

src/SB/Core/gc/iTRC.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ namespace ROMFont
2828
// Yes, this is a namespace, not a class.
2929
namespace iTRCDisk
3030
{
31+
char mMessage[];
32+
void (*mPadStopRumbling)();
33+
void (*mSndSuspend)();
34+
void (*mSndResume)();
35+
void (*mSndKill)();
36+
void (*mMovieSuspendFunction)();
37+
void (*mMovieResumeFunction)();
38+
3139
void SetPadStopRumblingFunction(void (*)(void));
3240
void SetSndSuspendFunction(void (*)(void));
3341
void SetSndResumeFunction(void (*)(void));
@@ -41,14 +49,15 @@ namespace iTRCDisk
4149
void SetDVDState();
4250
void SetErrorMessage(const char*);
4351
bool IsDiskIDed();
44-
char mMessage();
4552
} // namespace iTRCDisk
4653

4754
namespace ResetButton
4855
{
49-
int EnableReset();
50-
int mResetEnabled;
51-
int DisableReset();
56+
bool mResetEnabled;
57+
void (*mSndKill)();
58+
59+
void EnableReset();
60+
void DisableReset();
5261
void SetSndKillFunction(void (*func)());
5362
void CheckResetButton();
5463

src/SB/Core/x/xEntMotion.cpp

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "xEntMotion.h"
2+
#include "xMath.h"
23

34
#include <types.h>
45

@@ -12,3 +13,148 @@ void xMat3x3RMulVec(xVec3* o, const xMat3x3* m, const xVec3* v)
1213
o->y = y;
1314
o->z = z;
1415
}
16+
17+
// Artificial
18+
enum en_MOTIONTYPE
19+
{
20+
MOTION_TYPE_EXRT,
21+
MOTION_TYPE_ORBT,
22+
MOTION_TYPE_SPLN,
23+
MOTION_TYPE_MVPT,
24+
MOTION_TYPE_MECH,
25+
MOTION_TYPE_PEND
26+
};
27+
28+
void xEntMotionInit(xEntMotion* a, xEnt* b, xEntMotionAsset* c)
29+
{
30+
a->asset = c;
31+
a->type = c->type;
32+
a->flags = c->flags;
33+
34+
if (a->type == MOTION_TYPE_EXRT)
35+
{
36+
xVec3Copy(&a->er.a, &c->er.ret_pos);
37+
xVec3Add(&a->er.b, &c->er.ret_pos, &c->er.ext_dpos);
38+
39+
a->er.et = c->er.ext_tm;
40+
a->er.wet = c->er.ext_wait_tm;
41+
a->er.rt = c->er.ret_tm;
42+
a->er.wrt = c->er.ret_wait_tm;
43+
44+
if (a->er.p <= 0)
45+
{
46+
a->er.p = 10.0f;
47+
}
48+
49+
a->er.brt = a->er.et + a->er.wet;
50+
a->er.ert = a->er.brt + a->er.rt;
51+
a->er.p = a->er.ert + a->er.wrt;
52+
}
53+
else if (a->type == MOTION_TYPE_ORBT)
54+
{
55+
xVec3Copy((xVec3*)(&a->er.b), &c->er.ret_pos);
56+
57+
a->orb.a = c->orb.w;
58+
a->orb.b = c->orb.h;
59+
60+
if (c->orb.period <= 0.0f)
61+
{
62+
c->orb.period = 10.0f;
63+
}
64+
65+
a->orb.p = c->orb.period;
66+
a->orb.w = (2 * PI) / c->orb.period;
67+
}
68+
else if (a->type == MOTION_TYPE_MVPT)
69+
{
70+
// literally nothing
71+
}
72+
else if (a->type == MOTION_TYPE_PEND)
73+
{
74+
if (c->pen.period <= 1e-5f)
75+
{
76+
c->pen.period = 0;
77+
}
78+
79+
a->pen.w = (2 * PI) / c->pen.period;
80+
}
81+
else if (a->type == MOTION_TYPE_MECH)
82+
{
83+
if (c->mp.speed < 1e-5f)
84+
{
85+
c->mp.speed = 0;
86+
}
87+
88+
if (c->mech.sld_acc_tm + c->mech.sld_dec_tm > c->mech.sld_tm)
89+
{
90+
c->mech.sld_dec_tm =
91+
c->mech.sld_acc_tm =
92+
c->mech.sld_tm * 0.5f;
93+
}
94+
95+
if (c->mech.rot_tm < 3.0f)
96+
{
97+
c->mech.rot_tm = 1.0f;
98+
}
99+
100+
if (c->mech.type == 2)
101+
{
102+
if ( c->mech.rot_tm != c->mech.sld_tm )
103+
{
104+
c->mech.rot_tm = c->mech.sld_tm;
105+
}
106+
}
107+
if (c->mech.rot_acc_tm + c->mech.rot_dec_tm > c->mech.rot_tm)
108+
{
109+
c->mech.rot_dec_tm =
110+
c->mech.rot_acc_tm =
111+
c->mech.rot_tm * 0.5f;
112+
}
113+
}
114+
115+
a->owner = b;
116+
a->target = NULL;
117+
118+
xEntMotionDebugAdd(a);
119+
}
120+
121+
void xEntMechForward(xEntMotion* motion)
122+
{
123+
xEntMotionMechData* mech = &(motion->asset->mech);
124+
xEntMotionAsset* mkasst = motion->asset;
125+
126+
xEntMotionRun(motion);
127+
128+
if ((motion->mech.state != 0) && (motion->mech.state != 1) && (motion->mech.state != 2))
129+
{
130+
if (motion->mech.state == 3)
131+
{
132+
motion->mech.ss = -motion->mech.ss;
133+
motion->mech.sr = -motion->mech.sr;
134+
motion->tmr = mkasst->mech.sld_tm - motion->tmr;
135+
motion->mech.state = 0;
136+
}
137+
else if (motion->mech.state == 4)
138+
{
139+
motion->mech.ss = -motion->mech.ss;
140+
motion->mech.sr = -motion->mech.sr;
141+
motion->tmr = mkasst->mech.rot_tm - motion->tmr;
142+
motion->mech.state = 1;
143+
}
144+
else if ((motion->mech.state != 5) && (motion->mech.state != 6) && (motion->mech.state == 7))
145+
{
146+
motion->mech.ss = -motion->mech.ss;
147+
motion->mech.sr = -motion->mech.sr;
148+
motion->tmr = 0.0f;
149+
150+
if ((mech->type == 0) || (mech->type == 2) || (mech->type == 4))
151+
{
152+
motion->mech.state = 0;
153+
}
154+
else
155+
{
156+
motion->mech.state = 1;
157+
}
158+
}
159+
}
160+
}

src/SB/Core/x/xEntMotion.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ void xEntMotionReset(xEntMotion* motion, xScene* sc);
174174
void xEntMotionMove(xEntMotion* motion, xScene* sc, F32 dt, xEntFrame* frame);
175175
void xEntMotionTranslate(xEntMotion* motion, const xVec3* dpos, xMat4x3* dmat);
176176
void xEntMotionDebugInit(U16 num_xems);
177+
void xEntMotionDebugAdd(xEntMotion*);
177178
void xEntMotionDebugExit();
178179
void xEntMotionStop(xEntMotion* motion);
179180
void xEntMotionRun(xEntMotion* motion);

src/SB/Core/x/xNPCBasic.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,32 +103,23 @@ void xNPCBasic::Init(xEntAsset* asset)
103103
baseFlags &= 0xffef;
104104
}
105105

106-
// Register assignment in the floating point instructions is slightly wrong.
107106
void xNPCBasic::Reset()
108107
{
109108
xEntReset(this);
110109
DBG_PStatClear();
111110
if (!(U32(flags1.flg_basenpc) & 0x2))
112111
{
113112
xVec3Copy(&frame->drot.axis, &g_Y3);
114-
frame->drot.angle = xNPCBasic_float_0;
113+
frame->drot.angle = 0.0f;
115114
xVec3Copy(&frame->rot.axis, &g_Y3);
116115
frame->rot.angle = asset->ang.x;
117116
}
118117

119118
flags1.flg_basenpc |= 4;
120119
colFreq = -1;
121120

122-
F32 f1 = xurand();
123-
F32 f0 = xNPCBasic_float_onehalf;
124-
F32 f2 = xNPCBasic_float_onequarter;
125-
f1 -= f0;
126-
f0 = xNPCBasic_float_15;
127-
f1 = f2 * f1;
128-
f0 = f0 * f1 + f0;
129-
colFreqReset = (S32)f0;
121+
colFreqReset = (15.0f * (0.25f * (xurand() - 0.5f))) + 15.0f;
130122
RestoreColFlags();
131-
return;
132123
}
133124

134125
void NPC_alwaysUseSphere(xEnt* ent, xVec3* value)

src/SB/Core/x/xString.cpp

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "xString.h"
2+
#include "xMath.h"
23

34
#include <types.h>
45

@@ -76,24 +77,13 @@ U32 tolower__21_esc__2_unnamed_esc__2_xString_cpp_esc__2_Fi(U32 param_1)
7677
}
7778
}
7879

79-
/*
80-
// Non-matching
8180
S32 icompare(const substr& s1, const substr& s2)
8281
{
83-
S32 result;
84-
U32 len;
85-
86-
len = s2.size;
87-
88-
if (s1.size < s2.size)
89-
{
90-
len = s1.size;
91-
}
92-
93-
result = imemcmp(s1.text, s2.text, len);
94-
95-
if (result == 0)
82+
U32 len = MIN(s1.size, s2.size);
83+
S32 result = imemcmp(s1.text, s2.text, len);
84+
switch (result)
9685
{
86+
case 0:
9787
if (s1.size == s2.size)
9888
{
9989
result = 0;
@@ -106,7 +96,7 @@ S32 icompare(const substr& s1, const substr& s2)
10696
result = -1;
10797
}
10898
}
99+
break;
109100
}
110101
return result;
111102
}
112-
*/

src/SB/Game/zNPCSpawner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ st_XORDEREDARRAY* zNPCSpawner::FillPending()
175175
{
176176
ClearPending();
177177
ReFillPending();
178-
return &this->actvlist;
178+
return (st_XORDEREDARRAY*)this->pendlist.cnt;
179179
}
180180

181181
st_XORDEREDARRAY* zNPCSpawner::ReFillPending()

0 commit comments

Comments
 (0)