Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
CosInterpMinMax.inc.c
Go to the documentation of this file.
1#include "common.h"
2#include "npc.h"
3
4API_CALLABLE(N(CosInterpMinMax)) {
5 Bytecode* args = script->ptrReadPos;
6 s32 outVarTime = *args++;
7 s32 time = evt_get_variable(script, outVarTime);
8 s32 outValue = *args++;
9 f32 min = evt_get_float_variable(script, *args++);
10 f32 max = evt_get_float_variable(script, *args++);
11 s32 duration = evt_get_variable(script, *args++);
12 s32 onlyOnce = evt_get_variable(script, *args++);
13 f32 phaseOffset = (evt_get_float_variable(script, *args++) / 180.0f) * PI;
14 f32 delta = (max - min) / 2;
15
16 if (onlyOnce && duration < time) {
17 time = duration;
18 evt_set_variable(script, outVarTime, duration);
19 }
20
21 evt_set_float_variable(script, outValue,
22 (min + delta) // average value
23 - (delta * cos_rad(((time * PI) / duration) + phaseOffset))); // perturbation
24
25 return ApiStatus_DONE2;
26}
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
f32 evt_set_float_variable(Evt *script, Bytecode var, f32 value)
Definition evt.c:1977
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
Definition evt.c:1847
f32 cos_rad(f32 x)
Definition 43F0.c:717
f32 evt_get_float_variable(Evt *script, Bytecode var)
Definition evt.c:1930
#define PI
Definition macros.h:126