Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
tattle_window.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
7void func_E00D8264(EffectInstance* effect);
8void func_E00D8630(EffectInstance* effect);
9
10extern u8 D_09000000_3D7040[];
11
13 .background = { 0 },
14 .corners = {
16 .fmt = G_IM_FMT_IA,
17 .bitDepth = G_IM_SIZ_8b,
18 .size1 = { 16, 8 },
19 .size2 = { 16, 8 },
20 .size3 = { 16, 8 },
21 .size4 = { 16, 8 },
22 },
23 .opaqueCombineMode = gsDPSetCombineMode(PM_CC_15, G_CC_PASS2),
24 .transparentCombineMode = gsDPSetCombineMode(PM_CC_14, G_CC_PASS2),
25 .color1 = { 61, 74, 188, 255 },
26 .color2 = { 0, 25, 28, 255},
27};
28
29typedef struct TattleAnimFrame {
33} TattleAnimFrame; // size = 0x4
34
36 { .offsetY = -200, .closeAmtX = 255, .closeAmtY = 255 },
37 { .offsetY = -160, .closeAmtX = 255, .closeAmtY = 255 },
38 { .offsetY = -120, .closeAmtX = 255, .closeAmtY = 255 },
39 { .offsetY = -85, .closeAmtX = 255, .closeAmtY = 255 },
40 { .offsetY = -55, .closeAmtX = 255, .closeAmtY = 255 },
41 { .offsetY = -30, .closeAmtX = 255, .closeAmtY = 255 },
42 { .offsetY = -16, .closeAmtX = 255, .closeAmtY = 255 },
43 { .offsetY = -8, .closeAmtX = 255, .closeAmtY = 255 },
44 { .offsetY = -4, .closeAmtX = 255, .closeAmtY = 255 },
45 { .offsetY = -2, .closeAmtX = 255, .closeAmtY = 255 },
46 { .offsetY = -1, .closeAmtX = 255, .closeAmtY = 255 },
47 { .offsetY = 0, .closeAmtX = 255, .closeAmtY = 255 },
48 { .offsetY = 0, .closeAmtX = 255, .closeAmtY = 255 },
49 { .offsetY = 0, .closeAmtX = 255, .closeAmtY = 255 },
50 { .offsetY = 0, .closeAmtX = 255, .closeAmtY = 255 },
51 { .offsetY = 0, .closeAmtX = 230, .closeAmtY = 250 },
52 { .offsetY = 0, .closeAmtX = 120, .closeAmtY = 245 },
53 { .offsetY = 0, .closeAmtX = 0, .closeAmtY = 240 },
54 { .offsetY = 0, .closeAmtX = 0, .closeAmtY = 210 },
55 { .offsetY = 0, .closeAmtX = 0, .closeAmtY = 170 },
56 { .offsetY = 0, .closeAmtX = 0, .closeAmtY = 120 },
57 { .offsetY = 0, .closeAmtX = 0, .closeAmtY = 60 },
58 { .offsetY = 0, .closeAmtX = 0, .closeAmtY = 0 },
59};
60
61EffectInstance* tattle_window_main(s32 type, f32 x, f32 y, f32 z, f32 arg4, s32 duration) {
63 EffectBlueprint* bpPtr = &bp;
64 EffectInstance* effect;
66 s32 numParts = 1;
67
72 bp.unk_00 = 0;
73 bp.effectID = EFFECT_TATTLE_WINDOW;
74
75 effect = create_effect_instance(bpPtr);
76 effect->numParts = numParts;
77 part = effect->data.tattleWindow = general_heap_malloc(numParts * sizeof(*part));
78
79 ASSERT(effect->data.tattleWindow != NULL);
80
81 part->type = type;
82 part->unk_14 = 0;
83 if (duration <= 0) {
84 part->timeLeft = 1000;
85 } else {
86 part->timeLeft = duration;
87 }
88 part->pos.x = x;
89 part->pos.y = y;
90 part->pos.z = z;
91 part->scale = 0.0f;
92 part->unk_18 = arg4;
93 part->rot.x = 0.0f;
94 part->rot.y = 0.0f;
95 part->rot.z = 0.0f;
96 part->offset.x = part->offset.y = 0.0f;
97 part->closeAmt.x = 255;
98 part->closeAmt.y = 255;
99
100 return effect;
101}
102
105
107 s32 unk_10, unk_10_2;
108 s32 old_unk_14;
109 TattleWindowFXData* part = effect->data.tattleWindow;
110
111 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
112 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
114 }
115
116 if (part->timeLeft < 1000) {
117 part->timeLeft--;
118 }
119
120 old_unk_14 = part->unk_14++;
121 unk_10 = part->timeLeft;
122
123 if (unk_10 < 0) {
124 remove_effect(effect);
125 return;
126 }
127
128 unk_10_2 = unk_10;
129 part->rot.z = 0;
130 part->offset.x = 0;
131 part->scale = part->unk_18;
132
133 if (old_unk_14 < ARRAY_COUNT(TattleWindowAnimation)) {
134 part->offset.y = TattleWindowAnimation[old_unk_14].offsetY;
135 part->closeAmt.x = TattleWindowAnimation[old_unk_14].closeAmtX;
136 part->closeAmt.y = TattleWindowAnimation[old_unk_14].closeAmtY;
137 } else {
142 }
143
144 if (unk_10_2 < ARRAY_COUNT(TattleWindowAnimation)) {
145 part->offset.y = TattleWindowAnimation[unk_10_2].offsetY;
146 part->closeAmt.x = TattleWindowAnimation[unk_10_2].closeAmtX;
147 part->closeAmt.y = TattleWindowAnimation[unk_10_2].closeAmtY;
148 }
149}
150
153
155 func_E00D8630(effect);
156}
157
158void func_E00D8280(void) {
159}
160
161void tattle_window_fill_clipped_quad(s32 l, s32 t, s32 r, s32 b) {
162 if (l < 0) {
163 l = 0;
164 }
165 if (t < 0) {
166 t = 0;
167 }
168 if (r < 0) {
169 r = 0;
170 }
171 if (b < 0) {
172 b = 0;
173 }
174
175 if (l > SCREEN_WIDTH - 1) {
176 l = SCREEN_WIDTH - 1;
177 }
178 if (t > SCREEN_HEIGHT - 1) {
179 t = SCREEN_HEIGHT - 1;
180 }
181 if (r > SCREEN_WIDTH - 1) {
182 r = SCREEN_WIDTH - 1;
183 }
184 if (b > SCREEN_HEIGHT - 1) {
185 b = SCREEN_HEIGHT - 1;
186 }
187
188 gDPFillRectangle(gMainGfxPos++, l, t, r, b);
189}
190
191void func_E00D8334(TattleWindowFXData* data, s32 left, s32 top, s32 right, s32 bottom) {
192 f32 closeFracX = data->closeAmt.x / 255.0f;
193 f32 closeFracY = data->closeAmt.y / 255.0f;
194 s32 xMid, yMid;
195 s32 l, t, r, b;
196
197 // draw the 'shades' which appear over the window and tattle viewport to animate opening and closing
198 if (data->closeAmt.x > 0 || data->closeAmt.y > 0) {
199 gDPPipeSync(gMainGfxPos++);
200 gSPTexture(gMainGfxPos++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF);
201 gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
202 gDPSetTexturePersp(gMainGfxPos++, G_TP_NONE);
203 gDPSetTextureDetail(gMainGfxPos++, G_TD_CLAMP);
204 gDPSetTextureLOD(gMainGfxPos++, G_TL_TILE);
205 gDPSetTextureLUT(gMainGfxPos++, G_TT_NONE);
206 gDPSetTextureFilter(gMainGfxPos++, G_TF_AVERAGE);
207 gDPSetTextureConvert(gMainGfxPos++, G_TC_FILT);
208 gDPSetRenderMode(gMainGfxPos++, G_RM_CLD_SURF, G_RM_CLD_SURF2);
209 gDPSetCombineMode(gMainGfxPos++, G_CC_PRIMITIVE, G_CC_PRIMITIVE);
210 gDPSetPrimColor(gMainGfxPos++, 0, 0, 24, 48, 96, 255);
211 l = left + 4;
212 r = (left + right) - 4;
213 t = top + 4;
214 b = (top + bottom) - 4;
215 xMid = (r - l) / 2;
216 yMid = (b - t) / 2;
217 tattle_window_fill_clipped_quad(l, t, l + (xMid * closeFracX), b);
218 tattle_window_fill_clipped_quad(r - (xMid * closeFracX), t, r, b);
219 tattle_window_fill_clipped_quad(l, t, r, t + (yMid * closeFracY));
220 tattle_window_fill_clipped_quad(l, b - (yMid * closeFracY), r, b);
221 }
222}
223
225 TattleWindowFXData* data = effect->data.tattleWindow;
226 s32 flags;
227
228 gDPPipeSync(gMainGfxPos++);
229 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
230
231 if (data->scale == 1.0f && data->rot.x == 0.0f && data->rot.y == 0.0f && data->rot.z == 0.0f) {
232 flags = 0;
233 } else {
234 flags = 1;
235 }
236
237 draw_box(
239 (data->pos.x + data->offset.x) - 75.0f,
240 (data->pos.y + data->offset.y) - 53.0f,
241 data->pos.z,
242 150, 107,
243 255, 0,
244 data->scale, data->scale,
245 data->rot.x, data->rot.y, data->rot.z,
246 (void (*)(void*)) func_E00D8334, data, NULL, SCREEN_WIDTH, SCREEN_HEIGHT, NULL);
247 gDPPipeSync(gMainGfxPos++);
248}
WindowBackground background
s8 flags
Definition demo_api.c:15
#define general_heap_malloc
#define remove_effect
#define draw_box
#define create_effect_instance
struct TattleWindowFXData * tattleWindow
Definition effects.h:2572
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517
#define SCREEN_WIDTH
Definition macros.h:105
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define PM_CC_14
Definition macros.h:301
#define SCREEN_HEIGHT
Definition macros.h:106
#define PM_CC_15
Definition macros.h:302
#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
u8 D_09000000_3D7040[]
void tattle_window_fill_clipped_quad(s32 l, s32 t, s32 r, s32 b)
void func_E00D8630(EffectInstance *effect)
WindowStyleCustom TattleWindowStyle
TattleAnimFrame TattleWindowAnimation[]
void tattle_window_render(EffectInstance *effect)
void func_E00D8264(EffectInstance *effect)
void tattle_window_init(EffectInstance *effect)
void func_E00D8280(void)
void tattle_window_update(EffectInstance *effect)
EffectInstance * tattle_window_main(s32 type, f32 x, f32 y, f32 z, f32 arg4, s32 duration)
void func_E00D8334(TattleWindowFXData *data, s32 left, s32 top, s32 right, s32 bottom)
Gfx * gMainGfxPos
Definition cam_main.c:15