Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
Snowflakes.inc.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects.h"
3
4u16 N(StarAnimPhases)[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
5
6// unused
7void N(build_gfx_star)(s32 index) {
8 Vtx* firstVertex;
9 Vtx* copiedVertices;
10 s32 numVertices;
11 s32 i;
12 s32 temp3;
13
14 mdl_get_copied_vertices(index, &firstVertex, &copiedVertices, &numVertices);
15
16 for (i = 0; i < numVertices; i++) {
17 Vtx* vtx = &copiedVertices[i];
18 s16 temp1 = (sins(N(StarAnimPhases)[index] * (i % 3 + 1) + i) + 0x8000) / 2;
19 s32 temp2 = temp1 * 155;
20 vtx->v.cn[2] = temp2 / 0x8000 + 100;
21 vtx->v.cn[1] = temp2 / 0x8000 + 50;
22
23 temp3 = sins(N(StarAnimPhases)[index] / 0x8000 * (((i / 2) % 3 + 1) << 15) + N(StarAnimPhases)[index] / 0x4000 * 0x8000 + i) + 0x8000;
24 vtx->v.cn[0] = vtx->v.cn[0] * temp3 / 0x10000;
25 }
26
27 gSPDisplayList(gMainGfxPos++, mdl_get_copied_gfx(index));
28 N(StarAnimPhases)[index] += 0x253;
29}
30
31API_CALLABLE(N(SpawnSnowfall)) {
32 fx_snowfall(0, 16);
33 return ApiStatus_DONE2;
34}
35
36API_CALLABLE(N(GetSnowflakePosition)) {
37 Bytecode* args = script->ptrReadPos;
38 s32 phase = evt_get_variable(script, *args++);
39 s32 posXInOut = *args++;
40 s32 posYInOut = *args++;
41 s32 posZInOut = *args++;
42 f32 posY = sin_rad(DEG_TO_RAD(phase / 10) * 8.0f) * 10.0f;
43
44 evt_set_variable(script, posXInOut, 0);
45 evt_set_variable(script, posYInOut, posY);
46 evt_set_variable(script, posZInOut, 0);
47
48 return ApiStatus_DONE2;
49}
50
51EvtScript N(EVS_SpawnSnowfall) = {
52 Call(N(SpawnSnowfall))
53 Loop(0)
54 Wait(1)
56 Return
57 End
58};
59
60EvtScript N(EVS_RandomlySpinSnowflake) = {
62 Label(0)
63 Call(RandInt, 30, LVar0)
64 Add(LVar0, 30)
65 Wait(LVar0)
66 Set(LVar1, 0)
67 Loop(10)
68 Add(LVar1, 36)
69 Call(RotateModel, LVarA, LVar1, 0, 1, 0)
70 Wait(1)
72 Goto(0)
73 Return
74 End
75};
76
77EvtScript N(EVS_AnimateHangingSnowflake_RandomSpin) = {
78 Set(LVarA, LVar0) // modelID
80 Exec(N(EVS_RandomlySpinSnowflake))
81 Set(LVar7, 0)
82 Label(0)
83 Add(LVar7, 4)
84 IfGt(LVar7, 3599)
85 Sub(LVar7, 3600)
86 EndIf
87 Call(N(GetSnowflakePosition), LVar7, LVar0, LVar1, LVar2)
89 Wait(1)
90 Goto(0)
91 Return
92 End
93};
94
95EvtScript N(EVS_AnimateHangingSnowflake_NoSpin) = {
97 Set(LVar7, 0)
98 Label(0)
99 Add(LVar7, 4)
100 IfGt(LVar7, 3599)
101 Sub(LVar7, 3600)
102 EndIf
103 Call(N(GetSnowflakePosition), LVar7, LVar0, LVar1, LVar2)
105 Wait(1)
106 Goto(0)
107 Return
108 End
109};
void N build_gfx_star(s32 index)
Bytecode EvtScript[]
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
Gfx * mdl_get_copied_gfx(s32 copyIndex)
Definition model.c:4086
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
Definition evt.c:1847
f32 sin_rad(f32 x)
Definition 43F0.c:713
void mdl_get_copied_vertices(s32 copyIndex, Vtx **firstVertex, Vtx **copiedVertices, s32 *numCopied)
Definition model.c:4077
ApiStatus TranslateModel(Evt *script, b32 isInitialCall)
Translates the given model's position.
ApiStatus RotateModel(Evt *script, b32 isInitialCall)
Rotates the model the given amount on the selected axis.
ApiStatus RandInt(Evt *script, b32 isInitialCall)
#define Set(VAR, INT_VALUE)
Sets the given variable to a given value casted to an integer.
Definition macros.h:365
#define Sub(VAR, INT_VALUE)
Definition macros.h:377
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
Definition macros.h:213
#define Add(VAR, INT_VALUE)
Definition macros.h:376
#define EndLoop
Marks the end of a loop.
Definition macros.h:248
#define Goto(LABEL_ID)
Moves execution to the given label.
Definition macros.h:232
#define IfGt(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR <= RVAR.
Definition macros.h:278
#define Label(LABEL_ID)
Marks this point in the script as a Goto target.
Definition macros.h:227
#define EndIf
Marks the end of an if statement or an else block.
Definition macros.h:298
#define LVarB
Definition macros.h:159
#define LVar7
Definition macros.h:155
#define LVar2
Definition macros.h:150
#define DEG_TO_RAD(deg)
Definition macros.h:134
#define LVar1
Definition macros.h:149
#define LVarA
Definition macros.h:158
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
Definition macros.h:254
#define Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
Definition macros.h:576
#define Loop(TIMES)
Marks the beginning of a loop.
Definition macros.h:245
#define LVar0
Definition macros.h:148
#define Exec(EVT_SOURCE)
Launches a new thread.
Definition macros.h:455
#define Return
Kills the current EVT thread.
Definition macros.h:217
Gfx * gMainGfxPos
Definition cam_main.c:15