Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
quizmo_assistant.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09002400_409480[];
5extern Gfx D_09002528_4095A8[];
6extern Gfx D_090025B8_409638[];
7extern Gfx D_09002648_4096C8[];
8extern Gfx D_090026D8_409758[];
9extern Gfx D_090027F0_409870[];
10
15
17
18s32 D_E011C518[] = { 1, 1, 2, 2, 2 };
19s32 D_E011C52C[] = { 3, 3, 4, 4 };
20
24void quizmo_assistant_appendGfx(void* effect);
25
26EffectInstance* quizmo_assistant_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5) {
28 EffectInstance* effect;
30 s32 numParts = 1;
31
35 bp.unk_00 = 0;
36 bp.renderUI = NULL;
37 bp.effectID = EFFECT_QUIZMO_ASSISTANT;
38
39 effect = create_effect_instance(&bp);
40 effect->numParts = numParts;
41 data = effect->data.quizmoAssistant = general_heap_malloc(numParts * sizeof(*data));
42 ASSERT(effect->data.quizmoAssistant != NULL);
43
44 data->unk_00 = arg0;
45 data->lifetime = 0;
46 if (arg5 <= 0) {
47 data->vanishTimer = 1000;
48 } else {
49 data->vanishTimer = arg5;
50 }
51 data->fadeInAmt = 255;
52 data->pos.x = arg1;
53 data->pos.y = arg2;
54 data->pos.z = arg3;
55 data->anim = 0;
56
57 return effect;
58}
59
62
65
66 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
67 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
68 data->vanishTimer = 16;
69 }
70
71 if (data->vanishTimer < 1000) {
72 data->vanishTimer--;
73 }
74
75 data->lifetime++;
76
77 if (data->vanishTimer < 0) {
78 remove_effect(effect);
79 return;
80 }
81
82 if (data->vanishTimer < 16) {
83 data->fadeInAmt = data->vanishTimer * 16;
84 }
85}
86
88 RenderTask renderTask;
89 RenderTask* retTask;
90
92 renderTask.appendGfxArg = effect;
93 renderTask.dist = 10;
95
96 retTask = queue_render_task(&renderTask);
98}
99
100void quizmo_assistant_appendGfx(void* effect) {
101 QuizmoAssistantFXData* data = ((EffectInstance*)effect)->data.quizmoAssistant;
102 s32 lifetime = data->lifetime;
103 s32 fadeInAmt = data->fadeInAmt;
104 s32 idx;
105 Matrix4f sp18;
106 Matrix4f sp58;
107
108 gDPPipeSync(gMainGfxPos++);
109 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
110
111 guTranslateF(sp18, data->pos.x, data->pos.y, data->pos.z);
112 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
113 guMtxCatF(sp58, sp18, sp18);
114 guTranslateF(sp58, 89.5f, 0.0f, 2.0f);
115 guMtxCatF(sp58, sp18, sp18);
116 guScaleF(sp58, 5.0f / 7, 5.0f / 7, 5.0f / 7);
117 guMtxCatF(sp58, sp18, sp18);
119
120 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
121 gDPSetPrimColor(gMainGfxPos++, 0, 0, fadeInAmt, fadeInAmt, fadeInAmt, 255);
122 gSPDisplayList(gMainGfxPos++, D_E011C514[0]);
123
124 switch (data->anim) {
125 case 0:
126 idx = 0;
127 break;
128 case 1:
129 idx = D_E011C518[lifetime % ARRAY_COUNT(D_E011C518)];
130 break;
131 case 2:
132 default:
133 idx = D_E011C52C[lifetime % ARRAY_COUNT(D_E011C52C)];
134 break;
135 }
136
137 gSPDisplayList(gMainGfxPos++, D_E011C500[idx]);
138 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
139 gDPPipeSync(gMainGfxPos++);
140}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define guRotateF
#define queue_render_task
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define create_effect_instance
#define guScaleF
struct QuizmoAssistantFXData * quizmoAssistant
Definition effects.h:2592
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
EffectInstance * quizmo_assistant_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5)
Gfx D_090025B8_409638[]
Gfx D_09002400_409480[]
Gfx * D_E011C514[]
void quizmo_assistant_appendGfx(void *effect)
Gfx D_09002648_4096C8[]
s32 D_E011C52C[]
void quizmo_assistant_render(EffectInstance *effect)
Gfx D_090026D8_409758[]
Gfx D_090027F0_409870[]
void quizmo_assistant_init(EffectInstance *effect)
s32 D_E011C518[]
void quizmo_assistant_update(EffectInstance *effect)
Gfx * D_E011C500[]
Gfx D_09002528_4095A8[]
#define ARRAY_COUNT(arr)
Definition macros.h:40
#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 *)
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