From 25aaa2833003a32f58c5a813c40b20e61e7c7206 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 27 Oct 2025 14:34:30 +0100 Subject: [PATCH] clean up some file splits --- data/data_8109D10.s | 5 +- data/data_810AE24_2.s | 2 - include/{code_8097670.h => adventure_info.h} | 29 +-- include/adventure_save.h | 7 + include/friend_list_menu.h | 69 ------- include/party_list_menu.h | 83 --------- include/play_time.h | 15 +- ld_script.ld | 5 +- src/{code_8097670.c => adventure_info.c} | 67 +------ src/adventure_log.c | 2 +- src/adventure_save.c | 37 ++++ src/debug_menu1.c | 2 +- src/dungeon_main.c | 3 +- src/dungeon_mon_recruit.c | 5 +- src/event_flag.c | 2 +- src/exclusive_pokemon.c | 91 +++------ src/friend_list_menu.c | 165 +++++++++++------ src/ground_script.c | 2 +- src/load_screen.c | 2 +- src/luminous_cave.c | 2 +- src/main_loops.c | 3 +- src/party_list_menu.c | 184 +++++++++++++------ src/play_time.c | 1 - src/pokemon_evolution.c | 2 +- src/position_util.c | 62 ++----- src/run_dungeon.c | 3 +- src/save.c | 5 +- src/string_format.c | 3 - src/wonder_mail_2.c | 2 +- sym_ewram.txt | 2 +- sym_ewram_init.txt | 2 +- 31 files changed, 380 insertions(+), 484 deletions(-) rename include/{code_8097670.h => adventure_info.h} (83%) create mode 100644 include/adventure_save.h rename src/{code_8097670.c => adventure_info.c} (85%) create mode 100644 src/adventure_save.c diff --git a/data/data_8109D10.s b/data/data_8109D10.s index e370b90af..8d7010a5f 100644 --- a/data/data_8109D10.s +++ b/data/data_8109D10.s @@ -1,9 +1,6 @@ .section .rodata -@ ??? -.string "pksdir0\0" -@ ??? -.string "pksdir0\0" + @ ??? .string "pksdir0\0" @ ???.c 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/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/ld_script.ld b/ld_script.ld index 08e8c7451..d77bf35bd 100755 --- a/ld_script.ld +++ b/ld_script.ld @@ -327,7 +327,8 @@ SECTIONS { src/code_80958E8.o(.text); src/code_80972F4.o(.text); src/code_8097504.o(.text); - src/code_8097670.o(.text); + src/adventure_info.o(.text); + src/adventure_save.o(.text); src/code_8097DD0.o(.text); src/code_8097F40.o(.text); src/exclusive_pokemon.o(.text); @@ -715,6 +716,8 @@ SECTIONS { src/code_80958E8.o(.rodata); src/code_80972F4.o(.rodata); src/code_8097504.o(.rodata); + src/adventure_info.o(.rodata); + src/adventure_save.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/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_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_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..b3f40593f 100644 --- a/src/event_flag.c +++ b/src/event_flag.c @@ -12,7 +12,7 @@ #include "other_random.h" #include "friend_area.h" #include "code_80972F4.h" -#include "code_8097670.h" +#include "adventure_info.h" #include "pokemon.h" #include "pokemon_3.h" #include "ground_place.h" diff --git a/src/exclusive_pokemon.c b/src/exclusive_pokemon.c index de8c43553..a1cba079e 100644 --- a/src/exclusive_pokemon.c +++ b/src/exclusive_pokemon.c @@ -36,32 +36,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 +58,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 +81,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 +111,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 +125,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); } } @@ -224,39 +200,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..8df36120f 100644 --- a/src/ground_script.c +++ b/src/ground_script.c @@ -12,7 +12,7 @@ #include "code_8094F88.h" #include "code_80958E8.h" #include "code_80972F4.h" -#include "code_8097670.h" +#include "adventure_info.h" #include "code_80A26CC.h" #include "debug.h" #include "dungeon_info.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/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_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/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..d1ed25da4 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,7 @@ #include "memory.h" #include "pokemon_3.h" #include "random.h" -#include "save.h" +#include "adventure_save.h" // size: 0x800 struct unk_struct 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/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/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"