1#pragma helper_mask_gpr 0x30
2#pragma helper_mask_fpr 0x1000
3#pragma name_counter 3062
5#include "menu_save.hpp"
11#include "battle_globals.hpp"
15#include "dun/gameloop.hpp"
16#include "editatra.hpp"
19#include "mainitemmodel.hpp"
21#include "memorycardaccess.hpp"
22#include "menu_draw.hpp"
23#include "menu_inventory.hpp"
24#include "menuitemstep.hpp"
30#include "userstatus.hpp"
51static void DrawEventItemBoard(
int x,
int y,
int top,
int bottom,
int alpha,
CTexture *texture);
60static int EventItemSelectKey(
int *result);
69static void EventItemSelectDraw();
78static int SaveMenuKeySaveCheck() {
81 if (McCheckMCPs2(card) == 0) {
82 SaveMenu.
key_no = SAVE_KEY_ALERT;
83 SaveMenu.
alert_no = SAVE_ALERT_NO_CARD;
88 SaveMenu.
key_no = SAVE_KEY_ALERT;
89 SaveMenu.
alert_no = SAVE_ALERT_CARD_ERROR;
94 SaveMenu.
key_no = SAVE_KEY_FORMAT;
95 McAccess.
SetFuncNo(MC_OPERATION_SEARCH_TYPE);
100 SaveMenu.
key_no = SAVE_KEY_NEW_DIR_SELECT;
105 SaveMenu.
key_no = SAVE_KEY_SAVE_DECIDE;
107 McAccess.
SetFuncNo(MC_OPERATION_SEARCH_TYPE);
108 SaveMenu.
key_no = SAVE_KEY_SAVE;
121static int SaveMenuKeySaveDecide() {
122 if (GamePad.
Down(PAD_CROSS) != 0) {
123 McAccess.
SetFuncNo(MC_OPERATION_SEARCH_TYPE);
124 int file_no = SaveMenu.
file_no;
127 SaveMenu.
key_no = SAVE_KEY_SAVE;
128 ComMenuSePlay(MENU_SOUND_CONFIRM);
132 if (GamePad.
Down(PAD_CIRCLE) != 0) {
133 SaveMenu.
key_no = SAVE_KEY_FILE_SELECT;
134 ComMenuSePlay(MENU_SOUND_REFUSE);
149static int SaveMenuKeySave() {
152 if (McCheckMCPs2(card) == 0) {
153 SaveMenu.
key_no = SAVE_KEY_ALERT;
154 SaveMenu.
alert_no = SAVE_ALERT_NO_CARD;
159 SaveMenu.
key_no = SAVE_KEY_ALERT;
160 SaveMenu.
alert_no = SAVE_ALERT_CARD_ERROR;
165 SaveMenu.
key_no = SAVE_KEY_ALERT;
166 SaveMenu.
alert_no = SAVE_ALERT_NO_SPACE_FILE;
172 SaveMenu.
key_no = SAVE_KEY_END_SAVE;
183static int SaveMenuKeyEndSave() {
184 if ((GamePad.
Down(PAD_CROSS) != 0) || (GamePad.
Down(PAD_CIRCLE) != 0)) {
186 SaveMenu.
key_no = SAVE_KEY_FILE_SELECT;
199static int SaveMenuKeyLoadDecide() {
200 if (GamePad.
Down(PAD_CROSS) != 0) {
201 int file_no = SaveMenu.
file_no;
205 if (file_info->
state != 0) {
206 McAccess.
SetFuncNo(MC_OPERATION_SEARCH_TYPE);
208 SaveMenu.
key_no = SAVE_KEY_LOAD;
209 ComMenuSePlay(MENU_SOUND_CONFIRM);
211 ComMenuSePlay(MENU_SOUND_REFUSE);
217 if (GamePad.
Down(PAD_CIRCLE) != 0) {
218 SaveMenu.
key_no = SAVE_KEY_FILE_SELECT;
219 ComMenuSePlay(MENU_SOUND_REFUSE);
233static int SaveMenuKeyLoad() {
236 if (McCheckMCPs2(card) == 0) {
237 SaveMenu.
key_no = SAVE_KEY_ALERT;
238 SaveMenu.
alert_no = SAVE_ALERT_NO_CARD;
243 SaveMenu.
key_no = SAVE_KEY_ALERT;
244 SaveMenu.
alert_no = SAVE_ALERT_CARD_ERROR;
250 SaveMenu.
key_no = SAVE_KEY_FILE_SELECT;
261static int SaveMenuKeyArart() {
263 case SAVE_ALERT_NONE:
265 case SAVE_ALERT_NO_CARD:
266 if (GamePad.
Down(PAD_CIRCLE | PAD_CROSS) != 0) {
267 SaveMenu.
key_no = SAVE_KEY_MC_SELECT;
269 ComMenuSePlay(MENU_SOUND_REFUSE);
273 case SAVE_ALERT_CARD_FULL:
274 if (GamePad.
Down(PAD_CIRCLE | PAD_CROSS) != 0) {
275 SaveMenu.
key_no = SAVE_KEY_MC_SELECT;
277 ComMenuSePlay(MENU_SOUND_REFUSE);
282 if (GamePad.
Down(PAD_CIRCLE | PAD_CROSS) != 0) {
283 SaveMenu.
key_no = SAVE_KEY_MC_SELECT;
285 ComMenuSePlay(MENU_SOUND_REFUSE);
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);
309 if (GamePad.
Down(PAD_CIRCLE) != 0) {
310 SaveMenu.
key_no = SAVE_KEY_MC_SELECT;
313 ComMenuSePlay(MENU_SOUND_REFUSE);
327static int SaveMenuKeyNewDir() {
330 if (McCheckMCPs2(card) == 0) {
331 SaveMenu.
key_no = SAVE_KEY_ALERT;
332 SaveMenu.
alert_no = SAVE_ALERT_NO_CARD;
337 SaveMenu.
key_no = SAVE_KEY_ALERT;
338 SaveMenu.
alert_no = SAVE_ALERT_CARD_ERROR;
343 SaveMenu.
key_no = SAVE_KEY_ALERT;
344 SaveMenu.
alert_no = SAVE_ALERT_NO_SPACE_DIR;
348 McAccess.
SetFuncNo(MC_OPERATION_MAKE_DIR);
349 SaveMenu.
key_no = SAVE_KEY_SAVE;
360static int SaveMenuKeyFormat() {
363 if (McCheckMCPs2(card) == 0) {
364 SaveMenu.
key_no = SAVE_KEY_ALERT;
365 SaveMenu.
alert_no = SAVE_ALERT_NO_CARD;
370 SaveMenu.
key_no = SAVE_KEY_ALERT;
371 SaveMenu.
alert_no = SAVE_ALERT_CARD_ERROR;
375 if (GamePad.
Down(PAD_CROSS) != 0) {
377 SaveMenu.
key_no = SAVE_KEY_NEW_DIR;
378 ComMenuSePlay(MENU_SOUND_CONFIRM);
382 if (GamePad.
Down(PAD_CIRCLE) != 0) {
383 SaveMenu.
key_no = SAVE_KEY_MC_SELECT;
385 ComMenuSePlay(MENU_SOUND_REFUSE);
399static int SaveMenuKeyUnFormat() {
403 McAccess.
SetFuncNo(MC_OPERATION_UNFORMAT);
405 SaveMenu.
key_no = SAVE_KEY_MC_SELECT;
419static int SaveMenuKeyDifVersion() {
420 if (GamePad.
Down(PAD_TRIANGLE | PAD_CIRCLE | PAD_CROSS | PAD_SQUARE) != 0) {
422 int file_no = McAccess.
file_no;
436static s32 SaveMenuKeyDelete() {
447static s32 SaveMenuKeyCopy() {
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;
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;
494static int SaveMenuKeySaveEnding() {
495 SaveMenu.
key_no = SAVE_KEY_END_SAVE_ENDING;
496 McAccess.
SetFuncNo(MC_OPERATION_SAVE_CONFIG);
507static int SaveMenuKeyEndSaveEnding() {
508 if (GamePad.
Down(PAD_CROSS) != 0) {
509 SaveMenu.
key_no = SAVE_KEY_MC_SELECT;
516int GetSaveMenuMsgNo() {
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:
527 case SAVE_KEY_NEW_DIR:
531 case MC_OPERATION_IDLE:
532 switch (SaveMenu.
key_no) {
533 case SAVE_KEY_CHECK_MC:
536 case SAVE_KEY_MODE_SELECT:
539 case SAVE_KEY_MC_SELECT:
542 case SAVE_KEY_SAVE_DECIDE:
545 case SAVE_KEY_LOAD_DECIDE:
550 case SAVE_ALERT_NO_CARD:
553 case SAVE_ALERT_CARD_FULL:
556 case SAVE_ALERT_CARD_ERROR:
559 case SAVE_ALERT_FORMAT_FAILED:
562 case SAVE_ALERT_SAVE_FAILED:
565 case SAVE_ALERT_NO_SPACE_DIR:
568 case SAVE_ALERT_NO_SPACE_FILE:
571 case SAVE_ALERT_NO_SAVE_DATA:
574 case SAVE_ALERT_LOAD_FAILED:
577 case SAVE_ALERT_NONE:
578 case SAVE_ALERT_UNK_3:
579 case SAVE_ALERT_UNK_4:
580 case SAVE_ALERT_UNK_5:
585 case SAVE_KEY_FORMAT:
588 case SAVE_KEY_NEW_DIR_SELECT:
591 case SAVE_KEY_DELETE:
597 case SAVE_KEY_DIF_VERSION:
600 case SAVE_KEY_SAVE_ENDING:
601 case SAVE_KEY_SAVE_DECIDE_ENDING:
604 case SAVE_KEY_AFTER_ENDING:
607 case SAVE_KEY_END_SAVE:
608 case SAVE_KEY_END_SAVE_ENDING:
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:
619 case SAVE_KEY_NEW_DIR:
620 case SAVE_KEY_UNFORMAT:
633int SaveMenuTextureEnter() {
636 if (ReadBGSync() == 0) {
638 {
"#frame_image_save#640#" SCREEN_HEIGHT_STR
"#4", 0, 0},
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);
656 char *moji_names[4] = {
"alphabet",
"kata",
"hira",
"alphabet"};
658 for (i = 0; i < 4; i++) {
659 SaveMenuMojiTextbl[i] = TexManager.GetTexture(moji_names[i], -1);
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));
674 char *save_buffer = (
char *) pack + bg->
size;
676 {
"dkicon.ico", NULL, 0},
677 {
"dkicon_c.ico", NULL, 0},
678 {
"dkicon_d.ico", NULL, 0}
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);
694int SaveMenuEffectFadeOut() {
695 if (SaveMenu.
key_no == SAVE_KEY_FADE_OUT) {
710static void GetSaveBoardAlphaInfo(
int x,
int width,
int &start_alpha,
int &end_alpha,
int alpha) {
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;
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;
738void DrawSaveBoard(
SAVEDATA_INFO *info,
CTexture **name_texture,
int x,
int y,
int unused,
int alpha) {
750 spRGBA top = {0x80, 0x80, 0x80, 0};
752 spRGBA bottom = {0x80, 0x80, 0x80, 0};
756 GetSaveBoardAlphaInfo(y, 0x88, start_alpha, end_alpha, 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);
763 s8 number_shift[] = {0, 0, 0, 10, 0, 4, 13};
764 draw_x += number_shift[GetMenuLangFlag()];
768 RECT number_rect = {0x88, 0xCA, 0xC, 0x10};
769 GetSaveBoardAlphaInfo(y, 0x10, start_alpha, end_alpha, alpha);
771 bottom.
a = end_alpha;
783 for (digits = GetNumberKeta(number); 0 < digits; digits--) {
786 width = number_rect.
width;
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);
799 GetSaveBoardAlphaInfo(y, 0x16, start_alpha, end_alpha, alpha);
801 bottom.
a = end_alpha;
802 int name_x = draw_x + 8;
804 if (info->
name != NULL) {
805 DrawSaveBoardCharaName2(name_x, draw_y, (
short *) info->
name, name_texture, top, bottom);
809 RECT time_rect = {0x88, 0xB8, 0xC, 0x12};
810 int column = x + 0x92;
811 draw_x = column + 0xA;
813 GetSaveBoardAlphaInfo(draw_y, 0x12, start_alpha, end_alpha, alpha);
815 bottom.
a = end_alpha;
818 if (frames >= 0x1499700) {
823 time[0] = frames / 3600;
824 time[1] = (frames / 60 - time[0] * 60) % 60;
825 time[2] = frames % 60;
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);
834 CRect_i_ colon(0x100, 0xB8, 0xC, 0x12);
835 GetSaveBoardAlphaInfo(draw_y, 0x12, start_alpha, end_alpha, alpha);
837 bottom.
a = end_alpha;
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);
844 GetSaveBoardAlphaInfo(draw_y, 0x12, start_alpha, end_alpha, alpha);
846 bottom.
a = end_alpha;
857 for (digits = GetNumberKeta(number); 0 < digits; digits--) {
860 width = number_rect.
width;
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);
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};
879 if (map_name[map] < 0xE) {
880 name_u = (map_name[map] / 7) * 0x88;
881 name_v = (map_name[map] % 7) * 0x14 + 0xB8;
883 map_name[map] -= 0xE;
884 name_u = (map_name[map] / 7) * 0x88;
885 name_v = (map_name[map] % 7) * 0x14 + 0x144;
890 GetSaveBoardAlphaInfo(draw_y, 0x14, start_alpha, end_alpha, 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);
896 int face_x = x + 0xCF;
899 GetSaveBoardAlphaInfo(draw_y, 0x30, start_alpha, end_alpha, alpha);
901 bottom.
a = end_alpha;
904 DrawMenu2DSprite(SaveBoard,
CRect_i_(draw_x, draw_y, 0x30, 0x31),
CRect_i_(i * 0x30, 0x88, 0x30, 0x30), &top, &top, &bottom, &bottom);
910 GetSaveBoardAlphaInfo(draw_y, 0x30, start_alpha, end_alpha, alpha);
912 bottom.
a = end_alpha;
917void DrawNewFileTemplete(
int x,
int y,
int alpha) {
925 spRGBA top = {0x80, 0x80, 0x80, 0};
927 spRGBA bottom = {0x80, 0x80, 0x80, 0};
931 GetSaveBoardAlphaInfo(y, 0x10, start_alpha, end_alpha, 0x80);
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);
939 GetSaveBoardAlphaInfo(y + 0x78, 0x10, start_alpha, end_alpha, 0x80);
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);
947 GetSaveBoardAlphaInfo(y + 0x10, 0x68, start_alpha, end_alpha, 0x80);
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);
954 GetSaveBoardAlphaInfo(y + 0x35, 0x1E, start_alpha, end_alpha, 0x80);
956 bottom.
a = end_alpha;
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);
962 set2DSprite(GetVif1Packet(), SaveBoard,
CRect_i_(x + 0x86, y + 0x35, 0x74, 0x1E),
CRect_i_(0x10C, 0xB8, 0x74, 0x1E), &top, &top, &bottom, &bottom, 1);
971 printf(
"Memory Card Initialized Failed\n");
975 for (port = 0; port < 2; port++) {
976 McAccess.
port = port;
977 McAccess.
SetFuncNo(MC_OPERATION_SEARCH_TYPE);
980 result = McAccess.
Step();
981 }
while (result == 0);
989 if ((McCheckMCPs2(card) == 0) || (card->
formatted == 0)) {
993 McAccess.
SetFuncNo(MC_OPERATION_GET_DIR);
995 while (McAccess.
Step() == 0) {
998 McAccess.
SetFuncNo(MC_OPERATION_LOAD_CONFIG);
1001 result = McAccess.
Step();
1002 }
while (result == 0);
1004 if ((result >= 0) && (card->
dir_exists != 0)) {
1012int SaveEnableCheck() {
1019 return SAVE_ENABLE_NO_CARD;
1025 for (port = 0; port < 2; port++) {
1026 McAccess.
port = port;
1027 McAccess.
SetFuncNo(MC_OPERATION_SEARCH_TYPE);
1030 result = McAccess.
Step();
1031 }
while (result == 0);
1039 if (McCheckMCPs2(card) == 0) {
1049 McAccess.
SetFuncNo(MC_OPERATION_GET_DIR);
1052 result = McAccess.
Step();
1053 }
while (result == 0);
1060 return SAVE_ENABLE_OK;
1063 if (free_size < card->free_size) {
1069 return SAVE_ENABLE_NO_CARD;
1072 if (free_size < 0x190) {
1073 return SAVE_ENABLE_NO_SPACE;
1076 return SAVE_ENABLE_OK;
1082float EventBoardPos[2];
1109s32 MiniEventTextureBlock;
1114int MiniEventTexReadFlag;
1121void InitEventItemSelect(
int block,
int *usable,
ITEM_PACK *pack,
int x,
int y,
int vanish,
int fish_mode) {
1126 StayTex = TexManager.GetTexture(AtoraVibeTextureName, -1);
1128 MiniEventTextureBlock = block;
1129 MiniMenu.
lang = GetMenuLangFlag();
1130 s8 lang_y[7] = {0, -0x10, -0x10, -0x10, -0x10, -0x10, -0x10};
1131 EventBoardPos[0] = x;
1133 EventBoardPos[1] = (float) y + (
float) lang_y[MiniMenu.
lang] + 20.0f;
1135 EventBoardPos[1] = (float) y + (
float) lang_y[MiniMenu.
lang];
1137 EventItemPackPt = pack;
1140 for (i = 0; i < pack->
num; i++) {
1141 if (pack->
item[i] >= ITEM_DUNGEON_START) {
1148 printf(
"itemno = %d\n", usable[MiniMenu.
usable_num]);
1156 MiniMenu.
vanish = vanish;
1158 if (MiniMenu.
vanish != 0) {
1159 printf(
"vanish after use !\n");
1161 printf(
"exist after use \n");
1165 {
"#frame_image#640#" SCREEN_HEIGHT_STR
"#4", 0, 0},
1168 texture[0].
block_no = MiniEventTextureBlock;
1169 TexManager.DeleteTextureBlock(MiniEventTextureBlock);
1170 TexManager.CleanUpTextureList();
1171 TexManager.LoadTextureBlockEX(-1, texture);
1173 u_long128 *buffer = (u_long128 *) read_buffer;
1174 buffer = MenuCalcBufAlignment(buffer);
1175 LoadFileBGMenuData(
"eventmnu2.pak", buffer);
1179 EventItemMoveY = 56.0f + EventBoardPos[1] - MiniMenu.
scroll_row * 0x28;
1180 int rows = EventItemPackPt->
num / 5;
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;
1200static void EventItemSelectExit() {
1201 TexManager.DeleteTextureBlock(MiniEventTextureBlock);
1202 TexManager.CleanUpTextureList();
1207int EventItemSelectLoop(
int *result) {
1214 switch (MiniMenu.
state) {
1215 case MINI_MENU_CHOOSING:
1218 case MINI_MENU_FADE_IN:
1226 case MINI_MENU_FADE_OUT:
1237 FrameImageDraw(alpha, 0x80);
1238 MenuTextureReload(MiniEventTextureBlock);
1239 done = EventItemSelectKey(result);
1240 EventItemSelectDraw();
1244 EventItemSelectExit();
1250static int EventItemSelectKey(
int *result) {
1259 if (MiniEventTexReadFlag == 0) {
1260 if (ReadBGSync() == 0) {
1262 {
"#frame_image#640#" SCREEN_HEIGHT_STR
"#4", 0, 0},
1267 texture[0].
block_no = MiniEventTextureBlock;
1268 texture[1].
block_no = MiniEventTextureBlock;
1269 texture[2].
block_no = MiniEventTextureBlock;
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));
1280 CommonMenuMes2.
Step();
1281 MiniEventTexReadFlag = 1;
1288 old_cursor = MiniMenu.
cursor;
1289 slot_num = EventItemPackPt->
num;
1291 switch (MiniMenu.
state) {
1292 case MINI_MENU_REFUSED:
1293 if (GamePad.
Down(PAD_CIRCLE | PAD_CROSS) != 0) {
1294 MiniMenu.
state = MINI_MENU_CHOOSING;
1298 case MINI_MENU_CHOOSING:
1299 if (GamePad.
Down(PAD_UP) != 0 && MiniMenu.
cursor > 4) {
1303 if (GamePad.
Down(PAD_DOWN) != 0 && MiniMenu.
cursor < slot_num - 5) {
1307 if (GamePad.
Down(PAD_LEFT) != 0 && 0 < MiniMenu.
cursor) {
1311 if (GamePad.
Down(PAD_RIGHT) != 0 && MiniMenu.
cursor < slot_num - 1) {
1323 if (old_cursor != MiniMenu.
cursor) {
1324 ComMenuSePlay(MENU_SOUND_CURSOR);
1327 if (GamePad.
Down(PAD_SQUARE) != 0) {
1328 SeitonItemBoard(EventItemPackPt);
1329 ComMenuSePlay(MENU_SOUND_CONFIRM);
1333 if (GamePad.
Down(PAD_CROSS) != 0) {
1338 slot = EventItemPackPt->
item;
1340 for (pack_index = 0; pack_index < EventItemPackPt->
num; pack_index++) {
1341 if (*slot >= ITEM_DUNGEON_START) {
1342 if (MiniMenu.
cursor == event_no) {
1352 if (pack_index == EventItemPackPt->
num - 1) {
1353 pack_index = EventItemPackPt->
num;
1360 for (i = 0; slot != NULL && MiniMenu.
usable[i] >= ITEM_DUNGEON_START && i < 13; i++) {
1361 if (MiniMenu.
usable[i] == *result) {
1364 if (MiniMenu.
vanish != 0 && 0 <= pack_index && pack_index < EventItemPackPt->num) {
1365 EventItemPackPt->
item[pack_index] = 0;
1373 ComMenuSePlay(MENU_SOUND_REFUSE);
1374 }
else if (accepted != 0) {
1376 ComMenuSePlay(MENU_SOUND_CONFIRM);
1378 printf(
"Miss\tselected itemNo = %d\n", *result);
1379 ComMenuSePlay(MENU_SOUND_CONFIRM);
1384 MiniMenu.
state = MINI_MENU_REFUSED;
1387 }
else if (GamePad.
Down(PAD_CIRCLE) != 0) {
1388 ComMenuSePlay(MENU_SOUND_REFUSE);
1400 item = EventItemPackPt->
item;
1402 for (
int j = 0; j < EventItemPackPt->
num; j++) {
1403 if (*item >= ITEM_DUNGEON_START) {
1404 if (MiniMenu.
cursor == event_no) {
1419 message = *item + 500;
1427 if (CommonMenuMes2.
mes_made != message) {
1441static void DrawEventAndFishMenuBoard_Ver(
CTexture *texture,
CRect_i_ rect,
int src_u,
int src_width,
int unused,
int alpha) {
1444 DrawMenu2DSprite(texture,
CRect_i_(rect.
x, y, rect.
width, 0x94),
CRect_i_(src_u, 0, src_width, 0x94), alpha);
1448 DrawMenu2DSprite(texture,
CRect_i_(rect.
x, y, rect.
width, 0x1E),
CRect_i_(src_u, 0xC6, src_width, 0x1E), alpha);
1455s8 kakudai_tate_lang[7] = {0, 16, 16, 16, 16, 16, 16};
1460s8 kakudai_yoko_lang[7] = {0, 10, 10, 10, 10, 10, 10};
1470static void DrawEventAndFishMenuBoard(
CTexture *texture,
int x,
int y,
int alpha,
int lang) {
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};
1475 int extra_height = kakudai_tate_lang[lang];
1476 int extra_width = kakudai_yoko_lang[lang];
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);
1492 rows = EventItemPackPt->
num / 5;
1498 bar_height = 136.0f / rows;
1500 if (68.0f < bar_height) {
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);
1510static void EventItemSelectDraw() {
1527 if (MiniEventTexReadFlag == 0) {
1533 switch (MiniMenu.
state) {
1534 case MINI_MENU_FADE_IN:
1539 MiniMenu.
state = MINI_MENU_CHOOSING;
1543 case MINI_MENU_FADE_OUT:
1553 left = EventBoardPos[0];
1554 top = EventBoardPos[1];
1559 board = FishFoodBoard;
1561 board = MiniEventBoard;
1564 row_top = 56.0f + top;
1566 clip_bottom = 136.0f + top;
1567 icon_x = 32.0f + left;
1570 board_x = 28.0f + left;
1571 row_y = row_top - MiniMenu.
scroll_row * 0x28;
1572 EventItemMoveY += (row_y - EventItemMoveY) >> 2;
1574 if (abs(EventItemMoveY - row_y) < 4) {
1575 EventItemMoveY = row_y;
1578 row_y = EventItemMoveY;
1580 for (i = 0; i < EventItemPackPt->
num / 5; i++) {
1581 DrawEventItemBoard(board_x, row_y, clip_top, clip_bottom, alpha, board);
1585 memset(items, 0,
sizeof(items));
1588 for (
int j = 0; j < EventItemPackPt->
num; j++) {
1589 if (EventItemPackPt->
item[j] >= ITEM_DUNGEON_START) {
1590 items[i++] = EventItemPackPt->
item[j];
1594 row_y = EventItemMoveY;
1596 for (i = 0; i < 100; i++) {
1597 if (clip_bottom < y) {
1602 DrawIconParts(items[i], x, y, clip_top, clip_bottom, alpha, 0);
1612 DrawEventAndFishMenuBoard(board, left, top, alpha, MiniMenu.
lang);
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);
1622 if (CursorVibeCnt >= 0x405F7E00) {
1628 s8 message_pos[7][2] = {
1638 s8 message_pos[7][2] = {
1648 DrawMenuClsMes(&CommonMenuMes2, 20.0f + left + message_pos[MiniMenu.
lang][0], 146.0f + top + message_pos[MiniMenu.
lang][1]);
1650 if (MiniMenu.
state == MINI_MENU_REFUSED) {
1651 if (CommonMenuMes1.
mes_made != 1) {
1657 DrawMenuClsMes(&CommonMenuMes1, 0xDC, 0xA0);
1660 if (MiniMenu.
state != MINI_MENU_CHOOSING) {
1669static void DrawEventItemBoard(
int x,
int y,
int top,
int bottom,
int alpha,
CTexture *texture) {
1674 if ((y < top - 0x27) || (bottom <= y)) {
1682 MenuTextureClip(clip_y, clip_v, clip_height, top, bottom);
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);
1690int PlayerAllItemCheck(
int item) {
1706s32 GetAddAttachItem(s32 item_no) {
1711 if ((item_no >= ITEM_ATTACH_STAT_START) && (item_no < ITEM_ATTACH_GEM_START)) {
1718int TransWepNo(
int weapon_no) {
1721 item_no = weapon_no;
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;
1742int TransWepNoNewToOld(
int weapon_no) {
1745 item_no = weapon_no;
1746 printf(
"newitemno is %d\n", item_no);
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;
1764 printf(
"olditemno is %d\n", item_no);
int SearchItemIndexNo(int item_id)
void MenuModeOn(int threshold)
void SetAutoRepeat(int mask, int initial_delay, int repeat_delay)
void SetFuncNo(int func_no)
SAVEDATA_INFO file_info[MC_SAVE_FILE_MAX]
int CheckFileNo(int file_no)
void SetIconData(MC_ICON_DATA *icon)
void SetBuff(char *buffer)
MC_CARD_INFO card[MC_CARD_MAX]
CDngStatusData * GetDngStatus()
CStockItem * GetStockItem()
int SearchItem(int item_no)
int MakeMesWin(int mes_no)