Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
sweat.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09000200_35C750[];
5extern Gfx D_090002C8_35C818[];
6extern Gfx D_09000390_35C8E0[];
7extern Gfx D_09000460_35C9B0[];
8
9void sweat_init(EffectInstance* effect);
10void sweat_update(EffectInstance* effect);
11void sweat_render(EffectInstance* effect);
12void sweat_appendGfx(void* effect);
13
14void sweat_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, s32 timeLeft) {
15 EffectBlueprint effectBp;
16 EffectInstance* effect;
17 SweatFXData* data;
18 Matrix4f matrix;
19 f32 temp_f2;
20 s32 numParts = 1;
21
22 effectBp.init = (void*)sweat_init;
23 effectBp.update = sweat_update;
24 effectBp.renderWorld = sweat_render;
25 effectBp.unk_00 = 0;
26 effectBp.renderUI = NULL;
27 effectBp.effectID = EFFECT_SWEAT;
28
29 effect = create_effect_instance(&effectBp);
30 effect->numParts = numParts;
31
32 data = effect->data.sweat = general_heap_malloc(numParts * sizeof(*data));
33 ASSERT(data != NULL);
34
35 data->unk_00 = arg0;
36 guRotateF(matrix, -arg5, sin_deg(gCameras[gCurrentCameraID].curYaw), 0.0f, -cos_deg(gCameras[gCurrentCameraID].curYaw));
37 temp_f2 = arg4 + 16.0f;
38 data->pos.x = arg1 + (matrix[1][0] * temp_f2);
39 data->pos.y = arg2 + (matrix[1][1] * temp_f2);
40 data->pos.z = arg3 + (matrix[1][2] * temp_f2);
41 data->unk_18 = matrix[1][0];
42 data->unk_1C = matrix[1][1];
43 data->unk_20 = matrix[1][2];
44 data->unk_10 = arg5;
45 data->timeLeft = timeLeft;
46}
47
49}
50
52 SweatFXData* data = effect->data.sweat;
53
54 data->timeLeft--;
55 if (data->timeLeft < 0) {
56 remove_effect(effect);
57 return;
58 }
59 data->pos.x += data->unk_18;
60 data->pos.y += data->unk_1C;
61 data->pos.z += data->unk_20;
62 data->unk_1C -= 0.05;
63 data->unk_18 *= 0.94;
64 if (data->unk_1C < -0.1) {
65 data->unk_1C = -0.1f;
66 }
67 data->unk_20 *= 0.94;
68}
69
71 RenderTask renderTask;
72 RenderTask* retTask;
73
74 renderTask.appendGfx = sweat_appendGfx;
75 renderTask.appendGfxArg = effect;
76 renderTask.dist = 0;
78
79 retTask = queue_render_task(&renderTask);
81}
82
83void sweat_appendGfx(void* effect) {
84 SweatFXData* data = ((EffectInstance*)effect)->data.sweat;
85 Matrix4f sp18;
86 Matrix4f sp58;
87
88 gDPPipeSync(gMainGfxPos++);
89 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
90
91 guTranslateF(sp18, data->pos.x, data->pos.y, data->pos.z);
92 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
93 guMtxCatF(sp58, sp18, sp18);
94 guRotateF(sp58, data->unk_10, 0.0f, 0.0f, 1.0f);
95 guMtxCatF(sp58, sp18, sp18);
97
98 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
99
100 if (data->unk_10 > 0.0f) {
101 gSPDisplayList(gMainGfxPos++, data->unk_00 == 0 ? D_09000200_35C750 : D_090002C8_35C818);
102 } else {
103 gSPDisplayList(gMainGfxPos++, data->unk_00 == 0 ? D_09000390_35C8E0 : D_09000460_35C9B0);
104 }
105
106 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
107}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define guRotateF
#define queue_render_task
#define guMtxF2L
#define sin_deg
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define cos_deg
#define create_effect_instance
s32 timeLeft
Definition effects.h:611
Vec3f pos
Definition effects.h:605
struct SweatFXData * sweat
Definition effects.h:2504
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
void(* renderUI)(EffectInstance *effectInst)
Definition effects.h:2655
void(* init)(EffectInstance *effectInst)
Definition effects.h:2652
void(* update)(EffectInstance *effectInst)
Definition effects.h:2653
void(* renderWorld)(EffectInstance *effectInst)
Definition effects.h:2654
void * appendGfxArg
void(* appendGfx)(void *)
Gfx D_09000200_35C750[]
void sweat_render(EffectInstance *effect)
Definition sweat.c:70
Gfx D_09000460_35C9B0[]
void sweat_init(EffectInstance *effect)
Definition sweat.c:48
Gfx D_09000390_35C8E0[]
void sweat_update(EffectInstance *effect)
Definition sweat.c:51
Gfx D_090002C8_35C818[]
void sweat_appendGfx(void *effect)
Definition sweat.c:83
void sweat_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, s32 timeLeft)
Definition sweat.c:14
Camera gCameras[4]
Definition cam_main.c:17
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
s32 gCurrentCameraID
Definition cam_math.c:4
DisplayContext * gDisplayContext
Definition cam_main.c:16