From 36ad3b4adbd37ac0b567f6abef52ff9cd17e91f3 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 8 Jun 2025 14:46:06 +0200 Subject: [PATCH] start dumping dungeon data --- data/data_81076E4.s | 42 ----- include/dungeon.h | 3 +- include/pokemon_evolution.h | 12 +- include/pokemon_summary_window.h | 2 +- include/structs/str_dungeon.h | 2 +- ld_script.ld | 1 + src/dungeon.c | 257 ++++++++++++++++++++++++++++--- src/dungeon_misc.c | 6 +- src/dungeon_name_banner.c | 2 +- src/dungeon_spawns.c | 8 +- src/dungeon_tilemap.c | 14 +- src/luminous_cave.c | 2 +- src/pokemon_evolution.c | 16 +- src/pokemon_summary_window.c | 6 +- src/unk_dungeon_load_maybe.c | 2 +- 15 files changed, 277 insertions(+), 98 deletions(-) diff --git a/data/data_81076E4.s b/data/data_81076E4.s index 8a7fc209e..0338e1458 100644 --- a/data/data_81076E4.s +++ b/data/data_81076E4.s @@ -4,49 +4,7 @@ -@ dungeon -.string "pksdir0\0" -.align 2,0 -.global gDungeonFloorCount -gDungeonFloorCount: @ 81077A8 -@ replacing .incbin "baserom.gba", 0x1077A8, 0x40 -.byte 0x04, 0x06, 0x0a, 0x0e, 0x0a, 0x0b, 0x04, 0x0d, 0x0f, 0x0d, 0x04, 0x0a, 0x06, 0x10, 0x06, 0x18 -.byte 0x04, 0x1a, 0x0a, 0x29, 0x64, 0x15, 0x05, 0x64, 0x15, 0x0c, 0x64, 0x64, 0x1a, 0x1a, 0x0d, 0x15 -.byte 0x33, 0x1f, 0x1f, 0x1f, 0x15, 0x1f, 0x10, 0x0d, 0x14, 0x1f, 0x0b, 0x10, 0x15, 0x15, 0x1f, 0x05 -.byte 0x05, 0x0b, 0x03, 0x33, 0x46, 0x10, 0x1f, 0x14, 0x14, 0x0c, 0x64, 0x4c, 0x29, 0x64, 0x64, 0x02 - -.global gUnknown_81077E8 -gUnknown_81077E8: @ 81077E8 -@ replacing .incbin "baserom.gba", 0x1077E8, 0x40 -.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - -.global gUnknown_8107828 -gUnknown_8107828: @ 8107828 -@ replacing .incbin "baserom.gba", 0x107828, 0x85C -.byte 0x02, 0x09, 0x00, 0x00, 0x03, 0x0d, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x0a, 0x03, 0x00, 0x00 -.byte 0x0c, 0x05, 0x00, 0x00, 0x0e, 0x05, 0x00, 0x00, 0x10, 0x02, 0x00, 0x00, 0x10, 0x03, 0x00, 0x00 -.byte 0x12, 0x09, 0x00, 0x00, 0x13, 0x28, 0x00, 0x00, 0x14, 0x63, 0x00, 0x00, 0x15, 0x14, 0x00, 0x00 -.byte 0x17, 0x3b, 0x00, 0x00, 0x17, 0x63, 0x00, 0x00, 0x1a, 0x14, 0x00, 0x00, 0x1a, 0x32, 0x00, 0x00 -.byte 0x1a, 0x63, 0x00, 0x00, 0x1b, 0x0f, 0x00, 0x00, 0x1b, 0x19, 0x00, 0x00, 0x1b, 0x23, 0x00, 0x00 -.byte 0x1b, 0x2d, 0x00, 0x00, 0x1b, 0x3c, 0x00, 0x00, 0x1b, 0x46, 0x00, 0x00, 0x1b, 0x50, 0x00, 0x00 -.byte 0x1d, 0x19, 0x00, 0x00, 0x21, 0x14, 0x00, 0x00, 0x21, 0x1e, 0x00, 0x00, 0x22, 0x1e, 0x00, 0x00 -.byte 0x23, 0x14, 0x00, 0x00, 0x23, 0x1e, 0x00, 0x00, 0x24, 0x0a, 0x00, 0x00, 0x24, 0x0f, 0x00, 0x00 -.byte 0x24, 0x14, 0x00, 0x00, 0x25, 0x1e, 0x00, 0x00, 0x29, 0x0f, 0x00, 0x00, 0x29, 0x19, 0x00, 0x00 -.byte 0x2a, 0x0a, 0x00, 0x00, 0x31, 0x01, 0x00, 0x00, 0x31, 0x02, 0x00, 0x00, 0x31, 0x03, 0x00, 0x00 -.byte 0x31, 0x04, 0x00, 0x00, 0x31, 0x05, 0x00, 0x00, 0x31, 0x06, 0x00, 0x00, 0x31, 0x07, 0x00, 0x00 -.byte 0x31, 0x08, 0x00, 0x00, 0x31, 0x09, 0x00, 0x00, 0x31, 0x0a, 0x00, 0x00, 0x34, 0x03, 0x00, 0x00 -.byte 0x34, 0x06, 0x00, 0x00, 0x34, 0x09, 0x00, 0x00, 0x34, 0x0c, 0x00, 0x00, 0x34, 0x0f, 0x00, 0x00 -.byte 0x34, 0x12, 0x00, 0x00, 0x34, 0x15, 0x00, 0x00, 0x34, 0x18, 0x00, 0x00, 0x34, 0x1b, 0x00, 0x00 -.byte 0x34, 0x1e, 0x00, 0x00, 0x34, 0x21, 0x00, 0x00, 0x34, 0x24, 0x00, 0x00, 0x34, 0x27, 0x00, 0x00 -.byte 0x34, 0x2a, 0x00, 0x00, 0x34, 0x2d, 0x00, 0x00, 0x34, 0x30, 0x00, 0x00, 0x34, 0x33, 0x00, 0x00 -.byte 0x34, 0x36, 0x00, 0x00, 0x34, 0x39, 0x00, 0x00, 0x34, 0x3c, 0x00, 0x00, 0x34, 0x3f, 0x00, 0x00 -.byte 0x34, 0x42, 0x00, 0x00, 0x34, 0x45, 0x00, 0x00, 0x35, 0x0f, 0x00, 0x00, 0x3b, 0x32, 0x00, 0x00 -.byte 0x3b, 0x48, 0x00, 0x00, 0x3c, 0x1e, 0x00, 0x00, 0x3c, 0x28, 0x00, 0x00, 0x3e, 0x63, 0x00, 0x00 -.byte 0x3f, 0xff, 0x00, 0x00 .global gUnknown_810795C gUnknown_810795C: @ 810795C diff --git a/include/dungeon.h b/include/dungeon.h index e57af204a..75b951e1c 100644 --- a/include/dungeon.h +++ b/include/dungeon.h @@ -4,6 +4,7 @@ #include "structs/str_dungeon.h" s32 GetDungeonFloorCount(u8 dungeon); +s32 GetDungeonStartingFloor(u8 dungeon); const u8 *GetDungeonName1(u8 dungeon); bool8 IsStairDirectionUp(u8 dungeon); u32 GetMaxItemsAllowed(u8 dungeon); @@ -13,7 +14,7 @@ s16 GetRandomMovementChance(u8 dungeon); void PrintYellowDungeonNametoBuffer(u8 *buffer, DungeonLocation *dungeonLocation); void PrintDungeonLocationtoBuffer(u8 *buffer, DungeonLocation *dungeonLocation); -void sub_80901D8(DungeonLocation *param_1, DungeonLocation *param_2); +void GeneralizeMazeDungeonLoc(DungeonLocation *dst, const DungeonLocation *src); u32 sub_809034C(u8 dungeonIndex, s32 speciesId_, u8 *buffer, bool32 param_4_, bool32 param_5_); u32 sub_80908D8(DungeonLocation *dungeon); u8 sub_8090910(DungeonLocation *dungeon, u32 param_2); diff --git a/include/pokemon_evolution.h b/include/pokemon_evolution.h index 21d31771b..0bfa1abe8 100644 --- a/include/pokemon_evolution.h +++ b/include/pokemon_evolution.h @@ -3,6 +3,14 @@ #include "structs/str_pokemon.h" +enum +{ + EVO_STRING_NOT_NOW, + EVO_STRING_POSSIBLE, + EVO_STRING_NO_MORE, + EVO_STRING_EMPTY, +}; + // size: 0x8 typedef struct EvolveStatus { @@ -15,8 +23,8 @@ typedef struct EvolveStatus /* 0x6 */ s16 targetEvolveSpecies; } EvolveStatus; -void sub_808F468(struct PokemonStruct1 *pokemon, EvolveStatus *evolveStatus,bool8 param_3); -s32 sub_808F700(PokemonStruct1 *pokemon); +void SetMonEvolveStatus(struct PokemonStruct1 *pokemon, EvolveStatus *evolveStatus,bool8 param_3); +s32 GetMonSummaryScreenEvoStringId(PokemonStruct1 *pokemon); PokemonStruct1 *sub_808F734(PokemonStruct1 *pokemon, s16 _species); PokemonStruct1 *sub_808F798(PokemonStruct1 *pokemon, s16 _species); diff --git a/include/pokemon_summary_window.h b/include/pokemon_summary_window.h index 14da4c0a1..a6ce6201e 100644 --- a/include/pokemon_summary_window.h +++ b/include/pokemon_summary_window.h @@ -39,7 +39,7 @@ struct MonSummaryInfo s16 unk40; s16 fill42; struct unkPokeSubStruct_C unk44[2]; - u8 unk4C; + u8 evoStringId; u8 fill4D[3]; IqSkillFlags IQSkills; // 0x50 u8 tactic; diff --git a/include/structs/str_dungeon.h b/include/structs/str_dungeon.h index d5c4f430c..affdee446 100644 --- a/include/structs/str_dungeon.h +++ b/include/structs/str_dungeon.h @@ -381,7 +381,7 @@ typedef struct Dungeon u8 unk10; u8 unk11; s16 unk12; - s16 unk14; + s16 startFloorId; // It's always 0 by default(see sDungeonStartingFloor table). If changed, it would be possible for the first entered floor to be displayed as not B1, but the specified number. s16 unk16; u32 unk18[(0xB8 - 0x18) / 4]; Entity *unkB8; diff --git a/ld_script.ld b/ld_script.ld index 6333c2ccd..a5cebb150 100755 --- a/ld_script.ld +++ b/ld_script.ld @@ -676,6 +676,7 @@ SECTIONS { src/pokemon_3.o(.rodata); src/pokemon_evolution.o(.rodata); src/pokemon_summary_window.o(.rodata); + src/dungeon.o(.rodata); data/data_81076E4.o(.rodata); src/game_options.o(.rodata); src/random_mersenne_twister.o(.rodata); diff --git a/src/dungeon.c b/src/dungeon.c index 6879dafc7..d6fc82702 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -1,4 +1,5 @@ #include "global.h" +#include "globaldata.h" #include "constants/dungeon.h" #include "constants/monster.h" #include "constants/type.h" @@ -16,11 +17,7 @@ extern const char gUnknown_8108F10[]; extern const char gUnknown_8108F18[]; extern const char gUnknown_8108F2C[]; -extern u8 gDungeonFloorCount[]; extern const u8 *const gUnknown_8108084[]; -extern DungeonLocation gUnknown_8107828[]; -extern u8 gDungeonFloorCount[]; -extern u8 gUnknown_81077E8[]; extern u8 gUnknown_8108F40[]; extern u16 gUnknown_8108F42[]; extern u8 gUnknown_8108F4A[4]; @@ -29,6 +26,223 @@ extern u8 gUnknown_8108F50[]; static void sub_8090888(u8 *param_1, u8 *param_2); static bool8 sub_8090820(u16 moveID); +static const u8 sDungeonFloorCount[] = { + [DUNGEON_TINY_WOODS] = 4, + [DUNGEON_THUNDERWAVE_CAVE] = 6, + [DUNGEON_MT_STEEL] = 10, + [DUNGEON_SINISTER_WOODS] = 14, + [DUNGEON_SILENT_CHASM] = 10, + [DUNGEON_MT_THUNDER] = 11, + [DUNGEON_MT_THUNDER_PEAK] = 4, + [DUNGEON_GREAT_CANYON] = 13, + [DUNGEON_LAPIS_CAVE] = 15, + [DUNGEON_MT_BLAZE] = 13, + [DUNGEON_MT_BLAZE_PEAK] = 4, + [DUNGEON_FROSTY_FOREST] = 10, + [DUNGEON_FROSTY_GROTTO] = 6, + [DUNGEON_MT_FREEZE] = 16, + [DUNGEON_MT_FREEZE_PEAK] = 6, + [DUNGEON_MAGMA_CAVERN] = 24, + [DUNGEON_MAGMA_CAVERN_PIT] = 4, + [DUNGEON_SKY_TOWER] = 26, + [DUNGEON_SKY_TOWER_SUMMIT] = 10, + [DUNGEON_STORMY_SEA] = 41, + [DUNGEON_SILVER_TRENCH] = 100, + [DUNGEON_METEOR_CAVE] = 21, + [DUNGEON_MT_FREEZE_PEAK_2] = 5, + [DUNGEON_WESTERN_CAVE] = 100, + [DUNGEON_BOSS_3] = 21, + [DUNGEON_BOSS_4] = 12, + [DUNGEON_WISH_CAVE] = 100, + [DUNGEON_BURIED_RELIC] = 100, + [DUNGEON_PITFALL_VALLEY] = 26, + [DUNGEON_NORTHERN_RANGE] = 26, + [DUNGEON_BOSS_9] = 13, + [DUNGEON_DESERT_REGION] = 21, + [DUNGEON_SOUTHERN_CAVERN] = 51, + [DUNGEON_WYVERN_HILL] = 31, + [DUNGEON_FIERY_FIELD] = 31, + [DUNGEON_NORTHWIND_FIELD] = 31, + [DUNGEON_SOLAR_CAVE] = 21, + [DUNGEON_LIGHTNING_FIELD] = 31, + [DUNGEON_DARKNIGHT_RELIC] = 16, + [DUNGEON_WONDROUS_SEA] = 13, + [DUNGEON_MURKY_CAVE] = 20, + [DUNGEON_GRAND_SEA] = 31, + [DUNGEON_UPROAR_FOREST] = 11, + [DUNGEON_ODDITY_CAVE] = 16, + [DUNGEON_REMAINS_ISLAND] = 21, + [DUNGEON_MARVELOUS_SEA] = 21, + [DUNGEON_FANTASY_STRAIT] = 31, + [DUNGEON_ROCK_PATH] = 5, + [DUNGEON_SNOW_PATH] = 5, + [DUNGEON_AUTOPILOT] = 11, + [DUNGEON_D50] = 3, + [DUNGEON_D51] = 51, + [DUNGEON_NORMAL_MAZE] = 70, + [DUNGEON_HOWLING_FOREST] = 16, + [DUNGEON_D54] = 31, + [DUNGEON_POISON_MAZE] = 20, + [DUNGEON_WATERFALL_POND] = 20, + [DUNGEON_UNKNOWN_RELIC] = 12, + [DUNGEON_JOYOUS_TOWER] = 100, + [DUNGEON_FAR_OFF_SEA] = 76, + [DUNGEON_MT_FARAWAY] = 41, + [DUNGEON_D61] = 100, + [DUNGEON_PURITY_FOREST] = 100, + [DUNGEON_OUT_ON_RESCUE] = 2, +}; + +// All dungeons always start at the first floor. +static const u8 sDungeonStartingFloor[] = { + [DUNGEON_TINY_WOODS] = 0, + [DUNGEON_THUNDERWAVE_CAVE] = 0, + [DUNGEON_MT_STEEL] = 0, + [DUNGEON_SINISTER_WOODS] = 0, + [DUNGEON_SILENT_CHASM] = 0, + [DUNGEON_MT_THUNDER] = 0, + [DUNGEON_MT_THUNDER_PEAK] = 0, + [DUNGEON_GREAT_CANYON] = 0, + [DUNGEON_LAPIS_CAVE] = 0, + [DUNGEON_MT_BLAZE] = 0, + [DUNGEON_MT_BLAZE_PEAK] = 0, + [DUNGEON_FROSTY_FOREST] = 0, + [DUNGEON_FROSTY_GROTTO] = 0, + [DUNGEON_MT_FREEZE] = 0, + [DUNGEON_MT_FREEZE_PEAK] = 0, + [DUNGEON_MAGMA_CAVERN] = 0, + [DUNGEON_MAGMA_CAVERN_PIT] = 0, + [DUNGEON_SKY_TOWER] = 0, + [DUNGEON_SKY_TOWER_SUMMIT] = 0, + [DUNGEON_STORMY_SEA] = 0, + [DUNGEON_SILVER_TRENCH] = 0, + [DUNGEON_METEOR_CAVE] = 0, + [DUNGEON_MT_FREEZE_PEAK_2] = 0, + [DUNGEON_WESTERN_CAVE] = 0, + [DUNGEON_BOSS_3] = 0, + [DUNGEON_BOSS_4] = 0, + [DUNGEON_WISH_CAVE] = 0, + [DUNGEON_BURIED_RELIC] = 0, + [DUNGEON_PITFALL_VALLEY] = 0, + [DUNGEON_NORTHERN_RANGE] = 0, + [DUNGEON_BOSS_9] = 0, + [DUNGEON_DESERT_REGION] = 0, + [DUNGEON_SOUTHERN_CAVERN] = 0, + [DUNGEON_WYVERN_HILL] = 0, + [DUNGEON_FIERY_FIELD] = 0, + [DUNGEON_NORTHWIND_FIELD] = 0, + [DUNGEON_SOLAR_CAVE] = 0, + [DUNGEON_LIGHTNING_FIELD] = 0, + [DUNGEON_DARKNIGHT_RELIC] = 0, + [DUNGEON_WONDROUS_SEA] = 0, + [DUNGEON_MURKY_CAVE] = 0, + [DUNGEON_GRAND_SEA] = 0, + [DUNGEON_UPROAR_FOREST] = 0, + [DUNGEON_ODDITY_CAVE] = 0, + [DUNGEON_REMAINS_ISLAND] = 0, + [DUNGEON_MARVELOUS_SEA] = 0, + [DUNGEON_FANTASY_STRAIT] = 0, + [DUNGEON_ROCK_PATH] = 0, + [DUNGEON_SNOW_PATH] = 0, + [DUNGEON_AUTOPILOT] = 0, + [DUNGEON_D50] = 0, + [DUNGEON_D51] = 0, + [DUNGEON_NORMAL_MAZE] = 0, + [DUNGEON_HOWLING_FOREST] = 0, + [DUNGEON_D54] = 0, + [DUNGEON_POISON_MAZE] = 0, + [DUNGEON_WATERFALL_POND] = 0, + [DUNGEON_UNKNOWN_RELIC] = 0, + [DUNGEON_JOYOUS_TOWER] = 0, + [DUNGEON_FAR_OFF_SEA] = 0, + [DUNGEON_MT_FARAWAY] = 0, + [DUNGEON_D61] = 0, + [DUNGEON_PURITY_FOREST] = 0, + [DUNGEON_OUT_ON_RESCUE] = 0, +}; + +static const DungeonLocation gUnknown_8107828[] = +{ + { .id = DUNGEON_MT_STEEL, .floor = 9 }, + { .id = DUNGEON_SINISTER_WOODS, .floor = 13 }, + { .id = DUNGEON_MT_THUNDER_PEAK, .floor = 3 }, + { .id = DUNGEON_MT_BLAZE_PEAK, .floor = 3 }, + { .id = DUNGEON_FROSTY_GROTTO, .floor = 5 }, + { .id = DUNGEON_MT_FREEZE_PEAK, .floor = 5 }, + { .id = DUNGEON_MAGMA_CAVERN_PIT, .floor = 2 }, + { .id = DUNGEON_MAGMA_CAVERN_PIT, .floor = 3 }, + { .id = DUNGEON_SKY_TOWER_SUMMIT, .floor = 9 }, + { .id = DUNGEON_STORMY_SEA, .floor = 40 }, + { .id = DUNGEON_SILVER_TRENCH, .floor = 99 }, + { .id = DUNGEON_METEOR_CAVE, .floor = 20 }, + { .id = DUNGEON_WESTERN_CAVE, .floor = 59 }, + { .id = DUNGEON_WESTERN_CAVE, .floor = 99 }, + { .id = DUNGEON_WISH_CAVE, .floor = 20 }, + { .id = DUNGEON_WISH_CAVE, .floor = 50 }, + { .id = DUNGEON_WISH_CAVE, .floor = 99 }, + { .id = DUNGEON_BURIED_RELIC, .floor = 15 }, + { .id = DUNGEON_BURIED_RELIC, .floor = 25 }, + { .id = DUNGEON_BURIED_RELIC, .floor = 35 }, + { .id = DUNGEON_BURIED_RELIC, .floor = 45 }, + { .id = DUNGEON_BURIED_RELIC, .floor = 60 }, + { .id = DUNGEON_BURIED_RELIC, .floor = 70 }, + { .id = DUNGEON_BURIED_RELIC, .floor = 80 }, + { .id = DUNGEON_NORTHERN_RANGE, .floor = 25 }, + { .id = DUNGEON_WYVERN_HILL, .floor = 20 }, + { .id = DUNGEON_WYVERN_HILL, .floor = 30 }, + { .id = DUNGEON_FIERY_FIELD, .floor = 30 }, + { .id = DUNGEON_NORTHWIND_FIELD, .floor = 20 }, + { .id = DUNGEON_NORTHWIND_FIELD, .floor = 30 }, + { .id = DUNGEON_SOLAR_CAVE, .floor = 10 }, + { .id = DUNGEON_SOLAR_CAVE, .floor = 15 }, + { .id = DUNGEON_SOLAR_CAVE, .floor = 20 }, + { .id = DUNGEON_LIGHTNING_FIELD, .floor = 30 }, + { .id = DUNGEON_GRAND_SEA, .floor = 15 }, + { .id = DUNGEON_GRAND_SEA, .floor = 25 }, + { .id = DUNGEON_UPROAR_FOREST, .floor = 10 }, + { .id = DUNGEON_AUTOPILOT, .floor = 1 }, + { .id = DUNGEON_AUTOPILOT, .floor = 2 }, + { .id = DUNGEON_AUTOPILOT, .floor = 3 }, + { .id = DUNGEON_AUTOPILOT, .floor = 4 }, + { .id = DUNGEON_AUTOPILOT, .floor = 5 }, + { .id = DUNGEON_AUTOPILOT, .floor = 6 }, + { .id = DUNGEON_AUTOPILOT, .floor = 7 }, + { .id = DUNGEON_AUTOPILOT, .floor = 8 }, + { .id = DUNGEON_AUTOPILOT, .floor = 9 }, + { .id = DUNGEON_AUTOPILOT, .floor = 10 }, + // Used for all mazes, see GeneralizeMazeDungeonLoc + { .id = DUNGEON_NORMAL_MAZE, .floor = 3 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 6 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 9 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 12 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 15 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 18 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 21 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 24 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 27 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 30 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 33 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 36 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 39 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 42 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 45 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 48 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 51 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 54 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 57 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 60 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 63 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 66 }, + { .id = DUNGEON_NORMAL_MAZE, .floor = 69 }, + { .id = DUNGEON_HOWLING_FOREST, .floor = 15 }, + { .id = DUNGEON_FAR_OFF_SEA, .floor = 50 }, + { .id = DUNGEON_FAR_OFF_SEA, .floor = 72 }, + { .id = DUNGEON_MT_FARAWAY, .floor = 30 }, + { .id = DUNGEON_MT_FARAWAY, .floor = 40 }, + { .id = DUNGEON_PURITY_FOREST, .floor = 99 }, + { .id = DUNGEON_OUT_ON_RESCUE, .floor = 255 } +}; + const u8 *GetDungeonName1(u8 dungeon) { return gDungeonNames[dungeon].name1; @@ -98,8 +312,8 @@ bool8 sub_809017C(DungeonLocation* a1) { DungeonLocation location; int i; - sub_80901D8(&location, a1); - for (i = 0; i < 999 && gUnknown_8107828[i].id != 63; ++i) { + GeneralizeMazeDungeonLoc(&location, a1); + for (i = 0; i < 999 && gUnknown_8107828[i].id != DUNGEON_OUT_ON_RESCUE; ++i) { if (location.id == gUnknown_8107828[i].id && location.floor == gUnknown_8107828[i].floor) { return TRUE; @@ -108,15 +322,16 @@ bool8 sub_809017C(DungeonLocation* a1) return FALSE; } -void sub_80901D8(DungeonLocation *param_1,DungeonLocation *param_2) +// Treats all mazes as DUNGEON_NORMAL_MAZE +void GeneralizeMazeDungeonLoc(DungeonLocation *dst, const DungeonLocation *src) { - if (DUNGEON_IS_MAZE(param_2->id)) { - param_1->id = DUNGEON_NORMAL_MAZE; - param_1->floor = (param_2->id - DUNGEON_NORMAL_MAZE_2) * 3 + param_2->floor; - } - else { - *param_1 = *param_2; - } + if (DUNGEON_IS_MAZE(src->id)) { + dst->id = DUNGEON_NORMAL_MAZE; + dst->floor = (src->id - DUNGEON_NORMAL_MAZE_2) * 3 + src->floor; + } + else { + *dst = *src; + } } void PrintYellowDungeonNametoBuffer(u8 *buffer, DungeonLocation *dungeonLocation) @@ -144,20 +359,20 @@ s32 GetDungeonFloorCount(u8 dungeon) { if (DUNGEON_IS_MAZE(dungeon)) return 4; - else if(dungeon > DUNGEON_PURITY_FOREST) + else if (dungeon > DUNGEON_PURITY_FOREST) return 1; else - return gDungeonFloorCount[dungeon]; + return sDungeonFloorCount[dungeon]; } -u8 sub_80902C8(u8 dungeon) +s32 GetDungeonStartingFloor(u8 dungeon) { if (DUNGEON_IS_MAZE(dungeon)) return 0; - else if(dungeon > DUNGEON_PURITY_FOREST) + else if (dungeon > DUNGEON_PURITY_FOREST) return 0; else - return gUnknown_81077E8[dungeon]; + return sDungeonStartingFloor[dungeon]; } // arm9.bin::0205ECA0 @@ -414,7 +629,7 @@ static void sub_8090888(u8 *param_1, u8 *param_2) u32 sub_80908D8(DungeonLocation *dungeon) { - if (dungeon->id < DUNGEON_OUT_ON_RESCUE && dungeon->floor < gDungeonFloorCount[dungeon->id]) { + if (dungeon->id < DUNGEON_OUT_ON_RESCUE && dungeon->floor < sDungeonFloorCount[dungeon->id]) { return gUnknown_8108084[dungeon->id][dungeon->floor]; } else { @@ -426,7 +641,7 @@ u8 sub_8090910(DungeonLocation *dungeon, u32 param_2) { s32 rand1 = RandInt(9999); s32 rand2 = RandInt(9999); - if (dungeon->id < DUNGEON_OUT_ON_RESCUE && dungeon->floor < gDungeonFloorCount[dungeon->id]) { + if (dungeon->id < DUNGEON_OUT_ON_RESCUE && dungeon->floor < sDungeonFloorCount[dungeon->id]) { return sub_8091E94(param_2, rand1, rand2); } else { diff --git a/src/dungeon_misc.c b/src/dungeon_misc.c index 4494e5b78..1007ff8bb 100644 --- a/src/dungeon_misc.c +++ b/src/dungeon_misc.c @@ -893,10 +893,10 @@ void SetMonSummaryInfoFromEntity(struct MonSummaryInfo *param_1, Entity *target) param_1->unk44[1].level = 0; param_1->IQSkills = info->IQSkillMenuFlags; if (gDungeon->unk644.unk16 != 0) { - param_1->unk4C = sub_806A4DC(info); + param_1->evoStringId = sub_806A4DC(info); } else { - param_1->unk4C = 3; + param_1->evoStringId = EVO_STRING_EMPTY; } uVar15 = 0; @@ -1414,7 +1414,7 @@ s32 sub_806A4DC(EntityInfo *info) pokemon.offense.att[0] = info->atk[0]; pokemon.offense.def[0] = info->def[0]; - return sub_808F700(&pokemon); + return GetMonSummaryScreenEvoStringId(&pokemon); } bool8 sub_806A538(s16 r0) diff --git a/src/dungeon_name_banner.c b/src/dungeon_name_banner.c index 30cf86368..cb9f4801b 100644 --- a/src/dungeon_name_banner.c +++ b/src/dungeon_name_banner.c @@ -63,7 +63,7 @@ void ShowDungeonNameBanner_Async(void) } CpuClear((void *)(VRAM + 0x140), 0x1C00); if (sub_80848EC()) { - s32 currFloor = gDungeon->unk644.dungeonLocation.floor + gDungeon->unk14; + s32 currFloor = gDungeon->unk644.dungeonLocation.floor + gDungeon->startFloorId; const u8 *dungName = GetDungeonName2(gDungeon->unk644.dungeonLocation.id); s32 r5 = 10; diff --git a/src/dungeon_spawns.c b/src/dungeon_spawns.c index e3c95d5ce..556e8f8ac 100644 --- a/src/dungeon_spawns.c +++ b/src/dungeon_spawns.c @@ -23,10 +23,6 @@ #include "dungeon_config.h" #include "structs/dungeon_mapparam.h" -// File split is correct. - -extern s32 sub_80902C8(u8 dungeon); - void sub_803D4AC(void) { gDungeon->unk1C570.id = DUNGEON_INVALID; @@ -40,7 +36,7 @@ void SetFloorItemMonsterSpawns(void) OpenedFile *file; struct DungeonMapParam1 *strPtr; - sub_80901D8(&gDungeon->unk644.dungeonLocation2, &gDungeon->unk644.dungeonLocation); + GeneralizeMazeDungeonLoc(&gDungeon->unk644.dungeonLocation2, &gDungeon->unk644.dungeonLocation); if (gDungeon->unk1C570.id == gDungeon->unk644.dungeonLocation2.id && gDungeon->unk1C570.floor == gDungeon->unk644.dungeonLocation2.floor) return; @@ -49,7 +45,7 @@ void SetFloorItemMonsterSpawns(void) strPtr = &((struct DungeonMapParam2 *)(file->data))->unk0[gDungeon->unk1C570.id][gDungeon->unk1C570.floor]; gDungeon->unk1CEC8 = GetDungeonFloorCount(gDungeon->unk644.dungeonLocation.id); - gDungeon->unk14 = sub_80902C8(gDungeon->unk644.dungeonLocation.id); + gDungeon->startFloorId = GetDungeonStartingFloor(gDungeon->unk644.dungeonLocation.id); gDungeon->floorProperties = ((struct DungeonMapParam2 *)(file->data))->floorProperties[strPtr->unk0]; diff --git a/src/dungeon_tilemap.c b/src/dungeon_tilemap.c index 25895b922..c539da3fe 100644 --- a/src/dungeon_tilemap.c +++ b/src/dungeon_tilemap.c @@ -479,7 +479,7 @@ void sub_803FB74(void) { s32 i; u16 *arrPtr; - s32 r5, r6, unkFloor; + s32 r5, r6, currFloor; UnkDungeonGlobal_unk181E8_sub *strPtr = &gDungeon->unk181e8; bool32 lowHp = FALSE; bool32 hungry = FALSE; @@ -540,9 +540,9 @@ void sub_803FB74(void) } arrPtr = gBgTilemaps[0][0]; - unkFloor = gDungeon->unk14 + gDungeon->unk644.dungeonLocation.floor; - if (strPtr->unk3A != unkFloor) { - strPtr->unk3A = unkFloor; + currFloor = gDungeon->startFloorId + gDungeon->unk644.dungeonLocation.floor; + if (strPtr->unk3A != currFloor) { + strPtr->unk3A = currFloor; if (IsStairDirectionUp(gDungeon->unk644.dungeonLocation.id)) { arrPtr[1] = 0; } @@ -550,12 +550,12 @@ void sub_803FB74(void) arrPtr[1] = 0xF2BE; } - if (unkFloor < 10) { - sub_803FE30(unkFloor, &arrPtr[2], strPtr->unk18216, 1); + if (currFloor < 10) { + sub_803FE30(currFloor, &arrPtr[2], strPtr->unk18216, 1); arrPtr[3] = 0xF2B8; } else { - sub_803FE30(unkFloor, &arrPtr[2], strPtr->unk18216, 0); + sub_803FE30(currFloor, &arrPtr[2], strPtr->unk18216, 0); arrPtr[4] = 0xF2B8; } } diff --git a/src/luminous_cave.c b/src/luminous_cave.c index 59f617493..9116452a7 100644 --- a/src/luminous_cave.c +++ b/src/luminous_cave.c @@ -734,7 +734,7 @@ static void sub_8025254(void) } sLuminousCaveWork->evolveStatus.wurmpleVal = RandInt(0xFF); - sub_808F468(sLuminousCaveWork->pokeStruct, &sLuminousCaveWork->evolveStatus, 1); + SetMonEvolveStatus(sLuminousCaveWork->pokeStruct, &sLuminousCaveWork->evolveStatus, 1); } static bool8 LuminousCave_HasOnly1Member(void) diff --git a/src/pokemon_evolution.c b/src/pokemon_evolution.c index fa0d9de1c..475ec62be 100644 --- a/src/pokemon_evolution.c +++ b/src/pokemon_evolution.c @@ -9,7 +9,7 @@ #include "constants/evolve_type.h" #include "constants/evolution_status.h" -void sub_808F468(PokemonStruct1 *pokemon, EvolveStatus *evolveStatus,bool8 param_3) +void SetMonEvolveStatus(PokemonStruct1 *pokemon, EvolveStatus *evolveStatus, bool8 param_3) { struct FriendAreaCapacity friendAreaCapacity; struct unkEvolve evolveConditions; @@ -170,19 +170,19 @@ void sub_808F468(PokemonStruct1 *pokemon, EvolveStatus *evolveStatus,bool8 param } } -s32 sub_808F700(PokemonStruct1 *pokemon) +s32 GetMonSummaryScreenEvoStringId(PokemonStruct1 *pokemon) { EvolveStatus evolveStatus; - sub_808F468(pokemon, &evolveStatus, 0); - if ((evolveStatus.evolutionConditionStatus & EVOLUTION_GOOD)) { - return 1; + SetMonEvolveStatus(pokemon, &evolveStatus, 0); + if (evolveStatus.evolutionConditionStatus & EVOLUTION_GOOD) { + return EVO_STRING_POSSIBLE; } - else if ((evolveStatus.evolutionConditionStatus & EVOLUTION_NO_MORE)) { - return 2; + else if (evolveStatus.evolutionConditionStatus & EVOLUTION_NO_MORE) { + return EVO_STRING_NO_MORE; } else { - return 0; + return EVO_STRING_NOT_NOW; } } diff --git a/src/pokemon_summary_window.c b/src/pokemon_summary_window.c index 2526d53d5..2806ac967 100644 --- a/src/pokemon_summary_window.c +++ b/src/pokemon_summary_window.c @@ -226,7 +226,7 @@ void ShowPokemonSummaryWindow(s32 which, s32 currSubWindowId, struct MonSummaryI strcpy(gFormatBuffer_Monsters[0],gUnknown_810E02C[GetBodySize(monInfo->species)]); PrintFormattedStringOnWindow(4,y,gUnknown_810DF98,windowId,'\0'); y += 0xD; - PrintFormattedStringOnWindow(4,y,gEvolutionStrings[monInfo->unk4C],windowId,'\0'); + PrintFormattedStringOnWindow(4,y,gEvolutionStrings[monInfo->evoStringId],windowId,'\0'); break; } } @@ -284,10 +284,10 @@ void SetMonSummaryInfo(struct MonSummaryInfo *dst, struct PokemonStruct1 *pokemo dst->unk44[1] = pokemon->unkC[1]; dst->IQSkills = pokemon->IQSkills; if (param_3) { - dst->unk4C = sub_808F700(pokemon); + dst->evoStringId = GetMonSummaryScreenEvoStringId(pokemon); } else { - dst->unk4C = 3; + dst->evoStringId = EVO_STRING_EMPTY; } for(index = 0; index < 0xC; index++) diff --git a/src/unk_dungeon_load_maybe.c b/src/unk_dungeon_load_maybe.c index f129af140..3453cc381 100644 --- a/src/unk_dungeon_load_maybe.c +++ b/src/unk_dungeon_load_maybe.c @@ -29,7 +29,7 @@ void sub_80ADD9C(OpenedFile **a0, OpenedFile **a1, u32 *a2, void *a3, u16 *a4, D void *r10 = MemoryAlloc(0x930, 7); OpenedFile *mapParamFile = OpenFileAndGetFileDataPtr("mapparam", &gDungeonFileArchive); - sub_80901D8(&dungLoc, a5); + GeneralizeMazeDungeonLoc(&dungLoc, a5); dungId = dungLoc.id; dungFloor = dungLoc.floor; if (dungId > 62) {