diff --git a/data/data_8109D10.s b/data/data_8109D10.s index e370b90af..1029e780c 100644 --- a/data/data_8109D10.s +++ b/data/data_8109D10.s @@ -1,14 +1,9 @@ .section .rodata -@ ??? + + .string "pksdir0\0" -@ ??? -.string "pksdir0\0" -@ ??? -.string "pksdir0\0" -@ ???.c -.string "pksdir0\0" -@ 8109D30 + #include "dungeon/dungeon_data.inc" .align 2,0 diff --git a/data/data_810AE24_2.s b/data/data_810AE24_2.s index 245fcac63..e05d752ca 100644 --- a/data/data_810AE24_2.s +++ b/data/data_810AE24_2.s @@ -1,5 +1,3 @@ .section .rodata .string "pksdir0\0" -.string "pksdir0\0" -.align 2,0 diff --git a/include/code_8097670.h b/include/adventure_info.h similarity index 83% rename from include/code_8097670.h rename to include/adventure_info.h index bc72437aa..6e140798a 100644 --- a/include/code_8097670.h +++ b/include/adventure_info.h @@ -1,7 +1,8 @@ -#ifndef GUARD_CODE_8097670_H -#define GUARD_CODE_8097670_H +#ifndef GUARD_ADVENTURE_INFO_H +#define GUARD_ADVENTURE_INFO_H -#include "structs/str_dungeon.h" +#include "structs/str_dungeon_location.h" +#include "data_serializer.h" // See gAdventureLogText enum AdventureAchievement @@ -60,28 +61,32 @@ struct unkStruct_203B494 extern struct unkStruct_203B494 *gUnknown_203B494; -const u8 *GetAdventureLogLine(u8 index); -DungeonLocation *GetDungeonLocationInfo(void); -s32 GetNumAdventures(void); -void ResetNumAdventures(void); - void sub_8097670(void); struct unkStruct_203B494 *sub_8097680(void); +void SetDungeonLocationInfo(DungeonLocation *dl); +DungeonLocation *GetDungeonLocationInfo(void); void ResetAdventureInfo(void); void SetAdventureAchievement(u8); bool8 GetAdventureAchievement(u8); +const u8 *GetAdventureLogLine(u8 index); +void ResetNumAdventures(void); +void IncrementNumAdventures(void); +s32 GetNumAdventures(void); void IncrementFriendRescueSuccesses(void); s32 GetFriendRescueSuccesses(void); void IncrementNumEvolved(void); s32 GetAdventureNumEvolved(void); +void IncrementThievingSuccesses(void); s16 GetThievingSuccesses(void); void IncrementAdventureNumJoined(void); s16 GetAdventureNumJoined(void); s16 GetAdventureMovesLearned(void); +void IncrementAdventureFloorsExplored(void); s16 GetAdventureFloorsExplored(void); +void sub_80978C8(s16 pokeIndex); +bool8 sub_8097900(s16 pokeIndex); void UpdateAdventureAchievements(void); -u32 SaveAdventureData(u8 *r0, u32 size); -u32 RestoreAdventureData(u8 *r0, u32 size); -void SetDungeonLocationInfo(DungeonLocation *dl); +void WriteAdventureBits(DataSerializer *r0); +void ReadAdventureBits(DataSerializer *r0); -#endif // GUARD_CODE_8097670_H \ No newline at end of file +#endif // GUARD_ADVENTURE_INFO_H diff --git a/include/adventure_save.h b/include/adventure_save.h new file mode 100644 index 000000000..63a15e303 --- /dev/null +++ b/include/adventure_save.h @@ -0,0 +1,7 @@ +#ifndef GUARD_ADVENTURE_SAVE_H +#define GUARD_ADVENTURE_SAVE_H + +u32 SaveAdventureData(u8 *buffer, u32 bufLen); +u32 RestoreAdventureData(u8 *buffer, u32 bufLen); + +#endif // GUARD_ADVENTURE_SAVE_H diff --git a/include/code_80958E8.h b/include/code_80958E8.h index 199409aea..aa1b0d452 100644 --- a/include/code_80958E8.h +++ b/include/code_80958E8.h @@ -70,6 +70,7 @@ u8 *sub_8096DD8(void); u8 *sub_8096DE8(void); u8 sub_8096E2C(void); void sub_8096EEC(WonderMail *mail); +bool8 sub_8096F50(WonderMail *mail); bool8 ValidateWonderMail(WonderMail *data); void WriteWonderMailBits(DataSerializer *a, WonderMail *b); diff --git a/include/code_80972F4.h b/include/code_80972F4.h deleted file mode 100644 index 61e269e1c..000000000 --- a/include/code_80972F4.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef GUARD_CODE_80972F4_H -#define GUARD_CODE_80972F4_H - -#include "structs/str_wonder_mail.h" - -// size: 0x8 -typedef struct MissionText -{ - /* 0x0 */ const u8 *text; - u8 unk4; - u8 unk5; - u8 unk6; - u8 unk7; -} MissionText; - -const u8 *GetCurrentMissionText(s16 index); -bool8 IsMazeCompleted(s16 mazeIndex); - -bool8 sub_8096F50(WonderMail *mail); -void sub_8097418(s32 index, bool32); -bool8 sub_8097504(s16 mazeIndex); -const u8 *sub_80975DC(s16); -bool8 sub_8097384(s32 param_1); -bool8 RescueScenarioConquered(s32 param_1); - -#endif // GUARD_CODE_80972F4_H diff --git a/include/dungeon_data.h b/include/dungeon_data.h index 2e57d7356..93076f05b 100644 --- a/include/dungeon_data.h +++ b/include/dungeon_data.h @@ -58,4 +58,6 @@ extern const s16 gVoltTackleIQReq; extern const u8 gDungeonWaterType[76]; extern const struct ExclusivePokemon gExclusivePokemon[NUM_EXCLUSIVE_POKEMON]; +bool8 IsWaterDungeon(u32 r0); + #endif // GUARD_DUNGEON_DATA_H diff --git a/include/friend_list_menu.h b/include/friend_list_menu.h index 5de7fe06a..35dfb07e6 100644 --- a/include/friend_list_menu.h +++ b/include/friend_list_menu.h @@ -1,78 +1,9 @@ #ifndef INCLUDE_FRIEND_LIST_MENU_H #define INCLUDE_FRIEND_LIST_MENU_H -#include "structs/menu.h" -#include "structs/str_items.h" -#include "structs/str_moves.h" -#include "structs/str_pokemon.h" - -// there might be more overlap with unkStruct_203B2BC -// I was working on the moves and put the data that seemed to correspond to that -// into a separate struct -typedef struct unkStruct_203B2B4 -{ - // size: 0x178 - s32 unk0; - s32 state; - u32 fallbackState; - u8 unkC; // friend Area - u8 unkD; // friend Area - s16 species; - u32 itemIndex; - BulkItem item1; - BulkItem item2; - /* 0x1C */ Pokemon *pokeStruct; - u32 moveIndex; // some sort of move index - u16 moveID; - Move moves[8]; - u16 moveIDs[4]; // some list of move IDs - u32 menuAction1; - s32 menuAction2; - MenuStruct unk78; - MenuItem unkC8[8]; - u16 unk108[8]; - WindowTemplates unk118; -} unkStruct_203B2B4; - bool8 CreateFriendListMenu(s32 param_1); u32 sub_8025354(void); u8 sub_802540C(void); void CleanFriendListMenu(void); -enum FriendListMenuStates { - // 0 - // 1 - // 2 - // 3 - FRIEND_LIST_MENU_STATE_SUMMARY = 4, - FRIEND_LIST_MENU_STATE_CHECK_IQ = 5, - FRIEND_LIST_MENU_STATE_STANDBY = 7, - FRIEND_LIST_MENU_STATE_ITEM_GIVEN = 8, - FRIEND_LIST_MENU_STATE_ITEM_EXCHANGE = 9, - FRIEND_LIST_MENU_STATE_TAKE = 0xA, - FRIEND_LIST_MENU_STATE_GIVE = 0xB, - // 0xC - // 0xD - FRIEND_LIST_MENU_STATE_INFO = 0xE, - FRIEND_LIST_MENU_STATE_MOVES = 0xF, - // 0x10 - // 0x11 - // 0x12 - FRIEND_LIST_MENU_STATE_EXIT = 0x13 -}; - -enum FriendListMenuActions { - FRIEND_LIST_MENU_NULL = 1, - FRIEND_LIST_MENU_INFO = 4, - FRIEND_LIST_MENU_SUMMARY = 4, - FRIEND_LIST_MENU_CHECK_IQ = 5, - FRIEND_LIST_MENU_MOVES, - FRIEND_LIST_MENU_VISIT, - // 8 - FRIEND_LIST_MENU_STANDBY = 9, - FRIEND_LIST_MENU_GIVE = 0xA, - FRIEND_LIST_MENU_TAKE, - -}; - #endif diff --git a/include/party_list_menu.h b/include/party_list_menu.h index 3e7bf2df0..73f9824ae 100644 --- a/include/party_list_menu.h +++ b/include/party_list_menu.h @@ -1,92 +1,9 @@ #ifndef GUARD_PARTY_LIST_MENU_H #define GUARD_PARTY_LIST_MENU_H -#include "constants/move.h" -#include "items.h" -#include "structs/menu.h" -#include "pokemon.h" -#include "structs/str_text.h" - -// size: 0x280 -typedef struct unkStruct_203B2B8 -{ - /* 0x0 */ s32 state; - /* 0x4 */ s32 fallbackState; - bool8 unk8; - /* 0xA */ s16 pokeSpecies; - /* 0xC */ u32 id; - /* 0x10 */ BulkItem item1; - /* 0x14 */ BulkItem item2; - /* 0x18 */ Pokemon *pokeStruct; - /* 0x1C */ bool8 isTeamLeader; - /* 0x20 */ u32 moveIndex; - /* 0x24 */ u16 moveID; - /* 0x28 */ Move moves[8]; - /* 0x68 */ u16 moveIDs[4]; // some list of move IDs - /* 0x70 */ u32 menuAction1; - /* 0x74 */ u32 menuAction2; - /* 0x78 */ u32 menuAction3; // unused - MenuStruct unk7C; - MenuStruct unkCC; - MenuStruct unk11C; // unused - MenuItem unk16C[10]; - MenuItem unk1BC[10]; - u16 unk20C[10]; - WindowTemplates unk220; -} unkStruct_203B2B8; - bool8 CreatePartyListMenu(Pokemon *pokeStruct); u32 sub_8025F68(void); bool8 sub_802604C(void); void CleanPartyListMenu(void); -enum PartyListMenuStates -{ - PARTY_LIST_STATE_INIT, - PARTY_LIST_STATE_MAIN_MENU, - PARTY_LIST_STATE_MAIN_MENU_1, - PARTY_LIST_STATE_SUMMARY = 3, - PARTY_LIST_STATE_CHECK_IQ = 4, - PARTY_LIST_STATE_JOIN_TEAM = 5, - PARTY_LIST_STATE_STANDBY = 6, - PARTY_LIST_STATE_MAKE_LEADER = 7, - PARTY_LIST_STATE_POKEMON_FAREWELL = 8, - // 9 - // 0xA - // 0xB - PARTY_LIST_STATE_SAY_FAREWELL = 0xC, - PARTY_LIST_STATE_CONFIRM_SAY_FAREWELL = 0xD, - PARTY_LIST_STATE_GIVE_GUMMI = 0xe, - PARTY_LIST_STATE_GIVEN_ITEM = 0xF, - PARTY_LIST_STATE_GIVEN_ITEM_HELD_ITEM = 0x10, - PARTY_LIST_STATE_TAKE_ITEM = 0x11, - PARTY_LIST_STATE_GIVE_ITEM = 0x12, - PARTY_LIST_STATE_GIVE_ITEM_1 = 0x13, - // 0x14 - // 0x15 - PARTY_LIST_STATE_MOVES = 0x16, - // 0x17 - // 0x18 - PARTY_LIST_STATE_EXIT = 0x19, - -}; - -enum PartyListMenuActions -{ - PARTY_LIST_MENU_NULL = 1, - PARTY_LIST_MENU_YES, - PARTY_LIST_MENU_NO, - PARTY_LIST_MENU_INFO = 4, - PARTY_LIST_MENU_SUMMARY = 4, - PARTY_LIST_MENU_CHECK_IQ, - PARTY_LIST_MENU_JOIN_TEAM, - PARTY_LIST_MENU_STANDBY, - PARTY_LIST_MENU_MAKE_LEADER, - PARTY_LIST_MENU_SAY_FAREWELL, - PARTY_LIST_MENU_GIVE_GUMMI, - PARTY_LIST_MENU_GIVE_ITEM, - PARTY_LIST_MENU_TAKE_ITEM, - PARTY_LIST_MENU_MOVES, -}; - #endif // GUARD_PARTY_LIST_MENU_H diff --git a/include/play_time.h b/include/play_time.h index b4b10b12b..40f2fd2d3 100644 --- a/include/play_time.h +++ b/include/play_time.h @@ -1,6 +1,8 @@ #ifndef GUARD_PLAY_TIME_H #define GUARD_PLAY_TIME_H +#include "data_serializer.h" + struct PlayTimeStruct { s16 hours; @@ -13,12 +15,13 @@ struct PlayTimeStruct extern struct PlayTimeStruct *gPlayTimeRef; extern struct PlayTimeStruct gPlayTime; -void IncrementPlayTime(struct PlayTimeStruct *Time); -void ResetPlayTime(struct PlayTimeStruct *Time); -struct PlayTimeStruct *GetPlayTime(void); -void DeconstructPlayTime(struct PlayTimeStruct *r0, u32 *outHours, u32 *outMinutes, u32 *outSeconds); void InitializePlayTime(void); +struct PlayTimeStruct *GetPlayTime(void); +void ResetPlayTime(struct PlayTimeStruct *Time); +void IncrementPlayTime(struct PlayTimeStruct *Time); +void DeconstructPlayTime(struct PlayTimeStruct *r0, u32 *outHours, u32 *outMinutes, u32 *outSeconds); +void WritePlayTimeBits(DataSerializer *r0); +void ReadPlayTimeBits(DataSerializer *r0); - -#endif // GUARD_PLAY_TIME_H +#endif // GUARD_PLAY_TIME_H diff --git a/include/rescue_scenario.h b/include/rescue_scenario.h new file mode 100644 index 000000000..3bf3dc55d --- /dev/null +++ b/include/rescue_scenario.h @@ -0,0 +1,17 @@ +#ifndef GUARD_RESCUE_SCENARIO_H +#define GUARD_RESCUE_SCENARIO_H + +#include "structs/str_wonder_mail.h" + +void sub_80972F4(void); +void nullsub_128(void); +bool8 sub_8097318(s16 param_1); +void sub_809733C(s16 param_1, u32 param_2); +bool8 sub_8097384(s32 param_1); +void sub_80973A8(s32 param_1, u32 param_2); +bool8 RescueScenarioConquered(s32 param_1); +void sub_8097418(s32 index, bool32); +const u8 *sub_80974A0(s16 index); +const u8 *GetCurrentMissionText(s16 index); + +#endif // GUARD_RESCUE_SCENARIO_H diff --git a/include/code_8097DD0.h b/include/status_strings.h similarity index 53% rename from include/code_8097DD0.h rename to include/status_strings.h index 45a59d411..6a13e01f9 100644 --- a/include/code_8097DD0.h +++ b/include/status_strings.h @@ -1,8 +1,8 @@ -#ifndef GUARD_CODE_8097DD0_H -#define GUARD_CODE_8097DD0_H +#ifndef GUARD_STATUS_STRINGS_H +#define GUARD_STATUS_STRINGS_H #include "structs/str_status_text.h" s32 PrepareStatusStringArrays(const char *str, STATUSTEXTS(statuses)); -#endif // GUARD_CODE_8097DD0_H +#endif // GUARD_STATUS_STRINGS_H diff --git a/include/training_maze.h b/include/training_maze.h new file mode 100644 index 000000000..559fbb424 --- /dev/null +++ b/include/training_maze.h @@ -0,0 +1,12 @@ +#ifndef GUARD_TRAINING_MAZE_H +#define GUARD_TRAINING_MAZE_H + +void sub_80974E8(void); +bool8 sub_8097504(s16 mazeIndex); +bool8 IsMazeCompleted(s16 mazeIndex); +void sub_80975A8(s16 param_1,u8 param_2); +const u8 *sub_80975DC(s16 r0); +bool8 HasCompletedAllMazes(void); +bool8 sub_8097640(void); + +#endif // GUARD_TRAINING_MAZE_H diff --git a/ld_script.ld b/ld_script.ld index 08e8c7451..5656463f3 100755 --- a/ld_script.ld +++ b/ld_script.ld @@ -325,11 +325,12 @@ SECTIONS { src/play_time.o(.text); src/code_8094F88.o(.text); src/code_80958E8.o(.text); - src/code_80972F4.o(.text); - src/code_8097504.o(.text); - src/code_8097670.o(.text); - src/code_8097DD0.o(.text); - src/code_8097F40.o(.text); + src/rescue_scenario.o(.text); + src/training_maze.o(.text); + src/adventure_info.o(.text); + src/adventure_save.o(.text); + src/status_strings.o(.text); + src/dungeon_data.o(.text); src/exclusive_pokemon.o(.text); src/position_util.o(.text); src/ground_main.o(.text); @@ -713,8 +714,11 @@ SECTIONS { src/play_time.o(.rodata); src/code_8094F88.o(.rodata); src/code_80958E8.o(.rodata); - src/code_80972F4.o(.rodata); - src/code_8097504.o(.rodata); + src/rescue_scenario.o(.rodata); + src/training_maze.o(.rodata); + src/adventure_info.o(.rodata); + src/adventure_save.o(.rodata); + src/status_strings.o(.rodata); data/data_8109D10.o(.rodata); src/dungeon_data.o(.rodata); src/exclusive_pokemon.o(.rodata); diff --git a/src/code_8097670.c b/src/adventure_info.c similarity index 85% rename from src/code_8097670.c rename to src/adventure_info.c index b82922e96..2addc6990 100644 --- a/src/code_8097670.c +++ b/src/adventure_info.c @@ -1,21 +1,17 @@ #include "global.h" -#include "code_8097670.h" -#include "exclusive_pokemon.h" +#include "globaldata.h" +#include "adventure_info.h" #include "pokemon.h" #include "pokemon_3.h" #include "friend_area.h" #include "moves.h" #include "strings.h" #include "dungeon_info.h" -#include "game_options.h" static EWRAM_DATA struct unkStruct_203B494 sUnknown_2039778 = {0}; EWRAM_INIT struct unkStruct_203B494 *gUnknown_203B494 = { NULL }; // NDS=20EB98C -void ReadPlayTimeBits(DataSerializer *r0); -void WritePlayTimeBits(DataSerializer *r0); - void sub_8097670(void) { gUnknown_203B494 = &sUnknown_2039778; @@ -180,32 +176,15 @@ s16 GetAdventureFloorsExplored(void) void sub_80978C8(s16 pokeIndex) { - s32 iVar2; - struct unkStruct_203B494 *preload; - s32 baseSpecies; - - baseSpecies = GetBaseSpeciesNoUnown(pokeIndex); - preload = gUnknown_203B494; - iVar2 = baseSpecies; - if (baseSpecies < 0) - iVar2 = baseSpecies + 0x1F; // 0b11111 - - preload->unk54[iVar2 >> 5] |= 1 << (baseSpecies + (iVar2 >> 5) * -32); + s32 baseSpecies = GetBaseSpeciesNoUnown(pokeIndex); + gUnknown_203B494->unk54[baseSpecies / 32] |= 1 << (baseSpecies % 32); } bool8 sub_8097900(s16 pokeIndex) { - s32 iVar2; - struct unkStruct_203B494 *preload; - s32 baseSpecies; + s32 baseSpecies = GetBaseSpeciesNoUnown(pokeIndex); - baseSpecies = GetBaseSpeciesNoUnown(pokeIndex); - preload = gUnknown_203B494; - iVar2 = baseSpecies; - if (baseSpecies < 0) - iVar2 = baseSpecies + 0x1F; // 0b11111 - - if (preload->unk1C[iVar2 >> 5] & (1 << (baseSpecies + (iVar2 >> 5) * -32))) + if (gUnknown_203B494->unk1C[baseSpecies / 32] & (1 << (baseSpecies % 32))) return TRUE; return FALSE; } @@ -328,7 +307,7 @@ void UpdateAdventureAchievements(void) } } -static void WriteAdventureBits(DataSerializer *r0) +void WriteAdventureBits(DataSerializer *r0) { UpdateAdventureAchievements(); WriteBits(r0, &gUnknown_203B494->numAdventures, 17); @@ -345,7 +324,7 @@ static void WriteAdventureBits(DataSerializer *r0) WriteDungeonLocationBits(r0, &gUnknown_203B494->dungeonLocation); } -static void ReadAdventureBits(DataSerializer *r0) +void ReadAdventureBits(DataSerializer *r0) { ReadBits(r0, &gUnknown_203B494->numAdventures, 17); ReadBits(r0, &gUnknown_203B494->friendRescueSuccesses, 17); @@ -360,33 +339,3 @@ static void ReadAdventureBits(DataSerializer *r0) ReadBits(r0, gUnknown_203B494->learnedMoves, ARRAY_COUNT_INT(gUnknown_203B494->learnedMoves) * 32); ReadDungeonLocationBits(r0, &gUnknown_203B494->dungeonLocation); } - -u32 SaveAdventureData(u8 *buffer, u32 bufLen) -{ - DataSerializer seri; - - InitBitWriter(&seri, buffer, bufLen); - - WriteGameOptionsBits(&seri); - WritePlayTimeBits(&seri); - WriteAdventureBits(&seri); - WriteExclusivePokemon(&seri); - - FinishBitSerializer(&seri); - return seri.count; -} - -u32 RestoreAdventureData(u8 *buffer, u32 bufLen) -{ - DataSerializer seri; - - InitBitReader(&seri, buffer, bufLen); - - ReadGameOptionsBits(&seri); - ReadPlayTimeBits(&seri); - ReadAdventureBits(&seri); - ReadExclusivePokemon(&seri); - - FinishBitSerializer(&seri); - return seri.count; -} diff --git a/src/adventure_log.c b/src/adventure_log.c index f2978e714..f0fc2f9d3 100644 --- a/src/adventure_log.c +++ b/src/adventure_log.c @@ -4,7 +4,7 @@ #include "text_3.h" #include "adventure_log.h" #include "music_util.h" -#include "code_8097670.h" +#include "adventure_info.h" #include "input.h" #include "memory.h" #include "menu_input.h" diff --git a/src/adventure_save.c b/src/adventure_save.c new file mode 100644 index 000000000..1565f15d9 --- /dev/null +++ b/src/adventure_save.c @@ -0,0 +1,37 @@ +#include "global.h" +#include "globaldata.h" +#include "adventure_info.h" +#include "data_serializer.h" +#include "play_time.h" +#include "game_options.h" +#include "exclusive_pokemon.h" + +u32 SaveAdventureData(u8 *buffer, u32 bufLen) +{ + DataSerializer seri; + + InitBitWriter(&seri, buffer, bufLen); + + WriteGameOptionsBits(&seri); + WritePlayTimeBits(&seri); + WriteAdventureBits(&seri); + WriteExclusivePokemon(&seri); + + FinishBitSerializer(&seri); + return seri.count; +} + +u32 RestoreAdventureData(u8 *buffer, u32 bufLen) +{ + DataSerializer seri; + + InitBitReader(&seri, buffer, bufLen); + + ReadGameOptionsBits(&seri); + ReadPlayTimeBits(&seri); + ReadAdventureBits(&seri); + ReadExclusivePokemon(&seri); + + FinishBitSerializer(&seri); + return seri.count; +} diff --git a/src/code_8072F3C.c b/src/code_8072F3C.c index ac1ebc616..935b171d6 100644 --- a/src/code_8072F3C.c +++ b/src/code_8072F3C.c @@ -5,6 +5,7 @@ #include "music_util.h" #include "code_80958E8.h" #include "code_80A26CC.h" +#include "rescue_scenario.h" #include "input.h" #include "memory.h" #include "menu_input.h" @@ -61,10 +62,8 @@ ALIGNED(4) const u8 gUnknown_80E0754[] = {0x83, 0xC0}; void sub_802F9C0(void); void sub_802FA50(void); -const u8 *sub_80974A0(s16 index); extern bool8 sub_802FCF0(void); s32 sub_802FBF4(void); -extern u8 sub_8097384(s16); u32 sub_802F73C(u32 r0, DungeonPos *r1, u32 r2, u8 r3) { diff --git a/src/code_80958E8.c b/src/code_80958E8.c index b808d57ad..c0baa86fa 100644 --- a/src/code_80958E8.c +++ b/src/code_80958E8.c @@ -3,6 +3,7 @@ #include "code_803C1D0.h" #include "code_80958E8.h" #include "code_80A26CC.h" +#include "rescue_scenario.h" #include "constants/dungeon.h" #include "constants/friend_area.h" #include "constants/wonder_mail.h" @@ -19,8 +20,6 @@ extern void sub_803C37C(struct DungeonLocation *, u8, u8 *); -extern u8 sub_8097318(s16 param_1); - bool8 sub_8095E38(WonderMail *mail, u8 dungeon, u32 floor, u8 param_4); u8 sub_8095F28(u8 param_1); bool8 GenerateMailJobDungeonInfo(WonderMail *mail); diff --git a/src/code_8097F40.c b/src/code_8097F40.c deleted file mode 100644 index 19de5ff95..000000000 --- a/src/code_8097F40.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "global.h" -#include "dungeon_map_access.h" -#include "dungeon_data.h" - -bool8 IsWaterDungeon(u32 r0) -{ - return gDungeonWaterType[r0] == DUNGEON_WATER_TYPE_WATER; -} diff --git a/src/code_80A26CC.c b/src/code_80A26CC.c index 15ae856f7..718f07b87 100644 --- a/src/code_80A26CC.c +++ b/src/code_80A26CC.c @@ -1,6 +1,6 @@ #include "global.h" #include "globaldata.h" -#include "code_80972F4.h" +#include "rescue_scenario.h" #include "code_80A26CC.h" #include "event_flag.h" #include "constants/dungeon.h" diff --git a/src/data/story_missions.h b/src/data/story_missions.h deleted file mode 100644 index a2c253169..000000000 --- a/src/data/story_missions.h +++ /dev/null @@ -1,35 +0,0 @@ - -static const MissionText sStoryMissionText[] = { - { _("Rescue Caterpie."), -1, -1, 0, 0 }, - { _("Rescue Magnemite."), -1, -1, 0, 0 }, - { _("Rescue Diglett."), 0, 1, 0, 0 }, - { _("Rescue Metapod."), 2, 3, 0, 0 }, - { _("Rescue Jumpluff."), -1, -1, 0, 0 }, - { _("Rescue Shiftry."), 4, 5, 0, 0 }, - { _("Meet Xatu."), -1, -1, 0, 0 }, - { _("Fugitive"), -1, -1, 0, 0 }, - { _("Fugitive"), 6, 7, 0, 0 }, - { _("Fugitive"), 8, 9, 0, 0 }, - { _("Meet Ninetales."), -1, 10, 0, 0 }, - { _("Rescue Alakazam."), 11, 12, 0, 0 }, - { _("Seek Rayquaza's help."), 14, 15, 0, 0 }, - { _("{COLOR YELLOW_C}Scenario Progress Dummy{RESET}"), -1, -1, 0, 0 }, - { _("Punish bad Mankey."), 16, 17, 0, 0 }, - { _("Rescue Smeargle."), -1, 33, 0, 0 }, - { _("Explore seafloor."), -1, -1, 0, 0 }, - { _("Meet sea guardian."), -1, -1, 0, 0 }, - { _("Check mystery Pokémon."), -1, -1, 0, 0 }, - { _("Meet Xatu."), -1, -1, 0, 0 }, - { _("Mirage Pokémon 1"), 20, 21, 0, 0 }, - { _("Mirage Pokémon 2"), 22, 23, 0, 0 }, - { _("Mirage Pokémon 3"), 24, 25, 0, 0 }, - { _("Mirage Pokémon 4"), -1, 26, 0, 0 }, - { _("Meet toughest Pokémon."), 18, 19, 0, 0 }, - { _("Catch thief."), 27, 28, 0, 0 }, - { _("Rescue Latias."), -1, -1, 0, 0 }, - { _("Investigate Relic."), -1, -1, 0, 0 }, - { _("Rescue Medicham."), -1, 32, 0, 0 }, - { _("Meet Ninetales."), -1, -1, 0, 0 }, - { _("Break Gardevoir's curse."), -1, -1, 0, 0 }, - { NULL, -1, -1, 0, 0 }, -}; \ No newline at end of file diff --git a/src/debug_menu1.c b/src/debug_menu1.c index b016dccac..99558e221 100644 --- a/src/debug_menu1.c +++ b/src/debug_menu1.c @@ -3,7 +3,7 @@ #include "constants/friend_area.h" #include "constants/main_menu.h" #include "constants/move_id.h" -#include "code_8097670.h" +#include "adventure_info.h" #include "debug_menu1.h" #include "friend_area.h" #include "input.h" diff --git a/src/dungeon_data.c b/src/dungeon_data.c index 0cfc277f9..d6f4e0c1e 100644 --- a/src/dungeon_data.c +++ b/src/dungeon_data.c @@ -4,6 +4,11 @@ #include "dungeon_map_access.h" #include "constants/walkable_tile.h" +bool8 IsWaterDungeon(u32 r0) +{ + return gDungeonWaterType[r0] == DUNGEON_WATER_TYPE_WATER; +} + // TODO: gDungeons from `dungeon/dungeon_data.inc` const u8 gInvalidDungeonIDs[11] = diff --git a/src/dungeon_main.c b/src/dungeon_main.c index 22034d0c7..d64aff749 100644 --- a/src/dungeon_main.c +++ b/src/dungeon_main.c @@ -62,8 +62,7 @@ #include "dungeon_entity_movement.h" #include "dungeon_8041AD0.h" #include "status_checks.h" - -void sub_80978C8(s16 a0); +#include "adventure_info.h" static EWRAM_DATA bool8 sInDiagonalMode = 0; static EWRAM_DATA bool8 sInRotateMode = 0; diff --git a/src/dungeon_menu_others.c b/src/dungeon_menu_others.c index bb100322c..75c990a82 100644 --- a/src/dungeon_menu_others.c +++ b/src/dungeon_menu_others.c @@ -5,7 +5,7 @@ #include "dungeon_vram.h" #include "dungeon_tilemap.h" #include "dungeon_action.h" -#include "code_8097DD0.h" +#include "status_strings.h" #include "dungeon_info.h" #include "dungeon_exit.h" #include "dungeon_action.h" diff --git a/src/dungeon_menu_stairs.c b/src/dungeon_menu_stairs.c index 66ad6f5b9..899cf8b6d 100644 --- a/src/dungeon_menu_stairs.c +++ b/src/dungeon_menu_stairs.c @@ -3,7 +3,7 @@ #include "dungeon_vram.h" #include "dungeon_tilemap.h" #include "dungeon_action.h" -#include "code_8097DD0.h" +#include "status_strings.h" #include "dungeon_info.h" #include "dungeon_action.h" #include "dungeon_generation.h" diff --git a/src/dungeon_menu_team.c b/src/dungeon_menu_team.c index 0468c5d5d..924210c6d 100644 --- a/src/dungeon_menu_team.c +++ b/src/dungeon_menu_team.c @@ -14,7 +14,7 @@ #include "dungeon_tilemap.h" #include "dungeon_action.h" #include "dungeon_mon_sprite_render.h" -#include "code_8097DD0.h" +#include "status_strings.h" #include "dungeon_action.h" #include "dungeon_ai_movement.h" #include "dungeon_items.h" diff --git a/src/dungeon_menu_tile.c b/src/dungeon_menu_tile.c index 11df04ffc..7e37fbdce 100644 --- a/src/dungeon_menu_tile.c +++ b/src/dungeon_menu_tile.c @@ -3,7 +3,7 @@ #include "dungeon_vram.h" #include "dungeon_tilemap.h" #include "dungeon_action.h" -#include "code_8097DD0.h" +#include "status_strings.h" #include "dungeon_info.h" #include "dungeon_action.h" #include "dungeon_engine.h" diff --git a/src/dungeon_mon_recruit.c b/src/dungeon_mon_recruit.c index 459c938c8..e0bf3e86c 100644 --- a/src/dungeon_mon_recruit.c +++ b/src/dungeon_mon_recruit.c @@ -10,7 +10,7 @@ #include "music_util.h" #include "dungeon_message.h" #include "dungeon_mon_sprite_render.h" -#include "code_8097670.h" +#include "adventure_info.h" #include "dungeon_info.h" #include "dungeon_items.h" #include "dungeon_logic.h" @@ -30,8 +30,7 @@ #include "string_format.h" #include "dungeon_mon_spawn.h" #include "move_orb_effects_5.h" - -extern bool8 sub_8097900(s16 pokeIndex); +#include "adventure_info.h" static void nullsub_96(Entity *pokemon,Entity *target); static void sub_806F910(void); diff --git a/src/event_flag.c b/src/event_flag.c index 3393c9114..c376dc932 100644 --- a/src/event_flag.c +++ b/src/event_flag.c @@ -11,24 +11,19 @@ #include "rescue_team_info.h" #include "other_random.h" #include "friend_area.h" -#include "code_80972F4.h" -#include "code_8097670.h" +#include "rescue_scenario.h" +#include "adventure_info.h" #include "pokemon.h" #include "pokemon_3.h" #include "ground_place.h" #include "ground_main.h" #include "script_vars_info.h" +#include "training_maze.h" EWRAM_DATA u8 gScriptVarBuffer[SCRIPT_VAR_BUFFER_LEN] = {0}; // NDS=020876DC #include "data/event_flag.h" -extern bool8 HasCompletedAllMazes(void); -extern void sub_809733C(u32, u32); -extern void sub_80973A8(u32, u32); -extern void sub_80972F4(void); -extern void nullsub_128(void); - // arm9.bin::0200FF68 void ThoroughlyResetScriptVars(void) { @@ -556,95 +551,96 @@ bool8 ScriptVarScenarioAfter(s16 varId,u32 pMain,s32 pSub) // arm9.bin::0200ECE0 void sub_8001D88(void) { - u32 local_c; - u32 auStack8; + u32 local_c; + u32 auStack8; + + GetScriptVarScenario(3, &auStack8, &local_c); + if (auStack8 < 1 || auStack8 > 0x1b) + return; - GetScriptVarScenario(3, &auStack8, &local_c); - if (auStack8 - 1 < 0x1b) { if (ScriptVarScenarioBefore(SCENARIO_SUB1,0x1f,0) != 0) { - if (ScriptVarScenarioAfter(SCENARIO_MAIN,0xf,7) != 0) { - ScenarioCalc(SCENARIO_SUB1,0x1f,0); - sub_8097418(0xe,1); - SetScriptVarValue(NULL,BASE_LEVEL,2); - } - else { - if ((ScriptVarScenarioEqual(SCENARIO_SUB1,0,0)) && (ScriptVarScenarioAfter(SCENARIO_MAIN,0xf,3))) { - ScenarioCalc(SCENARIO_SUB1,0x1d,1); + if (ScriptVarScenarioAfter(SCENARIO_MAIN,0xf,7) != 0) { + ScenarioCalc(SCENARIO_SUB1,0x1f,0); + sub_8097418(0xe,1); + SetScriptVarValue(NULL,BASE_LEVEL,2); + } + else { + if ((ScriptVarScenarioEqual(SCENARIO_SUB1,0,0)) && (ScriptVarScenarioAfter(SCENARIO_MAIN,0xf,3))) { + ScenarioCalc(SCENARIO_SUB1,0x1d,1); + } } - } } if ((ScriptVarScenarioEqual(SCENARIO_SUB1,0x1f,0)) && (GetFriendAreaStatus(SKY_BLUE_PLAINS))) { - ScenarioCalc(SCENARIO_SUB1,0x1f,1); - sub_809733C(0xf,1); + ScenarioCalc(SCENARIO_SUB1,0x1f,1); + sub_809733C(0xf,1); } if (auStack8 > 0x11) { - sub_80973A8(0x25,1); - if (((FindItemInInventory(ITEM_HM_DIVE) != -1) || (gTeamInventoryRef->teamStorage[ITEM_HM_DIVE] != 0)) || - (ScriptVarScenarioAfter(SCENARIO_SUB2,0x21,3) != 0)) { - sub_80973A8(0x22,1); - } - if (GetFriendAreaStatus(FURNACE_DESERT) != 0) { - sub_80973A8(0x1f,1); - } - if (GetFriendAreaStatus(BOULDER_CAVE)) { - sub_80973A8(0x20,1); - } - if (GetFriendAreaStatus(DRAGON_CAVE)) { - sub_80973A8(0x21,1); - } - if (GetFriendAreaStatus(SECRETIVE_FOREST)) { - sub_80973A8(0x23,1); - } - if (GetFriendAreaStatus(SERENE_SEA)) { - sub_80973A8(0x24,1); - sub_80973A8(0x28,1); - } - if ((GetFriendAreaStatus(AGED_CHAMBER_AN)) && (GetFriendAreaStatus(AGED_CHAMBER_O_EXCLAIM))) { - sub_80973A8(0x26,1); - } - if (ScriptVarScenarioEqual(SCENARIO_SUB2,0,0)) { - ScenarioCalc(SCENARIO_SUB2,0x21,1); - } - if ((FindItemInInventory(ITEM_HM_SURF) != -1) || (gTeamInventoryRef->teamStorage[ITEM_HM_SURF] != 0)) { - if (ScriptVarScenarioEqual(SCENARIO_SUB4,0,0)) { - ScenarioCalc(SCENARIO_SUB4,0x26,1); + sub_80973A8(0x25,1); + if (((FindItemInInventory(ITEM_HM_DIVE) != -1) || (gTeamInventoryRef->teamStorage[ITEM_HM_DIVE] != 0)) || + (ScriptVarScenarioAfter(SCENARIO_SUB2,0x21,3) != 0)) { + sub_80973A8(0x22,1); } - if ((ScriptVarScenarioEqual(SCENARIO_SUB6,0,0)) && (GetFriendAreaStatus(SOUTHERN_ISLAND))) { - ScenarioCalc(SCENARIO_SUB6,0x2e,1); + if (GetFriendAreaStatus(FURNACE_DESERT) != 0) { + sub_80973A8(0x1f,1); } - } - if (!ScriptVarScenarioBefore(SCENARIO_SUB6,0x30,0)) { - if ((ScriptVarScenarioEqual(SCENARIO_SUB2,0x22,0)) && HasRecruitedMon(MONSTER_ARTICUNO) && HasRecruitedMon(MONSTER_ZAPDOS) && HasRecruitedMon(MONSTER_MOLTRES)) { - ScenarioCalc(SCENARIO_SUB2,0x22,1); + if (GetFriendAreaStatus(BOULDER_CAVE)) { + sub_80973A8(0x20,1); } - if (((ScriptVarScenarioEqual(SCENARIO_SUB8,0,0)) && (ScriptVarScenarioAfter(SCENARIO_SUB2,0x21,3) != 0)) && - (GetFriendAreaStatus(SKY_BLUE_PLAINS))) { - ScenarioCalc(SCENARIO_SUB8,0x33,1); + if (GetFriendAreaStatus(DRAGON_CAVE)) { + sub_80973A8(0x21,1); } - if (GetFriendAreaStatus(SKY_BLUE_PLAINS)) { - sub_80973A8(0x27,1); + if (GetFriendAreaStatus(SECRETIVE_FOREST)) { + sub_80973A8(0x23,1); } - if (GetFriendAreaStatus(SKY_BLUE_PLAINS)) { - sub_80973A8(0x29,1); + if (GetFriendAreaStatus(SERENE_SEA)) { + sub_80973A8(0x24,1); + sub_80973A8(0x28,1); } - } - if (!ScriptVarScenarioBefore(SCENARIO_SUB2,0x22,0)) { - if (ScriptVarScenarioEqual(SCENARIO_SUB7,0,0)) { - ScenarioCalc(SCENARIO_SUB7,0x31,1); - sub_809733C(0x1b,1); + if ((GetFriendAreaStatus(AGED_CHAMBER_AN)) && (GetFriendAreaStatus(AGED_CHAMBER_O_EXCLAIM))) { + sub_80973A8(0x26,1); } - if ((ScriptVarScenarioEqual(SCENARIO_SUB9,0,0)) && (!ScriptVarScenarioBefore(SCENARIO_SUB8,0x34,0))) { - ScenarioCalc(SCENARIO_SUB9,0x35,1); + if (ScriptVarScenarioEqual(SCENARIO_SUB2,0,0)) { + ScenarioCalc(SCENARIO_SUB2,0x21,1); + } + if ((FindItemInInventory(ITEM_HM_SURF) != -1) || (gTeamInventoryRef->teamStorage[ITEM_HM_SURF] != 0)) { + if (ScriptVarScenarioEqual(SCENARIO_SUB4,0,0)) { + ScenarioCalc(SCENARIO_SUB4,0x26,1); + } + if ((ScriptVarScenarioEqual(SCENARIO_SUB6,0,0)) && (GetFriendAreaStatus(SOUTHERN_ISLAND))) { + ScenarioCalc(SCENARIO_SUB6,0x2e,1); + } + } + if (!ScriptVarScenarioBefore(SCENARIO_SUB6,0x30,0)) { + if ((ScriptVarScenarioEqual(SCENARIO_SUB2,0x22,0)) && HasRecruitedMon(MONSTER_ARTICUNO) && HasRecruitedMon(MONSTER_ZAPDOS) && HasRecruitedMon(MONSTER_MOLTRES)) { + ScenarioCalc(SCENARIO_SUB2,0x22,1); + } + if (((ScriptVarScenarioEqual(SCENARIO_SUB8,0,0)) && (ScriptVarScenarioAfter(SCENARIO_SUB2,0x21,3) != 0)) && + (GetFriendAreaStatus(SKY_BLUE_PLAINS))) { + ScenarioCalc(SCENARIO_SUB8,0x33,1); + } + if (GetFriendAreaStatus(SKY_BLUE_PLAINS)) { + sub_80973A8(0x27,1); + } + if (GetFriendAreaStatus(SKY_BLUE_PLAINS)) { + sub_80973A8(0x29,1); + } + } + if (!ScriptVarScenarioBefore(SCENARIO_SUB2,0x22,0)) { + if (ScriptVarScenarioEqual(SCENARIO_SUB7,0,0)) { + ScenarioCalc(SCENARIO_SUB7,0x31,1); + sub_809733C(0x1b,1); + } + if ((ScriptVarScenarioEqual(SCENARIO_SUB9,0,0)) && (!ScriptVarScenarioBefore(SCENARIO_SUB8,0x34,0))) { + ScenarioCalc(SCENARIO_SUB9,0x35,1); + } + } + if ((ScriptVarScenarioEqual(SCENARIO_SUB3,0,0)) && (HasRecruitedMon(MONSTER_LUGIA))) { + ScenarioCalc(SCENARIO_SUB3,0x24,1); + } + if ((ScriptVarScenarioEqual(SCENARIO_SUB5,0,0)) && (HasRecruitedMon(MONSTER_HO_OH))) { + ScenarioCalc(SCENARIO_SUB5,0x2c,1); } - } - if ((ScriptVarScenarioEqual(SCENARIO_SUB3,0,0)) && (HasRecruitedMon(MONSTER_LUGIA))) { - ScenarioCalc(SCENARIO_SUB3,0x24,1); - } - if ((ScriptVarScenarioEqual(SCENARIO_SUB5,0,0)) && (HasRecruitedMon(MONSTER_HO_OH))) { - ScenarioCalc(SCENARIO_SUB5,0x2c,1); - } } - } } // arm9.bin::0200EC08 diff --git a/src/exclusive_pokemon.c b/src/exclusive_pokemon.c index de8c43553..e8faf27e2 100644 --- a/src/exclusive_pokemon.c +++ b/src/exclusive_pokemon.c @@ -1,16 +1,8 @@ #include "global.h" +#include "globaldata.h" #include "exclusive_pokemon.h" #include "dungeon_data.h" -const u8 filler_ex0[8] = -{ - 'p', 'k', 's', 'd', 'i', 'r', '0', 0 -}; -const u8 filler_ex1[8] = -{ - 'p', 'k', 's', 'd', 'i', 'r', '0', 0 -}; - EWRAM_INIT struct ExclusivePokemonData *gUnknown_203B498 = {0}; EWRAM_DATA struct ExclusivePokemonData gExclusivePokemonInfo = {0}; @@ -36,32 +28,21 @@ void InitializeExclusivePokemon(void) void sub_8097FA8(u8 param_1) { - gUnknown_203B498->unk48[param_1 >> 5] |= 1 << ((param_1 & 0x1f)); + gUnknown_203B498->unk48[param_1 / 32] |= 1 << ((param_1 % 32)); } void sub_8097FD0(u8 param_1) { - gUnknown_203B498->unk3C[param_1 >> 5] |= 1 << ((param_1 & 0x1f)); + gUnknown_203B498->unk3C[param_1 / 32] |= 1 << ((param_1 % 32)); } void sub_8097FF8(void) { - s32 iVar1; s32 index; - struct ExclusivePokemonData *ptr; - for(index = 0; index < 0x40; index++) - { - ptr = gUnknown_203B498; - if (index < 0) { - iVar1 = index + 0x1f; - } - else - { - iVar1 = index; - } - if ((ptr->unk48[iVar1 >> 5] & (1 << (index - ((iVar1 >> 5) * 0x20)))) != 0) { - ptr->unk3C[iVar1 >> 5] |= (1 << (index - ((iVar1 >> 5) * 0x20))); + for (index = 0; index < 0x40; index++) { + if ((gUnknown_203B498->unk48[index / 32] & (1 << (index % 32))) != 0) { + gUnknown_203B498->unk3C[index / 32] |= (1 << (index % 32)); } } sub_8098080(); @@ -69,8 +50,8 @@ void sub_8097FF8(void) void sub_8098044(u8 param_1) { - gUnknown_203B498->unk3C[param_1 >> 5] &= ~(1 << (((param_1 & 0x1f)))); - gUnknown_203B498->unk48[param_1 >> 5] &= ~(1 << (((param_1 & 0x1f)))); + gUnknown_203B498->unk3C[param_1 / 32] &= ~(1 << (((param_1 % 32)))); + gUnknown_203B498->unk48[param_1 / 32] &= ~(1 << (((param_1 % 32)))); } void sub_8098080(void) @@ -92,39 +73,26 @@ u8 sub_80980A4(void) void sub_80980B4(s16 pokeID) { - s32 index; - s32 pokeID_s32; - s32 pokeID_s32_1; - struct ExclusivePokemonData *ptr; + s32 pokeID_s32 = pokeID; + s32 pokeID_s32_1 = pokeID_s32; + if (pokeID_s32 == MONSTER_DECOY) + return; + if (pokeID_s32 == MONSTER_STATUE) + return; + if (pokeID_s32 == MONSTER_RAYQUAZA_CUTSCENE) + return; - pokeID_s32 = pokeID; - pokeID_s32_1 = pokeID_s32; - if (pokeID_s32 != MONSTER_DECOY) - { - if(pokeID_s32 != MONSTER_STATUE) - { - if(pokeID_s32 != MONSTER_RAYQUAZA_CUTSCENE) { - ptr = gUnknown_203B498; - index = pokeID_s32; - if (pokeID_s32 < 0) { - index = pokeID_s32 + 0x1f; - } - ptr->unk4[index >> 5] |= 1 << (s16)((pokeID_s32_1 - (index >> 5) * 0x20)); - } - } - } + gUnknown_203B498->unk4[pokeID_s32 / 32] |= 1 << (s16)(pokeID_s32_1 % 32); } bool8 sub_8098100(u8 param_1) { - u32 index = param_1; - - if (index > 0x3f) { + if (param_1 > 0x3f) { return FALSE; } else { - return (gUnknown_203B498->unk3C[param_1 >> 0x5] & (1 << (index & 0x1f))) != 0; + return (gUnknown_203B498->unk3C[param_1 / 32] & (1 << (param_1 % 32))) != 0; } } @@ -135,12 +103,12 @@ bool8 sub_8098134(s16 pokeID) pokeID_s32 = pokeID; pokeID_s32_1 = pokeID_s32; - return ((gUnknown_203B498->unk4[pokeID_s32 / 32] & (1 << (s16)(pokeID_s32_1 - ((pokeID_s32 / 32) * 0x20)))) != 0); + return ((gUnknown_203B498->unk4[pokeID_s32 / 32] & (1 << (s16)(pokeID_s32_1 % 32))) != 0); } void SetTutorialFlag(s32 index) { - gUnknown_203B498->unk54[index / 32] |= (1 << (index - ((index / 32) * 32))); + gUnknown_203B498->unk54[index / 32] |= (1 << (index % 32)); } bool32 GetTutorialFlag(s32 index) @@ -149,7 +117,7 @@ bool32 GetTutorialFlag(s32 index) return FALSE; } else { - return (((gUnknown_203B498->unk54[index / 32]) & (1 << (index - ((index / 32) * 32)))) != 0); + return (((gUnknown_203B498->unk54[index / 32]) & (1 << (index % 32))) != 0); } } @@ -194,7 +162,6 @@ void WriteExclusivePokemon(DataSerializer *r0) neg_1 = -1; zero = 0; - WriteBits(r0, gUnknown_203B498, 1); for(index = 0; index < MONSTER_MAX; index++) { @@ -224,39 +191,32 @@ void WriteExclusivePokemon(DataSerializer *r0) void ReadExclusivePokemon(DataSerializer *r0) { s32 index; - u8 stack_0; - u8 stack_1; - u8 stack_2; - u8 stack_3; memset(gUnknown_203B498, 0, sizeof(struct ExclusivePokemonData)); ReadBits(r0, gUnknown_203B498, 1); - for(index = 0; index < MONSTER_MAX; index++) - { + for (index = 0; index < MONSTER_MAX; index++) { + u8 stack_0; ReadBits(r0, &stack_0, 1); if(stack_0) sub_80980B4(index); } - for(index = 0; index < 64; index++) - { + for (index = 0; index < 64; index++) { + u8 stack_1; ReadBits(r0, &stack_1, 1); if(stack_1) sub_8097FA8(index); } - for(index = 0; index < 31; index++) - { + for (index = 0; index < 31; index++) { + u8 stack_2; ReadBits(r0, &stack_2, 1); if(stack_2) SetTutorialFlag(index); } - for(index = 0; index < NUM_EXCLUSIVE_POKEMON; index++) - { + for (index = 0; index < NUM_EXCLUSIVE_POKEMON; index++) { + u8 stack_3; ReadBits(r0, &stack_3, 1); - do; while(0); // do/while needed for matching - jiang - - gUnknown_203B498->Exclusives[index] = 1 & stack_3; + gUnknown_203B498->Exclusives[index] = (stack_3 & 1) != 0; } sub_8097FF8(); } - diff --git a/src/friend_list_menu.c b/src/friend_list_menu.c index dc10d1686..53a01d064 100644 --- a/src/friend_list_menu.c +++ b/src/friend_list_menu.c @@ -1,5 +1,6 @@ #include "global.h" #include "globaldata.h" +#include "friend_list_menu.h" #include "constants/dungeon.h" #include "music_util.h" #include "code_801602C.h" @@ -11,7 +12,6 @@ #include "code_8099360.h" #include "common_strings.h" #include "event_flag.h" -#include "friend_list_menu.h" #include "ground_map.h" #include "input.h" #include "iq_skill_menu.h" @@ -27,31 +27,92 @@ #include "text_2.h" #include "unk_ds_only_feature.h" -EWRAM_INIT unkStruct_203B2B4 *gUnknown_203B2B4 = {NULL}; +// there might be more overlap with unkStruct_203B2BC +// I was working on the moves and put the data that seemed to correspond to that +// into a separate struct +typedef struct unkStruct_203B2B4 +{ + // size: 0x178 + s32 unk0; + s32 state; + u32 fallbackState; + u8 unkC; // friend Area + u8 unkD; // friend Area + s16 species; + u32 itemIndex; + BulkItem item1; + BulkItem item2; + /* 0x1C */ Pokemon *pokeStruct; + u32 moveIndex; // some sort of move index + u16 moveID; + Move moves[8]; + u16 moveIDs[4]; // some list of move IDs + u32 menuAction1; + s32 menuAction2; + MenuStruct unk78; + MenuItem unkC8[8]; + u16 unk108[8]; + WindowTemplates unk118; +} unkStruct_203B2B4; + +static EWRAM_INIT unkStruct_203B2B4 *gUnknown_203B2B4 = {NULL}; #include "data/friend_list_menu.h" -extern s32 sub_80144A4(s32 *); +static void SetFriendListMenuState(s32); +static void sub_802544C(void); +static void sub_8025518(void); +static void sub_8025728(void); +static void sub_802591C(void); +static void sub_80259F0(void); +static void sub_8025A84(void); +static void sub_8025BCC(void); +static void sub_8025BE8(void); +static void sub_8025C04(void); +static void sub_8025CB4(void); +static void sub_8025D90(void); +static void sub_8025DAC(void); +static void sub_8025E08(void); +static void sub_8025E24(void); +static void FriendListMenu_GotoFallbackState(void); +static void sub_8025E68(u32 , BulkItem *); +static bool8 FriendListMenu_isOnTeam(Pokemon *); -void SetFriendListMenuState(s32); -void sub_802544C(void); -void sub_8025518(void); -void sub_8025728(void); -void sub_802591C(void); -void sub_80259F0(void); -void sub_8025A84(void); -void sub_8025BCC(void); -void sub_8025BE8(void); -void sub_8025C04(void); -void sub_8025CB4(void); -void sub_8025D90(void); -void sub_8025DAC(void); -void sub_8025E08(void); -void sub_8025E24(void); -void FriendListMenu_GotoFallbackState(void); -void sub_8025E68(u32 , BulkItem *); -bool8 FriendListMenu_isOnTeam(Pokemon *); +enum FriendListMenuStates { + // 0 + // 1 + // 2 + // 3 + FRIEND_LIST_MENU_STATE_SUMMARY = 4, + FRIEND_LIST_MENU_STATE_CHECK_IQ = 5, + FRIEND_LIST_MENU_STATE_STANDBY = 7, + FRIEND_LIST_MENU_STATE_ITEM_GIVEN = 8, + FRIEND_LIST_MENU_STATE_ITEM_EXCHANGE = 9, + FRIEND_LIST_MENU_STATE_TAKE = 0xA, + FRIEND_LIST_MENU_STATE_GIVE = 0xB, + // 0xC + // 0xD + FRIEND_LIST_MENU_STATE_INFO = 0xE, + FRIEND_LIST_MENU_STATE_MOVES = 0xF, + // 0x10 + // 0x11 + // 0x12 + FRIEND_LIST_MENU_STATE_EXIT = 0x13 +}; +enum FriendListMenuActions { + FRIEND_LIST_MENU_NULL = 1, + FRIEND_LIST_MENU_INFO = 4, + FRIEND_LIST_MENU_SUMMARY = 4, + FRIEND_LIST_MENU_CHECK_IQ = 5, + FRIEND_LIST_MENU_MOVES, + FRIEND_LIST_MENU_VISIT, + // 8 + FRIEND_LIST_MENU_STANDBY = 9, + FRIEND_LIST_MENU_GIVE = 0xA, + FRIEND_LIST_MENU_TAKE, + +}; bool8 CreateFriendListMenu(s32 param_1) { @@ -126,21 +187,17 @@ u8 sub_802540C(void) void CleanFriendListMenu(void) { - if(gUnknown_203B2B4 != NULL) - { - MemoryFree(gUnknown_203B2B4); - gUnknown_203B2B4 = NULL; - } + TRY_FREE_AND_SET_NULL(gUnknown_203B2B4); } -void SetFriendListMenuState(s32 newState) +static void SetFriendListMenuState(s32 newState) { gUnknown_203B2B4->state = newState; sub_802544C(); sub_8025518(); } -void sub_802544C(void) +static void sub_802544C(void) { s32 i; @@ -171,7 +228,7 @@ void sub_802544C(void) ShowWindows(&gUnknown_203B2B4->unk118, TRUE, TRUE); } -void sub_8025518(void) +static void sub_8025518(void) { u32 uVar3; Item item; @@ -257,7 +314,7 @@ void sub_8025518(void) } } -void sub_8025728(void) +static void sub_8025728(void) { int index; Pokemon *pokeStruct; @@ -330,7 +387,7 @@ void sub_8025728(void) } } -void sub_802591C(void) +static void sub_802591C(void) { int index; s32 loopMax = 0; @@ -368,7 +425,7 @@ void sub_802591C(void) } } -void sub_80259F0(void) +static void sub_80259F0(void) { switch(FriendList_HandleInput(TRUE)) { @@ -391,7 +448,7 @@ void sub_80259F0(void) } } -void sub_8025A84(void) +static void sub_8025A84(void) { s32 menuAction = 0; @@ -452,7 +509,7 @@ void sub_8025A84(void) } } -void sub_8025BCC(void) +static void sub_8025BCC(void) { switch(sub_80244E4()) { @@ -467,7 +524,7 @@ void sub_8025BCC(void) } } -void sub_8025BE8(void) +static void sub_8025BE8(void) { switch(sub_801BF48()) { @@ -482,7 +539,7 @@ void sub_8025BE8(void) } } -void sub_8025C04(void) +static void sub_8025C04(void) { switch(sub_801A6E8(TRUE)) { @@ -509,7 +566,7 @@ void sub_8025C04(void) } } -void sub_8025CB4(void) +static void sub_8025CB4(void) { u32 nextState; s32 menuAction; @@ -554,7 +611,7 @@ void sub_8025CB4(void) } } -void sub_8025D90(void) +static void sub_8025D90(void) { switch(sub_801B410()) { @@ -568,7 +625,7 @@ void sub_8025D90(void) } } -void sub_8025DAC(void) +static void sub_8025DAC(void) { switch(sub_801EF38(1)) { @@ -590,7 +647,7 @@ void sub_8025DAC(void) } } -void sub_8025E08(void) +static void sub_8025E08(void) { switch(sub_801F890()) { @@ -604,7 +661,7 @@ void sub_8025E08(void) } } -void sub_8025E24(void) +static void sub_8025E24(void) { switch(sub_8016080()) { @@ -617,7 +674,7 @@ void sub_8025E24(void) } } -void FriendListMenu_GotoFallbackState(void) +static void FriendListMenu_GotoFallbackState(void) { s32 local; if(sub_80144A4(&local) == 0) @@ -626,7 +683,7 @@ void FriendListMenu_GotoFallbackState(void) } } -void sub_8025E68(u32 r0, BulkItem *heldItem) +static void sub_8025E68(u32 r0, BulkItem *heldItem) { Item item; struct unkStruct_8090F58 a3; @@ -643,21 +700,13 @@ void sub_8025E68(u32 r0, BulkItem *heldItem) sub_80073E0(r0); } -bool8 FriendListMenu_isOnTeam(Pokemon *pokeStruct) +static bool8 FriendListMenu_isOnTeam(Pokemon *pokeStruct) { - bool32 flag; if (pokeStruct->isTeamLeader) - { - return FALSE; - } - else - { - flag = FALSE; - if(pokeStruct->dungeonLocation.id == DUNGEON_JOIN_LOCATION_PARTNER) - flag = TRUE; - if(flag && !sub_80023E4(8)) - return FALSE; - else - return TRUE; - } + return FALSE; + + if (IsMonPartner(pokeStruct) && !sub_80023E4(8)) + return FALSE; + + return TRUE; } diff --git a/src/ground_script.c b/src/ground_script.c index 3a25886fc..a3de80601 100644 --- a/src/ground_script.c +++ b/src/ground_script.c @@ -11,8 +11,8 @@ #include "code_8099360.h" #include "code_8094F88.h" #include "code_80958E8.h" -#include "code_80972F4.h" -#include "code_8097670.h" +#include "rescue_scenario.h" +#include "adventure_info.h" #include "code_80A26CC.h" #include "debug.h" #include "dungeon_info.h" @@ -54,15 +54,12 @@ #include "ground_object.h" #include "ground_weather.h" #include "code_809D148.h" +#include "training_maze.h" // Beware of the declarations without specified arguments, returning u32 or s32, these were quickly hacked in to get the code to compile and link // The return values are almost certainly NOT correct and will need to be rechecked when moving to header files char sub_8002984(s32, u8); bool8 sub_802FCF0(void); -void sub_809733C(s16, bool8); -void sub_80973A8(s16, bool8); -void sub_80975A8(s16, bool8); -void GroundScriptLockJumpZero(s16); bool8 sub_8099B94(void); PixelPos SetVecFromDirectionSpeed(s8, s32); bool8 sub_80961D8(void); @@ -70,7 +67,6 @@ void ResetMailbox(void); void sub_80963FC(void); void sub_8096488(void); bool8 sub_80964B4(void); -bool8 sub_8097640(); u8 sub_80964E4(); // For gScriptLocks, gScriptLockConds, gUnlockBranchLabels diff --git a/src/iq_skill_info_menu.c b/src/iq_skill_info_menu.c index e88bc73ad..a671ee04c 100644 --- a/src/iq_skill_info_menu.c +++ b/src/iq_skill_info_menu.c @@ -1,7 +1,7 @@ #include "global.h" #include "globaldata.h" #include "music_util.h" -#include "code_8097DD0.h" +#include "status_strings.h" #include "input.h" #include "iq_skill_info_menu.h" #include "memory.h" diff --git a/src/items.c b/src/items.c index ae3994770..d164cacd8 100644 --- a/src/items.c +++ b/src/items.c @@ -1,6 +1,6 @@ #include "global.h" #include "globaldata.h" -#include "code_8097DD0.h" +#include "status_strings.h" #include "constants/colors.h" #include "constants/type.h" #include "code_800D090.h" diff --git a/src/load_screen.c b/src/load_screen.c index c08498962..83236c094 100644 --- a/src/load_screen.c +++ b/src/load_screen.c @@ -6,7 +6,7 @@ #include "bg_palette_buffer.h" #include "code_800D090.h" #include "code_8094F88.h" -#include "code_8097670.h" +#include "adventure_info.h" #include "def_filearchives.h" #include "dungeon_info.h" #include "event_flag.h" diff --git a/src/luminous_cave.c b/src/luminous_cave.c index 737803593..a0cf475df 100644 --- a/src/luminous_cave.c +++ b/src/luminous_cave.c @@ -6,7 +6,7 @@ #include "music_util.h" #include "code_801602C.h" #include "code_801B3C0.h" -#include "code_8097670.h" +#include "adventure_info.h" #include "code_8099360.h" #include "common_strings.h" #include "input.h" diff --git a/src/main_loops.c b/src/main_loops.c index 52427e138..86793c6df 100644 --- a/src/main_loops.c +++ b/src/main_loops.c @@ -13,7 +13,7 @@ #include "run_dungeon.h" #include "code_8094F88.h" #include "code_80958E8.h" -#include "code_8097670.h" +#include "adventure_info.h" #include "code_8099360.h" #include "code_80A26CC.h" #include "cpu.h" @@ -86,7 +86,6 @@ static u32 xxx_script_related_8001334(u32 r0); static void MainLoops_RunFrameActions(u32 unused); extern bool8 sub_8096A08(u8 dungeon, Pokemon *pokemon); -extern void IncrementNumAdventures(void); extern void sub_8096BD0(void); static const unkTalkTable sBaseKindTable[17] = { diff --git a/src/makuhita_dojo2.c b/src/makuhita_dojo2.c index a986cc304..e97d58713 100644 --- a/src/makuhita_dojo2.c +++ b/src/makuhita_dojo2.c @@ -4,7 +4,7 @@ #include "constants/input.h" #include "code_800D090.h" #include "music_util.h" -#include "code_80972F4.h" +#include "training_maze.h" #include "code_80A26CC.h" #include "dungeon_info.h" #include "input.h" diff --git a/src/moves.c b/src/moves.c index 1ae0c212b..3486190b1 100644 --- a/src/moves.c +++ b/src/moves.c @@ -4,7 +4,7 @@ #include "constants/monster.h" #include "code_800D090.h" #include "data_serializer.h" -#include "code_8097DD0.h" +#include "status_strings.h" #include "def_filearchives.h" #include "memory.h" #include "moves.h" diff --git a/src/party_list_menu.c b/src/party_list_menu.c index 1a26d31e3..7a49148b1 100644 --- a/src/party_list_menu.c +++ b/src/party_list_menu.c @@ -28,39 +28,113 @@ #include "text_util.h" #include "unk_ds_only_feature.h" +// size: 0x280 +typedef struct unkStruct_203B2B8 +{ + /* 0x0 */ s32 state; + /* 0x4 */ s32 fallbackState; + bool8 unk8; + /* 0xA */ s16 pokeSpecies; + /* 0xC */ u32 id; + /* 0x10 */ BulkItem item1; + /* 0x14 */ BulkItem item2; + /* 0x18 */ Pokemon *pokeStruct; + /* 0x1C */ bool8 isTeamLeader; + /* 0x20 */ u32 moveIndex; + /* 0x24 */ u16 moveID; + /* 0x28 */ Move moves[8]; + /* 0x68 */ u16 moveIDs[4]; // some list of move IDs + /* 0x70 */ u32 menuAction1; + /* 0x74 */ u32 menuAction2; + /* 0x78 */ u32 menuAction3; // unused + MenuStruct unk7C; + MenuStruct unkCC; + MenuStruct unk11C; // unused + MenuItem unk16C[10]; + MenuItem unk1BC[10]; + u16 unk20C[10]; + WindowTemplates unk220; +} unkStruct_203B2B8; + static EWRAM_INIT unkStruct_203B2B8 *sUnknown_203B2B8 = {NULL}; #include "data/party_list_menu.h" -extern u32 sub_8026F04(Pokemon *); -bool8 CanTakePokemonHeldItem(Pokemon *r0); -bool8 sub_8026E88(Pokemon *r0); -bool8 sub_8026EB8(Pokemon *r0); -void sub_8026E08(u32 r0); -void sub_8026DAC(u32 r0, BulkItem *item); -void sub_8026FA4(void); -void PartyListMenu_BuildYesNoMenu(void); - -void PartyListMenu_CreateMenu2(void); -void PartyListMenu_CreateMenu1(void); -void HandlePartyListMenuCallback(void); - -void PartyListMenu_HandleMenu1(void); -void sub_8026A78(void); -void sub_8026A94(void); -void sub_8026AB0(void); -void sub_8026B10(void); -void sub_8026B48(void); -void sub_8026B64(void); -void PartyListMenu_HandleMenu2(void); -void sub_8026CF0(void); -void sub_8026D0C(void); -void sub_8026D6C(void); -void PartyListMenu_GotoFallbackState(void); - +static u32 sub_8026F04(Pokemon *); +static bool8 CanTakePokemonHeldItem(Pokemon *r0); +static bool8 sub_8026E88(Pokemon *r0); +static bool8 sub_8026EB8(Pokemon *r0); +static void sub_8026E08(u32 r0); +static void sub_8026DAC(u32 r0, BulkItem *item); +static void sub_8026FA4(void); +static void PartyListMenu_BuildYesNoMenu(void); +static void PartyListMenu_CreateMenu2(void); +static void PartyListMenu_CreateMenu1(void); +static void HandlePartyListMenuCallback(void); +static void PartyListMenu_HandleMenu1(void); +static void sub_8026A78(void); +static void sub_8026A94(void); +static void sub_8026AB0(void); +static void sub_8026B10(void); +static void sub_8026B48(void); +static void sub_8026B64(void); +static void PartyListMenu_HandleMenu2(void); +static void sub_8026CF0(void); +static void sub_8026D0C(void); +static void sub_8026D6C(void); +static void PartyListMenu_GotoFallbackState(void); static void SetPartyListMenuState(s32 newState); static void sub_802608C(void); +enum PartyListMenuStates +{ + PARTY_LIST_STATE_INIT, + PARTY_LIST_STATE_MAIN_MENU, + PARTY_LIST_STATE_MAIN_MENU_1, + PARTY_LIST_STATE_SUMMARY = 3, + PARTY_LIST_STATE_CHECK_IQ = 4, + PARTY_LIST_STATE_JOIN_TEAM = 5, + PARTY_LIST_STATE_STANDBY = 6, + PARTY_LIST_STATE_MAKE_LEADER = 7, + PARTY_LIST_STATE_POKEMON_FAREWELL = 8, + // 9 + // 0xA + // 0xB + PARTY_LIST_STATE_SAY_FAREWELL = 0xC, + PARTY_LIST_STATE_CONFIRM_SAY_FAREWELL = 0xD, + PARTY_LIST_STATE_GIVE_GUMMI = 0xe, + PARTY_LIST_STATE_GIVEN_ITEM = 0xF, + PARTY_LIST_STATE_GIVEN_ITEM_HELD_ITEM = 0x10, + PARTY_LIST_STATE_TAKE_ITEM = 0x11, + PARTY_LIST_STATE_GIVE_ITEM = 0x12, + PARTY_LIST_STATE_GIVE_ITEM_1 = 0x13, + // 0x14 + // 0x15 + PARTY_LIST_STATE_MOVES = 0x16, + // 0x17 + // 0x18 + PARTY_LIST_STATE_EXIT = 0x19, + +}; + +enum PartyListMenuActions +{ + PARTY_LIST_MENU_NULL = 1, + PARTY_LIST_MENU_YES, + PARTY_LIST_MENU_NO, + PARTY_LIST_MENU_INFO = 4, + PARTY_LIST_MENU_SUMMARY = 4, + PARTY_LIST_MENU_CHECK_IQ, + PARTY_LIST_MENU_JOIN_TEAM, + PARTY_LIST_MENU_STANDBY, + PARTY_LIST_MENU_MAKE_LEADER, + PARTY_LIST_MENU_SAY_FAREWELL, + PARTY_LIST_MENU_GIVE_GUMMI, + PARTY_LIST_MENU_GIVE_ITEM, + PARTY_LIST_MENU_TAKE_ITEM, + PARTY_LIST_MENU_MOVES, +}; + bool8 CreatePartyListMenu(Pokemon *pokeStruct) { s32 i; @@ -141,10 +215,7 @@ bool8 sub_802604C(void) void CleanPartyListMenu(void) { - if (sUnknown_203B2B8) { - MemoryFree(sUnknown_203B2B8); - sUnknown_203B2B8 = NULL; - } + TRY_FREE_AND_SET_NULL(sUnknown_203B2B8); } static void SetPartyListMenuState(s32 newState) @@ -189,7 +260,7 @@ static void sub_802608C(void) ShowWindows(&sUnknown_203B2B8->unk220, TRUE, TRUE); } -void HandlePartyListMenuCallback(void) +static void HandlePartyListMenuCallback(void) { Item item; @@ -301,7 +372,8 @@ void HandlePartyListMenuCallback(void) } } -void PartyListMenu_CreateMenu1(void) { +static void PartyListMenu_CreateMenu1(void) +{ Pokemon *pokeStruct; s32 index; s32 loopMax = 0; @@ -404,7 +476,7 @@ void PartyListMenu_CreateMenu1(void) { } } -void PartyListMenu_CreateMenu2(void) +static void PartyListMenu_CreateMenu2(void) { s32 index; s32 loopMax = 0; @@ -440,7 +512,8 @@ void PartyListMenu_CreateMenu2(void) } } -void PartyListMenu_BuildYesNoMenu(void) { +static void PartyListMenu_BuildYesNoMenu(void) +{ s32 loopMax = 0; sUnknown_203B2B8->unk1BC[loopMax].text = gCommonYes[0]; sUnknown_203B2B8->unk1BC[loopMax].menuAction = PARTY_LIST_MENU_YES; @@ -452,7 +525,7 @@ void PartyListMenu_BuildYesNoMenu(void) { sUnknown_203B2B8->unk1BC[loopMax].menuAction = PARTY_LIST_MENU_NULL; } -void PartyListMenu_HandleMenu1(void) +static void PartyListMenu_HandleMenu1(void) { Pokemon *playerPokemon; Pokemon *newLeader; @@ -526,7 +599,7 @@ void PartyListMenu_HandleMenu1(void) } } -void sub_8026A78(void) +static void sub_8026A78(void) { switch(sub_80244E4()) { @@ -541,7 +614,7 @@ void sub_8026A78(void) } } -void sub_8026A94(void) +static void sub_8026A94(void) { switch(sub_801BF48()) { @@ -556,7 +629,6 @@ void sub_8026A94(void) } } - static inline bool8 sub_8026AB0_sub(void) { if (sUnknown_203B2B8->pokeStruct->dungeonLocation.id == DUNGEON_HOWLING_FOREST_2 || sUnknown_203B2B8->pokeStruct->dungeonLocation.id == DUNGEON_POKEMON_SQUARE) return TRUE; @@ -564,7 +636,7 @@ static inline bool8 sub_8026AB0_sub(void) { return FALSE; } -void sub_8026AB0(void) +static void sub_8026AB0(void) { s32 temp; if(sub_80144A4(&temp) == 0) @@ -585,7 +657,7 @@ void sub_8026AB0(void) } } -void sub_8026B10(void) +static void sub_8026B10(void) { s32 temp; if(sub_80144A4(&temp) == 0) @@ -603,8 +675,7 @@ void sub_8026B10(void) } } - -void sub_8026B48(void) +static void sub_8026B48(void) { switch(sub_8022860()) { @@ -619,8 +690,7 @@ void sub_8026B48(void) } } - -void sub_8026B64(void) +static void sub_8026B64(void) { switch(sub_801A6E8(TRUE)) { @@ -647,7 +717,7 @@ void sub_8026B64(void) } } -void PartyListMenu_HandleMenu2(void) +static void PartyListMenu_HandleMenu2(void) { u32 nextState; struct unkStruct_8090F58 temp; @@ -691,7 +761,7 @@ void PartyListMenu_HandleMenu2(void) } } -void sub_8026CF0(void) +static void sub_8026CF0(void) { switch(sub_801B410()) { @@ -706,8 +776,7 @@ void sub_8026CF0(void) } } - -void sub_8026D0C(void) +static void sub_8026D0C(void) { switch(sub_801EF38(1)) { @@ -727,7 +796,7 @@ void sub_8026D0C(void) } } -void sub_8026D6C(void) +static void sub_8026D6C(void) { switch(sub_801F890()) { @@ -742,7 +811,7 @@ void sub_8026D6C(void) } } -void PartyListMenu_GotoFallbackState(void) +static void PartyListMenu_GotoFallbackState(void) { s32 temp; if(sub_80144A4(&temp) == 0) @@ -751,7 +820,7 @@ void PartyListMenu_GotoFallbackState(void) } } -void sub_8026DAC(u32 r0, BulkItem *item) +static void sub_8026DAC(u32 r0, BulkItem *item) { Item slot; struct unkStruct_8090F58 temp; @@ -768,7 +837,7 @@ void sub_8026DAC(u32 r0, BulkItem *item) sub_80073E0(r0); } -void sub_8026E08(u32 r0) +static void sub_8026E08(u32 r0) { u8 buffer1[40]; u8 buffer[20]; @@ -784,7 +853,7 @@ void sub_8026E08(u32 r0) sub_80073E0(r0); } -bool8 sub_8026E88(Pokemon *r0) +static bool8 sub_8026E88(Pokemon *r0) { bool8 flag; if(!r0->isTeamLeader) @@ -799,7 +868,7 @@ bool8 sub_8026E88(Pokemon *r0) return TRUE; } -bool8 sub_8026EB8(Pokemon *r0) +static bool8 sub_8026EB8(Pokemon *r0) { bool8 flag; if(sub_808D3BC() != r0) @@ -820,8 +889,7 @@ bool8 sub_8026EB8(Pokemon *r0) return FALSE; } - -u32 sub_8026F04(Pokemon *r0) +static u32 sub_8026F04(Pokemon *r0) { if(r0->heldItem.id == ITEM_NOTHING) return 0; @@ -833,7 +901,7 @@ u32 sub_8026F04(Pokemon *r0) return 3; } -bool8 CanTakePokemonHeldItem(Pokemon *r0) +static bool8 CanTakePokemonHeldItem(Pokemon *r0) { if(IsNotMoneyOrUsedTMItem(r0->heldItem.id)) { @@ -853,7 +921,7 @@ bool8 CanTakePokemonHeldItem(Pokemon *r0) return TRUE; } -void sub_8026FA4(void) +static void sub_8026FA4(void) { switch(sub_8026F04(sUnknown_203B2B8->pokeStruct)) { diff --git a/src/play_time.c b/src/play_time.c index 5326ce245..37e71f5c7 100644 --- a/src/play_time.c +++ b/src/play_time.c @@ -6,7 +6,6 @@ EWRAM_INIT struct PlayTimeStruct *gPlayTimeRef = {NULL}; EWRAM_DATA struct PlayTimeStruct gPlayTime = {0}; - void InitializePlayTime(void) { gPlayTimeRef = &gPlayTime; diff --git a/src/pokemon.c b/src/pokemon.c index 7680e56b1..7f9ea1eef 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -5,7 +5,7 @@ #include "constants/monster.h" #include "constants/tactic.h" #include "code_800D090.h" -#include "code_8097DD0.h" +#include "status_strings.h" #include "cpu.h" #include "decompress_at.h" #include "def_filearchives.h" diff --git a/src/pokemon_evolution.c b/src/pokemon_evolution.c index d86187e32..2399ead6e 100644 --- a/src/pokemon_evolution.c +++ b/src/pokemon_evolution.c @@ -5,7 +5,7 @@ #include "pokemon_3.h" #include "text_util.h" #include "friend_area.h" -#include "code_8097670.h" +#include "adventure_info.h" #include "constants/evolve_type.h" #include "constants/evolution_status.h" diff --git a/src/position_util.c b/src/position_util.c index fc87d3b9e..130083cab 100644 --- a/src/position_util.c +++ b/src/position_util.c @@ -1,4 +1,5 @@ #include "global.h" +#include "globaldata.h" #include "position_util.h" #include "constants/direction.h" @@ -11,56 +12,25 @@ static const s32 sFacingDirMapping[3][3] = { s32 GetDirectionTowardsPosition(DungeonPos *originPos, DungeonPos *targetPos) { - s32 direction; - s32 yDiff; - s32 xDiff; + s32 xDiff = targetPos->x - originPos->x; + s32 yDiff = targetPos->y - originPos->y; - xDiff = targetPos->x - originPos->x; - yDiff = targetPos->y - originPos->y; if (xDiff == 0 && yDiff == 0) - { - direction = DIRECTION_SOUTH; - } - else - { - if (xDiff > 0) - { - xDiff = 1; - } - if (yDiff > 0) - { - yDiff = 1; - } - if (xDiff <= -1) - { - xDiff = -1; - } - if (yDiff <= -1) - { - yDiff = -1; - } - direction = sFacingDirMapping[yDiff + 1][xDiff + 1]; - } - return direction; + return DIRECTION_SOUTH; + + if (xDiff >= 1) + xDiff = 1; + if (yDiff >= 1) + yDiff = 1; + if (xDiff <= -1) + xDiff = -1; + if (yDiff <= -1) + yDiff = -1; + + return sFacingDirMapping[yDiff + 1][xDiff + 1]; } s32 GetDistance(DungeonPos *pos1, DungeonPos *pos2) { - s32 distanceX = pos1->x - pos2->x; - s32 distance; - if (distanceX < 0) - { - distanceX = -distanceX; - } - distance = pos1->y - pos2->y; - if (distance < 0) - { - distance = -distance; - } - if (distance < distanceX) - { - distance = distanceX; - } - return distance; + return max(abs(pos1->x - pos2->x), abs(pos1->y - pos2->y)); } - diff --git a/src/post_office_guide2.c b/src/post_office_guide2.c index cfb4808d3..99ad55e6b 100644 --- a/src/post_office_guide2.c +++ b/src/post_office_guide2.c @@ -6,7 +6,7 @@ #include "music_util.h" #include "code_8094F88.h" #include "code_80958E8.h" -#include "code_80972F4.h" +#include "rescue_scenario.h" #include "code_8099360.h" #include "code_80A26CC.h" #include "input.h" @@ -19,6 +19,7 @@ #include "text_1.h" #include "text_3.h" #include "ground_main.h" +#include "training_maze.h" static EWRAM_INIT unkStruct_203B330 *sUnknown_203B330 = {NULL}; diff --git a/src/code_80972F4.c b/src/rescue_scenario.c similarity index 60% rename from src/code_80972F4.c rename to src/rescue_scenario.c index f931f64a8..06bb24ce8 100644 --- a/src/code_80972F4.c +++ b/src/rescue_scenario.c @@ -1,13 +1,56 @@ #include "global.h" #include "globaldata.h" +#include "rescue_scenario.h" #include "dungeon_info.h" #include "event_flag.h" #include "exclusive_pokemon.h" #include "code_80958E8.h" -#include "code_80972F4.h" #include "code_80A26CC.h" -#include "data/story_missions.h" +// size: 0x8 +typedef struct MissionText +{ + /* 0x0 */ const u8 *text; + u8 unk4; + u8 unk5; + u8 unk6; + u8 unk7; +} MissionText; + +static const MissionText sStoryMissionText[] = { + { _("Rescue Caterpie."), -1, -1, 0, 0 }, + { _("Rescue Magnemite."), -1, -1, 0, 0 }, + { _("Rescue Diglett."), 0, 1, 0, 0 }, + { _("Rescue Metapod."), 2, 3, 0, 0 }, + { _("Rescue Jumpluff."), -1, -1, 0, 0 }, + { _("Rescue Shiftry."), 4, 5, 0, 0 }, + { _("Meet Xatu."), -1, -1, 0, 0 }, + { _("Fugitive"), -1, -1, 0, 0 }, + { _("Fugitive"), 6, 7, 0, 0 }, + { _("Fugitive"), 8, 9, 0, 0 }, + { _("Meet Ninetales."), -1, 10, 0, 0 }, + { _("Rescue Alakazam."), 11, 12, 0, 0 }, + { _("Seek Rayquaza's help."), 14, 15, 0, 0 }, + { _("{COLOR YELLOW_C}Scenario Progress Dummy{RESET}"), -1, -1, 0, 0 }, + { _("Punish bad Mankey."), 16, 17, 0, 0 }, + { _("Rescue Smeargle."), -1, 33, 0, 0 }, + { _("Explore seafloor."), -1, -1, 0, 0 }, + { _("Meet sea guardian."), -1, -1, 0, 0 }, + { _("Check mystery Pokémon."), -1, -1, 0, 0 }, + { _("Meet Xatu."), -1, -1, 0, 0 }, + { _("Mirage Pokémon 1"), 20, 21, 0, 0 }, + { _("Mirage Pokémon 2"), 22, 23, 0, 0 }, + { _("Mirage Pokémon 3"), 24, 25, 0, 0 }, + { _("Mirage Pokémon 4"), -1, 26, 0, 0 }, + { _("Meet toughest Pokémon."), 18, 19, 0, 0 }, + { _("Catch thief."), 27, 28, 0, 0 }, + { _("Rescue Latias."), -1, -1, 0, 0 }, + { _("Investigate Relic."), -1, -1, 0, 0 }, + { _("Rescue Medicham."), -1, 32, 0, 0 }, + { _("Meet Ninetales."), -1, -1, 0, 0 }, + { _("Break Gardevoir's curse."), -1, -1, 0, 0 }, + { NULL, -1, -1, 0, 0 }, +}; ALIGNED(4) const u8 gDummyScenarioText[] = _("{COLOR YELLOW_C}Scenario try dummy{RESET}"); ALIGNED(4) const u8 gBlankMission[] = _("{COLOR RED_W}???{RESET}"); @@ -23,26 +66,17 @@ void sub_80972F4(void) void nullsub_128(void) {} -s32 sub_8097318(s16 param_1) +bool8 sub_8097318(s16 param_1) { - s32 iVar1; - s32 param_1_s32; + s32 param_1_s32 = param_1; - param_1_s32 = param_1; + if (param_1_s32 == 0xd) + return FALSE; - if (param_1_s32 == 0xd) { - iVar1 = 0; - } - else { - iVar1 = GetScriptVarArrayValue(NULL,RESCUE_SCENARIO_ORDER_LIST, (u16) param_1_s32); - if (iVar1 != 0) { - iVar1 = 1; - } - } - return iVar1; + return GetScriptVarArrayValue(NULL,RESCUE_SCENARIO_ORDER_LIST, (u16) param_1_s32) != 0; } -void sub_809733C(s16 param_1,u32 param_2) +void sub_809733C(s16 param_1, u32 param_2) { s32 uVar2; u8 param_2_u8; @@ -81,7 +115,7 @@ bool8 sub_8097384(s32 param_1) } } -void sub_80973A8(s32 param_1,u32 param_2) +void sub_80973A8(s32 param_1, u32 param_2) { s32 sVar1; s32 param_1_s32 = (s16)param_1; @@ -111,7 +145,7 @@ bool8 RescueScenarioConquered(s32 param_1) } } -void sub_8097418(s32 index,bool32 param_2) +void sub_8097418(s32 index, bool32 param_2) { int index_s32 = (s16)index; bool8 param_2_u8 = param_2; @@ -133,7 +167,7 @@ void sub_8097418(s32 index,bool32 param_2) } } -const u8 *sub_809747C(s16 index) +UNUSED static const u8 *sub_809747C(s16 index) { if(index == 0xD) { @@ -169,13 +203,3 @@ const u8 *GetCurrentMissionText(s16 index) return gBlankMission; } } - -void sub_80974E8(void) -{ - ClearScriptVarArray(NULL, TRAINING_CONQUEST_LIST); - ClearScriptVarArray(NULL, TRAINING_PRESENT_LIST); -} - -void nullsub_208(void) -{ -} diff --git a/src/run_dungeon.c b/src/run_dungeon.c index 3ebf50053..b95c39e0b 100644 --- a/src/run_dungeon.c +++ b/src/run_dungeon.c @@ -62,6 +62,7 @@ #include "dungeon_8041AD0.h" #include "ground_main.h" #include "dungeon_mon_sprite_render.h" +#include "adventure_info.h" EWRAM_INIT struct UnkStruct_203B414 *gUnknown_203B414 = NULL; EWRAM_INIT Dungeon *gDungeon = NULL; @@ -70,10 +71,8 @@ static EWRAM_INIT u8 *gSerializedData_203B41C = NULL; extern void sub_8068BDC(u8 r0); extern void sub_803D4AC(void); extern void sub_8068F28(void); -extern void IncrementThievingSuccesses(void); extern void sub_8043D60(void); extern void sub_80840A4(void); -extern void IncrementAdventureFloorsExplored(void); extern void sub_806AB2C(void); extern void sub_807E5AC(void); extern void nullsub_16(void); diff --git a/src/save.c b/src/save.c index 587152a95..81a732a6f 100644 --- a/src/save.c +++ b/src/save.c @@ -1,8 +1,9 @@ #include "global.h" #include "globaldata.h" +#include "save.h" #include "music_util.h" #include "string_format.h" -#include "code_8097670.h" +#include "adventure_info.h" #include "event_flag.h" #include "exclusive_pokemon.h" #include "flash.h" @@ -11,7 +12,9 @@ #include "memory.h" #include "pokemon_3.h" #include "random.h" -#include "save.h" +#include "adventure_save.h" +#include "training_maze.h" +#include "rescue_scenario.h" // size: 0x800 struct unk_struct @@ -43,8 +46,6 @@ extern u32 sub_8095624(u8 *, u32); extern u32 RestoreMailInfo(void* a, s32 b); extern u32 SaveMailInfo(u8 *, u32); extern void sub_80958E4(u32 *a, u32 b); -extern void sub_80972F4(void); -extern void sub_80974E8(void); u32 sub_8011C1C(void) { diff --git a/src/code_8097DD0.c b/src/status_strings.c similarity index 94% rename from src/code_8097DD0.c rename to src/status_strings.c index 33e21b66c..7deded8e5 100644 --- a/src/code_8097DD0.c +++ b/src/status_strings.c @@ -1,4 +1,6 @@ #include "global.h" +#include "globaldata.h" +#include "status_strings.h" #include "structs/str_status_text.h" #include "strings.h" #include "decompress_3.h" @@ -27,7 +29,7 @@ s32 PrepareStatusStringArrays(const char *str, STATUSTEXTS(statuses)) if (gStatusDescriptions[i].name == NULL) break; - for (j = 0; j < 100; j++) { + for (j = 0; j < ARRAY_COUNT_INT(formattedStatusString); j++) { if (gStatusDescriptions[i].name[j] == '#' && gStatusDescriptions[i].name[j + 1] == 'r') { formattedStatusString[j++] = '#'; formattedStatusString[j++] = 'r'; diff --git a/src/string_format.c b/src/string_format.c index 481094664..dec496ada 100644 --- a/src/string_format.c +++ b/src/string_format.c @@ -55,9 +55,6 @@ static const WindowTemplate sOnlyTextDialogueBoxWindowTemplate = { .header = NULL, }; -extern void DisplayMonPortraitSprite(s32 a0, const u8 *compressedData, s32 a2); -extern void sub_80073E0(s32 a0); - static void sub_8014A88(void); static bool8 sub_8014B94(void); static void nullsub_35(void); diff --git a/src/strings.c b/src/strings.c index 5c75ccb54..34a13cf7b 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1,4 +1,5 @@ #include "global.h" +#include "globaldata.h" #include "strings.h" #include "constants/friend_area.h" #include "constants/tactic.h" diff --git a/src/code_8097504.c b/src/training_maze.c similarity index 70% rename from src/code_8097504.c rename to src/training_maze.c index e7de933d3..894265c99 100644 --- a/src/code_8097504.c +++ b/src/training_maze.c @@ -1,14 +1,25 @@ #include "global.h" #include "globaldata.h" +#include "training_maze.h" #include "constants/dungeon.h" #include "dungeon_info.h" #include "event_flag.h" #include "code_80A26CC.h" -#include "code_80972F4.h" +#include "rescue_scenario.h" -ALIGNED(4) const char gMeetNinetalesText[] = "Meet Ninetales."; -ALIGNED(4) const char gAvoidCaptureText[] = "Avoid capture."; -ALIGNED(4) const char gFinalScenarioText[] = _("Defeat the final Pokémon."); +ALIGNED(4) static const char gMeetNinetalesText[] = "Meet Ninetales."; +ALIGNED(4) static const char gAvoidCaptureText[] = "Avoid capture."; +ALIGNED(4) static const char gFinalScenarioText[] = _("Defeat the final Pokémon."); + +void sub_80974E8(void) +{ + ClearScriptVarArray(NULL, TRAINING_CONQUEST_LIST); + ClearScriptVarArray(NULL, TRAINING_PRESENT_LIST); +} + +UNUSED static void nullsub_208(void) +{ +} bool8 sub_8097504(s16 mazeIndex) { @@ -68,15 +79,15 @@ void sub_80975A8(s16 param_1,u8 param_2) SetScriptVarArrayValue(NULL,TRAINING_CONQUEST_LIST,param_1_u16,param_2); } -const u8 *sub_80975C4(s16 index) +UNUSED static const u8 *sub_80975C4(s16 index) { return GetDungeonName1(sub_80A2728(index)); } const u8 *sub_80975DC(s16 r0) { - if(r0 == 23 || r0 == 24) { - if(ScriptVarScenarioEqual(SCENARIO_MAIN, 0xE, -1)) + if (r0 == 23 || r0 == 24) { + if (ScriptVarScenarioEqual(SCENARIO_MAIN, 0xE, -1)) return gMeetNinetalesText; else return gAvoidCaptureText; @@ -88,9 +99,8 @@ const u8 *sub_80975DC(s16 r0) bool8 HasCompletedAllMazes(void) { s32 index; - for(index = 0; index < NUM_BASIC_DUNGEON_MAZE; index++) - { - if(!(bool8)IsMazeCompleted(index)) + for (index = 0; index < NUM_BASIC_DUNGEON_MAZE; index++) { + if(!IsMazeCompleted(index)) return FALSE; } return TRUE; @@ -98,14 +108,11 @@ bool8 HasCompletedAllMazes(void) bool8 sub_8097640(void) { - if(GetScriptVarArrayValue(NULL, TRAINING_CONQUEST_LIST, 0x1F) == 0 && HasCompletedAllMazes()) - { + if (GetScriptVarArrayValue(NULL, TRAINING_CONQUEST_LIST, 0x1F) == 0 && HasCompletedAllMazes()) { SetScriptVarArrayValue(NULL, TRAINING_CONQUEST_LIST, 0x1F, 1); return TRUE; } - else - { + else { return FALSE; } } - diff --git a/src/unk_dungeon_load_maybe.c b/src/unk_dungeon_load_maybe.c index 0f3d7d633..e6bcc1431 100644 --- a/src/unk_dungeon_load_maybe.c +++ b/src/unk_dungeon_load_maybe.c @@ -3,14 +3,13 @@ #include "unk_dungeon_load.h" #include "memory.h" #include "dungeon_info.h" +#include "dungeon_data.h" #include "decompress_at.h" #include "def_filearchives.h" #include "file_system.h" #include "constants/dungeon.h" #include "structs/dungeon_mapparam.h" -extern bool8 IsWaterDungeon(u32 r0); - static s32 sub_80ADFB8(s32 a0, s32 a1, s32 a2, s32 a3, u16 *a4, s32 a5, u8 *a6, s32 a7); // This function is called when loading a transition between a dungeon and its summit, where the player can continue, save, or go back. diff --git a/src/wonder_mail_2.c b/src/wonder_mail_2.c index 7a88243fe..06a519edf 100644 --- a/src/wonder_mail_2.c +++ b/src/wonder_mail_2.c @@ -5,7 +5,7 @@ #include "code_800D090.h" #include "code_802F204.h" #include "code_8094F88.h" -#include "code_8097670.h" +#include "adventure_info.h" #include "code_8099360.h" #include "event_flag.h" #include "game_options.h" diff --git a/src/wonder_mail_802D098.c b/src/wonder_mail_802D098.c index 518cb2d37..1aa0f21ad 100644 --- a/src/wonder_mail_802D098.c +++ b/src/wonder_mail_802D098.c @@ -4,7 +4,7 @@ #include "code_802DE84.h" #include "code_803B050.h" #include "code_80958E8.h" -#include "code_80972F4.h" +#include "rescue_scenario.h" #include "code_8099360.h" #include "common_strings.h" #include "input.h" diff --git a/sym_ewram.txt b/sym_ewram.txt index 283f7c7de..89c811fce 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -71,7 +71,7 @@ .space 4 .include "src/code_80958E8.o" .space 4 - .include "src/code_8097670.o" + .include "src/adventure_info.o" .space 4 .include "src/exclusive_pokemon.o" .space 4 diff --git a/sym_ewram_init.txt b/sym_ewram_init.txt index b0bc35ac3..6790ab1c9 100644 --- a/sym_ewram_init.txt +++ b/sym_ewram_init.txt @@ -136,7 +136,7 @@ .include "src/play_time.o" .include "src/code_8094F88.o" .include "src/code_80958E8.o" -.include "src/code_8097670.o" +.include "src/adventure_info.o" .include "src/exclusive_pokemon.o" .include "src/ground_main.o" .include "src/script_item.o"