From 86354f1d50a5cb510b2788558c06342b21dbaa08 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 5 Feb 2020 02:47:32 -0500 Subject: [PATCH] Document some pokenav and region map --- data/maps/AlteringCave/map.json | 2 +- data/maps/BirthIsland_Exterior/map.json | 2 +- data/maps/BirthIsland_Harbor/map.json | 2 +- .../scripts.inc | 2 +- .../scripts.inc | 2 +- data/maps/NavelRock_B1F/map.json | 2 +- data/maps/NavelRock_Bottom/map.json | 2 +- data/maps/NavelRock_Down01/map.json | 2 +- data/maps/NavelRock_Down02/map.json | 2 +- data/maps/NavelRock_Down03/map.json | 2 +- data/maps/NavelRock_Down04/map.json | 2 +- data/maps/NavelRock_Down05/map.json | 2 +- data/maps/NavelRock_Down06/map.json | 2 +- data/maps/NavelRock_Down07/map.json | 2 +- data/maps/NavelRock_Down08/map.json | 2 +- data/maps/NavelRock_Down09/map.json | 2 +- data/maps/NavelRock_Down10/map.json | 2 +- data/maps/NavelRock_Down11/map.json | 2 +- data/maps/NavelRock_Entrance/map.json | 2 +- data/maps/NavelRock_Exterior/map.json | 2 +- data/maps/NavelRock_Fork/map.json | 2 +- data/maps/NavelRock_Harbor/map.json | 2 +- data/maps/NavelRock_Top/map.json | 2 +- data/maps/NavelRock_Up1/map.json | 2 +- data/maps/NavelRock_Up2/map.json | 2 +- data/maps/NavelRock_Up3/map.json | 2 +- data/maps/NavelRock_Up4/map.json | 2 +- data/scripts/abnormal_weather.inc | 2 +- .../pokenav/{zoom.png => city_zoom_text.png} | Bin .../{zoom_tiles.png => city_zoom_tiles.png} | Bin ...8622868.pal => region_map_info_window.pal} | 0 include/constants/heal_locations.h | 8 +- include/constants/region_map_sections.h | 12 +- include/constants/weather.h | 47 +- include/pokedex_area_region_map.h | 17 + include/pokenav.h | 109 +- include/region_map.h | 45 +- include/unk_pokedex_area_screen_helper.h | 17 - ld_script.txt | 4 +- src/data/region_map/city_map_entries.h | 46 +- src/data/region_map/region_map_entries.h | 12 +- src/field_region_map.c | 35 +- src/field_specials.c | 14 +- src/graphics.c | 4 +- src/map_name_popup.c | 6 +- src/party_menu.c | 2 +- src/pokedex_area_region_map.c | 66 + src/pokedex_area_screen.c | 24 +- src/pokemon_summary_screen.c | 2 +- src/pokenav.c | 300 ++-- src/pokenav_conditions_1.c | 2 +- src/pokenav_conditions_2.c | 4 +- src/pokenav_conditions_3.c | 10 +- src/pokenav_main_menu.c | 80 +- src/pokenav_match_call_1.c | 14 +- src/pokenav_match_call_2.c | 34 +- src/pokenav_match_call_ui.c | 2 + src/pokenav_menu_handler_1.c | 44 +- src/pokenav_menu_handler_2.c | 71 +- src/pokenav_region_map.c | 520 +++---- src/pokenav_ribbons_1.c | 8 +- src/pokenav_ribbons_2.c | 4 +- src/region_map.c | 1241 ++++++++--------- src/unk_pokedex_area_screen_helper.c | 68 - sym_ewram.txt | 2 +- 65 files changed, 1477 insertions(+), 1453 deletions(-) rename graphics/pokenav/{zoom.png => city_zoom_text.png} (100%) rename graphics/pokenav/{zoom_tiles.png => city_zoom_tiles.png} (100%) rename graphics/pokenav/{8622868.pal => region_map_info_window.pal} (100%) create mode 100755 include/pokedex_area_region_map.h delete mode 100755 include/unk_pokedex_area_screen_helper.h create mode 100644 src/pokedex_area_region_map.c delete mode 100644 src/unk_pokedex_area_screen_helper.c diff --git a/data/maps/AlteringCave/map.json b/data/maps/AlteringCave/map.json index 848eb95c1..2addfddb7 100644 --- a/data/maps/AlteringCave/map.json +++ b/data/maps/AlteringCave/map.json @@ -3,7 +3,7 @@ "name": "AlteringCave", "layout": "LAYOUT_ALTERING_CAVE", "music": "MUS_RG_NANADUNGEON", - "region_map_section": "MAPSEC_ALTERING_CAVE_2", + "region_map_section": "MAPSEC_ALTERING_CAVE", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_UNDERGROUND", diff --git a/data/maps/BirthIsland_Exterior/map.json b/data/maps/BirthIsland_Exterior/map.json index 50bd57f0b..ddb06e994 100644 --- a/data/maps/BirthIsland_Exterior/map.json +++ b/data/maps/BirthIsland_Exterior/map.json @@ -3,7 +3,7 @@ "name": "BirthIsland_Exterior", "layout": "LAYOUT_BIRTH_ISLAND_EXTERIOR", "music": "MUS_NONE", - "region_map_section": "MAPSEC_BIRTH_ISLAND_2", + "region_map_section": "MAPSEC_BIRTH_ISLAND", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_INDOOR", diff --git a/data/maps/BirthIsland_Harbor/map.json b/data/maps/BirthIsland_Harbor/map.json index ea124d9ef..4df765428 100644 --- a/data/maps/BirthIsland_Harbor/map.json +++ b/data/maps/BirthIsland_Harbor/map.json @@ -3,7 +3,7 @@ "name": "BirthIsland_Harbor", "layout": "LAYOUT_ISLAND_HARBOR", "music": "MUS_NONE", - "region_map_section": "MAPSEC_BIRTH_ISLAND_2", + "region_map_section": "MAPSEC_BIRTH_ISLAND", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_INDOOR", diff --git a/data/maps/EverGrandeCity_PokemonCenter_1F/scripts.inc b/data/maps/EverGrandeCity_PokemonCenter_1F/scripts.inc index 95be20f75..333bffc37 100644 --- a/data/maps/EverGrandeCity_PokemonCenter_1F/scripts.inc +++ b/data/maps/EverGrandeCity_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ EverGrandeCity_PokemonCenter_1F_MapScripts:: @ 8229A34 .byte 0 EverGrandeCity_PokemonCenter_1F_OnTransition: @ 8229A3F - setrespawn HEAL_LOCATION_EVER_GRANDE_CITY_1 + setrespawn HEAL_LOCATION_EVER_GRANDE_CITY call_if_unset FLAG_MET_SCOTT_IN_EVERGRANDE, EverGrandeCity_PokemonCenter_1F_EventScript_TryShowScott end diff --git a/data/maps/EverGrandeCity_PokemonLeague_1F/scripts.inc b/data/maps/EverGrandeCity_PokemonLeague_1F/scripts.inc index 814025895..5c6400509 100644 --- a/data/maps/EverGrandeCity_PokemonLeague_1F/scripts.inc +++ b/data/maps/EverGrandeCity_PokemonLeague_1F/scripts.inc @@ -4,7 +4,7 @@ EverGrandeCity_PokemonLeague_1F_MapScripts:: @ 82295D2 .byte 0 EverGrandeCity_PokemonLeague_1F_OnTransition: @ 82295DD - setrespawn HEAL_LOCATION_EVER_GRANDE_CITY_2 + setrespawn HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE setflag FLAG_LANDMARK_POKEMON_LEAGUE call_if_unset FLAG_ENTERED_ELITE_FOUR, EverGrandeCity_PokemonLeague_1F_EventScript_GuardsBlockDoor end diff --git a/data/maps/NavelRock_B1F/map.json b/data/maps/NavelRock_B1F/map.json index 6b5cd0089..bfea2e738 100644 --- a/data/maps/NavelRock_B1F/map.json +++ b/data/maps/NavelRock_B1F/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_B1F", "layout": "LAYOUT_NAVEL_ROCK_B1F", "music": "MUS_RG_NANADUNGEON", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_UNDERGROUND", diff --git a/data/maps/NavelRock_Bottom/map.json b/data/maps/NavelRock_Bottom/map.json index 1ae004107..b2ebb08c6 100644 --- a/data/maps/NavelRock_Bottom/map.json +++ b/data/maps/NavelRock_Bottom/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_Bottom", "layout": "LAYOUT_NAVEL_ROCK_BOTTOM", "music": "MUS_RG_NANADUNGEON", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_UNDERGROUND", diff --git a/data/maps/NavelRock_Down01/map.json b/data/maps/NavelRock_Down01/map.json index 50f60b52e..255e69a8e 100644 --- a/data/maps/NavelRock_Down01/map.json +++ b/data/maps/NavelRock_Down01/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_Down01", "layout": "LAYOUT_NAVEL_ROCK_LADDER_ROOM1", "music": "MUS_RG_NANADUNGEON", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_UNDERGROUND", diff --git a/data/maps/NavelRock_Down02/map.json b/data/maps/NavelRock_Down02/map.json index fb2d15145..3fbf7ee63 100644 --- a/data/maps/NavelRock_Down02/map.json +++ b/data/maps/NavelRock_Down02/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_Down02", "layout": "LAYOUT_NAVEL_ROCK_LADDER_ROOM2", "music": "MUS_RG_NANADUNGEON", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_UNDERGROUND", diff --git a/data/maps/NavelRock_Down03/map.json b/data/maps/NavelRock_Down03/map.json index a82e03610..9f8650c27 100644 --- a/data/maps/NavelRock_Down03/map.json +++ b/data/maps/NavelRock_Down03/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_Down03", "layout": "LAYOUT_NAVEL_ROCK_LADDER_ROOM1", "music": "MUS_RG_NANADUNGEON", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_UNDERGROUND", diff --git a/data/maps/NavelRock_Down04/map.json b/data/maps/NavelRock_Down04/map.json index 58e81b709..ce7f0c267 100644 --- a/data/maps/NavelRock_Down04/map.json +++ b/data/maps/NavelRock_Down04/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_Down04", "layout": "LAYOUT_NAVEL_ROCK_LADDER_ROOM2", "music": "MUS_RG_NANADUNGEON", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_UNDERGROUND", diff --git a/data/maps/NavelRock_Down05/map.json b/data/maps/NavelRock_Down05/map.json index a1fcef804..4a0f0630c 100644 --- a/data/maps/NavelRock_Down05/map.json +++ b/data/maps/NavelRock_Down05/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_Down05", "layout": "LAYOUT_NAVEL_ROCK_LADDER_ROOM1", "music": "MUS_RG_NANADUNGEON", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_UNDERGROUND", diff --git a/data/maps/NavelRock_Down06/map.json b/data/maps/NavelRock_Down06/map.json index 204a2a2cf..2964e533f 100644 --- a/data/maps/NavelRock_Down06/map.json +++ b/data/maps/NavelRock_Down06/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_Down06", "layout": "LAYOUT_NAVEL_ROCK_LADDER_ROOM2", "music": "MUS_RG_NANADUNGEON", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_UNDERGROUND", diff --git a/data/maps/NavelRock_Down07/map.json b/data/maps/NavelRock_Down07/map.json index f48063d8a..a1cbac77b 100644 --- a/data/maps/NavelRock_Down07/map.json +++ b/data/maps/NavelRock_Down07/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_Down07", "layout": "LAYOUT_NAVEL_ROCK_LADDER_ROOM1", "music": "MUS_RG_NANADUNGEON", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_UNDERGROUND", diff --git a/data/maps/NavelRock_Down08/map.json b/data/maps/NavelRock_Down08/map.json index d5f7ea8fe..7065aa090 100644 --- a/data/maps/NavelRock_Down08/map.json +++ b/data/maps/NavelRock_Down08/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_Down08", "layout": "LAYOUT_NAVEL_ROCK_LADDER_ROOM2", "music": "MUS_RG_NANADUNGEON", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_UNDERGROUND", diff --git a/data/maps/NavelRock_Down09/map.json b/data/maps/NavelRock_Down09/map.json index 348739b31..9f4618afb 100644 --- a/data/maps/NavelRock_Down09/map.json +++ b/data/maps/NavelRock_Down09/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_Down09", "layout": "LAYOUT_NAVEL_ROCK_LADDER_ROOM1", "music": "MUS_RG_NANADUNGEON", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_UNDERGROUND", diff --git a/data/maps/NavelRock_Down10/map.json b/data/maps/NavelRock_Down10/map.json index 3aa128fa0..6aca30847 100644 --- a/data/maps/NavelRock_Down10/map.json +++ b/data/maps/NavelRock_Down10/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_Down10", "layout": "LAYOUT_NAVEL_ROCK_LADDER_ROOM2", "music": "MUS_RG_NANADUNGEON", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_UNDERGROUND", diff --git a/data/maps/NavelRock_Down11/map.json b/data/maps/NavelRock_Down11/map.json index 0ed44f0fc..257c2ba6f 100644 --- a/data/maps/NavelRock_Down11/map.json +++ b/data/maps/NavelRock_Down11/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_Down11", "layout": "LAYOUT_NAVEL_ROCK_LADDER_ROOM1", "music": "MUS_RG_NANADUNGEON", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_UNDERGROUND", diff --git a/data/maps/NavelRock_Entrance/map.json b/data/maps/NavelRock_Entrance/map.json index 983df45df..dbe05a525 100644 --- a/data/maps/NavelRock_Entrance/map.json +++ b/data/maps/NavelRock_Entrance/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_Entrance", "layout": "LAYOUT_NAVEL_ROCK_ENTRANCE", "music": "MUS_RG_NANADUNGEON", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_UNDERGROUND", diff --git a/data/maps/NavelRock_Exterior/map.json b/data/maps/NavelRock_Exterior/map.json index b98f08d4e..951f9a468 100644 --- a/data/maps/NavelRock_Exterior/map.json +++ b/data/maps/NavelRock_Exterior/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_Exterior", "layout": "LAYOUT_NAVEL_ROCK_EXTERIOR", "music": "MUS_RG_NANASHIMA", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_INDOOR", diff --git a/data/maps/NavelRock_Fork/map.json b/data/maps/NavelRock_Fork/map.json index 728b8a7aa..960735377 100644 --- a/data/maps/NavelRock_Fork/map.json +++ b/data/maps/NavelRock_Fork/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_Fork", "layout": "LAYOUT_NAVEL_ROCK_FORK", "music": "MUS_RG_NANADUNGEON", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_UNDERGROUND", diff --git a/data/maps/NavelRock_Harbor/map.json b/data/maps/NavelRock_Harbor/map.json index e91dfa8d1..6c7957832 100644 --- a/data/maps/NavelRock_Harbor/map.json +++ b/data/maps/NavelRock_Harbor/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_Harbor", "layout": "LAYOUT_ISLAND_HARBOR", "music": "MUS_RG_NANASHIMA", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_INDOOR", diff --git a/data/maps/NavelRock_Top/map.json b/data/maps/NavelRock_Top/map.json index c906c4ceb..03cc3ab7b 100644 --- a/data/maps/NavelRock_Top/map.json +++ b/data/maps/NavelRock_Top/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_Top", "layout": "LAYOUT_NAVEL_ROCK_TOP", "music": "MUS_RG_NANADUNGEON", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_SHADE", "map_type": "MAP_TYPE_UNDERGROUND", diff --git a/data/maps/NavelRock_Up1/map.json b/data/maps/NavelRock_Up1/map.json index 24d1b5a32..7142677f5 100644 --- a/data/maps/NavelRock_Up1/map.json +++ b/data/maps/NavelRock_Up1/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_Up1", "layout": "LAYOUT_NAVEL_ROCK_LADDER_ROOM1", "music": "MUS_RG_NANADUNGEON", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_UNDERGROUND", diff --git a/data/maps/NavelRock_Up2/map.json b/data/maps/NavelRock_Up2/map.json index 2d16e798c..606b46ba6 100644 --- a/data/maps/NavelRock_Up2/map.json +++ b/data/maps/NavelRock_Up2/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_Up2", "layout": "LAYOUT_NAVEL_ROCK_LADDER_ROOM2", "music": "MUS_RG_NANADUNGEON", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_UNDERGROUND", diff --git a/data/maps/NavelRock_Up3/map.json b/data/maps/NavelRock_Up3/map.json index 2e984b379..9612a2dcc 100644 --- a/data/maps/NavelRock_Up3/map.json +++ b/data/maps/NavelRock_Up3/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_Up3", "layout": "LAYOUT_NAVEL_ROCK_LADDER_ROOM1", "music": "MUS_RG_NANADUNGEON", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_UNDERGROUND", diff --git a/data/maps/NavelRock_Up4/map.json b/data/maps/NavelRock_Up4/map.json index e448e6a9a..27f8b6b81 100644 --- a/data/maps/NavelRock_Up4/map.json +++ b/data/maps/NavelRock_Up4/map.json @@ -3,7 +3,7 @@ "name": "NavelRock_Up4", "layout": "LAYOUT_NAVEL_ROCK_LADDER_ROOM2", "music": "MUS_RG_NANADUNGEON", - "region_map_section": "MAPSEC_NAVEL_ROCK2", + "region_map_section": "MAPSEC_NAVEL_ROCK", "requires_flash": false, "weather": "WEATHER_NONE", "map_type": "MAP_TYPE_UNDERGROUND", diff --git a/data/scripts/abnormal_weather.inc b/data/scripts/abnormal_weather.inc index 88da0405f..16f8af41f 100644 --- a/data/scripts/abnormal_weather.inc +++ b/data/scripts/abnormal_weather.inc @@ -172,7 +172,7 @@ AbnormalWeather_StartGroudonWeather:: @ 8273D1B AbnormalWeather_EventScript_EndEventAndCleanup_1:: @ 8273D1F lockall - compare VAR_ABNORMAL_WEATHER_LOCATION, ABNORMAL_WEATHER_KYOGRE_LOCATIONS_START + compare VAR_ABNORMAL_WEATHER_LOCATION, MARINE_CAVE_LOCATIONS_START goto_if_ge AbnormalWeather_EventScript_ShowRainEndedMessage goto AbnormalWeather_EventScript_ShowSunEndedMessage end diff --git a/graphics/pokenav/zoom.png b/graphics/pokenav/city_zoom_text.png similarity index 100% rename from graphics/pokenav/zoom.png rename to graphics/pokenav/city_zoom_text.png diff --git a/graphics/pokenav/zoom_tiles.png b/graphics/pokenav/city_zoom_tiles.png similarity index 100% rename from graphics/pokenav/zoom_tiles.png rename to graphics/pokenav/city_zoom_tiles.png diff --git a/graphics/pokenav/8622868.pal b/graphics/pokenav/region_map_info_window.pal similarity index 100% rename from graphics/pokenav/8622868.pal rename to graphics/pokenav/region_map_info_window.pal diff --git a/include/constants/heal_locations.h b/include/constants/heal_locations.h index 64c8956a9..272a69dfa 100644 --- a/include/constants/heal_locations.h +++ b/include/constants/heal_locations.h @@ -11,16 +11,16 @@ #define HEAL_LOCATION_LILYCOVE_CITY 8 #define HEAL_LOCATION_MOSSDEEP_CITY 9 #define HEAL_LOCATION_SOOTOPOLIS_CITY 10 -#define HEAL_LOCATION_EVER_GRANDE_CITY_1 11 -#define HEAL_LOCATION_LITTLEROOT_TOWN_1 12 -#define HEAL_LOCATION_LITTLEROOT_TOWN_2 13 +#define HEAL_LOCATION_EVER_GRANDE_CITY 11 +#define HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE 12 +#define HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE 13 #define HEAL_LOCATION_OLDALE_TOWN 14 #define HEAL_LOCATION_DEWFORD_TOWN 15 #define HEAL_LOCATION_LAVARIDGE_TOWN 16 #define HEAL_LOCATION_FALLARBOR_TOWN 17 #define HEAL_LOCATION_VERDANTURF_TOWN 18 #define HEAL_LOCATION_PACIFIDLOG_TOWN 19 -#define HEAL_LOCATION_EVER_GRANDE_CITY_2 20 +#define HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE 20 #define HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR 21 #define HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST 22 diff --git a/include/constants/region_map_sections.h b/include/constants/region_map_sections.h index bba76939c..7b780be01 100644 --- a/include/constants/region_map_sections.h +++ b/include/constants/region_map_sections.h @@ -175,7 +175,7 @@ #define MAPSEC_SEVII_ISLE_22 0xAB #define MAPSEC_SEVII_ISLE_23 0xAC #define MAPSEC_SEVII_ISLE_24 0xAD -#define MAPSEC_NAVEL_ROCK 0xAE +#define MAPSEC_NAVEL_ROCK_FRLG 0xAE #define MAPSEC_MT_EMBER 0xAF #define MAPSEC_BERRY_FOREST 0xB0 #define MAPSEC_ICEFALL_CAVE 0xB1 @@ -184,11 +184,11 @@ #define MAPSEC_DOTTED_HOLE 0xB4 #define MAPSEC_LOST_CAVE 0xB5 #define MAPSEC_PATTERN_BUSH 0xB6 -#define MAPSEC_ALTERING_CAVE 0xB7 +#define MAPSEC_ALTERING_CAVE_FRLG 0xB7 #define MAPSEC_TANOBY_CHAMBERS 0xB8 #define MAPSEC_THREE_ISLE_PATH 0xB9 #define MAPSEC_TANOBY_KEY 0xBA -#define MAPSEC_BIRTH_ISLAND 0xBB +#define MAPSEC_BIRTH_ISLAND_FRLG 0xBB #define MAPSEC_MONEAN_CHAMBER 0xBC #define MAPSEC_LIPTOO_CHAMBER 0xBD #define MAPSEC_WEEPTH_CHAMBER 0xBE @@ -201,7 +201,7 @@ #define MAPSEC_AQUA_HIDEOUT 0xC5 #define MAPSEC_MAGMA_HIDEOUT 0xC6 #define MAPSEC_MIRAGE_TOWER 0xC7 -#define MAPSEC_BIRTH_ISLAND_2 0xC8 +#define MAPSEC_BIRTH_ISLAND 0xC8 #define MAPSEC_FARAWAY_ISLAND 0xC9 #define MAPSEC_ARTISAN_CAVE 0xCA #define MAPSEC_MARINE_CAVE 0xCB @@ -211,8 +211,8 @@ #define MAPSEC_UNDERWATER_UNK1 0xCF #define MAPSEC_UNDERWATER_129 0xD0 #define MAPSEC_DESERT_UNDERPASS 0xD1 -#define MAPSEC_ALTERING_CAVE_2 0xD2 -#define MAPSEC_NAVEL_ROCK2 0xD3 +#define MAPSEC_ALTERING_CAVE 0xD2 +#define MAPSEC_NAVEL_ROCK 0xD3 #define MAPSEC_TRAINER_HILL 0xD4 #define MAPSEC_NONE 0xD5 diff --git a/include/constants/weather.h b/include/constants/weather.h index 98a0a2e1e..aa0309882 100644 --- a/include/constants/weather.h +++ b/include/constants/weather.h @@ -39,28 +39,31 @@ // These are the "abnormal weather events" that are used // to find Kyogre and Groudon. -#define ABNORMAL_WEATHER_COUNT_PER_LEGENDARY 8 -#define ABNORMAL_WEATHER_GROUDON_LOCATIONS_START 1 -#define ABNORMAL_WEATHER_KYOGRE_LOCATIONS_START 1 + ABNORMAL_WEATHER_COUNT_PER_LEGENDARY +#define ABNORMAL_WEATHER_LOCATIONS (MARINE_CAVE_LOCATIONS + TERRA_CAVE_LOCATIONS) +#define ABNORMAL_WEATHER_NONE 0 -#define ABNORMAL_WEATHER_NONE 0 -// Groudon locations -#define ABNORMAL_WEATHER_ROUTE_114_NORTH 1 -#define ABNORMAL_WEATHER_ROUTE_114_SOUTH 2 -#define ABNORMAL_WEATHER_ROUTE_115_WEST 3 -#define ABNORMAL_WEATHER_ROUTE_115_EAST 4 -#define ABNORMAL_WEATHER_ROUTE_116_NORTH 5 -#define ABNORMAL_WEATHER_ROUTE_116_SOUTH 6 -#define ABNORMAL_WEATHER_ROUTE_118_EAST 7 -#define ABNORMAL_WEATHER_ROUTE_118_WEST 8 -// Kyogre locations -#define ABNORMAL_WEATHER_ROUTE_105_NORTH 9 -#define ABNORMAL_WEATHER_ROUTE_105_SOUTH 10 -#define ABNORMAL_WEATHER_ROUTE_125_WEST 11 -#define ABNORMAL_WEATHER_ROUTE_125_EAST 12 -#define ABNORMAL_WEATHER_ROUTE_127_NORTH 13 -#define ABNORMAL_WEATHER_ROUTE_127_SOUTH 14 -#define ABNORMAL_WEATHER_ROUTE_129_WEST 15 -#define ABNORMAL_WEATHER_ROUTE_129_EAST 16 +// Groudon/Terra Cave locations +#define TERRA_CAVE_LOCATIONS_START 1 +#define ABNORMAL_WEATHER_ROUTE_114_NORTH (TERRA_CAVE_LOCATIONS_START + 0) +#define ABNORMAL_WEATHER_ROUTE_114_SOUTH (TERRA_CAVE_LOCATIONS_START + 1) +#define ABNORMAL_WEATHER_ROUTE_115_WEST (TERRA_CAVE_LOCATIONS_START + 2) +#define ABNORMAL_WEATHER_ROUTE_115_EAST (TERRA_CAVE_LOCATIONS_START + 3) +#define ABNORMAL_WEATHER_ROUTE_116_NORTH (TERRA_CAVE_LOCATIONS_START + 4) +#define ABNORMAL_WEATHER_ROUTE_116_SOUTH (TERRA_CAVE_LOCATIONS_START + 5) +#define ABNORMAL_WEATHER_ROUTE_118_EAST (TERRA_CAVE_LOCATIONS_START + 6) +#define ABNORMAL_WEATHER_ROUTE_118_WEST (TERRA_CAVE_LOCATIONS_START + 7) +#define TERRA_CAVE_LOCATIONS 8 + +// Kyogre/Marina Cave locations +#define MARINE_CAVE_LOCATIONS_START (TERRA_CAVE_LOCATIONS_START + TERRA_CAVE_LOCATIONS) +#define ABNORMAL_WEATHER_ROUTE_105_NORTH (MARINE_CAVE_LOCATIONS_START + 0) +#define ABNORMAL_WEATHER_ROUTE_105_SOUTH (MARINE_CAVE_LOCATIONS_START + 1) +#define ABNORMAL_WEATHER_ROUTE_125_WEST (MARINE_CAVE_LOCATIONS_START + 2) +#define ABNORMAL_WEATHER_ROUTE_125_EAST (MARINE_CAVE_LOCATIONS_START + 3) +#define ABNORMAL_WEATHER_ROUTE_127_NORTH (MARINE_CAVE_LOCATIONS_START + 4) +#define ABNORMAL_WEATHER_ROUTE_127_SOUTH (MARINE_CAVE_LOCATIONS_START + 5) +#define ABNORMAL_WEATHER_ROUTE_129_WEST (MARINE_CAVE_LOCATIONS_START + 6) +#define ABNORMAL_WEATHER_ROUTE_129_EAST (MARINE_CAVE_LOCATIONS_START + 7) +#define MARINE_CAVE_LOCATIONS 8 #endif // GUARD_CONSTANTS_WEATHER_H diff --git a/include/pokedex_area_region_map.h b/include/pokedex_area_region_map.h new file mode 100755 index 000000000..175f60c74 --- /dev/null +++ b/include/pokedex_area_region_map.h @@ -0,0 +1,17 @@ +#ifndef GUARD_POKEDEX_AREA_REGION_MAP_H +#define GUARD_POKEDEX_AREA_REGION_MAP_H + +struct PokedexAreaMapTemplate +{ + u32 bg:2; + u32 offset:8; + u32 mode:2; + u32 unk:20; // never read +}; + +void LoadPokedexAreaMapGfx(const struct PokedexAreaMapTemplate *); +bool32 sub_81C4E90(void); +void PokedexAreaMapChangeBgY(u32); +void FreePokedexAreaMapBgNum(void); + +#endif // GUARD_POKEDEX_AREA_REGION_MAP_H diff --git a/include/pokenav.h b/include/pokenav.h index fe5616618..3eafe9af2 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -65,24 +65,44 @@ enum POKENAV_MODE_FORCE_CALL_EXIT, // Pokenav tutorial after calling Mr. Stone }; +enum +{ + POKENAV_GFX_MAIN_MENU, + POKENAV_GFX_CONDITION_MENU, + POKENAV_GFX_RIBBONS_MENU, + POKENAV_GFX_MATCH_CALL_MENU, + POKENAV_GFX_MAP_MENU_ZOOMED_OUT, + POKENAV_GFX_MAP_MENU_ZOOMED_IN, + POKENAV_GFX_PARTY_MENU, + POKENAV_GFX_SEARCH_MENU, + POKENAV_GFX_COOL_MENU, + POKENAV_GFX_BEAUTY_MENU, + POKENAV_GFX_CUTE_MENU, + POKENAV_GFX_SMART_MENU, + POKENAV_GFX_TOUGH_MENU, + POKENAV_GFX_MENUS_END, +}; + +#define POKENAV_GFX_SUBMENUS_START POKENAV_GFX_PARTY_MENU + #define POKENAV_MENU_IDS_START 100000 enum { - POKENAV_MENU_0 = POKENAV_MENU_IDS_START, - POKENAV_MENU_1, - POKENAV_MENU_2, - POKENAV_MENU_3, - POKENAV_MENU_4, - POKENAV_MENU_5, - POKENAV_MENU_6, - POKENAV_MENU_7, - POKENAV_MENU_8, - POKENAV_MENU_9, - POKENAV_MENU_A, - POKENAV_MENU_B, - POKENAV_MENU_C, - POKENAV_MENU_D, - POKENAV_MENU_E, + POKENAV_MAIN_MENU = POKENAV_MENU_IDS_START, + POKENAV_MAIN_MENU_CURSOR_ON_MAP, + POKENAV_CONDITION_MENU, + POKENAV_CONDITION_SEARCH_MENU, + POKENAV_MAIN_MENU_CURSOR_ON_MATCH_CALL, + POKENAV_MAIN_MENU_CURSOR_ON_RIBBONS, + POKENAV_REGION_MAP, + POKENAV_CONDITION_PARTY, + POKENAV_CONDITION_SEARCH_RESULTS, + POKENAV_MENU_9, // Condition + POKENAV_MENU_A, // Condition + POKENAV_MATCH_CALL, + POKENAV_RIBBONS_MON_LIST, + POKENAV_MENU_D, // Ribbons + POKENAV_MENU_E, // Ribbons }; enum @@ -220,6 +240,15 @@ enum POKENAV_MC_FUNC_EXIT }; +enum +{ + POKENAV_MAP_FUNC_NONE, + POKENAV_MAP_FUNC_CURSOR_MOVED, + POKENAV_MAP_FUNC_ZOOM_OUT, + POKENAV_MAP_FUNC_ZOOM_IN, + POKENAV_MAP_FUNC_EXIT, +}; + // pokenav.c void SetSelectedConditionSearch(u32); u32 GetSelectedConditionSearch(void); @@ -275,7 +304,7 @@ void sub_81C7850(u32 a0); u32 sub_81C786C(void); void LoadLeftHeaderGfxForIndex(u32 arg0); void sub_81C7FA0(u32 arg0, bool32 arg1, bool32 arg2); -void sub_81C7AC0(s32 a0); +void PokenavFadeScreen(s32 fadeType); bool32 sub_81C8010(void); void InitBgTemplates(const struct BgTemplate *templates, int count); bool32 IsPaletteFadeActive(void); @@ -298,30 +327,30 @@ void sub_81C7834(void *func1, void *func2); void ShutdownPokenav(void); // pokenav_menu_handler_1.c -bool32 PokenavCallback_Init_0(void); -bool32 PokenavCallback_Init_4(void); -bool32 PokenavCallback_Init_5(void); -bool32 PokenavCallback_Init_2(void); -bool32 PokenavCallback_Init_3(void); -u32 sub_81C941C(void); -void sub_81C9430(void); +bool32 PokenavCallback_Init_MainMenuCursorOnMap(void); +bool32 PokenavCallback_Init_MainMenuCursorOnMatchCall(void); +bool32 PokenavCallback_Init_MainMenuCursorOnRibbons(void); +bool32 PokenavCallback_Init_ConditionMenu(void); +bool32 PokenavCallback_Init_ConditionSearchMenu(void); +u32 GetMenuHandlerCallback(void); +void FreeMenuHandlerSubstruct1(void); int GetPokenavMenuType(void); int GetPokenavCursorPos(void); int GetCurrentMenuItemId(void); u16 GetHelpBarTextId(void); // pokenav_menu_handler_2.c -bool32 sub_81C9924(void); -bool32 sub_81C9940(void); +bool32 OpenPokenavMenuInitial(void); +bool32 OpenPokenavMenuNotInitial(void); void CreateMenuHandlerLoopedTask(s32 ltIdx); -bool32 sub_81C99C0(void); -void sub_81C99D4(void); +bool32 IsMenuHandlerLoopedTaskActive(void); +void FreeMenuHandlerSubstruct2(void); void sub_81CAADC(void); // pokenav_match_call_1.c -bool32 PokenavCallback_Init_11(void); -u32 sub_81CAB24(void); -void sub_81CAB38(void); +bool32 PokenavCallback_Init_MatchCall(void); +u32 GetMatchCallCallback(void); +void FreeMatchCallSubstruct1(void); int sub_81CAE28(void); int GetNumberRegistered(void); int sub_81CAE48(void); @@ -341,19 +370,19 @@ int GetIndexDeltaOfNextCheckPageUp(int index); bool32 IsRematchEntryRegistered(int index); // pokenav_match_call_2.c -bool32 sub_81CB260(void); +bool32 OpenMatchCall(void); void CreateMatchCallLoopedTask(s32 index); -u32 sub_81CB2CC(void); -void sub_81CB2E0(void); +bool32 IsMatchCallLoopedTaskActive(void); +void FreeMatchCallSubstruct2(void); // pokenav_region_map.c -u32 PokenavCallback_Init_6(void); -void sub_81CC524(void); -u32 sub_81CC554(void); -bool32 sub_81CC5F4(void); -void sub_81CC62C(s32); -u32 sub_81CC65C(void); -void sub_81CC670(void); +u32 PokenavCallback_Init_RegionMap(void); +u32 GetRegionMapCallback(void); +bool32 OpenPokenavRegionMap(void); +void CreateRegionMapLoopedTask(s32); +bool32 IsRegionMapLoopedTaskActive(void); +void FreeRegionMapSubstruct1(void); +void FreeRegionMapSubstruct2(void); // pokenav_conditions_1.c u32 PokenavCallback_Init_7(void); diff --git a/include/region_map.h b/include/region_map.h index 0d219643d..97364abd8 100644 --- a/include/region_map.h +++ b/include/region_map.h @@ -4,20 +4,21 @@ #include "bg.h" // Exported type declarations +#define MAP_NAME_LENGTH 16 enum { - INPUT_EVENT_NONE, - INPUT_EVENT_MOVE_START, - INPUT_EVENT_MOVE_CONT, - INPUT_EVENT_MOVE_END, - INPUT_EVENT_A_BUTTON, - INPUT_EVENT_B_BUTTON, + MAP_INPUT_NONE, + MAP_INPUT_MOVE_START, + MAP_INPUT_MOVE_CONT, + MAP_INPUT_MOVE_END, + MAP_INPUT_A_BUTTON, + MAP_INPUT_B_BUTTON, }; enum { MAPSECTYPE_NONE, - MAPSECTYPE_PLAIN, + MAPSECTYPE_ROUTE, MAPSECTYPE_CITY_CANFLY, MAPSECTYPE_CITY_CANTFLY, MAPSECTYPE_BATTLE_FRONTIER @@ -25,9 +26,9 @@ enum { struct RegionMap { /*0x000*/ u16 mapSecId; - /*0x002*/ u8 iconDrawType; + /*0x002*/ u8 mapSecType; /*0x003*/ u8 posWithinMapSec; - /*0x004*/ u8 mapSecName[0x14]; + /*0x004*/ u8 mapSecName[20]; /*0x018*/ u8 (*inputCallback)(void); /*0x01c*/ struct Sprite *cursorSprite; /*0x020*/ struct Sprite *playerIconSprite; @@ -90,28 +91,28 @@ struct RegionMapLocation // Exported RAM declarations // Exported ROM declarations -void sub_8122CF8(struct RegionMap *regionMap, const struct BgTemplate *template, bool8 zoomed); -bool8 sub_8122DB0(void); +void InitRegionMapData(struct RegionMap *regionMap, const struct BgTemplate *template, bool8 zoomed); +bool8 LoadRegionMapGfx(void); void UpdateRegionMapVideoRegs(void); void InitRegionMap(struct RegionMap *regionMap, u8 argument); -u8 sub_81230AC(void); -bool8 sub_8123514(void); +u8 DoRegionMapInputCallback(void); +bool8 UpdateRegionMapZoom(void); void FreeRegionMapIconResources(void); -u16 GetRegionMapSectionIdAt(u16 x, u16 y); +u16 GetRegionMapSecIdAt(u16 x, u16 y); void CreateRegionMapPlayerIcon(u16 x, u16 y); void CreateRegionMapCursor(u16 tileTag, u16 paletteTag); +bool32 IsEventIslandMapSecId(u8 mapSecId); u8 *GetMapName(u8 *, u16, u16); -bool32 sub_8124668(u8 mapSecId); u8 *GetMapNameGeneric(u8 *dest, u16 mapSecId); -u8 *sub_8124610(u8 *dest, u16 mapSecId); +u8 *GetMapNameHandleAquaHideout(u8 *dest, u16 mapSecId); u16 CorrectSpecialMapSecId(u16 mapSecId); -void sub_8122D88(struct RegionMap *regionMap); +void ShowRegionMapForPokedexAreaScreen(struct RegionMap *regionMap); void PokedexAreaScreen_UpdateRegionMapVariablesAndVideoRegs(s16 x, s16 y); -void MCB2_FlyMap(void); -bool8 sub_8124658(void); -void sub_812454C(void); -void sub_8123030(u16 a0, u32 a1); -void sub_8123418(void); +void CB2_OpenFlyMap(void); +bool8 IsRegionMapZoomed(void); +void TrySetPlayerIconBlink(void); +void sub_8123030(u16 color, u32 coeff); +void SetRegionMapDataForZoom(void); extern const struct RegionMapLocation gRegionMapEntries[]; diff --git a/include/unk_pokedex_area_screen_helper.h b/include/unk_pokedex_area_screen_helper.h deleted file mode 100755 index 45beed70e..000000000 --- a/include/unk_pokedex_area_screen_helper.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef GUARD_UNK_POKEDEX_AREA_SCREEN_HELPER_H -#define GUARD_UNK_POKEDEX_AREA_SCREEN_HELPER_H - -struct UnkStruct_1C4D70 -{ - u32 bg:2; - u32 unk2:8; - u32 unk10:2; - u32 unk12:20; -}; - -void sub_81C4D70(const struct UnkStruct_1C4D70 *); -bool32 sub_81C4E90(void); -void sub_81C4ED0(u32); -void sub_81C4EB4(void); - -#endif // GUARD_UNK_POKEDEX_AREA_SCREEN_HELPER_H diff --git a/ld_script.txt b/ld_script.txt index a4f2bc3dc..5ce484d08 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -302,7 +302,7 @@ SECTIONS { src/mirage_tower.o(.text); src/berry_fix_program.o(.text); src/pokemon_summary_screen.o(.text); - src/unk_pokedex_area_screen_helper.o(.text); + src/pokedex_area_region_map.o(.text); src/battle_pyramid_bag.o(.text); src/pokenav.o(.text); src/pokenav_main_menu.o(.text); @@ -659,7 +659,7 @@ SECTIONS { src/mirage_tower.o(.rodata); src/berry_fix_program.o(.rodata); src/pokemon_summary_screen.o(.rodata); - src/unk_pokedex_area_screen_helper.o(.rodata); + src/pokedex_area_region_map.o(.rodata); src/battle_pyramid_bag.o(.rodata); src/pokenav.o(.rodata); src/pokenav_main_menu.o(.rodata); diff --git a/src/data/region_map/city_map_entries.h b/src/data/region_map/city_map_entries.h index 7b8361a7c..09689da5b 100644 --- a/src/data/region_map/city_map_entries.h +++ b/src/data/region_map/city_map_entries.h @@ -1,112 +1,112 @@ -const struct CityMapEntry gPokenavCityMaps[] = +static const struct CityMapEntry sPokenavCityMaps[NUM_CITY_MAPS] = { { - .mapSecId = 0, + .mapSecId = MAPSEC_LITTLEROOT_TOWN, .index = 0, .tilemap = gPokenavCityMap_Littleroot_0, }, { - .mapSecId = 1, + .mapSecId = MAPSEC_OLDALE_TOWN, .index = 0, .tilemap = gPokenavCityMap_Oldale_0, }, { - .mapSecId = 2, + .mapSecId = MAPSEC_DEWFORD_TOWN, .index = 0, .tilemap = gPokenavCityMap_Dewford_0, }, { - .mapSecId = 3, + .mapSecId = MAPSEC_LAVARIDGE_TOWN, .index = 0, .tilemap = gPokenavCityMap_Lavarige_0, }, { - .mapSecId = 4, + .mapSecId = MAPSEC_FALLARBOR_TOWN, .index = 0, .tilemap = gPokenavCityMap_Fallarbor_0, }, { - .mapSecId = 5, + .mapSecId = MAPSEC_VERDANTURF_TOWN, .index = 0, .tilemap = gPokenavCityMap_Verdanturf_0, }, { - .mapSecId = 6, + .mapSecId = MAPSEC_PACIFIDLOG_TOWN, .index = 0, .tilemap = gPokenavCityMap_Pacifidlog_0, }, { - .mapSecId = 7, + .mapSecId = MAPSEC_PETALBURG_CITY, .index = 0, .tilemap = gPokenavCityMap_Petalburg_0, }, { - .mapSecId = 8, + .mapSecId = MAPSEC_SLATEPORT_CITY, .index = 0, .tilemap = gPokenavCityMap_Slateport_0, }, { - .mapSecId = 8, + .mapSecId = MAPSEC_SLATEPORT_CITY, .index = 1, .tilemap = gPokenavCityMap_Slateport_1, }, { - .mapSecId = 9, + .mapSecId = MAPSEC_MAUVILLE_CITY, .index = 0, .tilemap = gPokenavCityMap_Mauville_0, }, { - .mapSecId = 9, + .mapSecId = MAPSEC_MAUVILLE_CITY, .index = 1, .tilemap = gPokenavCityMap_Mauville_1, }, { - .mapSecId = 10, + .mapSecId = MAPSEC_RUSTBORO_CITY, .index = 0, .tilemap = gPokenavCityMap_Rustboro_0, }, { - .mapSecId = 10, + .mapSecId = MAPSEC_RUSTBORO_CITY, .index = 1, .tilemap = gPokenavCityMap_Rustboro_1, }, { - .mapSecId = 11, + .mapSecId = MAPSEC_FORTREE_CITY, .index = 0, .tilemap = gPokenavCityMap_Fortree_0, }, { - .mapSecId = 12, + .mapSecId = MAPSEC_LILYCOVE_CITY, .index = 0, .tilemap = gPokenavCityMap_Lilycove_0, }, { - .mapSecId = 12, + .mapSecId = MAPSEC_LILYCOVE_CITY, .index = 1, .tilemap = gPokenavCityMap_Lilycove_1, }, { - .mapSecId = 13, + .mapSecId = MAPSEC_MOSSDEEP_CITY, .index = 0, .tilemap = gPokenavCityMap_Mossdeep_0, }, { - .mapSecId = 13, + .mapSecId = MAPSEC_MOSSDEEP_CITY, .index = 1, .tilemap = gPokenavCityMap_Mossdeep_1, }, { - .mapSecId = 14, + .mapSecId = MAPSEC_SOOTOPOLIS_CITY, .index = 0, .tilemap = gPokenavCityMap_Sootopolis_0, }, { - .mapSecId = 15, + .mapSecId = MAPSEC_EVER_GRANDE_CITY, .index = 0, .tilemap = gPokenavCityMap_EverGrande_0, }, { - .mapSecId = 15, + .mapSecId = MAPSEC_EVER_GRANDE_CITY, .index = 1, .tilemap = gPokenavCityMap_EverGrande_1, }, diff --git a/src/data/region_map/region_map_entries.h b/src/data/region_map/region_map_entries.h index b2d625c84..1d503d72f 100644 --- a/src/data/region_map/region_map_entries.h +++ b/src/data/region_map/region_map_entries.h @@ -374,7 +374,7 @@ const struct RegionMapLocation gRegionMapEntries[] = { [MAPSEC_SEVII_ISLE_22] = { 0, 0, 1, 1, sMapName_SeviiIsle22}, [MAPSEC_SEVII_ISLE_23] = { 0, 0, 1, 1, sMapName_SeviiIsle23}, [MAPSEC_SEVII_ISLE_24] = { 0, 0, 1, 1, sMapName_SeviiIsle24}, - [MAPSEC_NAVEL_ROCK] = { 0, 0, 1, 1, sMapName_NavelRock}, + [MAPSEC_NAVEL_ROCK_FRLG] = { 0, 0, 1, 1, sMapName_NavelRock}, [MAPSEC_MT_EMBER] = { 0, 0, 1, 1, sMapName_MtEmber}, [MAPSEC_BERRY_FOREST] = { 0, 0, 1, 1, sMapName_BerryForest}, [MAPSEC_ICEFALL_CAVE] = { 0, 0, 1, 1, sMapName_IcefallCave}, @@ -383,11 +383,11 @@ const struct RegionMapLocation gRegionMapEntries[] = { [MAPSEC_DOTTED_HOLE] = { 0, 0, 1, 1, sMapName_DottedHole}, [MAPSEC_LOST_CAVE] = { 0, 0, 1, 1, sMapName_LostCave}, [MAPSEC_PATTERN_BUSH] = { 0, 0, 1, 1, sMapName_PatternBush}, - [MAPSEC_ALTERING_CAVE] = { 0, 0, 1, 1, sMapName_AlteringCave}, + [MAPSEC_ALTERING_CAVE_FRLG] = { 0, 0, 1, 1, sMapName_AlteringCave}, [MAPSEC_TANOBY_CHAMBERS] = { 0, 0, 1, 1, sMapName_TanobyChambers}, [MAPSEC_THREE_ISLE_PATH] = { 0, 0, 1, 1, sMapName_ThreeIslePath}, [MAPSEC_TANOBY_KEY] = { 0, 0, 1, 1, sMapName_TanobyKey}, - [MAPSEC_BIRTH_ISLAND] = { 0, 0, 1, 1, sMapName_BirthIsland}, + [MAPSEC_BIRTH_ISLAND_FRLG] = { 0, 0, 1, 1, sMapName_BirthIsland}, [MAPSEC_MONEAN_CHAMBER] = { 0, 0, 1, 1, sMapName_MoneanChamber}, [MAPSEC_LIPTOO_CHAMBER] = { 0, 0, 1, 1, sMapName_LiptooChamber}, [MAPSEC_WEEPTH_CHAMBER] = { 0, 0, 1, 1, sMapName_WeepthChamber}, @@ -400,7 +400,7 @@ const struct RegionMapLocation gRegionMapEntries[] = { [MAPSEC_AQUA_HIDEOUT] = {19, 3, 1, 1, sMapName_AquaHideout}, [MAPSEC_MAGMA_HIDEOUT] = { 6, 3, 1, 1, sMapName_MagmaHideout}, [MAPSEC_MIRAGE_TOWER] = { 8, 2, 1, 1, sMapName_MirageTower}, - [MAPSEC_BIRTH_ISLAND_2] = { 0, 0, 1, 1, sMapName_BirthIsland}, + [MAPSEC_BIRTH_ISLAND] = { 0, 0, 1, 1, sMapName_BirthIsland}, [MAPSEC_FARAWAY_ISLAND] = { 0, 0, 1, 1, sMapName_FarawayIsland}, [MAPSEC_ARTISAN_CAVE] = {22, 12, 1, 1, sMapName_ArtisanCave}, [MAPSEC_MARINE_CAVE] = { 0, 0, 1, 1, sMapName_MarineCave}, @@ -410,8 +410,8 @@ const struct RegionMapLocation gRegionMapEntries[] = { [MAPSEC_UNDERWATER_UNK1] = {24, 3, 2, 2, sMapName_Underwater}, [MAPSEC_UNDERWATER_129] = {24, 10, 2, 1, sMapName_Underwater}, [MAPSEC_DESERT_UNDERPASS] = { 2, 0, 1, 1, sMapName_DesertUnderpass}, - [MAPSEC_ALTERING_CAVE_2] = { 6, 8, 1, 1, sMapName_AlteringCave}, - [MAPSEC_NAVEL_ROCK2] = { 0, 0, 1, 1, sMapName_NavelRock}, + [MAPSEC_ALTERING_CAVE] = { 6, 8, 1, 1, sMapName_AlteringCave}, + [MAPSEC_NAVEL_ROCK] = { 0, 0, 1, 1, sMapName_NavelRock}, [MAPSEC_TRAINER_HILL] = { 8, 4, 1, 1, sMapName_TrainerHill} }; diff --git a/src/field_region_map.c b/src/field_region_map.c index 184c49b40..50d2b5a8e 100644 --- a/src/field_region_map.c +++ b/src/field_region_map.c @@ -13,13 +13,23 @@ #include "window.h" #include "constants/rgb.h" +/* + * This is the type of map shown when interacting with the metatiles for + * a wall-mounted Region Map (on the wall of the Pokemon Centers near the PC) + * It does not zoom, and pressing A or B closes the map + * + * For the region map in the pokenav, see pokenav_region_map.c + * For the region map in the pokedex, see pokdex_area_screen.c/pokedex_area_region_map.c + * For the fly map, and utility functions all of the maps use, see region_map.c + */ + // Static type declarations // Static RAM declarations static EWRAM_DATA struct { MainCallback callback; - u32 filler_004; + u32 unused; struct RegionMap regionMap; u16 state; } *sFieldRegionMapHandler = NULL; @@ -34,7 +44,7 @@ static void PrintRegionMapSecName(void); // .rodata -static const struct BgTemplate gUnknown_085E5068[] = { +static const struct BgTemplate sFieldRegionMapBgTemplates[] = { { .bg = 0, .charBaseIndex = 0, @@ -54,7 +64,7 @@ static const struct BgTemplate gUnknown_085E5068[] = { } }; -static const struct WindowTemplate gUnknown_085E5070[] = +static const struct WindowTemplate sFieldRegionMapWindowTemplates[] = { { .bg = 0, @@ -102,8 +112,8 @@ static void MCB2_InitRegionMapRegisters(void) ResetSpriteData(); FreeAllSpritePalettes(); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(1, gUnknown_085E5068, 2); - InitWindows(gUnknown_085E5070); + InitBgsFromTemplates(1, sFieldRegionMapBgTemplates, 2); + InitWindows(sFieldRegionMapWindowTemplates); DeactivateAllTextPrinters(); LoadUserWindowBorderGfx(0, 0x27, 0xd0); clear_scheduled_bg_copies_to_vram(); @@ -134,7 +144,7 @@ static void FieldUpdateRegionMap(void) switch (sFieldRegionMapHandler->state) { case 0: - InitRegionMap(&sFieldRegionMapHandler->regionMap, 0); + InitRegionMap(&sFieldRegionMapHandler->regionMap, FALSE); CreateRegionMapPlayerIcon(0, 0); CreateRegionMapCursor(1, 1); sFieldRegionMapHandler->state++; @@ -162,13 +172,13 @@ static void FieldUpdateRegionMap(void) } break; case 4: - switch (sub_81230AC()) + switch (DoRegionMapInputCallback()) { - case INPUT_EVENT_MOVE_END: + case MAP_INPUT_MOVE_END: PrintRegionMapSecName(); break; - case INPUT_EVENT_A_BUTTON: - case INPUT_EVENT_B_BUTTON: + case MAP_INPUT_A_BUTTON: + case MAP_INPUT_B_BUTTON: sFieldRegionMapHandler->state++; break; } @@ -184,8 +194,7 @@ static void FieldUpdateRegionMap(void) SetMainCallback2(sFieldRegionMapHandler->callback); if (sFieldRegionMapHandler != NULL) { - free(sFieldRegionMapHandler); - sFieldRegionMapHandler = NULL; + FREE_AND_SET_NULL(sFieldRegionMapHandler); } FreeAllWindowBuffers(); } @@ -195,7 +204,7 @@ static void FieldUpdateRegionMap(void) static void PrintRegionMapSecName(void) { - if (sFieldRegionMapHandler->regionMap.iconDrawType != MAPSECTYPE_NONE) + if (sFieldRegionMapHandler->regionMap.mapSecType != MAPSECTYPE_NONE) { FillWindowPixelBuffer(0, PIXEL_FILL(1)); AddTextPrinterParameterized(0, 1, sFieldRegionMapHandler->regionMap.mapSecName, 0, 1, 0, NULL); diff --git a/src/field_specials.c b/src/field_specials.c index ce3ccce95..701a03c32 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -3550,21 +3550,21 @@ void CreateAbnormalWeatherEvent(void) if (FlagGet(FLAG_DEFEATED_KYOGRE) == TRUE) { - VarSet(VAR_ABNORMAL_WEATHER_LOCATION, (randomValue % ABNORMAL_WEATHER_COUNT_PER_LEGENDARY) + ABNORMAL_WEATHER_GROUDON_LOCATIONS_START); + VarSet(VAR_ABNORMAL_WEATHER_LOCATION, (randomValue % TERRA_CAVE_LOCATIONS) + TERRA_CAVE_LOCATIONS_START); } else if (FlagGet(FLAG_DEFEATED_GROUDON) == TRUE) { - VarSet(VAR_ABNORMAL_WEATHER_LOCATION, (randomValue % ABNORMAL_WEATHER_COUNT_PER_LEGENDARY) + ABNORMAL_WEATHER_KYOGRE_LOCATIONS_START); + VarSet(VAR_ABNORMAL_WEATHER_LOCATION, (randomValue % MARINE_CAVE_LOCATIONS) + MARINE_CAVE_LOCATIONS_START); } else if ((randomValue & 1) == 0) { randomValue = Random(); - VarSet(VAR_ABNORMAL_WEATHER_LOCATION, (randomValue % ABNORMAL_WEATHER_COUNT_PER_LEGENDARY) + ABNORMAL_WEATHER_GROUDON_LOCATIONS_START); + VarSet(VAR_ABNORMAL_WEATHER_LOCATION, (randomValue % TERRA_CAVE_LOCATIONS) + TERRA_CAVE_LOCATIONS_START); } else { randomValue = Random(); - VarSet(VAR_ABNORMAL_WEATHER_LOCATION, (randomValue % ABNORMAL_WEATHER_COUNT_PER_LEGENDARY) + ABNORMAL_WEATHER_KYOGRE_LOCATIONS_START); + VarSet(VAR_ABNORMAL_WEATHER_LOCATION, (randomValue % MARINE_CAVE_LOCATIONS) + MARINE_CAVE_LOCATIONS_START); } } @@ -3595,14 +3595,10 @@ bool32 GetAbnormalWeatherMapNameAndType(void) GetMapName(gStringVar1, sAbnormalWeatherMapNumbers[abnormalWeather - 1], 0); - if (abnormalWeather < ABNORMAL_WEATHER_KYOGRE_LOCATIONS_START) - { + if (abnormalWeather < MARINE_CAVE_LOCATIONS_START) return FALSE; - } else - { return TRUE; - } } bool8 AbnormalWeatherHasExpired(void) diff --git a/src/graphics.c b/src/graphics.c index eeeba56c9..82d6701ef 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1355,8 +1355,8 @@ const u16 gPokenavMessageBox_Pal[] = INCBIN_U16("graphics/pokenav/message.gbapal const u32 gPokenavMessageBox_Gfx[] = INCBIN_U32("graphics/pokenav/message.4bpp.lz"); const u32 gPokenavMessageBox_Tilemap[] = INCBIN_U32("graphics/pokenav/message.bin.lz"); -const u16 gHoennMapZoomIcons_Pal[] = INCBIN_U16("graphics/pokenav/zoom_tiles.gbapal"); -const u32 gHoennMapZoomIcons_Gfx[] = INCBIN_U32("graphics/pokenav/zoom.4bpp.lz"); +const u16 gRegionMapCityZoomTiles_Pal[] = INCBIN_U16("graphics/pokenav/city_zoom_tiles.gbapal"); +const u32 gRegionMapCityZoomText_Gfx[] = INCBIN_U32("graphics/pokenav/city_zoom_text.4bpp.lz"); const u16 gPokenavConditionCancel_Pal[] = INCBIN_U16("graphics/pokenav/cancel.gbapal"); const u8 gPokenavConditionCancel_Gfx[] = INCBIN_U8("graphics/pokenav/cancel.4bpp"); diff --git a/src/map_name_popup.c b/src/map_name_popup.c index b84489a17..35110581f 100644 --- a/src/map_name_popup.c +++ b/src/map_name_popup.c @@ -161,7 +161,7 @@ static const u8 gRegionMapSectionId_To_PopUpThemeIdMapping[] = [MAPSEC_AQUA_HIDEOUT - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_STONE, [MAPSEC_MAGMA_HIDEOUT - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_STONE, [MAPSEC_MIRAGE_TOWER - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_STONE, - [MAPSEC_BIRTH_ISLAND_2 - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_WOOD, + [MAPSEC_BIRTH_ISLAND - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_WOOD, [MAPSEC_FARAWAY_ISLAND - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_WOOD, [MAPSEC_ARTISAN_CAVE - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_STONE, [MAPSEC_MARINE_CAVE - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_STONE, @@ -171,8 +171,8 @@ static const u8 gRegionMapSectionId_To_PopUpThemeIdMapping[] = [MAPSEC_UNDERWATER_UNK1 - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_STONE2, [MAPSEC_UNDERWATER_129 - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_STONE2, [MAPSEC_DESERT_UNDERPASS - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_STONE, - [MAPSEC_ALTERING_CAVE_2 - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_STONE, - [MAPSEC_NAVEL_ROCK2 - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_STONE, + [MAPSEC_ALTERING_CAVE - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_STONE, + [MAPSEC_NAVEL_ROCK - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_STONE, [MAPSEC_TRAINER_HILL - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_MARBLE }; diff --git a/src/party_menu.c b/src/party_menu.c index 4decdeb02..d0eaa42fd 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -3680,7 +3680,7 @@ static void CursorCb_FieldMove(u8 taskId) sPartyMenuInternal->data[0] = fieldMove; break; case FIELD_MOVE_FLY: - gPartyMenu.exitCallback = MCB2_FlyMap; + gPartyMenu.exitCallback = CB2_OpenFlyMap; Task_ClosePartyMenu(taskId); break; default: diff --git a/src/pokedex_area_region_map.c b/src/pokedex_area_region_map.c new file mode 100644 index 000000000..dfea9ea44 --- /dev/null +++ b/src/pokedex_area_region_map.c @@ -0,0 +1,66 @@ +#include "global.h" +#include "main.h" +#include "menu.h" +#include "bg.h" +#include "malloc.h" +#include "palette.h" +#include "pokedex_area_region_map.h" + +static EWRAM_DATA u8 *sPokedexAreaMapBgNum = NULL; + +static const u16 sPokedexAreaMap_Pal[] = INCBIN_U16("graphics/interface/region_map.gbapal"); +static const u32 sPokedexAreaMap_Gfx[] = INCBIN_U32("graphics/interface/region_map.8bpp.lz"); +static const u32 sPokedexAreaMap_Tilemap[] = INCBIN_U32("graphics/interface/region_map.bin.lz"); +static const u32 sPokedexAreaMapAffine_Gfx[] = INCBIN_U32("graphics/interface/region_map_affine.8bpp.lz"); +static const u32 sPokedexAreaMapAffine_Tilemap[] = INCBIN_U32("graphics/interface/region_map_affine.bin.lz"); + +void LoadPokedexAreaMapGfx(const struct PokedexAreaMapTemplate *template) +{ + u8 mode; + sPokedexAreaMapBgNum = Alloc(4); + mode = template->mode; + + if (mode == 0) + { + SetBgAttribute(template->bg, BG_ATTR_METRIC, 0); + decompress_and_copy_tile_data_to_vram(template->bg, sPokedexAreaMap_Gfx, 0, template->offset, 0); + sub_8199D3C(decompress_and_copy_tile_data_to_vram(template->bg, sPokedexAreaMap_Tilemap, 0, 0, 1), template->offset, 32, 32, FALSE); + } + else + { + SetBgAttribute(template->bg, BG_ATTR_METRIC, 2); + SetBgAttribute(template->bg, BG_ATTR_TYPE, 1); + decompress_and_copy_tile_data_to_vram(template->bg, sPokedexAreaMapAffine_Gfx, 0, template->offset, 0); + sub_8199D3C(decompress_and_copy_tile_data_to_vram(template->bg, sPokedexAreaMapAffine_Tilemap, 0, 0, 1), template->offset, 64, 64, TRUE); + } + + ChangeBgX(template->bg, 0, 0); + ChangeBgY(template->bg, 0, 0); + SetBgAttribute(template->bg, BG_ATTR_PALETTEMODE, 1); + CpuCopy32(sPokedexAreaMap_Pal, &gPlttBufferUnfaded[0x70], 0x60); + *sPokedexAreaMapBgNum = template->bg; +} + +bool32 sub_81C4E90(void) +{ + if (!free_temp_tile_data_buffers_if_possible()) + { + ShowBg(*sPokedexAreaMapBgNum); + return FALSE; + } + else + { + return TRUE; + } +} + +void FreePokedexAreaMapBgNum(void) +{ + if (sPokedexAreaMapBgNum != NULL) + FREE_AND_SET_NULL(sPokedexAreaMapBgNum); +} + +void PokedexAreaMapChangeBgY(u32 a0) +{ + ChangeBgY(*sPokedexAreaMapBgNum, a0 * 0x100, 0); +} diff --git a/src/pokedex_area_screen.c b/src/pokedex_area_screen.c index 697fdb792..474788357 100755 --- a/src/pokedex_area_screen.c +++ b/src/pokedex_area_screen.c @@ -14,7 +14,7 @@ #include "sound.h" #include "string_util.h" #include "trig.h" -#include "unk_pokedex_area_screen_helper.h" +#include "pokedex_area_region_map.h" #include "wild_encounter.h" #include "constants/maps.h" #include "constants/region_map_sections.h" @@ -113,7 +113,7 @@ static const u16 sLandmarkData[][2] = { {MAPSEC_SKY_PILLAR, FLAG_LANDMARK_SKY_PILLAR}, {MAPSEC_SEAFLOOR_CAVERN, FLAG_LANDMARK_SEAFLOOR_CAVERN}, - {MAPSEC_ALTERING_CAVE_2, FLAG_LANDMARK_ALTERING_CAVE}, + {MAPSEC_ALTERING_CAVE, FLAG_LANDMARK_ALTERING_CAVE}, {MAPSEC_MIRAGE_TOWER, FLAG_LANDMARK_MIRAGE_TOWER}, {MAPSEC_DESERT_UNDERPASS, FLAG_LANDMARK_DESERT_UNDERPASS}, {MAPSEC_ARTISAN_CAVE, FLAG_LANDMARK_ARTISAN_CAVE}, @@ -230,12 +230,12 @@ static const u8 sAreaGlowTilemapMapping[] = { 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, }; -static const struct UnkStruct_1C4D70 sUnknown_085B4018 = +static const struct PokedexAreaMapTemplate sPokedexAreaMapTemplate = { .bg = 3, - .unk2 = 0, - .unk10 = 0, - .unk12 = 2, + .offset = 0, + .mode = 0, + .unk = 2, }; static const u8 sAreaMarkerTiles[]; @@ -456,7 +456,7 @@ static u16 GetRegionMapSectionId(u8 mapGroup, u8 mapNum) static bool8 MapHasMon(const struct WildPokemonHeader *info, u16 species) { - if (GetRegionMapSectionId(info->mapGroup, info->mapNum) == MAPSEC_ALTERING_CAVE_2) + if (GetRegionMapSectionId(info->mapGroup, info->mapNum) == MAPSEC_ALTERING_CAVE) { sPokedexAreaScreen->unk6E2++; if (sPokedexAreaScreen->unk6E2 != sPokedexAreaScreen->unk6E4 + 1) @@ -503,7 +503,7 @@ static void BuildAreaGlowTilemap(void) { for (x = 0; x < AREA_SCREEN_WIDTH; x++) { - if (GetRegionMapSectionIdAt(x, y) == sPokedexAreaScreen->overworldAreasWithMons[i].regionMapSectionId) + if (GetRegionMapSecIdAt(x, y) == sPokedexAreaScreen->overworldAreasWithMons[i].regionMapSectionId) sPokedexAreaScreen->areaGlowTilemap[j] = GLOW_TILE_FULL; j++; @@ -662,13 +662,13 @@ static void Task_PokedexAreaScreen_0(u8 taskId) break; case 1: SetBgAttribute(3, BG_ATTR_CHARBASEINDEX, 3); - sub_81C4D70(&sUnknown_085B4018); + LoadPokedexAreaMapGfx(&sPokedexAreaMapTemplate); StringFill(sPokedexAreaScreen->charBuffer, CHAR_SPACE, 16); break; case 2: if (sub_81C4E90() == TRUE) return; - sub_81C4ED0(-8); + PokedexAreaMapChangeBgY(-8); break; case 3: ResetDrawAreaGlowState(); @@ -678,7 +678,7 @@ static void Task_PokedexAreaScreen_0(u8 taskId) return; break; case 5: - sub_8122D88(&sPokedexAreaScreen->regionMap); + ShowRegionMapForPokedexAreaScreen(&sPokedexAreaScreen->regionMap); CreateRegionMapPlayerIcon(1, 1); PokedexAreaScreen_UpdateRegionMapVariablesAndVideoRegs(0, -8); break; @@ -746,7 +746,7 @@ static void Task_PokedexAreaScreen_1(u8 taskId) sPokedexAreaScreen->errno[0] = gTasks[taskId].data[1]; sub_813D6B4(); DestroyTask(taskId); - sub_81C4EB4(); + FreePokedexAreaMapBgNum(); FREE_AND_SET_NULL(sPokedexAreaScreen); return; } diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index ffd468a9b..81befefc5 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -3095,7 +3095,7 @@ static void BufferMonTrainerMemo(void) if (sum->metLocation < MAPSEC_NONE) { - sub_8124610(metLocationString, sum->metLocation); + GetMapNameHandleAquaHideout(metLocationString, sum->metLocation); DynamicPlaceholderTextUtil_SetPlaceholderPtr(4, metLocationString); } diff --git a/src/pokenav.c b/src/pokenav.c index 03b29ab0b..8ea33575a 100644 --- a/src/pokenav.c +++ b/src/pokenav.c @@ -26,18 +26,18 @@ struct PokenavResources void *field10[SUBSTRUCT_COUNT]; }; -struct UnknownPokenavCallbackStruct +struct PokenavCallbacks { - bool32 (*unk0)(void); - u32 (*unk4)(void); - bool32 (*unk8)(void); - void (*unkC)(s32); - u32 (*unk10)(void); - void (*unk14)(void); - void (*unk18)(void); + bool32 (*init)(void); + u32 (*callback)(void); + bool32 (*open)(void); + void (*createLoopTask)(s32); + bool32 (*isLoopTaskActive)(void); + void (*free1)(void); + void (*free2)(void); }; -static u32 sub_81C75E0(void); +static u32 GetCurrentMenuCB(void); static u32 sub_81C75D4(void); static bool32 SetActivePokenavMenu(u32 menuId); static bool32 AnyMonHasRibbon(void); @@ -51,142 +51,158 @@ static void Task_RunLoopedTask(u8 taskId); static void Task_Pokenav(u8 taskId); static void CB2_InitPokenavForTutorial(void); -const struct UnknownPokenavCallbackStruct PokenavMenuCallbacks[15] = +// TODO: Use MENU ids +const struct PokenavCallbacks PokenavMenuCallbacks[15] = { + [POKENAV_MAIN_MENU - POKENAV_MENU_IDS_START] = { - .unk0 = PokenavCallback_Init_0, - .unk4 = sub_81C941C, - .unk8 = sub_81C9924, - .unkC = CreateMenuHandlerLoopedTask, - .unk10 = sub_81C99C0, - .unk14 = sub_81C9430, - .unk18 = sub_81C99D4, + .init = PokenavCallback_Init_MainMenuCursorOnMap, + .callback = GetMenuHandlerCallback, + .open = OpenPokenavMenuInitial, + .createLoopTask = CreateMenuHandlerLoopedTask, + .isLoopTaskActive = IsMenuHandlerLoopedTaskActive, + .free1 = FreeMenuHandlerSubstruct1, + .free2 = FreeMenuHandlerSubstruct2, }, + [POKENAV_MAIN_MENU_CURSOR_ON_MAP - POKENAV_MENU_IDS_START] = { - .unk0 = PokenavCallback_Init_0, - .unk4 = sub_81C941C, - .unk8 = sub_81C9940, - .unkC = CreateMenuHandlerLoopedTask, - .unk10 = sub_81C99C0, - .unk14 = sub_81C9430, - .unk18 = sub_81C99D4, + .init = PokenavCallback_Init_MainMenuCursorOnMap, + .callback = GetMenuHandlerCallback, + .open = OpenPokenavMenuNotInitial, + .createLoopTask = CreateMenuHandlerLoopedTask, + .isLoopTaskActive = IsMenuHandlerLoopedTaskActive, + .free1 = FreeMenuHandlerSubstruct1, + .free2 = FreeMenuHandlerSubstruct2, }, + [POKENAV_CONDITION_MENU - POKENAV_MENU_IDS_START] = { - .unk0 = PokenavCallback_Init_2, - .unk4 = sub_81C941C, - .unk8 = sub_81C9940, - .unkC = CreateMenuHandlerLoopedTask, - .unk10 = sub_81C99C0, - .unk14 = sub_81C9430, - .unk18 = sub_81C99D4, + .init = PokenavCallback_Init_ConditionMenu, + .callback = GetMenuHandlerCallback, + .open = OpenPokenavMenuNotInitial, + .createLoopTask = CreateMenuHandlerLoopedTask, + .isLoopTaskActive = IsMenuHandlerLoopedTaskActive, + .free1 = FreeMenuHandlerSubstruct1, + .free2 = FreeMenuHandlerSubstruct2, }, + [POKENAV_CONDITION_SEARCH_MENU - POKENAV_MENU_IDS_START] = { - .unk0 = PokenavCallback_Init_3, - .unk4 = sub_81C941C, - .unk8 = sub_81C9940, - .unkC = CreateMenuHandlerLoopedTask, - .unk10 = sub_81C99C0, - .unk14 = sub_81C9430, - .unk18 = sub_81C99D4, + .init = PokenavCallback_Init_ConditionSearchMenu, + .callback = GetMenuHandlerCallback, + .open = OpenPokenavMenuNotInitial, + .createLoopTask = CreateMenuHandlerLoopedTask, + .isLoopTaskActive = IsMenuHandlerLoopedTaskActive, + .free1 = FreeMenuHandlerSubstruct1, + .free2 = FreeMenuHandlerSubstruct2, }, + [POKENAV_MAIN_MENU_CURSOR_ON_MATCH_CALL - POKENAV_MENU_IDS_START] = { - .unk0 = PokenavCallback_Init_4, - .unk4 = sub_81C941C, - .unk8 = sub_81C9940, - .unkC = CreateMenuHandlerLoopedTask, - .unk10 = sub_81C99C0, - .unk14 = sub_81C9430, - .unk18 = sub_81C99D4, + .init = PokenavCallback_Init_MainMenuCursorOnMatchCall, + .callback = GetMenuHandlerCallback, + .open = OpenPokenavMenuNotInitial, + .createLoopTask = CreateMenuHandlerLoopedTask, + .isLoopTaskActive = IsMenuHandlerLoopedTaskActive, + .free1 = FreeMenuHandlerSubstruct1, + .free2 = FreeMenuHandlerSubstruct2, }, + [POKENAV_MAIN_MENU_CURSOR_ON_RIBBONS - POKENAV_MENU_IDS_START] = { - .unk0 = PokenavCallback_Init_5, - .unk4 = sub_81C941C, - .unk8 = sub_81C9940, - .unkC = CreateMenuHandlerLoopedTask, - .unk10 = sub_81C99C0, - .unk14 = sub_81C9430, - .unk18 = sub_81C99D4, + .init = PokenavCallback_Init_MainMenuCursorOnRibbons, + .callback = GetMenuHandlerCallback, + .open = OpenPokenavMenuNotInitial, + .createLoopTask = CreateMenuHandlerLoopedTask, + .isLoopTaskActive = IsMenuHandlerLoopedTaskActive, + .free1 = FreeMenuHandlerSubstruct1, + .free2 = FreeMenuHandlerSubstruct2, }, + [POKENAV_REGION_MAP - POKENAV_MENU_IDS_START] = { - .unk0 = PokenavCallback_Init_6, - .unk4 = sub_81CC554, - .unk8 = sub_81CC5F4, - .unkC = sub_81CC62C, - .unk10 = sub_81CC65C, - .unk14 = sub_81CC524, - .unk18 = sub_81CC670, + .init = PokenavCallback_Init_RegionMap, + .callback = GetRegionMapCallback, + .open = OpenPokenavRegionMap, + .createLoopTask = CreateRegionMapLoopedTask, + .isLoopTaskActive = IsRegionMapLoopedTaskActive, + .free1 = FreeRegionMapSubstruct1, + .free2 = FreeRegionMapSubstruct2, }, + [POKENAV_CONDITION_PARTY - POKENAV_MENU_IDS_START] = { - .unk0 = PokenavCallback_Init_7, - .unk4 = sub_81CD070, - .unk8 = sub_81CDDD4, - .unkC = sub_81CDE2C, - .unk10 = sub_81CDE64, - .unk14 = sub_81CD1C0, - .unk18 = sub_81CECA0, + .init = PokenavCallback_Init_7, + .callback = sub_81CD070, + .open = sub_81CDDD4, + .createLoopTask = sub_81CDE2C, + .isLoopTaskActive = sub_81CDE64, + .free1 = sub_81CD1C0, + .free2 = sub_81CECA0, }, + [POKENAV_CONDITION_SEARCH_RESULTS - POKENAV_MENU_IDS_START] = { - .unk0 = PokenavCallback_Init_8, - .unk4 = sub_81CEFDC, - .unk8 = sub_81CF330, - .unkC = sub_81CF3A0, - .unk10 = sub_81CF3D0, - .unk14 = sub_81CEFF0, - .unk18 = sub_81CF3F8, + .init = PokenavCallback_Init_8, + .callback = sub_81CEFDC, + .open = sub_81CF330, + .createLoopTask = sub_81CF3A0, + .isLoopTaskActive = sub_81CF3D0, + .free1 = sub_81CEFF0, + .free2 = sub_81CF3F8, }, + [POKENAV_MENU_9 - POKENAV_MENU_IDS_START] = { - .unk0 = PokenavCallback_Init_9, - .unk4 = sub_81CD070, - .unk8 = sub_81CDDD4, - .unkC = sub_81CDE2C, - .unk10 = sub_81CDE64, - .unk14 = sub_81CD1C0, - .unk18 = sub_81CECA0, + .init = PokenavCallback_Init_9, + .callback = sub_81CD070, + .open = sub_81CDDD4, + .createLoopTask = sub_81CDE2C, + .isLoopTaskActive = sub_81CDE64, + .free1 = sub_81CD1C0, + .free2 = sub_81CECA0, }, + [POKENAV_MENU_A - POKENAV_MENU_IDS_START] = { - .unk0 = PokenavCallback_Init_10, - .unk4 = sub_81CEFDC, - .unk8 = sub_81CF368, - .unkC = sub_81CF3A0, - .unk10 = sub_81CF3D0, - .unk14 = sub_81CEFF0, - .unk18 = sub_81CF3F8, + .init = PokenavCallback_Init_10, + .callback = sub_81CEFDC, + .open = sub_81CF368, + .createLoopTask = sub_81CF3A0, + .isLoopTaskActive = sub_81CF3D0, + .free1 = sub_81CEFF0, + .free2 = sub_81CF3F8, }, + [POKENAV_MATCH_CALL - POKENAV_MENU_IDS_START] = { - .unk0 = PokenavCallback_Init_11, - .unk4 = sub_81CAB24, - .unk8 = sub_81CB260, - .unkC = CreateMatchCallLoopedTask, - .unk10 = sub_81CB2CC, - .unk14 = sub_81CAB38, - .unk18 = sub_81CB2E0, + .init = PokenavCallback_Init_MatchCall, + .callback = GetMatchCallCallback, + .open = OpenMatchCall, + .createLoopTask = CreateMatchCallLoopedTask, + .isLoopTaskActive = IsMatchCallLoopedTaskActive, + .free1 = FreeMatchCallSubstruct1, + .free2 = FreeMatchCallSubstruct2, }, + [POKENAV_RIBBONS_MON_LIST - POKENAV_MENU_IDS_START] = { - .unk0 = PokenavCallback_Init_12, - .unk4 = sub_81CFA34, - .unk8 = sub_81CFDD0, - .unkC = sub_81CFE40, - .unk10 = sub_81CFE70, - .unk14 = sub_81CFA48, - .unk18 = sub_81CFE98, + .init = PokenavCallback_Init_12, + .callback = sub_81CFA34, + .open = sub_81CFDD0, + .createLoopTask = sub_81CFE40, + .isLoopTaskActive = sub_81CFE70, + .free1 = sub_81CFA48, + .free2 = sub_81CFE98, }, + [POKENAV_MENU_D - POKENAV_MENU_IDS_START] = { - .unk0 = PokenavCallback_Init_13, - .unk4 = sub_81D04A0, - .unk8 = sub_81D0978, - .unkC = sub_81D09B0, - .unk10 = sub_81D09E0, - .unk14 = sub_81D04B8, - .unk18 = sub_81D09F4, + .init = PokenavCallback_Init_13, + .callback = sub_81D04A0, + .open = sub_81D0978, + .createLoopTask = sub_81D09B0, + .isLoopTaskActive = sub_81D09E0, + .free1 = sub_81D04B8, + .free2 = sub_81D09F4, }, + [POKENAV_MENU_E - POKENAV_MENU_IDS_START] = { - .unk0 = PokenavCallback_Init_14, - .unk4 = sub_81CFA34, - .unk8 = sub_81CFE08, - .unkC = sub_81CFE40, - .unk10 = sub_81CFE70, - .unk14 = sub_81CFA48, - .unk18 = sub_81CFE98, + .init = PokenavCallback_Init_14, + .callback = sub_81CFA34, + .open = sub_81CFE08, + .createLoopTask = sub_81CFE40, + .isLoopTaskActive = sub_81CFE70, + .free1 = sub_81CFA48, + .free2 = sub_81CFE98, }, }; @@ -416,66 +432,68 @@ static void VBlankCB_Pokenav(void) ProcessSpriteCopyRequests(); } +#define tState data[0] + static void Task_Pokenav(u8 taskId) { - u32 v1; + u32 menuId; s16 *data = gTasks[taskId].data; - switch (data[0]) + switch (tState) { case 0: InitPokenavMainMenu(); - data[0] = 1; + tState = 1; break; case 1: // Wait for LoopedTask_InitPokenavMenu to finish if (PokenavMainMenuLoopedTaskIsActive()) break; - SetActivePokenavMenu(POKENAV_MENU_0); - data[0] = 4; + SetActivePokenavMenu(POKENAV_MAIN_MENU); + tState = 4; break; case 2: if (sub_81C786C()) break; - data[0] = 3; + tState = 3; case 3: - v1 = sub_81C75E0(); - if (v1 == -1) + menuId = GetCurrentMenuCB(); + if (menuId == -1) { ShutdownPokenav(); - data[0] = 5; + tState = 5; } - else if (v1 >= POKENAV_MENU_IDS_START) + else if (menuId >= POKENAV_MENU_IDS_START) { - PokenavMenuCallbacks[gPokenavResources->currentMenuIndex].unk18(); - PokenavMenuCallbacks[gPokenavResources->currentMenuIndex].unk14(); - if (SetActivePokenavMenu(v1)) + PokenavMenuCallbacks[gPokenavResources->currentMenuIndex].free2(); + PokenavMenuCallbacks[gPokenavResources->currentMenuIndex].free1(); + if (SetActivePokenavMenu(menuId)) { - data[0] = 4; + tState = 4; } else { ShutdownPokenav(); - data[0] = 5; + tState = 5; } } - else if (v1 != 0) + else if (menuId != 0) { - sub_81C7850(v1); + sub_81C7850(menuId); if (sub_81C786C()) - data[0] = 2; + tState = 2; } break; case 4: if (!sub_81C75D4()) - data[0] = 3; + tState = 3; break; case 5: if (!WaitForPokenavShutdownFade()) { bool32 calledFromScript = (gPokenavResources->mode != POKENAV_MODE_NORMAL); - sub_81C9430(); + FreeMenuHandlerSubstruct1(); FreePokenavResources(); if (calledFromScript) SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); @@ -486,18 +504,20 @@ static void Task_Pokenav(u8 taskId) } } +#undef tState + static bool32 SetActivePokenavMenu(u32 menuId) { u32 index = menuId - POKENAV_MENU_IDS_START; InitKeys_(); - if (!PokenavMenuCallbacks[index].unk0()) + if (!PokenavMenuCallbacks[index].init()) return FALSE; - if (!PokenavMenuCallbacks[index].unk8()) + if (!PokenavMenuCallbacks[index].open()) return FALSE; - sub_81C7834(PokenavMenuCallbacks[index].unkC, PokenavMenuCallbacks[index].unk10); - gPokenavResources->currentMenuCb1 = PokenavMenuCallbacks[index].unk4; + sub_81C7834(PokenavMenuCallbacks[index].createLoopTask, PokenavMenuCallbacks[index].isLoopTaskActive); + gPokenavResources->currentMenuCb1 = PokenavMenuCallbacks[index].callback; gPokenavResources->currentMenuIndex = index; return TRUE; } @@ -507,7 +527,7 @@ static u32 sub_81C75D4(void) return sub_81C786C(); } -static u32 sub_81C75E0(void) +static u32 GetCurrentMenuCB(void) { return gPokenavResources->currentMenuCb1(); } diff --git a/src/pokenav_conditions_1.c b/src/pokenav_conditions_1.c index 70c309992..84e2a9682 100644 --- a/src/pokenav_conditions_1.c +++ b/src/pokenav_conditions_1.c @@ -147,7 +147,7 @@ u32 sub_81CD110(struct PokenavSub11 *structPtr) u32 sub_81CD19C(struct PokenavSub11 *structPtr) { if (structPtr->unk6300 == 0) - return POKENAV_MENU_2; + return POKENAV_CONDITION_MENU; else return POKENAV_MENU_A; } diff --git a/src/pokenav_conditions_2.c b/src/pokenav_conditions_2.c index 11fdaa425..ed253f90f 100644 --- a/src/pokenav_conditions_2.c +++ b/src/pokenav_conditions_2.c @@ -296,7 +296,7 @@ u32 sub_81CDE94(s32 state) PrintHelpBarText(HELPBAR_CONDITION_MON_STATUS); return LT_INC_AND_PAUSE; case 15: - sub_81C7AC0(1); + PokenavFadeScreen(1); if (!sub_81CDD5C()) { LoadLeftHeaderGfxForIndex(6); @@ -353,7 +353,7 @@ u32 sub_81CE2D0(s32 state) sub_81CEE74(FALSE); return 1; case 2: - sub_81C7AC0(0); + PokenavFadeScreen(0); if (!sub_81CDD5C()) sub_81C78A0(); return 0; diff --git a/src/pokenav_conditions_3.c b/src/pokenav_conditions_3.c index 9b6ce432b..74bc3cc9d 100644 --- a/src/pokenav_conditions_3.c +++ b/src/pokenav_conditions_3.c @@ -197,12 +197,12 @@ static u32 sub_81CF030(struct PokenavSub7 *structPtr) static u32 sub_81CF0B0(struct PokenavSub7 *structPtr) { - return 100003; + return POKENAV_CONDITION_SEARCH_MENU; } static u32 sub_81CF0B8(struct PokenavSub7 *structPtr) { - return 100009; + return POKENAV_MENU_9; } static u32 sub_81CF0C0(void) @@ -448,7 +448,7 @@ static u32 sub_81CF418(s32 state) sub_81C7FA0(r4, 1, 0); sub_81C7FA0(1, 1, 0); } - sub_81C7AC0(1); + PokenavFadeScreen(1); return LT_INC_AND_PAUSE; case 5: if (IsPaletteFadeActive()) @@ -598,7 +598,7 @@ static u32 sub_81CF758(s32 state) { case 0: PlaySE(SE_SELECT); - sub_81C7AC0(0); + PokenavFadeScreen(0); sub_81C78A0(); return LT_INC_AND_PAUSE; case 1: @@ -618,7 +618,7 @@ static u32 sub_81CF798(s32 state) { case 0: PlaySE(SE_SELECT); - sub_81C7AC0(0); + PokenavFadeScreen(0); return LT_INC_AND_PAUSE; case 1: if (IsPaletteFadeActive()) diff --git a/src/pokenav_main_menu.c b/src/pokenav_main_menu.c index 583d23a55..fdd27b087 100644 --- a/src/pokenav_main_menu.c +++ b/src/pokenav_main_menu.c @@ -13,28 +13,6 @@ #include "menu.h" #include "dma3.h" -enum -{ - POKENAV_GFX_MAIN_MENU, - POKENAV_GFX_CONDITION_MENU, - POKENAV_GFX_RIBBONS_MENU, - POKENAV_GFX_MATCH_CALL_MENU, - // One of these is for the zoomed-in map, and the other is for the - // zoomed-out map. Don't know which is which yet. - POKENAV_GFX_MAP_MENU_UNK0, - POKENAV_GFX_MAP_MENU_UNK1, - POKENAV_GFX_PARTY_MENU, - POKENAV_GFX_SEARCH_MENU, - POKENAV_GFX_COOL_MENU, - POKENAV_GFX_BEAUTY_MENU, - POKENAV_GFX_CUTE_MENU, - POKENAV_GFX_SMART_MENU, - POKENAV_GFX_TOUGH_MENU, - POKENAV_GFX_MENUS_END, -}; - -#define POKENAV_GFX_SUBMENUS_START POKENAV_GFX_PARTY_MENU - struct PokenavMainMenuResources { void (*unk0)(u32); @@ -42,7 +20,7 @@ struct PokenavMainMenuResources u32 unk8; u32 currentTaskId; u32 helpBarWindowId; - u32 unk14; + u32 palettes; struct Sprite *spinningPokenav; struct Sprite *leftHeaderSprites[2]; struct Sprite *submenuLeftHeaderSprites[2]; @@ -174,12 +152,12 @@ static const struct CompressedSpriteSheet sPokenavMenuLeftHeaderSpriteSheets[] = .size = 0x20, .tag = 4 }, - [POKENAV_GFX_MAP_MENU_UNK0] = { + [POKENAV_GFX_MAP_MENU_ZOOMED_OUT] = { .data = gPokenavLeftHeaderHoennMap_Gfx, .size = 0x20, .tag = 0 }, - [POKENAV_GFX_MAP_MENU_UNK1] = { + [POKENAV_GFX_MAP_MENU_ZOOMED_IN] = { .data = gPokenavLeftHeaderHoennMap_Gfx, .size = 0x40, .tag = 0 @@ -343,7 +321,7 @@ bool32 WaitForPokenavShutdownFade(void) { if (!gPaletteFade.active) { - sub_81C99D4(); + FreeMenuHandlerSubstruct2(); CleanupPokenavMainMenuResources(); FreeAllWindowBuffers(); return FALSE; @@ -629,17 +607,17 @@ _081C7AAE:\n\ .syntax divided"); } -void sub_81C7AC0(s32 a0) +void PokenavFadeScreen(s32 fadeType) { struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); - switch (a0) + switch (fadeType) { case 0: - BeginNormalPaletteFade(structPtr->unk14, -2, 0, 16, RGB_BLACK); + BeginNormalPaletteFade(structPtr->palettes, -2, 0, 16, RGB_BLACK); break; case 1: - BeginNormalPaletteFade(structPtr->unk14, -2, 16, 0, RGB_BLACK); + BeginNormalPaletteFade(structPtr->palettes, -2, 16, 0, RGB_BLACK); break; case 2: BeginNormalPaletteFade(0xFFFFFFFF, -2, 0, 16, RGB_BLACK); @@ -708,7 +686,7 @@ static void InitPokenavMainMenuResources(void) LoadCompressedSpriteSheet(&gSpinningPokenavSpriteSheet[i]); Pokenav_AllocAndLoadPalettes(gSpinningNavgearPalettes); - structPtr->unk14 = ~1 & ~(0x10000 << IndexOfSpritePaletteTag(0)); + structPtr->palettes = ~1 & ~(0x10000 << IndexOfSpritePaletteTag(0)); spriteId = CreateSprite(&sSpinningPokenavSpriteTemplate, 220, 12, 0); structPtr->spinningPokenav = &gSprites[spriteId]; } @@ -772,61 +750,61 @@ static void InitHoennMapHeaderSprites(void) } } -void LoadLeftHeaderGfxForIndex(u32 arg0) +void LoadLeftHeaderGfxForIndex(u32 menuGfxId) { - if (arg0 < POKENAV_GFX_SUBMENUS_START) - LoadLeftHeaderGfxForMenu(arg0); + if (menuGfxId < POKENAV_GFX_SUBMENUS_START) + LoadLeftHeaderGfxForMenu(menuGfxId); else - LoadLeftHeaderGfxForSubMenu(arg0 - POKENAV_GFX_SUBMENUS_START); + LoadLeftHeaderGfxForSubMenu(menuGfxId - POKENAV_GFX_SUBMENUS_START); } -void sub_81C7E14(u32 arg0) +void sub_81C7E14(u32 menuGfxId) { struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0); - if (arg0 == 4) + if (menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_OUT) structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 32; else structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + 64; } -static void LoadLeftHeaderGfxForMenu(u32 index) +static void LoadLeftHeaderGfxForMenu(u32 menuGfxId) { struct PokenavMainMenuResources *structPtr; u32 size, tag; - if (index >= POKENAV_GFX_SUBMENUS_START) + if (menuGfxId >= POKENAV_GFX_SUBMENUS_START) return; structPtr = GetSubstructPtr(0); - tag = sPokenavMenuLeftHeaderSpriteSheets[index].tag; - size = GetDecompressedDataSize(sPokenavMenuLeftHeaderSpriteSheets[index].data); + tag = sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].tag; + size = GetDecompressedDataSize(sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].data); LoadPalette(&gPokenavLeftHeader_Pal[tag * 16], (IndexOfSpritePaletteTag(1) * 16) + 0x100, 0x20); - LZ77UnCompWram(sPokenavMenuLeftHeaderSpriteSheets[index].data, gDecompressionBuffer); + LZ77UnCompWram(sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].data, gDecompressionBuffer); RequestDma3Copy(gDecompressionBuffer, (void *)VRAM + 0x10000 + (GetSpriteTileStartByTag(2) * 32), size, 1); - structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + sPokenavMenuLeftHeaderSpriteSheets[index].size; + structPtr->leftHeaderSprites[1]->oam.tileNum = GetSpriteTileStartByTag(2) + sPokenavMenuLeftHeaderSpriteSheets[menuGfxId].size; - if (index == POKENAV_GFX_MAP_MENU_UNK0 || index == POKENAV_GFX_MAP_MENU_UNK1) + if (menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_OUT || menuGfxId == POKENAV_GFX_MAP_MENU_ZOOMED_IN) structPtr->leftHeaderSprites[1]->pos2.x = 56; else structPtr->leftHeaderSprites[1]->pos2.x = 64; } -static void LoadLeftHeaderGfxForSubMenu(u32 arg0) +static void LoadLeftHeaderGfxForSubMenu(u32 menuGfxId) { u32 size, tag; - if (arg0 >= POKENAV_GFX_MENUS_END - POKENAV_GFX_SUBMENUS_START) + if (menuGfxId >= POKENAV_GFX_MENUS_END - POKENAV_GFX_SUBMENUS_START) return; - tag = sPokenavSubMenuLeftHeaderSpriteSheets[arg0].tag; - size = GetDecompressedDataSize(sPokenavSubMenuLeftHeaderSpriteSheets[arg0].data); + tag = sPokenavSubMenuLeftHeaderSpriteSheets[menuGfxId].tag; + size = GetDecompressedDataSize(sPokenavSubMenuLeftHeaderSpriteSheets[menuGfxId].data); LoadPalette(&gPokenavLeftHeader_Pal[tag * 16], (IndexOfSpritePaletteTag(2) * 16) + 0x100, 0x20); - LZ77UnCompWram(sPokenavSubMenuLeftHeaderSpriteSheets[arg0].data, &gDecompressionBuffer[0x1000]); + LZ77UnCompWram(sPokenavSubMenuLeftHeaderSpriteSheets[menuGfxId].data, &gDecompressionBuffer[0x1000]); RequestDma3Copy(&gDecompressionBuffer[0x1000], (void *)VRAM + 0x10800 + (GetSpriteTileStartByTag(2) * 32), size, 1); } -void sub_81C7FA0(u32 arg0, bool32 arg1, bool32 arg2) +void sub_81C7FA0(u32 menuGfxId, bool32 arg1, bool32 arg2) { u32 var; @@ -835,7 +813,7 @@ void sub_81C7FA0(u32 arg0, bool32 arg1, bool32 arg2) else var = 0x10; - if (arg0 < 6) + if (menuGfxId < POKENAV_GFX_SUBMENUS_START) ShowLeftHeaderSprites(var, arg2); else ShowLeftHeaderSubmenuSprites(var, arg2); diff --git a/src/pokenav_match_call_1.c b/src/pokenav_match_call_1.c index 28e84b50b..ef1d5343f 100755 --- a/src/pokenav_match_call_1.c +++ b/src/pokenav_match_call_1.c @@ -30,7 +30,7 @@ struct Pokenav3Struct }; static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *); -static u32 sub_81CABFC(struct Pokenav3Struct *); +static u32 GetExitMatchCallMenuId(struct Pokenav3Struct *); static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *); static u32 CB2_HandleCheckPageInput(struct Pokenav3Struct *); static u32 CB2_HandleCallInput(struct Pokenav3Struct *); @@ -52,7 +52,7 @@ static const u8 sMatchCallOptionsHasCheckPage[] = MATCH_CALL_OPTION_CANCEL }; -bool32 PokenavCallback_Init_11(void) +bool32 PokenavCallback_Init_MatchCall(void) { struct Pokenav3Struct *state = AllocSubstruct(5, sizeof(struct Pokenav3Struct)); if (!state) @@ -65,13 +65,13 @@ bool32 PokenavCallback_Init_11(void) return TRUE; } -u32 sub_81CAB24(void) +u32 GetMatchCallCallback(void) { struct Pokenav3Struct *state = GetSubstructPtr(5); return state->callback(state); } -void sub_81CAB38(void) +void FreeMatchCallSubstruct1(void) { FreePokenavSubstruct(5); } @@ -113,7 +113,7 @@ static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state) { if (GetPokenavMode() != POKENAV_MODE_FORCE_CALL_READY) { - state->callback = sub_81CABFC; + state->callback = GetExitMatchCallMenuId; return POKENAV_MC_FUNC_EXIT; } else @@ -126,9 +126,9 @@ static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state) return POKENAV_MC_FUNC_NONE; } -static u32 sub_81CABFC(struct Pokenav3Struct *state) +static u32 GetExitMatchCallMenuId(struct Pokenav3Struct *state) { - return POKENAV_MENU_4; + return POKENAV_MAIN_MENU_CURSOR_ON_MATCH_CALL; } static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *state) diff --git a/src/pokenav_match_call_2.c b/src/pokenav_match_call_2.c index aaa1767aa..aa69c592f 100755 --- a/src/pokenav_match_call_2.c +++ b/src/pokenav_match_call_2.c @@ -27,8 +27,8 @@ struct Pokenav4Struct { - bool32 (*unk0)(void); - u32 unk4; + bool32 (*isTaskActiveCB)(void); + u32 loopTaskId; u8 filler8[0x6]; u8 unkE; u8 unkF; @@ -49,8 +49,8 @@ struct Pokenav4Struct u8 unk2028[0x20]; }; -static bool32 sub_81CB310(void); -static u32 sub_81CB324(s32); +static bool32 GetCurrentLoopedTaskActive(void); +static u32 LoopedTask_OpenMatchCall(s32); static void sub_81CBBB8(void); static void sub_81CBC1C(void); static void sub_81CC2B4(void); @@ -274,32 +274,32 @@ static const struct SpriteTemplate sTrainerPicSpriteTemplate = .callback = SpriteCallbackDummy, }; -bool32 sub_81CB260(void) +bool32 OpenMatchCall(void) { struct Pokenav4Struct *state = AllocSubstruct(6, sizeof(struct Pokenav4Struct)); if (!state) return FALSE; state->unk19 = 0; - state->unk4 = CreateLoopedTask(sub_81CB324, 1); - state->unk0 = sub_81CB310; + state->loopTaskId = CreateLoopedTask(LoopedTask_OpenMatchCall, 1); + state->isTaskActiveCB = GetCurrentLoopedTaskActive; return TRUE; } void CreateMatchCallLoopedTask(s32 index) { struct Pokenav4Struct *state = GetSubstructPtr(6); - state->unk4 = CreateLoopedTask(sMatchCallLoopTaskFuncs[index], 1); - state->unk0 = sub_81CB310; + state->loopTaskId = CreateLoopedTask(sMatchCallLoopTaskFuncs[index], 1); + state->isTaskActiveCB = GetCurrentLoopedTaskActive; } -u32 sub_81CB2CC(void) +bool32 IsMatchCallLoopedTaskActive(void) { struct Pokenav4Struct *state = GetSubstructPtr(6); - return state->unk0(); + return state->isTaskActiveCB(); } -void sub_81CB2E0(void) +void FreeMatchCallSubstruct2(void) { struct Pokenav4Struct *state = GetSubstructPtr(6); sub_81CC2B4(); @@ -310,13 +310,13 @@ void sub_81CB2E0(void) FreePokenavSubstruct(6); } -static bool32 sub_81CB310(void) +static bool32 GetCurrentLoopedTaskActive(void) { struct Pokenav4Struct *state = GetSubstructPtr(6); - return IsLoopedTaskActive(state->unk4); + return IsLoopedTaskActive(state->loopTaskId); } -static u32 sub_81CB324(s32 taskState) +static u32 LoopedTask_OpenMatchCall(s32 taskState) { struct Pokenav4Struct *state = GetSubstructPtr(6); switch (taskState) @@ -376,7 +376,7 @@ static u32 sub_81CB324(s32 taskState) sub_81CC214(); LoadLeftHeaderGfxForIndex(3); sub_81C7FA0(3, 1, 0); - sub_81C7AC0(1); + PokenavFadeScreen(1); return LT_INC_AND_PAUSE; case 7: if (IsPaletteFadeActive() || sub_81C8010()) @@ -849,7 +849,7 @@ u32 ExitMatchCall(s32 taskState) case 0: PlaySE(SE_SELECT); sub_81CBC38(0); - sub_81C7AC0(0); + PokenavFadeScreen(0); sub_81C78A0(); return LT_INC_AND_PAUSE; case 1: diff --git a/src/pokenav_match_call_ui.c b/src/pokenav_match_call_ui.c index fd346393e..01740fcce 100644 --- a/src/pokenav_match_call_ui.c +++ b/src/pokenav_match_call_ui.c @@ -7,6 +7,8 @@ #include "menu.h" #include "decompress.h" +// TODO: This UI isnt just for match call, seems to be the general pokenav list UI + struct UnknownSubSubStruct_0203CF40 { u8 bg; u8 unk1; diff --git a/src/pokenav_menu_handler_1.c b/src/pokenav_menu_handler_1.c index 44176176d..bd33a21af 100644 --- a/src/pokenav_menu_handler_1.c +++ b/src/pokenav_menu_handler_1.c @@ -11,15 +11,15 @@ struct Pokenav1Struct s16 cursorPos; u16 currMenuItem; u16 helpBarIndex; - u32 unk8; + u32 menuId; u32 (*callback)(struct Pokenav1Struct*); }; static bool32 UpdateMenuCursorPos(struct Pokenav1Struct *state); static void ReturnToConditionMenu(struct Pokenav1Struct *state); static void ReturnToMainMenu(struct Pokenav1Struct *state); -static u32 sub_81C97BC(struct Pokenav1Struct *state); -static void sub_81C97B0(struct Pokenav1Struct *state, u32 a1); +static u32 GetMenuId(struct Pokenav1Struct *state); +static void SetMenuIdAndCB(struct Pokenav1Struct *state, u32 a1); static u32 CB2_ReturnToConditionMenu(struct Pokenav1Struct *state); static u32 CB2_ReturnToMainMenu(struct Pokenav1Struct *state); static u32 HandleConditionSearchMenuInput(struct Pokenav1Struct *state); @@ -97,7 +97,7 @@ static u8 GetPokenavMainMenuType(void) return menuType; } -bool32 PokenavCallback_Init_0(void) +bool32 PokenavCallback_Init_MainMenuCursorOnMap(void) { struct Pokenav1Struct *state = AllocSubstruct(1, sizeof(struct Pokenav1Struct)); if (!state) @@ -111,7 +111,7 @@ bool32 PokenavCallback_Init_0(void) return TRUE; } -bool32 PokenavCallback_Init_4(void) +bool32 PokenavCallback_Init_MainMenuCursorOnMatchCall(void) { struct Pokenav1Struct *state = AllocSubstruct(1, sizeof(struct Pokenav1Struct)); if (!state) @@ -125,7 +125,7 @@ bool32 PokenavCallback_Init_4(void) return TRUE; } -bool32 PokenavCallback_Init_5(void) +bool32 PokenavCallback_Init_MainMenuCursorOnRibbons(void) { struct Pokenav1Struct *state = AllocSubstruct(1, sizeof(struct Pokenav1Struct)); if (!state) @@ -138,7 +138,7 @@ bool32 PokenavCallback_Init_5(void) return TRUE; } -bool32 PokenavCallback_Init_2(void) +bool32 PokenavCallback_Init_ConditionMenu(void) { struct Pokenav1Struct *state = AllocSubstruct(1, sizeof(struct Pokenav1Struct)); if (!state) @@ -152,7 +152,7 @@ bool32 PokenavCallback_Init_2(void) return TRUE; } -bool32 PokenavCallback_Init_3(void) +bool32 PokenavCallback_Init_ConditionSearchMenu(void) { struct Pokenav1Struct *state = AllocSubstruct(1, sizeof(struct Pokenav1Struct)); if (!state) @@ -200,13 +200,13 @@ static u32 (*GetMainMenuInputHandler(void))(struct Pokenav1Struct*) } } -u32 sub_81C941C(void) +u32 GetMenuHandlerCallback(void) { struct Pokenav1Struct *state = GetSubstructPtr(1); return state->callback(state); } -void sub_81C9430(void) +void FreeMenuHandlerSubstruct1(void) { FreePokenavSubstruct(1); } @@ -222,7 +222,7 @@ static u32 HandleMainMenuInput(struct Pokenav1Struct *state) { case POKENAV_MENUITEM_MAP: state->helpBarIndex = gSaveBlock2Ptr->regionMapZoom ? HELPBAR_MAP_ZOOMED_IN : HELPBAR_MAP_ZOOMED_OUT; - sub_81C97B0(state, POKENAV_MENU_6); + SetMenuIdAndCB(state, POKENAV_REGION_MAP); return POKENAV_MENU_FUNC_OPEN_FEATURE; case POKENAV_MENUITEM_CONDITION: state->menuType = POKENAV_MENU_TYPE_CONDITION; @@ -232,13 +232,13 @@ static u32 HandleMainMenuInput(struct Pokenav1Struct *state) return POKENAV_MENU_FUNC_OPEN_CONDITION; case POKENAV_MENUITEM_MATCH_CALL: state->helpBarIndex = HELPBAR_MC_TRAINER_LIST; - sub_81C97B0(state, POKENAV_MENU_B); + SetMenuIdAndCB(state, POKENAV_MATCH_CALL); return POKENAV_MENU_FUNC_OPEN_FEATURE; case POKENAV_MENUITEM_RIBBONS: if (CanViewRibbonsMenu()) { state->helpBarIndex = HELPBAR_RIBBONS_MON_LIST; - sub_81C97B0(state, POKENAV_MENU_C); + SetMenuIdAndCB(state, POKENAV_RIBBONS_MON_LIST); return POKENAV_MENU_FUNC_OPEN_FEATURE; } else @@ -268,7 +268,7 @@ static u32 HandleMainMenuInputTutorial(struct Pokenav1Struct *state) if (sMenuItems[state->menuType][state->cursorPos] == POKENAV_MENUITEM_MATCH_CALL) { state->helpBarIndex = HELPBAR_MC_TRAINER_LIST; - sub_81C97B0(state, POKENAV_MENU_B); + SetMenuIdAndCB(state, POKENAV_MATCH_CALL); return POKENAV_MENU_FUNC_OPEN_FEATURE; } else @@ -304,7 +304,7 @@ static u32 HandleMainMenuInputEndTutorial(struct Pokenav1Struct *state) else if (menuItem == POKENAV_MENUITEM_MATCH_CALL) { state->helpBarIndex = HELPBAR_MC_TRAINER_LIST; - sub_81C97B0(state, POKENAV_MENU_B); + SetMenuIdAndCB(state, POKENAV_MATCH_CALL); return POKENAV_MENU_FUNC_OPEN_FEATURE; } else @@ -355,7 +355,7 @@ static u32 HandleConditionMenuInput(struct Pokenav1Struct *state) return POKENAV_MENU_FUNC_OPEN_CONDITION_SEARCH; case POKENAV_MENUITEM_CONDITION_PARTY: state->helpBarIndex = 0; - sub_81C97B0(state, POKENAV_MENU_7); + SetMenuIdAndCB(state, POKENAV_CONDITION_PARTY); return POKENAV_MENU_FUNC_OPEN_FEATURE; case POKENAV_MENUITEM_CONDITION_CANCEL: PlaySE(SE_SELECT); @@ -393,7 +393,7 @@ static u32 HandleConditionSearchMenuInput(struct Pokenav1Struct *state) if (menuItem != POKENAV_MENUITEM_CONDITION_SEARCH_CANCEL) { SetSelectedConditionSearch(menuItem - POKENAV_MENUITEM_CONDITION_SEARCH_COOL); - sub_81C97B0(state, POKENAV_MENU_8); + SetMenuIdAndCB(state, POKENAV_CONDITION_SEARCH_RESULTS); state->helpBarIndex = HELPBAR_CONDITION_MON_LIST; return POKENAV_MENU_FUNC_OPEN_FEATURE; } @@ -434,15 +434,15 @@ static u32 CB2_ReturnToConditionMenu(struct Pokenav1Struct *state) return POKENAV_MENU_FUNC_RETURN_TO_CONDITION; } -static void sub_81C97B0(struct Pokenav1Struct *state, u32 a1) +static void SetMenuIdAndCB(struct Pokenav1Struct *state, u32 menuId) { - state->unk8 = a1; - state->callback = sub_81C97BC; + state->menuId = menuId; + state->callback = GetMenuId; } -static u32 sub_81C97BC(struct Pokenav1Struct *state) +static u32 GetMenuId(struct Pokenav1Struct *state) { - return state->unk8; + return state->menuId; } static void ReturnToMainMenu(struct Pokenav1Struct *state) diff --git a/src/pokenav_menu_handler_2.c b/src/pokenav_menu_handler_2.c index 94b816b6d..1dfbf3417 100644 --- a/src/pokenav_menu_handler_2.c +++ b/src/pokenav_menu_handler_2.c @@ -17,26 +17,24 @@ #include "constants/songs.h" #include "constants/rgb.h" -// Top Menu - struct Pokenav2Struct { - bool32 (*callback)(void); + bool32 (*isTaskActiveCB)(void); u32 loopedTaskId; u16 optionDescWindowId; u8 bg3ScrollTaskId; u8 cursorPos; bool8 otherIconsInMotion; - u8 field_00d; + bool8 pokenavAlreadyOpen; bool32 iconVisible[MAX_POKENAV_MENUITEMS]; struct Sprite * field_028; struct Sprite * iconSprites[MAX_POKENAV_MENUITEMS][4]; u16 bg1TilemapBuffer[0x400]; }; -static struct Pokenav2Struct * sub_81C9958(void); -static bool32 sub_81C99FC(void); -static u32 sub_81C9A10(s32 state); +static struct Pokenav2Struct * OpenPokenavMenu(void); +static bool32 GetCurrentLoopedTaskActive(void); +static u32 LoopedTask_OpenMenu(s32 state); static u32 LoopedTask_MoveMenuCursor(s32 state); static u32 LoopedTask_OpenConditionMenu(s32 state); static u32 LoopedTask_ReturnToMainMenu(s32 state); @@ -337,59 +335,56 @@ static bool32 sub_81C98D4(void) return FALSE; } -bool32 sub_81C9924(void) +bool32 OpenPokenavMenuInitial(void) { - struct Pokenav2Struct * unk = sub_81C9958(); + struct Pokenav2Struct * state = OpenPokenavMenu(); - if (unk == NULL) + if (state == NULL) return FALSE; - unk->field_00d = 0; + state->pokenavAlreadyOpen = FALSE; return TRUE; } -bool32 sub_81C9940(void) +bool32 OpenPokenavMenuNotInitial(void) { - struct Pokenav2Struct * unk = sub_81C9958(); + struct Pokenav2Struct * state = OpenPokenavMenu(); - if (unk == NULL) + if (state == NULL) return FALSE; - unk->field_00d = 1; + state->pokenavAlreadyOpen = TRUE; return TRUE; } -static struct Pokenav2Struct * sub_81C9958(void) +static struct Pokenav2Struct * OpenPokenavMenu(void) { - struct Pokenav2Struct * unk = AllocSubstruct(2, sizeof(struct Pokenav2Struct)); + struct Pokenav2Struct * state = AllocSubstruct(2, sizeof(struct Pokenav2Struct)); - if (unk != NULL) + if (state != NULL) { - unk->otherIconsInMotion = FALSE; - unk->loopedTaskId = CreateLoopedTask(sub_81C9A10, 1); - unk->callback = sub_81C99FC; + state->otherIconsInMotion = FALSE; + state->loopedTaskId = CreateLoopedTask(LoopedTask_OpenMenu, 1); + state->isTaskActiveCB = GetCurrentLoopedTaskActive; } - return unk; + return state; } - void CreateMenuHandlerLoopedTask(s32 ltIdx) { - struct Pokenav2Struct * unk = GetSubstructPtr(2); - - unk->loopedTaskId = CreateLoopedTask(sMenuHandlerLoopTaskFuncs[ltIdx], 1); - unk->callback = sub_81C99FC; + struct Pokenav2Struct * state = GetSubstructPtr(2); + state->loopedTaskId = CreateLoopedTask(sMenuHandlerLoopTaskFuncs[ltIdx], 1); + state->isTaskActiveCB = GetCurrentLoopedTaskActive; } -bool32 sub_81C99C0(void) +bool32 IsMenuHandlerLoopedTaskActive(void) { - struct Pokenav2Struct * unk = GetSubstructPtr(2); - - return unk->callback(); + struct Pokenav2Struct * state = GetSubstructPtr(2); + return state->isTaskActiveCB(); } -void sub_81C99D4(void) +void FreeMenuHandlerSubstruct2(void) { struct Pokenav2Struct * unk = GetSubstructPtr(2); @@ -400,14 +395,14 @@ void sub_81C99D4(void) FreePokenavSubstruct(2); } -static bool32 sub_81C99FC(void) +static bool32 GetCurrentLoopedTaskActive(void) { struct Pokenav2Struct * unk = GetSubstructPtr(2); return IsLoopedTaskActive(unk->loopedTaskId); } -static u32 sub_81C9A10(s32 state) +static u32 LoopedTask_OpenMenu(s32 state) { struct Pokenav2Struct * unk = GetSubstructPtr(2); @@ -466,12 +461,12 @@ static u32 sub_81C9A10(s32 state) ShowBg(1); ShowBg(2); ShowBg(3); - if (unk->field_00d) - sub_81C7AC0(1); + if (unk->pokenavAlreadyOpen) + PokenavFadeScreen(1); else { PlaySE(SE_PN_ON); - sub_81C7AC0(3); + PokenavFadeScreen(3); } switch (GetPokenavMenuType()) { @@ -741,7 +736,7 @@ static u32 LoopedTask_OpenPokenavFeature(s32 state) return LT_PAUSE; if (sub_81C8010()) return LT_PAUSE; - sub_81C7AC0(0); + PokenavFadeScreen(0); return LT_INC_AND_PAUSE; case 3: if (IsPaletteFadeActive()) diff --git a/src/pokenav_region_map.c b/src/pokenav_region_map.c index be30ca94d..59eaf6b71 100755 --- a/src/pokenav_region_map.c +++ b/src/pokenav_region_map.c @@ -13,23 +13,27 @@ #include "task.h" #include "text_window.h" #include "window.h" +#include "constants/rgb.h" #include "constants/songs.h" +#include "constants/region_map_sections.h" + +#define NUM_CITY_MAPS 22 struct Pokenav5Struct { u8 filler0[0xC]; - bool32 unkC; - u32 (*unk10)(struct Pokenav5Struct *); + bool32 zoomDisabled; + u32 (*callback)(struct Pokenav5Struct *); }; struct Pokenav5Struct_2 { - bool32 (*unk0)(void); - u32 unk4; - u16 unk8; - struct Sprite *cityFeatureTextSprites[3]; - u8 unk18[0x800]; - u8 cityZoomPics[22][0xC8]; + bool32 (*isTaskActiveCB)(void); + u32 loopTaskId; + u16 infoWindowId; + struct Sprite *cityZoomTextSprites[3]; + u8 tilemapBuffer[0x800]; + u8 cityZoomPics[NUM_CITY_MAPS][200]; }; struct CityMapEntry @@ -39,45 +43,43 @@ struct CityMapEntry const u32 *tilemap; }; -static u32 sub_81CC568(struct Pokenav5Struct *); -static u32 sub_81CC5B4(struct Pokenav5Struct *); -static u32 sub_81CC5DC(struct Pokenav5Struct *); -static u32 sub_81CC6F4(s32); -static u32 sub_81CCD34(s32); -static bool32 sub_81CC6BC(void); -static void sub_81CC9EC(void); -static void sub_81CC9C0(void); -static void sub_81CCD10(void); -static bool32 sub_81CCD24(void); -static void sub_81CCA1C(struct Pokenav5Struct_2 *); -static bool32 sub_81CCAFC(void); -static void sub_81CCB0C(struct Pokenav5Struct_2 *); -static bool32 sub_81CCC4C(struct Pokenav5Struct_2 *); -static void sub_81CCC5C(int); -static bool32 sub_81CCC88(void); -static void sub_81CCE58(void); -static void sub_81CCD70(struct Pokenav5Struct_2 *, int, int); -static void sub_81CCDE8(struct Pokenav5Struct_2 *, int, int); -static void sub_81CCFA4(int); -static void sub_81CCC9C(u8 taskId); -static void sub_81CCF78(void); -void sub_81CCEF4(struct Sprite *sprite); -u32 sub_81CC848(s32); -u32 sub_81CC878(s32); -u32 sub_81CC8D8(s32); -u32 sub_81CC95C(s32); +static u32 HandleRegionMapInput(struct Pokenav5Struct *); +static u32 HandleRegionMapInputZoomDisabled(struct Pokenav5Struct *); +static u32 GetExitRegionMapMenuId(struct Pokenav5Struct *); +static u32 LoopedTask_OpenRegionMap(s32); +static u32 LoopedTask_DecompressCityMaps(s32); +static bool32 GetCurrentLoopedTaskActive(void); +static void FreeCityZoomViewGfx(void); +static void LoadCityZoomViewGfx(void); +static void DecompressCityMaps(void); +static bool32 IsDecompressCityMapsActive(void); +static void LoadPokenavRegionMapGfx(struct Pokenav5Struct_2 *); +static bool32 TryFreeTempTileDataBuffers(void); +static void UpdateMapSecInfoWindow(struct Pokenav5Struct_2 *); +static bool32 IsDma3ManagerBusyWithBgCopy_(struct Pokenav5Struct_2 *); +static void ChangeBgYForZoom(bool32); +static bool32 IsChangeBgYForZoomActive(void); +static void CreateCityZoomTextSprites(void); +static void DrawCityMap(struct Pokenav5Struct_2 *, int, int); +static void PrintLandmarkNames(struct Pokenav5Struct_2 *, int, int); +static void SetCityZoomTextInvisibility(bool32); +static void Task_ChangeBgYForZoom(u8 taskId); +static void UpdateCityZoomTextPosition(void); +static void SpriteCB_CityZoomText(struct Sprite *sprite); +static u32 LoopedTask_UpdateInfoAfterCursorMove(s32); +static u32 LoopedTask_RegionMapZoomOut(s32); +static u32 LoopedTask_RegionMapZoomIn(s32); +static u32 LoopedTask_ExitRegionMap(s32); -extern const u16 gHoennMapZoomIcons_Pal[]; -extern const struct SpriteTemplate gUnknown_086231D0; -extern const u32 gHoennMapZoomIcons_Gfx[]; +extern const u16 gRegionMapCityZoomTiles_Pal[]; +extern const u32 gRegionMapCityZoomText_Gfx[]; -const u16 gUnknown_08622868[] = INCBIN_U16("graphics/pokenav/8622868.gbapal"); -const u32 gUnknown_08622888[] = INCBIN_U32("graphics/pokenav/zoom_tiles.4bpp.lz"); +static const u16 sMapSecInfoWindow_Pal[] = INCBIN_U16("graphics/pokenav/region_map_info_window.gbapal"); +static const u32 sRegionMapCityZoomTiles_Gfx[] = INCBIN_U32("graphics/pokenav/city_zoom_tiles.4bpp.lz"); #include "data/region_map/city_map_tilemaps.h" - -const struct BgTemplate gUnknown_086230D8[3] = +static const struct BgTemplate sRegionMapBgTemplates[3] = { { .bg = 1, @@ -108,27 +110,27 @@ const struct BgTemplate gUnknown_086230D8[3] = }, }; -const LoopedTask gUnknown_086230E4[] = +static const LoopedTask sRegionMapLoopTaskFuncs[] = { - NULL, - sub_81CC848, - sub_81CC878, - sub_81CC8D8, - sub_81CC95C + [POKENAV_MAP_FUNC_NONE] = NULL, + [POKENAV_MAP_FUNC_CURSOR_MOVED] = LoopedTask_UpdateInfoAfterCursorMove, + [POKENAV_MAP_FUNC_ZOOM_OUT] = LoopedTask_RegionMapZoomOut, + [POKENAV_MAP_FUNC_ZOOM_IN] = LoopedTask_RegionMapZoomIn, + [POKENAV_MAP_FUNC_EXIT] = LoopedTask_ExitRegionMap }; -const struct CompressedSpriteSheet gUnknown_086230F8[1] = +static const struct CompressedSpriteSheet sCityZoomTextSpriteSheet[1] = { - {gHoennMapZoomIcons_Gfx, 0x800, 6} + {gRegionMapCityZoomText_Gfx, 0x800, 6} }; -const struct SpritePalette gUnknown_08623100[] = +static const struct SpritePalette sCityZoomTilesSpritePalette[] = { - {gHoennMapZoomIcons_Pal, 11}, + {gRegionMapCityZoomTiles_Pal, 11}, {} }; -const struct WindowTemplate gUnknown_08623110 = +static const struct WindowTemplate sMapSecInfoWindowTemplate = { .bg = 1, .tilemapLeft = 17, @@ -141,7 +143,7 @@ const struct WindowTemplate gUnknown_08623110 = #include "data/region_map/city_map_entries.h" -const struct OamData gUnknown_086231C8 = +const struct OamData sCityZoomTextSprite_OamData = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -155,18 +157,18 @@ const struct OamData gUnknown_086231C8 = .paletteNum = 0, }; -const struct SpriteTemplate gUnknown_086231D0 = +static const struct SpriteTemplate sCityZoomTextSpriteTemplate = { .tileTag = 6, .paletteTag = 11, - .oam = &gUnknown_086231C8, + .oam = &sCityZoomTextSprite_OamData, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_81CCEF4, + .callback = SpriteCB_CityZoomText, }; -u32 PokenavCallback_Init_6(void) +u32 PokenavCallback_Init_RegionMap(void) { struct Pokenav5Struct *state = AllocSubstruct(3, sizeof(struct Pokenav5Struct)); if (!state) @@ -175,105 +177,105 @@ u32 PokenavCallback_Init_6(void) if (!AllocSubstruct(16, sizeof(struct RegionMap))) return FALSE; - state->unkC = sub_8124668(gMapHeader.regionMapSectionId); - if (!state->unkC) - state->unk10 = sub_81CC568; + state->zoomDisabled = IsEventIslandMapSecId(gMapHeader.regionMapSectionId); + if (!state->zoomDisabled) + state->callback = HandleRegionMapInput; else - state->unk10 = sub_81CC5B4; + state->callback = HandleRegionMapInputZoomDisabled; return TRUE; } -void sub_81CC524(void) +void FreeRegionMapSubstruct1(void) { - gSaveBlock2Ptr->regionMapZoom = sub_8124658(); + gSaveBlock2Ptr->regionMapZoom = IsRegionMapZoomed(); FreePokenavSubstruct(16); FreePokenavSubstruct(3); } -u32 sub_81CC554(void) +u32 GetRegionMapCallback(void) { struct Pokenav5Struct *state = GetSubstructPtr(3); - return state->unk10(state); + return state->callback(state); } -static u32 sub_81CC568(struct Pokenav5Struct *state) +static u32 HandleRegionMapInput(struct Pokenav5Struct *state) { - switch (sub_81230AC()) + switch (DoRegionMapInputCallback()) { - case 3: - return 1; - case 4: - if (!sub_8124658()) - return 3; - return 2; - case 5: - state->unk10 = sub_81CC5DC; - return 4; + case MAP_INPUT_MOVE_END: + return POKENAV_MAP_FUNC_CURSOR_MOVED; + case MAP_INPUT_A_BUTTON: + if (!IsRegionMapZoomed()) + return POKENAV_MAP_FUNC_ZOOM_IN; + return POKENAV_MAP_FUNC_ZOOM_OUT; + case MAP_INPUT_B_BUTTON: + state->callback = GetExitRegionMapMenuId; + return POKENAV_MAP_FUNC_EXIT; } - return 0; + return POKENAV_MAP_FUNC_NONE; } -static u32 sub_81CC5B4(struct Pokenav5Struct *state) +static u32 HandleRegionMapInputZoomDisabled(struct Pokenav5Struct *state) { if (gMain.newKeys & B_BUTTON) { - state->unk10 = sub_81CC5DC; - return 4; + state->callback = GetExitRegionMapMenuId; + return POKENAV_MAP_FUNC_EXIT; } - return 0; + return POKENAV_MAP_FUNC_NONE; } -static u32 sub_81CC5DC(struct Pokenav5Struct *state) +static u32 GetExitRegionMapMenuId(struct Pokenav5Struct *state) { - return POKENAV_MENU_1; + return POKENAV_MAIN_MENU_CURSOR_ON_MAP; } -bool32 sub_81CC5E4(void) +bool32 GetZoomDisabled(void) { struct Pokenav5Struct *state = GetSubstructPtr(3); - return state->unkC; + return state->zoomDisabled; } -bool32 sub_81CC5F4(void) +bool32 OpenPokenavRegionMap(void) { struct Pokenav5Struct_2 *state = AllocSubstruct(4, sizeof(struct Pokenav5Struct_2)); if (!state) return FALSE; - state->unk4 = CreateLoopedTask(sub_81CC6F4, 1); - state->unk0 = sub_81CC6BC; + state->loopTaskId = CreateLoopedTask(LoopedTask_OpenRegionMap, 1); + state->isTaskActiveCB = GetCurrentLoopedTaskActive; return TRUE; } -void sub_81CC62C(s32 index) +void CreateRegionMapLoopedTask(s32 index) { struct Pokenav5Struct_2 *state = GetSubstructPtr(4); - state->unk4 = CreateLoopedTask(gUnknown_086230E4[index], 1); - state->unk0 = sub_81CC6BC; + state->loopTaskId = CreateLoopedTask(sRegionMapLoopTaskFuncs[index], 1); + state->isTaskActiveCB = GetCurrentLoopedTaskActive; } -u32 sub_81CC65C(void) +bool32 IsRegionMapLoopedTaskActive(void) { struct Pokenav5Struct_2 *state = GetSubstructPtr(4); - return state->unk0(); + return state->isTaskActiveCB(); } -void sub_81CC670(void) +void FreeRegionMapSubstruct2(void) { struct Pokenav5Struct_2 *state = GetSubstructPtr(4); FreeRegionMapIconResources(); - sub_81CC9EC(); - RemoveWindow(state->unk8); + FreeCityZoomViewGfx(); + RemoveWindow(state->infoWindowId); FreePokenavSubstruct(16); FreePokenavSubstruct(4); SetPokenavVBlankCallback(); SetBgMode(0); } -static void sub_81CC6A4(void) +static void VBlankCB_RegionMap(void) { TransferPlttBuffer(); LoadOam(); @@ -281,23 +283,23 @@ static void sub_81CC6A4(void) UpdateRegionMapVideoRegs(); } -static bool32 sub_81CC6BC(void) +static bool32 GetCurrentLoopedTaskActive(void) { struct Pokenav5Struct_2 *state = GetSubstructPtr(4); - return IsLoopedTaskActive(state->unk4); + return IsLoopedTaskActive(state->loopTaskId); } -static bool8 sub_81CC6D0(void) +static bool8 ShouldOpenRegionMapZoomed(void) { - if (sub_81CC5E4()) + if (GetZoomDisabled()) return FALSE; - return gSaveBlock2Ptr->regionMapZoom == 1; + return gSaveBlock2Ptr->regionMapZoom == TRUE; } -static u32 sub_81CC6F4(s32 taskState) +static u32 LoopedTask_OpenRegionMap(s32 taskState) { - int var0; + int menuGfxId; struct RegionMap *regionMap; struct Pokenav5Struct_2 *state = GetSubstructPtr(4); switch (taskState) @@ -308,209 +310,209 @@ static u32 sub_81CC6F4(s32 taskState) HideBg(2); HideBg(3); SetBgMode(1); - InitBgTemplates(gUnknown_086230D8, ARRAY_COUNT(gUnknown_086230D8) - 1); + InitBgTemplates(sRegionMapBgTemplates, ARRAY_COUNT(sRegionMapBgTemplates) - 1); regionMap = GetSubstructPtr(16); - sub_8122CF8(regionMap, &gUnknown_086230D8[1], sub_81CC6D0()); - sub_81CC9C0(); - return 0; + InitRegionMapData(regionMap, &sRegionMapBgTemplates[1], ShouldOpenRegionMapZoomed()); + LoadCityZoomViewGfx(); + return LT_INC_AND_PAUSE; case 1: - if (sub_8122DB0()) - return 2; + if (LoadRegionMapGfx()) + return LT_PAUSE; - if (!sub_81CC5E4()) + if (!GetZoomDisabled()) { CreateRegionMapPlayerIcon(4, 9); CreateRegionMapCursor(5, 10); - sub_812454C(); + TrySetPlayerIconBlink(); } else { - sub_8123030(0, 6); + sub_8123030(RGB_BLACK, 6); } - return 0; + return LT_INC_AND_PAUSE; case 2: - sub_81CCD10(); - return 1; + DecompressCityMaps(); + return LT_INC_AND_CONTINUE; case 3: - if (sub_81CCD24()) - return 2; + if (IsDecompressCityMapsActive()) + return LT_PAUSE; - sub_81CCA1C(state); - return 1; + LoadPokenavRegionMapGfx(state); + return LT_INC_AND_CONTINUE; case 4: - if (sub_81CCAFC()) - return 2; + if (TryFreeTempTileDataBuffers()) + return LT_PAUSE; - sub_81CCB0C(state); + UpdateMapSecInfoWindow(state); sub_81C7B40(); - return 0; + return LT_INC_AND_PAUSE; case 5: - if (sub_81CCC4C(state)) - return 2; + if (IsDma3ManagerBusyWithBgCopy_(state)) + return LT_PAUSE; ShowBg(1); ShowBg(2); - SetVBlankCallback_(sub_81CC6A4); - return 0; + SetVBlankCallback_(VBlankCB_RegionMap); + return LT_INC_AND_PAUSE; case 6: - if (!sub_81CC6D0()) - var0 = 4; + if (!ShouldOpenRegionMapZoomed()) + menuGfxId = POKENAV_GFX_MAP_MENU_ZOOMED_OUT; else - var0 = 5; + menuGfxId = POKENAV_GFX_MAP_MENU_ZOOMED_IN; - LoadLeftHeaderGfxForIndex(var0); - sub_81C7FA0(var0, 1, 1); - sub_81C7AC0(1); - return 0; + LoadLeftHeaderGfxForIndex(menuGfxId); + sub_81C7FA0(menuGfxId, 1, 1); + PokenavFadeScreen(1); + return LT_INC_AND_PAUSE; case 7: if (IsPaletteFadeActive() || sub_81C8010()) - return 2; - return 1; + return LT_PAUSE; + return LT_INC_AND_CONTINUE; default: - return 4; + return LT_FINISH; } } -u32 sub_81CC848(s32 taskState) +static u32 LoopedTask_UpdateInfoAfterCursorMove(s32 taskState) { struct Pokenav5Struct_2 *state = GetSubstructPtr(4); switch (taskState) { case 0: - sub_81CCB0C(state); - return 0; + UpdateMapSecInfoWindow(state); + return LT_INC_AND_PAUSE; case 1: - if (sub_81CCC4C(state)) - return 2; + if (IsDma3ManagerBusyWithBgCopy_(state)) + return LT_PAUSE; break; } - return 4; + return LT_FINISH; } -u32 sub_81CC878(s32 taskState) +static u32 LoopedTask_RegionMapZoomOut(s32 taskState) { switch (taskState) { case 0: PlaySE(SE_SELECT); - sub_81CCC5C(0); - sub_8123418(); - return 0; + ChangeBgYForZoom(FALSE); + SetRegionMapDataForZoom(); + return LT_INC_AND_PAUSE; case 1: - if (sub_8123514() || sub_81CCC88()) - return 2; + if (UpdateRegionMapZoom() || IsChangeBgYForZoomActive()) + return LT_PAUSE; PrintHelpBarText(HELPBAR_MAP_ZOOMED_OUT); - return 0; + return LT_INC_AND_PAUSE; case 2: if (WaitForHelpBar()) - return 2; + return LT_PAUSE; - sub_81C7E14(4); + sub_81C7E14(POKENAV_GFX_MAP_MENU_ZOOMED_OUT); break; } - return 4; + return LT_FINISH; } -u32 sub_81CC8D8(s32 taskState) +static u32 LoopedTask_RegionMapZoomIn(s32 taskState) { struct Pokenav5Struct_2 *state = GetSubstructPtr(4); switch (taskState) { case 0: PlaySE(SE_SELECT); - sub_81CCB0C(state); - return 0; + UpdateMapSecInfoWindow(state); + return LT_INC_AND_PAUSE; case 1: - if (sub_81CCC4C(state)) - return 2; + if (IsDma3ManagerBusyWithBgCopy_(state)) + return LT_PAUSE; - sub_81CCC5C(1); - sub_8123418(); - return 0; + ChangeBgYForZoom(TRUE); + SetRegionMapDataForZoom(); + return LT_INC_AND_PAUSE; case 2: - if (sub_8123514() || sub_81CCC88()) - return 2; + if (UpdateRegionMapZoom() || IsChangeBgYForZoomActive()) + return LT_PAUSE; PrintHelpBarText(HELPBAR_MAP_ZOOMED_IN); - return 0; + return LT_INC_AND_PAUSE; case 3: if (WaitForHelpBar()) - return 2; + return LT_PAUSE; - sub_81C7E14(5); + sub_81C7E14(POKENAV_GFX_MAP_MENU_ZOOMED_IN); break; } - return 4; + return LT_FINISH; } -u32 sub_81CC95C(s32 taskState) +static u32 LoopedTask_ExitRegionMap(s32 taskState) { switch (taskState) { case 0: PlaySE(SE_SELECT); - sub_81C7AC0(0); - return 0; + PokenavFadeScreen(0); + return LT_INC_AND_PAUSE; case 1: if (IsPaletteFadeActive()) - return 2; + return LT_PAUSE; sub_81C7FDC(); sub_81C78A0(); - return 0; + return LT_INC_AND_PAUSE; case 2: if (MainMenuLoopedTaskIsBusy()) - return 2; + return LT_PAUSE; HideBg(1); HideBg(2); HideBg(3); - return 0; + return LT_INC_AND_PAUSE; } - return 4; + return LT_FINISH; } -static void sub_81CC9C0(void) +static void LoadCityZoomViewGfx(void) { int i; - for (i = 0; i < ARRAY_COUNT(gUnknown_086230F8); i++) - LoadCompressedSpriteSheet(&gUnknown_086230F8[i]); + for (i = 0; i < ARRAY_COUNT(sCityZoomTextSpriteSheet); i++) + LoadCompressedSpriteSheet(&sCityZoomTextSpriteSheet[i]); - Pokenav_AllocAndLoadPalettes(gUnknown_08623100); - sub_81CCE58(); + Pokenav_AllocAndLoadPalettes(sCityZoomTilesSpritePalette); + CreateCityZoomTextSprites(); } -static void sub_81CC9EC(void) +static void FreeCityZoomViewGfx(void) { int i; struct Pokenav5Struct_2 *state = GetSubstructPtr(4); FreeSpriteTilesByTag(6); FreeSpritePaletteByTag(11); - for (i = 0; i < 3; i++) - DestroySprite(state->cityFeatureTextSprites[i]); + for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++) + DestroySprite(state->cityZoomTextSprites[i]); } -static void sub_81CCA1C(struct Pokenav5Struct_2 *state) +static void LoadPokenavRegionMapGfx(struct Pokenav5Struct_2 *state) { sub_8199DF0(1, PIXEL_FILL(0), 0x40, 1); sub_8199DF0(1, PIXEL_FILL(1), 0x41, 1); - CpuFill16(0x1040, state->unk18, 0x800); - SetBgTilemapBuffer(1, state->unk18); - state->unk8 = AddWindow(&gUnknown_08623110); - LoadUserWindowBorderGfx_(state->unk8, 0x42, 0x40); - DrawTextBorderOuter(state->unk8, 0x42, 4); - decompress_and_copy_tile_data_to_vram(1, gUnknown_08622888, 0, 0, 0); - FillWindowPixelBuffer(state->unk8, PIXEL_FILL(1)); - PutWindowTilemap(state->unk8); - CopyWindowToVram(state->unk8, 3); - CopyPaletteIntoBufferUnfaded(gUnknown_08622868, 0x10, 0x20); - CopyPaletteIntoBufferUnfaded(gHoennMapZoomIcons_Pal, 0x30, 0x20); - if (!sub_8124658()) + CpuFill16(0x1040, state->tilemapBuffer, 0x800); + SetBgTilemapBuffer(1, state->tilemapBuffer); + state->infoWindowId = AddWindow(&sMapSecInfoWindowTemplate); + LoadUserWindowBorderGfx_(state->infoWindowId, 0x42, 0x40); + DrawTextBorderOuter(state->infoWindowId, 0x42, 4); + decompress_and_copy_tile_data_to_vram(1, sRegionMapCityZoomTiles_Gfx, 0, 0, 0); + FillWindowPixelBuffer(state->infoWindowId, PIXEL_FILL(1)); + PutWindowTilemap(state->infoWindowId); + CopyWindowToVram(state->infoWindowId, 3); + CopyPaletteIntoBufferUnfaded(sMapSecInfoWindow_Pal, 0x10, 0x20); + CopyPaletteIntoBufferUnfaded(gRegionMapCityZoomTiles_Pal, 0x30, 0x20); + if (!IsRegionMapZoomed()) ChangeBgY(1, -0x6000, 0); else ChangeBgY(1, 0, 0); @@ -518,68 +520,70 @@ static void sub_81CCA1C(struct Pokenav5Struct_2 *state) ChangeBgX(1, 0, 0); } -static bool32 sub_81CCAFC(void) +static bool32 TryFreeTempTileDataBuffers(void) { return free_temp_tile_data_buffers_if_possible(); } -static void sub_81CCB0C(struct Pokenav5Struct_2 *state) +static void UpdateMapSecInfoWindow(struct Pokenav5Struct_2 *state) { struct RegionMap *regionMap = GetSubstructPtr(16); - switch (regionMap->iconDrawType) + switch (regionMap->mapSecType) { case MAPSECTYPE_CITY_CANFLY: - FillWindowPixelBuffer(state->unk8, PIXEL_FILL(1)); - PutWindowRectTilemap(state->unk8, 0, 0, 12, 2); - AddTextPrinterParameterized(state->unk8, 7, regionMap->mapSecName, 0, 1, TEXT_SPEED_FF, NULL); - sub_81CCD70(state, regionMap->mapSecId, regionMap->posWithinMapSec); - CopyWindowToVram(state->unk8, 3); - sub_81CCFA4(0); + FillWindowPixelBuffer(state->infoWindowId, PIXEL_FILL(1)); + PutWindowRectTilemap(state->infoWindowId, 0, 0, 12, 2); + AddTextPrinterParameterized(state->infoWindowId, 7, regionMap->mapSecName, 0, 1, TEXT_SPEED_FF, NULL); + DrawCityMap(state, regionMap->mapSecId, regionMap->posWithinMapSec); + CopyWindowToVram(state->infoWindowId, 3); + SetCityZoomTextInvisibility(FALSE); break; case MAPSECTYPE_CITY_CANTFLY: - FillWindowPixelBuffer(state->unk8, PIXEL_FILL(1)); - PutWindowRectTilemap(state->unk8, 0, 0, 12, 2); - AddTextPrinterParameterized(state->unk8, 7, regionMap->mapSecName, 0, 1, TEXT_SPEED_FF, NULL); + FillWindowPixelBuffer(state->infoWindowId, PIXEL_FILL(1)); + PutWindowRectTilemap(state->infoWindowId, 0, 0, 12, 2); + AddTextPrinterParameterized(state->infoWindowId, 7, regionMap->mapSecName, 0, 1, TEXT_SPEED_FF, NULL); FillBgTilemapBufferRect(1, 0x1041, 17, 6, 12, 11, 17); - CopyWindowToVram(state->unk8, 3); - sub_81CCFA4(1); + CopyWindowToVram(state->infoWindowId, 3); + SetCityZoomTextInvisibility(TRUE); break; - case MAPSECTYPE_PLAIN: + case MAPSECTYPE_ROUTE: case MAPSECTYPE_BATTLE_FRONTIER: - FillWindowPixelBuffer(state->unk8, PIXEL_FILL(1)); - PutWindowTilemap(state->unk8); - AddTextPrinterParameterized(state->unk8, 7, regionMap->mapSecName, 0, 1, TEXT_SPEED_FF, NULL); - sub_81CCDE8(state, regionMap->mapSecId, regionMap->posWithinMapSec); - CopyWindowToVram(state->unk8, 3); - sub_81CCFA4(1); + FillWindowPixelBuffer(state->infoWindowId, PIXEL_FILL(1)); + PutWindowTilemap(state->infoWindowId); + AddTextPrinterParameterized(state->infoWindowId, 7, regionMap->mapSecName, 0, 1, TEXT_SPEED_FF, NULL); + PrintLandmarkNames(state, regionMap->mapSecId, regionMap->posWithinMapSec); + CopyWindowToVram(state->infoWindowId, 3); + SetCityZoomTextInvisibility(TRUE); break; case MAPSECTYPE_NONE: FillBgTilemapBufferRect(1, 0x1041, 17, 4, 12, 13, 17); CopyBgTilemapBufferToVram(1); - sub_81CCFA4(1); + SetCityZoomTextInvisibility(TRUE); break; } } -static bool32 sub_81CCC4C(struct Pokenav5Struct_2 *state) +static bool32 IsDma3ManagerBusyWithBgCopy_(struct Pokenav5Struct_2 *state) { return IsDma3ManagerBusyWithBgCopy(); } -static void sub_81CCC5C(int arg0) +#define tZoomIn data[0] + +static void ChangeBgYForZoom(bool32 zoomIn) { - u8 taskId = CreateTask(sub_81CCC9C, 3); - gTasks[taskId].data[0] = arg0; + u8 taskId = CreateTask(Task_ChangeBgYForZoom, 3); + gTasks[taskId].tZoomIn = zoomIn; } -static bool32 sub_81CCC88(void) +static bool32 IsChangeBgYForZoomActive(void) { - return FuncIsActiveTask(sub_81CCC9C); + return FuncIsActiveTask(Task_ChangeBgYForZoom); } -static void sub_81CCC9C(u8 taskId) +static void Task_ChangeBgYForZoom(u8 taskId) { - if (gTasks[taskId].data[0]) + if (gTasks[taskId].tZoomIn) { if (ChangeBgY(1, 0x480, 1) >= 0) { @@ -587,7 +591,7 @@ static void sub_81CCC9C(u8 taskId) DestroyTask(taskId); } - sub_81CCF78(); + UpdateCityZoomTextPosition(); } else { @@ -597,46 +601,48 @@ static void sub_81CCC9C(u8 taskId) DestroyTask(taskId); } - sub_81CCF78(); + UpdateCityZoomTextPosition(); } } -static void sub_81CCD10(void) +#undef tZoomIn + +static void DecompressCityMaps(void) { - CreateLoopedTask(sub_81CCD34, 1); + CreateLoopedTask(LoopedTask_DecompressCityMaps, 1); } -static bool32 sub_81CCD24(void) +static bool32 IsDecompressCityMapsActive(void) { - return FuncIsActiveLoopedTask(sub_81CCD34); + return FuncIsActiveLoopedTask(LoopedTask_DecompressCityMaps); } -static u32 sub_81CCD34(s32 taskState) +static u32 LoopedTask_DecompressCityMaps(s32 taskState) { struct Pokenav5Struct_2 *state = GetSubstructPtr(4); - if (taskState < (int)ARRAY_COUNT(gPokenavCityMaps)) + if (taskState < NUM_CITY_MAPS) { - LZ77UnCompWram(gPokenavCityMaps[taskState].tilemap, state->cityZoomPics[taskState]); - return 1; + LZ77UnCompWram(sPokenavCityMaps[taskState].tilemap, state->cityZoomPics[taskState]); + return LT_INC_AND_CONTINUE; } - return 4; + return LT_FINISH; } -static void sub_81CCD70(struct Pokenav5Struct_2 *state, int mapSecId, int pos) +static void DrawCityMap(struct Pokenav5Struct_2 *state, int mapSecId, int pos) { int i; - for (i = 0; i < (int)ARRAY_COUNT(gPokenavCityMaps) && (gPokenavCityMaps[i].mapSecId != mapSecId || gPokenavCityMaps[i].index != pos); i++) + for (i = 0; i < NUM_CITY_MAPS && (sPokenavCityMaps[i].mapSecId != mapSecId || sPokenavCityMaps[i].index != pos); i++) ; - if (i == ARRAY_COUNT(gPokenavCityMaps)) + if (i == NUM_CITY_MAPS) return; FillBgTilemapBufferRect_Palette0(1, 0x1041, 17, 6, 12, 11); CopyToBgTilemapBufferRect(1, state->cityZoomPics[i], 18, 6, 10, 10); } -static void sub_81CCDE8(struct Pokenav5Struct_2 *state, int mapSecId, int pos) +static void PrintLandmarkNames(struct Pokenav5Struct_2 *state, int mapSecId, int pos) { int i = 0; while (1) @@ -646,26 +652,27 @@ static void sub_81CCDE8(struct Pokenav5Struct_2 *state, int mapSecId, int pos) break; StringCopyPadded(gStringVar1, landmarkName, CHAR_SPACE, 12); - AddTextPrinterParameterized(state->unk8, 7, gStringVar1, 0, i * 16 + 17, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(state->infoWindowId, 7, gStringVar1, 0, i * 16 + 17, TEXT_SPEED_FF, NULL); i++; } } -static void sub_81CCE58(void) +static void CreateCityZoomTextSprites(void) { int i; int y; struct Sprite *sprite; struct Pokenav5Struct_2 *state = GetSubstructPtr(4); - if (!sub_8124658()) + // When not zoomed in the text is still created but its pushed off screen + if (!IsRegionMapZoomed()) y = 228; else y = 132; - for (i = 0; i < 3; i++) + for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++) { - u8 spriteId = CreateSprite(&gUnknown_086231D0, 152 + i * 32, y, 8); + u8 spriteId = CreateSprite(&sCityZoomTextSpriteTemplate, 152 + i * 32, y, 8); sprite = &gSprites[spriteId]; sprite->data[0] = 0; sprite->data[1] = i * 4; @@ -673,11 +680,12 @@ static void sub_81CCE58(void) sprite->data[3] = 150; sprite->data[4] = i * 4; sprite->oam.tileNum += i * 4; - state->cityFeatureTextSprites[i] = sprite; + state->cityZoomTextSprites[i] = sprite; } } -void sub_81CCEF4(struct Sprite *sprite) +// Slide and cycle through the text key showing what the features on the zoomed city map are +static void SpriteCB_CityZoomText(struct Sprite *sprite) { if (sprite->data[3]) { @@ -711,19 +719,19 @@ void sub_81CCEF4(struct Sprite *sprite) } } -static void sub_81CCF78(void) +static void UpdateCityZoomTextPosition(void) { int i; struct Pokenav5Struct_2 *state = GetSubstructPtr(4); int y = 132 - (GetBgY(1) >> 8); - for (i = 0; i < 3; i++) - state->cityFeatureTextSprites[i]->pos1.y = y; + for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++) + state->cityZoomTextSprites[i]->pos1.y = y; } -static void sub_81CCFA4(int invisible) +static void SetCityZoomTextInvisibility(bool32 invisible) { int i; struct Pokenav5Struct_2 *state = GetSubstructPtr(4); - for (i = 0; i < 3; i++) - state->cityFeatureTextSprites[i]->invisible = invisible; + for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++) + state->cityZoomTextSprites[i]->invisible = invisible; } diff --git a/src/pokenav_ribbons_1.c b/src/pokenav_ribbons_1.c index 63b4adb30..db3b7f08e 100644 --- a/src/pokenav_ribbons_1.c +++ b/src/pokenav_ribbons_1.c @@ -188,7 +188,7 @@ static u32 sub_81CFA88(struct PokenavSub9 *structPtr) static u32 sub_81CFB08(struct PokenavSub9 *structPtr) { - return POKENAV_MENU_5; + return POKENAV_MAIN_MENU_CURSOR_ON_RIBBONS; } static u32 sub_81CFB10(struct PokenavSub9 *structPtr) @@ -446,7 +446,7 @@ static u32 sub_81CFEB8(s32 state) ShowBg(2); HideBg(3); PrintHelpBarText(HELPBAR_RIBBONS_MON_LIST); - sub_81C7AC0(1); + PokenavFadeScreen(1); if (!unk->unkC) { LoadLeftHeaderGfxForIndex(2); @@ -601,7 +601,7 @@ static u32 sub_81D01DC(s32 state) { case 0: PlaySE(SE_SELECT); - sub_81C7AC0(0); + PokenavFadeScreen(0); sub_81C78A0(); return LT_INC_AND_PAUSE; case 1: @@ -621,7 +621,7 @@ static u32 sub_81D021C(s32 state) { case 0: PlaySE(SE_SELECT); - sub_81C7AC0(0); + PokenavFadeScreen(0); return LT_INC_AND_PAUSE; case 1: if (IsPaletteFadeActive()) diff --git a/src/pokenav_ribbons_2.c b/src/pokenav_ribbons_2.c index 2789b1244..f27b664ea 100644 --- a/src/pokenav_ribbons_2.c +++ b/src/pokenav_ribbons_2.c @@ -586,7 +586,7 @@ u32 sub_81D0A6C(s32 state) ShowBg(1); ShowBg(2); HideBg(3); - sub_81C7AC0(1); + PokenavFadeScreen(1); return LT_INC_AND_PAUSE; } return LT_PAUSE; @@ -604,7 +604,7 @@ u32 sub_81D0C54(s32 state) { case 0: PlaySE(SE_SELECT); - sub_81C7AC0(0); + PokenavFadeScreen(0); return LT_INC_AND_PAUSE; case 1: if (IsPaletteFadeActive()) diff --git a/src/region_map.c b/src/region_map.c index 5694d4c7a..e183261b9 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -28,6 +28,17 @@ #include "constants/heal_locations.h" #include "constants/map_types.h" #include "constants/rgb.h" +#include "constants/weather.h" + +/* + * This file handles region maps generally, and the map used when selecting a fly destination. + * Specific features of other region map uses are handled elsewhere + * + * For the region map in the pokenav, see pokenav_region_map.c + * For the region map in the pokedex, see pokdex_area_screen.c/pokedex_area_region_map.c + * For the region map that can be viewed on the wall of pokemon centers, see field_region_map.c + * + */ #define MAP_WIDTH 28 #define MAP_HEIGHT 15 @@ -36,9 +47,11 @@ #define MAPCURSOR_X_MAX (MAPCURSOR_X_MIN + MAP_WIDTH - 1) #define MAPCURSOR_Y_MAX (MAPCURSOR_Y_MIN + MAP_HEIGHT - 1) +#define FLYDESTICON_RED_OUTLINE 6 + // Static type declarations -struct FlagControlledFlyDest +struct MultiNameFlyDest { const u8 *const *name; u16 mapSecId; @@ -48,18 +61,18 @@ struct FlagControlledFlyDest // Static RAM declarations static EWRAM_DATA struct RegionMap *gRegionMap = NULL; + static EWRAM_DATA struct { - /*0x000*/ void (*unk_000)(void); - /*0x004*/ u16 unk_004; - /*0x006*/ u16 mapSecId; - /*0x008*/ struct RegionMap regionMap; - /*0x88c*/ u8 unk_88c[0x1c0]; - /*0xa4c*/ u8 unk_a4c[0x26]; - /*0xa72*/ bool8 choseFlyLocation; -} *sFlyMap = NULL; // a74 + void (*callback)(void); + u16 state; + u16 mapSecId; + struct RegionMap regionMap; + u8 tileBuffer[0x1c0]; + u8 nameBuffer[0x26]; // never read + bool8 choseFlyLocation; +} *sFlyMap = NULL; static bool32 gUnknown_03001180; -static bool32 gUnknown_03001184; // Static ROM declarations @@ -68,44 +81,44 @@ static u8 MoveRegionMapCursor_Full(void); static u8 ProcessRegionMapInput_Zoomed(void); static u8 MoveRegionMapCursor_Zoomed(void); static void CalcZoomScrollParams(s16 scrollX, s16 scrollY, s16 c, s16 d, u16 e, u16 f, u8 rotation); -static u16 GetRegionMapSectionIdAt_Internal(u16 x, u16 y); +static u16 GetMapSecIdAt(u16 x, u16 y); static void RegionMap_SetBG2XAndBG2Y(s16 x, s16 y); -static void RegionMap_InitializeStateBasedOnPlayerLocation(void); +static void InitMapBasedOnPlayerLocation(void); static void RegionMap_InitializeStateBasedOnSSTidalLocation(void); -static u8 get_flagnr_blue_points(u16 mapSecId); +static u8 GetMapsecType(u16 mapSecId); static u16 CorrectSpecialMapSecId_Internal(u16 mapSecId); -static u16 RegionMap_GetTerraCaveMapSecId(void); -static void RegionMap_GetMarineCaveCoords(u16 *x, u16 *y); -static bool32 RegionMap_IsPlayerInCave(u8 mapSecId); -static void RegionMap_GetPositionOfCursorWithinMapSection(void); +static u16 GetTerraOrMarineCaveMapSecId(void); +static void GetMarineCaveCoords(u16 *x, u16 *y); +static bool32 IsPlayerInAquaHideout(u8 mapSecId); +static void GetPositionOfCursorWithinMapSec(void); static bool8 RegionMap_IsMapSecIdInNextRow(u16 y); -static void SpriteCallback_CursorFull(struct Sprite *sprite); +static void SpriteCB_CursorMapFull(struct Sprite *sprite); static void FreeRegionMapCursorSprite(void); static void HideRegionMapPlayerIcon(void); static void UnhideRegionMapPlayerIcon(void); -static void RegionMapPlayerIconSpriteCallback_Zoomed(struct Sprite *sprite); -static void RegionMapPlayerIconSpriteCallback_Full(struct Sprite *sprite); -static void RegionMapPlayerIconSpriteCallback(struct Sprite *sprite); -static void sub_81248C0(void); -static void sub_81248D4(void); -static void sub_81248F4(void callback(void)); -static void sub_8124904(void); -static void sub_8124A70(void); -static void sub_8124AD4(void); -static void sub_8124BE4(void); -static void sub_8124CBC(struct Sprite *sprite); -static void sub_8124D14(void); -static void sub_8124D64(void); -static void sub_8124E0C(void); +static void SpriteCB_PlayerIconMapZoomed(struct Sprite *sprite); +static void SpriteCB_PlayerIconMapFull(struct Sprite *sprite); +static void SpriteCB_PlayerIcon(struct Sprite *sprite); +static void VBlankCB_FlyMap(void); +static void CB2_FlyMap(void); +static void SetFlyMapCallback(void callback(void)); +static void DrawFlyDestTextWindow(void); +static void LoadFlyDestIcons(void); +static void CreateFlyDestIcons(void); +static void TryCreateRedOutlineFlyDestIcons(void); +static void SpriteCB_FlyDestIcon(struct Sprite *sprite); +static void CB_FadeInFlyMap(void); +static void CB_HandleFlyMapInput(void); +static void CB_ExitFlyMap(void); // .rodata static const u16 sRegionMapCursorPal[] = INCBIN_U16("graphics/pokenav/cursor.gbapal"); static const u32 sRegionMapCursorSmallGfxLZ[] = INCBIN_U32("graphics/pokenav/cursor_small.4bpp.lz"); static const u32 sRegionMapCursorLargeGfxLZ[] = INCBIN_U32("graphics/pokenav/cursor_large.4bpp.lz"); -static const u16 sRegionMapBkgnd_Pal[] = INCBIN_U16("graphics/pokenav/region_map.gbapal"); -static const u32 sRegionMapBkgnd_GfxLZ[] = INCBIN_U32("graphics/pokenav/region_map.8bpp.lz"); -static const u32 sRegionMapBkgnd_TilemapLZ[] = INCBIN_U32("graphics/pokenav/region_map_map.bin.lz"); +static const u16 sRegionMapBg_Pal[] = INCBIN_U16("graphics/pokenav/region_map.gbapal"); +static const u32 sRegionMapBg_GfxLZ[] = INCBIN_U32("graphics/pokenav/region_map.8bpp.lz"); +static const u32 sRegionMapBg_TilemapLZ[] = INCBIN_U32("graphics/pokenav/region_map_map.bin.lz"); static const u16 sRegionMapPlayerIcon_BrendanPal[] = INCBIN_U16("graphics/pokenav/brendan_icon.gbapal"); static const u8 sRegionMapPlayerIcon_BrendanGfx[] = INCBIN_U8("graphics/pokenav/brendan_icon.4bpp"); static const u16 sRegionMapPlayerIcon_MayPal[] = INCBIN_U16("graphics/pokenav/may_icon.gbapal"); @@ -137,52 +150,54 @@ static const u16 sRegionMap_SpecialPlaceLocations[][2] = {MAPSEC_MIRAGE_TOWER, MAPSEC_ROUTE_111}, {MAPSEC_TRAINER_HILL, MAPSEC_ROUTE_111}, {MAPSEC_DESERT_UNDERPASS, MAPSEC_ROUTE_114}, - {MAPSEC_ALTERING_CAVE_2, MAPSEC_ROUTE_103}, + {MAPSEC_ALTERING_CAVE, MAPSEC_ROUTE_103}, {MAPSEC_ARTISAN_CAVE, MAPSEC_ROUTE_103}, {MAPSEC_ABANDONED_SHIP, MAPSEC_ROUTE_108}, {MAPSEC_NONE, MAPSEC_NONE} }; -static const u16 sRegionMap_MarineCaveMapSecIds[] = +static const u16 sMarineCaveMapSecIds[] = { MAPSEC_MARINE_CAVE, MAPSEC_UNDERWATER_MARINE_CAVE, MAPSEC_UNDERWATER_MARINE_CAVE }; -static const u16 sTerraCaveMapSectionIds[] = +static const u16 sTerraOrMarineCaveMapSecIds[ABNORMAL_WEATHER_LOCATIONS] = { - MAPSEC_ROUTE_114, - MAPSEC_ROUTE_114, - MAPSEC_ROUTE_115, - MAPSEC_ROUTE_115, - MAPSEC_ROUTE_116, - MAPSEC_ROUTE_116, - MAPSEC_ROUTE_118, - MAPSEC_ROUTE_118, - MAPSEC_ROUTE_105, - MAPSEC_ROUTE_105, - MAPSEC_ROUTE_125, - MAPSEC_ROUTE_125, - MAPSEC_ROUTE_127, - MAPSEC_ROUTE_127, - MAPSEC_ROUTE_129, - MAPSEC_ROUTE_129 + [ABNORMAL_WEATHER_ROUTE_114_NORTH - 1] = MAPSEC_ROUTE_114, + [ABNORMAL_WEATHER_ROUTE_114_SOUTH - 1] = MAPSEC_ROUTE_114, + [ABNORMAL_WEATHER_ROUTE_115_WEST - 1] = MAPSEC_ROUTE_115, + [ABNORMAL_WEATHER_ROUTE_115_EAST - 1] = MAPSEC_ROUTE_115, + [ABNORMAL_WEATHER_ROUTE_116_NORTH - 1] = MAPSEC_ROUTE_116, + [ABNORMAL_WEATHER_ROUTE_116_SOUTH - 1] = MAPSEC_ROUTE_116, + [ABNORMAL_WEATHER_ROUTE_118_EAST - 1] = MAPSEC_ROUTE_118, + [ABNORMAL_WEATHER_ROUTE_118_WEST - 1] = MAPSEC_ROUTE_118, + [ABNORMAL_WEATHER_ROUTE_105_NORTH - 1] = MAPSEC_ROUTE_105, + [ABNORMAL_WEATHER_ROUTE_105_SOUTH - 1] = MAPSEC_ROUTE_105, + [ABNORMAL_WEATHER_ROUTE_125_WEST - 1] = MAPSEC_ROUTE_125, + [ABNORMAL_WEATHER_ROUTE_125_EAST - 1] = MAPSEC_ROUTE_125, + [ABNORMAL_WEATHER_ROUTE_127_NORTH - 1] = MAPSEC_ROUTE_127, + [ABNORMAL_WEATHER_ROUTE_127_SOUTH - 1] = MAPSEC_ROUTE_127, + [ABNORMAL_WEATHER_ROUTE_129_WEST - 1] = MAPSEC_ROUTE_129, + [ABNORMAL_WEATHER_ROUTE_129_EAST - 1] = MAPSEC_ROUTE_129 }; -static const struct UCoords16 sTerraCaveLocationCoords[] = +#define MARINE_CAVE_COORD(location)(ABNORMAL_WEATHER_##location - MARINE_CAVE_LOCATIONS_START) + +static const struct UCoords16 sMarineCaveLocationCoords[MARINE_CAVE_LOCATIONS] = { - {0x00, 0x0a}, - {0x00, 0x0c}, - {0x18, 0x03}, - {0x19, 0x04}, - {0x19, 0x06}, - {0x19, 0x07}, - {0x18, 0x0a}, - {0x18, 0x0a} + [MARINE_CAVE_COORD(ROUTE_105_NORTH)] = {0, 10}, + [MARINE_CAVE_COORD(ROUTE_105_SOUTH)] = {0, 12}, + [MARINE_CAVE_COORD(ROUTE_125_WEST)] = {24, 3}, + [MARINE_CAVE_COORD(ROUTE_125_EAST)] = {25, 4}, + [MARINE_CAVE_COORD(ROUTE_127_NORTH)] = {25, 6}, + [MARINE_CAVE_COORD(ROUTE_127_SOUTH)] = {25, 7}, + [MARINE_CAVE_COORD(ROUTE_129_WEST)] = {24, 10}, + [MARINE_CAVE_COORD(ROUTE_129_EAST)] = {24, 10} }; -static const u8 sRegionMap_MapSecAquaHideoutOld[] = +static const u8 sMapSecAquaHideoutOld[] = { MAPSEC_AQUA_HIDEOUT_OLD }; @@ -230,7 +245,7 @@ static const struct SpriteTemplate sRegionMapCursorSpriteTemplate = .anims = sRegionMapCursorAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCallback_CursorFull + .callback = SpriteCB_CursorMapFull }; static const struct OamData sRegionMapPlayerIconOam = @@ -251,11 +266,12 @@ static const union AnimCmd *const sRegionMapPlayerIconAnimTable[] = sRegionMapPlayerIconAnim1 }; -static const u8 sRegionMapEventSectionIds[] = +// Event islands that don't appear on map. (Southern Island does) +static const u8 sMapSecIdsOffMap[] = { - MAPSEC_BIRTH_ISLAND_2, + MAPSEC_BIRTH_ISLAND, MAPSEC_FARAWAY_ISLAND, - MAPSEC_NAVEL_ROCK2 + MAPSEC_NAVEL_ROCK }; static const u16 sRegionMapFramePal[] = INCBIN_U16("graphics/pokenav/map_frame.gbapal"); @@ -264,9 +280,9 @@ static const u32 sRegionMapFrameGfxLZ[] = INCBIN_U32("graphics/pokenav/map_frame static const u32 sRegionMapFrameTilemapLZ[] = INCBIN_U32("graphics/pokenav/map_frame.bin.lz"); -static const u16 Unknown_085A1D48[] = INCBIN_U16("graphics/pokenav/fly_target_icons.gbapal"); +static const u16 sFlyTargetIcons_Pal[] = INCBIN_U16("graphics/pokenav/fly_target_icons.gbapal"); -static const u32 sUnknown_085A1D68[] = INCBIN_U32("graphics/pokenav/fly_target_icons.4bpp.lz"); +static const u32 sFlyTargetIcons_Gfx[] = INCBIN_U32("graphics/pokenav/fly_target_icons.4bpp.lz"); static const u8 sMapHealLocations[][3] = { @@ -285,7 +301,7 @@ static const u8 sMapHealLocations[][3] = {MAP_GROUP(LILYCOVE_CITY), MAP_NUM(LILYCOVE_CITY), HEAL_LOCATION_LILYCOVE_CITY}, {MAP_GROUP(MOSSDEEP_CITY), MAP_NUM(MOSSDEEP_CITY), HEAL_LOCATION_MOSSDEEP_CITY}, {MAP_GROUP(SOOTOPOLIS_CITY), MAP_NUM(SOOTOPOLIS_CITY), HEAL_LOCATION_SOOTOPOLIS_CITY}, - {MAP_GROUP(EVER_GRANDE_CITY), MAP_NUM(EVER_GRANDE_CITY), HEAL_LOCATION_EVER_GRANDE_CITY_1}, + {MAP_GROUP(EVER_GRANDE_CITY), MAP_NUM(EVER_GRANDE_CITY), HEAL_LOCATION_EVER_GRANDE_CITY}, {MAP_GROUP(ROUTE101), MAP_NUM(ROUTE101), 0}, {MAP_GROUP(ROUTE102), MAP_NUM(ROUTE102), 0}, {MAP_GROUP(ROUTE103), MAP_NUM(ROUTE103), 0}, @@ -322,22 +338,22 @@ static const u8 sMapHealLocations[][3] = {MAP_GROUP(ROUTE134), MAP_NUM(ROUTE134), 0} }; -static const u8 *const gUnknown_085A1ED4[] = +static const u8 *const sEverGrandeCityNames[] = { gText_PokemonLeague, gText_PokemonCenter }; -static const struct FlagControlledFlyDest gUnknown_085A1EDC[] = +static const struct MultiNameFlyDest sMultiNameFlyDestinations[] = { { - .name = gUnknown_085A1ED4, + .name = sEverGrandeCityNames, .mapSecId = MAPSEC_EVER_GRANDE_CITY, .flag = FLAG_LANDMARK_POKEMON_LEAGUE } }; -static const struct BgTemplate gUnknown_085A1EE4[] = +static const struct BgTemplate sFlyMapBgTemplates[] = { { .bg = 0, @@ -365,7 +381,7 @@ static const struct BgTemplate gUnknown_085A1EE4[] = } }; -static const struct WindowTemplate gUnknown_085A1EF0[] = +static const struct WindowTemplate sFlyMapWindowTemplates[] = { { .bg = 0, @@ -397,13 +413,13 @@ static const struct WindowTemplate gUnknown_085A1EF0[] = DUMMY_WIN_TEMPLATE }; -static const struct SpritePalette gUnknown_085A1F10 = +static const struct SpritePalette sFlyTargetIconsSpritePalette = { - .data = Unknown_085A1D48, + .data = sFlyTargetIcons_Pal, .tag = 2 }; -static const u16 sUnknown_085A1F18[][2] = +static const u16 sRedOutlineFlyDestinations[][2] = { { FLAG_LANDMARK_BATTLE_FRONTIER, @@ -415,72 +431,73 @@ static const u16 sUnknown_085A1F18[][2] = } }; -static const struct OamData gOamData_085A1F20 = +static const struct OamData sFlyDestIcon_OamData = { .shape = SPRITE_SHAPE(8x8), .size = SPRITE_SIZE(8x8), .priority = 2 }; -static const union AnimCmd gUnknown_085A1F28[] = +static const union AnimCmd sFlyDestIcon_Anim_8x8CanFly[] = { ANIMCMD_FRAME( 0, 5), ANIMCMD_END }; -static const union AnimCmd gUnknown_085A1F30[] = +static const union AnimCmd sFlyDestIcon_Anim_16x8CanFly[] = { ANIMCMD_FRAME( 1, 5), ANIMCMD_END }; -static const union AnimCmd gUnknown_085A1F38[] = +static const union AnimCmd sFlyDestIcon_Anim_8x16CanFly[] = { ANIMCMD_FRAME( 3, 5), ANIMCMD_END }; -static const union AnimCmd gUnknown_085A1F40[] = +static const union AnimCmd sFlyDestIcon_Anim_8x8CantFly[] = { ANIMCMD_FRAME( 5, 5), ANIMCMD_END }; -static const union AnimCmd gUnknown_085A1F48[] = +static const union AnimCmd sFlyDestIcon_Anim_16x8CantFly[] = { ANIMCMD_FRAME( 6, 5), ANIMCMD_END }; -static const union AnimCmd gUnknown_085A1F50[] = +static const union AnimCmd sFlyDestIcon_Anim_8x16CantFly[] = { ANIMCMD_FRAME( 8, 5), ANIMCMD_END }; -static const union AnimCmd gUnknown_085A1F58[] = +// Only used by Battle Frontier +static const union AnimCmd sFlyDestIcon_Anim_RedOutline[] = { ANIMCMD_FRAME(10, 5), ANIMCMD_END }; -static const union AnimCmd *const gUnknown_085A1F60[] = +static const union AnimCmd *const sFlyDestIcon_Anims[] = { - gUnknown_085A1F28, - gUnknown_085A1F30, - gUnknown_085A1F38, - gUnknown_085A1F40, - gUnknown_085A1F48, - gUnknown_085A1F50, - gUnknown_085A1F58 + [SPRITE_SHAPE(8x8)] = sFlyDestIcon_Anim_8x8CanFly, + [SPRITE_SHAPE(16x8)] = sFlyDestIcon_Anim_16x8CanFly, + [SPRITE_SHAPE(8x16)] = sFlyDestIcon_Anim_8x16CanFly, + [SPRITE_SHAPE(8x8) + 3] = sFlyDestIcon_Anim_8x8CantFly, + [SPRITE_SHAPE(16x8) + 3] = sFlyDestIcon_Anim_16x8CantFly, + [SPRITE_SHAPE(8x16) + 3] = sFlyDestIcon_Anim_8x16CantFly, + [FLYDESTICON_RED_OUTLINE] = sFlyDestIcon_Anim_RedOutline }; -static const struct SpriteTemplate gUnknown_085A1F7C = +static const struct SpriteTemplate sFlyDestIconSpriteTemplate = { .tileTag = 2, .paletteTag = 2, - .oam = &gOamData_085A1F20, - .anims = gUnknown_085A1F60, + .oam = &sFlyDestIcon_OamData, + .anims = sFlyDestIcon_Anims, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy @@ -490,11 +507,11 @@ static const struct SpriteTemplate gUnknown_085A1F7C = void InitRegionMap(struct RegionMap *regionMap, bool8 zoomed) { - sub_8122CF8(regionMap, NULL, zoomed); - while (sub_8122DB0()); + InitRegionMapData(regionMap, NULL, zoomed); + while (LoadRegionMapGfx()); } -void sub_8122CF8(struct RegionMap *regionMap, const struct BgTemplate *template, bool8 zoomed) +void InitRegionMapData(struct RegionMap *regionMap, const struct BgTemplate *template, bool8 zoomed) { gRegionMap = regionMap; gRegionMap->initStep = 0; @@ -516,46 +533,38 @@ void sub_8122CF8(struct RegionMap *regionMap, const struct BgTemplate *template, } } -void sub_8122D88(struct RegionMap *regionMap) +void ShowRegionMapForPokedexAreaScreen(struct RegionMap *regionMap) { gRegionMap = regionMap; - RegionMap_InitializeStateBasedOnPlayerLocation(); + InitMapBasedOnPlayerLocation(); gRegionMap->playerIconSpritePosX = gRegionMap->cursorPosX; gRegionMap->playerIconSpritePosY = gRegionMap->cursorPosY; } -bool8 sub_8122DB0(void) +bool8 LoadRegionMapGfx(void) { switch (gRegionMap->initStep) { case 0: if (gRegionMap->bgManaged) - { - decompress_and_copy_tile_data_to_vram(gRegionMap->bgNum, sRegionMapBkgnd_GfxLZ, 0, 0, 0); - } + decompress_and_copy_tile_data_to_vram(gRegionMap->bgNum, sRegionMapBg_GfxLZ, 0, 0, 0); else - { - LZ77UnCompVram(sRegionMapBkgnd_GfxLZ, (u16 *)BG_CHAR_ADDR(2)); - } + LZ77UnCompVram(sRegionMapBg_GfxLZ, (u16 *)BG_CHAR_ADDR(2)); break; case 1: if (gRegionMap->bgManaged) { if (!free_temp_tile_data_buffers_if_possible()) - { - decompress_and_copy_tile_data_to_vram(gRegionMap->bgNum, sRegionMapBkgnd_TilemapLZ, 0, 0, 1); - } + decompress_and_copy_tile_data_to_vram(gRegionMap->bgNum, sRegionMapBg_TilemapLZ, 0, 0, 1); } else { - LZ77UnCompVram(sRegionMapBkgnd_TilemapLZ, (u16 *)BG_SCREEN_ADDR(28)); + LZ77UnCompVram(sRegionMapBg_TilemapLZ, (u16 *)BG_SCREEN_ADDR(28)); } break; case 2: if (!free_temp_tile_data_buffers_if_possible()) - { - LoadPalette(sRegionMapBkgnd_Pal, 0x70, 0x60); - } + LoadPalette(sRegionMapBg_Pal, 0x70, 0x60); break; case 3: LZ77UnCompWram(sRegionMapCursorSmallGfxLZ, gRegionMap->cursorSmallImage); @@ -564,12 +573,12 @@ bool8 sub_8122DB0(void) LZ77UnCompWram(sRegionMapCursorLargeGfxLZ, gRegionMap->cursorLargeImage); break; case 5: - RegionMap_InitializeStateBasedOnPlayerLocation(); + InitMapBasedOnPlayerLocation(); gRegionMap->playerIconSpritePosX = gRegionMap->cursorPosX; gRegionMap->playerIconSpritePosY = gRegionMap->cursorPosY; gRegionMap->mapSecId = CorrectSpecialMapSecId_Internal(gRegionMap->mapSecId); - gRegionMap->iconDrawType = get_flagnr_blue_points(gRegionMap->mapSecId); - GetMapName(gRegionMap->mapSecName, gRegionMap->mapSecId, 16); + gRegionMap->mapSecType = GetMapsecType(gRegionMap->mapSecId); + GetMapName(gRegionMap->mapSecName, gRegionMap->mapSecId, MAP_NAME_LENGTH); break; case 6: if (gRegionMap->zoomed == FALSE) @@ -586,7 +595,7 @@ bool8 sub_8122DB0(void) } break; case 7: - RegionMap_GetPositionOfCursorWithinMapSection(); + GetPositionOfCursorWithinMapSec(); UpdateRegionMapVideoRegs(); gRegionMap->cursorSprite = NULL; gRegionMap->playerIconSprite = NULL; @@ -609,9 +618,9 @@ bool8 sub_8122DB0(void) return TRUE; } -void sub_8123030(u16 a0, u32 a1) +void sub_8123030(u16 color, u32 coeff) { - BlendPalettes(0x380, a1, a0); + BlendPalettes(0x380, coeff, color); CpuCopy16(gPlttBufferFaded + 0x70, gPlttBufferUnfaded + 0x70, 0x60); } @@ -631,7 +640,7 @@ void FreeRegionMapIconResources(void) } } -u8 sub_81230AC(void) +u8 DoRegionMapInputCallback(void) { return gRegionMap->inputCallback(); } @@ -640,38 +649,38 @@ static u8 ProcessRegionMapInput_Full(void) { u8 input; - input = INPUT_EVENT_NONE; + input = MAP_INPUT_NONE; gRegionMap->cursorDeltaX = 0; gRegionMap->cursorDeltaY = 0; if (gMain.heldKeys & DPAD_UP && gRegionMap->cursorPosY > MAPCURSOR_Y_MIN) { gRegionMap->cursorDeltaY = -1; - input = INPUT_EVENT_MOVE_START; + input = MAP_INPUT_MOVE_START; } if (gMain.heldKeys & DPAD_DOWN && gRegionMap->cursorPosY < MAPCURSOR_Y_MAX) { gRegionMap->cursorDeltaY = +1; - input = INPUT_EVENT_MOVE_START; + input = MAP_INPUT_MOVE_START; } if (gMain.heldKeys & DPAD_LEFT && gRegionMap->cursorPosX > MAPCURSOR_X_MIN) { gRegionMap->cursorDeltaX = -1; - input = INPUT_EVENT_MOVE_START; + input = MAP_INPUT_MOVE_START; } if (gMain.heldKeys & DPAD_RIGHT && gRegionMap->cursorPosX < MAPCURSOR_X_MAX) { gRegionMap->cursorDeltaX = +1; - input = INPUT_EVENT_MOVE_START; + input = MAP_INPUT_MOVE_START; } if (gMain.newKeys & A_BUTTON) { - input = INPUT_EVENT_A_BUTTON; + input = MAP_INPUT_A_BUTTON; } else if (gMain.newKeys & B_BUTTON) { - input = INPUT_EVENT_B_BUTTON; + input = MAP_INPUT_B_BUTTON; } - if (input == INPUT_EVENT_MOVE_START) + if (input == MAP_INPUT_MOVE_START) { gRegionMap->cursorMovementFrameCounter = 4; gRegionMap->inputCallback = MoveRegionMapCursor_Full; @@ -684,9 +693,8 @@ static u8 MoveRegionMapCursor_Full(void) u16 mapSecId; if (gRegionMap->cursorMovementFrameCounter != 0) - { - return INPUT_EVENT_MOVE_CONT; - } + return MAP_INPUT_MOVE_CONT; + if (gRegionMap->cursorDeltaX > 0) { gRegionMap->cursorPosX++; @@ -703,54 +711,55 @@ static u8 MoveRegionMapCursor_Full(void) { gRegionMap->cursorPosY--; } - mapSecId = GetRegionMapSectionIdAt_Internal(gRegionMap->cursorPosX, gRegionMap->cursorPosY); - gRegionMap->iconDrawType = get_flagnr_blue_points(mapSecId); + + mapSecId = GetMapSecIdAt(gRegionMap->cursorPosX, gRegionMap->cursorPosY); + gRegionMap->mapSecType = GetMapsecType(mapSecId); if (mapSecId != gRegionMap->mapSecId) { gRegionMap->mapSecId = mapSecId; - GetMapName(gRegionMap->mapSecName, gRegionMap->mapSecId, 16); + GetMapName(gRegionMap->mapSecName, gRegionMap->mapSecId, MAP_NAME_LENGTH); } - RegionMap_GetPositionOfCursorWithinMapSection(); + GetPositionOfCursorWithinMapSec(); gRegionMap->inputCallback = ProcessRegionMapInput_Full; - return INPUT_EVENT_MOVE_END; + return MAP_INPUT_MOVE_END; } static u8 ProcessRegionMapInput_Zoomed(void) { u8 input; - input = INPUT_EVENT_NONE; + input = MAP_INPUT_NONE; gRegionMap->zoomedCursorDeltaX = 0; gRegionMap->zoomedCursorDeltaY = 0; if (gMain.heldKeys & DPAD_UP && gRegionMap->scrollY > -0x34) { gRegionMap->zoomedCursorDeltaY = -1; - input = INPUT_EVENT_MOVE_START; + input = MAP_INPUT_MOVE_START; } if (gMain.heldKeys & DPAD_DOWN && gRegionMap->scrollY < 0x3c) { gRegionMap->zoomedCursorDeltaY = +1; - input = INPUT_EVENT_MOVE_START; + input = MAP_INPUT_MOVE_START; } if (gMain.heldKeys & DPAD_LEFT && gRegionMap->scrollX > -0x2c) { gRegionMap->zoomedCursorDeltaX = -1; - input = INPUT_EVENT_MOVE_START; + input = MAP_INPUT_MOVE_START; } if (gMain.heldKeys & DPAD_RIGHT && gRegionMap->scrollX < 0xac) { gRegionMap->zoomedCursorDeltaX = +1; - input = INPUT_EVENT_MOVE_START; + input = MAP_INPUT_MOVE_START; } if (gMain.newKeys & A_BUTTON) { - input = INPUT_EVENT_A_BUTTON; + input = MAP_INPUT_A_BUTTON; } if (gMain.newKeys & B_BUTTON) { - input = INPUT_EVENT_B_BUTTON; + input = MAP_INPUT_B_BUTTON; } - if (input == INPUT_EVENT_MOVE_START) + if (input == MAP_INPUT_MOVE_START) { gRegionMap->inputCallback = MoveRegionMapCursor_Zoomed; gRegionMap->zoomedCursorMovementFrameCounter = 0; @@ -776,23 +785,23 @@ static u8 MoveRegionMapCursor_Zoomed(void) { gRegionMap->zoomedCursorPosX = x; gRegionMap->zoomedCursorPosY = y; - mapSecId = GetRegionMapSectionIdAt_Internal(x, y); - gRegionMap->iconDrawType = get_flagnr_blue_points(mapSecId); + mapSecId = GetMapSecIdAt(x, y); + gRegionMap->mapSecType = GetMapsecType(mapSecId); if (mapSecId != gRegionMap->mapSecId) { gRegionMap->mapSecId = mapSecId; - GetMapName(gRegionMap->mapSecName, gRegionMap->mapSecId, 16); + GetMapName(gRegionMap->mapSecName, gRegionMap->mapSecId, MAP_NAME_LENGTH); } - RegionMap_GetPositionOfCursorWithinMapSection(); + GetPositionOfCursorWithinMapSec(); } gRegionMap->zoomedCursorMovementFrameCounter = 0; gRegionMap->inputCallback = ProcessRegionMapInput_Zoomed; - return INPUT_EVENT_MOVE_END; + return MAP_INPUT_MOVE_END; } - return INPUT_EVENT_MOVE_CONT; + return MAP_INPUT_MOVE_CONT; } -void sub_8123418(void) +void SetRegionMapDataForZoom(void) { if (gRegionMap->zoomed == FALSE) { @@ -827,13 +836,13 @@ void sub_8123418(void) HideRegionMapPlayerIcon(); } -bool8 sub_8123514(void) +bool8 UpdateRegionMapZoom(void) { bool8 retVal; if (gRegionMap->unk_06e >= 16) { - return 0; + return FALSE; } gRegionMap->unk_06e++; if (gRegionMap->unk_06e == 16) @@ -945,7 +954,7 @@ void PokedexAreaScreen_UpdateRegionMapVariablesAndVideoRegs(s16 x, s16 y) } } -static u16 GetRegionMapSectionIdAt_Internal(u16 x, u16 y) +static u16 GetMapSecIdAt(u16 x, u16 y) { if (y < MAPCURSOR_Y_MIN || y > MAPCURSOR_Y_MAX || x < MAPCURSOR_X_MIN || x > MAPCURSOR_X_MAX) { @@ -956,7 +965,7 @@ static u16 GetRegionMapSectionIdAt_Internal(u16 x, u16 y) return sRegionMap_MapSectionLayout[x + y * MAP_WIDTH]; } -static void RegionMap_InitializeStateBasedOnPlayerLocation(void) +static void InitMapBasedOnPlayerLocation(void) { const struct MapHeader *mapHeader; u16 mapWidth; @@ -978,80 +987,76 @@ static void RegionMap_InitializeStateBasedOnPlayerLocation(void) switch (GetMapTypeByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum)) { - default: - case MAP_TYPE_TOWN: - case MAP_TYPE_CITY: - case MAP_TYPE_ROUTE: - case MAP_TYPE_UNDERWATER: - case MAP_TYPE_OCEAN_ROUTE: - gRegionMap->mapSecId = gMapHeader.regionMapSectionId; - gRegionMap->playerIsInCave = FALSE; - mapWidth = gMapHeader.mapLayout->width; - mapHeight = gMapHeader.mapLayout->height; - x = gSaveBlock1Ptr->pos.x; - y = gSaveBlock1Ptr->pos.y; - if (gRegionMap->mapSecId == MAPSEC_UNDERWATER_128 || gRegionMap->mapSecId == MAPSEC_UNDERWATER_MARINE_CAVE) - { - gRegionMap->playerIsInCave = TRUE; - } - break; - case MAP_TYPE_UNDERGROUND: - case MAP_TYPE_UNUSED_2: - if (gMapHeader.flags & MAP_ALLOW_ESCAPE_ROPE) - { - mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->escapeWarp.mapGroup, gSaveBlock1Ptr->escapeWarp.mapNum); - gRegionMap->mapSecId = mapHeader->regionMapSectionId; - gRegionMap->playerIsInCave = TRUE; - mapWidth = mapHeader->mapLayout->width; - mapHeight = mapHeader->mapLayout->height; - x = gSaveBlock1Ptr->escapeWarp.x; - y = gSaveBlock1Ptr->escapeWarp.y; - } - else - { - gRegionMap->mapSecId = gMapHeader.regionMapSectionId; - gRegionMap->playerIsInCave = TRUE; - mapWidth = 1; - mapHeight = 1; - x = 1; - y = 1; - } - break; - case MAP_TYPE_SECRET_BASE: - mapHeader = Overworld_GetMapHeaderByGroupAndId((u16)gSaveBlock1Ptr->dynamicWarp.mapGroup, (u16)gSaveBlock1Ptr->dynamicWarp.mapNum); + default: + case MAP_TYPE_TOWN: + case MAP_TYPE_CITY: + case MAP_TYPE_ROUTE: + case MAP_TYPE_UNDERWATER: + case MAP_TYPE_OCEAN_ROUTE: + gRegionMap->mapSecId = gMapHeader.regionMapSectionId; + gRegionMap->playerIsInCave = FALSE; + mapWidth = gMapHeader.mapLayout->width; + mapHeight = gMapHeader.mapLayout->height; + x = gSaveBlock1Ptr->pos.x; + y = gSaveBlock1Ptr->pos.y; + if (gRegionMap->mapSecId == MAPSEC_UNDERWATER_128 || gRegionMap->mapSecId == MAPSEC_UNDERWATER_MARINE_CAVE) + gRegionMap->playerIsInCave = TRUE; + break; + case MAP_TYPE_UNDERGROUND: + case MAP_TYPE_UNUSED_2: + if (gMapHeader.flags & MAP_ALLOW_ESCAPE_ROPE) + { + mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->escapeWarp.mapGroup, gSaveBlock1Ptr->escapeWarp.mapNum); gRegionMap->mapSecId = mapHeader->regionMapSectionId; gRegionMap->playerIsInCave = TRUE; mapWidth = mapHeader->mapLayout->width; mapHeight = mapHeader->mapLayout->height; - x = gSaveBlock1Ptr->dynamicWarp.x; - y = gSaveBlock1Ptr->dynamicWarp.y; - break; - case MAP_TYPE_INDOOR: + x = gSaveBlock1Ptr->escapeWarp.x; + y = gSaveBlock1Ptr->escapeWarp.y; + } + else + { gRegionMap->mapSecId = gMapHeader.regionMapSectionId; - if (gRegionMap->mapSecId != MAPSEC_DYNAMIC) - { - warp = &gSaveBlock1Ptr->escapeWarp; - mapHeader = Overworld_GetMapHeaderByGroupAndId(warp->mapGroup, warp->mapNum); - } - else - { - warp = &gSaveBlock1Ptr->dynamicWarp; - mapHeader = Overworld_GetMapHeaderByGroupAndId(warp->mapGroup, warp->mapNum); - gRegionMap->mapSecId = mapHeader->regionMapSectionId; - } - if (RegionMap_IsPlayerInCave(gRegionMap->mapSecId)) - { - gRegionMap->playerIsInCave = TRUE; - } - else - { - gRegionMap->playerIsInCave = FALSE; - } - mapWidth = mapHeader->mapLayout->width; - mapHeight = mapHeader->mapLayout->height; - x = warp->x; - y = warp->y; - break; + gRegionMap->playerIsInCave = TRUE; + mapWidth = 1; + mapHeight = 1; + x = 1; + y = 1; + } + break; + case MAP_TYPE_SECRET_BASE: + mapHeader = Overworld_GetMapHeaderByGroupAndId((u16)gSaveBlock1Ptr->dynamicWarp.mapGroup, (u16)gSaveBlock1Ptr->dynamicWarp.mapNum); + gRegionMap->mapSecId = mapHeader->regionMapSectionId; + gRegionMap->playerIsInCave = TRUE; + mapWidth = mapHeader->mapLayout->width; + mapHeight = mapHeader->mapLayout->height; + x = gSaveBlock1Ptr->dynamicWarp.x; + y = gSaveBlock1Ptr->dynamicWarp.y; + break; + case MAP_TYPE_INDOOR: + gRegionMap->mapSecId = gMapHeader.regionMapSectionId; + if (gRegionMap->mapSecId != MAPSEC_DYNAMIC) + { + warp = &gSaveBlock1Ptr->escapeWarp; + mapHeader = Overworld_GetMapHeaderByGroupAndId(warp->mapGroup, warp->mapNum); + } + else + { + warp = &gSaveBlock1Ptr->dynamicWarp; + mapHeader = Overworld_GetMapHeaderByGroupAndId(warp->mapGroup, warp->mapNum); + gRegionMap->mapSecId = mapHeader->regionMapSectionId; + } + + if (IsPlayerInAquaHideout(gRegionMap->mapSecId)) + gRegionMap->playerIsInCave = TRUE; + else + gRegionMap->playerIsInCave = FALSE; + + mapWidth = mapHeader->mapLayout->width; + mapHeight = mapHeader->mapLayout->height; + x = warp->x; + y = warp->y; + break; } xOnMap = x; @@ -1080,51 +1085,36 @@ static void RegionMap_InitializeStateBasedOnPlayerLocation(void) switch (gRegionMap->mapSecId) { - case MAPSEC_ROUTE_114: - if (y != 0) - { - x = 0; - } - break; - case MAPSEC_ROUTE_126: - case MAPSEC_UNDERWATER_125: + case MAPSEC_ROUTE_114: + if (y != 0) x = 0; - if (gSaveBlock1Ptr->pos.x > 32) - { - x = 1; - } - if (gSaveBlock1Ptr->pos.x > 0x33) - { - x++; - } - y = 0; - if (gSaveBlock1Ptr->pos.y > 0x25) - { - y = 1; - } - if (gSaveBlock1Ptr->pos.y > 0x38) - { - y++; - } - break; - case MAPSEC_ROUTE_121: - x = 0; - if (xOnMap > 14) - { - x = 1; - } - if (xOnMap > 0x1C) - { - x++; - } - if (xOnMap > 0x36) - { - x++; - } - break; - case MAPSEC_UNDERWATER_MARINE_CAVE: - RegionMap_GetMarineCaveCoords(&gRegionMap->cursorPosX, &gRegionMap->cursorPosY); - return; + break; + case MAPSEC_ROUTE_126: + case MAPSEC_UNDERWATER_125: + x = 0; + if (gSaveBlock1Ptr->pos.x > 32) + x++; + if (gSaveBlock1Ptr->pos.x > 51) + x++; + + y = 0; + if (gSaveBlock1Ptr->pos.y > 37) + y++; + if (gSaveBlock1Ptr->pos.y > 56) + y++; + break; + case MAPSEC_ROUTE_121: + x = 0; + if (xOnMap > 14) + x++; + if (xOnMap > 28) + x++; + if (xOnMap > 54) + x++; + break; + case MAPSEC_UNDERWATER_MARINE_CAVE: + GetMarineCaveCoords(&gRegionMap->cursorPosX, &gRegionMap->cursorPosY); + return; } gRegionMap->cursorPosX = gRegionMapEntries[gRegionMap->mapSecId].x + x + MAPCURSOR_X_MIN; gRegionMap->cursorPosY = gRegionMapEntries[gRegionMap->mapSecId].y + y + MAPCURSOR_Y_MIN; @@ -1145,104 +1135,104 @@ static void RegionMap_InitializeStateBasedOnSSTidalLocation(void) x = 0; switch (GetSSTidalLocation(&mapGroup, &mapNum, &xOnMap, &yOnMap)) { - case SS_TIDAL_LOCATION_SLATEPORT: - gRegionMap->mapSecId = MAPSEC_SLATEPORT_CITY; - break; - case SS_TIDAL_LOCATION_LILYCOVE: - gRegionMap->mapSecId = MAPSEC_LILYCOVE_CITY; - break; - case SS_TIDAL_LOCATION_ROUTE124: - gRegionMap->mapSecId = MAPSEC_ROUTE_124; - break; - case SS_TIDAL_LOCATION_ROUTE131: - gRegionMap->mapSecId = MAPSEC_ROUTE_131; - break; - default: - case SS_TIDAL_LOCATION_CURRENTS: - mapHeader = Overworld_GetMapHeaderByGroupAndId(mapGroup, mapNum); + case SS_TIDAL_LOCATION_SLATEPORT: + gRegionMap->mapSecId = MAPSEC_SLATEPORT_CITY; + break; + case SS_TIDAL_LOCATION_LILYCOVE: + gRegionMap->mapSecId = MAPSEC_LILYCOVE_CITY; + break; + case SS_TIDAL_LOCATION_ROUTE124: + gRegionMap->mapSecId = MAPSEC_ROUTE_124; + break; + case SS_TIDAL_LOCATION_ROUTE131: + gRegionMap->mapSecId = MAPSEC_ROUTE_131; + break; + default: + case SS_TIDAL_LOCATION_CURRENTS: + mapHeader = Overworld_GetMapHeaderByGroupAndId(mapGroup, mapNum); - gRegionMap->mapSecId = mapHeader->regionMapSectionId; - dimensionScale = mapHeader->mapLayout->width / gRegionMapEntries[gRegionMap->mapSecId].width; - if (dimensionScale == 0) - dimensionScale = 1; - x = xOnMap / dimensionScale; - if (x >= gRegionMapEntries[gRegionMap->mapSecId].width) - x = gRegionMapEntries[gRegionMap->mapSecId].width - 1; + gRegionMap->mapSecId = mapHeader->regionMapSectionId; + dimensionScale = mapHeader->mapLayout->width / gRegionMapEntries[gRegionMap->mapSecId].width; + if (dimensionScale == 0) + dimensionScale = 1; + x = xOnMap / dimensionScale; + if (x >= gRegionMapEntries[gRegionMap->mapSecId].width) + x = gRegionMapEntries[gRegionMap->mapSecId].width - 1; - dimensionScale = mapHeader->mapLayout->height / gRegionMapEntries[gRegionMap->mapSecId].height; - if (dimensionScale == 0) - dimensionScale = 1; - y = yOnMap / dimensionScale; - if (y >= gRegionMapEntries[gRegionMap->mapSecId].height) - y = gRegionMapEntries[gRegionMap->mapSecId].height - 1; - break; + dimensionScale = mapHeader->mapLayout->height / gRegionMapEntries[gRegionMap->mapSecId].height; + if (dimensionScale == 0) + dimensionScale = 1; + y = yOnMap / dimensionScale; + if (y >= gRegionMapEntries[gRegionMap->mapSecId].height) + y = gRegionMapEntries[gRegionMap->mapSecId].height - 1; + break; } gRegionMap->playerIsInCave = FALSE; gRegionMap->cursorPosX = gRegionMapEntries[gRegionMap->mapSecId].x + x + MAPCURSOR_X_MIN; gRegionMap->cursorPosY = gRegionMapEntries[gRegionMap->mapSecId].y + y + MAPCURSOR_Y_MIN; } -static u8 get_flagnr_blue_points(u16 mapSecId) +static u8 GetMapsecType(u16 mapSecId) { switch (mapSecId) { - case MAPSEC_NONE: - return MAPSECTYPE_NONE; - case MAPSEC_LITTLEROOT_TOWN: - return FlagGet(FLAG_VISITED_LITTLEROOT_TOWN) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; - case MAPSEC_OLDALE_TOWN: - return FlagGet(FLAG_VISITED_OLDALE_TOWN) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; - case MAPSEC_DEWFORD_TOWN: - return FlagGet(FLAG_VISITED_DEWFORD_TOWN) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; - case MAPSEC_LAVARIDGE_TOWN: - return FlagGet(FLAG_VISITED_LAVARIDGE_TOWN) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; - case MAPSEC_FALLARBOR_TOWN: - return FlagGet(FLAG_VISITED_FALLARBOR_TOWN) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; - case MAPSEC_VERDANTURF_TOWN: - return FlagGet(FLAG_VISITED_VERDANTURF_TOWN) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; - case MAPSEC_PACIFIDLOG_TOWN: - return FlagGet(FLAG_VISITED_PACIFIDLOG_TOWN) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; - case MAPSEC_PETALBURG_CITY: - return FlagGet(FLAG_VISITED_PETALBURG_CITY) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; - case MAPSEC_SLATEPORT_CITY: - return FlagGet(FLAG_VISITED_SLATEPORT_CITY) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; - case MAPSEC_MAUVILLE_CITY: - return FlagGet(FLAG_VISITED_MAUVILLE_CITY) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; - case MAPSEC_RUSTBORO_CITY: - return FlagGet(FLAG_VISITED_RUSTBORO_CITY) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; - case MAPSEC_FORTREE_CITY: - return FlagGet(FLAG_VISITED_FORTREE_CITY) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; - case MAPSEC_LILYCOVE_CITY: - return FlagGet(FLAG_VISITED_LILYCOVE_CITY) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; - case MAPSEC_MOSSDEEP_CITY: - return FlagGet(FLAG_VISITED_MOSSDEEP_CITY) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; - case MAPSEC_SOOTOPOLIS_CITY: - return FlagGet(FLAG_VISITED_SOOTOPOLIS_CITY) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; - case MAPSEC_EVER_GRANDE_CITY: - return FlagGet(FLAG_VISITED_EVER_GRANDE_CITY) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; - case MAPSEC_BATTLE_FRONTIER: - return FlagGet(FLAG_LANDMARK_BATTLE_FRONTIER) ? MAPSECTYPE_BATTLE_FRONTIER : MAPSECTYPE_NONE; - case MAPSEC_SOUTHERN_ISLAND: - return FlagGet(FLAG_LANDMARK_SOUTHERN_ISLAND) ? MAPSECTYPE_PLAIN : MAPSECTYPE_NONE; - default: - return MAPSECTYPE_PLAIN; + case MAPSEC_NONE: + return MAPSECTYPE_NONE; + case MAPSEC_LITTLEROOT_TOWN: + return FlagGet(FLAG_VISITED_LITTLEROOT_TOWN) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; + case MAPSEC_OLDALE_TOWN: + return FlagGet(FLAG_VISITED_OLDALE_TOWN) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; + case MAPSEC_DEWFORD_TOWN: + return FlagGet(FLAG_VISITED_DEWFORD_TOWN) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; + case MAPSEC_LAVARIDGE_TOWN: + return FlagGet(FLAG_VISITED_LAVARIDGE_TOWN) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; + case MAPSEC_FALLARBOR_TOWN: + return FlagGet(FLAG_VISITED_FALLARBOR_TOWN) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; + case MAPSEC_VERDANTURF_TOWN: + return FlagGet(FLAG_VISITED_VERDANTURF_TOWN) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; + case MAPSEC_PACIFIDLOG_TOWN: + return FlagGet(FLAG_VISITED_PACIFIDLOG_TOWN) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; + case MAPSEC_PETALBURG_CITY: + return FlagGet(FLAG_VISITED_PETALBURG_CITY) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; + case MAPSEC_SLATEPORT_CITY: + return FlagGet(FLAG_VISITED_SLATEPORT_CITY) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; + case MAPSEC_MAUVILLE_CITY: + return FlagGet(FLAG_VISITED_MAUVILLE_CITY) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; + case MAPSEC_RUSTBORO_CITY: + return FlagGet(FLAG_VISITED_RUSTBORO_CITY) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; + case MAPSEC_FORTREE_CITY: + return FlagGet(FLAG_VISITED_FORTREE_CITY) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; + case MAPSEC_LILYCOVE_CITY: + return FlagGet(FLAG_VISITED_LILYCOVE_CITY) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; + case MAPSEC_MOSSDEEP_CITY: + return FlagGet(FLAG_VISITED_MOSSDEEP_CITY) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; + case MAPSEC_SOOTOPOLIS_CITY: + return FlagGet(FLAG_VISITED_SOOTOPOLIS_CITY) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; + case MAPSEC_EVER_GRANDE_CITY: + return FlagGet(FLAG_VISITED_EVER_GRANDE_CITY) ? MAPSECTYPE_CITY_CANFLY : MAPSECTYPE_CITY_CANTFLY; + case MAPSEC_BATTLE_FRONTIER: + return FlagGet(FLAG_LANDMARK_BATTLE_FRONTIER) ? MAPSECTYPE_BATTLE_FRONTIER : MAPSECTYPE_NONE; + case MAPSEC_SOUTHERN_ISLAND: + return FlagGet(FLAG_LANDMARK_SOUTHERN_ISLAND) ? MAPSECTYPE_ROUTE : MAPSECTYPE_NONE; + default: + return MAPSECTYPE_ROUTE; } } -u16 GetRegionMapSectionIdAt(u16 x, u16 y) +u16 GetRegionMapSecIdAt(u16 x, u16 y) { - return GetRegionMapSectionIdAt_Internal(x, y); + return GetMapSecIdAt(x, y); } static u16 CorrectSpecialMapSecId_Internal(u16 mapSecId) { u32 i; - for (i = 0; i < 3; i++) + for (i = 0; i < ARRAY_COUNT(sMarineCaveMapSecIds); i++) { - if (sRegionMap_MarineCaveMapSecIds[i] == mapSecId) + if (sMarineCaveMapSecIds[i] == mapSecId) { - return RegionMap_GetTerraCaveMapSecId(); + return GetTerraOrMarineCaveMapSecId(); } } for (i = 0; sRegionMap_SpecialPlaceLocations[i][0] != MAPSEC_NONE; i++) @@ -1255,42 +1245,43 @@ static u16 CorrectSpecialMapSecId_Internal(u16 mapSecId) return mapSecId; } -static u16 RegionMap_GetTerraCaveMapSecId(void) +static u16 GetTerraOrMarineCaveMapSecId(void) { s16 idx; idx = VarGet(VAR_ABNORMAL_WEATHER_LOCATION) - 1; - if (idx < 0 || idx > 15) - { + + if (idx < 0 || idx > ABNORMAL_WEATHER_LOCATIONS - 1) idx = 0; - } - return sTerraCaveMapSectionIds[idx]; + + return sTerraOrMarineCaveMapSecIds[idx]; } -static void RegionMap_GetMarineCaveCoords(u16 *x, u16 *y) +static void GetMarineCaveCoords(u16 *x, u16 *y) { u16 idx; idx = VarGet(VAR_ABNORMAL_WEATHER_LOCATION); - if (idx < 9 || idx > 16) + if (idx < MARINE_CAVE_LOCATIONS_START || idx > ABNORMAL_WEATHER_LOCATIONS) { - idx = 9; + idx = MARINE_CAVE_LOCATIONS_START; } - idx -= 9; - *x = sTerraCaveLocationCoords[idx].x + MAPCURSOR_X_MIN; - *y = sTerraCaveLocationCoords[idx].y + MAPCURSOR_Y_MIN; + idx -= MARINE_CAVE_LOCATIONS_START; + + *x = sMarineCaveLocationCoords[idx].x + MAPCURSOR_X_MIN; + *y = sMarineCaveLocationCoords[idx].y + MAPCURSOR_Y_MIN; } -static bool32 RegionMap_IsPlayerInCave(u8 mapSecId) +// Probably meant to be an "IsPlayerInIndoorDungeon" function, but in practice it only has the one mapsec +// Additionally, because the mapsec doesnt exist in Emerald, this function always returns FALSE +static bool32 IsPlayerInAquaHideout(u8 mapSecId) { u32 i; - for (i = 0; i < 1; i++) + for (i = 0; i < ARRAY_COUNT(sMapSecAquaHideoutOld); i++) { - if (sRegionMap_MapSecAquaHideoutOld[i] == mapSecId) - { + if (sMapSecAquaHideoutOld[i] == mapSecId) return TRUE; - } } return FALSE; } @@ -1300,7 +1291,7 @@ u16 CorrectSpecialMapSecId(u16 mapSecId) return CorrectSpecialMapSecId_Internal(mapSecId); } -static void RegionMap_GetPositionOfCursorWithinMapSection(void) +static void GetPositionOfCursorWithinMapSec(void) { u16 x; u16 y; @@ -1339,7 +1330,7 @@ static void RegionMap_GetPositionOfCursorWithinMapSection(void) else { x--; - if (GetRegionMapSectionIdAt_Internal(x, y) == gRegionMap->mapSecId) + if (GetMapSecIdAt(x, y) == gRegionMap->mapSecId) { posWithinMapSec++; } @@ -1358,7 +1349,7 @@ static bool8 RegionMap_IsMapSecIdInNextRow(u16 y) } for (x = MAPCURSOR_X_MIN; x <= MAPCURSOR_X_MAX; x++) { - if (GetRegionMapSectionIdAt_Internal(x, y) == gRegionMap->mapSecId) + if (GetMapSecIdAt(x, y) == gRegionMap->mapSecId) { return TRUE; } @@ -1366,7 +1357,7 @@ static bool8 RegionMap_IsMapSecIdInNextRow(u16 y) return FALSE; } -static void SpriteCallback_CursorFull(struct Sprite *sprite) +static void SpriteCB_CursorMapFull(struct Sprite *sprite) { if (gRegionMap->cursorMovementFrameCounter != 0) { @@ -1376,7 +1367,7 @@ static void SpriteCallback_CursorFull(struct Sprite *sprite) } } -static void SpriteCallback_CursorZoomed(struct Sprite *sprite) +static void SpriteCB_CursorMapZoomed(struct Sprite *sprite) { } @@ -1400,13 +1391,13 @@ void CreateRegionMapCursor(u16 tileTag, u16 paletteTag) { sheet.data = gRegionMap->cursorSmallImage; sheet.size = sizeof(gRegionMap->cursorSmallImage); - template.callback = SpriteCallback_CursorFull; + template.callback = SpriteCB_CursorMapFull; } else { sheet.data = gRegionMap->cursorLargeImage; sheet.size = sizeof(gRegionMap->cursorLargeImage); - template.callback = SpriteCallback_CursorZoomed; + template.callback = SpriteCB_CursorMapZoomed; } LoadSpriteSheet(&sheet); LoadSpritePalette(&palette); @@ -1443,12 +1434,14 @@ static void FreeRegionMapCursorSprite(void) } } -void sub_8124268(void) +// Unused +static void SetUnkCursorSpriteData(void) { gRegionMap->cursorSprite->data[3] = TRUE; } -void sub_8124278(void) +// Unused +static void ClearUnkCursorSpriteData(void) { gRegionMap->cursorSprite->data[3] = FALSE; } @@ -1460,7 +1453,7 @@ void CreateRegionMapPlayerIcon(u16 tileTag, u16 paletteTag) struct SpritePalette palette = {sRegionMapPlayerIcon_BrendanPal, paletteTag}; struct SpriteTemplate template = {tileTag, paletteTag, &sRegionMapPlayerIconOam, sRegionMapPlayerIconAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy}; - if (sub_8124668(gMapHeader.regionMapSectionId)) + if (IsEventIslandMapSecId(gMapHeader.regionMapSectionId)) { gRegionMap->playerIconSprite = NULL; return; @@ -1478,13 +1471,13 @@ void CreateRegionMapPlayerIcon(u16 tileTag, u16 paletteTag) { gRegionMap->playerIconSprite->pos1.x = gRegionMap->playerIconSpritePosX * 8 + 4; gRegionMap->playerIconSprite->pos1.y = gRegionMap->playerIconSpritePosY * 8 + 4; - gRegionMap->playerIconSprite->callback = RegionMapPlayerIconSpriteCallback_Full; + gRegionMap->playerIconSprite->callback = SpriteCB_PlayerIconMapFull; } else { gRegionMap->playerIconSprite->pos1.x = gRegionMap->playerIconSpritePosX * 16 - 0x30; gRegionMap->playerIconSprite->pos1.y = gRegionMap->playerIconSpritePosY * 16 - 0x42; - gRegionMap->playerIconSprite->callback = RegionMapPlayerIconSpriteCallback_Zoomed; + gRegionMap->playerIconSprite->callback = SpriteCB_PlayerIconMapZoomed; } } @@ -1505,7 +1498,7 @@ static void UnhideRegionMapPlayerIcon(void) { gRegionMap->playerIconSprite->pos1.x = gRegionMap->playerIconSpritePosX * 16 - 0x30; gRegionMap->playerIconSprite->pos1.y = gRegionMap->playerIconSpritePosY * 16 - 0x42; - gRegionMap->playerIconSprite->callback = RegionMapPlayerIconSpriteCallback_Zoomed; + gRegionMap->playerIconSprite->callback = SpriteCB_PlayerIconMapZoomed; gRegionMap->playerIconSprite->invisible = FALSE; } else @@ -1514,13 +1507,13 @@ static void UnhideRegionMapPlayerIcon(void) gRegionMap->playerIconSprite->pos1.y = gRegionMap->playerIconSpritePosY * 8 + 4; gRegionMap->playerIconSprite->pos2.x = 0; gRegionMap->playerIconSprite->pos2.y = 0; - gRegionMap->playerIconSprite->callback = RegionMapPlayerIconSpriteCallback_Full; + gRegionMap->playerIconSprite->callback = SpriteCB_PlayerIconMapFull; gRegionMap->playerIconSprite->invisible = FALSE; } } } -static void RegionMapPlayerIconSpriteCallback_Zoomed(struct Sprite *sprite) +static void SpriteCB_PlayerIconMapZoomed(struct Sprite *sprite) { sprite->pos2.x = -2 * gRegionMap->scrollX; sprite->pos2.y = -2 * gRegionMap->scrollY; @@ -1536,7 +1529,7 @@ static void RegionMapPlayerIconSpriteCallback_Zoomed(struct Sprite *sprite) } if (sprite->data[2] == TRUE) { - RegionMapPlayerIconSpriteCallback(sprite); + SpriteCB_PlayerIcon(sprite); } else { @@ -1544,12 +1537,12 @@ static void RegionMapPlayerIconSpriteCallback_Zoomed(struct Sprite *sprite) } } -static void RegionMapPlayerIconSpriteCallback_Full(struct Sprite *sprite) +static void SpriteCB_PlayerIconMapFull(struct Sprite *sprite) { - RegionMapPlayerIconSpriteCallback(sprite); + SpriteCB_PlayerIcon(sprite); } -static void RegionMapPlayerIconSpriteCallback(struct Sprite *sprite) +static void SpriteCB_PlayerIcon(struct Sprite *sprite) { if (gRegionMap->blinkPlayerIcon) { @@ -1565,12 +1558,10 @@ static void RegionMapPlayerIconSpriteCallback(struct Sprite *sprite) } } -void sub_812454C(void) +void TrySetPlayerIconBlink(void) { if (gRegionMap->playerIsInCave) - { gRegionMap->blinkPlayerIcon = TRUE; - } } u8 *GetMapName(u8 *dest, u16 regionMapId, u16 padLength) @@ -1610,28 +1601,24 @@ u8 *GetMapNameGeneric(u8 *dest, u16 mapSecId) { switch (mapSecId) { - case MAPSEC_DYNAMIC: - return StringCopy(dest, gText_Ferry); - case MAPSEC_SECRET_BASE: - return StringCopy(dest, gText_SecretBase); - default: - return GetMapName(dest, mapSecId, 0); + case MAPSEC_DYNAMIC: + return StringCopy(dest, gText_Ferry); + case MAPSEC_SECRET_BASE: + return StringCopy(dest, gText_SecretBase); + default: + return GetMapName(dest, mapSecId, 0); } } -u8 *sub_8124610(u8 *dest, u16 mapSecId) +u8 *GetMapNameHandleAquaHideout(u8 *dest, u16 mapSecId) { if (mapSecId == MAPSEC_AQUA_HIDEOUT_OLD) - { return StringCopy(dest, gText_Hideout); - } else - { return GetMapNameGeneric(dest, mapSecId); - } } -void sub_8124630(u16 mapSecId, u16 *x, u16 *y, u16 *width, u16 *height) +static void GetMapSecDimensions(u16 mapSecId, u16 *x, u16 *y, u16 *width, u16 *height) { *x = gRegionMapEntries[mapSecId].x; *y = gRegionMapEntries[mapSecId].y; @@ -1639,172 +1626,170 @@ void sub_8124630(u16 mapSecId, u16 *x, u16 *y, u16 *width, u16 *height) *height = gRegionMapEntries[mapSecId].height; } -bool8 sub_8124658(void) +bool8 IsRegionMapZoomed(void) { return gRegionMap->zoomed; } -bool32 sub_8124668(u8 mapSecId) +bool32 IsEventIslandMapSecId(u8 mapSecId) { u32 i; - for (i = 0; i < 3; i++) + for (i = 0; i < ARRAY_COUNT(sMapSecIdsOffMap); i++) { - if (mapSecId == sRegionMapEventSectionIds[i]) - { + if (mapSecId == sMapSecIdsOffMap[i]) return TRUE; - } } return FALSE; } -void MCB2_FlyMap(void) +void CB2_OpenFlyMap(void) { switch (gMain.state) { - case 0: - SetVBlankCallback(NULL); - SetGpuReg(REG_OFFSET_DISPCNT, 0); - SetGpuReg(REG_OFFSET_BG0HOFS, 0); - SetGpuReg(REG_OFFSET_BG0VOFS, 0); - SetGpuReg(REG_OFFSET_BG1HOFS, 0); - SetGpuReg(REG_OFFSET_BG1VOFS, 0); - SetGpuReg(REG_OFFSET_BG2VOFS, 0); - SetGpuReg(REG_OFFSET_BG2HOFS, 0); - SetGpuReg(REG_OFFSET_BG3HOFS, 0); - SetGpuReg(REG_OFFSET_BG3VOFS, 0); - sFlyMap = malloc(sizeof(*sFlyMap)); - if (sFlyMap == NULL) - { - SetMainCallback2(CB2_ReturnToFieldWithOpenMenu); - } - else - { - ResetPaletteFade(); - ResetSpriteData(); - FreeSpriteTileRanges(); - FreeAllSpritePalettes(); - gMain.state++; - } - break; - case 1: - ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(1, gUnknown_085A1EE4, 3); + case 0: + SetVBlankCallback(NULL); + SetGpuReg(REG_OFFSET_DISPCNT, 0); + SetGpuReg(REG_OFFSET_BG0HOFS, 0); + SetGpuReg(REG_OFFSET_BG0VOFS, 0); + SetGpuReg(REG_OFFSET_BG1HOFS, 0); + SetGpuReg(REG_OFFSET_BG1VOFS, 0); + SetGpuReg(REG_OFFSET_BG2VOFS, 0); + SetGpuReg(REG_OFFSET_BG2HOFS, 0); + SetGpuReg(REG_OFFSET_BG3HOFS, 0); + SetGpuReg(REG_OFFSET_BG3VOFS, 0); + sFlyMap = malloc(sizeof(*sFlyMap)); + if (sFlyMap == NULL) + { + SetMainCallback2(CB2_ReturnToFieldWithOpenMenu); + } + else + { + ResetPaletteFade(); + ResetSpriteData(); + FreeSpriteTileRanges(); + FreeAllSpritePalettes(); gMain.state++; - break; - case 2: - InitWindows(gUnknown_085A1EF0); - DeactivateAllTextPrinters(); - gMain.state++; - break; - case 3: - LoadUserWindowBorderGfx(0, 0x65, 0xd0); - clear_scheduled_bg_copies_to_vram(); - gMain.state++; - break; - case 4: - InitRegionMap(&sFlyMap->regionMap, FALSE); - CreateRegionMapCursor(0, 0); - CreateRegionMapPlayerIcon(1, 1); - sFlyMap->mapSecId = sFlyMap->regionMap.mapSecId; - StringFill(sFlyMap->unk_a4c, CHAR_SPACE, 16); - gUnknown_03001180 = TRUE; - sub_8124904(); - gMain.state++; - break; - case 5: - LZ77UnCompVram(sRegionMapFrameGfxLZ, (u16 *)BG_CHAR_ADDR(3)); - gMain.state++; - break; - case 6: - LZ77UnCompVram(sRegionMapFrameTilemapLZ, (u16 *)BG_SCREEN_ADDR(30)); - gMain.state++; - break; - case 7: - LoadPalette(sRegionMapFramePal, 0x10, 0x20); - PutWindowTilemap(2); - FillWindowPixelBuffer(2, PIXEL_FILL(0)); - AddTextPrinterParameterized(2, 1, gText_FlyToWhere, 0, 1, 0, NULL); - schedule_bg_copy_tilemap_to_vram(0); - gMain.state++; - break; - case 8: - sub_8124A70(); - gMain.state++; - break; - case 9: - BlendPalettes(-1, 16, 0); - SetVBlankCallback(sub_81248C0); - gMain.state++; - break; - case 10: - SetGpuReg(REG_OFFSET_BLDCNT, 0); - SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); - ShowBg(0); - ShowBg(1); - ShowBg(2); - sub_81248F4(sub_8124D14); - SetMainCallback2(sub_81248D4); - gMain.state++; - break; + } + break; + case 1: + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(1, sFlyMapBgTemplates, 3); + gMain.state++; + break; + case 2: + InitWindows(sFlyMapWindowTemplates); + DeactivateAllTextPrinters(); + gMain.state++; + break; + case 3: + LoadUserWindowBorderGfx(0, 0x65, 0xd0); + clear_scheduled_bg_copies_to_vram(); + gMain.state++; + break; + case 4: + InitRegionMap(&sFlyMap->regionMap, FALSE); + CreateRegionMapCursor(0, 0); + CreateRegionMapPlayerIcon(1, 1); + sFlyMap->mapSecId = sFlyMap->regionMap.mapSecId; + StringFill(sFlyMap->nameBuffer, CHAR_SPACE, MAP_NAME_LENGTH); + gUnknown_03001180 = TRUE; + DrawFlyDestTextWindow(); + gMain.state++; + break; + case 5: + LZ77UnCompVram(sRegionMapFrameGfxLZ, (u16 *)BG_CHAR_ADDR(3)); + gMain.state++; + break; + case 6: + LZ77UnCompVram(sRegionMapFrameTilemapLZ, (u16 *)BG_SCREEN_ADDR(30)); + gMain.state++; + break; + case 7: + LoadPalette(sRegionMapFramePal, 0x10, 0x20); + PutWindowTilemap(2); + FillWindowPixelBuffer(2, PIXEL_FILL(0)); + AddTextPrinterParameterized(2, 1, gText_FlyToWhere, 0, 1, 0, NULL); + schedule_bg_copy_tilemap_to_vram(0); + gMain.state++; + break; + case 8: + LoadFlyDestIcons(); + gMain.state++; + break; + case 9: + BlendPalettes(-1, 16, 0); + SetVBlankCallback(VBlankCB_FlyMap); + gMain.state++; + break; + case 10: + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); + ShowBg(0); + ShowBg(1); + ShowBg(2); + SetFlyMapCallback(CB_FadeInFlyMap); + SetMainCallback2(CB2_FlyMap); + gMain.state++; + break; } } -static void sub_81248C0(void) +static void VBlankCB_FlyMap(void) { LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); } -static void sub_81248D4(void) +static void CB2_FlyMap(void) { - sFlyMap->unk_000(); + sFlyMap->callback(); AnimateSprites(); BuildOamBuffer(); do_scheduled_bg_tilemap_copies_to_vram(); } -static void sub_81248F4(void callback(void)) +static void SetFlyMapCallback(void callback(void)) { - sFlyMap->unk_000 = callback; - sFlyMap->unk_004 = 0; + sFlyMap->callback = callback; + sFlyMap->state = 0; } -static void sub_8124904(void) +static void DrawFlyDestTextWindow(void) { u16 i; - bool32 flag; + bool32 namePrinted; const u8 *name; - if (sFlyMap->regionMap.iconDrawType > MAPSECTYPE_NONE && sFlyMap->regionMap.iconDrawType <= MAPSECTYPE_BATTLE_FRONTIER) + if (sFlyMap->regionMap.mapSecType > MAPSECTYPE_NONE && sFlyMap->regionMap.mapSecType <= MAPSECTYPE_BATTLE_FRONTIER) { - flag = FALSE; - for (i = 0; i < ARRAY_COUNT(gUnknown_085A1EDC); i++) + namePrinted = FALSE; + for (i = 0; i < ARRAY_COUNT(sMultiNameFlyDestinations); i++) { - if (sFlyMap->regionMap.mapSecId == gUnknown_085A1EDC[i].mapSecId) + if (sFlyMap->regionMap.mapSecId == sMultiNameFlyDestinations[i].mapSecId) { - if (FlagGet(gUnknown_085A1EDC[i].flag)) + if (FlagGet(sMultiNameFlyDestinations[i].flag)) { - StringLength(gUnknown_085A1EDC[i].name[sFlyMap->regionMap.posWithinMapSec]); - flag = TRUE; + StringLength(sMultiNameFlyDestinations[i].name[sFlyMap->regionMap.posWithinMapSec]); + namePrinted = TRUE; ClearStdWindowAndFrameToTransparent(0, FALSE); - DrawStdFrameWithCustomTileAndPalette(1, FALSE, 0x65, 0x0d); + DrawStdFrameWithCustomTileAndPalette(1, FALSE, 101, 13); AddTextPrinterParameterized(1, 1, sFlyMap->regionMap.mapSecName, 0, 1, 0, NULL); - name = gUnknown_085A1EDC[i].name[sFlyMap->regionMap.posWithinMapSec]; - AddTextPrinterParameterized(1, 1, name, GetStringRightAlignXOffset(1, name, 0x60), 0x11, 0, NULL); + name = sMultiNameFlyDestinations[i].name[sFlyMap->regionMap.posWithinMapSec]; + AddTextPrinterParameterized(1, 1, name, GetStringRightAlignXOffset(1, name, 96), 17, 0, NULL); schedule_bg_copy_tilemap_to_vram(0); gUnknown_03001180 = TRUE; } break; } } - if (!flag) + if (!namePrinted) { if (gUnknown_03001180 == TRUE) { ClearStdWindowAndFrameToTransparent(1, FALSE); - DrawStdFrameWithCustomTileAndPalette(0, FALSE, 0x65, 0x0d); + DrawStdFrameWithCustomTileAndPalette(0, FALSE, 101, 13); } else { @@ -1820,7 +1805,7 @@ static void sub_8124904(void) if (gUnknown_03001180 == TRUE) { ClearStdWindowAndFrameToTransparent(1, FALSE); - DrawStdFrameWithCustomTileAndPalette(0, FALSE, 0x65, 0x0d); + DrawStdFrameWithCustomTileAndPalette(0, FALSE, 101, 13); } FillWindowPixelBuffer(0, PIXEL_FILL(1)); CopyWindowToVram(0, 2); @@ -1830,24 +1815,28 @@ static void sub_8124904(void) } -static void sub_8124A70(void) +static void LoadFlyDestIcons(void) { struct SpriteSheet sheet; - LZ77UnCompWram(sUnknown_085A1D68, sFlyMap->unk_88c); - sheet.data = sFlyMap->unk_88c; - sheet.size = 0x1c0; + LZ77UnCompWram(sFlyTargetIcons_Gfx, sFlyMap->tileBuffer); + sheet.data = sFlyMap->tileBuffer; + sheet.size = sizeof(sFlyMap->tileBuffer); sheet.tag = 2; LoadSpriteSheet(&sheet); - LoadSpritePalette(&gUnknown_085A1F10); - sub_8124AD4(); - sub_8124BE4(); + LoadSpritePalette(&sFlyTargetIconsSpritePalette); + CreateFlyDestIcons(); + TryCreateRedOutlineFlyDestIcons(); } -static void sub_8124AD4(void) +// Sprite data for SpriteCB_FlyDestIcon +#define sIconMapSec data[0] +#define sFlickerTimer data[1] + +static void CreateFlyDestIcons(void) { u16 canFlyFlag; - u16 i; + u16 mapSecId; u16 x; u16 y; u16 width; @@ -1856,43 +1845,39 @@ static void sub_8124AD4(void) u8 spriteId; canFlyFlag = FLAG_VISITED_LITTLEROOT_TOWN; - for (i = 0; i < 16; i++) + for (mapSecId = MAPSEC_LITTLEROOT_TOWN; mapSecId <= MAPSEC_EVER_GRANDE_CITY; mapSecId++) { - sub_8124630(i, &x, &y, &width, &height); + GetMapSecDimensions(mapSecId, &x, &y, &width, &height); x = (x + MAPCURSOR_X_MIN) * 8 + 4; y = (y + MAPCURSOR_Y_MIN) * 8 + 4; + if (width == 2) - { shape = SPRITE_SHAPE(16x8); - } else if (height == 2) - { shape = SPRITE_SHAPE(8x16); - } else - { shape = SPRITE_SHAPE(8x8); - } - spriteId = CreateSprite(&gUnknown_085A1F7C, x, y, 10); + + spriteId = CreateSprite(&sFlyDestIconSpriteTemplate, x, y, 10); if (spriteId != MAX_SPRITES) { gSprites[spriteId].oam.shape = shape; + if (FlagGet(canFlyFlag)) - { - gSprites[spriteId].callback = sub_8124CBC; - } + gSprites[spriteId].callback = SpriteCB_FlyDestIcon; else - { shape += 3; - } + StartSpriteAnim(&gSprites[spriteId], shape); - gSprites[spriteId].data[0] = i; + gSprites[spriteId].sIconMapSec = mapSecId; } canFlyFlag++; } } -static void sub_8124BE4(void) +// Draw a red outline box on the mapsec if its corresponding flag has been set +// Only used for Battle Frontier, but set up to handle more +static void TryCreateRedOutlineFlyDestIcons(void) { u16 i; u16 x; @@ -1902,142 +1887,142 @@ static void sub_8124BE4(void) u16 mapSecId; u8 spriteId; - for (i = 0; sUnknown_085A1F18[i][1] != MAPSEC_NONE; i++) + for (i = 0; sRedOutlineFlyDestinations[i][1] != MAPSEC_NONE; i++) { - if (FlagGet(sUnknown_085A1F18[i][0])) + if (FlagGet(sRedOutlineFlyDestinations[i][0])) { - mapSecId = sUnknown_085A1F18[i][1]; - sub_8124630(mapSecId, &x, &y, &width, &height); + mapSecId = sRedOutlineFlyDestinations[i][1]; + GetMapSecDimensions(mapSecId, &x, &y, &width, &height); x = (x + MAPCURSOR_X_MIN) * 8; y = (y + MAPCURSOR_Y_MIN) * 8; - spriteId = CreateSprite(&gUnknown_085A1F7C, x, y, 10); + spriteId = CreateSprite(&sFlyDestIconSpriteTemplate, x, y, 10); if (spriteId != MAX_SPRITES) { gSprites[spriteId].oam.size = SPRITE_SIZE(16x16); - gSprites[spriteId].callback = sub_8124CBC; - StartSpriteAnim(&gSprites[spriteId], 6); - gSprites[spriteId].data[0] = mapSecId; + gSprites[spriteId].callback = SpriteCB_FlyDestIcon; + StartSpriteAnim(&gSprites[spriteId], FLYDESTICON_RED_OUTLINE); + gSprites[spriteId].sIconMapSec = mapSecId; } } } } -static void sub_8124CBC(struct Sprite *sprite) +// Flickers fly destination icon color (by hiding the fly icon sprite) if the cursor is currently on it +static void SpriteCB_FlyDestIcon(struct Sprite *sprite) { - if (sFlyMap->regionMap.mapSecId == sprite->data[0]) + if (sFlyMap->regionMap.mapSecId == sprite->sIconMapSec) { - if (++sprite->data[1] > 16) + if (++sprite->sFlickerTimer > 16) { - sprite->data[1] = 0; + sprite->sFlickerTimer = 0; sprite->invisible = sprite->invisible ? FALSE : TRUE; } } else { - sprite->data[1] = 16; + sprite->sFlickerTimer = 16; sprite->invisible = FALSE; } } -static void sub_8124D14(void) +#undef sIconMapSec +#undef sFlickerTimer + +static void CB_FadeInFlyMap(void) { - switch (sFlyMap->unk_004) + switch (sFlyMap->state) { - case 0: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); - sFlyMap->unk_004++; - break; - case 1: - if (!UpdatePaletteFade()) - { - sub_81248F4(sub_8124D64); - } - break; + case 0: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); + sFlyMap->state++; + break; + case 1: + if (!UpdatePaletteFade()) + { + SetFlyMapCallback(CB_HandleFlyMapInput); + } + break; } } -static void sub_8124D64(void) +static void CB_HandleFlyMapInput(void) { - if (sFlyMap->unk_004 == 0) + if (sFlyMap->state == 0) { - switch (sub_81230AC()) + switch (DoRegionMapInputCallback()) { - case INPUT_EVENT_NONE: - case INPUT_EVENT_MOVE_START: - case INPUT_EVENT_MOVE_CONT: - break; - case INPUT_EVENT_MOVE_END: - sub_8124904(); - break; - case INPUT_EVENT_A_BUTTON: - if (sFlyMap->regionMap.iconDrawType == MAPSECTYPE_CITY_CANFLY || sFlyMap->regionMap.iconDrawType == MAPSECTYPE_BATTLE_FRONTIER) - { - m4aSongNumStart(SE_SELECT); - sFlyMap->choseFlyLocation = TRUE; - sub_81248F4(sub_8124E0C); - } - break; - case INPUT_EVENT_B_BUTTON: + case MAP_INPUT_NONE: + case MAP_INPUT_MOVE_START: + case MAP_INPUT_MOVE_CONT: + break; + case MAP_INPUT_MOVE_END: + DrawFlyDestTextWindow(); + break; + case MAP_INPUT_A_BUTTON: + if (sFlyMap->regionMap.mapSecType == MAPSECTYPE_CITY_CANFLY || sFlyMap->regionMap.mapSecType == MAPSECTYPE_BATTLE_FRONTIER) + { m4aSongNumStart(SE_SELECT); - sFlyMap->choseFlyLocation = FALSE; - sub_81248F4(sub_8124E0C); - break; + sFlyMap->choseFlyLocation = TRUE; + SetFlyMapCallback(CB_ExitFlyMap); + } + break; + case MAP_INPUT_B_BUTTON: + m4aSongNumStart(SE_SELECT); + sFlyMap->choseFlyLocation = FALSE; + SetFlyMapCallback(CB_ExitFlyMap); + break; } } } -static void sub_8124E0C(void) +static void CB_ExitFlyMap(void) { - switch (sFlyMap->unk_004) + switch (sFlyMap->state) { - case 0: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sFlyMap->unk_004++; - break; - case 1: - if (!UpdatePaletteFade()) + case 0: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + sFlyMap->state++; + break; + case 1: + if (!UpdatePaletteFade()) + { + FreeRegionMapIconResources(); + if (sFlyMap->choseFlyLocation) { - FreeRegionMapIconResources(); - if (sFlyMap->choseFlyLocation) + switch (sFlyMap->regionMap.mapSecId) { - switch (sFlyMap->regionMap.mapSecId) - { - case MAPSEC_SOUTHERN_ISLAND: - SetWarpDestinationToHealLocation(HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR); - break; - case MAPSEC_BATTLE_FRONTIER: - SetWarpDestinationToHealLocation(HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST); - break; - case MAPSEC_LITTLEROOT_TOWN: - SetWarpDestinationToHealLocation(gSaveBlock2Ptr->playerGender == MALE ? HEAL_LOCATION_LITTLEROOT_TOWN_1 : HEAL_LOCATION_LITTLEROOT_TOWN_2); - break; - case MAPSEC_EVER_GRANDE_CITY: - SetWarpDestinationToHealLocation(FlagGet(FLAG_LANDMARK_POKEMON_LEAGUE) && sFlyMap->regionMap.posWithinMapSec == 0 ? HEAL_LOCATION_EVER_GRANDE_CITY_2 : HEAL_LOCATION_EVER_GRANDE_CITY_1); - break; - default: - if (sMapHealLocations[sFlyMap->regionMap.mapSecId][2] != 0) - { - SetWarpDestinationToHealLocation(sMapHealLocations[sFlyMap->regionMap.mapSecId][2]); - } - else - { - SetWarpDestinationToMapWarp(sMapHealLocations[sFlyMap->regionMap.mapSecId][0], sMapHealLocations[sFlyMap->regionMap.mapSecId][1], -1); - } - break; - } - ReturnToFieldFromFlyMapSelect(); + case MAPSEC_SOUTHERN_ISLAND: + SetWarpDestinationToHealLocation(HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR); + break; + case MAPSEC_BATTLE_FRONTIER: + SetWarpDestinationToHealLocation(HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST); + break; + case MAPSEC_LITTLEROOT_TOWN: + SetWarpDestinationToHealLocation(gSaveBlock2Ptr->playerGender == MALE ? HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE : HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE); + break; + case MAPSEC_EVER_GRANDE_CITY: + SetWarpDestinationToHealLocation(FlagGet(FLAG_LANDMARK_POKEMON_LEAGUE) && sFlyMap->regionMap.posWithinMapSec == 0 ? HEAL_LOCATION_EVER_GRANDE_CITY_POKEMON_LEAGUE : HEAL_LOCATION_EVER_GRANDE_CITY); + break; + default: + if (sMapHealLocations[sFlyMap->regionMap.mapSecId][2] != 0) + SetWarpDestinationToHealLocation(sMapHealLocations[sFlyMap->regionMap.mapSecId][2]); + else + SetWarpDestinationToMapWarp(sMapHealLocations[sFlyMap->regionMap.mapSecId][0], sMapHealLocations[sFlyMap->regionMap.mapSecId][1], -1); + break; } - else - { - SetMainCallback2(CB2_ReturnToPartyMenuFromFlyMap); - } - if (sFlyMap != NULL) - { - free(sFlyMap); - sFlyMap = NULL; - } - FreeAllWindowBuffers(); + ReturnToFieldFromFlyMapSelect(); } - break; + else + { + SetMainCallback2(CB2_ReturnToPartyMenuFromFlyMap); + } + if (sFlyMap != NULL) + { + free(sFlyMap); + sFlyMap = NULL; + } + FreeAllWindowBuffers(); + } + break; } } diff --git a/src/unk_pokedex_area_screen_helper.c b/src/unk_pokedex_area_screen_helper.c deleted file mode 100644 index 9b2401cb2..000000000 --- a/src/unk_pokedex_area_screen_helper.c +++ /dev/null @@ -1,68 +0,0 @@ -#include "global.h" -#include "main.h" -#include "menu.h" -#include "bg.h" -#include "malloc.h" -#include "palette.h" -#include "unk_pokedex_area_screen_helper.h" - -EWRAM_DATA u8 *gUnknown_0203CF28 = NULL; - -static const u16 gUnknown_0861D140[] = INCBIN_U16("graphics/interface/region_map.gbapal"); -static const u32 gUnknown_0861D1A0[] = INCBIN_U32("graphics/interface/region_map.8bpp.lz"); -static const u32 gUnknown_0861DEF4[] = INCBIN_U32("graphics/interface/region_map.bin.lz"); -static const u32 gUnknown_0861E208[] = INCBIN_U32("graphics/interface/region_map_affine.8bpp.lz"); -static const u32 gUnknown_0861EF64[] = INCBIN_U32("graphics/interface/region_map_affine.bin.lz"); - -void sub_81C4D70(const struct UnkStruct_1C4D70 *template) -{ - u8 unk; - gUnknown_0203CF28 = Alloc(4); - unk = template->unk10; - - if (unk == 0) - { - SetBgAttribute(template->bg, BG_ATTR_METRIC, 0); - decompress_and_copy_tile_data_to_vram(template->bg, gUnknown_0861D1A0, 0, template->unk2, unk); - sub_8199D3C(decompress_and_copy_tile_data_to_vram(template->bg, gUnknown_0861DEF4, 0, 0, 1), template->unk2, 32, 32, unk); - } - else - { - SetBgAttribute(template->bg, BG_ATTR_METRIC, 2); - SetBgAttribute(template->bg, BG_ATTR_TYPE, 1); - decompress_and_copy_tile_data_to_vram(template->bg, gUnknown_0861E208, 0, template->unk2, 0); - sub_8199D3C(decompress_and_copy_tile_data_to_vram(template->bg, gUnknown_0861EF64, 0, 0, 1), template->unk2, 64, 64, 1); - } - - ChangeBgX(template->bg, 0, 0); - ChangeBgY(template->bg, 0, 0); - SetBgAttribute(template->bg, BG_ATTR_PALETTEMODE, 1); - CpuCopy32(gUnknown_0861D140, &gPlttBufferUnfaded[0x70], 0x60); - *gUnknown_0203CF28 = template->bg; -} - -bool32 sub_81C4E90(void) -{ - if (!free_temp_tile_data_buffers_if_possible()) - { - ShowBg(*gUnknown_0203CF28); - return FALSE; - } - else - { - return TRUE; - } -} - -void sub_81C4EB4(void) -{ - if (gUnknown_0203CF28 != NULL) - { - FREE_AND_SET_NULL(gUnknown_0203CF28); - } -} - -void sub_81C4ED0(u32 a0) -{ - ChangeBgY(*gUnknown_0203CF28, a0 * 0x100, 0); -} diff --git a/sym_ewram.txt b/sym_ewram.txt index 79e89fc9b..1490a598a 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -137,7 +137,7 @@ .include "src/party_menu.o" .include "src/mirage_tower.o" .include "src/pokemon_summary_screen.o" - .include "src/unk_pokedex_area_screen_helper.o" + .include "src/pokedex_area_region_map.o" .include "src/battle_pyramid_bag.o" .include "src/pokenav.o" .include "src/pokenav_match_call_ui.o"