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;
32static HudElemID gPauseCommonHIDs[8];
33static s32 gPauseShownDescMsg;
34static s32 gPauseDescTextMaxPos;
35static s32 gPauseDescTextPos;
36static s32 gPauseDescTextOffset;
37static HudScript* gPauseShownDescIconScript;
38static s32 gPauseTutorialSprites[3];
39
40static HudScript* gPauseHudScripts[] = {
43};
55s16 D_8024EFB8[] = { -10, -25, -42, -60, -80 }; //unused
57s16 gPauseWindowFlipUpAngles[] = { -80, -65, -38, -30, -10, 0 };
58s16 gPauseWindowFlipUpAngles_2[] = { 80, 65, 38, 30, 10, 0 };
60u8 D_8024EFEC[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x11, 0x00, 0x25, 0x00, 0x3C,
61 0x00, 0x55, 0x00, 0x6E }; //unused
62s16 gPauseWindowFlipDownAngles[] = { -10, -25, -42, -60, -80};
63s16 gPauseWindowFlipDownAngles_2[] = { 10, 25, 42, 60, 80 };
67
77
87
88 // unused
98
99s32 gPauseTutorialIconIDs[] = { 5, 4, 5, 5, 5, 5, 6 };
100u8 gPauseMenuTextScrollInterpEasingLUT[] = { 0, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8};
101u8 gPauseMenuPageScrollInterpEasingLUT[] = { 0, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8};
102
124 .vp = {
125 .vscale = { 640, 480, 511, 0 },
126 .vtrans = { 640, 480, 511, 0 },
127 }
128};
131 {
133 .unk_01 = 0,
134 .pos = { .x = 12, .y = 20 },
135 .width = 296,
136 .height = 200,
137 .priority = 0,
138 .fpDrawContents = &pause_main_draw_contents,
139 .tab = nullptr,
140 .parentID = WIN_NONE,
141 .fpUpdate = { WINDOW_UPDATE_SHOW },
142 .extraFlags = WINDOW_FLAG_40,
143 .style = { .customStyle = &gPauseWS_0 }
144 },
145 {
146 .windowID = WIN_PAUSE_TUTORIAL,
147 .unk_01 = 0,
148 .pos = { .x = 0, .y = 138 },
149 .width = 296,
150 .height = 63,
151 .priority = 0,
152 .fpDrawContents = &pause_tutorial_draw_contents,
153 .tab = nullptr,
154 .parentID = WIN_PAUSE_MAIN,
155 .fpUpdate = { WINDOW_UPDATE_HIDE },
156 .extraFlags = 0,
157 .style = { .customStyle = &gPauseWS_2 }
158 },
159 {
160 .windowID = WIN_PAUSE_DECRIPTION,
161 .unk_01 = 0,
162 .pos = { .x = 20, .y = 164 },
163 .width = 256,
164 .height = 32,
165 .priority = 0,
166 .fpDrawContents = &pause_textbox_draw_contents,
167 .tab = nullptr,
168 .parentID = WIN_PAUSE_MAIN,
169 .fpUpdate = { .func = &basic_window_update },
170 .extraFlags = 0,
171 .style = { .customStyle = &gPauseWS_1 }
172 },
173 {
174 .windowID = WIN_PAUSE_CURSOR,
175 .unk_01 = 0,
176 .pos = { .x = 0, .y = 0 },
177 .width = SCREEN_WIDTH,
178 .height = SCREEN_HEIGHT,
179 .priority = 0,
180 .fpDrawContents = &pause_draw_cursor,
181 .tab = nullptr,
182 .parentID = WIN_NONE,
183 .fpUpdate = { WINDOW_UPDATE_SHOW },
184 .extraFlags = 0,
185 .style = { .customStyle = &gPauseWS_0 }
186 }
187};
188
192
193void pause_set_cursor_pos_immediate(s32 windowID, s32 posX, s32 posY) {
194 Window* window = &gWindows[windowID];
195
197 if (D_8024EFB4 != 0) {
198 s32 i;
199
200 for (i = WIN_PAUSE_MAIN; i < WIN_PAUSE_CURSOR; i++) {
201 Window* window = &gWindows[i];
202 s8 parent = window->parent;
203
204 if ((parent == WIN_NONE || parent == WIN_PAUSE_MAIN) && (window->flags & WINDOW_FLAG_INITIAL_ANIMATION)) {
205 break;
206 }
207 }
208 if (i >= WIN_PAUSE_CURSOR) {
209 D_8024EFB4 = 0;
210 }
211 }
213 gPauseCursorPosX = posX;
215 gPauseCursorPosY = posY;
216
217 } else if ((window->flags & WINDOW_FLAG_INITIAL_ANIMATION) == 0 && (window->parent == WIN_NONE || !(gWindows[window->parent].flags & WINDOW_FLAG_INITIAL_ANIMATION))) {
219 gPauseCursorPosX = posX;
221 gPauseCursorPosY = posY;
222 }
223}
224
225void pause_set_cursor_pos(s32 windowID, s32 posX, s32 posY) {
226 Window* window = &gWindows[windowID];
227
229 if (D_8024EFB4 != 0) {
230 s32 i;
231
232 for (i = WIN_PAUSE_MAIN; i < WIN_PAUSE_CURSOR; i++) {
233 Window* window = &gWindows[i];
234 s8 parent = window->parent;
235
236 if ((parent == WIN_NONE || parent == WIN_PAUSE_MAIN) && (window->flags & WINDOW_FLAG_INITIAL_ANIMATION)) {
237 break;
238 }
239 }
240 if (i >= 44) {
241 D_8024EFB4 = 0;
242 }
243 }
245 gPauseCursorPosX = posX;
247 gPauseCursorPosY = posY;
248 } else if ((window->flags & WINDOW_FLAG_INITIAL_ANIMATION) == 0 && (window->parent == WIN_NONE || !(gWindows[window->parent].flags & WINDOW_FLAG_INITIAL_ANIMATION))) {
251 }
252}
253
255 s32 xDelta;
256 s32 yDelta;
257
260
262 if ((xDelta == 0) && (yDelta == 0)) {
265 }
266 }
267
270
271 if (gPauseCursorTargetOpacity == 0) {
272 gPauseCursorOpacity -= 128;
273 if (gPauseCursorOpacity < 0) {
275 }
276 } else {
278 if (gPauseCursorOpacity> 255) {
280 }
281 }
283}
284
285void pause_update_tab_default(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
286 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity) {
288
289 *darkening = 160;
291}
292
293void func_80242FBC(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
294 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity) {
296
297 *darkening = 160;
298 *opacity = 80;
300}
301
302void pause_update_tab_inactive(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
303 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity) {
305 s32 updateCounter = window->updateCounter;
306
307 if (updateCounter == 0) {
308 window->flags &= ~WINDOW_FLAG_HIDDEN;
309 }
310
311 if (updateCounter == 5) {
312 update_window_hierarchy(windowIndex, window->originalPriority);
313 }
314
315 if (updateCounter < 10) {
316 *darkening = (updateCounter + 1) * 16;
317 } else {
318 *darkening = 160;
320 }
321}
322
323void pause_update_tab_active(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
324 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity) {
326
327 if (window->updateCounter == 0) {
328 update_window_hierarchy(windowIndex, window->originalPriority);
329 *darkening = 0;
331 }
332}
333
334void func_802430E4(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
335 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity) {
337 s32 updateCounter = window->updateCounter;
338
339 if (updateCounter == 0) {
340 window->flags &= ~WINDOW_FLAG_HIDDEN;
341 }
342
343 if (updateCounter < 16) {
344 *opacity = updateCounter * 16;
345 } else {
346 *opacity = 255;
348 }
349}
350
351void func_8024313C(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
352 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity) {
354 s32 updateCounter = window->updateCounter;
355
356 if (updateCounter < 16) {
357 *opacity = 255 - (updateCounter * 16);
358 } else {
359 *opacity = 0;
361 window->flags |= WINDOW_FLAG_HIDDEN;
362 }
363}
364
365void pause_update_page_active_2(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
366 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity) {
368 s32 updateCounter = window->updateCounter;
369
370 if (updateCounter == 0) {
371 window->flags &= ~WINDOW_FLAG_HIDDEN;
372 }
373 if (updateCounter < 7) {
374 *flags = gPauseWindowFlipUpFlags[updateCounter];
375 *rotX += gPauseWindowFlipUpAngles[updateCounter];
376 } else {
378 *rotX += gPauseWindowFlipUpAngles[6];
380 }
381}
382
383void pause_update_page_active_1(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
384 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity) {
386 s32 updateCounter = window->updateCounter;
387
388 if (updateCounter == 0) {
389 window->flags &= ~WINDOW_FLAG_HIDDEN;
390 }
391 if (updateCounter < 7) {
392 *flags = gPauseWindowFlipUpFlags[updateCounter];
393 *rotX += gPauseWindowFlipUpAngles_2[updateCounter];
394 } else {
396 *rotX += gPauseWindowFlipUpAngles_2[6];
398 }
399}
400
401void pause_update_page_inactive_1(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
402 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity) {
404 s32 updateCounter = window->updateCounter;
405
406 if (updateCounter < 5) {
407 *flags = gPauseWindowFlipDownFlags[updateCounter];
408 *rotX += gPauseWindowFlipDownAngles[updateCounter];
409 } else {
411 *rotX += gPauseWindowFlipDownAngles[4];
413 window->flags |= WINDOW_FLAG_HIDDEN;
414 }
415}
416
417void pause_update_page_inactive_2(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
418 f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity) {
420 s32 updateCounter = window->updateCounter;
421
422 if (updateCounter < 5) {
423 *flags = gPauseWindowFlipDownFlags[updateCounter];
424 *rotX = gPauseWindowFlipDownAngles_2[updateCounter];
425 } else {
429 window->flags |= WINDOW_FLAG_HIDDEN;
430 }
431}
432
434 s32 val;
436 s32 s = sign(deltaBefore);
437
438 if (db >= 16) {
439 val = 8;
440 } else {
442 }
443
444 return val * s;
445}
446
448 s32 val;
450 s32 s = sign(deltaBefore);
451
452 if (db >= 16) {
453 val = db / 2;
454 if (val > 20) {
455 val = 20;
456 }
457 } else {
459 }
460
461 return val * s;
462}
463
464void pause_draw_cursor(MenuPanel* menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening) {
466
469 if (currentOpacity > 0) {
470 if (currentOpacity > 255) {
471 currentOpacity = 255;
472 }
473 hud_element_set_alpha(gPauseCommonHIDs[0], currentOpacity);
475 hud_element_draw_without_clipping(gPauseCommonHIDs[0]);
476 }
477}
478
479void pause_main_draw_contents(MenuPanel* menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening) {
480}
481
482void pause_textbox_draw_contents(MenuPanel* menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening) {
483 s32 msgID = gPauseShownDescMsg;
484
485 if (msgID == MSG_NONE) {
486 return;
487 }
488
489 if (gPauseDescTextPos != 0) {
490 hud_element_set_render_pos(gPauseCommonHIDs[1], baseX + width - 4, baseY + 4);
491 hud_element_draw_without_clipping(gPauseCommonHIDs[1]);
492 }
493
494 if (gPauseDescTextPos < gPauseDescTextMaxPos) {
495 hud_element_set_render_pos(gPauseCommonHIDs[2], baseX + width - 4, baseY + height - 4);
496 hud_element_draw_without_clipping(gPauseCommonHIDs[2]);
497 }
498
500 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, baseX + 1, baseY + 1, baseX + width - 1, baseY + height - 1);
501 draw_msg(msgID, baseX + 10, baseY - gPauseDescTextOffset, 255, MSG_PAL_STANDARD, 0);
502 if (gPauseShownDescIconScript != 0) {
504 hud_element_set_render_pos(gPauseCommonHIDs[3], baseX - 4, baseY + 16);
505 hud_element_set_script(gPauseCommonHIDs[3], gPauseShownDescIconScript);
508 hud_element_set_scale(gPauseCommonHIDs[3], 1.0f);
509 hud_element_draw_without_clipping(gPauseCommonHIDs[3]);
510 }
511}
512
513void pause_tutorial_draw_contents(MenuPanel* menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening) {
516 f32 (*matrix2ptr)[4];
517 s32 msgHeight;
518 s32 msgWidth;
527 s32 i;
529 s32 state;
530
531 if (evt_get_variable(nullptr, GF_Tutorial_Badges) == false) {
532 return;
533 }
534
538 gDPSetPrimColor(gMainGfxPos++, 0, 0, 55, 55, 55, 255);
539 pause_draw_rect(baseX * 4, baseY * 4, (baseX + width) * 4, (baseY + 12) * 4, 0, 0, 0, 0, 0);
541 gDPSetPrimColor(gMainGfxPos++, 0, 0, 185, 185, 185, 255);
542 pause_draw_rect(baseX * 4, (baseY + 12) * 4, (baseX + width) * 4, (baseY + height) * 4, 0, 0, 0, 0, 0);
545 guOrthoF(matrix1, 0.0f, 320.0f, 240.0f, 0.0f, -100.0f, 100.0f, 1.0f);
548
549 for (i = 0; i < 3; i++) {
550 //needed to match
552 switch (i) {
553 case 0:
554 guTranslateF(matrix1, 40.0f, 223.0f, 0);
555 guScaleF(matrix2ptr, -0.8f, 0.8f, 1.0f);
556 break;
557 case 1:
558 guTranslateF(matrix1, 60.0f, 223.0f, 0);
559 guScaleF(matrix2ptr, -0.8f, 0.8f, 1.0f);
560 break;
561 default:
562 guTranslateF(matrix1, 280.0f, 223.0f, 0);
563 guScaleF(matrix2ptr, 0.8f, 0.8f, 1.0f);
564 break;
565 }
566
568 guRotateF(matrix2ptr, 180.0f, 0.0f, 0.0f, 1.0f);
570 guRotateF(matrix2ptr, 180.0f, 0.0f, 1.0f, 0.0f);
574 set_npc_imgfx_all(gPauseTutorialSprites[i], IMGFX_SET_COLOR, 255, 255, 255, 255, 64);
575 spr_draw_npc_sprite(gPauseTutorialSprites[i], 0, 0, 0, matrix1);
577 }
578
580 margin = (s32)(width - msgWidth) >> 1;
583 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, baseX + 1, baseY + 1, baseX + width - 1, baseY + height - 1);
584 state = gPauseTutorialState;
586 margin2 = (s32)(width - msgWidth2) >> 1;
588 hud_element_set_render_pos(gPauseCommonHIDs[gPauseTutorialIconIDs[gPauseTutorialState]], baseX + width / 2 - 2, baseY + 52);
592
594 hud_element_set_render_pos(gPauseCommonHIDs[7], baseX + width / 2 + 1, baseY + 50);
595 hud_element_draw_without_clipping(gPauseCommonHIDs[7]);
596 }
597
599}
600
601void pause_init(void) {
602 s32 posX;
603 s32 x;
606 s32 i;
607
609
610 for (i = 0; i < ARRAY_COUNT(gPauseHudScripts); i++) {
611 gPauseCommonHIDs[i] = hud_element_create(gPauseHudScripts[i]);
612 if (gPauseHudScripts[i] == &HES_AnimatedCursorHand) {
614 } else {
616 }
617 }
618
619 gPauseCursorHID = gPauseCommonHIDs[0];
621 gPauseShownDescMsg = 0;
622 gPauseDescTextPos = 0;
623 gPauseDescTextOffset = 0;
624 gPauseDescTextMaxPos = 0;
625 gPauseShownDescIconScript = 0;
629
631 for (i = 0; i < ARRAY_COUNT(gPausePanels); menuPanels++, i++) {
632 if ((*menuPanels)->fpInit) {
633 (*menuPanels)->fpInit(*menuPanels);
634 }
635 }
636
637 posX = 225;
638 for (i = 6; i > 0; i--) {
639 if (!gPausePanels[i]->initialized) {
641 } else {
642 gWindows[WIN_PAUSE_TUTORIAL + i].pos.x = posX + 14;
643 posX -= 45;
644 }
645 }
649
650 if (evt_get_variable(nullptr, GF_Tutorial_Badges)) {
651 for (i = 0; i < ARRAY_COUNT(gPauseTutorialSpriteAnims); i++) {
652 gPauseTutorialSprites[i] = spr_load_npc_sprite(gPauseTutorialSpriteAnims[i][0], gPauseTutorialSpriteAnims[i]);
653 }
654
657 }
658
660}
661
665 s32 heldNew = *held;
666
667 switch (gPauseTutorialInputState) {
668 case 0:
670 if (pressedNew) {
672 }
673 if (pressedOld && pressedNew == 0) {
675 }
676 if (gPauseTutorialState == 0) {
677 pressedNew = 0;
678 heldNew = 0;
679 }
680 break;
681 case 1:
682 gPauseTutorialFrameCounter = 0;
684 pressedNew = 0;
685 heldNew = 0;
686 break;
687 case 2:
688 if (--gPauseTutorialFrameCounter <= 0) {
690 }
691 pressedNew = 0;
692 heldNew = 0;
693 break;
694 case 3:
695 gPauseTutorialFrameCounter = 16;
698 pressedNew = 0;
699 heldNew = 0;
700 break;
701 case 4:
702 if (--gPauseTutorialFrameCounter <= 0) {
704 }
705 pressedNew = 0;
706 heldNew = 0;
707 break;
708 }
709
711 *held = heldNew;
712}
713
715 s32 height;
716 s32 width;
717 s32 maxLineChars;
718 s32 numLines;
719 s32 i;
723
724 if (evt_get_variable(nullptr, GF_Tutorial_Badges)) {
725 for (i = 0; i < ARRAY_COUNT(gPauseTutorialSprites); i++) {
726 spr_update_sprite(gPauseTutorialSprites[i], gPauseTutorialSpriteAnims[i][1], 1.0f);
727 }
728 }
729
732 if (evt_get_variable(nullptr, GF_Tutorial_Badges)) {
734 }
735
740 return;
741 }
742
743 if (gPauseCurrentDescIconScript != gPauseShownDescIconScript) {
744 gPauseShownDescIconScript = gPauseCurrentDescIconScript;
745 }
746
747 if (currentDescMsg != gPauseShownDescMsg) {
748 gPauseShownDescMsg = currentDescMsg;
749 gPauseDescTextPos = 0;
750 gPauseDescTextOffset = 0;
751 if (currentDescMsg != 0) {
752 get_msg_properties(currentDescMsg, &height, &width, &maxLineChars, &numLines, nullptr, nullptr, 0);
753 if (numLines % 2) {
754 numLines++;
755 }
756 gPauseDescTextMaxPos = numLines - 2;
757 if (gPauseDescTextMaxPos < 0) {
758 gPauseDescTextMaxPos = 0;
759 }
760 } else {
761 gPauseDescTextMaxPos = 0;
762 }
763 }
765 gPauseDescTextPos -= 2;
766 if (gPauseDescTextPos < 0) {
767 gPauseDescTextPos = 0;
768 }
769 }
771 gPauseDescTextPos += 2;
772 if (gPauseDescTextPos > gPauseDescTextMaxPos) {
773 gPauseDescTextPos = gPauseDescTextMaxPos;
774 }
775 }
776 gPauseDescTextOffset += pause_interp_text_scroll(gPauseDescTextPos * 16 - gPauseDescTextOffset);
777 if (currentPanel->initialized) {
778 if (currentPanel->fpHandleInput) {
779 currentPanel->fpHandleInput(currentPanel);
780 }
781 }
783 for (i = 0; i < ARRAY_COUNT(gPausePanels); menuPanels++, i++) {
784 if ((*menuPanels)->initialized) {
785 if ((*menuPanels)->fpUpdate) {
786 (*menuPanels)->fpUpdate(*menuPanels);
787 }
788 }
789 }
790}
791
792void pause_cleanup(void) {
793 s32 i;
795
796 for (i = 0; i < ARRAY_COUNT(gPauseCommonHIDs); i++) {
797 hud_element_free(gPauseCommonHIDs[i]);
798 }
799
800 if (evt_get_variable(nullptr, GF_Tutorial_Badges)) {
801 for (i = 0; i < ARRAY_COUNT(gPauseTutorialSprites); i++) {
802 spr_free_sprite(gPauseTutorialSprites[i]);
803 }
804 }
805
807 for (i = 0; i < ARRAY_COUNT(gPausePanels); menuPanels++, i++) {
808 if ((*menuPanels)->initialized) {
809 if ((*menuPanels)->fpCleanup) {
810 (*menuPanels)->fpCleanup(*menuPanels);
811 }
812 }
813 }
814
815 for (i = WIN_PAUSE_MAIN; i < WIN_PAUSE_CURSOR; i++)
817
819}
820
822 s32 totalCost = 0;
823 s32 i;
824
825 for (i = 0; i < ARRAY_COUNT(gPlayerData.equippedBadges); i++) {
826 s16 itemID = gPlayerData.equippedBadges[i];
827
828 if (itemID != ITEM_NONE) {
829 s32 moveID = gItemTable[itemID].moveID;
830
831 totalCost += gMoveTable[moveID].costBP;
832 }
833 }
834 return totalCost;
835}
836
837void pause_draw_rect(s32 ulx, s32 uly, s32 lrx, s32 lry, s32 tileIdx, s32 uls, s32 ult, s32 dsdx, s32 dtdy) {
838 if (ulx <= -2688 || uly <= -2688 || lrx <= 0 || lry <= 0) {
839 return;
840 }
841 if (ulx >= 1280 || uly >= 960 || lrx >= 2688 || lry >= 2688) {
842 return;
843 }
844 gSPScisTextureRectangle(gMainGfxPos++, ulx, uly, lrx, lry, tileIdx, uls, ult, dsdx, dtdy);
845}
846
848 if (len < 2) {
849 // Trivially sorted
850 return;
851 } else if (len == 2) {
852 // Trivial 2-element sort
853 if (compare(&arr[0], &arr[1]) > 0) {
854 s16 temp = arr[0];
855 arr[0] = arr[1];
856 arr[1] = temp;
857 }
858 } else {
859 // Nontrivial sort required, use shell sort
860 u32 gap = 1;
861 s16* end;
862
863 while (gap < len) {
864 gap = gap * 2 + 1;
865 }
866
867 end = &arr[len];
868 while ((gap /= 2) != 0) {
870
871 for (window_end = &arr[gap]; window_end < end; window_end++) {
873
874 // This could be written simpler as a while loop, but the compiler figures out that it only needs to do
875 // the "cur_elem < end" check on the first iteration in that case
876 if (cur_elem >= arr && cur_elem < end) {
877 do {
879 s16* elem_b = cur_elem + gap;
880
881 if (compare(elem_a, elem_b) > 0) {
882 s16 temp = *elem_a;
883 *elem_a = *elem_b;
884 *elem_b = temp;
885 cur_elem -= gap;
886 } else {
887 break;
888 }
889 } while (cur_elem >= arr && cur_elem < end);
890 }
891 }
892 }
893 }
894}
BSS s32 PopupMenu_SelectedIndex
HudScript HES_PressAButton
HudScript HES_StickTapRight
s16 equippedBadges[64]
Mtx matrixStack[0x200]
s32 HudElemID
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:4970
@ BUTTON_A
Definition enums.h:2776
@ BUTTON_C_UP
Definition enums.h:2766
@ BUTTON_START
Definition enums.h:2773
@ BUTTON_C_DOWN
Definition enums.h:2765
@ BUTTON_STICK_RIGHT
Definition enums.h:2780
@ BUTTON_B
Definition enums.h:2775
@ IMGFX_SET_COLOR
Definition enums.h:4708
@ DRAW_FLAG_ROTSCALE
Definition enums.h:4588
@ MSG_PAL_WHITE
Definition enums.h:4990
@ MSG_PAL_STANDARD
Definition enums.h:5000
@ WINDOW_UPDATE_SHOW
Definition enums.h:4896
@ WINDOW_UPDATE_HIDE
Definition enums.h:4897
@ WINDOW_FLAG_40
Definition enums.h:4584
@ WINDOW_FLAG_INITIAL_ANIMATION
Definition enums.h:4581
@ WINDOW_FLAG_HIDDEN
Updated but not rendered.
Definition enums.h:4580
@ SOUND_MENU_CLOSE
Definition enums.h:700
@ SOUND_MENU_SHOW_CHOICE
Definition enums.h:557
@ SOUND_MENU_ERROR
Definition enums.h:936
@ WIN_PAUSE_TAB_INVIS
Definition enums.h:4871
@ WIN_PAUSE_CURSOR
Definition enums.h:4872
@ WIN_PAUSE_MAIN
Definition enums.h:4848
@ WIN_PAUSE_TAB_STATS
Definition enums.h:4853
@ WIN_NONE
Definition enums.h:4825
@ WIN_PAUSE_TUTORIAL
Definition enums.h:4851
@ WIN_PAUSE_DECRIPTION
Definition enums.h:4849
HudScript HES_AnimatedCursorHand
s32 sign(s32 value)
Definition 43F0.c:374
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1730
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:1673
void enforce_hpfp_limits(void)
Definition inventory.c:462
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)
HudElemID hud_element_create(HudScript *anim)
Creates a new HUD element and returns its ID.
void hud_element_set_render_pos(s32 id, s32 x, s32 y)
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_DROP_SHADOW
Definition hud_element.h:97
@ HUD_ELEMENT_FLAG_MANUAL_RENDER
Definition hud_element.h:78
@ HUD_ELEMENT_FLAG_FILTER_TEX
Definition hud_element.h:86
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:56
u8 gPauseMenuPageScrollInterpEasingLUT[]
Definition pause_main.c:101
s32 gPauseCursorTargetPosX
Definition pause_main.c:51
void pause_handle_input(s32 pressed, s32 held)
Definition pause_main.c:714
s32 gPauseCursorOpacity
Definition pause_main.c:50
MenuPanel gPausePanelSpirits
MenuPanel gPausePanelMap
Definition pause_map.c:76
s32 gPauseTutorialInputState
Definition pause_main.c:65
s16 D_8024EFB8[]
Definition pause_main.c:55
s16 gPauseWindowFlipUpAngles_2[]
Definition pause_main.c:58
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:365
s32 pause_interp_vertical_scroll(s32 deltaBefore)
Definition pause_main.c:447
void pause_tutorial_draw_contents(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
Definition pause_main.c:513
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:334
BSS s32 gPausePressedButtons
Definition pause_main.c:24
s32 gPauseTutorialSpriteAnims[][4]
Definition pause_main.c:103
s32 gPauseTutorialScrollPos
Definition pause_main.c:129
s32 gPauseTutorialState
Definition pause_main.c:64
BSS HudElemID gPauseCursorHID
Definition pause_main.c:27
s16 gPauseWindowFlipDownAngles[]
Definition pause_main.c:62
s32 gPauseTutorialDescMessages[]
Definition pause_main.c:68
BSS HudScript * gPauseCurrentDescIconScript
Definition pause_main.c:26
s32 gPauseCursorPosX
Definition pause_main.c:48
BSS s8 D_802700D[7]
Definition pause_main.c:29
MenuPanel gPausePanelStats
s32 gPauseTutorialCmdMessages[]
Definition pause_main.c:78
void pause_main_draw_contents(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
Definition pause_main.c:479
s32 gPauseCursorTargetPosY
Definition pause_main.c:52
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:417
s32 D_8024F074[]
Definition pause_main.c:89
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:293
s32 pause_get_total_equipped_bp_cost(void)
Definition pause_main.c:821
MenuPanel * gPausePanels[]
Definition pause_main.c:44
s32 pause_interp_text_scroll(s32 deltaBefore)
Definition pause_main.c:433
u8 gPauseWindowFlipDownFlags[]
Definition pause_main.c:59
void pause_cleanup(void)
Definition pause_main.c:792
void pause_set_cursor_opacity(s32 val)
Definition pause_main.c:189
s32 gPauseCursorPosY
Definition pause_main.c:49
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:302
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:351
BSS s32 gPauseHeldButtons
Definition pause_main.c:23
void pause_interp_cursor(void)
Definition pause_main.c:254
void pause_draw_cursor(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
Definition pause_main.c:464
void pause_set_cursor_pos_immediate(s32 windowID, s32 posX, s32 posY)
Definition pause_main.c:193
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:323
u8 gPauseMenuTextScrollInterpEasingLUT[]
Definition pause_main.c:100
MenuPanel gPausePanelItems
Definition pause_items.c:51
void pause_textbox_draw_contents(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
Definition pause_main.c:482
Vp gPauseTutorialViewport
Definition pause_main.c:123
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:401
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:285
void pause_init(void)
Definition pause_main.c:601
s16 gPauseWindowFlipDownAngles_2[]
Definition pause_main.c:63
u32 D_8024EFB4
Definition pause_main.c:54
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:383
s16 gPauseWindowFlipUpAngles[]
Definition pause_main.c:57
s32 gPauseTutorialIconIDs[]
Definition pause_main.c:99
MenuPanel gPausePanelPartners
s32 gPauseTutorialButtons[]
Definition pause_main.c:66
void pause_set_cursor_pos(s32 windowID, s32 posX, s32 posY)
Definition pause_main.c:225
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:837
u8 D_8024EFEC[]
Definition pause_main.c:60
s32 gPauseCursorTargetOpacity
Definition pause_main.c:53
void pause_sort_item_list(s16 *arr, s32 len, s32(*compare)(s16 *, s16 *))
Definition pause_main.c:847
void pause_tutorial_input(s32 *pressed, s32 *held)
Definition pause_main.c:662
MenuWindowBP gPauseCommonWindowsBPs[]
Definition pause_main.c:130
MenuPanel gPausePanelBadges
void sfx_play_sound(s32 soundID)
@ GF_Tutorial_Badges
#define DMA_COPY_SEGMENT(segment)
Definition macros.h:537
#define SCREEN_WIDTH
Definition macros.h:108
#define BSS
Definition macros.h:6
#define ARRAY_COUNT(arr)
Definition macros.h:39
#define SCREEN_HEIGHT
Definition macros.h:109
s32 spr_update_sprite(s32 spriteInstanceID, s32 animID, f32 timeScale)
Definition sprite.c:1061
s32 spr_free_sprite(s32 spriteInstanceID)
Definition sprite.c:1162
void set_npc_imgfx_all(s32 spriteIdx, ImgFXType imgfxType, s32 imgfxArg1, s32 imgfxArg2, s32 imgfxArg3, s32 imgfxArg4, s32 imgfxArg5)
Definition sprite.c:1238
s32 spr_draw_npc_sprite(s32 spriteInstanceID, s32 yaw, s32 alphaIn, PAL_PTR *paletteList, Matrix4f mtx)
Definition sprite.c:1094
s32 spr_load_npc_sprite(s32 animID, u32 *extraAnimList)
Definition sprite.c:1015
void(* fpUpdate)(struct MenuPanel *)
void(* fpCleanup)(struct MenuPanel *)
void(* fpInit)(struct MenuPanel *)
#define ANIM_LIST_END
Terminates an extraAnimationList.
Definition types.h:22
ItemData gItemTable[]
Gfx * gMainGfxPos
Definition cam_main.c:14
PlayerData gPlayerData
Definition 77480.c:39
u16 gMatrixListPos
Definition main_loop.c:44
MoveData gMoveTable[]
Window gWindows[64]
Definition windows.c:23
DisplayContext * gDisplayContext
Definition cam_main.c:15