Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
chapter_change.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3#include "message_ids.h"
4
5typedef struct {
6 /* 0x00 */ Gfx* displayList;
7 /* 0x04 */ s16 x;
8 /* 0x06 */ s16 y;
9 /* 0x08 */ s16 width;
10 /* 0x0A */ s16 height;
11} UnkStruct; // size: 0xC
12
13extern Gfx D_0900BE40_3F7CA0[];
14extern Gfx D_0900BE88_3F7CE8[];
15extern Gfx D_0900BED0_3F7D30[];
16extern Gfx D_0900BF18_3F7D78[];
17extern Gfx D_0900BF60_3F7DC0[];
18extern Gfx D_0900BFA8_3F7E08[];
19extern Gfx D_0900BFF0_3F7E50[];
20extern Gfx D_0900C038_3F7E98[];
21#if VERSION_JP
22extern Gfx D_0900B900_3FFA20[];
23extern Gfx D_0900B9E8_3FFB08[];
24extern Gfx D_0900BA30_3FFB50[];
25extern Gfx D_0900BB18_3FFC38[];
26#else
27extern Gfx D_0900C080_3F7EE0[];
28extern Gfx D_0900C168_3F7FC8[];
29extern Gfx D_0900C1B0_3F8010[];
30extern Gfx D_0900C1F8_3F8058[];
31extern Gfx D_0900C240_3F80A0[];
32extern Gfx D_0900C328_3F8188[];
33extern Gfx D_0900C370_3F81D0[];
34#endif
35extern Gfx D_0900C458_3F82B8[];
36extern Gfx D_0900C540_3F83A0[];
37
38s32 D_E010E750[] = {
39 -1,
40 MSG_Menus_019D, MSG_Menus_019E, MSG_Menus_019F,
41 MSG_Menus_01A0, MSG_Menus_01A1, MSG_Menus_01A2,
42 MSG_Menus_01A3, MSG_Menus_01A4, MSG_Menus_019C,
43 -1, -1, -1, -1, -1, -1, -1, -1, -1
44};
45
47#if VERSION_JP
48 { D_0900B900_3FFA20, 0, 0, 104, 20 },
49 { D_0900B9E8_3FFB08, 0, 20, 104, 20 },
50#else
51 { D_0900C080_3F7EE0, 104, 0, 128, 10 },
52 { D_0900C168_3F7FC8, 104, 10, 128, 10 },
53 { D_0900C1B0_3F8010, 104, 20, 128, 10 },
54 { D_0900C1F8_3F8058, 104, 30, 128, 10 },
55#endif
56 { NULL, 0, 0, 0, 0 }
57};
58
60 { D_0900C458_3F82B8, -16, -6, 144, 20 },
61 { D_0900C540_3F83A0, -16, 14, 144, 20 },
62 { NULL, 0, 0, 0, 0 }
63};
64
66#if VERSION_JP
67 { D_0900B900_3FFA20, 24, -6, 104, 20 },
68 { D_0900B9E8_3FFB08, 24, 14, 104, 20 },
69#else
70 { D_0900C080_3F7EE0, 0, -6, 128, 10 },
71 { D_0900C168_3F7FC8, 0, 4, 128, 10 },
72 { D_0900C1B0_3F8010, 0, 14, 128, 10 },
73 { D_0900C1F8_3F8058, 0, 24, 128, 10 },
74#endif
75 { NULL, 0, 0, 0, 0 }
76};
77
79#if VERSION_IQUE
80 { D_0900C240_3F80A0, 70, 0, 104, 20 },
81 { D_0900C328_3F8188, 70, 20, 104, 20 },
82 { D_0900C370_3F81D0, 172, 0, 16, 40 },
83#elif VERSION_JP
84 { D_0900BA30_3FFB50, 96, 0, 96, 20 },
85 { D_0900BB18_3FFC38, 96, 20, 96, 20 },
86#else
87 { D_0900C240_3F80A0, 0, 0, 104, 20 },
88 { D_0900C328_3F8188, 0, 20, 104, 20 },
89 { D_0900C370_3F81D0, 232, 0, 16, 40 },
90#endif
91 { NULL, 0, 0, 0, 0 }
92};
93
94#if VERSION_PAL
95UnkStruct D_E010E838_b[] = {
96 { D_0900C080_3F7EE0, 0, 0, 128, 10 },
97 { D_0900C168_3F7FC8, 0, 10, 128, 10 },
98 { D_0900C1B0_3F8010, 0, 20, 128, 10 },
99 { D_0900C1F8_3F8058, 0, 30, 128, 10 },
100 { NULL, 0, 0, 0, 0 }
101};
102
103UnkStruct D_E010E838_c[] = {
104 { D_0900C240_3F80A0, 128, 0, 104, 20 },
105 { D_0900C328_3F8188, 128, 20, 104, 20 },
106 { D_0900C370_3F81D0, 232, 0, 16, 40 },
107 { NULL, 0, 0, 0, 0 }
108};
109#endif
110
111#if VERSION_IQUE
112#define X_VAR 48
113#define Y_VAR -13
114#else
115#define X_VAR 128
116#define Y_VAR -33
117#endif
118
120 { D_0900BE40_3F7CA0, X_VAR, Y_VAR, 64, 64 },
121 { NULL, 0, 0, 0, 0 },
122 { D_0900BE88_3F7CE8, X_VAR, Y_VAR, 64, 64 },
123 { NULL, 0, 0, 0, 0 },
124 { D_0900BED0_3F7D30, X_VAR, Y_VAR, 64, 64 },
125 { NULL, 0, 0, 0, 0 },
126 { D_0900BF18_3F7D78, X_VAR, Y_VAR, 64, 64 },
127 { NULL, 0, 0, 0, 0 },
128 { D_0900BF60_3F7DC0, X_VAR, Y_VAR, 64, 64 },
129 { NULL, 0, 0, 0, 0 },
130 { D_0900BFA8_3F7E08, X_VAR, Y_VAR, 64, 64 },
131 { NULL, 0, 0, 0, 0 },
132 { D_0900BFF0_3F7E50, X_VAR, Y_VAR, 64, 64 },
133 { NULL, 0, 0, 0, 0 },
134 { D_0900C038_3F7E98, X_VAR, Y_VAR, 64, 64 },
135 { NULL, 0, 0, 0, 0 }
136};
137
141void chapter_change_appendGfx(void* effect);
142
143void func_E010E000(ChapterChangeFXData* data, s32 arg1, UnkStruct* arg2) {
144 s32 unk_1C = data->lifetime;
145 UnkStruct* it;
146 f32 posX;
147 f32 posY;
148 s32 temp;
149
150 if (arg1 == 0) {
151 posX = data->chapterPos.x;
152 posY = data->chapterPos.y;
153 } else {
154 posX = data->endOfPos.x;
155 posY = data->endOfPos.y;
156 }
157
158 if (arg2 != NULL) {
159 for (it = arg2; it->displayList != NULL; it++) {
160 gSPDisplayList(gMainGfxPos++, it->displayList);
161
162 temp = it->x - 384;
163 gDPSetTileSize(gMainGfxPos++, 1, (unk_1C * 4 - temp) * 4, 0, (unk_1C * 4 - it->x + 511) * 4, 0);
164 gSPScisTextureRectangle(gMainGfxPos++,
165 (posX + it->x) * 4,
166 (posY + it->y) * 4,
167 (posX + it->x + it->width) * 4,
168 (posY + it->y + it->height) * 4,
169 G_TX_RENDERTILE, 0, 0, 1024, 1024);
170 }
171
172 gDPPipeSync(gMainGfxPos++);
173 }
174}
175
176EffectInstance* chapter_change_main(s32 arg0, f32 posX, f32 posY, f32 arg3, f32 arg4, s32 duration) {
179 EffectInstance* effect;
180 s32 numParts = 1;
181
185 bp.unk_00 = 0;
186 bp.renderUI = NULL;
187 bp.effectID = EFFECT_CHAPTER_CHANGE;
188
189 effect = create_effect_instance(&bp);
190 effect->numParts = numParts;
191 data = effect->data.chapterChange = general_heap_malloc(numParts * sizeof(*data));
192 ASSERT(effect->data.chapterChange != NULL);
193
194 data->unk_00 = arg0;
195 data->lifetime = 0;
196 if (duration <= 0) {
197 data->timeLeft = 1000;
198 } else {
199 data->timeLeft = duration;
200 }
201 data->chapterPos.x = data->endOfPos.x = posX;
202 data->chapterPos.y = data->endOfPos.y = posY;
203 data->unk_0C = arg3;
204 data->unk_50 = arg4;
205 data->unk_20 = 255;
206 data->unk_24 = 255;
207 data->unk_28 = 255;
208 data->unk_2C = 255;
209 data->unk_30 = 0;
210 data->unk_34 = 0;
211 data->unk_38 = 0;
212 if (arg0 == 0 || (arg0 >= 10 && arg0 <= 18)) {
213 data->unk_3C = 0;
214 } else {
215 data->unk_3C = 255;
216 }
217 data->unk_54 = D_E010E750[arg0];
218 if (data->unk_54 >= 0) {
219 data->unk_40 = 160;
220 data->unk_44 = 160;
221 data->unk_48 = get_msg_width(data->unk_54, 0);
222 data->unk_4C = 24;
223 }
224
225 return effect;
226}
227
230
232 ChapterChangeFXData* data = effect->data.chapterChange;
233
234 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
235 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
236 data->timeLeft = 16;
237 }
238
239 if (data->timeLeft < 1000) {
240 data->timeLeft--;
241 }
242
243 data->lifetime++;
244
245 if (data->timeLeft < 0) {
246 remove_effect(effect);
247 }
248}
249
251 RenderTask renderTask;
252 RenderTask* retTask;
253
255 renderTask.appendGfxArg = effect;
256 renderTask.dist = 10;
258
259 retTask = queue_render_task(&renderTask);
261}
262
263void chapter_change_appendGfx(void* effect) {
264 ChapterChangeFXData* data = ((EffectInstance*)effect)->data.chapterChange;
265 s32 unk_2C = data->unk_2C;
266 u32 unk_00 = data->unk_00;
267 UnkStruct* ptr0;
268 UnkStruct* ptr1;
269
270 gDPPipeSync(gMainGfxPos++);
271 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
272
273 switch (unk_00) {
274 case 1:
275 case 2:
276 case 3:
277 case 4:
278 case 5:
279 case 6:
280 case 7:
281 case 8:
282 ptr0 = D_E010E7FC;
283 ptr1 = &D_E010E868[(unk_00 - 1) * 2];
284 break;
285 case 9:
286 ptr0 = D_E010E7D8;
287 ptr1 = NULL;
288 break;
289 case 0:
290 case 10:
291 case 11:
292 case 12:
293 case 13:
294 case 14:
295 case 15:
296 case 16:
297 case 17:
298 case 18:
299#if VERSION_PAL
301 ptr0 = D_E010E838_b;
302 ptr1 = D_E010E838_c;
303 break;
304 }
305#endif
306 ptr0 = D_E010E79C;
307 ptr1 = D_E010E838;
308 break;
309 default:
310 ptr1 = NULL;
311 ptr0 = NULL;
312 break;
313 }
314
315 gDPSetPrimColor(gMainGfxPos++, 0, 0, data->unk_20, data->unk_24, data->unk_28, unk_2C);
316 gDPSetEnvColor(gMainGfxPos++, data->unk_30, data->unk_34, data->unk_38, data->unk_3C);
317
318 func_E010E000(data, 0, ptr0);
319 func_E010E000(data, 1, ptr1);
320
321 if (data->unk_54 >= 0) {
322 draw_msg(data->unk_54, data->unk_40 - data->unk_48, data->unk_44, 255, 21, 0);
323 }
324
325 gDPPipeSync(gMainGfxPos++);
326}
Gfx D_0900BE40_3F7CA0[]
Gfx D_0900BF60_3F7DC0[]
Gfx D_0900C038_3F7E98[]
Gfx D_0900BE88_3F7CE8[]
Gfx D_0900C168_3F7FC8[]
UnkStruct D_E010E7D8[]
Gfx D_0900C1F8_3F8058[]
Gfx D_0900BED0_3F7D30[]
#define Y_VAR
UnkStruct D_E010E868[]
void chapter_change_render(EffectInstance *effect)
void func_E010E000(ChapterChangeFXData *data, s32 arg1, UnkStruct *arg2)
Gfx D_0900BFF0_3F7E50[]
Gfx D_0900C328_3F8188[]
Gfx D_0900C080_3F7EE0[]
UnkStruct D_E010E7FC[]
UnkStruct D_E010E79C[]
Gfx D_0900C540_3F83A0[]
Gfx D_0900BFA8_3F7E08[]
Gfx D_0900C458_3F82B8[]
void chapter_change_init(EffectInstance *effect)
EffectInstance * chapter_change_main(s32 arg0, f32 posX, f32 posY, f32 arg3, f32 arg4, s32 duration)
void chapter_change_appendGfx(void *effect)
Gfx D_0900C1B0_3F8010[]
Gfx D_0900C240_3F80A0[]
s32 D_E010E750[]
Gfx D_0900C370_3F81D0[]
Gfx D_0900BF18_3F7D78[]
void chapter_change_update(EffectInstance *effect)
#define X_VAR
UnkStruct D_E010E838[]
#define general_heap_malloc
#define get_msg_width
#define queue_render_task
#define remove_effect
#define draw_msg
#define create_effect_instance
struct ChapterChangeFXData * chapterChange
Definition effects.h:2585
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517
@ LANGUAGE_DE
Definition enums.h:6401
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
#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 *)
#define gCurrentLanguage
Definition variables.h:115
Gfx * gMainGfxPos
Definition cam_main.c:15
Gfx * displayList