From 24da346796d42646e6d4039f171cab7be1aecfcf Mon Sep 17 00:00:00 2001 From: Seth Barberee Date: Sun, 25 Aug 2024 20:52:19 -0700 Subject: [PATCH] more documentation/cleanup --- include/constants/wonder_mail.h | 1 + include/status.h | 1 + include/wonder_mail_4.h | 15 ++++ include/wonder_mail_5.h | 9 +++ src/code_8048480.c | 1 - src/friend_rescue.c | 25 ++---- src/pelipper_board.c | 26 +++--- src/save_menu.c | 9 ++- src/status_actions.c | 1 - src/thank_you_wonder_mail.c | 136 +++++++++++++++++--------------- src/weather.c | 1 - src/wonder_mail.c | 26 ++---- src/wonder_mail_2.c | 29 ++++--- src/wonder_mail_4.c | 15 ++-- src/wonder_mail_5.c | 33 ++++---- src/wonder_mail_6.c | 72 ++++++++--------- src/wonder_mail_main_menu.c | 8 +- 17 files changed, 203 insertions(+), 205 deletions(-) create mode 100644 include/wonder_mail_4.h create mode 100644 include/wonder_mail_5.h diff --git a/include/constants/wonder_mail.h b/include/constants/wonder_mail.h index d0cc5c6b..08ecdfee 100644 --- a/include/constants/wonder_mail.h +++ b/include/constants/wonder_mail.h @@ -41,6 +41,7 @@ enum WonderMailTypes WONDER_MAIL_TYPE_WONDER = 5, WONDER_MAIL_TYPE_COMPLETED, WONDER_MAIL_TYPE_OKD, + MAX_WONDER_MAIL_TYPES }; // Used in CreateRescueTitle and CreateRescueDescription diff --git a/include/status.h b/include/status.h index 98b290e7..0526c007 100644 --- a/include/status.h +++ b/include/status.h @@ -36,5 +36,6 @@ void HandleStockpile(Entity * pokemon, Entity * target); void InvisibleStatusTarget(Entity * pokemon, Entity * target); void PerishSongTarget(Entity * pokemon, Entity * target); void EncoreStatusTarget(Entity * pokemon, Entity * target); +void sub_8078A58(struct Entity *pokemon, struct Entity *target, s32 param_3, s32 param_4); #endif diff --git a/include/wonder_mail_4.h b/include/wonder_mail_4.h new file mode 100644 index 00000000..e24e7f4b --- /dev/null +++ b/include/wonder_mail_4.h @@ -0,0 +1,15 @@ +#ifndef WONDER_MAIL_4_H +#define WONDER_MAIL_4_H + +#include "structs/str_text.h" + +u32 sub_80306A8(u32 wonderMailType, u32 r1, UnkTextStruct2_sub *r2, u32 r3); +u32 sub_8030768(u8 r0); +u8 sub_80307EC(void); +void sub_8030810(u8 r0); +void sub_803084C(void); +u8 *sub_8030894(void); +void sub_803092C(void); +bool8 HasNoWonderMailType(u32 wonderMailType); + +#endif /* ifndef WONDER_MAIL_4_H */ diff --git a/include/wonder_mail_5.h b/include/wonder_mail_5.h new file mode 100644 index 00000000..873886b3 --- /dev/null +++ b/include/wonder_mail_5.h @@ -0,0 +1,9 @@ +#ifndef WONDER_MAIL_5_H +#define WONDER_MAIL_5_H + +bool8 sub_8030D40(u8 mailIndex, s32 windowID); +u32 sub_8030DA0(void); +void sub_8030DE4(void); + + +#endif /* ifndef WONDER_MAIL_5_H */ diff --git a/src/code_8048480.c b/src/code_8048480.c index 8dfd6c68..bfbb8ad8 100644 --- a/src/code_8048480.c +++ b/src/code_8048480.c @@ -112,7 +112,6 @@ extern void sub_8072008(Entity *pokemon, Entity *r1, u32 r2, u8 r3, u32); extern void LevelDownTarget(Entity *pokemon, Entity *r1, u32 r2); extern void sub_80522F4(Entity *pokemon, Entity *r1, const u8[]); extern void sub_806F370(Entity *pokemon, Entity *r1, u32, u32, u8 *, u8, s32, u32, u32, u32); -extern void sub_8078A58(Entity *, Entity *, s32, u32); extern s32 sub_8042520(Entity *); Entity *sub_80696FC(Entity *); extern void sub_806A7E8(EntityInfo *, s32); diff --git a/src/friend_rescue.c b/src/friend_rescue.c index 761bc40f..86024ccd 100644 --- a/src/friend_rescue.c +++ b/src/friend_rescue.c @@ -25,6 +25,8 @@ #include "text_util.h" #include "text1.h" #include "text2.h" +#include "wonder_mail_4.h" +#include "wonder_mail_5.h" extern void SetFriendRescueMenuState(u32); @@ -298,14 +300,6 @@ void sub_80353BC(void); void sub_8035424(void); void sub_8035430(void); -extern u32 sub_8030DA0(void); -extern void sub_8030DE4(void); -extern void sub_803092C(void); -extern u32 sub_8030768(u32); -extern void sub_803084C(void); -extern void sub_8030D40(u8, u32); -extern void sub_8030810(u32); -extern u8 sub_80307EC(void); extern u32 sub_8031DCC(void); extern void sub_8031E00(void); extern u32 sub_8039068(u32, u8 *passwordBuffer, unkStruct_203B480 *r0); @@ -313,9 +307,6 @@ extern u32 sub_8039068(u32, u8 *passwordBuffer, unkStruct_203B480 *r0); extern void sub_8031E10(void); extern u8 sub_800D588(void); extern u32 sub_8023CE8(void); -extern u32 sub_80306A8(u32 wonderMailType, u32, UnkTextStruct2_sub *, u32); -extern u32 sub_8030894(void); -extern void sub_803092C(void); extern bool8 sub_8031D70(u32 mailIndex, s32); extern s32 sub_8037B28(u32); @@ -833,8 +824,8 @@ void sub_8032828(void) case 0x32: if (sub_8030894() == 0) { ResetUnusedInputStruct(); - xxx_call_save_unk_text_struct_800641C(NULL, TRUE, TRUE); - sub_80306A8(1, 0, NULL, 6); + sub_800641C(NULL, TRUE, TRUE); + sub_80306A8(WONDER_MAIL_TYPE_SOS, 0, NULL, 6); } break; case 0x35: @@ -930,8 +921,8 @@ void sub_8032828(void) case 0x1D: if (sub_8030894() == 0) { ResetUnusedInputStruct(); - xxx_call_save_unk_text_struct_800641C(NULL, TRUE, TRUE); - sub_80306A8(4, 0, NULL, 6); + sub_800641C(NULL, TRUE, TRUE); + sub_80306A8(WONDER_MAIL_TYPE_AOK, 0, NULL, 6); } break; case 0x20: @@ -1037,8 +1028,8 @@ void sub_8032828(void) if (sub_8030894() != 0) break; ResetUnusedInputStruct(); - xxx_call_save_unk_text_struct_800641C(NULL, TRUE, TRUE); - sub_80306A8(1, 0, NULL, 6); + sub_800641C(NULL, TRUE, TRUE); + sub_80306A8(WONDER_MAIL_TYPE_SOS, 0, NULL, 6); break; case 0x15: sub_8014248(&gUnknown_80E2F78[0], 0, 6, gUnknown_80E2290, NULL, 4, 0, NULL, 0x101); diff --git a/src/pelipper_board.c b/src/pelipper_board.c index e7ec9b56..ec7c65f2 100644 --- a/src/pelipper_board.c +++ b/src/pelipper_board.c @@ -66,20 +66,18 @@ const u8 gPelipperBoard_JobList[] = "Job List"; const u8 gPelipperBoard_Accepted[] = "Accepted"; const u8 gPelipperStatusSlash[] = "/"; -extern void sub_802ECB4(void); -extern void nullsub_134(void); -extern void sub_802ED4C(void); -extern void sub_802EDBC(void); -extern void sub_802EEA0(void); -extern void sub_802EEBC(void); -extern void sub_802E94C(void); -extern void sub_802EA58(void); -extern void CreatePelipperBoardMenu(void); -extern void sub_802EC10(void); - -extern void CreatePelipperAcceptedStatusBox(u32); - -void SetPelipperBoardState(u32); +static void sub_802ECB4(void); +static void nullsub_134(void); +static void sub_802ED4C(void); +static void sub_802EDBC(void); +static void sub_802EEA0(void); +static void sub_802EEBC(void); +static void sub_802E94C(void); +static void sub_802EA58(void); +static void CreatePelipperBoardMenu(void); +static void sub_802EC10(void); +static void CreatePelipperAcceptedStatusBox(u32); +static void SetPelipperBoardState(u32); u32 sub_802E864(void) { diff --git a/src/save_menu.c b/src/save_menu.c index 3f589a5a..4c7601cf 100644 --- a/src/save_menu.c +++ b/src/save_menu.c @@ -114,10 +114,11 @@ ALIGNED(4) const u8 gUnknown_80E7178[] = _("{CENTER_ALIGN}The data could not be "{CENTER_ALIGN}Please turn off the power and remove\n" "{CENTER_ALIGN}and reinsert the DS Card."); -extern void sub_8038440(); -extern void sub_80384D0(); -extern void sub_8038830(); -extern void sub_80388C4(void); +static void sub_8038830(void); +static void sub_80388C4(void); + +extern void sub_8038440(void); +extern void sub_80384D0(void); extern void sub_80140F8(void); void CreateSaveMenu(s32 currMenu) diff --git a/src/status_actions.c b/src/status_actions.c index 12e72f85..b94e59c9 100644 --- a/src/status_actions.c +++ b/src/status_actions.c @@ -35,7 +35,6 @@ extern void sub_807F43C(Entity *, Entity *); extern void sub_807DC68(Entity *, Entity *); -extern void sub_8078A58(Entity *, Entity *, s32, u32); extern u32 sub_803D73C(u32); extern void sub_8045C28(Item *, u8 , u8); extern void sub_80464C8(Entity *, Position *, Item *); diff --git a/src/thank_you_wonder_mail.c b/src/thank_you_wonder_mail.c index b6b33e4f..9674d84f 100644 --- a/src/thank_you_wonder_mail.c +++ b/src/thank_you_wonder_mail.c @@ -23,6 +23,8 @@ #include "text1.h" #include "text2.h" #include "thank_you_wonder_mail.h" +#include "wonder_mail_4.h" +#include "wonder_mail_5.h" static EWRAM_DATA_2 WonderMailStruct_203B2C4 *sUnknown_203B2C4 = {0}; @@ -54,9 +56,24 @@ static EWRAM_DATA_2 WonderMailStruct_203B2C4 *sUnknown_203B2C4 = {0}; #define PROCESS_THANK_YOU_PASSWORD 0x27 #define THANK_YOU_PASSWORD_WRONG 0x28 +enum menuActions { + CANCEL_ACTION, + SEND_THANK_YOU_MAIL_ACTION, + GET_THANK_YOU_MAIL_ACTION, + // 3 - GAME_LINK + // 4 - ??? + // 5 - PASSWORD + YES_ACTION = 0x7, + NO_ACTION, + SEND_ITEM_ACTION, + NO_SEND_ITEM_ACTION, + CONFIRM_ACTION, + INFO_ACTION, +}; + const Item gUnknown_80DED44 = { - 1, 0, 0 + ITEM_FLAG_EXISTS, 0, ITEM_NOTHING }; extern char gUnknown_202E5D8[0x50]; @@ -88,9 +105,9 @@ extern const u8 DontSendItem_Text[]; const MenuItem gUnknown_80DED78[3] = { - {"Confirm", 0xB}, - {"Info", 0xC}, - {NULL, 0x0}, + {"Confirm", CONFIRM_ACTION}, + {"Info", INFO_ACTION}, + {NULL, CANCEL_ACTION}, }; // Unused @@ -107,40 +124,40 @@ const UnkTextStruct2 gUnknown_80DEDA0 = const MenuItem gThankYouMailMainMenuItems[4] = { - {"Send Thank-You Mail", 0x1}, - {"Get Thank-You Mail", 0x2}, - {"Cancel", 0x0}, - {NULL, 0x0}, + {"Send Thank-You Mail", SEND_THANK_YOU_MAIL_ACTION}, + {"Get Thank-You Mail", GET_THANK_YOU_MAIL_ACTION}, + {"Cancel", CANCEL_ACTION}, + {NULL, CANCEL_ACTION}, }; const MenuItem gUnknown_80DEE08[4] = { {"Game Link cable", WONDER_MAIL_GAME_LINK}, {"Password", WONDER_MAIL_PASSWORD}, - {"Cancel", 0x0}, - {NULL, 0x0}, + {"Cancel", CANCEL_ACTION}, + {NULL, CANCEL_ACTION}, }; const MenuItem gUnknown_80DEE44[3] = { - {"Yes", 0x7}, - {"Cancel", 0x0}, - {NULL, 0x0}, + {"Yes", YES_ACTION}, + {"Cancel", CANCEL_ACTION}, + {NULL, CANCEL_ACTION}, }; const MenuItem gUnknown_80DEE60[3] = { - {"Yes", 0x7}, - {"No", 0x8}, - {NULL, 0x0}, + {"Yes", YES_ACTION}, + {"No", NO_ACTION}, + {NULL, CANCEL_ACTION}, }; const MenuItem gUnknown_80DEE7C[4] = { - {SendItem_Text, 0x9}, - {DontSendItem_Text, 0xA}, - {"Cancel", 0x0}, - {NULL, 0x0}, + {SendItem_Text, SEND_ITEM_ACTION}, + {DontSendItem_Text, NO_SEND_ITEM_ACTION}, + {"Cancel", CANCEL_ACTION}, + {NULL, CANCEL_ACTION}, }; ALIGNED(4) static const u8 DontSendItem_Text[] = _("Don{APOSTROPHE}t Send Item"); @@ -148,29 +165,24 @@ ALIGNED(4) static const u8 SendItem_Text[] = "Send Item"; const MenuItem gUnknown_80DEEBC[3] = { - {"Send w/o Item", 0xA}, - {"Cancel", 0x0}, - {NULL, 0x0}, + {"Send w/o Item", NO_SEND_ITEM_ACTION}, + {"Cancel", CANCEL_ACTION}, + {NULL, CANCEL_ACTION}, }; const MenuItem gUnknown_80DEEE4[4] = { - {"Yes", 0x7}, - {"No", 0x8}, - {"Cancel", 0x0}, - {NULL, 0x0}, + {"Yes", YES_ACTION}, + {"No", NO_ACTION}, + {"Cancel", CANCEL_ACTION}, + {NULL, CANCEL_ACTION}, }; #include "data/thank_you_wonder_mail.h" -extern void sub_8030810(u32); extern u32 sub_8031DCC(void); extern void sub_8031E00(void); -extern u32 sub_8030768(u32); -extern s8 sub_80307EC(void); -extern void sub_8030D40(u8, u32); -extern u32 sub_8030DA0(); extern void HandleThankYouMailPelipperMainMenu(); extern void sub_802AAC8(); extern void ReturnToThankYouMailMainMenu(); @@ -211,19 +223,13 @@ extern void HandleThankYouMailPasswordMenu(); extern void sub_802A9FC(); extern void sub_802A828(); extern void sub_802A850(); -extern void sub_8030DE4(); -extern void sub_803084C(); extern void sub_8031E10(); extern void SetThankYouMailMenuState(u32); -extern void sub_803092C(void); extern s32 sub_8037B28(u32); -extern u32 sub_8030894(void); -extern void sub_80306A8(u32, u32, u32, u32); extern u8 sub_800D588(void); extern u32 GetDungeonTeamRankPts(DungeonLocation *, u32); extern void sub_8031D70(u8, u32); -extern void sub_803092C(void); extern void sub_8011C28(u32); extern u32 sub_8039068(u32, u8 *r1, unkStruct_203B480 *r0); @@ -543,11 +549,11 @@ void sub_802A090(void) { switch(menuAction) { - case 7: + case YES_ACTION: SetThankYouMailMenuState(SELECT_THANK_YOU_MAIL_COMMS); break; - case 8: - case 0: + case NO_ACTION: + case CANCEL_ACTION: SetThankYouMailMenuState(ANYTHING_ELSE_THANK_YOU_MAIN_MENU); break; default: @@ -601,11 +607,11 @@ void sub_802A174(void) switch(menuAction) { - case 0xB: + case CONFIRM_ACTION: sub_803084C(); SetThankYouMailMenuState(0xe); break; - case 0xC: + case INFO_ACTION: sUnknown_203B2C4->fallbackState = 0x2b; RestoreUnkTextStruct_8006518(sUnknown_203B2C4->unk3BC); ResetUnusedInputStruct(); @@ -613,7 +619,7 @@ void sub_802A174(void) sub_8030D40(sUnknown_203B2C4->mailIndex,0); SetThankYouMailMenuState(0x12); break; - case 0: + case CANCEL_ACTION: case 0xD: sub_8035CC0(sUnknown_203B2C4->unk35C,2); sub_8030810(1); @@ -711,11 +717,11 @@ void sub_802A39C(void) switch(menuAction) { - case 0xB: + case CONFIRM_ACTION: sub_801CBB8(); SetThankYouMailMenuState(CONFIRM_ITEM_TO_SEND); break; - case 0xC: + case INFO_ACTION: sUnknown_203B2C4->fallbackState = 0x2b; RestoreUnkTextStruct_8006518(sUnknown_203B2C4->unk3BC); ResetUnusedInputStruct(); @@ -723,7 +729,7 @@ void sub_802A39C(void) sub_801B3C0(&sUnknown_203B2C4->unk41C); SetThankYouMailMenuState(SHOW_ITEM_TO_SEND_INFO); break; - case 0: + case CANCEL_ACTION: case 0xD: sub_8035CC0(sUnknown_203B2C4->unk35C, 3); sub_801CCD8(); @@ -907,14 +913,14 @@ void sub_802A75C(void) { switch(menuAction) { - case 7: + case YES_ACTION: // NOTE: if statement is needed to match if(sUnknown_203B2C4->wonderMailMode) SetThankYouMailMenuState(COMMUNICATING_THANK_YOU_MAIL); else SetThankYouMailMenuState(COMMUNICATING_THANK_YOU_MAIL); break; - case 0: + case CANCEL_ACTION: SetThankYouMailMenuState(ANYTHING_ELSE_THANK_YOU_MAIN_MENU); break; } @@ -929,7 +935,7 @@ void HandleConfirmItemtoSendMenu(void) { switch(menuAction) { - case 7: + case YES_ACTION: mail = GetMailatIndex(sUnknown_203B2C4->mailIndex); if(sUnknown_203B2C4->unk41C.id != ITEM_NOTHING) { @@ -938,10 +944,10 @@ void HandleConfirmItemtoSendMenu(void) gTeamInventoryRef->teamStorage[sUnknown_203B2C4->unk41C.id]--; SetThankYouMailMenuState(0x29); break; - case 8: + case NO_ACTION: SetThankYouMailMenuState(PROMPT_ITEM_TO_SEND); break; - case 0: + case CANCEL_ACTION: SetThankYouMailMenuState(ANYTHING_ELSE_THANK_YOU_MAIN_MENU); break; } @@ -997,7 +1003,7 @@ void sub_802A8BC(void) { switch(menuAction) { - case 0xA: + case NO_SEND_ITEM_ACTION: switch(sUnknown_203B2C4->wonderMailMethod) { case WONDER_MAIL_GAME_LINK: @@ -1009,7 +1015,7 @@ void sub_802A8BC(void) break; } break; - case 0: + case CANCEL_ACTION: SetThankYouMailMenuState(ANYTHING_ELSE_THANK_YOU_MAIN_MENU); break; } @@ -1023,7 +1029,7 @@ void sub_802A910(void) { switch(menuAction) { - case 9: + case SEND_ITEM_ACTION: if(sub_801CF14(0)) { SetThankYouMailMenuState(THANK_YOU_MAIL_STORAGE_EMPTY); @@ -1033,7 +1039,7 @@ void sub_802A910(void) SetThankYouMailMenuState(PROMPT_ITEM_TO_SEND); } break; - case 0xA: + case NO_SEND_ITEM_ACTION: switch(sUnknown_203B2C4->wonderMailMethod) { case WONDER_MAIL_GAME_LINK: @@ -1045,7 +1051,7 @@ void sub_802A910(void) break; } break; - case 0: + case CANCEL_ACTION: SetThankYouMailMenuState(ANYTHING_ELSE_THANK_YOU_MAIN_MENU); break; } @@ -1068,7 +1074,7 @@ void sub_802A9A8(void) { switch(menuAction) { - case 0x7: + case YES_ACTION: switch(sUnknown_203B2C4->wonderMailMethod) { case WONDER_MAIL_GAME_LINK: @@ -1080,7 +1086,7 @@ void sub_802A9A8(void) break; } break; - case 0: + case CANCEL_ACTION: SetThankYouMailMenuState(ANYTHING_ELSE_THANK_YOU_MAIN_MENU); break; } @@ -1094,10 +1100,10 @@ void sub_802A9FC(void) { switch(menuAction) { - case 0x7: + case YES_ACTION: SetThankYouMailMenuState(PROMPT_THANK_YOU_PASSWORD); break; - case 0: + case CANCEL_ACTION: SetThankYouMailMenuState(ANYTHING_ELSE_THANK_YOU_MAIN_MENU); break; } @@ -1141,7 +1147,7 @@ void HandleMailCommunicationMenu(void) break; } break; - case 0: + case CANCEL_ACTION: SetThankYouMailMenuState(ANYTHING_ELSE_THANK_YOU_MAIN_MENU); break; } @@ -1173,7 +1179,7 @@ void HandleThankYouMailPelipperMainMenu(void) { switch(menuAction) { - case 1: + case SEND_THANK_YOU_MAIL_ACTION: sUnknown_203B2C4->unk40 = 6; sUnknown_203B2C4->wonderMailMode = WONDER_MAIL_MODE_SEND; if(CountMailType(5) == 0) @@ -1185,12 +1191,12 @@ void HandleThankYouMailPelipperMainMenu(void) SetThankYouMailMenuState(PROMPT_THANK_YOU_TO_SEND); } break; - case 2: + case GET_THANK_YOU_MAIL_ACTION: sUnknown_203B2C4->unk40 = 7; sUnknown_203B2C4->wonderMailMode = WONDER_MAIL_MODE_RECEIVE; SetThankYouMailMenuState(SELECT_THANK_YOU_MAIL_COMMS); break; - case 0: + case CANCEL_ACTION: SetThankYouMailMenuState(2); break; } diff --git a/src/weather.c b/src/weather.c index cd391ee9..d90d326a 100644 --- a/src/weather.c +++ b/src/weather.c @@ -11,7 +11,6 @@ extern void TriggerWeatherAbilities(void); extern void sub_807EAA0(u32, u32); -void sub_807E5E4(u8); u8 GetApparentWeather(Entity *pokemon) { diff --git a/src/wonder_mail.c b/src/wonder_mail.c index 580d6456..5dd4fa0d 100644 --- a/src/wonder_mail.c +++ b/src/wonder_mail.c @@ -21,13 +21,14 @@ #include "text1.h" #include "text2.h" #include "wonder_mail.h" +#include "wonder_mail_4.h" +#include "wonder_mail_5.h" static EWRAM_DATA_2 WonderMailStruct_203B2C0 *sUnknown_203B2C0 = {0}; extern void sub_8011C28(u32); extern void sub_809927C(u8); -extern bool8 HasNoWonderMailType(u32); extern u32 sub_8031050(); extern void sub_80310B4(); @@ -36,28 +37,15 @@ extern char gAvailablePokemonNames[0x50]; extern void nullsub_130(void); extern void sub_8028348(void); -extern void sub_803084C(); -extern u32 sub_8030768(u32); -extern s8 sub_80307EC(); -extern void sub_8030D40(u8, u32); -extern void sub_8030810(u32); -extern u32 sub_8030DA0(void); -extern void sub_8030DE4(void); -extern void sub_803092C(void); extern u32 sub_8039068(u32, u8 *r1, unkStruct_203B480 *r0); -extern void sub_8095274(u32); extern u32 sub_8031DCC(); extern void sub_8031E10(); extern void sub_8031E00(); extern void sub_8031E10(void); -extern void sub_803084C(void); -extern void sub_8030DE4(); -extern void sub_80306A8(u32, u32, u32, u32); extern s32 sub_8037B28(u32); extern void sub_8031D70(u8, u32); extern u32 sub_8023CE8(void); -extern u32 sub_8030894(void); extern void sub_8030F58(u32); extern void sub_8029B34(void); extern void sub_8029AD8(void); @@ -111,9 +99,7 @@ extern void sub_8029044(void); extern void sub_8028CFC(void); extern void sub_8028D4C(void); extern void sub_8031E10(void); -extern void sub_803084C(void); extern void sub_80310B4(void); -extern void sub_8030DE4(void); extern const u8 DontSendPokemon_80DDB80[]; extern const u8 SendPokemon_80DDB98[]; @@ -632,7 +618,7 @@ void sub_8028348(void) ResetUnusedInputStruct(); xxx_call_save_unk_text_struct_800641C(NULL, TRUE, TRUE); // SOS Mail - sub_80306A8(2, 0, 0, 6); + sub_80306A8(WONDER_MAIL_TYPE_SOS_1, 0, 0, 6); } break; case 0x20: @@ -1356,7 +1342,7 @@ void sub_802939C(void) } else { - SetFriendRescueCounterState(0x2); + SetFriendRescueCounterState(FRIEND_RESCUE_EXIT_PRE); } } } @@ -1399,8 +1385,8 @@ void sub_80293F4(void) sub_8095274(mail.unk10.unk10); mail.mailType = 2; sub_80951BC(&mail); - xxx_info_box_80141B4(gWonderMailAOKMailReceivedText, 0, &sUnknown_203B2C0->faceFile, 0x101); - SetFriendRescueCounterState(0x23); + sub_80141B4(gWonderMailAOKMailReceivedText, 0, &sUnknown_203B2C0->faceFile, 0x101); + SetFriendRescueCounterState(RECEIVED_FRIEND_SOS_MAIL); break; case 23: case 24: diff --git a/src/wonder_mail_2.c b/src/wonder_mail_2.c index 066441b9..19441ba2 100644 --- a/src/wonder_mail_2.c +++ b/src/wonder_mail_2.c @@ -37,6 +37,11 @@ struct unkStruct_203B2C8 u32 fill13C; }; +enum States { + INIT_STATE, + EXIT_STATE = 5 +}; + static EWRAM_DATA_2 struct unkStruct_203B2C8 *sUnknown_203B2C8 = {0}; extern void sub_80920D8(u8 *buffer); @@ -78,9 +83,8 @@ ALIGNED(4) const char gUnknown_80DFB14[] = _( " Please give me a shout if\n" "you would like to send {COLOR_1 LIGHT_BLUE}A-OK Mail{END_COLOR_TEXT_1}."); -u32 sub_802B2D4(void) +s32 sub_802B2D4(void) { - s32 iVar1; OpenedFile *faceFile; ResetUnusedInputStruct(); @@ -97,19 +101,20 @@ u32 sub_802B2D4(void) sUnknown_203B2C8->unk12 = 0; sUnknown_203B2C8->unkC = 2; sUnknown_203B2C8->unkE = 8; - if (sub_8099394(&sUnknown_203B2C8->unk1) == 1) { - sub_802B548(0); - iVar1 = 1; + if (sub_8099394(&sUnknown_203B2C8->unk1) != 1) { + return 0; } else - iVar1 = 0; - return iVar1; + { + sub_802B548(INIT_STATE); + return 1; + } } u32 sub_802B358(void) { switch(sUnknown_203B2C8->currState) { - case 0: + case INIT_STATE: sub_802B560(); break; case 1: @@ -124,7 +129,7 @@ u32 sub_802B358(void) case 4: sub_802B624(); break; - case 5: + case EXIT_STATE: return 3; } return 0; @@ -151,7 +156,7 @@ void sub_802B3E0(void) char teamNameBuffer[40]; switch(sUnknown_203B2C8->currState) { - case 0: + case INIT_STATE: if (sub_80023E4(0)) { // Copy Team Name to buffer sub_80920D8(teamNameBuffer); @@ -179,7 +184,7 @@ void sub_802B3E0(void) sUnknown_203B2C8->unk114.itemRewards[2] = ITEM_NOTHING; sUnknown_203B2C8->unk114.quantity = 10; sUnknown_203B2C8->unk114.friendAreaReward = 0; - sub_802F204(&sUnknown_203B2C8->unk114, 0); + sub_802F204(&sUnknown_203B2C8->unk114, FALSE); break; case 2: // I hope you will keep on rescuing your friends @@ -260,6 +265,6 @@ void sub_802B624(void) s32 temp; if (sub_80144A4(&temp) == 0) { - sub_802B548(5); + sub_802B548(EXIT_STATE); } } diff --git a/src/wonder_mail_4.c b/src/wonder_mail_4.c index 06d4a09c..14a8b937 100644 --- a/src/wonder_mail_4.c +++ b/src/wonder_mail_4.c @@ -14,6 +14,7 @@ #include "text1.h" #include "text2.h" #include "structs/struct_sub80095e4.h" +#include "wonder_mail_4.h" struct unkStruct_203B320 { @@ -53,7 +54,7 @@ extern const u8 ThanksList[]; extern const u8 CompletedJobs[]; extern const u8 OkdRescue[]; -const u8 * const gUnknown_80E086C[] = +const u8 * const gUnknown_80E086C[MAX_WONDER_MAIL_TYPES] = { SOSList, RequestList, @@ -74,10 +75,8 @@ ALIGNED(4) const u8 SOSMail[] = "SOS Mail"; ALIGNED(4) const u8 RequestList[] = "Request List"; ALIGNED(4) const u8 SOSList[] = "SOS List"; -extern bool8 HasNoWonderMailType(u32); -extern s32 sub_8030A74(void); -extern void sub_80308A0(void); -extern void sub_803092C(void); +s32 sub_8030A74(void); +void sub_80308A0(void); u32 sub_80306A8(u32 wonderMailType, u32 r1, UnkTextStruct2_sub *r2, u32 r3) { @@ -125,7 +124,7 @@ u32 sub_8030768(u8 r0) PlayMenuSoundEffect(0); return 3; default: - if(sub_80138B8(&gUnknown_203B320->s28.s0.input, 1) != 0) + if(sub_80138B8(&gUnknown_203B320->s28.s0.input, TRUE) != 0) { sub_80308A0(); sub_803092C(); @@ -152,7 +151,7 @@ void sub_8030810(u8 r0) AddMenuCursorSprite(&gUnknown_203B320->s28.s0.input); } -void sub_803084C() +void sub_803084C(void) { if(gUnknown_203B320 != NULL) { @@ -164,7 +163,7 @@ void sub_803084C() } } -u8 *sub_8030894() +u8 *sub_8030894(void) { return gUnknown_203B320->unk0; } diff --git a/src/wonder_mail_5.c b/src/wonder_mail_5.c index 4423fe86..2f7133a0 100644 --- a/src/wonder_mail_5.c +++ b/src/wonder_mail_5.c @@ -1,3 +1,4 @@ +#include "constants/input.h" #include "global.h" #include "globaldata.h" #include "code_800D090.h" @@ -19,7 +20,7 @@ struct unkStruct_203B324 // size: 0x78 MenuInputStructSub unk0; u8 mailIndex; - u32 unk10; + u32 windowID; UnkTextStruct2 *unk14; UnkTextStruct2 unk18[4]; }; @@ -57,27 +58,27 @@ extern void sub_8030DD4(void); void sub_8030E2C(void); void sub_8030E48(void); -bool8 sub_8030D40(u8 mailIndex, s32 param_2) +bool8 sub_8030D40(u8 mailIndex, s32 windowID) { gUnknown_203B324 = MemoryAlloc(sizeof(struct unkStruct_203B324), 8); gUnknown_203B324->mailIndex = mailIndex; sub_801317C(&gUnknown_203B324->unk0); - gUnknown_203B324->unk10 = param_2; - gUnknown_203B324->unk14 = &gUnknown_203B324->unk18[param_2]; - RestoreUnkTextStruct_8006518(gUnknown_203B324->unk18); - gUnknown_203B324->unk18[gUnknown_203B324->unk10] = gUnknown_80E091C; + gUnknown_203B324->windowID = windowID; + gUnknown_203B324->unk14 = &gUnknown_203B324->unk18[windowID]; + sub_8006518(gUnknown_203B324->unk18); + gUnknown_203B324->unk18[gUnknown_203B324->windowID] = gUnknown_80E091C; sub_8030DD4(); return TRUE; } -u8 sub_8030DA0(void) +u32 sub_8030DA0(void) { - switch(sub_8012A64(&gUnknown_203B324->unk0, gUnknown_203B324->unk10)) + switch(sub_8012A64(&gUnknown_203B324->unk0, gUnknown_203B324->windowID)) { - case 2: + case INPUT_B_BUTTON: PlayMenuSoundEffect(1); return 2; - case 1: + case INPUT_A_BUTTON: PlayMenuSoundEffect(0); return 3; default: @@ -95,7 +96,7 @@ void sub_8030DE4(void) { if(gUnknown_203B324 != NULL) { - gUnknown_203B324->unk18[gUnknown_203B324->unk10] = gUnknown_80E0900; + gUnknown_203B324->unk18[gUnknown_203B324->windowID] = gUnknown_80E0900; ResetUnusedInputStruct(); xxx_call_save_unk_text_struct_800641C(gUnknown_203B324->unk18, TRUE, TRUE); MemoryFree(gUnknown_203B324); @@ -117,8 +118,8 @@ void sub_8030E48(void) u8 buffer [256]; mail = &gUnknown_203B480[gUnknown_203B324->mailIndex]; - sub_80073B8(gUnknown_203B324->unk10); - stack.unk0[0] = gUnknown_203B324->unk10; + sub_80073B8(gUnknown_203B324->windowID); + stack.unk0[0] = gUnknown_203B324->windowID; stack.mailTitleType = 7; stack.mailMissionType = MISSION_TYPE_FRIEND_RESCUE; stack.mailStatus = MAIL_STATUS_SUSPENDED; @@ -150,8 +151,8 @@ void sub_8030E48(void) } CreateRescueDescription(&stack); uVar2 = mail->unk10.unk10_u16 % 10000; - PrintStringOnWindow(10,0x68,gUnknown_80E0934,gUnknown_203B324->unk10,0); // ID: + PrintStringOnWindow(10,0x68,gUnknown_80E0934,gUnknown_203B324->windowID,0); // ID: sprintfStatic(buffer,gUnknown_80E0938,uVar2); // %-4d - PrintStringOnWindow(0x44,0x68,buffer,gUnknown_203B324->unk10,0); - sub_80073E0(gUnknown_203B324->unk10); + PrintStringOnWindow(0x44,0x68,buffer,gUnknown_203B324->windowID,0); + sub_80073E0(gUnknown_203B324->windowID); } diff --git a/src/wonder_mail_6.c b/src/wonder_mail_6.c index 1077e2f5..bdc7bac7 100644 --- a/src/wonder_mail_6.c +++ b/src/wonder_mail_6.c @@ -8,8 +8,8 @@ #include "code_8094F88.h" #include "menu_input.h" #include "code_80130A8.h" - -extern bool8 HasNoWonderMailType(u32); +#include "wonder_mail_4.h" +#include "wonder_mail_5.h" struct unkStruct_203B328 { @@ -32,18 +32,27 @@ static EWRAM_DATA_2 struct unkStruct_203B328 *gUnknown_203B328 = {0}; extern unkStruct_203B480 *gUnknown_203B480; +enum MenuActions { + CANCEL_ACTION = 1, + YES_ACTION, + NO_ACTION, + DELETE_ACTION, + INFO_ACTION, + DELETE_ALL_MAIL_ACTION, // Unused +}; + const MenuItem gUnknown_80E0948[] = { - {"Yes", 0x2}, - {"No", 0x3}, - {NULL, 0x1} + {"Yes", YES_ACTION}, + {"No", NO_ACTION}, + {NULL, CANCEL_ACTION} }; const MenuItem gUnknown_80E0968[] = { - {"Delete", 0x4}, - {"Info", 0x5}, - {NULL, 0x1} + {"Delete", DELETE_ACTION}, + {"Info", INFO_ACTION}, + {NULL, CANCEL_ACTION} }; const UnkTextStruct2 gUnknown_80E0990 = { @@ -79,35 +88,18 @@ ALIGNED(4) const u8 gUnknown_80E0A0C[] = _( " ...Uh{COMMA} no?\n" "You don{APOSTROPHE}t have any {COLOR_1 LIGHT_BLUE}A-OK Mail{END_COLOR_TEXT_1}."); -extern void sub_80306A8(s32, u32, u32, u32); extern void sub_8031300(void); extern void sub_803136C(void); extern void sub_80313D8(u32); extern void sub_8031498(void); -extern void sub_803084C(void); extern void sub_80310FC(); extern void sub_8031258(); -extern u32 sub_8030768(u32); -extern u8 sub_80307EC(void); -extern u32 sub_8030DA0(void); -extern void sub_8030DE4(); - -extern void sub_8030810(u32); -extern void sub_803092C(void); -extern void sub_8030D40(u8, u32); enum States { INIT_STATE = 0, DELETE_SINGLE_MAIL_STATE = 2, DELETE_ALL_MAIL_STATE = 3, -}; - -enum MenuActions { - CANCEL_ACTION = 1, - YES_ACTION, - NO_ACTION, - DELETE_ACTION, - INFO_ACTION + INFO_STATE = 4, }; bool8 sub_8030F58(u32 wonderMailType) @@ -165,7 +157,7 @@ s32 sub_8031050(void) case DELETE_ALL_MAIL_STATE: sub_80313D8(gUnknown_203B328->state); break; - case 4: + case INFO_STATE: sub_8031498(); break; case 5: @@ -213,7 +205,7 @@ void sub_80310FC(void) gUnknown_203B328->unkA8[2] = gUnknown_80E09C0; sub_8012CAC(&gUnknown_203B328->unkA8[2], gUnknown_80E0948); break; - case 4: + case INFO_STATE: gUnknown_203B328->unkA8[0] = gUnknown_80E0990; gUnknown_203B328->unkA8[1] = gUnknown_80E0990; gUnknown_203B328->unkA8[2] = gUnknown_80E0990; @@ -239,15 +231,15 @@ void sub_8031258(void) break; case 1: sub_803092C(); - sub_8012D60(&gUnknown_203B328->unk8, gUnknown_80E0968, 0, 0, 4, 1); + sub_8012D60(&gUnknown_203B328->unk8, gUnknown_80E0968, NULL, NULL, DELETE_ACTION, 1); break; case DELETE_SINGLE_MAIL_STATE: case DELETE_ALL_MAIL_STATE: sub_803092C(); sub_8012EA4(&gUnknown_203B328->unk8, 0); - sub_8012D60(&gUnknown_203B328->unk58, gUnknown_80E0948, 0, 0, 3, 2); + sub_8012D60(&gUnknown_203B328->unk58, gUnknown_80E0948, NULL, NULL, NO_ACTION, 2); break; - case 4: + case INFO_STATE: sub_8030D40(gUnknown_203B328->mailIndex, 3); break; case 5: @@ -267,7 +259,7 @@ void sub_8031300(void) break; case 4: gUnknown_203B328->mailIndex = sub_80307EC(); - sub_80310E4(4); + sub_80310E4(INFO_STATE); break; case 2: sub_80310E4(6); @@ -291,16 +283,16 @@ void sub_803136C(void) switch(menuAction) { case CANCEL_ACTION: - sub_80310E4(0); + sub_80310E4(INIT_STATE); break; - case 6: - sub_80310E4(3); + case DELETE_ALL_MAIL_ACTION: + sub_80310E4(DELETE_ALL_MAIL_STATE); break; case DELETE_ACTION: - sub_80310E4(2); + sub_80310E4(DELETE_SINGLE_MAIL_STATE); break; case INFO_ACTION: - sub_80310E4(4); + sub_80310E4(INFO_STATE); break; } @@ -323,7 +315,7 @@ void sub_80313D8(u32 state) { case CANCEL_ACTION: case NO_ACTION: - sub_80310E4(0); + sub_80310E4(INIT_STATE); break; case YES_ACTION: switch(state) @@ -346,7 +338,7 @@ void sub_80313D8(u32 state) sub_80310E4(5); } else { - sub_80310E4(0); + sub_80310E4(INIT_STATE); } } break; @@ -363,7 +355,7 @@ void sub_8031498(void) case 2: case 3: sub_8030DE4(); - sub_80310E4(0); + sub_80310E4(INIT_STATE); break; } } diff --git a/src/wonder_mail_main_menu.c b/src/wonder_mail_main_menu.c index 60626d15..09f27b39 100644 --- a/src/wonder_mail_main_menu.c +++ b/src/wonder_mail_main_menu.c @@ -19,6 +19,8 @@ #include "text2.h" #include "wonder_mail_802D098.h" #include "wonder_mail_main_menu.h" +#include "wonder_mail_4.h" +#include "wonder_mail_5.h" #define SELECT_WONDER_MAIL_MODE_MAIN_SCREEN 0 #define SEND_WONDER_MAIL_MAIN_SCREEN 1 @@ -69,17 +71,11 @@ EWRAM_DATA_2 struct unkStruct_203B3E8 *gUnknown_203B3E8 = {0}; #include "data/wonder_mail_main_menu.h" extern void SetWonderMailMainMenuState(u8); -extern void sub_8030DE4(void); -extern void sub_803084C(void); extern void sub_8031E10(void); - extern u8 sub_800D588(void); extern void sub_802EF48(void); - extern s32 sub_8037B28(u32); -extern bool8 IsValidWonderMail(WonderMail *WonderMailData); - void PrintWonderMailMainMenuError(u32); void HandleWonderMailMainScreen(void); void HandleGameLinkCableMenu(void);