From ccbc0ea6471daab196fff4366a5ad4c5721a693d Mon Sep 17 00:00:00 2001 From: Kermalis <29823718+Kermalis@users.noreply.github.com> Date: Fri, 29 Sep 2023 23:46:27 -0400 Subject: [PATCH] Split+data wonder_mail_3 and wonder_mail_2_1 --- include/adventure_log.h | 2 +- include/code_801B3C0.h | 2 +- include/code_801EE10.h | 3 +- include/code_8023144.h | 2 +- include/code_8024458.h | 2 +- include/code_802DB28.h | 2 +- include/code_802DE84.h | 4 +- include/code_802F204.h | 2 +- include/code_803B050.h | 3 +- include/code_803C1D0.h | 4 +- include/code_8094F88.h | 29 +- include/code_80958E8.h | 6 +- include/code_80958E8_1.h | 8 +- include/code_8096AF8.h | 4 + include/code_80972F4.h | 4 + include/code_8098BDC.h | 1 + include/friend_rescue.h | 4 +- include/hints_menu1.h | 2 +- include/hints_menu2.h | 2 +- include/input.h | 37 - include/kangaskhan_storage1.h | 2 +- include/kecleon_bros2.h | 2 +- include/kecleon_bros3.h | 2 +- include/kecleon_bros4.h | 2 +- include/mailbox.h | 3 +- include/mailbox_8095F8C.h | 2 +- include/makuhita_dojo2.h | 2 +- {src => include}/math.h | 0 include/personality_test.h | 2 +- include/pokemon_news1.h | 2 +- include/pokemon_news2.h | 2 +- include/pokemon_news3.h | 2 +- include/post_office_guide2.h | 2 +- include/save.h | 1 + include/structs/menu.h | 38 +- .../{code_802C39C.h => structs/str_802C39C.h} | 9 +- include/structs/str_wonder_mail.h | 82 ++ include/thank_you_wonder_mail.h | 42 + include/wigglytuff_shop2.h | 2 +- include/wonder_mail.h | 74 +- include/wonder_mail_2_1.h | 44 - include/wonder_mail_3.h | 79 -- include/wonder_mail_802C10C.h | 2 +- include/wonder_mail_802C4C8.h | 28 + include/wonder_mail_802C860.h | 30 + include/wonder_mail_802CDD4.h | 24 + include/wonder_mail_802D098.h | 46 + ld_script.txt | 12 +- src/adventure_log.c | 1 + src/bg_control.c | 1 - src/code_2.c | 1 - src/code_800C9CC.c | 1 - src/code_80118A4.c | 1 - src/code_8012A18.c | 1 - src/code_801602C.c | 1 + src/code_801B3C0.c | 1 + src/code_801B60C.c | 1 + src/code_801BEEC.c | 1 + src/code_801C244.c | 1 + src/code_801C620.c | 1 + src/code_801C8C4.c | 1 + src/code_801D014.c | 4 +- src/code_801D9E4.c | 1 + src/code_801EE10.c | 1 + src/code_801EE10_mid.c | 1 + src/code_80227B8.c | 1 + src/code_8023144.c | 1 + src/code_8024458.c | 1 + src/code_802DB28.c | 2 + src/code_802DE84.c | 1 + src/code_803B050.c | 1 - src/code_8040094.c | 1 - src/code_80958E8.c | 3 +- src/code_80958E8_1.c | 5 +- src/code_80972F4.c | 7 +- src/data/wonder_mail_802C4C8.h | 21 + src/data/wonder_mail_802C860.h | 31 + src/data/wonder_mail_802CDD4.h | 21 + src/data/wonder_mail_802D098.h | 88 ++ src/debug_menu1.c | 1 + src/debug_menu2.c | 1 + src/debug_menu3.c | 1 + src/debug_menu4.c | 1 + src/event_flag.c | 1 - src/felicity_bank.c | 1 + src/friend_area_action_menu.c | 1 + src/friend_list_menu.c | 1 + src/ground_main.c | 1 - src/gulpin_shop.c | 1 + src/gulpin_shop_801FB50.c | 1 + src/hints_menu1.c | 1 + src/hints_menu2.c | 1 + src/kangaskhan_storage1.c | 1 + src/kangaskhan_storage2.c | 1 + src/kecleon_bros1.c | 1 + src/kecleon_bros2.c | 1 + src/kecleon_bros3.c | 1 + src/kecleon_bros4.c | 1 + src/mailbox.c | 8 +- src/main_menu1.c | 1 + src/main_menu2.c | 1 + src/makuhita_dojo1.c | 1 + src/makuhita_dojo2.c | 1 + src/menu_input.c | 1 + src/options_menu1.c | 1 + src/options_menu2.c | 1 + src/other_menus2.c | 2 +- src/party_list_menu.c | 1 + src/pelipper_board.c | 8 +- src/personality_test.c | 1 + src/pokemon_news1.c | 1 + src/pokemon_news2.c | 1 + src/pokemon_news3.c | 3 +- src/post_office_guide1.c | 1 + src/post_office_guide2.c | 2 +- src/rescue_password_menu.c | 1 - src/save_menu.c | 1 + src/thank_you_wonder_mail.c | 3 +- src/trade_items_menu.c | 1 + src/unk_menu_203B360.c | 1 + src/wigglytuff_shop1.c | 1 + src/wigglytuff_shop2.c | 1 + src/wigglytuff_shop3.c | 1 + src/wonder_mail.c | 3 + src/wonder_mail_2.c | 2 +- src/wonder_mail_2_1.c | 450 ------- src/wonder_mail_3.c | 1050 ----------------- src/wonder_mail_3_mid.c | 20 +- src/wonder_mail_4.c | 4 +- src/wonder_mail_5.c | 2 +- src/wonder_mail_6.c | 1 + src/wonder_mail_802C10C.c | 1 + src/wonder_mail_802C4C8.c | 222 ++++ src/wonder_mail_802C860.c | 310 +++++ src/wonder_mail_802CDD4.c | 180 +++ src/wonder_mail_802D098.c | 579 +++++++++ src/wonder_mail_main_menu.c | 15 +- sym_ewram2.txt | 15 +- 138 files changed, 1900 insertions(+), 1883 deletions(-) rename {src => include}/math.h (100%) rename include/{code_802C39C.h => structs/str_802C39C.h} (83%) create mode 100644 include/structs/str_wonder_mail.h create mode 100644 include/thank_you_wonder_mail.h delete mode 100644 include/wonder_mail_2_1.h delete mode 100644 include/wonder_mail_3.h create mode 100644 include/wonder_mail_802C4C8.h create mode 100644 include/wonder_mail_802C860.h create mode 100644 include/wonder_mail_802CDD4.h create mode 100644 include/wonder_mail_802D098.h create mode 100644 src/data/wonder_mail_802C4C8.h create mode 100644 src/data/wonder_mail_802C860.h create mode 100644 src/data/wonder_mail_802CDD4.h create mode 100644 src/data/wonder_mail_802D098.h delete mode 100644 src/wonder_mail_2_1.c delete mode 100644 src/wonder_mail_3.c create mode 100644 src/wonder_mail_802C4C8.c create mode 100644 src/wonder_mail_802C860.c create mode 100644 src/wonder_mail_802CDD4.c create mode 100644 src/wonder_mail_802D098.c diff --git a/include/adventure_log.h b/include/adventure_log.h index a2fef9277..74b0eae9d 100644 --- a/include/adventure_log.h +++ b/include/adventure_log.h @@ -1,7 +1,7 @@ #ifndef GUARD_ADVENTURE_LOG_H #define GUARD_ADVENTURE_LOG_H -#include "input.h" +#include "structs/menu.h" #include "structs/str_text.h" // size: 0xA0 diff --git a/include/code_801B3C0.h b/include/code_801B3C0.h index 6ab0d10f7..33db72e14 100644 --- a/include/code_801B3C0.h +++ b/include/code_801B3C0.h @@ -1,8 +1,8 @@ #ifndef GUARD_CODE_801B3C0_H #define GUARD_CODE_801B3C0_H -#include "input.h" #include "items.h" +#include "structs/menu.h" #include "structs/subStruct_203B240.h" #include "structs/str_text.h" diff --git a/include/code_801EE10.h b/include/code_801EE10.h index c67fe4299..3201fc987 100644 --- a/include/code_801EE10.h +++ b/include/code_801EE10.h @@ -2,9 +2,8 @@ #define CODE_801EE10_H #include "constants/move.h" - -#include "input.h" #include "pokemon.h" +#include "structs/menu.h" #include "structs/str_text.h" // size 0xBC diff --git a/include/code_8023144.h b/include/code_8023144.h index 772b0fd2e..4edf3b47e 100644 --- a/include/code_8023144.h +++ b/include/code_8023144.h @@ -1,7 +1,7 @@ #ifndef GUARD_CODE_8023144_H #define GUARD_CODE_8023144_H -#include "input.h" +#include "structs/menu.h" #include "structs/str_text.h" // size: 0x3FC diff --git a/include/code_8024458.h b/include/code_8024458.h index 8cbf206c3..5718330e8 100644 --- a/include/code_8024458.h +++ b/include/code_8024458.h @@ -1,7 +1,7 @@ #ifndef GUARD_CODE_8024458_H #define GUARD_CODE_8024458_H -#include "input.h" +#include "structs/menu.h" #include "structs/str_text.h" struct unkStruct_203B2AC diff --git a/include/code_802DB28.h b/include/code_802DB28.h index f77b8328a..ebf7ad19e 100644 --- a/include/code_802DB28.h +++ b/include/code_802DB28.h @@ -2,8 +2,8 @@ #define GUARD_CODE_802DB28_H #include "file_system.h" -#include "wonder_mail.h" #include "structs/str_text.h" +#include "structs/str_wonder_mail.h" // size: 0xA8 struct unkStruct_203B2FC diff --git a/include/code_802DE84.h b/include/code_802DE84.h index 19b0e7a2f..cd553c082 100644 --- a/include/code_802DE84.h +++ b/include/code_802DE84.h @@ -1,8 +1,8 @@ #ifndef GUARD_CODE_802DE84_H #define GUARD_CODE_802DE84_H -#include "code_802C39C.h" -#include "input.h" +#include "structs/str_802C39C.h" +#include "structs/menu.h" #include "structs/str_text.h" // size: 0x7C diff --git a/include/code_802F204.h b/include/code_802F204.h index 5f3b3353f..8fcf239bd 100644 --- a/include/code_802F204.h +++ b/include/code_802F204.h @@ -1,7 +1,7 @@ #ifndef GUARD_CODE_802F204_H #define GUARD_CODE_802F204_H -#include "wonder_mail.h" +#include "structs/str_wonder_mail.h" u32 sub_802F204(unkStruct_802F204 *, bool8 displayClientSprite); u32 sub_802F298(void); diff --git a/include/code_803B050.h b/include/code_803B050.h index 15575393f..cdb92a269 100644 --- a/include/code_803B050.h +++ b/include/code_803B050.h @@ -1,7 +1,7 @@ #ifndef GUARD_CODE_803B050_H #define GUARD_CODE_803B050_H -#include "code_802C39C.h" +#include "structs/str_802C39C.h" // size: 0x8 typedef struct unkStruct_80E9920 @@ -26,6 +26,7 @@ void CreateRescueTitle(unkStruct_802C39C *); void sub_803B6B0(s32 x, s32 y, u8 index, u32); // code_803B050.s +extern unkStruct_803B344 *sub_803B344(u8); extern void sub_803B35C(WonderMail *, unkStruct_802C39C *); #endif // GUARD_CODE_803B050_H \ No newline at end of file diff --git a/include/code_803C1D0.h b/include/code_803C1D0.h index 453a16047..9a005f239 100644 --- a/include/code_803C1D0.h +++ b/include/code_803C1D0.h @@ -1,9 +1,9 @@ #ifndef GUARD_CODE_803C1D0_H #define GUARD_CODE_803C1D0_H -#include "wonder_mail.h" +#include "structs/str_wonder_mail.h" // code_803C1D0.s -extern void sub_803C21C(WonderMail *, unkStruct_802F204*); +extern void sub_803C21C(WonderMail *, unkStruct_802F204 *); #endif // GUARD_CODE_803C1D0_H \ No newline at end of file diff --git a/include/code_8094F88.h b/include/code_8094F88.h index 8a450601c..dd204cd53 100644 --- a/include/code_8094F88.h +++ b/include/code_8094F88.h @@ -5,34 +5,7 @@ #include "structs/str_dungeon.h" #include "items.h" #include "pokemon.h" - -// size: 0x8 -typedef struct WonderMailSub -{ - /* 0x0 */ DungeonLocation dungeon; - /* 0x4 */ u32 seed; -} WonderMailSub; - -// size: 0x30 -typedef struct unkStruct_203B480 -{ - /* 0x0 */ u8 mailType; - /* 0x1 */ u8 missionType; - WonderMailSub unk4; - /* 0xC */ s16 clientSpecies; - /* 0xE */ s16 targetSpecies; - union unk10_temp - { - u32 unk10; - u16 unk10_u16; - } unk10; - /* 0x14 */ u8 playerName[0x20 - 0x14]; - Item item; - u32 unk24; - u32 unk28; - /* 0x2C */ s8 rescuesAllowed; - u8 unk2D; -} unkStruct_203B480; +#include "structs/str_wonder_mail.h" // size: 0x5C typedef struct unkStruct_203B484 diff --git a/include/code_80958E8.h b/include/code_80958E8.h index 965c9b7f0..e5678a4e7 100644 --- a/include/code_80958E8.h +++ b/include/code_80958E8.h @@ -1,8 +1,8 @@ #ifndef GUARD_CODE_80958E8_H #define GUARD_CODE_80958E8_H -#include "wonder_mail.h" #include "constants/mailbox.h" +#include "structs/str_wonder_mail.h" // size: 0xC typedef struct subStruct_203B490 @@ -18,8 +18,8 @@ typedef struct unkStruct_203B490 /* 0x0 */ WonderMail mailboxSlots[NUM_MAILBOX_SLOTS]; /* 0x50 */ WonderMail pelipperBoardJobs[MAX_ACCEPTED_JOBS]; /* 0xF0 */ WonderMail jobSlots[MAX_ACCEPTED_JOBS]; - u8 unk190[0x28]; - u8 unk1B8[0x78]; + u8 unk190[40]; + u8 unk1B8[120]; subStruct_203B490 unk230[16]; /* 0x2F0 */ u8 PKMNNewsReceived[NUM_POKEMON_NEWS]; bool8 unk328; diff --git a/include/code_80958E8_1.h b/include/code_80958E8_1.h index 22b4b644d..4a6d6fb5a 100644 --- a/include/code_80958E8_1.h +++ b/include/code_80958E8_1.h @@ -1,7 +1,7 @@ #ifndef GUARD_CODE_80958E8_1_H #define GUARD_CODE_80958E8_1_H -#include "wonder_mail.h" +#include "structs/str_wonder_mail.h" // size: 0x8 struct unkStruct_8096AF8 @@ -11,11 +11,17 @@ struct unkStruct_8096AF8 /* 0x4 */ u16 targetSpecies; }; +bool8 AcceptJob(WonderMail *mail); s32 CountJobsinDungeon(u8 dungeon); WonderMail *GetJobSlotInfo(u8 index); +s32 GetNumAcceptedJobs(void); +bool8 IsJobSlotEmpty(u8 index); bool8 IsMailinJobSlot(WonderMail *mail); +void ResetJobSlot(u8 index); +bool8 sub_809693C(WonderMail *mail); void sub_8096AF8(struct unkStruct_8096AF8 *, u8 slotIndex, u8 dungeon); +bool8 sub_8096C08(u8 *jobIndex); // code_80958E8_1.s extern WonderMail *GetPelipperBoardSlotInfo(u8); diff --git a/include/code_8096AF8.h b/include/code_8096AF8.h index 8397553f5..4ebe2a7b5 100644 --- a/include/code_8096AF8.h +++ b/include/code_8096AF8.h @@ -3,6 +3,10 @@ // code_8096AF8.s extern u8 CheckPKMNNewsSlot(u8); +extern void sub_8096C80(void); +extern void sub_8096D24(void); +extern u8 *sub_8096DD8(void); +extern u8 *sub_8096DE8(void); extern bool8 sub_8096E2C(void); extern void sub_8096EEC(void); diff --git a/include/code_80972F4.h b/include/code_80972F4.h index 0df6cbe31..aed85c256 100644 --- a/include/code_80972F4.h +++ b/include/code_80972F4.h @@ -1,6 +1,8 @@ #ifndef GUARD_CODE_80972F4_H #define GUARD_CODE_80972F4_H +#include "structs/str_wonder_mail.h" + // size: 0x8 typedef struct MissionText { @@ -15,6 +17,8 @@ const u8 *GetCurrentMissionText(s16 index); // TODO: this should probably be bool8 but can't get a match just yet bool32 IsMazeCompleted(s16 mazeIndex); +bool8 sub_8096F50(WonderMail *mail); +void sub_8097418(s16 index, bool32); bool8 sub_8097504(s16 mazeIndex); const u8 *sub_80975DC(u32); diff --git a/include/code_8098BDC.h b/include/code_8098BDC.h index 1d1d3b591..c07e0bc33 100644 --- a/include/code_8098BDC.h +++ b/include/code_8098BDC.h @@ -3,6 +3,7 @@ // code_8098DBC.s extern void nullsub_104(void); +extern u8 sub_8099328(u8 *); extern void sub_80993D8(void); extern void sub_80993E4(void); extern void sub_8099690(u32); diff --git a/include/friend_rescue.h b/include/friend_rescue.h index 2c641cf26..2db0ba41f 100644 --- a/include/friend_rescue.h +++ b/include/friend_rescue.h @@ -4,8 +4,8 @@ #include "code_8094F88.h" #include "items.h" #include "pokemon.h" -#include "wonder_mail.h" #include "structs/menu.h" +#include "structs/str_wonder_mail.h" // size: 0x568 typedef struct WonderMailStruct_203B33C @@ -53,4 +53,4 @@ enum FriendRescueMenuStates { FRIEND_RESCUE_MENU_DEFAULT_FALLBACK = 0x7e, }; -#endif +#endif \ No newline at end of file diff --git a/include/hints_menu1.h b/include/hints_menu1.h index c41636e32..68dbd1225 100644 --- a/include/hints_menu1.h +++ b/include/hints_menu1.h @@ -1,7 +1,7 @@ #ifndef GUARD_HINTS_MENU1_H #define GUARD_HINTS_MENU1_H -#include "input.h" +#include "structs/menu.h" #include "structs/str_text.h" // size: 0x9C diff --git a/include/hints_menu2.h b/include/hints_menu2.h index 203adb24d..d16682a48 100644 --- a/include/hints_menu2.h +++ b/include/hints_menu2.h @@ -1,7 +1,7 @@ #ifndef GUARD_HINTS_MENU2_H #define GUARD_HINTS_MENU2_H -#include "input.h" +#include "structs/menu.h" #include "structs/str_text.h" // size: 0xA0 diff --git a/include/input.h b/include/input.h index cc55909a0..1dba6adad 100644 --- a/include/input.h +++ b/include/input.h @@ -47,43 +47,6 @@ typedef struct UnusedInputStruct u8 unk29; } UnusedInputStruct; -// size: 0xC -typedef struct MenuInputStructSub -{ - u8 unk0; - /* 0x1 */ u8 a_button; - /* 0x2 */ u8 b_button; - /* 0x3 */ u8 dpad_right; - /* 0x4 */ u8 dpad_left; - u8 fill5[3]; - u16 unk8; - s16 unkA; -} MenuInputStructSub; - -// size: 0x34 -typedef struct MenuInputStruct -{ - s32 unk0; - u16 unk4; - s16 unk6; - s16 unk8; // Maybe Position - s16 unkA; - s16 unkC; // Maybe Position - s16 unkE; - u32 unk10; - s16 unk14; // Maybe Position - s16 unk16; - /* 0x18 */ s16 menuIndex; - s16 unk1A; - s16 unk1C; - s16 unk1E; - s16 unk20; - s16 unk22; - u16 unk24; - u16 unk26; - MenuInputStructSub unk28; -} MenuInputStruct; - extern Inputs gRealInputs; void InitInput(void); diff --git a/include/kangaskhan_storage1.h b/include/kangaskhan_storage1.h index 551af5a45..e8425dea6 100644 --- a/include/kangaskhan_storage1.h +++ b/include/kangaskhan_storage1.h @@ -2,8 +2,8 @@ #define GUARD_KANGASKHAN_STORAGE1_H #include "file_system.h" -#include "items.h" #include "structs/menu.h" +#include "structs/str_items.h" #include "structs/str_text.h" enum KangaskhanStorageStates diff --git a/include/kecleon_bros2.h b/include/kecleon_bros2.h index 12bafad76..6500558fa 100644 --- a/include/kecleon_bros2.h +++ b/include/kecleon_bros2.h @@ -1,7 +1,7 @@ #ifndef GUARD_KECLEON_BROS2_H #define GUARD_KECLEON_BROS2_H -#include "input.h" +#include "structs/menu.h" #include "structs/str_text.h" // size: 0xA0 diff --git a/include/kecleon_bros3.h b/include/kecleon_bros3.h index d4f6bb67c..c815b448e 100644 --- a/include/kecleon_bros3.h +++ b/include/kecleon_bros3.h @@ -1,7 +1,7 @@ #ifndef GUARD_KECLEON_BROS3_H #define GUARD_KECLEON_BROS3_H -#include "input.h" +#include "structs/menu.h" #include "structs/str_text.h" // size: 0xA0 diff --git a/include/kecleon_bros4.h b/include/kecleon_bros4.h index dd31848f7..f80f1caa2 100644 --- a/include/kecleon_bros4.h +++ b/include/kecleon_bros4.h @@ -2,7 +2,7 @@ #define GUARD_KECLEON_BROS4_H #include "constants/item.h" -#include "input.h" +#include "structs/menu.h" #include "structs/str_text.h" // size: 0xF4 diff --git a/include/mailbox.h b/include/mailbox.h index 4ff13cf58..ea8ec6557 100644 --- a/include/mailbox.h +++ b/include/mailbox.h @@ -4,7 +4,7 @@ #include "structs/menu.h" #include "structs/str_text.h" #include "constants/mailbox.h" -#include "code_802C39C.h" +#include "structs/str_802C39C.h" struct unkStruct_203B304 { @@ -23,7 +23,6 @@ struct unkStruct_203B304 }; extern void SetMailboxState(u32); -extern s32 GetNumAcceptedJobs(void); enum MailBoxStates { diff --git a/include/mailbox_8095F8C.h b/include/mailbox_8095F8C.h index 2f692e9f8..fdd8d44db 100644 --- a/include/mailbox_8095F8C.h +++ b/include/mailbox_8095F8C.h @@ -1,7 +1,7 @@ #ifndef GUARD_MAILBOX_8095F8C_H #define GUARD_MAILBOX_8095F8C_H -#include "wonder_mail.h" +#include "structs/str_wonder_mail.h" WonderMail *GetMailboxSlotInfo(u8 index); bool8 IsMailSlotEmpty(u8 index); diff --git a/include/makuhita_dojo2.h b/include/makuhita_dojo2.h index e50c338fb..85636a9be 100644 --- a/include/makuhita_dojo2.h +++ b/include/makuhita_dojo2.h @@ -2,7 +2,7 @@ #define GUARD_MAKUHITA_DOJO2_H #include "constants/dungeon.h" -#include "input.h" +#include "structs/menu.h" #include "structs/str_text.h" // size: 0xD0 diff --git a/src/math.h b/include/math.h similarity index 100% rename from src/math.h rename to include/math.h diff --git a/include/personality_test.h b/include/personality_test.h index d75755e07..c6abea68f 100644 --- a/include/personality_test.h +++ b/include/personality_test.h @@ -2,7 +2,7 @@ #define GUARD_PERSONALITY_TEST_H #include "constants/personality_test.h" -#include "input.h" +#include "structs/menu.h" #include "structs/str_text.h" // Definitely wrong but need to figure out better structure later diff --git a/include/pokemon_news1.h b/include/pokemon_news1.h index c8c113db7..89ace4596 100644 --- a/include/pokemon_news1.h +++ b/include/pokemon_news1.h @@ -2,7 +2,7 @@ #define GUARD_POKEMON_NEWS1_H #include "constants/wonder_mail.h" -#include "input.h" +#include "structs/menu.h" #include "structs/str_text.h" // size: 0xD4; diff --git a/include/pokemon_news2.h b/include/pokemon_news2.h index 6a02b054c..03da4a4d0 100644 --- a/include/pokemon_news2.h +++ b/include/pokemon_news2.h @@ -1,7 +1,7 @@ #ifndef GUARD_POKEMON_NEWS2_H #define GUARD_POKEMON_NEWS2_H -#include "input.h" +#include "structs/menu.h" #include "structs/str_text.h" // size: 0x94 diff --git a/include/pokemon_news3.h b/include/pokemon_news3.h index 72a7a2222..878833a73 100644 --- a/include/pokemon_news3.h +++ b/include/pokemon_news3.h @@ -1,7 +1,7 @@ #ifndef GUARD_POKEMON_NEWS3_H #define GUARD_POKEMON_NEWS3_H -#include "input.h" +#include "structs/menu.h" #include "structs/str_text.h" // size: 0xA4 diff --git a/include/post_office_guide2.h b/include/post_office_guide2.h index f06409d80..1f8a1b67c 100644 --- a/include/post_office_guide2.h +++ b/include/post_office_guide2.h @@ -1,7 +1,7 @@ #ifndef GUARD_POST_OFFICE_GUIDE2_H #define GUARD_POST_OFFICE_GUIDE2_H -#include "input.h" +#include "structs/menu.h" #include "structs/str_text.h" // size: 0x78 diff --git a/include/save.h b/include/save.h index 6ba2fe0e9..dfd000e0f 100644 --- a/include/save.h +++ b/include/save.h @@ -7,6 +7,7 @@ #include "rescue_team_info.h" #include "pokemon.h" #include "items.h" +#include "code_8094F88.h" #include "code_80958E8.h" enum diff --git a/include/structs/menu.h b/include/structs/menu.h index bd0de04cf..2322d40fe 100644 --- a/include/structs/menu.h +++ b/include/structs/menu.h @@ -1,10 +1,46 @@ #ifndef GUARD_MENU_H #define GUARD_MENU_H -#include "input.h" #include "sprite_oam.h" #include "structs/str_text.h" +// size: 0xC +typedef struct MenuInputStructSub +{ + u8 unk0; + /* 0x1 */ u8 a_button; + /* 0x2 */ u8 b_button; + /* 0x3 */ u8 dpad_right; + /* 0x4 */ u8 dpad_left; + u8 fill5[3]; + u16 unk8; + s16 unkA; +} MenuInputStructSub; + +// size: 0x34 +typedef struct MenuInputStruct +{ + s32 unk0; + u16 unk4; + s16 unk6; + s16 unk8; // Maybe Position + s16 unkA; + s16 unkC; // Maybe Position + s16 unkE; + u32 unk10; + s16 unk14; // Maybe Position + s16 unk16; + /* 0x18 */ s16 menuIndex; + s16 unk1A; + s16 unk1C; + s16 unk1E; + s16 unk20; + s16 unk22; + u16 unk24; + u16 unk26; + MenuInputStructSub unk28; +} MenuInputStruct; + // size: 0x8 typedef struct MenuItem { diff --git a/include/code_802C39C.h b/include/structs/str_802C39C.h similarity index 83% rename from include/code_802C39C.h rename to include/structs/str_802C39C.h index 0dc2053f1..c1c7f7a9b 100644 --- a/include/code_802C39C.h +++ b/include/structs/str_802C39C.h @@ -1,8 +1,7 @@ -#ifndef GUARD_CODE_802C39C_H -#define GUARD_CODE_802C39C_H +#ifndef GUARD_CODE_STR_802C39C_H +#define GUARD_CODE_STR_802C39C_H -#include "code_8094F88.h" -#include "wonder_mail.h" +#include "structs/str_wonder_mail.h" // size: 0x58 typedef struct unkStruct_802C39C @@ -30,4 +29,4 @@ typedef struct unkStruct_802C39C /* 0x54 */ WonderMail *mail; } unkStruct_802C39C; -#endif // GUARD_CODE_802C39C_H \ No newline at end of file +#endif // GUARD_CODE_STR_802C39C_H \ No newline at end of file diff --git a/include/structs/str_wonder_mail.h b/include/structs/str_wonder_mail.h new file mode 100644 index 000000000..fcf48db54 --- /dev/null +++ b/include/structs/str_wonder_mail.h @@ -0,0 +1,82 @@ +#ifndef GUARD_STR_WONDER_MAIL_H +#define GUARD_STR_WONDER_MAIL_H + +#include "constants/wonder_mail.h" +#include "structs/str_dungeon.h" +#include "structs/str_pokemon.h" + +// size: 0x8 +typedef struct WonderMailSub +{ + /* 0x0 */ DungeonLocation dungeon; + /* 0x4 */ u32 seed; +} WonderMailSub; + +// size: 0x14 +typedef struct WonderMail +{ + /* 0x0 */ u8 mailType; + /* 0x1 */ u8 missionType; + u8 unk2; + /* 0x4 */ WonderMailSub unk4; + /* 0xC */ s16 clientSpecies; + /* 0xE */ s16 targetSpecies; + /* 0x10 */ u8 targetItem; + /* 0x11 */ u8 rewardType; + /* 0x12 */ u8 itemReward; + /* 0x13 */ u8 friendAreaReward; +} WonderMail; + +// size: 0x28 +typedef struct unkStruct_802F204 +{ + /* 0x0 */ u8 clientName[POKEMON_NAME_LENGTH]; + /* 0xA */ u8 name2[POKEMON_NAME_LENGTH]; // target name? + /* 0x14 */ s16 clientSpecies; + u8 unk16; + /* 0x18 */ s32 moneyReward; + /* 0x1C */ u8 itemRewards[MAX_ITEM_REWARDS]; + /* 0x1F */ u8 quantity; + /* 0x20 */ u8 friendAreaReward; + /* 0x24 */ u32 teamRankPtsReward; +} unkStruct_802F204; + +// size: 0xB4 +typedef struct unkStruct_803B344 +{ + /* 0x0 */ WonderMail mail; + u8 *unk14; + u8 *unk18; + u8 fill1C[0x3C - 0x1C]; + u8 unk3C[0xB4 - 0x3C]; +} unkStruct_803B344; + +// size: 0x30 +typedef struct unkStruct_203B480 +{ + /* 0x0 */ u8 mailType; + /* 0x1 */ u8 missionType; + WonderMailSub unk4; + /* 0xC */ s16 clientSpecies; + /* 0xE */ s16 targetSpecies; + union unk10_temp + { + u32 unk10; + u16 unk10_u16; + } unk10; + /* 0x14 */ u8 playerName[0x20 - 0x14]; + Item item; + u32 unk24; + u32 unk28; + /* 0x2C */ s8 rescuesAllowed; + u8 unk2D; +} unkStruct_203B480; + +// size: 0x88 +typedef struct WonderMailStruct_203B2C0_sub +{ + /* 0x0 */ unkStruct_203B480 mail; + /* 0x30 */ PokemonStruct1 pokemon; +} WonderMailStruct_203B2C0_sub; + +#endif // GUARD_STR_WONDER_MAIL_H \ No newline at end of file diff --git a/include/thank_you_wonder_mail.h b/include/thank_you_wonder_mail.h new file mode 100644 index 000000000..e16fe78b9 --- /dev/null +++ b/include/thank_you_wonder_mail.h @@ -0,0 +1,42 @@ +#ifndef GUARD_THANK_YOU_WONDER_MAIL_H +#define GUARD_THANK_YOU_WONDER_MAIL_H + +#include "constants/wonder_mail.h" +#include "file_system.h" +#include "structs/menu.h" +#include "structs/str_items.h" +#include "structs/str_text.h" +#include "structs/str_wonder_mail.h" + +// size: 0x564 +typedef struct WonderMailStruct_203B2C4 +{ + /* 0x0 */ u8 state; + /* 0x4 */ u32 fallbackState; // wonder mail link status?? + /* 0x8 */ u8 passwordBuffer[PASSWORD_BUFFER_SIZE]; // Probably a buffer for entry + u8 unk3E; + u32 unk40; + /* 0x44 */ u32 linkError; // another link status + u8 filler48[0x1B8 - 0x48]; + unkStruct_203B480 unk1B8; + unkStruct_203B480 unk1E8; + /* 0x218 */ s8 mailIndex; + MenuStruct unk21C[4]; + UnkTextStruct2 unk35C[4]; + UnkTextStruct2 unk3BC[4]; + Item unk41C; + /* 0x420 */ OpenedFile *faceFile; + /* 0x424 */ u8 *faceData; + u16 unk428; + u16 unk42A; + u8 unk42C; + u8 unk42D; + u8 unk42E; + u32 unk430; + /* 0x434 */ u8 formattedString[0x100]; + /* 0x534 */ s32 wonderMailMethod; + /* 0x538 */ u32 wonderMailMode; + unkStruct_802F204 unk53C; +} WonderMailStruct_203B2C4; + +#endif // GUARD_THANK_YOU_WONDER_MAIL_H \ No newline at end of file diff --git a/include/wigglytuff_shop2.h b/include/wigglytuff_shop2.h index 68a73faa8..51e2790ab 100644 --- a/include/wigglytuff_shop2.h +++ b/include/wigglytuff_shop2.h @@ -1,7 +1,7 @@ #ifndef GUARD_WIGGLYTUFF_SHOP2_H #define GUARD_WIGGLYTUFF_SHOP2_H -#include "input.h" +#include "structs/menu.h" #include "structs/str_text.h" typedef struct WigglytuffShop2Work diff --git a/include/wonder_mail.h b/include/wonder_mail.h index 467fd9470..e821bb0fb 100644 --- a/include/wonder_mail.h +++ b/include/wonder_mail.h @@ -1,49 +1,10 @@ #ifndef GUARD_WONDER_MAIL_H #define GUARD_WONDER_MAIL_H -#include "code_8094F88.h" #include "constants/wonder_mail.h" #include "file_system.h" -#include "items.h" #include "structs/menu.h" -#include "pokemon.h" -#include "structs/str_text.h" - -// size: 0x28 -typedef struct unkStruct_802F204 -{ - /* 0x0 */ u8 clientName[POKEMON_NAME_LENGTH]; - /* 0xA */ u8 name2[POKEMON_NAME_LENGTH]; // target name? - /* 0x14 */ s16 clientSpecies; - u8 unk16; - /* 0x18 */ s32 moneyReward; - /* 0x1C */ u8 itemRewards[MAX_ITEM_REWARDS]; - /* 0x1F */ u8 quantity; - /* 0x20 */ u8 friendAreaReward; - /* 0x24 */ u32 teamRankPtsReward; -} unkStruct_802F204; - -// size: 0x14 -typedef struct WonderMail -{ - /* 0x0 */ u8 mailType; // mail type - /* 0x1 */ u8 missionType; // mission type - u8 unk2; - /* 0x4 */ WonderMailSub unk4; - /* 0xC */ s16 clientSpecies; // client pokemon - /* 0xE */ s16 targetSpecies; // target - /* 0x10 */ u8 targetItem; // item to find/deliver - /* 0x11 */ u8 rewardType; // reward type - /* 0x12 */ u8 itemReward; // item reward - /* 0x13 */ u8 friendAreaReward; // friend area -} WonderMail; - -// size: 0x88 -typedef struct WonderMailStruct_203B2C0_sub -{ - /* 0x0 */ unkStruct_203B480 mail; - /* 0x30 */ PokemonStruct1 pokemon; -} WonderMailStruct_203B2C0_sub; +#include "structs/str_wonder_mail.h" // size: 0x548 typedef struct WonderMailStruct_203B2C0 @@ -79,37 +40,4 @@ typedef struct WonderMailStruct_203B2C0 /* 0x544 */ s16 speciesNum; } WonderMailStruct_203B2C0; -// size: 0x564 -typedef struct WonderMailStruct_203B2C4 -{ - /* 0x0 */ u8 state; - /* 0x4 */ u32 fallbackState; // wonder mail link status?? - /* 0x8 */ u8 passwordBuffer[PASSWORD_BUFFER_SIZE]; // Probably a buffer for entry - u8 unk3E; - u32 unk40; - /* 0x44 */ u32 linkError; // another link status - u8 filler48[0x1B8 - 0x48]; - unkStruct_203B480 unk1B8; - unkStruct_203B480 unk1E8; - /* 0x218 */ s8 mailIndex; - MenuStruct unk21C[4]; - UnkTextStruct2 unk35C[4]; - UnkTextStruct2 unk3BC[4]; - Item unk41C; - /* 0x420 */ OpenedFile *faceFile; - /* 0x424 */ u8 *faceData; - u16 unk428; - u16 unk42A; - u8 unk42C; - u8 unk42D; - u8 unk42E; - u32 unk430; - /* 0x434 */ u8 formattedString[0x100]; - /* 0x534 */ s32 wonderMailMethod; - /* 0x538 */ u32 wonderMailMode; - unkStruct_802F204 unk53C; -} WonderMailStruct_203B2C4; - -void SetFriendRescueCounterState(u32 r0); - #endif // GUARD_WONDER_MAIL_H \ No newline at end of file diff --git a/include/wonder_mail_2_1.h b/include/wonder_mail_2_1.h deleted file mode 100644 index b7e27dda3..000000000 --- a/include/wonder_mail_2_1.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef GUARD_WONDER_MAIL_2_1_H -#define GUARD_WONDER_MAIL_2_1_H - -#include "code_802C39C.h" -#include "constants/mailbox.h" -#include "input.h" -#include "structs/menu.h" -#include "structs/str_text.h" - -// size: 0xA8 -struct unkStruct_203B2E8 -{ - u8 pelipperBoardSlots[MAX_ACCEPTED_JOBS]; - MenuInputStruct input; - u32 unk3C; - UnkTextStruct2 *unk40; - UnkTextStruct2 unk44[4]; - u8 unkA4[4]; -}; - -// size: 0x1FC -struct unkStruct_203B2F0 -{ - u32 unk0; - u32 state; - u8 unk8[0xC - 0x8]; - u8 unkC; - unkStruct_802C39C unk10; - u32 menuAction; - MenuStruct unk6C; - MenuStruct unkBC; - MenuItem unk10C[8]; - MenuItem unk14C[8]; - u8 fill18C[0x19C - 0x18C]; - UnkTextStruct2 unk19C[4]; -}; - -bool8 HasNoAcceptedJobs(void); -bool8 InitializeJobListMenu(u32); - -u32 sub_802C898(void); -void sub_802C8F4(void); - -#endif // GUARD_WONDER_MAIL_2_1_H \ No newline at end of file diff --git a/include/wonder_mail_3.h b/include/wonder_mail_3.h deleted file mode 100644 index 9ea7a9dd6..000000000 --- a/include/wonder_mail_3.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef GUARD_WONDER_MAIL_3_H -#define GUARD_WONDER_MAIL_3_H - -#include "code_802C39C.h" -#include "input.h" -#include "structs/menu.h" -#include "structs/str_text.h" -#include "wonder_mail.h" - -// size: 0xB4 -typedef struct unkStruct_803B344 -{ - /* 0x0 */ WonderMail mail; - u8 *unk14; - u8 *unk18; - u8 fill1C[0x3C - 0x1C]; - u8 unk3C[0xB4 - 0x3C]; -} unkStruct_803B344; - -// size: 0xA0 -typedef struct unkStruct_203B2F4 -{ - MenuInputStruct input; - u32 unk34; - UnkTextStruct2 *unk38; - UnkTextStruct2 unk3C[4]; - u8 unk9C[4]; -} unkStruct_203B2F4; - -// size: 0x1C -typedef struct unkSubStruct_203B2F8 -{ - /* 0x0 */ WonderMail wonderMail; - /* 0x14 */ u8 *unk14; - /* 0x18 */ u8 *unk18; -} unkSubStruct_203B2F8; - -// size: 0x208 -typedef struct unkStruct_203B2F8 -{ - /* 0x0 */ s32 state; - /* 0x4 */ s32 fallbackState; - /* 0x8 */ u8 wonderMailAccepted; - /* 0x9 */ bool8 unk9; - /* 0xA */ u8 dungeonID; - u8 unkB; - /* 0xC */ unkSubStruct_203B2F8 *mail; - /* 0x10 */ u8 jobSlotIndex; - unkStruct_802C39C unk14; - /* 0x6C */ u32 menuAction1; - /* 0x70 */ u32 menuAction2; - /* 0x74 */ u32 menuAction3; - /* 0x78 */ MenuStruct unk78; - /* 0xC8 */ MenuStruct unkC8; - MenuItem unk118[8]; - MenuItem unk158[8]; - u16 unk198[8]; - UnkTextStruct2 unk1A8[4]; -} unkStruct_203B2F8; - -enum WonderMailRescueStates -{ - INITIAL_WONDER_MAIL_CHECK = 0, - // 1 - WONDER_MAIL_EXIT = 2, - DUPLICATE_WONDER_MAIL, - DUPLICATE_WONDER_MAIL_1, - // 5 - 7 - RECEIVE_WONDER_MAIL = 8, - // 9 - JOB_LIST_FULL = 10, - DRAW_JOB_LIST, - DRAW_JOB_LIST_1, - // 13 - 16 -}; - -u32 sub_802D098(unkSubStruct_203B2F8 *mail); - -#endif // GUARD_WONDER_MAIL_3_H \ No newline at end of file diff --git a/include/wonder_mail_802C10C.h b/include/wonder_mail_802C10C.h index 538af7361..dd5606f2b 100644 --- a/include/wonder_mail_802C10C.h +++ b/include/wonder_mail_802C10C.h @@ -2,7 +2,7 @@ #define GUARD_WONDER_MAIL_802C10C_H #include "constants/mailbox.h" -#include "input.h" +#include "structs/menu.h" #include "structs/str_text.h" // size: 0xA8 diff --git a/include/wonder_mail_802C4C8.h b/include/wonder_mail_802C4C8.h new file mode 100644 index 000000000..9c3df04fe --- /dev/null +++ b/include/wonder_mail_802C4C8.h @@ -0,0 +1,28 @@ +#ifndef GUARD_WONDER_MAIL_802C4C8_H +#define GUARD_WONDER_MAIL_802C4C8_H + +#include "constants/mailbox.h" +#include "structs/menu.h" +#include "structs/str_text.h" + +// size: 0xA8 +struct unkStruct_203B2E8 +{ + /* 0x0 */ u8 pelipperBoardSlots[MAX_ACCEPTED_JOBS]; + /* 0x8 */ MenuInputStruct input; + u32 unk3C; + UnkTextStruct2 *unk40; + UnkTextStruct2 unk44[4]; + u8 unkA4[4]; +}; + +void DrawJobListMenu(void); +bool8 HasNoAcceptedJobs(void); +u8 GetPelipperBoardSlotIndex(void); + +bool8 sub_802C4C8(s32, UnkTextStruct2_sub *, u32); +u32 sub_802C598(bool8); +void sub_802C640(bool8 cursorSprite); +void sub_802C688(void); + +#endif // GUARD_WONDER_MAIL_802C4C8_H \ No newline at end of file diff --git a/include/wonder_mail_802C860.h b/include/wonder_mail_802C860.h new file mode 100644 index 000000000..572ad8420 --- /dev/null +++ b/include/wonder_mail_802C860.h @@ -0,0 +1,30 @@ +#ifndef GUARD_WONDER_MAIL_802C860_H +#define GUARD_WONDER_MAIL_802C860_H + +#include "structs/str_802C39C.h" +#include "structs/menu.h" +#include "structs/str_text.h" + +// size: 0x1FC +struct unkStruct_203B2F0 +{ + u32 unk0; + /* 0x4 */ u32 state; + u8 unk8[0xC - 0x8]; + u8 unkC; + unkStruct_802C39C unk10; + /* 0x68 */ u32 menuAction; + MenuStruct unk6C; + MenuStruct unkBC; + MenuItem unk10C[8]; + MenuItem unk14C[8]; + u8 fill18C[0x19C - 0x18C]; + UnkTextStruct2 unk19C[4]; +}; + +bool8 InitializeJobListMenu(u32); + +u32 sub_802C898(void); +void sub_802C8F4(void); + +#endif // GUARD_WONDER_MAIL_802C860_H \ No newline at end of file diff --git a/include/wonder_mail_802CDD4.h b/include/wonder_mail_802CDD4.h new file mode 100644 index 000000000..2c00d71d8 --- /dev/null +++ b/include/wonder_mail_802CDD4.h @@ -0,0 +1,24 @@ +#ifndef GUARD_WONDER_MAIL_802CDD4_H +#define GUARD_WONDER_MAIL_802CDD4_H + +#include "structs/menu.h" +#include "structs/str_text.h" + +// size: 0xA0 +typedef struct unkStruct_203B2F4 +{ + MenuInputStruct input; + u32 unk34; + UnkTextStruct2 *unk38; + UnkTextStruct2 unk3C[4]; + u8 unk9C[4]; +} unkStruct_203B2F4; + +bool8 sub_802CDD4(u32); +u32 sub_802CE5C(bool8); +u8 sub_802CEBC(void); +void sub_802CED8(bool8 cursorSprite); +void sub_802CF14(void); +void sub_802CFD0(void); + +#endif // GUARD_WONDER_MAIL_802CDD4_H \ No newline at end of file diff --git a/include/wonder_mail_802D098.h b/include/wonder_mail_802D098.h new file mode 100644 index 000000000..182128537 --- /dev/null +++ b/include/wonder_mail_802D098.h @@ -0,0 +1,46 @@ +#ifndef GUARD_WONDER_MAIL_802D098_H +#define GUARD_WONDER_MAIL_802D098_H + +#include "structs/str_802C39C.h" +#include "structs/menu.h" +#include "structs/str_text.h" +#include "structs/str_wonder_mail.h" + +// size: 0x1C +typedef struct unkSubStruct_203B2F8 +{ + /* 0x0 */ WonderMail wonderMail; + u8 *unk14; + u8 *unk18; +} unkSubStruct_203B2F8; + +// size: 0x208 +typedef struct unkStruct_203B2F8 +{ + /* 0x0 */ s32 state; + /* 0x4 */ s32 fallbackState; + /* 0x8 */ u8 wonderMailAccepted; + bool8 unk9; + /* 0xA */ u8 dungeonID; + u8 unkB; + /* 0xC */ unkSubStruct_203B2F8 *mail; + /* 0x10 */ u8 jobSlotIndex; + unkStruct_802C39C unk14; + /* 0x6C */ u32 menuAction1; + /* 0x70 */ u32 menuAction2; + /* 0x74 */ u32 menuAction3; + MenuStruct unk78; + MenuStruct unkC8; + MenuItem unk118[8]; + MenuItem unk158[8]; + u16 unk198[8]; + UnkTextStruct2 unk1A8[4]; +} unkStruct_203B2F8; + +bool8 GetWonderMailAccepted(void); + +bool8 sub_802D098(unkSubStruct_203B2F8 *mail); +u32 sub_802D0E0(void); +void sub_802D184(void); + +#endif // GUARD_WONDER_MAIL_802D098_H \ No newline at end of file diff --git a/ld_script.txt b/ld_script.txt index e4c3670b7..a1491dd9a 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -141,8 +141,10 @@ SECTIONS { src/pokemon_news2.o(.text); src/pokemon_news3.o(.text); src/wonder_mail_802C10C.o(.text); - src/wonder_mail_2_1.o(.text); - src/wonder_mail_3.o(.text); + src/wonder_mail_802C4C8.o(.text); + src/wonder_mail_802C860.o(.text); + src/wonder_mail_802CDD4.o(.text); + src/wonder_mail_802D098.o(.text); src/code_802DB28.o(.text); src/code_802DE84.o(.text); src/mailbox.o(.text); @@ -461,8 +463,10 @@ SECTIONS { src/pokemon_news2.o(.rodata); src/pokemon_news3.o(.rodata); src/wonder_mail_802C10C.o(.rodata); - src/wonder_mail_2_1.o(.rodata); - src/wonder_mail_3.o(.rodata); + src/wonder_mail_802C4C8.o(.rodata); + src/wonder_mail_802C860.o(.rodata); + src/wonder_mail_802CDD4.o(.rodata); + src/wonder_mail_802D098.o(.rodata); src/code_802DB28.o(.rodata); src/code_802DE84.o(.rodata); src/mailbox.o(.rodata); diff --git a/src/adventure_log.c b/src/adventure_log.c index 52cc608b4..ae9fe8aec 100644 --- a/src/adventure_log.c +++ b/src/adventure_log.c @@ -4,6 +4,7 @@ #include "code_80130A8.h" #include "code_8097670.h" #include "constants/input.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "text1.h" diff --git a/src/bg_control.c b/src/bg_control.c index be665382d..77bf4c7f6 100644 --- a/src/bg_control.c +++ b/src/bg_control.c @@ -1,6 +1,5 @@ #include "global.h" #include "bg_control.h" -#include "input.h" EWRAM_DATA BGControlStruct gBG0Control = {0}; EWRAM_DATA BGControlStruct gBG1Control = {0}; diff --git a/src/code_2.c b/src/code_2.c index db574aaca..2ed16fd56 100644 --- a/src/code_2.c +++ b/src/code_2.c @@ -17,7 +17,6 @@ #include "file_system.h" #include "friend_area.h" #include "game_options.h" -#include "input.h" #include "main_menu1.h" #include "main_menu2.h" #include "memory.h" diff --git a/src/code_800C9CC.c b/src/code_800C9CC.c index 562c0080a..1216320bb 100644 --- a/src/code_800C9CC.c +++ b/src/code_800C9CC.c @@ -1,6 +1,5 @@ #include "global.h" #include "code_800C9CC.h" -#include "input.h" #include "random.h" #include "reg_control.h" diff --git a/src/code_80118A4.c b/src/code_80118A4.c index 34abab9d8..475acf55e 100644 --- a/src/code_80118A4.c +++ b/src/code_80118A4.c @@ -11,7 +11,6 @@ #include "constants/bg_music.h" #include "play_time.h" #include "bg_control.h" -#include "input.h" #include "config.h" #include "game_options.h" #include "sprite.h" diff --git a/src/code_8012A18.c b/src/code_8012A18.c index 1db9fd69f..50f3e28df 100644 --- a/src/code_8012A18.c +++ b/src/code_8012A18.c @@ -6,7 +6,6 @@ #include "code_80118A4.h" #include "code_80130A8.h" #include "game_options.h" -#include "input.h" #include "sprite.h" extern void nullsub_8(u8); diff --git a/src/code_801602C.c b/src/code_801602C.c index 1bc00f44e..6b70e55e9 100644 --- a/src/code_801602C.c +++ b/src/code_801602C.c @@ -3,6 +3,7 @@ #include "code_80130A8.h" #include "code_801602C.h" #include "common_strings.h" +#include "input.h" #include "memory.h" #include "text_util.h" #include "text1.h" diff --git a/src/code_801B3C0.c b/src/code_801B3C0.c index 878db80b4..74d321c65 100644 --- a/src/code_801B3C0.c +++ b/src/code_801B3C0.c @@ -2,6 +2,7 @@ #include "code_80118A4.h" #include "code_80130A8.h" #include "code_801B3C0.h" +#include "input.h" #include "items.h" #include "memory.h" #include "menu_input.h" diff --git a/src/code_801B60C.c b/src/code_801B60C.c index ab906ebed..bd1c30c42 100644 --- a/src/code_801B60C.c +++ b/src/code_801B60C.c @@ -6,6 +6,7 @@ #include "code_8098BDC.h" #include "common_strings.h" #include "constants/colors.h" +#include "input.h" #include "items.h" #include "kecleon_bros4.h" #include "memory.h" diff --git a/src/code_801BEEC.c b/src/code_801BEEC.c index 9d9f99233..d292a9ae8 100644 --- a/src/code_801BEEC.c +++ b/src/code_801BEEC.c @@ -4,6 +4,7 @@ #include "code_801C244.h" #include "code_801C620.h" #include "common_strings.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "pokemon_3.h" diff --git a/src/code_801C244.c b/src/code_801C244.c index 4ef9fe4bb..012555c0a 100644 --- a/src/code_801C244.c +++ b/src/code_801C244.c @@ -2,6 +2,7 @@ #include "code_80118A4.h" #include "code_80130A8.h" #include "code_801C244.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "pokemon_3.h" diff --git a/src/code_801C620.c b/src/code_801C620.c index 8f105ecf0..2bd24e7d2 100644 --- a/src/code_801C620.c +++ b/src/code_801C620.c @@ -3,6 +3,7 @@ #include "code_80130A8.h" #include "code_801C620.h" #include "code_8097DD0.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "pokemon_3.h" diff --git a/src/code_801C8C4.c b/src/code_801C8C4.c index 5f8deebef..e385f0f2c 100644 --- a/src/code_801C8C4.c +++ b/src/code_801C8C4.c @@ -1,6 +1,7 @@ #include "global.h" #include "code_80118A4.h" #include "code_801C8C4.h" +#include "input.h" #include "items.h" #include "memory.h" #include "menu_input.h" diff --git a/src/code_801D014.c b/src/code_801D014.c index 6d46daf2e..47467a646 100644 --- a/src/code_801D014.c +++ b/src/code_801D014.c @@ -17,6 +17,7 @@ #include "ground_lives.h" #include "ground_main.h" #include "ground_map_1.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "options_menu1.h" @@ -25,7 +26,8 @@ #include "text1.h" #include "text2.h" #include "wigglytuff_shop2.h" -#include "wonder_mail_2_1.h" +#include "wonder_mail_802C4C8.h" +#include "wonder_mail_802C860.h" extern u8 gAvailablePokemonNames[]; // 202DF98 diff --git a/src/code_801D9E4.c b/src/code_801D9E4.c index e3ab6b38a..ea72611da 100644 --- a/src/code_801D9E4.c +++ b/src/code_801D9E4.c @@ -3,6 +3,7 @@ #include "code_801D9E4.h" #include "constants/input.h" #include "ground_main.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "text1.h" diff --git a/src/code_801EE10.c b/src/code_801EE10.c index 00f8881da..92a14e6bc 100644 --- a/src/code_801EE10.c +++ b/src/code_801EE10.c @@ -1,4 +1,5 @@ #include "global.h" +#include "input.h" #include "text1.h" #include "text2.h" #include "memory.h" diff --git a/src/code_801EE10_mid.c b/src/code_801EE10_mid.c index a90c4dbb5..be1d62bd5 100644 --- a/src/code_801EE10_mid.c +++ b/src/code_801EE10_mid.c @@ -12,6 +12,7 @@ #include "code_80130A8.h" #include "code_801EE10_mid.h" #include "code_80118A4.h" +#include "input.h" extern unkStruct_203B270 *gUnknown_203B270; diff --git a/src/code_80227B8.c b/src/code_80227B8.c index ebdc1628e..ac1e5acff 100644 --- a/src/code_80227B8.c +++ b/src/code_80227B8.c @@ -6,6 +6,7 @@ #include "code_8098BDC.h" #include "common_strings.h" #include "constants/colors.h" +#include "input.h" #include "kecleon_bros4.h" #include "memory.h" #include "menu_input.h" diff --git a/src/code_8023144.c b/src/code_8023144.c index 831bd8733..9b4e29504 100644 --- a/src/code_8023144.c +++ b/src/code_8023144.c @@ -6,6 +6,7 @@ #include "constants/input.h" #include "exclusive_pokemon.h" #include "friend_area.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "pokemon_3.h" diff --git a/src/code_8024458.c b/src/code_8024458.c index 59ed7c2a5..36b0e0f95 100644 --- a/src/code_8024458.c +++ b/src/code_8024458.c @@ -3,6 +3,7 @@ #include "code_8024458.h" #include "constants/input.h" #include "event_flag.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "pokemon.h" diff --git a/src/code_802DB28.c b/src/code_802DB28.c index 4dfd4a6b4..d9c12cfb5 100644 --- a/src/code_802DB28.c +++ b/src/code_802DB28.c @@ -6,8 +6,10 @@ #include "code_80958E8_1.h" #include "code_8096AF8.h" #include "exclusive_pokemon.h" +#include "input.h" #include "items.h" #include "memory.h" +#include "pokemon.h" #include "text1.h" #include "text2.h" diff --git a/src/code_802DE84.c b/src/code_802DE84.c index 3f3b47dd1..66faec3ec 100644 --- a/src/code_802DE84.c +++ b/src/code_802DE84.c @@ -2,6 +2,7 @@ #include "code_80118A4.h" #include "code_802DE84.h" #include "code_803B050.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "text1.h" diff --git a/src/code_803B050.c b/src/code_803B050.c index 55a7d0df3..41dabb4b2 100644 --- a/src/code_803B050.c +++ b/src/code_803B050.c @@ -12,7 +12,6 @@ #include "text2.h" #include "code_800D090.h" #include "menu_input.h" -#include "wonder_mail.h" #include "dungeon.h" // This file was originally 7 files. Check data_80E7D40.s diff --git a/src/code_8040094.c b/src/code_8040094.c index 9e53e91be..85657d9ba 100644 --- a/src/code_8040094.c +++ b/src/code_8040094.c @@ -8,7 +8,6 @@ #include "dungeon_map_access.h" #include "dungeon_music.h" #include "file_system.h" -#include "input.h" #include "play_time.h" extern s32 gUnknown_80F6568[]; diff --git a/src/code_80958E8.c b/src/code_80958E8.c index ed72436ec..0adeb9811 100644 --- a/src/code_80958E8.c +++ b/src/code_80958E8.c @@ -3,10 +3,10 @@ #include "items.h" #include "friend_area.h" #include "constants/friend_area.h" -#include "wonder_mail.h" #include "constants/wonder_mail.h" #include "dungeon.h" #include "code_80958E8.h" +#include "code_80958E8_1.h" #include "pokemon.h" #include "pokemon_3.h" #include "code_8094F88.h" @@ -16,7 +16,6 @@ extern bool8 sub_809017C(DungeonLocation *); extern u8 sub_803C1D0(DungeonLocation *, u8); extern bool8 sub_803C0DC(s16); extern void ResetPelipperBoardSlot(u8); -extern void ResetJobSlot(u8); extern bool8 ValidateWonderMail(WonderMail *); static EWRAM_DATA unkStruct_203B490 sUnknown_2039448 = {0}; diff --git a/src/code_80958E8_1.c b/src/code_80958E8_1.c index c5125ad6b..8410815b2 100644 --- a/src/code_80958E8_1.c +++ b/src/code_80958E8_1.c @@ -8,13 +8,10 @@ #include "code_80958E8_1.h" #include "random.h" #include "pokemon.h" +#include "code_8096AF8.h" -extern u8 IsJobSlotEmpty(u8); extern bool8 IsValidWonderMail(WonderMail *WonderMailData); extern u8 sub_8095E38(WonderMail *, u8, u8, bool8); -extern void ResetJobSlot(u8); -extern void sub_8096C80(void); -extern void sub_8096D24(void); extern void sub_80965F4(); extern void SortPelipperJobs(); u8 sub_8097318(s16 param_1); diff --git a/src/code_80972F4.c b/src/code_80972F4.c index 0fe55f8f0..1a57ea86c 100644 --- a/src/code_80972F4.c +++ b/src/code_80972F4.c @@ -1,7 +1,6 @@ #include "global.h" #include "constants/dungeon.h" #include "pokemon.h" -#include "wonder_mail.h" #include "code_80958E8.h" #include "dungeon.h" #include "exclusive_pokemon.h" @@ -269,12 +268,12 @@ bool32 sub_80973F4(s16 param_1) return val; } -void sub_8097418(s16 index,u32 param_2) +void sub_8097418(s16 index,bool32 param_2) { int index_s32 = index; - u8 param_2_u8 = param_2; + bool8 param_2_u8 = param_2; if (index_s32 != 0xd) { - if ((param_2_u8 != 0) && (sub_800199C(0,0x2c,index_s32,0), index_s32 < 0x1f)) { + if ((param_2_u8) && (sub_800199C(0,0x2c,index_s32,0), index_s32 < 0x1f)) { MissionText *mt = &gStoryMissionText[index_s32]; if (mt->unk4 != 0xFF) { sub_8097FA8(mt->unk4); diff --git a/src/data/wonder_mail_802C4C8.h b/src/data/wonder_mail_802C4C8.h new file mode 100644 index 000000000..0103d14ae --- /dev/null +++ b/src/data/wonder_mail_802C4C8.h @@ -0,0 +1,21 @@ +ALIGNED(4) static const u8 sFill[] = _("pksdir0"); + +static const UnkTextStruct2 sUnknown_80DFCE4 = { + 0, 0, 0, 0, + 3, + 0, 0, + 0, 0, + 0, 0, + NULL +}; + +static const UnkTextStruct2 sUnknown_80DFCFC = { + 0, 0, 0, 0, + 6, + 2, 2, + 24, 14, + 14, 0, + NULL +}; + +ALIGNED(4) static const u8 sJobList[] = _("Job List"); \ No newline at end of file diff --git a/src/data/wonder_mail_802C860.h b/src/data/wonder_mail_802C860.h new file mode 100644 index 000000000..4a5873273 --- /dev/null +++ b/src/data/wonder_mail_802C860.h @@ -0,0 +1,31 @@ +ALIGNED(4) static const u8 sFill[] = _("pksdir0"); + +static const UnkTextStruct2 sUnknown_80DFD28 = { + 0, 0, 0, 0, + 3, + 0, 0, + 0, 0, + 0, 0, + NULL +}; + +static const UnkTextStruct2 sUnknown_80DFD40 = { + 0, 0, 0, 0, + 4, + 21, 6, + 7, 3, + 3, 0, + NULL +}; + +static const UnkTextStruct2 sUnknown_80DFD58 = { + 0, 0, 0, 0, + 4, + 21, 15, + 6, 3, + 3, 0, + NULL +}; + +ALIGNED(4) static const u8 sTakeJob[] = _("Take Job"); +ALIGNED(4) static const u8 sSuspend[] = _("Suspend"); \ No newline at end of file diff --git a/src/data/wonder_mail_802CDD4.h b/src/data/wonder_mail_802CDD4.h new file mode 100644 index 000000000..9868d43e2 --- /dev/null +++ b/src/data/wonder_mail_802CDD4.h @@ -0,0 +1,21 @@ +ALIGNED(4) static const u8 sFill[] = _("pksdir0"); + +static const UnkTextStruct2 sUnknown_80DFD8C = { + 0, 0, 0, 0, + 3, + 0, 0, + 0, 0, + 0, 0, + NULL +}; + +static const UnkTextStruct2 sUnknown_80DFDA4 = { + 0, 0, 0, 0, + 6, + 2, 2, + 24, 14, + 14, 0, + NULL +}; + +ALIGNED(4) static const u8 sRescueEvent[] = _("RESCUE EVENT"); \ No newline at end of file diff --git a/src/data/wonder_mail_802D098.h b/src/data/wonder_mail_802D098.h new file mode 100644 index 000000000..1bfdf8e1f --- /dev/null +++ b/src/data/wonder_mail_802D098.h @@ -0,0 +1,88 @@ +ALIGNED(4) static const u8 sFill[] = _("pksdir0"); + +static const UnkTextStruct2 sUnknown_80DFDD4 = { + 0, 0, 0, 0, + 3, + 0, 0, + 0, 0, + 0, 0, + NULL +}; + +UNUSED static const UnkTextStruct2 sUnknown_80DFDEC = { + 0, 0, 0, 0, + 3, + 3, 3, + 7, 3, + 3, 0, + NULL +}; + +static const UnkTextStruct2 sUnknown_80DFE04 = { + 0, 0, 0, 0, + 3, + 21, 6, + 7, 3, + 3, 0, + NULL +}; + +static const UnkTextStruct2 sUnknown_80DFE1C = { + 0, 0, 0, 0, + 3, + 21, 15, + 7, 3, + 3, 0, + NULL +}; + +UNUSED static const UnkTextStruct2 sUnknown_80DFE34 = { + 0, 0, 0, 0, + 3, + 21, 15, + 6, 3, + 3, 0, + NULL +}; + +ALIGNED(4) static const u8 sReplaceOldMailPrompt[] = _( + "Are you sure you want to replace the\n" + "old {COLOR_1 LIGHT_BLUE}Wonder Mail{END_COLOR_TEXT_1} with the new one?"); + +ALIGNED(4) static const u8 sMailAlreadyReceived[] = _( + "This {COLOR_1 LIGHT_BLUE}Wonder Mail{END_COLOR_TEXT_1} has already been\n" + "received."); + +ALIGNED(4) static const u8 sMailAlreadyReceivedMayNotReceiveAgain[] = _( + "This {COLOR_1 LIGHT_BLUE}Wonder Mail{END_COLOR_TEXT_1} has already been\n" + "received.\n" + "You may not receive the same one again."); + +ALIGNED(4) static const u8 sOnlyOneMailCanBeHeldPleaseCompleteFirst[] = _( + "Only {COLOR_1 LIGHT_BLUE}one piece{END_COLOR_TEXT_1} of {COLOR_1 LIGHT_BLUE}Wonder Mail{END_COLOR_TEXT_1} can be held.\n" + "Please receive it after completing any\n" + "rescue mission in progress."); + +ALIGNED(4) static const u8 sTeamQuicksavedCompleteFirst[] = _( + "The rescue team has quicksaved in\n" + "a dungeon with a mission in progress.\n" + "Please complete the mission first."); + +ALIGNED(4) static const u8 sTeamQuicksavedCannotDelete[] = _( + "The rescue team has quicksaved in\n" + "a dungeon with a mission in progress.\n" + "Mail cannot be deleted now."); + +ALIGNED(4) static const u8 sReceivedWonderMail[] = _("Received the {COLOR_1 LIGHT_BLUE}Wonder Mail{END_COLOR_TEXT_1}!"); + +ALIGNED(4) static const u8 sOnlyOneMailCanBeHeldSoReplacePrompt[] = _( + "Only {COLOR_1 LIGHT_BLUE}one piece{END_COLOR_TEXT_1} of {COLOR_1 LIGHT_BLUE}Wonder Mail{END_COLOR_TEXT_1} can be held.\n" + "Is it OK to replace the old {COLOR_1 LIGHT_BLUE}Wonder Mail{END_COLOR_TEXT_1}\n" + "with the new one?"); + +ALIGNED(4) static const u8 sJobListFullPleaseDelete[] = _( + "Your {COLOR_1 LIGHT_BLUE}Job List{END_COLOR_TEXT_1} is full.\n" + "Please select and delete unwanted mail."); + +ALIGNED(4) static const u8 sNewMail[] = _("New Mail"); +ALIGNED(4) static const u8 sOldMail[] = _("Old Mail"); \ No newline at end of file diff --git a/src/debug_menu1.c b/src/debug_menu1.c index bc735f4a7..a2db5d945 100644 --- a/src/debug_menu1.c +++ b/src/debug_menu1.c @@ -4,6 +4,7 @@ #include "constants/main_menu.h" #include "debug_menu1.h" #include "friend_area.h" +#include "input.h" #include "main_menu1.h" #include "memory.h" #include "menu_input.h" diff --git a/src/debug_menu2.c b/src/debug_menu2.c index fec7a2e9f..aa603300d 100644 --- a/src/debug_menu2.c +++ b/src/debug_menu2.c @@ -4,6 +4,7 @@ #include "code_801C8C4.h" #include "common_strings.h" #include "debug_menu2.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "text1.h" diff --git a/src/debug_menu3.c b/src/debug_menu3.c index 1e6859a25..cffd9d6a1 100644 --- a/src/debug_menu3.c +++ b/src/debug_menu3.c @@ -3,6 +3,7 @@ #include "common_strings.h" #include "debug_menu3.h" #include "friend_area.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "pokemon.h" diff --git a/src/debug_menu4.c b/src/debug_menu4.c index f307074b5..561d66c3f 100644 --- a/src/debug_menu4.c +++ b/src/debug_menu4.c @@ -3,6 +3,7 @@ #include "code_801602C.h" #include "code_8023868.h" #include "debug_menu4.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "text1.h" diff --git a/src/event_flag.c b/src/event_flag.c index 5f7738306..11734ce91 100644 --- a/src/event_flag.c +++ b/src/event_flag.c @@ -45,7 +45,6 @@ extern u8 gUnknown_80B7388[]; void FatalError(DebugLocation *, const char *, ...) __attribute__((noreturn)); extern bool8 HasCompletedAllMazes(void); -extern void sub_8097418(u32, u32); extern void sub_800160C(struct UnkEventStruct *r0, u32 r1, u32 r2); extern u8 sub_8002658(s16); extern void sub_80018D8(u32, u32, u32); diff --git a/src/felicity_bank.c b/src/felicity_bank.c index 4388c5794..bcfd661c6 100644 --- a/src/felicity_bank.c +++ b/src/felicity_bank.c @@ -3,6 +3,7 @@ #include "code_80130A8.h" #include "common_strings.h" #include "felicity_bank.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "pokemon.h" diff --git a/src/friend_area_action_menu.c b/src/friend_area_action_menu.c index 08cc76b55..ded576cdf 100644 --- a/src/friend_area_action_menu.c +++ b/src/friend_area_action_menu.c @@ -11,6 +11,7 @@ #include "constants/dungeon.h" #include "event_flag.h" #include "friend_area_action_menu.h" +#include "input.h" #include "items.h" #include "kecleon_bros4.h" #include "memory.h" diff --git a/src/friend_list_menu.c b/src/friend_list_menu.c index 348922289..9462cd37d 100644 --- a/src/friend_list_menu.c +++ b/src/friend_list_menu.c @@ -13,6 +13,7 @@ #include "constants/dungeon.h" #include "event_flag.h" #include "ground_map_1.h" +#include "input.h" #include "items.h" #include "kecleon_bros4.h" #include "memory.h" diff --git a/src/ground_main.c b/src/ground_main.c index 16275e998..8ef714d9c 100644 --- a/src/ground_main.c +++ b/src/ground_main.c @@ -7,7 +7,6 @@ #include "event_flag.h" #include "ground_main.h" #include "ground_map_2.h" -#include "input.h" #include "play_time.h" EWRAM_DATA u32 gUnknown_20398A8 = {0}; diff --git a/src/gulpin_shop.c b/src/gulpin_shop.c index 481700205..91ea240cd 100644 --- a/src/gulpin_shop.c +++ b/src/gulpin_shop.c @@ -5,6 +5,7 @@ #include "code_80130A8.h" #include "common_strings.h" #include "gulpin_shop.h" +#include "input.h" #include "pokemon.h" #include "memory.h" #include "menu_input.h" diff --git a/src/gulpin_shop_801FB50.c b/src/gulpin_shop_801FB50.c index f3994a857..d8489dfa3 100644 --- a/src/gulpin_shop_801FB50.c +++ b/src/gulpin_shop_801FB50.c @@ -10,6 +10,7 @@ #include "felicity_bank.h" #include "gulpin_shop.h" #include "gulpin_shop_801FB50.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "moves.h" diff --git a/src/hints_menu1.c b/src/hints_menu1.c index beaa55de2..5153fa48e 100644 --- a/src/hints_menu1.c +++ b/src/hints_menu1.c @@ -2,6 +2,7 @@ #include "code_80118A4.h" #include "common_strings.h" #include "hints_menu1.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "text1.h" diff --git a/src/hints_menu2.c b/src/hints_menu2.c index 3efe8b018..7eb2e151f 100644 --- a/src/hints_menu2.c +++ b/src/hints_menu2.c @@ -2,6 +2,7 @@ #include "code_80118A4.h" #include "common_strings.h" #include "hints_menu2.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "text1.h" diff --git a/src/kangaskhan_storage1.c b/src/kangaskhan_storage1.c index e6db2592b..84173b1f5 100644 --- a/src/kangaskhan_storage1.c +++ b/src/kangaskhan_storage1.c @@ -4,6 +4,7 @@ #include "code_801C8C4.h" #include "code_8098BDC.h" #include "common_strings.h" +#include "input.h" #include "kangaskhan_storage1.h" #include "kecleon_bros4.h" #include "memory.h" diff --git a/src/kangaskhan_storage2.c b/src/kangaskhan_storage2.c index cd5631bc4..a97164d0a 100644 --- a/src/kangaskhan_storage2.c +++ b/src/kangaskhan_storage2.c @@ -4,6 +4,7 @@ #include "code_801C8C4.h" #include "code_8098BDC.h" #include "common_strings.h" +#include "input.h" #include "kangaskhan_storage2.h" #include "kecleon_bros4.h" #include "memory.h" diff --git a/src/kecleon_bros1.c b/src/kecleon_bros1.c index 8f54aa6b7..970edcd2c 100644 --- a/src/kecleon_bros1.c +++ b/src/kecleon_bros1.c @@ -5,6 +5,7 @@ #include "code_8098BDC.h" #include "common_strings.h" #include "felicity_bank.h" +#include "input.h" #include "items.h" #include "kecleon_bros1.h" #include "kecleon_bros2.h" diff --git a/src/kecleon_bros2.c b/src/kecleon_bros2.c index 1aca68aaf..5d54bebc5 100644 --- a/src/kecleon_bros2.c +++ b/src/kecleon_bros2.c @@ -2,6 +2,7 @@ #include "code_800D090.h" #include "code_80118A4.h" #include "constants/input.h" +#include "input.h" #include "items.h" #include "kecleon_bros2.h" #include "memory.h" diff --git a/src/kecleon_bros3.c b/src/kecleon_bros3.c index eae57a0ae..e4eb0c16c 100644 --- a/src/kecleon_bros3.c +++ b/src/kecleon_bros3.c @@ -2,6 +2,7 @@ #include "code_800D090.h" #include "code_80118A4.h" #include "constants/input.h" +#include "input.h" #include "items.h" #include "kecleon_bros3.h" #include "memory.h" diff --git a/src/kecleon_bros4.c b/src/kecleon_bros4.c index eefd235df..a2580dc87 100644 --- a/src/kecleon_bros4.c +++ b/src/kecleon_bros4.c @@ -4,6 +4,7 @@ #include "code_80130A8.h" #include "code_8098BDC.h" #include "constants/input.h" +#include "input.h" #include "items.h" #include "kecleon_bros4.h" #include "memory.h" diff --git a/src/mailbox.c b/src/mailbox.c index 2a771bfb3..7a863ba1d 100644 --- a/src/mailbox.c +++ b/src/mailbox.c @@ -7,16 +7,17 @@ #include "structs/menu.h" #include "input.h" #include "mailbox.h" -#include "wonder_mail.h" #include "menu_input.h" #include "code_80118A4.h" -#include "wonder_mail_2_1.h" #include "pokemon_news1.h" #include "pokemon_news2.h" #include "pokemon_news3.h" #include "mailbox_8095F8C.h" #include "code_803B050.h" #include "code_80958E8_1.h" +#include "wonder_mail_802C4C8.h" +#include "wonder_mail_802C860.h" +#include "code_8096AF8.h" EWRAM_DATA_2 struct unkStruct_203B304 *gUnknown_203B304 = {0}; @@ -85,9 +86,6 @@ extern void sub_802E088(u32); extern void CreateMailboxMenu(void); extern void CreateMailActionMenu(void); extern void CreateMailAcceptedStatusBox(u32); -extern void AcceptJob(WonderMail *); -extern void sub_8096C80(void); -extern void sub_8096D24(void); extern void ReceivePKMNNews(u8); extern void sub_8096078(void); diff --git a/src/main_menu1.c b/src/main_menu1.c index 0ced9b756..f47134f02 100644 --- a/src/main_menu1.c +++ b/src/main_menu1.c @@ -7,6 +7,7 @@ #include "ds_menus.h" #include "friend_rescue.h" #include "game_options.h" +#include "input.h" #include "load_screen.h" #include "main_menu1.h" #include "main_menu2.h" diff --git a/src/main_menu2.c b/src/main_menu2.c index 578f9cc3e..2bc001b7a 100644 --- a/src/main_menu2.c +++ b/src/main_menu2.c @@ -2,6 +2,7 @@ #include "code_803D0D8.h" #include "constants/main_menu.h" #include "constants/wonder_mail.h" +#include "input.h" #include "main_menu1.h" #include "main_menu2.h" #include "memory.h" diff --git a/src/makuhita_dojo1.c b/src/makuhita_dojo1.c index 25285039c..d6990e08e 100644 --- a/src/makuhita_dojo1.c +++ b/src/makuhita_dojo1.c @@ -6,6 +6,7 @@ #include "common_strings.h" #include "constants/colors.h" #include "dungeon.h" +#include "input.h" #include "makuhita_dojo1.h" #include "makuhita_dojo2.h" #include "memory.h" diff --git a/src/makuhita_dojo2.c b/src/makuhita_dojo2.c index ff3416328..5ed76f593 100644 --- a/src/makuhita_dojo2.c +++ b/src/makuhita_dojo2.c @@ -6,6 +6,7 @@ #include "constants/colors.h" #include "constants/input.h" #include "dungeon.h" +#include "input.h" #include "makuhita_dojo2.h" #include "memory.h" #include "menu_input.h" diff --git a/src/menu_input.c b/src/menu_input.c index e18d91c0d..45152b9f8 100644 --- a/src/menu_input.c +++ b/src/menu_input.c @@ -5,6 +5,7 @@ #include "code_80130A8.h" #include "constants/colors.h" #include "constants/input.h" +#include "input.h" #include "menu_input.h" #include "sprite.h" #include "text_util.h" diff --git a/src/options_menu1.c b/src/options_menu1.c index d61fce4cc..d10f9cc9a 100644 --- a/src/options_menu1.c +++ b/src/options_menu1.c @@ -4,6 +4,7 @@ #include "common_strings.h" #include "hints_menu1.h" #include "hints_menu2.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "options_menu1.h" diff --git a/src/options_menu2.c b/src/options_menu2.c index c26517ca3..b48dea6a8 100644 --- a/src/options_menu2.c +++ b/src/options_menu2.c @@ -2,6 +2,7 @@ #include "code_80118A4.h" #include "constants/colors.h" #include "constants/input.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "options_menu2.h" diff --git a/src/other_menus2.c b/src/other_menus2.c index e75c3c29c..8fc98d5fe 100644 --- a/src/other_menus2.c +++ b/src/other_menus2.c @@ -2,13 +2,13 @@ #include "code_8094F88.h" #include "constants/communication_error_codes.h" #include "constants/dungeon.h" -#include "structs/str_dungeon.h" #include "main_menu1.h" #include "memory.h" #include "other_menus1.h" #include "other_menus2.h" #include "pokemon.h" #include "save.h" +#include "structs/str_dungeon.h" // rescue_password_menu.c extern s32 gCommsTimeout; // Counts to 100 and then errors if other player hasn't connected diff --git a/src/party_list_menu.c b/src/party_list_menu.c index 6408e0d9b..56c44f7f3 100644 --- a/src/party_list_menu.c +++ b/src/party_list_menu.c @@ -12,6 +12,7 @@ #include "common_strings.h" #include "constants/dungeon.h" #include "event_flag.h" +#include "input.h" #include "items.h" #include "kecleon_bros4.h" #include "memory.h" diff --git a/src/pelipper_board.c b/src/pelipper_board.c index 18a948af1..b9d90c1a1 100644 --- a/src/pelipper_board.c +++ b/src/pelipper_board.c @@ -8,15 +8,16 @@ #include "text2.h" #include "structs/menu.h" #include "input.h" -#include "wonder_mail.h" #include "menu_input.h" #include "common_strings.h" #include "pelipper_board.h" #include "code_80118A4.h" -#include "wonder_mail_2_1.h" #include "wonder_mail_802C10C.h" #include "code_80958E8_1.h" #include "code_803B050.h" +#include "wonder_mail_802C4C8.h" +#include "wonder_mail_802C860.h" +#include "code_8096AF8.h" EWRAM_DATA_2 struct unkStruct_203B308 *gPelipperBoard = {0}; @@ -79,9 +80,6 @@ extern void sub_802EC10(void); extern void CreatePelipperAcceptedStatusBox(u32); -extern void sub_8096C80(void); -extern void sub_8096D24(void); -extern void AcceptJob(WonderMail*); extern void ResetPelipperBoardSlot(u8); extern void sub_80965F4(void); diff --git a/src/personality_test.c b/src/personality_test.c index 734c7b434..f08287de8 100644 --- a/src/personality_test.c +++ b/src/personality_test.c @@ -8,6 +8,7 @@ #include "constants/input.h" #include "constants/type.h" #include "game_options.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "personality_test.h" diff --git a/src/pokemon_news1.c b/src/pokemon_news1.c index 7e1e548ca..224bca31e 100644 --- a/src/pokemon_news1.c +++ b/src/pokemon_news1.c @@ -4,6 +4,7 @@ #include "code_803B050.h" #include "code_8096AF8.h" #include "constants/input.h" +#include "input.h" #include "pokemon_mail.h" #include "pokemon_news1.h" #include "pokemon_news2.h" diff --git a/src/pokemon_news2.c b/src/pokemon_news2.c index e0c62ac93..caf043373 100644 --- a/src/pokemon_news2.c +++ b/src/pokemon_news2.c @@ -2,6 +2,7 @@ #include "code_80118A4.h" #include "code_80130A8.h" #include "game_options.h" +#include "input.h" #include "pokemon_mail.h" #include "pokemon_mid.h" #include "pokemon_news2.h" diff --git a/src/pokemon_news3.c b/src/pokemon_news3.c index 98072d7ee..0014a464d 100644 --- a/src/pokemon_news3.c +++ b/src/pokemon_news3.c @@ -1,17 +1,18 @@ #include "global.h" #include "code_800D090.h" #include "code_80118A4.h" -#include "code_802C39C.h" #include "code_803B050.h" #include "code_80958E8_1.h" #include "constants/input.h" #include "constants/mailbox.h" +#include "input.h" #include "mailbox_8095F8C.h" #include "memory.h" #include "menu_input.h" #include "pokemon_mail.h" #include "pokemon_mid.h" #include "pokemon_news3.h" +#include "structs/str_802C39C.h" #include "text1.h" #include "text2.h" diff --git a/src/post_office_guide1.c b/src/post_office_guide1.c index be5529960..c7c24fba5 100644 --- a/src/post_office_guide1.c +++ b/src/post_office_guide1.c @@ -1,5 +1,6 @@ #include "global.h" #include "code_80130A8.h" +#include "input.h" #include "memory.h" #include "structs/menu.h" #include "pokemon.h" diff --git a/src/post_office_guide2.c b/src/post_office_guide2.c index 6a9f8b34c..490d1a23a 100644 --- a/src/post_office_guide2.c +++ b/src/post_office_guide2.c @@ -8,13 +8,13 @@ #include "code_80A26CC.h" #include "constants/mailbox.h" #include "constants/wonder_mail.h" +#include "input.h" #include "items.h" #include "memory.h" #include "menu_input.h" #include "post_office_guide2.h" #include "text1.h" #include "text2.h" -#include "wonder_mail.h" extern u8 gUnknown_202DE58[]; diff --git a/src/rescue_password_menu.c b/src/rescue_password_menu.c index 289324b36..fec4c24d8 100644 --- a/src/rescue_password_menu.c +++ b/src/rescue_password_menu.c @@ -13,7 +13,6 @@ #include "save.h" #include "text1.h" #include "text2.h" -#include "wonder_mail.h" #define RESCUE_PASSWORD_SIZE 0x36 diff --git a/src/save_menu.c b/src/save_menu.c index eec52d552..e1faf246e 100644 --- a/src/save_menu.c +++ b/src/save_menu.c @@ -1,6 +1,7 @@ #include "global.h" #include "code_80130A8.h" #include "constants/main_menu.h" +#include "input.h" #include "main_menu1.h" #include "memory.h" #include "menu_input.h" diff --git a/src/thank_you_wonder_mail.c b/src/thank_you_wonder_mail.c index cd13f81b9..229ac4155 100644 --- a/src/thank_you_wonder_mail.c +++ b/src/thank_you_wonder_mail.c @@ -8,6 +8,7 @@ #include "code_8094F88.h" #include "constants/communication_error_codes.h" #include "cpu.h" +#include "input.h" #include "items.h" #include "main_menu1.h" #include "memory.h" @@ -20,7 +21,7 @@ #include "text_util.h" #include "text1.h" #include "text2.h" -#include "wonder_mail.h" +#include "thank_you_wonder_mail.h" static EWRAM_DATA_2 WonderMailStruct_203B2C4 *sUnknown_203B2C4 = {0}; diff --git a/src/trade_items_menu.c b/src/trade_items_menu.c index 65dddd35a..7d9912766 100644 --- a/src/trade_items_menu.c +++ b/src/trade_items_menu.c @@ -5,6 +5,7 @@ #include "code_801C8C4.h" #include "constants/communication_error_codes.h" #include "cpu.h" +#include "input.h" #include "items.h" #include "main_menu1.h" #include "memory.h" diff --git a/src/unk_menu_203B360.c b/src/unk_menu_203B360.c index 54c61c9e0..b3d0378fc 100644 --- a/src/unk_menu_203B360.c +++ b/src/unk_menu_203B360.c @@ -1,5 +1,6 @@ #include "global.h" #include "constants/main_menu.h" +#include "input.h" #include "main_menu1.h" #include "memory.h" #include "menu_input.h" diff --git a/src/wigglytuff_shop1.c b/src/wigglytuff_shop1.c index 3122cb8bc..ebbb358bc 100644 --- a/src/wigglytuff_shop1.c +++ b/src/wigglytuff_shop1.c @@ -4,6 +4,7 @@ #include "constants/input.h" #include "event_flag.h" #include "friend_area.h" +#include "input.h" #include "items.h" #include "memory.h" #include "menu_input.h" diff --git a/src/wigglytuff_shop2.c b/src/wigglytuff_shop2.c index 49ba357df..fd1750b75 100644 --- a/src/wigglytuff_shop2.c +++ b/src/wigglytuff_shop2.c @@ -4,6 +4,7 @@ #include "common_strings.h" #include "exclusive_pokemon.h" #include "friend_area.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "pokemon.h" diff --git a/src/wigglytuff_shop3.c b/src/wigglytuff_shop3.c index 4b0ea5b83..119b16952 100644 --- a/src/wigglytuff_shop3.c +++ b/src/wigglytuff_shop3.c @@ -7,6 +7,7 @@ #include "event_flag.h" #include "felicity_bank.h" #include "friend_area.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "pokemon.h" diff --git a/src/wonder_mail.c b/src/wonder_mail.c index 15cb54cd8..8d42c5252 100644 --- a/src/wonder_mail.c +++ b/src/wonder_mail.c @@ -7,6 +7,7 @@ #include "code_80A26CC.h" #include "constants/communication_error_codes.h" #include "cpu.h" +#include "input.h" #include "items.h" #include "main_menu1.h" #include "memory.h" @@ -268,6 +269,8 @@ ALIGNED(4) const u8 SendPokemon_80DDB98[] = _("Send Pokémon"); #include "data/wonder_mail_1.h" +void SetFriendRescueCounterState(u32 r0); + u32 sub_8027F88(void) { char *monName; diff --git a/src/wonder_mail_2.c b/src/wonder_mail_2.c index c8ef8a84c..85a4f6c38 100644 --- a/src/wonder_mail_2.c +++ b/src/wonder_mail_2.c @@ -8,6 +8,7 @@ #include "constants/wonder_mail.h" #include "event_flag.h" #include "game_options.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "pokemon.h" @@ -15,7 +16,6 @@ #include "save.h" #include "save_write.h" #include "text1.h" -#include "wonder_mail.h" struct unkStruct_203B2C8 { diff --git a/src/wonder_mail_2_1.c b/src/wonder_mail_2_1.c deleted file mode 100644 index 807a019fd..000000000 --- a/src/wonder_mail_2_1.c +++ /dev/null @@ -1,450 +0,0 @@ -#include "global.h" -#include "code_802DE84.h" -#include "constants/input.h" -#include "constants/mailbox.h" -#include "input.h" -#include "memory.h" -#include "text1.h" -#include "text2.h" -#include "structs/menu.h" -#include "code_802C39C.h" -#include "menu_input.h" -#include "wonder_mail_2_1.h" -#include "code_80118A4.h" -#include "code_80958E8_1.h" -#include "code_803B050.h" - -static EWRAM_DATA_2 struct unkStruct_203B2E8* gUnknown_203B2E8 = {0}; -static EWRAM_DATA_2 u16 gUnknown_203B2EC = {0}; - -extern struct unkStruct_203B2F0 *gUnknown_203B2F0; - -ALIGNED(4) static const char wonder_mail_2_fill4[] = "pksdir0"; - -const UnkTextStruct2 gUnknown_80DFCE4 = -{ - 0x00, 0x00, 0x00, 0x00, - 0x03, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0x00, - NULL -}; - -const UnkTextStruct2 gUnknown_80DFCFC = -{ - 0x00, 0x00, 0x00, 0x00, - 0x06, - 0x02, 0x02, - 0x18, 0x0E, - 0x0E, 0x00, - NULL -}; - -const u8 gUnknown_80DFD14[] = "Job List"; -static const u8 wonder_mail_fill[] = "pksdir0"; - -const UnkTextStruct2 gUnknown_80DFD28 = -{ - 0x00, 0x00, 0x00, 0x00, - 0x03, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0x00, - NULL -}; - -const UnkTextStruct2 gUnknown_80DFD40 = -{ - 0x00, 0x00, 0x00, 0x00, - 0x04, - 0x15, 0x06, - 0x07, 0x03, - 0x03, 0x00, - NULL -}; - -const UnkTextStruct2 gUnknown_80DFD58 = -{ - 0x00, 0x00, 0x00, 0x00, - 0x04, - 0x15, 0x0f, - 0x06, 0x03, - 0x03, 0x00, - NULL -}; - -const u8 gUnknown_80DFD70[] = "Take Job"; -const u8 gUnknown_80DFD7C[] = "Suspend"; -static const u8 wonder_mail_fill0[] = "pksdir0"; - -const UnkTextStruct2 gUnknown_80DFD8C = -{ - 0x00, 0x00, 0x00, 0x00, - 0x03, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0x00, - NULL -}; - -const UnkTextStruct2 gUnknown_80DFDA4 = -{ - 0x00, 0x00, 0x00, 0x00, - 0x06, - 0x02, 0x02, - 0x18, 0x0e, - 0x0e, 0x00, - NULL -}; - -const u8 gUnknown_80DFDBC[] = "RESCUE EVENT"; -static const u8 wonder_mail_fill1[] = "pksdir0"; - -extern void sub_802CAA4(void); -extern u8 IsJobSlotEmpty(u8); - -extern void sub_802C6DC(void); -extern void DrawJobListMenu(void); -extern void SetJobListState(u32); -extern void sub_802CC00(void); -extern void sub_802CC70(void); -extern void sub_802CD38(void); -extern void sub_802CDB8(void); -extern void sub_802C928(void); -extern void sub_802C9D8(void); -extern void sub_802CBAC(void); - -s32 CountAcceptedJobs(void); - - - - - -bool8 sub_802C4C8(int param_1,UnkTextStruct2_sub *param_2,u32 param_3) -{ - if (HasNoAcceptedJobs()) { - return FALSE; - } - else - { - gUnknown_203B2E8 = MemoryAlloc(sizeof(struct unkStruct_203B2E8), 8); - gUnknown_203B2E8->unk3C = param_1; - gUnknown_203B2E8->unk40 = &gUnknown_203B2E8->unk44[param_1]; - sub_8006518(gUnknown_203B2E8->unk44); - - gUnknown_203B2E8->unk44[gUnknown_203B2E8->unk3C] = gUnknown_80DFCFC; - - gUnknown_203B2E8->unk40->unk14 = gUnknown_203B2E8->unkA4; - - if (param_2 != NULL) - gUnknown_203B2E8->unk44[gUnknown_203B2E8->unk3C].unk8 = *param_2; - - sub_8012D34(gUnknown_203B2E8->unk40,param_3); - ResetUnusedInputStruct(); - sub_800641C(gUnknown_203B2E8->unk44, TRUE, TRUE); - sub_8013848(&gUnknown_203B2E8->input,CountAcceptedJobs(),param_3,param_1); - gUnknown_203B2E8->input.menuIndex = gUnknown_203B2EC; - sub_8013984(&gUnknown_203B2E8->input); - sub_802C6DC(); - DrawJobListMenu(); - return TRUE; - } -} - -u32 sub_802C598(u8 param_1) -{ - if (param_1 == '\0') { - sub_8013660(&gUnknown_203B2E8->input); - return 0; - } - else { - switch(GetKeyPress(&gUnknown_203B2E8->input)) - { - case INPUT_B_BUTTON: - PlayMenuSoundEffect(1); - return 2; - case INPUT_A_BUTTON: - PlayMenuSoundEffect(0); - return 3; - case INPUT_START_BUTTON: - PlayMenuSoundEffect(4); - return 4; - } - if (sub_80138B8(&gUnknown_203B2E8->input, 1) != '\0') { - sub_802C6DC(); - DrawJobListMenu(); - return 1; - } - else { - return 0; - } - } -} - -u8 GetPelipperBoardSlotIndex(void) -{ - return gUnknown_203B2E8->pelipperBoardSlots[gUnknown_203B2E8->input.unk1E * gUnknown_203B2E8->input.unk1C + gUnknown_203B2E8->input.menuIndex]; -} - -void sub_802C640(u8 r0) -{ - ResetUnusedInputStruct(); - sub_800641C(gUnknown_203B2E8->unk44, FALSE, FALSE); - gUnknown_203B2E8->input.unk22 = CountAcceptedJobs(); - sub_8013984(&gUnknown_203B2E8->input); - sub_802C6DC(); - DrawJobListMenu(); - if(r0) - AddMenuCursorSprite(&gUnknown_203B2E8->input); -} - -void sub_802C688(void) -{ - if(gUnknown_203B2E8 != NULL) - { - gUnknown_203B2EC = gUnknown_203B2E8->input.menuIndex; - gUnknown_203B2E8->unk44[gUnknown_203B2E8->unk3C] = gUnknown_80DFCE4; - ResetUnusedInputStruct(); - sub_800641C(gUnknown_203B2E8->unk44, TRUE, TRUE); - MemoryFree(gUnknown_203B2E8); - gUnknown_203B2E8 = NULL; - } -} - -NAKED -void sub_802C6DC(void) -{ - asm_unified("\tpush {r4,lr}\n" - "\tldr r4, _0802C74C\n" - "\tldr r0, [r4]\n" - "\tldrh r1, [r0, 0x28]\n" - "\tadds r0, 0xA4\n" - "\tmovs r2, 0\n" - "\tstrb r1, [r0]\n" - "\tldr r0, [r4]\n" - "\tldrh r1, [r0, 0x26]\n" - "\tadds r0, 0xA5\n" - "\tstrb r1, [r0]\n" - "\tldr r0, [r4]\n" - "\tadds r0, 0xA6\n" - "\tmovs r1, 0xC\n" - "\tstrb r1, [r0]\n" - "\tldr r0, [r4]\n" - "\tadds r0, 0xA7\n" - "\tstrb r2, [r0]\n" - "\tldr r0, [r4]\n" - "\tmovs r1, 0x22\n" - "\tldrsh r0, [r0, r1]\n" - "\tmovs r1, 0x18\n" - "\tbl sub_8009614\n" - "\tadds r0, 0x2\n" - "\tlsls r0, 16\n" - "\tldr r2, [r4]\n" - "\tldr r3, [r2, 0x3C]\n" - "\tlsls r1, r3, 1\n" - "\tadds r1, r3\n" - "\tlsls r1, 3\n" - "\tadds r1, r2, r1\n" - "\tadds r1, 0x52\n" - "\tasrs r3, r0, 16\n" - "\tlsrs r0, 16\n" - "\tstrh r0, [r1]\n" - "\tldr r1, [r2, 0x3C]\n" - "\tlsls r0, r1, 1\n" - "\tadds r0, r1\n" - "\tlsls r0, 3\n" - "\tadds r2, r0\n" - "\tadds r3, 0x2\n" - "\tadds r2, 0x54\n" - "\tstrh r3, [r2]\n" - "\tbl ResetUnusedInputStruct\n" - "\tldr r0, [r4]\n" - "\tadds r0, 0x44\n" - "\tmovs r1, 0x1\n" - "\tmovs r2, 0x1\n" - "\tbl sub_800641C\n" - "\tpop {r4}\n" - "\tpop {r0}\n" - "\tbx r0\n" - "\t.align 2, 0\n" -"_0802C74C: .4byte gUnknown_203B2E8"); - -} - -void DrawJobListMenu(void) -{ - WonderMail *mail; - int index; - s32 r4; - s32 r5; - unkStruct_802C39C local; - - sub_8008C54(gUnknown_203B2E8->unk3C); - sub_80073B8(gUnknown_203B2E8->unk3C); - r4 = gUnknown_203B2E8->input.unk1E * 8; - r5 = r4; - r5 += 10; - xxx_call_draw_string(r5,0,gUnknown_80DFD14,gUnknown_203B2E8->unk3C,0); // "Job List" - r4 += 4; - r5 = r4 + gUnknown_203B2E8->unkA4[2] * 8; - sub_8012BC4(r5,0,gUnknown_203B2E8->input.unk1E + 1,2,7,gUnknown_203B2E8->unk3C); - - for(index = 0; index < gUnknown_203B2E8->input.unk1A; index++) - { - mail = GetJobSlotInfo(gUnknown_203B2E8->pelipperBoardSlots[gUnknown_203B2E8->input.unk1E * gUnknown_203B2E8->input.unk1C + index]); - local.unk0[0] = gUnknown_203B2E8->unk3C; - local.y = sub_8013800(&gUnknown_203B2E8->input,index); - sub_803B35C(mail,&local); - CreateRescueTitle(&local); - } - sub_80073E0(gUnknown_203B2E8->unk3C); -} - -s32 CountAcceptedJobs(void) -{ - s32 index; - s32 counter = 0; - for(index = 0; index < MAX_ACCEPTED_JOBS; index++) - { - if(!IsJobSlotEmpty(index)) - { - gUnknown_203B2E8->pelipperBoardSlots[counter] = index; - counter++; - } - } - return counter; -} - -bool8 HasNoAcceptedJobs(void) -{ - s32 index; - for(index = 0; index < MAX_ACCEPTED_JOBS; index++) - { - if(!IsJobSlotEmpty(index)) - return FALSE; - } - return TRUE; -} - - - - -// THIS IS A NEW FILE: - - - - - -bool8 InitializeJobListMenu(u32 r0) -{ - if(HasNoAcceptedJobs()) - { - return FALSE; - } - else - { - gUnknown_203B2F0 = MemoryAlloc(sizeof(struct unkStruct_203B2F0), 0x8); - gUnknown_203B2F0->menuAction = 0; - gUnknown_203B2F0->unk0 = r0; - SetJobListState(0); - return TRUE; - } -} - -u32 sub_802C898(void) -{ - switch(gUnknown_203B2F0->state) - { - case 0: - case 1: - sub_802CC00(); - break; - case 2: - sub_802CC70(); - break; - case 3: - sub_802CD38(); - break; - case 4: - sub_802CDB8(); - break; - case 5: - default: - return 3; - } - return 0; -} - -void sub_802C8F4(void) -{ - if(gUnknown_203B2F0 != NULL) - { - MemoryFree(gUnknown_203B2F0); - gUnknown_203B2F0 = NULL; - } -} - -void SetJobListState(u32 newState) -{ - gUnknown_203B2F0->state = newState; - sub_802C928(); - sub_802C9D8(); -} - -void sub_802C928(void) -{ - s32 index; - sub_8006518(gUnknown_203B2F0->unk19C); - switch(gUnknown_203B2F0->state) - { - case 2: - sub_802CAA4(); - gUnknown_203B2F0->unk19C[2] = gUnknown_80DFD40; - sub_8012CAC(&gUnknown_203B2F0->unk19C[2], gUnknown_203B2F0->unk10C); - break; - case 3: - gUnknown_203B2F0->unk19C[3] = gUnknown_80DFD58; - break; - default: - for(index = 0; index < 4; index++) - { - gUnknown_203B2F0->unk19C[index] = gUnknown_80DFD28; - } - break; - } - ResetUnusedInputStruct(); - sub_800641C(gUnknown_203B2F0->unk19C, TRUE, TRUE); -} - -void sub_802C9D8(void) -{ - switch(gUnknown_203B2F0->state) - { - case 0: - sub_802C4C8(0, 0, 4); - break; - case 1: - sub_802C640(1); - break; - case 2: - DrawJobListMenu(); - sub_8012D60(&gUnknown_203B2F0->unk6C, gUnknown_203B2F0->unk10C, 0, 0, gUnknown_203B2F0->menuAction, 2); - break; - case 3: - sub_802CBAC(); - DrawJobListMenu(); - sub_8012EA4(&gUnknown_203B2F0->unk6C, 0); - sub_8012D60(&gUnknown_203B2F0->unkBC, gUnknown_203B2F0->unk14C, 0, 0, 6, 3); - break; - case 4: - sub_803B35C(GetJobSlotInfo(gUnknown_203B2F0->unkC), &gUnknown_203B2F0->unk10); - gUnknown_203B2F0->unk10.unk0[0] = 3; - sub_802DE84(&gUnknown_203B2F0->unk10); - break; - case 5: - default: - break; - } -} - diff --git a/src/wonder_mail_3.c b/src/wonder_mail_3.c deleted file mode 100644 index feb6d39ac..000000000 --- a/src/wonder_mail_3.c +++ /dev/null @@ -1,1050 +0,0 @@ -#include "global.h" -#include "constants/mailbox.h" -#include "code_802DE84.h" -#include "common_strings.h" -#include "constants/dungeon.h" -#include "constants/input.h" -#include "memory.h" -#include "text1.h" -#include "text2.h" -#include "mailbox.h" -#include "wonder_mail.h" -#include "wonder_mail_3.h" -#include "menu_input.h" -#include "code_80958E8.h" -#include "wonder_mail_2_1.h" -#include "code_80130A8.h" -#include "code_80118A4.h" -#include "code_80A26CC.h" -#include "code_80958E8_1.h" -#include "code_803B050.h" - -static EWRAM_DATA_2 unkStruct_203B2F4 *sUnknown_203B2F4 = {0}; - -extern unkStruct_203B2F8 *gUnknown_203B2F8; - -const UnkTextStruct2 gUnknown_80DFDD4 = -{ - 0x00, 0x00, 0x00, 0x00, - 0x03, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0x00, - NULL -}; - -// Unused -const UnkTextStruct2 gUnknown_80DFDEC = -{ - 0x00, 0x00, 0x00, 0x00, - 0x03, - 0x03, 0x03, - 0x07, 0x03, - 0x03, 0x00, - NULL -}; - -const UnkTextStruct2 gUnknown_80DFE04 = -{ - 0x00, 0x00, 0x00, 0x00, - 0x03, - 0x15, 0x06, - 0x07, 0x03, - 0x03, 0x00, - NULL -}; -const UnkTextStruct2 gUnknown_80DFE1C = -{ - 0x00, 0x00, 0x00, 0x00, - 0x03, - 0x15, 0x0f, - 0x07, 0x03, - 0x03, 0x00, - NULL -}; - -// Unused -const UnkTextStruct2 gUnknown_80DFE34 = -{ - 0x00, 0x00, 0x00, 0x00, - 0x03, - 0x15, 0x0f, - 0x06, 0x03, - 0x03, 0x00, - NULL -}; - -ALIGNED(4) const u8 gUnknown_80DFE4C[] = _( - "Are you sure you want to replace the\n" - "old {COLOR_1 LIGHT_BLUE}Wonder Mail{END_COLOR_TEXT_1} with the new one?"); - -ALIGNED(4) const u8 gUnknown_80DFE9C[] = _( - "This {COLOR_1 LIGHT_BLUE}Wonder Mail{END_COLOR_TEXT_1} has already been\n" - "received."); - -ALIGNED(4) const u8 gUnknown_80DFED0[] = _( - "This {COLOR_1 LIGHT_BLUE}Wonder Mail{END_COLOR_TEXT_1} has already been\n" - "received.\n" - "You may not receive the same one again."); - -ALIGNED(4) const u8 gUnknown_80DFF2C[] = _( - "Only {COLOR_1 LIGHT_BLUE}one piece{END_COLOR_TEXT_1} of {COLOR_1 LIGHT_BLUE}Wonder Mail{END_COLOR_TEXT_1} can be held.\n" - "Please receive it after completing any\n" - "rescue mission in progress."); - -ALIGNED(4) const u8 gUnknown_80DFFA4[] = - "The rescue team has quicksaved in\n" - "a dungeon with a mission in progress.\n" - "Please complete the mission first."; - -ALIGNED(4) const u8 gUnknown_80E0010[] = - "The rescue team has quicksaved in\n" - "a dungeon with a mission in progress.\n" - "Mail cannot be deleted now."; - -ALIGNED(4) const u8 gReceivedWonderMail[] = _( - "Received the {COLOR_1 LIGHT_BLUE}Wonder Mail{END_COLOR_TEXT_1}!"); - -ALIGNED(4) const u8 gUnknown_80E0094[] = _( - "Only {COLOR_1 LIGHT_BLUE}one piece{END_COLOR_TEXT_1} of {COLOR_1 LIGHT_BLUE}Wonder Mail{END_COLOR_TEXT_1} can be held.\n" - "Is it OK to replace the old {COLOR_1 LIGHT_BLUE}Wonder Mail{END_COLOR_TEXT_1}\n" - "with the new one?"); - -ALIGNED(4) const u8 gUnknown_80E0108[] = _( - "Your {COLOR_1 LIGHT_BLUE}Job List{END_COLOR_TEXT_1} is full.\n" - "Please select and delete unwanted mail."); - -ALIGNED(4) const u8 gUnknown_80E014C[] = "New Mail"; -ALIGNED(4) const u8 gUnknown_80E0158[] = "Old Mail"; - -extern void sub_802D63C(void); -extern void sub_802D5A4(void); - -extern u8 sub_8099328(u8 *); -extern u32 sub_8011C1C(); -extern void sub_802D1A0(u32); - -extern void sub_802D7D0(); -extern void sub_802D8CC(); -extern void sub_802D940(); -extern void sub_802D9F0(); -extern void sub_802DA60(); -extern void sub_802D82C(); -extern void AdvancetoFallbackWonderMailRescueState(); -extern void sub_802D1B8(); -extern void sub_802D2A8(); - - -extern u8 sub_8096F50(WonderMail *); -extern u8 sub_802DAA8(void); -extern u8 sub_802DADC(void); -extern u8 *sub_8096DD8(void); -extern u8 sub_8096C08(u8 *); -extern void DrawJobListMenu(void); -extern void sub_802D73C(void); -extern void sub_802C640(u32); -extern void sub_802C4C8(u32, u32, u32); -extern void sub_8097418(u32, u32); -extern void sub_802D690(void); -extern void sub_8096C80(void); -extern void sub_8096D24(void); -extern u8 *sub_8096DE8(void); -extern void AcceptJob(unkSubStruct_203B2F8 *); -unkStruct_803B344 *sub_803B344(u8); -extern u8 gUnknown_80DFDBC[]; -extern void sub_802CF5C(void); -extern void sub_802CFD0(void); - -extern void SetJobListState(u32); -extern void ResetJobSlot(u8); -u32 sub_802C598(u8 param_1); -extern void sub_802C688(void); -extern u8 GetPelipperBoardSlotIndex(void); - -extern UnkTextStruct2 gUnknown_80DFD8C; -extern UnkTextStruct2 gUnknown_80DFDA4; - -extern struct unkStruct_203B2F0 *gUnknown_203B2F0; - -extern u8 gUnknown_80DFD70[]; -extern u8 gUnknown_80DFD7C[]; - -extern bool8 sub_809693C(WonderMail *); - -void sub_802CAA4(void) { - s32 loopMax; - WonderMail *mail; - s32 index; - - loopMax = 0; - mail = GetJobSlotInfo(gUnknown_203B2F0->unkC); - if(gUnknown_203B2F0->unk0 == 0) - { - switch(mail->mailType) - { - case 5: - gUnknown_203B2F0->unk10C[loopMax].text = gUnknown_80DFD70; // Take Job - if(sub_809693C(mail) || !sub_80A2824(mail->unk4.dungeon.id)) - { - gUnknown_203B2F0->unk10C[loopMax].menuAction = -1; - } - else - { - gUnknown_203B2F0->unk10C[loopMax].menuAction = 2; - } - loopMax += 1; - break; - case 6: - gUnknown_203B2F0->unk10C[loopMax].text = gUnknown_80DFD7C; // Suspend - gUnknown_203B2F0->unk10C[loopMax].menuAction = 3; - loopMax += 1; - break; - } - } - gUnknown_203B2F0->unk10C[loopMax].text = gCommonDelete[0]; - gUnknown_203B2F0->unk10C[loopMax].menuAction = 4; - loopMax += 1; - gUnknown_203B2F0->unk10C[loopMax].text = gCommonInfo[0]; - gUnknown_203B2F0->unk10C[loopMax].menuAction = 7; - loopMax += 1; - gUnknown_203B2F0->unk10C[loopMax].text = NULL; - gUnknown_203B2F0->unk10C[loopMax].menuAction = 1; - - for(index = 0; index < loopMax; index++) - { - if(gUnknown_203B2F0->unk10C[index].menuAction != -1) - { - if(gUnknown_203B2F0->unk10C[index].menuAction == gUnknown_203B2F0->menuAction) - return; - } - } - gUnknown_203B2F0->menuAction = 7; -} - -void sub_802CBAC(void) -{ - s32 loopMax; - loopMax = 0; - - gUnknown_203B2F0->unk14C[loopMax].text = gCommonYes[0]; - gUnknown_203B2F0->unk14C[loopMax].menuAction = 5; - loopMax += 1; - gUnknown_203B2F0->unk14C[loopMax].text = gCommonNo[0]; - gUnknown_203B2F0->unk14C[loopMax].menuAction = 6; - loopMax += 1; - gUnknown_203B2F0->unk14C[loopMax].text = NULL; - gUnknown_203B2F0->unk14C[loopMax].menuAction = 1; -} - -void sub_802CC00(void) -{ - switch(sub_802C598(1)) - { - case 3: - gUnknown_203B2F0->unkC = GetPelipperBoardSlotIndex(); - SetJobListState(2); - break; - case 4: - gUnknown_203B2F0->unkC = GetPelipperBoardSlotIndex(); - SetJobListState(4); - break; - case 0: - case 1: - break; - case 2: - sub_802C688(); - SetJobListState(5); - break; - } -} - -void sub_802CC70(void) -{ - s32 menuAction; - WonderMail *mail; - WonderMail *mail2; - - menuAction = 0; - sub_802C598(0); - if (!sub_8012FD8(&gUnknown_203B2F0->unk6C)) { - sub_8013114(&gUnknown_203B2F0->unk6C,&menuAction); - if(menuAction != 1) gUnknown_203B2F0->menuAction = menuAction; - } - switch(menuAction) - { - case 2: - PlaySound(0x133); - mail = GetJobSlotInfo(gUnknown_203B2F0->unkC); - mail->mailType = MAIL_TYPE_TAKEN_JOB; - SetJobListState(1); - break; - case 3: - PlaySound(0x133); - mail2 = GetJobSlotInfo(gUnknown_203B2F0->unkC); - mail2->mailType = MAIL_TYPE_SUSPENDED_JOB; - SetJobListState(1); - break; - case 4: - SetJobListState(3); - break; - case 7: - SetJobListState(4); - break; - case 1: - SetJobListState(1); - break; - } -} - -void sub_802CD38(void) -{ - s32 menuAction; - - menuAction = 0; - sub_802C598(0); - sub_8012FD8(&gUnknown_203B2F0->unk6C); - if (!sub_8012FD8(&gUnknown_203B2F0->unkBC)) { - sub_8013114(&gUnknown_203B2F0->unkBC,&menuAction); - } - switch(menuAction) - { - case 1: - case 6: - SetJobListState(1); - break; - case 5: - ResetJobSlot(gUnknown_203B2F0->unkC); - sub_8096C80(); - if (HasNoAcceptedJobs()) { - sub_802C688(); - SetJobListState(5); - } - else { - SetJobListState(1); - } - break; - } -} - -void sub_802CDB8(void) -{ - switch(sub_802DEE0()) - { - case 2: - case 3: - sub_802DF24(); - SetJobListState(1); - break; - case 0: - case 1: - break; - } -} - - - - -// THIS IS A NEW FILE: - - - - - -bool8 sub_802CDD4(u32 r0) -{ - if(sUnknown_203B2F4 == NULL) - { - sUnknown_203B2F4 = MemoryAlloc(sizeof(unkStruct_203B2F4), 8); - } - sUnknown_203B2F4->unk34 = r0; - sUnknown_203B2F4->unk38 = &sUnknown_203B2F4->unk3C[sUnknown_203B2F4->unk34]; - sub_8006518(sUnknown_203B2F4->unk3C); - sUnknown_203B2F4->unk3C[sUnknown_203B2F4->unk34] = gUnknown_80DFDA4; - sUnknown_203B2F4->unk38->unk14 = sUnknown_203B2F4->unk9C; - sub_8012D34(sUnknown_203B2F4->unk38, 4); - ResetUnusedInputStruct(); - sub_800641C(sUnknown_203B2F4->unk3C, TRUE, TRUE); - sub_8013848(&sUnknown_203B2F4->input, 5, 4, r0); - sub_802CF5C(); - sub_802CFD0(); - return TRUE; -} - -u32 sub_802CE5C(u8 r0) -{ - if(r0 == 0) - { - sub_8013660(&sUnknown_203B2F4->input); - return 0; - } - else - { - switch(GetKeyPress(&sUnknown_203B2F4->input)) - { - case INPUT_B_BUTTON: - PlayMenuSoundEffect(1); - return 2; - case INPUT_A_BUTTON: - return 3; - default: - if(sub_80138B8(&sUnknown_203B2F4->input, 1) != 0) - { - sub_802CF5C(); - sub_802CFD0(); - return 1; - } - else - { - return 0; - } - } - } -} - -u8 sub_802CEBC(void) -{ - return (sUnknown_203B2F4->input.unk1E * sUnknown_203B2F4->input.unk1C) + sUnknown_203B2F4->input.menuIndex; -} - -void sub_802CED8(u8 r0) -{ - ResetUnusedInputStruct(); - sub_800641C(sUnknown_203B2F4->unk3C, FALSE, FALSE); - sub_8013984(&sUnknown_203B2F4->input); - sub_802CF5C(); - sub_802CFD0(); - if(r0) - AddMenuCursorSprite(&sUnknown_203B2F4->input); -} - -void sub_802CF14(void) -{ - if(sUnknown_203B2F4) - { - sUnknown_203B2F4->unk3C[sUnknown_203B2F4->unk34] = gUnknown_80DFD8C; - ResetUnusedInputStruct(); - sub_800641C(sUnknown_203B2F4->unk3C, TRUE, TRUE); - MemoryFree(sUnknown_203B2F4); - sUnknown_203B2F4 = NULL; - } -} - -NAKED -void sub_802CF5C(void) -{ - asm_unified( - "\tpush {r4,lr}\n" - "\tldr r4, _0802CFCC\n" - "\tldr r0, [r4]\n" - "\tldrh r1, [r0, 0x20]\n" - "\tadds r0, 0x9C\n" - "\tmovs r2, 0\n" - "\tstrb r1, [r0]\n" - "\tldr r0, [r4]\n" - "\tldrh r1, [r0, 0x1E]\n" - "\tadds r0, 0x9D\n" - "\tstrb r1, [r0]\n" - "\tldr r0, [r4]\n" - "\tadds r0, 0x9E\n" - "\tmovs r1, 0xC\n" - "\tstrb r1, [r0]\n" - "\tldr r0, [r4]\n" - "\tadds r0, 0x9F\n" - "\tstrb r2, [r0]\n" - "\tldr r0, [r4]\n" - "\tmovs r1, 0x1A\n" - "\tldrsh r0, [r0, r1]\n" - "\tmovs r1, 0x18\n" - "\tbl sub_8009614\n" - "\tadds r0, 0x2\n" - "\tlsls r0, 16\n" - "\tldr r2, [r4]\n" - "\tldr r3, [r2, 0x34]\n" - "\tlsls r1, r3, 1\n" - "\tadds r1, r3\n" - "\tlsls r1, 3\n" - "\tadds r1, r2, r1\n" - "\tadds r1, 0x4A\n" - "\tasrs r3, r0, 16\n" - "\tlsrs r0, 16\n" - "\tstrh r0, [r1]\n" - "\tldr r1, [r2, 0x34]\n" - "\tlsls r0, r1, 1\n" - "\tadds r0, r1\n" - "\tlsls r0, 3\n" - "\tadds r2, r0\n" - "\tadds r3, 0x2\n" - "\tadds r2, 0x4C\n" - "\tstrh r3, [r2]\n" - "\tbl ResetUnusedInputStruct\n" - "\tldr r0, [r4]\n" - "\tadds r0, 0x3C\n" - "\tmovs r1, 0x1\n" - "\tmovs r2, 0x1\n" - "\tbl sub_800641C\n" - "\tpop {r4}\n" - "\tpop {r0}\n" - "\tbx r0\n" - "\t.align 2, 0\n" -"_0802CFCC: .4byte sUnknown_203B2F4"); -} - - -void sub_802CFD0(void) -{ - unkStruct_802C39C local; - unkStruct_803B344 *iVar1; - s32 r5; - s32 r4; - - sub_8008C54(sUnknown_203B2F4->unk34); - sub_80073B8(sUnknown_203B2F4->unk34); - r5 = r4 = sUnknown_203B2F4->input.unk1E * 8 + 10; - xxx_call_draw_string(r5,0,gUnknown_80DFDBC,sUnknown_203B2F4->unk34,0); // RESCUE EVENT - r4 -= 6; - r5 = r4 + (sUnknown_203B2F4->unk9C[2] * 8); - sub_8012BC4(r5,0,sUnknown_203B2F4->input.unk1E + 1,2,7,sUnknown_203B2F4->unk34); - - for(r5 = 0; r5 < sUnknown_203B2F4->input.unk1A; r5++) - { - iVar1 = sub_803B344(sUnknown_203B2F4->input.unk1E * sUnknown_203B2F4->input.unk1C + r5); - local.unk0[0] = sUnknown_203B2F4->unk34; - local.y = sub_8013800(&sUnknown_203B2F4->input, r5); - sub_803B35C(&iVar1->mail,&local); - local.unk43 = 1; - local.unk4C = iVar1->unk14; - CreateRescueTitle(&local); - } - sub_80073E0(sUnknown_203B2F4->unk34); -} - - - - - - -// THIS IS A NEW FILE: - - - - -u32 sub_802D098(unkSubStruct_203B2F8 *mail) -{ - gUnknown_203B2F8 = MemoryAlloc(sizeof(unkStruct_203B2F8),8); - gUnknown_203B2F8->menuAction1 = 0; - gUnknown_203B2F8->menuAction2 = 0; - gUnknown_203B2F8->menuAction3 = 0; - gUnknown_203B2F8->mail = mail; - gUnknown_203B2F8->wonderMailAccepted = FALSE; - gUnknown_203B2F8->unk9 = sub_8099328(&gUnknown_203B2F8->dungeonID); - if (sub_8011C1C() != 2) { - gUnknown_203B2F8->unk9 = FALSE; - } - sub_802D1A0(INITIAL_WONDER_MAIL_CHECK); - return 1; -} - -u32 sub_802D0E0(void) -{ - switch(gUnknown_203B2F8->state) { - case INITIAL_WONDER_MAIL_CHECK: - break; - case 1: - sub_802D7D0(); - break; - case DRAW_JOB_LIST: - case DRAW_JOB_LIST_1: - sub_802D8CC(); - break; - case 0xd: - sub_802D940(); - break; - case 0xe: - sub_802D9F0(); - break; - case 0xf: - case 0x10: - sub_802DA60(); - break; - case 9: - sub_802D82C(); - break; - case WONDER_MAIL_EXIT: - return 3; - default: - AdvancetoFallbackWonderMailRescueState(); - break; - } - return 0; -} - -bool8 GetWonderMailAccepted(void) -{ - return gUnknown_203B2F8->wonderMailAccepted; -} - -void sub_802D184(void) -{ - if(gUnknown_203B2F8 != NULL) - { - MemoryFree(gUnknown_203B2F8); - gUnknown_203B2F8 = NULL; - } -} - -void sub_802D1A0(u32 newState) -{ - gUnknown_203B2F8->state = newState; - sub_802D1B8(); - sub_802D2A8(); -} - -void sub_802D1B8(void) -{ - s32 index; - sub_8006518(gUnknown_203B2F8->unk1A8); - switch(gUnknown_203B2F8->state) - { - case 0xD: - sub_802D5A4(); - gUnknown_203B2F8->unk1A8[2] = gUnknown_80DFE04; - sub_8012CAC(&gUnknown_203B2F8->unk1A8[2], gUnknown_203B2F8->unk118); - gUnknown_203B2F8->unk1A8[2].unkC = 6; - break; - case 0xE: - sub_802D63C(); - gUnknown_203B2F8->unk1A8[3] = gUnknown_80DFE1C; - sub_8012CAC(&gUnknown_203B2F8->unk1A8[3], gUnknown_203B2F8->unk158); - gUnknown_203B2F8->unk1A8[3].unkC = 6; - break; - default: - for(index = 0; index < 4; index++) - { - gUnknown_203B2F8->unk1A8[index] = gUnknown_80DFDD4; - } - break; - case WONDER_MAIL_EXIT: - break; - } - ResetUnusedInputStruct(); - sub_800641C(gUnknown_203B2F8->unk1A8, TRUE, TRUE); -} - -void sub_802D2A8(void) -{ - - switch(gUnknown_203B2F8->state) { - case INITIAL_WONDER_MAIL_CHECK: - if (IsMailinJobSlot(&gUnknown_203B2F8->mail->wonderMail)) { - sub_802D1A0(DUPLICATE_WONDER_MAIL); - } - else if (sub_8096F50(&gUnknown_203B2F8->mail->wonderMail) != 0) { - sub_802D1A0(DUPLICATE_WONDER_MAIL_1); - } - else if ((gUnknown_203B2F8->mail->wonderMail.unk2 == 4) && (sub_8096C08(&gUnknown_203B2F8->jobSlotIndex) != 0)) { - if (sub_802DAA8() != 0) { - sub_802D1A0(9); - } - else { - sub_802D1A0(5); - } - } - else if (GetNumAcceptedJobs() >= MAX_ACCEPTED_JOBS) { - if (sub_802DADC() != 0) { - sub_802D1A0(JOB_LIST_FULL); - } - else { - sub_802D1A0(6); - } - } - else - sub_802D1A0(RECEIVE_WONDER_MAIL); - break; - case 1: - sub_802D73C(); - sub_8014248(gUnknown_80DFE4C,0,gUnknown_203B2F8->menuAction2,gUnknown_203B2F8->unk158,0,4,0,0,0); - break; - case DUPLICATE_WONDER_MAIL: - gUnknown_203B2F8->fallbackState = WONDER_MAIL_EXIT; - sub_80141B4(gUnknown_80DFE9C,0,0,0x101); - break; - case DUPLICATE_WONDER_MAIL_1: - gUnknown_203B2F8->fallbackState = WONDER_MAIL_EXIT; - sub_80141B4(gUnknown_80DFED0,0,0,0x101); - break; - case 5: - gUnknown_203B2F8->fallbackState = WONDER_MAIL_EXIT; - sub_80141B4(gUnknown_80DFF2C,0,0,0x101); - break; - case 6: - gUnknown_203B2F8->fallbackState = WONDER_MAIL_EXIT; - sub_80141B4(gUnknown_80DFFA4,0,0,0x101); - break; - case 7: - gUnknown_203B2F8->fallbackState = DRAW_JOB_LIST_1; - sub_80141B4(gUnknown_80E0010,0,0,0x101); - break; - case RECEIVE_WONDER_MAIL: - gUnknown_203B2F8->wonderMailAccepted = TRUE; - AcceptJob(gUnknown_203B2F8->mail); - sub_8096C80(); - sub_8096D24(); - if (gUnknown_203B2F8->mail->wonderMail.unk2 == 4) { - MemoryCopy8(sub_8096DD8(),gUnknown_203B2F8->mail->unk14,0x28); - MemoryCopy8(sub_8096DE8(),gUnknown_203B2F8->mail->unk18,0x78); - } - switch(gUnknown_203B2F8->mail->wonderMail.unk4.dungeon.id) - { - // NOTE: subtract 1 from each of the case as the input?? - case DUNGEON_ODDITY_CAVE: // 0x2B - sub_8097418(0x2A, 1); - break; - case DUNGEON_REMAINS_ISLAND: - sub_8097418(0x2B, 1); - break; - case DUNGEON_MARVELOUS_SEA: - sub_8097418(0x2C, 1); - break; - case DUNGEON_FANTASY_STRAIT: // 0x2E - sub_8097418(0x2D, 1); - break; - } - gUnknown_203B2F8->fallbackState = WONDER_MAIL_EXIT; - sub_80141B4(gReceivedWonderMail,0,0,0x101); - break; - case 9: - sub_802D690(); - sub_8014248(gUnknown_80E0094,0,gUnknown_203B2F8->menuAction3,gUnknown_203B2F8->unk158,0,4,0,0,0); - break; - case JOB_LIST_FULL: - gUnknown_203B2F8->fallbackState = DRAW_JOB_LIST; - sub_80141B4(gUnknown_80E0108,0,0,0x101); - break; - case DRAW_JOB_LIST: - sub_802C4C8(0,0,4); - break; - case DRAW_JOB_LIST_1: - sub_802C640(1); - break; - case 0xd: - DrawJobListMenu(); - sub_8012D60(&gUnknown_203B2F8->unk78,gUnknown_203B2F8->unk118,0,gUnknown_203B2F8->unk198, - gUnknown_203B2F8->menuAction1,2); - break; - case 0xe: - DrawJobListMenu(); - sub_8012EA4(&gUnknown_203B2F8->unk78,0); - sub_8012D60(&gUnknown_203B2F8->unkC8,gUnknown_203B2F8->unk158,0,0,4,3); - break; - case 0xf: - sub_803B35C(GetJobSlotInfo(gUnknown_203B2F8->jobSlotIndex),&gUnknown_203B2F8->unk14); - gUnknown_203B2F8->unk14.unk0[0] = 3; - sub_802DE84(&gUnknown_203B2F8->unk14); - break; - case 0x10: - sub_803B35C(&gUnknown_203B2F8->mail->wonderMail,&gUnknown_203B2F8->unk14); - gUnknown_203B2F8->unk14.unk0[0] = 3; - gUnknown_203B2F8->unk14.mailStatus = MAIL_STATUS_SUSPENDED; - gUnknown_203B2F8->unk14.unk50 = gUnknown_203B2F8->mail->unk18; - sub_802DE84(&gUnknown_203B2F8->unk14); - break; - } -} - -void sub_802D5A4(void) { - s32 loopMax; - s32 index; - - loopMax = 0; - MemoryFill16(gUnknown_203B2F8->unk198, 0, sizeof(gUnknown_203B2F8->unk198)); - gUnknown_203B2F8->unk118[loopMax].text = gCommonDelete[0]; - gUnknown_203B2F8->unk118[loopMax].menuAction = 2; - loopMax += 1; - gUnknown_203B2F8->unk118[loopMax].text = gCommonInfo[0]; - gUnknown_203B2F8->unk118[loopMax].menuAction = 5; - loopMax += 1; - gUnknown_203B2F8->unk118[loopMax].text = NULL; - gUnknown_203B2F8->unk118[loopMax].menuAction = 1; - - for(index = 0; index < loopMax; index++) - { - if (gUnknown_203B2F8->unk198[index] == 0) { - if(gUnknown_203B2F8->unk118[index].menuAction == gUnknown_203B2F8->menuAction1) - return; - } - } - gUnknown_203B2F8->menuAction1 = 2; -} - -void sub_802D63C(void) { - s32 loopMax = 0; - gUnknown_203B2F8->unk158[loopMax].text = gCommonYes[0]; - gUnknown_203B2F8->unk158[loopMax].menuAction = 3; - loopMax += 1; - gUnknown_203B2F8->unk158[loopMax].text = gCommonNo[0]; - gUnknown_203B2F8->unk158[loopMax].menuAction = 4; - loopMax += 1; - gUnknown_203B2F8->unk158[loopMax].text = NULL; - gUnknown_203B2F8->unk158[loopMax].menuAction = 1; -} - -void sub_802D690(void) { - s32 loopMax; - s32 index; - - loopMax = 0; - gUnknown_203B2F8->unk158[loopMax].text = gCommonYes[0]; - gUnknown_203B2F8->unk158[loopMax].menuAction = 3; - loopMax += 1; - gUnknown_203B2F8->unk158[loopMax].text = gCommonNo[0]; - gUnknown_203B2F8->unk158[loopMax].menuAction = 4; - loopMax += 1; - gUnknown_203B2F8->unk158[loopMax].text = gUnknown_80E014C; - gUnknown_203B2F8->unk158[loopMax].menuAction = 6; - loopMax += 1; - gUnknown_203B2F8->unk158[loopMax].text = gUnknown_80E0158; - gUnknown_203B2F8->unk158[loopMax].menuAction = 7; - loopMax += 1; - gUnknown_203B2F8->unk158[loopMax].text = NULL; - gUnknown_203B2F8->unk158[loopMax].menuAction = 1; - - for(index = 0; index < loopMax; index++) - { - if(gUnknown_203B2F8->unk158[index].menuAction == gUnknown_203B2F8->menuAction3) - return; - } - gUnknown_203B2F8->menuAction3 = 4; -} - -void sub_802D73C(void) { - s32 loopMax; - s32 index; - - loopMax = 0; - gUnknown_203B2F8->unk158[loopMax].text = gCommonYes[0]; - gUnknown_203B2F8->unk158[loopMax].menuAction = 3; - loopMax += 1; - gUnknown_203B2F8->unk158[loopMax].text = gCommonNo[0]; - gUnknown_203B2F8->unk158[loopMax].menuAction = 4; - loopMax += 1; - gUnknown_203B2F8->unk158[loopMax].text = gUnknown_80E014C; - gUnknown_203B2F8->unk158[loopMax].menuAction = 6; - loopMax += 1; - gUnknown_203B2F8->unk158[loopMax].text = NULL; - gUnknown_203B2F8->unk158[loopMax].menuAction = 1; - - for(index = 0; index < loopMax; index++) - { - if(gUnknown_203B2F8->unk158[index].menuAction == gUnknown_203B2F8->menuAction2) - return; - } - gUnknown_203B2F8->menuAction2 = 4; -} - -void sub_802D7D0(void) -{ - s32 menuAction; - - if (sub_80144A4(&menuAction) == 0) { - if (menuAction != 1) { - gUnknown_203B2F8->menuAction2 = menuAction; - } - switch(menuAction) { - // Yes - case 3: - sub_802D1A0(WONDER_MAIL_EXIT); - break; - // New Mail - case 6: - gUnknown_203B2F8->fallbackState = 1; - sub_802D1A0(0x10); - break; - // No - case 4: - case 2: - default: - sub_802D1A0(INITIAL_WONDER_MAIL_CHECK); - break; - } - } -} - -void sub_802D82C(void) -{ - s32 menuAction; - - if (sub_80144A4(&menuAction) == 0) { - if (menuAction != 1) { - gUnknown_203B2F8->menuAction3 = menuAction; - } - switch(menuAction) { - // Yes - case 3: - ResetJobSlot(gUnknown_203B2F8->jobSlotIndex); - sub_8096C80(); - sub_802D1A0(RECEIVE_WONDER_MAIL); - break; - // New Mail - case 6: - gUnknown_203B2F8->fallbackState = 9; - sub_802D1A0(0x10); - break; - // Old Mail - case 7: - gUnknown_203B2F8->fallbackState = 9; - sub_802D1A0(0xf); - break; - // No - default: - case 1: - case 2: - case 4: - sub_802D1A0(1); - break; - } - } -} - -void sub_802D8CC(void) -{ - switch(sub_802C598(1)) { - case 0: - case 1: - break; - case 3: - gUnknown_203B2F8->jobSlotIndex = GetPelipperBoardSlotIndex(); - sub_802D1A0(0xd); - break; - case 4: - gUnknown_203B2F8->jobSlotIndex = GetPelipperBoardSlotIndex(); - gUnknown_203B2F8->fallbackState = DRAW_JOB_LIST_1; - sub_802D1A0(0xf); - break; - case 2: - sub_802C688(); - sub_802D1A0(1); - break; - } -} - -void sub_802D940(void) -{ - WonderMail *mail; - s32 menuAction; - - menuAction = 0; - sub_802C598(0); - if ((sub_8012FD8(&gUnknown_203B2F8->unk78) == 0) && (sub_8013114(&gUnknown_203B2F8->unk78,&menuAction), menuAction != 1)) { - gUnknown_203B2F8->menuAction1 = menuAction; - } - - switch(menuAction) - { - // Delete - case 2: - if ((gUnknown_203B2F8->unk9) && (((mail = &gUnknown_203B490->jobSlots[gUnknown_203B2F8->jobSlotIndex]), mail->mailType > MAIL_TYPE_SUSPENDED_JOB) && (gUnknown_203B2F8->dungeonID == mail->unk4.dungeon.id))) - { - sub_802D1A0(7); - } - else { - sub_802D1A0(0xE); - } - break; - // Info - case 5: - gUnknown_203B2F8->fallbackState = DRAW_JOB_LIST_1; - sub_802D1A0(0xf); - break; - case 1: - sub_802D1A0(DRAW_JOB_LIST_1); - break; - } -} - -void sub_802D9F0(void) -{ - s32 menuAction; - - menuAction = 0; - sub_802C598(0); - sub_8012FD8(&gUnknown_203B2F8->unk78); - if (sub_8012FD8(&gUnknown_203B2F8->unkC8) == 0) { - sub_8013114(&gUnknown_203B2F8->unkC8,&menuAction); - } - - switch(menuAction) - { - // No - case 1: - case 4: - sub_802D1A0(DRAW_JOB_LIST_1); - break; - // Yes - case 3: - sub_802C688(); - ResetJobSlot(gUnknown_203B2F8->jobSlotIndex); - sub_8096C80(); - sub_802D1A0(RECEIVE_WONDER_MAIL); - break; - } -} - -void sub_802DA60(void) -{ - switch(sub_802DEE0()) - { - case 2: - case 3: - sub_802DF24(); - sub_802D1A0(gUnknown_203B2F8->fallbackState); - break; - case 0: - case 1: - break; - } -} - -void AdvancetoFallbackWonderMailRescueState(void) -{ - s32 temp; - if(sub_80144A4(&temp) == 0) - { - sub_802D1A0(gUnknown_203B2F8->fallbackState); - } -} - -bool8 sub_802DAA8(void) -{ - WonderMail *mail; - - mail = GetJobSlotInfo(gUnknown_203B2F8->jobSlotIndex); - if (!gUnknown_203B2F8->unk9) { - return TRUE; - } - else { - if ( (mail->mailType != WONDER_MAIL_TYPE_THANK_YOU) && (gUnknown_203B2F8->dungeonID == mail->unk4.dungeon.id)) return FALSE; - return TRUE; - } -} - -bool8 sub_802DADC(void) -{ - u8 mailType; - WonderMail *mail; - s32 counter; - - if (!gUnknown_203B2F8->unk9) { -_0802DAE8: - return TRUE; - } - else { - for( mail = &gUnknown_203B490->jobSlots[0], counter = 0; counter < MAX_ACCEPTED_JOBS; mail++, counter++) - { - mailType = mail->mailType; - if (((mailType == 0) || (mailType == WONDER_MAIL_TYPE_THANK_YOU)) || - ((WONDER_MAIL_TYPE_THANK_YOU < mailType && (gUnknown_203B2F8->dungeonID != mail->unk4.dungeon.id)))) goto _0802DAE8; - } - return FALSE; - } -} - diff --git a/src/wonder_mail_3_mid.c b/src/wonder_mail_3_mid.c index 061c8abdc..a9253656c 100644 --- a/src/wonder_mail_3_mid.c +++ b/src/wonder_mail_3_mid.c @@ -5,22 +5,20 @@ #include "memory.h" #include "text1.h" #include "text2.h" -#include "wonder_mail.h" #include "pokemon.h" #include "pokemon_mid.h" #include "rescue_team_info.h" #include "friend_area.h" #include "items.h" #include "menu_input.h" -#include "code_802C39C.h" +#include "structs/str_802C39C.h" #include "code_80130A8.h" #include "code_80118A4.h" -#include "wonder_mail_3.h" #include "code_801B60C.h" #include "common_strings.h" #include "code_803B050.h" - -extern unkStruct_803B344 *sub_803B344(u8); +#include "wonder_mail_802CDD4.h" +#include "input.h" struct unkStruct_203B30C { @@ -104,12 +102,6 @@ extern void sub_802F1E8(void); extern void sub_802F004(); extern void sub_802F088(); extern void sub_802F108(void); -extern void sub_802CDD4(u32); -extern void sub_802CED8(u32); -extern void sub_802CFD0(void); -extern u8 sub_802CEBC(void); -extern u32 sub_802CE5C(u32); -extern void sub_802CF14(void); extern void sub_802F6FC(void); extern void ProceedToNextRewardSceneState(void); extern void sub_802F300(void); @@ -325,7 +317,7 @@ void sub_802F088(void) sub_802CDD4(0); break; case 1: - sub_802CED8(1); + sub_802CED8(TRUE); break; case 2: sub_802CFD0(); @@ -357,7 +349,7 @@ void sub_802F108(void) void sub_802F148(void) { - switch(sub_802CE5C(1)) + switch(sub_802CE5C(TRUE)) { case 0: case 1: @@ -378,7 +370,7 @@ void sub_802F184(void) s32 menuAction; menuAction = 0; - sub_802CE5C(0); + sub_802CE5C(FALSE); if (sub_8012FD8(&gUnknown_203B30C->unk60) == 0) { sub_8013114(&gUnknown_203B30C->unk60, &menuAction); diff --git a/src/wonder_mail_4.c b/src/wonder_mail_4.c index 31dc0a24a..f0acccb29 100644 --- a/src/wonder_mail_4.c +++ b/src/wonder_mail_4.c @@ -2,13 +2,13 @@ #include "global.h" #include "text1.h" #include "text2.h" -#include "input.h" #include "memory.h" +#include "input.h" #include "items.h" #include "pokemon.h" #include "code_8094F88.h" #include "constants/wonder_mail.h" -#include "code_802C39C.h" +#include "structs/str_802C39C.h" #include "menu_input.h" #include "code_80118A4.h" #include "code_803B050.h" diff --git a/src/wonder_mail_5.c b/src/wonder_mail_5.c index 363e5b1c5..337c35bb8 100644 --- a/src/wonder_mail_5.c +++ b/src/wonder_mail_5.c @@ -8,7 +8,7 @@ #include "pokemon.h" #include "code_8094F88.h" #include "code_800D090.h" -#include "code_802C39C.h" +#include "structs/str_802C39C.h" #include "menu_input.h" #include "code_80118A4.h" diff --git a/src/wonder_mail_6.c b/src/wonder_mail_6.c index 58f430f35..b82d8e7af 100644 --- a/src/wonder_mail_6.c +++ b/src/wonder_mail_6.c @@ -1,4 +1,5 @@ #include "global.h" +#include "input.h" #include "memory.h" #include "text1.h" #include "text2.h" diff --git a/src/wonder_mail_802C10C.c b/src/wonder_mail_802C10C.c index 9d3044d98..81b4534b6 100644 --- a/src/wonder_mail_802C10C.c +++ b/src/wonder_mail_802C10C.c @@ -3,6 +3,7 @@ #include "code_803B050.h" #include "code_80958E8_1.h" #include "constants/input.h" +#include "input.h" #include "memory.h" #include "menu_input.h" #include "text1.h" diff --git a/src/wonder_mail_802C4C8.c b/src/wonder_mail_802C4C8.c new file mode 100644 index 000000000..3f3c9178a --- /dev/null +++ b/src/wonder_mail_802C4C8.c @@ -0,0 +1,222 @@ +#include "global.h" +#include "code_80118A4.h" +#include "code_803B050.h" +#include "code_80958E8_1.h" +#include "constants/input.h" +#include "input.h" +#include "memory.h" +#include "menu_input.h" +#include "structs/str_802C39C.h" +#include "structs/str_wonder_mail.h" +#include "text1.h" +#include "text2.h" +#include "wonder_mail_802C4C8.h" + +static EWRAM_DATA_2 struct unkStruct_203B2E8* gUnknown_203B2E8 = {0}; +static EWRAM_DATA_2 u16 gUnknown_203B2EC = {0}; + +#include "data/wonder_mail_802C4C8.h" + +static s32 CountAcceptedJobs(void); + +static void sub_802C6DC(void); + +bool8 sub_802C4C8(s32 a0, UnkTextStruct2_sub *a1, u32 a2) +{ + if (HasNoAcceptedJobs()) + return FALSE; + + gUnknown_203B2E8 = MemoryAlloc(sizeof(struct unkStruct_203B2E8), 8); + gUnknown_203B2E8->unk3C = a0; + gUnknown_203B2E8->unk40 = &gUnknown_203B2E8->unk44[a0]; + sub_8006518(gUnknown_203B2E8->unk44); + + gUnknown_203B2E8->unk44[gUnknown_203B2E8->unk3C] = sUnknown_80DFCFC; + gUnknown_203B2E8->unk40->unk14 = gUnknown_203B2E8->unkA4; + + if (a1 != NULL) + gUnknown_203B2E8->unk44[gUnknown_203B2E8->unk3C].unk8 = *a1; + + sub_8012D34(gUnknown_203B2E8->unk40, a2); + ResetUnusedInputStruct(); + sub_800641C(gUnknown_203B2E8->unk44, TRUE, TRUE); + sub_8013848(&gUnknown_203B2E8->input, CountAcceptedJobs(), a2, a0); + gUnknown_203B2E8->input.menuIndex = gUnknown_203B2EC; + sub_8013984(&gUnknown_203B2E8->input); + sub_802C6DC(); + DrawJobListMenu(); + return TRUE; +} + +u32 sub_802C598(bool8 a0) +{ + if (!a0) { + sub_8013660(&gUnknown_203B2E8->input); + return 0; + } + + switch (GetKeyPress(&gUnknown_203B2E8->input)) { + case INPUT_B_BUTTON: + PlayMenuSoundEffect(1); + return 2; + case INPUT_A_BUTTON: + PlayMenuSoundEffect(0); + return 3; + case INPUT_START_BUTTON: + PlayMenuSoundEffect(4); + return 4; + } + + if (sub_80138B8(&gUnknown_203B2E8->input, 1)) { + sub_802C6DC(); + DrawJobListMenu(); + return 1; + } + return 0; +} + +u8 GetPelipperBoardSlotIndex(void) +{ + return gUnknown_203B2E8->pelipperBoardSlots[(gUnknown_203B2E8->input.unk1E * gUnknown_203B2E8->input.unk1C) + gUnknown_203B2E8->input.menuIndex]; +} + +void sub_802C640(bool8 cursorSprite) +{ + ResetUnusedInputStruct(); + sub_800641C(gUnknown_203B2E8->unk44, FALSE, FALSE); + gUnknown_203B2E8->input.unk22 = CountAcceptedJobs(); + sub_8013984(&gUnknown_203B2E8->input); + sub_802C6DC(); + DrawJobListMenu(); + + if (cursorSprite) + AddMenuCursorSprite(&gUnknown_203B2E8->input); +} + +void sub_802C688(void) +{ + if (gUnknown_203B2E8 != NULL) { + gUnknown_203B2EC = gUnknown_203B2E8->input.menuIndex; + gUnknown_203B2E8->unk44[gUnknown_203B2E8->unk3C] = sUnknown_80DFCE4; + ResetUnusedInputStruct(); + sub_800641C(gUnknown_203B2E8->unk44, TRUE, TRUE); + MemoryFree(gUnknown_203B2E8); + gUnknown_203B2E8 = NULL; + } +} + +NAKED +static void sub_802C6DC(void) +{ + asm_unified("\tpush {r4,lr}\n" + "\tldr r4, _0802C74C\n" + "\tldr r0, [r4]\n" + "\tldrh r1, [r0, 0x28]\n" + "\tadds r0, 0xA4\n" + "\tmovs r2, 0\n" + "\tstrb r1, [r0]\n" + "\tldr r0, [r4]\n" + "\tldrh r1, [r0, 0x26]\n" + "\tadds r0, 0xA5\n" + "\tstrb r1, [r0]\n" + "\tldr r0, [r4]\n" + "\tadds r0, 0xA6\n" + "\tmovs r1, 0xC\n" + "\tstrb r1, [r0]\n" + "\tldr r0, [r4]\n" + "\tadds r0, 0xA7\n" + "\tstrb r2, [r0]\n" + "\tldr r0, [r4]\n" + "\tmovs r1, 0x22\n" + "\tldrsh r0, [r0, r1]\n" + "\tmovs r1, 0x18\n" + "\tbl sub_8009614\n" + "\tadds r0, 0x2\n" + "\tlsls r0, 16\n" + "\tldr r2, [r4]\n" + "\tldr r3, [r2, 0x3C]\n" + "\tlsls r1, r3, 1\n" + "\tadds r1, r3\n" + "\tlsls r1, 3\n" + "\tadds r1, r2, r1\n" + "\tadds r1, 0x52\n" + "\tasrs r3, r0, 16\n" + "\tlsrs r0, 16\n" + "\tstrh r0, [r1]\n" + "\tldr r1, [r2, 0x3C]\n" + "\tlsls r0, r1, 1\n" + "\tadds r0, r1\n" + "\tlsls r0, 3\n" + "\tadds r2, r0\n" + "\tadds r3, 0x2\n" + "\tadds r2, 0x54\n" + "\tstrh r3, [r2]\n" + "\tbl ResetUnusedInputStruct\n" + "\tldr r0, [r4]\n" + "\tadds r0, 0x44\n" + "\tmovs r1, 0x1\n" + "\tmovs r2, 0x1\n" + "\tbl sub_800641C\n" + "\tpop {r4}\n" + "\tpop {r0}\n" + "\tbx r0\n" + "\t.align 2, 0\n" +"_0802C74C: .4byte gUnknown_203B2E8"); +} + +void DrawJobListMenu(void) +{ + WonderMail *mail; + s32 i; + s32 r4; + s32 x; + unkStruct_802C39C local; + + sub_8008C54(gUnknown_203B2E8->unk3C); + sub_80073B8(gUnknown_203B2E8->unk3C); + r4 = gUnknown_203B2E8->input.unk1E * 8; + x = r4; + x += 10; + xxx_call_draw_string(x, 0, sJobList, gUnknown_203B2E8->unk3C, 0); + + r4 += 4; + x = r4 + (gUnknown_203B2E8->unkA4[2] * 8); + sub_8012BC4(x, 0, gUnknown_203B2E8->input.unk1E + 1, 2, 7, gUnknown_203B2E8->unk3C); + + for (i = 0; i < gUnknown_203B2E8->input.unk1A; i++) { + mail = GetJobSlotInfo(gUnknown_203B2E8->pelipperBoardSlots[(gUnknown_203B2E8->input.unk1E * gUnknown_203B2E8->input.unk1C) + i]); + local.unk0[0] = gUnknown_203B2E8->unk3C; + local.y = sub_8013800(&gUnknown_203B2E8->input, i); + sub_803B35C(mail, &local); + CreateRescueTitle(&local); + } + + sub_80073E0(gUnknown_203B2E8->unk3C); +} + +static s32 CountAcceptedJobs(void) +{ + s32 i; + s32 sum = 0; + + for (i = 0; i < MAX_ACCEPTED_JOBS; i++) { + if (!IsJobSlotEmpty(i)) { + gUnknown_203B2E8->pelipperBoardSlots[sum] = i; + sum++; + } + } + + return sum; +} + +bool8 HasNoAcceptedJobs(void) +{ + s32 i; + + for (i = 0; i < MAX_ACCEPTED_JOBS; i++) { + if (!IsJobSlotEmpty(i)) + return FALSE; + } + + return TRUE; +} \ No newline at end of file diff --git a/src/wonder_mail_802C860.c b/src/wonder_mail_802C860.c new file mode 100644 index 000000000..95c69b0ae --- /dev/null +++ b/src/wonder_mail_802C860.c @@ -0,0 +1,310 @@ +#include "global.h" +#include "code_80118A4.h" +#include "code_803B050.h" +#include "code_802DE84.h" +#include "code_80958E8_1.h" +#include "code_8096AF8.h" +#include "code_80A26CC.h" +#include "common_strings.h" +#include "input.h" +#include "memory.h" +#include "menu_input.h" +#include "wonder_mail_802C4C8.h" +#include "wonder_mail_802C860.h" +#include "text1.h" +#include "text2.h" + +static EWRAM_DATA_2 struct unkStruct_203B2F0 *sUnknown_203B2F0 = {0}; + +#include "data/wonder_mail_802C860.h" + +static void SetJobListState(u32 newState); + +static void sub_802C928(void); +static void sub_802C9D8(void); +static void sub_802CAA4(void); +static void sub_802CBAC(void); +static void sub_802CC00(void); +static void sub_802CC70(void); +static void sub_802CD38(void); +static void sub_802CDB8(void); + +bool8 InitializeJobListMenu(u32 a0) +{ + if (HasNoAcceptedJobs()) + return FALSE; + + sUnknown_203B2F0 = MemoryAlloc(sizeof(struct unkStruct_203B2F0), 8); + sUnknown_203B2F0->menuAction = 0; + sUnknown_203B2F0->unk0 = a0; + SetJobListState(0); + return TRUE; +} + +u32 sub_802C898(void) +{ + switch (sUnknown_203B2F0->state) { + case 0: + case 1: + sub_802CC00(); + break; + case 2: + sub_802CC70(); + break; + case 3: + sub_802CD38(); + break; + case 4: + sub_802CDB8(); + break; + case 5: + default: + return 3; + } + return 0; +} + +void sub_802C8F4(void) +{ + if (sUnknown_203B2F0 != NULL) { + MemoryFree(sUnknown_203B2F0); + sUnknown_203B2F0 = NULL; + } +} + +static void SetJobListState(u32 newState) +{ + sUnknown_203B2F0->state = newState; + sub_802C928(); + sub_802C9D8(); +} + +static void sub_802C928(void) +{ + s32 i; + + sub_8006518(sUnknown_203B2F0->unk19C); + + switch (sUnknown_203B2F0->state) { + case 2: + sub_802CAA4(); + sUnknown_203B2F0->unk19C[2] = sUnknown_80DFD40; + sub_8012CAC(&sUnknown_203B2F0->unk19C[2], sUnknown_203B2F0->unk10C); + break; + case 3: + sUnknown_203B2F0->unk19C[3] = sUnknown_80DFD58; + break; + default: + for (i = 0; i < 4; i++) + sUnknown_203B2F0->unk19C[i] = sUnknown_80DFD28; + break; + } + + ResetUnusedInputStruct(); + sub_800641C(sUnknown_203B2F0->unk19C, TRUE, TRUE); +} + +static void sub_802C9D8(void) +{ + switch (sUnknown_203B2F0->state) { + case 0: + sub_802C4C8(0, NULL, 4); + break; + case 1: + sub_802C640(TRUE); + break; + case 2: + DrawJobListMenu(); + sub_8012D60(&sUnknown_203B2F0->unk6C, sUnknown_203B2F0->unk10C, 0, 0, sUnknown_203B2F0->menuAction, 2); + break; + case 3: + sub_802CBAC(); + DrawJobListMenu(); + sub_8012EA4(&sUnknown_203B2F0->unk6C, 0); + sub_8012D60(&sUnknown_203B2F0->unkBC, sUnknown_203B2F0->unk14C, 0, 0, 6, 3); + break; + case 4: + sub_803B35C(GetJobSlotInfo(sUnknown_203B2F0->unkC), &sUnknown_203B2F0->unk10); + sUnknown_203B2F0->unk10.unk0[0] = 3; + sub_802DE84(&sUnknown_203B2F0->unk10); + break; + case 5: + default: + break; + } +} + +static void sub_802CAA4(void) +{ + s32 loopMax; + WonderMail *mail; + s32 i; + + loopMax = 0; + mail = GetJobSlotInfo(sUnknown_203B2F0->unkC); + + if (sUnknown_203B2F0->unk0 == 0) { + switch (mail->mailType) { + case 5: + sUnknown_203B2F0->unk10C[loopMax].text = sTakeJob; + + if (sub_809693C(mail) || !sub_80A2824(mail->unk4.dungeon.id)) + sUnknown_203B2F0->unk10C[loopMax].menuAction = -1; + else + sUnknown_203B2F0->unk10C[loopMax].menuAction = 2; + + loopMax++; + break; + case 6: + sUnknown_203B2F0->unk10C[loopMax].text = sSuspend; + sUnknown_203B2F0->unk10C[loopMax].menuAction = 3; + loopMax++; + break; + } + } + + sUnknown_203B2F0->unk10C[loopMax].text = gCommonDelete[0]; + sUnknown_203B2F0->unk10C[loopMax].menuAction = 4; + + loopMax++; + sUnknown_203B2F0->unk10C[loopMax].text = gCommonInfo[0]; + sUnknown_203B2F0->unk10C[loopMax].menuAction = 7; + + loopMax++; + sUnknown_203B2F0->unk10C[loopMax].text = NULL; + sUnknown_203B2F0->unk10C[loopMax].menuAction = 1; + + for (i = 0; i < loopMax; i++) { + if (sUnknown_203B2F0->unk10C[i].menuAction != -1) { + if (sUnknown_203B2F0->unk10C[i].menuAction == sUnknown_203B2F0->menuAction) + return; + } + } + + sUnknown_203B2F0->menuAction = 7; +} + +static void sub_802CBAC(void) +{ + s32 loopMax; + + loopMax = 0; + sUnknown_203B2F0->unk14C[loopMax].text = gCommonYes[0]; + sUnknown_203B2F0->unk14C[loopMax].menuAction = 5; + + loopMax++; + sUnknown_203B2F0->unk14C[loopMax].text = gCommonNo[0]; + sUnknown_203B2F0->unk14C[loopMax].menuAction = 6; + + loopMax++; + sUnknown_203B2F0->unk14C[loopMax].text = NULL; + sUnknown_203B2F0->unk14C[loopMax].menuAction = 1; +} + +static void sub_802CC00(void) +{ + switch (sub_802C598(TRUE)) { + case 3: + sUnknown_203B2F0->unkC = GetPelipperBoardSlotIndex(); + SetJobListState(2); + break; + case 4: + sUnknown_203B2F0->unkC = GetPelipperBoardSlotIndex(); + SetJobListState(4); + break; + case 0: + case 1: + break; + case 2: + sub_802C688(); + SetJobListState(5); + break; + } +} + +static void sub_802CC70(void) +{ + s32 menuAction; + WonderMail *mail; + WonderMail *mail2; + + menuAction = 0; + + sub_802C598(FALSE); + + if (!sub_8012FD8(&sUnknown_203B2F0->unk6C)) { + sub_8013114(&sUnknown_203B2F0->unk6C, &menuAction); + + if (menuAction != 1) + sUnknown_203B2F0->menuAction = menuAction; + } + + switch (menuAction) { + case 2: + PlaySound(307); + mail = GetJobSlotInfo(sUnknown_203B2F0->unkC); + mail->mailType = MAIL_TYPE_TAKEN_JOB; + SetJobListState(1); + break; + case 3: + PlaySound(307); + mail2 = GetJobSlotInfo(sUnknown_203B2F0->unkC); + mail2->mailType = MAIL_TYPE_SUSPENDED_JOB; + SetJobListState(1); + break; + case 4: + SetJobListState(3); + break; + case 7: + SetJobListState(4); + break; + case 1: + SetJobListState(1); + break; + } +} + +static void sub_802CD38(void) +{ + s32 menuAction; + + menuAction = 0; + + sub_802C598(FALSE); + sub_8012FD8(&sUnknown_203B2F0->unk6C); + + if (!sub_8012FD8(&sUnknown_203B2F0->unkBC)) + sub_8013114(&sUnknown_203B2F0->unkBC, &menuAction); + + switch (menuAction) { + case 1: + case 6: + SetJobListState(1); + break; + case 5: + ResetJobSlot(sUnknown_203B2F0->unkC); + sub_8096C80(); + + if (HasNoAcceptedJobs()) { + sub_802C688(); + SetJobListState(5); + } + else + SetJobListState(1); + break; + } +} + +static void sub_802CDB8(void) +{ + switch (sub_802DEE0()) { + case 2: + case 3: + sub_802DF24(); + SetJobListState(1); + break; + case 0: + case 1: + break; + } +} \ No newline at end of file diff --git a/src/wonder_mail_802CDD4.c b/src/wonder_mail_802CDD4.c new file mode 100644 index 000000000..b3bda2362 --- /dev/null +++ b/src/wonder_mail_802CDD4.c @@ -0,0 +1,180 @@ +#include "global.h" +#include "code_80118A4.h" +#include "code_803B050.h" +#include "constants/input.h" +#include "input.h" +#include "memory.h" +#include "menu_input.h" +#include "structs/str_802C39C.h" +#include "structs/str_wonder_mail.h" +#include "text1.h" +#include "text2.h" +#include "wonder_mail_802CDD4.h" + +static EWRAM_DATA_2 unkStruct_203B2F4 *sUnknown_203B2F4 = {0}; + +#include "data/wonder_mail_802CDD4.h" + +static void sub_802CF5C(void); + +bool8 sub_802CDD4(u32 a0) +{ + if (sUnknown_203B2F4 == NULL) + sUnknown_203B2F4 = MemoryAlloc(sizeof(unkStruct_203B2F4), 8); + + sUnknown_203B2F4->unk34 = a0; + sUnknown_203B2F4->unk38 = &sUnknown_203B2F4->unk3C[sUnknown_203B2F4->unk34]; + sub_8006518(sUnknown_203B2F4->unk3C); + sUnknown_203B2F4->unk3C[sUnknown_203B2F4->unk34] = sUnknown_80DFDA4; + sUnknown_203B2F4->unk38->unk14 = sUnknown_203B2F4->unk9C; + sub_8012D34(sUnknown_203B2F4->unk38, 4); + ResetUnusedInputStruct(); + sub_800641C(sUnknown_203B2F4->unk3C, TRUE, TRUE); + sub_8013848(&sUnknown_203B2F4->input, 5, 4, a0); + sub_802CF5C(); + sub_802CFD0(); + return TRUE; +} + +u32 sub_802CE5C(bool8 a0) +{ + if (!a0) { + sub_8013660(&sUnknown_203B2F4->input); + return 0; + } + + switch (GetKeyPress(&sUnknown_203B2F4->input)) { + case INPUT_B_BUTTON: + PlayMenuSoundEffect(1); + return 2; + case INPUT_A_BUTTON: + return 3; + default: + if (sub_80138B8(&sUnknown_203B2F4->input, TRUE)) { + sub_802CF5C(); + sub_802CFD0(); + return 1; + } + return 0; + } +} + +u8 sub_802CEBC(void) +{ + return (sUnknown_203B2F4->input.unk1E * sUnknown_203B2F4->input.unk1C) + sUnknown_203B2F4->input.menuIndex; +} + +void sub_802CED8(bool8 cursorSprite) +{ + ResetUnusedInputStruct(); + sub_800641C(sUnknown_203B2F4->unk3C, FALSE, FALSE); + sub_8013984(&sUnknown_203B2F4->input); + sub_802CF5C(); + sub_802CFD0(); + + if (cursorSprite) + AddMenuCursorSprite(&sUnknown_203B2F4->input); +} + +void sub_802CF14(void) +{ + if (sUnknown_203B2F4 != NULL) { + sUnknown_203B2F4->unk3C[sUnknown_203B2F4->unk34] = sUnknown_80DFD8C; + ResetUnusedInputStruct(); + sub_800641C(sUnknown_203B2F4->unk3C, TRUE, TRUE); + MemoryFree(sUnknown_203B2F4); + sUnknown_203B2F4 = NULL; + } +} + +NAKED +static void sub_802CF5C(void) +{ + asm_unified( + "\tpush {r4,lr}\n" + "\tldr r4, _0802CFCC\n" + "\tldr r0, [r4]\n" + "\tldrh r1, [r0, 0x20]\n" + "\tadds r0, 0x9C\n" + "\tmovs r2, 0\n" + "\tstrb r1, [r0]\n" + "\tldr r0, [r4]\n" + "\tldrh r1, [r0, 0x1E]\n" + "\tadds r0, 0x9D\n" + "\tstrb r1, [r0]\n" + "\tldr r0, [r4]\n" + "\tadds r0, 0x9E\n" + "\tmovs r1, 0xC\n" + "\tstrb r1, [r0]\n" + "\tldr r0, [r4]\n" + "\tadds r0, 0x9F\n" + "\tstrb r2, [r0]\n" + "\tldr r0, [r4]\n" + "\tmovs r1, 0x1A\n" + "\tldrsh r0, [r0, r1]\n" + "\tmovs r1, 0x18\n" + "\tbl sub_8009614\n" + "\tadds r0, 0x2\n" + "\tlsls r0, 16\n" + "\tldr r2, [r4]\n" + "\tldr r3, [r2, 0x34]\n" + "\tlsls r1, r3, 1\n" + "\tadds r1, r3\n" + "\tlsls r1, 3\n" + "\tadds r1, r2, r1\n" + "\tadds r1, 0x4A\n" + "\tasrs r3, r0, 16\n" + "\tlsrs r0, 16\n" + "\tstrh r0, [r1]\n" + "\tldr r1, [r2, 0x34]\n" + "\tlsls r0, r1, 1\n" + "\tadds r0, r1\n" + "\tlsls r0, 3\n" + "\tadds r2, r0\n" + "\tadds r3, 0x2\n" + "\tadds r2, 0x4C\n" + "\tstrh r3, [r2]\n" + "\tbl ResetUnusedInputStruct\n" + "\tldr r0, [r4]\n" + "\tadds r0, 0x3C\n" + "\tmovs r1, 0x1\n" + "\tmovs r2, 0x1\n" + "\tbl sub_800641C\n" + "\tpop {r4}\n" + "\tpop {r0}\n" + "\tbx r0\n" + "\t.align 2, 0\n" +"_0802CFCC: .4byte sUnknown_203B2F4"); +} + +void sub_802CFD0(void) +{ + unkStruct_802C39C local; + unkStruct_803B344 *iVar1; + s32 r5; + s32 r4; + + sub_8008C54(sUnknown_203B2F4->unk34); + sub_80073B8(sUnknown_203B2F4->unk34); + + r5 = r4 = (sUnknown_203B2F4->input.unk1E * 8) + 10; + xxx_call_draw_string(r5, 0, sRescueEvent, sUnknown_203B2F4->unk34, 0); + + r4 -= 6; + r5 = r4 + (sUnknown_203B2F4->unk9C[2] * 8); + sub_8012BC4(r5, 0, sUnknown_203B2F4->input.unk1E + 1, 2, 7, sUnknown_203B2F4->unk34); + + for (r5 = 0; r5 < sUnknown_203B2F4->input.unk1A; r5++) { + iVar1 = sub_803B344((sUnknown_203B2F4->input.unk1E * sUnknown_203B2F4->input.unk1C) + r5); + + local.unk0[0] = sUnknown_203B2F4->unk34; + local.y = sub_8013800(&sUnknown_203B2F4->input, r5); + sub_803B35C(&iVar1->mail, &local); + + local.unk43 = 1; + local.unk4C = iVar1->unk14; + CreateRescueTitle(&local); + } + + sub_80073E0(sUnknown_203B2F4->unk34); +} \ No newline at end of file diff --git a/src/wonder_mail_802D098.c b/src/wonder_mail_802D098.c new file mode 100644 index 000000000..9c74965b0 --- /dev/null +++ b/src/wonder_mail_802D098.c @@ -0,0 +1,579 @@ +#include "global.h" +#include "code_80130A8.h" +#include "code_802DE84.h" +#include "code_803B050.h" +#include "code_80958E8_1.h" +#include "code_8096AF8.h" +#include "code_80972F4.h" +#include "code_8098BDC.h" +#include "common_strings.h" +#include "constants/dungeon.h" +#include "input.h" +#include "memory.h" +#include "menu_input.h" +#include "save.h" +#include "text1.h" +#include "text2.h" +#include "wonder_mail_802C4C8.h" +#include "wonder_mail_802D098.h" + +enum WonderMailRescueStates +{ + INITIAL_WONDER_MAIL_CHECK = 0, + // 1 + WONDER_MAIL_EXIT = 2, + DUPLICATE_WONDER_MAIL, + DUPLICATE_WONDER_MAIL_1, + // 5 - 7 + RECEIVE_WONDER_MAIL = 8, + // 9 + JOB_LIST_FULL = 10, + DRAW_JOB_LIST, + DRAW_JOB_LIST_1, + // 13 - 16 +}; + +static EWRAM_DATA_2 unkStruct_203B2F8 *sUnknown_203B2F8 = {0}; + +#include "data/wonder_mail_802D098.h" + +static void AdvancetoFallbackWonderMailRescueState(void); + +static void sub_802D1A0(u32 newState); +static void sub_802D1B8(void); +static void sub_802D2A8(void); +static void sub_802D5A4(void); +static void sub_802D63C(void); +static void sub_802D690(void); +static void sub_802D73C(void); +static void sub_802D7D0(void); +static void sub_802D82C(void); +static void sub_802D8CC(void); +static void sub_802D940(void); +static void sub_802D9F0(void); +static void sub_802DA60(void); +static bool8 sub_802DAA8(void); +static bool8 sub_802DADC(void); + +bool8 sub_802D098(unkSubStruct_203B2F8 *mail) +{ + sUnknown_203B2F8 = MemoryAlloc(sizeof(unkStruct_203B2F8), 8); + sUnknown_203B2F8->menuAction1 = 0; + sUnknown_203B2F8->menuAction2 = 0; + sUnknown_203B2F8->menuAction3 = 0; + sUnknown_203B2F8->mail = mail; + sUnknown_203B2F8->wonderMailAccepted = FALSE; + sUnknown_203B2F8->unk9 = sub_8099328(&sUnknown_203B2F8->dungeonID); + + if (sub_8011C1C() != 2) + sUnknown_203B2F8->unk9 = FALSE; + + sub_802D1A0(INITIAL_WONDER_MAIL_CHECK); + return TRUE; +} + +u32 sub_802D0E0(void) +{ + switch (sUnknown_203B2F8->state) { + case INITIAL_WONDER_MAIL_CHECK: + break; + case 1: + sub_802D7D0(); + break; + case DRAW_JOB_LIST: + case DRAW_JOB_LIST_1: + sub_802D8CC(); + break; + case 13: + sub_802D940(); + break; + case 14: + sub_802D9F0(); + break; + case 15: + case 16: + sub_802DA60(); + break; + case 9: + sub_802D82C(); + break; + case WONDER_MAIL_EXIT: + return 3; + default: + AdvancetoFallbackWonderMailRescueState(); + break; + } + return 0; +} + +bool8 GetWonderMailAccepted(void) +{ + return sUnknown_203B2F8->wonderMailAccepted; +} + +void sub_802D184(void) +{ + if (sUnknown_203B2F8 != NULL) { + MemoryFree(sUnknown_203B2F8); + sUnknown_203B2F8 = NULL; + } +} + +static void sub_802D1A0(u32 newState) +{ + sUnknown_203B2F8->state = newState; + sub_802D1B8(); + sub_802D2A8(); +} + +static void sub_802D1B8(void) +{ + s32 i; + + sub_8006518(sUnknown_203B2F8->unk1A8); + + switch (sUnknown_203B2F8->state) { + case 13: + sub_802D5A4(); + sUnknown_203B2F8->unk1A8[2] = sUnknown_80DFE04; + sub_8012CAC(&sUnknown_203B2F8->unk1A8[2], sUnknown_203B2F8->unk118); + sUnknown_203B2F8->unk1A8[2].unkC = 6; + break; + case 14: + sub_802D63C(); + sUnknown_203B2F8->unk1A8[3] = sUnknown_80DFE1C; + sub_8012CAC(&sUnknown_203B2F8->unk1A8[3], sUnknown_203B2F8->unk158); + sUnknown_203B2F8->unk1A8[3].unkC = 6; + break; + default: + for (i = 0; i < 4; i++) + sUnknown_203B2F8->unk1A8[i] = sUnknown_80DFDD4; + break; + case WONDER_MAIL_EXIT: + break; + } + + ResetUnusedInputStruct(); + sub_800641C(sUnknown_203B2F8->unk1A8, TRUE, TRUE); +} + +static void sub_802D2A8(void) +{ + switch (sUnknown_203B2F8->state) { + case INITIAL_WONDER_MAIL_CHECK: + if (IsMailinJobSlot(&sUnknown_203B2F8->mail->wonderMail)) + sub_802D1A0(DUPLICATE_WONDER_MAIL); + else if (sub_8096F50(&sUnknown_203B2F8->mail->wonderMail)) + sub_802D1A0(DUPLICATE_WONDER_MAIL_1); + else if (sUnknown_203B2F8->mail->wonderMail.unk2 == 4 && sub_8096C08(&sUnknown_203B2F8->jobSlotIndex)) { + if (sub_802DAA8()) + sub_802D1A0(9); + else + sub_802D1A0(5); + } + else if (GetNumAcceptedJobs() >= MAX_ACCEPTED_JOBS) { + if (sub_802DADC()) + sub_802D1A0(JOB_LIST_FULL); + else + sub_802D1A0(6); + } + else + sub_802D1A0(RECEIVE_WONDER_MAIL); + break; + case 1: + sub_802D73C(); + sub_8014248(sReplaceOldMailPrompt, 0, sUnknown_203B2F8->menuAction2, sUnknown_203B2F8->unk158, 0, 4, 0, NULL, 0); + break; + case DUPLICATE_WONDER_MAIL: + sUnknown_203B2F8->fallbackState = WONDER_MAIL_EXIT; + sub_80141B4(sMailAlreadyReceived, 0, NULL, 0x101); + break; + case DUPLICATE_WONDER_MAIL_1: + sUnknown_203B2F8->fallbackState = WONDER_MAIL_EXIT; + sub_80141B4(sMailAlreadyReceivedMayNotReceiveAgain, 0, NULL, 0x101); + break; + case 5: + sUnknown_203B2F8->fallbackState = WONDER_MAIL_EXIT; + sub_80141B4(sOnlyOneMailCanBeHeldPleaseCompleteFirst, 0, NULL, 0x101); + break; + case 6: + sUnknown_203B2F8->fallbackState = WONDER_MAIL_EXIT; + sub_80141B4(sTeamQuicksavedCompleteFirst, 0, NULL, 0x101); + break; + case 7: + sUnknown_203B2F8->fallbackState = DRAW_JOB_LIST_1; + sub_80141B4(sTeamQuicksavedCannotDelete, 0, NULL, 0x101); + break; + case RECEIVE_WONDER_MAIL: + sUnknown_203B2F8->wonderMailAccepted = TRUE; + AcceptJob(&sUnknown_203B2F8->mail->wonderMail); + sub_8096C80(); + sub_8096D24(); + + if (sUnknown_203B2F8->mail->wonderMail.unk2 == 4) { + MemoryCopy8(sub_8096DD8(), sUnknown_203B2F8->mail->unk14, 40); + MemoryCopy8(sub_8096DE8(), sUnknown_203B2F8->mail->unk18, 120); + } + + switch (sUnknown_203B2F8->mail->wonderMail.unk4.dungeon.id) { + case DUNGEON_ODDITY_CAVE: + sub_8097418(DUNGEON_ODDITY_CAVE - 1, 1); + break; + case DUNGEON_REMAINS_ISLAND: + sub_8097418(DUNGEON_REMAINS_ISLAND - 1, 1); + break; + case DUNGEON_MARVELOUS_SEA: + sub_8097418(DUNGEON_MARVELOUS_SEA - 1, 1); + break; + case DUNGEON_FANTASY_STRAIT: + sub_8097418(DUNGEON_FANTASY_STRAIT - 1, 1); + break; + } + + sUnknown_203B2F8->fallbackState = WONDER_MAIL_EXIT; + sub_80141B4(sReceivedWonderMail, 0, NULL, 0x101); + break; + case 9: + sub_802D690(); + sub_8014248(sOnlyOneMailCanBeHeldSoReplacePrompt,0,sUnknown_203B2F8->menuAction3,sUnknown_203B2F8->unk158,0,4,0,0,0); + break; + case JOB_LIST_FULL: + sUnknown_203B2F8->fallbackState = DRAW_JOB_LIST; + sub_80141B4(sJobListFullPleaseDelete, 0, NULL, 0x101); + break; + case DRAW_JOB_LIST: + sub_802C4C8(0, NULL, 4); + break; + case DRAW_JOB_LIST_1: + sub_802C640(TRUE); + break; + case 0xd: + DrawJobListMenu(); + sub_8012D60(&sUnknown_203B2F8->unk78, sUnknown_203B2F8->unk118, NULL, sUnknown_203B2F8->unk198, sUnknown_203B2F8->menuAction1, 2); + break; + case 0xe: + DrawJobListMenu(); + sub_8012EA4(&sUnknown_203B2F8->unk78, 0); + sub_8012D60(&sUnknown_203B2F8->unkC8, sUnknown_203B2F8->unk158, NULL, NULL, 4, 3); + break; + case 0xf: + sub_803B35C(GetJobSlotInfo(sUnknown_203B2F8->jobSlotIndex), &sUnknown_203B2F8->unk14); + sUnknown_203B2F8->unk14.unk0[0] = 3; + sub_802DE84(&sUnknown_203B2F8->unk14); + break; + case 0x10: + sub_803B35C(&sUnknown_203B2F8->mail->wonderMail, &sUnknown_203B2F8->unk14); + sUnknown_203B2F8->unk14.unk0[0] = 3; + sUnknown_203B2F8->unk14.mailStatus = MAIL_STATUS_SUSPENDED; + sUnknown_203B2F8->unk14.unk50 = sUnknown_203B2F8->mail->unk18; + sub_802DE84(&sUnknown_203B2F8->unk14); + break; + } +} + +static void sub_802D5A4(void) +{ + s32 loopMax; + s32 i; + + loopMax = 0; + MemoryFill16(sUnknown_203B2F8->unk198, 0, sizeof(sUnknown_203B2F8->unk198)); + sUnknown_203B2F8->unk118[loopMax].text = gCommonDelete[0]; + sUnknown_203B2F8->unk118[loopMax].menuAction = 2; + + loopMax++; + sUnknown_203B2F8->unk118[loopMax].text = gCommonInfo[0]; + sUnknown_203B2F8->unk118[loopMax].menuAction = 5; + + loopMax++; + sUnknown_203B2F8->unk118[loopMax].text = NULL; + sUnknown_203B2F8->unk118[loopMax].menuAction = 1; + + for (i = 0; i < loopMax; i++) { + if (sUnknown_203B2F8->unk198[i] == 0) { + if (sUnknown_203B2F8->unk118[i].menuAction == sUnknown_203B2F8->menuAction1) + return; + } + } + + sUnknown_203B2F8->menuAction1 = 2; +} + +static void sub_802D63C(void) +{ + s32 loopMax; + + loopMax = 0; + sUnknown_203B2F8->unk158[loopMax].text = gCommonYes[0]; + sUnknown_203B2F8->unk158[loopMax].menuAction = 3; + + loopMax++; + sUnknown_203B2F8->unk158[loopMax].text = gCommonNo[0]; + sUnknown_203B2F8->unk158[loopMax].menuAction = 4; + + loopMax++; + sUnknown_203B2F8->unk158[loopMax].text = NULL; + sUnknown_203B2F8->unk158[loopMax].menuAction = 1; +} + +static void sub_802D690(void) +{ + s32 loopMax; + s32 i; + + loopMax = 0; + sUnknown_203B2F8->unk158[loopMax].text = gCommonYes[0]; + sUnknown_203B2F8->unk158[loopMax].menuAction = 3; + + loopMax++; + sUnknown_203B2F8->unk158[loopMax].text = gCommonNo[0]; + sUnknown_203B2F8->unk158[loopMax].menuAction = 4; + + loopMax++; + sUnknown_203B2F8->unk158[loopMax].text = sNewMail; + sUnknown_203B2F8->unk158[loopMax].menuAction = 6; + + loopMax++; + sUnknown_203B2F8->unk158[loopMax].text = sOldMail; + sUnknown_203B2F8->unk158[loopMax].menuAction = 7; + + loopMax++; + sUnknown_203B2F8->unk158[loopMax].text = NULL; + sUnknown_203B2F8->unk158[loopMax].menuAction = 1; + + for (i = 0; i < loopMax; i++) { + if (sUnknown_203B2F8->unk158[i].menuAction == sUnknown_203B2F8->menuAction3) + return; + } + + sUnknown_203B2F8->menuAction3 = 4; +} + +static void sub_802D73C(void) +{ + s32 loopMax; + s32 i; + + loopMax = 0; + sUnknown_203B2F8->unk158[loopMax].text = gCommonYes[0]; + sUnknown_203B2F8->unk158[loopMax].menuAction = 3; + + loopMax++; + sUnknown_203B2F8->unk158[loopMax].text = gCommonNo[0]; + sUnknown_203B2F8->unk158[loopMax].menuAction = 4; + + loopMax++; + sUnknown_203B2F8->unk158[loopMax].text = sNewMail; + sUnknown_203B2F8->unk158[loopMax].menuAction = 6; + + loopMax++; + sUnknown_203B2F8->unk158[loopMax].text = NULL; + sUnknown_203B2F8->unk158[loopMax].menuAction = 1; + + for (i = 0; i < loopMax; i++) { + if (sUnknown_203B2F8->unk158[i].menuAction == sUnknown_203B2F8->menuAction2) + return; + } + + sUnknown_203B2F8->menuAction2 = 4; +} + +static void sub_802D7D0(void) +{ + s32 menuAction; + + if (sub_80144A4(&menuAction)) + return; + + if (menuAction != 1) + sUnknown_203B2F8->menuAction2 = menuAction; + + switch (menuAction) { + case 3: // Yes + sub_802D1A0(WONDER_MAIL_EXIT); + break; + case 6: // New Mail + sUnknown_203B2F8->fallbackState = 1; + sub_802D1A0(0x10); + break; + case 4: // No + case 2: + default: + sub_802D1A0(INITIAL_WONDER_MAIL_CHECK); + break; + } +} + +static void sub_802D82C(void) +{ + s32 menuAction; + + if (sub_80144A4(&menuAction)) + return; + + if (menuAction != 1) + sUnknown_203B2F8->menuAction3 = menuAction; + + switch (menuAction) { + case 3: // Yes + ResetJobSlot(sUnknown_203B2F8->jobSlotIndex); + sub_8096C80(); + sub_802D1A0(RECEIVE_WONDER_MAIL); + break; + case 6: // New Mail + sUnknown_203B2F8->fallbackState = 9; + sub_802D1A0(16); + break; + case 7: // Old Mail + sUnknown_203B2F8->fallbackState = 9; + sub_802D1A0(15); + break; + default: // No + case 1: + case 2: + case 4: + sub_802D1A0(1); + break; + } +} + +static void sub_802D8CC(void) +{ + switch (sub_802C598(TRUE)) { + case 0: + case 1: + break; + case 3: + sUnknown_203B2F8->jobSlotIndex = GetPelipperBoardSlotIndex(); + sub_802D1A0(13); + break; + case 4: + sUnknown_203B2F8->jobSlotIndex = GetPelipperBoardSlotIndex(); + sUnknown_203B2F8->fallbackState = DRAW_JOB_LIST_1; + sub_802D1A0(15); + break; + case 2: + sub_802C688(); + sub_802D1A0(1); + break; + } +} + +static void sub_802D940(void) +{ + WonderMail *mail; + s32 menuAction; + + menuAction = 0; + sub_802C598(FALSE); + + if (!sub_8012FD8(&sUnknown_203B2F8->unk78)) { + sub_8013114(&sUnknown_203B2F8->unk78, &menuAction); + if (menuAction != 1) + sUnknown_203B2F8->menuAction1 = menuAction; + } + + switch (menuAction) { + case 2: // Delete + if (sUnknown_203B2F8->unk9) { + mail = &gUnknown_203B490->jobSlots[sUnknown_203B2F8->jobSlotIndex]; + if (mail->mailType > MAIL_TYPE_SUSPENDED_JOB && sUnknown_203B2F8->dungeonID == mail->unk4.dungeon.id) { + sub_802D1A0(7); + break; + } + } + + sub_802D1A0(14); + break; + case 5: // Info + sUnknown_203B2F8->fallbackState = DRAW_JOB_LIST_1; + sub_802D1A0(15); + break; + case 1: + sub_802D1A0(DRAW_JOB_LIST_1); + break; + } +} + +static void sub_802D9F0(void) +{ + s32 menuAction; + + menuAction = 0; + sub_802C598(FALSE); + sub_8012FD8(&sUnknown_203B2F8->unk78); + if (!sub_8012FD8(&sUnknown_203B2F8->unkC8)) + sub_8013114(&sUnknown_203B2F8->unkC8, &menuAction); + + switch (menuAction) { + case 1: // No + case 4: + sub_802D1A0(DRAW_JOB_LIST_1); + break; + + case 3: // Yes + sub_802C688(); + ResetJobSlot(sUnknown_203B2F8->jobSlotIndex); + sub_8096C80(); + sub_802D1A0(RECEIVE_WONDER_MAIL); + break; + } +} + +static void sub_802DA60(void) +{ + switch (sub_802DEE0()) { + case 2: + case 3: + sub_802DF24(); + sub_802D1A0(sUnknown_203B2F8->fallbackState); + break; + case 0: + case 1: + break; + } +} + +static void AdvancetoFallbackWonderMailRescueState(void) +{ + s32 temp; + + if (sub_80144A4(&temp) == 0) + sub_802D1A0(sUnknown_203B2F8->fallbackState); +} + +static bool8 sub_802DAA8(void) +{ + WonderMail *mail; + + mail = GetJobSlotInfo(sUnknown_203B2F8->jobSlotIndex); + + if (!sUnknown_203B2F8->unk9) + return TRUE; + + if (mail->mailType != WONDER_MAIL_TYPE_THANK_YOU && sUnknown_203B2F8->dungeonID == mail->unk4.dungeon.id) + return FALSE; + return TRUE; +} + +static bool8 sub_802DADC(void) +{ + u8 mailType; + WonderMail *mail; + s32 i; + + if (!sUnknown_203B2F8->unk9) + return TRUE; + + for (mail = &gUnknown_203B490->jobSlots[0], i = 0; i < MAX_ACCEPTED_JOBS; mail++, i++) { + mailType = mail->mailType; + if (mailType == 0) + return TRUE; + if (mailType == WONDER_MAIL_TYPE_THANK_YOU) + return TRUE; + if (WONDER_MAIL_TYPE_THANK_YOU < mailType && sUnknown_203B2F8->dungeonID != mail->unk4.dungeon.id) + return TRUE; + } + + return FALSE; +} \ No newline at end of file diff --git a/src/wonder_mail_main_menu.c b/src/wonder_mail_main_menu.c index 0423c188c..14bee125e 100644 --- a/src/wonder_mail_main_menu.c +++ b/src/wonder_mail_main_menu.c @@ -2,6 +2,7 @@ #include "code_80118A4.h" #include "code_80130A8.h" #include "code_801B3C0.h" +#include "code_803B050.h" #include "code_801C8C4.h" #include "code_8094F88.h" #include "constants/communication_error_codes.h" @@ -10,11 +11,11 @@ #include "input.h" #include "memory.h" #include "other_menus2.h" +#include "save.h" #include "save_write.h" #include "text1.h" #include "text2.h" -#include "wonder_mail.h" -#include "wonder_mail_3.h" +#include "wonder_mail_802D098.h" #include "wonder_mail_main_menu.h" #define SELECT_WONDER_MAIL_MODE_MAIN_SCREEN 0 @@ -116,7 +117,6 @@ struct unkStruct_203B3E8 EWRAM_DATA_2 struct unkStruct_203B3E8 *gUnknown_203B3E8 = {0}; -extern u32 sub_8011C1C(void); extern void SetWonderMailMainMenuState(u8); extern void sub_8030DE4(void); extern void sub_803084C(void); @@ -125,17 +125,8 @@ extern void sub_8031E10(void); extern u8 sub_800D588(void); extern void sub_802EF48(void); - -extern unkStruct_803B344 *sub_803B344(u8); - - - extern s32 sub_8037B28(u32); -extern u32 sub_802D0E0(); -extern bool8 GetWonderMailAccepted(); -extern void sub_802D184(); - extern bool8 DecodeWonderMailPassword(u8 *, WonderMail *); extern bool8 IsValidWonderMail(WonderMail *WonderMailData); diff --git a/sym_ewram2.txt b/sym_ewram2.txt index abf9b877b..282ed6a73 100644 --- a/sym_ewram2.txt +++ b/sym_ewram2.txt @@ -186,17 +186,10 @@ gUnknown_203B2AA: /* 203B2AA (sub_8023868 - sub_8023C60) */ .include "src/pokemon_news2.o" .include "src/pokemon_news3.o" .include "src/wonder_mail_802C10C.o" -.include "src/wonder_mail_2_1.o" - .space 0x2 - -gUnknown_203B2F0: /* 203B2F0 (InitializeJobListMenu - sub_802CD38) */ - .space 0x4 - -.include "src/wonder_mail_3.o" - -gUnknown_203B2F8: /* 203B2F8 (sub_802D098 - sub_802DADC) */ - .space 0x4 - +.include "src/wonder_mail_802C4C8.o" +.include "src/wonder_mail_802C860.o" +.include "src/wonder_mail_802CDD4.o" +.include "src/wonder_mail_802D098.o" .include "src/code_802DB28.o" .include "src/code_802DE84.o" .include "src/mailbox.o"