1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
|
/**
* c_lib.cpp
*
*/
#include "SSystem/SComponent/c_lib.h"
#include "string.h"
#include "SSystem/SComponent/c_math.h"
/* 8026F93C-8026F95C 26A27C 0020+00 0/0 3/3 0/0 .text cLib_memCpy__FPvPCvUl */
void cLib_memCpy(void* dst, const void* src, unsigned long size) {
memcpy(dst, src, size);
}
/* 8026F95C-8026F97C 26A29C 0020+00 0/0 4/4 0/0 .text cLib_memSet__FPviUl */
void cLib_memSet(void* dst, int value, unsigned long size) {
memset(dst, value, size);
}
/* 8026F97C-8026FA3C 26A2BC 00C0+00 0/0 50/50 178/178 .text cLib_addCalc__FPfffff */
f32 cLib_addCalc(f32* pValue, f32 target, f32 scale, f32 maxStep, f32 minStep) {
if (*pValue != target) {
f32 step = scale * (target - *pValue);
if (step >= minStep || step <= -minStep) {
if (step > maxStep) {
step = maxStep;
}
if (step < -maxStep) {
step = -maxStep;
}
*pValue += step;
} else {
if (step > 0) {
if (step < minStep) {
*pValue += minStep;
if (*pValue > target) {
*pValue = target;
}
}
} else {
minStep = -minStep;
if (step > minStep) {
*pValue += minStep;
if (*pValue < target) {
*pValue = target;
}
}
}
}
}
return fabsf(target - *pValue);
}
/* 8026FA3C-8026FA80 26A37C 0044+00 0/0 20/20 701/701 .text cLib_addCalc2__FPffff */
void cLib_addCalc2(f32* pValue, f32 target, f32 scale, f32 maxStep) {
if (*pValue != target) {
f32 step = scale * (target - *pValue);
if (step > maxStep) {
step = maxStep;
} else if (step < -maxStep) {
step = -maxStep;
}
*pValue += step;
}
}
/* 8026FA80-8026FAB8 26A3C0 0038+00 0/0 2/2 322/322 .text cLib_addCalc0__FPfff */
void cLib_addCalc0(f32* pValue, f32 scale, f32 maxStep) {
f32 step = *pValue * scale;
if (step > maxStep) {
step = maxStep;
} else if (step < -maxStep) {
step = -maxStep;
}
*pValue -= step;
}
/* 8026FAB8-8026FDF4 26A3F8 033C+00 0/0 3/3 78/78 .text cLib_addCalcPos__FP4cXyzRC4cXyzfff */
f32 cLib_addCalcPos(cXyz* pValue, cXyz const& target, f32 scale, f32 maxStep, f32 minStep) {
if (*pValue != target) {
cXyz diff = (*pValue - target);
f32 step = diff.abs();
if (step < minStep) {
*pValue = target;
} else {
step *= scale;
diff *= scale;
if (!cLib_IsZero(step)) {
if (step > maxStep) {
diff *= (maxStep / step);
} else if (step < minStep) {
diff *= (minStep / step);
}
*pValue -= diff;
} else {
*pValue = target;
}
}
}
return pValue->abs(target);
}
/* 8026FDF4-80270178 26A734 0384+00 0/0 1/1 4/4 .text cLib_addCalcPosXZ__FP4cXyzRC4cXyzfff */
f32 cLib_addCalcPosXZ(cXyz* pValue, cXyz const& target, f32 scale, f32 maxStep, f32 minStep) {
if (pValue->x != target.x || pValue->z != target.z) {
cXyz diff = (*pValue - target);
f32 step = diff.absXZ();
if (step < minStep) {
pValue->x = target.x;
pValue->z = target.z;
} else {
step *= scale;
diff *= scale;
if (!cLib_IsZero(step)) {
if (step > maxStep) {
diff *= (maxStep / step);
} else if (step < minStep) {
diff *= (minStep / step);
}
pValue->x -= diff.x;
pValue->z -= diff.z;
} else {
pValue->x = target.x;
pValue->z = target.z;
}
}
}
return (*pValue - target).absXZ();
}
/* 80270178-80270350 26AAB8 01D8+00 0/0 2/2 33/33 .text cLib_addCalcPos2__FP4cXyzRC4cXyzff */
void cLib_addCalcPos2(cXyz* pValue, cXyz const& target, f32 scale, f32 maxStep) {
if (*pValue != target) {
cXyz diff = (*pValue - target) * scale;
if (diff.abs() > maxStep) {
diff = diff.normZP();
diff *= maxStep;
}
*pValue -= diff;
}
}
/* 80270350-80270540 26AC90 01F0+00 0/0 0/0 4/4 .text cLib_addCalcPosXZ2__FP4cXyzRC4cXyzff */
void cLib_addCalcPosXZ2(cXyz* pValue, cXyz const& target, f32 scale, f32 maxStep) {
if (pValue->x != target.x || pValue->z != target.z) {
cXyz diff = (*pValue - target) * scale;
f32 step = diff.absXZ();
if (!cLib_IsZero(step)) {
if (step > maxStep) {
diff *= (maxStep / step);
}
pValue->x -= diff.x;
pValue->z -= diff.z;
}
}
}
/* 80270540-80270608 26AE80 00C8+00 0/0 81/81 244/244 .text cLib_addCalcAngleS__FPsssss
*/
s16 cLib_addCalcAngleS(s16* pValue, s16 target, s16 scale, s16 maxStep, s16 minStep) {
s16 diff = target - *pValue;
if (*pValue != target) {
s16 step = (diff) / scale;
if (step > minStep || step < -minStep) {
if (step > maxStep) {
step = maxStep;
}
if (step < -maxStep) {
step = -maxStep;
}
*pValue += step;
} else {
if (0 <= diff) {
*pValue += minStep;
diff = target - *pValue;
if (0 >= diff) {
*pValue = target;
}
} else {
*pValue -= minStep;
diff = target - *pValue;
if (0 <= diff) {
*pValue = target;
}
}
}
}
return target - *pValue;
}
/* 80270608-8027065C 26AF48 0054+00 0/0 2/2 849/849 .text cLib_addCalcAngleS2__FPssss */
void cLib_addCalcAngleS2(s16* pValue, s16 target, s16 scale, s16 maxStep) {
s16 diff = target - *pValue;
s16 step = diff / scale;
if (step > maxStep) {
*pValue += maxStep;
} else if (step < -maxStep) {
*pValue -= maxStep;
} else {
*pValue += step;
}
}
/* 8027065C-802706D0 26AF9C 0074+00 0/0 3/3 14/14 .text cLib_chaseUC__FPUcUcUc */
int cLib_chaseUC(u8* pValue, u8 target, u8 step) {
if (step) {
s16 wideValue = *pValue;
s16 wideTarget = target;
s16 wideStep;
if (wideValue > wideTarget) {
wideStep = -step;
} else {
wideStep = step;
}
wideValue += wideStep;
if (wideStep * (wideValue - wideTarget) >= 0) {
*pValue = target;
return 1;
} else {
*pValue = wideValue;
}
} else if (*pValue == target) {
return 1;
}
return 0;
}
/* 802706D0-80270740 26B010 0070+00 0/0 4/4 49/49 .text cLib_chaseS__FPsss */
int cLib_chaseS(s16* pValue, s16 target, s16 step) {
if (step) {
if (*pValue > target) {
step = -step;
}
*pValue += step;
if (step * (*pValue - target) >= 0) {
*pValue = target;
return 1;
}
} else if (*pValue == target) {
return 1;
}
return 0;
}
/* 80270740-802707AC 26B080 006C+00 0/0 70/70 448/448 .text cLib_chaseF__FPfff */
int cLib_chaseF(f32* pValue, f32 target, f32 step) {
if (step) {
if (*pValue > target) {
step = -step;
}
*pValue += step;
if (step * (*pValue - target) >= 0) {
*pValue = target;
return 1;
}
} else if (*pValue == target) {
return 1;
}
return 0;
}
/* 802707AC-80270990 26B0EC 01E4+00 0/0 3/3 60/60 .text cLib_chasePos__FP4cXyzRC4cXyzf */
int cLib_chasePos(cXyz* pValue, cXyz const& target, f32 step) {
if (step) {
cXyz diff = *pValue - target;
f32 diffF = diff.abs();
if (cLib_IsZero(diffF) || diffF <= step) {
*pValue = target;
return 1;
}
*pValue -= diff * (step / diffF);
} else if (*pValue == target) {
return 1;
}
return 0;
}
/* 80270990-80270B90 26B2D0 0200+00 0/0 1/0 19/19 .text cLib_chasePosXZ__FP4cXyzRC4cXyzf
*/
int cLib_chasePosXZ(cXyz* pValue, cXyz const& target, f32 step) {
cXyz diff = *pValue - target;
diff.y = 0;
f32 diffF = diff.absXZ();
if (step) {
if (cLib_IsZero(diffF) || diffF <= step) {
*pValue = target;
return 1;
}
*pValue -= diff * (step / diffF);
} else if (cLib_IsZero(diffF)) {
return 1;
}
return 0;
}
/* 80270B90-80270C04 26B4D0 0074+00 0/0 4/4 213/213 .text cLib_chaseAngleS__FPsss */
int cLib_chaseAngleS(s16* pValue, s16 target, s16 step) {
if (step) {
if ((s16)(*pValue - target) > 0) {
step = -step;
}
*pValue += step;
if (step * (s16)(*pValue - target) >= 0) {
*pValue = target;
return 1;
}
} else if (*pValue == target) {
return 1;
}
return 0;
}
/* 80270C04-80270C3C 26B544 0038+00 0/0 39/39 454/454 .text cLib_targetAngleY__FPC3VecPC3Vec */
s16 cLib_targetAngleY(const Vec* lhs, const Vec* rhs) {
return cM_atan2s(rhs->x - lhs->x, rhs->z - lhs->z);
}
/* 80270C3C-80270C74 26B57C 0038+00 0/0 0/0 7/7 .text cLib_targetAngleY__FRC3VecRC3Vec */
s16 cLib_targetAngleY(const Vec& lhs, const Vec& rhs) {
return cM_atan2s(rhs.x - lhs.x, rhs.z - lhs.z);
}
/* 80270C74-80270DC0 26B5B4 014C+00 0/0 2/2 109/109 .text cLib_targetAngleX__FPC4cXyzPC4cXyz */
s16 cLib_targetAngleX(cXyz const* param_0, cXyz const* param_1) {
cXyz diff = *param_1 - *param_0;
f32 f1 = sqrtf(diff.getMagXZ());
return cM_atan2s(diff.y, f1);
}
/* 80270DC0-80270E24 26B700 0064+00 0/0 2/2 118/118 .text cLib_offsetPos__FP4cXyzPC4cXyzsPC4cXyz
*/
void cLib_offsetPos(cXyz* pDest, cXyz const* pSrc, s16 angle, cXyz const* vec) {
f32 cos = cM_scos(angle);
f32 sin = cM_ssin(angle);
pDest->x = pSrc->x + (vec->x * cos + vec->z * sin);
pDest->y = pSrc->y + vec->y;
pDest->z = pSrc->z + (vec->z * cos - vec->x * sin);
}
/* 80270E24-80270E4C 26B764 0028+00 0/0 48/48 71/71 .text cLib_distanceAngleS__Fss */
s32 cLib_distanceAngleS(s16 x, s16 y) {
return abs(static_cast<s16>(x - y));
}
/* ############################################################################################## */
/* 80430DB8-80430F98 05DAD8 01E0+00 2/1 0/0 0/0 .bss mtx */
static Mtx mtx[10];
/* 80450768-80450770 -00001 0004+04 6/6 2/2 695/695 .sdata calc_mtx */
Mtx* calc_mtx = mtx;
/* 80270E4C-80270E5C 26B78C 0010+00 0/0 1/1 0/0 .text MtxInit__Fv */
void MtxInit() {
calc_mtx = mtx;
}
/* 80270E5C-80270EA4 26B79C 0048+00 0/0 0/0 43/43 .text MtxTrans__FfffUc */
void MtxTrans(f32 x_trans, f32 y_trans, f32 z_trans, u8 param_3) {
if (param_3 == 0) {
MTXTrans(*calc_mtx, x_trans, y_trans, z_trans);
} else {
Mtx mtx;
MTXTrans(mtx, x_trans, y_trans, z_trans);
MTXConcat(*calc_mtx, mtx, *calc_mtx);
}
}
/* 80270EA4-80270EEC 26B7E4 0048+00 0/0 0/0 46/46 .text MtxScale__FfffUc */
void MtxScale(f32 x_trans, f32 y_trans, f32 z_trans, u8 param_3) {
if (param_3 == 0) {
MTXScale(*calc_mtx, x_trans, y_trans, z_trans);
} else {
Mtx mtx;
MTXScale(mtx, x_trans, y_trans, z_trans);
MTXConcat(*calc_mtx, mtx, *calc_mtx);
}
}
/* 80270EEC-80270F1C 26B82C 0030+00 0/0 2/2 615/615 .text MtxPosition__FP4cXyzP4cXyz */
void MtxPosition(cXyz* src, cXyz* dest) {
MTXMultVec(*calc_mtx, src, dest);
}
/* 80270F1C-80270F58 26B85C 003C+00 0/0 0/0 20/20 .text MtxPush__Fv */
void MtxPush() {
Mtx mtx;
MTXCopy(*calc_mtx, mtx);
calc_mtx++;
MTXCopy(mtx, *calc_mtx);
}
/* 80270F58-80270F68 26B898 0010+00 0/0 0/0 20/20 .text MtxPull__Fv */
Mtx* MtxPull() {
return calc_mtx--;
}
|