Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
stars_orbiting.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09000440_363090[];
5extern Gfx D_090004F0_363140[];
6
9
13void func_E005E318(EffectInstance* effect);
14void func_E005E334(EffectInstance* effect);
15
17 s32 type,
18 f32 posX,
19 f32 posY,
20 f32 posZ,
21 f32 radius,
22 s32 numStars,
23 EffectInstance** outEffect
24) {
26 EffectInstance* effect;
28 s32 i;
29
30 numStars++;
31
35 bp.unk_00 = 0;
37 bp.effectID = EFFECT_STARS_ORBITING;
38
39 effect = create_effect_instance(&bp);
40 effect->numParts = numStars;
41 part = effect->data.starsOrbiting = general_heap_malloc(numStars * sizeof(*part));
42 ASSERT(effect->data.starsOrbiting != NULL);
43
44 mem_clear(part, numStars * sizeof(*part));
45
46 part->type = type;
47 part->pos.x = posX;
48 part->pos.y = posY;
49 part->pos.z = posZ;
50 part->orbitRadius = 0;
51 part->yaw = 0;
52 part->targetRadius = radius;
53 part->enabled = TRUE;
54
55 part++;
56 for (i = 1; i < numStars; i++, part++) {
57 part->pos.x = 0;
58 part->pos.y = 0;
59 part->pos.z = 0;
60 part->roll = (i - 1) * 360 / (numStars - 1);
61 part->rollSpinRate = 20.0f;
62 part->pitch = 0;
63 part->yaw = (i - 1) * 360 / (numStars - 1);
64 }
65
66 *outEffect = effect;
67}
68
71
74 f32 radius;
75 s32 i;
76
77 if (part->enabled) {
78 part->yaw++;
79 part->orbitRadius += (part->targetRadius - part->orbitRadius) * 0.1;
80 radius = part->orbitRadius;
81
82 part++;
83 for (i = 1; i < effect->numParts; i++, part++) {
84 part->pos.x = radius * sin_deg(part->yaw);
85 part->pos.z = radius * cos_deg(part->yaw) * cos_deg(part->pitch);
86 part->pos.y = radius * cos_deg(part->yaw) * sin_deg(part->pitch);
87 part->roll += part->rollSpinRate;
88 part->pitch = 0.0f;
89 part->yaw += 16;
90 if (part->yaw > 360) {
91 part->yaw -= 360;
92 }
93 }
94 }
95}
96
99
101 func_E005E334(effect);
102}
103
105 StarsOrbitingFXData* part = effect->data.starsOrbiting;
106 Matrix4f sp18;
107 Matrix4f sp58;
108 Matrix4f sp98;
109 s32 i;
110
111 if (part->enabled) {
112 Gfx* dlist = D_E005E670[0];
113 Gfx* dlist2 = D_E005E674[0];
114
115 gDPPipeSync(gMainGfxPos++);
116 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
117 gSPDisplayList(gMainGfxPos++, dlist2);
118
119 guTranslateF(sp18, part->pos.x, part->pos.y, part->pos.z);
120 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
121 guMtxCatF(sp58, sp18, sp98);
123
124 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
125 gDPSetPrimColor(gMainGfxPos++, 0, 0, 220, 220, 40, 255);
126
127 part++;
128 for (i = 1; i < effect->numParts; i++, part++) {
129 guTranslateF(sp18, part->pos.x, part->pos.y, part->pos.z);
130 guRotateF(sp58, part->roll, 0.0f, 0.0f, 1.0f);
131 guMtxCatF(sp58, sp18, sp18);
133
134 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
135 gSPDisplayList(gMainGfxPos++, dlist);
136 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
137 }
138
139 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
140 }
141}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define guRotateF
#define guMtxF2L
#define sin_deg
#define guTranslateF
#define guMtxCatF
#define cos_deg
#define create_effect_instance
#define mem_clear
struct StarsOrbitingFXData * starsOrbiting
Definition effects.h:2511
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
Gfx * D_E005E670[]
void stars_orbiting_render(EffectInstance *effect)
void func_E005E334(EffectInstance *effect)
Gfx D_09000440_363090[]
void stars_orbiting_update(EffectInstance *effect)
void stars_orbiting_main(s32 type, f32 posX, f32 posY, f32 posZ, f32 radius, s32 numStars, EffectInstance **outEffect)
void func_E005E318(EffectInstance *effect)
Gfx * D_E005E674[]
Gfx D_090004F0_363140[]
void stars_orbiting_init(EffectInstance *effect)
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
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