Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
pause_main.c
Go to the documentation of this file.
1#include "ld_addrs.h"
2#include "message_ids.h"
3#include "sprite.h"
4#include "pause_common.h"
5#include "game_modes.h"
6#include "sprite/npc/Goombaria.h"
7#include "sprite/npc/WorldGoombario.h"
8#include "sprite/npc/Goompa.h"
9
17
18void pause_tutorial_draw_contents(MenuPanel* menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening);
19void pause_main_draw_contents(MenuPanel* menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening);
20void pause_textbox_draw_contents(MenuPanel* menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening);
21void pause_draw_cursor(MenuPanel* menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening);
22
29BSS s8 D_802700D[7]; //padding
30
31static s32 gPauseTutorialFrameCounter;
32#if !VERSION_IQUE
33static s32 D_802700E4;
34#endif
35static s32 gPauseCommonIconIDs[8];
36static s32 gPauseShownDescMsg;
37static s32 gPauseDescTextMaxPos;
38static s32 gPauseDescTextPos;
39static s32 gPauseDescTextOffset;
40static HudScript* gPauseShownDescIconScript;
41static s32 gPauseTutorialSprites[3];
42
43static HudScript* gPauseIconScripts[] = {
46};
57u32 D_8024EFB4 = 1;
58s16 D_8024EFB8[] = { -10, -25, -42, -60, -80 }; //unused
60s16 gPauseWindowFlipUpAngles[] = { -80, -65, -38, -30, -10, 0 };
61s16 gPauseWindowFlipUpAngles_2[] = { 80, 65, 38, 30, 10, 0 };
63u8 D_8024EFEC[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x11, 0x00, 0x25, 0x00, 0x3C,
64 0x00, 0x55, 0x00, 0x6E }; //unused
65s16 gPauseWindowFlipDownAngles[] = { -10, -25, -42, -60, -80};
66s16 gPauseWindowFlipDownAngles_2[] = { 10, 25, 42, 60, 80 };
70
80
90
91 // unused
101
102s32 gPauseTutorialIconIDs[] = { 5, 4, 5, 5, 5, 5, 6 };
103u8 gPauseMenuTextScrollInterpEasingLUT[] = { 0, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8};
104u8 gPauseMenuPageScrollInterpEasingLUT[] = { 0, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8};
105
107 {
108 ANIM_Goombaria_Still,
109 ANIM_Goombaria_Idle,
110 ANIM_Goombaria_Talk,
112 },
113 {
114 ANIM_WorldGoombario_Still,
115 ANIM_WorldGoombario_Idle,
116 ANIM_WorldGoombario_Talk,
118 },
119 {
120 ANIM_Goompa_Still,
121 ANIM_Goompa_Idle,
122 ANIM_Goompa_Talk,
124 }
125};
127 .vp = {
128 .vscale = { 640, 480, 511, 0 },
129 .vtrans = { 640, 480, 511, 0 },
130 }
131};
134 {
136 .unk_01 = 0,
137 .pos = { .x = 12, .y = 20 },
138 .width = 296,
139 .height = 200,
140 .priority = 0,
141 .fpDrawContents = &pause_main_draw_contents,
142 .tab = NULL,
143 .parentID = WIN_NONE,
144 .fpUpdate = { WINDOW_UPDATE_SHOW },
145 .extraFlags = WINDOW_FLAG_40,
146 .style = { .customStyle = &gPauseWS_0 }
147 },
148 {
149 .windowID = WIN_PAUSE_TUTORIAL,
150 .unk_01 = 0,
151 .pos = { .x = 0, .y = 138 },
152 .width = 296,
153 .height = 63,
154 .priority = 0,
155 .fpDrawContents = &pause_tutorial_draw_contents,
156 .tab = NULL,
157 .parentID = WIN_PAUSE_MAIN,
158 .fpUpdate = { WINDOW_UPDATE_HIDE },
159 .extraFlags = 0,
160 .style = { .customStyle = &gPauseWS_2 }
161 },
162 {
163 .windowID = WIN_PAUSE_DECRIPTION,
164 .unk_01 = 0,
165 .pos = { .x = 20, .y = 164 },
166 .width = 256,
167 .height = 32,
168 .priority = 0,
169 .fpDrawContents = &pause_textbox_draw_contents,
170 .tab = NULL,
171 .parentID = WIN_PAUSE_MAIN,
172 .fpUpdate = { .func = &basic_window_update },
173 .extraFlags = 0,
174 .style = { .customStyle = &gPauseWS_1 }
175 },
176 {
177 .windowID = WIN_PAUSE_CURSOR,
178 .unk_01 = 0,
179 .pos = { .x = 0, .y = 0 },
180 .width = SCREEN_WIDTH,
181 .height = SCREEN_HEIGHT,
182 .priority = 0,
183 .fpDrawContents = &pause_draw_cursor,
184 .tab = NULL,
185 .parentID = WIN_NONE,
186 .fpUpdate = { WINDOW_UPDATE_SHOW },
187 .extraFlags = 0,
188 .style = { .customStyle = &gPauseWS_0 }
189 }
190};
191
195
196void pause_set_cursor_pos_immediate(s32 windowID, s32 posX, s32 posY) {
197 Window* window = &gWindows[windowID];
198
200 if (D_8024EFB4 != 0) {
201 s32 i;
202
203 for (i = WIN_PAUSE_MAIN; i < WIN_PAUSE_CURSOR; i++) {
204 Window* window = &gWindows[i];
205 s8 parent = window->parent;
206
207 if ((parent == WIN_NONE || parent == WIN_PAUSE_MAIN) && (window->flags & WINDOW_FLAG_INITIAL_ANIMATION)) {
208 break;
209 }
210 }
211 if (i >= WIN_PAUSE_CURSOR) {
212 D_8024EFB4 = 0;
213 }
214 }
216 gPauseCursorPosX = posX;
218 gPauseCursorPosY = posY;
219
220 } else if ((window->flags & WINDOW_FLAG_INITIAL_ANIMATION) == 0 && (window->parent == WIN_NONE || !(gWindows[window->parent].flags & WINDOW_FLAG_INITIAL_ANIMATION))) {
222 gPauseCursorPosX = posX;
224 gPauseCursorPosY = posY;
225 }
226}
227
228void pause_set_cursor_pos(s32 windowID, s32 posX, s32 posY) {
229 Window* window = &gWindows[windowID];
230
232 if (D_8024EFB4 != 0) {
233 s32 i;
234
235 for (i = WIN_PAUSE_MAIN; i < WIN_PAUSE_CURSOR; i++) {
236 Window* window = &gWindows[i];
237 s8 parent = window->parent;
238
239 if ((parent == WIN_NONE || parent == WIN_PAUSE_MAIN) && (window->flags & WINDOW_FLAG_INITIAL_ANIMATION)) {
240 break;
241 }
242 }
243 if (i >= 44) {
244 D_8024EFB4 = 0;
245 }
246 }
248 gPauseCursorPosX = posX;
250 gPauseCursorPosY = posY;
251 } else if ((window->flags & WINDOW_FLAG_INITIAL_ANIMATION) == 0 && (window->parent == WIN_NONE || !(gWindows[window->parent].flags & WINDOW_FLAG_INITIAL_ANIMATION))) {
254 }
255}
256
258 s32 xDelta;
259 s32 yDelta;
260 s32* opacity;
261
262 xDelta = (gPauseCursorTargetPosX - gPauseCursorPosX) * 0.5;
263 yDelta = (gPauseCursorTargetPosY - gPauseCursorPosY) * 0.5;
264
266 if ((xDelta == 0) && (yDelta == 0)) {
269 }
270 }
271
272 gPauseCursorPosX += xDelta;
273 gPauseCursorPosY += yDelta;
274
275 if (gPauseCursorTargetOpacity == 0) {
276 gPauseCursorOpacity -= 128;
277 if (gPauseCursorOpacity < 0) {
279 }
280 } else {
282 if (gPauseCursorOpacity> 255) {
284 }
285 }
287}
288
289void pause_update_tab_default(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
290 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity) {
291 Window* window = &gWindows[windowIndex];
292
293 *darkening = 160;
295}
296
297void func_80242FBC(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
298 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity) {
299 Window* window = &gWindows[windowIndex];
300
301 *darkening = 160;
302 *opacity = 80;
304}
305
306void pause_update_tab_inactive(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
307 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity) {
308 Window* window = &gWindows[windowIndex];
309 s32 updateCounter = window->updateCounter;
310
311 if (updateCounter == 0) {
312 window->flags &= ~WINDOW_FLAG_HIDDEN;
313 }
314
315 if (updateCounter == 5) {
316 update_window_hierarchy(windowIndex, window->originalPriority);
317 }
318
319 if (updateCounter < 10) {
320 *darkening = (updateCounter + 1) * 16;
321 } else {
322 *darkening = 160;
323 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
324 }
325}
326
327void pause_update_tab_active(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
328 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity) {
329 Window* window = &gWindows[windowIndex];
330
331 if (window->updateCounter == 0) {
332 update_window_hierarchy(windowIndex, window->originalPriority);
333 *darkening = 0;
334 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
335 }
336}
337
338void func_802430E4(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
339 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity) {
340 Window* window = &gWindows[windowIndex];
341 s32 updateCounter = window->updateCounter;
342
343 if (updateCounter == 0) {
344 window->flags &= ~WINDOW_FLAG_HIDDEN;
345 }
346
347 if (updateCounter < 16) {
348 *opacity = updateCounter * 16;
349 } else {
350 *opacity = 255;
351 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
352 }
353}
354
355void func_8024313C(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
356 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity) {
357 Window* window = &gWindows[windowIndex];
358 s32 updateCounter = window->updateCounter;
359
360 if (updateCounter < 16) {
361 *opacity = 255 - (updateCounter * 16);
362 } else {
363 *opacity = 0;
364 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
365 window->flags |= WINDOW_FLAG_HIDDEN;
366 }
367}
368
369void pause_update_page_active_2(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
370 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity) {
371 Window* window = &gWindows[windowIndex];
372 s32 updateCounter = window->updateCounter;
373
374 if (updateCounter == 0) {
375 window->flags &= ~WINDOW_FLAG_HIDDEN;
376 }
377 if (updateCounter < 7) {
378 *flags = gPauseWindowFlipUpFlags[updateCounter];
379 *rotX += gPauseWindowFlipUpAngles[updateCounter];
380 } else {
382 *rotX += gPauseWindowFlipUpAngles[6];
383 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
384 }
385}
386
387void pause_update_page_active_1(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
388 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity) {
389 Window* window = &gWindows[windowIndex];
390 s32 updateCounter = window->updateCounter;
391
392 if (updateCounter == 0) {
393 window->flags &= ~WINDOW_FLAG_HIDDEN;
394 }
395 if (updateCounter < 7) {
396 *flags = gPauseWindowFlipUpFlags[updateCounter];
397 *rotX += gPauseWindowFlipUpAngles_2[updateCounter];
398 } else {
400 *rotX += gPauseWindowFlipUpAngles_2[6];
401 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
402 }
403}
404
405void pause_update_page_inactive_1(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
406 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity) {
407 Window* window = &gWindows[windowIndex];
408 s32 updateCounter = window->updateCounter;
409
410 if (updateCounter < 5) {
411 *flags = gPauseWindowFlipDownFlags[updateCounter];
412 *rotX += gPauseWindowFlipDownAngles[updateCounter];
413 } else {
415 *rotX += gPauseWindowFlipDownAngles[4];
416 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
417 window->flags |= WINDOW_FLAG_HIDDEN;
418 }
419}
420
421void pause_update_page_inactive_2(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
422 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity) {
423 Window* window = &gWindows[windowIndex];
424 s32 updateCounter = window->updateCounter;
425
426 if (updateCounter < 5) {
427 *flags = gPauseWindowFlipDownFlags[updateCounter];
428 *rotX = gPauseWindowFlipDownAngles_2[updateCounter];
429 } else {
432 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
433 window->flags |= WINDOW_FLAG_HIDDEN;
434 }
435}
436
437s32 pause_interp_text_scroll(s32 deltaBefore) {
438 s32 val;
439 s32 db = abs(deltaBefore);
440 s32 s = sign(deltaBefore);
441
442 if (db >= 16) {
443 val = 8;
444 } else {
446 }
447
448 return val * s;
449}
450
451s32 pause_interp_vertical_scroll(s32 deltaBefore) {
452 s32 val;
453 s32 db = abs(deltaBefore);
454 s32 s = sign(deltaBefore);
455
456 if (db >= 16) {
457 val = db / 2;
458 if (val > 20) {
459 val = 20;
460 }
461 } else {
463 }
464
465 return val * s;
466}
467
468void pause_draw_cursor(MenuPanel* menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening) {
469 s32 currentOpacity;
470
472 currentOpacity = gPauseCursorOpacity;
473 if (currentOpacity > 0) {
474 if (currentOpacity > 255) {
475 currentOpacity = 255;
476 }
477 hud_element_set_alpha(gPauseCommonIconIDs[0], currentOpacity);
478 hud_element_set_render_pos(gPauseCommonIconIDs[0], baseX + gPauseCursorPosX, baseY + gPauseCursorPosY);
479 hud_element_draw_without_clipping(gPauseCommonIconIDs[0]);
480 }
481}
482
483void pause_main_draw_contents(MenuPanel* menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening) {
484}
485
486void pause_textbox_draw_contents(MenuPanel* menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening) {
487 s32 msgID = gPauseShownDescMsg;
488
489 if (msgID == MSG_NONE) {
490 return;
491 }
492
493 if (gPauseDescTextPos != 0) {
494 hud_element_set_render_pos(gPauseCommonIconIDs[1], baseX + width - 4, baseY + 4);
495 hud_element_draw_without_clipping(gPauseCommonIconIDs[1]);
496 }
497
498 if (gPauseDescTextPos < gPauseDescTextMaxPos) {
499 hud_element_set_render_pos(gPauseCommonIconIDs[2], baseX + width - 4, baseY + height - 4);
500 hud_element_draw_without_clipping(gPauseCommonIconIDs[2]);
501 }
502
503 gDPPipeSync(gMainGfxPos++);
504 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, baseX + 1, baseY + 1, baseX + width - 1, baseY + height - 1);
505 draw_msg(msgID, baseX + 10, baseY - gPauseDescTextOffset, 255, MSG_PAL_STANDARD, 0);
506 if (gPauseShownDescIconScript != 0) {
507 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
508 hud_element_set_render_pos(gPauseCommonIconIDs[3], baseX - 4, baseY + 16);
509 hud_element_set_script(gPauseCommonIconIDs[3], gPauseShownDescIconScript);
512 hud_element_set_scale(gPauseCommonIconIDs[3], 1.0f);
513 hud_element_draw_without_clipping(gPauseCommonIconIDs[3]);
514 }
515}
516
517void pause_tutorial_draw_contents(MenuPanel* menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening) {
518 Matrix4f matrix1;
519 Matrix4f matrix2;
520 f32 (*matrix2ptr)[4];
521 s32 msgHeight;
522 s32 msgWidth;
523 s32 msgMaxLineChars;
524 s32 msgNumLines;
525 s32 msgMaxLinesPerPage;
526 s32 msgHeight2;
527 u32 msgWidth2;
528 s32 msgMaxLineChars2;
529 s32 msgNumLines2;
530 s32 msgMaxLinesPerPage2;
531 s32 i;
532 s32 margin, margin2;
533 s32 state;
534
535 if (evt_get_variable(NULL, GF_Tutorial_Badges) == FALSE) {
536 return;
537 }
538
539 gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
540 gDPSetRenderMode(gMainGfxPos++, G_RM_CLD_SURF, G_RM_CLD_SURF2);
541 gDPSetCombineMode(gMainGfxPos++, G_CC_PRIMITIVE, G_CC_PRIMITIVE);
542 gDPSetPrimColor(gMainGfxPos++, 0, 0, 55, 55, 55, 255);
543 pause_draw_rect(baseX * 4, baseY * 4, (baseX + width) * 4, (baseY + 12) * 4, 0, 0, 0, 0, 0);
544 gDPPipeSync(gMainGfxPos++);
545 gDPSetPrimColor(gMainGfxPos++, 0, 0, 185, 185, 185, 255);
546 pause_draw_rect(baseX * 4, (baseY + 12) * 4, (baseX + width) * 4, (baseY + height) * 4, 0, 0, 0, 0, 0);
547 gDPPipeSync(gMainGfxPos++);
548 gSPViewport(gMainGfxPos++, &gPauseTutorialViewport);
549 guOrthoF(matrix1, 0.0f, 320.0f, 240.0f, 0.0f, -100.0f, 100.0f, 1.0f);
551 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
552
553 for (i = 0; i < 3; i++) {
554 //needed to match
555 matrix2ptr = matrix2;
556 switch (i) {
557 case 0:
558 guTranslateF(matrix1, 40.0f, 223.0f, 0);
559 guScaleF(matrix2ptr, -0.8f, 0.8f, 1.0f);
560 break;
561 case 1:
562 guTranslateF(matrix1, 60.0f, 223.0f, 0);
563 guScaleF(matrix2ptr, -0.8f, 0.8f, 1.0f);
564 break;
565 default:
566 guTranslateF(matrix1, 280.0f, 223.0f, 0);
567 guScaleF(matrix2ptr, 0.8f, 0.8f, 1.0f);
568 break;
569 }
570
571 guMtxCatF(matrix2ptr, matrix1, matrix1);
572 guRotateF(matrix2ptr, 180.0f, 0.0f, 0.0f, 1.0f);
573 guMtxCatF(matrix2ptr, matrix1, matrix1);
574 guRotateF(matrix2ptr, 180.0f, 0.0f, 1.0f, 0.0f);
575 guMtxCatF(matrix2ptr, matrix1, matrix1);
577 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
578 set_npc_imgfx_all(gPauseTutorialSprites[i], IMGFX_SET_COLOR, 255, 255, 255, 255, 64);
579 spr_draw_npc_sprite(gPauseTutorialSprites[i], 0, 0, 0, matrix1);
580 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
581 }
582
583 get_msg_properties(pause_get_menu_msg(PAUSE_MSG_TUT_NAME_BADGES), &msgHeight, &msgWidth, &msgMaxLineChars, &msgNumLines, &msgMaxLinesPerPage, NULL, 1);
584 margin = (s32)(width - msgWidth) >> 1;
587 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, baseX + 1, baseY + 1, baseX + width - 1, baseY + height - 1);
588 state = gPauseTutorialState;
589 get_msg_properties(pause_get_menu_msg(gPauseTutorialDescMessages[state]), &msgHeight2, &msgWidth2, &msgMaxLineChars2, &msgNumLines2, &msgMaxLinesPerPage2, NULL, 1);
590 margin2 = (s32)(width - msgWidth2) >> 1;
592 hud_element_set_render_pos(gPauseCommonIconIDs[gPauseTutorialIconIDs[gPauseTutorialState]], baseX + width / 2 - 2, baseY + 52);
596
598 hud_element_set_render_pos(gPauseCommonIconIDs[7], baseX + width / 2 + 1, baseY + 50);
599 hud_element_draw_without_clipping(gPauseCommonIconIDs[7]);
600 }
601
602 draw_msg(pause_get_menu_msg(gPauseTutorialCmdMessages[gPauseTutorialState]), baseX + width / 2 + 10, baseY + 44, 255, MSG_PAL_STANDARD, 0);
603}
604
605void pause_init(void) {
606 s32 posX;
607 s32 x;
608 Window* pauseWindows;
609 MenuPanel** menuPanels;
610 s32 i;
611
612 DMA_COPY_SEGMENT(ui_images_filemenu_pause);
613
614 for (i = 0; i < ARRAY_COUNT(gPauseIconScripts); i++) {
615 gPauseCommonIconIDs[i] = hud_element_create(gPauseIconScripts[i]);
616 if (gPauseIconScripts[i] == &HES_AnimatedCursorHand) {
618 } else {
619 hud_element_set_flags(gPauseCommonIconIDs[i], HUD_ELEMENT_FLAG_80);
620 }
621 }
622
623 gPauseCursorIconID = gPauseCommonIconIDs[0];
625 gPauseShownDescMsg = 0;
626 gPauseDescTextPos = 0;
627 gPauseDescTextOffset = 0;
628 gPauseDescTextMaxPos = 0;
629 gPauseShownDescIconScript = 0;
630 gPauseCurrentDescMsg = MSG_NONE;
633
634 menuPanels = gPausePanels;
635 for (i = 0; i < ARRAY_COUNT(gPausePanels); menuPanels++, i++) {
636 if ((*menuPanels)->fpInit) {
637 (*menuPanels)->fpInit(*menuPanels);
638 }
639 }
640
641 posX = 225;
642 for (i = 6; i > 0; i--) {
643 if (!gPausePanels[i]->initialized) {
645 } else {
646 gWindows[WIN_PAUSE_TUTORIAL + i].pos.x = posX + 14;
647 posX -= 45;
648 }
649 }
650 pauseWindows = &gWindows[WIN_PAUSE_TAB_STATS];
651 x = pauseWindows[gPausePanels[0]->col].pos.x;
653
655 for (i = 0; i < ARRAY_COUNT(gPauseTutorialSpriteAnims); i++) {
656 gPauseTutorialSprites[i] = spr_load_npc_sprite(gPauseTutorialSpriteAnims[i][0], gPauseTutorialSpriteAnims[i]);
657 }
658
661 }
662
664}
665
666void pause_tutorial_input(s32 *pressed, s32 *held) {
667 s32 pressedOld = *pressed;
668 s32 pressedNew = *pressed;
669 s32 heldNew = *held;
670
671 switch (gPauseTutorialInputState) {
672 case 0:
673 heldNew = pressedNew = pressedNew & gPauseTutorialButtons[gPauseTutorialState];
674 if (pressedNew) {
676 }
677 if (pressedOld && pressedNew == 0) {
679 }
680 if (gPauseTutorialState == 0) {
681 pressedNew = 0;
682 heldNew = 0;
683 }
684 break;
685 case 1:
686 gPauseTutorialFrameCounter = 0;
688 pressedNew = 0;
689 heldNew = 0;
690 break;
691 case 2:
692 if (--gPauseTutorialFrameCounter <= 0) {
694 }
695 pressedNew = 0;
696 heldNew = 0;
697 break;
698 case 3:
699 gPauseTutorialFrameCounter = 16;
702 pressedNew = 0;
703 heldNew = 0;
704 break;
705 case 4:
706 if (--gPauseTutorialFrameCounter <= 0) {
708 }
709 pressedNew = 0;
710 heldNew = 0;
711 break;
712 }
713
714 *pressed = pressedNew;
715 *held = heldNew;
716}
717
718void pause_handle_input(s32 pressed, s32 held) {
719 s32 height;
720 s32 width;
721 s32 maxLineChars;
722 s32 numLines;
723 s32 i,j;
724 MenuPanel** menuPanels;
725 s32 currentDescMsg = gPauseCurrentDescMsg;
727
729 for (i = 0; i < ARRAY_COUNT(gPauseTutorialSprites); i++) {
730 spr_update_sprite(gPauseTutorialSprites[i], gPauseTutorialSpriteAnims[i][1], 1.0f);
731 }
732 }
733
734 gPausePressedButtons = pressed;
735 gPauseHeldButtons = held;
738 }
739
744 return;
745 }
746
747 if (gPauseCurrentDescIconScript != gPauseShownDescIconScript) {
748 gPauseShownDescIconScript = gPauseCurrentDescIconScript;
749 }
750
751 if (currentDescMsg != gPauseShownDescMsg) {
752 gPauseShownDescMsg = currentDescMsg;
753 gPauseDescTextPos = 0;
754 gPauseDescTextOffset = 0;
755 if (currentDescMsg != 0) {
756 get_msg_properties(currentDescMsg, &height, &width, &maxLineChars, &numLines, NULL, NULL, 0);
757 if (numLines % 2) {
758 numLines++;
759 }
760 gPauseDescTextMaxPos = numLines - 2;
761 if (gPauseDescTextMaxPos < 0) {
762 gPauseDescTextMaxPos = 0;
763 }
764 } else {
765 gPauseDescTextMaxPos = 0;
766 }
767 }
769 gPauseDescTextPos -= 2;
770 if (gPauseDescTextPos < 0) {
771 gPauseDescTextPos = 0;
772 }
773 }
775 gPauseDescTextPos += 2;
776 if (gPauseDescTextPos > gPauseDescTextMaxPos) {
777 gPauseDescTextPos = gPauseDescTextMaxPos;
778 }
779 }
780 gPauseDescTextOffset += pause_interp_text_scroll(gPauseDescTextPos * 16 - gPauseDescTextOffset);
781 if (currentPanel->initialized) {
782 if (currentPanel->fpHandleInput) {
783 currentPanel->fpHandleInput(currentPanel);
784 }
785 }
786 menuPanels = gPausePanels;
787 for (i = 0; i < ARRAY_COUNT(gPausePanels); menuPanels++, i++) {
788 if ((*menuPanels)->initialized) {
789 if ((*menuPanels)->fpUpdate) {
790 (*menuPanels)->fpUpdate(*menuPanels);
791 }
792 }
793 }
794}
795
796void pause_cleanup(void) {
797 s32 i;
798 MenuPanel** menuPanels;
799
800 for (i = 0; i < ARRAY_COUNT(gPauseCommonIconIDs); i++) {
801 hud_element_free(gPauseCommonIconIDs[i]);
802 }
803
805 for (i = 0; i < ARRAY_COUNT(gPauseTutorialSprites); i++) {
806 spr_free_sprite(gPauseTutorialSprites[i]);
807 }
808 }
809
810 menuPanels = gPausePanels;
811 for (i = 0; i < ARRAY_COUNT(gPausePanels); menuPanels++, i++) {
812 if ((*menuPanels)->initialized) {
813 if ((*menuPanels)->fpCleanup) {
814 (*menuPanels)->fpCleanup(*menuPanels);
815 }
816 }
817 }
818
819 for (i = WIN_PAUSE_MAIN; i < WIN_PAUSE_CURSOR; i++)
821
823}
824
826 s32 totalCost = 0;
827 s32 i;
828
829 for (i = 0; i < ARRAY_COUNT(gPlayerData.equippedBadges); i++) {
830 s16 itemID = gPlayerData.equippedBadges[i];
831
832 if (itemID != ITEM_NONE) {
833 s32 moveID = gItemTable[itemID].moveID;
834
835 totalCost += gMoveTable[moveID].costBP;
836 }
837 }
838 return totalCost;
839}
840
841void pause_draw_rect(s32 ulx, s32 uly, s32 lrx, s32 lry, s32 tileIdx, s32 uls, s32 ult, s32 dsdx, s32 dtdy) {
842 if (ulx <= -2688 || uly <= -2688 || lrx <= 0 || lry <= 0) {
843 return;
844 }
845 if (ulx >= 1280 || uly >= 960 || lrx >= 2688 || lry >= 2688) {
846 return;
847 }
848 gSPScisTextureRectangle(gMainGfxPos++, ulx, uly, lrx, lry, tileIdx, uls, ult, dsdx, dtdy);
849}
850
851void pause_sort_item_list(s16* arr, s32 len, s32 (*compare)(s16*, s16 *)) {
852 if (len < 2) {
853 // Trivially sorted
854 return;
855 } else if (len == 2) {
856 // Trivial 2-element sort
857 if (compare(&arr[0], &arr[1]) > 0) {
858 s16 temp = arr[0];
859 arr[0] = arr[1];
860 arr[1] = temp;
861 }
862 } else {
863 // Nontrivial sort required, use shell sort
864 u32 gap = 1;
865 s16* end;
866
867 while (gap < len) {
868 gap = gap * 2 + 1;
869 }
870
871 end = &arr[len];
872 while ((gap /= 2) != 0) {
873 s16* window_end;
874
875 for (window_end = &arr[gap]; window_end < end; window_end++) {
876 s16* cur_elem = window_end - gap;
877
878 // This could be written simpler as a while loop, but the compiler figures out that it only needs to do
879 // the "cur_elem < end" check on the first iteration in that case
880 if (cur_elem >= arr && cur_elem < end) {
881 do {
882 s16* elem_a = cur_elem;
883 s16* elem_b = cur_elem + gap;
884
885 if (compare(elem_a, elem_b) > 0) {
886 s16 temp = *elem_a;
887 *elem_a = *elem_b;
888 *elem_b = temp;
889 cur_elem -= gap;
890 } else {
891 break;
892 }
893 } while (cur_elem >= arr && cur_elem < end);
894 }
895 }
896 }
897 }
898}
899
900static const f32 rodata_padding[] = {0.0f, 0.0f, 0.0f};
HudScript HES_PressAButton
HudScript HES_StickTapRight
s16 equippedBadges[64]
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
s8 flags
Definition demo_api.c:15
#define guRotateF
#define guOrthoF
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define draw_msg
#define guScaleF
@ DRAW_MSG_STYLE_MENU
Definition enums.h:5385
@ BUTTON_A
Definition enums.h:2790
@ BUTTON_C_UP
Definition enums.h:2780
@ BUTTON_START
Definition enums.h:2787
@ BUTTON_C_DOWN
Definition enums.h:2779
@ BUTTON_STICK_RIGHT
Definition enums.h:2794
@ BUTTON_B
Definition enums.h:2789
@ IMGFX_SET_COLOR
Definition enums.h:5123
@ DRAW_FLAG_ROTSCALE
Definition enums.h:5003
@ MSG_PAL_WHITE
Definition enums.h:5405
@ MSG_PAL_STANDARD
Definition enums.h:5415
@ WINDOW_UPDATE_SHOW
Definition enums.h:5311
@ WINDOW_UPDATE_HIDE
Definition enums.h:5312
@ WINDOW_FLAG_40
Definition enums.h:4999
@ WINDOW_FLAG_INITIAL_ANIMATION
Definition enums.h:4996
@ WINDOW_FLAG_HIDDEN
Updated but not rendered.
Definition enums.h:4995
@ SOUND_MENU_CLOSE
Definition enums.h:697
@ SOUND_MENU_SHOW_CHOICE
Definition enums.h:554
@ SOUND_MENU_ERROR
Definition enums.h:933
@ WIN_PAUSE_TAB_INVIS
Definition enums.h:5286
@ WIN_PAUSE_CURSOR
Definition enums.h:5287
@ WIN_PAUSE_MAIN
Definition enums.h:5263
@ WIN_PAUSE_TAB_STATS
Definition enums.h:5268
@ WIN_NONE
Definition enums.h:5240
@ WIN_PAUSE_TUTORIAL
Definition enums.h:5266
@ WIN_PAUSE_DECRIPTION
Definition enums.h:5264
HudScript HES_AnimatedCursorHand
s32 sign(s32 value)
Definition 43F0.c:376
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
void set_window_update(s32 panelID, s32)
Definition windows.c:434
void basic_window_update(s32 windowIndex, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
Definition windows.c:161
void update_window_hierarchy(s32 windowIndex, u8 arg1)
Definition windows.c:393
void setup_pause_menu_tab(MenuWindowBP *bpArray, s32 arraySize)
Definition windows.c:461
void get_msg_properties(s32 msgID, s32 *height, s32 *width, s32 *maxLineChars, s32 *numLines, s32 *maxLinesPerPage, s32 *arg6, u16 charset)
Definition msg.c:1671
void enforce_hpfp_limits(void)
Definition inventory.c:457
s32 get_game_mode(void)
Definition game_modes.c:123
void set_game_mode(s32 modeID)
Definition game_modes.c:127
@ GAME_MODE_UNPAUSE
Definition game_modes.h:18
@ GAME_MODE_END_FILE_SELECT
Definition game_modes.h:20
HudScript HES_PressStartButton
HudScript HES_StartButtonText
void hud_element_set_scale(s32 index, f32 scale)
void hud_element_set_alpha(s32 id, s32 opacity)
void hud_element_draw_without_clipping(s32 id)
void hud_element_set_script(s32 id, HudScript *anim)
void hud_element_set_render_pos(s32 id, s32 x, s32 y)
s32 hud_element_create(HudScript *anim)
Creates a new HUD element and returns its ID.
void hud_element_set_flags(s32 id, s32 flags)
Turns on the given flags.
void hud_element_clear_flags(s32 id, s32 flags)
Turns off the given flags.
void hud_element_free(s32 id)
@ HUD_ELEMENT_FLAG_80
Definition hud_element.h:80
@ HUD_ELEMENT_FLAG_DROP_SHADOW
@ HUD_ELEMENT_FLAG_FILTER_TEX
Definition hud_element.h:88
s32 HudScript[]
Definition hud_element.h:9
HudScript HES_DescMsgNext
HudScript HES_DescMsgPrev
HudScript HES_UnusedBadge
WindowStyleCustom gPauseWS_2
WindowStyleCustom gPauseWS_0
WindowStyleCustom gPauseWS_1
s32 pause_get_menu_msg(s32 index)
Definition pause_gfx.c:583
@ PAUSE_MSG_TUT_DESC_3
@ PAUSE_MSG_TUT_DESC_5
@ PAUSE_MSG_TUT_CMD_4
@ PAUSE_MSG_TUT_DESC_4
@ PAUSE_MSG_TUT_DESC_1
@ PAUSE_MSG_TUT_UNUSED_6
@ PAUSE_MSG_TUT_CMD_3
@ PAUSE_MSG_TUT_UNUSED_2
@ PAUSE_MSG_TUT_CMD_1
@ PAUSE_MSG_TUT_CMD_5
@ PAUSE_MSG_TUT_UNUSED_5
@ PAUSE_MSG_TUT_DESC_2
@ PAUSE_MSG_TUT_DESC_6
@ PAUSE_MSG_TUT_UNUSED_7
@ PAUSE_MSG_TUT_CMD_6
@ PAUSE_MSG_TUT_UNUSED_3
@ PAUSE_MSG_TUT_UNUSED_4
@ PAUSE_MSG_TUT_DESC_7
@ PAUSE_MSG_TUT_CMD_2
@ PAUSE_MSG_TUT_NAME_BADGES
@ PAUSE_MSG_TUT_CMD_7
@ PAUSE_MSG_TUT_UNUSED_1
u8 gPauseWindowFlipUpFlags[]
Definition pause_main.c:59
u8 gPauseMenuPageScrollInterpEasingLUT[]
Definition pause_main.c:104
s32 gPauseCursorTargetPosX
Definition pause_main.c:54
void pause_handle_input(s32 pressed, s32 held)
Definition pause_main.c:718
s32 gPauseCursorOpacity
Definition pause_main.c:53
MenuPanel gPausePanelSpirits
MenuPanel gPausePanelMap
Definition pause_map.c:76
s32 gPauseTutorialInputState
Definition pause_main.c:68
s16 D_8024EFB8[]
Definition pause_main.c:58
s16 gPauseWindowFlipUpAngles_2[]
Definition pause_main.c:61
MenuPanel gPausePanelTabs
Definition pause_tabs.c:185
void pause_update_page_active_2(s32 windowIndex, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
Definition pause_main.c:369
s32 pause_interp_vertical_scroll(s32 deltaBefore)
Definition pause_main.c:451
void pause_tutorial_draw_contents(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
Definition pause_main.c:517
BSS s8 gPauseMenuCurrentTab
Definition pause_main.c:28
void func_802430E4(s32 windowIndex, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
Definition pause_main.c:338
BSS s32 gPausePressedButtons
Definition pause_main.c:24
s32 gPauseTutorialSpriteAnims[][4]
Definition pause_main.c:106
s32 gPauseTutorialScrollPos
Definition pause_main.c:132
s32 gPauseTutorialState
Definition pause_main.c:67
s16 gPauseWindowFlipDownAngles[]
Definition pause_main.c:65
s32 gPauseTutorialDescMessages[]
Definition pause_main.c:71
BSS HudScript * gPauseCurrentDescIconScript
Definition pause_main.c:26
s32 gPauseCursorPosX
Definition pause_main.c:51
BSS s8 D_802700D[7]
Definition pause_main.c:29
MenuPanel gPausePanelStats
s32 gPauseTutorialCmdMessages[]
Definition pause_main.c:81
void pause_main_draw_contents(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
Definition pause_main.c:483
BSS s32 gPauseCursorIconID
Definition pause_main.c:27
s32 gPauseCursorTargetPosY
Definition pause_main.c:55
void pause_update_page_inactive_2(s32 windowIndex, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
Definition pause_main.c:421
s32 D_8024F074[]
Definition pause_main.c:92
void func_80242FBC(s32 windowIndex, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
Definition pause_main.c:297
s32 pause_get_total_equipped_bp_cost(void)
Definition pause_main.c:825
MenuPanel * gPausePanels[]
Definition pause_main.c:47
s32 pause_interp_text_scroll(s32 deltaBefore)
Definition pause_main.c:437
u8 gPauseWindowFlipDownFlags[]
Definition pause_main.c:62
void pause_cleanup(void)
Definition pause_main.c:796
void pause_set_cursor_opacity(s32 val)
Definition pause_main.c:192
s32 gPauseCursorPosY
Definition pause_main.c:52
void pause_update_tab_inactive(s32 windowIndex, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
Definition pause_main.c:306
void func_8024313C(s32 windowIndex, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
Definition pause_main.c:355
BSS s32 gPauseHeldButtons
Definition pause_main.c:23
void pause_interp_cursor(void)
Definition pause_main.c:257
void pause_draw_cursor(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
Definition pause_main.c:468
void pause_set_cursor_pos_immediate(s32 windowID, s32 posX, s32 posY)
Definition pause_main.c:196
void pause_update_tab_active(s32 windowIndex, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
Definition pause_main.c:327
u8 gPauseMenuTextScrollInterpEasingLUT[]
Definition pause_main.c:103
MenuPanel gPausePanelItems
Definition pause_items.c:52
void pause_textbox_draw_contents(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
Definition pause_main.c:486
Vp gPauseTutorialViewport
Definition pause_main.c:126
void pause_update_page_inactive_1(s32 windowIndex, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
Definition pause_main.c:405
void pause_update_tab_default(s32 windowIndex, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
Definition pause_main.c:289
void pause_init(void)
Definition pause_main.c:605
s16 gPauseWindowFlipDownAngles_2[]
Definition pause_main.c:66
u32 D_8024EFB4
Definition pause_main.c:57
BSS s32 gPauseCurrentDescMsg
Definition pause_main.c:25
void pause_update_page_active_1(s32 windowIndex, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
Definition pause_main.c:387
s16 gPauseWindowFlipUpAngles[]
Definition pause_main.c:60
s32 gPauseTutorialIconIDs[]
Definition pause_main.c:102
MenuPanel gPausePanelPartners
s32 gPauseTutorialButtons[]
Definition pause_main.c:69
void pause_set_cursor_pos(s32 windowID, s32 posX, s32 posY)
Definition pause_main.c:228
void pause_draw_rect(s32 ulx, s32 uly, s32 lrx, s32 lry, s32 tileIdx, s32 uls, s32 ult, s32 dsdx, s32 dtdy)
Definition pause_main.c:841
u8 D_8024EFEC[]
Definition pause_main.c:63
s32 gPauseCursorTargetOpacity
Definition pause_main.c:56
void pause_sort_item_list(s16 *arr, s32 len, s32(*compare)(s16 *, s16 *))
Definition pause_main.c:851
void pause_tutorial_input(s32 *pressed, s32 *held)
Definition pause_main.c:666
MenuWindowBP gPauseCommonWindowsBPs[]
Definition pause_main.c:133
MenuPanel gPausePanelBadges
void sfx_play_sound(s32 soundID)
Definition sfx.c:517
@ GF_Tutorial_Badges
#define DMA_COPY_SEGMENT(segment)
Definition macros.h:525
#define SCREEN_WIDTH
Definition macros.h:105
#define BSS
Definition macros.h:7
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define SCREEN_HEIGHT
Definition macros.h:106
s32 spr_draw_npc_sprite(s32 spriteInstanceID, s32 yaw, s32 arg2, PAL_PTR *paletteList, Matrix4f mtx)
Definition sprite.c:1106
s32 spr_update_sprite(s32 spriteInstanceID, s32 animID, f32 timeScale)
Definition sprite.c:1072
s32 spr_free_sprite(s32 spriteInstanceID)
Definition sprite.c:1178
void set_npc_imgfx_all(s32 spriteIdx, ImgFXType imgfxType, s32 imgfxArg1, s32 imgfxArg2, s32 imgfxArg3, s32 imgfxArg4, s32 imgfxArg5)
Definition sprite.c:1254
s32 spr_load_npc_sprite(s32 animID, u32 *extraAnimList)
Definition sprite.c:1026
void(* fpHandleInput)(struct MenuPanel *)
void(* fpUpdate)(struct MenuPanel *)
void(* fpCleanup)(struct MenuPanel *)
void(* fpInit)(struct MenuPanel *)
u8 originalPriority
#define ANIM_LIST_END
Terminates an extraAnimationList.
Definition types.h:22
ItemData gItemTable[]
Gfx * gMainGfxPos
Definition cam_main.c:15
PlayerData gPlayerData
Definition 77480.c:40
u16 gMatrixListPos
Definition main_loop.c:45
MoveData gMoveTable[]
Window gWindows[64]
Definition windows.c:23
DisplayContext * gDisplayContext
Definition cam_main.c:16