DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
menu_save.cpp
1#pragma helper_mask_gpr 0x30
2#pragma helper_mask_fpr 0x1000
3#pragma name_counter 3062
4
5#include "menu_save.hpp"
6
7#include <cstdio>
8#include <cstdlib>
9#include <cstring>
10
11#include "battle_globals.hpp"
12#include "camera.hpp"
13#include "clsmes.hpp"
14#include "dataread.hpp"
15#include "dun/gameloop.hpp"
16#include "editatra.hpp"
17#include "gamepad.hpp"
18#include "itemdata.hpp"
19#include "mainitemmodel.hpp"
20#include "memcard.hpp"
21#include "memorycardaccess.hpp"
22#include "menu_draw.hpp"
23#include "menu_inventory.hpp"
24#include "menuitemstep.hpp"
25#include "mglib.hpp"
26#include "rect.hpp"
27#include "savedata.hpp"
28#include "snd.hpp"
29#include "texture.hpp"
30#include "userstatus.hpp"
31
32SAVE_MENU_STATE SaveMenu;
33CTexture *SaveMenuMojiTextbl[4];
34
36MINI_MENU_INFO MiniMenu;
37
42void ExitSaveSelect();
43
51static void DrawEventItemBoard(int x, int y, int top, int bottom, int alpha, CTexture *texture);
52
60static int EventItemSelectKey(int *result);
61
69static void EventItemSelectDraw();
70
78static int SaveMenuKeySaveCheck() {
79 MC_CARD_INFO *card = &McAccess.card[McAccess.port];
80
81 if (McCheckMCPs2(card) == 0) {
82 SaveMenu.key_no = SAVE_KEY_ALERT;
83 SaveMenu.alert_no = SAVE_ALERT_NO_CARD;
84 return 1;
85 }
86
87 if ((card->result < 0) || (card->format_change != 0)) {
88 SaveMenu.key_no = SAVE_KEY_ALERT;
89 SaveMenu.alert_no = SAVE_ALERT_CARD_ERROR;
90 return 1;
91 }
92
93 if (card->formatted == 0) {
94 SaveMenu.key_no = SAVE_KEY_FORMAT;
95 McAccess.SetFuncNo(MC_OPERATION_SEARCH_TYPE);
96 return 1;
97 }
98
99 if (card->dir_exists == 0) {
100 SaveMenu.key_no = SAVE_KEY_NEW_DIR_SELECT;
101 return 1;
102 }
103
104 if (McAccess.CheckFileNo(SaveMenu.file_no) != 0) {
105 SaveMenu.key_no = SAVE_KEY_SAVE_DECIDE;
106 } else {
107 McAccess.SetFuncNo(MC_OPERATION_SEARCH_TYPE);
108 SaveMenu.key_no = SAVE_KEY_SAVE;
109 }
110
111 return 1;
112}
113
121static int SaveMenuKeySaveDecide() {
122 if (GamePad.Down(PAD_CROSS) != 0) {
123 McAccess.SetFuncNo(MC_OPERATION_SEARCH_TYPE);
124 int file_no = SaveMenu.file_no;
125 McAccess.file_no = file_no;
126 ((s32 *) SaveData->GetConfigData())[17] = file_no;
127 SaveMenu.key_no = SAVE_KEY_SAVE;
128 ComMenuSePlay(MENU_SOUND_CONFIRM);
129 return 1;
130 }
131
132 if (GamePad.Down(PAD_CIRCLE) != 0) {
133 SaveMenu.key_no = SAVE_KEY_FILE_SELECT;
134 ComMenuSePlay(MENU_SOUND_REFUSE);
135 SaveMenu.step_time = 0;
136 return 1;
137 }
138
139 return 1;
140}
141
149static int SaveMenuKeySave() {
150 MC_CARD_INFO *card = &McAccess.card[McAccess.port];
151
152 if (McCheckMCPs2(card) == 0) {
153 SaveMenu.key_no = SAVE_KEY_ALERT;
154 SaveMenu.alert_no = SAVE_ALERT_NO_CARD;
155 return 1;
156 }
157
158 if (card->result < 0) {
159 SaveMenu.key_no = SAVE_KEY_ALERT;
160 SaveMenu.alert_no = SAVE_ALERT_CARD_ERROR;
161 return 1;
162 }
163
164 if ((card->free_size < 0x50) && (McAccess.CheckFileNo(SaveMenu.file_no) == 0)) {
165 SaveMenu.key_no = SAVE_KEY_ALERT;
166 SaveMenu.alert_no = SAVE_ALERT_NO_SPACE_FILE;
167 return 1;
168 }
169
170 McAccess.SetFuncNo(MC_OPERATION_SAVE);
171 McAccess.file_no = SaveMenu.file_no;
172 SaveMenu.key_no = SAVE_KEY_END_SAVE;
173 return 1;
174}
175
183static int SaveMenuKeyEndSave() {
184 if ((GamePad.Down(PAD_CROSS) != 0) || (GamePad.Down(PAD_CIRCLE) != 0)) {
185 McAccess.SetFuncNo(MC_OPERATION_IDLE);
186 SaveMenu.key_no = SAVE_KEY_FILE_SELECT;
187 }
188
189 return 1;
190}
191
199static int SaveMenuKeyLoadDecide() {
200 if (GamePad.Down(PAD_CROSS) != 0) {
201 int file_no = SaveMenu.file_no;
202
203 SAVEDATA_INFO *file_info = &McAccess.file_info[file_no];
204
205 if (file_info->state != 0) {
206 McAccess.SetFuncNo(MC_OPERATION_SEARCH_TYPE);
207 McAccess.file_no = SaveMenu.file_no;
208 SaveMenu.key_no = SAVE_KEY_LOAD;
209 ComMenuSePlay(MENU_SOUND_CONFIRM);
210 } else {
211 ComMenuSePlay(MENU_SOUND_REFUSE);
212 }
213
214 return 1;
215 }
216
217 if (GamePad.Down(PAD_CIRCLE) != 0) {
218 SaveMenu.key_no = SAVE_KEY_FILE_SELECT;
219 ComMenuSePlay(MENU_SOUND_REFUSE);
220 return 1;
221 }
222
223 return 1;
224}
225
233static int SaveMenuKeyLoad() {
234 MC_CARD_INFO *card = &McAccess.card[McAccess.port];
235
236 if (McCheckMCPs2(card) == 0) {
237 SaveMenu.key_no = SAVE_KEY_ALERT;
238 SaveMenu.alert_no = SAVE_ALERT_NO_CARD;
239 return 1;
240 }
241
242 if (card->result < 0) {
243 SaveMenu.key_no = SAVE_KEY_ALERT;
244 SaveMenu.alert_no = SAVE_ALERT_CARD_ERROR;
245 return 1;
246 }
247
248 McAccess.SetFuncNo(MC_OPERATION_LOAD);
249 McAccess.file_no = SaveMenu.file_no;
250 SaveMenu.key_no = SAVE_KEY_FILE_SELECT;
251 return 1;
252}
253
261static int SaveMenuKeyArart() {
262 switch (SaveMenu.alert_no) {
263 case SAVE_ALERT_NONE:
264 break;
265 case SAVE_ALERT_NO_CARD:
266 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
267 SaveMenu.key_no = SAVE_KEY_MC_SELECT;
268 SaveMenu.file_no = McAccess.port;
269 ComMenuSePlay(MENU_SOUND_REFUSE);
270 }
271
272 break;
273 case SAVE_ALERT_CARD_FULL:
274 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
275 SaveMenu.key_no = SAVE_KEY_MC_SELECT;
276 SaveMenu.file_no = McAccess.port;
277 ComMenuSePlay(MENU_SOUND_REFUSE);
278 }
279
280 break;
281 default:
282 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
283 SaveMenu.key_no = SAVE_KEY_MC_SELECT;
284 SaveMenu.file_no = McAccess.port;
285 ComMenuSePlay(MENU_SOUND_REFUSE);
286 }
287
288 break;
289 }
290
291 return 1;
292}
293
301static int SaveMenuKeyNewDirSelect() {
302 if (GamePad.Down(PAD_CROSS) != 0) {
303 McAccess.SetFuncNo(MC_OPERATION_SEARCH_TYPE);
304 SaveMenu.key_no = SAVE_KEY_NEW_DIR;
305 ComMenuSePlay(MENU_SOUND_CONFIRM);
306 return 1;
307 }
308
309 if (GamePad.Down(PAD_CIRCLE) != 0) {
310 SaveMenu.key_no = SAVE_KEY_MC_SELECT;
311 SaveMenu.file_no = McAccess.port;
312 SaveMenu.step_time = 0;
313 ComMenuSePlay(MENU_SOUND_REFUSE);
314 return 1;
315 }
316
317 return 1;
318}
319
327static int SaveMenuKeyNewDir() {
328 MC_CARD_INFO *card = &McAccess.card[McAccess.port];
329
330 if (McCheckMCPs2(card) == 0) {
331 SaveMenu.key_no = SAVE_KEY_ALERT;
332 SaveMenu.alert_no = SAVE_ALERT_NO_CARD;
333 return 1;
334 }
335
336 if ((card->result < 0) || (card->formatted == 0)) {
337 SaveMenu.key_no = SAVE_KEY_ALERT;
338 SaveMenu.alert_no = SAVE_ALERT_CARD_ERROR;
339 return 1;
340 }
341
342 if (card->free_size < 0x190) {
343 SaveMenu.key_no = SAVE_KEY_ALERT;
344 SaveMenu.alert_no = SAVE_ALERT_NO_SPACE_DIR;
345 return 1;
346 }
347
348 McAccess.SetFuncNo(MC_OPERATION_MAKE_DIR);
349 SaveMenu.key_no = SAVE_KEY_SAVE;
350 PORT_RETURN(1);
351}
352
360static int SaveMenuKeyFormat() {
361 MC_CARD_INFO *card = &McAccess.card[McAccess.port];
362
363 if (McCheckMCPs2(card) == 0) {
364 SaveMenu.key_no = SAVE_KEY_ALERT;
365 SaveMenu.alert_no = SAVE_ALERT_NO_CARD;
366 return 1;
367 }
368
369 if (card->result < 0) {
370 SaveMenu.key_no = SAVE_KEY_ALERT;
371 SaveMenu.alert_no = SAVE_ALERT_CARD_ERROR;
372 return 1;
373 }
374
375 if (GamePad.Down(PAD_CROSS) != 0) {
376 McAccess.SetFuncNo(MC_OPERATION_FORMAT);
377 SaveMenu.key_no = SAVE_KEY_NEW_DIR;
378 ComMenuSePlay(MENU_SOUND_CONFIRM);
379 return 1;
380 }
381
382 if (GamePad.Down(PAD_CIRCLE) != 0) {
383 SaveMenu.key_no = SAVE_KEY_MC_SELECT;
384 SaveMenu.file_no = McAccess.port;
385 ComMenuSePlay(MENU_SOUND_REFUSE);
386 return 1;
387 }
388
389 return 1;
390}
391
399static int SaveMenuKeyUnFormat() {
400 MC_CARD_INFO *card = &McAccess.card[McAccess.port];
401
402 if (card->formatted != 0) {
403 McAccess.SetFuncNo(MC_OPERATION_UNFORMAT);
404 } else {
405 SaveMenu.key_no = SAVE_KEY_MC_SELECT;
406 SaveMenu.file_no = McAccess.port;
407 }
408
409 return 1;
410}
411
419static int SaveMenuKeyDifVersion() {
420 if (GamePad.Down(PAD_TRIANGLE | PAD_CIRCLE | PAD_CROSS | PAD_SQUARE) != 0) {
421 McAccess.SetFuncNo(MC_OPERATION_DELETE);
422 int file_no = McAccess.file_no;
423 McAccess.file_no = file_no;
424 }
425
426 return 1;
427}
428
436static s32 SaveMenuKeyDelete() {
437 return 1;
438}
439
447static s32 SaveMenuKeyCopy() {
448 return 1;
449}
450
458static int SaveMenuKeyAfterEnding() {
459 if (GamePad.Down(PAD_CROSS) != 0) {
460 SaveMenu.key_no = SAVE_KEY_MC_SELECT;
461 } else if (GamePad.Down(PAD_CIRCLE) != 0) {
462 SaveMenu.key_no = SAVE_KEY_FADE_OUT;
463 ExitSaveSelect();
464 }
465
466 return 1;
467}
468
476static int SaveMenuKeySaveDecideEnding() {
477 if (GamePad.Down(PAD_CROSS) != 0) {
478 SaveMenu.key_no = SAVE_KEY_SAVE_ENDING;
479 } else if (GamePad.Down(PAD_CIRCLE) != 0) {
480 SaveMenu.key_no = SAVE_KEY_FADE_OUT;
481 ExitSaveSelect();
482 }
483
484 return 1;
485}
486
494static int SaveMenuKeySaveEnding() {
495 SaveMenu.key_no = SAVE_KEY_END_SAVE_ENDING;
496 McAccess.SetFuncNo(MC_OPERATION_SAVE_CONFIG);
497 return 1;
498}
499
507static int SaveMenuKeyEndSaveEnding() {
508 if (GamePad.Down(PAD_CROSS) != 0) {
509 SaveMenu.key_no = SAVE_KEY_MC_SELECT;
510 McAccess.SetFuncNo(MC_OPERATION_IDLE);
511 }
512
513 return 1;
514}
515
516int GetSaveMenuMsgNo() {
517 int msg_no = 0;
518
519 switch (McAccess.GetFuncNo()) {
520 case MC_OPERATION_SEARCH_TYPE:
521 switch (SaveMenu.key_no) {
522 case SAVE_KEY_CHECK_MC_TYPE:
523 case SAVE_KEY_SAVE_CHECK:
524 case SAVE_KEY_FILE_SELECT:
525 case SAVE_KEY_SAVE:
526 case SAVE_KEY_LOAD:
527 case SAVE_KEY_NEW_DIR:
528 msg_no = 0xFF;
529 break;
530 }
531 case MC_OPERATION_IDLE:
532 switch (SaveMenu.key_no) {
533 case SAVE_KEY_CHECK_MC:
534 msg_no = 0xFF;
535 break;
536 case SAVE_KEY_MODE_SELECT:
537 msg_no = 0xFA;
538 break;
539 case SAVE_KEY_MC_SELECT:
540 msg_no = 0xFB;
541 break;
542 case SAVE_KEY_SAVE_DECIDE:
543 msg_no = 0x108;
544 break;
545 case SAVE_KEY_LOAD_DECIDE:
546 msg_no = 0x10E;
547 break;
548 case SAVE_KEY_ALERT:
549 switch (SaveMenu.alert_no) {
550 case SAVE_ALERT_NO_CARD:
551 msg_no = 0xFD;
552 break;
553 case SAVE_ALERT_CARD_FULL:
554 msg_no = 0x11B;
555 break;
556 case SAVE_ALERT_CARD_ERROR:
557 msg_no = 0x101;
558 break;
559 case SAVE_ALERT_FORMAT_FAILED:
560 msg_no = 0x11A;
561 break;
562 case SAVE_ALERT_SAVE_FAILED:
563 msg_no = 0x10A;
564 break;
565 case SAVE_ALERT_NO_SPACE_DIR:
566 msg_no = 0x117;
567 break;
568 case SAVE_ALERT_NO_SPACE_FILE:
569 msg_no = 0x100;
570 break;
571 case SAVE_ALERT_NO_SAVE_DATA:
572 msg_no = 0x111;
573 break;
574 case SAVE_ALERT_LOAD_FAILED:
575 msg_no = 0x112;
576 break;
577 case SAVE_ALERT_NONE:
578 case SAVE_ALERT_UNK_3:
579 case SAVE_ALERT_UNK_4:
580 case SAVE_ALERT_UNK_5:
581 break;
582 }
583
584 break;
585 case SAVE_KEY_FORMAT:
586 msg_no = 0x10B;
587 break;
588 case SAVE_KEY_NEW_DIR_SELECT:
589 msg_no = 0x118;
590 break;
591 case SAVE_KEY_DELETE:
592 msg_no = 0x122;
593 break;
594 case SAVE_KEY_COPY:
595 msg_no = 0x124;
596 break;
597 case SAVE_KEY_DIF_VERSION:
598 msg_no = 0x12B;
599 break;
600 case SAVE_KEY_SAVE_ENDING:
601 case SAVE_KEY_SAVE_DECIDE_ENDING:
602 msg_no = 0;
603 break;
604 case SAVE_KEY_AFTER_ENDING:
605 msg_no = 0x12A;
606 break;
607 case SAVE_KEY_END_SAVE:
608 case SAVE_KEY_END_SAVE_ENDING:
609 msg_no = 0x106;
610 break;
611 case SAVE_KEY_FADE_IN:
612 case SAVE_KEY_FADE_OUT:
613 case SAVE_KEY_CHECK_MC_TYPE:
614 case SAVE_KEY_LOAD_CONFIG:
615 case SAVE_KEY_FILE_SELECT:
616 case SAVE_KEY_SAVE_CHECK:
617 case SAVE_KEY_SAVE:
618 case SAVE_KEY_LOAD:
619 case SAVE_KEY_NEW_DIR:
620 case SAVE_KEY_UNFORMAT:
621 break;
622 }
623
624 break;
625 default:
626 msg_no = McAccess.GetMsgNo(0xFA);
627 break;
628 }
629
630 return msg_no;
631}
632
633int SaveMenuTextureEnter() {
634 ReadBG();
635
636 if (ReadBGSync() == 0) {
637 LOADTEXTURE_INFO2 tex[3] = {
638 {"#frame_image_save#640#" SCREEN_HEIGHT_STR "#4", 0, 0},
639 {NULL, 0, 0},
640 {NULL, 0, 0}
641 };
642 BG_READ_INFO *bg;
643 u_int *pack;
644 int i;
645
646 tex[0].block_no = SaveMenu.block_no;
647 tex[1].block_no = SaveMenu.block_no;
648 bg = GetReadBGFile(0);
649 pack = GetPackFile((u_int *) bg->buffer, "saveimg.img", NULL);
650 tex[1].name = (char *) pack;
651 TexManager.DeleteTextureBlock(SaveMenu.block_no);
652 TexManager.CleanUpTextureList();
653 TexManager.LoadTextureBlockEX(-1, tex);
654 SaveBoard = TexManager.GetTexture("save", -1);
655
656 char *moji_names[4] = {"alphabet", "kata", "hira", "alphabet"};
657
658 for (i = 0; i < 4; i++) {
659 SaveMenuMojiTextbl[i] = TexManager.GetTexture(moji_names[i], -1);
660 }
661
662 switch (SaveMenu.mode) {
663 case SAVE_MENU_MODE_ENDING:
664 case SAVE_MENU_MODE_LOAD:
665 InitMenuMesSet(MENU_MES_SET_ALLMENU, (short *) GetPackFile((u_int *) bg->buffer, allmenu_mes, NULL));
666 break;
667 }
668
669 CommonMenuMes2.stay_frame = true;
670 CommonMenuMes2.value_show = true;
671 CommonMenuMes2.value_signed = false;
672 CommonMenuMes2.cursor_lit = true;
673
674 char *save_buffer = (char *) pack + bg->size;
675 MC_ICON_DATA icon = {
676 {"dkicon.ico", NULL, 0},
677 {"dkicon_c.ico", NULL, 0},
678 {"dkicon_d.ico", NULL, 0}
679 };
680
681 for (i = 0; i < 3; i++) {
682 (&icon.view)[i].data = (char *) GetPackFile((u_int *) bg->buffer, (&icon.view)[i].name, &(&icon.view)[i].size);
683 }
684
685 McAccess.SetBuff(save_buffer);
686 McAccess.SetIconData(&icon);
687 McAccess.MakeMcIconSysInfo();
688 return 1;
689 }
690
691 return 0;
692}
693
694int SaveMenuEffectFadeOut() {
695 if (SaveMenu.key_no == SAVE_KEY_FADE_OUT) {
696 return 1;
697 }
698
699 return 0;
700}
701
710static void GetSaveBoardAlphaInfo(int x, int width, int &start_alpha, int &end_alpha, int alpha) {
711 if (x < 0) {
712 start_alpha = 0;
713 } else if ((0 <= x) && (x < 0x81)) {
714 start_alpha = (x * alpha) >> 7;
715 } else if ((x > 0x80) && (x < SCREEN_HEIGHT - 0x7F)) {
716 start_alpha = (alpha * 0x80) >> 7;
717 } else if ((x > SCREEN_HEIGHT - 0x80) && (x < SCREEN_HEIGHT + 1)) {
718 start_alpha = ((SCREEN_HEIGHT - x) * alpha) >> 7;
719 } else {
720 start_alpha = 0;
721 }
722
723 x += width;
724
725 if (x < 0) {
726 end_alpha = 0;
727 } else if ((0 <= x) && (x < 0x81)) {
728 end_alpha = (x * alpha) >> 7;
729 } else if ((x > 0x80) && (x < SCREEN_HEIGHT - 0x7F)) {
730 end_alpha = (alpha * 0x80) >> 7;
731 } else if ((x > SCREEN_HEIGHT - 0x80) && (x < SCREEN_HEIGHT + 1)) {
732 end_alpha = ((SCREEN_HEIGHT - x) * alpha) >> 7;
733 } else {
734 end_alpha = 0;
735 }
736}
737
738void DrawSaveBoard(SAVEDATA_INFO *info, CTexture **name_texture, int x, int y, int unused, int alpha) {
739 int i;
740 int draw_x;
741 int draw_y;
742#ifndef PAL
743 int time[3];
744#endif
745
746 if (info == NULL) {
747 return;
748 }
749
750 spRGBA top = {0x80, 0x80, 0x80, 0};
751 top.a = alpha;
752 spRGBA bottom = {0x80, 0x80, 0x80, 0};
753 bottom.a = alpha;
754 int start_alpha;
755 int end_alpha;
756 GetSaveBoardAlphaInfo(y, 0x88, start_alpha, end_alpha, alpha);
757 top.a = start_alpha;
758 bottom.a = end_alpha;
759 DrawMenu2DSprite(SaveBoard, CRect_i_(x, y, 0x180, 0x87), CRect_i_(0, 0, 0x180, 0x88), &top, &top, &bottom, &bottom);
760
761 draw_x = x + 0x54;
762#ifdef PAL
763 s8 number_shift[] = {0, 0, 0, 10, 0, 4, 13};
764 draw_x += number_shift[GetMenuLangFlag()];
765 int time[3];
766#endif
767 draw_y = y + 8;
768 RECT number_rect = {0x88, 0xCA, 0xC, 0x10};
769 GetSaveBoardAlphaInfo(y, 0x10, start_alpha, end_alpha, alpha);
770 top.a = start_alpha;
771 bottom.a = end_alpha;
772
773 if (info != NULL) {
774 int digits;
775 int number = info->file_no;
776 int clip_y;
777 int src_y;
778 int height;
779 int digit;
780 int width;
781 int src_x;
782
783 for (digits = GetNumberKeta(number); 0 < digits; digits--) {
784 clip_y = draw_y;
785 digit = number % 10;
786 width = number_rect.width;
787 draw_x -= width - 1;
788 src_x = number_rect.x + width * digit;
789 src_y = number_rect.y;
790 height = number_rect.height;
791 MenuTextureClip(clip_y, src_y, height, 0, SCREEN_HEIGHT);
792 DrawMenu2DSprite(SaveBoard, CRect_i_(draw_x, clip_y, width, height - 1), CRect_i_(src_x, src_y, width, height), &top, &top, &bottom, &bottom);
793 number /= 10;
794 }
795 }
796
797 draw_x = x + 0x1A;
798 draw_y = y + 0x1C;
799 GetSaveBoardAlphaInfo(y, 0x16, start_alpha, end_alpha, alpha);
800 top.a = start_alpha;
801 bottom.a = end_alpha;
802 int name_x = draw_x + 8;
803
804 if (info->name != NULL) {
805 DrawSaveBoardCharaName2(name_x, draw_y, (short *) info->name, name_texture, top, bottom);
806 }
807
808 // Play time, as hours, minutes and seconds.
809 RECT time_rect = {0x88, 0xB8, 0xC, 0x12};
810 int column = x + 0x92;
811 draw_x = column + 0xA;
812 draw_y = y + 0x36;
813 GetSaveBoardAlphaInfo(draw_y, 0x12, start_alpha, end_alpha, alpha);
814 top.a = start_alpha;
815 bottom.a = end_alpha;
816 int frames = info->play_time;
817
818 if (frames >= 0x1499700) {
819 frames = 0x14996C4;
820 }
821
822 frames /= 60;
823 time[0] = frames / 3600;
824 time[1] = (frames / 60 - time[0] * 60) % 60;
825 time[2] = frames % 60;
826
827 for (int part = 2; part >= 0; part--) {
828 int value = time[part];
829 DrawMenu2DSprite(SaveBoard, CRect_i_(draw_x, draw_y, time_rect.width, time_rect.height), CRect_i_(time_rect.x + time_rect.width * (value / 10), time_rect.y, time_rect.width, time_rect.height), &top, &top, &bottom, &bottom);
830 DrawMenu2DSprite(SaveBoard, CRect_i_(draw_x + time_rect.width, draw_y, time_rect.width, time_rect.height), CRect_i_(time_rect.x + time_rect.width * (value % 10), time_rect.y, time_rect.width, time_rect.height), &top, &top, &bottom, &bottom);
831 draw_x -= 0x1E;
832 }
833
834 CRect_i_ colon(0x100, 0xB8, 0xC, 0x12);
835 GetSaveBoardAlphaInfo(draw_y, 0x12, start_alpha, end_alpha, alpha);
836 top.a = start_alpha;
837 bottom.a = end_alpha;
838 draw_x = column + 2;
839 DrawMenu2DSprite(SaveBoard, CRect_i_(draw_x, draw_y, 0xC, 0x12), colon, &top, &top, &bottom, &bottom);
840 DrawMenu2DSprite(SaveBoard, CRect_i_(draw_x - 0x1E, draw_y, 0xC, 0x12), colon, &top, &top, &bottom, &bottom);
841
842 draw_x = x + 0x88;
843 draw_y = y + 0x52;
844 GetSaveBoardAlphaInfo(draw_y, 0x12, start_alpha, end_alpha, alpha);
845 top.a = start_alpha;
846 bottom.a = end_alpha;
847 {
848 int digits;
849 int number = info->quest_total;
850 int clip_y;
851 int src_y;
852 int height;
853 int digit;
854 int width;
855 int src_x;
856
857 for (digits = GetNumberKeta(number); 0 < digits; digits--) {
858 clip_y = draw_y;
859 digit = number % 10;
860 width = number_rect.width;
861 draw_x -= width - 1;
862 src_x = number_rect.x + width * digit;
863 src_y = number_rect.y;
864 height = number_rect.height;
865 MenuTextureClip(clip_y, src_y, height, 0, SCREEN_HEIGHT);
866 DrawMenu2DSprite(SaveBoard, CRect_i_(draw_x, clip_y, width, height - 1), CRect_i_(src_x, src_y, width, height), &top, &top, &bottom, &bottom);
867 number /= 10;
868 }
869 }
870
871 // Row of each map's name on the board texture; a map from 14 on is in the second block.
872 int map = info->map_no;
873 s16 map_name[62] = {0, 1, 2, 3, 6, 0, 0, 0, 0, 0, 0, 1, 1, 1, 9, 9, 9, 9, 9, 2, 2,
874 4, 10, 4, 13, 13, 13, 10, 9, 4, 4, 4, 4, 1, 10, 12, 10, 5, 13, 12, 13, 4,
875 10, 2, 2, 2, 13, 4, 13, 13, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 14};
876 int name_u;
877 int name_v;
878
879 if (map_name[map] < 0xE) {
880 name_u = (map_name[map] / 7) * 0x88;
881 name_v = (map_name[map] % 7) * 0x14 + 0xB8;
882 } else {
883 map_name[map] -= 0xE;
884 name_u = (map_name[map] / 7) * 0x88;
885 name_v = (map_name[map] % 7) * 0x14 + 0x144;
886 }
887
888 draw_x = x + 0x23;
889 draw_y = y + 0x63;
890 GetSaveBoardAlphaInfo(draw_y, 0x14, start_alpha, end_alpha, alpha);
891 top.a = start_alpha;
892 bottom.a = end_alpha;
893 DrawMenu2DSprite(SaveBoard, CRect_i_(draw_x, draw_y, 0x88, 0x15), CRect_i_(name_u, name_v, 0x88, 0x14), &top, &top, &bottom, &bottom);
894
895 // A face for each member of the party, three to a row.
896 int face_x = x + 0xCF;
897 draw_x = face_x;
898 draw_y = y + 0x1A;
899 GetSaveBoardAlphaInfo(draw_y, 0x30, start_alpha, end_alpha, alpha);
900 top.a = start_alpha;
901 bottom.a = end_alpha;
902
903 for (i = 0; i < info->party_size; i++) {
904 DrawMenu2DSprite(SaveBoard, CRect_i_(draw_x, draw_y, 0x30, 0x31), CRect_i_(i * 0x30, 0x88, 0x30, 0x30), &top, &top, &bottom, &bottom);
905 draw_x += 0x38;
906
907 if (i == 2) {
908 draw_x = face_x;
909 draw_y += 0x34;
910 GetSaveBoardAlphaInfo(draw_y, 0x30, start_alpha, end_alpha, alpha);
911 top.a = start_alpha;
912 bottom.a = end_alpha;
913 }
914 }
915}
916
917void DrawNewFileTemplete(int x, int y, int alpha) {
918 int start_alpha;
919 int end_alpha;
920
921 if (y % 2 != 0) {
922 y++;
923 }
924
925 spRGBA top = {0x80, 0x80, 0x80, 0};
926 top.a = alpha;
927 spRGBA bottom = {0x80, 0x80, 0x80, 0};
928 bottom.a = alpha;
929
930 // Top edge: two corners and the run between them.
931 GetSaveBoardAlphaInfo(y, 0x10, start_alpha, end_alpha, 0x80);
932 top.a = start_alpha;
933 bottom.a = end_alpha;
934 set2DSprite(Vif1Packet, SaveBoard, CRect_i_(x, y, 0x10, 0xF), CRect_i_(0x120, 0x88, 0x10, 0x10), &top, &top, &bottom, &bottom, 1);
935 set2DSprite(Vif1Packet, SaveBoard, CRect_i_(x + 0x170, y, 0x10, 0xF), CRect_i_(0x140, 0x88, 0x10, 0x10), &top, &top, &bottom, &bottom, 1);
936 set2DSprite(Vif1Packet, SaveBoard, CRect_i_(x + 0x10, y, 0x160, 0xF), CRect_i_(0x130, 0x88, 0x10, 0x10), &top, &top, &bottom, &bottom, 1);
937
938 // Bottom edge.
939 GetSaveBoardAlphaInfo(y + 0x78, 0x10, start_alpha, end_alpha, 0x80);
940 top.a = start_alpha;
941 bottom.a = end_alpha;
942 set2DSprite(Vif1Packet, SaveBoard, CRect_i_(x, y + 0x78, 0x10, 0xF), CRect_i_(0x120, 0xA8, 0x10, 0x10), &top, &top, &bottom, &bottom, 1);
943 set2DSprite(Vif1Packet, SaveBoard, CRect_i_(x + 0x170, y + 0x78, 0x10, 0xF), CRect_i_(0x140, 0xA8, 0x10, 0x10), &top, &top, &bottom, &bottom, 1);
944 set2DSprite(Vif1Packet, SaveBoard, CRect_i_(x + 0x10, y + 0x78, 0x160, 0xF), CRect_i_(0x130, 0xA8, 0x10, 0x10), &top, &top, &bottom, &bottom, 1);
945
946 // Sides.
947 GetSaveBoardAlphaInfo(y + 0x10, 0x68, start_alpha, end_alpha, 0x80);
948 top.a = start_alpha;
949 bottom.a = end_alpha;
950 set2DSprite(Vif1Packet, SaveBoard, CRect_i_(x, y + 0xF, 0x10, 0x69), CRect_i_(0x120, 0x98, 0x10, 0x10), &top, &top, &bottom, &bottom, 1);
951 set2DSprite(Vif1Packet, SaveBoard, CRect_i_(x + 0x170, y + 0xF, 0x10, 0x69), CRect_i_(0x140, 0x98, 0x10, 0x10), &top, &top, &bottom, &bottom, 1);
952
953 // "New file".
954 GetSaveBoardAlphaInfo(y + 0x35, 0x1E, start_alpha, end_alpha, 0x80);
955 top.a = start_alpha;
956 bottom.a = end_alpha;
957#ifdef PAL
958 s8 label_inset[] = {64, 64, 64, 64, 38, 64, 64};
959 int label_x = 0xC0 - label_inset[GetMenuLangFlag()];
960 set2DSprite(GetVif1Packet(), SaveBoard, CRect_i_(x + label_x, y + 0x35, 0x74, 0x1E), CRect_i_(0x10C, 0xB8, 0x74, 0x1E), &top, &top, &bottom, &bottom, 1);
961#else
962 set2DSprite(GetVif1Packet(), SaveBoard, CRect_i_(x + 0x86, y + 0x35, 0x74, 0x1E), CRect_i_(0x10C, 0xB8, 0x74, 0x1E), &top, &top, &bottom, &bottom, 1);
963#endif
964}
965
966int InitExistData() {
967 int port;
968 int result;
969
970 if (McAccess.InitForMC() != 0) {
971 printf("Memory Card Initialized Failed\n");
972 return 0;
973 }
974
975 for (port = 0; port < 2; port++) {
976 McAccess.port = port;
977 McAccess.SetFuncNo(MC_OPERATION_SEARCH_TYPE);
978
979 do {
980 result = McAccess.Step();
981 } while (result == 0);
982
983 if (result < 0) {
984 continue;
985 }
986
987 MC_CARD_INFO *card = &McAccess.card[McAccess.port];
988
989 if ((McCheckMCPs2(card) == 0) || (card->formatted == 0)) {
990 continue;
991 }
992
993 McAccess.SetFuncNo(MC_OPERATION_GET_DIR);
994
995 while (McAccess.Step() == 0) {
996 }
997
998 McAccess.SetFuncNo(MC_OPERATION_LOAD_CONFIG);
999
1000 do {
1001 result = McAccess.Step();
1002 } while (result == 0);
1003
1004 if ((result >= 0) && (card->dir_exists != 0)) {
1005 return 1;
1006 }
1007 }
1008
1009 return 0;
1010}
1011
1012int SaveEnableCheck() {
1013 int found;
1014 int free_size;
1015 int port;
1016 int result;
1017
1018 if (McAccess.InitForMC() != 0) {
1019 return SAVE_ENABLE_NO_CARD;
1020 }
1021
1022 found = 0;
1023 free_size = 0;
1024
1025 for (port = 0; port < 2; port++) {
1026 McAccess.port = port;
1027 McAccess.SetFuncNo(MC_OPERATION_SEARCH_TYPE);
1028
1029 do {
1030 result = McAccess.Step();
1031 } while (result == 0);
1032
1033 if (result < 0) {
1034 continue;
1035 }
1036
1037 MC_CARD_INFO *card = &McAccess.card[McAccess.port];
1038
1039 if (McCheckMCPs2(card) == 0) {
1040 continue;
1041 }
1042
1043 found = 1;
1044
1045 if (card->formatted == 0) {
1046 return found;
1047 }
1048
1049 McAccess.SetFuncNo(MC_OPERATION_GET_DIR);
1050
1051 do {
1052 result = McAccess.Step();
1053 } while (result == 0);
1054
1055 if (result < 0) {
1056 continue;
1057 }
1058
1059 if (card->dir_exists != 0) {
1060 return SAVE_ENABLE_OK;
1061 }
1062
1063 if (free_size < card->free_size) {
1064 free_size = card->free_size;
1065 }
1066 }
1067
1068 if (found == 0) {
1069 return SAVE_ENABLE_NO_CARD;
1070 }
1071
1072 if (free_size < 0x190) {
1073 return SAVE_ENABLE_NO_SPACE;
1074 }
1075
1076 return SAVE_ENABLE_OK;
1077}
1078
1082float EventBoardPos[2];
1083
1087int EventItemMoveY;
1088
1092float EventBarY;
1093
1097CTexture *MiniEventBoard;
1098
1102CTexture *FishFoodBoard;
1103
1107ITEM_PACK *EventItemPackPt;
1108
1109s32 MiniEventTextureBlock;
1110
1114int MiniEventTexReadFlag;
1115
1119float MiniCur[2];
1120
1121void InitEventItemSelect(int block, int *usable, ITEM_PACK *pack, int x, int y, int vanish, int fish_mode) {
1122 int i;
1123
1124 GamePad.SetAutoRepeat(PAD_DPAD, 0x1E, 5);
1125 GamePad.MenuModeOn(0x78);
1126 StayTex = TexManager.GetTexture(AtoraVibeTextureName, -1);
1127 MiniMenu.fish_mode = fish_mode;
1128 MiniEventTextureBlock = block;
1129 MiniMenu.lang = GetMenuLangFlag();
1130 s8 lang_y[7] = {0, -0x10, -0x10, -0x10, -0x10, -0x10, -0x10};
1131 EventBoardPos[0] = x;
1132#ifdef PAL
1133 EventBoardPos[1] = (float) y + (float) lang_y[MiniMenu.lang] + 20.0f;
1134#else
1135 EventBoardPos[1] = (float) y + (float) lang_y[MiniMenu.lang];
1136#endif
1137 EventItemPackPt = pack;
1138 MiniMenu.event_item_num = 0;
1139
1140 for (i = 0; i < pack->num; i++) {
1141 if (pack->item[i] >= ITEM_DUNGEON_START) {
1142 MiniMenu.event_item_num++;
1143 }
1144 }
1145
1146 for (MiniMenu.usable_num = 0; MiniMenu.usable_num < 13; MiniMenu.usable_num++) {
1147 MiniMenu.usable[MiniMenu.usable_num] = usable[MiniMenu.usable_num];
1148 printf("itemno = %d\n", usable[MiniMenu.usable_num]);
1149
1150 if (usable[MiniMenu.usable_num] < 0) {
1151 break;
1152 }
1153 }
1154
1155 MiniMenu.selected = -1;
1156 MiniMenu.vanish = vanish;
1157
1158 if (MiniMenu.vanish != 0) {
1159 printf("vanish after use !\n");
1160 } else {
1161 printf("exist after use \n");
1162 }
1163
1164 LOADTEXTURE_INFO2 texture[2] = {
1165 {"#frame_image#640#" SCREEN_HEIGHT_STR "#4", 0, 0},
1166 {NULL, 0, 0}
1167 };
1168 texture[0].block_no = MiniEventTextureBlock;
1169 TexManager.DeleteTextureBlock(MiniEventTextureBlock);
1170 TexManager.CleanUpTextureList();
1171 TexManager.LoadTextureBlockEX(-1, texture);
1172 StartReadBG();
1173 u_long128 *buffer = (u_long128 *) read_buffer;
1174 buffer = MenuCalcBufAlignment(buffer);
1175 LoadFileBGMenuData("eventmnu2.pak", buffer);
1176 ReadBG();
1177 MiniMenu.cursor = 0;
1178 MiniMenu.scroll_row = 0;
1179 EventItemMoveY = 56.0f + EventBoardPos[1] - MiniMenu.scroll_row * 0x28;
1180 int rows = EventItemPackPt->num / 5;
1181
1182 if (rows <= 0) {
1183 rows = 1;
1184 }
1185
1186 EventBarY = 60.0f + EventBoardPos[1] + (int) (68.0f * MiniMenu.scroll_row) / rows;
1187 MiniCur[0] = 6.0f + EventBoardPos[0] + ((MiniMenu.cursor + 5) % 5) * 0x2A;
1188 MiniCur[1] = 60.0f + EventBoardPos[1] + ((MiniMenu.cursor - MiniMenu.scroll_row * 5) / 5) * 0x28;
1189 MiniMenu.state = MINI_MENU_FADE_IN;
1190 MiniEventTexReadFlag = 0;
1191}
1192
1200static void EventItemSelectExit() {
1201 TexManager.DeleteTextureBlock(MiniEventTextureBlock);
1202 TexManager.CleanUpTextureList();
1203 GamePad.AutoRepeatOff();
1204 GamePad.MenuModeOff();
1205}
1206
1207int EventItemSelectLoop(int *result) {
1208 int done;
1209 int alpha;
1210
1211 ReadBG();
1212 alpha = 0x40;
1213
1214 switch (MiniMenu.state) {
1215 case MINI_MENU_CHOOSING:
1216 alpha = 0x40;
1217 break;
1218 case MINI_MENU_FADE_IN:
1219 alpha = 0x80 - MiniMenu.state_time * 4;
1220
1221 if (alpha < 0x40) {
1222 alpha = 0x40;
1223 }
1224
1225 break;
1226 case MINI_MENU_FADE_OUT:
1227 alpha = MiniMenu.state_time * 4 + 0x40;
1228
1229 if (alpha > 0x80) {
1230 alpha = 0x80;
1231 }
1232
1233 break;
1234 }
1235
1236 setbilinear(0);
1237 FrameImageDraw(alpha, 0x80);
1238 MenuTextureReload(MiniEventTextureBlock);
1239 done = EventItemSelectKey(result);
1240 EventItemSelectDraw();
1241 setbilinear(1);
1242
1243 if (done != 0) {
1244 EventItemSelectExit();
1245 }
1246
1247 return done;
1248}
1249
1250static int EventItemSelectKey(int *result) {
1251 int done;
1252 int old_cursor;
1253 int slot_num;
1254 int pack_index;
1255 int accepted;
1256 int i;
1257 s16 *slot;
1258
1259 if (MiniEventTexReadFlag == 0) {
1260 if (ReadBGSync() == 0) {
1261 LOADTEXTURE_INFO2 texture[4] = {
1262 {"#frame_image#640#" SCREEN_HEIGHT_STR "#4", 0, 0},
1263 {NULL, 0, 0},
1264 {NULL, 0, 0},
1265 {NULL, 0, 0}
1266 };
1267 texture[0].block_no = MiniEventTextureBlock;
1268 texture[1].block_no = MiniEventTextureBlock;
1269 texture[2].block_no = MiniEventTextureBlock;
1270 BG_READ_INFO *file = GetReadBGFile(0);
1271 texture[1].name = (char *) GetPackFile((u_int *) file->buffer, "eventmnu.img", NULL);
1272 texture[2].name = (char *) GetPackFile((u_int *) file->buffer, "fishmnu.img", NULL);
1273 TexManager.DeleteTextureBlock(MiniEventTextureBlock);
1274 TexManager.LoadTextureBlockEX(-1, texture);
1275 MiniEventBoard = TexManager.GetTexture("eventmnu", -1);
1276 FishFoodBoard = TexManager.GetTexture("fishmnu", -1);
1277 ItemIcon = TexManager.GetTexture("itemicon", -1);
1278 InitMenuMesSet(MENU_MES_SET_EVENT_ITEM, (short *) GetPackFile((u_int *) file->buffer, "eventuse.bin", NULL));
1279 CommonMenuMes2.MakeMesWin(0);
1280 CommonMenuMes2.Step();
1281 MiniEventTexReadFlag = 1;
1282 } else {
1283 return 0;
1284 }
1285 }
1286
1287 done = 0;
1288 old_cursor = MiniMenu.cursor;
1289 slot_num = EventItemPackPt->num;
1290
1291 switch (MiniMenu.state) {
1292 case MINI_MENU_REFUSED:
1293 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
1294 MiniMenu.state = MINI_MENU_CHOOSING;
1295 }
1296
1297 break;
1298 case MINI_MENU_CHOOSING:
1299 if (GamePad.Down(PAD_UP) != 0 && MiniMenu.cursor > 4) {
1300 MiniMenu.cursor -= 5;
1301 }
1302
1303 if (GamePad.Down(PAD_DOWN) != 0 && MiniMenu.cursor < slot_num - 5) {
1304 MiniMenu.cursor += 5;
1305 }
1306
1307 if (GamePad.Down(PAD_LEFT) != 0 && 0 < MiniMenu.cursor) {
1308 MiniMenu.cursor--;
1309 }
1310
1311 if (GamePad.Down(PAD_RIGHT) != 0 && MiniMenu.cursor < slot_num - 1) {
1312 MiniMenu.cursor++;
1313 }
1314
1315 if (MiniMenu.cursor < MiniMenu.scroll_row * 5) {
1316 MiniMenu.scroll_row--;
1317 }
1318
1319 if ((MiniMenu.scroll_row + 2) * 5 - 1 < MiniMenu.cursor) {
1320 MiniMenu.scroll_row++;
1321 }
1322
1323 if (old_cursor != MiniMenu.cursor) {
1324 ComMenuSePlay(MENU_SOUND_CURSOR);
1325 }
1326
1327 if (GamePad.Down(PAD_SQUARE) != 0) {
1328 SeitonItemBoard(EventItemPackPt);
1329 ComMenuSePlay(MENU_SOUND_CONFIRM);
1330 break;
1331 }
1332
1333 if (GamePad.Down(PAD_CROSS) != 0) {
1334 pack_index = -1;
1335
1336 if (MiniMenu.cursor < MiniMenu.event_item_num) {
1337 int event_no = 0;
1338 slot = EventItemPackPt->item;
1339
1340 for (pack_index = 0; pack_index < EventItemPackPt->num; pack_index++) {
1341 if (*slot >= ITEM_DUNGEON_START) {
1342 if (MiniMenu.cursor == event_no) {
1343 *result = *slot;
1344 break;
1345 }
1346
1347 event_no++;
1348 }
1349
1350 slot++;
1351
1352 if (pack_index == EventItemPackPt->num - 1) {
1353 pack_index = EventItemPackPt->num;
1354 }
1355 }
1356 }
1357
1358 accepted = 0;
1359
1360 for (i = 0; slot != NULL && MiniMenu.usable[i] >= ITEM_DUNGEON_START && i < 13; i++) {
1361 if (MiniMenu.usable[i] == *result) {
1362 accepted = 1;
1363
1364 if (MiniMenu.vanish != 0 && 0 <= pack_index && pack_index < EventItemPackPt->num) {
1365 EventItemPackPt->item[pack_index] = 0;
1366 }
1367
1368 break;
1369 }
1370 }
1371
1372 if (slot == NULL) {
1373 ComMenuSePlay(MENU_SOUND_REFUSE);
1374 } else if (accepted != 0) {
1375 done = 1;
1376 ComMenuSePlay(MENU_SOUND_CONFIRM);
1377 } else {
1378 printf("Miss\tselected itemNo = %d\n", *result);
1379 ComMenuSePlay(MENU_SOUND_CONFIRM);
1380 done = 1;
1381
1382 if (MiniMenu.fish_mode != 0) {
1383 done = 0;
1384 MiniMenu.state = MINI_MENU_REFUSED;
1385 }
1386 }
1387 } else if (GamePad.Down(PAD_CIRCLE) != 0) {
1388 ComMenuSePlay(MENU_SOUND_REFUSE);
1389 *result = -1;
1390 done = 1;
1391 }
1392
1393 break;
1394 }
1395
1396 s16 *item = NULL;
1397
1398 if (MiniMenu.cursor < MiniMenu.event_item_num) {
1399 int event_no = 0;
1400 item = EventItemPackPt->item;
1401
1402 for (int j = 0; j < EventItemPackPt->num; j++) {
1403 if (*item >= ITEM_DUNGEON_START) {
1404 if (MiniMenu.cursor == event_no) {
1405 break;
1406 }
1407
1408 event_no++;
1409 }
1410
1411 item++;
1412 }
1413 }
1414
1415 int message;
1416
1417 if (item != NULL) {
1418 if (0 < *item) {
1419 message = *item + 500;
1420 } else {
1421 message = 0;
1422 }
1423 } else {
1424 message = 0;
1425 }
1426
1427 if (CommonMenuMes2.mes_made != message) {
1428 CommonMenuMes2.MakeMesWin(message);
1429 }
1430
1431 return done;
1432}
1433
1441static void DrawEventAndFishMenuBoard_Ver(CTexture *texture, CRect_i_ rect, int src_u, int src_width, int unused, int alpha) {
1442 int y = rect.y;
1443
1444 DrawMenu2DSprite(texture, CRect_i_(rect.x, y, rect.width, 0x94), CRect_i_(src_u, 0, src_width, 0x94), alpha);
1445 y += 0x94;
1446 DrawMenu2DSprite(texture, CRect_i_(rect.x, y, rect.width, rect.height + 0x32), CRect_i_(src_u, 0x94, src_width, 0x14), alpha);
1447 y += rect.height + 0x32;
1448 DrawMenu2DSprite(texture, CRect_i_(rect.x, y, rect.width, 0x1E), CRect_i_(src_u, 0xC6, src_width, 0x1E), alpha);
1449}
1450
1451#ifndef PAL
1455s8 kakudai_tate_lang[7] = {0, 16, 16, 16, 16, 16, 16};
1456
1460s8 kakudai_yoko_lang[7] = {0, 10, 10, 10, 10, 10, 10};
1461#endif
1462
1470static void DrawEventAndFishMenuBoard(CTexture *texture, int x, int y, int alpha, int lang) {
1471#ifdef PAL
1472 s8 kakudai_tate_lang[7] = {0, 16, 16, 16, 16, 16, 16};
1473 s8 kakudai_yoko_lang[7] = {0, 10, 10, 20, 10, 16, 14};
1474#endif
1475 int extra_height = kakudai_tate_lang[lang];
1476 int extra_width = kakudai_yoko_lang[lang];
1477 int rows;
1478 float bar_height;
1479
1480 CRect_i_ center(x + 0x1C, y, 0xD2, extra_height);
1481 DrawEventAndFishMenuBoard_Ver(texture, center, 0x1C, 0xD2, lang, alpha);
1482 int edge = extra_width + 6;
1483 CRect_i_ left_inner(x + 0x1C - edge, y, edge, extra_height);
1484 CRect_i_ left_outer(x + 8 - edge, y, 0x14, extra_height);
1485 DrawEventAndFishMenuBoard_Ver(texture, left_inner, 0x14, 6, lang, alpha);
1486 DrawEventAndFishMenuBoard_Ver(texture, left_outer, 0, 0x14, lang, alpha);
1487 CRect_i_ right_inner(x + 0xEE, y, edge, extra_height);
1488 CRect_i_ right_outer(x + 0xEE + edge, y, 0x20, extra_height);
1489 DrawEventAndFishMenuBoard_Ver(texture, right_inner, 0xEC, 6, lang, alpha);
1490 DrawEventAndFishMenuBoard_Ver(texture, right_outer, 0xF4, 0x20, lang, alpha);
1491
1492 rows = EventItemPackPt->num / 5;
1493
1494 if (rows <= 0) {
1495 rows = 1;
1496 }
1497
1498 bar_height = 136.0f / rows;
1499
1500 if (68.0f < bar_height) {
1501 bar_height = 68.0f;
1502 }
1503
1504 int bar_x = x + 0xF6 + edge;
1505 EventBarY += ((int) ((y + 0x3C) + (68.0f * MiniMenu.scroll_row) / rows) - EventBarY) / 4.0f;
1506 int bar_y = EventBarY;
1507 DrawMenu2DSprite(texture, CRect_i_(bar_x, bar_y, 8, (int) bar_height), CRect_i_(0, 0xE4, 8, 0xC), alpha);
1508}
1509
1510static void EventItemSelectDraw() {
1511 s16 items[100];
1512 float left;
1513 float top;
1514 float icon_x;
1515 float row_top;
1516 int alpha;
1517 int x;
1518 int y;
1519 CTexture *board;
1520 int clip_bottom;
1521 int row_y;
1522 int i;
1523 int clip_top;
1524 int count;
1525 int board_x;
1526
1527 if (MiniEventTexReadFlag == 0) {
1528 return;
1529 }
1530
1531 alpha = 0x80;
1532
1533 switch (MiniMenu.state) {
1534 case MINI_MENU_FADE_IN:
1535 alpha = MiniMenu.state_time * 8;
1536
1537 if (alpha > 0x80) {
1538 alpha = 0x80;
1539 MiniMenu.state = MINI_MENU_CHOOSING;
1540 }
1541
1542 break;
1543 case MINI_MENU_FADE_OUT:
1544 alpha = 0x80 - MiniMenu.state_time * 8;
1545
1546 if (alpha < 0) {
1547 alpha = 0;
1548 }
1549
1550 break;
1551 }
1552
1553 left = EventBoardPos[0];
1554 top = EventBoardPos[1];
1555 x = left;
1556 y = top;
1557
1558 if (MiniMenu.fish_mode != 0) {
1559 board = FishFoodBoard;
1560 } else {
1561 board = MiniEventBoard;
1562 }
1563
1564 row_top = 56.0f + top;
1565 clip_top = row_top;
1566 clip_bottom = 136.0f + top;
1567 icon_x = 32.0f + left;
1568 x = icon_x;
1569 count = 0;
1570 board_x = 28.0f + left;
1571 row_y = row_top - MiniMenu.scroll_row * 0x28;
1572 EventItemMoveY += (row_y - EventItemMoveY) >> 2;
1573
1574 if (abs(EventItemMoveY - row_y) < 4) {
1575 EventItemMoveY = row_y;
1576 }
1577
1578 row_y = EventItemMoveY;
1579
1580 for (i = 0; i < EventItemPackPt->num / 5; i++) {
1581 DrawEventItemBoard(board_x, row_y, clip_top, clip_bottom, alpha, board);
1582 row_y += 0x28;
1583 }
1584
1585 memset(items, 0, sizeof(items));
1586 i = 0;
1587
1588 for (int j = 0; j < EventItemPackPt->num; j++) {
1589 if (EventItemPackPt->item[j] >= ITEM_DUNGEON_START) {
1590 items[i++] = EventItemPackPt->item[j];
1591 }
1592 }
1593
1594 row_y = EventItemMoveY;
1595
1596 for (i = 0; i < 100; i++) {
1597 if (clip_bottom < y) {
1598 break;
1599 }
1600
1601 y = row_y + 4;
1602 DrawIconParts(items[i], x, y, clip_top, clip_bottom, alpha, 0);
1603 x += 0x2A;
1604 count++;
1605
1606 if (i % 5 == 4) {
1607 x = icon_x;
1608 row_y += 0x28;
1609 }
1610 }
1611
1612 DrawEventAndFishMenuBoard(board, left, top, alpha, MiniMenu.lang);
1613 y = MiniMenu.cursor;
1614 x = 6.0f + left + ((y + 5) % 5) * 0x2A;
1615 y = 60.0f + top + ((y - MiniMenu.scroll_row * 5) / 5) * 0x28;
1616 DrawMenuWaku(x + 0x10, y - 9, 0x24, 0x24, 0, StayTex, alpha);
1617 MiniCur[0] += (x - MiniCur[0]) / 4.0f;
1618 MiniCur[1] += (y - MiniCur[1]) / 4.0f;
1619 DrawMenuObjectVibe(MiniCur[0], MiniCur[1], 1, 0x40);
1620 CursorVibeCnt++;
1621
1622 if (CursorVibeCnt >= 0x405F7E00) {
1623 CursorVibeCnt = 0;
1624 }
1625
1626 CommonMenuMes2.edge_alpha = alpha;
1627#ifdef PAL
1628 s8 message_pos[7][2] = {
1629 {0, 0},
1630 {-4, 0},
1631 {-4, 0},
1632 {-9, 0},
1633 {-4, 0},
1634 {-7, 0},
1635 {-6, 0}
1636 };
1637#else
1638 s8 message_pos[7][2] = {
1639 {0, 0},
1640 {-4, 0},
1641 {-4, 0},
1642 {-4, 0},
1643 {-4, 0},
1644 {-4, 0},
1645 {-4, 0}
1646 };
1647#endif
1648 DrawMenuClsMes(&CommonMenuMes2, 20.0f + left + message_pos[MiniMenu.lang][0], 146.0f + top + message_pos[MiniMenu.lang][1]);
1649
1650 if (MiniMenu.state == MINI_MENU_REFUSED) {
1651 if (CommonMenuMes1.mes_made != 1) {
1652 CommonMenuMes1.MakeMesWin(1);
1653 }
1654
1655 AllFadeForMenu(0);
1656 CommonMenuMes1.stay_frame = true;
1657 DrawMenuClsMes(&CommonMenuMes1, 0xDC, 0xA0);
1658 }
1659
1660 if (MiniMenu.state != MINI_MENU_CHOOSING) {
1661 MiniMenu.state_time++;
1662 } else {
1663 MiniMenu.state_time = 0;
1664 }
1665
1666 setbilinear(1);
1667}
1668
1669static void DrawEventItemBoard(int x, int y, int top, int bottom, int alpha, CTexture *texture) {
1670 int clip_y;
1671 int clip_v;
1672 int clip_height;
1673
1674 if ((y < top - 0x27) || (bottom <= y)) {
1675 return;
1676 }
1677
1678 int pos_x = x;
1679 clip_y = y;
1680 clip_v = 0;
1681 clip_height = 0x28;
1682 MenuTextureClip(clip_y, clip_v, clip_height, top, bottom);
1683
1684 for (int i = 0; i < 5; i++) {
1685 DrawMenu2DSprite(texture, CRect_i_(pos_x, clip_y + 1, 0x28, clip_height), CRect_i_(0x116, clip_v, 0x28, clip_height), alpha);
1686 pos_x += 0x2A;
1687 }
1688}
1689
1690int PlayerAllItemCheck(int item) {
1691 CDngStatusData *dungeon_status = SaveData->GetDngStatus();
1692 CStockItem *stock = SaveData->GetStockItem();
1693 int has_item = 0;
1694
1695 if (dungeon_status->SearchItemIndexNo(item) >= 0) {
1696 has_item = 1;
1697 }
1698
1699 if (stock->SearchItem(item) != 0) {
1700 has_item = 1;
1701 }
1702
1703 return has_item;
1704}
1705
1706s32 GetAddAttachItem(s32 item_no) {
1707 s32 result;
1708
1709 result = 0;
1710
1711 if ((item_no >= ITEM_ATTACH_STAT_START) && (item_no < ITEM_ATTACH_GEM_START)) {
1712 result = 1;
1713 }
1714
1715 return result;
1716}
1717
1718int TransWepNo(int weapon_no) {
1719 s32 item_no;
1720
1721 item_no = weapon_no;
1722
1723 if (item_no > 0) {
1724 if ((item_no > 0) && (item_no < 0x15)) {
1725 item_no += ITEM_WEAPON_DAGGER_BROKEN - 1;
1726 } else if ((item_no >= 0x15) && (item_no < 0x21)) {
1727 item_no += ITEM_WEAPON_WOODENSLINGSHOT_BROKEN - 0x15;
1728 } else if ((item_no >= 0x21) && (item_no < 0x2E)) {
1729 item_no += ITEM_WEAPON_MALLET_BROKEN - 0x21;
1730 } else if ((item_no >= 0x2E) && (item_no < 0x3A)) {
1731 item_no += ITEM_WEAPON_GOLD_RING_BROKEN - 0x2E;
1732 } else if ((item_no >= 0x3A) && (item_no < 0x46)) {
1733 item_no += ITEM_WEAPON_FIGHTING_STICK_BROKEN - 0x3A;
1734 } else if ((item_no >= 0x46) && (item_no < ITEM_ATTACH_START)) {
1735 item_no += ITEM_WEAPON_MACHINE_GUN_BROKEN - 0x46;
1736 }
1737 }
1738
1739 return item_no;
1740}
1741
1742int TransWepNoNewToOld(int weapon_no) {
1743 s32 item_no;
1744
1745 item_no = weapon_no;
1746 printf("newitemno is %d\n", item_no);
1747
1748 if (item_no >= ITEM_WEAPON_START) {
1749 if ((item_no >= ITEM_WEAPON_START) && (item_no < ITEM_WEAPON_MARDAN_EINS)) {
1750 item_no -= ITEM_WEAPON_DAGGER_BROKEN - 1;
1751 } else if ((item_no >= ITEM_WEAPON_WOODENSLINGSHOT_BROKEN) && (item_no < ITEM_WEAPON_MATADOR)) {
1752 item_no -= ITEM_WEAPON_WOODENSLINGSHOT_BROKEN - 0x15;
1753 } else if ((item_no >= ITEM_WEAPON_MALLET_BROKEN) && (item_no < ITEM_WEAPON_PLATE_HAMMER)) {
1754 item_no -= ITEM_WEAPON_MALLET_BROKEN - 0x21;
1755 } else if ((item_no >= ITEM_WEAPON_GOLD_RING_BROKEN) && (item_no < ITEM_WEAPON_POCKLEKUL)) {
1756 item_no -= ITEM_WEAPON_GOLD_RING_BROKEN - 0x2E;
1757 } else if ((item_no >= ITEM_WEAPON_FIGHTING_STICK_BROKEN) && (item_no < ITEM_WEAPON_5_FOOT_NAIL)) {
1758 item_no -= ITEM_WEAPON_FIGHTING_STICK_BROKEN - 0x3A;
1759 } else if ((item_no >= ITEM_WEAPON_MACHINE_GUN_BROKEN) && (item_no < ITEM_WEAPON_SNAIL)) {
1760 item_no -= ITEM_WEAPON_MACHINE_GUN_BROKEN - 0x46;
1761 }
1762 }
1763
1764 printf("olditemno is %d\n", item_no);
1765 return item_no;
1766}
int SearchItemIndexNo(int item_id)
int Down(int mask)
Definition gamepad.cpp:583
void MenuModeOff()
Definition gamepad.cpp:617
void MenuModeOn(int threshold)
Definition gamepad.cpp:613
void SetAutoRepeat(int mask, int initial_delay, int repeat_delay)
Definition gamepad.cpp:485
void AutoRepeatOff()
Definition gamepad.cpp:609
void SetFuncNo(int func_no)
SAVEDATA_INFO file_info[MC_SAVE_FILE_MAX]
int GetMsgNo(int msg_no)
int CheckFileNo(int file_no)
void SetIconData(MC_ICON_DATA *icon)
void SetBuff(char *buffer)
MC_CARD_INFO card[MC_CARD_MAX]
s32 x
Definition rect.hpp:18
s32 width
Definition rect.hpp:20
s32 height
Definition rect.hpp:21
s32 y
Definition rect.hpp:19
CDngStatusData * GetDngStatus()
Definition savedata.cpp:250
void * GetConfigData()
Definition savedata.cpp:33
CStockItem * GetStockItem()
Definition savedata.cpp:254
int SearchItem(int item_no)
char name[32]
Definition texture.hpp:56
void Step()
Definition clsmes.cpp:575
s32 cursor_lit
Definition clsmes.hpp:226
s32 mes_made
Definition clsmes.hpp:207
s32 value_signed
Definition clsmes.hpp:219
s32 stay_frame
Definition clsmes.hpp:189
s32 edge_alpha
Definition clsmes.hpp:213
int MakeMesWin(int mes_no)
Definition clsmes.cpp:1669
s32 value_show
Definition clsmes.hpp:220
u_long128 * buffer
Definition dataread.hpp:29
s16 item[103]
MC_ICON_FILE view
Definition title.cpp:61
s32 width
Definition rect.hpp:36
s32 height
Definition rect.hpp:37
int y
Definition title.cpp:63
int x
Definition title.cpp:62
u8 a
Definition rect.hpp:49