Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
got_item_outline.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern IMG_BIN D_09000000_345B40[][0x1000];
5extern IMG_BIN D_09004000_349B40[][0x1000];
6extern Gfx D_09008100_34DC40[];
7extern Gfx D_09008170_34DCB0[];
8extern Gfx D_09008190_34DCD0[];
9extern Gfx D_090081A8_34DCE8[];
10extern Gfx D_090081C0_34DD00[];
11
15
16u8 AnimScaleIn[] = { 60, 120, 140, 147, 149, 150 };
17u8 AnimScaleOut[] = { 150, 150, 150, 150, 150, 150 };
18
22void got_item_outline_appendGfx(void* effect);
23
25 s32 type,
26 f32 posX,
27 f32 posY,
28 f32 posZ,
29 f32 arg4,
30 EffectInstance** outEffect
31) {
33 EffectInstance* effect;
35 s32 numParts = 1;
36
40 bp.unk_00 = 0;
41 bp.renderUI = NULL;
42 bp.effectID = EFFECT_GOT_ITEM_OUTLINE;
43
44 effect = create_effect_instance(&bp);
45 effect->numParts = numParts;
46 data = effect->data.gotItemOutline = general_heap_malloc(numParts * sizeof(*data));
47 ASSERT(effect->data.gotItemOutline != NULL);
48
49 data->timeLeft = 100;
50 data->type = type;
51 data->lifetime = 0;
52 data->pos.x = posX;
53 data->pos.y = posY;
54 data->pos.z = posZ;
55 data->alpha = 255;
56
57 *outEffect = effect;
58}
59
62
65 s32 time;
66
67 if (data->timeLeft < 100) {
68 data->timeLeft--;
69 if (data->timeLeft < 0) {
70 remove_effect(effect);
71 return;
72 }
73 }
74
75 data->lifetime++;
76 time = data->lifetime;
77
78 if (data->timeLeft < 6) {
79 data->scale = AnimScaleOut[5 - data->timeLeft] / 150.0f;
80 data->alpha /= 2;
81 } else {
82 if (time < 7) {
83 data->scale = AnimScaleIn[time - 1] / 150.0f;
84 } else {
85 data->scale = 1.0f;
86 }
87
88 if (time >= 7) {
89 data->lifetime = 7;
90 }
91 }
92}
93
95 RenderTask renderTask;
96 RenderTask* retTask;
97
99 renderTask.appendGfxArg = effect;
100 renderTask.dist = 0;
102
103 retTask = queue_render_task(&renderTask);
105}
106
107void func_E003621C(void) {
108}
109
110void got_item_outline_appendGfx(void* effect) {
111 GotItemOutlineFXData* data = ((EffectInstance*)effect)->data.gotItemOutline;
112 s32 type = data->type;
113 f32 scale = data->scale;
114 Matrix4f mtxTransform;
115 Matrix4f mtxTemp;
116 s32 i;
117
118 if (scale != 0.0f) {
119 gDPPipeSync(gMainGfxPos++);
120 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
121 gSPDisplayList(gMainGfxPos++, D_09008100_34DC40);
122
123 if (type == 0) {
124 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, 255, data->alpha);
125 gDPSetEnvColor(gMainGfxPos++, 0, 0, 0, 255);
126 } else {
127 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, 255, data->alpha);
128 gDPSetEnvColor(gMainGfxPos++, 255, 255, 0, 255);
129 }
130
131 guTranslateF(mtxTransform, data->pos.x, data->pos.y, data->pos.z);
132 guRotateF(mtxTemp, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
133 guMtxCatF(mtxTemp, mtxTransform, mtxTransform);
134 guTranslateF(mtxTemp, 0.0f, 0.0f, -2.0f);
135 guMtxCatF(mtxTemp, mtxTransform, mtxTransform);
136
137 scale *= 0.6;
138
139 guScaleF(mtxTemp, scale, scale, 1.0f);
140 guMtxCatF(mtxTemp, mtxTransform, mtxTransform);
142
143 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
144
145 for (i = 0; i < 4; i++) {
146 IMG_PTR img;
147
148 if (type == 0) {
149 img = D_09000000_345B40[i];
150 } else {
151 img = D_09004000_349B40[i];
152 }
153
154 gDPSetTextureImage(gMainGfxPos++, G_IM_FMT_IA, G_IM_SIZ_8b, 128, img);
155 gDPSetTile(gMainGfxPos++, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 0, G_TX_LOADTILE, 0,
156 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD,
157 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD);
158 gDPLoadSync(gMainGfxPos++);
159 gDPLoadTile(gMainGfxPos++, G_TX_LOADTILE, 0, 0, 508, 124);
160 gDPPipeSync(gMainGfxPos++);
161 gDPSetTile(gMainGfxPos++, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 0, G_TX_RENDERTILE, 0,
162 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD,
163 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD);
164 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE, 0, 0, 508, 124);
165 gSPDisplayList(gMainGfxPos++, D_E0036630[i]);
166 }
167
168 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
169 gDPPipeSync(gMainGfxPos++);
170 }
171}
#define IMG_BIN
Mtx matrixStack[0x200]
#define IMG_PTR
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 GotItemOutlineFXData * gotItemOutline
Definition effects.h:2491
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
Gfx D_090081C0_34DD00[]
void got_item_outline_appendGfx(void *effect)
u8 AnimScaleOut[]
u8 AnimScaleIn[]
Gfx D_09008170_34DCB0[]
void got_item_outline_main(s32 type, f32 posX, f32 posY, f32 posZ, f32 arg4, EffectInstance **outEffect)
Gfx D_09008190_34DCD0[]
void func_E003621C(void)
void got_item_outline_render(EffectInstance *effect)
Gfx D_090081A8_34DCE8[]
Gfx * D_E0036630[]
void got_item_outline_init(EffectInstance *effect)
void got_item_outline_update(EffectInstance *effect)
IMG_BIN D_09000000_345B40[][0x1000]
IMG_BIN D_09004000_349B40[][0x1000]
Gfx D_09008100_34DC40[]
#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