Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
music_note.c File Reference

Go to the source code of this file.

Functions

void music_note_appendGfx (void *effect)
 
void music_note_init (EffectInstance *effect)
 
void music_note_update (EffectInstance *effect)
 
void music_note_render (EffectInstance *effect)
 
void music_note_main (s32 type, f32 posX, f32 posY, f32 posZ)
 

Variables

Gfx D_09000FC0_35B5A0 []
 
Gfx D_09001038_35B618 []
 
Gfx D_090010C0_35B6A0 []
 
Gfx D_09001148_35B728 []
 
Gfx D_090011D0_35B7B0 []
 
Gfx D_09001258_35B838 []
 
Gfx D_090012E0_35B8C0 []
 
Gfx D_09001368_35B948 []
 
Gfx * D_E004C660 []
 
s8 D_E004C67C []
 

Function Documentation

◆ music_note_appendGfx()

void music_note_appendGfx ( void * effect)

Definition at line 131 of file music_note.c.

131 {
132 EffectInstance* effect = data;
133 MusicNoteFXData* fxData = effect->data.musicNote;
134 Matrix4f mtxTransform, mtxTemp;
135 s32 colorIdx = fxData->lifetime;
136 s32 dlistIdx = fxData->noteType;
137 s32 rgbOffset;
138
139 // TODO required to match - need to initialize define twice for some reason
140 rgbOffset = (colorIdx * 3) % ARRAY_COUNT(D_E004C67C);
141 rgbOffset = (colorIdx * 3) % ARRAY_COUNT(D_E004C67C);
142
143 gDPPipeSync(gMainGfxPos++);
144 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
145 gSPDisplayList(gMainGfxPos++, D_09000FC0_35B5A0);
146 gDPSetPrimColor(gMainGfxPos++, 0, 0,
147 D_E004C67C[rgbOffset], D_E004C67C[rgbOffset + 1], D_E004C67C[rgbOffset + 2], fxData->alpha
148 );
149 guTranslateF(mtxTransform, fxData->pos.x, fxData->pos.y, fxData->pos.z);
150 guRotateF(mtxTemp, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
151 guMtxCatF(mtxTemp, mtxTransform, mtxTransform);
152 guScaleF(mtxTemp, fxData->scale, fxData->scale, 0.0f);
153 guMtxCatF(mtxTemp, mtxTransform, mtxTransform);
155 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
156 gSPDisplayList(gMainGfxPos++, D_E004C660[dlistIdx]);
157 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
158 gDPPipeSync(gMainGfxPos++);
159}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guRotateF
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define guScaleF
struct MusicNoteFXData * musicNote
Definition effects.h:2502
EffectData data
Definition effects.h:2605
Gfx D_09000FC0_35B5A0[]
s8 D_E004C67C[]
Definition music_note.c:21
Gfx * D_E004C660[]
Definition music_note.c:18
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
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

Referenced by music_note_render().

◆ music_note_init()

void music_note_init ( EffectInstance * effect)

Definition at line 91 of file music_note.c.

91 {
92}

Referenced by music_note_main().

◆ music_note_update()

void music_note_update ( EffectInstance * effect)

Definition at line 94 of file music_note.c.

94 {
95 MusicNoteFXData* part = effect->data.musicNote;
96 s32 timeLeft;
97
98 part->timeLeft--;
99 part->lifetime++;
100 timeLeft = part->timeLeft;
101 if (timeLeft < 0) {
102 remove_effect(effect);
103 return;
104 }
105 if (timeLeft >= 6) {
106 part->alpha += (255 - part->alpha) * 0.3;
107 part->scale += (1.0f - part->scale) * 0.3;
108 }
109 if (timeLeft < 10) {
110 part->alpha = timeLeft * 25;
111 }
112 part->pos.x += part->velX;
113 part->pos.y += part->velY;
114 part->velX += (part->finalVelX - part->velX) * 0.04;
115 part->velY += (part->finalVelY - part->velY) * 0.04;
116}
#define remove_effect

Referenced by music_note_main().

◆ music_note_render()

void music_note_render ( EffectInstance * effect)

Definition at line 118 of file music_note.c.

118 {
119 RenderTask renderTask;
120 RenderTask* retTask;
121
122 renderTask.appendGfx = music_note_appendGfx;
123 renderTask.appendGfxArg = effect;
124 renderTask.dist = 0;
126
127 retTask = queue_render_task(&renderTask);
129}
#define queue_render_task
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
void music_note_appendGfx(void *effect)
Definition music_note.c:131
void * appendGfxArg
void(* appendGfx)(void *)

Referenced by music_note_main().

◆ music_note_main()

void music_note_main ( s32 type,
f32 posX,
f32 posY,
f32 posZ )

Definition at line 36 of file music_note.c.

36 {
38 EffectBlueprint* bpPtr = &bp;
39 EffectInstance* effect;
40 MusicNoteFXData* part;
41 s32 numParts = 1;
42 s32 randInt;
43
44 bp.unk_00 = 0;
48 bp.renderUI = NULL;
49 bp.effectID = EFFECT_MUSIC_NOTE;
50
51 effect = create_effect_instance(bpPtr);
52 effect->numParts = numParts;
53
54 part = effect->data.musicNote = general_heap_malloc(numParts * sizeof(*part));
55
56 ASSERT(effect->data.musicNote != NULL);
57
58 part->type = type;
59 part->pos.x = posX;
60 part->pos.y = posY;
61 part->pos.z = posZ;
62 part->scale = 0;
63 part->timeLeft = 64;
64 part->alpha = 0;
65 part->lifetime = 0;
66 part->noteType = rand_int(6);
67 switch (type) {
68 case 0:
69 part->velX = 0.0f;
70 part->velY = 1.0f;
71 part->finalVelX = 0.0f;
72 part->finalVelY = 1.0f;
73 break;
74 case 1:
75 randInt = rand_int(10);
76 part->velX = (randInt * 0.1) + -5.0;
77 part->velY = (rand_int(10) * 0.1) + 0.5;
78 part->finalVelX = 0.0f;
79 part->finalVelY = 0.0f;
80 break;
81 default:
82 randInt = rand_int(10);
83 part->velX = 5.0 - (randInt * 0.1);
84 part->velY = (rand_int(10) * 0.1) + 1.0;
85 part->finalVelX = 0.0f;
86 part->finalVelY = 0.0f;
87 break;
88 }
89}
#define general_heap_malloc
#define rand_int
#define create_effect_instance
#define ASSERT(condition)
void music_note_init(EffectInstance *effect)
Definition music_note.c:91
void music_note_update(EffectInstance *effect)
Definition music_note.c:94
void music_note_render(EffectInstance *effect)
Definition music_note.c:118
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

Variable Documentation

◆ D_09000FC0_35B5A0

Gfx D_09000FC0_35B5A0[]
extern

Referenced by music_note_appendGfx().

◆ D_09001038_35B618

Gfx D_09001038_35B618[]
extern

◆ D_090010C0_35B6A0

Gfx D_090010C0_35B6A0[]
extern

◆ D_09001148_35B728

Gfx D_09001148_35B728[]
extern

◆ D_090011D0_35B7B0

Gfx D_090011D0_35B7B0[]
extern

◆ D_09001258_35B838

Gfx D_09001258_35B838[]
extern

◆ D_090012E0_35B8C0

Gfx D_090012E0_35B8C0[]
extern

◆ D_09001368_35B948

Gfx D_09001368_35B948[]
extern

◆ D_E004C660

Gfx* D_E004C660[]
Initial value:
Gfx D_09001148_35B728[]
Gfx D_09001258_35B838[]
Gfx D_090011D0_35B7B0[]
Gfx D_09001368_35B948[]
Gfx D_09001038_35B618[]
Gfx D_090012E0_35B8C0[]
Gfx D_090010C0_35B6A0[]

Definition at line 18 of file music_note.c.

Referenced by music_note_appendGfx().

◆ D_E004C67C

s8 D_E004C67C[]
Initial value:
= {
254, 172, 172,
254, 172, 213,
254, 180, 154,
213, 180, 254,
180, 180, 254,
180, 221, 254,
180, 254, 254,
180, 254, 213,
180, 254, 180,
213, 254, 180,
254, 254, 180,
254, 213, 172,
}

Definition at line 21 of file music_note.c.

21 {
22 254, 172, 172,
23 254, 172, 213,
24 254, 180, 154,
25 213, 180, 254,
26 180, 180, 254,
27 180, 221, 254,
28 180, 254, 254,
29 180, 254, 213,
30 180, 254, 180,
31 213, 254, 180,
32 254, 254, 180,
33 254, 213, 172,
34};

Referenced by music_note_appendGfx().