diff --git a/data/data_8109D10.s b/data/data_8109D10.s index 8d7010a5f..1029e780c 100644 --- a/data/data_8109D10.s +++ b/data/data_8109D10.s @@ -1,11 +1,9 @@ .section .rodata -@ ??? + .string "pksdir0\0" -@ ???.c -.string "pksdir0\0" -@ 8109D30 + #include "dungeon/dungeon_data.inc" .align 2,0 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/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 d77bf35bd..5656463f3 100755 --- a/ld_script.ld +++ b/ld_script.ld @@ -325,12 +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/rescue_scenario.o(.text); + src/training_maze.o(.text); src/adventure_info.o(.text); src/adventure_save.o(.text); - src/code_8097DD0.o(.text); - src/code_8097F40.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); @@ -714,10 +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_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/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_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/event_flag.c b/src/event_flag.c index b3f40593f..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 "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 a1cba079e..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}; @@ -170,7 +162,6 @@ void WriteExclusivePokemon(DataSerializer *r0) neg_1 = -1; zero = 0; - WriteBits(r0, gUnknown_203B498, 1); for(index = 0; index < MONSTER_MAX; index++) { diff --git a/src/ground_script.c b/src/ground_script.c index 8df36120f..a3de80601 100644 --- a/src/ground_script.c +++ b/src/ground_script.c @@ -11,7 +11,7 @@ #include "code_8099360.h" #include "code_8094F88.h" #include "code_80958E8.h" -#include "code_80972F4.h" +#include "rescue_scenario.h" #include "adventure_info.h" #include "code_80A26CC.h" #include "debug.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/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/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/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/save.c b/src/save.c index d1ed25da4..81a732a6f 100644 --- a/src/save.c +++ b/src/save.c @@ -13,6 +13,8 @@ #include "pokemon_3.h" #include "random.h" #include "adventure_save.h" +#include "training_maze.h" +#include "rescue_scenario.h" // size: 0x800 struct unk_struct @@ -44,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/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_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"