From 79010bcfd6b1377ff124db30e7ea396913d5be13 Mon Sep 17 00:00:00 2001 From: Kermalis <29823718+Kermalis@users.noreply.github.com> Date: Fri, 1 Sep 2023 01:14:34 -0400 Subject: [PATCH] Clean code_8097670 and adventure_log --- include/adventure_log.h | 21 ++- include/adventure_log_menu.h | 8 ++ include/code_8094F88.h | 3 + include/code_8097670.h | 20 +++ include/luminous_cave.h | 3 + include/pokemon_3.h | 2 + include/save.h | 2 +- src/adventure_log.c | 263 ++++++++++++++++------------------- src/adventure_log_menu.c | 5 +- src/code_2.c | 24 ++-- src/code_8094F88.c | 3 +- src/code_8097670.c | 91 ++++++------ src/code_8097DD0.c | 20 +-- src/load_screen.c | 31 ++--- src/luminous_cave.c | 23 ++- src/main_menu.c | 2 +- src/pokemon_3.c | 2 +- src/save.c | 85 ++++++----- src/wonder_mail_2.c | 18 +-- 19 files changed, 311 insertions(+), 315 deletions(-) create mode 100644 include/adventure_log_menu.h diff --git a/include/adventure_log.h b/include/adventure_log.h index bdf31965e..33185525b 100644 --- a/include/adventure_log.h +++ b/include/adventure_log.h @@ -1,8 +1,21 @@ #ifndef GUARD_ADVENTURE_LOG_H #define GUARD_ADVENTURE_LOG_H -void CreateAdventureLogMenu(void); -void CleanAdventureLogMenu(void); -u32 UpdateAdventureLogMenu(void); +#include "input.h" +#include "text.h" -#endif +// size: 0xA0 +struct AdventureLog +{ + struct MenuInputStruct input; + u32 unk34; + struct UnkTextStruct2 *unk38; + struct UnkTextStruct2 unk3C[4]; + u8 unk9C[4]; +}; + +void CleanAdventureLogScreen(void); +bool8 CreateAdventureLogScreen(u32); +u32 HandleAdventureLogInput(u8); + +#endif // GUARD_ADVENTURE_LOG_H \ No newline at end of file diff --git a/include/adventure_log_menu.h b/include/adventure_log_menu.h new file mode 100644 index 000000000..2fe5afab6 --- /dev/null +++ b/include/adventure_log_menu.h @@ -0,0 +1,8 @@ +#ifndef GUARD_ADVENTURE_LOG_MENU_H +#define GUARD_ADVENTURE_LOG_MENU_H + +void CreateAdventureLogMenu(void); +void CleanAdventureLogMenu(void); +u32 UpdateAdventureLogMenu(void); + +#endif // GUARD_ADVENTURE_LOG_MENU_H \ No newline at end of file diff --git a/include/code_8094F88.h b/include/code_8094F88.h index beadbb71b..0089001c0 100644 --- a/include/code_8094F88.h +++ b/include/code_8094F88.h @@ -1,7 +1,10 @@ #ifndef GUARD_CODE_8094F88_H #define GUARD_CODE_8094F88_H +#include "code_8092334.h" +#include "dungeon_global_data.h" #include "item.h" +#include "pokemon.h" struct WonderMailSub { diff --git a/include/code_8097670.h b/include/code_8097670.h index 2d8d118cd..e173a814f 100644 --- a/include/code_8097670.h +++ b/include/code_8097670.h @@ -20,6 +20,26 @@ struct unkStruct_203B494 s32 unkC0; }; +extern struct unkStruct_203B494 *gUnknown_203B494; + +const u8 *GetAdventureLogLine(u8 index); +struct DungeonLocation *GetDungeonLocationInfo(void); +s32 GetNumAdventures(void); +void ResetNumAdventures(void); + +void sub_8097670(void); +struct unkStruct_203B494 *sub_8097680(void); +void sub_80976A8(void); void sub_80976F8(u8); +bool8 sub_8097710(u8); +void sub_8097790(void); +s32 sub_80977B8(void); +void sub_80977D0(void); +s32 sub_80977F8(void); +s16 sub_8097838(void); +void sub_8097848(void); +s16 sub_8097870(void); +s16 sub_8097880(void); +s16 sub_80978B8(void); #endif // GUARD_CODE_8097670_H \ No newline at end of file diff --git a/include/luminous_cave.h b/include/luminous_cave.h index 7e3a5a7ee..decaf8e2e 100644 --- a/include/luminous_cave.h +++ b/include/luminous_cave.h @@ -1,7 +1,10 @@ #ifndef GUARD_LUMINOUS_CAVE_H #define GUARD_LUMINOUS_CAVE_H +#include "file_system.h" +#include "item.h" #include "menu.h" +#include "pokemon_3.h" #include "text.h" struct unkStruct_203B2B0 diff --git a/include/pokemon_3.h b/include/pokemon_3.h index eb62866e4..3732cbe36 100644 --- a/include/pokemon_3.h +++ b/include/pokemon_3.h @@ -1,6 +1,8 @@ #ifndef GUARD_POKEMON_3_H #define GUARD_POKEMON_3_H +#include "pokemon.h" + struct EvolveStatus { u8 evoItem1; diff --git a/include/save.h b/include/save.h index c86e57ad4..d2899168f 100644 --- a/include/save.h +++ b/include/save.h @@ -55,7 +55,7 @@ struct UnkStruct_203B184 { /* 0x14 */ struct unkStruct_203B48C *unk14; /* 0x18 */ struct unkStruct_203B490 *mailInfo; /* 0x1C */ struct RescueTeamData *RescueTeamInfo; - /* 0x20 */ u32 unk20; + /* 0x20 */ struct unkStruct_203B494 *unk20; /* 0x24 */ struct ExclusivePokemonData *ExclusivePokemon; /* 0x28 */ bool8 *BoughtFriendAreas; /* 0x2C */ struct GameOptions *gameOptions; diff --git a/src/adventure_log.c b/src/adventure_log.c index 5c069f1a6..e6bde6776 100644 --- a/src/adventure_log.c +++ b/src/adventure_log.c @@ -1,25 +1,17 @@ #include "global.h" +#include "adventure_log.h" #include "code_80118A4.h" #include "code_80130A8.h" +#include "code_8097670.h" #include "constants/input.h" #include "memory.h" #include "menu_input.h" #include "text1.h" #include "text2.h" -struct AdventureLog -{ - // size: 0xA0 - struct MenuInputStruct input; - u32 unk34; - struct UnkTextStruct2 *unk38; - struct UnkTextStruct2 unk3C[4]; - u8 unk9C[4]; -}; +static EWRAM_DATA_2 struct AdventureLog *sAdventureLog = {0}; -EWRAM_DATA_2 struct AdventureLog *gAdventureLog = {0}; - -const struct UnkTextStruct2 gUnknown_80E1FF0 = { +static const struct UnkTextStruct2 sUnknown_80E1FF0 = { 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, @@ -27,7 +19,7 @@ const struct UnkTextStruct2 gUnknown_80E1FF0 = { 0x00, 0x00, NULL }; -const struct UnkTextStruct2 gUnknown_80E2008 = { +static const struct UnkTextStruct2 sUnknown_80E2008 = { 0x00, 0x00, 0x00, 0x00, 0x06, 0x02, 0x02, @@ -36,50 +28,41 @@ const struct UnkTextStruct2 gUnknown_80E2008 = { NULL }; -// Adventure Log Text -const u8 gAdventureLogHeaderText[] = "Adventure Log"; -const u8 gAdventureLogTextPlaceholder[] = "~95~95~95~95~95~95~95~95~95~95~95~95~95~95~95 "; // string of ??????? -const u8 fill_adven[] = "pksdir0"; +static const u8 sAdventureLogHeaderText[] = "Adventure Log"; +static const u8 sAdventureLogTextPlaceholder[] = "~95~95~95~95~95~95~95~95~95~95~95~95~95~95~95 "; // string of ??????? +static const u8 sFill1[] = "pksdir0"; -void sub_8032084(); -void DisplayAdventureLog(); -extern bool8 sub_8097710(u8); - -extern s16 sub_80978B8(); -extern s16 sub_8097880(); -extern s16 sub_8097838(); -extern s16 sub_8097870(); -extern s32 sub_80977B8(); -extern s32 sub_80977F8(); -const u8 *GetAdventureLogLine(u8 index); +// ??? extern u32 gUnknown_202DE30; -u32 CreateAdventureLogScreen(u32 param_1) -{ - gAdventureLog = MemoryAlloc(sizeof(struct AdventureLog),8); - gAdventureLog->unk34 = param_1; - gAdventureLog->unk38 = &gAdventureLog->unk3C[param_1]; - sub_8006518(gAdventureLog->unk3C); - gAdventureLog->unk3C[gAdventureLog->unk34] = gUnknown_80E2008; - gAdventureLog->unk38->unk14 = gAdventureLog->unk9C; +static void sub_8032084(); +static void DisplayAdventureLog(); - ResetUnusedInputStruct(); - sub_800641C(gAdventureLog->unk3C, TRUE, TRUE); - sub_8013818(&gAdventureLog->input,0x20,8,param_1); - sub_8032084(); - DisplayAdventureLog(); - return 1; +bool8 CreateAdventureLogScreen(u32 kind) +{ + sAdventureLog = MemoryAlloc(sizeof(struct AdventureLog), 8); + sAdventureLog->unk34 = kind; + sAdventureLog->unk38 = &sAdventureLog->unk3C[kind]; + sub_8006518(sAdventureLog->unk3C); + sAdventureLog->unk3C[sAdventureLog->unk34] = sUnknown_80E2008; + sAdventureLog->unk38->unk14 = sAdventureLog->unk9C; + + ResetUnusedInputStruct(); + sub_800641C(sAdventureLog->unk3C, TRUE, TRUE); + sub_8013818(&sAdventureLog->input, 0x20, 8, kind); + sub_8032084(); + DisplayAdventureLog(); + return TRUE; } u32 HandleAdventureLogInput(u8 param_1) { - if (param_1 == 0) { - sub_8013660(&gAdventureLog->input); - return 0; - } - else { - switch(GetKeyPress(&gAdventureLog->input)) - { + if (param_1 == 0) { + sub_8013660(&sAdventureLog->input); + return 0; + } + + switch (GetKeyPress(&sAdventureLog->input)) { case INPUT_B_BUTTON: PlayMenuSoundEffect(1); return 2; @@ -87,52 +70,48 @@ u32 HandleAdventureLogInput(u8 param_1) PlayMenuSoundEffect(0); return 3; default: - if (sub_8013938(&gAdventureLog->input)) { + if (sub_8013938(&sAdventureLog->input)) { sub_8032084(); DisplayAdventureLog(); return 1; } - else { - return 0; - } + return 0; } - } } void CleanAdventureLogScreen(void) { - if (gAdventureLog != NULL) { - gAdventureLog->unk3C[gAdventureLog->unk34] = gUnknown_80E1FF0; - ResetUnusedInputStruct(); - sub_800641C(gAdventureLog->unk3C, TRUE, TRUE); - MemoryFree(gAdventureLog); - gAdventureLog = 0; - } + if (sAdventureLog != NULL) { + sAdventureLog->unk3C[sAdventureLog->unk34] = sUnknown_80E1FF0; + ResetUnusedInputStruct(); + sub_800641C(sAdventureLog->unk3C, TRUE, TRUE); + MemoryFree(sAdventureLog); + sAdventureLog = NULL; + } } - #ifdef NONMATCHING -void sub_8032084(void) +static void sub_8032084(void) { - u32 sVar2; - - gAdventureLog->unk9C[0] = gAdventureLog->unk20; - gAdventureLog->unk9C[1]= gAdventureLog->unk0.unk1E; - gAdventureLog->unk9C[2]= 0xb; - gAdventureLog->unk9C[3]= 0; - // So a sign extend.. - sVar2 = sub_80095E4(gAdventureLog->unk0.unk1A,0xc) + 2 << 0x10; - // TODO needs asr r3, r0, r16 - // and lsr r0, r0, r16 - gAdventureLog->unk3C[gAdventureLog->unk34].unkE = sVar2; - // Good past here except regs for this store - gAdventureLog->unk3C[gAdventureLog->unk34].unk10 = sVar2 + 2; - ResetUnusedInputStruct(); - sub_800641C(gAdventureLog->unk3C, TRUE, TRUE); + u32 sVar2; + + sAdventureLog->unk9C[0] = sAdventureLog->unk20; + sAdventureLog->unk9C[1] = sAdventureLog->unk0.unk1E; + sAdventureLog->unk9C[2] = 11; + sAdventureLog->unk9C[3] = 0; + // So a sign extend.. + sVar2 = sub_80095E4(sAdventureLog->unk0.unk1A, 12) + 2 << 0x10; + // TODO needs asr r3, r0, r16 + // and lsr r0, r0, r16 + sAdventureLog->unk3C[sAdventureLog->unk34].unkE = sVar2; + // Good past here except regs for this store + sAdventureLog->unk3C[sAdventureLog->unk34].unk10 = sVar2 + 2; + ResetUnusedInputStruct(); + sub_800641C(sAdventureLog->unk3C, TRUE, TRUE); } #else NAKED -void sub_8032084(void) +static void sub_8032084(void) { asm_unified("\tpush {r4,lr}\n" "\tldr r4, _080320F4\n" @@ -187,74 +166,74 @@ void sub_8032084(void) "\tpop {r0}\n" "\tbx r0\n" "\t.align 2, 0\n" -"_080320F4: .4byte gAdventureLog"); +"_080320F4: .4byte sAdventureLog"); } #endif -void DisplayAdventureLog(void) +static void DisplayAdventureLog(void) { - s32 counter; - s32 r4; // r4 - s32 r6; // r6 - u8 temp; - s32 v1, v2, v3, v4, v5, v6; - - sub_8008C54(gAdventureLog->unk34); - sub_80073B8(gAdventureLog->unk34); - r4 = gAdventureLog->input.unk1E * 8; - r6 = r4; - r6 += 10; - // Draw Header - xxx_call_draw_string(r6, 0, gAdventureLogHeaderText, gAdventureLog->unk34, 0); - r4 += 4; - r6 = r4 + gAdventureLog->unk9C[2] * 8; - // Draw Page # - sub_8012BC4(r6, 0, gAdventureLog->input.unk1E + 1, 1, 7, gAdventureLog->unk34); + s32 counter; + s32 r4; // r4 + s32 r6; // r6 + u8 temp; + s32 v1, v2, v3, v4, v5, v6; - for(counter = 0; counter < gAdventureLog->input.unk1A; counter++) - { - temp = gAdventureLog->input.unk1E * gAdventureLog->input.unk1C + counter; - if(sub_8097710(temp)){ - switch(temp) { - case 0xc: - v1 = sub_80978B8(); - gUnknown_202DE30 = (s16)v1; - xxx_format_and_draw(8, sub_8013800(&gAdventureLog->input, counter), GetAdventureLogLine(temp), gAdventureLog->unk34, 0); - break; - case 7: - v2 = sub_8097880(); - gUnknown_202DE30 = (s16)v2; - xxx_format_and_draw(8, sub_8013800(&gAdventureLog->input, counter), GetAdventureLogLine(temp), gAdventureLog->unk34, 0); - break; - case 0xb: - v3 = sub_8097838(); - gUnknown_202DE30 = (s16)v3; - xxx_format_and_draw(8, sub_8013800(&gAdventureLog->input, counter), GetAdventureLogLine(temp), gAdventureLog->unk34, 0); - break; - case 8: - v4 = sub_80977B8(); - gUnknown_202DE30 = v4; - xxx_format_and_draw(8, sub_8013800(&gAdventureLog->input, counter), GetAdventureLogLine(temp), gAdventureLog->unk34, 0); - break; - case 9: - v5 = sub_80977F8(); - gUnknown_202DE30 = v5; - xxx_format_and_draw(8, sub_8013800(&gAdventureLog->input, counter), GetAdventureLogLine(temp), gAdventureLog->unk34, 0); - break; - case 10: - v6 = sub_8097870(); - gUnknown_202DE30 = (s16)v6; - // fallthrough - default: - xxx_format_and_draw(8, sub_8013800(&gAdventureLog->input, counter), GetAdventureLogLine(temp), gAdventureLog->unk34, 0); - break; + sub_8008C54(sAdventureLog->unk34); + sub_80073B8(sAdventureLog->unk34); + r4 = sAdventureLog->input.unk1E * 8; + r6 = r4; + r6 += 10; + // Draw Header + xxx_call_draw_string(r6, 0, sAdventureLogHeaderText, sAdventureLog->unk34, 0); + r4 += 4; + r6 = r4 + sAdventureLog->unk9C[2] * 8; + // Draw Page # + sub_8012BC4(r6, 0, sAdventureLog->input.unk1E + 1, 1, 7, sAdventureLog->unk34); + + for (counter = 0; counter < sAdventureLog->input.unk1A; counter++) { + temp = sAdventureLog->input.unk1E * sAdventureLog->input.unk1C + counter; + + if (sub_8097710(temp)) { + switch (temp) { + case 12: + v1 = sub_80978B8(); + gUnknown_202DE30 = (s16)v1; + xxx_format_and_draw(8, sub_8013800(&sAdventureLog->input, counter), GetAdventureLogLine(temp), sAdventureLog->unk34, 0); + break; + case 7: + v2 = sub_8097880(); + gUnknown_202DE30 = (s16)v2; + xxx_format_and_draw(8, sub_8013800(&sAdventureLog->input, counter), GetAdventureLogLine(temp), sAdventureLog->unk34, 0); + break; + case 11: + v3 = sub_8097838(); + gUnknown_202DE30 = (s16)v3; + xxx_format_and_draw(8, sub_8013800(&sAdventureLog->input, counter), GetAdventureLogLine(temp), sAdventureLog->unk34, 0); + break; + case 8: + v4 = sub_80977B8(); + gUnknown_202DE30 = v4; + xxx_format_and_draw(8, sub_8013800(&sAdventureLog->input, counter), GetAdventureLogLine(temp), sAdventureLog->unk34, 0); + break; + case 9: + v5 = sub_80977F8(); + gUnknown_202DE30 = v5; + xxx_format_and_draw(8, sub_8013800(&sAdventureLog->input, counter), GetAdventureLogLine(temp), sAdventureLog->unk34, 0); + break; + case 10: + v6 = sub_8097870(); + gUnknown_202DE30 = (s16)v6; + // fallthrough + default: + xxx_format_and_draw(8, sub_8013800(&sAdventureLog->input, counter), GetAdventureLogLine(temp), sAdventureLog->unk34, 0); + break; + } + } + else { + // Draw the ?????????? across the row + xxx_call_draw_string(8, sub_8013800(&sAdventureLog->input, counter), sAdventureLogTextPlaceholder, sAdventureLog->unk34, 0); } } - else - { - // Draw the ?????????? across the row - xxx_call_draw_string(8, sub_8013800(&gAdventureLog->input, counter), gAdventureLogTextPlaceholder, gAdventureLog->unk34, 0); - } - } - sub_80073E0(gAdventureLog->unk34); + + sub_80073E0(sAdventureLog->unk34); } diff --git a/src/adventure_log_menu.c b/src/adventure_log_menu.c index 949d39833..69684af72 100644 --- a/src/adventure_log_menu.c +++ b/src/adventure_log_menu.c @@ -1,13 +1,10 @@ #include "global.h" #include "adventure_log.h" +#include "adventure_log_menu.h" #include "input.h" #include "main_menu.h" #include "text1.h" -extern void CreateAdventureLogScreen(u32); -extern u32 HandleAdventureLogInput(u32); -extern void CleanAdventureLogScreen(void); - void CreateAdventureLogMenu(void) { CreateAdventureLogScreen(0); diff --git a/src/code_2.c b/src/code_2.c index 5624990fa..22e928c8d 100644 --- a/src/code_2.c +++ b/src/code_2.c @@ -1,32 +1,32 @@ #include "global.h" #include "bg_control.h" +#include "bg_palette_buffer.h" +#include "code_800558C.h" +#include "code_80118A4.h" +#include "code_8094F88.h" +#include "code_8097670.h" #include "constants/bg_music.h" +#include "cpu.h" #include "debug.h" +#include "exclusive_pokemon.h" #include "file_system.h" #include "friend_area.h" +#include "game_options.h" #include "input.h" -#include "memory.h" #include "main_menu.h" +#include "memory.h" #include "moves.h" #include "music.h" #include "play_time.h" -#include "save.h" -#include "game_options.h" -#include "text1.h" -#include "text2.h" -#include "exclusive_pokemon.h" #include "pokemon.h" #include "rescue_team_info.h" -#include "cpu.h" -#include "code_8094F88.h" +#include "save.h" #include "sprite.h" -#include "code_80118A4.h" -#include "bg_palette_buffer.h" -#include "code_800558C.h" +#include "text1.h" +#include "text2.h" extern void NDS_LoadOverlay_GroundMain(void); extern void sub_8014144(void); -extern void sub_8097670(void); extern void LoadGameOptions(void); extern void SetWindowBGColor(void); extern void LoadItemParameters(void); diff --git a/src/code_8094F88.c b/src/code_8094F88.c index e4678aafe..7bd7d4e1a 100644 --- a/src/code_8094F88.c +++ b/src/code_8094F88.c @@ -1,7 +1,6 @@ #include "global.h" -#include "constants/wonder_mail.h" -#include "pokemon.h" #include "code_8094F88.h" +#include "constants/wonder_mail.h" #include "memory.h" #include "dungeon.h" #include "random.h" diff --git a/src/code_8097670.c b/src/code_8097670.c index e2976bd50..b16f889d8 100644 --- a/src/code_8097670.c +++ b/src/code_8097670.c @@ -3,19 +3,21 @@ #include "pokemon.h" #include "pokemon_3.h" -EWRAM_DATA_2 struct unkStruct_203B494 *gUnknown_203B494 = {0}; -EWRAM_DATA struct unkStruct_203B494 gUnknown_2039778 = {0}; +static EWRAM_DATA struct unkStruct_203B494 sUnknown_2039778 = {0}; +EWRAM_DATA_2 struct unkStruct_203B494 *gUnknown_203B494 = {0}; + +// data_810AE24.s extern const u8 *gAdventureLogText[]; void sub_8097670(void) { - gUnknown_203B494 = &gUnknown_2039778; + gUnknown_203B494 = &sUnknown_2039778; } struct unkStruct_203B494 *sub_8097680(void) { - return &gUnknown_2039778; + return &sUnknown_2039778; } void SetDungeonLocationInfo(struct DungeonLocation *r0) @@ -41,15 +43,11 @@ void sub_80976A8(void) gUnknown_203B494->unk8 = 0; gUnknown_203B494->unkC = 0; - for(index = 0; index < 0xE; index++) - { + for (index = 0; index < 14; index++) gUnknown_203B494->unk1C[index] = 0; - } - for(index = 0; index < 0xD; index++) - { + for (index = 0; index < 13; index++) gUnknown_203B494->unk8C[index] = 0; - } } void sub_80976F8(u8 r0) @@ -59,10 +57,9 @@ void sub_80976F8(u8 r0) bool8 sub_8097710(u8 r0) { - if(gUnknown_203B494->unk0 & (1 << r0)) + if (gUnknown_203B494->unk0 & (1 << r0)) return TRUE; - else - return FALSE; + return FALSE; } const u8 *GetAdventureLogLine(u8 index) @@ -78,7 +75,7 @@ void ResetNumAdventures(void) void IncrementNumAdventures(void) { gUnknown_203B494->numAdventures++; - if(gUnknown_203B494->numAdventures > 99999) + if (gUnknown_203B494->numAdventures > 99999) gUnknown_203B494->numAdventures = 99999; } @@ -87,7 +84,7 @@ s32 GetNumAdventures(void) return gUnknown_203B494->numAdventures; } -void SetNumAdventures(s32 numAdventures) +UNUSED static void SetNumAdventures(s32 numAdventures) { gUnknown_203B494->numAdventures = numAdventures; } @@ -95,8 +92,9 @@ void SetNumAdventures(s32 numAdventures) void sub_8097790(void) { gUnknown_203B494->unk8++; - if(gUnknown_203B494->unk8 > 99999) + if (gUnknown_203B494->unk8 > 99999) gUnknown_203B494->unk8 = 99999; + sub_80976F8(8); } @@ -105,7 +103,7 @@ s32 sub_80977B8(void) return gUnknown_203B494->unk8; } -void sub_80977C4(s32 r0) +UNUSED static void sub_80977C4(s32 r0) { gUnknown_203B494->unk8 = r0; } @@ -113,8 +111,9 @@ void sub_80977C4(s32 r0) void sub_80977D0(void) { gUnknown_203B494->unkC++; - if(gUnknown_203B494->unkC > 99999) + if (gUnknown_203B494->unkC > 99999) gUnknown_203B494->unkC = 99999; + sub_80976F8(9); } @@ -123,15 +122,16 @@ s32 sub_80977F8(void) return gUnknown_203B494->unkC; } -void sub_8097804(s32 r0) +UNUSED static void sub_8097804(s32 r0) { gUnknown_203B494->unkC = r0; } void sub_8097810(void) { - if(gUnknown_203B494->unk14 < 9999) + if (gUnknown_203B494->unk14 < 9999) gUnknown_203B494->unk14++; + sub_80976F8(11); } @@ -142,8 +142,9 @@ s16 sub_8097838(void) void sub_8097848(void) { - if(gUnknown_203B494->unk16 < 9999) + if (gUnknown_203B494->unk16 < 9999) gUnknown_203B494->unk16++; + sub_80976F8(10); } @@ -159,8 +160,9 @@ s16 sub_8097880(void) void sub_8097890(void) { - if(gUnknown_203B494->unkC0 < 99999) + if (gUnknown_203B494->unkC0 < 99999) gUnknown_203B494->unkC0++; + sub_80976F8(12); } @@ -171,33 +173,32 @@ s16 sub_80978B8(void) void sub_80978C8(s16 pokeIndex) { - s32 iVar2; - struct unkStruct_203B494 *preload; - s32 baseSpecies; + s32 iVar2; + struct unkStruct_203B494 *preload; + s32 baseSpecies; - baseSpecies = GetBaseSpeciesNoUnown(pokeIndex); - preload = gUnknown_203B494; - iVar2 = baseSpecies; - if (baseSpecies < 0) { - iVar2 = baseSpecies + 0x1f; - } - preload->unk54[iVar2 >> 5] |= 1 << (baseSpecies + (iVar2 >> 5) * -0x20); + baseSpecies = GetBaseSpeciesNoUnown(pokeIndex); + preload = gUnknown_203B494; + iVar2 = baseSpecies; + if (baseSpecies < 0) + iVar2 = baseSpecies + 0x1F; // 0x1F == MONSTER_NIDOQUEEN + + preload->unk54[iVar2 >> 5] |= 1 << (baseSpecies + (iVar2 >> 5) * -0x20); } bool8 sub_8097900(s16 pokeIndex) { - s32 iVar2; - struct unkStruct_203B494 *preload; - s32 baseSpecies; + s32 iVar2; + struct unkStruct_203B494 *preload; + s32 baseSpecies; - baseSpecies = GetBaseSpeciesNoUnown(pokeIndex); - preload = gUnknown_203B494; - iVar2 = baseSpecies; - if (baseSpecies < 0) { - iVar2 = baseSpecies + 0x1f; - } - if(preload->unk1C[iVar2 >> 5] & (1 << (baseSpecies + (iVar2 >> 5) * -0x20))) - return TRUE; - else + baseSpecies = GetBaseSpeciesNoUnown(pokeIndex); + preload = gUnknown_203B494; + iVar2 = baseSpecies; + if (baseSpecies < 0) + iVar2 = baseSpecies + 0x1F; // 0x1F == MONSTER_NIDOQUEEN + + if (preload->unk1C[iVar2 >> 5] & (1 << (baseSpecies + (iVar2 >> 5) * -0x20))) + return TRUE; return FALSE; -} +} \ No newline at end of file diff --git a/src/code_8097DD0.c b/src/code_8097DD0.c index f8336901c..678437c27 100644 --- a/src/code_8097DD0.c +++ b/src/code_8097DD0.c @@ -1,27 +1,9 @@ #include "global.h" #include "code_8092334.h" +#include "code_8097670.h" #include "pokemon.h" #include "exclusive_pokemon.h" -struct unkStruct_203B494 -{ - // size: 0xC8? - u32 unk0; // 32 bit bitfield, I think - s32 numAdventures; - s32 unk8; - s32 unkC; - struct DungeonLocation dungeonLocation; - s16 unk14; - s16 unk16; - s16 unk18; - u32 unk1C[0xE]; - u32 unk54[0xE]; - u32 unk8C[0xD]; - s32 unkC0; -}; - -extern struct unkStruct_203B494 *gUnknown_203B494; - extern void SaveDungeonLocation(struct unkStruct_8094924*, struct DungeonLocation*); extern void RestoreDungeonLocation(struct unkStruct_8094924*, struct DungeonLocation*); void ReadGameOptions(struct unkStruct_8094924 *param_1); diff --git a/src/load_screen.c b/src/load_screen.c index 22212a018..1932bef8d 100644 --- a/src/load_screen.c +++ b/src/load_screen.c @@ -1,20 +1,21 @@ #include "global.h" -#include "constants/wonder_mail.h" -#include "input.h" -#include "main_menu.h" -#include "play_time.h" -#include "file_system.h" -#include "memory.h" -#include "menu.h" -#include "text1.h" -#include "text2.h" -#include "text_util.h" -#include "pokemon.h" -#include "save.h" #include "code_800D090.h" #include "code_8094F88.h" -#include "menu_input.h" +#include "code_8097670.h" +#include "constants/wonder_mail.h" #include "event_flag.h" +#include "file_system.h" +#include "input.h" +#include "main_menu.h" +#include "memory.h" +#include "menu.h" +#include "menu_input.h" +#include "play_time.h" +#include "pokemon.h" +#include "save.h" +#include "text_util.h" +#include "text1.h" +#include "text2.h" extern const struct FileArchive gTitleMenuFileArchive; @@ -46,9 +47,7 @@ void sub_80397B4(void); extern void sub_80920D8(u8 *); extern struct PokemonStruct *GetPlayerPokemonStruct(void); extern u8 *sub_8098FB4(); -extern u8 *GetDungeonLocationInfo(void); -extern u32 GetNumAdventures(void); -extern void PrintDungeonLocationtoBuffer(u8 *, u8 *); +extern void PrintDungeonLocationtoBuffer(u8 *, struct DungeonLocation *); extern u32 sub_8001658(u32, u32); extern void xxx_format_string(u8 *, u8 *, u8 *, u32); diff --git a/src/luminous_cave.c b/src/luminous_cave.c index e1210eee7..b6f80ad96 100644 --- a/src/luminous_cave.c +++ b/src/luminous_cave.c @@ -1,24 +1,22 @@ #include "global.h" +#include "code_80118A4.h" +#include "code_8012A18_1.h" +#include "code_80130A8.h" +#include "code_801B3C0.h" +#include "code_8097670.h" #include "constants/bg_music.h" #include "constants/colors.h" #include "constants/evolution_status.h" #include "input.h" -#include "item.h" +#include "kecleon_bros.h" +#include "luminous_cave.h" #include "memory.h" -#include "pokemon.h" -#include "pokemon_3.h" +#include "menu_input.h" #include "random.h" +#include "team_inventory.h" +#include "text_util.h" #include "text1.h" #include "text2.h" -#include "text_util.h" -#include "team_inventory.h" -#include "menu_input.h" -#include "kecleon_bros.h" -#include "code_80130A8.h" -#include "code_8012A18_1.h" -#include "code_801B3C0.h" -#include "code_80118A4.h" -#include "luminous_cave.h" EWRAM_DATA_2 struct unkStruct_203B2B0 *gUnknown_203B2B0 = {0}; extern struct UnkTextStruct2 gUnknown_80DCA00; @@ -157,7 +155,6 @@ extern void LuminousCave_AdvancetoFallbackState(void); extern void sub_8024804(void); extern void UpdateLuminousCaveDialogue(void); -void sub_80977D0(void); void sub_8024CFC(void); void sub_8025254(void); void sub_8024D48(void); diff --git a/src/main_menu.c b/src/main_menu.c index 12e19420b..9180877e3 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -2,7 +2,7 @@ #include "text1.h" #include "text2.h" #include "menu_input.h" -#include "adventure_log.h" +#include "adventure_log_menu.h" #include "debug_menu1.h" #include "ds_menus.h" #include "pokemon.h" diff --git a/src/pokemon_3.c b/src/pokemon_3.c index a4f7e54fb..995768fc7 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -11,6 +11,7 @@ #include "text_util.h" #include "friend_area.h" #include "luminous_cave.h" +#include "code_8097670.h" extern u8 *gIQSkillNames[]; extern u8 *gIQSkillDescriptions[]; @@ -61,7 +62,6 @@ extern void sub_808F428(struct unkStruct_8094924*, struct unkStruct_808E6F4*); s16 GetPokemonEvolveConditions(s16 index, struct unkEvolve *r1); u32 sub_808F798(struct PokemonStruct *, s16); -void sub_8097848(void); bool8 sub_808E668(s16 species, s16* a2, s16* a3) { diff --git a/src/save.c b/src/save.c index c90b5ea55..d9deb5b38 100644 --- a/src/save.c +++ b/src/save.c @@ -1,30 +1,31 @@ #include "global.h" +#include "code_80118A4.h" +#include "code_80130A8.h" +#include "code_8097670.h" #include "event_flag.h" +#include "exclusive_pokemon.h" #include "flash.h" #include "friend_area.h" +#include "game_options.h" #include "memory.h" #include "pokemon.h" #include "random.h" #include "save.h" #include "team_inventory.h" -#include "exclusive_pokemon.h" -#include "game_options.h" -#include "code_80130A8.h" -#include "code_80118A4.h" EWRAM_DATA_2 u32 gUnknown_203B17C = {0}; EWRAM_DATA_2 char *gUnknown_203B180 = {0}; EWRAM_DATA_2 struct UnkStruct_203B184 *gUnknown_203B184 = {0}; extern struct GameOptions *gGameOptionsRef; +// size: 0x800 struct unk_struct { - // size: 0x800 u32 unk0; - u8 gameInternalName[0x10]; // has "POKE_DUNGEON__05 + u8 gameInternalName[16]; // has "POKE_DUNGEON__05 u32 checksum; u32 unk18; - u32 dungeonLocation; + struct DungeonLocation dungeonLocation; u32 unk20; u32 padding[503]; }; @@ -77,7 +78,6 @@ EWRAM_DATA_2 struct QuickSaveWrite *gQuickSaveWrite = {0}; extern s32 gUnknown_202DE28; extern u32 *gUnknown_203B488; -extern u32 gUnknown_203B494; ALIGNED(4) const char sGameInternalVersion[] = _("POKE_DUNGEON__05"); @@ -153,7 +153,6 @@ extern u32 sub_80954CC(void* a, s32 b); extern u32 sub_8095624(u8 *, u32); extern u32 RestoreMailInfo(void* a, s32 b); extern u32 SaveMailInfo(u8 *, u32); -extern void sub_80976A8(); extern u32 sub_8097D60(u8 *, u32); extern u32 sub_8097D98(void* a, s32 b); extern void sub_80993E4(); @@ -162,10 +161,7 @@ extern void sub_80958E4(u32 *a, u32 b); extern struct unkStruct_203B490 *GetMailInfo(void); extern void InitializeMailJobsNews(void); extern void sub_80972F4(void); -extern u32 sub_8097680(void); -extern u32 *GetDungeonLocationInfo(void); extern void sub_80974E8(void); -extern void ResetNumAdventures(void); extern void sub_80993D8(void); u32 sub_8011C1C(void) @@ -592,46 +588,43 @@ void InitializePlayerData(void) } -// Unused -void nullsub_200(u32 r0) +UNUSED static void nullsub_200(u32 r0) { } -// Unused -void sub_8012334(struct UnkStruct_203B184 *r0) +UNUSED static void sub_8012334(struct UnkStruct_203B184 *r0) { gUnknown_203B184 = r0; - if(r0 != NULL) - { - gTeamInventoryRef = r0->MoneyItems; - gRecruitedPokemonRef = r0->recruitedPokemon; - gUnknown_203B480 = r0->unk8; - gUnknown_203B484 = r0->unkC; - gUnknown_203B488 = r0->unk10; - gUnknown_203B48C = r0->unk14; - gUnknown_203B490 = r0->mailInfo; - gRescueTeamInfoRef = r0->RescueTeamInfo; - gUnknown_203B494 = r0->unk20; - gUnknown_203B498 = r0->ExclusivePokemon; - gFriendAreas = r0->BoughtFriendAreas; - gGameOptionsRef = r0->gameOptions; - gPlayTimeRef = r0->playTime; - return; + if (r0 != NULL) { + gTeamInventoryRef = r0->MoneyItems; + gRecruitedPokemonRef = r0->recruitedPokemon; + gUnknown_203B480 = r0->unk8; + gUnknown_203B484 = r0->unkC; + gUnknown_203B488 = r0->unk10; + gUnknown_203B48C = r0->unk14; + gUnknown_203B490 = r0->mailInfo; + gRescueTeamInfoRef = r0->RescueTeamInfo; + gUnknown_203B494 = r0->unk20; + gUnknown_203B498 = r0->ExclusivePokemon; + gFriendAreas = r0->BoughtFriendAreas; + gGameOptionsRef = r0->gameOptions; + gPlayTimeRef = r0->playTime; + } + else { + gTeamInventoryRef = GetMoneyItemsInfo(); + gRecruitedPokemonRef = GetRecruitedPokemon(); + gUnknown_203B480 = sub_80950F8(); + gUnknown_203B484 = sub_8095100(); + gUnknown_203B488 = sub_8095108(); + gUnknown_203B48C = sub_8095110(); + gUnknown_203B490 = GetMailInfo(); + gRescueTeamInfoRef = GetRescueTeamInfo(); + gUnknown_203B494 = sub_8097680(); + gUnknown_203B498 = GetExclusivePokemon(); + gFriendAreas = GetBoughtFriendAreas(); + gGameOptionsRef = GetGameOptions(); + gPlayTimeRef = GetPlayTime(); } - gTeamInventoryRef = GetMoneyItemsInfo(); - gRecruitedPokemonRef = GetRecruitedPokemon(); - gUnknown_203B480 = sub_80950F8(); - gUnknown_203B484 = sub_8095100(); - gUnknown_203B488 = sub_8095108(); - gUnknown_203B48C = sub_8095110(); - gUnknown_203B490 = GetMailInfo(); - gRescueTeamInfoRef = GetRescueTeamInfo(); - gUnknown_203B494 = sub_8097680(); - gUnknown_203B498 = GetExclusivePokemon(); - gFriendAreas = GetBoughtFriendAreas(); - gGameOptionsRef = GetGameOptions(); - gPlayTimeRef = GetPlayTime(); - } void PrepareSavePakRead(void) diff --git a/src/wonder_mail_2.c b/src/wonder_mail_2.c index c37dc425e..a285aad97 100644 --- a/src/wonder_mail_2.c +++ b/src/wonder_mail_2.c @@ -1,18 +1,19 @@ #include "global.h" +#include "code_800D090.h" +#include "code_80130A8.h" +#include "code_8094F88.h" +#include "code_8097670.h" #include "constants/item.h" #include "constants/wonder_mail.h" +#include "event_flag.h" +#include "game_options.h" +#include "memory.h" +#include "menu_input.h" #include "pokemon.h" #include "pokemon_mail.h" -#include "memory.h" -#include "text1.h" #include "save.h" -#include "game_options.h" +#include "text1.h" #include "wonder_mail.h" -#include "code_800D090.h" -#include "code_8094F88.h" -#include "menu_input.h" -#include "code_80130A8.h" -#include "event_flag.h" struct unkStruct_203B2C8 { @@ -36,7 +37,6 @@ struct unkStruct_203B2C8 extern struct unkStruct_203B2C8 *gUnknown_203B2C8; extern void sub_80920D8(u8 *buffer); -extern void sub_8097790(void); extern char gUnknown_202E5D8[0x50]; extern char gAvailablePokemonNames[0x50]; extern u32 sub_802F298(void);