Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
quizmo_stage.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09000218_398DD8[];
5extern Gfx D_09001518_39A0D8[];
6extern Mtx D_09004148_39CD08[];
7extern Gfx D_09006D48_39F908[];
8extern Gfx D_09006DA0_39F960[];
9extern Gfx D_09006E28_39F9E8[];
10extern Gfx D_09006F20_39FAE0[];
11extern Gfx D_09006FB0_39FB70[];
12extern Gfx D_09006FD8_39FB98[];
13extern Gfx D_09007030_39FBF0[];
14extern Gfx D_09007090_39FC50[];
15extern Gfx D_090070E8_39FCA8[];
16extern Gfx D_09007230_39FDF0[];
17
21void quizmo_stage_appendGfx(void* effect);
22
23EffectInstance* quizmo_stage_main(s32 arg0, f32 posX, f32 posY, f32 posZ) {
24 EffectBlueprint effectBp;
25 EffectInstance* effect;
27 s32 numParts = 1;
28
29 effectBp.init = quizmo_stage_init;
30 effectBp.update = quizmo_stage_update;
32 effectBp.unk_00 = 0;
33 effectBp.renderUI = NULL;
34 effectBp.effectID = EFFECT_QUIZMO_STAGE;
35
36 effect = create_effect_instance(&effectBp);
37 effect->numParts = numParts;
38
39 data = effect->data.quizmoStage = general_heap_malloc(numParts * sizeof(*data));
40 ASSERT(data != NULL);
41
42 data->vanishTimer = 100;
43 data->microphoneRaiseAmt = 255;
44 data->rearWallRaiseAmt = 255;
45 data->leftWallRaiseAmt = 255;
46 data->rightWallRaiseAmt = 255;
47 data->podiumRaiseAmt = 255;
48 data->lightScrollIncrement = 64;
49 data->unk_00 = arg0;
50 data->origin.x = posX;
51 data->origin.y = posY;
52 data->origin.z = posZ;
53 data->lightScrollAmt = 0;
54 data->lightScrollDelay = 15;
55 data->unkEffectMode = 0;
56 data->lifetime = 0;
57
58 return effect;
59}
60
63
65 QuizmoStageFXData *data = effect->data.quizmoStage;
66 s32 lifeTime;
67
68 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
69 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
70 data->vanishTimer = 30;
71 }
72
73 if (data->vanishTimer < 100) {
74 data->vanishTimer--;
75 }
76
77 data->lifetime++;
78 lifeTime = data->lifetime;
79
80 if (data->vanishTimer < 0) {
81 remove_effect(effect);
82 return;
83 }
84 if (data->vanishTimer < 16) {
85 data->microphoneRaiseAmt = data->vanishTimer * 16;
86 }
87 if ((lifeTime % data->lightScrollDelay) == 0) {
89 if (data->lightScrollAmt >= 1025) {
90 data->lightScrollAmt -= 1024;
91 }
92 }
93}
94
96 RenderTask renderTask;
97 RenderTask* retTask;
98
100 renderTask.appendGfxArg = effect;
101 renderTask.dist = 0;
103
104 retTask = queue_render_task(&renderTask);
106}
107
108void quizmo_stage_appendGfx(void* effect) {
109 QuizmoStageFXData* data = ((EffectInstance*)effect)->data.quizmoStage;
110 s32 microphoneRaiseAmt = data->microphoneRaiseAmt;
111 Matrix4f sp18;
112 Matrix4f sp58;
113
114 gDPPipeSync(gMainGfxPos++);
115 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
116
117 guTranslateF(sp18, data->origin.x, data->origin.y, data->origin.z);
118 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
119 guMtxCatF(sp58, sp18, sp18);
121
122 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
123 gDPSetPrimColor(gMainGfxPos++, 0, 0, microphoneRaiseAmt, microphoneRaiseAmt, microphoneRaiseAmt, 255);
124 gDPSetCombineMode(gMainGfxPos++, G_CC_MODULATEIA, PM_CC2_MULTIPLY_PRIM);
125 gSPDisplayList(gMainGfxPos++, D_09007230_39FDF0);
126
127 if (data->unk_3C != 255) {
128 gSPMatrix(gMainGfxPos++, &D_09004148_39CD08[2], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
129
130 guRotateF(sp18, (data->rearWallRaiseAmt * 180) / 255 - 180, 1.0f, 0.0f, 0.0f);
132
133 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
134 gSPDisplayList(gMainGfxPos++, D_09006E28_39F9E8);
135 gSPDisplayList(gMainGfxPos++, D_09001518_39A0D8);
136 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE, data->lightScrollAmt, 0, data->lightScrollAmt + 252, 60);
137 gSPDisplayList(gMainGfxPos++, D_09006DA0_39F960);
138 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
139 gSPMatrix(gMainGfxPos++, &D_09004148_39CD08[0], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
140
141 guRotateF(sp18, 90 - (data->leftWallRaiseAmt * 90) / 255, 0.0f, 0.0f, 1.0f);
143
144 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
145 gSPDisplayList(gMainGfxPos++, D_09006FB0_39FB70);
146 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
147 gSPMatrix(gMainGfxPos++, &D_09004148_39CD08[1], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
148
149 guRotateF(sp18, (data->rightWallRaiseAmt * 90) / 255 - 90, 0.0f, 0.0f, 1.0f);
151
152 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
153 gSPDisplayList(gMainGfxPos++, D_09006F20_39FAE0);
154 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
155 gSPDisplayList(gMainGfxPos++, D_090070E8_39FCA8);
156 gSPDisplayList(gMainGfxPos++, D_09007030_39FBF0);
157 gSPDisplayList(gMainGfxPos++, D_09001518_39A0D8);
158 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE, data->lightScrollAmt, 0, data->lightScrollAmt + 252, 60);
159 gSPDisplayList(gMainGfxPos++, D_09006FD8_39FB98);
160 gSPMatrix(gMainGfxPos++, &D_09004148_39CD08[3], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
161
162 guRotateF(sp18, 90 - (data->podiumRaiseAmt * 90) / 255, 1.0f, 0.0f, 0.0f);
164
165 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
166 gSPDisplayList(gMainGfxPos++, D_09006D48_39F908);
167 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
168 gSPDisplayList(gMainGfxPos++, D_09000218_398DD8);
169 gSPDisplayList(gMainGfxPos++, D_09007090_39FC50);
170 }
171
172 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
173 gDPPipeSync(gMainGfxPos++);
174}
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
struct QuizmoStageFXData * quizmoStage
Definition effects.h:2542
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_SURFACE_OPA
Definition enums.h:3264
Gfx D_09007090_39FC50[]
Gfx D_09006DA0_39F960[]
Mtx D_09004148_39CD08[]
Gfx D_09000218_398DD8[]
Gfx D_09006FB0_39FB70[]
void quizmo_stage_render(EffectInstance *effect)
Gfx D_09007030_39FBF0[]
Gfx D_09006FD8_39FB98[]
Gfx D_090070E8_39FCA8[]
Gfx D_09006F20_39FAE0[]
void quizmo_stage_init(EffectInstance *effect)
EffectInstance * quizmo_stage_main(s32 arg0, f32 posX, f32 posY, f32 posZ)
Gfx D_09006E28_39F9E8[]
Gfx D_09001518_39A0D8[]
Gfx D_09007230_39FDF0[]
void quizmo_stage_appendGfx(void *effect)
Gfx D_09006D48_39F908[]
void quizmo_stage_update(EffectInstance *effect)
#define PM_CC2_MULTIPLY_PRIM
Definition macros.h:305
#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