Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
filemenu_common.c
Go to the documentation of this file.
1#include "common.h"
2#include "filemenu.h"
3#include "hud_element.h"
4#include "fio.h"
5#include "ld_addrs.h"
6#include "game_modes.h"
7#include "dx/config.h"
8#include "gcc/memory.h"
9#include "gcc/string.h"
10
12
17
32s32 D_80249BB0 = TRUE;
33s32 D_80249BB8 = 0;
34s16 D_80249BBC[16] = { 315, 303, 283, 260, 235, 210, 185, 160, 135, 110, 85, 60, 37, 17, 5, 0 };
35s16 D_80249BDC[16] = { 315, 303, 283, 260, 235, 210, 185, 160, 135, 110, 85, 60, 37, 17, 5, 0 };
36s16 D_80249BFC[16] = { 157, 151, 141, 130, 117, 105, 92, 80, 67, 55, 42, 30, 18, 8, 2, 0 };
37s16 D_80249C1C[16] = { 157, 151, 141, 130, 117, 105, 92, 80, 67, 55, 42, 30, 18, 8, 2, 0 };
38s16 D_80249C3C[16] = { 63, 60, 56, 52, 47, 42, 37, 32, 27, 22, 17, 12, 7, 3, 1, 0 };
39s16 D_80249C5C[16] = { 63, 60, 56, 52, 47, 42, 37, 32, 27, 22, 17, 12, 7, 3, 1, 0 };
40s16 D_80249C7C[10] = { -5, -17, -37, -60, -85, -110, -135, -160, -185, -210 };
41s16 D_80249C90[10] = { -5, -17, -37, -60, -85, -110, -135, -160, -185, -210 };
42s16 D_80249CA4[10] = { -2, -8, -18, -30, -42, -55, -70, -85, -100, -115 };
43s16 D_80249CB8[10] = { -2, -8, -18, -30, -42, -55, -70, -85, -100, -115 };
44s16 D_80249CCC[10] = { -1, -3, -7, -12, -17, -22, -27, -32, -37, -42 };
45s16 D_80249CE0[10] = { -1, -3, -7, -12, -17, -22, -27, -32, -37, -42 };
46s16 D_80249CF4[16] = { 180, 173, 161, 148, 134, 120, 105, 91, 77, 62, 48, 34, 21, 9, 2, 0 };
47s16 D_80249D14[16] = { 0, 2, 9, 21, 34, 48, 62, 77, 91, 105, 120, 134, 148, 161, 173, 180 };
48s16 D_80249D34[10] = { 185, 160, 135, 110, 85, 60, 37, 17, 5, 0 };
49s16 D_80249D48[10] = { 0, 5, 17, 37, 60, 85, 110, 135, 160, 185};
50
52 .vp = {
53 .vscale = { 640, 480, 511, 0},
54 .vtrans = { 640, 480, 511, 0},
55 }
56};
58 7.0f, 12.5f, 13.0f, 14.5f, 14.0f,
59 13.0f, 11.5f, 9.5f, 7.5f, 5.5f,
60 3.5f, 2.0f, 1.0f, 0.5f, 0.0f
61};
62
64 {
66 .pos = {
67 .x = 16,
68 .y = 24,
69 },
70 .width = 288,
71 .height = 192,
72 .priority = WINDOW_PRIORITY_0,
73 .fpDrawContents = NULL,
74 .tab = NULL,
75 .parentID = -1,
76 .fpUpdate = { WINDOW_UPDATE_SHOW },
77 .extraFlags = WINDOW_FLAG_40,
78 .style = { .customStyle = &filemenu_windowStyles[0] },
79 },
80 {
81 .windowID = WIN_FILES_COPYARROW,
82 .pos = {
83 .x = 0,
84 .y = 0,
85 },
86 .width = 288,
87 .height = 192,
88 .priority = WINDOW_PRIORITY_0,
89 .fpDrawContents = filemenu_draw_contents_copy_arrow,
90 .tab = NULL,
91 .parentID = WIN_FILES_MAIN,
92 .fpUpdate = { WINDOW_UPDATE_SHOW } ,
93 .extraFlags = 0,
94 .style = { .customStyle = &filemenu_windowStyles[1] },
95 },
96 {
97 .windowID = WIN_FILES_CURSOR,
98 .pos = {
99 .x = 0,
100 .y = 0,
101 },
102 .width = 320,
103 .height = 240,
104 .priority = WINDOW_PRIORITY_0,
105 .fpDrawContents = filemenu_draw_cursor,
106 .tab = NULL,
107 .parentID = -1,
108 .fpUpdate = { WINDOW_UPDATE_SHOW },
109 .extraFlags = 0,
110 .style = { .customStyle = &filemenu_windowStyles[1] },
111 },
112};
113
114extern Gfx filemenu_dl_copyarrow[];
115extern Gfx D_8024B6F0[];
116extern Gfx D_8024B708[];
117
130
131#if VERSION_PAL
132BSS s32 D_802517D0[1];
133BSS s32 D_802517D4[1];
134BSS u16 D_802517E0[2][0x400] ALIGNED(16);
135#endif
136
137#if VERSION_IQUE
138BSS u8 filemenu_glyphBuffer[20][0x80];
139#endif
140
141void filemenu_draw_rect(s32 ulx, s32 uly, s32 lrx, s32 lry, s32 tileIdx, s32 uls, s32 ult, s32 dsdx, s32 dtdy) {
142 if (ulx <= -2688 || uly <= -2688 || lrx <= 0 || lry <= 0) {
143 return;
144 }
145 if (ulx >= 1280 || uly >= 960 || lrx >= 2688 || lry >= 2688) {
146 return;
147 }
148 gSPScisTextureRectangle(gMainGfxPos++, ulx, uly, lrx, lry, tileIdx, uls, ult, dsdx, dtdy);
149}
150
151void filemenu_set_selected(MenuPanel* menu, s32 col, s32 row) {
152 menu->col = col;
153 menu->row = row;
154 menu->selected = menu->gridData[(menu->state * menu->numCols * menu->numRows) +
155 (menu->numCols * menu->row) + menu->col];
156}
157
161}
162
163void filemenu_set_cursor_goal_pos(s32 windowID, s32 posX, s32 posY) {
164 Window* window = &gWindows[windowID];
165
167 if (D_80249BB0) {
168 s32 i;
169
170 for (i = WIN_FILES_MAIN; i < ARRAY_COUNT(gWindows); i++) {
171 Window* window = &gWindows[i];
172 s8 parent = window->parent;
173
174 if ((parent == WIN_NONE || parent == WIN_FILES_MAIN) && (window->flags & WINDOW_FLAG_INITIAL_ANIMATION)) {
175 break;
176 }
177 }
178 if (i >= ARRAY_COUNT(gWindows)) {
179 D_80249BB0 = FALSE;
180 }
181 }
186 } else if (!(window->flags & WINDOW_FLAG_INITIAL_ANIMATION) &&
187 (window->parent == WIN_NONE || !(gWindows[window->parent].flags & WINDOW_FLAG_INITIAL_ANIMATION))) {
190 }
191}
192
194 s32 targetPosX = filemenu_cursor_targetX;
195 s32 targetPosY = filemenu_cursor_targetY;
196 s32 xDelta;
197 s32 yDelta;
198 s32 i;
199
200 xDelta = (targetPosX - filemenu_cursor_posX) * 0.5;
201 yDelta = (targetPosY - filemenu_cursor_posY) * 0.5;
202
203 if ((targetPosX != filemenu_cursor_posX) || (targetPosY != filemenu_cursor_posY)) {
204 if ((xDelta == 0) && (yDelta == 0)) {
205 filemenu_cursor_posX = targetPosX;
206 filemenu_cursor_posY = targetPosY;
207 }
208 }
209
210 filemenu_cursor_posX += xDelta;
211 filemenu_cursor_posY += yDelta;
212
213 if (filemenu_cursorGoalAlpha == 0) {
215 if (filemenu_cursor_alpha < 0) {
217 }
218 } else {
220 if (filemenu_cursor_alpha > 255) {
222 }
223 }
224
225 for (i = WIN_FILES_MAIN; i < ARRAY_COUNT(gWindows); i++) {
226 Window* window = &gWindows[i];
227 s8 parent = window->parent;
228
229 if ((parent == WIN_NONE || parent == WIN_FILES_MAIN) && (window->flags & WINDOW_FLAG_INITIAL_ANIMATION)) {
230 break;
231 }
232 }
233
234 if (D_80249BB8 == 0) {
235 if (filemenu_cursorGoalAlpha == 0) {
236 D_80249BB8 = 1;
237 }
238 }
239
240 if (i >= ARRAY_COUNT(gWindows)) {
241 if (filemenu_cursorGoalAlpha2 == 255) {
242 if (D_80249BB8 != 0) {
243 D_80249BB8--;
244 if (D_80249BB8 == 0) {
247 }
248 }
249 }
250 if (D_80249BB8 == 0) {
252 }
253 } else if (filemenu_cursorGoalAlpha == 0) {
254 D_80249BB8 = 1;
255 }
256
258}
259
260void filemenu_update(void) {
261 MenuPanel* menu;
262 s32 i;
263
264 for (i = WIN_FILES_MAIN; i < ARRAY_COUNT(gWindows); i++) {
265 if ((gWindows[i].parent == WIN_NONE || gWindows[i].parent == WIN_FILES_MAIN) &&
267 {
268 break;
269 }
270 }
271
272 if (i >= ARRAY_COUNT(gWindows)) {
275 } else {
278 }
279
280 // B overrides A
282 filemenu_pressedButtons &= ~BUTTON_A;
283 }
285 filemenu_heldButtons &= ~BUTTON_A;
286 }
287
288 // only process inputs for the current menu
290 if (menu->initialized) {
291 if (menu->fpHandleInput != NULL) {
292 menu->fpHandleInput(menu);
293 }
294 }
295
296 // update all menus
297 for (i = 0; i < ARRAY_COUNT(filemenu_menus); i++) {
298 menu = filemenu_menus[i];
299 if (menu->initialized && menu->fpUpdate != NULL) {
300 menu->fpUpdate(menu);
301 }
302 }
303}
304
306 s32 windowIdx,
307 s32* flags,
308 s32* posX, s32* posY, s32* posZ,
309 f32* scaleX, f32* scaleY,
310 f32* rotX, f32* rotY, f32* rotZ,
311 s32* darkening,
312 s32* opacity
313) {
314 Window* window = &gWindows[windowIdx];
315 s32 updateCounter = window->updateCounter;
316
317 if (updateCounter == 0) {
318 window->flags &= ~WINDOW_FLAG_HIDDEN;
319 }
320
321 if (updateCounter < ARRAY_COUNT(D_80249BBC)) {
322 *posX -= D_80249BBC[updateCounter];
323 } else {
324 *posX -= D_80249BBC[ARRAY_COUNT(D_80249BBC) - 1];
325 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
326 }
327}
328
330 s32 windowIdx,
331 s32* flags,
332 s32* posX, s32* posY, s32* posZ,
333 f32* scaleX, f32* scaleY,
334 f32* rotX, f32* rotY, f32* rotZ,
335 s32* darkening,
336 s32* opacity
337) {
338 Window* window = &gWindows[windowIdx];
339 s32 updateCounter = window->updateCounter;
340
341 if (updateCounter == 0) {
342 window->flags &= ~WINDOW_FLAG_HIDDEN;
343 }
344
345 if (updateCounter < ARRAY_COUNT(D_80249BDC)) {
346 *posX += D_80249BDC[updateCounter];
347 } else {
348 *posX += D_80249BDC[ARRAY_COUNT(D_80249BDC) - 1];
349 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
350 }
351}
352
354 s32 windowIdx,
355 s32* flags,
356 s32* posX, s32* posY, s32* posZ,
357 f32* scaleX, f32* scaleY,
358 f32* rotX, f32* rotY, f32* rotZ,
359 s32* darkening,
360 s32* opacity
361) {
362 Window* window = &gWindows[windowIdx];
363 s32 updateCounter = window->updateCounter;
364
365 if (updateCounter == 0) {
366 window->flags &= ~WINDOW_FLAG_HIDDEN;
367 }
368
369 if (updateCounter < ARRAY_COUNT(D_80249BFC)) {
370 *posX -= D_80249BFC[updateCounter];
371 } else {
372 *posX -= D_80249BFC[ARRAY_COUNT(D_80249BFC) - 1];
373 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
374 }
375}
376
378 s32 windowIdx,
379 s32* flags,
380 s32* posX, s32* posY, s32* posZ,
381 f32* scaleX, f32* scaleY,
382 f32* rotX, f32* rotY, f32* rotZ,
383 s32* darkening,
384 s32* opacity
385) {
386 Window* window = &gWindows[windowIdx];
387 s32 updateCounter = window->updateCounter;
388
389 if (updateCounter == 0) {
390 window->flags &= ~WINDOW_FLAG_HIDDEN;
391 }
392
393 if (updateCounter < ARRAY_COUNT(D_80249C1C)) {
394 *posX += D_80249C1C[updateCounter];
395 } else {
396 *posX += D_80249C1C[ARRAY_COUNT(D_80249C1C) - 1];
397 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
398 }
399}
400
402 s32 windowIdx,
403 s32* flags,
404 s32* posX, s32* posY, s32* posZ,
405 f32* scaleX, f32* scaleY,
406 f32* rotX, f32* rotY, f32* rotZ,
407 s32* darkening,
408 s32* opacity
409) {
410 Window* window = &gWindows[windowIdx];
411 s32 updateCounter = window->updateCounter;
412
413 if (updateCounter == 0) {
414 window->flags &= ~WINDOW_FLAG_HIDDEN;
415 }
416
417 if (updateCounter < ARRAY_COUNT(D_80249C3C)) {
418 *posY += D_80249C3C[updateCounter];
419 } else {
420 *posY += D_80249C3C[ARRAY_COUNT(D_80249C3C) - 1];
421 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
422 }
423}
424
426 s32 windowIdx,
427 s32* flags,
428 s32* posX, s32* posY, s32* posZ,
429 f32* scaleX, f32* scaleY,
430 f32* rotX, f32* rotY, f32* rotZ,
431 s32* darkening,
432 s32* opacity
433) {
434 Window* window = &gWindows[windowIdx];
435 s32 updateCounter = window->updateCounter;
436
437 if (updateCounter == 0) {
438 window->flags &= ~WINDOW_FLAG_HIDDEN;
439 }
440
441 if (updateCounter < ARRAY_COUNT(D_80249C5C)) {
442 *posY -= D_80249C5C[updateCounter];
443 } else {
444 *posY -= D_80249C5C[ARRAY_COUNT(D_80249C5C) - 1];
445 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
446 }
447}
448
450 s32 windowIdx,
451 s32* flags,
452 s32* posX, s32* posY, s32* posZ,
453 f32* scaleX, f32* scaleY,
454 f32* rotX, f32* rotY, f32* rotZ,
455 s32* darkening,
456 s32* opacity
457) {
458 Window* window = &gWindows[windowIdx];
459 s32 updateCounter = window->updateCounter;
460
461 if (updateCounter < ARRAY_COUNT(D_80249C7C)) {
462 *posX += D_80249C7C[updateCounter];
463 } else {
464 *posX += D_80249C7C[ARRAY_COUNT(D_80249C7C) - 1];
465 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
466 window->flags |= WINDOW_FLAG_HIDDEN;
467 }
468}
469
471 s32 windowIdx,
472 s32* flags,
473 s32* posX, s32* posY, s32* posZ,
474 f32* scaleX, f32* scaleY,
475 f32* rotX, f32* rotY, f32* rotZ,
476 s32* darkening,
477 s32* opacity
478) {
479 Window* window = &gWindows[windowIdx];
480 s32 updateCounter = window->updateCounter;
481
482 if (updateCounter < ARRAY_COUNT(D_80249C90)) {
483 *posX -= D_80249C90[updateCounter];
484 } else {
485 *posX -= D_80249C90[ARRAY_COUNT(D_80249C90) - 1];
486 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
487 window->flags |= WINDOW_FLAG_HIDDEN;
488 }
489}
490
492 s32 windowIdx,
493 s32* flags,
494 s32* posX, s32* posY, s32* posZ,
495 f32* scaleX, f32* scaleY,
496 f32* rotX, f32* rotY, f32* rotZ,
497 s32* darkening,
498 s32* opacity
499) {
500 Window* window = &gWindows[windowIdx];
501 s32 updateCounter = window->updateCounter;
502
503 if (updateCounter < ARRAY_COUNT(D_80249CA4)) {
504 *posX += D_80249CA4[updateCounter];
505 } else {
506 *posX += D_80249CA4[ARRAY_COUNT(D_80249CA4) - 1];
507 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
508 window->flags |= WINDOW_FLAG_HIDDEN;
509 }
510}
511
513 s32 windowIdx,
514 s32* flags,
515 s32* posX, s32* posY, s32* posZ,
516 f32* scaleX, f32* scaleY,
517 f32* rotX, f32* rotY, f32* rotZ,
518 s32* darkening,
519 s32* opacity
520) {
521 Window* window = &gWindows[windowIdx];
522 s32 updateCounter = window->updateCounter;
523
524 if (updateCounter < ARRAY_COUNT(D_80249CB8)) {
525 *posX -= D_80249CB8[updateCounter];
526 } else {
527 *posX -= D_80249CB8[ARRAY_COUNT(D_80249CB8) - 1];
528 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
529 window->flags |= WINDOW_FLAG_HIDDEN;
530 }
531}
532
534 s32 windowIdx,
535 s32* flags,
536 s32* posX, s32* posY, s32* posZ,
537 f32* scaleX, f32* scaleY,
538 f32* rotX, f32* rotY, f32* rotZ,
539 s32* darkening,
540 s32* opacity
541) {
542 Window* window = &gWindows[windowIdx];
543 s32 updateCounter = window->updateCounter;
544
545 if (updateCounter < ARRAY_COUNT(D_80249CCC)) {
546 *posY += D_80249CCC[updateCounter];
547 } else {
548 *posY += D_80249CCC[ARRAY_COUNT(D_80249CCC) - 1];
549 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
550 window->flags |= WINDOW_FLAG_HIDDEN;
551 }
552}
553
555 s32 windowIdx,
556 s32* flags,
557 s32* posX, s32* posY, s32* posZ,
558 f32* scaleX, f32* scaleY,
559 f32* rotX, f32* rotY, f32* rotZ,
560 s32* darkening,
561 s32* opacity
562) {
563 Window* window = &gWindows[windowIdx];
564 s32 updateCounter = window->updateCounter;
565
566 if (updateCounter < ARRAY_COUNT(D_80249CE0)) {
567 *posY -= D_80249CE0[updateCounter];
568 } else {
569 *posY -= D_80249CE0[ARRAY_COUNT(D_80249CE0) - 1];
570 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
571 window->flags |= WINDOW_FLAG_HIDDEN;
572 }
573}
574
576 s32 windowIdx,
577 s32* flags,
578 s32* posX, s32* posY, s32* posZ,
579 f32* scaleX, f32* scaleY,
580 f32* rotX, f32* rotY, f32* rotZ,
581 s32* darkening,
582 s32* opacity
583) {
584 Window* window = &gWindows[windowIdx];
585 s32 updateCounter = window->updateCounter;
586
587 if (updateCounter == 0) {
588 window->flags &= ~WINDOW_FLAG_HIDDEN;
589 }
590
591 if (updateCounter < ARRAY_COUNT(D_80249CF4)) {
592 *rotY += D_80249CF4[updateCounter];
594 } else {
595 *flags = 0;
596 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
597 }
598}
599
601 s32 windowIdx,
602 s32* flags,
603 s32* posX, s32* posY, s32* posZ,
604 f32* scaleX, f32* scaleY,
605 f32* rotX, f32* rotY, f32* rotZ,
606 s32* darkening,
607 s32* opacity
608) {
609 Window* window = &gWindows[windowIdx];
610 s32 updateCounter = window->updateCounter;
611
612 if (updateCounter < 10) { // TODO: array count?
613 *rotY += -D_80249D14[updateCounter];
615 } else {
616 *flags = 0;
617 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
618 window->flags |= WINDOW_FLAG_HIDDEN;
619 }
620}
621
623 s32 windowIdx,
624 s32* flags,
625 s32* posX, s32* posY, s32* posZ,
626 f32* scaleX, f32* scaleY,
627 f32* rotX, f32* rotY, f32* rotZ,
628 s32* darkening,
629 s32* opacity
630) {
631 Window* window = &gWindows[windowIdx];
632 Window* parent = &gWindows[window->parent];
633 s32 updateCounter = window->updateCounter;
634 f32 temp_f4 = updateCounter / 16.0f;
635 s32 widthDelta = (parent->width / 2) - (window->width / 2);
636 s32 heightDelta = (parent->height / 2) - (window->height / 2) - 34;
637
638 if (updateCounter < 16) {
639 *posX += -window->pos.x + (((f32) (widthDelta - window->pos.x) * temp_f4) + window->pos.x);
640 *posY += -window->pos.y + (((f32) (heightDelta - window->pos.y) * temp_f4) + window->pos.y);
641 } else {
642 *posX += -window->pos.x + ((f32) (widthDelta - window->pos.x) + window->pos.x);
643 *posY += -window->pos.y + ((f32) (heightDelta - window->pos.y) + window->pos.y);
644 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
645 }
646}
647
649 s32 windowIdx,
650 s32* flags,
651 s32* posX, s32* posY, s32* posZ,
652 f32* scaleX, f32* scaleY,
653 f32* rotX, f32* rotY, f32* rotZ,
654 s32* darkening,
655 s32* opacity
656) {
657 Window* window = &gWindows[windowIdx];
658 s32 updateCounter = window->updateCounter;
659 f32 temp_f4 = 1.0f - (updateCounter / 16.0f);
660
661 if (updateCounter < 16) {
662 *posX += -window->pos.x + (((80 - window->pos.x) * temp_f4) + window->pos.x);
663 *posY += -window->pos.y + (((36 - window->pos.y) * temp_f4) + window->pos.y);
664 } else {
665 *posX += -window->pos.x + ((80 - window->pos.x) * 0.0f + window->pos.x);
666 *posY += -window->pos.y + ((36 - window->pos.y) * 0.0f + window->pos.y);
667 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
668 }
669}
670
672 s32 windowIdx,
673 s32* flags,
674 s32* posX, s32* posY, s32* posZ,
675 f32* scaleX, f32* scaleY,
676 f32* rotX, f32* rotY, f32* rotZ,
677 s32* darkening,
678 s32* opacity
679) {
680 Window* window = &gWindows[windowIdx];
681 s32 updateCounter = window->updateCounter;
682 u32 counter;
683
684 gDPPipeSync(gMainGfxPos++);
685 gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
686 gDPSetCombineMode(gMainGfxPos++, G_CC_PRIMITIVE, G_CC_PRIMITIVE);
687 gDPSetRenderMode(gMainGfxPos++, G_RM_CLD_SURF, G_RM_CLD_SURF2);
688 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, 140);
689
690 if (updateCounter < 10) {
691 s32 x = updateCounter * 16;
692 s32 y = updateCounter * 12;
693 filemenu_draw_rect(0, 0, SCREEN_WIDTH * 4, y * 4, 0, 0, 0, 0, 0);
694 filemenu_draw_rect(0, (SCREEN_HEIGHT - y) * 4, SCREEN_WIDTH * 4, SCREEN_HEIGHT * 4, 0, 0, 0, 0, 0);
695 filemenu_draw_rect(0, y * 4, x * 4, (SCREEN_HEIGHT - y) * 4, 0, 0, 0, 0, 0);
696 filemenu_draw_rect((SCREEN_WIDTH - x) * 4, y * 4, SCREEN_WIDTH * 4, (SCREEN_HEIGHT - y) * 4, 0, 0, 0, 0, 0);
697 } else {
698 filemenu_draw_rect(0, 0, SCREEN_WIDTH * 4, SCREEN_HEIGHT * 4, 0, 0, 0, 0, 0);
699 }
700
701 counter = updateCounter - 10;
702 if (counter < 10) {
703 window->flags &= ~WINDOW_FLAG_HIDDEN;
704 *posY -= D_80249D34[counter];
705 }
706 if (updateCounter >= 20) {
707 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
708 }
709}
710
712 s32 windowIdx,
713 s32* flags,
714 s32* posX, s32* posY, s32* posZ,
715 f32* scaleX, f32* scaleY,
716 f32* rotX, f32* rotY, f32* rotZ,
717 s32* darkening,
718 s32* opacity
719) {
720 Window* window = &gWindows[windowIdx];
721 s32 updateCounter = window->updateCounter;
722
723 if (updateCounter < ARRAY_COUNT(D_80249D48)) {
724 gDPPipeSync(gMainGfxPos++);
725 gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
726 gDPSetCombineMode(gMainGfxPos++, G_CC_PRIMITIVE, G_CC_PRIMITIVE);
727 gDPSetRenderMode(gMainGfxPos++, G_RM_CLD_SURF, G_RM_CLD_SURF2);
728 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, 140 - updateCounter * 14);
729 filemenu_draw_rect(0, 0, 1280, 960, 0, 0, 0, 0, 0);
730 *posY -= D_80249D48[updateCounter];
731 } else {
732 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
733 window->flags |= WINDOW_FLAG_HIDDEN;
734 }
735}
736
737void filemenu_draw_cursor(MenuPanel* menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening) {
738 s32 temp_a1;
739
741 temp_a1 = filemenu_cursor_alpha;
742 if (temp_a1 > 0) {
743 if (temp_a1 > 255) {
744 temp_a1 = 255;
745 }
749 }
750}
751
752void filemenu_draw_contents_copy_arrow(MenuPanel* menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity,
753 s32 darkening)
754{
755 Matrix4f transformMtx, tempMtx;
756 f32 startX, startZ;
757 f32 endX, endZ;
758 f32 rotAngle;
759
761 return;
762 }
763
764 // check for invalid selection
765 if (filemenu_menus[FILE_MENU_MAIN]->selected >= 4) {
766 return;
767 }
768
769 // check if different files are selected
771 return;
772 }
773
774 // do not show while message menu is showing
776 return;
777 }
778
779 switch (filemenu_CopyFromFileIdx) {
780 case 0:
781 startX = 130.0f;
782 startZ = 90.0f;
783 break;
784 case 1:
785 startX = 190.0f;
786 startZ = 90.0f;
787 break;
788 case 2:
789 startX = 130.0f;
790 startZ = 150.0f;
791 break;
792 default:
793 startX = 190.0f;
794 startZ = 150.0f;
795 break;
796 }
797
798 switch (filemenu_menus[FILE_MENU_MAIN]->selected) {
799 case 0:
800 endX = 130.0f;
801 endZ = 90.0f;
802 break;
803 case 1:
804 endX = 190.0f;
805 endZ = 90.0f;
806 break;
807 case 2:
808 endX = 130.0f;
809 endZ = 150.0f;
810 break;
811 default:
812 endX = 190.0f;
813 endZ = 150.0f;
814 break;
815 }
816
817 rotAngle = -atan2(startX, startZ, endX, endZ) - 90.0f;
818
819 gSPViewport(gMainGfxPos++, &D_80249D60);
820
821 guOrthoF(transformMtx, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, -100.0f, 100.0f, 1.0f);
823
825 G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
826 gSPDisplayList(gMainGfxPos++, filemenu_dl_copyarrow);
827 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, 128);
828 gDPSetEnvColor(gMainGfxPos++, 0, 0, 0, 0);
829
830 guTranslateF(transformMtx, startX + 4.0f, startZ + 4.0f, 0.0f);
831 guScaleF(tempMtx, -1.0f, 1.0f, 1.0f);
832 guMtxCatF(tempMtx, transformMtx, transformMtx);
833 guRotateF(tempMtx, rotAngle, 0.0f, 0.0f, 1.0f);
834 guMtxCatF(tempMtx, transformMtx, transformMtx);
836
838 G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
839 gSPDisplayList(gMainGfxPos++, D_8024B6F0);
840 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
841
843 guMtxCatF(tempMtx, transformMtx, transformMtx);
845
847 G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
848 gDPSetTileSize(gMainGfxPos++, 1, (gGameStatusPtr->frameCounter * 8) % 512, 0,
849 ((gGameStatusPtr->frameCounter * 8) % 512) + 60, 0);
850 gSPDisplayList(gMainGfxPos++, D_8024B708);
851 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
852 gDPSetPrimColor(gMainGfxPos++, 0, 0, 230, 230, 230, 255);
853 gDPSetEnvColor(gMainGfxPos++, 232, 40, 160, 0);
854
855 guTranslateF(transformMtx, startX, startZ, 0.0f);
856 guScaleF(tempMtx, -1.0f, 1.0f, 1.0f);
857 guMtxCatF(tempMtx, transformMtx, transformMtx);
858 guRotateF(tempMtx, rotAngle, 0.0f, 0.0f, 1.0f);
859 guMtxCatF(tempMtx, transformMtx, transformMtx);
861
863 G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
864 gSPDisplayList(gMainGfxPos++, D_8024B6F0);
865 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
866
868 guMtxCatF(tempMtx, transformMtx, transformMtx);
870
872 G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
873 gDPSetTileSize(gMainGfxPos++, 1, (gGameStatusPtr->frameCounter * 8) % 512, 0,
874 ((gGameStatusPtr->frameCounter * 8) % 512) + 60, 0);
875 gSPDisplayList(gMainGfxPos++, D_8024B708);
876 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
877}
878
879void func_PAL_8002B574(void); // TODO identify
880
881// TODO bad match, look into
882void filemenu_init(s32 arg0) {
883 MenuPanel* menu;
884 s32 i;
885
886 DMA_COPY_SEGMENT(ui_images_filemenu_pause);
887
888 for (i = 0; i < ARRAY_COUNT(filemenu_cursorHudElemID); i++) {
891 }
892
894 if (arg0 == 0) {
896 }
898
901
903
904 if (menu->state == FM_MAIN_SELECT_FILE) {
905 for (i = 0; i < ARRAY_COUNT(filemenu_menus); i++) {
906 if (fio_load_game(i)) {
908 gSaveSlotMetadata[i].hasData = TRUE;
911 } else {
912 gSaveSlotMetadata[i].hasData = FALSE;
913 gSaveSlotMetadata[i].validData = FALSE;
914 memset(gSaveSlotMetadata[i].modName, ARRAY_COUNT(gSaveSlotMetadata[i].modName), 0);
915 }
916 }
917
921 }
923 }
924
926
927 for (i = 0; i < ARRAY_COUNT(filemenu_menus); i++) {
928 menu = filemenu_menus[i];
929 if (menu->fpInit != NULL) {
930 menu->fpInit(menu);
931 }
932 }
934}
935
937 MenuPanel* menu;
938 s32 i;
939
940 for (i = 0; i < ARRAY_COUNT(filemenu_cursorHudElemID); i++) {
942 }
943
944 for (i = 0; i < ARRAY_COUNT(filemenu_menus); i++) {
945 menu = filemenu_menus[i];
946 if (menu->initialized) {
947 if (menu->fpCleanup != NULL) {
948 menu->fpCleanup(menu);
949 }
950 }
951 }
952
953 for (i = WIN_FILES_MAIN; i < ARRAY_COUNT(gWindows); i++) {
955 }
956
960}
961
965 && filemenu_menus[FILE_MENU_CONFIRM]->selected == 0)
966 {
967 return 2;
968 } else if (filemenu_menus[FILE_MENU_MAIN]->state == FM_MAIN_SELECT_FILE && filemenu_menus[FILE_MENU_MAIN]->selected < 4) {
969 return 1;
970 } else {
971 return 0;
972 }
973}
u32 pressedButtons[4]
WindowBackground background
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
WindowStyleCustom * customStyle
#define DX_MOD_NAME
Creates the version string that appears on the file select menu.
Definition config.h:7
s8 flags
Definition demo_api.c:15
#define guRotateF
#define guOrthoF
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define atan2
#define guScaleF
@ BUTTON_B
Definition enums.h:2789
@ WINDOW_PRIORITY_0
Definition enums.h:3182
@ DRAW_FLAG_ROTSCALE
Definition enums.h:5003
@ DRAW_FLAG_CULL_BACK
Definition enums.h:5006
@ 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
@ WIN_FILES_MAIN
Definition enums.h:5288
@ WIN_FILES_CURSOR
Definition enums.h:5265
@ WIN_FILES_COPYARROW
Definition enums.h:5267
@ WIN_NONE
Definition enums.h:5240
@ WIN_PAUSE_TUTORIAL
Definition enums.h:5266
@ WIN_PAUSE_DECRIPTION
Definition enums.h:5264
WindowStyleCustom filemenu_windowStyles[]
@ FM_MAIN_SELECT_FILE
Definition filemenu.h:24
@ FM_MAIN_SELECT_COPY_TO
Definition filemenu.h:27
@ FILE_MENU_CONFIRM
Definition filemenu.h:18
@ FILE_MENU_MESSAGE
Definition filemenu.h:19
@ FILE_MENU_MAIN
Definition filemenu.h:17
s16 D_80249C90[10]
void func_802435C4(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
s32 D_80249BB0
BSS s32 filemenu_8024C0A4[3]
BSS s32 filemenu_cursorHudElem
void filemenu_update_hidden_with_rotation(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
s32 filemenu_cursor_targetX
MenuWindowBP filemenu_common_windowBPs[]
s16 D_80249CE0[10]
void filemenu_cleanup(void)
void filemenu_set_cursor_goal_pos(s32 windowID, s32 posX, s32 posY)
s32 filemenu_cursor_alpha
void filemenu_update_deselect_file(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
void filemenu_update_hidden_options_left(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
void filemenu_update_hidden_name_confirm(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
Gfx D_8024B708[]
void func_8024330C(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
HudScript * filemenu_cursor_hudElemScripts[]
HudScript HES_AnimatedCursorHand
s16 D_80249BBC[16]
s16 D_80249CF4[16]
s16 D_80249D48[10]
void filemenu_set_cursor_alpha(s32 alpha)
MenuPanel filemenu_createfile_menuBP
MenuPanel * filemenu_menus[]
s16 D_80249C7C[10]
s32 D_80249BB8
s16 D_80249C1C[16]
BSS s32 filemenu_cursorHudElemID[1]
MenuPanel filemenu_main_menuBP
f32 CopyArrowAnimOffsets[]
s16 D_80249CB8[10]
BSS s8 filemenu_currentMenu
void filemenu_update(void)
void filemenu_init(s32 arg0)
void filemenu_draw_rect(s32 ulx, s32 uly, s32 lrx, s32 lry, s32 tileIdx, s32 uls, s32 ult, s32 dsdx, s32 dtdy)
BSS s8 filemenu_filename_pos
s16 D_80249CA4[10]
s16 D_80249BDC[16]
BSS s32 filemenu_createfile_hudElems[4]
BSS s32 filemenu_hudElemIDs[20]
s32 filemenu_cursor_targetY
MenuPanel filemenu_yesno_menuBP
void filemenu_update_hidden_options_bottom(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
BSS s32 filemenu_CopyToFileIdx
BSS s32 filemenu_CopyFromFileIdx
void filemenu_update_show_options_left(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
void filemenu_update_hidden_title(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
Vp D_80249D60
s16 D_80249C3C[16]
void filemenu_draw_cursor(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
s32 filemenu_cursorGoalAlpha
void filemenu_update_show_options_right(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
void filemenu_update_show_with_rotation(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
MenuPanel filemenu_info_menuBP
Gfx D_8024B6F0[]
void filemenu_update_show_name_confirm(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
void filemenu_update_select_file(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
void filemenu_update_hidden_options_right(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
s32 filemenu_cursor_posX
Gfx filemenu_dl_copyarrow[]
Definition filemenu_gfx.c:8
void func_PAL_8002B574(void)
void filemenu_draw_contents_copy_arrow(MenuPanel *menu, s32 baseX, s32 baseY, s32 width, s32 height, s32 opacity, s32 darkening)
s32 func_80244BC4()
s32 filemenu_cursorGoalAlpha2
s16 D_80249C5C[16]
void filemenu_update_show_options_bottom(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
s16 D_80249D14[16]
void filemenu_update_show_name_input(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
void filemenu_update_show_title(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
void filemenu_update_hidden_name_input(s32 windowIdx, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
void filemenu_update_cursor(void)
void filemenu_set_selected(MenuPanel *menu, s32 col, s32 row)
s32 filemenu_cursor_posY
s16 D_80249D34[10]
s16 D_80249CCC[10]
s16 D_80249BFC[16]
BSS s32 filemenu_pressedButtons
BSS s32 filemenu_heldButtons
BSS s32 filemenu_8024C09C
u8 filemenu_glyphBuffer[20][0x80]
b32 fio_load_globals(void)
Definition fio.c:75
b32 fio_load_game(s32 saveSlot)
Definition fio.c:167
SaveGlobals gSaveGlobals
Definition fio.c:20
SaveFileSummary gSaveSlotSummary[4]
SaveSlotMetadata gSaveSlotMetadata[4]
void set_window_update(s32 panelID, s32)
Definition windows.c:434
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
s32 get_game_mode(void)
Definition game_modes.c:123
@ GAME_MODE_END_FILE_SELECT
Definition game_modes.h:20
void hud_element_set_alpha(s32 id, s32 opacity)
void hud_element_draw_without_clipping(s32 id)
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_free(s32 id)
@ HUD_ELEMENT_FLAG_80
Definition hud_element.h:80
@ HUD_ELEMENT_FLAG_DROP_SHADOW
s32 HudScript[]
Definition hud_element.h:9
#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
#define ALIGNED(x)
Definition macros.h:10
void(* fpHandleInput)(struct MenuPanel *)
void(* fpUpdate)(struct MenuPanel *)
void(* fpCleanup)(struct MenuPanel *)
void(* fpInit)(struct MenuPanel *)
WindowStyle style
GameStatus * gGameStatusPtr
Definition main_loop.c:32
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
Window gWindows[64]
Definition windows.c:23
DisplayContext * gDisplayContext
Definition cam_main.c:16
SaveFileSummary summary
Definition versioning.h:170
SaveData gCurrentSaveFile
Definition fio.c:21
char modName[28]
Definition versioning.h:145
u32 lastFileSelected
Definition versioning.h:15