Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
throw_spiny.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3#include "effects.h"
4
5void throw_spiny_appendGfx(void* effect);
6
10
11extern Gfx D_09000800_3D02F0[];
12extern Gfx D_090008D8_3D03C8[];
13extern Gfx D_090009F0_3D04E0[];
14
16
17u8 D_E00C8718[8] = { 110, 150, 130, 110, 100, 95, 100, 0 };
18u8 D_E00C8720[8] = { 80, 60, 80, 100, 120, 110, 100, 0 };
19
20//during spiny surge
21EffectInstance* throw_spiny_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, f32 arg7, s32 time) {
23 EffectBlueprint* bpPtr = &bp;
24 EffectInstance* effect;
25 ThrowSpinyFXData* spinyObject;
26 s32 numParts = 1;
27 f32 temp_f4, temp_f8, gravity;
28
32 bp.unk_00 = 0;
33 bp.renderUI = NULL;
34 bp.effectID = EFFECT_THROW_SPINY;
35
36 effect = (EffectInstance*)create_effect_instance(bpPtr);
37 effect->numParts = numParts;
38 spinyObject = effect->data.throwSpiny = general_heap_malloc(numParts * sizeof(*spinyObject));
39 ASSERT(effect->data.throwSpiny != NULL);
40 spinyObject->unk_00 = arg0;
41 spinyObject->lifeDuration = 0;
42
43 if (time <= 0) {
44 spinyObject->life = 1000;
45 } else {
46 spinyObject->life = time + 60;
47 }
48
49 temp_f8 = arg5 - arg2;
50 temp_f4 = time;
51 gravity = (temp_f8 / temp_f4) - (time * -0.10000000149011612); //TODO: fix this weird number
52 spinyObject->timeUntilFall = time;
53 spinyObject->rgba = 255;
54 spinyObject->unk_10 = arg1;
55 spinyObject->unk_14 = arg2;
56 spinyObject->unk_18 = arg3;
57 spinyObject->unk_1C = arg4;
58 spinyObject->unk_20 = arg5;
59 spinyObject->unk_24 = arg6;
60 spinyObject->unk_44 = (arg4 - arg1) / temp_f4;
61 spinyObject->unk_4C = (arg6 - arg3) / temp_f4;
62 spinyObject->pos.x = arg1;
63 spinyObject->pos.y = arg2;
64 spinyObject->pos.z = arg3;
65 spinyObject->gravity = gravity;
66
67 if (temp_f8 < 0.0f) {
68 spinyObject->unk_64 = 1;
69 } else {
70 spinyObject->unk_64 = 0;
71 }
72
73 spinyObject->unk_40 = arg7;
74 spinyObject->unk_30 = 70;
75 spinyObject->unk_34 = 180;
76 spinyObject->unk_38 = 120;
77 spinyObject->yaw = rand_int(360);
78 spinyObject->rotSpeed = rand_int(10) + 5;
79 spinyObject->state = -1;
80 spinyObject->xScale = 1.0f;
81 spinyObject->yScale = 1.0f;
82 return effect;
83}
84
86}
87
88void throw_spiny_update(EffectInstance* effectInstance) {
89 ThrowSpinyFXData* spinyObject = effectInstance->data.throwSpiny;
90 u32 state;
91 f32 gravity;
92 s32 lifeDuration;
93
94 if (effectInstance->flags & FX_INSTANCE_FLAG_DISMISS) {
95 effectInstance->flags &= ~FX_INSTANCE_FLAG_DISMISS;
96 spinyObject->life = 16;
97 }
98
99 if (spinyObject->life < 1000) {
100 spinyObject->life--;
101 }
102
103 spinyObject->lifeDuration++;
104
105 if (spinyObject->life < 0) {
106 remove_effect(effectInstance);
107 return;
108 }
109
110 lifeDuration = spinyObject->lifeDuration;
111 state = spinyObject->state;
112
113 if (state < 7) {
114 spinyObject->xScale = D_E00C8718[state] * 0.01f;
115 spinyObject->yScale = D_E00C8720[state] * 0.01f;
116 spinyObject->state += 1;
117 spinyObject->yaw -= 40.0f;
118 } else {
119 spinyObject->gravity += -0.2f;
120 spinyObject->pos.x += spinyObject->unk_44;
121 spinyObject->pos.y += spinyObject->gravity;
122 spinyObject->pos.z += spinyObject->unk_4C;
123 spinyObject->yaw += spinyObject->rotSpeed;
124 }
125
126 if ((lifeDuration - 1) == spinyObject->timeUntilFall) {
127 spinyObject->state = 0;
128 spinyObject->gravity = -spinyObject->gravity;
129 spinyObject->unk_44 = spinyObject->unk_44;
130 spinyObject->rotSpeed = -4.0f;
131 return;
132 }
133
134 gravity = spinyObject->gravity;
135
136 if ((gravity < 0.0f) && (spinyObject->pos.y < 100.0 / 7.0)) {
137 spinyObject->pos.y = 100.0f / 7.0f;
138 spinyObject->rotSpeed = -20.0f;
139 spinyObject->gravity = gravity - gravity;
140 }
141}
142
144 RenderTask renderTask;
145 RenderTask* retTask;
146
147 renderTask.appendGfx = throw_spiny_appendGfx;
148 renderTask.appendGfxArg = effect;
149 renderTask.dist = 10;
151
152 retTask = queue_render_task(&renderTask);
154}
155
156void func_E00C844C(void) {
157}
158
159void throw_spiny_appendGfx(void* effect) {
160 Matrix4f sp18;
161 Matrix4f sp58;
162 Camera* camera = &gCameras[gCurrentCameraID];
163 ThrowSpinyFXData* data = ((EffectInstance*)effect)->data.throwSpiny;
164 s32 temp_s5 = data->rgba;
165 s32 temp_s6 = data->unk_00;
166 f32 scale = data->unk_40 * SPRITE_WORLD_SCALE_D;
167
168 gDPPipeSync(gMainGfxPos++);
169 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
170
171 guTranslateF(sp18, data->pos.x, data->pos.y, data->pos.z);
172 guScaleF(sp58, scale * data->xScale, scale * data->yScale, scale);
173 guMtxCatF(sp58, sp18, sp18);
174 guRotateF(sp58, data->yaw, 0.0f, 0.0f, 1.0f);
175 guMtxCatF(sp58, sp18, sp18);
177
178 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
179 gSPMatrix(gMainGfxPos++, camera->mtxBillboard, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
180 gDPSetPrimColor(gMainGfxPos++, 0, 0, data->unk_30, data->unk_34, data->unk_38, temp_s5);
181 gSPDisplayList(gMainGfxPos++, D_E00C8710[temp_s6]);
182 gSPDisplayList(gMainGfxPos++, D_090009F0_3D04E0);
183 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
184}
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 rand_int
#define create_effect_instance
#define guScaleF
struct ThrowSpinyFXData * throwSpiny
Definition effects.h:2564
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
#define SPRITE_WORLD_SCALE_D
Definition macros.h:140
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
Mtx * mtxBillboard
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_090009F0_3D04E0[]
u8 D_E00C8720[8]
Definition throw_spiny.c:18
Gfx * D_E00C8710[2]
Definition throw_spiny.c:15
void throw_spiny_update(EffectInstance *effect)
Definition throw_spiny.c:88
Gfx D_09000800_3D02F0[]
void throw_spiny_init(EffectInstance *effect)
Definition throw_spiny.c:85
void func_E00C844C(void)
void throw_spiny_appendGfx(void *effect)
EffectInstance * throw_spiny_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, f32 arg7, s32 time)
Definition throw_spiny.c:21
void throw_spiny_render(EffectInstance *effect)
u8 D_E00C8718[8]
Definition throw_spiny.c:17
Gfx D_090008D8_3D03C8[]
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