Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
WaterEffects.inc.c
Go to the documentation of this file.
1#include "common.h"
2
3enum {
8};
9
10API_CALLABLE(N(UpdateAnimatedFish)) {
11 Bytecode* args = script->ptrReadPos;
12 f32 vt0 = 0.0f;
13 f32 vt1 = 0.0f;
14 f32 vt2 = 0.0f;
15 f32 vt3;
16 f32 vt4;
17
22 s32 state;
23
24 script->functionTemp[0] = state = evt_get_variable(script, *args++);
25
26 switch (state) {
27 case FISH_STATE_INIT:
28 vt0 = 142.0f;
29 vt1 = 0.0f;
30 vt2 = -118.0f;
31 script->varTable[3] = 142;
32 script->varTable[4] = 0;
33 script->varTable[5] = -118;
34 script->varTable[6] = 44;
35 script->varTable[7] = -118;
36 script->varTable[8] = 3;
37 script->varTable[9] = 0;
38 script->varTable[11] = 0;
39 script->functionTemp[0] = FISH_STATE_1;
40 break;
41 case FISH_STATE_3:
42 vt0 = 91.0f;
43 vt1 = 0.0f;
44 vt2 = -118.0f;
45 script->varTable[3] = 91;
46 script->varTable[4] = 0;
47 script->varTable[5] = -118;
48 script->varTable[6] = 91;
49 script->varTable[7] = -118;
50 script->varTable[8] = 3;
51 script->varTable[9] = 0;
52 script->varTable[11] = 0;
53 script->functionTemp[0] = FISH_STATE_1;
54 break;
55 case FISH_STATE_1:
56 script->varTable[9] += script->varTable[8];
57 if (script->varTable[9] > 45) {
58 script->varTable[9] = 45;
59 }
60 vt0 = script->varTable[3];
61 vt1 = script->varTable[4];
62 vt2 = script->varTable[5];
63 vt3 = script->varTable[6];
64 vt4 = script->varTable[7];
65 temp_f20 = vt0 * (1.0 - sin_rad(DEG_TO_RAD(script->varTable[9])));
66 vt0 = (temp_f20 + (vt3 * sin_rad(DEG_TO_RAD(script->varTable[9]))));
67 vt1 = vt1 + sin_rad(DEG_TO_RAD(script->varTable[9] * 2)) * 90.0f;
68 temp_f20_2 = vt2 * (1.0 - sin_rad(DEG_TO_RAD(script->varTable[9])));
69 vt2 = temp_f20_2 + (vt4 * sin_rad(DEG_TO_RAD(script->varTable[9])));
70 if (script->varTable[9] == 45) {
71 script->varTable[11] = 1;
72 }
73 break;
74 case FISH_STATE_2:
75 script->varTable[9] += script->varTable[8];
76 if (script->varTable[9] > 90) {
77 script->varTable[9] = 90;
78 }
79 vt0 = script->varTable[3];
80 vt1 = script->varTable[4];
81 vt2 = script->varTable[5];
82 vt3 = script->varTable[6];
83 vt4 = script->varTable[7];
84 temp_f20_3 = vt0 * (1.0 - sin_rad(DEG_TO_RAD(script->varTable[9])));
85 vt0 = (temp_f20_3 + (vt3 * sin_rad(DEG_TO_RAD(script->varTable[9]))));
86 vt1 = vt1 + sin_rad(DEG_TO_RAD(script->varTable[9] * 2)) * 90.0f;
87 temp_f20_4 = vt2 * (1.0 - sin_rad(DEG_TO_RAD(script->varTable[9])));
88 vt2 = temp_f20_4 + (vt4 * sin_rad(DEG_TO_RAD(script->varTable[9])));
89 if (script->varTable[9] == 90) {
90 script->varTable[11] = 2;
91 }
92 break;
93 }
94 script->varTable[0] = vt0;
95 script->varTable[1] = vt1;
96 script->varTable[2] = vt2;
97 return ApiStatus_DONE2;
98}
99
101 Set(LVarA, LVar0)
102 Label(0)
105 Call(RotateModel, LVarA, -20, 0, 0, 1)
106 Wait(1)
107 Loop(0)
110 Call(RotateModel, LVarA, -20, 0, 0, 1)
111 Wait(1)
112 IfEq(LVarB, 1)
114 EndIf
115 EndLoop
117 Call(RotateModel, LVarA, -7, 0, 0, 1)
118 Wait(5)
120 Call(RotateModel, LVarA, -27, 0, 0, 1)
121 Wait(2)
123 Call(RotateModel, LVarA, -5, 0, 0, 1)
124 Wait(3)
126 Call(RotateModel, LVarA, -20, 0, 0, 1)
127 Wait(5)
128 Loop(0)
131 Call(RotateModel, LVarA, -20, 0, 0, 1)
132 Wait(1)
133 IfEq(LVarB, 2)
135 EndIf
136 EndLoop
137 Call(RandInt, 80, LVarB)
138 Add(LVarB, 30)
139 Loop(LVarB)
141 Call(RotateModel, LVarA, -20, 0, 0, 1)
142 Wait(1)
143 EndLoop
144 Call(RandInt, 5, LVar0)
145 IfNe(LVar0, 0)
146 Goto(0)
147 EndIf
150 Call(RotateModel, LVarA, -20, 0, 0, 1)
151 Wait(1)
152 Loop(0)
155 Call(RotateModel, LVarA, -20, 0, 0, 1)
156 Wait(1)
157 IfEq(LVarB, 1)
159 EndIf
160 EndLoop
162 Call(RotateModel, LVarA, -7, 0, 0, 1)
163 Wait(5)
165 Call(RotateModel, LVarA, -27, 0, 0, 1)
166 Wait(2)
168 Call(RotateModel, LVarA, -5, 0, 0, 1)
169 Wait(3)
171 Call(RotateModel, LVarA, -20, 0, 0, 1)
172 Wait(5)
173 Loop(0)
176 Call(RotateModel, LVarA, -20, 0, 0, 1)
177 Wait(1)
178 IfEq(LVarB, 2)
180 EndIf
181 EndLoop
182 Call(RandInt, 80, LVarB)
183 Add(LVarB, 30)
184 Loop(LVarB)
186 Call(RotateModel, LVarA, -20, 0, 0, 1)
187 Wait(1)
188 EndLoop
189 Goto(0)
190 Return
191 End
192};
193
195 Set(LVarA, LVar0)
196 Loop(0)
197 Call(TranslateModel, LVarA, 1, 0, 0)
198 Wait(2)
199 Call(TranslateModel, LVarA, 1, 0, 0)
200 Wait(2)
201 Call(TranslateModel, LVarA, 1, -1, 0)
202 Wait(2)
203 Call(TranslateModel, LVarA, 2, -1, 0)
204 Wait(2)
205 Call(TranslateModel, LVarA, 2, -1, 0)
206 Wait(2)
207 Call(TranslateModel, LVarA, 2, -1, 0)
208 Wait(2)
209 Call(TranslateModel, LVarA, 3, -2, 0)
210 Wait(2)
211 Call(TranslateModel, LVarA, 3, -2, 0)
212 Wait(2)
213 Call(TranslateModel, LVarA, 3, -3, 0)
214 Wait(2)
215 Call(TranslateModel, LVarA, 3, -3, 0)
216 Wait(2)
217 Call(TranslateModel, LVarA, 3, -3, 0)
218 Wait(2)
219 Call(TranslateModel, LVarA, 3, -2, 0)
220 Wait(2)
221 Call(TranslateModel, LVarA, 2, -2, 0)
222 Wait(2)
223 Call(TranslateModel, LVarA, 2, -1, 0)
224 Wait(2)
225 Call(TranslateModel, LVarA, 1, 0, 0)
226 Wait(2)
227 Call(TranslateModel, LVarA, 1, 1, 0)
228 Wait(2)
229 Call(TranslateModel, LVarA, 0, 1, 0)
230 Wait(2)
231 Call(TranslateModel, LVarA, -1, 1, 0)
232 Wait(2)
233 Call(TranslateModel, LVarA, -1, 1, 0)
234 Wait(2)
235 Call(TranslateModel, LVarA, -1, 0, 0)
236 Wait(2)
237 Call(TranslateModel, LVarA, -1, 0, 0)
238 Wait(2)
239 Call(TranslateModel, LVarA, 0, 0, 0)
240 Wait(2)
241 EndLoop
242 Return
243 End
244};
245
247 0, -1, -1, -2, -2, -3, -5, -8,
248 -8, -7, -6, -4, -2, -1, 0, 255,
249};
250
252 Set(LVarA, LVar0) // modelID
253 Set(LVarB, LVar1)
254 Set(LVar5, 5)
256 Label(0)
257 // drift along from left to right
259 IfEq(LVar1, 255)
262 EndIf
263 Set(LVar0, LVar5)
265 Wait(1)
266 Add(LVar5, 1)
267 Set(LVarC, LVarB)
268 Sub(LVarC, 20)
270 Goto(1)
271 EndIf
272 Set(LVar0, LVar5)
274 Wait(1)
275 Add(LVar5, 1)
276 Set(LVarC, LVarB)
277 Sub(LVarC, 20)
279 Goto(1)
280 EndIf
281 Goto(0)
282 Label(1)
283 // fall down
284 Set(LVar2, 0)
285 Loop(20)
286 Add(LVar5, 1)
287 Sub(LVar1, 2)
288 Set(LVar0, LVar5)
290 Wait(1)
291 EndLoop
292 // reset to left side of stage
293 Sub(LVar5, 280)
294 Set(LVar1, 0)
295 Goto(0)
296 Return
297 End
298};
299
301 Set(LVarA, LVar0)
302 Loop(0)
303 Call(TranslateModel, LVarA, 0, 0, 0)
304 Wait(2)
305 Call(TranslateModel, LVarA, 0, 0, 0)
306 Wait(2)
307 Call(TranslateModel, LVarA, 0, -1, 0)
308 Wait(2)
309 Call(TranslateModel, LVarA, 0, -1, 0)
310 Wait(2)
311 Call(TranslateModel, LVarA, 0, -1, 0)
312 Wait(2)
313 Call(TranslateModel, LVarA, 0, -1, 0)
314 Wait(2)
315 Call(TranslateModel, LVarA, 0, -2, 0)
316 Wait(2)
317 Call(TranslateModel, LVarA, 0, -2, 0)
318 Wait(2)
319 Call(TranslateModel, LVarA, 0, -3, 0)
320 Wait(2)
321 Call(TranslateModel, LVarA, 0, -3, 0)
322 Wait(2)
323 Call(TranslateModel, LVarA, 0, -3, 0)
324 Wait(2)
325 Call(TranslateModel, LVarA, 0, -2, 0)
326 Wait(2)
327 Call(TranslateModel, LVarA, 0, -2, 0)
328 Wait(2)
329 Call(TranslateModel, LVarA, 0, -1, 0)
330 Wait(2)
331 Call(TranslateModel, LVarA, 0, 0, 0)
332 Wait(2)
333 Call(TranslateModel, LVarA, 0, 1, 0)
334 Wait(2)
335 Call(TranslateModel, LVarA, 0, 1, 0)
336 Wait(2)
337 Call(TranslateModel, LVarA, 0, 1, 0)
338 Wait(2)
339 Call(TranslateModel, LVarA, 0, 1, 0)
340 Wait(2)
341 Call(TranslateModel, LVarA, 0, 0, 0)
342 Wait(2)
343 Call(TranslateModel, LVarA, 0, 0, 0)
344 Wait(2)
345 Call(TranslateModel, LVarA, 0, 0, 0)
346 Wait(2)
347 EndLoop
348 Return
349 End
350};
BSS s32 PopupMenu_SelectedIndex
@ FISH_STATE_1
@ FISH_STATE_2
@ FISH_STATE_INIT
@ FISH_STATE_3
Bytecode EvtScript[]
#define ApiStatus_DONE2
Definition evt.h:119
s32 Bytecode
Definition evt.h:7
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1730
f32 sin_rad(f32 x)
Definition 43F0.c:713
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 Ref(sym)
Address/pointer constant.
Definition macros.h:61
#define Set(VAR, INT_VALUE)
Sets the given variable to a given value casted to an integer.
Definition macros.h:366
#define Sub(VAR, INT_VALUE)
Definition macros.h:378
#define IfNe(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR != RVAR.
Definition macros.h:273
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
Definition macros.h:214
#define UseBuf(INT_PTR)
Loads a s32 pointer for use with subsequent EVT_BUF_READ commands.
Definition macros.h:390
#define Add(VAR, INT_VALUE)
Definition macros.h:377
#define EndLoop
Marks the end of a loop.
Definition macros.h:249
#define Goto(LABEL_ID)
Moves execution to the given label.
Definition macros.h:233
#define LVarC
Definition macros.h:161
#define BufRead1(VAR)
Consumes the next s32 from the buffer and stores it in the given variable.
Definition macros.h:393
#define IfGt(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR <= RVAR.
Definition macros.h:279
#define Label(LABEL_ID)
Marks this point in the script as a Goto target.
Definition macros.h:228
#define EndIf
Marks the end of an if statement or an else block.
Definition macros.h:299
#define LVar5
Definition macros.h:154
#define LVarB
Definition macros.h:160
#define BreakLoop
Breaks out of the innermost loop.
Definition macros.h:252
#define LVar2
Definition macros.h:151
#define DEG_TO_RAD(deg)
Definition macros.h:145
#define LVar1
Definition macros.h:150
#define LVarA
Definition macros.h:159
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
Definition macros.h:255
#define IfEq(LVAR, RVAR)
Marks the beginning of an if statement that only executes if LVAR == RVAR.
Definition macros.h:270
#define Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
Definition macros.h:577
#define Loop(TIMES)
Marks the beginning of a loop.
Definition macros.h:246
#define LVar0
Definition macros.h:149
#define Return
Kills the current EVT thread.
Definition macros.h:218